oxide-wasm 0.1.0 → 0.1.1
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/index.mjs +6 -6
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -15,20 +15,20 @@ export async function init(module_or_path) {
|
|
|
15
15
|
const importUrl = import.meta.url;
|
|
16
16
|
if (!module_or_path && importUrl.startsWith("file://")) {
|
|
17
17
|
const { pathname: filename } = new URL("./pkg/oxide_wasm_bg.wasm", importUrl);
|
|
18
|
-
let
|
|
18
|
+
let wasmData;
|
|
19
19
|
if (globalThis.Deno) {
|
|
20
|
-
|
|
20
|
+
wasmData = await Deno.readFile(filename);
|
|
21
21
|
} else if (globalThis.Bun) {
|
|
22
|
-
|
|
22
|
+
wasmData = await Bun.file(filename).arrayBuffer();
|
|
23
23
|
} else {
|
|
24
24
|
const moduleSpecifier = `node:fs/promises`;
|
|
25
25
|
const fsPromise = await import(moduleSpecifier); // <- use variable to skip deno-lsp analyzing
|
|
26
|
-
|
|
26
|
+
wasmData = await fsPromise.readFile(filename);
|
|
27
27
|
}
|
|
28
|
-
initWasmSync({ module:
|
|
28
|
+
initWasmSync({ module: wasmData });
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
const esmshBaseUrl = "https://esm.sh
|
|
31
|
+
const esmshBaseUrl = "https://esm.sh/oxide-wasm@";
|
|
32
32
|
if (!module_or_path && importUrl.startsWith(esmshBaseUrl)) {
|
|
33
33
|
const version = importUrl.slice(esmshBaseUrl.length).split("/", 1)[0];
|
|
34
34
|
module_or_path = esmshBaseUrl + version + "/pkg/oxide_wasm_bg.wasm";
|