wasm-idle 0.0.8 → 0.0.10
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/encode.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare function readStr(u8: Uint8Array, o: number, len?: number): string;
|
|
2
|
+
export declare function readStrR(u8: Uint8Array, o: number, len?: number): string;
|
|
2
3
|
export declare function readOct(u8: Uint8Array, o: number, len: number): number;
|
|
3
4
|
export declare function readUint8(u8: Uint8Array, o: number, len: number): Uint8Array;
|
package/dist/clang/encode.js
CHANGED
|
@@ -5,6 +5,13 @@ export function readStr(u8, o, len = -1) {
|
|
|
5
5
|
str += String.fromCharCode(u8[i]);
|
|
6
6
|
return str;
|
|
7
7
|
}
|
|
8
|
+
export function readStrR(u8, o, len = -1) {
|
|
9
|
+
const end = len === -1 ? u8.length : o + len;
|
|
10
|
+
let str = [];
|
|
11
|
+
for (let i = o; i < end && u8[i]; ++i)
|
|
12
|
+
str.push(u8[i]);
|
|
13
|
+
return new TextDecoder().decode(Uint8Array.from(str));
|
|
14
|
+
}
|
|
8
15
|
export function readOct(u8, o, len) {
|
|
9
16
|
return parseInt(readStr(u8, o, len), 8);
|
|
10
17
|
}
|
package/dist/clang/index.js
CHANGED
|
@@ -13,6 +13,23 @@ const clangCommonArgs = [
|
|
|
13
13
|
'-fmessage-length', '80',
|
|
14
14
|
'-fcolor-diagnostics',
|
|
15
15
|
];
|
|
16
|
+
const toUtf8 = (text) => {
|
|
17
|
+
const surrogate = encodeURIComponent(text);
|
|
18
|
+
let result = '';
|
|
19
|
+
for (let i = 0; i < surrogate.length;) {
|
|
20
|
+
const character = surrogate[i];
|
|
21
|
+
i += 1;
|
|
22
|
+
if (character == '%') {
|
|
23
|
+
const hex = surrogate.substring(i, i += 2);
|
|
24
|
+
if (hex)
|
|
25
|
+
result += String.fromCharCode(parseInt(hex, 16));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
result += character;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
16
33
|
export default class Clang {
|
|
17
34
|
ready;
|
|
18
35
|
memfs;
|
|
@@ -64,13 +81,13 @@ export default class Clang {
|
|
|
64
81
|
}
|
|
65
82
|
async compile(options) {
|
|
66
83
|
const input = options.input;
|
|
67
|
-
const code = options.code;
|
|
84
|
+
const code = toUtf8(options.code);
|
|
68
85
|
const obj = options.obj;
|
|
69
86
|
const opt = options.opt || '2';
|
|
70
87
|
await this.ready;
|
|
71
88
|
this.memfs.addFile(input, code);
|
|
72
89
|
const clang = await this.getModule(clangUrl(this.path));
|
|
73
|
-
return await this.run(clang, this.log, 'clang', '-cc1', '-emit-obj', ...clangCommonArgs, '-O' + opt, '-o', obj, '-x', 'c++', input);
|
|
90
|
+
return await this.run(clang, this.log, 'clang', '-cc1', '-emit-obj', ...clangCommonArgs, '-O' + opt, '-o', obj, '-std=c++17', '-x', 'c++', input);
|
|
74
91
|
}
|
|
75
92
|
async link(obj, wasm) {
|
|
76
93
|
const stackSize = 1024 * 1024;
|
|
@@ -79,7 +96,7 @@ export default class Clang {
|
|
|
79
96
|
await this.ready;
|
|
80
97
|
const lld = await this.getModule(lldUrl(this.path));
|
|
81
98
|
return await this.run(lld, this.log, 'wasm-ld', '--no-threads', '--export-dynamic', // TODO required?
|
|
82
|
-
'-z', `stack-size=${stackSize}`, `-L${libdir}`, crt1, obj, '-lc', '-lc++', '-lc++abi', '-
|
|
99
|
+
'-z', `stack-size=${stackSize}`, `-L${libdir}`, crt1, obj, '-lc', '-lc++', '-lc++abi', '-o', wasm);
|
|
83
100
|
}
|
|
84
101
|
async run(module, out, ...args) {
|
|
85
102
|
this.memfs.out = out;
|
|
@@ -8,6 +8,7 @@ export default class Memory {
|
|
|
8
8
|
read8(o: number): number;
|
|
9
9
|
read32(o: number): number;
|
|
10
10
|
readStr(o: number, len: number): string;
|
|
11
|
+
readStrR(o: number, len: number): string;
|
|
11
12
|
write8(o: number, v: number): void;
|
|
12
13
|
write32(o: number, v: number): void;
|
|
13
14
|
write64(o: number, vlo: number, vhi?: number): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readStr } from "../encode";
|
|
1
|
+
import { readStr, readStrR } from "../encode";
|
|
2
2
|
export default class Memory {
|
|
3
3
|
memory;
|
|
4
4
|
buffer;
|
|
@@ -26,6 +26,9 @@ export default class Memory {
|
|
|
26
26
|
readStr(o, len) {
|
|
27
27
|
return readStr(this.u8, o, len);
|
|
28
28
|
}
|
|
29
|
+
readStrR(o, len) {
|
|
30
|
+
return readStrR(this.u8, o, len);
|
|
31
|
+
}
|
|
29
32
|
write8(o, v) {
|
|
30
33
|
this.u8[o] = v;
|
|
31
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wasm-idle",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "A simple web app to run C++/Python code in the browser",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,26 +17,26 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@sveltejs/adapter-auto": "^2.1.0",
|
|
20
|
-
"@sveltejs/adapter-static": "^2.0.
|
|
21
|
-
"@sveltejs/kit": "^1.22.
|
|
22
|
-
"@sveltejs/package": "^2.
|
|
23
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
24
|
-
"@typescript-eslint/parser": "^
|
|
25
|
-
"eslint": "^8.
|
|
26
|
-
"eslint-config-prettier": "^8.
|
|
20
|
+
"@sveltejs/adapter-static": "^2.0.3",
|
|
21
|
+
"@sveltejs/kit": "^1.22.3",
|
|
22
|
+
"@sveltejs/package": "^2.2.0",
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^6.2.0",
|
|
24
|
+
"@typescript-eslint/parser": "^6.2.0",
|
|
25
|
+
"eslint": "^8.46.0",
|
|
26
|
+
"eslint-config-prettier": "^8.9.0",
|
|
27
27
|
"eslint-plugin-svelte3": "^4.0.0",
|
|
28
28
|
"gh-pages": "^5.0.0",
|
|
29
29
|
"monaco-editor": "^0.40.0",
|
|
30
30
|
"prettier": "^3.0.0",
|
|
31
|
-
"prettier-plugin-svelte": "^
|
|
32
|
-
"svelte": "^4.
|
|
33
|
-
"svelte-check": "^3.4.
|
|
34
|
-
"tslib": "^2.6.
|
|
31
|
+
"prettier-plugin-svelte": "^3.0.3",
|
|
32
|
+
"svelte": "^4.1.1",
|
|
33
|
+
"svelte-check": "^3.4.6",
|
|
34
|
+
"tslib": "^2.6.1",
|
|
35
35
|
"typescript": "^5.1.6",
|
|
36
|
-
"vite": "^4.4.
|
|
36
|
+
"vite": "^4.4.7"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"pyodide": "
|
|
39
|
+
"pyodide": "0.23.1",
|
|
40
40
|
"xterm": "^5.2.1",
|
|
41
41
|
"xterm-addon-canvas": "^0.4.0",
|
|
42
42
|
"xterm-addon-fit": "^0.7.0",
|