wasm-idle 1.2.0 → 1.3.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/README.md CHANGED
@@ -344,10 +344,10 @@ variables or import SvelteKit modules.
344
344
  | Malbolge<br>`MALBOLGE` | Original Ben Olmstead interpreter, TryItOnline/malbolge b0869870 (public domain), compiled with WASI SDK 33 | Runs the original 59049-cell ternary and self-modifying interpreter; source-file input is separate from byte stdin/stdout; EOF stores 59048; requires at least two non-whitespace source bytes | `runtimeAssets.rootUrl`, `stdin`, `activePath`, `workspaceFiles`; fixed interpreter argv; prepare compiles the runtime without executing or validating the source |
345
345
  | Whitespace<br>`WHITESPACE` | koturn/Whitespace 22a57aab (MIT), compiled with WASI SDK 33 | Runs the upstream Whitespace 0.3 interpreter with a documented divisor-guard correction, copy/slide, heap, labels, calls and signed 32-bit integers; character/numeric stdin and exact stdout; character EOF is -1; source limit 65535 UTF-8 bytes | `runtimeAssets.rootUrl`, `stdin`, `activePath`, `workspaceFiles`; fixed interpreter argv; prepare compiles the runtime without executing or validating the source |
346
346
  | C3<br>`C3` | wasm-llvm/c3-browser: C3 0.8.3 / LLVM 22.1.8 | Verified c3c and builtin LLD compile real C3 in a fresh browser Worker; UTF-8 env.readByte/env.writeByte ABI and exported main; std::io and WASI unavailable | `runtimeAssets.c3.baseUrl`, `stdin`, `activePath`, `workspaceFiles`; fixed compiler flags and bounded Wasm memories |
347
- | C<br>`C` | @wasm-idle/llvm-core@1.2.0 / Clang 22.1.8 WASI sysroot from the `wasm-llvm` producer | `clang` for `wasm32-wasi`; default `-std=gnu11`; LLDB mode compiles untouched source with embedded DWARF at `-g -O0` and runs it in WAMR; normal runs still use the browser WASI host; supports `stdin` and `programArgs` | `runtimeAssets.clang.baseUrl`/`loader` or `rootUrl`; `compileArgs`, `programArgs`, `cVersion`, `activePath`, `workspaceFiles`, `debugMode`, `breakpoints`, `pauseOnEntry` |
348
- | C++<br>`CPP` | @wasm-idle/llvm-core@1.2.0 / Clang 22.1.8 WASI sysroot from the `wasm-llvm` producer | `clang++` for `wasm32-wasi`; default `-std=gnu++20`; LLDB mode compiles untouched source with embedded DWARF at `-g -O0` and runs it in WAMR; normal runs still use the browser WASI host; supports `stdin` and `programArgs` | `runtimeAssets.clang.baseUrl`/`loader` or `rootUrl`; `compileArgs`, `programArgs`, `cppVersion`, `activePath`, `workspaceFiles`, `debugMode`, `breakpoints`, `pauseOnEntry` |
349
- | Objective-C<br>`OBJC` | GNUstep libobjc2 v2.3 assets from the `wasm-llvm` producer + @wasm-idle/llvm-core@1.2.0 | `clang -x objective-c -fobjc-runtime=gnustep-2.0 -fblocks` for `wasm32-wasi`; links `libobjc.a`, `libgnustep-base.a`, and `libffi.a` when Foundation is imported; Foundation headers are inlined from `foundation-headers.json`; includes a constructor wrapper for Objective-C class registration; auto-compiles `.m`/`.mm`/`.c` workspace files; trace debug instruments active source and uses wasm-idle controls; supports `stdin` and `programArgs`; large Objective-C assets may be served as gzip-only `.gz` files through the service worker or worker fallback | `runtimeAssets.objectivec.baseUrl`/`libobjcUrl`/`headersUrl`/`libgnustepBaseUrl`/`libgnustepBaseObjectUrl`/`foundationHeadersUrl`/`libffiUrl` or `PUBLIC_WASM_OBJECTIVEC_*`; `runtimeAssets.clang.baseUrl`/`loader` for the clang toolchain; `activePath`, `workspaceFiles`, `compileArgs`, `debug`, `breakpoints`, `pauseOnEntry` |
350
- | Objective-C++<br>`OBJECTIVECXX` | Same GNUstep libobjc2 v2.3 + libc++ assets as Objective-C from the `wasm-llvm` producer + @wasm-idle/llvm-core@1.2.0; no extra compiler assets | `clang -x objective-c++ -std=gnu++20 -fobjc-runtime=gnustep-2.0 -fblocks` for `wasm32-wasi` with libc++ headers; active file defaults to `main.mm`; links `libobjc.a` (plus GNUstep Base and `libffi.a` when Foundation is imported); auto-compiles `.mm`/`.m`/`.c` workspace files; supports `stdin` and `programArgs`; trace debugging is not supported | Shares `runtimeAssets.objectivec` and `runtimeAssets.clang` with Objective-C; `activePath`, `workspaceFiles`, `compileArgs`, `programArgs` |
347
+ | C<br>`C` | @wasm-idle/llvm-core@1.3.0 / Clang 22.1.8 WASI sysroot from the `wasm-llvm` producer | `clang` for `wasm32-wasi`; default `-std=gnu11`; LLDB mode compiles untouched source with embedded DWARF at `-g -O0` and runs it in WAMR; normal runs still use the browser WASI host; supports `stdin` and `programArgs` | `runtimeAssets.clang.baseUrl`/`loader` or `rootUrl`; `compileArgs`, `programArgs`, `cVersion`, `activePath`, `workspaceFiles`, `debugMode`, `breakpoints`, `pauseOnEntry` |
348
+ | C++<br>`CPP` | @wasm-idle/llvm-core@1.3.0 / Clang 22.1.8 WASI sysroot from the `wasm-llvm` producer | `clang++` for `wasm32-wasi`; default `-std=gnu++20`; LLDB mode compiles untouched source with embedded DWARF at `-g -O0` and runs it in WAMR; normal runs still use the browser WASI host; supports `stdin` and `programArgs` | `runtimeAssets.clang.baseUrl`/`loader` or `rootUrl`; `compileArgs`, `programArgs`, `cppVersion`, `activePath`, `workspaceFiles`, `debugMode`, `breakpoints`, `pauseOnEntry` |
349
+ | Objective-C<br>`OBJC` | GNUstep libobjc2 v2.3 assets from the `wasm-llvm` producer + @wasm-idle/llvm-core@1.3.0 | `clang -x objective-c -fobjc-runtime=gnustep-2.0 -fblocks` for `wasm32-wasi`; links `libobjc.a`, `libgnustep-base.a`, and `libffi.a` when Foundation is imported; Foundation headers are inlined from `foundation-headers.json`; includes a constructor wrapper for Objective-C class registration; auto-compiles `.m`/`.mm`/`.c` workspace files; trace debug instruments active source and uses wasm-idle controls; supports `stdin` and `programArgs`; large Objective-C assets may be served as gzip-only `.gz` files through the service worker or worker fallback | `runtimeAssets.objectivec.baseUrl`/`libobjcUrl`/`headersUrl`/`libgnustepBaseUrl`/`libgnustepBaseObjectUrl`/`foundationHeadersUrl`/`libffiUrl` or `PUBLIC_WASM_OBJECTIVEC_*`; `runtimeAssets.clang.baseUrl`/`loader` for the clang toolchain; `activePath`, `workspaceFiles`, `compileArgs`, `debug`, `breakpoints`, `pauseOnEntry` |
350
+ | Objective-C++<br>`OBJECTIVECXX` | Same GNUstep libobjc2 v2.3 + libc++ assets as Objective-C from the `wasm-llvm` producer + @wasm-idle/llvm-core@1.3.0; no extra compiler assets | `clang -x objective-c++ -std=gnu++20 -fobjc-runtime=gnustep-2.0 -fblocks` for `wasm32-wasi` with libc++ headers; active file defaults to `main.mm`; links `libobjc.a` (plus GNUstep Base and `libffi.a` when Foundation is imported); auto-compiles `.mm`/`.m`/`.c` workspace files; supports `stdin` and `programArgs`; trace debugging is not supported | Shares `runtimeAssets.objectivec` and `runtimeAssets.clang` with Objective-C; `activePath`, `workspaceFiles`, `compileArgs`, `programArgs` |
351
351
  | Python<br>`PYTHON3` | static ESM `static/pyodide/pyodide.mjs` / pyodide@314.0.7 | loads `pyodide.mjs`, `pyodide.asm.mjs`, `pyodide.asm.wasm`, and `python_stdlib.zip` from the configured static asset tree on demand; supports `stdin`, workspace files, and trace debugging | `runtimeAssets.python.baseUrl`/`loader` or `rootUrl`; `stdin`, `activePath`, `workspaceFiles`, `debug`, `breakpoints`, `pauseOnEntry`, `debugPath` |
