foldkit-site 0.1.0 → 0.2.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/README.md CHANGED
@@ -52,7 +52,7 @@ pnpm add foldkit-site
52
52
  ```
53
53
 
54
54
  Peers: `effect`, `foldkit`. `foldkit-surface` is a dependency (for
55
- `Site.sources`).
55
+ `Site.sources`), and `foldkit-ssr` for the `Meta` a node's head returns.
56
56
 
57
57
  ## 60-second example
58
58
 
@@ -65,7 +65,7 @@ const Person = Site.route(personRouter, AppRoute.Person, {
65
65
  section: 'People',
66
66
  })
67
67
 
68
- const AppSite = Site.make(Home, Site.mount(People, []))
68
+ const AppSite = Site.make(Home, Site.mount(People, [Person]))
69
69
 
70
70
  // One declaration builds the value and the address together.
71
71
  const target = Site.target(Person, { personId: 3 })
@@ -87,8 +87,8 @@ without re-parsing anything.
87
87
 
88
88
  **Nodes.** `Site.route(router, case, options?)` declares one location. Options
89
89
  are `title` (a function of the route value), `section`, `landing` (the
90
- section's nav address as this node's params), `shortcut` (the keys that go
91
- here), `history`, and `surface` (below). The node is frozen; keep the
90
+ section's nav address as this node's params), `shortcut` (the keys that go to
91
+ its landing, as Foldkit's key bindings name them: `'/'`, `['G', 'H']`), `history`, and `surface` (below). The node is frozen; keep the
92
92
  exported value and use it for targets and hrefs. To annotate in steps, or to
93
93
  share an annotation bundle across nodes, build incrementally instead — the
94
94
  options are sugar over this builder:
@@ -117,6 +117,41 @@ throw at `make`: both would make chain inspection ambiguous.
117
117
  URL is built by the node's own router, a round trip holds by construction: a
118
118
  built URL parses back to the target's route (there is a test proving it).
119
119
 
120
+ **Both directions.** A tree's type carries its routes, so the tree is the
121
+ one declaration of address to route and back. `Site.parse(site, NotFound)`
122
+ is the application's parser: the first node, in tree order (depth-first,
123
+ parents first), whose router takes the whole address, or the fallback; put a
124
+ node that takes any segment (`/:slug`) after the nodes whose literal it would
125
+ take too. `Site.hrefOf(site, route)` builds a route's address with its node's
126
+ router, and refuses at compile time a route no node holds.
127
+
128
+ **One tree, one document.** A tree holds the routes one application draws.
129
+ `Site.routeAt(site, url)` is the route a node reads at an address, as
130
+ `Site.parse` reads it, or `None` when no node takes it: an address the tree
131
+ does not hold is another document's, reached with a full load, not a
132
+ Navigate Command that could only draw NotFound.
133
+
134
+ **Every address.** `Site.targets(site, paths)` lists the site in tree order:
135
+ a node whose route has no params once, and a node with params by its
136
+ `Site.paths(node, list)`, where `list` is an Effect giving each address's
137
+ params and, for a sitemap, when it last changed:
138
+
139
+ ```ts
140
+ const list = Site.paths(People, Effect.succeed([{ params: { searchText: Option.none() } }]))
141
+ const people = Site.paths(
142
+ Person,
143
+ Effect.succeed([{ params: { personId: 3 }, modified: '2026-10-01' }]),
144
+ )
145
+ const listed = Site.targets(AppSite, [list, people])
146
+ // an Effect of [..., { node: Person, route, url: '/people/3', modified: '2026-10-01' }]
147
+ ```
148
+
149
+ A build renders what it lists, a sitemap keeps what `Site.indexedOf` keeps,
150
+ and prefetch can warm it. A node with params and no `paths`, `paths` for a
151
+ node the tree does not hold, and `paths` given twice are refused, so no page
152
+ is left out unsaid; `Site.paths(node, Effect.succeed([]))` lists none. Its
153
+ failures and services are those of the lists, typed.
154
+
120
155
  **Inspection.** `Site.nodeOf(site, route)` and `Site.chainOf(site, route)`
121
156
  resolve a route value to its node and its root-first chain (`[]` for a tag
122
157
  the tree does not hold, as an inactive Surface resolves to nothing).
@@ -134,9 +169,40 @@ rule by hand.
134
169
  **Navigation metadata.** Titles and sections read with `Site.titleOf` and
135
170
  `Site.sectionOf`. `Site.landing(site, section)` is where the section's nav
136
171
  item points: the first node of the section that declares a landing, as a
137
- target. Shortcuts ride beside their destinations; key bindings stay
138
- application-owned, derived with each name validated against the application's
139
- union. Annotate once; derive nav, titles, shortcuts, and breadcrumbs from it.
172
+ target. `Site.shortcuts(site, toMessage)` is the tree's shortcuts as key
173
+ bindings for `Subscription.keyBindings`, each sending the Message
174
+ `toMessage` makes of its node's landing target; a shortcut with no landing,
175
+ or one used twice, is refused. Annotate once; derive nav, titles, shortcuts,
176
+ and breadcrumbs from it.
177
+
178
+ **Head metadata.** `meta` is what a node says of itself to a search result
179
+ and a link preview: a function of its route and the Model, since a post's
180
+ excerpt is data, not an address. It returns `foldkit-ssr`'s `Meta`
181
+ (description, image, type, article dates, JSON-LD, ...). `indexed: false`
182
+ keeps a node, and every node below it that does not say otherwise, out of
183
+ search engines. `Site.metaOf(site, route, model)` reads the route's chain
184
+ root first, a deeper node's field replacing its ancestor's, the preview
185
+ title falling back to the node's `title`, and `noindex` for an unindexed
186
+ route whatever its `meta` says. It is an SSR plan's `meta` as it stands:
187
+
188
+ ```ts
189
+ const Person = Site.node(personRouter, AppRoute.Person)
190
+ .title(({ personId }) => `Person ${personId} | Routing`)
191
+ .meta<Model>(({ route, model }) => ({ description: model.bios[route.personId] }))
192
+ .node
193
+ const Nested = Site.route(nestedRouter, AppRoute.Nested, { indexed: false })
194
+
195
+ const plan = SSR.plan(App, {
196
+ id: 'site',
197
+ state: Projection.pick(App.model.route, App.model.bios),
198
+ meta: model => Site.metaOf(AppSite, model.route, model),
199
+ })
200
+ ```
201
+
202
+ The plan writes it into the generated page and keeps the head in step as the
203
+ reader moves; the Site only says what it is. `meta` must read what crosses
204
+ to the browser (the route, a resumed read), as any plan's `meta` must.
205
+ `Site.indexedOf(site, route)` is the same flag for a sitemap.
140
206
 
141
207
  ## Nested rendering
142
208
 
@@ -241,13 +307,17 @@ const update = assembly.update((model, message) =>
241
307
  )
242
308
  ```
243
309
 
244
- A click on an internal link navigates — pushing or replacing per
310
+ A click on a link the tree holds navigates — pushing or replacing per
245
311
  `Site.historyOf`, computed from the current route, so entries stay entries.
246
- An external link loads. A URL change sets the route field, or returns the
312
+ Any other link loads, on this origin or not (`Site.routeAt`): another
313
+ application serves it. A URL change sets the route field, or returns the
247
314
  same Model when the address parses to the route already shown, so an echo of
248
315
  our own write never re-renders or clears pending state. The application's own
249
316
  update answers nothing for either message; `reduces` names them for its
250
- guard, the way `Remote.reduces` does.
317
+ guard, the way `Remote.reduces` does. What a new route does beyond setting
318
+ the field is `arrived: (model, route) => ({ model, commands })`, run after the
319
+ routed pages are told and never for an echo: the CMS site moves focus to what
320
+ it drew there (`examples/cms/src/apps/siteApp.ts`).
251
321
 
252
322
  The wiring claims the click tag and shares the change tag with URL mirrors,
253
323
  which read their slices first. `CompletedNavigation` is one completion for
@@ -259,7 +329,7 @@ placements land; until then informing them stays hand-written.
259
329
 
260
330
  **Navigation rendering.** Derive the nav from the tree instead of keeping
261
331
  parallel tables: sections in tree order, hrefs from `Site.landing`, titles
262
- from `Site.titleOf`, shortcuts from the annotated nodes, and the current
332
+ from `Site.titleOf`, key bindings from `Site.shortcuts`, and the current
263
333
  section by comparing tags.
264
334
 
265
335
  **Route changes.** On a URL change, resolve the route value once, then
@@ -277,7 +347,6 @@ caller-composed — there is no `prepare` in any plan.
277
347
  ## Limits / when not to use it
278
348
 
279
349
  - A single-screen application has one node; the tree buys nothing.
280
- - Keyboard shortcuts are still hand-written per application.
281
350
  - Bundles with OutMessages, and children that are not Bundles, stay on
282
351
  `Bundle.at` and `Link.child`: `Site.placement` takes neither `onOut` nor a
283
352
  non-Bundle child.
package/dist/index.d.mts CHANGED
@@ -1,10 +1,12 @@
1
- import { Option, Schema } from "effect";
1
+ import { Effect, Option, Schema } from "effect";
2
2
  import { AnyMessage, Bundle, Helper, Link, Placed, PlacementConfig, ResourceEntries, SeedFor } from "foldkit-bundle";
3
+ import { Router } from "foldkit/route";
3
4
  import * as Update from "foldkit/update";
4
5
  import { Url } from "foldkit/url";
5
6
  import { ActiveSurface, ModelPlace, Surface, SurfaceSource, Wiring } from "foldkit-surface";
6
7
  import { Html, HtmlBuilder } from "foldkit/html";
7
- import { Router } from "foldkit/route";
8
+ import { KeyBinding, KeySequence } from "foldkit/subscription";
9
+ import { Meta } from "foldkit-ssr/client";
8
10
  //#region src/index.d.ts
9
11
  /** Whether moving to a target adds a history step (`push`) or replaces the current one. */
10
12
  export type HistoryIntent = 'push' | 'replace';
@@ -49,6 +51,16 @@ export interface NodeLayout {
49
51
  export interface NodeView {
50
52
  readonly render: (model: any, h: any) => Html;
51
53
  }
54
+ /**
55
+ * What a node says of itself in the document's head, from its route value and
56
+ * the Model (a post's excerpt is in the Model, not the route). The node keeps
57
+ * it with the Model as `any`, quarantined as `NodeLayout`'s is: name the Model
58
+ * where it is declared (`.meta<Model>(...)`) and it checks there.
59
+ */
60
+ export type NodeMeta<Route, Model = any> = (page: {
61
+ readonly route: Route;
62
+ readonly model: Model;
63
+ }) => Meta;
52
64
  /**
53
65
  * The route's place in the Model, read and written. A field holding a tagged
54
66
  * union is a *union of* `FieldRef`s, one per case, which no single
@@ -109,12 +121,11 @@ export interface SiteNode<Route extends {
109
121
  */
110
122
  readonly landing?: Omit<Route, '_tag'> | undefined;
111
123
  /**
112
- * The keyboard shortcut announcing this node, for key bindings derived
113
- * beside the application (`G H` for Home): the characters pressed in
114
- * sequence. Key bindings stay application-owned; this only names them once,
115
- * next to the destination they go to.
124
+ * The keys that go to this node's `landing`, as Foldkit's key bindings name
125
+ * them: one press (`'/'`, `'Mod+K'`) or a sequence (`['G', 'H']`).
126
+ * `Site.shortcuts` makes the bindings.
116
127
  */
117
- readonly shortcut?: string | undefined;
128
+ readonly shortcut?: KeySequence | undefined;
118
129
  /**
119
130
  * Which history step a move within this node is: a string, or a function
120
131
  * for nodes where some param changes are entries of their own (another
@@ -128,12 +139,26 @@ export interface SiteNode<Route extends {
128
139
  readonly layout?: NodeLayout | undefined;
129
140
  /** What this node draws for its own route, if it draws anything. */
130
141
  readonly view?: NodeView | undefined;
142
+ /** What this node says of itself in the head; nodes below override it per field. */
143
+ readonly meta?: NodeMeta<Route> | undefined;
144
+ /**
145
+ * Whether search engines index this node and, unless they say otherwise,
146
+ * the nodes below it. Undeclared up the whole chain, a node is indexed.
147
+ */
148
+ readonly indexed?: boolean | undefined;
131
149
  }
132
- /** A node mounted with its children: structure, not state. */
133
- export interface SiteMount {
150
+ /** Carries the routes a mount or tree holds, in its type only: nothing sets it. */
151
+ declare const routes: unique symbol;
152
+ /** A node mounted with its children: structure, not state. `Route` is every route it holds. */
153
+ export interface SiteMount<Route extends {
154
+ readonly _tag: string;
155
+ } = any> {
134
156
  readonly node: SiteNode<any>;
135
157
  readonly children: ReadonlyArray<SiteMount>;
158
+ readonly [routes]?: (route: Route) => void;
136
159
  }
160
+ /** The routes a bare node or a mount holds. */
161
+ export type RoutesOf<Mounted> = Mounted extends SiteNode<infer Route> ? Route : Mounted extends SiteMount<infer Route> ? Route : never;
137
162
  /**
138
163
  * A node under construction, from `Site.node`: each method annotates and
139
164
  * returns the builder, so nodes compose in steps and annotation bundles are
@@ -153,7 +178,7 @@ export interface NodeBuilder<Route extends {
153
178
  *
154
179
  * ```ts
155
180
  * const inSection = <R extends { readonly _tag: string }>(b: NodeBuilder<R>) =>
156
- * b.section('People').shortcut('GP')
181
+ * b.section('People').shortcut(['G', 'P'])
157
182
  *
158
183
  * const Person = Site.node(personRouter, AppRoute.Person).pipe(inSection).node
159
184
  * ```
@@ -168,23 +193,57 @@ export interface NodeBuilder<Route extends {
168
193
  section(section: string): NodeBuilder<Route>;
169
194
  /** Where the section's nav item points, as this node's params. */
170
195
  landing(landing: Omit<Route, '_tag'>): NodeBuilder<Route>;
171
- /** The keyboard shortcut announcing this node. */
172
- shortcut(shortcut: string): NodeBuilder<Route>;
196
+ /** The keys that go to this node's landing. */
197
+ shortcut(shortcut: KeySequence): NodeBuilder<Route>;
173
198
  /** Which history step a move within this node is. */
174
199
  history(history: HistoryIntent | ((prev: Route, next: Route) => HistoryIntent)): NodeBuilder<Route>;
175
200
  /** A layout wrapping everything under this node. */
176
201
  layout(layout: NodeLayout): NodeBuilder<Route>;
177
202
  /** What this node draws for its own route. */
178
203
  view(view: NodeView): NodeBuilder<Route>;
204
+ /** What this node says of itself in the head, from its route and the Model. */
205
+ meta<Model = any>(meta: NodeMeta<Route, Model>): NodeBuilder<Route>;
206
+ /** Whether search engines index this node and the nodes below it. */
207
+ indexed(indexed: boolean): NodeBuilder<Route>;
179
208
  /** The Surface this route activates. */
180
209
  surface<SRoot, SModel, SMessage, SParams>(config: {
181
210
  readonly surface: Surface<SRoot, SModel, SMessage, SParams>;
182
211
  readonly params: (route: Route) => SParams;
183
212
  }): NodeBuilder<Route>;
184
213
  }
