@ttsc/wasm 0.14.0-dev.20260528.1 → 0.14.0-dev.20260529.1
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 +6 -21
- package/dist/ttsc.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,11 +39,7 @@ func main() {
|
|
|
39
39
|
}
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
The native sibling `main.go` is recommended when you want `go run ./cmd/your-wasm`
|
|
43
|
-
to smoke-test the same `host.Plugin` dispatchers without the browser MemFS
|
|
44
|
-
bridge. See `packages/wasm/cmd/ttsc-wasm/main.go` and
|
|
45
|
-
`website/compiler/cmd/playground/main.go` in the repo for reference layouts.
|
|
46
|
-
A minimal custom plugin dispatcher looks like this:
|
|
42
|
+
The native sibling `main.go` is recommended when you want `go run ./cmd/your-wasm` to smoke-test the same `host.Plugin` dispatchers without the browser MemFS bridge. See `packages/wasm/cmd/ttsc-wasm/main.go` and `website/compiler/cmd/playground/main.go` in the repo for reference layouts. A minimal custom plugin dispatcher looks like this:
|
|
47
43
|
|
|
48
44
|
```go
|
|
49
45
|
//go:build !js
|
|
@@ -81,11 +77,7 @@ GOOS=js GOARCH=wasm go build -trimpath -ldflags "-s -w" \
|
|
|
81
77
|
cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" public/wasm_exec.js
|
|
82
78
|
```
|
|
83
79
|
|
|
84
|
-
Keep `wasm_exec.js` from the same Go toolchain that built your wasm. The
|
|
85
|
-
prebuilt `dist/ttsc.wasm` and `dist/wasm_exec.js` pair already match each
|
|
86
|
-
other; custom binaries should copy the loader from their own toolchain. Older
|
|
87
|
-
Go installs may keep the loader under `$(go env GOROOT)/misc/wasm/wasm_exec.js`
|
|
88
|
-
instead of `lib/wasm`.
|
|
80
|
+
Keep `wasm_exec.js` from the same Go toolchain that built your wasm. The prebuilt `dist/ttsc.wasm` and `dist/wasm_exec.js` pair already match each other; custom binaries should copy the loader from their own toolchain. Older Go installs may keep the loader under `$(go env GOROOT)/misc/wasm/wasm_exec.js` instead of `lib/wasm`.
|
|
89
81
|
|
|
90
82
|
### Stamping version metadata at link time
|
|
91
83
|
|
|
@@ -116,10 +108,7 @@ const result = await api.build({ cwd: "/work" });
|
|
|
116
108
|
console.log(result.result); // JSON: { diagnostics, output }
|
|
117
109
|
```
|
|
118
110
|
|
|
119
|
-
Booting two wasms with the same `apiName` overwrites the previous global
|
|
120
|
-
binding; pick a unique `apiName` per binary. `bootTtsc` also installs shared
|
|
121
|
-
`fs` and `process` globals in its Worker, so use separate Workers when binaries
|
|
122
|
-
need independent filesystems.
|
|
111
|
+
Booting two wasms with the same `apiName` overwrites the previous global binding; pick a unique `apiName` per binary. `bootTtsc` also installs shared `fs` and `process` globals in its Worker, so use separate Workers when binaries need independent filesystems.
|
|
123
112
|
|
|
124
113
|
## Fountain API (snapshot, AST, type checker)
|
|
125
114
|
|
|
@@ -159,7 +148,7 @@ try {
|
|
|
159
148
|
Verbs and payload types:
|
|
160
149
|
|
|
161
150
|
| Verb | Payload type |
|
|
162
|
-
|
|
|
151
|
+
| --- | --- |
|
|
163
152
|
| `snapshot({ cwd, tsconfig? })` | `ITtscSnapshotResult` `{ handle }` |
|
|
164
153
|
| `releaseSnapshot({ handle })` | `ITtscReleaseSnapshotResult` `{ released }` |
|
|
165
154
|
| `snapshots()` | `ITtscSnapshotsResult` `{ handles }` |
|
|
@@ -170,13 +159,9 @@ Verbs and payload types:
|
|
|
170
159
|
| `getTypeAtPosition({ handle, path, position })` | `ITtscTypeAtPositionResult` `{ type }` |
|
|
171
160
|
| `getSymbolAtPosition({ handle, path, position })` | `ITtscSymbolAtPositionResult` `{ symbol }` |
|
|
172
161
|
|
|
173
|
-
`position` is a **byte offset** into the source text — the same coordinate
|
|
174
|
-
TypeScript-Go uses internally. JS callers that have a UTF-16 `(line,
|
|
175
|
-
character)` pair (e.g. from Monaco) must convert it before calling.
|
|
162
|
+
`position` is a **byte offset** into the source text — the same coordinate TypeScript-Go uses internally. JS callers that have a UTF-16 `(line, character)` pair (e.g. from Monaco) must convert it before calling.
|
|
176
163
|
|
|
177
|
-
**Lifecycle:** JS owns the handle. The wasm keeps the program (parsed AST,
|
|
178
|
-
checker pool lease, every source file) alive until you call
|
|
179
|
-
`releaseSnapshot`. Leaking handles leaks memory in the wasm linear heap.
|
|
164
|
+
**Lifecycle:** JS owns the handle. The wasm keeps the program (parsed AST, checker pool lease, every source file) alive until you call `releaseSnapshot`. Leaking handles leaks memory in the wasm linear heap.
|
|
180
165
|
|
|
181
166
|
## Plugin contract
|
|
182
167
|
|
package/dist/ttsc.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttsc/wasm",
|
|
3
|
-
"version": "0.14.0-dev.
|
|
3
|
+
"version": "0.14.0-dev.20260529.1",
|
|
4
4
|
"description": "Build in-browser ttsc playgrounds. Compose ttsc + typescript-go with your own plugins via the Go host helper.",
|
|
5
5
|
"main": "lib/src/index.js",
|
|
6
6
|
"types": "lib/src/index.d.ts",
|