352
352
  | Befunge-93<br>`BEFUNGE93` | catseye/Befunge-93 8fe4065c (BSD-3-Clause), compiled with WASI SDK 33 | Runs the original interpreter with an 80 by 25 wrapping playfield, signed 32-bit stack, string mode and self-modifying p/g instructions; character and integer stdin share the WASI terminal; character EOF is -1 | `runtimeAssets.rootUrl`, `stdin`, `activePath`, `workspaceFiles`; fixed quiet argv; prepare compiles the runtime without executing or validating the source |
353
353
  | Brainfuck<br>`BRAINFUCK` | susam/bfc b1b92fc (MIT), compiled with WASI SDK 33 | Runs the pinned upstream interpreter in a browser Worker with a fresh read-only source filesystem; 30000 wrapping 8-bit cells, UTF-8 byte stdin/stdout, EOF sets the cell to zero | `runtimeAssets.rootUrl`, `stdin`, `activePath`, `workspaceFiles`; fixed interpreter argv; prepare compiles the runtime without executing or validating the source |
@@ -361,7 +361,7 @@ variables or import SvelteKit modules.
361
361
  | VB.NET<br>`VBNET` | wasm-dotnet@0.1.0 / .NET 9.0.16 browser-wasm / Roslyn Visual Basic 4.14.0 | `VisualBasicCompilationOptions(OutputKind.ConsoleApplication)`; `concurrentBuild=false`, `OptionStrict=Off`, `OptionInfer=On`, `OptionExplicit=On`; target `browser-wasm`; language-specific AOT bundle `runtime/vbnet/`; supports `stdin` and `programArgs` | `runtimeAssets.dotnet.moduleUrl` or `PUBLIC_WASM_DOTNET_MODULE_URL`; `programArgs`, LSP on/off |
362
362
  | Elixir<br>`ELIXIR` | wasm-elixir asset bundle / @swmansion/popcorn@0.3.3 | Popcorn/AtomVM bundle `bundle.avm`; supports `stdin` | `runtimeAssets.elixir.bundleUrl` or `PUBLIC_WASM_ELIXIR_BUNDLE_URL` |
363
363
  | Erlang<br>`ERLANG` | wasm-elixir asset bundle / @swmansion/popcorn@0.3.3 | Popcorn/AtomVM bundle `bundle.avm`; supports `stdin` | `runtimeAssets.erlang.bundleUrl` or `PUBLIC_WASM_ERLANG_BUNDLE_URL`; falls back to Elixir bundle URL |
364
- | Prolog<br>`PROLOG` | swipl-wasm@8.2.1 synced into `static/wasm-prolog` | static worker runs SWI-Prolog; supports `stdin` and `programArgs` | `runtimeAssets.prolog.baseUrl`/`runtimeAssets.prolog.workerUrl` or `PUBLIC_WASM_PROLOG_BASE_URL`/`PUBLIC_WASM_PROLOG_WORKER_URL`; `programArgs`, `activePath`, `workspaceFiles` |
364
+ | Prolog<br>`PROLOG` | swipl-wasm@8.2.5 synced into `static/wasm-prolog` | static worker runs SWI-Prolog; supports `stdin` and `programArgs` | `runtimeAssets.prolog.baseUrl`/`runtimeAssets.prolog.workerUrl` or `PUBLIC_WASM_PROLOG_BASE_URL`/`PUBLIC_WASM_PROLOG_WORKER_URL`; `programArgs`, `activePath`, `workspaceFiles` |
365
365
  | Gleam<br>`GLEAM` | @live-codes/gleam-precompiled@0.5.0 static worker | Gleam worker compiles/runs browser output with source manifest; supports `stdin` | `runtimeAssets.gleam.baseUrl`/`workerUrl`/`manifestUrl` or `PUBLIC_WASM_GLEAM_*`; `programArgs`, `workspaceFiles` |
366
366
  | Grain<br>`GRAIN` | grain-lang/grain v0.7.2 release: upstream js_of_ocaml grainc.bc.js + @grain/stdlib 0.7.2 (precompiled .gro) | Verified upstream grainc compiles `.gr` workspace files to WASI in a fresh browser Worker; stdio-only WASI host with streaming `stdin` | `runtimeAssets.grain.baseUrl` or `PUBLIC_WASM_GRAIN_BASE_URL`; `stdin`, `programArgs`, `activePath`, `workspaceFiles`; Wasm memory bounded by `limits.maxWasmMemoryBytes` |
367
367
  | Perl<br>`PERL` | WebPerl v0.09-beta (webperl_prebuilt_v0.09-beta.zip) | host-verifies the manifest, stored assets, logical hashes, and profile-bound one-shot runner before executing `emperl`; supports `stdin` and `programArgs` | explicit `runtimeAssets.perl.baseUrl`/`workerUrl`/`manifestUrl` overrides require one complete profile-and-runner receipt bundle; URL-only `PUBLIC_WASM_PERL_*` overrides fail closed; `programArgs`, `activePath`, `workspaceFiles` |
@@ -379,8 +379,8 @@ variables or import SvelteKit modules.
379
379
  | ReScript<br>`RESCRIPT` | upstream ReScript 12.3.1 playground `compiler.js` + `compiler-builtins/cmij.js` + `@rescript/runtime@12.3.1` | static worker compiles `Main.res` to CommonJS with the official js_of_ocaml ReScript compiler, then runs it against the upstream stdlib runtime; stdin via `fs.readLineSync(0)`/`fs.readFileSync(0)`; compiler errors/warnings become editor diagnostics; supports `programArgs` | `runtimeAssets.rescript.baseUrl`/`runtimeAssets.rescript.workerUrl` or `PUBLIC_WASM_RESCRIPT_BASE_URL`/`PUBLIC_WASM_RESCRIPT_WORKER_URL`; `programArgs`, `activePath`, `workspaceFiles` |
380
380
  | TinyGo<br>`TINYGO` | wasm-tinygo@0.0.0 / upstream TinyGo 0.40.1 browser toolchain | receipt-verifies and runs upstream `cmd/go` plus TinyGo in a disposable capped Worker; targets `wasip1`; supports `stdin`, `programArgs`, `workspaceFiles`, hosted C++ without exceptions/RTTI, and offline `vendor/modules.txt` | `runtimeAssets.tinygo.moduleUrl`/`assetLoader`; `PUBLIC_WASM_TINYGO_MODULE_URL`, execution/workspace resource limits, `programArgs` |
381
381
  | OCaml<br>`OCAML` | wasm-of-js-of-ocaml@0.1.0 / js_of_ocaml + wasm_of_ocaml | default backend `wasm`; selectable `wasm`, `js`; `ocamlWasmBinaryenMode` `fast`, `full`; supports `stdin`; outer module and manifest are size/SHA-256 verified before use | `runtimeAssets.ocaml.moduleUrl`/`manifestUrl` plus `moduleReceipt`/`manifestReceipt` for a custom generation, or `PUBLIC_WASM_OCAML_*` for a mirror of the bundled generation; `ocamlBackend` |
