@descix/egpt-math-sdk 0.1.0 → 0.1.1

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/dist/index.js CHANGED
@@ -38,15 +38,25 @@ async function loadEgptMathWasm({ wasmUrl, wasmModuleUrl } = {}) {
38
38
  try {
39
39
  const mod = await import(wasmModuleUrl);
40
40
  let initArg = wasmUrl;
41
+ let initArgIsBytes = false;
41
42
  if (typeof process !== "undefined" && wasmUrl && wasmUrl.startsWith("file://")) {
42
43
  const fs = await import("node:fs/promises");
43
44
  const { fileURLToPath } = await import("node:url");
44
45
  initArg = await fs.readFile(fileURLToPath(wasmUrl));
46
+ initArgIsBytes = true;
47
+ } else if (wasmUrl) {
48
+ const response = await fetch(String(wasmUrl));
49
+ if (!response.ok) {
50
+ throw new Error(`wasm binary fetch failed: ${response.status} ${response.statusText} (${wasmUrl})`);
51
+ }
52
+ initArg = await response.arrayBuffer();
53
+ initArgIsBytes = true;
45
54
  }
55
+ const initPayload = initArgIsBytes ? { module_or_path: initArg } : initArg;
46
56
  if (typeof mod.default === "function" && wasmUrl) {
47
- await mod.default(initArg);
57
+ await mod.default(initPayload);
48
58
  } else if (typeof mod.init === "function" && wasmUrl) {
49
- await mod.init(initArg);
59
+ await mod.init(initPayload);
50
60
  }
51
61
  return {
52
62
  mode: "wasm-bridge",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descix/egpt-math-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "WASM-focused EGPT Math SDK package skeleton for browser integration.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -40,7 +40,7 @@
40
40
  "license": "SEE LICENSE IN LICENSE",
41
41
  "repository": {
42
42
  "type": "git",
43
- "url": "git+https://github.com/eabadir/frqtl.git",
43
+ "url": "git+https://github.com/eabadir/fraqtl.git",
44
44
  "directory": "sdk/egpt-math-sdk"
45
45
  },
46
46
  "sideEffects": false,