@ultimat3/render 6.0.0 → 7.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 CHANGED
@@ -30,7 +30,7 @@ Tier 4. May import tiers 0–3: `core`, `schema`, `i18n`, `money`, `time`, `cach
30
30
  | Island timing | the route's `hydrate` and nothing else — derived from the declaration, never declared on the island. An island declaring its own strategy would be a second way to say "this route hydrates" (axiom 1) and a second thing `budget.js` would have to chase. `hydrate: 'never'` + an island is still `X_ISLAND_NOT_HYDRATED`, and so is an `island()` call *below* the `defineRoute` that drains it. The `fix:` names exactly ONE of the two edits — `islandNeverDrained(spec)` tells the causes apart at the throw site, and a message offering both makes half the instruction wrong for every reader. |
31
31
  | Island node shape | a **branded array** (`IslandNode extends Array<never>`), and every walker tests `isIslandNode` BEFORE `Array.isArray`. An app types JSX with `jsxImportSource: solid-js`, whose `JSX.Element` is a type ALIAS — unaugmentable — and whose only object-shaped member is `ArrayElement`; a plain object was TS2786 at every `<Island />`, so the feature only worked through `h(Island, …)`, which is what render's own tests used. The array stays empty; the shell is `props.children`. Never satisfy this by importing solid's union. |
32
32
  | Island declaration order | `island()` above `defineRoute`, drained by it (`drainDeclaredIslands`). Package-internal — reachable from `./island`, never re-exported by `src/index.ts`: an app calling the drain between its `island()` and its `defineRoute` would silently un-declare the islands the route derives everything from, and a public export is semver-locked the moment it ships. Ambient, and NOT the thing the collector refuses to be: that one is per RENDER, where two requests would bill each other; this one is per MODULE, evaluated once, before any request — and `src` is resolved relative to the route file, so an `island()` call is route-module-local by construction. |
33
- | Derived budget | `registry.ts`, not `defineRoute`: a ceiling is only meaningful against a surface baseline, and the surface is a fact of the file path the route table already reads. `site/` → `4kb`, `app/` → `18kb` (`DEFAULT_ISLAND_JS_BYTES` above `jsBaselineBytes`). A declared `budget.js` wins; a `'never'` route gets none, so the contradiction stays visible. |
33
+ | Derived budget | `registry.ts`, not `defineRoute`: a ceiling is only meaningful against a surface baseline, and the surface is a fact of the file path the route table already reads. `site/` → `20kb`, `app/` → `34kb` (`DEFAULT_ISLAND_JS_BYTES` above `jsBaselineBytes`). **Calibrated on a Solid island** `As of 2026-08`: it was `4kb`, sized from `contact-sales.island.tsx`, which imports no `solid-js` at all — and `render(() => <p>hello</p>, el)` measures 12,588 B, so the default sat a factor of three below the floor of every island that uses the JSX runtime, on every surface. A declared `budget.js` wins; a `'never'` route gets none, so the contradiction stays visible. |
34
34
  | `RouteEntry.islands` | filled from `config.islands` at registration, and from nothing else — `RegisterRouteInput` has no `islands` key. It was `input.islands ?? []`, undocumented and passed by nothing, so `routeJsBytes`'s "what registration declared" half read `[]` on every route in the framework's history; keeping it as a fallback would be a second answer to one question that can only ever weaken it, since a caller passing `[]` un-weighs a declared island. |
35
35
  | Island props | declared, JSON-safe, under `ISLAND_PROPS_MAX_BYTES` — `island-props.ts` is the one gate. A structural walk, never a `JSON.stringify` round trip: stringify drops a function and an `undefined` silently, which is the footgun rather than the check. |
36
36
  | A prop lands via `Object.defineProperty` | never `out[key] = v`. For exactly one name — `__proto__`, which `JSON.parse` mints as a real OWN key off any request body — the assignment runs `Object.prototype`'s setter: the prop was DROPPED from the browser payload (the footgun the walk exists to prevent), the record handed back as `IslandProps` carried a prototype built from request data, so a later `bag.row.isAdmin` on the SERVER read attacker-chosen values, and `ISLAND_PROPS_MAX_BYTES` under-counted because `JSON.stringify` could not see it. Same shape `@ultimat3/mcp`'s `validate-args.ts` uses for the same class. |
@@ -40,6 +40,8 @@ Tier 4. May import tiers 0–3: `core`, `schema`, `i18n`, `money`, `time`, `cach
40
40
  | Island bytes | `routeJsBytes` unions `entry.islands` with the rendered directives' `moduleId`s. Reading either alone is a budget that counts the runtime and not the chunk. |
