wasm-idle 0.7.1 → 0.7.2

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
@@ -33,10 +33,10 @@ storage.
33
33
 
34
34
  The demo app can also vendor the sibling `wasm-tinygo` browser build under `static/wasm-tinygo/`
35
35
  and load its `runtime.js` entry directly inside the TinyGo playground sandbox. The example page
36
- only auto-discovers a host-assisted `/api/tinygo/compile` endpoint when the browser itself is
37
- running on `localhost` during `vite dev` / `vite preview`. Non-local and static deployments do not
38
- probe that path implicitly anymore; set `PUBLIC_WASM_TINYGO_HOST_COMPILE_URL` or
39
- `runtimeAssets.tinygo.hostCompileUrl` explicitly if you want to use a real TinyGo compile service.
36
+ uses the bundled browser runtime by default, including on `localhost` during `vite dev` /
37
+ `vite preview`. Set `PUBLIC_WASM_TINYGO_HOST_COMPILE_URL` or
38
+ `runtimeAssets.tinygo.hostCompileUrl` explicitly, or open the example page with
39
+ `?tinygoCompilePath=host`, if you want to use a real TinyGo compile service.
40
40
  Refresh the
41
41
  bundled runtime assets after rebuilding the sibling `wasm-tinygo` project with:
42
42
 
@@ -48,13 +48,16 @@ cd ../wasm-idle
48
48
  pnpm run sync:wasm-tinygo
49
49
  ```
50
50
 
51
- TinyGo currently exposes a single `wasm` target through the example page. The browser pipeline
52
- still lives inside `wasm-tinygo`; `wasm-idle` now imports its reusable `runtime.js` library entry
53
- directly, then runs the emitted artifact with browser WASI so terminal stdin/EOF behavior stays
54
- consistent with the other runtimes. When host compile is unavailable, the bundled browser fallback
55
- now loads the vendored TinyGo runtime in `direct` mode, skips the old bootstrap-only compile step,
56
- and runs the resulting WASI artifact locally. A host compile service is still useful when you want
57
- an explicit remote compile seam or broader compatibility than the shipped browser bundle.
51
+ TinyGo exposes `wasm`, `wasip1`, `wasip2`, and `wasip3` targets through the example page. The
52
+ browser pipeline still lives inside `wasm-tinygo`; `wasm-idle` imports its reusable `runtime.js`
53
+ library entry directly, forwards the selected target into the build request, then runs the emitted
54
+ artifact with browser WASI so terminal stdin/EOF behavior stays consistent with the other runtimes.
55
+ The default bundled browser path loads the vendored TinyGo runtime in `direct` mode, skips the old
56
+ bootstrap-only compile step, and runs runnable WASI artifacts locally. The `wasip2` and `wasip3`
57
+ entries use the preview target profiles shipped by the bundled `wasm-tinygo` runtime, so they may
58
+ produce non-runnable preview artifacts until the matching execution path is available. A host
59
+ compile service is still useful when you want an explicit remote compile seam or broader
60
+ compatibility than the shipped browser bundle.
58
61
 
59
62
  ## Browser regression commands
60
63
 
@@ -95,7 +98,8 @@ The browser helper writes stdin through the page-owned `window.__wasmIdleDebug.w
95
98
  hook instead of trying to click xterm's hidden helper textarea, which proved too flaky for repeatable
96
99
  Playwright runs.
97
100
  The TinyGo probe follows the same pattern. The host-assisted path still looks for
98
- `tinygo host compile ready: target=wasip1`, while the browser-only path should load the vendored
101
+ `tinygo host compile ready: target=wasip1` when you opt into `?tinygoCompilePath=host`, while the
102
+ default browser path should load the vendored
99
103
  runtime in `direct` mode and avoid the old bootstrap compile command altogether.
100
104
  The TinyGo browser commands currently default to `vite dev`.
101
105
  If Rust ever reports `invalid metadata files for crate core` or `Unsupported archive identifier`,
@@ -119,7 +123,7 @@ Rust still supports an external browser compiler module for library consumers. P
119
123
  TinyGo can use a host compile service when one is configured explicitly. Point
120
124
  `PUBLIC_WASM_TINYGO_HOST_COMPILE_URL` at an endpoint that accepts `POST { source }` and returns the
121
125
  compiled wasm artifact payload, or pass `runtimeAssets.tinygo.hostCompileUrl` at runtime. The
122
- bundled browser fallback still expects a browser-loadable `wasm-tinygo` runtime module. Point
126
+ bundled browser runtime still expects a browser-loadable `wasm-tinygo` runtime module. Point
123
127
  `PUBLIC_WASM_TINYGO_MODULE_URL` at a built entry such as `.../wasm-tinygo/dist/runtime.js`, or
124
128
  pass `runtimeAssets.tinygo.moduleUrl` at runtime. The older `PUBLIC_WASM_TINYGO_APP_URL` /
125
129
  `runtimeAssets.tinygo.appUrl` document path is still accepted and normalized to `runtime.js`.
