summaryrefslogtreecommitdiff
path: root/docs/web.md
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-08-01 22:44:19 -0300
committerGabriel Schneider <[email protected]>2026-08-10 09:17:07 -0300
commitd59397d4146ffa23adbbe6dc99c64ebb22a93b2d (patch)
treea06984bf172a6c894c1586d58aad02ec302b6c2d /docs/web.md
parentcbcdf01764e2e144a821643c3a8e9a5ad39eda2e (diff)
downloadpardes-d59397d4146ffa23adbbe6dc99c64ebb22a93b2d.tar.gz
pardes-d59397d4146ffa23adbbe6dc99c64ebb22a93b2d.zip
add vanilla DOM web backend
Diffstat (limited to 'docs/web.md')
-rw-r--r--docs/web.md49
1 files changed, 49 insertions, 0 deletions
diff --git a/docs/web.md b/docs/web.md
new file mode 100644
index 00000000..339509d2
--- /dev/null
+++ b/docs/web.md
@@ -0,0 +1,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.