payid-rule-engine 0.2.3 → 0.2.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/wasm.ts +7 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payid-rule-engine",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
package/src/wasm.ts CHANGED
@@ -1,22 +1,12 @@
1
- export async function loadWasm(binary?: Buffer): Promise<WebAssembly.Instance> {
2
- let wasmBinary = binary;
1
+ export async function loadWasm(binary?: Buffer | Uint8Array): Promise<WebAssembly.Instance> {
2
+ let wasmBinary: Buffer | Uint8Array | undefined = binary;
3
3
 
4
4
  if (!wasmBinary || wasmBinary.length === 0) {
5
- if (typeof process !== "undefined" && process.versions?.node) {
6
- const { readFileSync } = await import("fs");
7
- const { join, dirname } = await import("path");
8
- const { fileURLToPath } = await import("url");
9
-
10
- const __dir = dirname(fileURLToPath(import.meta.url));
11
- wasmBinary = readFileSync(join(__dir, "wasm/rule_engine.wasm"));
12
-
13
- // Browser
14
- } else {
15
- const wasmUrl = new URL("../wasm/rule_engine.wasm", import.meta.url);
16
- const res = await fetch(wasmUrl);
17
- if (!res.ok) throw new Error(`Failed to load rule_engine.wasm: ${res.status}`);
18
- wasmBinary = Buffer.from(await res.arrayBuffer());
19
- }
5
+ const { readFileSync } = await import(/* webpackIgnore: true */ "fs");
6
+ const { join, dirname } = await import(/* webpackIgnore: true */ "path");
7
+ const { fileURLToPath } = await import(/* webpackIgnore: true */ "url");
8
+ const __dir = dirname(fileURLToPath(import.meta.url));
9
+ wasmBinary = readFileSync(join(__dir, "wasm/rule_engine.wasm"));
20
10
  }
21
11
 
22
12
  const module = await WebAssembly.compile(wasmBinary);