Files
rose-ash/shared/sx/templates/client-libs/page-functions.sx
giles d40a9c6796 sx-tools: WASM kernel updates, TW/CSSX rework, content refresh, new debugging tools
Build tooling: updated OCaml bootstrapper, compile-modules, bundle.sh, sx-build-all.
WASM browser: rebuilt sx_browser.bc.js/wasm, sx-platform-2.js, .sxbc bytecode files.
CSSX/Tailwind: reworked cssx.sx templates and tw-layout, added tw-type support.
Content: refreshed essays, plans, geography, reactive islands, docs, demos, handlers.
New tools: bisect_sxbc.sh, test-spa.js, render-trace.sx, morph playwright spec.
Tests: added test-match.sx, test-examples.sx, updated test-tw.sx and web tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 11:31:57 +00:00

679 lines
23 KiB
Plaintext

(define
slug->component
(fn
(slug prefix infix suffix)
(if
infix
(make-symbol (str prefix slug infix slug suffix))
(make-symbol (str prefix slug suffix)))))
(define
make-page-fn
(fn
(default-name prefix infix suffix)
(fn
(slug)
(if
(nil? slug)
(list (make-symbol default-name))
(list (slug->component slug prefix infix suffix))))))
(define
home
(fn
(content)
(if (nil? content) (quote (~docs-content/home-content)) content)))
(define language (fn (content) (if (nil? content) nil content)))
(define
geography
(fn
(content)
(if (nil? content) (quote (~geography/index-content)) content)))
(define applications (fn (content) (if (nil? content) nil content)))
(define etc (fn (content) (if (nil? content) nil content)))
(define hypermedia (fn (content) (if (nil? content) nil content)))
(define
reactive
(fn
(content)
(if
(nil? content)
(quote (~reactive-islands/index/reactive-islands-index-content))
content)))
(define
examples
(make-page-fn
"~reactive-islands/demo/reactive-islands-demo-content"
"~reactive-islands/demo/example-"
nil
""))
(define
cek
(fn
(slug)
(if
(nil? slug)
(quote (~geography/cek/cek-content))
(case
slug
"demo"
(quote (~geography/cek/cek-demo-content))
"freeze"
(quote (~geography/cek/cek-freeze-content))
"content"
(quote (~geography/cek/cek-content-address-content))
:else (quote (~geography/cek/cek-content))))))
(define
provide
(fn
(content)
(if (nil? content) (quote (~geography/provide-content)) content)))
(define
scopes
(fn
(content)
(if (nil? content) (quote (~geography/scopes-content)) content)))
(define
spreads
(fn
(content)
(if (nil? content) (quote (~geography/spreads-content)) content)))
(define
marshes
(fn
(slug)
(if
(nil? slug)
(quote (~reactive-islands/marshes/reactive-islands-marshes-content))
(case
slug
"hypermedia-feeds"
(quote (~reactive-islands/marshes/example-hypermedia-feeds))
"server-signals"
(quote (~reactive-islands/marshes/example-server-signals))
"on-settle"
(quote (~reactive-islands/marshes/example-on-settle))
"signal-triggers"
(quote (~reactive-islands/marshes/example-signal-triggers))
"view-transform"
(quote (~reactive-islands/marshes/example-view-transform))
:else (quote (~reactive-islands/marshes/reactive-islands-marshes-content))))))
(define
isomorphism
(fn
(slug)
(if
(nil? slug)
(quote (~plans/isomorphic/plan-isomorphic-content))
(case
slug
"bundle-analyzer"
(let
((data (helper "bundle-analyzer-data")))
(quasiquote
(~analyzer/bundle-analyzer-content
:pages (unquote (get data "pages"))
:total-components (unquote (get data "total-components"))
:total-macros (unquote (get data "total-macros"))
:pure-count (unquote (get data "pure-count"))
:io-count (unquote (get data "io-count")))))
"routing-analyzer"
(let
((data (helper "routing-analyzer-data")))
(quasiquote
(~routing-analyzer/content
:pages (unquote (get data "pages"))
:total-pages (unquote (get data "total-pages"))
:client-count (unquote (get data "client-count"))
:server-count (unquote (get data "server-count"))
:registry-sample (unquote (get data "registry-sample")))))
"data-test"
(let
((data (helper "data-test-data")))
(quasiquote
(~data-test/content
:server-time (unquote (get data "server-time"))
:items (unquote (get data "items"))
:phase (unquote (get data "phase"))
:transport (unquote (get data "transport")))))
"async-io"
(quote (~async-io-demo/content))
"affinity"
(let
((data (helper "affinity-demo-data")))
(quasiquote
(~affinity-demo/content
:components (unquote (get data "components"))
:page-plans (unquote (get data "page-plans")))))
"optimistic"
(let
((data (helper "optimistic-demo-data")))
(quasiquote
(~optimistic-demo/content
:items (unquote (get data "items"))
:server-time (unquote (get data "server-time")))))
"offline"
(let
((data (helper "offline-demo-data")))
(quasiquote
(~offline-demo/content
:notes (unquote (get data "notes"))
:server-time (unquote (get data "server-time")))))
:else (quote (~plans/isomorphic/plan-isomorphic-content))))))
(define
doc
(fn
(slug)
(if
(nil? slug)
(quote (~docs-content/docs-introduction-content))
(case
slug
"introduction"
(quote (~docs-content/docs-introduction-content))
"getting-started"
(quote (~docs-content/docs-getting-started-content))
"components"
(quote (~docs-content/docs-components-content))
"evaluator"
(quote (~docs-content/docs-evaluator-content))
"primitives"
(let
((data (helper "primitives-data")))
(quasiquote
(~docs-content/docs-primitives-content
:prims (~docs/primitives-tables :primitives (unquote data)))))
"special-forms"
(let
((data (helper "special-forms-data")))
(quasiquote
(~docs-content/docs-special-forms-content
:forms (~docs/special-forms-tables :forms (unquote data)))))
"server-rendering"
(quote (~docs-content/docs-server-rendering-content))
:else (quote (~docs-content/docs-introduction-content))))))
(define
spec
(fn
(slug)
(if
(nil? slug)
(quote (~specs/architecture-content))
(case
slug
"core"
(let
((files (make-spec-files core-spec-items)))
(quasiquote
(~specs/overview-content
:spec-title "Core Language"
:spec-files (unquote files))))
"adapters"
(let
((files (make-spec-files adapter-spec-items)))
(quasiquote
(~specs/overview-content
:spec-title "Adapters"
:spec-files (unquote files))))
"browser"
(let
((files (make-spec-files browser-spec-items)))
(quasiquote
(~specs/overview-content
:spec-title "Browser Runtime"
:spec-files (unquote files))))
"reactive"
(let
((files (make-spec-files reactive-spec-items)))
(quasiquote
(~specs/overview-content
:spec-title "Reactive System"
:spec-files (unquote files))))
"host"
(let
((files (make-spec-files host-spec-items)))
(quasiquote
(~specs/overview-content
:spec-title "Host Interface"
:spec-files (unquote files))))
"extensions"
(let
((files (make-spec-files extension-spec-items)))
(quasiquote
(~specs/overview-content
:spec-title "Extensions"
:spec-files (unquote files))))
:else (let
((found-spec (find-spec slug)))
(if
found-spec
(let
((src (helper "read-spec-file" (get found-spec "filename"))))
(quasiquote
(~specs/detail-content
:spec-title (unquote (get found-spec "title"))
:spec-desc (unquote (get found-spec "desc"))
:spec-filename (unquote (get found-spec "filename"))
:spec-source (unquote src)
:spec-prose (unquote (get found-spec "prose")))))
(quasiquote (~specs/not-found :slug (unquote slug)))))))))
(define
explore
(fn
(slug)
(if
(nil? slug)
(quote (~specs/architecture-content))
(let
((found-spec (find-spec slug)))
(if
found-spec
(let
((data (spec-explore (get found-spec "filename") (get found-spec "title") (get found-spec "desc"))))
(if
data
(quasiquote
(~specs-explorer/spec-explorer-content :data (unquote data)))
(quasiquote (~specs/not-found :slug (unquote slug)))))
(quasiquote (~specs/not-found :slug (unquote slug))))))))
(define
make-spec-files
(fn
(items)
(map
(fn
(item)
(dict
:title (get item "title")
:desc (get item "desc")
:prose (get item "prose")
:filename (get item "filename")
:href (str "/sx/(language.(spec." (get item "slug") "))")
:source (helper "read-spec-file" (get item "filename"))))
items)))
(define
bootstrapper
(fn
(slug)
(if
(nil? slug)
(quote (~specs/bootstrappers-index-content))
(let
((data (helper "bootstrapper-data" slug)))
(if
(get data "bootstrapper-not-found")
(quasiquote (~specs/not-found :slug (unquote slug)))
(case
slug
"self-hosting"
(quasiquote
(~specs/bootstrapper-self-hosting-content
:py-sx-source (unquote (get data "py-sx-source"))
:g0-output (unquote (get data "g0-output"))
:g1-output (unquote (get data "g1-output"))
:defines-matched (unquote (get data "defines-matched"))
:defines-total (unquote (get data "defines-total"))
:g0-lines (unquote (get data "g0-lines"))
:g0-bytes (unquote (get data "g0-bytes"))
:verification-status (unquote (get data "verification-status"))))
"self-hosting-js"
(quasiquote
(~specs/bootstrapper-self-hosting-js-content
:js-sx-source (unquote (get data "js-sx-source"))
:defines-matched (unquote (get data "defines-matched"))
:defines-total (unquote (get data "defines-total"))
:js-sx-lines (unquote (get data "js-sx-lines"))
:verification-status (unquote (get data "verification-status"))))
"python"
(quasiquote
(~specs/bootstrapper-py-content
:bootstrapper-source (unquote (get data "bootstrapper-source"))
:bootstrapped-output (unquote (get data "bootstrapped-output"))))
"page-helpers"
(let
((ph-data (helper "page-helpers-demo-data")))
(quasiquote
(~page-helpers-demo/content
:sf-categories (unquote (get ph-data "sf-categories"))
:sf-total (unquote (get ph-data "sf-total"))
:sf-ms (unquote (get ph-data "sf-ms"))
:ref-sample (unquote (get ph-data "ref-sample"))
:ref-ms (unquote (get ph-data "ref-ms"))
:attr-result (unquote (get ph-data "attr-result"))
:attr-ms (unquote (get ph-data "attr-ms"))
:comp-source (unquote (get ph-data "comp-source"))
:comp-ms (unquote (get ph-data "comp-ms"))
:routing-result (unquote (get ph-data "routing-result"))
:routing-ms (unquote (get ph-data "routing-ms"))
:server-total-ms (unquote (get ph-data "server-total-ms"))
:sf-source (unquote (get ph-data "sf-source"))
:attr-detail (unquote (get ph-data "attr-detail"))
:req-attrs (unquote (get ph-data "req-attrs"))
:attr-keys (unquote (get ph-data "attr-keys")))))
:else (quasiquote
(~specs/bootstrapper-js-content
:bootstrapper-source (unquote (get data "bootstrapper-source"))
:bootstrapped-output (unquote (get data "bootstrapped-output"))))))))))
(define
test
(fn
(slug)
(if
(nil? slug)
(let
((data (helper "run-modular-tests" "all")))
(quasiquote
(~testing/overview-content
:server-results (unquote (get data "server-results"))
:framework-source (unquote (get data "framework-source"))
:eval-source (unquote (get data "eval-source"))
:parser-source (unquote (get data "parser-source"))
:router-source (unquote (get data "router-source"))
:render-source (unquote (get data "render-source"))
:deps-source (unquote (get data "deps-source"))
:engine-source (unquote (get data "engine-source")))))
(case
slug
"runners"
(quote (~testing/runners-content))
:else (let
((data (helper "run-modular-tests" slug)))
(case
slug
"eval"
(quasiquote
(~testing/spec-content
:spec-name "eval"
:spec-title "Evaluator Tests"
:spec-desc "81 tests covering the core evaluator and all primitives."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
"parser"
(quasiquote
(~testing/spec-content
:spec-name "parser"
:spec-title "Parser Tests"
:spec-desc "39 tests covering tokenization and parsing."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
"router"
(quasiquote
(~testing/spec-content
:spec-name "router"
:spec-title "Router Tests"
:spec-desc "18 tests covering client-side route matching."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
"render"
(quasiquote
(~testing/spec-content
:spec-name "render"
:spec-title "Renderer Tests"
:spec-desc "23 tests covering HTML rendering."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
"deps"
(quasiquote
(~testing/spec-content
:spec-name "deps"
:spec-title "Dependency Analysis Tests"
:spec-desc "33 tests covering component dependency analysis."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
"engine"
(quasiquote
(~testing/spec-content
:spec-name "engine"
:spec-title "Engine Tests"
:spec-desc "37 tests covering engine pure functions."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
"orchestration"
(quasiquote
(~testing/spec-content
:spec-name "orchestration"
:spec-title "Orchestration Tests"
:spec-desc "17 tests covering orchestration."
:spec-source (unquote (get data "spec-source"))
:framework-source (unquote (get data "framework-source"))
:server-results (unquote (get data "server-results"))))
:else (quasiquote
(~testing/overview-content
:server-results (unquote (get data "server-results"))))))))))
(define
reference
(fn
(slug)
(if
(nil? slug)
(quote (~examples/reference-index-content))
(let
((data (helper "reference-data" slug)))
(case
slug
"attributes"
(quasiquote
(~reference/attrs-content
:req-table (~docs/attr-table-from-data
:title "Request Attributes"
:attrs (unquote (get data "req-attrs")))
:beh-table (~docs/attr-table-from-data
:title "Behavior Attributes"
:attrs (unquote (get data "beh-attrs")))
:uniq-table (~docs/attr-table-from-data
:title "Unique to sx"
:attrs (unquote (get data "uniq-attrs")))))
"headers"
(quasiquote
(~reference/headers-content
:req-table (~docs/headers-table-from-data
:title "Request Headers"
:headers (unquote (get data "req-headers")))
:resp-table (~docs/headers-table-from-data
:title "Response Headers"
:headers (unquote (get data "resp-headers")))))
"events"
(quasiquote
(~reference/events-content
:table (~docs/two-col-table-from-data
:intro "sx fires custom DOM events at various points in the request lifecycle."
:col1 "Event"
:col2 "Description"
:items (unquote (get data "events-list")))))
"js-api"
(quasiquote
(~reference/js-api-content
:table (~docs/two-col-table-from-data
:intro "The client-side sx.js library exposes a public API for programmatic use."
:col1 "Method"
:col2 "Description"
:items (unquote (get data "js-api-list")))))
:else (quasiquote
(~reference/attrs-content
:req-table (~docs/attr-table-from-data
:title "Request Attributes"
:attrs (unquote (get data "req-attrs")))
:beh-table (~docs/attr-table-from-data
:title "Behavior Attributes"
:attrs (unquote (get data "beh-attrs")))
:uniq-table (~docs/attr-table-from-data
:title "Unique to sx"
:attrs (unquote (get data "uniq-attrs"))))))))))
(define
reference-detail
(fn
(kind slug)
(if
(nil? slug)
nil
(case
kind
"attributes"
(let
((data (helper "attr-detail-data" slug)))
(if
(get data "attr-not-found")
(quasiquote (~reference/attr-not-found :slug (unquote slug)))
(quasiquote
(~reference/attr-detail-content
:title (unquote (get data "attr-title"))
:description (unquote (get data "attr-description"))
:demo (unquote (get data "attr-demo"))
:example-code (unquote (get data "attr-example"))
:handler-code (unquote (get data "attr-handler"))
:wire-placeholder-id (unquote (get data "attr-wire-id"))))))
"headers"
(let
((data (helper "header-detail-data" slug)))
(if
(get data "header-not-found")
(quasiquote (~reference/attr-not-found :slug (unquote slug)))
(quasiquote
(~reference/header-detail-content
:title (unquote (get data "header-title"))
:direction (unquote (get data "header-direction"))
:description (unquote (get data "header-description"))
:example-code (unquote (get data "header-example"))
:demo (unquote (get data "header-demo"))))))
"events"
(let
((data (helper "event-detail-data" slug)))
(if
(get data "event-not-found")
(quasiquote (~reference/attr-not-found :slug (unquote slug)))
(quasiquote
(~reference/event-detail-content
:title (unquote (get data "event-title"))
:description (unquote (get data "event-description"))
:example-code (unquote (get data "event-example"))
:demo (unquote (get data "event-demo"))))))
:else nil))))
(define
example
(fn
(slug)
(if
(nil? slug)
nil
(list (slug->component slug "~examples-content/example-" nil "")))))
(define sx-urls (fn (slug) (quote (~sx-urls/urls-content))))
(define cssx (make-page-fn "~cssx/overview-content" "~cssx/" nil "-content"))
(define
protocol
(make-page-fn "~protocols/wire-format-content" "~protocols/" nil "-content"))
(define
sx-pub
(fn (slug) (if (nil? slug) (quote (~sx-pub/overview-content)) nil)))
(define
sx-tools
(fn
(&key title &rest args)
(quasiquote
(~sx-tools/overview-content
:title (unquote (or title "SX Tools"))
(splice-unquote args)))))
(define tools (fn (content) (if (nil? content) nil content)))
(define
services
(fn
(&key title &rest args)
(quasiquote
(~services-tools/overview-content
:title (unquote (or title "Services"))
(splice-unquote args)))))
(define
reactive-runtime
(make-page-fn
"~reactive-runtime/overview-content"
"~reactive-runtime/"
nil
"-content"))
(define
native-browser
(make-page-fn
"~applications/native-browser/content"
"~applications/native-browser/"
nil
"-content"))
(define
essay
(make-page-fn "~essays/index/essays-index-content" "~essays/" "/essay-" ""))
(define
philosophy
(fn
(slug)
(if
(nil? slug)
(quote (~essays/philosophy-index/content))
(case
slug
"sx-manifesto"
(quote (~essay-sx-manifesto))
"godel-escher-bach"
(quote (~essays/godel-escher-bach/essay-godel-escher-bach))
"wittgenstein"
(quote (~essays/sx-and-wittgenstein/essay-sx-and-wittgenstein))
"dennett"
(quote (~essays/sx-and-dennett/essay-sx-and-dennett))
"existentialism"
(quote (~essays/s-existentialism/essay-s-existentialism))
"platonic-sx"
(quote (~essays/platonic-sx/essay-platonic-sx))
:else (quote (~essays/philosophy-index/content))))))
(define
plan
(make-page-fn
"~plans/index/plans-index-content"
"~plans/"
"/plan-"
"-content"))
(define capabilities (fn (&key title &rest args) (quasiquote (~geography/capabilities-content))))
(define modules (fn (&key title &rest args) (quasiquote (~geography/modules-content))))
(define eval-rules (fn (&key title &rest args) (quasiquote (~geography/eval-rules-content))))
(define sxtp (make-page-fn "~applications/sxtp/content" "~applications/sxtp/" nil "-content"))