2024-09-02 23:17:54 +00:00
|
|
|
import umWasm from '../pkg/um_wasm_bg.wasm';
|
|
|
|
import { __wbg_init, initSync } from '../pkg/um_wasm.js';
|
2024-09-14 18:55:53 +00:00
|
|
|
|
2024-09-02 23:17:54 +00:00
|
|
|
export * from '../pkg/um_wasm.js';
|
|
|
|
|
|
|
|
function loader() {
|
|
|
|
if (process.env.UMC_INLINE_BUILD === '1') {
|
|
|
|
initSync({ module: umWasm() });
|
2024-09-14 18:55:53 +00:00
|
|
|
return Promise.resolve(true);
|
2024-09-02 23:17:54 +00:00
|
|
|
} else {
|
2024-09-14 18:55:53 +00:00
|
|
|
/** @type {Promise<Buffer>|undefined} */
|
|
|
|
let wasm = undefined;
|
|
|
|
if (typeof document === 'undefined') {
|
|
|
|
// node
|
|
|
|
wasm = import('node:f' + 's/promises').then((fs) =>
|
|
|
|
fs.readFile(new URL('../pkg/um_wasm_bg.wasm', import.meta.url)),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return __wbg_init({ module_or_path: wasm }).then(() => true);
|
2024-09-02 23:17:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ready = loader();
|