OCaml evaluator for page dispatch + handler aser, 83/83 Playwright tests

Major architectural change: page function dispatch and handler execution
now go through the OCaml kernel instead of the Python bootstrapped evaluator.

OCaml integration:
- Page dispatch: bridge.eval() evaluates SX URL expressions (geography, marshes, etc.)
- Handler aser: bridge.aser() serializes handler responses as SX wire format
- _ensure_components loads all .sx files into OCaml kernel (spec, web adapter, handlers)
- defhandler/defpage registered as no-op special forms so handler files load
- helper IO primitive dispatches to Python page helpers + IO handlers
- ok-raw response format for SX wire format (no double-escaping)
- Natural list serialization in eval (no (list ...) wrapper)
- Clean pipe: _read_until_ok always sends io-response on error

SX adapter (aser):
- scope-emit!/scope-peek aliases to avoid CEK special form conflict
- aser-fragment/aser-call: strings starting with "(" pass through unserialized
- Registered cond-scheme?, is-else-clause?, primitive?, get-primitive in kernel
- random-int, parse-int as kernel primitives; json-encode, into via IO bridge

Handler migration:
- All IO calls converted to (helper "name" args...) pattern
- request-arg, request-form, state-get, state-set!, now, component-source etc.
- Fixed bare (effect ...) in island bodies leaking disposer functions as text
- Fixed lower-case → lower, ~search-results → ~examples/search-results

Reactive islands:
- sx-hydrate-islands called after client-side navigation swap
- force-dispose-islands-in for outerHTML swaps (clears hydration markers)
- clear-processed! platform primitive for re-hydration

Content restructuring:
- Design, event bridge, named stores, phase 2 consolidated into reactive overview
- Marshes split into overview + 5 example sub-pages
- Nav links use sx-get/sx-target for client-side navigation

Playwright test suite (sx/tests/test_demos.py):
- 83 tests covering hypermedia demos, reactive islands, marshes, spec explorer
- Server-side rendering, handler interactions, island hydration, navigation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-18 17:22:51 +00:00
parent 5b6e883e6d
commit 71c2003a60
33 changed files with 1848 additions and 852 deletions

View File

@@ -1,90 +1,10 @@
"""Documentation content for the sx docs site.
All page content as Python data structures, consumed by sx_components.py
to build s-expression page trees.
Data structures consumed by helpers.py for pages that need server-side data.
Navigation is defined in nav-data.sx (the single source of truth).
"""
from __future__ import annotations
# ---------------------------------------------------------------------------
# Navigation
# ---------------------------------------------------------------------------
DOCS_NAV = [
("Introduction", "/(language.(doc.introduction))"),
("Getting Started", "/(language.(doc.getting-started))"),
("Components", "/(language.(doc.components))"),
("Evaluator", "/(language.(doc.evaluator))"),
("Primitives", "/(language.(doc.primitives))"),
("CSS", "/(language.(doc.css))"),
("Server Rendering", "/(language.(doc.server-rendering))"),
]
REFERENCE_NAV = [
("Attributes", "/(geography.(hypermedia.(reference.attributes)))"),
("Headers", "/(geography.(hypermedia.(reference.headers)))"),
("Events", "/(geography.(hypermedia.(reference.events)))"),
("JS API", "/(geography.(hypermedia.(reference.js-api)))"),
]
PROTOCOLS_NAV = [
("Wire Format", "/(applications.(protocol.wire-format))"),
("Fragments", "/(applications.(protocol.fragments))"),
("Resolver I/O", "/(applications.(protocol.resolver-io))"),
("Internal Services", "/(applications.(protocol.internal-services))"),
("ActivityPub", "/(applications.(protocol.activitypub))"),
("Future", "/(applications.(protocol.future))"),
]
EXAMPLES_NAV = [
("Click to Load", "/(geography.(hypermedia.(example.click-to-load)))"),
("Form Submission", "/(geography.(hypermedia.(example.form-submission)))"),
("Polling", "/(geography.(hypermedia.(example.polling)))"),
("Delete Row", "/(geography.(hypermedia.(example.delete-row)))"),
("Inline Edit", "/(geography.(hypermedia.(example.inline-edit)))"),
("OOB Swaps", "/(geography.(hypermedia.(example.oob-swaps)))"),
("Lazy Loading", "/(geography.(hypermedia.(example.lazy-loading)))"),
("Infinite Scroll", "/(geography.(hypermedia.(example.infinite-scroll)))"),
("Progress Bar", "/(geography.(hypermedia.(example.progress-bar)))"),
("Active Search", "/(geography.(hypermedia.(example.active-search)))"),
("Inline Validation", "/(geography.(hypermedia.(example.inline-validation)))"),
("Value Select", "/(geography.(hypermedia.(example.value-select)))"),
("Reset on Submit", "/(geography.(hypermedia.(example.reset-on-submit)))"),
("Edit Row", "/(geography.(hypermedia.(example.edit-row)))"),
("Bulk Update", "/(geography.(hypermedia.(example.bulk-update)))"),
("Swap Positions", "/(geography.(hypermedia.(example.swap-positions)))"),
("Select Filter", "/(geography.(hypermedia.(example.select-filter)))"),
("Tabs", "/(geography.(hypermedia.(example.tabs)))"),
("Animations", "/(geography.(hypermedia.(example.animations)))"),
("Dialogs", "/(geography.(hypermedia.(example.dialogs)))"),
("Keyboard Shortcuts", "/(geography.(hypermedia.(example.keyboard-shortcuts)))"),
("PUT / PATCH", "/(geography.(hypermedia.(example.put-patch)))"),
("JSON Encoding", "/(geography.(hypermedia.(example.json-encoding)))"),
("Vals & Headers", "/(geography.(hypermedia.(example.vals-and-headers)))"),
("Loading States", "/(geography.(hypermedia.(example.loading-states)))"),
("Request Abort", "/(geography.(hypermedia.(example.sync-replace)))"),
("Retry", "/(geography.(hypermedia.(example.retry)))"),
]
ESSAYS_NAV = [
("sx sucks", "/(etc.(essay.sx-sucks))"),
("Why S-Expressions", "/(etc.(essay.why-sexps))"),
("The htmx/React Hybrid", "/(etc.(essay.htmx-react-hybrid))"),
("On-Demand CSS", "/(etc.(essay.on-demand-css))"),
("Client Reactivity", "/(etc.(essay.client-reactivity))"),
("SX Native", "/(etc.(essay.sx-native))"),
("The SX Manifesto", "/(etc.(philosophy.sx-manifesto))"),
("Tail-Call Optimization", "/(etc.(essay.tail-call-optimization))"),
("Continuations", "/(etc.(essay.continuations))"),
]
MAIN_NAV = [
("Docs", "/(language.(doc.introduction))"),
("Reference", "/(geography.(hypermedia.(reference)))"),
("Protocols", "/(applications.(protocol.wire-format))"),
("Examples", "/(geography.(hypermedia.(example.click-to-load)))"),
("Essays", "/(etc.(essay.sx-sucks))"),
]
# ---------------------------------------------------------------------------
# Reference: Attributes
# ---------------------------------------------------------------------------