-
-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathindex.js
More file actions
18 lines (17 loc) · 638 Bytes
/
index.js
File metadata and controls
18 lines (17 loc) · 638 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// @ts-check
import { instantiate } from './instantiate.js';
import { defaultBrowserSetup /* #if USE_SHARED_MEMORY */, createDefaultWorkerFactory /* #endif */} from './platforms/browser.js';
/** @type {import('./index.d').init} */
export async function init(options = {}) {
let module = options.module;
if (!module) {
module = fetch(new URL("@PACKAGE_TO_JS_MODULE_PATH@", import.meta.url))
}
const instantiateOptions = await defaultBrowserSetup({
module,
/* #if USE_SHARED_MEMORY */
spawnWorker: createDefaultWorkerFactory()
/* #endif */
})
return await instantiate(instantiateOptions);
}