@swifttui/web 0.0.27 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +58 -43
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,10 +1,26 @@
1
1
  # `@swifttui/web`
2
2
 
3
- Browser runtime package for SwiftTUI apps.
3
+ **Browser runtime for [SwiftTUI](https://swifttui.sh) apps — draw a
4
+ Swift-authored UI into a `<canvas>`, no terminal emulator.**
4
5
 
5
- This package owns browser-safe runtime APIs: scene manifest loading, canvas
6
- rendering, ARIA mounting, WebSocket scene bridges, and WASI scene bridges. Build
7
- tooling lives in the sibling [`@swifttui/build`](../build) workspace package.
6
+ [![npm](https://img.shields.io/npm/v/@swifttui/web)](https://www.npmjs.com/package/@swifttui/web)
7
+ ![License](https://img.shields.io/badge/license-MIT-3DA639)
8
+
9
+ `@swifttui/web` is the browser host for SwiftTUI. A SwiftTUI app compiles to
10
+ `wasm32-wasi` and streams a structured raster surface on stdout; this package
11
+ loads the scene manifest, renders that surface into a canvas, mounts an ARIA
12
+ tree for accessibility, and bridges input back to the running app — so the same
13
+ view code you run in a terminal runs on a web page. It does not load a terminal
14
+ emulator.
15
+
16
+ The build side — compiling your Swift app to wasm and capturing its manifest —
17
+ lives in the sibling
18
+ [`@swifttui/build`](https://www.npmjs.com/package/@swifttui/build) package.
19
+
20
+ - **Live demo:** <https://swifttui.sh/webexample>
21
+ - **Reference template:** [`swift-tui-examples/WebExample`](https://github.com/SwiftTUI/swift-tui-examples/tree/main/WebExample)
22
+ (≈60 lines of embedding code)
23
+ - **The framework:** [`SwiftTUI/swift-tui`](https://github.com/SwiftTUI/swift-tui)
8
24
 
9
25
  ## Installation
10
26
 
@@ -20,36 +36,6 @@ does **not** require Bun or a TypeScript build step. Subpath entrypoints
20
36
  (`./wasi`, `./wasi-worker`, `./manifest`, `./websocket`, `./testing`) and the
21
37
  `./style.css` asset are declared in `package.json` `exports`.
22
38
 
23
- ## Toolchains
24
-
25
- Use Bun for repo-local development of this package, and use the repo-default
26
- `swiftly` Swift 6.3.1 toolchain for every Swift command that the build pipeline
27
- triggers.
28
-
29
- Quick check:
30
-
31
- ```bash
32
- swiftly run swift --version
33
- ```
34
-
35
- Native-only development should also work in Xcode, but the documented package
36
- and wasm build path uses `swiftly` plus Bun.
37
-
38
- For source development, run `bun install` from the repo root or from any
39
- workspace package directory, and Bun will maintain one root `bun.lock` plus
40
- stable relative workspace links.
41
-
42
- ## Surface Transport
43
-
44
- This package uses SwiftTUI's `web-surface` WASI transport. The Swift runner
45
- emits structured raster-surface records on stdout, and the browser host draws
46
- rectangles and text into a canvas. It does not load a terminal emulator and does
47
- not depend on `ghostty-web` or `ghostty-vt.wasm`.
48
-
49
- `web-surface` is the default `SwiftTUIWASI` browser transport. WebHost still
50
- sets `TUIGUI_TRANSPORT=surface` explicitly so generated app environments are
51
- self-describing.
52
-
53
39
  ## API
54
40
 
55
41
  ```ts
@@ -93,7 +79,42 @@ import { startWasmSceneWorker } from "@swifttui/web/wasi-worker";
93
79
  startWasmSceneWorker();
94
80
  ```
95
81
 
96
- ## Scripts
82
+ The page that hosts the WASI runtime must serve
83
+ `Cross-Origin-Opener-Policy: same-origin` and
84
+ `Cross-Origin-Embedder-Policy: require-corp` so the `SharedArrayBuffer`-backed
85
+ stdin works.
86
+
87
+ ## Surface transport
88
+
89
+ This package uses SwiftTUI's `web-surface` WASI transport. The Swift runner
90
+ emits structured raster-surface records on stdout, and the browser host draws
91
+ rectangles and text into a canvas. It does not load a terminal emulator and does
92
+ not depend on `ghostty-web` or `ghostty-vt.wasm`.
93
+
94
+ `web-surface` is the default `SwiftTUIWASI` browser transport. WebHost still
95
+ sets `TUIGUI_TRANSPORT=surface` explicitly so generated app environments are
96
+ self-describing.
97
+
98
+ ## Notes
99
+
100
+ - Scene switching is controller-managed and retains existing scene runtimes.
101
+ - Terminal styling is host-owned through `WebHostTerminalStyle`, which carries
102
+ one active palette/theme pair plus the runtime payload sent into SwiftTUI.
103
+ - Hosts that want multiple themes swap entire `WebHostTerminalStyle` objects;
104
+ the library does not provide a built-in mode switcher.
105
+ - `BrowserWASIBridge` sets `TUIGUI_TRANSPORT=surface` and decodes surface
106
+ frames before handing them to the canvas runtime.
107
+
108
+ ## Developing this package
109
+
110
+ > Only needed if you are working **on** `@swifttui/web` itself. Consuming the
111
+ > package from an app needs only `npm install` (above) — not Bun or the Swift
112
+ > toolchain.
113
+
114
+ Use Bun for repo-local development, and the repo-default `swiftly` Swift 6.3.1
115
+ toolchain for any Swift command the build pipeline triggers
116
+ (`swiftly run swift --version`). Run `bun install` from the repo root or any
117
+ workspace package directory; Bun maintains one root `bun.lock`.
97
118
 
98
119
  - `bun test`
99
120
  - `bun run build` — compile the publishable package to `dist/` with tsdown
@@ -119,12 +140,6 @@ The demo/app build flow is intentionally small:
119
140
  artifact only if stripping still produces browser-parseable wasm.
120
141
  3. `build:web` bundles `index.html` and the browser entrypoint with Bun.
121
142
 
122
- ## Notes
143
+ ## License
123
144
 
124
- - Scene switching is controller-managed and retains existing scene runtimes.
125
- - Terminal styling is host-owned through `WebHostTerminalStyle`, which carries
126
- one active palette/theme pair plus the runtime payload sent into SwiftTUI.
127
- - Hosts that want multiple themes swap entire `WebHostTerminalStyle` objects;
128
- the library does not provide a built-in mode switcher.
129
- - `BrowserWASIBridge` sets `TUIGUI_TRANSPORT=surface` and decodes surface
130
- frames before handing them to the canvas runtime.
145
+ MIT see [LICENSE](LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swifttui/web",
3
- "version": "0.0.27",
3
+ "version": "0.1.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,