foldkit-site 0.5.0 → 0.7.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
@@ -354,6 +354,23 @@ the field is `arrived: (model, route) => ({ model, commands })`, run after the
354
354
  routed pages are told and never for an echo: the CMS site moves focus to what
355
355
  it drew there (`examples/cms/src/apps/siteApp.ts`).
356
356
 
357
+ `navigated: (model, kind) => model` is told what kind each navigation is,
358
+ before its route is set: `'history'` when the browser's `popstate` brought it
359
+ (Back, Forward), `'push'` for a link or a Command that wrote the URL. An echo
360
+ is no navigation, and tells nothing. Remote uses it to show a list the reader
361
+ just left as it was on the way back, rather than refetching it:
362
+
363
+ ```ts
364
+ const Navigating = Site.routing<Model, Message, AppRoute, RemoteClient>({
365
+ // ...site, route, parse, tags and completed, as above
366
+ navigated: (model, kind) => Data.reduce(model, { _tag: 'Navigated', kind }),
367
+ })
368
+ ```
369
+
370
+ The kind is read from the event Foldkit reduces the URL change in, so a change
371
+ reduced later than that (Foldkit defers a burst past its frame budget) reads
372
+ as `'push'`, which only refetches what Back would have shown as it was.
373
+
357
374
  The wiring claims the click tag and shares the change tag with URL mirrors,
358
375
  which read their slices first. `CompletedNavigation` is one completion for
359
376
  the navigation commands — declare the variant, pass the constructor. Route
package/dist/index.d.mts CHANGED
@@ -300,6 +300,13 @@ export interface SiteTarget<Route extends {
300
300
  readonly route: Route;
301
301
  readonly url: string;
302
302
  }