41
41
  | Island markup | the props `<script>` is emitted INSIDE the wrapper by `render-html.ts`, so a document assembler has exactly one thing left to remember: `hydrateRuntime(directives)`. |
42
42
  | Island boot | `el.__x` holds the boot PROMISE, never a boolean. As a flag, a second interaction while the chunk was still loading got a resolved promise back and the replay queue flushed into an island that had not mounted — the events went nowhere and the listeners were already removed. |
43
+ | Island mount markers | `data-x-mounted=""` when `mount()` RESOLVED, `data-x-failed="<message>"` when it rejected — set by the runtime, never by `emitIslandAttributes`, because the server does not know the answer. `el.__x` alone cannot carry this: it is assigned when `import()` is CALLED, so a chunk still downloading and one whose `mount()` threw were the same observable, and telling those apart is what `x shot` gates on. Two attributes rather than two values of one, so `[data-x-mounted]` never counts a failure as a success. The rejection handler RETHROWS — swallowing it resolves `el.__x` and the interaction runtime flushes its replay queue into an island that never mounted, which is the row above reintroduced one layer out. Costs 129 B of shared prelude: `idle` 744, `visible` 816, `interaction` 1,010 (`As of 2026-08-21`, the numbers `DEFAULT_ISLAND_JS_BYTES` is derived from). |
44
+ | `idle`'s deadline | `IDLE_HYDRATE_TIMEOUT_MS`, interpolated INTO the runtime string. Exported because a second reader has to agree — `x shot` waits before it photographs, and a settle shorter than this deadline reports an unhydrated page for one that hydrates perfectly. A constant the emitted string restates instead of reading is worse than no constant. |
43
45
  | Route truth | `registry.ts`. Never keep a second route list anywhere. |
44
46
  | Route filename | `page.tsx` under `site/`/`app/`, `route.ts` under `api/` — `ROUTE_FILENAME`, one per surface. The URL is the directory path. Anything else is `X_ROUTE_FILE_INVALID`; never widen the table to accept a second spelling. |
45
47
  | Registry input | descriptors only. `registerRoute` refuses a raw declaration with `X_ROUTE_UNNORMALIZED` — `defineRoute` is the one normalizer of everything the declaration alone decides, and every reader downstream assumes it ran. The registry fills in exactly one value on top: the island budget, which needs the surface, which is a fact of the file path only the route table reads. |
