wasm-idle 0.6.0 → 0.7.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.
Files changed (33) hide show
  1. package/README.md +85 -11
  2. package/dist/playground/assets.d.ts +43 -0
  3. package/dist/playground/assets.js +164 -0
  4. package/dist/playground/elixir.d.ts +32 -0
  5. package/dist/playground/elixir.js +173 -0
  6. package/dist/playground/go.d.ts +31 -0
  7. package/dist/playground/go.js +166 -0
  8. package/dist/playground/index.js +36 -1
  9. package/dist/playground/ocaml.d.ts +32 -0
  10. package/dist/playground/ocaml.js +341 -0
  11. package/dist/playground/options.d.ts +4 -0
  12. package/dist/playground/tinygo.d.ts +75 -0
  13. package/dist/playground/tinygo.js +510 -0
  14. package/dist/playground/wasmElixirVersion.d.ts +1 -0
  15. package/dist/playground/wasmElixirVersion.js +1 -0
  16. package/dist/playground/wasmGoVersion.d.ts +1 -0
  17. package/dist/playground/wasmGoVersion.js +1 -0
  18. package/dist/playground/wasmOcamlVersion.d.ts +1 -0
  19. package/dist/playground/wasmOcamlVersion.js +1 -0
  20. package/dist/playground/wasmRustVersion.d.ts +1 -1
  21. package/dist/playground/wasmRustVersion.js +1 -1
  22. package/dist/playground/wasmTinyGoVersion.d.ts +1 -0
  23. package/dist/playground/wasmTinyGoVersion.js +1 -0
  24. package/dist/playground/worker/elixir.d.ts +1 -0
  25. package/dist/playground/worker/elixir.js +317 -0
  26. package/dist/playground/worker/go.d.ts +1 -0
  27. package/dist/playground/worker/go.js +163 -0
  28. package/dist/playground/worker/ocaml.d.ts +1 -0
  29. package/dist/playground/worker/ocaml.js +449 -0
  30. package/dist/playground/worker/tinygo.d.ts +1 -0
  31. package/dist/playground/worker/tinygo.js +137 -0
  32. package/dist/terminal/Terminal.svelte +69 -29
  33. package/package.json +35 -22
@@ -61,8 +61,7 @@
61
61
  tc = 0,
62
62
  plugin = $state(),
63
63
  ll: string | null = null,
64
- loadedRuntimeAssets = $state<SandboxRuntimeAssets | undefined>(undefined),
65
- loadedPlayground = $state<PlaygroundBinding | undefined>(undefined),
64
+ loadedRuntimeAssetsKey: string | undefined = undefined,
66
65
  stopRequested = false;
67
66
 
