Add (param :as type) annotations to defcomp params across all services and templates
Annotates ~500 defcomp params across 62 files: market (5), blog (7), cart (5), events (3), federation (4), account (3), orders (2), shared templates (11), sx docs (14), plus remaining spec fn params (z3, test-framework, adapter-dom, adapter-async, engine, eval). Total annotations in codebase: 1043. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,14 +6,14 @@
|
||||
|
||||
;; --- Demo components with different affinities ---
|
||||
|
||||
(defcomp ~aff-demo-auto (&key label)
|
||||
(defcomp ~aff-demo-auto (&key (label :as string?))
|
||||
(div :class "rounded border border-stone-200 bg-white p-4"
|
||||
(div :class "flex items-center gap-2 mb-2"
|
||||
(span :class "inline-block w-2 h-2 rounded-full bg-stone-400")
|
||||
(span :class "text-sm font-mono text-stone-500" ":affinity :auto"))
|
||||
(p :class "text-stone-800" (or label "Pure component — no IO calls. Auto-detected as client-renderable."))))
|
||||
|
||||
(defcomp ~aff-demo-client (&key label)
|
||||
(defcomp ~aff-demo-client (&key (label :as string?))
|
||||
:affinity :client
|
||||
(div :class "rounded border border-blue-200 bg-blue-50 p-4"
|
||||
(div :class "flex items-center gap-2 mb-2"
|
||||
@@ -21,7 +21,7 @@
|
||||
(span :class "text-sm font-mono text-blue-600" ":affinity :client"))
|
||||
(p :class "text-blue-800" (or label "Explicitly client-rendered — even IO calls would be proxied."))))
|
||||
|
||||
(defcomp ~aff-demo-server (&key label)
|
||||
(defcomp ~aff-demo-server (&key (label :as string?))
|
||||
:affinity :server
|
||||
(div :class "rounded border border-amber-200 bg-amber-50 p-4"
|
||||
(div :class "flex items-center gap-2 mb-2"
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
;; Drill down into each bundle to see component tree; expand to see SX source.
|
||||
;; @css bg-green-100 text-green-800 bg-violet-600 bg-stone-200 text-violet-600 text-stone-600 text-green-600 rounded-full h-2.5 grid-cols-3 bg-blue-100 text-blue-800 bg-amber-100 text-amber-800 grid-cols-4 marker:text-stone-400 bg-blue-50 bg-amber-50 text-blue-700 text-amber-700 border-blue-200 border-amber-200 bg-blue-500 bg-amber-500
|
||||
|
||||
(defcomp ~bundle-analyzer-content (&key pages total-components total-macros
|
||||
pure-count io-count)
|
||||
(defcomp ~bundle-analyzer-content (&key (pages :as list) (total-components :as number) (total-macros :as number)
|
||||
(pure-count :as number) (io-count :as number))
|
||||
(~doc-page :title "Page Bundle Analyzer"
|
||||
|
||||
(p :class "text-stone-600 mb-6"
|
||||
@@ -55,13 +55,13 @@
|
||||
"walks all branches of control flow (if/when/cond/case), "
|
||||
"and includes macro definitions shared across components."))))
|
||||
|
||||
(defcomp ~analyzer-stat (&key label value cls)
|
||||
(defcomp ~analyzer-stat (&key (label :as string) (value :as string) (cls :as string))
|
||||
(div :class "rounded-lg border border-stone-200 p-4 text-center"
|
||||
(div :class (str "text-3xl font-bold " cls) value)
|
||||
(div :class "text-sm text-stone-500 mt-1" label)))
|
||||
|
||||
(defcomp ~analyzer-row (&key name path needed direct total pct savings
|
||||
io-refs pure-in-page io-in-page components)
|
||||
(defcomp ~analyzer-row (&key (name :as string) (path :as string) (needed :as number) (direct :as number) (total :as number) (pct :as number) (savings :as number)
|
||||
(io-refs :as list) (pure-in-page :as number) (io-in-page :as number) (components :as list))
|
||||
(details :class "rounded border border-stone-200"
|
||||
(summary :class "p-4 cursor-pointer hover:bg-stone-50 transition-colors"
|
||||
(div :class "flex items-center justify-between mb-2"
|
||||
@@ -97,7 +97,7 @@
|
||||
:source (get comp "source")))
|
||||
components)))))
|
||||
|
||||
(defcomp ~analyzer-component (&key comp-name is-pure io-refs deps source)
|
||||
(defcomp ~analyzer-component (&key (comp-name :as string) (is-pure :as boolean) (io-refs :as list) (deps :as list) (source :as string))
|
||||
(details :class (str "rounded border "
|
||||
(if is-pure "border-blue-200 bg-blue-50" "border-amber-200 bg-amber-50"))
|
||||
(summary :class "px-3 py-2 cursor-pointer hover:opacity-80 transition-opacity"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
;; "sx:route client+data" — cache miss, fetched from server
|
||||
;; "sx:route client+cache" — cache hit, rendered from cached data
|
||||
|
||||
(defcomp ~data-test-content (&key server-time items phase transport)
|
||||
(defcomp ~data-test-content (&key (server-time :as string) (items :as list) (phase :as string) (transport :as string))
|
||||
(div :class "space-y-8"
|
||||
(div :class "border-b border-stone-200 pb-6"
|
||||
(h1 :class "text-2xl font-bold text-stone-900" "Data Test")
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
;; SX docs utility components
|
||||
|
||||
(defcomp ~doc-placeholder (&key id)
|
||||
(defcomp ~doc-placeholder (&key (id :as string))
|
||||
(div :id id
|
||||
(div :class "bg-stone-100 rounded p-4 mt-3"
|
||||
(p :class "text-stone-400 italic text-sm"
|
||||
"Trigger the demo to see the actual content."))))
|
||||
|
||||
(defcomp ~doc-oob-code (&key target-id text)
|
||||
(defcomp ~doc-oob-code (&key (target-id :as string) (text :as string))
|
||||
(div :id target-id :sx-swap-oob "innerHTML"
|
||||
(div :class "not-prose bg-stone-100 rounded p-4 mt-3"
|
||||
(pre :class "text-sm whitespace-pre-wrap break-words"
|
||||
(code text)))))
|
||||
|
||||
(defcomp ~doc-attr-table (&key title rows)
|
||||
(defcomp ~doc-attr-table (&key (title :as string) rows)
|
||||
(div :class "space-y-3"
|
||||
(h3 :class "text-xl font-semibold text-stone-700" title)
|
||||
(div :class "overflow-x-auto rounded border border-stone-200"
|
||||
@@ -23,7 +23,7 @@
|
||||
(th :class "px-3 py-2 font-medium text-stone-600 text-center w-20" "In sx?")))
|
||||
(tbody rows)))))
|
||||
|
||||
(defcomp ~doc-headers-table (&key title rows)
|
||||
(defcomp ~doc-headers-table (&key (title :as string) rows)
|
||||
(div :class "space-y-3"
|
||||
(h3 :class "text-xl font-semibold text-stone-700" title)
|
||||
(div :class "overflow-x-auto rounded border border-stone-200"
|
||||
@@ -34,7 +34,7 @@
|
||||
(th :class "px-3 py-2 font-medium text-stone-600" "Description")))
|
||||
(tbody rows)))))
|
||||
|
||||
(defcomp ~doc-headers-row (&key name value description href)
|
||||
(defcomp ~doc-headers-row (&key (name :as string) (value :as string) (description :as string) (href :as string?))
|
||||
(tr :class "border-b border-stone-100"
|
||||
(td :class "px-3 py-2 font-mono text-sm whitespace-nowrap"
|
||||
(if href
|
||||
@@ -46,7 +46,7 @@
|
||||
(td :class "px-3 py-2 font-mono text-sm text-stone-500" value)
|
||||
(td :class "px-3 py-2 text-stone-700 text-sm" description)))
|
||||
|
||||
(defcomp ~doc-two-col-row (&key name description href)
|
||||
(defcomp ~doc-two-col-row (&key (name :as string) (description :as string) (href :as string?))
|
||||
(tr :class "border-b border-stone-100"
|
||||
(td :class "px-3 py-2 font-mono text-sm whitespace-nowrap"
|
||||
(if href
|
||||
@@ -57,7 +57,7 @@
|
||||
(span :class "text-violet-700" name)))
|
||||
(td :class "px-3 py-2 text-stone-700 text-sm" description)))
|
||||
|
||||
(defcomp ~doc-two-col-table (&key title intro col1 col2 rows)
|
||||
(defcomp ~doc-two-col-table (&key (title :as string?) (intro :as string?) (col1 :as string?) (col2 :as string?) rows)
|
||||
(div :class "space-y-3"
|
||||
(when title (h3 :class "text-xl font-semibold text-stone-700" title))
|
||||
(when intro (p :class "text-stone-600 mb-6" intro))
|
||||
@@ -82,7 +82,7 @@
|
||||
|
||||
;; Build attr table from a list of {name, desc, exists, href} dicts.
|
||||
;; Replaces _attr_table_sx() in utils.py.
|
||||
(defcomp ~doc-attr-table-from-data (&key title attrs)
|
||||
(defcomp ~doc-attr-table-from-data (&key (title :as string) (attrs :as list))
|
||||
(~doc-attr-table :title title
|
||||
:rows (<> (map (fn (a)
|
||||
(~doc-attr-row
|
||||
@@ -94,7 +94,7 @@
|
||||
|
||||
;; Build headers table from a list of {name, value, desc} dicts.
|
||||
;; Replaces _headers_table_sx() in utils.py.
|
||||
(defcomp ~doc-headers-table-from-data (&key title headers)
|
||||
(defcomp ~doc-headers-table-from-data (&key (title :as string) (headers :as list))
|
||||
(~doc-headers-table :title title
|
||||
:rows (<> (map (fn (h)
|
||||
(~doc-headers-row
|
||||
@@ -106,7 +106,7 @@
|
||||
|
||||
;; Build two-col table from a list of {name, desc} dicts.
|
||||
;; Replaces the _reference_events_sx / _reference_js_api_sx builders.
|
||||
(defcomp ~doc-two-col-table-from-data (&key title intro col1 col2 items)
|
||||
(defcomp ~doc-two-col-table-from-data (&key (title :as string?) (intro :as string?) (col1 :as string?) (col2 :as string?) (items :as list))
|
||||
(~doc-two-col-table :title title :intro intro :col1 col1 :col2 col2
|
||||
:rows (<> (map (fn (item)
|
||||
(~doc-two-col-row
|
||||
@@ -117,7 +117,7 @@
|
||||
|
||||
;; Build all primitives category tables from a {category: [prim, ...]} dict.
|
||||
;; Replaces _primitives_section_sx() in utils.py.
|
||||
(defcomp ~doc-primitives-tables (&key primitives)
|
||||
(defcomp ~doc-primitives-tables (&key (primitives :as dict))
|
||||
(<> (map (fn (cat)
|
||||
(~doc-primitives-table
|
||||
:category cat
|
||||
@@ -125,14 +125,14 @@
|
||||
(keys primitives))))
|
||||
|
||||
;; Build all special form category sections from a {category: [form, ...]} dict.
|
||||
(defcomp ~doc-special-forms-tables (&key forms)
|
||||
(defcomp ~doc-special-forms-tables (&key (forms :as dict))
|
||||
(<> (map (fn (cat)
|
||||
(~doc-special-forms-category
|
||||
:category cat
|
||||
:forms (get forms cat)))
|
||||
(keys forms))))
|
||||
|
||||
(defcomp ~doc-special-forms-category (&key category forms)
|
||||
(defcomp ~doc-special-forms-category (&key (category :as string) (forms :as list))
|
||||
(div :class "space-y-4"
|
||||
(h3 :class "text-xl font-semibold text-stone-800 border-b border-stone-200 pb-2" category)
|
||||
(div :class "space-y-4"
|
||||
@@ -145,7 +145,7 @@
|
||||
:example (get f "example")))
|
||||
forms))))
|
||||
|
||||
(defcomp ~doc-special-form-card (&key name syntax doc tail-position example)
|
||||
(defcomp ~doc-special-form-card (&key (name :as string) (syntax :as string) (doc :as string) (tail-position :as string) (example :as string))
|
||||
(div :class "not-prose border border-stone-200 rounded-lg p-4 space-y-3"
|
||||
(div :class "flex items-baseline gap-3"
|
||||
(code :class "text-lg font-bold text-violet-700" name)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
;; Example page template and reference index
|
||||
;; Template receives data values (code strings, titles), calls highlight internally.
|
||||
|
||||
(defcomp ~example-page-content (&key title description demo-description demo
|
||||
sx-code sx-lang handler-code handler-lang
|
||||
comp-placeholder-id wire-placeholder-id wire-note
|
||||
comp-heading handler-heading)
|
||||
(defcomp ~example-page-content (&key (title :as string) (description :as string) (demo-description :as string?) demo
|
||||
(sx-code :as string) (sx-lang :as string?) (handler-code :as string) (handler-lang :as string?)
|
||||
(comp-placeholder-id :as string?) (wire-placeholder-id :as string?) (wire-note :as string?)
|
||||
(comp-heading :as string?) (handler-heading :as string?))
|
||||
(~doc-page :title title
|
||||
(p :class "text-stone-600 mb-6" description)
|
||||
(~example-card :title "Demo" :description demo-description
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;; 404 Not Found page content
|
||||
|
||||
(defcomp ~not-found-content (&key path)
|
||||
(defcomp ~not-found-content (&key (path :as string?))
|
||||
(div :class "max-w-3xl mx-auto px-4 py-12 text-center"
|
||||
(h1 :style (cssx (:text (colour "stone" 800) (size "3xl") (weight "bold")))
|
||||
"404")
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
;; Shared card component — used by both server and client results
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
(defcomp ~demo-result-card (&key title ms desc theme &rest children)
|
||||
(defcomp ~demo-result-card (&key (title :as string) (ms :as number) (desc :as string) (theme :as string) &rest children)
|
||||
(let ((border (if (= theme "blue") "border-blue-200 bg-blue-50/30" "border-stone-200"))
|
||||
(title-c (if (= theme "blue") "text-blue-700" "text-stone-700"))
|
||||
(badge-c (if (= theme "blue") "text-blue-400" "text-stone-400"))
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
;; Reader Macro Demo: #z3 — SX Spec to SMT-LIB (live translation via z3.sx)
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
(defcomp ~z3-example (&key sx-source smt-output)
|
||||
(defcomp ~z3-example (&key (sx-source :as string) (smt-output :as string))
|
||||
(div :class "grid grid-cols-1 md:grid-cols-2 gap-4"
|
||||
(div
|
||||
(p :class "text-xs text-stone-500 uppercase tracking-wider mb-1" "SX Source")
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
(~doc-section :title "SX Diff Viewer" :id "diff-viewer"
|
||||
(p "Diffs rendered as SX components, not pre-formatted text:")
|
||||
(highlight ";; The diff viewer is a defcomp, composable like any other
|
||||
(defcomp ~diff-view (&key diff)
|
||||
(defcomp ~diff-view (&key (diff :as dict))
|
||||
(map (fn (hunk)
|
||||
(~diff-hunk
|
||||
:file (get hunk \"file\")
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
;; Helper: render a Phase 1 result row
|
||||
(defcomp ~prove-phase1-row (&key name status)
|
||||
(defcomp ~prove-phase1-row (&key (name :as string) (status :as string))
|
||||
(tr :class "border-t border-stone-100"
|
||||
(td :class "py-1.5 px-3 font-mono text-xs text-stone-700" name)
|
||||
(td :class "py-1.5 px-3 text-xs"
|
||||
@@ -12,7 +12,7 @@
|
||||
(span :class "text-red-600 font-medium" status)))))
|
||||
|
||||
;; Helper: render a Phase 2 result row
|
||||
(defcomp ~prove-phase2-row (&key name status tested skipped counterexample)
|
||||
(defcomp ~prove-phase2-row (&key (name :as string) (status :as string) (tested :as number) (skipped :as number) (counterexample :as string?))
|
||||
(tr :class "border-t border-stone-100"
|
||||
(td :class "py-1.5 px-3 font-mono text-xs text-stone-700" name)
|
||||
(td :class "py-1.5 px-3 text-xs"
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
(~doc-page :title "JavaScript API"
|
||||
table))
|
||||
|
||||
(defcomp ~reference-attr-detail-content (&key title description demo
|
||||
example-code handler-code wire-placeholder-id)
|
||||
(defcomp ~reference-attr-detail-content (&key (title :as string) (description :as string) demo
|
||||
(example-code :as string) (handler-code :as string?) (wire-placeholder-id :as string?))
|
||||
(~doc-page :title title
|
||||
(p :class "text-stone-600 mb-6" description)
|
||||
(when demo
|
||||
@@ -50,8 +50,8 @@
|
||||
"Trigger the demo to see the raw response the server sends.")
|
||||
(~doc-placeholder :id wire-placeholder-id)))))
|
||||
|
||||
(defcomp ~reference-header-detail-content (&key title direction description
|
||||
example-code demo)
|
||||
(defcomp ~reference-header-detail-content (&key (title :as string) (direction :as string) (description :as string)
|
||||
(example-code :as string?) demo)
|
||||
(~doc-page :title title
|
||||
(let ((badge-class (if (= direction "request")
|
||||
"bg-blue-100 text-blue-700"
|
||||
@@ -84,7 +84,7 @@
|
||||
(h3 :class "text-lg font-semibold text-stone-700 mt-6" "Example usage")
|
||||
(~example-source :code (highlight example-code "lisp"))))))
|
||||
|
||||
(defcomp ~reference-attr-not-found (&key slug)
|
||||
(defcomp ~reference-attr-not-found (&key (slug :as string))
|
||||
(~doc-page :title "Not Found"
|
||||
(p :class "text-stone-600"
|
||||
(str "No documentation found for \"" slug "\"."))))
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
(li (strong "Swap: ") "On success, the rendered DOM replaces " (code "#main-panel") " contents, " (code "pushState") " updates the URL, and the console logs " (code "sx:route client /path") ".")
|
||||
(li (strong "Fallback: ") "If anything fails (no match, eval error, missing component), the click falls through to a standard server fetch. Console logs " (code "sx:route server /path") ". The user sees no difference.")))))
|
||||
|
||||
(defcomp ~routing-row (&key name path mode has-data content-expr reason)
|
||||
(defcomp ~routing-row (&key (name :as string) (path :as string) (mode :as string) (has-data :as boolean) (content-expr :as string?) (reason :as string?))
|
||||
(div :class (str "rounded border p-3 flex items-center gap-3 "
|
||||
(if (= mode "client")
|
||||
"border-green-200 bg-green-50"
|
||||
|
||||
@@ -230,7 +230,7 @@ router.sx (standalone — pure string/list ops)")))
|
||||
;; Overview pages (Core / Adapters) — show truncated previews of each file
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
(defcomp ~spec-overview-content (&key spec-title spec-files)
|
||||
(defcomp ~spec-overview-content (&key (spec-title :as string) (spec-files :as list))
|
||||
(~doc-page :title (or spec-title "Specs")
|
||||
(p :class "text-stone-600 mb-6"
|
||||
(case spec-title
|
||||
@@ -264,7 +264,7 @@ router.sx (standalone — pure string/list ops)")))
|
||||
;; Detail page — full source of a single spec file
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
(defcomp ~spec-detail-content (&key spec-title spec-desc spec-filename spec-source spec-prose)
|
||||
(defcomp ~spec-detail-content (&key (spec-title :as string) (spec-desc :as string) (spec-filename :as string) (spec-source :as string) (spec-prose :as string?))
|
||||
(~doc-page :title spec-title
|
||||
(div :class "flex items-baseline gap-3 mb-4"
|
||||
(span :class "text-sm text-stone-400 font-mono" spec-filename)
|
||||
@@ -378,7 +378,7 @@ router.sx (standalone — pure string/list ops)")))
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; @css bg-green-100 text-green-800 bg-green-50 border-green-200 text-green-700
|
||||
|
||||
(defcomp ~bootstrapper-self-hosting-content (&key py-sx-source g0-output g1-output defines-matched defines-total g0-lines g0-bytes verification-status)
|
||||
(defcomp ~bootstrapper-self-hosting-content (&key (py-sx-source :as string) (g0-output :as string) (g1-output :as string) (defines-matched :as number) (defines-total :as number) (g0-lines :as number) (g0-bytes :as number) (verification-status :as string))
|
||||
(~doc-page :title "Self-Hosting Bootstrapper (py.sx)"
|
||||
(div :class "space-y-8"
|
||||
|
||||
@@ -594,7 +594,7 @@ router.sx (standalone — pure string/list ops)")))
|
||||
;; Not found
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
(defcomp ~spec-not-found (&key slug)
|
||||
(defcomp ~spec-not-found (&key (slug :as string))
|
||||
(~doc-page :title "Spec Not Found"
|
||||
(p :class "text-stone-600"
|
||||
"No specification found for \"" slug "\". This spec may not exist yet.")))
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
;; Generic streamed content chunk — rendered once per yield from the
|
||||
;; async generator. The :content expression receives different bindings
|
||||
;; each time, and the _stream_id determines which ~suspense slot it fills.
|
||||
(defcomp ~streaming-demo-chunk (&key stream-label stream-color stream-message stream-time)
|
||||
(defcomp ~streaming-demo-chunk (&key (stream-label :as string) (stream-color :as string) (stream-message :as string) (stream-time :as string))
|
||||
(let ((colors (get stream-colors stream-color)))
|
||||
(div :class (str "rounded-lg border p-5 space-y-3 " (get colors "border") " " (get colors "bg"))
|
||||
(div :class "flex items-center gap-2"
|
||||
|
||||
@@ -139,7 +139,7 @@ Per-spec platform functions:
|
||||
;; Per-spec test page (reusable for eval, parser, router, render)
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
(defcomp ~testing-spec-content (&key spec-name spec-title spec-desc spec-source framework-source server-results)
|
||||
(defcomp ~testing-spec-content (&key (spec-name :as string) (spec-title :as string) (spec-desc :as string) (spec-source :as string) (framework-source :as string) (server-results :as dict?))
|
||||
(~doc-page :title spec-title
|
||||
(div :class "space-y-8"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user