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>
75 lines
2.9 KiB
Plaintext
75 lines
2.9 KiB
Plaintext
;; SX docs — documentation page components
|
|
|
|
(defcomp ~docs/page (&key title &rest children)
|
|
(div :class "max-w-4xl mx-auto px-6 pb-8 pt-4"
|
|
(div :class "prose prose-stone max-w-none space-y-6" children)))
|
|
|
|
(defcomp ~docs/section (&key title id &rest children)
|
|
(section :id id :class "space-y-4"
|
|
(h2 :class "text-2xl font-semibold text-stone-800" title)
|
|
children))
|
|
|
|
(defcomp ~docs/subsection (&key title &rest children)
|
|
(div :class "space-y-3"
|
|
(h3 :class "text-xl font-semibold text-stone-700" title)
|
|
children))
|
|
|
|
(defcomp ~docs/code (&key code)
|
|
(div :class "not-prose bg-stone-100 rounded-lg p-5 mx-auto max-w-3xl"
|
|
(pre :class "text-sm leading-relaxed whitespace-pre-wrap break-words" (code code))))
|
|
|
|
(defcomp ~docs/note (&key &rest children)
|
|
(div :class "border-l-4 border-violet-400 bg-violet-50 p-4 text-stone-700 text-sm"
|
|
children))
|
|
|
|
(defcomp ~docs/table (&key headers rows)
|
|
(div :class "overflow-x-auto rounded border border-stone-200"
|
|
(table :class "w-full text-left text-sm"
|
|
(thead
|
|
(tr :class "border-b border-stone-200 bg-stone-100"
|
|
(map (fn (h) (th :class "px-3 py-2 font-medium text-stone-600" h)) headers)))
|
|
(tbody
|
|
(map (fn (row)
|
|
(tr :class "border-b border-stone-100"
|
|
(map (fn (cell) (td :class "px-3 py-2 text-stone-700" cell)) row)))
|
|
rows)))))
|
|
|
|
(defcomp ~docs/attr-row (&key attr description exists href)
|
|
(tr :class "border-b border-stone-100"
|
|
(td :class "px-3 py-2 font-mono text-sm whitespace-nowrap"
|
|
(if href
|
|
(a :href href
|
|
:sx-get href :sx-target "#main-panel" :sx-select "#main-panel"
|
|
:sx-swap "outerHTML" :sx-push-url "true"
|
|
:class "text-violet-700 hover:text-violet-900 underline" attr)
|
|
(span :class "text-violet-700" attr)))
|
|
(td :class "px-3 py-2 text-stone-700 text-sm" description)
|
|
(td :class "px-3 py-2 text-center"
|
|
(if exists
|
|
(span :class "text-emerald-600 text-sm" "yes")
|
|
(span :class "text-stone-400 text-sm italic" "not yet")))))
|
|
|
|
(defcomp ~docs/primitives-table (&key category primitives)
|
|
(div :class "space-y-2"
|
|
(h4 :class "text-lg font-semibold text-stone-700" category)
|
|
(div :class "flex flex-wrap gap-2"
|
|
(map (fn (p)
|
|
(span :class "inline-block px-2 py-1 rounded bg-stone-100 font-mono text-sm text-stone-700" p))
|
|
primitives))))
|
|
|
|
(defcomp ~docs/nav (&key items current)
|
|
(nav :class "flex flex-wrap gap-2 mb-8"
|
|
(map (fn (item)
|
|
(a :href (nth item 1)
|
|
:sx-get (nth item 1)
|
|
:sx-target "#main-panel"
|
|
:sx-select "#main-panel"
|
|
:sx-swap "outerHTML"
|
|
:sx-push-url "true"
|
|
:class (str "px-3 py-1.5 rounded text-sm font-medium no-underline "
|
|
(if (= (nth item 0) current)
|
|
"bg-violet-100 text-violet-800"
|
|
"bg-stone-100 text-stone-600 hover:bg-stone-200"))
|
|
(nth item 0)))
|
|
items)))
|