Remove CSSX style dictionary infrastructure — styling is just components
The entire parallel CSS system (StyleValue type, style dictionary, keyword atom resolver, content-addressed class generation, runtime CSS injection, localStorage caching) was built but never adopted — the codebase already uses :class strings with defcomp components for all styling. Remove ~3,000 lines of unused infrastructure. Deleted: - cssx.sx spec module (317 lines) - style_dict.py (782 lines) and style_resolver.py (254 lines) - StyleValue type, defkeyframes special form, build-keyframes platform fn - Style dict JSON delivery (<script type="text/sx-styles">), cookies, localStorage - css/merge-styles primitives, inject-style-value, fnv1a-hash platform interface Simplified: - defstyle now binds any value (string, function) — no StyleValue type needed - render-attrs no longer special-cases :style StyleValue → class conversion - Boot sequence skips style dict init step Preserved: - tw.css parsing + CSS class delivery (SX-Css headers, <style id="sx-css">) - All component infrastructure (defcomp, caching, bundling, deps) - defstyle as a binding form for reusable class strings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,16 +3,14 @@
|
||||
;;
|
||||
;; Handles the browser startup lifecycle:
|
||||
;; 1. CSS tracking init
|
||||
;; 2. Style dictionary loading (from <script type="text/sx-styles">)
|
||||
;; 3. Component script processing (from <script type="text/sx">)
|
||||
;; 4. Hydration of [data-sx] elements
|
||||
;; 5. Engine element processing
|
||||
;; 2. Component script processing (from <script type="text/sx">)
|
||||
;; 3. Hydration of [data-sx] elements
|
||||
;; 4. Engine element processing
|
||||
;;
|
||||
;; Also provides the public mounting/hydration API:
|
||||
;; mount, hydrate, update, render-component
|
||||
;;
|
||||
;; Depends on:
|
||||
;; cssx.sx — load-style-dict
|
||||
;; orchestration.sx — process-elements, engine-init
|
||||
;; adapter-dom.sx — render-to-dom
|
||||
;; render.sx — shared registries
|
||||
@@ -275,58 +273,6 @@
|
||||
(set-sx-comp-cookie hash))))))
|
||||
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; Style dictionary initialization
|
||||
;; --------------------------------------------------------------------------
|
||||
|
||||
(define init-style-dict
|
||||
(fn ()
|
||||
;; Process <script type="text/sx-styles"> tags with caching.
|
||||
(let ((scripts (query-style-scripts)))
|
||||
(for-each
|
||||
(fn (s)
|
||||
(when (not (is-processed? s "styles"))
|
||||
(mark-processed! s "styles")
|
||||
(let ((text (dom-text-content s))
|
||||
(hash (dom-get-attr s "data-hash")))
|
||||
(if (nil? hash)
|
||||
;; No hash — just parse inline
|
||||
(when (and text (not (empty? (trim text))))
|
||||
(parse-and-load-style-dict text))
|
||||
;; Hash-based caching
|
||||
(let ((has-inline (and text (not (empty? (trim text))))))
|
||||
(let ((cached-hash (local-storage-get "sx-styles-hash")))
|
||||
(if (= cached-hash hash)
|
||||
;; Cache hit
|
||||
(if has-inline
|
||||
(do
|
||||
(local-storage-set "sx-styles-src" text)
|
||||
(parse-and-load-style-dict text)
|
||||
(log-info "styles: downloaded (cookie stale)"))
|
||||
(let ((cached (local-storage-get "sx-styles-src")))
|
||||
(if cached
|
||||
(do
|
||||
(parse-and-load-style-dict cached)
|
||||
(log-info (str "styles: cached (" hash ")")))
|
||||
(do
|
||||
(clear-sx-styles-cookie)
|
||||
(browser-reload)))))
|
||||
;; Cache miss
|
||||
(if has-inline
|
||||
(do
|
||||
(local-storage-set "sx-styles-hash" hash)
|
||||
(local-storage-set "sx-styles-src" text)
|
||||
(parse-and-load-style-dict text)
|
||||
(log-info (str "styles: downloaded (" hash ")")))
|
||||
(do
|
||||
(local-storage-remove "sx-styles-hash")
|
||||
(local-storage-remove "sx-styles-src")
|
||||
(clear-sx-styles-cookie)
|
||||
(browser-reload)))))
|
||||
(set-sx-styles-cookie hash))))))
|
||||
scripts))))
|
||||
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; Page registry for client-side routing
|
||||
;; --------------------------------------------------------------------------
|
||||
@@ -375,7 +321,6 @@
|
||||
(do
|
||||
(log-info (str "sx-browser " SX_VERSION))
|
||||
(init-css-tracking)
|
||||
(init-style-dict)
|
||||
(process-page-scripts)
|
||||
(process-sx-scripts nil)
|
||||
(sx-hydrate-elements nil)
|
||||
@@ -389,9 +334,6 @@
|
||||
;; From orchestration.sx:
|
||||
;; process-elements, init-css-tracking
|
||||
;;
|
||||
;; From cssx.sx:
|
||||
;; load-style-dict
|
||||
;;
|
||||
;; === DOM / Render ===
|
||||
;; (resolve-mount-target target) → Element (string → querySelector, else identity)
|
||||
;; (sx-render-with-env source extra-env) → DOM node (parse + render with componentEnv + extra)
|
||||
@@ -420,7 +362,6 @@
|
||||
;;
|
||||
;; === Script queries ===
|
||||
;; (query-sx-scripts root) → list of <script type="text/sx"> elements
|
||||
;; (query-style-scripts) → list of <script type="text/sx-styles"> elements
|
||||
;; (query-page-scripts) → list of <script type="text/sx-pages"> elements
|
||||
;;
|
||||
;; === localStorage ===
|
||||
@@ -431,8 +372,6 @@
|
||||
;; === Cookies ===
|
||||
;; (set-sx-comp-cookie hash) → void
|
||||
;; (clear-sx-comp-cookie) → void
|
||||
;; (set-sx-styles-cookie hash) → void
|
||||
;; (clear-sx-styles-cookie) → void
|
||||
;;
|
||||
;; === Env ===
|
||||
;; (parse-env-attr el) → dict (parse data-sx-env JSON attr)
|
||||
@@ -444,8 +383,6 @@
|
||||
;; (log-parse-error label text err) → void (diagnostic parse error)
|
||||
;;
|
||||
;; === JSON parsing ===
|
||||
;; (parse-and-load-style-dict text) → void (JSON.parse + load-style-dict)
|
||||
;;
|
||||
;; === Processing markers ===
|
||||
;; (mark-processed! el key) → void
|
||||
;; (is-processed? el key) → boolean
|
||||
|
||||
Reference in New Issue
Block a user