@pi-oxide/pi-host-web 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Irving Ou <irving@pi-oxide.dev>"
6
6
  ],
7
7
  "description": "WASM host for pi-core. Browser FileSystem Access API, fetch(), JS event loop.",
8
- "version": "0.2.1",
8
+ "version": "0.3.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
Binary file
package/sdk/index.js CHANGED
@@ -35,14 +35,14 @@ let initialized = false;
35
35
  /** Ensure the WASM module is loaded. Safe to call multiple times. */
36
36
  export async function ensureInit() {
37
37
  if (initialized) return;
38
- if (typeof window !== "undefined") {
39
- await init();
40
- } else {
38
+ if (typeof process !== "undefined" && process.versions?.node) {
41
39
  const { readFileSync } = await import("node:fs");
42
40
  const bytes = readFileSync(
43
41
  new URL("../pi_host_web_bg.wasm", import.meta.url)
44
42
  );
45
43
  initSync({ module: bytes });
44
+ } else {
45
+ await init();
46
46
  }
47
47
  initialized = true;
48
48
  }