382
- | JavaScript<br>`JAVASCRIPT` | wasm-typescript@0.1.0 / @swc/wasm-typescript@1.16.13 | TypeScript service transpiles JS/TS and runs in browser sandbox; supports `stdin` and `programArgs` | `runtimeAssets.typescript.moduleUrl`/`libUrl` or `PUBLIC_WASM_TYPESCRIPT_MODULE_URL` |
383
- | TypeScript<br>`TYPESCRIPT` | wasm-typescript@0.1.0 / @swc/wasm-typescript@1.16.13 | TypeScript service transpiles then runs in browser sandbox; supports `stdin` and `programArgs` | `runtimeAssets.typescript.moduleUrl`/`libUrl` or `PUBLIC_WASM_TYPESCRIPT_MODULE_URL` |
382
+ | JavaScript<br>`JAVASCRIPT` | wasm-typescript@0.1.0 / @swc/wasm-typescript@1.16.20 | TypeScript service transpiles JS/TS and runs in browser sandbox; supports `stdin` and `programArgs` | `runtimeAssets.typescript.moduleUrl`/`libUrl` or `PUBLIC_WASM_TYPESCRIPT_MODULE_URL` |
383
+ | TypeScript<br>`TYPESCRIPT` | wasm-typescript@0.1.0 / @swc/wasm-typescript@1.16.20 | TypeScript service transpiles then runs in browser sandbox; supports `stdin` and `programArgs` | `runtimeAssets.typescript.moduleUrl`/`libUrl` or `PUBLIC_WASM_TYPESCRIPT_MODULE_URL` |
384
384
  | AssemblyScript<br>`ASSEMBLYSCRIPT` | static ESM `static/wasm-assemblyscript/runtime.mjs` produced from assemblyscript@0.28.20 + @assemblyscript/loader@0.28.20 | `asc <activePath> --outFile module.wasm --runtime incremental --bindings raw --optimize --exportRuntime`; runs the emitted WASM through WASI/browser imports and supports `stdin` | `runtimeAssets.assemblyscript.moduleUrl` or `PUBLIC_WASM_ASSEMBLYSCRIPT_MODULE_URL` or `rootUrl`; `stdin`, `activePath`, `workspaceFiles` |
385
385
  | WAT<br>`WAT` | wasm-wat@0.1.0 / wabt@1.0.39 | WABT parses WAT to WASM then runs through WASI shim; supports `stdin` and `programArgs` | `runtimeAssets.wat.moduleUrl` or `PUBLIC_WASM_WAT_MODULE_URL`; `programArgs` |
386
386
  | WASM<br>`WASM` | Browser WebAssembly + @bjorn3/browser_wasi_shim@0.4.2 | loads provided WASM bytes and executes with WASI preview1 imports; supports `stdin` and `programArgs` | `programArgs`, `stdin`, `activePath` |
@@ -393,15 +393,15 @@ variables or import SvelteKit modules.
393
393
  | Haskell<br>`HASKELL` | ghc-in-browser / GHC 9.14.0.20251031 WASI rootfs | loads `dyld.mjs`, `rootfs.tar.zst`, `bsdtar.wasm`; `compileArgs` become GHC args, otherwise legacy `args` become GHC args | `runtimeAssets.haskell.moduleUrl`/`rootfsUrl`/`bsdtarUrl`; `mainSoPath`, `searchDirs`, `activePath`, `workspaceFiles` |
394
394
  | LFortran<br>`LFORTRAN` | receipt-pinned `wasm-llvm/producer/lfortran-browser` artifacts in `static/wasm-lfortran` | real LFortran 0.65.0-97-gab867a23 LLVM evaluator compiles and executes Emscripten side modules in a fresh Worker; shared-ring stdin supports delayed READ and EOF; experimental Fortran feature coverage | `runtimeAssets.lfortran.baseUrl` relocates the reviewed bundle; `stdin`, `activePath`, workspace data/include files, cancellation and execution limits; no program arguments or multi-file module build orchestration |
395
395
  | Lean 4<br>`LEAN4` | receipt-pinned `wasm-llvm/producer/lean-browser` release downloaded from its immutable commit into `static/wasm-lean4` | real Lean 4.34.1 frontend and IR interpreter (`lean --run`) built for wasm32 Emscripten with pthreads; imports a wasm32 `Init` library compiled by that build; shared-ring stdin supports interactive `getLine` and EOF | `runtimeAssets.lean4.baseUrl` relocates the reviewed bundle; `stdin`, program arguments, `activePath`, cancellation and execution limits; single-file programs importing `Init` only (no `Std`/`Lean` imports or Lake packages) |
396
- | Fortran<br>`FORTRAN` | Netlib f2c 2022-09-09 + `@cowasm/f2c 1.0.0` libf2c + @wasm-idle/llvm-core@1.2.0 | runs `f2c.wasm` in WASI, compiles generated C with the llvm-core Clang host, links `libf2c.a`, then executes the resulting WASI module with `stdin` and `programArgs` | `runtimeAssets.fortran.baseUrl`/`f2cWasmUrl`/`libf2cUrl`/`f2cHeaderUrl`/`analyzerUrl` or `PUBLIC_WASM_FORTRAN_*`; `runtimeAssets.clang.baseUrl`/`loader` for the C backend; `activePath`, `workspaceFiles`, `compileArgs` |
397
- | COBOL<br>`COBOL` | GnuCOBOL 3.2 + GMP 6.3.0 assets from the `wasm-llvm` producer + @wasm-idle/llvm-core@1.2.0 | native gzip delivery for the frontend Wasm and filesystem tar assets; translates free-format COBOL with the real GnuCOBOL `cobc` frontend, compiles the generated C with the llvm-core Clang host, links libcob/GMP, and executes the resulting WASI module with `stdin` and `programArgs` | `runtimeAssets.cobol.baseUrl` or `PUBLIC_WASM_COBOL_BASE_URL`; `runtimeAssets.clang.baseUrl`/`loader` for the C backend; `activePath`, `workspaceFiles`, `compileArgs` |
398
- | V<br>`V` | V 0.5.2 compiler, vlib and WASI C sysroot assets from the `wasm-llvm` producer + @wasm-idle/llvm-core@1.2.0 | native gzip delivery for the compiler Wasm and filesystem tar assets; translates V to C with the real V compiler (built from the upstream `vc` bootstrap for WASI), compiles the generated C with the llvm-core Clang host, and executes the resulting WASI module with `stdin` and `programArgs` | `runtimeAssets.v.baseUrl` or `PUBLIC_WASM_V_BASE_URL`; `runtimeAssets.clang.baseUrl`/`loader` for the C backend; `activePath`, `workspaceFiles`, `compileArgs` |
396
+ | Fortran<br>`FORTRAN` | Netlib f2c 2022-09-09 + `@cowasm/f2c 1.0.0` libf2c + @wasm-idle/llvm-core@1.3.0 | runs `f2c.wasm` in WASI, compiles generated C with the llvm-core Clang host, links `libf2c.a`, then executes the resulting WASI module with `stdin` and `programArgs` | `runtimeAssets.fortran.baseUrl`/`f2cWasmUrl`/`libf2cUrl`/`f2cHeaderUrl`/`analyzerUrl` or `PUBLIC_WASM_FORTRAN_*`; `runtimeAssets.clang.baseUrl`/`loader` for the C backend; `activePath`, `workspaceFiles`, `compileArgs` |
397
+ | COBOL<br>`COBOL` | GnuCOBOL 3.2 + GMP 6.3.0 assets from the `wasm-llvm` producer + @wasm-idle/llvm-core@1.3.0 | native gzip delivery for the frontend Wasm and filesystem tar assets; translates free-format COBOL with the real GnuCOBOL `cobc` frontend, compiles the generated C with the llvm-core Clang host, links libcob/GMP, and executes the resulting WASI module with `stdin` and `programArgs` | `runtimeAssets.cobol.baseUrl` or `PUBLIC_WASM_COBOL_BASE_URL`; `runtimeAssets.clang.baseUrl`/`loader` for the C backend; `activePath`, `workspaceFiles`, `compileArgs` |
398
+ | V<br>`V` | V 0.5.2 compiler, vlib and WASI C sysroot assets from the `wasm-llvm` producer + @wasm-idle/llvm-core@1.3.0 | native gzip delivery for the compiler Wasm and filesystem tar assets; translates V to C with the real V compiler (built from the upstream `vc` bootstrap for WASI), compiles the generated C with the llvm-core Clang host, and executes the resulting WASI module with `stdin` and `programArgs` | `runtimeAssets.v.baseUrl` or `PUBLIC_WASM_V_BASE_URL`; `runtimeAssets.clang.baseUrl`/`loader` for the C backend; `activePath`, `workspaceFiles`, `compileArgs` |
399
399
  | R<br>`R` | versioned static `static/webr/<hash>/webr.js` / webr@0.6.0 | loads the browser ESM entry `webr.js` and its WebR runtime files from the configured static asset tree on demand; supports `stdin`, `programArgs`, and workspace files | `runtimeAssets.r.baseUrl` or `PUBLIC_WASM_R_BASE_URL`; `stdin`, `programArgs`, `activePath`, `workspaceFiles` |
