Skip to content

Commit

Permalink
renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
John Owens committed Nov 5, 2024
1 parent 4ecf4e7 commit 63ea954
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
14 changes: 14 additions & 0 deletions both_basic/both.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8" />
<title>Supporting Both Chrome And Node Sandbox</title>
</head>

<body>
<div id="plot"></div>
<script src="http://localhost:8000/webgpu-sandbox/both/both_chrome.mjs" type="module"></script>
</script>
</body>
</html>
4 changes: 4 additions & 0 deletions both_basic/both.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
async function main() {
console.log("I am main!");
}
export { main };
9 changes: 9 additions & 0 deletions both_basic/both_chrome.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { main } from "http://localhost:8000/webgpu-sandbox/both/both.mjs";
if (typeof process !== "undefined" && process.release.name === "node") {
// running in Node
alert("Use this only from a web browser.");
} else {
// running in browser
}

main();
9 changes: 9 additions & 0 deletions both_basic/both_node.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { main } from "./both.mjs";
if (typeof process !== "undefined" && process.release.name === "node") {
// running in Node
} else {
// running in browser
alert("Use this only in Node.");
}

main();

0 comments on commit 63ea954

Please sign in to comment.