blob: 339509d2820d93d19f7b0c738dd063f40628da3f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# DOM web backend
The web backend keeps the existing Pardes core and replaces the old
Emscripten/SDL/WebGL shell. Zig produces a `wasm32-freestanding` module with no
imports. Vanilla JavaScript owns `requestAnimationFrame`, browser input, window
sizing, and effect/IO dispatch; HTML and CSS render selectable, accessible text.
There is no canvas.
The default web build links Tree-sitter's C runtime and the Zig grammar inside
that same import-free module. A small freestanding compatibility layer supplies
the C ABI locally, so source panes retain the core's Tree-sitter highlighting
without Emscripten, WASI, or browser libc imports. Other grammar tiers remain
selectable with `-Dtree-sitter=minimal` or `-Dtree-sitter=full`.
`src/web.zig` is the narrow WASM ABI. Events enter through exported functions,
and `pardes_frame` writes the canonical `Surface` into a packed 20-byte cell
array. `src/web/app.mjs` reads that array in one linear pass and patches stable
DOM nodes. Core effects become browser operations (links, downloads, clipboard)
or `pardes-io` custom events for a process-capable embedding host.
Build a replay from a dump:
```sh
zig build web \
-Dplatform=web \
-Dtarget=wasm32-freestanding \
-Dtree-sitter=zig \
-Ddump=test/web-snapshots/source-list.dump.zon
```
The output is in `zig-out/web`. Serve that directory over HTTP; browsers do not
allow a useful WASM module load from `file:` URLs.
Two dependency-free test layers cover the boundary:
```sh
# Real WASM in Node plus a small DOM double.
zig build web-harness \
-Dplatform=web \
-Dtarget=wasm32-freestanding \
-Dtree-sitter=zig \
-Ddump=test/web-snapshots/source-list.dump.zon
# Real headless Chrome, DOM rendering, and browser touch input.
zig build web-e2e
```
Set `PARDES_CHROME` when Chrome/Chromium is not on `PATH` or in a normal
Playwright/Puppeteer cache.
|