303
+ /**
304
+ * The tag a tagged constructor names, read the way `Surface.when` reads it
305
+ * off a route case. Anything else is a definition-time error, not a silent
306
+ * mismatch.
307
+ */
308
+ /** What a navigation was: `history` for Back and Forward, `push` for a link or a Command. */
309
+ export type NavigationKind = 'history' | 'push';
303
310
  export declare const Site: {
304
311
  /**
305
312
  * One deployed location from its Foldkit Router and its route case:
@@ -636,6 +643,14 @@ export declare const Site: {
636
643
  * arrives nowhere, so it runs nothing.
637
644
  */
638
645
  readonly arrived?: ((model: Root, route: Route) => Update.Return<Root, Message, R>) | undefined;
646
+ /**
647
+ * Told what kind each navigation is, before its route is set: `history`
648
+ * for Back and Forward (`popstate`), `push` for a link or a Command that
649
+ * wrote the URL. Remote holds a list left for a history navigation back
650
+ * to it: `(model, kind) => Data.reduce(model, { _tag: 'Navigated', kind })`.
651
+ * An echo of the shown address is no navigation, and tells nothing.
652
+ */
653
+ readonly navigated?: ((model: Root, kind: NavigationKind) => Root) | undefined;
639
654
  /**
640
655
  * Reads a page ahead when the reader means to follow a link to it, so it
641
656
  * draws at once when they do. `links` says where they mean to go
@@ -685,7 +700,7 @@ export declare const Site: {
685
700
  }, Parent, LinkMessage extends AnyMessage, ChildModel, ChildMessage extends AnyMessage, Field extends string, Name extends string, Args, BundleR = never, BundleS = never, ViewInputs = void, Resources extends ResourceEntries<ChildModel, ChildMessage> = never, Helpers extends Readonly<Record<string, Helper<ChildModel, ChildMessage, never, BundleR>>> = never, ObserverR = never>(node: SiteNode<Route>, bundle: Bundle.Bundle<Name, Args, ChildModel, ChildMessage, never, BundleR, BundleS, ViewInputs, Resources, Helpers>, config: {
686
701
  readonly link: Link<Parent, LinkMessage, ChildModel, ChildMessage, Field>;
687
702
  readonly changed?: (route: Route) => ChildMessage | undefined;
688
- } & PlacementConfig<Args, Parent, LinkMessage, ChildMessage, never, never, ObserverR, SeedFor<Parent, Field>>) => SitePage<Parent, LinkMessage, BundleR | ObserverR, Placed<Name, Parent, LinkMessage, ChildModel, ChildMessage, BundleR | ObserverR, BundleS, ViewInputs, Resources, Helpers, Field, LinkMessage extends {
703
+ } & PlacementConfig<Args, Parent, LinkMessage, ChildMessage, never, never, ObserverR, SeedFor<Parent, Field>, ViewInputs>) => SitePage<Parent, LinkMessage, BundleR | ObserverR, Placed<Name, Parent, LinkMessage, ChildModel, ChildMessage, BundleR | ObserverR, BundleS, ViewInputs, Resources, Helpers, Field, LinkMessage extends {
689
704
  readonly _tag: infer Tag extends string;
690
705
  } ? Tag : string>>;
691
706
  };
@@ -1 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AAM,OAAO,UAAU,OAAO,OAAO,MAAM,SAAS;;;;;;;;;;;aAWvE;eAEM,OAAO,OAAO,OAAOA;eACrB,UAAU,OAAO,OAAO,aAC7B;iBAAmB,KAAKA;YAAe;eAClC,OAAO,OAAO,SAAS,QAAQ,QAAQ,gBAAgB;;QAGpE,OAAO,MAAM,SAAS;;aAEf,UAAU,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;EAkK9B,YACE;aAAyB;KACzB,QACA,oBAAoB,YACpB,YACA,qBAAqB,YACrB,sBACA,qBACA,MACA,iBACA,iBACA,mBACA,kBAAkB,gBAAgB,YAAY,uBAC9C,gBAAgB,SAAS,eAAe,OAAO,YAAY,qBAAqB,oBAEhF,mBAAiB,MAEX,SAAS,QAAM,QACb,OAAO,OACb,MACA,MACA,YACA,qBAEA,SACA,SACA,YACA,WACA,UACD;aAEU,MAAM,KAAK,QAAQ,aAAa,YAAY,cAAc;aAC1D,WAAW,OAAO,UAAU;MACnC,gBACF,MACA,QACA,aACA,4BAGA,WACA,QAAQ,QAAQ,YAEjB,SACD,QACA,aACA,UAAU,WACV,OACE,MACA,QACA,aACA,YACA,cACA,UAAU,WACV,SACA,YACA,WACA,SACA,OACA;aAA+B,YAAY;MAAuB"}
1
+ {"version":3,"file":"index.d.mts","names":["SurfaceType","UrlValue"],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;YAwDY;;;;;;;iBAQK,UAAU;WAAyB;WAAwB,OAAO,OAAO;GACvF,cAAc;;;;;;;;;iBAUA;WACN,SAASA;;WAET,WAAW,eAAe,OAAO;WACjC,SAAS,YAAY;;;;;;;;;iBAUf,YAAY,OAAO,OAAO,QAAQ,UAAU,SAAS;WAC3D,SAASA,QAAY,OAAO,QAAQ,UAAU;WAC9C,WAAW,OAAO,UAAU,OAAO,OAAO;WAC1C,SAAS,OAAO,OAAO,QAAQ,WAAW;;;;;;;;;;iBAWpC;WACN,SAAS,OAAO,MAAM,YAAY,WAAW;;;;;;;iBAQvC;WACN,SA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e,OAAO,YAAY,qBAAqB,oBAEhF,mBAAiB,MAEX,SAAS,QAAM,QACb,OAAO,OACb,MACA,MACA,YACA,qBAEA,SACA,SACA,YACA,WACA,UACD;aAEU,MAAM,KAAK,QAAQ,aAAa,YAAY,cAAc;aAC1D,WAAW,OAAO,UAAU;MACnC,gBACF,MACA,QACA,aACA,4BAGA,WACA,QAAQ,QAAQ,QAChB,gBAED,SACD,QACA,aACA,UAAU,WACV,OACE,MACA,QACA,aACA,YACA,cACA,UAAU,WACV,SACA,YACA,WACA,SACA,OACA;aAA+B,YAAY;MAAuB"}
package/dist/index.mjs CHANGED
@@ -43,10 +43,14 @@ const Access = defineTaggedUnion({
43
43
  Denied: { url: Schema.String }
44
44
  });
45
45
  /**
46
- * The tag a tagged constructor names, read the way `Surface.when` reads it
47
- * off a route case. Anything else is a definition-time error, not a silent
48
- * mismatch.
46
+ * The kind of the URL change being reduced. Foldkit reduces its Message on
47
+ * the stack of the event that caused it: the browser's `popstate` for Back
48
+ * and Forward, `foldkit:urlchange` for a URL a Command wrote. A change
49
+ * reduced off that stack (a drain deferred past Foldkit's budget) reads as
50
+ * `push`, which only refetches what a history navigation would have shown
51
+ * as it was.
49
52
  */
53
+ const navigationKind = () => typeof window !== "undefined" && window.event?.type === "popstate" ? "history" : "push";
50
54
  const tagOfConstructor = (constructor, what) => {
51
55
  const literal = constructor.fields?._tag?.ast?.literal;
52
56
  if (typeof literal !== "string") throw new Error(`${what} must be a tagged constructor`);
@@ -605,7 +609,7 @@ const Site = {
605
609
  messages: [config.completed],
606
610
  execute: ({ url, history }) => (history === "push" ? Navigation.pushUrl(url) : Navigation.replaceUrl(url)).pipe(Effect.as(config.completed()))
607
611
  });
608
- const { arrived, preload } = config;
612
+ const { arrived, navigated, preload } = config;
609
613
  const intendedTag = preload === void 0 ? void 0 : tagOfConstructor(preload.intended, "Site.routing: preload.intended must be a message constructor");
610
614
  const Load = Command.define("Site.Load", {
611
615
  args: { href: Schema.String },
@@ -681,6 +685,7 @@ const Site = {
681
685
  const next = config.parse(url);
682
686
  if (sameRoute(config.route.get(model), next)) return Option.some({ model });
683
687
  const steps = [
688
+ ...navigated === void 0 ? [] : [(model) => ({ model: navigated(model, navigationKind()) })],
684
689
  (model) => ({ model: setRoute(model, next) }),
685
690
  ...(config.pages ?? []).map((page) => (model) => Option.getOrElse(page.inform(model, next), () => ({ model }))),
686
691
  ...arrived === void 0 ? [] : [(model) => arrived(model, next)]
@@ -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, Stream } 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 { defineTaggedUnion } from 'foldkit/schema'\nimport type { Html, HtmlBuilder } from 'foldkit/html'\nimport * as Navigation from 'foldkit/navigation'\nimport * as Subscription from 'foldkit/subscription'\nimport type { KeyBinding, KeySequence } from 'foldkit/dom'\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 ModelRef,\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 /** Who is signed in, read from the Model; the Surface waits for one when given. */\n readonly viewer?: ((model: any) => Option.Option<any>) | undefined\n readonly params: (route: any, viewer: any) => any\n}\n\n/**\n * The Surface a node activates, as `Site.route` and `.surface` take it.\n * `params` reads the node's route; with `viewer`, it reads the signed-in\n * viewer too, and the Surface is active only once `viewer` gives one.\n * Without `viewer`, `Viewer` is `void`, so a `params` reading a viewer it was\n * never given does not compile.\n */\nexport interface NodeSurface<Route, SRoot, SModel, SMessage, SParams, Viewer> {\n readonly surface: SurfaceType<SRoot, SModel, SMessage, SParams>\n readonly viewer?: ((model: SRoot) => Option.Option<Viewer>) | undefined\n readonly params: (route: Route, viewer: Viewer) => SParams\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: ModelRef.focus(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 * Who may be shown this node and the nodes below it: see `Site.accessOf`.\n * Held as `never` for its reader, so a rule given in the options must\n * name the reader it reads (`allow: (me: Me) => …`).\n */\n readonly access?: NodeAccess<never> | undefined\n}\n\n/**\n * Who may be shown a node, and where anyone else is sent. Presentation, not\n * authorization: the server guards what the page reads whatever this says.\n * `Who` is what the application knows of the reader (its `Me` row, say).\n */\nexport interface NodeAccess<Who> {\n readonly allow: (who: Who) => boolean\n /** Where a reader `allow` refuses goes, given the address they asked for (a sign-in page returning to it). */\n readonly otherwise: (requested: string) => SiteTarget<any>\n}\n\n/**\n * Whether the reader may be shown a route: `Allowed`; `Pending` while the\n * application does not know who they are yet, to draw a loading state rather\n * than flash the sign-in page at someone signed in; `Denied` with the address\n * to send them to.\n */\nexport const Access = defineTaggedUnion({\n Allowed: {},\n Pending: {},\n Denied: { url: Schema.String },\n})\nexport type Access = typeof Access.Type\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 /** Who may be shown this node and the nodes below it, and where anyone else goes. */\n access<Who>(access: NodeAccess<Who>): NodeBuilder<Route>\n /** The Surface this route activates, and the viewer its params read, if any. */\n surface<SRoot, SModel, SMessage, SParams, Viewer = void>(\n config: NodeSurface<Route, SRoot, SModel, SMessage, SParams, Viewer>,\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/**\n * One surfaced node's `Surface.when` over the route place, or nothing\n * surfaceless. A node reading the viewer is active on its route only while\n * the viewer is known, and keeps the route's tag as its activation.\n */\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 const { surface, viewer, params } = bound\n if (surface.owner !== owner)\n throw new Error(`Site: \"${surface.name}\" belongs to another application than the site`)\n if (viewer === undefined)\n return [node.tag, Surface.when(surface, place, node.case, route => params(route, undefined))]\n const focus = ModelRef.focus(place)\n const gated = Surface.at(surface, (model: Root) => {\n const route = focus.get(model)\n return Predicate.isTagged(route, node.tag)\n ? Option.map(viewer(model), who => params(route, who))\n : Option.none()\n })\n return [node.tag, { ...gated, activation: { path: focus.dependency, tag: node.tag } }]\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, Viewer = void>(\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 access?: NodeAccess<never> | undefined\n readonly surface?: NodeSurface<Route, SRoot, SModel, SMessage, SParams, Viewer> | 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?.access !== undefined) built = built.access(options.access)\n if (options?.surface !== undefined)\n built = built.surface<SRoot, SModel, SMessage, SParams, Viewer>(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 access: access => at(Object.freeze({ ...built, access })),\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 * Whether the reader may be shown a route: every `access` up its chain,\n * root first, must allow `who`, and the first that refuses sends them to\n * its `otherwise`, given the route's address. `who` is `Option.none()`\n * while the application does not know yet (its `Me` loading): `Pending`\n * wherever a rule would need it. A route no rule covers is `Allowed`.\n *\n * ```ts\n * Access.match(Site.accessOf(AppSite, model.route, me), {\n * Allowed: () => page,\n * Pending: () => loading,\n * Denied: ({ url }) => redirecting, // and `update` replaces the URL with `url`\n * })\n * ```\n *\n * A server answers `Denied` with a 303 to `url` before rendering. It is\n * presentation: what the page reads is guarded on the server regardless.\n */\n accessOf: <Route extends { readonly _tag: string }, Who>(\n site: SiteTree<Route>,\n route: Route,\n who: Option.Option<Who>,\n ): Access => {\n for (const node of Site.chainOf(site, route)) {\n const { access } = node\n if (access === undefined) continue\n if (Option.isNone(who)) return Access.Pending()\n // The tree holds its rules' readers as `never`: `who` is the reader they read.\n if ((access as NodeAccess<Who>).allow(who.value)) continue\n const target = access.otherwise(Site.hrefOf(site, route))\n // A target this same rule covers refuses the reader again, for ever.\n if (Site.chainOf(site, target.route).includes(node))\n throw new Error(\n `foldkit-site: ${node.tag}'s access sends a refused reader to ${target.url}, which it also covers`,\n )\n return Access.Denied({ url: target.url })\n }\n return Access.Allowed()\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 * Dom.streamFromKeyBindings({\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: ModelRef.focus(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 /**\n * Reads a page ahead when the reader means to follow a link to it, so it\n * draws at once when they do. `links` says where they mean to go\n * (`pointedLinks()` from `foldkit-primitives/dom`), `intended` is the\n * application's Message carrying it, which the routing claims, and `read`\n * reads what the Model would read there, the route already set:\n * `there => Data.preload(there, actives)`. An address no node holds, or\n * the route shown, reads nothing, and the Model is never changed: what\n * was read lands as `read`'s own Messages.\n */\n readonly preload?:\n | {\n readonly links: Stream.Stream<UrlValue>\n readonly intended: Schema.Schema<Message> &\n ((fields: { readonly url: UrlValue }) => Message)\n readonly read: (there: Root) => Command.Command<Message, never, R>\n }\n | undefined\n }): Wiring<Root, Message, R> & {\n /** Whether the routing owns a message: its click, its URL change, or its preload intent. */\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, preload } = config\n const intendedTag =\n preload === undefined\n ? undefined\n : tagOfConstructor(\n preload.intended,\n 'Site.routing: preload.intended must be a message constructor',\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 handles = [\n config.tags.clicked,\n config.tags.changed,\n ...(intendedTag === undefined ? [] : [intendedTag]),\n ]\n const reduces = (message: Message): boolean =>\n // tag-check: open — the tags are the application's own variants, named in config\n handles.includes(message._tag)\n const wiring: Wiring<Root, Message, R> = {\n key: 'site',\n handles,\n shared: [config.tags.changed],\n ...(preload === undefined\n ? {}\n : {\n subscriptions: Subscription.make<Root, Message, R>()(() => ({\n 'site.intent': Subscription.persistentEntry(\n Stream.map(preload.links, url => preload.intended({ url })),\n ),\n })),\n }),\n route: (model, message) => {\n // tag-check: open — same ownership as reduces\n if (preload !== undefined && message._tag === intendedTag) {\n const url = (message as unknown as { readonly url: UrlValue }).url\n return Option.some(\n Option.match(Site.routeAt(config.site, url), {\n // Another document's page, which this application cannot read ahead.\n onNone: () => ({ model }),\n onSome: next =>\n sameRoute(config.route.get(model), next)\n ? { model }\n : { model, commands: [preload.read(config.route.set(model, next))] },\n }),\n )\n }\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, ...(intendedTag === undefined ? [] : [intendedTag])],\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8OA,MAAa,SAAS,kBAAkB;CACtC,SAAS,CAAC;CACV,SAAS,CAAC;CACV,QAAQ,EAAE,KAAK,OAAO,OAAO;AAC/B,CAAC;;;;;;AA4HD,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,MA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AAG,KACtB,UAAS,UACP,OAAO,UAAU,KAAK,OAAO,OAAO,IAAI,UAAU,EAAE,MAAM,EAAE,CAChE;MACA,GAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,UAAgB,QAAQ,OAAO,IAAI,CAAC;KACzE;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,cAAc,GAAI,gBAAgB,KAAA,IAAY,CAAC,IAAI,CAAC,WAAW,CAAE;IAC5E,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, Stream } 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 { defineTaggedUnion } from 'foldkit/schema'\nimport type { Html, HtmlBuilder } from 'foldkit/html'\nimport * as Navigation from 'foldkit/navigation'\nimport * as Subscription from 'foldkit/subscription'\nimport type { KeyBinding, KeySequence } from 'foldkit/dom'\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 ModelRef,\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 /** Who is signed in, read from the Model; the Surface waits for one when given. */\n readonly viewer?: ((model: any) => Option.Option<any>) | undefined\n readonly params: (route: any, viewer: any) => any\n}\n\n/**\n * The Surface a node activates, as `Site.route` and `.surface` take it.\n * `params` reads the node's route; with `viewer`, it reads the signed-in\n * viewer too, and the Surface is active only once `viewer` gives one.\n * Without `viewer`, `Viewer` is `void`, so a `params` reading a viewer it was\n * never given does not compile.\n */\nexport interface NodeSurface<Route, SRoot, SModel, SMessage, SParams, Viewer> {\n readonly surface: SurfaceType<SRoot, SModel, SMessage, SParams>\n readonly viewer?: ((model: SRoot) => Option.Option<Viewer>) | undefined\n readonly params: (route: Route, viewer: Viewer) => SParams\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: ModelRef.focus(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 * Who may be shown this node and the nodes below it: see `Site.accessOf`.\n * Held as `never` for its reader, so a rule given in the options must\n * name the reader it reads (`allow: (me: Me) => …`).\n */\n readonly access?: NodeAccess<never> | undefined\n}\n\n/**\n * Who may be shown a node, and where anyone else is sent. Presentation, not\n * authorization: the server guards what the page reads whatever this says.\n * `Who` is what the application knows of the reader (its `Me` row, say).\n */\nexport interface NodeAccess<Who> {\n readonly allow: (who: Who) => boolean\n /** Where a reader `allow` refuses goes, given the address they asked for (a sign-in page returning to it). */\n readonly otherwise: (requested: string) => SiteTarget<any>\n}\n\n/**\n * Whether the reader may be shown a route: `Allowed`; `Pending` while the\n * application does not know who they are yet, to draw a loading state rather\n * than flash the sign-in page at someone signed in; `Denied` with the address\n * to send them to.\n */\nexport const Access = defineTaggedUnion({\n Allowed: {},\n Pending: {},\n Denied: { url: Schema.String },\n})\nexport type Access = typeof Access.Type\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 /** Who may be shown this node and the nodes below it, and where anyone else goes. */\n access<Who>(access: NodeAccess<Who>): NodeBuilder<Route>\n /** The Surface this route activates, and the viewer its params read, if any. */\n surface<SRoot, SModel, SMessage, SParams, Viewer = void>(\n config: NodeSurface<Route, SRoot, SModel, SMessage, SParams, Viewer>,\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 */\n/** What a navigation was: `history` for Back and Forward, `push` for a link or a Command. */\nexport type NavigationKind = 'history' | 'push'\n\n/**\n * The kind of the URL change being reduced. Foldkit reduces its Message on\n * the stack of the event that caused it: the browser's `popstate` for Back\n * and Forward, `foldkit:urlchange` for a URL a Command wrote. A change\n * reduced off that stack (a drain deferred past Foldkit's budget) reads as\n * `push`, which only refetches what a history navigation would have shown\n * as it was.\n */\nconst navigationKind = (): NavigationKind =>\n typeof window !== 'undefined' && window.event?.type === 'popstate' ? 'history' : 'push'\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/**\n * One surfaced node's `Surface.when` over the route place, or nothing\n * surfaceless. A node reading the viewer is active on its route only while\n * the viewer is known, and keeps the route's tag as its activation.\n */\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 const { surface, viewer, params } = bound\n if (surface.owner !== owner)\n throw new Error(`Site: \"${surface.name}\" belongs to another application than the site`)\n if (viewer === undefined)\n return [node.tag, Surface.when(surface, place, node.case, route => params(route, undefined))]\n const focus = ModelRef.focus(place)\n const gated = Surface.at(surface, (model: Root) => {\n const route = focus.get(model)\n return Predicate.isTagged(route, node.tag)\n ? Option.map(viewer(model), who => params(route, who))\n : Option.none()\n })\n return [node.tag, { ...gated, activation: { path: focus.dependency, tag: node.tag } }]\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, Viewer = void>(\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 access?: NodeAccess<never> | undefined\n readonly surface?: NodeSurface<Route, SRoot, SModel, SMessage, SParams, Viewer> | 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?.access !== undefined) built = built.access(options.access)\n if (options?.surface !== undefined)\n built = built.surface<SRoot, SModel, SMessage, SParams, Viewer>(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 access: access => at(Object.freeze({ ...built, access })),\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 * Whether the reader may be shown a route: every `access` up its chain,\n * root first, must allow `who`, and the first that refuses sends them to\n * its `otherwise`, given the route's address. `who` is `Option.none()`\n * while the application does not know yet (its `Me` loading): `Pending`\n * wherever a rule would need it. A route no rule covers is `Allowed`.\n *\n * ```ts\n * Access.match(Site.accessOf(AppSite, model.route, me), {\n * Allowed: () => page,\n * Pending: () => loading,\n * Denied: ({ url }) => redirecting, // and `update` replaces the URL with `url`\n * })\n * ```\n *\n * A server answers `Denied` with a 303 to `url` before rendering. It is\n * presentation: what the page reads is guarded on the server regardless.\n */\n accessOf: <Route extends { readonly _tag: string }, Who>(\n site: SiteTree<Route>,\n route: Route,\n who: Option.Option<Who>,\n ): Access => {\n for (const node of Site.chainOf(site, route)) {\n const { access } = node\n if (access === undefined) continue\n if (Option.isNone(who)) return Access.Pending()\n // The tree holds its rules' readers as `never`: `who` is the reader they read.\n if ((access as NodeAccess<Who>).allow(who.value)) continue\n const target = access.otherwise(Site.hrefOf(site, route))\n // A target this same rule covers refuses the reader again, for ever.\n if (Site.chainOf(site, target.route).includes(node))\n throw new Error(\n `foldkit-site: ${node.tag}'s access sends a refused reader to ${target.url}, which it also covers`,\n )\n return Access.Denied({ url: target.url })\n }\n return Access.Allowed()\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 * Dom.streamFromKeyBindings({\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: ModelRef.focus(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 /**\n * Told what kind each navigation is, before its route is set: `history`\n * for Back and Forward (`popstate`), `push` for a link or a Command that\n * wrote the URL. Remote holds a list left for a history navigation back\n * to it: `(model, kind) => Data.reduce(model, { _tag: 'Navigated', kind })`.\n * An echo of the shown address is no navigation, and tells nothing.\n */\n readonly navigated?: ((model: Root, kind: NavigationKind) => Root) | undefined\n /**\n * Reads a page ahead when the reader means to follow a link to it, so it\n * draws at once when they do. `links` says where they mean to go\n * (`pointedLinks()` from `foldkit-primitives/dom`), `intended` is the\n * application's Message carrying it, which the routing claims, and `read`\n * reads what the Model would read there, the route already set:\n * `there => Data.preload(there, actives)`. An address no node holds, or\n * the route shown, reads nothing, and the Model is never changed: what\n * was read lands as `read`'s own Messages.\n */\n readonly preload?:\n | {\n readonly links: Stream.Stream<UrlValue>\n readonly intended: Schema.Schema<Message> &\n ((fields: { readonly url: UrlValue }) => Message)\n readonly read: (there: Root) => Command.Command<Message, never, R>\n }\n | undefined\n }): Wiring<Root, Message, R> & {\n /** Whether the routing owns a message: its click, its URL change, or its preload intent. */\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, navigated, preload } = config\n const intendedTag =\n preload === undefined\n ? undefined\n : tagOfConstructor(\n preload.intended,\n 'Site.routing: preload.intended must be a message constructor',\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 handles = [\n config.tags.clicked,\n config.tags.changed,\n ...(intendedTag === undefined ? [] : [intendedTag]),\n ]\n const reduces = (message: Message): boolean =>\n // tag-check: open — the tags are the application's own variants, named in config\n handles.includes(message._tag)\n const wiring: Wiring<Root, Message, R> = {\n key: 'site',\n handles,\n shared: [config.tags.changed],\n ...(preload === undefined\n ? {}\n : {\n subscriptions: Subscription.make<Root, Message, R>()(() => ({\n 'site.intent': Subscription.persistentEntry(\n Stream.map(preload.links, url => preload.intended({ url })),\n ),\n })),\n }),\n route: (model, message) => {\n // tag-check: open — same ownership as reduces\n if (preload !== undefined && message._tag === intendedTag) {\n const url = (message as unknown as { readonly url: UrlValue }).url\n return Option.some(\n Option.match(Site.routeAt(config.site, url), {\n // Another document's page, which this application cannot read ahead.\n onNone: () => ({ model }),\n onSome: next =>\n sameRoute(config.route.get(model), next)\n ? { model }\n : { model, commands: [preload.read(config.route.set(model, next))] },\n }),\n )\n }\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 ...(navigated === undefined\n ? []\n : [(model: Root) => ({ model: navigated(model, navigationKind()) })]),\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, ...(intendedTag === undefined ? [] : [intendedTag])],\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 ViewInputs\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8OA,MAAa,SAAS,kBAAkB;CACtC,SAAS,CAAC;CACV,SAAS,CAAC;CACV,QAAQ,EAAE,KAAK,OAAO,OAAO;AAC/B,CAAC;;;;;;;;;AAuID,MAAM,uBACJ,OAAO,WAAW,eAAe,OAAO,OAAO,SAAS,aAAa,YAAY;AAEnF,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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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldkit-site",
3
- "version": "0.5.0",
3
+ "version": "0.7.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",
@@ -38,28 +38,28 @@
38
38
  "LICENSE"
39
39
  ],
40
40
  "dependencies": {
41
- "foldkit-bundle": "0.9.0",
42
- "foldkit-surface": "0.11.0",
43
- "foldkit-ssr": "0.9.0"
41
+ "foldkit-bundle": "0.11.0",
42
+ "foldkit-ssr": "0.11.0",
43
+ "foldkit-surface": "0.13.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "effect": "^4.1.0",
47
47
  "foldkit": "^0.170.0"
48
48
  },
49
49
  "devDependencies": {
50
- "effect": "^4.1.0",
50
+ "effect": "^4.1.1",
51
51
  "foldkit": "0.170.0",
52
52
  "tsdown": "^0.23.1",
53
53
  "typescript": "7.0.2",
54
- "foldkit-bundle": "0.9.0",
55
- "foldkit-primitives": "0.16.0",
56
- "foldkit-entity": "0.14.0",
57
- "foldkit-remote": "0.22.0",
58
- "foldkit-ssr": "0.9.0",
59
- "foldkit-surface": "0.11.0"
54
+ "foldkit-entity": "0.16.0",
55
+ "foldkit-bundle": "0.11.0",
56
+ "foldkit-ssr": "0.11.0",
57
+ "foldkit-primitives": "0.18.0",
58
+ "foldkit-surface": "0.13.0",
59
+ "foldkit-remote": "0.24.0"
60
60
  },
61
61
  "scripts": {
62
- "build": "tsdown",
62
+ "build": "node ../../scripts/declarations.mjs . && tsdown && node ../../scripts/declared-any.mjs .",
63
63
  "typecheck": "tsc -b"
64
64
  }
65
65
  }