400
400
  | Octave<br>`OCTAVE` | Octave 10.3.0 (octave-10.3.0-pl5321h996e327_3.tar.bz2) | Octave CLI Emscripten worker; supports `stdin` and `programArgs` | `runtimeAssets.octave.baseUrl`/`workerUrl`/`manifestUrl` or `PUBLIC_WASM_OCTAVE_*` |
401
401
  | DuckDB<br>`DUCKDB` | static ESM `static/wasm-duckdb/runtime.mjs` produced from @duckdb/duckdb-wasm@1.33.1-dev57.0 | selects the best DuckDB-Wasm MVP/EH bundle on demand and creates a fresh in-memory database per run; `stdin` is registered as `stdin.txt` and `/dev/stdin` rather than terminal stdin | `runtimeAssets.duckdb.moduleUrl` or `PUBLIC_WASM_DUCKDB_MODULE_URL` or `rootUrl`; `stdin`, `activePath`, `workspaceFiles` |
402
- | SQLite<br>`SQLITE` | static ESM `static/wasm-sqlite/runtime.mjs` produced from sql.js@1.14.2 | sql.js loads `sql-wasm.wasm` on demand and executes SQL in a fresh in-memory database; terminal stdin is not applicable | `runtimeAssets.sqlite.moduleUrl`/`wasmUrl` or `PUBLIC_WASM_SQLITE_MODULE_URL`/`PUBLIC_WASM_SQLITE_WASM_URL` or `rootUrl`; `workspaceFiles` |
403
- | PostgreSQL<br>`POSTGRESQL` | static ESM `static/wasm-postgresql/runtime.mjs` produced from @electric-sql/pglite@0.5.8 | upstream PostgreSQL compiled to WebAssembly by PGlite; initdb runs once per worker and every run restores a fresh in-memory cluster, sends the script as one simple query, and prints result sets, notices, and `COPY ... TO STDOUT`; preloaded `stdin` is exposed as the server file `/dev/blob` | `runtimeAssets.postgresql.moduleUrl` or `PUBLIC_WASM_POSTGRESQL_MODULE_URL` or `rootUrl`; `stdin`, `activePath`, `workspaceFiles` |
404
- | PHP<br>`PHP` | static ESM `static/wasm-php/runtime.mjs` prebuilt by the standalone `producers/wasm-php` producer from @php-wasm/web-8-4@3.1.57 + @php-wasm/universal@3.1.57 | fixed PHP `8.4` php-wasm runtime; injects `$argv`/`$argc` and runs the active workspace script with `php.run`; supports `stdin` and `programArgs`; there is no runtime version selector | `runtimeAssets.php.moduleUrl` or `PUBLIC_WASM_PHP_MODULE_URL` or `rootUrl`; `stdin`, `programArgs`, `activePath`, `workspaceFiles` |
402
+ | SQLite<br>`SQLITE` | static ESM `static/wasm-sqlite/runtime.mjs` produced from sql.js@1.15.1 | sql.js loads `sql-wasm.wasm` on demand and executes SQL in a fresh in-memory database; terminal stdin is not applicable | `runtimeAssets.sqlite.moduleUrl`/`wasmUrl` or `PUBLIC_WASM_SQLITE_MODULE_URL`/`PUBLIC_WASM_SQLITE_WASM_URL` or `rootUrl`; `workspaceFiles` |
403
+ | PostgreSQL<br>`POSTGRESQL` | static ESM `static/wasm-postgresql/runtime.mjs` produced from @electric-sql/pglite@0.5.11 | upstream PostgreSQL compiled to WebAssembly by PGlite; initdb runs once per worker and every run restores a fresh in-memory cluster, sends the script as one simple query, and prints result sets, notices, and `COPY ... TO STDOUT`; preloaded `stdin` is exposed as the server file `/dev/blob` | `runtimeAssets.postgresql.moduleUrl` or `PUBLIC_WASM_POSTGRESQL_MODULE_URL` or `rootUrl`; `stdin`, `activePath`, `workspaceFiles` |
404
+ | PHP<br>`PHP` | static ESM `static/wasm-php/runtime.mjs` prebuilt by the standalone `producers/wasm-php` producer from @php-wasm/web-8-4@3.1.60 + @php-wasm/universal@3.1.60 | fixed PHP `8.4` php-wasm runtime; injects `$argv`/`$argc` and runs the active workspace script with `php.run`; supports `stdin` and `programArgs`; there is no runtime version selector | `runtimeAssets.php.moduleUrl` or `PUBLIC_WASM_PHP_MODULE_URL` or `rootUrl`; `stdin`, `programArgs`, `activePath`, `workspaceFiles` |
405
405
 
406
406
  ### Blocked candidates
407
407
 
@@ -523,7 +523,7 @@ opaque, receipt-pinned storage paths; these files are deployed page assets, not
523
523
  contents.
524
524
 
525
525
  PHP is built independently under `producers/wasm-php`, with its own lockfile and exact
526
- `@php-wasm/web-8-4@3.1.57` and `@php-wasm/universal@3.1.57` dependencies. Refresh the checked-in
526
+ `@php-wasm/web-8-4@3.1.60` and `@php-wasm/universal@3.1.60` dependencies. Refresh the checked-in
527
527
  page asset only when changing that producer:
528
528
 
