@danielsimonjr/mathts-functions 0.11.3 → 0.12.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/dist/{chunk-XDJV7IDD.js → chunk-LNJTPHSC.js} +20 -3
- package/dist/index.js +29251 -29118
- package/dist/typed/algebra.d.ts +11 -3
- package/dist/typed/algebra.d.ts.map +1 -1
- package/dist/typed/cas.d.ts.map +1 -1
- package/dist/typed/polynomial-ideal.d.ts +32 -0
- package/dist/typed/polynomial-ideal.d.ts.map +1 -0
- package/dist/wasm/WasmLoader.d.ts.map +1 -1
- package/dist/wasm/resolve.d.ts +17 -0
- package/dist/wasm/resolve.d.ts.map +1 -1
- package/dist/{wasm-bridge-NI5PIJZC.js → wasm-bridge-DXABVEBV.js} +1 -1
- package/package.json +5 -5
|
@@ -95,6 +95,24 @@ async function resolvePackagedWasm(metaUrl, wasmFile) {
|
|
|
95
95
|
}
|
|
96
96
|
return null;
|
|
97
97
|
}
|
|
98
|
+
async function defaultWasmLocation(metaUrl, wasmFile, opts) {
|
|
99
|
+
if (opts?.browser) {
|
|
100
|
+
return new URL(`./wasm/${wasmFile}`, metaUrl).href;
|
|
101
|
+
}
|
|
102
|
+
const { fileURLToPath } = await import("url");
|
|
103
|
+
const { dirname, join } = await import("path");
|
|
104
|
+
const { existsSync } = await import("fs");
|
|
105
|
+
let dir = dirname(fileURLToPath(metaUrl));
|
|
106
|
+
for (let depth = 0; depth < 8; depth++) {
|
|
107
|
+
if (existsSync(join(dir, "package.json"))) {
|
|
108
|
+
return join(dir, "dist", "wasm", wasmFile);
|
|
109
|
+
}
|
|
110
|
+
const parent = dirname(dir);
|
|
111
|
+
if (parent === dir) break;
|
|
112
|
+
dir = parent;
|
|
113
|
+
}
|
|
114
|
+
return join(dirname(fileURLToPath(metaUrl)), "wasm", wasmFile);
|
|
115
|
+
}
|
|
98
116
|
|
|
99
117
|
// src/wasm/WasmLoader.ts
|
|
100
118
|
var WasmLoader = class _WasmLoader {
|
|
@@ -202,10 +220,9 @@ var WasmLoader = class _WasmLoader {
|
|
|
202
220
|
if (this.isNode) {
|
|
203
221
|
const packaged = await resolvePackagedWasm(import.meta.url, wasmFile);
|
|
204
222
|
if (packaged) return packaged;
|
|
205
|
-
|
|
206
|
-
return fileURLToPath(new URL(`../../../lib/wasm/${wasmFile}`, import.meta.url));
|
|
223
|
+
return defaultWasmLocation(import.meta.url, wasmFile);
|
|
207
224
|
}
|
|
208
|
-
return
|
|
225
|
+
return defaultWasmLocation(import.meta.url, wasmFile, { browser: true });
|
|
209
226
|
}
|
|
210
227
|
async loadNodeWasm(path, totalStart) {
|
|
211
228
|
const fs = await import("fs");
|