@@ -146,6 +150,12 @@ const runtimeAssets: PlaygroundRuntimeAssets = {
146
150
  java: {
147
151
  baseUrl: 'https://cdn.example.com/repl/teavm/'
148
152
  },
153
+ clang: {
154
+ loader: async ({ asset }) => ({ url: `https://cdn.example.com/repl/clang/${asset}` })
155
+ },
156
+ clangd: {
157
+ loader: async ({ asset }) => ({ url: `https://cdn.example.com/repl/clangd/${asset}` })
158
+ },
149
159
  rust: {
150
160
  compilerUrl: 'https://cdn.example.com/wasm-rust/index.js'
151
161
  },
@@ -156,31 +166,31 @@ const runtimeAssets: PlaygroundRuntimeAssets = {
156
166
  };
157
167
  ```
158
168
 
159
- Python custom loaders receive file names under the Pyodide asset root and can serve both core assets and package files. TeaVM custom loaders receive file names under the TeaVM asset root. Rust expects a browser-loadable compiler module URL; that module is responsible for serving its own nested runtime assets. TinyGo can use either an explicit host compile URL or a browser-loadable runtime module. The browser runtime now ships a direct-mode fallback that can produce and run the bundled TinyGo WASI artifact locally, alongside its sibling `tools/go-probe.wasm` and vendored emception assets. A host compile service remains useful when you want a dedicated remote compile seam or compatibility beyond the shipped browser bundle. TinyGo also accepts a runtime asset loader + pack bundle in `runtimeAssets.tinygo` when you need to serve runtime assets out of a single compressed archive. Compressed TeaVM runtime assets are no longer unpacked inside the library; provide the final file URL or handle decompression in your own loader.
169
+ Python custom loaders receive file names under the Pyodide asset root and can serve both core assets and package files. TeaVM custom loaders receive file names under the TeaVM asset root. Clang custom loaders receive `bin/memfs.zip`, `bin/clang.zip`, `bin/lld.zip`, and `bin/sysroot.tar.zip`; clangd custom loaders receive `clangd.js` and `clangd.wasm.gz`, with the worker decompressing the gzip payload before instantiation. Rust expects a browser-loadable compiler module URL; that module is responsible for serving its own nested runtime assets. TinyGo can use either an explicit host compile URL or a browser-loadable runtime module. The browser runtime now ships a direct-mode execution path that can produce and run the bundled TinyGo WASI artifact locally, alongside its sibling `tools/go-probe.wasm` and vendored emception assets. A host compile service remains useful when you want a dedicated remote compile seam or compatibility beyond the shipped browser bundle. TinyGo also accepts a runtime asset loader + pack bundle in `runtimeAssets.tinygo` when you need to serve runtime assets out of a single compressed archive. Compressed TeaVM runtime assets are no longer unpacked inside the library; provide the final file URL or handle decompression in your own loader.
160
170
 
161
171
  If you want a host app to reuse the same runtime asset configuration for both `<Terminal>` and direct `playground(...)` access, bind it once:
162
172
 
163
173
  ```ts
164
174
  import Terminal, { createPlaygroundBinding } from 'wasm-idle';
165
175
 
166
- const wasmIdle = createPlaygroundBinding({
167
- rootUrl: 'https://cdn.example.com/repl',
168
- rust: {
169
- compilerUrl: 'https://cdn.example.com/wasm-rust/index.js'
170
- },
171
- tinygo: {
172
- hostCompileUrl: 'https://tinygo.example.com/api/compile',
173
- moduleUrl: 'https://cdn.example.com/wasm-tinygo/runtime.js',
174
- assetPacks: [
175
- {
176
- index: 'https://cdn.example.com/wasm-tinygo/runtime-pack/runtime-pack.index.json',
177
- asset: 'https://cdn.example.com/wasm-tinygo/runtime-pack/runtime-pack.bin',
178
- fileCount: 12,
179
- totalBytes: 123456
180
- }
181
- ]
182
- }
183
- });
176
+ const wasmIdle = createPlaygroundBinding({
177
+ rootUrl: 'https://cdn.example.com/repl',
178
+ rust: {
179
+ compilerUrl: 'https://cdn.example.com/wasm-rust/index.js'
180
+ },
181
+ tinygo: {
182
+ hostCompileUrl: 'https://tinygo.example.com/api/compile',
183
+ moduleUrl: 'https://cdn.example.com/wasm-tinygo/runtime.js',
184
+ assetPacks: [
185
+ {
186
+ index: 'https://cdn.example.com/wasm-tinygo/runtime-pack/runtime-pack.index.json',
187
+ asset: 'https://cdn.example.com/wasm-tinygo/runtime-pack/runtime-pack.bin',
188
+ fileCount: 12,
189
+ totalBytes: 123456
190
+ }
191
+ ]
192
+ }
193
+ });
184
194
 
185
195
  const sandbox = await wasmIdle.load('PYTHON');
186
196
  await sandbox.load('print("hi")', false);
@@ -0,0 +1,15 @@
1
+ export interface GccCompatibilityMemFs {
2
+ addDirectory(path: string): void;
3
+ addFile(path: string, contents: string): void;
4
+ }
5
+ export interface GccCompatibilityWriteFs {
6
+ mkdirTree(path: string): void;
7
+ writeFile(path: string, contents: string): void;
8
+ }
9
+ export interface GccCompatibilityHeader {
10
+ path: string;
11
+ contents: string;
12
+ }
13
+ export declare const GCC_COMPATIBILITY_HEADERS: GccCompatibilityHeader[];
14
+ export declare function installGccCompatibilityHeaders(memfs: GccCompatibilityMemFs): void;
15
+ export declare function writeGccCompatibilityHeaders(fs: GccCompatibilityWriteFs, root?: string): void;