package/README.md CHANGED
@@ -184,15 +184,45 @@ out three things. `hydrate` and `budget.js` are **derived from `island()`**, `As
184
184
  | Omitted | Derived | Overridden by |
185
185
  |---|---|---|
186
186
  | `hydrate` | `'interaction'` when the module declared an island, `'never'` when it did not | stating `hydrate` — the only way to say `idle` or `visible` |
187
- | `budget.js` | the surface baseline + 4kb (`site/` → `4kb`, `app/` → `18kb`) | stating `budget: { js }` |
187
+ | `budget.js` | the surface baseline + 20kb (`site/` → `20kb`, `app/` → `34kb`) | stating `budget: { js }` |
188
188
 
189
189
  Both were required and both were punished: an island on a route still at `'never'` is
190
190
  `X_ISLAND_NOT_HYDRATED`, and a `site/` route off `'never'` with no `budget.js` is refused at
191
191
  registration. Two failures for one omission the `island()` call above had already answered.
192
192
 
193
- 4kb because the reference app's real island is 875 B of chunk plus a 1,019 B runtime — room for a
194
- second small island, not enough to hide a library. It is a ceiling, not a pass: exceeding it is
195
- `X_BUDGET_EXCEEDED`, naming the island.
193
+ 20kb because a Solid island cannot cost less. Measured through `buildIslands`, minified, against
194
+ production Solid, `As of 2026-08`:
195
+
196
+ | Island | Bytes |
197
+ |---|---|
198
+ | `render(() => <p>hello</p>, el)` — the floor, before an author writes a line | 12,588 |
199
+ | a signal, a button and reactive text | 13,663 |
200
+ | `settings.island.tsx`, the heaviest island this repo ships | 17,797 |
201
+ | one directive's hydration runtime at `hydrate: 'idle'` | 615 |
202
+ | the same at `'interaction'`, which is what an island route declaring no `hydrate` gets | 881 |
203
+
204
+ 17,797 + 881 = **18,678** — the heaviest island this repo ships, plus the runtime an app pays
205
+ without writing a number down. `DEFAULT_ISLAND_HYDRATE` is `'interaction'`
206
+ ([`route.ts:33`](src/route.ts)), applied at `:253` to any island route that states no `hydrate`, so
207
+ `idle`'s 615 is the cheaper case and not the one a budget has to clear.
208
+
209
+ The default is **20,480** (20kb), which is not that number rounded: the next whole kilobyte above
210
+ it is 19,456, and clearing today's worst island by 778 bytes is a ceiling the next line anyone
211
+ writes breaks. 20kb leaves 1,802 B, and stays under 2× 18,678 — so a route that bundles the same
212
+ island twice is still refused. All three clauses are assertions in
213
+ [`modes.test.ts`](src/modes.test.ts)'s `DEFAULT_ISLAND_JS_BYTES` block, against the measured
214
+ table above; a default that stopped clearing the floor, or stopped being a ceiling, is red.
215
+
216
+ It was **4kb** until `As of 2026-08`, sized from `contact-sales.island.tsx` — 875 B of chunk, and
217
+ no `solid-js` import anywhere in it. Calibrating a JSX budget on the one island shape that does not
218
+ pay the JSX runtime put the default a factor of three below the floor of every island that does:
219
+ no `budget.js` under 4096 was reachable on any surface, because the allowance is measured ABOVE the
220
+ baseline and not against it. (Its second number was wrong too — one directive's hydration runtime
221
+ is 615 B at `idle` and 881 B at `interaction`, never 1,019.)
222
+
223
+ Still a ceiling and not a pass: exceeding it is `X_BUDGET_EXCEEDED`, naming the island. An island
224
+ that pulls a design system in — `@ultimat3/ui`'s `<Switch>` measures 36,335 B — writes its own
225
+ number down, which is the point of the field.
196
226
 
197
227
  `island()` goes **above** `defineRoute`, where JavaScript already puts a `const` the page uses:
198
228
  `defineRoute` drains the declarations made before it. Below it, the route resolves to `'never'` and
@@ -205,7 +235,7 @@ route's — because two islands wanting different timings would leave `RouteDesc
205
235
  | The route says | The island says |
206
236
  |---|---|
207
237
  | `hydrate` — WHEN it wakes, once, for the whole route, and only when the default is wrong | `src` — WHICH module, and `props` — what it may receive |
208
- | `budget.js` — how many bytes that is allowed to cost, when 4kb is not the number | `tag`, `events`, `rootMargin` — how the wrapper behaves |
238
+ | `budget.js` — how many bytes that is allowed to cost, when 20kb is not the number | `tag`, `events`, `rootMargin` — how the wrapper behaves |
209
239
 
210
240
  ### An island node is a JSX child
211
241
 
@@ -271,6 +301,26 @@ island (remove it), or the `island()` call sits below the `defineRoute` that wou
271
301
  be drained. A `'never'` route is also left with no derived budget, deliberately — a ceiling there
272
302
  would paper over the contradiction.
273
303
 
