brep-io-kernel 1.0.13 → 1.0.15
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-kernel/brep-kernel.js +3801 -3776
- package/package.json +1 -1
- package/src/BREP/setupManifold.js +32 -2
package/package.json
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// setupManifold.js (ESM)
|
|
2
2
|
// Universal loader that works in both Node.js and the browser (Vite)
|
|
3
3
|
|
|
4
|
-
import Module from 'manifold-3d';
|
|
5
|
-
|
|
6
4
|
const INLINE_WASM_BASE64 =
|
|
7
5
|
typeof __MANIFOLD_WASM_BASE64__ !== 'undefined' && __MANIFOLD_WASM_BASE64__;
|
|
8
6
|
|
|
@@ -10,6 +8,37 @@ const isNode =
|
|
|
10
8
|
typeof window === 'undefined' ||
|
|
11
9
|
(typeof process !== 'undefined' && process.versions?.node);
|
|
12
10
|
|
|
11
|
+
const patchFileURLToPathForDataUrl = async () => {
|
|
12
|
+
if (!isNode) return;
|
|
13
|
+
try {
|
|
14
|
+
const { createRequire } = await import('node:module');
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
const urlMod = require('node:url');
|
|
17
|
+
if (urlMod.__brepFileUrlPatched) return;
|
|
18
|
+
const original = urlMod.fileURLToPath;
|
|
19
|
+
urlMod.fileURLToPath = (value) => {
|
|
20
|
+
try {
|
|
21
|
+
return original(value);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
const href = typeof value === 'string' ? value : value?.href;
|
|
24
|
+
if (href && (href.startsWith('data:') || href.startsWith('blob:'))) {
|
|
25
|
+
return process.cwd();
|
|
26
|
+
}
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
urlMod.__brepFileUrlPatched = true;
|
|
31
|
+
} catch {
|
|
32
|
+
// ignore; Node-only patch
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const loadModule = async () => {
|
|
37
|
+
if (isNode) await patchFileURLToPathForDataUrl();
|
|
38
|
+
const mod = await import('manifold-3d');
|
|
39
|
+
return mod?.default ?? mod;
|
|
40
|
+
};
|
|
41
|
+
|
|
13
42
|
const decodeBase64ToUint8Array = (base64) => {
|
|
14
43
|
if (!base64) return null;
|
|
15
44
|
const normalized = base64.includes('base64,')
|
|
@@ -31,6 +60,7 @@ const decodeBase64ToUint8Array = (base64) => {
|
|
|
31
60
|
};
|
|
32
61
|
|
|
33
62
|
const initWasm = async (opts) => {
|
|
63
|
+
const Module = await loadModule();
|
|
34
64
|
const wasm = await Module(opts);
|
|
35
65
|
if (typeof wasm.setup === 'function') await wasm.setup();
|
|
36
66
|
return wasm;
|