URL restructure, 404 page, trailing slash normalization, layout fixes

- Rename /reactive-islands/ → /reactive/, /reference/ → /hypermedia/reference/,
  /examples/ → /hypermedia/examples/ across all .sx and .py files
- Add 404 error page (not-found.sx) working on both server refresh and
  client-side SX navigation via orchestration.sx error response handling
- Add trailing slash redirect (GET only, excludes /api/, /static/, /internal/)
- Remove blue sky-500 header bar from SX docs layout (conditional on header-rows)
- Fix 405 on API endpoints from trailing slash redirect hitting POST/PUT/DELETE
- Fix client-side 404: orchestration.sx now swaps error response content
  instead of silently dropping it
- Add new plan files and home page component

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 21:30:18 +00:00
parent e149dfe968
commit 1341c144da
35 changed files with 2305 additions and 438 deletions

View File

@@ -113,10 +113,12 @@
(when (= sync "replace")
(abort-previous el))
;; Abort any in-flight request targeting the same swap target.
;; This ensures rapid navigation (click A then B) cancels A's fetch.
;; Abort any in-flight request targeting the same swap target,
;; but only when trigger and target are different elements.
;; This ensures rapid navigation (click A then B) cancels A's fetch,
;; while polling (element targets itself) doesn't abort its own requests.
(let ((target-el (resolve-target el)))
(when target-el
(when (and target-el (not (identical? el target-el)))
(abort-previous-target target-el)))
(let ((ctrl (new-abort-controller)))
@@ -178,7 +180,12 @@
(do
(dom-dispatch el "sx:responseError"
(dict "status" status "text" text))
(handle-retry el verb method final-url extraParams))
;; If the error response has SX content, swap it in
;; (e.g. 404 pages) instead of just retrying
(if (and text (> (len text) 0))
(handle-fetch-success el final-url verb extraParams
get-header text)
(handle-retry el verb method final-url extraParams)))
(do
(dom-dispatch el "sx:afterRequest"
(dict "status" status))
@@ -246,12 +253,16 @@
;; History
(handle-history el url resp-headers)
;; Settle triggers (after small delay)
(when (get resp-headers "trigger-settle")
(set-timeout
(fn () (dispatch-trigger-events el
(get resp-headers "trigger-settle")))
20))
;; Settle phase (after small delay): triggers + sx-on-settle hooks
(set-timeout
(fn ()
;; Server-driven settle triggers
(when (get resp-headers "trigger-settle")
(dispatch-trigger-events el
(get resp-headers "trigger-settle")))
;; sx-on-settle: evaluate SX expression after swap settles
(process-settle-hooks el))
20)
;; Lifecycle event
(dom-dispatch el "sx:afterSwap"
@@ -452,6 +463,27 @@
(process-elements root)))
;; --------------------------------------------------------------------------
;; sx-on-settle — post-swap SX evaluation
;; --------------------------------------------------------------------------
;;
;; After a swap settles, evaluate the SX expression in the trigger element's
;; sx-on-settle attribute. The expression has access to all primitives
;; (including use-store, reset!, deref) so it can update reactive state
;; based on what the server returned.
;;
;; Example: (button :sx-get "/search" :sx-on-settle "(reset! (use-store \"count\") 0)")
(define process-settle-hooks
(fn (el)
(let ((settle-expr (dom-get-attr el "sx-on-settle")))
(when (and settle-expr (not (empty? settle-expr)))
(let ((exprs (sx-parse settle-expr)))
(for-each
(fn (expr) (eval-expr expr (env-extend (dict))))
exprs))))))
(define activate-scripts
(fn (root)
;; Re-activate scripts in swapped content.