lib_um_crypto_rust/um_wasm_loader/src/loader.mjs

24 lines
665 B
JavaScript
Raw Normal View History

import umWasm from '../pkg/um_wasm_bg.wasm';
import { __wbg_init, initSync } from '../pkg/um_wasm.js';
export * from '../pkg/um_wasm.js';
function loader() {
if (process.env.UMC_INLINE_BUILD === '1') {
initSync({ module: umWasm() });
return Promise.resolve(true);
} else {
/** @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);
}
}
export const ready = loader();