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 +42 -32
- package/dist/clang/gccCompat.d.ts +15 -0
- package/dist/clang/gccCompat.js +767 -0
- package/dist/clang/index.js +5 -1
- package/dist/clang/url.d.ts +4 -4
- package/dist/clang/url.js +5 -4
- package/dist/clangd/session.d.ts +5 -1
- package/dist/clangd/session.js +21 -3
- package/dist/clangd/worker.js +31 -46
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lsp/cpp/server.js +16 -5
- package/dist/lsp/index.d.ts +1 -1
- package/dist/lsp/index.js +1 -1
- package/dist/lsp/runtime.d.ts +2 -0
- package/dist/lsp/runtime.js +9 -8
- package/dist/lsp/types.d.ts +2 -0
- package/dist/playground/assetBridge.js +8 -2
- package/dist/playground/assets.d.ts +5 -1
- package/dist/playground/assets.js +88 -47
- package/dist/playground/clang.d.ts +4 -2
- package/dist/playground/clang.js +35 -4
- package/dist/playground/ocaml.js +2 -0
- package/dist/playground/options.d.ts +4 -0
- package/dist/playground/tinygo.d.ts +4 -1
- package/dist/playground/tinygo.js +11 -6
- package/dist/playground/wasmOcamlVersion.d.ts +1 -1
- package/dist/playground/wasmOcamlVersion.js +1 -1
- package/dist/playground/wasmTinyGoVersion.d.ts +1 -1
- package/dist/playground/wasmTinyGoVersion.js +1 -1
- package/dist/playground/worker/clang.js +7 -2
- package/dist/playground/worker/ocaml.js +5 -4
- package/dist/terminal/Terminal.svelte +4 -0
- package/package.json +1 -1
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
52
|
-
still lives inside `wasm-tinygo`; `wasm-idle`
|
|
53
|
-
directly,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
and runs
|
|
57
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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;
|