wasm-idle 0.0.16 → 0.0.17

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/dist/clang/url.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export const memfsUrl = (prefix) => prefix + '/clang/bin/memfs.zip';
2
2
  export const clangUrl = (prefix) => prefix + '/clang/bin/clang.zip';
3
3
  export const lldUrl = (prefix) => prefix + '/clang/bin/lld.zip';
4
- export const rootUrl = (prefix) => prefix + '/clang/bin/sysroot.tar';
4
+ export const rootUrl = (prefix) => prefix + '/clang/bin/sysroot.tar.zip';
@@ -1,3 +1,3 @@
1
+ export declare const readBuffer: (name: string) => Promise<Uint8Array | undefined>;
1
2
  export declare function compile(filename: string): Promise<any>;
2
3
  export declare function getInstance(module: WebAssembly.Module, imports: WebAssembly.Imports): Promise<WebAssembly.Instance>;
3
- export declare const readBuffer: (name: string) => Promise<ArrayBuffer>;
@@ -1,22 +1,22 @@
1
1
  import * as zip from "@zip.js/zip.js";
2
- const url = (url) => url;
3
2
  const store = {};
4
- export async function compile(filename) {
5
- // TODO: make compileStreaming work. It needs the server to use the
6
- // application/wasm mimetype.
7
- if (store[filename])
8
- return store[filename];
9
- const response = await fetch(url(filename));
3
+ export const readBuffer = async (name) => {
4
+ const response = await fetch(name);
10
5
  const blob = await response.blob();
11
6
  const reader = new zip.ZipReader(new zip.BlobReader(blob));
12
7
  const entries = await reader.getEntries();
13
8
  for (const entry of entries) {
14
- console.log(`Found WASM file: ${entry.filename}`);
15
9
  const data = await entry.getData(new zip.Uint8ArrayWriter());
16
- return store[filename] = WebAssembly.compile(data);
10
+ return data;
17
11
  }
12
+ };
13
+ export async function compile(filename) {
14
+ // TODO: make compileStreaming work. It needs the server to use the
15
+ // application/wasm mimetype.
16
+ if (store[filename])
17
+ return store[filename];
18
+ return store[filename] = WebAssembly.compile(await readBuffer(filename));
18
19
  }
19
20
  export function getInstance(module, imports) {
20
21
  return WebAssembly.instantiate(module, imports);
21
22
  }
22
- export const readBuffer = (name) => fetch(url(name)).then(r => r.arrayBuffer());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wasm-idle",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "A simple web app to run C++/Python code in the browser",
5
5
  "license": "MIT",
6
6
  "type": "module",