- Remove prism.js, sweetalert2, body.js, sx-browser.js from shell — only WASM kernel (sx_browser.bc.wasm.js + sx-platform.js) loads - Restore request-handler.sx integration: SX handles routing + AJAX detection, OCaml does aser → SSR → shell render pipeline - AJAX fragment support: SX-Request header returns content fragment (~14KB) instead of full page (~858KB), cached with "ajax:" prefix - Fix language/applications/etc page functions to return empty fragment instead of nil (was causing 404s) - Shared JIT VM globals: env_bind hook mirrors ALL bindings to a single shared globals table — eliminates stale-snapshot class of JIT bugs - Add native `parse` function for components that need SX parsing - Clean up unused shell params (sx-js-hash, body-js-hash, head-scripts, body-scripts, use-wasm) from shell.sx, helpers.py, and server.ml 14/32 Playwright tests pass (navigation, SSR, isomorphic, geography). Remaining failures are client-side (WASM bytecode 404s block hydration). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
57 lines
1.5 KiB
Plaintext
57 lines
1.5 KiB
Plaintext
(define
|
|
sx-url-to-expr
|
|
(fn
|
|
(path)
|
|
(cond
|
|
(or (= path "/") (= path "/sx/") (= path "/sx"))
|
|
"home"
|
|
(starts-with? path "/sx/")
|
|
(join " " (split (slice path 4 (len path)) "."))
|
|
(starts-with? path "/")
|
|
(join " " (split (slice path 1 (len path)) "."))
|
|
:else path)))
|
|
|
|
(define
|
|
sx-auto-quote
|
|
(fn
|
|
(expr env)
|
|
(cond
|
|
(and (symbol? expr) (not (env-has? env (symbol-name expr))))
|
|
(symbol-name expr)
|
|
(list? expr)
|
|
(map (fn (e) (sx-auto-quote e env)) expr)
|
|
:else expr)))
|
|
|
|
(define
|
|
sx-eval-page
|
|
(fn
|
|
(path-expr env)
|
|
(cek-try
|
|
(fn
|
|
()
|
|
(let
|
|
((exprs (sx-parse path-expr)))
|
|
(when
|
|
(not (empty? exprs))
|
|
(let
|
|
((expr (if (= (len exprs) 1) (first exprs) exprs))
|
|
(quoted (sx-auto-quote expr env))
|
|
(callable (if (symbol? quoted) (list quoted) quoted)))
|
|
(eval-expr callable env)))))
|
|
(fn (err) nil))))
|
|
|
|
(define
|
|
sx-handle-request
|
|
(fn
|
|
(path headers env shell-vars)
|
|
(let
|
|
((is-ajax (or (has-key? headers "sx-request") (has-key? headers "hx-request")))
|
|
(path-expr (sx-url-to-expr path))
|
|
(page-ast (sx-eval-page path-expr env)))
|
|
(if
|
|
(nil? page-ast)
|
|
nil
|
|
(let
|
|
((nav-path (if (and (>= (len path) 4) (= (slice path 0 4) "/sx/")) path (str "/sx" path))))
|
|
{:page-ast page-ast :nav-path nav-path :is-ajax is-ajax})))))
|