68
67
  function writeTerminalOutput(text: string) {
@@ -99,23 +98,39 @@
99
98
  async function initSandbox(language: string) {
100
99
  const currentPlayground = playground;
101
100
  const currentRuntimeAssets = currentPlayground?.runtimeAssets || runtimeAssets || path;
101
+ const currentRuntimeAssetsKey =
102
+ typeof currentRuntimeAssets === 'string'
103
+ ? currentRuntimeAssets
104
+ : JSON.stringify({
105
+ rootUrl: currentRuntimeAssets?.rootUrl || '',
106
+ pythonBaseUrl: currentRuntimeAssets?.python?.baseUrl || '',
107
+ hasPythonLoader: !!currentRuntimeAssets?.python?.loader,
108
+ javaBaseUrl: currentRuntimeAssets?.java?.baseUrl || '',
109
+ hasJavaLoader: !!currentRuntimeAssets?.java?.loader,
110
+ rustCompilerUrl: currentRuntimeAssets?.rust?.compilerUrl || '',
111
+ goCompilerUrl: currentRuntimeAssets?.go?.compilerUrl || '',
112
+ elixirBundleUrl: currentRuntimeAssets?.elixir?.bundleUrl || '',
113
+ ocamlModuleUrl: currentRuntimeAssets?.ocaml?.moduleUrl || '',
114
+ ocamlManifestUrl: currentRuntimeAssets?.ocaml?.manifestUrl || '',
115
+ tinygoAppUrl: currentRuntimeAssets?.tinygo?.appUrl || '',
116
+ tinygoHostCompileUrl: currentRuntimeAssets?.tinygo?.hostCompileUrl || '',
117
+ tinygoModuleUrl: currentRuntimeAssets?.tinygo?.moduleUrl || '',
118
+ tinygoDisableHostCompile: !!currentRuntimeAssets?.tinygo?.disableHostCompile
119
+ });
120
+ const requiresSandboxReset =
121
+ ll !== language || loadedRuntimeAssetsKey !== currentRuntimeAssetsKey;
102
122
  let _tc = ++tc;
103
123
  await wait();
104
- if (sandbox) await sandbox.clear();
124
+ if (sandbox && requiresSandboxReset) await sandbox.clear();
105
125
  input = '';
106
126
  finish = false;
107
- if (
108
- ll !== language ||
109
- loadedRuntimeAssets !== currentRuntimeAssets ||
110
- loadedPlayground !== currentPlayground
111
- ) {
127
+ if (!sandbox || requiresSandboxReset) {
112
128
  sandbox = currentPlayground
113
129
  ? await currentPlayground.load(language)
114
130
  : await load(language, currentRuntimeAssets);
115
131
  await sandbox.clear();
116
132
  ll = language;
117
- loadedRuntimeAssets = currentRuntimeAssets;
118
- loadedPlayground = currentPlayground;
133
+ loadedRuntimeAssetsKey = currentRuntimeAssetsKey;
119
134
  }
120
135
  sandbox.image = onimage;
121
136
  sandbox.ondebug = ondebug;
@@ -203,9 +218,17 @@
203
218
  ) {
204
219
  prog?.set?.(0);
205
220
  const loadProgress =
206
- language === 'RUST' ? phaseProgress(prog, 0, 0.05) : phaseProgress(prog, 0, 0.85);
221
+ language === 'RUST' ||
222
+ language === 'GO' ||
223
+ language === 'TINYGO' ||
224
+ language === 'OCAML'
225
+ ? phaseProgress(prog, 0, 0.05)
226
+ : phaseProgress(prog, 0, 0.85);
207
227
  const prepareProgress =
208
- language === 'RUST'
228
+ language === 'RUST' ||
229
+ language === 'GO' ||
230
+ language === 'TINYGO' ||
231
+ language === 'OCAML'
209
232
  ? phaseProgress(prog, 0.05, 0.99)
210
233
  : phaseProgress(prog, 0.85, 0.99);
211
234
  await Promise.all([
@@ -298,10 +321,40 @@
298
321
  allowProposedApi: true
299
322
  });
300
323
  term.open(ref);
324
+ term.onData((data: string) => {
325
+ if (!term || finish) return;
326
+ let pendingText = '';
327
+ for (const chunk of data) {
328
+ if (chunk === '\r' || chunk === '\n') {
329
+ if (pendingText) {
330
+ appendInputText(pendingText);
331
+ pendingText = '';
332
+ }
333
+ submitCurrentInput();
334
+ continue;
335
+ }
336
+ if (chunk === '\u007f') {
337
+ if (pendingText) {
338
+ appendInputText(pendingText);
339
+ pendingText = '';
340
+ }
341
+ if (term.buffer.active.cursorX > 0 && input.length > 0) {
342
+ term.write('\b \b');
343
+ input = Array.from(input).slice(0, -1).join('');
344
+ }
345
+ continue;
346
+ }
347
+ if ((chunk.codePointAt(0) || 0) >= 0x20) {
348
+ pendingText += chunk;
349
+ }
350
+ }
351
+ if (pendingText) {
352
+ appendInputText(pendingText);
353
+ }
354
+ });
301
355
  term.onKey((e: { key: string; domEvent: KeyboardEvent }) => {
302
356
  if (!term) return;
303
357
  const ev = e.domEvent;
304
- const printable = !ev.altKey && !ev.ctrlKey && !ev.metaKey;
305
358
  const isCopyShortcut = (ev.ctrlKey || ev.metaKey) && ev.key.toLowerCase() === 'c';
306
359
  if (isCopyShortcut && term.hasSelection()) {
307
360
  const selectedText = term.getSelection();
@@ -313,28 +366,15 @@
313
366
  }
314
367
  if (finish) return;
315
368
  onkey?.(ev);
316
- if (ev.key === 'Enter') {
317
- submitCurrentInput();
318
- } else if (ev.key === 'Backspace') {
319
- if (term.buffer.active.cursorX > 0) {
320
- term.write('\b \b');
321
- if (input.length > 0) input = input.substring(0, input.length - 1);
322
- }
323
- } else if (printable) {
324
- if (
325
- (e.key >= String.fromCharCode(0x20) &&
326
- e.key <= String.fromCharCode(0x7e)) ||
327
- e.key >= '\u00a0'
328
- ) {
329
- appendInputText(e.key);
330
- }
331
- } else if (isCopyShortcut) {
369
+ if (isCopyShortcut) {
332
370
  ev.preventDefault();
333
371
  sandbox.kill?.();
334
372
  } else if ((ev.ctrlKey || ev.metaKey) && ev.key.toLowerCase() === 'd') {
373
+ ev.preventDefault();
335
374
  if (input.length > 0) submitCurrentInput();
336
375
  sandbox?.eof?.();
337
376
  } else if ((ev.ctrlKey || ev.metaKey) && ev.key.toLowerCase() === 'v') {
377
+ ev.preventDefault();
338
378
  navigator.clipboard.readText().then((text) => {
339
379
  applyPastedText(text);
340
380
  });
package/package.json CHANGED
@@ -1,16 +1,28 @@
1
1
  {
2
2
  "name": "wasm-idle",
3
- "version": "0.6.0",
4
- "description": "A simple web app to run C++/Python/Java code in the browser",
3
+ "version": "0.7.0",
4
+ "description": "A simple web app to run code in the browser",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "dev": "vite dev",
9
+ "build:preview": "vite build",
9
10
  "build": "vite build && npm run package",
10
11
  "preview": "vite preview",
11
- "probe:rust-browser": "pnpm run sync:wasm-rust && pnpm build && node scripts/probe-rust-browser.mjs",
12
- "test:browser:playwright": "pnpm run sync:wasm-rust && pnpm build && WASM_IDLE_RUN_REAL_BROWSER_RUST=1 pnpm exec vitest run src/lib/playground/rust.playwright.test.ts",
12
+ "probe:go-browser": "node scripts/probe-go-browser.mjs",
13
+ "probe:ocaml-browser": "node scripts/probe-ocaml-browser.mjs",
14
+ "probe:rust-browser": "node scripts/probe-rust-browser.mjs",
15
+ "probe:tinygo-browser": "node scripts/probe-tinygo-browser.mjs",
16
+ "probe:tinygo-browser:static": "WASM_IDLE_DISABLE_TINYGO_HOST_COMPILE=1 node scripts/probe-tinygo-browser.mjs",
17
+ "sync:pyodide": "node scripts/sync-pyodide.mjs",
18
+ "test:browser:go": "WASM_IDLE_RUN_REAL_BROWSER_GO=1 pnpm exec vitest run src/lib/playground/go.playwright.test.ts",
19
+ "test:browser:ocaml": "WASM_IDLE_RUN_REAL_BROWSER_OCAML=1 pnpm exec vitest run src/lib/playground/ocaml.playwright.test.ts",
20
+ "test:browser:playwright": "WASM_IDLE_RUN_REAL_BROWSER_RUST=1 pnpm exec vitest run src/lib/playground/rust.playwright.test.ts",
21
+ "test:browser:tinygo": "WASM_IDLE_RUN_REAL_BROWSER_TINYGO=1 pnpm exec vitest run src/lib/playground/tinygo.playwright.test.ts",
22
+ "sync:wasm-of-js-of-ocaml": "node scripts/sync-wasm-of-js-of-ocaml.mjs",
23
+ "sync:wasm-go": "node scripts/sync-wasm-go.mjs",
13
24
  "sync:wasm-rust": "node scripts/sync-wasm-rust.mjs",
25
+ "sync:wasm-tinygo": "node scripts/sync-wasm-tinygo.mjs",
14
26
  "package": "svelte-kit sync && svelte-package && publint",
15
27
  "prepublishOnly": "npm run package",
16
28
  "test": "vitest run",
@@ -25,36 +37,37 @@
25
37
  "@eslint/js": "^10.0.1",
26
38
  "@sveltejs/adapter-auto": "^7.0.1",
27
39
  "@sveltejs/adapter-static": "^3.0.10",
28
- "@sveltejs/kit": "^2.55.0",
40
+ "@sveltejs/kit": "^2.57.1",
29
41
  "@sveltejs/package": "^2.5.7",
30
42
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
31
43
  "@testing-library/svelte": "^5.3.1",
32
44
  "@testing-library/user-event": "^14.6.1",
33
- "@types/node": "^25.5.0",
34
- "@typescript-eslint/eslint-plugin": "^8.57.2",
35
- "@typescript-eslint/parser": "^8.57.2",
36
- "eslint": "^10.1.0",
45
+ "@types/node": "^25.6.0",
46
+ "@typescript-eslint/eslint-plugin": "^8.58.2",
47
+ "@typescript-eslint/parser": "^8.58.2",
48
+ "eslint": "^10.2.0",
37
49
  "eslint-config-prettier": "^10.1.8",
38
- "eslint-plugin-svelte": "^3.16.0",
50
+ "eslint-plugin-svelte": "^3.17.0",
39
51
  "eslint-plugin-svelte3": "^4.0.0",
40
52
  "gh-pages": "^6.3.0",
41
- "globals": "^17.4.0",
42
- "jsdom": "^29.0.1",
53
+ "globals": "^17.5.0",
54
+ "jsdom": "^29.0.2",
43
55
  "monaco-editor": "^0.55.1",
44
- "playwright-core": "^1.58.2",
45
- "prettier": "^3.8.1",
56
+ "playwright-core": "^1.59.1",
57
+ "prettier": "^3.8.3",
46
58
  "prettier-plugin-svelte": "^3.5.1",
47
- "svelte": "^5.55.0",
48
- "svelte-check": "^4.4.5",
59
+ "svelte": "^5.55.4",
60
+ "svelte-check": "^4.4.6",
49
61
  "tslib": "^2.8.1",
50
- "typescript": "^5.9.3",
51
- "typescript-eslint": "^8.57.1",
52
- "vite": "^8.0.3",
53
- "vitest": "^4.1.1"
62
+ "typescript": "^6.0.2",
63
+ "typescript-eslint": "^8.58.2",
64
+ "vite": "^8.0.8",
65
+ "vitest": "^4.1.4"
54
66
  },
55
67
  "dependencies": {
56
68
  "@bjorn3/browser_wasi_shim": "^0.4.2",
57
69
  "@hancomac/monaco-languageclient": "^1.1.0",
70
+ "@swmansion/popcorn": "0.2.2",
58
71
  "@xterm/addon-canvas": "^0.7.0",
59
72
  "@xterm/addon-fit": "^0.11.0",
60
73
  "@xterm/addon-ligatures": "^0.10.0",
@@ -64,9 +77,9 @@
64
77
  "@xterm/addon-web-links": "^0.12.0",
65
78
  "@xterm/addon-webgl": "^0.19.0",
66
79
  "@xterm/xterm": "^6.0.0",
67
- "@zip.js/zip.js": "^2.8.23",
80
+ "@zip.js/zip.js": "^2.8.26",
68
81
  "publint": "^0.3.18",
69
- "pyodide": "0.26.2",
82
+ "pyodide": "0.29.3",
70
83
  "vscode-jsonrpc": "^8.2.1"
71
84
  },
72
85
  "files": [