wasm-idle 0.0.14 → 0.0.16
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/index.js +3 -1
- package/dist/clang/url.js +3 -3
- package/dist/clang/wasm.d.ts +1 -1
- package/dist/clang/wasm.js +12 -6
- package/package.json +3 -2
package/dist/clang/index.js
CHANGED
|
@@ -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) {
|
|
@@ -96,7 +98,7 @@ export default class Clang {
|
|
|
96
98
|
await this.ready;
|
|
97
99
|
const lld = await this.getModule(lldUrl(this.path));
|
|
98
100
|
return await this.run(lld, this.log, 'wasm-ld', '--no-threads', '--export-dynamic', // TODO required?
|
|
99
|
-
'-z', `stack-size=${stackSize}`, `-L${libdir}`, crt1, obj, '-lc', '-lc++', '-lc++abi', '-o', wasm);
|
|
101
|
+
'-z', `stack-size=${stackSize}`, `-L${libdir}`, crt1, obj, '-lc', '-lc++', '-lc++abi', '-lm', `-Llib/clang/8.0.1/lib/wasi`, '-lclang_rt.builtins-wasm32', '-o', wasm);
|
|
100
102
|
}
|
|
101
103
|
async run(module, out, ...args) {
|
|
102
104
|
this.memfs.out = out;
|
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';
|
|
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
4
|
export const rootUrl = (prefix) => prefix + '/clang/bin/sysroot.tar';
|
package/dist/clang/wasm.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function compile(filename: string): Promise<
|
|
1
|
+
export declare function compile(filename: string): Promise<any>;
|
|
2
2
|
export declare function getInstance(module: WebAssembly.Module, imports: WebAssembly.Imports): Promise<WebAssembly.Instance>;
|
|
3
3
|
export declare const readBuffer: (name: string) => Promise<ArrayBuffer>;
|
package/dist/clang/wasm.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import * as zip from "@zip.js/zip.js";
|
|
1
2
|
const url = (url) => url;
|
|
3
|
+
const store = {};
|
|
2
4
|
export async function compile(filename) {
|
|
3
5
|
// TODO: make compileStreaming work. It needs the server to use the
|
|
4
6
|
// application/wasm mimetype.
|
|
5
|
-
if (
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
if (store[filename])
|
|
8
|
+
return store[filename];
|
|
9
|
+
const response = await fetch(url(filename));
|
|
10
|
+
const blob = await response.blob();
|
|
11
|
+
const reader = new zip.ZipReader(new zip.BlobReader(blob));
|
|
12
|
+
const entries = await reader.getEntries();
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
console.log(`Found WASM file: ${entry.filename}`);
|
|
15
|
+
const data = await entry.getData(new zip.Uint8ArrayWriter());
|
|
16
|
+
return store[filename] = WebAssembly.compile(data);
|
|
11
17
|
}
|
|
12
18
|
}
|
|
13
19
|
export function getInstance(module, imports) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wasm-idle",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "A simple web app to run C++/Python code in the browser",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"vite": "^4.5.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"
|
|
39
|
+
"@zip.js/zip.js": "^2.7.30",
|
|
40
|
+
"pyodide": "0.23.1",
|
|
40
41
|
"xterm": "^5.3.0",
|
|
41
42
|
"xterm-addon-canvas": "^0.5.0",
|
|
42
43
|
"xterm-addon-fit": "^0.8.0",
|