185
- /** The deployed topology: roots with everything mounted under them, frozen. */
186
- export interface SiteTree {
214
+ /**
215
+ * The deployed topology: roots with everything mounted under them, frozen.
216
+ * `Route` is the union of every node's route, so the tree parses an address
217
+ * to it (`Site.parse`) and builds one back (`Site.hrefOf`).
218
+ */
219
+ export interface SiteTree<Route extends {
220
+ readonly _tag: string;
221
+ } = any> {
187
222
  readonly roots: ReadonlyArray<SiteMount>;
223
+ readonly [routes]?: (route: Route) => void;
224
+ }
225
+ /** One address a node's `Site.paths` lists: the route's params, and when its content last changed. */
226
+ export interface SitePath<Route extends {
227
+ readonly _tag: string;
228
+ }> {
229
+ readonly params: Omit<Route, '_tag'>;
230
+ /** When what the page shows last changed, as ISO 8601 text, for a sitemap. */
231
+ readonly modified?: string | undefined;
232
+ }
233
+ /** A node's addresses, listed by an Effect the build runs: from `Site.paths`. */
234
+ export interface SitePaths<E, R> {
235
+ readonly node: SiteNode<any>;
236
+ readonly list: Effect.Effect<ReadonlyArray<SitePath<any>>, E, R>;
237
+ }
238
+ /** How a listing of `SitePaths` can fail: each one's error, and none for no paths. */
239
+ export type PathsError<Paths> = Paths extends SitePaths<infer E, any> ? E : never;
240
+ /** What a listing of `SitePaths` needs: each one's services, and none for no paths. */
241
+ export type PathsServices<Paths> = Paths extends SitePaths<any, infer R> ? R : never;
242
+ /** One address of the whole site, from `Site.targets`: a target, and when it last changed. */
243
+ export interface SiteListed<Route extends {
244
+ readonly _tag: string;
245
+ }> extends SiteTarget<Route> {
246
+ readonly modified?: string | undefined;
188
247
  }
189
248
  /**
190
249
  * One typed destination: the node, the route value, and the URL, all from one
@@ -221,10 +280,12 @@ export declare const Site: {
221
280
  readonly title?: ((route: Route) => string) | undefined;
222
281
  readonly section?: string | undefined;
223
282
  readonly landing?: Omit<Route, "_tag"> | undefined;
224
- readonly shortcut?: string | undefined;
283
+ readonly shortcut?: KeySequence | undefined;
225
284
  readonly history?: HistoryIntent | ((prev: Route, next: Route) => HistoryIntent) | undefined;
226
285
  readonly layout?: NodeLayout | undefined;
227
286
  readonly view?: NodeView | undefined;
287
+ readonly meta?: NodeMeta<Route> | undefined;
288
+ readonly indexed?: boolean | undefined;
228
289
  readonly surface?: {
229
290
  readonly surface: Surface<SRoot, SModel, SMessage, SParams>;
230
291
  readonly params: (route: Route) => SParams;
@@ -257,13 +318,15 @@ export declare const Site: {
257
318
  * so it stays usable bare for targets and hrefs. Children may be bare
258
319
  * nodes (childless) or mounts.
259
320
  */
260
- mount: (node: SiteNode<any>, children?: ReadonlyArray<SiteNode<any> | SiteMount>) => SiteMount;
321
+ mount: <Route extends {
322
+ readonly _tag: string;
323
+ }, const Children extends ReadonlyArray<SiteNode<any> | SiteMount> = []>(node: SiteNode<Route>, children?: Children) => SiteMount<Route | RoutesOf<Children[number]>>;
261
324
  /**
262
325
  * The deployed topology from its roots: bare nodes or mounts, frozen.
263
326
  * Refuses two nodes sharing a tag and one node mounted twice, since both
264
327
  * would make chain inspection ambiguous.
265
328
  */
266
- make: (...roots: ReadonlyArray<SiteNode<any> | SiteMount>) => SiteTree;
329
+ make: <const Roots extends ReadonlyArray<SiteNode<any> | SiteMount>>(...roots: Roots) => SiteTree<RoutesOf<Roots[number]>>;
267
330
  /**
268
331
  * One typed destination: the route value and the URL from the node's own
269
332
  * declaration, so a link can never point where the parser would not go.
@@ -280,6 +343,58 @@ export declare const Site: {
280
343
  readonly _tag: string;
281
344
  }>(node: SiteNode<Route>, params: Omit<Route, "_tag">): string;
282
345
  };
346
+ /**
347
+ * The tree's parser: an address to the route of the first node, in tree
348
+ * order (depth-first, parents first), whose router takes all of it, or the
349
+ * fallback. A router that takes any segment (`/:slug`) belongs after the
350
+ * nodes whose literal it would take too. With `Site.hrefOf`, the tree is
351
+ * the one declaration of both directions.
352
+ */
353
+ parse: <Route extends {
354
+ readonly _tag: string;
355
+ }, Fallback>(site: SiteTree<Route>, fallback: {
356
+ readonly make: (data: {
357
+ readonly path: string;
358
+ }) => Fallback;
359
+ }) => ((url: Url) => Route | Fallback);
360
+ /**
361
+ * The route the tree reads at an address, as `Site.parse` does, or nothing
362
+ * when no node takes it: an address the tree does not hold is another
363
+ * document's, which a link reaches with a full load.
364
+ */
365
+ routeAt: <Route extends {
366
+ readonly _tag: string;
367
+ }>(site: SiteTree<Route>, url: Url) => Option.Option<Route>;
368
+ /**
369
+ * The address of a route the tree holds, built by its node's router, so it
370
+ * parses back to the same route (`Site.parse`).
371
+ */
372
+ hrefOf: <Route extends {
373
+ readonly _tag: string;
374
+ }>(site: SiteTree<Route>, route: Route) => string;
375
+ /**
376
+ * A node's addresses, from data: every published post is one. `list` is an
377
+ * Effect the build runs, such as a Remote query read through
378
+ * `Data.satisfy`, so it lists what a visitor may see.
379
+ *
380
+ * ```ts
381
+ * const posts = Site.paths(PostNode, listPosts.pipe(
382
+ * Effect.map(rows => rows.map(row => ({ params: { slug: row.slug }, modified: row.at }))),
383
+ * ))
384
+ * ```
385
+ */
386
+ paths: <Route extends {
387
+ readonly _tag: string;
388
+ }, E, R>(node: SiteNode<Route>, list: Effect.Effect<ReadonlyArray<SitePath<Route>>, E, R>) => SitePaths<E, R>;
389
+ /**
390
+ * Every address of the site, in tree order: one for each node whose route
391
+ * has no params, and what `paths` lists for each node whose route has
392
+ * them. What a build renders, a sitemap lists (with `Site.indexedOf`), and
393
+ * a prefetch warms. A node with params and no `paths` is refused, as are
394
+ * `paths` for a node the tree does not hold or twice for one node, so no
395
+ * page is left out unsaid; `Site.paths(node, Effect.succeed([]))` lists none.
396
+ */
397
+ targets: <const Paths extends ReadonlyArray<SitePaths<any, any>>>(site: SiteTree, paths: Paths) => Effect.Effect<ReadonlyArray<SiteListed<any>>, PathsError<Paths[number]>, PathsServices<Paths[number]>>;
283
398
  /** Every node in the tree, depth-first, parents before children. */
284
399
  nodesOf: (site: SiteTree) => ReadonlyArray<SiteNode<any>>;
285
400
  /** The node a route value is on, or nothing for a tag the tree does not hold. */
@@ -300,6 +415,29 @@ export declare const Site: {
300
415
  titleOf: (site: SiteTree, route: {
301
416
  readonly _tag: string;
302
417
  }) => string | undefined;
418
+ /**
419
+ * Whether search engines index a route: the nearest declaration up its
420
+ * chain, so a `noindex` studio covers every node below it. A route the tree
421
+ * does not hold is indexed, as a page with no declaration is.
422
+ */
423
+ indexedOf: (site: SiteTree, route: {
424
+ readonly _tag: string;
425
+ }) => boolean;
426
+ /**
427
+ * What a route says of itself in the head, for an SSR plan's `meta`:
428
+ *
429
+ * ```ts
430
+ * SSR.plan(App, { id: 'site', state, meta: model => Site.metaOf(AppSite, model.route, model) })
431
+ * ```
432
+ *
433
+ * Each node of the chain's `meta`, root first, with a deeper node's field
434
+ * replacing its ancestor's and a field it leaves out keeping the ancestor's.
435
+ * The preview title falls back to the route's `title`. An unindexed route
436
+ * (`Site.indexedOf`) is `noindex` whatever its `meta` says.
437
+ */
438
+ metaOf: <Root>(site: SiteTree, route: {
439
+ readonly _tag: string;
440
+ }, model: Root) => Meta;
303
441
  /** The navigation section the tree annotates for a route value, or nothing. */
304
442
  sectionOf: (site: SiteTree, route: {
305
443
  readonly _tag: string;
@@ -310,6 +448,20 @@ export declare const Site: {
310
448
  * every section shown needs a landing, so navigation asserts it.
311
449
  */
312
450
  landing: (site: SiteTree, section: string) => SiteTarget<any> | undefined;
451
+ /**
452
+ * The tree's shortcuts as key bindings, each sending the Message
453
+ * `toMessage` makes of its node's landing:
454
+ *
455
+ * ```ts
456
+ * Subscription.keyBindings({
457
+ * bindings: Site.shortcuts(AppSite, target => Message.PressedShortcut({ url: target.url })),
458
+ * })
459
+ * ```
460
+ *
461
+ * A shortcut on a node with no `landing` goes nowhere, and one used twice
462
+ * goes to two places; both are refused.
463
+ */
464
+ shortcuts: <Message>(site: SiteTree, toMessage: (target: SiteTarget<any>) => Message) => ReadonlyArray<KeyBinding<Message>>;
313
465
  /**
314
466
  * Which history step a move is: to another node, a step; within a node, its
315
467
  * declaration (a string, or a function for nodes where some param changes
@@ -347,18 +499,18 @@ export declare const Site: {
347
499
  * const prepared = yield* Data.satisfy({ ...model, route: target.route }, active)
348
500
  * ```
349
501
  *
350
- * There is deliberately no `SitePlan` object yet: the chain is already
351
- * `Site.chainOf`, and head/access metadata arrive with their real consumers
352
- * (§31.9), not ahead of them.
502
+ * There is deliberately no `SitePlan` object: the chain is already
503
+ * `Site.chainOf`, and the head is `Site.metaOf`.
353
504
  */
354
505
  sourcesFor: <Root>(site: SiteTree, owner: object, place: ModelPlace<Root>, route: {
355
506
  readonly _tag: string;
356
507
  }) => Record<string, ActiveSurface<Root> & SurfaceSource<Root>>;
357
508
  /**
358
509
  * The application's link-click and URL-change lifecycle as one wiring, so
359
- * `update` stops hand-writing those two branches. A click on an internal
360
- * link navigates (pushing or replacing per `Site.historyOf`); on an
361
- * external link it loads; a URL change sets the route field — or touches
510
+ * `update` stops hand-writing those two branches. A click on a link the
511
+ * tree holds navigates (pushing or replacing per `Site.historyOf`); on any
512
+ * other, on this origin or not, it loads, since another document serves
513
+ * it (`Site.routeAt`); a URL change sets the route field — or touches
362
514
  * nothing when the address parses to the route already shown, so an echo
363
515
  * of our own write never re-renders or clears pending state. The
364
516
  * application's own update answers nothing for either message; `reduces`
@@ -416,6 +568,12 @@ export declare const Site: {
416
568
  * `Site.routing<Model, Message, AppRoute, RemoteClient>`.
417
569
  */
418
570
  readonly pages?: ReadonlyArray<SitePage<Root, Message, R, any>> | undefined;
571
+ /**
572
+ * What the application does once a new route is set and its pages are
573
+ * told: moving focus to what it drew, say. An echo of the shown address
574
+ * arrives nowhere, so it runs nothing.
575
+ */
576
+ readonly arrived?: ((model: Root, route: Route) => Update.Return<Root, Message, R>) | undefined;
419
577
  }) => Wiring<Root, Message, R> & {
420
578
  /** Whether the routing owns a message: its click or its URL change. */
421
579
  readonly reduces: (message: Message) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;YAmDY;;;;;;;iBAQK,UAAU;WAAyB;WAAwB,OAAO,OAAO;GACvF,cAAc;;;;;;;;;iBAUA;WACN,SAAS;WACT,SAAS;;;;;;;;;;iBAWH;WACN,SAAS,OAAO,MAAM,YAAY,WAAW;;;;;;;iBAQvC;WACN,SAAS,YAAY,WAAW;;;;;;;;;;;;;;;iBAgB1B,WAAW,MAAM;WACvB;WACA,MAAM,MAAM,SAAS;WACrB,MAAM,MAAM,MAAM,OAAO,UAAU;;;;;;;;;iBAU7B,SAAS,QAAQ,eAAe,GAAG;WACzC,MAAM;WACN,QAAQ;;;;;WAKR,SACP,OAAO,QACP;aAAkB;QACf,OAAO,OAAO,OAAO,OAAO,QAAQ,eAAe;;;;;;;;iBASzC,SAAS;WAAyB;;WACxC;WACA,QAAQ,OAAO;WACf,MAAM,UAAU;;WAEhB,UAAU,OAAO;;WAEjB;;;;;;;WAOA,UAAU,KAAK;;;;;;;WAOf;;;;;;;WAOA,UAAU,kBAAkB,MAAM,OAAO,MAAM,UAAU;;WAEzD,QAAQ;;WAER,SAAS;;WAET,OAAO;;;iBAID;WACN,MAAM;WACN,UAAU,cAAc;;;;;;;;;iBAUlB,YAAY;WAAyB;;;WAE3C,MAAM,SAAS;;;;;;;;;;;;;;;;EAgBxB,KAAK,GAAG,KAAK,SAAS,YAAY,WAAW,IAAI;;EAEjD,MAAM,QAAQ,OAAO,mBAAmB,YAAY;;EAEpD,QAAQ,kBAAkB,YAAY;;EAEtC,QAAQ,SAAS,KAAK,iBAAiB,YAAY;;EAEnD,SAAS,mBAAmB,YAAY;;EAExC,QACE,SAAS,kBAAkB,MAAM,OAAO,MAAM,UAAU,iBACvD,YAAY;;EAEf,OAAO,QAAQ,aAAa,YAAY;;E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ACV,OACE,MACA,QACA,aACA,YACA,cACA,UAAU,WACV,SACA,YACA,WACA,SACA,OACA;aAA+B,YAAY;MAAuB"}
package/dist/index.mjs CHANGED
@@ -3,6 +3,7 @@ import "foldkit-bundle";
3
3
  import * as Command from "foldkit/command";
4
4
  import * as Navigation from "foldkit/navigation";
5
5
  import { UrlRequest } from "foldkit/navigation";
6
+ import { oneOf, parseUrlWithFallback } from "foldkit/route";
6
7
  import * as Update from "foldkit/update";
7
8
  import * as Url$1 from "foldkit/url";
8
9
  import { Surface } from "foldkit-surface";
@@ -39,7 +40,7 @@ const tagOfConstructor = (constructor, what) => {
39
40
  return literal;
40
41
  };
41
42
  const indexes = /* @__PURE__ */ new WeakMap();
42
- /** The parent and tag maps of a tree, computed once per tree value. */
43
+ /** The parent and tag maps and the parser of a tree, computed once per tree value. */
43
44
  const indexOf = (site) => {
44
45
  const known = indexes.get(site);
45
46
  if (known !== void 0) return known;
@@ -54,13 +55,21 @@ const indexOf = (site) => {
54
55
  for (const child of mount.children) visit(child, mount.node);
55
56
  };
56
57
  for (const root of site.roots) visit(root, void 0);
58
+ const parser = parseUrlWithFallback(oneOf(...[...parent.keys()].map((node) => node.router)), { make: () => Option.none() });
59
+ const read = (url) => {
60
+ const parsed = parser(url);
61
+ return Option.isOption(parsed) ? parsed : Option.some(parsed);
62
+ };
57
63
  const index = {
58
64
  parent,
59
- byTag
65
+ byTag,
66
+ read
60
67
  };
61
68
  indexes.set(site, index);
62
69
  return index;
63
70
  };
71
+ /** Whether a node's route has params beyond its tag, so its addresses must be listed. */
72
+ const takesParams = (node) => Object.keys(node.case.fields ?? {}).some((field) => field !== "_tag");
64
73
  const asMount = (node) => "children" in node ? node : {
65
74
  node,
66
75
  children: []
@@ -72,6 +81,8 @@ const sourceOf = (node, owner, place) => {
72
81
  if (bound.surface.owner !== owner) throw new Error(`Site: "${bound.surface.name}" belongs to another application than the site`);
73
82
  return [node.tag, Surface.when(bound.surface, place, node.case, bound.params)];
74
83
  };
84
+ /** The fields a `Meta` gives, so one left `undefined` does not erase an ancestor's. */
85
+ const saidOf = (meta) => Object.fromEntries(Object.entries(meta).filter(([, value]) => value !== void 0));
75
86
  const freezeMount = (mount) => Object.freeze({
76
87
  node: mount.node,
77
88
  children: Object.freeze(mount.children.map(freezeMount))
@@ -108,6 +119,8 @@ const Site = {
108
119
  if (options?.history !== void 0) built = built.history(options.history);
109
120
  if (options?.layout !== void 0) built = built.layout(options.layout);
110
121
  if (options?.view !== void 0) built = built.view(options.view);
122
+ if (options?.meta !== void 0) built = built.meta(options.meta);
123
+ if (options?.indexed !== void 0) built = built.indexed(options.indexed);
111
124
  if (options?.surface !== void 0) built = built.surface(options.surface);
112
125
  return built.node;
113
126
  },
@@ -162,6 +175,14 @@ const Site = {
162
175
  ...built,
163
176
  view
164
177
  })),
178
+ meta: (meta) => at(Object.freeze({
179
+ ...built,
180
+ meta
181
+ })),
182
+ indexed: (indexed) => at(Object.freeze({
183
+ ...built,
184
+ indexed
185
+ })),
165
186
  surface: (config) => at(Object.freeze({
166
187
  ...built,
167
188
  bound: config
@@ -174,9 +195,9 @@ const Site = {
174
195
  * so it stays usable bare for targets and hrefs. Children may be bare
175
196
  * nodes (childless) or mounts.
176
197
  */
177
- mount: (node, children = []) => Object.freeze({
198
+ mount: (node, children) => Object.freeze({
178
199
  node,
179
- children: Object.freeze(children.map(asMount))
200
+ children: Object.freeze((children ?? []).map(asMount))
180
201
  }),
181
202
  /**
182
203
  * The deployed topology from its roots: bare nodes or mounts, frozen.
@@ -203,6 +224,75 @@ const Site = {
203
224
  if (params === void 0) throw new Error(`Site.href: "${targetOrNode.tag}" needs params to build its URL`);
204
225
  return Site.target(targetOrNode, params).url;
205
226
  }),
227
+ /**
228
+ * The tree's parser: an address to the route of the first node, in tree
229
+ * order (depth-first, parents first), whose router takes all of it, or the
230
+ * fallback. A router that takes any segment (`/:slug`) belongs after the
231
+ * nodes whose literal it would take too. With `Site.hrefOf`, the tree is
232
+ * the one declaration of both directions.
233
+ */
234
+ parse: (site, fallback) => {
235
+ const { read } = indexOf(site);
236
+ return (url) => Option.getOrElse(read(url), () => fallback.make({ path: url.pathname }));
237
+ },
238
+ /**
239
+ * The route the tree reads at an address, as `Site.parse` does, or nothing
240
+ * when no node takes it: an address the tree does not hold is another
241
+ * document's, which a link reaches with a full load.
242
+ */
243
+ routeAt: (site, url) => indexOf(site).read(url),
244
+ /**
245
+ * The address of a route the tree holds, built by its node's router, so it
246
+ * parses back to the same route (`Site.parse`).
247
+ */
248
+ hrefOf: (site, route) => {
249
+ const node = indexOf(site).byTag.get(route._tag);
250
+ if (node === void 0) throw new Error(`Site.hrefOf: no node holds the tag "${route._tag}"`);
251
+ const { _tag, ...params } = route;
252
+ return node.router.build(params);
253
+ },
254
+ /**
255
+ * A node's addresses, from data: every published post is one. `list` is an
256
+ * Effect the build runs, such as a Remote query read through
257
+ * `Data.satisfy`, so it lists what a visitor may see.
258
+ *
259
+ * ```ts
260
+ * const posts = Site.paths(PostNode, listPosts.pipe(
261
+ * Effect.map(rows => rows.map(row => ({ params: { slug: row.slug }, modified: row.at }))),
262
+ * ))
263
+ * ```
264
+ */
265
+ paths: (node, list) => ({
266
+ node,
267
+ list
268
+ }),
269
+ /**
270
+ * Every address of the site, in tree order: one for each node whose route
271
+ * has no params, and what `paths` lists for each node whose route has
272
+ * them. What a build renders, a sitemap lists (with `Site.indexedOf`), and
273
+ * a prefetch warms. A node with params and no `paths` is refused, as are
274
+ * `paths` for a node the tree does not hold or twice for one node, so no
275
+ * page is left out unsaid; `Site.paths(node, Effect.succeed([]))` lists none.
276
+ */
277
+ targets: (site, paths) => {
278
+ const nodes = Site.nodesOf(site);
279
+ const listed = /* @__PURE__ */ new Map();
280
+ for (const each of paths) {
281
+ if (!nodes.includes(each.node)) throw new Error(`Site.targets: "${each.node.tag}" has paths but is not in the tree`);
282
+ if (listed.has(each.node)) throw new Error(`Site.targets: "${each.node.tag}" has paths twice`);
283
+ listed.set(each.node, each);
284
+ }
285
+ const unlisted = nodes.filter((node) => takesParams(node) && !listed.has(node));
286
+ if (unlisted.length > 0) throw new Error(`Site.targets: ${unlisted.map((node) => `"${node.tag}"`).join(", ")} take params and have no paths`);
287
+ return Effect.map(Effect.forEach(nodes, (node) => {
288
+ const source = listed.get(node);
289
+ if (source === void 0) return Effect.succeed([Site.target(node, {})]);
290
+ return Effect.map(source.list, (found) => found.map(({ params, modified }) => ({
291
+ ...Site.target(node, params),
292
+ ...modified === void 0 ? {} : { modified }
293
+ })));
294
+ }, { concurrency: "unbounded" }), (perNode) => perNode.flat());
295
+ },
206
296
  /** Every node in the tree, depth-first, parents before children. */
207
297
  nodesOf: (site) => {
208
298
  const out = [];
@@ -247,6 +337,47 @@ const Site = {
247
337
  titleOf: (site, route) => {
248
338
  return indexOf(site).byTag.get(route._tag)?.title?.(route);
249
339
  },
340
+ /**
341
+ * Whether search engines index a route: the nearest declaration up its
342
+ * chain, so a `noindex` studio covers every node below it. A route the tree
343
+ * does not hold is indexed, as a page with no declaration is.
344
+ */
345
+ indexedOf: (site, route) => {
346
+ const chain = Site.chainOf(site, route);
347
+ for (let at = chain.length - 1; at >= 0; at--) {
348
+ const indexed = chain[at].indexed;
349
+ if (indexed !== void 0) return indexed;
350
+ }
351
+ return true;
352
+ },
353
+ /**
354
+ * What a route says of itself in the head, for an SSR plan's `meta`:
355
+ *
356
+ * ```ts
357
+ * SSR.plan(App, { id: 'site', state, meta: model => Site.metaOf(AppSite, model.route, model) })
358
+ * ```
359
+ *
360
+ * Each node of the chain's `meta`, root first, with a deeper node's field
361
+ * replacing its ancestor's and a field it leaves out keeping the ancestor's.
362
+ * The preview title falls back to the route's `title`. An unindexed route
363
+ * (`Site.indexedOf`) is `noindex` whatever its `meta` says.
364
+ */
365
+ metaOf: (site, route, model) => {
366
+ let meta = {};
367
+ for (const node of Site.chainOf(site, route)) if (node.meta !== void 0) meta = {
368
+ ...meta,
369
+ ...saidOf(node.meta({
370
+ route,
371
+ model
372
+ }))
373
+ };
374
+ const title = meta.title ?? Site.titleOf(site, route);
375
+ return {
376
+ ...meta,
377
+ ...title === void 0 ? {} : { title },
378
+ ...Site.indexedOf(site, route) ? {} : { robots: "noindex" }
379
+ };
380
+ },
250
381
  /** The navigation section the tree annotates for a route value, or nothing. */
251
382
  sectionOf: (site, route) => indexOf(site).byTag.get(route._tag)?.section,
252
383
  /**
@@ -263,6 +394,40 @@ const Site = {
263
394
  }
264
395
  },
265
396
  /**
397
+ * The tree's shortcuts as key bindings, each sending the Message
398
+ * `toMessage` makes of its node's landing:
399
+ *
400
+ * ```ts
401
+ * Subscription.keyBindings({
402
+ * bindings: Site.shortcuts(AppSite, target => Message.PressedShortcut({ url: target.url })),
403
+ * })
404
+ * ```
405
+ *
406
+ * A shortcut on a node with no `landing` goes nowhere, and one used twice
407
+ * goes to two places; both are refused.
408
+ */
409
+ shortcuts: (site, toMessage) => {
410
+ const taken = /* @__PURE__ */ new Map();
411
+ return Site.nodesOf(site).flatMap((node) => {
412
+ const keys = node.shortcut;
413
+ if (keys === void 0) return [];
414
+ if (node.landing === void 0) throw new Error(`Site.shortcuts: "${node.tag}" has a shortcut and no landing to go to`);
415
+ const named = typeof keys === "string" ? keys : keys.join(" ");
416
+ const other = taken.get(named);
417
+ if (other !== void 0) throw new Error(`Site.shortcuts: "${named}" goes to both "${other}" and "${node.tag}"`);
418
+ taken.set(named, node.tag);
419
+ const message = toMessage(Site.target(node, node.landing));
420
+ const mapEvent = () => message;
421
+ return [typeof keys === "string" ? {
422
+ keys,
423
+ mapEvent
424
+ } : {
425
+ keys,
426
+ mapEvent
427
+ }];
428
+ });
429
+ },
430
+ /**
266
431
  * Which history step a move is: to another node, a step; within a node, its
267
432
  * declaration (a string, or a function for nodes where some param changes
268
433
  * are entries of their own); with no previous target — the current location
@@ -319,9 +484,8 @@ const Site = {
319
484
  * const prepared = yield* Data.satisfy({ ...model, route: target.route }, active)
320
485
  * ```
321
486
  *
322
- * There is deliberately no `SitePlan` object yet: the chain is already
323
- * `Site.chainOf`, and head/access metadata arrive with their real consumers
324
- * (§31.9), not ahead of them.
487
+ * There is deliberately no `SitePlan` object: the chain is already
488
+ * `Site.chainOf`, and the head is `Site.metaOf`.
325
489
  */
326
490
  sourcesFor: (site, owner, place, route) => {
327
491
  const out = {};
@@ -333,9 +497,10 @@ const Site = {
333
497
  },
334
498
  /**
335
499
  * The application's link-click and URL-change lifecycle as one wiring, so
336
- * `update` stops hand-writing those two branches. A click on an internal
337
- * link navigates (pushing or replacing per `Site.historyOf`); on an
338
- * external link it loads; a URL change sets the route field — or touches
500
+ * `update` stops hand-writing those two branches. A click on a link the
501
+ * tree holds navigates (pushing or replacing per `Site.historyOf`); on any
502
+ * other, on this origin or not, it loads, since another document serves
503
+ * it (`Site.routeAt`); a URL change sets the route field — or touches
339
504
  * nothing when the address parses to the route already shown, so an echo
340
505
  * of our own write never re-renders or clears pending state. The
341
506
  * application's own update answers nothing for either message; `reduces`
@@ -375,6 +540,7 @@ const Site = {
375
540
  messages: [config.completed],
376
541
  execute: ({ url, history }) => (history === "push" ? Navigation.pushUrl(url) : Navigation.replaceUrl(url)).pipe(Effect.as(config.completed()))
377
542
  });
543
+ const { arrived } = config;
378
544
  const Load = Command.define("Site.Load", {
379
545
  args: { href: Schema.String },
380
546
  messages: [config.completed],
@@ -401,22 +567,27 @@ const Site = {
401
567
  if (message._tag === config.tags.clicked) {
402
568
  const request = message.request;
403
569
  return Option.some(UrlRequest.match(request, {
404
- Internal: ({ url }) => {
405
- const next = config.parse(url);
406
- const node = Site.nodeOf(config.site, next);
407
- const intent = node === void 0 ? "push" : Site.historyOf(currentTarget(model), {
408
- node,
409
- route: next,
410
- url: Url$1.toString(url)
411
- });
412
- return {
570
+ Internal: ({ url }) => Option.match(Site.routeAt(config.site, url), {
571
+ onNone: () => ({
413
572
  model,
414
- commands: [Navigate({
415
- url: Url$1.toString(url),
416
- history: intent
417
- })]
418
- };
419
- },
573
+ commands: [Load({ href: Url$1.toString(url) })]
574
+ }),
575
+ onSome: (next) => {
576
+ const node = Site.nodeOf(config.site, next);
577
+ const history = Site.historyOf(currentTarget(model), {
578
+ node,
579
+ route: next,
580
+ url: Url$1.toString(url)
581
+ });
582
+ return {
583
+ model,
584
+ commands: [Navigate({
585
+ url: Url$1.toString(url),
586
+ history
587
+ })]
588
+ };
589
+ }
590
+ }),
420
591
  External: ({ href }) => ({
421
592
  model,
422
593
  commands: [Load({ href })]
@@ -427,7 +598,11 @@ const Site = {
427
598
  const url = message.url;
428
599
  const next = config.parse(url);
429
600
  if (sameRoute(config.route.get(model), next)) return Option.some({ model });
430
- const steps = [(model) => ({ model: setRoute(model, next) }), ...(config.pages ?? []).map((page) => (model) => Option.getOrElse(page.inform(model, next), () => ({ model })))];
601
+ const steps = [
602
+ (model) => ({ model: setRoute(model, next) }),
603
+ ...(config.pages ?? []).map((page) => (model) => Option.getOrElse(page.inform(model, next), () => ({ model }))),
604
+ ...arrived === void 0 ? [] : [(model) => arrived(model, next)]
605
+ ];
431
606
  return Option.some(Update.combine(model, steps));
432
607
  }
433
608
  return Option.none();
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["Url"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `foldkit-site` — the deployed route topology of a Foldkit application.\n *\n * A Site says where the application is: stable route nodes in a hierarchy,\n * each with its Foldkit Router, its metadata, and the Surfaces it activates.\n * Everything else — fetching, caching, rendering, navigation effects — stays\n * where it already is: the node compiles down to the primitives the runtime\n * already runs (`Route` biparsers, `Surface.when`, Bundle placements), so the\n * Site never becomes a second router, loader, or store.\n *\n * The rule, from the design:\n *\n * > Router says where the application is. Surface says what that state makes\n * > observable and capable. Remote says what server facts those observations\n * > require.\n *\n * Nothing here runs: nodes, mounts, trees, and targets are data. A `SiteTree`\n * is frozen at `Site.make`. `Site.routing` is the one runtime piece: the\n * link-click and URL-change lifecycle as a wiring, so applications stop\n * hand-writing those two update branches.\n */\nimport { Effect, Option, Predicate, Schema } from 'effect'\nimport {\n Bundle,\n Link,\n type AnyMessage,\n type Helper,\n type Placed,\n type PlacementConfig,\n type ResourceEntries,\n type SeedFor,\n} from 'foldkit-bundle'\nimport * as Command from 'foldkit/command'\nimport type { Html, HtmlBuilder } from 'foldkit/html'\nimport * as Navigation from 'foldkit/navigation'\nimport { UrlRequest } from 'foldkit/navigation'\nimport type { Router } from 'foldkit/route'\nimport * as Update from 'foldkit/update'\nimport * as Url from 'foldkit/url'\nimport type { Url as UrlValue } from 'foldkit/url'\nimport {\n Surface,\n type ActiveSurface,\n type Contract,\n type ModelPlace,\n type Surface as SurfaceType,\n type SurfaceSource,\n type Wiring,\n} from 'foldkit-surface'\n\n/** Whether moving to a target adds a history step (`push`) or replaces the current one. */\nexport type HistoryIntent = 'push' | 'replace'\n\n/**\n * A route-case constructor: the Schema for `Surface.when`, called to build\n * route values for targets. The `any` is deliberate and quarantined here:\n * every constructor of a `defineRouteUnion` case is callable with its fields,\n * and `Site.target` types the params from the route value instead.\n */\nexport interface RouteCase<Route extends { readonly _tag: string }> extends Schema.Schema<Route> {\n (params: any): Route\n}\n\n/**\n * A Surface a node activates, with the route's params made into its own: the\n * `Surface.when` a node lowers to, once the application says where its route\n * lives. The surface's own types are checked where the node is declared\n * (`Site.route` infers them); by the time sources resolve, only the owner\n * check can still fail, and it does, loudly.\n */\nexport interface BoundSurface {\n readonly surface: SurfaceType<any, any, any, any>\n readonly params: (route: any) => any\n}\n\n/**\n * A layout around everything under a node: it receives the composed child\n * explicitly — no Outlet, no context, no hidden route state. Ancestors with\n * layouts wrap the leaf's view root-first; ancestors without one pass\n * through. The `any` positions are deliberate and quarantined, as with\n * `BoundSurface`: annotate the function where it is declared and it checks\n * there.\n */\nexport interface NodeLayout {\n readonly render: (child: Html, model: any, h: any) => Html\n}\n\n/**\n * What a node draws for its own route: only the deepest node of the active\n * chain draws (its ancestors contribute layouts, never their views — a\n * person page shows no people list). Same `any` quarantine as `NodeLayout`.\n */\nexport interface NodeView {\n readonly render: (model: any, h: any) => Html\n}\n\n/**\n * The route's place in the Model, read and written. A field holding a tagged\n * union is a *union of* `FieldRef`s, one per case, which no single\n * `ModelRef<Root, Route>` accepts — so this is structural:\n *\n * ```ts\n * route: {\n * dependency: App.model.route.dependency,\n * get: (model) => model.route,\n * set: (model, route) => modifyFields(model, { route: () => route }),\n * },\n * ```\n */\nexport interface RouteField<Root, Route> {\n readonly dependency: readonly string[]\n readonly get: (root: Root) => Route\n readonly set: (root: Root, route: Route) => Root\n}\n\n/**\n * One routed page: its node, its Bundle placement, and how a route arrival\n * reaches the child. The placement drives both folds from one declaration —\n * `placed.update` for Messages, `placed.view` for drawing — and `inform`\n * tells the child when its route arrives, through its own Message. The\n * placement's full type rides along, so assemblies keep inferring services.\n */\nexport interface SitePage<Parent, ParentMessage, R, P> {\n readonly node: SiteNode<any>\n readonly placed: P\n /**\n * The child told of a route arrival: `None` for another node's route, for\n * a page with nothing to say, or when the child says nothing is needed.\n */\n readonly inform: (\n model: Parent,\n route: { readonly _tag: string },\n ) => Option.Option<Update.Return<Parent, ParentMessage, R>>\n}\n\n/**\n * One deployed location: its Router (which owns URL semantics), its route\n * case, and its metadata. A stable first-class value: mounting it in a tree\n * never mutates it, so the same node serves targets, hrefs, and inspection\n * wherever it is mounted.\n */\nexport interface SiteNode<Route extends { readonly _tag: string }> {\n readonly tag: string\n readonly router: Router<Route>\n readonly case: RouteCase<Route>\n /** The page's title for this route, once the route value is known. */\n readonly title?: ((route: Route) => string) | undefined\n /** The navigation section this route belongs to, for menus and breadcrumbs. */\n readonly section?: string | undefined\n /**\n * Where the section's nav item points: this node's params for its landing\n * address (a people list with no search, say). Nodes a section never lands\n * on — a person, a file — leave it absent; `Site.landing` reads the first\n * node of a section that declares one.\n */\n readonly landing?: Omit<Route, '_tag'> | undefined\n /**\n * The keyboard shortcut announcing this node, for key bindings derived\n * beside the application (`G H` for Home): the characters pressed in\n * sequence. Key bindings stay application-owned; this only names them once,\n * next to the destination they go to.\n */\n readonly shortcut?: string | undefined\n /**\n * Which history step a move within this node is: a string, or a function\n * for nodes where some param changes are entries of their own (another\n * person) and others are views of one entry (another search). A move to\n * another node — or from an unknown location — is always a step.\n */\n readonly history?: HistoryIntent | ((prev: Route, next: Route) => HistoryIntent) | undefined\n /** The Surface this route activates, if the node declares one. */\n readonly bound?: BoundSurface | undefined\n /** A layout wrapping everything under this node, if it declares one. */\n readonly layout?: NodeLayout | undefined\n /** What this node draws for its own route, if it draws anything. */\n readonly view?: NodeView | undefined\n}\n\n/** A node mounted with its children: structure, not state. */\nexport interface SiteMount {\n readonly node: SiteNode<any>\n readonly children: ReadonlyArray<SiteMount>\n}\n\n/**\n * A node under construction, from `Site.node`: each method annotates and\n * returns the builder, so nodes compose in steps and annotation bundles are\n * ordinary values. Methods — not pipeable fragments — because each stage of\n * a pipe is a separate generic call and could not infer the route. Read\n * `.node` at any stage for the frozen node so far.\n */\nexport interface NodeBuilder<Route extends { readonly _tag: string }> {\n /** The node so far: frozen, usable for targets and hrefs at any stage. */\n readonly node: SiteNode<Route>\n /**\n * One named bundle through the builder, Effect-style: the bundle stays\n * generic over the builder it meets, so it instantiates to this node's\n * route with no annotation. Chain for more than one.\n *\n * ```ts\n * const inSection = <R extends { readonly _tag: string }>(b: NodeBuilder<R>) =>\n * b.section('People').shortcut('GP')\n *\n * const Person = Site.node(personRouter, AppRoute.Person).pipe(inSection).node\n * ```\n *\n * Free `pipe(builder, bundle)` from `effect` composes the same way; this\n * method is the same spelling without the import.\n */\n pipe<A>(fn: (builder: NodeBuilder<Route>) => A): A\n /** The page's title for this route, once the route value is known. */\n title(title: (route: Route) => string): NodeBuilder<Route>\n /** The navigation section this route belongs to. */\n section(section: string): NodeBuilder<Route>\n /** Where the section's nav item points, as this node's params. */\n landing(landing: Omit<Route, '_tag'>): NodeBuilder<Route>\n /** The keyboard shortcut announcing this node. */\n shortcut(shortcut: string): NodeBuilder<Route>\n /** Which history step a move within this node is. */\n history(\n history: HistoryIntent | ((prev: Route, next: Route) => HistoryIntent),\n ): NodeBuilder<Route>\n /** A layout wrapping everything under this node. */\n layout(layout: NodeLayout): NodeBuilder<Route>\n /** What this node draws for its own route. */\n view(view: NodeView): NodeBuilder<Route>\n /** The Surface this route activates. */\n surface<SRoot, SModel, SMessage, SParams>(config: {\n readonly surface: SurfaceType<SRoot, SModel, SMessage, SParams>\n readonly params: (route: Route) => SParams\n }): NodeBuilder<Route>\n}\n\n/** The deployed topology: roots with everything mounted under them, frozen. */\nexport interface SiteTree {\n readonly roots: ReadonlyArray<SiteMount>\n}\n\n/**\n * One typed destination: the node, the route value, and the URL, all from one\n * declaration. Links, prefetch, and route analysis share this instead of each\n * rebuilding it.\n */\nexport interface SiteTarget<Route extends { readonly _tag: string }> {\n readonly node: SiteNode<Route>\n readonly route: Route\n readonly url: string\n}\n\n/**\n * The tag a tagged constructor names, read the way `Surface.when` reads it\n * off a route case. Anything else is a definition-time error, not a silent\n * mismatch.\n */\nconst tagOfConstructor = (constructor: unknown, what: string): string => {\n const literal = (constructor as { fields?: { _tag?: { ast?: { literal?: unknown } } } }).fields\n ?._tag?.ast?.literal\n if (typeof literal !== 'string') throw new Error(`${what} must be a tagged constructor`)\n return literal\n}\n\ninterface SiteIndex {\n readonly parent: ReadonlyMap<SiteNode<any>, SiteNode<any> | undefined>\n readonly byTag: ReadonlyMap<string, SiteNode<any>>\n}\n\nconst indexes = new WeakMap<SiteTree, SiteIndex>()\n\n/** The parent and tag maps of a tree, computed once per tree value. */\nconst indexOf = (site: SiteTree): SiteIndex => {\n const known = indexes.get(site)\n if (known !== undefined) return known\n const parent = new Map<SiteNode<any>, SiteNode<any> | undefined>()\n const byTag = new Map<string, SiteNode<any>>()\n const visit = (mount: SiteMount, above: SiteNode<any> | undefined): void => {\n if (parent.has(mount.node))\n throw new Error(\n `Site.make: \"${mount.node.tag}\" is mounted twice; a node has one place in a tree`,\n )\n const knownTag = byTag.get(mount.node.tag)\n if (knownTag !== undefined && knownTag !== mount.node)\n throw new Error(\n `Site.make: two nodes share the tag \"${mount.node.tag}\"; one route case is one node`,\n )\n parent.set(mount.node, above)\n byTag.set(mount.node.tag, mount.node)\n for (const child of mount.children) visit(child, mount.node)\n }\n for (const root of site.roots) visit(root, undefined)\n const index = { parent, byTag }\n indexes.set(site, index)\n return index\n}\n\nconst asMount = (node: SiteNode<any> | SiteMount): SiteMount =>\n 'children' in node ? node : { node, children: [] }\n\n/** One surfaced node's `Surface.when` over the route place, or nothing surfaceless. */\nconst sourceOf = <Root>(\n node: SiteNode<any>,\n owner: object,\n place: ModelPlace<Root>,\n): [string, ActiveSurface<Root> & SurfaceSource<Root>] | undefined => {\n const bound = node.bound\n if (bound === undefined) return undefined\n if (bound.surface.owner !== owner)\n throw new Error(`Site: \"${bound.surface.name}\" belongs to another application than the site`)\n return [node.tag, Surface.when(bound.surface, place, node.case, bound.params)]\n}\n\nconst freezeMount = (mount: SiteMount): SiteMount =>\n Object.freeze({\n node: mount.node,\n children: Object.freeze(mount.children.map(freezeMount)),\n })\n\n/** A bare node: its tag from its route case, nothing annotated. */\nconst baseNode = <Route extends { readonly _tag: string }>(\n router: Router<Route>,\n routeCase: RouteCase<Route>,\n): SiteNode<Route> =>\n Object.freeze({\n tag: tagOfConstructor(routeCase, 'Site.route: expected a route case from defineRouteUnion'),\n router,\n case: routeCase,\n })\n\nexport const Site = {\n /**\n * One deployed location from its Foldkit Router and its route case:\n *\n * ```ts\n * const Person = Site.route(personRouter, AppRoute.Person, {\n * title: ({ personId }) => `Person ${personId} | Routing`,\n * section: 'People',\n * })\n * ```\n *\n * The router stays the whole URL story (parse and build); the case names\n * the tag and builds route values. Metadata is annotated once here, and\n * navigation, titles, and history derive from it. To share annotations\n * across nodes, or to build incrementally, use the `Site.node` builder\n * instead — these options are sugar over it.\n */\n route: <Route extends { readonly _tag: string }, SRoot, SModel, SMessage, SParams>(\n router: Router<Route>,\n routeCase: RouteCase<Route>,\n options?: {\n readonly title?: ((route: Route) => string) | undefined\n readonly section?: string | undefined\n readonly landing?: Omit<Route, '_tag'> | undefined\n readonly shortcut?: string | undefined\n readonly history?: HistoryIntent | ((prev: Route, next: Route) => HistoryIntent) | undefined\n readonly layout?: NodeLayout | undefined\n readonly view?: NodeView | undefined\n readonly surface?:\n | {\n readonly surface: SurfaceType<SRoot, SModel, SMessage, SParams>\n readonly params: (route: Route) => SParams\n }\n | undefined\n },\n ): SiteNode<Route> => {\n let built = Site.node(router, routeCase)\n if (options?.title !== undefined) built = built.title(options.title)\n if (options?.section !== undefined) built = built.section(options.section)\n if (options?.landing !== undefined) built = built.landing(options.landing)\n if (options?.shortcut !== undefined) built = built.shortcut(options.shortcut)\n if (options?.history !== undefined) built = built.history(options.history)\n if (options?.layout !== undefined) built = built.layout(options.layout)\n if (options?.view !== undefined) built = built.view(options.view)\n if (options?.surface !== undefined)\n built = built.surface<SRoot, SModel, SMessage, SParams>(options.surface)\n return built.node\n },\n\n /**\n * One deployed location as an incremental builder, for nodes annotated in\n * steps or annotations shared across nodes:\n *\n * ```ts\n * const Person = Site.node(personRouter, AppRoute.Person)\n * .title(({ personId }) => `Person ${personId} | Routing`)\n * .section('People')\n * .node\n * ```\n *\n * Methods — not pipeable fragments — because a pipeable fragment cannot\n * infer the route: each stage is a separate generic call, so its type\n * parameter falls back to the constraint and a typed callback no longer\n * matches. A method already knows its node's route, so inline lambdas\n * infer with no annotation. Read `.node` at any stage: every step freezes,\n * so intermediates are usable nodes too (targets, hrefs), never drafts.\n * `Site.route`'s options are sugar over this builder — one implementation.\n */\n node: <Route extends { readonly _tag: string }>(\n router: Router<Route>,\n routeCase: RouteCase<Route>,\n ): NodeBuilder<Route> => {\n const at = (built: SiteNode<Route>): NodeBuilder<Route> => ({\n node: built,\n pipe: <A>(fn: (builder: NodeBuilder<Route>) => A): A => fn(at(built)),\n title: title => at(Object.freeze({ ...built, title })),\n section: section => at(Object.freeze({ ...built, section })),\n landing: landing => at(Object.freeze({ ...built, landing })),\n shortcut: shortcut => at(Object.freeze({ ...built, shortcut })),\n history: history => at(Object.freeze({ ...built, history })),\n layout: layout => at(Object.freeze({ ...built, layout })),\n view: view => at(Object.freeze({ ...built, view })),\n surface: config => at(Object.freeze({ ...built, bound: config as BoundSurface })),\n })\n return at(baseNode(router, routeCase))\n },\n\n /**\n * A node with its children. Returns a mount; the node itself is untouched,\n * so it stays usable bare for targets and hrefs. Children may be bare\n * nodes (childless) or mounts.\n */\n mount: (\n node: SiteNode<any>,\n children: ReadonlyArray<SiteNode<any> | SiteMount> = [],\n ): SiteMount => Object.freeze({ node, children: Object.freeze(children.map(asMount)) }),\n\n /**\n * The deployed topology from its roots: bare nodes or mounts, frozen.\n * Refuses two nodes sharing a tag and one node mounted twice, since both\n * would make chain inspection ambiguous.\n */\n make: (...roots: ReadonlyArray<SiteNode<any> | SiteMount>): SiteTree => {\n const tree: SiteTree = Object.freeze({\n roots: Object.freeze(roots.map(asMount).map(freezeMount)),\n })\n // Fail at definition time, not at the first inspection.\n indexOf(tree)\n return tree\n },\n\n /**\n * One typed destination: the route value and the URL from the node's own\n * declaration, so a link can never point where the parser would not go.\n */\n target: <Route extends { readonly _tag: string }>(\n node: SiteNode<Route>,\n params: Omit<Route, '_tag'>,\n ): SiteTarget<Route> => ({\n node,\n route: node.case(params),\n url: node.router.build(params),\n }),\n\n /** The URL of a target, or of a node with params directly. */\n href: (<Route extends { readonly _tag: string }>(\n targetOrNode: SiteTarget<Route> | SiteNode<Route>,\n params?: Omit<Route, '_tag'>,\n ): string => {\n if ('url' in targetOrNode) return targetOrNode.url\n if (params === undefined)\n throw new Error(`Site.href: \"${targetOrNode.tag}\" needs params to build its URL`)\n return Site.target(targetOrNode, params).url\n }) as {\n <Route extends { readonly _tag: string }>(target: SiteTarget<Route>): string\n <Route extends { readonly _tag: string }>(\n node: SiteNode<Route>,\n params: Omit<Route, '_tag'>,\n ): string\n },\n\n /** Every node in the tree, depth-first, parents before children. */\n nodesOf: (site: SiteTree): ReadonlyArray<SiteNode<any>> => {\n const out: Array<SiteNode<any>> = []\n const visit = (mount: SiteMount): void => {\n out.push(mount.node)\n for (const child of mount.children) visit(child)\n }\n for (const root of site.roots) visit(root)\n return out\n },\n\n /** The node a route value is on, or nothing for a tag the tree does not hold. */\n nodeOf: (site: SiteTree, route: { readonly _tag: string }): SiteNode<any> | undefined =>\n indexOf(site).byTag.get(route._tag),\n\n /** The chain a route value is on, root first; none for an unknown tag. */\n chainOf: (site: SiteTree, route: { readonly _tag: string }): ReadonlyArray<SiteNode<any>> => {\n const { parent, byTag } = indexOf(site)\n const node = byTag.get(route._tag)\n if (node === undefined) return []\n const chain: Array<SiteNode<any>> = [node]\n let above = parent.get(node)\n while (above !== undefined) {\n chain.unshift(above)\n above = parent.get(above)\n }\n return chain\n },\n\n /** The node above this one in the tree, or nothing at a root. */\n parentOf: (site: SiteTree, node: SiteNode<any>): SiteNode<any> | undefined =>\n indexOf(site).parent.get(node),\n\n /** Every node above this one, root first. */\n ancestorsOf: (site: SiteTree, node: SiteNode<any>): ReadonlyArray<SiteNode<any>> => {\n const { parent } = indexOf(site)\n const out: Array<SiteNode<any>> = []\n let above = parent.get(node)\n while (above !== undefined) {\n out.unshift(above)\n above = parent.get(above)\n }\n return out\n },\n\n /** How deep the node sits: a root is 0, its children 1. */\n depthOf: (site: SiteTree, node: SiteNode<any>): number => Site.ancestorsOf(site, node).length,\n\n /** The title the tree annotates for a route value, or nothing. */\n titleOf: (site: SiteTree, route: { readonly _tag: string }): string | undefined => {\n const node = indexOf(site).byTag.get(route._tag)\n return node?.title?.(route)\n },\n\n /** The navigation section the tree annotates for a route value, or nothing. */\n sectionOf: (site: SiteTree, route: { readonly _tag: string }): string | undefined =>\n indexOf(site).byTag.get(route._tag)?.section,\n\n /**\n * Where a section's nav item points: the first node of the section with a\n * landing, as a target. Nothing when no node of the section declares one —\n * every section shown needs a landing, so navigation asserts it.\n */\n landing: (site: SiteTree, section: string): SiteTarget<any> | undefined => {\n for (const candidate of Site.nodesOf(site)) {\n if (candidate.section !== section) continue\n const landing = candidate.landing\n if (landing === undefined) continue\n return Site.target(candidate, landing)\n }\n return undefined\n },\n\n /**\n * Which history step a move is: to another node, a step; within a node, its\n * declaration (a string, or a function for nodes where some param changes\n * are entries of their own); with no previous target — the current location\n * is unknown to the site — a step too, so Back can still return to it.\n */\n historyOf: (prev: SiteTarget<any> | undefined, next: SiteTarget<any>): HistoryIntent => {\n if (prev === undefined || prev.node !== next.node) return 'push'\n const rule = next.node.history ?? 'replace'\n return typeof rule === 'function' ? rule(prev.route, next.route) : rule\n },\n\n /**\n * What the route draws: the deepest node's view, wrapped by every\n * ancestor's layout root-first. Ancestors contribute layouts only — never\n * their views. Pure function composition over ordinary Foldkit rendering;\n * unknown tags and viewless leaves fail loudly, since rendering one would\n * guess.\n */\n view: <Root, Message>(\n site: SiteTree,\n route: { readonly _tag: string },\n model: Root,\n h: HtmlBuilder<Message>,\n ): Html => {\n const chain = Site.chainOf(site, route)\n if (chain.length === 0) throw new Error(`Site.view: no node holds the tag \"${route._tag}\"`)\n // A lookup, so the non-null assertion is the documented one.\n const leaf = chain[chain.length - 1]!\n if (leaf.view === undefined)\n throw new Error(`Site.view: \"${leaf.tag}\" draws nothing; give the leaf a view`)\n let child = leaf.view.render(model, h)\n for (let at = chain.length - 2; at >= 0; at--) {\n const layout = chain[at]!.layout\n if (layout !== undefined) child = layout.render(child, model, h)\n }\n return child\n },\n\n /**\n * What the tree's surfaced nodes activate, keyed by tag, for `Data.wiring`,\n * `Data.subscriptions`, `Data.satisfy`, or an SSR plan's `surfaces`: each\n * node's `Surface.when` over the application's route place. A surface from\n * another application is refused here, not at its reads.\n */\n sources: <Root>(\n site: SiteTree,\n owner: object,\n place: ModelPlace<Root>,\n ): Record<string, ActiveSurface<Root> & SurfaceSource<Root>> => {\n const out: Record<string, ActiveSurface<Root> & SurfaceSource<Root>> = {}\n for (const node of Site.nodesOf(site)) {\n const entry = sourceOf(node, owner, place)\n if (entry !== undefined) out[entry[0]] = entry[1]\n }\n return out\n },\n\n /**\n * The route-level Sources for one destination: the same entries as\n * `Site.sources`, but only the target's chain. Prefetch, SSR, and DevTools\n * read what a route will activate without building its Model first; the\n * preparation itself stays caller-composed (`Data.satisfy` over these, with\n * the route set to the target's). A tag the tree does not hold resolves to\n * no Sources, the way an inactive Surface resolves to nothing.\n *\n * ```ts\n * const active = Site.sourcesFor(AppSite, App.owner, App.model.route, target.route)\n * const prepared = yield* Data.satisfy({ ...model, route: target.route }, active)\n * ```\n *\n * There is deliberately no `SitePlan` object yet: the chain is already\n * `Site.chainOf`, and head/access metadata arrive with their real consumers\n * (§31.9), not ahead of them.\n */\n sourcesFor: <Root>(\n site: SiteTree,\n owner: object,\n place: ModelPlace<Root>,\n route: { readonly _tag: string },\n ): Record<string, ActiveSurface<Root> & SurfaceSource<Root>> => {\n const out: Record<string, ActiveSurface<Root> & SurfaceSource<Root>> = {}\n for (const node of Site.chainOf(site, route)) {\n const entry = sourceOf(node, owner, place)\n if (entry !== undefined) out[entry[0]] = entry[1]\n }\n return out\n },\n\n /**\n * The application's link-click and URL-change lifecycle as one wiring, so\n * `update` stops hand-writing those two branches. A click on an internal\n * link navigates (pushing or replacing per `Site.historyOf`); on an\n * external link it loads; a URL change sets the route field — or touches\n * nothing when the address parses to the route already shown, so an echo\n * of our own write never re-renders or clears pending state. The\n * application's own update answers nothing for either message; `reduces`\n * names them for its guard, the way `Remote.reduces` does.\n *\n * ```ts\n * const Routing = Site.routing<Model, Message, AppRoute>({\n * site: AppSite,\n * owner: App.owner,\n * route: {\n * dependency: App.model.route.dependency,\n * get: (model) => model.route,\n * set: (model, route) => modifyFields(model, { route: () => route }),\n * },\n * parse: urlToAppRoute,\n * tags: { clicked: 'ClickedLink', changed: 'ChangedUrl' },\n * completed: Message.CompletedNavigation,\n * })\n * const assembly = Bundle.assemble([Routing, ...pages])\n * const update = assembly.update((model, message) =>\n * Routing.reduces(message) ? { model } : updateOwn(model, message),\n * )\n * ```\n *\n * One routing per application: it claims the click tag and shares the\n * change tag with URL mirrors, which read their slices first. With `pages`,\n * a route change sets the field and then informs each page whose route\n * arrived, through the page's own `changed` Message.\n */\n routing: <\n Root,\n Message extends { readonly _tag: string },\n Route extends { readonly _tag: string },\n R = never,\n >(config: {\n readonly site: SiteTree\n /**\n * The application's identity token, for the Module contract. Raw Foldkit\n * applications have none; omit it and the contract claims no owner.\n */\n readonly owner?: object | undefined\n /** The route field, read and written (a `RouteField`, struct). */\n readonly route: RouteField<Root, Route>\n /** The application's URL parser, with its NotFound fallback. */\n readonly parse: (url: UrlValue) => Route\n /** The application's own link-click and URL-change tags. */\n readonly tags: { readonly clicked: string; readonly changed: string }\n /** One completion for the navigation commands to dispatch. */\n readonly completed: Schema.Schema<Message> & (() => Message)\n /**\n * Routed pages, informed when their route arrives. With service-needing\n * pages, name the services fourth:\n * `Site.routing<Model, Message, AppRoute, RemoteClient>`.\n */\n readonly pages?: ReadonlyArray<SitePage<Root, Message, R, any>> | undefined\n }): Wiring<Root, Message, R> & {\n /** Whether the routing owns a message: its click or its URL change. */\n readonly reduces: (message: Message) => boolean\n } => {\n const completedTag = tagOfConstructor(\n config.completed,\n 'Site.routing: completed must be a message constructor',\n )\n const Navigate = Command.define('Site.Navigate', {\n args: { url: Schema.String, history: Schema.Literals(['push', 'replace']) },\n messages: [config.completed],\n execute: ({ url, history }) =>\n (history === 'push' ? Navigation.pushUrl(url) : Navigation.replaceUrl(url)).pipe(\n Effect.as(config.completed()),\n ),\n })\n const Load = Command.define('Site.Load', {\n args: { href: Schema.String },\n messages: [config.completed],\n execute: ({ href }) => Navigation.load(href).pipe(Effect.as(config.completed())),\n })\n // Route values are plain data from the same constructors, so equal\n // addresses compare equal. Checked before every write, so an echo of our\n // own navigation touches nothing: same Model back, no re-render.\n const sameRoute = (a: Route, b: Route): boolean => JSON.stringify(a) === JSON.stringify(b)\n const setRoute = (model: Root, next: Route): Root => {\n const current = config.route.get(model)\n return sameRoute(current, next) ? model : config.route.set(model, next)\n }\n const currentTarget = (model: Root): SiteTarget<Route> | undefined => {\n const current = config.route.get(model)\n const node = Site.nodeOf(config.site, current) as SiteNode<Route> | undefined\n if (node === undefined) return undefined\n // The tag rides along for matching only; params are everything else.\n const { _tag, ...params } = current\n return Site.target(node, params)\n }\n const reduces = (message: Message): boolean =>\n // tag-check: open — the tags are the application's own variants, named in config\n message._tag === config.tags.clicked || message._tag === config.tags.changed\n const wiring: Wiring<Root, Message, R> = {\n key: 'site',\n handles: [config.tags.clicked, config.tags.changed],\n shared: [config.tags.changed],\n route: (model, message) => {\n // tag-check: open — same ownership as reduces\n if (message._tag === config.tags.clicked) {\n const request = (message as unknown as { readonly request: UrlRequest }).request\n return Option.some(\n UrlRequest.match(request, {\n Internal: ({ url }) => {\n const next = config.parse(url)\n const node = Site.nodeOf(config.site, next)\n const intent =\n node === undefined\n ? ('push' as const)\n : Site.historyOf(currentTarget(model), {\n node,\n route: next,\n url: Url.toString(url),\n })\n return {\n model,\n commands: [Navigate({ url: Url.toString(url), history: intent })],\n }\n },\n External: ({ href }) => ({ model, commands: [Load({ href })] }),\n }),\n )\n }\n // tag-check: open — same ownership as reduces\n if (message._tag === config.tags.changed) {\n const url = (message as unknown as { readonly url: UrlValue }).url\n const next = config.parse(url)\n // An echo of the shown address touches nothing: same Model back,\n // and no page is informed of a route it already has.\n if (sameRoute(config.route.get(model), next)) return Option.some({ model })\n const steps: Array<Update.Step<Root, Message, R>> = [\n model => ({ model: setRoute(model, next) }),\n ...(config.pages ?? []).map(\n page => (model: Root) =>\n Option.getOrElse(page.inform(model, next), () => ({ model })),\n ),\n ]\n return Option.some(Update.combine(model, steps))\n }\n return Option.none()\n },\n onUrl: (model, url) => setRoute(model, config.parse(url)),\n contract: {\n kind: 'site',\n name: 'site',\n owner: config.owner,\n owns: [],\n observes: [config.route.dependency],\n messages: [completedTag],\n metadata: [],\n } satisfies Contract,\n }\n return { ...wiring, reduces }\n },\n\n /**\n * One routed page stated once: its link (where its Model lives and how its\n * Messages wrap), what starts it, and what its route arrival tells it. The\n * link carries the field and the wrapper together; `placed.update` folds\n * the child's Messages and `placed.view` draws it, and `Site.routing`\n * informs it through `changed` when its route arrives.\n *\n * ```ts\n * const PeoplePage = Site.placement(People, PeopleBundle, {\n * link: Link.field<Model>()('peoplePage', Link.wrapper(Message.GotPeopleMessage)),\n * args: parent => ({\n * searchText: parent.route._tag === 'People' ? parent.route.searchText : Option.none(),\n * }),\n * changed: route => People.Message.ChangedRoute({ route }),\n * })\n * const assembly = Bundle.assemble([PeoplePage.placed, Routing])\n * ```\n *\n * `changed` receives the node's own case value and returns the child's\n * Message, or nothing when the arrival needs no answer. Without it the\n * page is never informed. Bundles with OutMessages, and children that are\n * not Bundles, stay on `Bundle.at` and `Link.child` directly.\n */\n placement: <\n Route extends { readonly _tag: string },\n Parent,\n LinkMessage extends AnyMessage,\n ChildModel,\n ChildMessage extends AnyMessage,\n Field extends string,\n Name extends string,\n Args,\n BundleR = never,\n BundleS = never,\n ViewInputs = void,\n Resources extends ResourceEntries<ChildModel, ChildMessage> = never,\n Helpers extends Readonly<Record<string, Helper<ChildModel, ChildMessage, never, BundleR>>> =\n never,\n ObserverR = never,\n >(\n node: SiteNode<Route>,\n bundle: Bundle.Bundle<\n Name,\n Args,\n ChildModel,\n ChildMessage,\n never,\n BundleR,\n BundleS,\n ViewInputs,\n Resources,\n Helpers\n >,\n config: {\n readonly link: Link<Parent, LinkMessage, ChildModel, ChildMessage, Field>\n readonly changed?: (route: Route) => ChildMessage | undefined\n } & PlacementConfig<\n Args,\n Parent,\n LinkMessage,\n ChildMessage,\n never,\n never,\n ObserverR,\n SeedFor<Parent, Field>\n >,\n ): SitePage<\n Parent,\n LinkMessage,\n BundleR | ObserverR,\n Placed<\n Name,\n Parent,\n LinkMessage,\n ChildModel,\n ChildMessage,\n BundleR | ObserverR,\n BundleS,\n ViewInputs,\n Resources,\n Helpers,\n Field,\n LinkMessage extends { readonly _tag: infer Tag extends string } ? Tag : string\n >\n > => {\n const { link, changed } = config\n // `link` and `changed` are this helper's own: `Bundle.at` reads its\n // known keys, and a non-literal tolerates the extra properties.\n const placed = bundle.at(link, config)\n return {\n node,\n placed,\n inform: (model, route) => {\n if (!Predicate.isTagged(route, node.tag) || changed === undefined) return Option.none()\n // Guarded by the tag the node was built from, which `Site.make`\n // keeps unique: this is the node's own case value.\n const child = changed(route as Route)\n if (child === undefined) return Option.none()\n return placed.update(model, link.toParentMessage(child))\n },\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8PA,MAAM,oBAAoB,aAAsB,SAAyB;CACvE,MAAM,UAAW,YAAwE,QACrF,MAAM,KAAK;CACf,IAAI,OAAO,YAAY,UAAU,MAAM,IAAI,MAAM,GAAG,KAAK,8BAA8B;CACvF,OAAO;AACT;AAOA,MAAM,0BAAU,IAAI,QAA6B;;AAGjD,MAAM,WAAW,SAA8B;CAC7C,MAAM,QAAQ,QAAQ,IAAI,IAAI;CAC9B,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,yBAAS,IAAI,IAA8C;CACjE,MAAM,wBAAQ,IAAI,IAA2B;CAC7C,MAAM,SAAS,OAAkB,UAA2C;EAC1E,IAAI,OAAO,IAAI,MAAM,IAAI,GACvB,MAAM,IAAI,MACR,eAAe,MAAM,KAAK,IAAI,mDAChC;EACF,MAAM,WAAW,MAAM,IAAI,MAAM,KAAK,GAAG;EACzC,IAAI,aAAa,KAAA,KAAa,aAAa,MAAM,MAC/C,MAAM,IAAI,MACR,uCAAuC,MAAM,KAAK,IAAI,8BACxD;EACF,OAAO,IAAI,MAAM,MAAM,KAAK;EAC5B,MAAM,IAAI,MAAM,KAAK,KAAK,MAAM,IAAI;EACpC,KAAK,MAAM,SAAS,MAAM,UAAU,MAAM,OAAO,MAAM,IAAI;CAC7D;CACA,KAAK,MAAM,QAAQ,KAAK,OAAO,MAAM,MAAM,KAAA,CAAS;CACpD,MAAM,QAAQ;EAAE;EAAQ;CAAM;CAC9B,QAAQ,IAAI,MAAM,KAAK;CACvB,OAAO;AACT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AAM,QAA8C,EAClD,WAAU,EAAE,OAAO,SAAS,OAAO,IAAI,EAAE,IACzC,IAAI,OAAO,SAAS,CAAC,EAAA,CAAG,KACtB,UAAS,UACP,OAAO,UAAU,KAAK,OAAO,OAAO,IAAI,UAAU,EAAE,MAAM,EAAE,CAChE,CACF;KACA,OAAO,OAAO,KAAK,OAAO,QAAQ,OAAO,KAAK,CAAC;IACjD;IACA,OAAO,OAAO,KAAK;GACrB;GACA,QAAQ,OAAO,QAAQ,SAAS,OAAO,OAAO,MAAM,GAAG,CAAC;GACxD,UAAU;IACR,MAAM;IACN,MAAM;IACN,OAAO,OAAO;IACd,MAAM,CAAC;IACP,UAAU,CAAC,OAAO,MAAM,UAAU;IAClC,UAAU,CAAC,YAAY;IACvB,UAAU,CAAC;GACb;GAEkB;EAAQ;CAC9B;;;;;;;;;;;;;;;;;;;;;;;;CAyBA,YAiBE,MACA,QAYA,WA+BG;EACH,MAAM,EAAE,MAAM,YAAY;EAG1B,MAAM,SAAS,OAAO,GAAG,MAAM,MAAM;EACrC,OAAO;GACL;GACA;GACA,SAAS,OAAO,UAAU;IACxB,IAAI,CAAC,UAAU,SAAS,OAAO,KAAK,GAAG,KAAK,YAAY,KAAA,GAAW,OAAO,OAAO,KAAK;IAGtF,MAAM,QAAQ,QAAQ,KAAc;IACpC,IAAI,UAAU,KAAA,GAAW,OAAO,OAAO,KAAK;IAC5C,OAAO,OAAO,OAAO,OAAO,KAAK,gBAAgB,KAAK,CAAC;GACzD;EACF;CACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":["Url"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `foldkit-site` — the deployed route topology of a Foldkit application.\n *\n * A Site says where the application is: stable route nodes in a hierarchy,\n * each with its Foldkit Router, its metadata, and the Surfaces it activates.\n * Everything else — fetching, caching, rendering, navigation effects — stays\n * where it already is: the node compiles down to the primitives the runtime\n * already runs (`Route` biparsers, `Surface.when`, Bundle placements), so the\n * Site never becomes a second router, loader, or store.\n *\n * The rule, from the design:\n *\n * > Router says where the application is. Surface says what that state makes\n * > observable and capable. Remote says what server facts those observations\n * > require.\n *\n * Nothing here runs: nodes, mounts, trees, and targets are data. A `SiteTree`\n * is frozen at `Site.make`. `Site.routing` is the one runtime piece: the\n * link-click and URL-change lifecycle as a wiring, so applications stop\n * hand-writing those two update branches.\n */\nimport { Effect, Option, Predicate, Schema } from 'effect'\nimport {\n Bundle,\n Link,\n type AnyMessage,\n type Helper,\n type Placed,\n type PlacementConfig,\n type ResourceEntries,\n type SeedFor,\n} from 'foldkit-bundle'\nimport * as Command from 'foldkit/command'\nimport type { Html, HtmlBuilder } from 'foldkit/html'\nimport * as Navigation from 'foldkit/navigation'\nimport type { KeyBinding, KeySequence } from 'foldkit/subscription'\nimport { UrlRequest } from 'foldkit/navigation'\nimport { oneOf, parseUrlWithFallback, type Router } from 'foldkit/route'\nimport type { Meta } from 'foldkit-ssr/client'\nimport * as Update from 'foldkit/update'\nimport * as Url from 'foldkit/url'\nimport type { Url as UrlValue } from 'foldkit/url'\nimport {\n Surface,\n type ActiveSurface,\n type Contract,\n type ModelPlace,\n type Surface as SurfaceType,\n type SurfaceSource,\n type Wiring,\n} from 'foldkit-surface'\n\n/** Whether moving to a target adds a history step (`push`) or replaces the current one. */\nexport type HistoryIntent = 'push' | 'replace'\n\n/**\n * A route-case constructor: the Schema for `Surface.when`, called to build\n * route values for targets. The `any` is deliberate and quarantined here:\n * every constructor of a `defineRouteUnion` case is callable with its fields,\n * and `Site.target` types the params from the route value instead.\n */\nexport interface RouteCase<Route extends { readonly _tag: string }> extends Schema.Schema<Route> {\n (params: any): Route\n}\n\n/**\n * A Surface a node activates, with the route's params made into its own: the\n * `Surface.when` a node lowers to, once the application says where its route\n * lives. The surface's own types are checked where the node is declared\n * (`Site.route` infers them); by the time sources resolve, only the owner\n * check can still fail, and it does, loudly.\n */\nexport interface BoundSurface {\n readonly surface: SurfaceType<any, any, any, any>\n readonly params: (route: any) => any\n}\n\n/**\n * A layout around everything under a node: it receives the composed child\n * explicitly — no Outlet, no context, no hidden route state. Ancestors with\n * layouts wrap the leaf's view root-first; ancestors without one pass\n * through. The `any` positions are deliberate and quarantined, as with\n * `BoundSurface`: annotate the function where it is declared and it checks\n * there.\n */\nexport interface NodeLayout {\n readonly render: (child: Html, model: any, h: any) => Html\n}\n\n/**\n * What a node draws for its own route: only the deepest node of the active\n * chain draws (its ancestors contribute layouts, never their views — a\n * person page shows no people list). Same `any` quarantine as `NodeLayout`.\n */\nexport interface NodeView {\n readonly render: (model: any, h: any) => Html\n}\n\n/**\n * What a node says of itself in the document's head, from its route value and\n * the Model (a post's excerpt is in the Model, not the route). The node keeps\n * it with the Model as `any`, quarantined as `NodeLayout`'s is: name the Model\n * where it is declared (`.meta<Model>(...)`) and it checks there.\n */\nexport type NodeMeta<Route, Model = any> = (page: {\n readonly route: Route\n readonly model: Model\n}) => Meta\n\n/**\n * The route's place in the Model, read and written. A field holding a tagged\n * union is a *union of* `FieldRef`s, one per case, which no single\n * `ModelRef<Root, Route>` accepts — so this is structural:\n *\n * ```ts\n * route: {\n * dependency: App.model.route.dependency,\n * get: (model) => model.route,\n * set: (model, route) => modifyFields(model, { route: () => route }),\n * },\n * ```\n */\nexport interface RouteField<Root, Route> {\n readonly dependency: readonly string[]\n readonly get: (root: Root) => Route\n readonly set: (root: Root, route: Route) => Root\n}\n\n/**\n * One routed page: its node, its Bundle placement, and how a route arrival\n * reaches the child. The placement drives both folds from one declaration —\n * `placed.update` for Messages, `placed.view` for drawing — and `inform`\n * tells the child when its route arrives, through its own Message. The\n * placement's full type rides along, so assemblies keep inferring services.\n */\nexport interface SitePage<Parent, ParentMessage, R, P> {\n readonly node: SiteNode<any>\n readonly placed: P\n /**\n * The child told of a route arrival: `None` for another node's route, for\n * a page with nothing to say, or when the child says nothing is needed.\n */\n readonly inform: (\n model: Parent,\n route: { readonly _tag: string },\n ) => Option.Option<Update.Return<Parent, ParentMessage, R>>\n}\n\n/**\n * One deployed location: its Router (which owns URL semantics), its route\n * case, and its metadata. A stable first-class value: mounting it in a tree\n * never mutates it, so the same node serves targets, hrefs, and inspection\n * wherever it is mounted.\n */\nexport interface SiteNode<Route extends { readonly _tag: string }> {\n readonly tag: string\n readonly router: Router<Route>\n readonly case: RouteCase<Route>\n /** The page's title for this route, once the route value is known. */\n readonly title?: ((route: Route) => string) | undefined\n /** The navigation section this route belongs to, for menus and breadcrumbs. */\n readonly section?: string | undefined\n /**\n * Where the section's nav item points: this node's params for its landing\n * address (a people list with no search, say). Nodes a section never lands\n * on — a person, a file — leave it absent; `Site.landing` reads the first\n * node of a section that declares one.\n */\n readonly landing?: Omit<Route, '_tag'> | undefined\n /**\n * The keys that go to this node's `landing`, as Foldkit's key bindings name\n * them: one press (`'/'`, `'Mod+K'`) or a sequence (`['G', 'H']`).\n * `Site.shortcuts` makes the bindings.\n */\n readonly shortcut?: KeySequence | undefined\n /**\n * Which history step a move within this node is: a string, or a function\n * for nodes where some param changes are entries of their own (another\n * person) and others are views of one entry (another search). A move to\n * another node — or from an unknown location — is always a step.\n */\n readonly history?: HistoryIntent | ((prev: Route, next: Route) => HistoryIntent) | undefined\n /** The Surface this route activates, if the node declares one. */\n readonly bound?: BoundSurface | undefined\n /** A layout wrapping everything under this node, if it declares one. */\n readonly layout?: NodeLayout | undefined\n /** What this node draws for its own route, if it draws anything. */\n readonly view?: NodeView | undefined\n /** What this node says of itself in the head; nodes below override it per field. */\n readonly meta?: NodeMeta<Route> | undefined\n /**\n * Whether search engines index this node and, unless they say otherwise,\n * the nodes below it. Undeclared up the whole chain, a node is indexed.\n */\n readonly indexed?: boolean | undefined\n}\n\n/** Carries the routes a mount or tree holds, in its type only: nothing sets it. */\ndeclare const routes: unique symbol\n\n/** A node mounted with its children: structure, not state. `Route` is every route it holds. */\nexport interface SiteMount<Route extends { readonly _tag: string } = any> {\n readonly node: SiteNode<any>\n readonly children: ReadonlyArray<SiteMount>\n readonly [routes]?: (route: Route) => void\n}\n\n/** The routes a bare node or a mount holds. */\nexport type RoutesOf<Mounted> =\n Mounted extends SiteNode<infer Route>\n ? Route\n : Mounted extends SiteMount<infer Route>\n ? Route\n : never\n\n/**\n * A node under construction, from `Site.node`: each method annotates and\n * returns the builder, so nodes compose in steps and annotation bundles are\n * ordinary values. Methods — not pipeable fragments — because each stage of\n * a pipe is a separate generic call and could not infer the route. Read\n * `.node` at any stage for the frozen node so far.\n */\nexport interface NodeBuilder<Route extends { readonly _tag: string }> {\n /** The node so far: frozen, usable for targets and hrefs at any stage. */\n readonly node: SiteNode<Route>\n /**\n * One named bundle through the builder, Effect-style: the bundle stays\n * generic over the builder it meets, so it instantiates to this node's\n * route with no annotation. Chain for more than one.\n *\n * ```ts\n * const inSection = <R extends { readonly _tag: string }>(b: NodeBuilder<R>) =>\n * b.section('People').shortcut(['G', 'P'])\n *\n * const Person = Site.node(personRouter, AppRoute.Person).pipe(inSection).node\n * ```\n *\n * Free `pipe(builder, bundle)` from `effect` composes the same way; this\n * method is the same spelling without the import.\n */\n pipe<A>(fn: (builder: NodeBuilder<Route>) => A): A\n /** The page's title for this route, once the route value is known. */\n title(title: (route: Route) => string): NodeBuilder<Route>\n /** The navigation section this route belongs to. */\n section(section: string): NodeBuilder<Route>\n /** Where the section's nav item points, as this node's params. */\n landing(landing: Omit<Route, '_tag'>): NodeBuilder<Route>\n /** The keys that go to this node's landing. */\n shortcut(shortcut: KeySequence): NodeBuilder<Route>\n /** Which history step a move within this node is. */\n history(\n history: HistoryIntent | ((prev: Route, next: Route) => HistoryIntent),\n ): NodeBuilder<Route>\n /** A layout wrapping everything under this node. */\n layout(layout: NodeLayout): NodeBuilder<Route>\n /** What this node draws for its own route. */\n view(view: NodeView): NodeBuilder<Route>\n /** What this node says of itself in the head, from its route and the Model. */\n meta<Model = any>(meta: NodeMeta<Route, Model>): NodeBuilder<Route>\n /** Whether search engines index this node and the nodes below it. */\n indexed(indexed: boolean): NodeBuilder<Route>\n /** The Surface this route activates. */\n surface<SRoot, SModel, SMessage, SParams>(config: {\n readonly surface: SurfaceType<SRoot, SModel, SMessage, SParams>\n readonly params: (route: Route) => SParams\n }): NodeBuilder<Route>\n}\n\n/**\n * The deployed topology: roots with everything mounted under them, frozen.\n * `Route` is the union of every node's route, so the tree parses an address\n * to it (`Site.parse`) and builds one back (`Site.hrefOf`).\n */\nexport interface SiteTree<Route extends { readonly _tag: string } = any> {\n readonly roots: ReadonlyArray<SiteMount>\n readonly [routes]?: (route: Route) => void\n}\n\n/** One address a node's `Site.paths` lists: the route's params, and when its content last changed. */\nexport interface SitePath<Route extends { readonly _tag: string }> {\n readonly params: Omit<Route, '_tag'>\n /** When what the page shows last changed, as ISO 8601 text, for a sitemap. */\n readonly modified?: string | undefined\n}\n\n/** A node's addresses, listed by an Effect the build runs: from `Site.paths`. */\nexport interface SitePaths<E, R> {\n readonly node: SiteNode<any>\n readonly list: Effect.Effect<ReadonlyArray<SitePath<any>>, E, R>\n}\n\n/** How a listing of `SitePaths` can fail: each one's error, and none for no paths. */\nexport type PathsError<Paths> = Paths extends SitePaths<infer E, any> ? E : never\n/** What a listing of `SitePaths` needs: each one's services, and none for no paths. */\nexport type PathsServices<Paths> = Paths extends SitePaths<any, infer R> ? R : never\n\n/** One address of the whole site, from `Site.targets`: a target, and when it last changed. */\nexport interface SiteListed<Route extends { readonly _tag: string }> extends SiteTarget<Route> {\n readonly modified?: string | undefined\n}\n\n/**\n * One typed destination: the node, the route value, and the URL, all from one\n * declaration. Links, prefetch, and route analysis share this instead of each\n * rebuilding it.\n */\nexport interface SiteTarget<Route extends { readonly _tag: string }> {\n readonly node: SiteNode<Route>\n readonly route: Route\n readonly url: string\n}\n\n/**\n * The tag a tagged constructor names, read the way `Surface.when` reads it\n * off a route case. Anything else is a definition-time error, not a silent\n * mismatch.\n */\nconst tagOfConstructor = (constructor: unknown, what: string): string => {\n const literal = (constructor as { fields?: { _tag?: { ast?: { literal?: unknown } } } }).fields\n ?._tag?.ast?.literal\n if (typeof literal !== 'string') throw new Error(`${what} must be a tagged constructor`)\n return literal\n}\n\ninterface SiteIndex {\n readonly parent: ReadonlyMap<SiteNode<any>, SiteNode<any> | undefined>\n readonly byTag: ReadonlyMap<string, SiteNode<any>>\n /** The route the first node in tree order reads at an address, or nothing. */\n readonly read: (url: UrlValue) => Option.Option<any>\n}\n\nconst indexes = new WeakMap<SiteTree, SiteIndex>()\n\n/** The parent and tag maps and the parser of a tree, computed once per tree value. */\nconst indexOf = (site: SiteTree): SiteIndex => {\n const known = indexes.get(site)\n if (known !== undefined) return known\n const parent = new Map<SiteNode<any>, SiteNode<any> | undefined>()\n const byTag = new Map<string, SiteNode<any>>()\n const visit = (mount: SiteMount, above: SiteNode<any> | undefined): void => {\n if (parent.has(mount.node))\n throw new Error(\n `Site.make: \"${mount.node.tag}\" is mounted twice; a node has one place in a tree`,\n )\n const knownTag = byTag.get(mount.node.tag)\n if (knownTag !== undefined && knownTag !== mount.node)\n throw new Error(\n `Site.make: two nodes share the tag \"${mount.node.tag}\"; one route case is one node`,\n )\n parent.set(mount.node, above)\n byTag.set(mount.node.tag, mount.node)\n for (const child of mount.children) visit(child, mount.node)\n }\n for (const root of site.roots) visit(root, undefined)\n // Foldkit's parser takes only a fallback, so no match falls back to `None`.\n const parser = parseUrlWithFallback<any, Option.Option<any>>(\n oneOf(...[...parent.keys()].map(node => node.router)),\n { make: () => Option.none() },\n )\n const read = (url: UrlValue): Option.Option<any> => {\n const parsed = parser(url)\n return Option.isOption(parsed) ? parsed : Option.some(parsed)\n }\n const index = { parent, byTag, read }\n indexes.set(site, index)\n return index\n}\n\n/** Whether a node's route has params beyond its tag, so its addresses must be listed. */\nconst takesParams = (node: SiteNode<any>): boolean =>\n Object.keys((node.case as { fields?: object }).fields ?? {}).some(field => field !== '_tag')\n\nconst asMount = (node: SiteNode<any> | SiteMount): SiteMount =>\n 'children' in node ? node : { node, children: [] }\n\n/** One surfaced node's `Surface.when` over the route place, or nothing surfaceless. */\nconst sourceOf = <Root>(\n node: SiteNode<any>,\n owner: object,\n place: ModelPlace<Root>,\n): [string, ActiveSurface<Root> & SurfaceSource<Root>] | undefined => {\n const bound = node.bound\n if (bound === undefined) return undefined\n if (bound.surface.owner !== owner)\n throw new Error(`Site: \"${bound.surface.name}\" belongs to another application than the site`)\n return [node.tag, Surface.when(bound.surface, place, node.case, bound.params)]\n}\n\n/** The fields a `Meta` gives, so one left `undefined` does not erase an ancestor's. */\nconst saidOf = (meta: Meta): Meta =>\n Object.fromEntries(Object.entries(meta).filter(([, value]) => value !== undefined))\n\nconst freezeMount = (mount: SiteMount): SiteMount =>\n Object.freeze({\n node: mount.node,\n children: Object.freeze(mount.children.map(freezeMount)),\n })\n\n/** A bare node: its tag from its route case, nothing annotated. */\nconst baseNode = <Route extends { readonly _tag: string }>(\n router: Router<Route>,\n routeCase: RouteCase<Route>,\n): SiteNode<Route> =>\n Object.freeze({\n tag: tagOfConstructor(routeCase, 'Site.route: expected a route case from defineRouteUnion'),\n router,\n case: routeCase,\n })\n\nexport const Site = {\n /**\n * One deployed location from its Foldkit Router and its route case:\n *\n * ```ts\n * const Person = Site.route(personRouter, AppRoute.Person, {\n * title: ({ personId }) => `Person ${personId} | Routing`,\n * section: 'People',\n * })\n * ```\n *\n * The router stays the whole URL story (parse and build); the case names\n * the tag and builds route values. Metadata is annotated once here, and\n * navigation, titles, and history derive from it. To share annotations\n * across nodes, or to build incrementally, use the `Site.node` builder\n * instead — these options are sugar over it.\n */\n route: <Route extends { readonly _tag: string }, SRoot, SModel, SMessage, SParams>(\n router: Router<Route>,\n routeCase: RouteCase<Route>,\n options?: {\n readonly title?: ((route: Route) => string) | undefined\n readonly section?: string | undefined\n readonly landing?: Omit<Route, '_tag'> | undefined\n readonly shortcut?: KeySequence | undefined\n readonly history?: HistoryIntent | ((prev: Route, next: Route) => HistoryIntent) | undefined\n readonly layout?: NodeLayout | undefined\n readonly view?: NodeView | undefined\n readonly meta?: NodeMeta<Route> | undefined\n readonly indexed?: boolean | undefined\n readonly surface?:\n | {\n readonly surface: SurfaceType<SRoot, SModel, SMessage, SParams>\n readonly params: (route: Route) => SParams\n }\n | undefined\n },\n ): SiteNode<Route> => {\n let built = Site.node(router, routeCase)\n if (options?.title !== undefined) built = built.title(options.title)\n if (options?.section !== undefined) built = built.section(options.section)\n if (options?.landing !== undefined) built = built.landing(options.landing)\n if (options?.shortcut !== undefined) built = built.shortcut(options.shortcut)\n if (options?.history !== undefined) built = built.history(options.history)\n if (options?.layout !== undefined) built = built.layout(options.layout)\n if (options?.view !== undefined) built = built.view(options.view)\n if (options?.meta !== undefined) built = built.meta(options.meta)\n if (options?.indexed !== undefined) built = built.indexed(options.indexed)\n if (options?.surface !== undefined)\n built = built.surface<SRoot, SModel, SMessage, SParams>(options.surface)\n return built.node\n },\n\n /**\n * One deployed location as an incremental builder, for nodes annotated in\n * steps or annotations shared across nodes:\n *\n * ```ts\n * const Person = Site.node(personRouter, AppRoute.Person)\n * .title(({ personId }) => `Person ${personId} | Routing`)\n * .section('People')\n * .node\n * ```\n *\n * Methods — not pipeable fragments — because a pipeable fragment cannot\n * infer the route: each stage is a separate generic call, so its type\n * parameter falls back to the constraint and a typed callback no longer\n * matches. A method already knows its node's route, so inline lambdas\n * infer with no annotation. Read `.node` at any stage: every step freezes,\n * so intermediates are usable nodes too (targets, hrefs), never drafts.\n * `Site.route`'s options are sugar over this builder — one implementation.\n */\n node: <Route extends { readonly _tag: string }>(\n router: Router<Route>,\n routeCase: RouteCase<Route>,\n ): NodeBuilder<Route> => {\n const at = (built: SiteNode<Route>): NodeBuilder<Route> => ({\n node: built,\n pipe: <A>(fn: (builder: NodeBuilder<Route>) => A): A => fn(at(built)),\n title: title => at(Object.freeze({ ...built, title })),\n section: section => at(Object.freeze({ ...built, section })),\n landing: landing => at(Object.freeze({ ...built, landing })),\n shortcut: shortcut => at(Object.freeze({ ...built, shortcut })),\n history: history => at(Object.freeze({ ...built, history })),\n layout: layout => at(Object.freeze({ ...built, layout })),\n view: view => at(Object.freeze({ ...built, view })),\n meta: meta => at(Object.freeze({ ...built, meta })),\n indexed: indexed => at(Object.freeze({ ...built, indexed })),\n surface: config => at(Object.freeze({ ...built, bound: config as BoundSurface })),\n })\n return at(baseNode(router, routeCase))\n },\n\n /**\n * A node with its children. Returns a mount; the node itself is untouched,\n * so it stays usable bare for targets and hrefs. Children may be bare\n * nodes (childless) or mounts.\n */\n mount: <\n Route extends { readonly _tag: string },\n const Children extends ReadonlyArray<SiteNode<any> | SiteMount> = [],\n >(\n node: SiteNode<Route>,\n children?: Children,\n ): SiteMount<Route | RoutesOf<Children[number]>> =>\n Object.freeze({ node, children: Object.freeze((children ?? []).map(asMount)) }),\n\n /**\n * The deployed topology from its roots: bare nodes or mounts, frozen.\n * Refuses two nodes sharing a tag and one node mounted twice, since both\n * would make chain inspection ambiguous.\n */\n make: <const Roots extends ReadonlyArray<SiteNode<any> | SiteMount>>(\n ...roots: Roots\n ): SiteTree<RoutesOf<Roots[number]>> => {\n const tree: SiteTree<RoutesOf<Roots[number]>> = Object.freeze({\n roots: Object.freeze(roots.map(asMount).map(freezeMount)),\n })\n // Fail at definition time, not at the first inspection.\n indexOf(tree)\n return tree\n },\n\n /**\n * One typed destination: the route value and the URL from the node's own\n * declaration, so a link can never point where the parser would not go.\n */\n target: <Route extends { readonly _tag: string }>(\n node: SiteNode<Route>,\n params: Omit<Route, '_tag'>,\n ): SiteTarget<Route> => ({\n node,\n route: node.case(params),\n url: node.router.build(params),\n }),\n\n /** The URL of a target, or of a node with params directly. */\n href: (<Route extends { readonly _tag: string }>(\n targetOrNode: SiteTarget<Route> | SiteNode<Route>,\n params?: Omit<Route, '_tag'>,\n ): string => {\n if ('url' in targetOrNode) return targetOrNode.url\n if (params === undefined)\n throw new Error(`Site.href: \"${targetOrNode.tag}\" needs params to build its URL`)\n return Site.target(targetOrNode, params).url\n }) as {\n <Route extends { readonly _tag: string }>(target: SiteTarget<Route>): string\n <Route extends { readonly _tag: string }>(\n node: SiteNode<Route>,\n params: Omit<Route, '_tag'>,\n ): string\n },\n\n /**\n * The tree's parser: an address to the route of the first node, in tree\n * order (depth-first, parents first), whose router takes all of it, or the\n * fallback. A router that takes any segment (`/:slug`) belongs after the\n * nodes whose literal it would take too. With `Site.hrefOf`, the tree is\n * the one declaration of both directions.\n */\n parse: <Route extends { readonly _tag: string }, Fallback>(\n site: SiteTree<Route>,\n fallback: { readonly make: (data: { readonly path: string }) => Fallback },\n ): ((url: UrlValue) => Route | Fallback) => {\n const { read } = indexOf(site)\n return (url): Route | Fallback =>\n Option.getOrElse(read(url), () => fallback.make({ path: url.pathname }))\n },\n\n /**\n * The route the tree reads at an address, as `Site.parse` does, or nothing\n * when no node takes it: an address the tree does not hold is another\n * document's, which a link reaches with a full load.\n */\n routeAt: <Route extends { readonly _tag: string }>(\n site: SiteTree<Route>,\n url: UrlValue,\n ): Option.Option<Route> => indexOf(site).read(url),\n\n /**\n * The address of a route the tree holds, built by its node's router, so it\n * parses back to the same route (`Site.parse`).\n */\n hrefOf: <Route extends { readonly _tag: string }>(\n site: SiteTree<Route>,\n route: Route,\n ): string => {\n const node = indexOf(site).byTag.get(route._tag)\n if (node === undefined) throw new Error(`Site.hrefOf: no node holds the tag \"${route._tag}\"`)\n const { _tag, ...params } = route\n return node.router.build(params)\n },\n\n /**\n * A node's addresses, from data: every published post is one. `list` is an\n * Effect the build runs, such as a Remote query read through\n * `Data.satisfy`, so it lists what a visitor may see.\n *\n * ```ts\n * const posts = Site.paths(PostNode, listPosts.pipe(\n * Effect.map(rows => rows.map(row => ({ params: { slug: row.slug }, modified: row.at }))),\n * ))\n * ```\n */\n paths: <Route extends { readonly _tag: string }, E, R>(\n node: SiteNode<Route>,\n list: Effect.Effect<ReadonlyArray<SitePath<Route>>, E, R>,\n ): SitePaths<E, R> => ({ node, list }),\n\n /**\n * Every address of the site, in tree order: one for each node whose route\n * has no params, and what `paths` lists for each node whose route has\n * them. What a build renders, a sitemap lists (with `Site.indexedOf`), and\n * a prefetch warms. A node with params and no `paths` is refused, as are\n * `paths` for a node the tree does not hold or twice for one node, so no\n * page is left out unsaid; `Site.paths(node, Effect.succeed([]))` lists none.\n */\n targets: <const Paths extends ReadonlyArray<SitePaths<any, any>>>(\n site: SiteTree,\n paths: Paths,\n ): Effect.Effect<\n ReadonlyArray<SiteListed<any>>,\n PathsError<Paths[number]>,\n PathsServices<Paths[number]>\n > => {\n const nodes = Site.nodesOf(site)\n const listed = new Map<SiteNode<any>, SitePaths<any, any>>()\n for (const each of paths) {\n if (!nodes.includes(each.node))\n throw new Error(`Site.targets: \"${each.node.tag}\" has paths but is not in the tree`)\n if (listed.has(each.node)) throw new Error(`Site.targets: \"${each.node.tag}\" has paths twice`)\n listed.set(each.node, each)\n }\n const unlisted = nodes.filter(node => takesParams(node) && !listed.has(node))\n if (unlisted.length > 0)\n throw new Error(\n `Site.targets: ${unlisted.map(node => `\"${node.tag}\"`).join(', ')} take params and have no paths`,\n )\n return Effect.map(\n Effect.forEach(\n nodes,\n node => {\n const source = listed.get(node)\n if (source === undefined) return Effect.succeed([Site.target(node, {})])\n return Effect.map(source.list, found =>\n found.map(({ params, modified }) => ({\n ...Site.target(node, params),\n ...(modified === undefined ? {} : { modified }),\n })),\n )\n },\n { concurrency: 'unbounded' },\n ),\n perNode => perNode.flat(),\n )\n },\n\n /** Every node in the tree, depth-first, parents before children. */\n nodesOf: (site: SiteTree): ReadonlyArray<SiteNode<any>> => {\n const out: Array<SiteNode<any>> = []\n const visit = (mount: SiteMount): void => {\n out.push(mount.node)\n for (const child of mount.children) visit(child)\n }\n for (const root of site.roots) visit(root)\n return out\n },\n\n /** The node a route value is on, or nothing for a tag the tree does not hold. */\n nodeOf: (site: SiteTree, route: { readonly _tag: string }): SiteNode<any> | undefined =>\n indexOf(site).byTag.get(route._tag),\n\n /** The chain a route value is on, root first; none for an unknown tag. */\n chainOf: (site: SiteTree, route: { readonly _tag: string }): ReadonlyArray<SiteNode<any>> => {\n const { parent, byTag } = indexOf(site)\n const node = byTag.get(route._tag)\n if (node === undefined) return []\n const chain: Array<SiteNode<any>> = [node]\n let above = parent.get(node)\n while (above !== undefined) {\n chain.unshift(above)\n above = parent.get(above)\n }\n return chain\n },\n\n /** The node above this one in the tree, or nothing at a root. */\n parentOf: (site: SiteTree, node: SiteNode<any>): SiteNode<any> | undefined =>\n indexOf(site).parent.get(node),\n\n /** Every node above this one, root first. */\n ancestorsOf: (site: SiteTree, node: SiteNode<any>): ReadonlyArray<SiteNode<any>> => {\n const { parent } = indexOf(site)\n const out: Array<SiteNode<any>> = []\n let above = parent.get(node)\n while (above !== undefined) {\n out.unshift(above)\n above = parent.get(above)\n }\n return out\n },\n\n /** How deep the node sits: a root is 0, its children 1. */\n depthOf: (site: SiteTree, node: SiteNode<any>): number => Site.ancestorsOf(site, node).length,\n\n /** The title the tree annotates for a route value, or nothing. */\n titleOf: (site: SiteTree, route: { readonly _tag: string }): string | undefined => {\n const node = indexOf(site).byTag.get(route._tag)\n return node?.title?.(route)\n },\n\n /**\n * Whether search engines index a route: the nearest declaration up its\n * chain, so a `noindex` studio covers every node below it. A route the tree\n * does not hold is indexed, as a page with no declaration is.\n */\n indexedOf: (site: SiteTree, route: { readonly _tag: string }): boolean => {\n const chain = Site.chainOf(site, route)\n for (let at = chain.length - 1; at >= 0; at--) {\n const indexed = chain[at]!.indexed\n if (indexed !== undefined) return indexed\n }\n return true\n },\n\n /**\n * What a route says of itself in the head, for an SSR plan's `meta`:\n *\n * ```ts\n * SSR.plan(App, { id: 'site', state, meta: model => Site.metaOf(AppSite, model.route, model) })\n * ```\n *\n * Each node of the chain's `meta`, root first, with a deeper node's field\n * replacing its ancestor's and a field it leaves out keeping the ancestor's.\n * The preview title falls back to the route's `title`. An unindexed route\n * (`Site.indexedOf`) is `noindex` whatever its `meta` says.\n */\n metaOf: <Root>(site: SiteTree, route: { readonly _tag: string }, model: Root): Meta => {\n let meta: Meta = {}\n for (const node of Site.chainOf(site, route))\n if (node.meta !== undefined) meta = { ...meta, ...saidOf(node.meta({ route, model })) }\n const title = meta.title ?? Site.titleOf(site, route)\n return {\n ...meta,\n ...(title === undefined ? {} : { title }),\n ...(Site.indexedOf(site, route) ? {} : { robots: 'noindex' }),\n }\n },\n\n /** The navigation section the tree annotates for a route value, or nothing. */\n sectionOf: (site: SiteTree, route: { readonly _tag: string }): string | undefined =>\n indexOf(site).byTag.get(route._tag)?.section,\n\n /**\n * Where a section's nav item points: the first node of the section with a\n * landing, as a target. Nothing when no node of the section declares one —\n * every section shown needs a landing, so navigation asserts it.\n */\n landing: (site: SiteTree, section: string): SiteTarget<any> | undefined => {\n for (const candidate of Site.nodesOf(site)) {\n if (candidate.section !== section) continue\n const landing = candidate.landing\n if (landing === undefined) continue\n return Site.target(candidate, landing)\n }\n return undefined\n },\n\n /**\n * The tree's shortcuts as key bindings, each sending the Message\n * `toMessage` makes of its node's landing:\n *\n * ```ts\n * Subscription.keyBindings({\n * bindings: Site.shortcuts(AppSite, target => Message.PressedShortcut({ url: target.url })),\n * })\n * ```\n *\n * A shortcut on a node with no `landing` goes nowhere, and one used twice\n * goes to two places; both are refused.\n */\n shortcuts: <Message>(\n site: SiteTree,\n toMessage: (target: SiteTarget<any>) => Message,\n ): ReadonlyArray<KeyBinding<Message>> => {\n const taken = new Map<string, string>()\n return Site.nodesOf(site).flatMap((node): ReadonlyArray<KeyBinding<Message>> => {\n const keys = node.shortcut\n if (keys === undefined) return []\n if (node.landing === undefined)\n throw new Error(`Site.shortcuts: \"${node.tag}\" has a shortcut and no landing to go to`)\n const named = typeof keys === 'string' ? keys : keys.join(' ')\n const other = taken.get(named)\n if (other !== undefined)\n throw new Error(`Site.shortcuts: \"${named}\" goes to both \"${other}\" and \"${node.tag}\"`)\n taken.set(named, node.tag)\n const message = toMessage(Site.target(node, node.landing))\n const mapEvent = () => message\n // The binding's two shapes are told apart by `keys`, so each is made whole.\n return [typeof keys === 'string' ? { keys, mapEvent } : { keys, mapEvent }]\n })\n },\n\n /**\n * Which history step a move is: to another node, a step; within a node, its\n * declaration (a string, or a function for nodes where some param changes\n * are entries of their own); with no previous target — the current location\n * is unknown to the site — a step too, so Back can still return to it.\n */\n historyOf: (prev: SiteTarget<any> | undefined, next: SiteTarget<any>): HistoryIntent => {\n if (prev === undefined || prev.node !== next.node) return 'push'\n const rule = next.node.history ?? 'replace'\n return typeof rule === 'function' ? rule(prev.route, next.route) : rule\n },\n\n /**\n * What the route draws: the deepest node's view, wrapped by every\n * ancestor's layout root-first. Ancestors contribute layouts only — never\n * their views. Pure function composition over ordinary Foldkit rendering;\n * unknown tags and viewless leaves fail loudly, since rendering one would\n * guess.\n */\n view: <Root, Message>(\n site: SiteTree,\n route: { readonly _tag: string },\n model: Root,\n h: HtmlBuilder<Message>,\n ): Html => {\n const chain = Site.chainOf(site, route)\n if (chain.length === 0) throw new Error(`Site.view: no node holds the tag \"${route._tag}\"`)\n // A lookup, so the non-null assertion is the documented one.\n const leaf = chain[chain.length - 1]!\n if (leaf.view === undefined)\n throw new Error(`Site.view: \"${leaf.tag}\" draws nothing; give the leaf a view`)\n let child = leaf.view.render(model, h)\n for (let at = chain.length - 2; at >= 0; at--) {\n const layout = chain[at]!.layout\n if (layout !== undefined) child = layout.render(child, model, h)\n }\n return child\n },\n\n /**\n * What the tree's surfaced nodes activate, keyed by tag, for `Data.wiring`,\n * `Data.subscriptions`, `Data.satisfy`, or an SSR plan's `surfaces`: each\n * node's `Surface.when` over the application's route place. A surface from\n * another application is refused here, not at its reads.\n */\n sources: <Root>(\n site: SiteTree,\n owner: object,\n place: ModelPlace<Root>,\n ): Record<string, ActiveSurface<Root> & SurfaceSource<Root>> => {\n const out: Record<string, ActiveSurface<Root> & SurfaceSource<Root>> = {}\n for (const node of Site.nodesOf(site)) {\n const entry = sourceOf(node, owner, place)\n if (entry !== undefined) out[entry[0]] = entry[1]\n }\n return out\n },\n\n /**\n * The route-level Sources for one destination: the same entries as\n * `Site.sources`, but only the target's chain. Prefetch, SSR, and DevTools\n * read what a route will activate without building its Model first; the\n * preparation itself stays caller-composed (`Data.satisfy` over these, with\n * the route set to the target's). A tag the tree does not hold resolves to\n * no Sources, the way an inactive Surface resolves to nothing.\n *\n * ```ts\n * const active = Site.sourcesFor(AppSite, App.owner, App.model.route, target.route)\n * const prepared = yield* Data.satisfy({ ...model, route: target.route }, active)\n * ```\n *\n * There is deliberately no `SitePlan` object: the chain is already\n * `Site.chainOf`, and the head is `Site.metaOf`.\n */\n sourcesFor: <Root>(\n site: SiteTree,\n owner: object,\n place: ModelPlace<Root>,\n route: { readonly _tag: string },\n ): Record<string, ActiveSurface<Root> & SurfaceSource<Root>> => {\n const out: Record<string, ActiveSurface<Root> & SurfaceSource<Root>> = {}\n for (const node of Site.chainOf(site, route)) {\n const entry = sourceOf(node, owner, place)\n if (entry !== undefined) out[entry[0]] = entry[1]\n }\n return out\n },\n\n /**\n * The application's link-click and URL-change lifecycle as one wiring, so\n * `update` stops hand-writing those two branches. A click on a link the\n * tree holds navigates (pushing or replacing per `Site.historyOf`); on any\n * other, on this origin or not, it loads, since another document serves\n * it (`Site.routeAt`); a URL change sets the route field — or touches\n * nothing when the address parses to the route already shown, so an echo\n * of our own write never re-renders or clears pending state. The\n * application's own update answers nothing for either message; `reduces`\n * names them for its guard, the way `Remote.reduces` does.\n *\n * ```ts\n * const Routing = Site.routing<Model, Message, AppRoute>({\n * site: AppSite,\n * owner: App.owner,\n * route: {\n * dependency: App.model.route.dependency,\n * get: (model) => model.route,\n * set: (model, route) => modifyFields(model, { route: () => route }),\n * },\n * parse: urlToAppRoute,\n * tags: { clicked: 'ClickedLink', changed: 'ChangedUrl' },\n * completed: Message.CompletedNavigation,\n * })\n * const assembly = Bundle.assemble([Routing, ...pages])\n * const update = assembly.update((model, message) =>\n * Routing.reduces(message) ? { model } : updateOwn(model, message),\n * )\n * ```\n *\n * One routing per application: it claims the click tag and shares the\n * change tag with URL mirrors, which read their slices first. With `pages`,\n * a route change sets the field and then informs each page whose route\n * arrived, through the page's own `changed` Message.\n */\n routing: <\n Root,\n Message extends { readonly _tag: string },\n Route extends { readonly _tag: string },\n R = never,\n >(config: {\n readonly site: SiteTree\n /**\n * The application's identity token, for the Module contract. Raw Foldkit\n * applications have none; omit it and the contract claims no owner.\n */\n readonly owner?: object | undefined\n /** The route field, read and written (a `RouteField`, struct). */\n readonly route: RouteField<Root, Route>\n /** The application's URL parser, with its NotFound fallback. */\n readonly parse: (url: UrlValue) => Route\n /** The application's own link-click and URL-change tags. */\n readonly tags: { readonly clicked: string; readonly changed: string }\n /** One completion for the navigation commands to dispatch. */\n readonly completed: Schema.Schema<Message> & (() => Message)\n /**\n * Routed pages, informed when their route arrives. With service-needing\n * pages, name the services fourth:\n * `Site.routing<Model, Message, AppRoute, RemoteClient>`.\n */\n readonly pages?: ReadonlyArray<SitePage<Root, Message, R, any>> | undefined\n /**\n * What the application does once a new route is set and its pages are\n * told: moving focus to what it drew, say. An echo of the shown address\n * arrives nowhere, so it runs nothing.\n */\n readonly arrived?: ((model: Root, route: Route) => Update.Return<Root, Message, R>) | undefined\n }): Wiring<Root, Message, R> & {\n /** Whether the routing owns a message: its click or its URL change. */\n readonly reduces: (message: Message) => boolean\n } => {\n const completedTag = tagOfConstructor(\n config.completed,\n 'Site.routing: completed must be a message constructor',\n )\n const Navigate = Command.define('Site.Navigate', {\n args: { url: Schema.String, history: Schema.Literals(['push', 'replace']) },\n messages: [config.completed],\n execute: ({ url, history }) =>\n (history === 'push' ? Navigation.pushUrl(url) : Navigation.replaceUrl(url)).pipe(\n Effect.as(config.completed()),\n ),\n })\n const { arrived } = config\n const Load = Command.define('Site.Load', {\n args: { href: Schema.String },\n messages: [config.completed],\n execute: ({ href }) => Navigation.load(href).pipe(Effect.as(config.completed())),\n })\n // Route values are plain data from the same constructors, so equal\n // addresses compare equal. Checked before every write, so an echo of our\n // own navigation touches nothing: same Model back, no re-render.\n const sameRoute = (a: Route, b: Route): boolean => JSON.stringify(a) === JSON.stringify(b)\n const setRoute = (model: Root, next: Route): Root => {\n const current = config.route.get(model)\n return sameRoute(current, next) ? model : config.route.set(model, next)\n }\n const currentTarget = (model: Root): SiteTarget<Route> | undefined => {\n const current = config.route.get(model)\n const node = Site.nodeOf(config.site, current) as SiteNode<Route> | undefined\n if (node === undefined) return undefined\n // The tag rides along for matching only; params are everything else.\n const { _tag, ...params } = current\n return Site.target(node, params)\n }\n const reduces = (message: Message): boolean =>\n // tag-check: open — the tags are the application's own variants, named in config\n message._tag === config.tags.clicked || message._tag === config.tags.changed\n const wiring: Wiring<Root, Message, R> = {\n key: 'site',\n handles: [config.tags.clicked, config.tags.changed],\n shared: [config.tags.changed],\n route: (model, message) => {\n // tag-check: open — same ownership as reduces\n if (message._tag === config.tags.clicked) {\n const request = (message as unknown as { readonly request: UrlRequest }).request\n return Option.some(\n UrlRequest.match(request, {\n Internal: ({ url }) =>\n Option.match(Site.routeAt(config.site, url), {\n // No node takes it, so another document serves it.\n onNone: () => ({ model, commands: [Load({ href: Url.toString(url) })] }),\n onSome: next => {\n // A lookup: the route came from one of the tree's nodes.\n const node = Site.nodeOf(config.site, next)!\n const history = Site.historyOf(currentTarget(model), {\n node,\n route: next,\n url: Url.toString(url),\n })\n return {\n model,\n commands: [Navigate({ url: Url.toString(url), history })],\n }\n },\n }),\n External: ({ href }) => ({ model, commands: [Load({ href })] }),\n }),\n )\n }\n // tag-check: open — same ownership as reduces\n if (message._tag === config.tags.changed) {\n const url = (message as unknown as { readonly url: UrlValue }).url\n const next = config.parse(url)\n // An echo of the shown address touches nothing: same Model back,\n // and no page is informed of a route it already has.\n if (sameRoute(config.route.get(model), next)) return Option.some({ model })\n const steps: Array<Update.Step<Root, Message, R>> = [\n model => ({ model: setRoute(model, next) }),\n ...(config.pages ?? []).map(\n page => (model: Root) =>\n Option.getOrElse(page.inform(model, next), () => ({ model })),\n ),\n ...(arrived === undefined ? [] : [(model: Root) => arrived(model, next)]),\n ]\n return Option.some(Update.combine(model, steps))\n }\n return Option.none()\n },\n onUrl: (model, url) => setRoute(model, config.parse(url)),\n contract: {\n kind: 'site',\n name: 'site',\n owner: config.owner,\n owns: [],\n observes: [config.route.dependency],\n messages: [completedTag],\n metadata: [],\n } satisfies Contract,\n }\n return { ...wiring, reduces }\n },\n\n /**\n * One routed page stated once: its link (where its Model lives and how its\n * Messages wrap), what starts it, and what its route arrival tells it. The\n * link carries the field and the wrapper together; `placed.update` folds\n * the child's Messages and `placed.view` draws it, and `Site.routing`\n * informs it through `changed` when its route arrives.\n *\n * ```ts\n * const PeoplePage = Site.placement(People, PeopleBundle, {\n * link: Link.field<Model>()('peoplePage', Link.wrapper(Message.GotPeopleMessage)),\n * args: parent => ({\n * searchText: parent.route._tag === 'People' ? parent.route.searchText : Option.none(),\n * }),\n * changed: route => People.Message.ChangedRoute({ route }),\n * })\n * const assembly = Bundle.assemble([PeoplePage.placed, Routing])\n * ```\n *\n * `changed` receives the node's own case value and returns the child's\n * Message, or nothing when the arrival needs no answer. Without it the\n * page is never informed. Bundles with OutMessages, and children that are\n * not Bundles, stay on `Bundle.at` and `Link.child` directly.\n */\n placement: <\n Route extends { readonly _tag: string },\n Parent,\n LinkMessage extends AnyMessage,\n ChildModel,\n ChildMessage extends AnyMessage,\n Field extends string,\n Name extends string,\n Args,\n BundleR = never,\n BundleS = never,\n ViewInputs = void,\n Resources extends ResourceEntries<ChildModel, ChildMessage> = never,\n Helpers extends Readonly<Record<string, Helper<ChildModel, ChildMessage, never, BundleR>>> =\n never,\n ObserverR = never,\n >(\n node: SiteNode<Route>,\n bundle: Bundle.Bundle<\n Name,\n Args,\n ChildModel,\n ChildMessage,\n never,\n BundleR,\n BundleS,\n ViewInputs,\n Resources,\n Helpers\n >,\n config: {\n readonly link: Link<Parent, LinkMessage, ChildModel, ChildMessage, Field>\n readonly changed?: (route: Route) => ChildMessage | undefined\n } & PlacementConfig<\n Args,\n Parent,\n LinkMessage,\n ChildMessage,\n never,\n never,\n ObserverR,\n SeedFor<Parent, Field>\n >,\n ): SitePage<\n Parent,\n LinkMessage,\n BundleR | ObserverR,\n Placed<\n Name,\n Parent,\n LinkMessage,\n ChildModel,\n ChildMessage,\n BundleR | ObserverR,\n BundleS,\n ViewInputs,\n Resources,\n Helpers,\n Field,\n LinkMessage extends { readonly _tag: infer Tag extends string } ? Tag : string\n >\n > => {\n const { link, changed } = config\n // `link` and `changed` are this helper's own: `Bundle.at` reads its\n // known keys, and a non-literal tolerates the extra properties.\n const placed = bundle.at(link, config)\n return {\n node,\n placed,\n inform: (model, route) => {\n if (!Predicate.isTagged(route, node.tag) || changed === undefined) return Option.none()\n // Guarded by the tag the node was built from, which `Site.make`\n // keeps unique: this is the node's own case value.\n const child = changed(route as Route)\n if (child === undefined) return Option.none()\n return placed.update(model, link.toParentMessage(child))\n },\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6TA,MAAM,oBAAoB,aAAsB,SAAyB;CACvE,MAAM,UAAW,YAAwE,QACrF,MAAM,KAAK;CACf,IAAI,OAAO,YAAY,UAAU,MAAM,IAAI,MAAM,GAAG,KAAK,8BAA8B;CACvF,OAAO;AACT;AASA,MAAM,0BAAU,IAAI,QAA6B;;AAGjD,MAAM,WAAW,SAA8B;CAC7C,MAAM,QAAQ,QAAQ,IAAI,IAAI;CAC9B,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,yBAAS,IAAI,IAA8C;CACjE,MAAM,wBAAQ,IAAI,IAA2B;CAC7C,MAAM,SAAS,OAAkB,UAA2C;EAC1E,IAAI,OAAO,IAAI,MAAM,IAAI,GACvB,MAAM,IAAI,MACR,eAAe,MAAM,KAAK,IAAI,mDAChC;EACF,MAAM,WAAW,MAAM,IAAI,MAAM,KAAK,GAAG;EACzC,IAAI,aAAa,KAAA,KAAa,aAAa,MAAM,MAC/C,MAAM,IAAI,MACR,uCAAuC,MAAM,KAAK,IAAI,8BACxD;EACF,OAAO,IAAI,MAAM,MAAM,KAAK;EAC5B,MAAM,IAAI,MAAM,KAAK,KAAK,MAAM,IAAI;EACpC,KAA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AK,YAAY,KAAA,GAAW,OAAO,OAAO,KAAK;IAGtF,MAAM,QAAQ,QAAQ,KAAc;IACpC,IAAI,UAAU,KAAA,GAAW,OAAO,OAAO,KAAK;IAC5C,OAAO,OAAO,OAAO,OAAO,KAAK,gBAAgB,KAAK,CAAC;GACzD;EACF;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldkit-site",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "The deployed route topology of a Foldkit application: stable route nodes, their hierarchy, typed targets, and per-node metadata, compiled to the Foldkit Router, Surface, and Bundle primitives the runtime already runs.",
5
5
  "keywords": [
6
6
  "foldkit",
@@ -39,6 +39,7 @@
39
39
  ],
40
40
  "dependencies": {
41
41
  "foldkit-bundle": "0.6.0",
42
+ "foldkit-ssr": "0.5.0",
42
43
  "foldkit-surface": "0.8.0"
43
44
  },
44
45
  "peerDependencies": {
@@ -51,10 +52,10 @@
51
52
  "tsdown": "^0.23.0",
52
53
  "typescript": "5.9.3",
53
54
  "foldkit-bundle": "0.6.0",
54
- "foldkit-entity": "0.8.0",
55
- "foldkit-remote": "0.14.0",
55
+ "foldkit-entity": "0.8.1",
56
56
  "foldkit-ssr": "0.5.0",
57
- "foldkit-surface": "0.8.0"
57
+ "foldkit-surface": "0.8.0",
58
+ "foldkit-remote": "0.15.0"
58
59
  },
59
60
  "scripts": {
60
61
  "build": "tsdown",