304
+ ### "Booted" and "mounted" are different facts, and the DOM says which
305
+
306
+ | In the DOM | Means |
307
+ |---|---|
308
+ | `data-x-island`, `data-x-hydrate` | **declared** — emitted for every island, `'never'` included |
309
+ | `el.__x` set, neither marker | **importing** — the chunk was requested, `mount()` has not settled |
310
+ | `data-x-mounted=""` | **running** — `mount()` resolved |
311
+ | `data-x-failed="<message>"` | **threw** — `mount()` rejected, and this is why |
312
+
313
+ `el.__x` is assigned when `import()` is *called*, so on its own it cannot tell a chunk still
314
+ downloading from one whose `mount()` threw — and the second is the half that gates a deploy. Both
315
+ markers are set by the runtime, never by `emitIslandAttributes`: the server does not know the
316
+ answer. A rejection still rethrows, so `el.__x` stays rejected and the `interaction` replay queue is
317
+ never flushed into an island that did not mount. `ISLAND_MOUNTED_ATTRIBUTE` and
318
+ `ISLAND_FAILED_ATTRIBUTE` are exported so a reader (`x shot`, an app's own test) names them once.
319
+
320
+ `IDLE_HYDRATE_TIMEOUT_MS` (2000) is the `requestIdleCallback` deadline the `idle` runtime is built
321
+ from, exported for the same reason: anything waiting for hydration has to wait at least this long,
322
+ and a second copy of the number is a settle that shoots early and calls a healthy page broken.
323
+
274
324
  ## Public API
275
325
 
276
326
  | Export | Owns |
@@ -284,6 +334,7 @@ would paper over the contradiction.
284
334
  | `createIsrController`, `invalidateAndRevalidate` | SWR + single-flight + tag triggers |
285
335
  | `renderSsr`, `streamResult` | the per-request modes |
286
336
  | `emitIslandAttributes`, `hydrateRuntime` | the four hydration strategies |
337
+ | `ISLAND_MOUNTED_ATTRIBUTE`, `ISLAND_FAILED_ATTRIBUTE`, `IDLE_HYDRATE_TIMEOUT_MS` | what hydration looks like from outside the page |
287
338
  | `graphFor`, `checkBudget`, `assertBudget` | two bundle graphs, per-route budgets |
288
339
  | `mergeHead`, `renderHead`, `themeScript` | `<head>` merge + the one inlined script |
289
340
 
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@ultimat3/render",
3
- "version": "6.0.0",
3
+ "version": "7.0.0",
4
4
  "description": "The route primitive and the five render modes: static, isr, ssr, stream, spa.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
+ "sideEffects": [
8
+ "./src/errors.ts",
9
+ "./src/index.ts"
10
+ ],
7
11
  "repository": {
8
12
  "type": "git",
9
13
  "url": "git+https://github.com/developerz-ai/ultimate.git",
@@ -31,10 +35,10 @@
31
35
  "test": "bun test"
32
36
  },
33
37
  "dependencies": {
34
- "@ultimat3/cache": "6.0.0",
35
- "@ultimat3/core": "6.0.0",
36
- "@ultimat3/i18n": "6.0.0",
37
- "@ultimat3/seo": "6.0.0",
38
+ "@ultimat3/cache": "7.0.0",
39
+ "@ultimat3/core": "7.0.0",
40
+ "@ultimat3/i18n": "7.0.0",
41
+ "@ultimat3/seo": "7.0.0",
38
42
  "sass": "1.102.0"
39
43
  }
40
44
  }
package/src/hydrate.ts CHANGED
@@ -5,8 +5,8 @@
5
5
  * answered instead of swallowed.
6
6
  */
7
7
 
8
+ import type { HydrateStrategy } from '@ultimat3/core';
8
9
  import { escapeAttribute, escapeJsonContent } from './html';
9
- import type { HydrateStrategy } from './route';
10
10
 