529
529
  ```bash
@@ -906,8 +906,8 @@ and other workspace `.sql` files run first. Preloaded stdin is exposed as the se
906
906
  `/dev/blob` (`COPY t FROM '/dev/blob'` or `pg_read_file('/dev/blob')`). Override the module with
907
907
  `PUBLIC_WASM_POSTGRESQL_MODULE_URL` or `runtimeAssets.postgresql.moduleUrl`.
908
908
  PHP dynamically imports the checked-in `static/wasm-php/runtime.mjs` output from the standalone
909
- `producers/wasm-php` build. That producer pins `@php-wasm/web-8-4@3.1.57` and
910
- `@php-wasm/universal@3.1.57`. It always creates PHP 8.4; there is no version field or
909
+ `producers/wasm-php` build. That producer pins `@php-wasm/web-8-4@3.1.60` and
910
+ `@php-wasm/universal@3.1.60`. It always creates PHP 8.4; there is no version field or
911
911
  environment-based version selector. Override only the module location with
912
912
  `PUBLIC_WASM_PHP_MODULE_URL` or `runtimeAssets.php.moduleUrl`. A custom host must serve the entry's
913
913
  sibling chunks and assets with compatible CORS and cross-origin isolation headers; a cross-origin
@@ -1116,6 +1116,74 @@ external static hosting and loaded by `@wasm-idle/llvm-core`. Also powered by Py
1116
1116
  `wasm-dotnet`, `wasm-of-js-of-ocaml`, `wasm-typescript`, `wasm-lisp`,
1117
1117
  `wasm-wat`, `wasm-lua`, Fennel, `wasm-zig`, CBQN, Janet, AtomVM/Popcorn, and `ghc-in-browser`.
1118
1118
 
1119
+ ### Python bytecode compilation
1120
+
1121
+ Choose a Python `.py` file and click **Compile .pyc** to download its compiled bytecode.
1122
+ **Python bytecode options** lets you change the invalidation mode and, in timestamp mode,
1123
+ set the source timestamp in Unix seconds.
1124
+ The browser SDK exposes the same operation independently of playground sessions:
1125
+
1126
+ ```ts
1127
+ import { compilePython } from 'wasm-idle';
1128
+
1129
+ const controller = new AbortController();
1130
+ const result = await compilePython('print("Hello")', {
1131
+ fileName: 'main.py',
1132
+ optimize: 0,
1133
+ runtimeAssets: { rootUrl: 'https://cdn.example.com/repl' },
1134
+ signal: controller.signal
1135
+ });
1136
+ // result.path: "main.pyc"
1137
+ // result.data: Uint8Array, suitable for a Blob or binary file storage
1138
+ // result.pythonVersion, result.cacheTag, result.magicNumber identify the compiler format.
1139
+ ```
1140
+
1141
+ Each request uses a dedicated Pyodide worker and disposes it on success, failure, or cancellation.
1142
+ It calls CPython's `py_compile` without executing user code or installing its imports, and leaves
1143
+ the playground workspace and active interpreter unchanged. By default, the output uses checked-hash
1144
+ invalidation, which stores a source hash instead of a timestamp, and the relative `fileName` in
1145
+ tracebacks. With the same source, `fileName`, options, and CPython runtime version, repeated
1146
+ compilations produce identical bytes, regardless of the wall clock or temporary directory.
1147
+ Pin the runtime assets when comparing builds across machines or releases.
1148
+ `fileName` defaults to `main.py`;
1149
+ `optimize` accepts `0`, `1` (remove assertions), or `2` (also remove docstrings).
1150
+
1151
+ The optional `invalidationMode` selects CPython's bytecode cache format:
1152
+
1153
+ | Mode | Header and source validation |
1154
+ | ------------------------ | --------------------------------------------------------------------------------------- |
1155
+ | `checked-hash` (default) | Stores a source hash; Python checks source content when validating the cache. |
1156
+ | `unchecked-hash` | Stores a source hash; Python normally trusts the cache without checking source content. |
1157
+ | `timestamp` | Stores source modification time and encoded source byte length. |
1158
+
1159
+ In `timestamp` mode, `timestamp` defaults to **0**, keeping this mode reproducible too.
1160
+ To choose another fixed time, supply an integer Unix timestamp from `0` to `4294967295`:
1161
+
1162
+ ```ts
1163
+ const result = await compilePython(source, {
1164
+ fileName: 'pkg/main.py',
1165
+ invalidationMode: 'timestamp',
1166
+ timestamp: 1_700_000_000
1167
+ });
1168
+ ```
1169
+
1170
+ `timestamp` is accepted only with `invalidationMode: 'timestamp'`; hash modes have no timestamp
1171
+ field. To use the current time, explicitly pass `Math.floor(Date.now() / 1000)` in timestamp
1172
+ mode; the resulting bytes then depend on that time. When distributing a timestamp-based cache
1173
+ alongside source, its timestamp and encoded byte size must match the source file's metadata
1174
+ for Python to reuse the cache.
1175
+
1176
+ The optional `progress` callback and `persistentCache` setting follow the runtime asset APIs.
1177
+ `limits` supports asset/startup/compile deadlines, `maxAssetBytes`, `maxWorkspaceBytes` for the
1178
+ source, and `maxOutputBytes` for the returned bytecode.
1179
+
1180
+ The generated file targets the loaded CPython bytecode version; it does not bundle imported
1181
+ modules. Standard `.pyc` compilation rejects top-level `await`, even though the playground's
1182
+ interactive execution supports it. Source-free files should be distributed as `module.pyc`
1183
+ beside other modules, rather than as orphaned `__pycache__` entries. Bytecode upload/execution
1184
+ is not a new playground input mode. See Python's [py_compile documentation](https://docs.python.org/3.14/library/py_compile.html)
1185
+ and [compiled module behavior](https://docs.python.org/3.14/tutorial/modules.html#compiled-python-files).
1186
+
1119
1187
  ### Ruby split standard library
1120
1188
 
1121
1189
  The bundled Ruby runtime also provides a verified `ruby.splitStdlib: true` profile. It compiles the genuine Ruby core Wasm while fetching the complete standard library and bundled gems as a separate read-only filesystem pack. The web demo selects this profile; library consumers retain the embedded-stdlib profile unless they opt in. Custom trust profiles continue to use the embedded path.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import playground, { createPlaygroundBinding } from './playground';
2
2
  export default playground;
3
3
  export { createPlaygroundBinding, playground };
4
+ export { compilePython, type PythonCompileOptions, type PythonCompileResult } from './pythonCompiler';
4
5
  export { createRuntimeSession } from './playground/runtimeSession';
5
6
  export { configureRuntimeAssetCache, createRuntimeAssetCacheBackend, fetchPinnedRuntimeAsset, prefetchRuntimeAssets, resolveRuntimeAssetLockEntry, type PrefetchRuntimeAssetsOptions, type PrefetchRuntimeAssetsResult, type RuntimeAssetCacheStats, type RuntimeAssetCacheBackend, type RuntimeAssetCacheBackendIdentity, type PinnedRuntimeAssetRequest, getRuntimeAssetCacheOptions, getRuntimeAssetCacheStats, clearRuntimeAssetCache, pruneRuntimeAssetCache, requestRuntimeAssetCachePersistence, type RuntimeAssetCacheOptions } from '@wasm-idle/core';
6
7
  export type { PlaygroundRuntimeSession } from './playground/runtimeSession';
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import playground, { createPlaygroundBinding } from './playground';
2
2
  export default playground;
3
3
  export { createPlaygroundBinding, playground };
4
+ export { compilePython } from './pythonCompiler';
4
5
  export { createRuntimeSession } from './playground/runtimeSession';
5
6
  export { configureRuntimeAssetCache, createRuntimeAssetCacheBackend, fetchPinnedRuntimeAsset, prefetchRuntimeAssets, resolveRuntimeAssetLockEntry, getRuntimeAssetCacheOptions, getRuntimeAssetCacheStats, clearRuntimeAssetCache, pruneRuntimeAssetCache, requestRuntimeAssetCachePersistence } from '@wasm-idle/core';
6
7
  export { isSharedArrayBufferAvailable, requireSharedArrayBuffer } from './playground/sharedBuffer';
@@ -1,4 +1,4 @@
1
1
  // Third-party license texts: java-debug-notices.txt beside the shared parser.
2
- import{a as l,c as B}from"./java-debug-FMHDKUN6.js";var I=new Set(["methodDeclaration","interfaceMethodDeclaration","constructorDeclaration","compactConstructorDeclaration","lambdaExpression","staticInitializer","instanceInitializer"]);function k(c,u){return Object.values(u?{[u]:c.children[u]??[]}:c.children).flat().filter(s=>"children"in s)}l(k,"nodes");function i(c,u){return k(c,u)[0]}l(i,"firstNode");function $(c,u){let s=c.children[u]?.[0];return s&&!("children"in s)?s:void 0}l($,"firstToken");function J(c,u){let s=new Map,g=[],v=l(e=>{g.push(e);for(let n of k(e))s.set(n,e),v(n)},"index");v(c);let m=l(e=>e?u.slice(e.location.startOffset,e.location.endOffset+1):"","text"),y=l((e,n)=>{for(let t=e;t;t=s.get(t))if(n(t))return t},"nearest"),S=new Set(["classBody","interfaceBody","enumBody","recordBody"]),w=l(e=>{for(let n=e;n;n=s.get(n)){if(I.has(n.name))return n;if(S.has(n.name))return}},"contextOf"),b=l((e,n)=>n.has(e.name)?[e]:k(e).flatMap(t=>b(t,n)),"descendants"),D=l((e,n)=>Object.entries(e.children).some(([t,a])=>t.endsWith("Modifier")&&a.some(r=>"children"in r&&$(r,n)!==void 0)),"hasModifier"),C=new Set(g.filter(e=>e.name==="methodDeclaration"&&m(i(i(e,"methodHeader"),"result")).trim()==="record")),O=new Set(["normalClassDeclaration","normalInterfaceDeclaration","enumDeclaration","recordDeclaration"]),N=[],o=l((e,n,t,a,r=a.location.startOffset)=>{let d=i(e,"variableDeclaratorId"),h=$(d??e,"Identifier")?.image;!h||h==="_"||N.push({name:h,type:n+m(d?i(d,"dims"):void 0),context:t,scope:a,availableFrom:r})},"add");for(let e of g.filter(n=>I.has(n.name))){if(C.has(e))continue;let n,t;if(e.name==="methodDeclaration"||e.name==="interfaceMethodDeclaration"){let a=i(e,"methodHeader");n=a?i(a,"methodDeclarator"):void 0,t=i(e,"methodBody")}else if(e.name==="constructorDeclaration")n=i(e,"constructorDeclarator"),t=i(e,"constructorBody");else if(e.name==="compactConstructorDeclaration"){let a=y(s.get(e),r=>r.name==="recordDeclaration");n=a?i(a,"recordHeader"):void 0,t=i(e,"constructorBody")}else e.name==="lambdaExpression"?(n=i(e,"lambdaParameters"),t=i(e,"lambdaBody")):t=i(e,"block");if(t){if(n){let a=new Set(["variableParaRegularParameter","variableArityParameter","regularLambdaParameter","conciseLambdaParameter","recordComponent"]);for(let r of b(n,a)){let d=m(i(r,"unannType")??i(r,"lambdaParameterType"));o(r,(d||"var")+(r.children.DotDotDot?"[]":""),e,t)}e.name==="lambdaExpression"&&n.children.Identifier&&o(n,"var",e,t)}if(e.name!=="lambdaExpression"&&e.name!=="staticInitializer"&&!D(e,"Static")){let a=y(s.get(e),h=>S.has(h.name)),r=a?s.get(a):void 0,d=r&&O.has(r.name)?m(i(r,"typeIdentifier")):"this";N.push({name:"this",type:d,context:e,scope:t,availableFrom:(i(t,"explicitConstructorInvocation")?.location.endOffset??t.location.startOffset-1)+1})}}}for(let e of g){let n=w(e);if(!n||C.has(n))continue;let t=s.get(e);if(e.name==="catchFormalParameter"&&t?.name==="catchClause"){let f=i(t,"block");f&&o(e,m(i(e,"catchType")),n,f);continue}if(e.name!=="localVariableDeclaration")continue;let a,r,d=!1;if(t?.name==="enhancedForStatement")a=i(t,"statement"),d=!0;else if(t?.name==="forInit"){let f=s.get(t);a=f?i(f,"statement"):void 0}else if(t?.name==="resource"){let f=y(t,p=>p.name==="tryWithResourcesStatement");a=f?i(f,"block"):void 0}else if(t?.name==="localVariableDeclarationStatement")a=y(t,f=>["block","constructorBody","switchBlockStatementGroup"].includes(f.name));else continue;if(!a)continue;r=Math.max(a.location.startOffset,e.location.endOffset+1);let h=i(e,"variableDeclaratorList"),x=m(i(e,"localVariableType"));for(let f of h?k(h,"variableDeclarator"):[])(d||f.children.variableInitializer)&&o(f,x,n,a,r)}return{recordLikeMethods:C,at(e,n){let t=w(e);return N.filter(a=>a.context===t&&n>=a.availableFrom&&n>=a.scope.location.startOffset&&n<=a.scope.location.endOffset)}}}l(J,"collectDebugBindings");var E=new Set(["ifStatement","whileStatement","doStatement","basicForStatement","enhancedForStatement"]);function j(c,u,s){if(s.trim()!==s||!/^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(s))throw new Error("Invalid Java debugger helper name");if(/[\u0000-\u001f\u007f]/.test(u))throw new Error("Unsupported Java debug source path");if(/\\u+[0-9a-fA-F]{4}/.test(c))throw new Error("Java Debug does not support Unicode preprocessing escapes; use Run for this source.");let g;try{g=B(c)}catch(o){throw new Error(`Java Debug parser cannot safely instrument this syntax; use Run for this source. ${o instanceof Error?o.message:String(o)}`)}let v=J(g,c),m=[0];for(let o=0;o<c.length;o++)c[o]==="\r"?(c[o+1]===`
2
+ import{a as l,c as B}from"./java-debug-HUZVAK4F.js";var I=new Set(["methodDeclaration","interfaceMethodDeclaration","constructorDeclaration","compactConstructorDeclaration","lambdaExpression","staticInitializer","instanceInitializer"]);function k(c,u){return Object.values(u?{[u]:c.children[u]??[]}:c.children).flat().filter(s=>"children"in s)}l(k,"nodes");function i(c,u){return k(c,u)[0]}l(i,"firstNode");function $(c,u){let s=c.children[u]?.[0];return s&&!("children"in s)?s:void 0}l($,"firstToken");function J(c,u){let s=new Map,g=[],v=l(e=>{g.push(e);for(let n of k(e))s.set(n,e),v(n)},"index");v(c);let m=l(e=>e?u.slice(e.location.startOffset,e.location.endOffset+1):"","text"),y=l((e,n)=>{for(let t=e;t;t=s.get(t))if(n(t))return t},"nearest"),S=new Set(["classBody","interfaceBody","enumBody","recordBody"]),w=l(e=>{for(let n=e;n;n=s.get(n)){if(I.has(n.name))return n;if(S.has(n.name))return}},"contextOf"),b=l((e,n)=>n.has(e.name)?[e]:k(e).flatMap(t=>b(t,n)),"descendants"),D=l((e,n)=>Object.entries(e.children).some(([t,a])=>t.endsWith("Modifier")&&a.some(r=>"children"in r&&$(r,n)!==void 0)),"hasModifier"),C=new Set(g.filter(e=>e.name==="methodDeclaration"&&m(i(i(e,"methodHeader"),"result")).trim()==="record")),O=new Set(["normalClassDeclaration","normalInterfaceDeclaration","enumDeclaration","recordDeclaration"]),N=[],o=l((e,n,t,a,r=a.location.startOffset)=>{let d=i(e,"variableDeclaratorId"),h=$(d??e,"Identifier")?.image;!h||h==="_"||N.push({name:h,type:n+m(d?i(d,"dims"):void 0),context:t,scope:a,availableFrom:r})},"add");for(let e of g.filter(n=>I.has(n.name))){if(C.has(e))continue;let n,t;if(e.name==="methodDeclaration"||e.name==="interfaceMethodDeclaration"){let a=i(e,"methodHeader");n=a?i(a,"methodDeclarator"):void 0,t=i(e,"methodBody")}else if(e.name==="constructorDeclaration")n=i(e,"constructorDeclarator"),t=i(e,"constructorBody");else if(e.name==="compactConstructorDeclaration"){let a=y(s.get(e),r=>r.name==="recordDeclaration");n=a?i(a,"recordHeader"):void 0,t=i(e,"constructorBody")}else e.name==="lambdaExpression"?(n=i(e,"lambdaParameters"),t=i(e,"lambdaBody")):t=i(e,"block");if(t){if(n){let a=new Set(["variableParaRegularParameter","variableArityParameter","regularLambdaParameter","conciseLambdaParameter","recordComponent"]);for(let r of b(n,a)){let d=m(i(r,"unannType")??i(r,"lambdaParameterType"));o(r,(d||"var")+(r.children.DotDotDot?"[]":""),e,t)}e.name==="lambdaExpression"&&n.children.Identifier&&o(n,"var",e,t)}if(e.name!=="lambdaExpression"&&e.name!=="staticInitializer"&&!D(e,"Static")){let a=y(s.get(e),h=>S.has(h.name)),r=a?s.get(a):void 0,d=r&&O.has(r.name)?m(i(r,"typeIdentifier")):"this";N.push({name:"this",type:d,context:e,scope:t,availableFrom:(i(t,"explicitConstructorInvocation")?.location.endOffset??t.location.startOffset-1)+1})}}}for(let e of g){let n=w(e);if(!n||C.has(n))continue;let t=s.get(e);if(e.name==="catchFormalParameter"&&t?.name==="catchClause"){let f=i(t,"block");f&&o(e,m(i(e,"catchType")),n,f);continue}if(e.name!=="localVariableDeclaration")continue;let a,r,d=!1;if(t?.name==="enhancedForStatement")a=i(t,"statement"),d=!0;else if(t?.name==="forInit"){let f=s.get(t);a=f?i(f,"statement"):void 0}else if(t?.name==="resource"){let f=y(t,p=>p.name==="tryWithResourcesStatement");a=f?i(f,"block"):void 0}else if(t?.name==="localVariableDeclarationStatement")a=y(t,f=>["block","constructorBody","switchBlockStatementGroup"].includes(f.name));else continue;if(!a)continue;r=Math.max(a.location.startOffset,e.location.endOffset+1);let h=i(e,"variableDeclaratorList"),x=m(i(e,"localVariableType"));for(let f of h?k(h,"variableDeclarator"):[])(d||f.children.variableInitializer)&&o(f,x,n,a,r)}return{recordLikeMethods:C,at(e,n){let t=w(e);return N.filter(a=>a.context===t&&n>=a.availableFrom&&n>=a.scope.location.startOffset&&n<=a.scope.location.endOffset)}}}l(J,"collectDebugBindings");var E=new Set(["ifStatement","whileStatement","doStatement","basicForStatement","enhancedForStatement"]);function j(c,u,s){if(s.trim()!==s||!/^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(s))throw new Error("Invalid Java debugger helper name");if(/[\u0000-\u001f\u007f]/.test(u))throw new Error("Unsupported Java debug source path");if(/\\u+[0-9a-fA-F]{4}/.test(c))throw new Error("Java Debug does not support Unicode preprocessing escapes; use Run for this source.");let g;try{g=B(c)}catch(o){throw new Error(`Java Debug parser cannot safely instrument this syntax; use Run for this source. ${o instanceof Error?o.message:String(o)}`)}let v=J(g,c),m=[0];for(let o=0;o<c.length;o++)c[o]==="\r"?(c[o+1]===`
3
3
  `&&o++,m.push(o+1)):c[o]===`
4
4
  `&&m.push(o+1);let y=[],S=new Set,w=new Map,b=l((o,e,n=!1)=>{let t=w.get(o)??[];t.push({text:e,closing:n}),w.set(o,t)},"insert"),D=l((o,e)=>{if(S.has(e))return"";S.add(e);let n=0,t=m.length;for(;n+1<t;){let p=n+t>>>1;m[p]<=e?n=p:t=p}let a={line:n+1,column:e-m[n]+1};y.push(a);let r=v.at(o,e),d=`${JSON.stringify(u)},${a.line},${a.column}`,h=r.map(p=>JSON.stringify(p.name)).join(","),x=r.map(p=>JSON.stringify(p.type)).join(","),f=r.map(p=>`${s}.capture(${p.name})`).join(",");return`if(${s}.poll(${d}))${s}.hit(${d},new java.lang.String[]{${h}},new java.lang.String[]{${x}},new java.lang.Object[]{${f}});`},"hook"),C=l((o,e)=>{let n=o.children.LCurly?.[0];if(!n)throw new Error("Java Debug parser returned a block without its opening token");let t=e??n.endOffset+1;b(t,D(o,t))},"blockEntry"),O=l((o,e)=>{if(v.recordLikeMethods.has(o))return;let n=e[e.length-1];if(o.name==="constructorBody"){let t=o.children.explicitConstructorInvocation?.[0];C(o,t?t.location.endOffset+1:void 0)}else if(o.name==="block"&&(n?.name==="methodBody"||n?.name==="lambdaBody"||n?.name==="switchRule"))C(o);else if(o.name==="blockStatement"&&(o.children.statement||o.children.localVariableDeclarationStatement))b(o.location.startOffset,D(o,o.location.startOffset));else if(o.name==="statement"&&E.has(n?.name??"")){let a=o.children.statementWithoutTrailingSubstatement?.[0]?.children.block?.[0];a?C(a):(b(o.location.startOffset,`{${D(o,o.location.startOffset)}`),b(o.location.endOffset+1,"}",!0))}else if(o.name==="switchRule"){let t=o.children.expression?.[0],a=o.children.throwStatement?.[0],r=t??a;if(r){let d=e.findLastIndex(x=>x.name==="switchStatement"),h=e[d-1]?.name==="primaryPrefix";b(r.location.startOffset,`{${D(r,r.location.startOffset)}${t&&h?"yield ":""}`),b(o.location.endOffset+1,"}",!0)}}for(let t of Object.values(o.children))for(let a of t)"children"in a&&O(a,[...e,o])},"visit");O(g,[]);let N=c;for(let[o,e]of[...w].sort(([n],[t])=>t-n)){let n=e.sort((t,a)=>Number(a.closing)-Number(t.closing)).map(t=>t.text).join("");N=N.slice(0,o)+n+N.slice(o)}return{code:N,locations:y}}l(j,"instrumentJavaDebugSource");export{j as instrumentJavaDebugSource};
