2024-09-02 23:17:54 +00:00
|
|
|
import umWasm from '../pkg/um_wasm_bg.wasm';
|
2024-09-20 20:14:24 +00:00
|
|
|
import { __wbg_init, initPanicHook, 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-20 20:14:24 +00:00
|
|
|
initPanicHook();
|
2024-09-14 18:55:53 +00:00
|
|
|
return Promise.resolve(true);
|
2024-09-02 23:17:54 +00:00
|
|
|
} else {
|
2024-09-14 19:09:38 +00:00
|
|
|
const url = new URL('um_wasm_bg.wasm', import.meta.url);
|
|
|
|
const wasm =
|
|
|
|
url.protocol === 'file:'
|
2024-09-15 14:41:43 +00:00
|
|
|
? import(/* @vite-ignore */ 'node:f' + 's/promises')
|
2024-09-14 19:09:38 +00:00
|
|
|
.then((fs) => fs.readFile(url))
|
|
|
|
.catch((err) => {
|
|
|
|
console.log('read wasm failed', err);
|
|
|
|
})
|
|
|
|
: undefined;
|
2024-09-20 20:14:24 +00:00
|
|
|
return __wbg_init({ module_or_path: wasm }).then(() => (initPanicHook(), true));
|
2024-09-02 23:17:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-18 23:00:30 +00:00
|
|
|
export function getUmcVersion() {
|
|
|
|
return process.env.UMC_VERSION;
|
|
|
|
}
|
|
|
|
|
2024-09-02 23:17:54 +00:00
|
|
|
export const ready = loader();
|