11
11
  export interface IslandDirective {
12
12
  /** Unique per INSTANCE: two of the same island on a page need two prop bags to find. */
@@ -29,6 +29,28 @@ export interface IslandDirective {
29
29
 
30
30
  export const DEFAULT_REPLAY_EVENTS = ['click', 'input', 'change', 'submit', 'keydown'] as const;
31
31
 
32
+ /**
33
+ * How long `idle` waits before hydrating anyway. Exported because a second reader exists and it
34
+ * has to agree: `x shot` leaves the page alone for this long before it photographs it, and a
35
+ * settle shorter than this timeout reports an unhydrated page for one that hydrates perfectly.
36
+ * The runtime string below interpolates it — two copies of one number is the drift axiom 2 refuses.
37
+ */
38
+ export const IDLE_HYDRATE_TIMEOUT_MS = 2_000;
39
+
40
+ /**
41
+ * Set by the runtime when the island's `mount()` RESOLVED. `el.__x` is set when `import()` is
42
+ * called, so it answers "the chunk was requested" and nothing more — three facts (declared,
43
+ * importing, running) had two observables between them, and the missing one is the half that gates.
44
+ */
45
+ export const ISLAND_MOUNTED_ATTRIBUTE = 'data-x-mounted';
46
+
47
+ /**
48
+ * Set by the runtime when `mount()` REJECTED, to the error's message. A failed island and one still
49
+ * loading are the two states an agent most needs to tell apart, and with a success marker alone
50
+ * they are the same absence.
51
+ */
52
+ export const ISLAND_FAILED_ATTRIBUTE = 'data-x-failed';
53
+
32
54
  /**
33
55
  * The island's markup wrapper. `never` gets attributes only, so the HTML is inert and the
34
56
  * runtime below is never emitted for that island.
@@ -84,20 +106,28 @@ export function requiredStrategies(
84
106
  // resolved promise. As a flag, a second click during the chunk's load short-circuited to
85
107
  // `Promise.resolve()`, and the interaction runtime flushed its replay queue into an island that
86
108
  // had not mounted — the events went to nothing and the listeners were already removed.
109
+ //
110
+ // The mount markers are what make the boot promise's OUTCOME readable from the DOM — by `x shot`,
111
+ // by an app's own test, by a human in devtools. `el.__x` exists from the moment `import()` is
112
+ // called, so it cannot tell a chunk that is still downloading from one whose `mount()` threw.
113
+ // The rejection handler rethrows: swallowing it would resolve `el.__x`, and the interaction
114
+ // runtime below would then flush its replay queue into an island that never mounted — the bug
115
+ // `el.__x`-as-a-promise was introduced to fix, reintroduced one layer further out.
87
116
  const RUNTIME_PRELUDE = `
88
- var Q={};
89
117
  function boot(el){var e=el.getAttribute('data-x-entry');
90
118
  if(!e)return Promise.resolve();if(el.__x)return el.__x;
91
119
  var p=document.querySelector('script[data-x-props="'+el.getAttribute('data-x-island')+'"]');
92
120
  var props=p?JSON.parse(p.textContent||'{}'):{};
93
- return el.__x=import(e).then(function(m){return m.mount(el,props)})}
121
+ return el.__x=import(e).then(function(m){return m.mount(el,props)}).then(
122
+ function(r){el.setAttribute('${ISLAND_MOUNTED_ATTRIBUTE}','');return r},
123
+ function(x){el.setAttribute('${ISLAND_FAILED_ATTRIBUTE}',x&&x.message||'1');throw x})}
94
124
  function each(s,f){Array.prototype.forEach.call(document.querySelectorAll(s),f)}
95
125
  `.trim();
96
126
 
97
127
  const RUNTIME_IDLE = `
98
128
  each('[data-x-hydrate="idle"]',function(el){
99
129
  var go=function(){boot(el)};
100
- if('requestIdleCallback'in window)requestIdleCallback(go,{timeout:2000});else setTimeout(go,1)})
130
+ if('requestIdleCallback'in window)requestIdleCallback(go,{timeout:${IDLE_HYDRATE_TIMEOUT_MS}});else setTimeout(go,1)})
101
131
  `.trim();
102
132
 
103
133
  const RUNTIME_VISIBLE = `
package/src/index.ts CHANGED
@@ -9,6 +9,15 @@ import { installRenderLoader } from './module-loader';
9
9
  // places one fact can be wrong instead of none.
10
10
  installRenderLoader();
11
11
 
12
+ /**
13
+ * The route vocabulary is declared once, at tier 0 (`@ultimat3/core`), and re-exported here
14
+ * because `defineRoute`, `MODE_SPECS`, `surfaceAllows` and `RouteDescriptor` all take these types
15
+ * in their signatures: a consumer calling this package's API should not need a second import to
16
+ * name its arguments. A re-export is not a declaration — `scripts/render-modes.test.ts` refuses a
17
+ * second declaration, which is what makes re-exporting safe where copying was not.
18
+ */
19
+ export type { HydrateStrategy, OfflineStrategy, RenderMode } from '@ultimat3/core';
20
+ export { HYDRATE_STRATEGIES, OFFLINE_STRATEGIES, RENDER_MODES } from '@ultimat3/core';
12
21
  export type { CompiledStylesheet } from './css-modules';
13
22
  export { compileStylesheet, isCssModule, isGlobalStylesheet, scopeClasses } from './css-modules';
14
23
  export { parseTtlMs } from './duration';
@@ -54,6 +63,9 @@ export {
54
63
  emitIslandProps,
55
64
  hydrateRuntime,
56
65
  hydrateRuntimeBytes,
66
+ IDLE_HYDRATE_TIMEOUT_MS,
67
+ ISLAND_FAILED_ATTRIBUTE,
68
+ ISLAND_MOUNTED_ATTRIBUTE,
57
69
  requiredStrategies,
58
70
  } from './hydrate';
59
71
  export type { IslandComponent, IslandDeclaration, IslandNode, IslandSpec } from './island';
@@ -89,7 +101,6 @@ export {
89
101
  defaultHydrate,
90
102
  defaultIslandBudget,
91
103
  MODE_SPECS,
92
- RENDER_MODES,
93
104
  } from './modes';
94
105
  export type { Stylesheet } from './module-loader';
95
106
  export {
@@ -162,11 +173,8 @@ export {
162
173
  streamResult,
163
174
  } from './render-stream';
164
175
  export type {
165
- HydrateStrategy,
166
176
  LoadRequirement,
167
- OfflineStrategy,
168
177
  PrerenderFn,
169
- RenderMode,
170
178
  RenderResult,
171
179
  RevalidateConfig,
172
180
  RouteBudget,
@@ -182,14 +190,7 @@ export type {
182
190
  RouteMetaFn,
183
191
  RouteParams,
184
192
  } from './route';
185
- export {
186
- DEFAULT_ISLAND_HYDRATE,
187
- defineRoute,
188
- HYDRATE_STRATEGIES,
189
- isRouteConfig,
190
- OFFLINE_STRATEGIES,
191
- tagKeys,
192
- } from './route';
193
+ export { DEFAULT_ISLAND_HYDRATE, defineRoute, isRouteConfig, tagKeys } from './route';
193
194
  export type { RouteComponent } from './route-component';
194
195
  export { pageComponentOf } from './route-component';
195
196
  export { metaContextFor, routeDataFor } from './route-data';
@@ -4,6 +4,7 @@
4
4
  * one place a route says it ships JavaScript, and the directives stay a per-render fact.
5
5
  */
6
6
 
7
+ import type { HydrateStrategy } from '@ultimat3/core';
7
8
  import { IslandInvalidError, IslandNotHydratedError } from './errors';
8
9
  import type { IslandDirective } from './hydrate';
9
10
  import { DEFAULT_REPLAY_EVENTS } from './hydrate';
@@ -12,7 +13,6 @@ import { isEmittableSpecifier, islandNeverDrained } from './island';
12
13
  import type { IslandProps } from './island-props';
13
14
  import { checkIslandProps } from './island-props';
14
15
  import type { JsxProps } from './jsx';
15
- import type { HydrateStrategy } from './route';
16
16
 
17
17
  /** The distinct client entries a rendered page pulled in — one per module, however many instances. */
18
18
  export function islandModuleIds(directives: readonly IslandDirective[]): readonly string[] {
package/src/islands.ts CHANGED
@@ -5,11 +5,11 @@
5
5
  * opt-in, budgeted island.
6
6
  */
7
7
 
8
+ import type { HydrateStrategy } from '@ultimat3/core';
8
9
  import { BudgetExceededError } from './errors';
9
10
  import type { IslandDirective } from './hydrate';
10
11
  import { hydrateRuntimeBytes } from './hydrate';
11
12
  import type { RouteEntry } from './registry';
12
- import type { HydrateStrategy } from './route';
13
13
  import type { Surface } from './surfaces';
14
14
  import { SURFACE_SPECS } from './surfaces';
15
15
 
package/src/modes.ts CHANGED
@@ -5,15 +5,14 @@
5
5
  * invariant is only documented is a mode that silently degrades in production.
6
6
  */
7
7
 
8
+ import type { HydrateStrategy, RenderMode } from '@ultimat3/core';
9
+ import { HYDRATE_STRATEGIES, RENDER_MODES } from '@ultimat3/core';
8
10
  import { parseTtlMs } from './duration';
9
11
  import { RouteModeInvalidError } from './errors';
10
- import type { HydrateStrategy, RenderMode, RouteConfig } from './route';
11
- import { HYDRATE_STRATEGIES } from './route';
12
+ import type { RouteConfig } from './route';
12
13
  import type { Surface } from './surfaces';
13
14
  import { SURFACE_SPECS, surfaceAllows } from './surfaces';
14
15
 
15
- export const RENDER_MODES = ['static', 'isr', 'ssr', 'stream'] as const;
16
-
17
16
  /**
18
17
  * Everything about a route except the two keys carrying its data generic. Mode invariants never
19
18
  * read metadata and never load anything, and omitting both keeps these checks free of `TData`.
@@ -38,7 +37,9 @@ export interface ModeSpec {
38
37
  readonly description: string;
39
38
  }
40
39
 
41
- export const MODE_SPECS: Readonly<Record<RenderMode, ModeSpec>> = Object.freeze({
40
+ /** Keyed with an explicit type argument for the reason `MODE_STRATEGY` in `@ultimat3/pwa`
41
+ * gives: a `const X: Record<…> = Object.freeze({…})` accepts an extra key in silence. */
42
+ export const MODE_SPECS = Object.freeze<Record<RenderMode, ModeSpec>>({
42
43
  static: {
43
44
  mode: 'static',
44
45
  perRequestState: false,
@@ -211,14 +212,42 @@ export function defaultHydrate(surface: Surface): HydrateStrategy {
211
212
  }
212
213
 
213
214
  /**
214
- * What an island route may spend ABOVE its surface's baseline when it declares no `budget.js`.
215
+ * What an island route may spend ABOVE its surface's baseline when it declares no `budget.js` —
216
+ * the island chunk plus the hydration runtime, which is what `routeJsBytes` adds to the baseline.
217
+ *
218
+ * **20kb, and it is calibrated on a Solid island** (`As of 2026-08-21`). It was 4096, justified in
219
+ * this comment as "twice what the reference app's real island costs (875 B of chunk plus a 1,019 B
220
+ * runtime)" — and that island, `contact-sales.island.tsx`, imports no `solid-js` at all. Calibrating
221
+ * a JSX budget on the one island shape that does not pay the JSX runtime made the default
222
+ * unreachable for every island that does: measured with `buildIslands`, minified, production Solid,
223
+ * `render(() => <p>hello</p>, el)` is **12,588 B** — the floor, before an author writes anything —
224
+ * a signal + a button + reactive text is 13,663 B, and the reference app's real Solid island
225
+ * (`settings.island.tsx`) is 17,797 B. No `budget.js` under 4096 was reachable by any of them, on
226
+ * any surface, because the allowance is measured above the baseline and not against it.
227
+ *
228
+ * The number: 17,797 (the heaviest island this repo actually ships) + 1,010 (`hydrateRuntimeBytes`
229
+ * for one directive at `DEFAULT_ISLAND_HYDRATE`, which is `'interaction'` — `route.ts:33`, applied
230
+ * at `:253` to any island route declaring no `hydrate`) = **18,807**. That is the worst case an
231
+ * app reaches without writing a number down. 20,480 is NOT that rounded up — the next whole
232
+ * kilobyte above it is 19,456 — it is one whole kB further, leaving 1,673 B of headroom and still
233
+ * under 2x 18,807, so a route bundling the same island twice is refused. `island-budget.test.ts`
234
+ * asserts all three. `idle` costs 744 and `visible` 816, so an island route that declares its
235
+ * strategy pays less; the default is what the budget has to clear.
236
+ *
237
+ * All three grew by 129 B on 2026-08-21 (from 881 / 615 / 687), when the prelude learned to mark a
238
+ * mount's OUTCOME so `x shot` can tell an island that RAN from one that only started loading. The
239
+ * headroom absorbed it and the conclusion is unchanged — which is the point of stating the
240
+ * arithmetic here rather than the answer alone. It is not
241
+ * derived from Solid's own size on purpose — this package may not import or name `solid-js`
242
+ * (`CLAUDE.md`), so a constant tracking the runtime's version would be a dependency in a comment.
215
243
  *
216
- * A number, not "unlimited", because the guard means nothing otherwise — and 4kb because that is
217
- * roughly twice what the reference app's real island costs (875 B of chunk plus a 1,019 B runtime),
218
- * which is enough for a second small island and not enough to hide a library. A declared
219
- * `budget.js` still wins, and exceeding this one still fails with the island named.
244
+ * Still a real ceiling, still real bytes on disk: an island that pulls a design system in
245
+ * (`@ultimat3/ui`'s `<Switch>` measures 36,335 B) or ships an engine twice must write its own
246
+ * number down, which is the whole point. Two defaults keyed on "does the graph reach Solid?" is
247
+ * not an option even setting axiom 1 aside: `registry.ts` reads this at REGISTRATION, before any
248
+ * bundle exists, so the answer is not available where the constant is used.
220
249
  */
221
- export const DEFAULT_ISLAND_JS_BYTES = 4096;
250
+ export const DEFAULT_ISLAND_JS_BYTES = 20_480;
222
251
 
223
252
  /**
224
253
  * The derived ceiling for a route whose hydration came from an island. Relative to the surface
package/src/registry.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  * from. Nothing downstream may keep its own list of routes.
6
6
  */
7
7
 
8
+ import type { HydrateStrategy, OfflineStrategy, RenderMode } from '@ultimat3/core';
8
9
  import {
9
10
  RouteDuplicateError,
10
11
  RouteFileInvalidError,
@@ -12,24 +13,22 @@ import {
12
13
  SurfaceBoundaryError,
13
14
  } from './errors';
14
15
  import { assertModeInvariants, defaultIslandBudget } from './modes';
15
- import type {
16
- HydrateStrategy,
17
- OfflineStrategy,
18
- RenderMode,
19
- RouteConfig,
20
- RouteData,
21
- RouteParams,
22
- } from './route';
16
+ import type { RouteConfig, RouteData, RouteParams } from './route';
23
17
  import { isRouteConfig, tagKeys } from './route';
24
18
  import type { RouteComponent } from './route-component';
25
19
  import type { Surface } from './surfaces';
26
20
  import { locateSurface } from './surfaces';
27
21
 
28
22
  /**
29
- * The one filename a route may carry, per surface. `shared/` is absent on purpose: it is a leaf
30
- * of helpers with no URL, so a route file there has nowhere to resolve to.
23
+ * The one filename a route may carry, per surface. `shared/` is `Exclude`d rather than merely
24
+ * absent: it is a leaf of helpers with no URL, so a route file there has nowhere to resolve to —
25
+ * and stating that in the key type makes the other three MANDATORY. `Partial<Record<Surface, …>>`
26
+ * said the same thing about `shared` and let any of the three go missing, which only three
27
+ * registration tests would have caught. A dropped `api` row is not a crash: `assertRouteFilename`
28
+ * reads `undefined` as "this file is under shared/", so every `api/` route author would have been
29
+ * told their file is a leaf of helpers.
31
30
  */
32
- export const ROUTE_FILENAME: Readonly<Partial<Record<Surface, string>>> = Object.freeze({
31
+ export const ROUTE_FILENAME = Object.freeze<Record<Exclude<Surface, 'shared'>, string>>({
33
32
  site: 'page.tsx',
34
33
  app: 'page.tsx',
35
34
  api: 'route.ts',
@@ -137,7 +136,9 @@ const shellQuote = (value: string): string => `'${value.replaceAll("'", "'\\''")
137
136
  * author already meant, plus the one filename that surface accepts.
138
137
  */
139
138
  function assertRouteFilename(file: string, surface: Surface, basename: string | undefined): void {
140
- const expected = ROUTE_FILENAME[surface];
139
+ // `shared` is the one surface with no filename, and the key type now says so — which is why
140
+ // this is a comparison rather than an `undefined` check on the lookup.
141
+ const expected = surface === 'shared' ? undefined : ROUTE_FILENAME[surface];
141
142
  if (expected === undefined) {
142
143
  throw new RouteFileInvalidError(
143
144
  `${file} is under shared/, which is a leaf of helpers with no URL — a route cannot live there`,
package/src/route.ts CHANGED
@@ -14,6 +14,8 @@
14
14
 
15
15
  import type { CacheTag } from '@ultimat3/cache';
16
16
  import { serializeTags } from '@ultimat3/cache';
17
+ import type { HydrateStrategy, OfflineStrategy, RenderMode } from '@ultimat3/core';
18
+ import { OFFLINE_STRATEGIES } from '@ultimat3/core';
17
19
  import type { Translator } from '@ultimat3/i18n';
18
20
  import type { RouteMeta } from '@ultimat3/seo';
19
21
  import { RouteLoadInvalidError, RouteMetaMissingError, RouteOfflineMissingError } from './errors';
@@ -21,13 +23,6 @@ import type { IslandSpec } from './island';
21
23
  import { drainDeclaredIslands } from './island';
22
24
  import { assertModeShape } from './modes';
23
25
 
24
- export type RenderMode = 'static' | 'isr' | 'ssr' | 'stream';
25
- export type OfflineStrategy = 'precache' | 'runtime' | 'network-only';
26
- export type HydrateStrategy = 'idle' | 'visible' | 'interaction' | 'never';
27
-
28
- export const OFFLINE_STRATEGIES = ['precache', 'runtime', 'network-only'] as const;
29
- export const HYDRATE_STRATEGIES = ['idle', 'visible', 'interaction', 'never'] as const;
30
-
31
26
  /**
32
27
  * What a page that declares an island hydrates as when it says nothing. The most conservative of
33
28
  * the three that ship JavaScript: nothing runs until the visitor acts, and `interaction` is the
package/src/surfaces.ts CHANGED
@@ -5,8 +5,8 @@
5
5
  * aspirational. Violations are build errors, resolved through the whole chain.
6
6
  */
7
7
 
8
+ import type { RenderMode } from '@ultimat3/core';
8
9
  import { SurfaceBoundaryError } from './errors';
9
- import type { RenderMode } from './route';
10
10
 
11
11
  export type Surface = 'site' | 'app' | 'api' | 'shared';
12
12
 
@@ -24,7 +24,7 @@ export interface SurfaceSpec {
24
24
  readonly mayImportTypes: readonly Surface[];
25
25
  }
26
26
 
27
- export const SURFACE_SPECS: Readonly<Record<Surface, SurfaceSpec>> = Object.freeze({
27
+ export const SURFACE_SPECS = Object.freeze<Record<Surface, SurfaceSpec>>({
28
28
  site: {
29
29
  surface: 'site',
30
30
  defaultMode: 'static',