@ttsc/wasm 0.14.0-dev.20260528.1 → 0.14.0-dev.20260529.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 +11 -26
- package/dist/ttsc.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ In-browser ttsc playground scaffolding. Compose ttsc + typescript-go with your o
|
|
|
6
6
|
|
|
7
7
|
## What you get
|
|
8
8
|
|
|
9
|
-
- A base `ttsc.wasm` (under `dist/`) that exposes vanilla `build` / `check` / `transform
|
|
9
|
+
- A base `ttsc.wasm` (under `dist/`) that exposes vanilla `build` / `check` / `transform`, no plugins linked. Useful as a sanity test or a no-plugin baseline.
|
|
10
10
|
- A Go helper package (`host/`) plugin authors import from their own `main_wasm.go` to bind a wasm to `globalThis[yourApiName]`.
|
|
11
11
|
- A JS runtime (`bootTtsc`, `createMemFS`, typed `ITtscApi` surface) that loads any host-built wasm into a Web Worker.
|
|
12
12
|
|
|
@@ -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
|
|
|
@@ -99,7 +91,7 @@ GOOS=js GOARCH=wasm go build -trimpath \
|
|
|
99
91
|
|
|
100
92
|
The `version`, `commit`, and `date` variables in `host/host.go` are all overridable. `globalThis[apiName].version()` reads from them.
|
|
101
93
|
|
|
102
|
-
4. Boot it from JS (a Web Worker is **required
|
|
94
|
+
4. Boot it from JS (a Web Worker is **required**: Go's `syscall/js` blocks the runtime while the wasm is alive; running on the main thread freezes the page). Use a classic Worker or a bundler target that still exposes `importScripts`; `bootTtsc` imports `wasm_exec.js` before starting Go.
|
|
103
95
|
|
|
104
96
|
```ts
|
|
105
97
|
import { bootTtsc } from "@ttsc/wasm";
|
|
@@ -116,14 +108,11 @@ 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
|
|
|
126
|
-
For embedders that want `embed-typescript`-style raw access to the program
|
|
115
|
+
For embedders that want `embed-typescript`-style raw access to the program, diagnostics, AST nodes, the type checker at a position. The same `globalThis[apiName]` object also exposes fountain verbs. They share the standard `{code, stdout, stderr, result}` envelope; `result` is JSON.
|
|
127
116
|
|
|
128
117
|
```ts
|
|
129
118
|
import { bootTtsc, parseResult } from "@ttsc/wasm";
|
|
@@ -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
|
|
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
|
|
|
@@ -189,7 +174,7 @@ type Plugin interface {
|
|
|
189
174
|
}
|
|
190
175
|
```
|
|
191
176
|
|
|
192
|
-
The host installs `globalThis[apiName].plugin({ name, command, ...opts })` that translates the JS options object into a CLI-shaped argv and calls your plugin's `Run`. Your `Run` body can forward to the same function the native sidecar's `main.go` calls
|
|
177
|
+
The host installs `globalThis[apiName].plugin({ name, command, ...opts })` that translates the JS options object into a CLI-shaped argv and calls your plugin's `Run`. Your `Run` body can forward to the same function the native sidecar's `main.go` calls, for example `utility.RunBuild(args)` for plugins backed by `packages/ttsc/utility`.
|
|
193
178
|
|
|
194
179
|
## Published-tarball Go module layout
|
|
195
180
|
|
|
@@ -197,7 +182,7 @@ The published `@ttsc/wasm` tarball ships:
|
|
|
197
182
|
|
|
198
183
|
- A rewritten root `go.mod` whose `replace` directives point at `./shim-vendor/shim/*` (vendored at pack time from `packages/ttsc/shim/`).
|
|
199
184
|
- The full `host/`, `cmd/`, `build/` Go source so consumers can `go build -tags '...'` their own wasm against your host helper.
|
|
200
|
-
- `dist/ttsc.wasm` + `dist/wasm_exec.js
|
|
185
|
+
- `dist/ttsc.wasm` + `dist/wasm_exec.js`: the no-plugin sanity binary and the Go runtime loader.
|
|
201
186
|
|
|
202
187
|
The tarball intentionally drops the `replace github.com/samchon/ttsc/packages/ttsc => ../ttsc` directive that the in-repo `go.mod` carries: consumers of the published module who want to rebuild the wasm must supply their own `replace` (or vendor `packages/ttsc` themselves). The published `dist/ttsc.wasm` is plug-and-play for runtime use; the Go module is for **plugin authors extending the host**, not for vanilla consumers.
|
|
203
188
|
|
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.2",
|
|
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",
|