wasm-idle 0.0.15 → 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.
@@ -51,6 +51,8 @@ export default class Clang {
51
51
  stdin: options.stdin,
52
52
  path: this.path
53
53
  });
54
+ this.getModule(clangUrl(this.path));
55
+ this.getModule(lldUrl(this.path));
54
56
  this.ready = this.memfs.ready.then(() => this.hostLogAsync(`Untarring ${rootUrl(this.path)}`, readBuffer(rootUrl(this.path)).then(buffer => untar(buffer, this.memfs))));
55
57
  }
56
58
  hostLog(message) {
package/dist/clang/url.js CHANGED
@@ -1,4 +1,4 @@
1
- export const memfsUrl = (prefix) => prefix + '/clang/bin/memfs';
2
- export const clangUrl = (prefix) => prefix + '/clang/bin/clang';
3
- export const lldUrl = (prefix) => prefix + '/clang/bin/lld';
4
- export const rootUrl = (prefix) => prefix + '/clang/bin/sysroot.tar';
1
+ export const memfsUrl = (prefix) => prefix + '/clang/bin/memfs.zip';
2
+ export const clangUrl = (prefix) => prefix + '/clang/bin/clang.zip';
3
+ export const lldUrl = (prefix) => prefix + '/clang/bin/lld.zip';
4
+ export const rootUrl = (prefix) => prefix + '/clang/bin/sysroot.tar.zip';
@@ -1,3 +1,3 @@
1
- export declare function compile(filename: string): Promise<WebAssembly.Module>;
1
+ export declare const readBuffer: (name: string) => Promise<Uint8Array | undefined>;
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,16 +1,22 @@
1
- const url = (url) => url;
1
+ import * as zip from "@zip.js/zip.js";
2
+ const store = {};
3
+ export const readBuffer = async (name) => {
4
+ const response = await fetch(name);
5
+ const blob = await response.blob();
6
+ const reader = new zip.ZipReader(new zip.BlobReader(blob));
7
+ const entries = await reader.getEntries();
8
+ for (const entry of entries) {
9
+ const data = await entry.getData(new zip.Uint8ArrayWriter());
10
+ return data;
11
+ }
12
+ };
2
13
  export async function compile(filename) {
3
14
  // TODO: make compileStreaming work. It needs the server to use the
4
15
  // application/wasm mimetype.
5
- if (false && WebAssembly.compileStreaming) {
6
- return WebAssembly.compileStreaming(fetch(url(filename)));
7
- }
8
- else {
9
- const response = await fetch(url(filename));
10
- return WebAssembly.compile(await response.arrayBuffer());
11
- }
16
+ if (store[filename])
17
+ return store[filename];
18
+ return store[filename] = WebAssembly.compile(await readBuffer(filename));
12
19
  }
13
20
  export function getInstance(module, imports) {
14
21
  return WebAssembly.instantiate(module, imports);
15
22
  }
16
- 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.15",
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",
@@ -36,6 +36,7 @@
36
36
  "vite": "^4.5.0"
37
37
  },
38
38
  "dependencies": {
39
+ "@zip.js/zip.js": "^2.7.30",
39
40
  "pyodide": "0.23.1",
40
41
  "xterm": "^5.3.0",
41
42
  "xterm-addon-canvas": "^0.5.0",