@ultimat3/render 30.8.0 → 31.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +23 -16
- package/README.md +27 -17
- package/package.json +9 -7
- package/src/adapter.ts +13 -0
- package/src/client-sync-tags.ts +11 -1
- package/src/client.ts +2 -0
- package/src/html.ts +57 -18
- package/src/index.ts +6 -28
- package/src/island-props.ts +3 -7
- package/src/jsx.ts +7 -1
- package/src/navigation-history.ts +12 -0
- package/src/navigation-intercept.ts +157 -0
- package/src/navigation.ts +20 -124
- package/src/registry.ts +9 -0
- package/src/render-html.ts +25 -159
- package/src/render-instrument.ts +66 -0
- package/src/render-isr-store-codec.ts +41 -0
- package/src/render-isr-store-storage.ts +194 -0
- package/src/render-isr-store.ts +68 -18
- package/src/render-isr-types.ts +8 -3
- package/src/render-isr.ts +72 -30
- package/src/render-walk.ts +275 -0
- package/src/server.ts +9 -1
- package/src/surfaces.ts +23 -5
package/CLAUDE.md
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
Owns: the `route` primitive, the four render modes, the route table, the surface boundary,
|
|
4
4
|
islands + budgets, hydration directives, `<head>` merge, **the server JSX runtime and the two Bun
|
|
5
5
|
loaders that make an app's `.tsx` and `.scss` runnable**.
|
|
6
|
+
A row marked `†` has its full text in [`docs/history/render-rules.md`](../../docs/history/render-rules.md).
|
|
6
7
|
|
|
7
|
-
**
|
|
8
|
+
**Entry points**: `"."`, `"./server"`, `"./client"`, `"./navigation"`, and `"./adapter"` (`adapter.ts`, the
|
|
9
|
+
`isrStore` port's TYPES — `IsrStore` and its entry shapes; no installer: `@ultimat3/cli` reads
|
|
10
|
+
`runtime.ts`'s `isrStore`). `"."` and `"./server"` disjoint. `"."` (`index.ts`) is the CLIENT half and bundles for the browser;
|
|
8
11
|
`"./server"` (`server.ts`) is the build-time half — `css-modules`, `module-loader`, `render-html`,
|
|
9
12
|
`render-isr`, `render-ssr`, `render-static`, `render-stream` — and does not (`css-modules.ts` needs
|
|
10
13
|
`node:url`, which a browser build cannot link; no `sideEffects` value repairs that). Never re-export
|
|
@@ -34,7 +37,7 @@ axiom 6). Never `cli` (upward).
|
|
|
34
37
|
| `load` | optional, and the ONE server-side data seam. Resolved once per render by `routeDataFor()` and handed to **both** `meta` and the page component. Absent `load`, the context IS the data (`{ params, url }`). |
|
|
35
38
|
| `load` is required when the context cannot supply the data | `LoadRequirement<TData>` in `defineRoute`'s parameter. `RouteContext` is a type ALIAS on purpose — only an alias carries the implicit index signature that makes it a `RouteData`. |
|
|
36
39
|
| A loader's own error | rethrown only when `isUltimateError` says so (core's brand), never a `code` property and never `instanceof UltimateError` — a tier-0 error is branded, not a subclass. Everything else is `X_ROUTE_LOAD_FAILED`. |
|
|
37
|
-
| A loader's own STATUS | `withStatus(status, data)` (`route-status.ts`) — the ONE way a page answers 404/410/503
|
|
40
|
+
| A loader's own STATUS | `withStatus(status, data)` (`route-status.ts`) — the ONE way a page answers 404/410/503; `routeStatusOf(data)` reads it; a 3xx is `X_ROUTE_STATUS_INVALID` † |
|
|
38
41
|
| Type claims | `type-pins.tsx`, never a `.test.ts` — `tsconfig.json` excludes tests. `.tsx` so the island-as-JSX claim is checked against the JSX an author writes. |
|
|
39
42
|
| Descriptor `meta` / `load` | always `(x) => Promise<…>`. Authors may declare either sync; consumers never branch. |
|
|
40
43
|
| Descriptor `budget` | always an object, `{}` when undeclared. `budget.js === undefined` is the site/ hydration failure. |
|
|
@@ -51,27 +54,28 @@ axiom 6). Never `cli` (upward).
|
|
|
51
54
|
| Island props | declared, JSON-safe, under `ISLAND_PROPS_MAX_BYTES` (16 KiB; the doc comment carries the arithmetic) — `island-props.ts` is the one gate, a structural walk, never a `JSON.stringify` round trip. Over the cap the cause names the heaviest props and the fix names the endpoint pattern, never "raise the cap". `X_ISLAND_PROPS_INVALID` has a row in `@ultimat3/http`'s table (500). |
|
|
52
55
|
| A prop lands via `Object.defineProperty` | never `out[key] = v` — `__proto__` (a real own key off `JSON.parse`) would run the prototype setter. |
|
|
53
56
|
| An attribute alias is a `Map` | never a record (`toString` resolved to a function). `MODE_SPECS[config.render]` is guarded by `Object.hasOwn` for the same reason. |
|
|
54
|
-
| An attribute NAME is validated too | `ATTRIBUTE_NAME` in `html.ts
|
|
57
|
+
| An attribute NAME is validated too | `ATTRIBUTE_NAME` in `html.ts`, refused as `null`; `head-attributes.ts` prints through the same `attributePair`. One rule, never two † |
|
|
55
58
|
| Which attributes take a URL | `URL_BEARING_ATTRIBUTES` in `html.ts` — core's four plus `data`, `poster`, `ping`, `xlink:href`. `srcdoc` is refused outright (entity-decoded, then parsed as HTML). |
|
|
56
59
|
| Island collection | per render, `renderToHtml(tree, { islands })`. Never module-global and never on an ambient context. |
|
|
57
60
|
| A byte count in a message | `formatBytes` from `@ultimat3/core`, never a local one. |
|
|
58
61
|
| Island bytes | **not this package's**: `@ultimat3/cli`'s `packages/cli/src/budgets.ts` measures the EMITTED document and is the gate. What stays here is the budget grammar (`parseByteBudget`) and `defaultIslandBudget`. |
|
|
59
|
-
| The hydration runtime's CSP | `HYDRATE_RUNTIME_BODIES` — every body `hydrateRuntime` can emit
|
|
60
|
-
| Island markup | the props `<script>` is emitted INSIDE the wrapper by `render-
|
|
62
|
+
| The hydration runtime's CSP | `HYDRATE_RUNTIME_BODIES` — every inline body `hydrateRuntime` can emit, hashed by `@ultimat3/cli`'s `script-csp.ts`; `runtimeBody` is the one string served and hashed † |
|
|
63
|
+
| Island markup | the props `<script>` is emitted INSIDE the wrapper by `render-walk.ts`; an assembler only adds `hydrateRuntime(directives)`. |
|
|
61
64
|
| Island boot | `el.__x` holds the boot PROMISE, never a boolean. |
|
|
62
65
|
| Island mount markers | `data-x-mounted=""` when `mount()` resolved, `data-x-failed="<message>"` when it rejected — set by the runtime, never by `emitIslandAttributes`. The rejection handler RETHROWS. Prelude sizes `As of 2026-10-05`: `idle` 1,843, `visible` 886, `interaction` 1,728 B (what `DEFAULT_ISLAND_JS_BYTES` derives from). |
|
|
63
66
|
| A runtime that calls `boot` | TERMINATES the chain: `idle`/`visible` end in `.catch(hush)`, `interaction` passes `off` as the rejection arm. `hydrate-runtime.test.ts` reds on an unhandled rejection. |
|
|
64
67
|
| `idle` replays too | `idle` and `interaction` share ONE `catchUp(el)` in `hydrate.ts` (capture listeners for `data-x-events`, default `click`; a queue; `aim`; one flush). A caught event wakes an `idle` island early; each event replays once. `hydrate-replay.test.ts`. |
|
|
65
|
-
| Where `interaction` replays | `aim(el, ev)`, never `ev.target`
|
|
66
|
-
| A held island | `
|
|
68
|
+
| Where `interaction` replays | `aim(el, ev)`, never `ev.target` (`mount` detaches the pressed node). Fallback order: `docs/history/render.md`. `hydrate-replay.test.ts`. |
|
|
69
|
+
| A held island | `island-hold.ts`: `hold` on the collector, revealed together, never hidden for good. Full rule: `docs/history/render.md` |
|
|
67
70
|
| `idle`'s deadline | `IDLE_HYDRATE_TIMEOUT_MS`, interpolated INTO the runtime string and exported for `x shot`'s settle. |
|
|
68
71
|
| Route truth | `registry.ts`. Never a second route list and never a second matcher — `@ultimat3/http`'s trie (`stages.ts`) serves requests. `routeFor` is an exact-path `Map` lookup. |
|
|
69
72
|
| Route filename | `page.tsx` under `site/`/`app/` — `ROUTE_FILENAME`, keyed by `RouteSurface`. Anything else is `X_ROUTE_FILE_INVALID`, any file under `api/` or `shared/` included. |
|
|
70
|
-
| Mounted routes | `registerMountedRoutes(mount, routes)` (`mounted-routes.ts`)
|
|
73
|
+
| Mounted routes | `registerMountedRoutes(mount, routes)` (`mounted-routes.ts`): a package's routes with no surface file — described, never rendered here; a clash is `X_ROUTE_DUPLICATE` † |
|
|
71
74
|
| Registry input | descriptors only. `registerRoute` refuses a raw declaration with `X_ROUTE_UNNORMALIZED`; it fills in only the island budget. |
|
|
72
75
|
| Descriptors | `describePages()` stays JSON-safe, sorted by path, deterministic. |
|
|
73
76
|
| Every string order | `byCodeUnit` (`code-unit-order.ts`), never `localeCompare` (ICU default locale and collation version vary by machine). |
|
|
74
77
|
| Boundary | `surfaces.ts` throws; it never warns. Type-only edges are not violations. |
|
|
78
|
+
| Surface vocabulary | `SURFACES`/`Surface` are core's (`route-vocabulary.ts`); the `Surface` type is re-exported, `SURFACES` never (`X_HELPER_COPY`). `JsonValue` is schema's |
|
|
75
79
|
| Stream cancellation | the source has a `cancel()` and `write` is guarded on it; a disconnect aborts `StreamHole.resolve(signal)`. |
|
|
76
80
|
| ISR detach | `attach()`'s returned function clears the revalidator too — only if the slot is still its own (`installedRevalidator`). |
|
|
77
81
|
| "Is this a TTL?" has one reader | `parseTtlMs` in `duration.ts`, below `modes.ts` and `render-isr.ts`. |
|
|
@@ -83,21 +87,23 @@ axiom 6). Never `cli` (upward).
|
|
|
83
87
|
| Which route a stored ISR path is | exact path first, else the MOST SPECIFIC pattern: `route-pattern.ts`'s `compilePattern` (never a second compiler), sorted on `CompiledPattern.specificity`. Never table order: `describePages()` sorts `*` before `:`. |
|
|
84
88
|
| `CompiledPattern.specificity` | the ONE ordering rule, read by ISR, `@ultimat3/cli`'s sitemap extras and `@ultimat3/admin`'s `adminRouteMatch`: `@ultimat3/core`'s `routeRank(path)` — the request trie's order as one integer, shared with `@ultimat3/pwa`'s worker rule order. Never a local rank. |
|
|
85
89
|
| `compilePattern`'s regex | a `*catch-all` owns its separator, `(?:/(.*))?`, so the bare prefix `static-path.ts` writes for an empty rest (`/docs`) matches; a literal character matches raw OR percent-encoded, either hex case — a store key is `URL.pathname`, and `precios-españa` arrives as `precios-espa%C3%B1a`. `route-pattern.test.ts`. |
|
|
86
|
-
| Marking a page stale | `IsrStore.markStale(path)
|
|
87
|
-
| ISR store bound | `memoryIsrStore()
|
|
90
|
+
| Marking a page stale | `IsrStore.markStale(path)` in place, never `set({ ...entry, stale: true })`. |
|
|
91
|
+
| ISR store bound | `memoryIsrStore()`: entries + bytes, LRU (`markStale` keeps place). Shared: `storageIsrStore`, write-then-verify fence, oldest write first. Every call awaited. |
|
|
88
92
|
| A `RenderResult.status` | `finiteStatus(subject, status)` (`finite-status.ts`), 200–599 whole, at every site that takes one from a caller; `isRenderStatus` is the TOTAL read of a stored `IsrEntry.status`. The name carries `finite` so `bun run finite-bounds` recognises it. |
|
|
89
93
|
| `IsrEntry.ttlMs` off a store | normalised by `entryTtlMs`, TOTAL — anything not positive-finite is tag-only `null`, with an `isr.entry_ttl_invalid` warning. |
|
|
90
94
|
| Route path from file | `locateSurface()` answers which surface AND where it starts. Never re-derive the offset from the surface name. |
|
|
91
|
-
| An undecodable path segment |
|
|
92
|
-
| ISR registration | reconciled
|
|
95
|
+
| An undecodable path segment | no match, never a throw (`decodeSegment`, `registry.ts`). |
|
|
96
|
+
| ISR registration | reconciled with `store.paths()` once registrations outgrow the last listing (`forgetEvictedPaths`), best-effort after the result. A bust reads no page back. |
|
|
97
|
+
| A write vs an invalidation | the process fence is asked again AFTER `write` settles; moved → undone (`markStale` or `delete`, as the route purges), `cacheable: false` (`render-isr-store-storage.test.ts`). |
|
|
93
98
|
| Stream hole deadline | `DEFAULT_HOLE_TIMEOUT_MS` (15 s), `holeTimeoutMs: null` to opt out, otherwise a whole number ≥ 1. A hole reveals exactly once — promise, rejection or deadline. |
|
|
94
99
|
| Errors | `errors.ts` subclasses only, but for `navigation-errors.ts` (re-exported; keeps `./client` off the table). Never a bare `Error`, never a bare `TODO`. |
|
|
95
|
-
| Policy | render checks *presence* only
|
|
100
|
+
| Policy | render checks *presence* only; `@ultimat3/policy` evaluates. |
|
|
96
101
|
| A gated route is never a cached one | `modes.ts` refuses `policy` on both `static` and `isr` (`X_ROUTE_MODE_INVALID`, `modes.test.ts`). `ssr` is the one gated mode. Both also RENDER as nobody: `@ultimat3/cli` wraps them in http's `withAnonymousRequest` (`runtime-render-shared-actor.test.ts`). |
|
|
97
|
-
| Responses |
|
|
102
|
+
| Responses | `RenderResult`; `@ultimat3/http` builds the `Response`. |
|
|
98
103
|
| Who owns `cache-control` | a mode states intent; `@ultimat3/http`'s `cache-headers` stage decides and may overrule. This package cannot see the actor and never tries. |
|
|
99
104
|
| Solid | no `solid-js` import anywhere in this package; `type-pins.tsx` satisfies `JSX.Element` structurally. `jsx.ts` builds inert nodes. Islands are compiled by `@ultimat3/cli`'s `solid-loader.ts` with `babel-preset-solid`. |
|
|
100
105
|
| Root element | `ROOT_ELEMENT_ID` (`render-html.ts`). |
|
|
106
|
+
| The tree walker | `render-walk.ts`: synchronous until a promise or hole (a slot); never an `async` frame per node; its output rope is flattened every `FLATTEN_EVERY` (1,024) fragments — `scripts/bench/render-html.bench.test.ts` holds < 16 MiB live at 50k rows. |
|
|
101
107
|
| The loaders | `module-loader.ts` installs them at **`server.ts`** module scope, once. `packages/cli/src/app-load.ts` imports `@ultimat3/render/server` for that side effect. |
|
|
102
108
|
| Path style tag | `client-path-style-tag.ts` — `<meta name="ultimate-path-style">`, read by core's `actionPath`. Principal-free, on every document; written ONLY for a non-default style, so a `'resource'` app's bytes do not move. `@ultimat3/cli`'s `headFor` hands it `@ultimat3/action`'s `actionPathStyle()` per render — this package has no edge to `action`. |
|
|
103
109
|
| Client sync tags | `client-sync-tags.ts` — `ultimate-sync`, `ultimate-build`, `ultimate-sync-worker`. Principal-free, on every document. |
|
|
@@ -107,14 +113,14 @@ axiom 6). Never `cli` (upward).
|
|
|
107
113
|
| Script and style CONTENT | never raw: `escapeHtml`, `escapeRawTextContent` (`</` → `<\/`, `<!--` → `<\!--`), or `escapeJsonContent` for a `type` ending in `json`. Never HTML-escape a script body. |
|
|
108
114
|
| Which export is the page | `route-component.ts`: `Page` → a single `…Page` → a single capitalised function. |
|
|
109
115
|
| CSS-module scoping | `scopeClasses` rewrites class selectors in qualified-rule PRELUDES only (`inPreludes`) — never a declaration (`local(Inter.Regular)`), a comment or an at-rule prelude; a class is a whole CSS identifier, escapes included, and the map key is its unescaped name. The suffix hashes the basename + the COMPILED CSS, so two modules with one source and different partials never share a class name. |
|
|
110
|
-
| Stylesheets | compiled by `css-modules.ts`, grouped per surface, served by the CLI as one content-hashed file per surface (`@ultimat3/cli`'s `style-bundle.ts`) from `stylesFor`. `sass` is
|
|
116
|
+
| Stylesheets | compiled by `css-modules.ts`, grouped per surface, served by the CLI as one content-hashed file per surface (`@ultimat3/cli`'s `style-bundle.ts`) from `stylesFor`. `sass` is the only third-party dependency; every compile goes through `sass-cache.ts` (rule: `docs/history/render.md`). |
|
|
111
117
|
| CSS order | `stylesFor` sorts **globals before modules** (`isGlobalStylesheet`). `shared/` is carried by both graphs. |
|
|
112
118
|
| A package's sheets | carried by BOTH surfaces unless the package claims its directory: `claimStylesheets(import.meta.dir, 'app')` makes every sheet below it that surface's alone, still ordered with the library. `@ultimat3/admin` claims `app` — a `site/` document carried its dashboard CSS (axiom 6). A claim re-classifies sheets already registered and survives `clearStylesheets()`. |
|
|
113
119
|
| The global layer | the app's `shared/global.scss` `@use`s `@ultimat3/ui/global.scss`, side-effect-imported by `shared/global.ts` (this package may not import `ui`). `x verify` fails with `X_STYLES_GLOBAL_MISSING` when a surface's document defines none. |
|
|
114
120
|
| Colours | tokens and `data-theme` only. No hex in `head.ts` or any emitted script. |
|
|
115
121
|
| An island's `mount` | RETURNS its disposer: the router calls it on navigation, `mountIsland` on cleanup. Typed `void` or returning nothing is cli's `X_ISLAND_DISPOSER_MISSING` (`boundaries`). |
|
|
116
122
|
| `<head>` binding | `head.ts` stays injection-only; `head-seo.ts` is the ONE binding of `HeadRenderers` to `@ultimat3/seo`. |
|
|
117
|
-
| Client navigation | `navigation*.ts` — soft navigation over server-rendered documents, NOT a mode
|
|
123
|
+
| Client navigation | `navigation*.ts` — soft navigation over server-rendered documents, NOT a mode. controller `navigation.ts`, listeners `navigation-intercept.ts`, pure rules `navigation-rules.ts`; Chrome proof `packages/cli/e2e/client-navigation-*.e2e.test.ts`; never imports ui. `refresh()`: `navigation-refresh.ts`; `scheduleRefresh()`: `refresh-idle.ts` on `./client`, never reloads without the router. Full rule: `docs/history/render.md` |
|
|
118
124
|
| Modal on the click | `navigation-modal-frame.ts`: `modal.loading(url)` in `navigate`'s synchronous prefix opens the frame off `NAVIGATION_MODALS_META`; the answer's meta still decides. Closing aborts (`abandon`); the router `release()`s before its own dismissals; `settle()` in `finally`. Never `showModal()` where popovers exist, never a toggle on `<html>`/`<body>` ([why](../../docs/history/render.md#the-modal-that-opens-on-the-click)) |
|
|
119
125
|
| Router ↔ the page's lifecycle | `navigation-scroll.ts` owns `scrollRestoration = 'manual'` and RESTORES the entry's saved offset at start, before its first save (a reload, or Back after a full load). Full rule: `docs/history/render.md` |
|
|
120
126
|
| Router ↔ islands | ONE bootstrap: the swap re-runs the inline hydration runtime, whose `each` visits a root once per tab (`el.__v`). Never add a second mount path for the router. Dispose = call what `el.__x` resolved to. |
|
|
@@ -122,6 +128,7 @@ axiom 6). Never `cli` (upward).
|
|
|
122
128
|
| Router: nothing is sent twice | every fetch `cache: 'no-cache'` (#693), `redirect: 'manual'`, a POST never re-sent; the cache answers only a reusable 2xx and is emptied by every write signal; an answer is bounded by `NAVIGATION_TIMEOUT_MS`, past it a network failure, a refresh's QUIET (`navigation-deadline.ts`) ([full rule](../../docs/history/render.md#router-nothing-is-sent-twice)) |
|
|
123
129
|
| `Hole` | `hole.ts` imports only `@ultimat3/core/render-node` and is a branded array like `IslandNode`; every walker tests `isHoleNode` before `Array.isArray`. `render-html.ts`'s `HoleSink` is per render (`renderToHtml(tree, { islands, holes })`); only the CLI's `stream` branch passes one. Sinkless: children inline, so `budgets` weighs a hole's island; under a hole nested holes are inline |
|
|
124
130
|
| `hydrateRuntime(directives, { async })` | async while a hole is open and no boot is in the document; `route-islands.ts`'s `streamScripts` decides. Body and hash unchanged. Proof: `packages/cli/e2e/stream-hole.e2e.test.ts`, which fails without it |
|
|
131
|
+
| Instrumentation | `render-instrument.ts`: `render.page`/`.hole`/`.isr.regenerate` spans + bus events, keyed on the route pattern |
|
|
125
132
|
| A hole's failure | `error` markup, the log line, `reportError(source: 'http')`, `X_TIMEOUT` for a deadline; nothing once the client cancelled |
|
|
126
133
|
|
|
127
134
|
Cross-package: `@ultimat3/pwa` consumes route descriptors as **data**, never by import.
|
package/README.md
CHANGED
|
@@ -73,6 +73,16 @@ for a host assembling its own stream; `enter(signal, run)` is the host's scope f
|
|
|
73
73
|
`StreamHole` gains `error?` and `after?(outcome)` (asked on every reveal, failed ones too);
|
|
74
74
|
`hydrateRuntime(directives, { async: true })` is the runtime for a document still parsing.
|
|
75
75
|
|
|
76
|
+
## What a render tells the instrumentation bus
|
|
77
|
+
|
|
78
|
+
| Event | When | Payload |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `render.page` | each `renderComponent` — every mode | `route` (the registered PATTERN, `/blog/:slug`; the file for an unregistered one) |
|
|
81
|
+
| `render.hole` | each streamed `<Hole>` fill | `route`, `hole` (its id) |
|
|
82
|
+
| `render.isr.regenerate` | each ISR generation, never each request that joined it | `route`, `path` |
|
|
83
|
+
|
|
84
|
+
Each is an internal span of the same name carrying `http.route`, and an event with `durationMs` and `error` on failure → [Observability](https://github.com/developerz-ai/ultimate/wiki/Observability).
|
|
85
|
+
|
|
76
86
|
## `load` is the one server-side data seam
|
|
77
87
|
|
|
78
88
|
Optional, and the only way a page gets data. It runs **once per render** and the result is handed
|
|
@@ -557,7 +567,9 @@ side effect. Anything that loads an app's source — `x dev`, `x build`, `server
|
|
|
557
567
|
`@ultimat3/render/client` is the **browser** entry — what an island or a page script calls:
|
|
558
568
|
`navigate`, `refresh`, `openModal`, `closeModal`, `NavigateToOptions`,
|
|
559
569
|
`NavigationModalPathInvalidError`, `NAVIGATE_EVENT`, `NAVIGATED_EVENT`, `NAVIGATION_ERROR_EVENT`,
|
|
560
|
-
`
|
|
570
|
+
`NAVIGATION_MODAL_ATTRIBUTE` (the `data-x-modal` the router marks its `<dialog>` with — style
|
|
571
|
+
`dialog[data-x-modal]` off the constant, never a restated string), `disposeIslands`,
|
|
572
|
+
`scheduleRefresh`.
|
|
561
573
|
The barrel bundles for the browser but its `sideEffects` keeps `errors.ts` — render's code table,
|
|
562
574
|
and core's and schema's titles tables behind it — in every chunk that reaches it; this entry's
|
|
563
575
|
graph is the navigation helpers plus `@ultimat3/core/page` (`client-bundle.test.ts`). `As of
|
|
@@ -594,21 +606,10 @@ a job boundary the class is gone and the `code` is what survives — match on th
|
|
|
594
606
|
| Class | Code | Declared in |
|
|
595
607
|
|---|---|---|
|
|
596
608
|
| `AssetMissingError` | `X_ASSET_MISSING` | `src/errors.ts` |
|
|
597
|
-
| `BudgetExceededError` | `X_BUDGET_EXCEEDED` | `src/errors.ts` |
|
|
598
609
|
| `IslandInvalidError` | `X_ISLAND_INVALID` | `src/errors.ts` |
|
|
599
|
-
| `IslandNotHydratedError` | `X_ISLAND_NOT_HYDRATED` | `src/errors.ts` |
|
|
600
|
-
| `IslandPropsInvalidError` | `X_ISLAND_PROPS_INVALID` | `src/errors.ts` |
|
|
601
610
|
| `NavigationModalPathInvalidError` | `X_NAVIGATION_MODAL_PATH_INVALID` | `src/navigation-errors.ts` (re-exported by `src/errors.ts`; also on `/client`) |
|
|
602
|
-
| `PrerenderFailedError` | `X_PRERENDER_FAILED` | `src/errors.ts` |
|
|
603
611
|
| `RouteDuplicateError` | `X_ROUTE_DUPLICATE` | `src/errors.ts` |
|
|
604
|
-
| `RouteFileInvalidError` | `X_ROUTE_FILE_INVALID` | `src/errors.ts` |
|
|
605
|
-
| `RouteLoadFailedError` | `X_ROUTE_LOAD_FAILED` | `src/errors.ts` |
|
|
606
|
-
| `RouteLoadInvalidError` | `X_ROUTE_LOAD_INVALID` | `src/errors.ts` |
|
|
607
|
-
| `RouteMetaMissingError` | `X_ROUTE_META_MISSING` | `src/errors.ts` |
|
|
608
612
|
| `RouteModeInvalidError` | `X_ROUTE_MODE_INVALID` | `src/errors.ts` |
|
|
609
|
-
| `RouteOfflineMissingError` | `X_ROUTE_OFFLINE_MISSING` | `src/errors.ts` |
|
|
610
|
-
| `RouteStatusInvalidError` | `X_ROUTE_STATUS_INVALID` | `src/errors.ts` |
|
|
611
|
-
| `SurfaceBoundaryError` | `X_SURFACE_BOUNDARY` | `src/errors.ts` |
|
|
612
613
|
|
|
613
614
|
## Public API
|
|
614
615
|
|
|
@@ -623,7 +624,7 @@ a job boundary the class is gone and the `code` is what survives — match on th
|
|
|
623
624
|
| `MODE_SPECS`, `assertModeShape`, `assertModeInvariants` | the mode invariant table |
|
|
624
625
|
| `registerRoute`, `describePages`, `routeFor`, `routePathFromFile` | the route table |
|
|
625
626
|
| `registerMountedRoutes`, `RouteMount`, `RouteMountInput`, `MountedRouteInput` | routes a package mounts with no surface file: listed by `describePages()` with `mount: { by, permissions }`, absent from `routeEntries()` |
|
|
626
|
-
| `checkSurfaceBoundary`, `
|
|
627
|
+
| `checkSurfaceBoundary`, `surfaceOf` | the hard boundary |
|
|
627
628
|
| `renderStatic`†, `enumeratePrerender`† | build-time render, content hashing |
|
|
628
629
|
| `isrController`†, `invalidateAndRevalidate`† | SWR + single-flight + tag triggers |
|
|
629
630
|
| `isrKey`†, `isrRequestUrl`†, `undeclaredQuery`†, `isrRouteFor`† | the one derivation of an `isr` store key — the path in `@ultimat3/http`'s `canonicalPath` spelling, so every spelling the router answers with a page is that page's one entry — the request URL narrowed to `revalidate.query`, and the route a key reads back as (a key no route owns is never stored) |
|
|
@@ -637,8 +638,8 @@ a job boundary the class is gone and the `code` is what survives — match on th
|
|
|
637
638
|
| `ISLAND_MOUNTED_ATTRIBUTE`, `ISLAND_FAILED_ATTRIBUTE`, `IDLE_HYDRATE_TIMEOUT_MS` | what hydration looks like from outside the page |
|
|
638
639
|
| `ISLAND_HOLD_ATTRIBUTE`, `ISLAND_HOLD_MS`, `ISLAND_HOLD_REVEAL` | a held island's marker, and the cap after which it shows its server markup regardless |
|
|
639
640
|
| `parseByteBudget`, `defaultIslandBudget` | the `'40kb'` budget grammar, and the ceiling a declared island earns |
|
|
640
|
-
| `
|
|
641
|
-
| `zoneScript`, `zoneScriptBody
|
|
641
|
+
| `renderHead`, `themeScript` | `<head>` merge + the one inlined script; it stamps `data-theme` and, beside it, the fallback itself as `data-theme-default` for `@ultimat3/ui`'s `clearTheme`/`watchOsTheme` |
|
|
642
|
+
| `zoneScript`, `zoneScriptBody` | `time.detect`'s inline script, `app/` documents only: writes `x_timezone_detected` from `Intl`'s zone, which `@ultimat3/http` ranks below every chosen zone. Under 200 B; tag and CSP hash from one body |
|
|
642
643
|
| `clientNavigationTags`, `linkVerdict`, `formVerdict`, `responseVerdict`, `reusable`, `mayPrefetch`, `NAVIGATION_*` (`NAVIGATION_ERROR_EVENT`‡), `NAVIGATE_EVENT`‡, `NAVIGATED_EVENT`‡ | the client router's document tags and its pure rules; the router itself is `@ultimat3/render/navigation`, built and served by the CLI |
|
|
643
644
|
| `navigate`‡, `refresh`‡, `openModal`‡, `closeModal`‡, `NavigateToOptions`‡, `NavigationModalPathInvalidError`‡ | navigating from code: the router when the page has one, the browser's own load when not. Import from `/client` in an island |
|
|
644
645
|
| `scheduleRefresh`‡ | a `refresh()` once the visitor is idle, coalesced; never a reload |
|
|
@@ -646,6 +647,7 @@ a job boundary the class is gone and the `code` is what survives — match on th
|
|
|
646
647
|
| `modalAddress`, `modalLocation`, `addressOf`, `presentation`, `modalHistory`, `leaveModal`, `NAVIGATION_PRESENTATION_META`, `NAVIGATION_MODAL_ATTRIBUTE` | route-presented modals (`navigation: 'modal'`): the hash grammar, when an answer is a modal, and what leaving one does to history |
|
|
647
648
|
| `declaresModal`, `parseModalRoutes`, `modalRouteList`, `ModalRoutes`, `NAVIGATION_MODALS_META`, `NAVIGATION_MODAL_BODY_ATTRIBUTE`, `NAVIGATION_MODAL_CLOSE_ATTRIBUTE`, `NAVIGATION_MODAL_SKELETON_ATTRIBUTE` | the modal that opens on the click: the meta naming a surface's modal routes (composed by the server, read by the router) and the frame's attributes, styled by `@ultimat3/ui` |
|
|
648
649
|
| `isRouteNavigation`, `navigationModeOf`, `navigationPrefetches`, `RouteNavigationDeclaration`, `RouteModalPrefetch` | `navigation:` read back: the four spellings, which mode, prefetched or not |
|
|
650
|
+
| `@ultimat3/render/adapter` | the `isrStore` port (`IsrStore` and its entry shapes) and `AssetResolver`, the table `setAssetResolver` installs |
|
|
649
651
|
| `clientPathStyleTags`, `CLIENT_PATH_STYLE_META` | `<meta name="ultimate-path-style">` — the action path style the server serves, for the browser's typed client. No tag for `'resource'`, the default |
|
|
650
652
|
|
|
651
653
|
## Notes
|
|
@@ -658,8 +660,16 @@ a job boundary the class is gone and the `code` is what survives — match on th
|
|
|
658
660
|
pages by hand, so nobody forgets one. `controller.attach()` installs it as the
|
|
659
661
|
framework's `Revalidator`, and the function it returns releases **both** halves — the
|
|
660
662
|
dependents and the revalidator slot, the latter only while it is still this controller's.
|
|
661
|
-
The default store (`memoryIsrStore`) is capped at `DEFAULT_ISR_MAX_ENTRIES` (1,000) pages
|
|
662
|
-
|
|
663
|
+
The default store (`memoryIsrStore`) is capped at `DEFAULT_ISR_MAX_ENTRIES` (1,000) pages
|
|
664
|
+
AND `DEFAULT_ISR_MAX_BYTES` (256 MiB of `html.length`; `memoryIsrStore({ maxEntries, maxBytes })`),
|
|
665
|
+
least recently USED evicted first — a hit moves a page to the back, a stale mark does not, and a
|
|
666
|
+
page larger than the whole byte cap is not kept.
|
|
667
|
+
`storageIsrStore({ disk, maxEntries?, maxBytes?, sweepEvery?, prefix? })` is the SHARED store:
|
|
668
|
+
pages and tag-fence tokens as objects on any disk with `put`/`get`/`delete`/`list` (`IsrDisk` —
|
|
669
|
+
`@ultimat3/storage`'s `StorageDriver` as it is), so every replica reads one copy. A write is
|
|
670
|
+
checked, written and checked again (a disk has no compare-and-put); eviction is oldest write
|
|
671
|
+
first. Every `IsrStore` method may answer a promise (`IsrAnswer<T>`); the controller awaits each,
|
|
672
|
+
and `revalidateByTags` / `markStale` are async. One regeneration holds its page for at most
|
|
663
673
|
`DEFAULT_ISR_REGENERATE_DEADLINE_MS` (30 s; `isrController({ regenerateDeadlineMs })`),
|
|
664
674
|
so a render that never settles no longer pins the page for the life of the process. A stored
|
|
665
675
|
path takes its TTL and tags from the most specific matching route (static > `:param` >
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/render",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "31.0.0",
|
|
4
4
|
"description": "The route primitive and the five render modes: static, isr, ssr, stream, spa.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"exports": {
|
|
33
33
|
".": "./src/index.ts",
|
|
34
|
+
"./adapter": "./src/adapter.ts",
|
|
34
35
|
"./client": "./src/client.ts",
|
|
35
36
|
"./server": "./src/server.ts",
|
|
36
37
|
"./navigation": "./src/navigation-entry.ts"
|
|
@@ -51,11 +52,12 @@
|
|
|
51
52
|
"test": "bun test"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
|
-
"@ultimat3/cache": "
|
|
55
|
-
"@ultimat3/core": "
|
|
56
|
-
"@ultimat3/http": "
|
|
57
|
-
"@ultimat3/i18n": "
|
|
58
|
-
"@ultimat3/
|
|
59
|
-
"
|
|
55
|
+
"@ultimat3/cache": "31.0.0",
|
|
56
|
+
"@ultimat3/core": "31.0.0",
|
|
57
|
+
"@ultimat3/http": "31.0.0",
|
|
58
|
+
"@ultimat3/i18n": "31.0.0",
|
|
59
|
+
"@ultimat3/schema": "31.0.0",
|
|
60
|
+
"@ultimat3/seo": "31.0.0",
|
|
61
|
+
"sass": "1.106.1"
|
|
60
62
|
}
|
|
61
63
|
}
|
package/src/adapter.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// `@ultimat3/render/adapter`: the `isrStore` port (`ADAPTER_PORTS`) as an adapter author needs it —
|
|
2
|
+
// `IsrStore` and the entry shapes it keeps. No installer: the boot READS `runtime.ts`'s `isrStore`
|
|
3
|
+
// where it builds the ISR controller (`@ultimat3/cli`'s `serve-web.ts`); `memoryIsrStore` and
|
|
4
|
+
// `storageIsrStore` stay on `./server`. Types only, so this subpath costs no bundle a byte.
|
|
5
|
+
|
|
6
|
+
export type { AssetResolver } from './asset';
|
|
7
|
+
export type {
|
|
8
|
+
IsrAnswer,
|
|
9
|
+
IsrEntry,
|
|
10
|
+
IsrState,
|
|
11
|
+
IsrStore,
|
|
12
|
+
IsrTagFence,
|
|
13
|
+
} from './render-isr-store';
|
package/src/client-sync-tags.ts
CHANGED
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
* the socket. Principal-free, so a shareable document may carry them — unlike the scope tag.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
CLIENT_BUILD_META,
|
|
9
|
+
CLIENT_OUTBOX_MAX_META,
|
|
10
|
+
CLIENT_SYNC_META,
|
|
11
|
+
CLIENT_SYNC_WORKER_META,
|
|
12
|
+
} from '@ultimat3/core';
|
|
8
13
|
import type { HeadTag } from './head';
|
|
9
14
|
|
|
10
15
|
export interface ClientSyncHead {
|
|
@@ -13,6 +18,8 @@ export interface ClientSyncHead {
|
|
|
13
18
|
readonly workerUrl?: string | undefined;
|
|
14
19
|
/** `/_x/assets/page-boot/<hash>.js` — realtime's page boot, when the app has realtime. */
|
|
15
20
|
readonly bootUrl?: string | undefined;
|
|
21
|
+
/** `realtime.maxQueued`: the page outbox's ceiling, which the boot builds it with. */
|
|
22
|
+
readonly outboxMaxQueued?: number | undefined;
|
|
16
23
|
}
|
|
17
24
|
|
|
18
25
|
export function clientSyncTags(head: ClientSyncHead): readonly HeadTag[] {
|
|
@@ -20,6 +27,9 @@ export function clientSyncTags(head: ClientSyncHead): readonly HeadTag[] {
|
|
|
20
27
|
meta(CLIENT_SYNC_META, head.syncUrl),
|
|
21
28
|
meta(CLIENT_BUILD_META, head.buildId),
|
|
22
29
|
...(head.workerUrl === undefined ? [] : [meta(CLIENT_SYNC_WORKER_META, head.workerUrl)]),
|
|
30
|
+
...(head.outboxMaxQueued === undefined
|
|
31
|
+
? []
|
|
32
|
+
: [meta(CLIENT_OUTBOX_MAX_META, String(head.outboxMaxQueued))]),
|
|
23
33
|
];
|
|
24
34
|
}
|
|
25
35
|
|
package/src/client.ts
CHANGED
|
@@ -13,6 +13,8 @@ export { disposeIslands } from './island-dispose';
|
|
|
13
13
|
export type { NavigateToOptions } from './navigation-api';
|
|
14
14
|
export { closeModal, navigate, openModal, refresh } from './navigation-api';
|
|
15
15
|
export { NavigationModalPathInvalidError } from './navigation-errors';
|
|
16
|
+
// What the router marks its modal `<dialog>` with: `dialog[${NAVIGATION_MODAL_ATTRIBUTE}]` in a style.
|
|
17
|
+
export { NAVIGATION_MODAL_ATTRIBUTE } from './navigation-modal-rules';
|
|
16
18
|
export { NAVIGATE_EVENT, NAVIGATED_EVENT, NAVIGATION_ERROR_EVENT } from './navigation-rules';
|
|
17
19
|
// A channel said the page changed: re-read it once the visitor is idle (`refresh-idle.ts`).
|
|
18
20
|
export { scheduleRefresh } from './refresh-idle';
|
package/src/html.ts
CHANGED
|
@@ -135,46 +135,85 @@ export function styleValue(value: unknown): string | null {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* a broken inline handler that looks like it works.
|
|
138
|
+
* What a prop NAME means, decided once: the name every check below reads off is a pure function of
|
|
139
|
+
* the string, and a big page asks the same five names a million times. `null` = never emitted.
|
|
141
140
|
*/
|
|
142
|
-
|
|
141
|
+
interface NameVerdict {
|
|
142
|
+
readonly attribute: string;
|
|
143
|
+
readonly kind: 'plain' | 'style' | 'url';
|
|
144
|
+
/** The lowercased spelling `safeUrl` is keyed on. */
|
|
145
|
+
readonly folded: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function judgeName(name: string): NameVerdict | null {
|
|
143
149
|
if (NON_ATTRIBUTES.has(name)) return null;
|
|
144
|
-
if (value === undefined || value === null || value === false) return null;
|
|
145
|
-
if (typeof value === 'function') return null;
|
|
146
150
|
if (!isAttributeName(name)) return null;
|
|
147
151
|
// Folded, because HTML attribute names are case-insensitive and the two checks below already
|
|
148
152
|
// fold: `ONERROR="alert(1)"` went out on the wire off a spread row for as long as this line was
|
|
149
153
|
// `name.startsWith('on')`.
|
|
150
|
-
if (name.toLowerCase().startsWith('on')
|
|
151
|
-
|
|
154
|
+
if (name.length > 2 && name.toLowerCase().startsWith('on')) return null;
|
|
152
155
|
const attribute = ATTRIBUTE_ALIASES.get(name) ?? name;
|
|
153
|
-
|
|
156
|
+
const folded = attribute.toLowerCase();
|
|
157
|
+
if (REFUSED_ATTRIBUTES.has(folded)) return null;
|
|
158
|
+
if (attribute === 'style') return { attribute, kind: 'style', folded };
|
|
159
|
+
return { attribute, kind: URL_BEARING_ATTRIBUTES.has(folded) ? 'url' : 'plain', folded };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Bounded: a name can come off a spread row (`<div {...row} />`), so the set of names is the
|
|
164
|
+
* data's, not the code's. Past the cap a name is judged every time — correct, only slower.
|
|
165
|
+
*/
|
|
166
|
+
const NAME_CACHE_MAX = 1024;
|
|
167
|
+
const nameCache = new Map<string, NameVerdict | null>();
|
|
168
|
+
|
|
169
|
+
function verdictOf(name: string): NameVerdict | null {
|
|
170
|
+
const cached = nameCache.get(name);
|
|
171
|
+
if (cached !== undefined || nameCache.has(name)) return cached ?? null;
|
|
172
|
+
const verdict = judgeName(name);
|
|
173
|
+
if (nameCache.size < NAME_CACHE_MAX) nameCache.set(name, verdict);
|
|
174
|
+
return verdict;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* One prop → one attribute string, or `null` when it emits nothing. Event handlers are dropped
|
|
179
|
+
* rather than stringified: the server has no listeners, and `onclick="function(){…}"` would ship
|
|
180
|
+
* a broken inline handler that looks like it works.
|
|
181
|
+
*/
|
|
182
|
+
export function attributePair(name: string, value: unknown): string | null {
|
|
183
|
+
if (value === undefined || value === null || value === false) return null;
|
|
184
|
+
if (typeof value === 'function') return null;
|
|
185
|
+
const verdict = verdictOf(name);
|
|
186
|
+
if (verdict === null) return null;
|
|
187
|
+
const { attribute } = verdict;
|
|
154
188
|
if (value === true) return attribute;
|
|
155
|
-
if (
|
|
189
|
+
if (verdict.kind === 'style') {
|
|
156
190
|
const style = styleValue(value);
|
|
157
191
|
return style === null ? null : `style="${escapeHtml(style)}"`;
|
|
158
192
|
}
|
|
159
|
-
const text = String(value);
|
|
193
|
+
const text = typeof value === 'string' ? value : String(value);
|
|
160
194
|
// Escaping makes a value inert inside the quotes; it cannot make a SCHEME inert, because
|
|
161
195
|
// `href="javascript:alert(1)"` never leaves them. One choke point for both, here, because this
|
|
162
196
|
// module is the single place injection is prevented and an href off a database row is the shape
|
|
163
197
|
// every app writes. A refused URL emits no attribute at all — an anchor with no `href` is inert
|
|
164
198
|
// and still renders its text, where a blanked one is a live link nobody checked.
|
|
165
|
-
if (
|
|
166
|
-
const url = safeUrl(text,
|
|
199
|
+
if (verdict.kind === 'url') {
|
|
200
|
+
const url = safeUrl(text, verdict.folded);
|
|
167
201
|
if (url === null) return null;
|
|
168
202
|
return `${attribute}="${escapeHtml(url)}"`;
|
|
169
203
|
}
|
|
170
204
|
return `${attribute}="${escapeHtml(text)}"`;
|
|
171
205
|
}
|
|
172
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Own enumerable keys, as `Object.entries` gave, without building a pair array per element: on a
|
|
209
|
+
* 50k-row page that allocation was the walker's single largest cost (plan 101 slice 14 P1).
|
|
210
|
+
*/
|
|
173
211
|
export function renderAttributes(props: JsxProps): string {
|
|
174
|
-
|
|
175
|
-
for (const
|
|
176
|
-
|
|
177
|
-
|
|
212
|
+
let out = '';
|
|
213
|
+
for (const name in props) {
|
|
214
|
+
if (!Object.hasOwn(props, name)) continue;
|
|
215
|
+
const pair = attributePair(name, props[name]);
|
|
216
|
+
if (pair !== null) out += ` ${pair}`;
|
|
178
217
|
}
|
|
179
|
-
return
|
|
218
|
+
return out;
|
|
180
219
|
}
|
package/src/index.ts
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export type { HydrateStrategy, OfflineStrategy, RenderMode } from '@ultimat3/core';
|
|
16
16
|
/** `asset('assets/x.avif')` → the content-hashed URL the site asset surface serves it at. */
|
|
17
|
-
export type { AssetExtension, AssetPath
|
|
18
|
-
export { ASSET_DIR,
|
|
17
|
+
export type { AssetExtension, AssetPath } from './asset';
|
|
18
|
+
export { ASSET_DIR, asset, assetPathProblem, setAssetResolver } from './asset';
|
|
19
19
|
/** The `<meta name="ultimate-path-style">` core's `actionPath` reads — a non-default style only. */
|
|
20
20
|
export { clientPathStyleTags } from './client-path-style-tag';
|
|
21
21
|
export { clientPinTags } from './client-pins-tag';
|
|
@@ -35,25 +35,12 @@ export { parseTtlMs } from './duration';
|
|
|
35
35
|
export type { RenderErrorCode } from './errors';
|
|
36
36
|
export {
|
|
37
37
|
AssetMissingError,
|
|
38
|
-
BudgetExceededError,
|
|
39
38
|
IslandInvalidError,
|
|
40
|
-
IslandNotHydratedError,
|
|
41
|
-
IslandPropsInvalidError,
|
|
42
39
|
NavigationModalPathInvalidError,
|
|
43
|
-
PrerenderFailedError,
|
|
44
|
-
RENDER_ERROR_CODES,
|
|
45
|
-
RENDER_ERROR_TITLES,
|
|
46
40
|
RouteDuplicateError,
|
|
47
|
-
RouteFileInvalidError,
|
|
48
|
-
RouteLoadFailedError,
|
|
49
|
-
RouteLoadInvalidError,
|
|
50
|
-
RouteMetaMissingError,
|
|
51
41
|
RouteModeInvalidError,
|
|
52
42
|
RouteNavigationInvalidError,
|
|
53
|
-
RouteOfflineMissingError,
|
|
54
43
|
RoutePostInvalidError,
|
|
55
|
-
RouteStatusInvalidError,
|
|
56
|
-
SurfaceBoundaryError,
|
|
57
44
|
} from './errors';
|
|
58
45
|
export type {
|
|
59
46
|
HeadRenderers,
|
|
@@ -67,7 +54,6 @@ export type {
|
|
|
67
54
|
export {
|
|
68
55
|
documentBaseline,
|
|
69
56
|
headFromMeta,
|
|
70
|
-
mergeHead,
|
|
71
57
|
renderHead,
|
|
72
58
|
themeScript,
|
|
73
59
|
themeScriptBody,
|
|
@@ -106,7 +92,6 @@ export {
|
|
|
106
92
|
assertModeInvariants,
|
|
107
93
|
assertModeShape,
|
|
108
94
|
DEFAULT_ISLAND_JS_BYTES,
|
|
109
|
-
defaultHydrate,
|
|
110
95
|
defaultIslandBudget,
|
|
111
96
|
MODE_SPECS,
|
|
112
97
|
} from './modes';
|
|
@@ -118,8 +103,8 @@ export {
|
|
|
118
103
|
export type { NavigateToOptions } from './navigation-api';
|
|
119
104
|
export { closeModal, navigate, openModal, refresh } from './navigation-api';
|
|
120
105
|
/** Client-side navigation over server-rendered documents — `navigation: { client }` surfaces. */
|
|
121
|
-
export type {
|
|
122
|
-
export { cacheKey,
|
|
106
|
+
export type { NavigationCache, NavigationCacheOptions } from './navigation-cache';
|
|
107
|
+
export { cacheKey, navigationCache } from './navigation-cache';
|
|
123
108
|
export type { ModalRoutes, Presentation, PresentationFacts } from './navigation-modal-rules';
|
|
124
109
|
export {
|
|
125
110
|
addressOf,
|
|
@@ -155,15 +140,10 @@ export {
|
|
|
155
140
|
NAVIGATE_EVENT,
|
|
156
141
|
NAVIGATED_EVENT,
|
|
157
142
|
NAVIGATING_ATTRIBUTE,
|
|
158
|
-
NAVIGATION_CACHE_TTL_MS,
|
|
159
143
|
NAVIGATION_ERROR_EVENT,
|
|
160
|
-
NAVIGATION_MAX_HOPS,
|
|
161
144
|
NAVIGATION_META,
|
|
162
145
|
NAVIGATION_NO_PREFETCH_ATTRIBUTE,
|
|
163
|
-
NAVIGATION_NO_STORE_REUSE_MS,
|
|
164
146
|
NAVIGATION_PERSIST_ATTRIBUTE,
|
|
165
|
-
NAVIGATION_PREFETCH_DELAY_MS,
|
|
166
|
-
NAVIGATION_PROGRESS_DELAY_MS,
|
|
167
147
|
NAVIGATION_RELOAD_ATTRIBUTE,
|
|
168
148
|
responseVerdict,
|
|
169
149
|
reusable,
|
|
@@ -212,7 +192,7 @@ export type {
|
|
|
212
192
|
RouteMetaFn,
|
|
213
193
|
RouteParams,
|
|
214
194
|
} from './route';
|
|
215
|
-
export {
|
|
195
|
+
export { defineRoute, isRouteConfig } from './route';
|
|
216
196
|
export type { RouteComponent } from './route-component';
|
|
217
197
|
export { pageComponentOf } from './route-component';
|
|
218
198
|
export { metaContextFor, routeDataFor } from './route-data';
|
|
@@ -248,12 +228,10 @@ export type {
|
|
|
248
228
|
SurfaceSpec,
|
|
249
229
|
} from './surfaces';
|
|
250
230
|
export {
|
|
251
|
-
assertSurfaceBoundary,
|
|
252
231
|
checkSurfaceBoundary,
|
|
253
232
|
importGraph,
|
|
254
233
|
SURFACE_SPECS,
|
|
255
|
-
SURFACES,
|
|
256
234
|
surfaceAllows,
|
|
257
235
|
surfaceOf,
|
|
258
236
|
} from './surfaces';
|
|
259
|
-
export {
|
|
237
|
+
export { zoneScript, zoneScriptBody } from './zone-script';
|
package/src/island-props.ts
CHANGED
|
@@ -4,16 +4,12 @@
|
|
|
4
4
|
* reaches the browser is this bag, and every rule here is about what must not travel.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import type { JsonValue } from '@ultimat3/schema';
|
|
7
8
|
import { IslandPropsInvalidError } from './errors';
|
|
8
9
|
import type { JsxProps } from './jsx';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
| number
|
|
13
|
-
| boolean
|
|
14
|
-
| null
|
|
15
|
-
| readonly JsonValue[]
|
|
16
|
-
| { readonly [key: string]: JsonValue };
|
|
11
|
+
// `@ultimat3/schema`'s one declaration, re-exported for this package's callers — never restated.
|
|
12
|
+
export type { JsonValue };
|
|
17
13
|
|
|
18
14
|
export type IslandProps = Readonly<Record<string, JsonValue>>;
|
|
19
15
|
|
package/src/jsx.ts
CHANGED
|
@@ -53,7 +53,13 @@ export function h(
|
|
|
53
53
|
// The overloads above are where a call is checked; a node carries the pair erased, which is all
|
|
54
54
|
// `render-html.ts` ever reads — it hands `props` back to the `type` it arrived with.
|
|
55
55
|
const erased = type as string | JsxComponent;
|
|
56
|
-
|
|
56
|
+
if (props === null) {
|
|
57
|
+
// No props to copy: the spread below cloned an empty object for every bare `<td>` on the page.
|
|
58
|
+
if (children.length === 0) return { [JSX_NODE]: true, type: erased, props: {} };
|
|
59
|
+
const only = children.length === 1 ? children[0] : children;
|
|
60
|
+
return { [JSX_NODE]: true, type: erased, props: { children: only } };
|
|
61
|
+
}
|
|
62
|
+
const base = props as JsxProps;
|
|
57
63
|
if (children.length === 0) return { [JSX_NODE]: true, type: erased, props: base };
|
|
58
64
|
return {
|
|
59
65
|
[JSX_NODE]: true,
|
|
@@ -49,6 +49,18 @@ export function saveEntryScroll(win: Window, rendered: string): void {
|
|
|
49
49
|
win.history.replaceState({ ...state, [STATE_KEY]: entry }, '');
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* The entry a swapped-in page gets: pushed for a new visit, replaced for the same URL (or when
|
|
54
|
+
* asked), none on a back/forward — whose entry already names the page.
|
|
55
|
+
*/
|
|
56
|
+
export function recordEntry(win: Window, landed: string, doc: string, mode: HistoryMode): void {
|
|
57
|
+
if (mode === 'none') return;
|
|
58
|
+
const same = landed === win.location.href || mode === 'replace';
|
|
59
|
+
const state = { [STATE_KEY]: { scroll: [0, 0], doc } satisfies EntryState };
|
|
60
|
+
if (same) win.history.replaceState(state, '', landed);
|
|
61
|
+
else win.history.pushState(state, '', landed);
|
|
62
|
+
}
|
|
63
|
+
|
|
52
64
|
/**
|
|
53
65
|
* Where the new page lands: the saved offset on back/forward, the fragment's element, else the
|
|
54
66
|
* top. `instant`, whatever the page's `scroll-behavior` says — `@ultimat3/ui`'s reset makes it
|