@@ -127,6 +127,7 @@ export declare class LldbSandboxSession {
127
127
  private finish;
128
128
  private fail;
129
129
  private publishStop;
130
+ private publishDebuggerOutput;
130
131
  private publishActiveDebugEvent;
131
132
  private trackSessionDisposal;
132
133
  private requireSession;
@@ -290,6 +290,15 @@ export class LldbSandboxSession {
290
290
  },
291
291
  fetchImpl: this.options.fetchImpl,
292
292
  onOutput: (_channel, output) => this.options.onOutput(output),
293
+ onDebuggerOutput: (channel, output) => {
294
+ if (lifecycleVersion !== this.lifecycleVersion || this.session !== session)
295
+ return;
296
+ this.publishDebuggerOutput({
297
+ type: 'output',
298
+ category: channel === 'stderr' ? 'important' : 'console',
299
+ output
300
+ });
301
+ },
293
302
  onLifecycle: (event) => {
294
303
  if (lifecycleVersion !== this.lifecycleVersion || this.session !== session) {
295
304
  return;
@@ -1061,8 +1070,28 @@ export class LldbSandboxSession {
1061
1070
  handleDapEvent(event) {
1062
1071
  if (event.event === 'output') {
1063
1072
  const body = event.body;
1064
- if (typeof body?.output === 'string')
1073
+ if (typeof body?.output !== 'string')
1074
+ return;
1075
+ if (body.category === 'stdout' || body.category === 'stderr') {
1065
1076
  this.options.onOutput(body.output);
1077
+ }
1078
+ else if (body.category !== 'telemetry') {
1079
+ // DAP defaults missing or unknown categories to debugger console output.
1080
+ // Keep console logpoints and their source location available to host UIs.
1081
+ this.publishDebuggerOutput({
1082
+ type: 'output',
1083
+ category: body.category === 'important' ? 'important' : 'console',
1084
+ output: body.output,
1085
+ ...(typeof body.source?.path === 'string'
1086
+ ? { sourcePath: body.source.path }
1087
+ : {}),
1088
+ ...(typeof body.line === 'number' &&
1089
+ Number.isSafeInteger(body.line) &&
1090
+ body.line > 0
1091
+ ? { line: body.line }
1092
+ : {})
1093
+ });
1094
+ }
1066
1095
  return;
1067
1096
  }
1068
1097
  if (event.event === 'stopped') {
@@ -1249,7 +1278,11 @@ export class LldbSandboxSession {
1249
1278
  reason = 'pause';
1250
1279
  }
1251
1280
  else {
1252
- this.options.onOutput(`LLDB could not resolve ${this.options.entryFunctionName ?? 'main'}; paused at runtime entry.\n`);
1281
+ this.publishDebuggerOutput({
1282
+ type: 'output',
1283
+ category: 'important',
1284
+ output: `LLDB could not resolve ${this.options.entryFunctionName ?? 'main'}; paused at runtime entry.\n`
1285
+ });
1253
1286
  }
1254
1287
  }
1255
1288
  }
@@ -1487,6 +1520,16 @@ export class LldbSandboxSession {
1487
1520
  // Consumer callbacks cannot interrupt target teardown or completion settlement.
1488
1521
  }
1489
1522
  }
1523
+ publishDebuggerOutput(event) {
1524
+ if (!event.output)
1525
+ return;
1526
+ try {
1527
+ this.options.onDebugEvent(event);
1528
+ }
1529
+ catch {
1530
+ // A diagnostics consumer must not interrupt target execution or teardown.
1531
+ }
1532
+ }
1490
1533
  publishActiveDebugEvent(event) {
1491
1534
  try {
1492
1535
  this.options.onDebugEvent(event);
@@ -36,7 +36,7 @@ declare class ObjectiveC extends CompiledLldbSandbox implements Sandbox {
36
36
  run(code: string, prepare: boolean, log?: boolean, prog?: SandboxProgress, args?: string[], options?: SandboxExecutionOptions): Promise<boolean | string>;
37
37
  debugCommand(command: DebugCommand): Promise<void> | undefined;
38
38
  setBreakpoints(lines: number[], sourcePath?: string): Promise<void> | undefined;
39
- setSourceBreakpoints(breakpoints: DebugSourceBreakpoint[], sourcePath?: string): Promise<any>;
39
+ setSourceBreakpoints(breakpoints: DebugSourceBreakpoint[], sourcePath?: string): Promise<void>;
40
40
  debugEvaluate(expression: string): Promise<string>;
41
41
  kill(): void;
42
42
  terminate(): void;
@@ -3,6 +3,7 @@ import { WorkerAssetBridge } from './assetBridge';
3
3
  import { RuntimeAssetCache } from './runtimeAssetCache';
4
4
  import { type PlaygroundRuntimeAssets } from './assets';
5
5
  import type { Sandbox, SandboxProgress } from './sandbox';
6
+ import { type PythonCompileOptions, type PythonCompileResult } from './pythonCompileOptions';
6
7
  declare class Python implements Sandbox {
7
8
  ts: number;
8
9
  output: any;
@@ -56,6 +57,8 @@ declare class Python implements Sandbox {
56
57
  load(runtimeAssets?: string | PlaygroundRuntimeAssets, code?: string, log?: boolean, _args?: string[], options?: SandboxExecutionOptions, progress?: SandboxProgress): Promise<void>;
57
58
  write(input: string): void;
58
59
  eof(): void;
60
+ /** Used by compilePython's dedicated instance; never runs source or resolves its imports. */
61
+ compile(code: string, options?: PythonCompileOptions): Promise<PythonCompileResult>;
59
62
  private flushPendingInput;
60
63
  run(code: string, prepare: boolean, _log?: boolean, _prog?: SandboxProgress, _args?: string[], options?: SandboxExecutionOptions): Promise<boolean | string>;
61
64
  debugCommand(command: DebugCommand): void;
@@ -5,6 +5,7 @@ import { bufferedSequence, flushBufferedEof, flushQueuedStdin, resetBufferedStdi
5
5
  import { createWasmIdleSharedBuffer, requireSharedArrayBuffer } from './sharedBuffer';
6
6
  import { WorkerSession } from './workerSession';
7
7
  import { reportWorkerProgress } from './workerProgress';
8
+ import { resolvePythonCompileRequest } from './pythonCompileOptions';
8
9
  import { BusyError, DEFAULT_WORKSPACE_LIMITS, OutputLimitError, RuntimeConfigurationError, TimeoutError, resolveExecutionLimits, validateExecutionWorkspace } from '@wasm-idle/core';
9
10
  const debugBreakpointBufferInts = 1028;
10
11
  const outputEncoder = new TextEncoder();
@@ -12,7 +13,7 @@ const abortReason = (signal, phase, label = 'Python') => signal.reason !== undef
12
13
  ? signal.reason
13
14
  : new DOMException(phase === 'startup'
14
15
  ? `${label} runtime startup aborted`
15
- : `${label} execution aborted`, 'AbortError');
16
+ : `${label} ${phase === 'compile' ? 'compilation' : 'execution'} aborted`, 'AbortError');
16
17
  class Python {
17
18
  ts = Date.now();
18
19
  output = null;
@@ -188,7 +189,7 @@ class Python {
188
189
  timeout = setTimeout(() => {
189
190
  if (!this.isOperationActive(operation))
190
191
  return;
191
- this.cancelOperation(operation, new TimeoutError(`${this.runtimeLabel} ${operation.phase === 'startup' ? 'startup' : 'execution'} timed out after ${timeoutMs} ms`, {
192
+ this.cancelOperation(operation, new TimeoutError(`${this.runtimeLabel} ${operation.phase === 'startup' ? 'startup' : operation.phase === 'compile' ? 'compilation' : 'execution'} timed out after ${timeoutMs} ms`, {
192
193
  phase: operation.phase,
193
194
  runtimeId: this.runtimeId,
194
195
  timeoutMs
@@ -347,6 +348,125 @@ class Python {
347
348
  this.pendingEof = true;
348
349
  this.flushPendingInput();
349
350
  }
351
+ /** Used by compilePython's dedicated instance; never runs source or resolves its imports. */
352
+ compile(code, options = {}) {
353
+ let operation;
354
+ try {
355
+ operation = this.beginOperation('compile');
356
+ }
357
+ catch (error) {
358
+ return Promise.reject(error);
359
+ }
360
+ let request;
361
+ const worker = this.worker;
362
+ try {
363
+ if (this.workerLanguage !== 'python') {
364
+ throw new RuntimeConfigurationError('Bytecode compilation is only available for Python');
365
+ }
366
+ request = resolvePythonCompileRequest(code, options);
367
+ options.signal?.throwIfAborted();
368
+ if (!worker)
369
+ throw new Error('Python worker not loaded');
370
+ this.assetBridge?.setExecutionPersistentCache(options.persistentCache);
371
+ }
372
+ catch (error) {
373
+ return Promise.reject(this.releaseBeforeSession(operation, error));
374
+ }
375
+ const { fileName, optimize, limits, invalidationMode, timestamp } = request;
376
+ const path = fileName.slice(0, -3) + '.pyc';
377
+ this.exit = false;
378
+ this.begin = Date.now();
379
+ let handler;
380
+ const compiling = new Promise((resolve, reject) => {
381
+ const workerOperation = this.workerSession.beginRun(worker, reject);
382
+ this.bindOperationTimeout(operation, limits.compileTimeoutMs);
383
+ this.bindAbortSignal(operation, options.signal);
384
+ if (!this.isOperationActive(operation))
385
+ return;
386
+ const finish = (result, error) => {
387
+ if (!this.isOperationActive(operation))
388
+ return;
389
+ this.workerSession.complete(workerOperation);
390
+ this.releaseOperation(operation);
391
+ this.cleanupOperation(operation);
392
+ if (result)
393
+ resolve(result);
394
+ else
395
+ reject(error);
396
+ };
397
+ handler = (event) => {
398
+ if (!this.isOperationActive(operation) || this.worker !== worker)
399
+ return;
400
+ try {
401
+ if (this.assetBridge?.handleMessage(event))
402
+ return;
403
+ reportWorkerProgress(options.progress, event.data?.progress);
404
+ if (!this.isOperationActive(operation))
405
+ return;
406
+ if (event.data?.error !== undefined) {
407
+ const outputLimit = event.data.outputLimit;
408
+ finish(undefined, outputLimit
409
+ ? new OutputLimitError(String(event.data.error), {
410
+ runtimeId: 'PYTHON3',
411
+ phase: 'compile',
412
+ actual: outputLimit.actual,
413
+ limit: outputLimit.limit
414
+ })
415
+ : event.data.error);
416
+ return;
417
+ }
418
+ if (event.data?.compiled === undefined)
419
+ return;
420
+ const result = event.data.compiled;
421
+ if (!result ||
422
+ result.path !== path ||
423
+ !(result.data instanceof Uint8Array) ||
424
+ result.data.byteLength < 16 ||
425
+ typeof result.pythonVersion !== 'string' ||
426
+ typeof result.cacheTag !== 'string' ||
427
+ typeof result.magicNumber !== 'string' ||
428
+ !/^[0-9a-f]{8}$/.test(result.magicNumber))
429
+ throw new Error('Invalid Python bytecode result');
430
+ if (result.data.byteLength > limits.maxOutputBytes) {
431
+ throw new OutputLimitError('Python bytecode exceeds the configured byte limit', {
432
+ runtimeId: 'PYTHON3',
433
+ phase: 'compile',
434
+ actual: result.data.byteLength,
435
+ limit: limits.maxOutputBytes
436
+ });
437
+ }
438
+ finish(result);
439
+ }
440
+ catch (error) {
441
+ this.cancelOperation(operation, error);
442
+ }
443
+ };
444
+ worker.onmessage = handler;
445
+ try {
446
+ worker.postMessage({
447
+ compile: true,
448
+ language: 'python',
449
+ code,
450
+ fileName,
451
+ optimize,
452
+ invalidationMode,
453
+ timestamp,
454
+ maxArtifactBytes: limits.maxOutputBytes
455
+ });
456
+ }
457
+ catch (error) {
458
+ finish(undefined, error);
459
+ }
460
+ });
461
+ return compiling.finally(() => {
462
+ this.releaseOperation(operation);
463
+ this.cleanupOperation(operation);
464
+ this.exit = true;
465
+ this.elapse = Date.now() - this.begin;
466
+ if (worker?.onmessage === handler)
467
+ worker.onmessage = null;
468
+ });
469
+ }
350
470
  flushPendingInput() {
351
471
  if (!this.waitingForInput)
352
472
  return;