wasm-idle 0.0.21 → 0.1.0
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 +1 -1
- package/dist/playground/sandbox.js +1 -1
- package/dist/playground/worker/python.js +21 -7
- package/dist/terminal/Terminal.svelte +12 -21
- package/dist/terminal/Terminal.svelte.d.ts +9 -7
- package/dist/terminal/plugin/index.d.ts +7 -7
- package/dist/terminal/plugin/index.js +6 -6
- package/package.json +47 -36
- package/static/image.jpeg +0 -0
package/dist/clang/index.js
CHANGED
|
@@ -102,7 +102,7 @@ export default class Clang {
|
|
|
102
102
|
await this.ready;
|
|
103
103
|
this.memfs.addFile(input, code);
|
|
104
104
|
const clang = await this.getModule(clangUrl(this.path));
|
|
105
|
-
return await this.run(clang,
|
|
105
|
+
return await this.run(clang, true, 'clang', '-cc1', '-emit-obj', ...clangCommonArgs, '-O' + opt, '-o', obj, '-std=c++17', '-x', 'c++', input);
|
|
106
106
|
}
|
|
107
107
|
async link(obj, wasm) {
|
|
108
108
|
const stackSize = 1024 * 1024;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default sandbox;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
self.document = {
|
|
2
|
+
querySelector() {
|
|
3
|
+
return null;
|
|
4
|
+
},
|
|
2
5
|
querySelectorAll() {
|
|
3
6
|
return [];
|
|
4
7
|
}
|
|
@@ -38,7 +41,18 @@ self.onmessage = async (event) => {
|
|
|
38
41
|
stdinBufferPyodide = new Int32Array(buffer);
|
|
39
42
|
interruptBufferPyodide = new Uint8Array(interrupt);
|
|
40
43
|
pyodide.setInterruptBuffer(interruptBufferPyodide);
|
|
41
|
-
|
|
44
|
+
const toPythonStr = (obj) => {
|
|
45
|
+
if (obj === true)
|
|
46
|
+
return 'True';
|
|
47
|
+
if (obj === false)
|
|
48
|
+
return 'False';
|
|
49
|
+
if (obj === null)
|
|
50
|
+
return 'None';
|
|
51
|
+
if (obj === undefined)
|
|
52
|
+
return 'None';
|
|
53
|
+
return obj.toString();
|
|
54
|
+
};
|
|
55
|
+
self.prompt = self['__pyodide__input_' + ts] = (output) => {
|
|
42
56
|
if (output)
|
|
43
57
|
postMessage({ output });
|
|
44
58
|
while (true) {
|
|
@@ -62,16 +76,16 @@ self.onmessage = async (event) => {
|
|
|
62
76
|
self['__pyodide__output_' + ts] = (...data) => {
|
|
63
77
|
let sep = ' ', end = '\r\n', output = '', clear = [];
|
|
64
78
|
for (const i of data) {
|
|
65
|
-
if (i
|
|
66
|
-
end = i.end
|
|
67
|
-
else if (i
|
|
68
|
-
sep = i.sep
|
|
79
|
+
if (i?.end !== undefined)
|
|
80
|
+
end = toPythonStr(i.end);
|
|
81
|
+
else if (i?.sep !== undefined)
|
|
82
|
+
sep = toPythonStr(i.sep);
|
|
69
83
|
else
|
|
70
84
|
clear.push(i);
|
|
71
85
|
}
|
|
72
86
|
for (let i = 0; i < clear.length; i++) {
|
|
73
|
-
if (typeof clear[i] === 'string' || (!clear[i]
|
|
74
|
-
output += clear[i]
|
|
87
|
+
if (typeof clear[i] === 'string' || (!clear[i]?.end && !clear[i]?.sep)) {
|
|
88
|
+
output += toPythonStr(clear[i]);
|
|
75
89
|
if (i < clear.length - 1)
|
|
76
90
|
output += sep;
|
|
77
91
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>import { Theme, registerAllPlugins } from "./";
|
|
2
2
|
import load from "../playground";
|
|
3
3
|
import { onMount, createEventDispatcher } from "svelte";
|
|
4
|
-
import "xterm/css/xterm.css";
|
|
4
|
+
import "@xterm/xterm/css/xterm.css";
|
|
5
5
|
const dispatch = createEventDispatcher();
|
|
6
6
|
export let dark = false, path = "", font = "'D2 coding', monospace";
|
|
7
7
|
let ref, clientWidth, clientHeight, term, finish = true, input = "", sandbox, first = true, tc = 0, plugin, ll = null;
|
|
@@ -18,8 +18,7 @@ function wait() {
|
|
|
18
18
|
async function initSandbox(language) {
|
|
19
19
|
let _tc = ++tc;
|
|
20
20
|
await wait();
|
|
21
|
-
if (sandbox)
|
|
22
|
-
await sandbox.clear();
|
|
21
|
+
if (sandbox) await sandbox.clear();
|
|
23
22
|
input = "";
|
|
24
23
|
finish = false;
|
|
25
24
|
if (ll !== language) {
|
|
@@ -49,8 +48,7 @@ async function initTerm(blink = true) {
|
|
|
49
48
|
await wait();
|
|
50
49
|
term.options.cursorBlink = blink;
|
|
51
50
|
term.focus();
|
|
52
|
-
if (!first)
|
|
53
|
-
term.write(`\r
|
|
51
|
+
if (!first) term.write(`\r
|
|
54
52
|
\x1B[0m`);
|
|
55
53
|
first = false;
|
|
56
54
|
}
|
|
@@ -74,8 +72,7 @@ export const terminal = {
|
|
|
74
72
|
async destroy() {
|
|
75
73
|
await wait();
|
|
76
74
|
term.dispose();
|
|
77
|
-
if (sandbox)
|
|
78
|
-
await sandbox.clear();
|
|
75
|
+
if (sandbox) await sandbox.clear();
|
|
79
76
|
},
|
|
80
77
|
async write(input2) {
|
|
81
78
|
await wait();
|
|
@@ -83,19 +80,16 @@ export const terminal = {
|
|
|
83
80
|
sandbox.write(input2.replaceAll("\r", "\n") + "\n");
|
|
84
81
|
}
|
|
85
82
|
};
|
|
86
|
-
$:
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
else
|
|
91
|
-
term.options.theme = Theme.Tango_Light;
|
|
92
|
-
}
|
|
83
|
+
$: if (term) {
|
|
84
|
+
if (dark) term.options.theme = Theme.Tango_Dark;
|
|
85
|
+
else term.options.theme = Theme.Tango_Light;
|
|
86
|
+
}
|
|
93
87
|
$: {
|
|
94
88
|
void 0, clientHeight;
|
|
95
89
|
plugin?.fit?.fit?.();
|
|
96
90
|
}
|
|
97
91
|
onMount(() => {
|
|
98
|
-
import("xterm").then(async ({ Terminal }) => {
|
|
92
|
+
import("@xterm/xterm").then(async ({ Terminal }) => {
|
|
99
93
|
term = new Terminal({
|
|
100
94
|
theme: dark ? Theme.Tango_Dark : Theme.Tango_Light,
|
|
101
95
|
cursorBlink: false,
|
|
@@ -105,8 +99,7 @@ onMount(() => {
|
|
|
105
99
|
});
|
|
106
100
|
term.open(ref);
|
|
107
101
|
term.onKey((e) => {
|
|
108
|
-
if (finish)
|
|
109
|
-
return;
|
|
102
|
+
if (finish) return;
|
|
110
103
|
const ev = e.domEvent;
|
|
111
104
|
const printable = !ev.altKey && !ev.ctrlKey && !ev.metaKey;
|
|
112
105
|
dispatch("key", ev);
|
|
@@ -117,8 +110,7 @@ onMount(() => {
|
|
|
117
110
|
} else if (ev.key === "Backspace") {
|
|
118
111
|
if (term._core.buffer.x > 0) {
|
|
119
112
|
term.write("\b \b");
|
|
120
|
-
if (input.length > 0)
|
|
121
|
-
input = input.substring(0, input.length - 1);
|
|
113
|
+
if (input.length > 0) input = input.substring(0, input.length - 1);
|
|
122
114
|
}
|
|
123
115
|
} else if (printable) {
|
|
124
116
|
if (e.key >= String.fromCharCode(32) && e.key <= String.fromCharCode(126) || e.key >= "\xA0") {
|
|
@@ -141,8 +133,7 @@ onMount(() => {
|
|
|
141
133
|
});
|
|
142
134
|
return async () => {
|
|
143
135
|
term.dispose();
|
|
144
|
-
if (sandbox)
|
|
145
|
-
await sandbox.clear();
|
|
136
|
+
if (sandbox) await sandbox.clear();
|
|
146
137
|
};
|
|
147
138
|
});
|
|
148
139
|
</script>
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import 'xterm/css/xterm.css';
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import '@xterm/xterm/css/xterm.css';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
dark?: boolean
|
|
6
|
-
path?: string
|
|
7
|
-
font?: string
|
|
5
|
+
dark?: boolean;
|
|
6
|
+
path?: string;
|
|
7
|
+
font?: string;
|
|
8
8
|
terminal?: {
|
|
9
9
|
clear(): Promise<void>;
|
|
10
10
|
prepare(language: any, code: any, log: boolean | undefined, prog: any): Promise<any>;
|
|
11
11
|
run(language: any, code: any, log: boolean | undefined, prog: any): Promise<any>;
|
|
12
12
|
destroy(): Promise<void>;
|
|
13
13
|
write(input: string): Promise<void>;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
};
|
|
16
16
|
events: {
|
|
17
17
|
finish: CustomEvent<any>;
|
|
@@ -21,11 +21,13 @@ declare const __propDef: {
|
|
|
21
21
|
[evt: string]: CustomEvent<any>;
|
|
22
22
|
};
|
|
23
23
|
slots: {};
|
|
24
|
+
exports?: {} | undefined;
|
|
25
|
+
bindings?: string | undefined;
|
|
24
26
|
};
|
|
25
27
|
export type TerminalProps = typeof __propDef.props;
|
|
26
28
|
export type TerminalEvents = typeof __propDef.events;
|
|
27
29
|
export type TerminalSlots = typeof __propDef.slots;
|
|
28
|
-
export default class Terminal extends
|
|
30
|
+
export default class Terminal extends SvelteComponent<TerminalProps, TerminalEvents, TerminalSlots> {
|
|
29
31
|
get terminal(): {
|
|
30
32
|
clear(): Promise<void>;
|
|
31
33
|
prepare(language: any, code: any, log: boolean | undefined, prog: any): Promise<any>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Terminal } from
|
|
1
|
+
import type { Terminal } from '@xterm/xterm';
|
|
2
2
|
export default function registerAllPlugins(term: Terminal): Promise<{
|
|
3
|
-
fit: import("xterm
|
|
4
|
-
search: import("xterm
|
|
5
|
-
serialize: import("xterm
|
|
6
|
-
weblink: import("xterm
|
|
7
|
-
webgl: import("xterm
|
|
8
|
-
unicode: import("xterm
|
|
3
|
+
fit: import("@xterm/addon-fit").FitAddon;
|
|
4
|
+
search: import("@xterm/addon-search").SearchAddon;
|
|
5
|
+
serialize: import("@xterm/addon-serialize").SerializeAddon;
|
|
6
|
+
weblink: import("@xterm/addon-web-links").WebLinksAddon;
|
|
7
|
+
webgl: import("@xterm/addon-webgl").WebglAddon;
|
|
8
|
+
unicode: import("@xterm/addon-unicode11").Unicode11Addon;
|
|
9
9
|
}>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export default async function registerAllPlugins(term) {
|
|
2
|
-
const { FitAddon } = await import('xterm
|
|
3
|
-
const { SearchAddon } = await import('xterm
|
|
4
|
-
const { SerializeAddon } = await import('xterm
|
|
5
|
-
const { WebLinksAddon } = await import('xterm
|
|
6
|
-
const { WebglAddon } = await import('xterm
|
|
7
|
-
const { Unicode11Addon } = await import('xterm
|
|
2
|
+
const { FitAddon } = await import('@xterm/addon-fit');
|
|
3
|
+
const { SearchAddon } = await import('@xterm/addon-search');
|
|
4
|
+
const { SerializeAddon } = await import('@xterm/addon-serialize');
|
|
5
|
+
const { WebLinksAddon } = await import('@xterm/addon-web-links');
|
|
6
|
+
const { WebglAddon } = await import('@xterm/addon-webgl');
|
|
7
|
+
const { Unicode11Addon } = await import('@xterm/addon-unicode11');
|
|
8
8
|
const plugins = {
|
|
9
9
|
fit: new FitAddon(),
|
|
10
10
|
search: new SearchAddon(),
|
package/package.json
CHANGED
|
@@ -1,62 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wasm-idle",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "A simple web app to run C++/Python code in the browser",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "vite dev",
|
|
9
|
-
"build": "vite build",
|
|
9
|
+
"build": "vite build && npm run package",
|
|
10
10
|
"preview": "vite preview",
|
|
11
|
+
"package": "svelte-kit sync && svelte-package && publint",
|
|
12
|
+
"prepublishOnly": "npm run package",
|
|
11
13
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
12
14
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
13
|
-
"lint": "prettier --
|
|
14
|
-
"format": "prettier --
|
|
15
|
-
"deploy": "svelte-package && npm publish",
|
|
16
|
-
"page": "pnpm run build && node ./gh-pages.js"
|
|
15
|
+
"lint": "prettier --check . && eslint .",
|
|
16
|
+
"format": "prettier --write ."
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@sveltejs/adapter-
|
|
21
|
-
"@sveltejs/
|
|
22
|
-
"@sveltejs/
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
25
|
-
"eslint": "^8.
|
|
26
|
-
"eslint
|
|
19
|
+
"@eslint/js": "^9.8.0",
|
|
20
|
+
"@sveltejs/adapter-auto": "^3.2.2",
|
|
21
|
+
"@sveltejs/adapter-static": "^3.0.2",
|
|
22
|
+
"@sveltejs/kit": "^2.5.20",
|
|
23
|
+
"@sveltejs/package": "^2.3.2",
|
|
24
|
+
"@sveltejs/vite-plugin-svelte": "^3.1.1",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^8.0.1",
|
|
26
|
+
"@typescript-eslint/parser": "^8.0.1",
|
|
27
|
+
"eslint": "^9.8.0",
|
|
28
|
+
"eslint-config-prettier": "^9.1.0",
|
|
29
|
+
"eslint-plugin-svelte": "^2.43.0",
|
|
27
30
|
"eslint-plugin-svelte3": "^4.0.0",
|
|
28
|
-
"gh-pages": "^6.
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"prettier
|
|
32
|
-
"svelte": "^
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
31
|
+
"gh-pages": "^6.1.1",
|
|
32
|
+
"globals": "^15.9.0",
|
|
33
|
+
"monaco-editor": "^0.50.0",
|
|
34
|
+
"prettier": "^3.3.3",
|
|
35
|
+
"prettier-plugin-svelte": "^3.2.6",
|
|
36
|
+
"publint": "^0.2.9",
|
|
37
|
+
"svelte": "^4.2.18",
|
|
38
|
+
"svelte-check": "^3.8.5",
|
|
39
|
+
"tslib": "^2.6.3",
|
|
40
|
+
"typescript": "^5.5.4",
|
|
41
|
+
"typescript-eslint": "^8.0.1",
|
|
42
|
+
"vite": "^5.3.5"
|
|
37
43
|
},
|
|
38
44
|
"dependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"
|
|
41
|
-
"xterm": "^
|
|
42
|
-
"xterm
|
|
43
|
-
"xterm
|
|
44
|
-
"xterm
|
|
45
|
-
"xterm
|
|
46
|
-
"xterm
|
|
47
|
-
"xterm
|
|
48
|
-
"
|
|
49
|
-
"
|
|
45
|
+
"@xterm/addon-canvas": "^0.7.0",
|
|
46
|
+
"@xterm/addon-fit": "^0.10.0",
|
|
47
|
+
"@xterm/addon-ligatures": "^0.9.0",
|
|
48
|
+
"@xterm/addon-search": "^0.15.0",
|
|
49
|
+
"@xterm/addon-serialize": "^0.13.0",
|
|
50
|
+
"@xterm/addon-unicode11": "^0.8.0",
|
|
51
|
+
"@xterm/addon-web-links": "^0.11.0",
|
|
52
|
+
"@xterm/addon-webgl": "^0.18.0",
|
|
53
|
+
"@xterm/xterm": "^5.5.0",
|
|
54
|
+
"@zip.js/zip.js": "^2.7.48",
|
|
55
|
+
"pyodide": "0.26.2"
|
|
50
56
|
},
|
|
51
57
|
"files": [
|
|
52
58
|
"dist",
|
|
53
|
-
"
|
|
59
|
+
"!dist/**/*.test.*",
|
|
60
|
+
"!dist/**/*.spec.*"
|
|
54
61
|
],
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"svelte": "^4.2.18"
|
|
64
|
+
},
|
|
55
65
|
"exports": {
|
|
56
66
|
".": {
|
|
57
67
|
"types": "./dist/index.d.ts",
|
|
58
68
|
"svelte": "./dist/index.js"
|
|
59
69
|
}
|
|
60
70
|
},
|
|
61
|
-
"svelte": "./dist/index.js"
|
|
71
|
+
"svelte": "./dist/index.js",
|
|
72
|
+
"types": "./dist/index.d.ts"
|
|
62
73
|
}
|
package/static/image.jpeg
DELETED
|
Binary file
|