From 63ea95447e543f9bad0f50b03d061dcdb5184449 Mon Sep 17 00:00:00 2001 From: John Owens Date: Tue, 5 Nov 2024 09:43:04 -0800 Subject: [PATCH] renamed --- both_basic/both.html | 14 ++++++++++++++ both_basic/both.mjs | 4 ++++ both_basic/both_chrome.mjs | 9 +++++++++ both_basic/both_node.mjs | 9 +++++++++ 4 files changed, 36 insertions(+) create mode 100644 both_basic/both.html create mode 100644 both_basic/both.mjs create mode 100644 both_basic/both_chrome.mjs create mode 100644 both_basic/both_node.mjs diff --git a/both_basic/both.html b/both_basic/both.html new file mode 100644 index 0000000..eac896f --- /dev/null +++ b/both_basic/both.html @@ -0,0 +1,14 @@ + + + + + + Supporting Both Chrome And Node Sandbox + + + +
+ + + + diff --git a/both_basic/both.mjs b/both_basic/both.mjs new file mode 100644 index 0000000..49f835b --- /dev/null +++ b/both_basic/both.mjs @@ -0,0 +1,4 @@ +async function main() { + console.log("I am main!"); +} +export { main }; diff --git a/both_basic/both_chrome.mjs b/both_basic/both_chrome.mjs new file mode 100644 index 0000000..9af059a --- /dev/null +++ b/both_basic/both_chrome.mjs @@ -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(); diff --git a/both_basic/both_node.mjs b/both_basic/both_node.mjs new file mode 100644 index 0000000..a935566 --- /dev/null +++ b/both_basic/both_node.mjs @@ -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();