@warlock.js/web 5.1.0 → 5.2.1

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.
Files changed (148) hide show
  1. package/CHANGELOG.md +182 -0
  2. package/README.md +126 -12
  3. package/esm/build/contribution.d.mts +10 -13
  4. package/esm/build/contribution.mjs +45 -57
  5. package/esm/build/contribution.mjs.map +1 -1
  6. package/esm/build/discover-pages.mjs +104 -44
  7. package/esm/build/discover-pages.mjs.map +1 -1
  8. package/esm/build/generate-client-registry.mjs +46 -12
  9. package/esm/build/generate-client-registry.mjs.map +1 -1
  10. package/esm/build/generate-pages-barrel.mjs +54 -12
  11. package/esm/build/generate-pages-barrel.mjs.map +1 -1
  12. package/esm/build/page-default-export.mjs +48 -0
  13. package/esm/build/page-default-export.mjs.map +1 -0
  14. package/esm/build/page-routes-manifest.mjs +21 -0
  15. package/esm/build/page-routes-manifest.mjs.map +1 -0
  16. package/esm/build/public-files.mjs +45 -0
  17. package/esm/build/public-files.mjs.map +1 -0
  18. package/esm/build/read-route-exports.mjs.map +1 -1
  19. package/esm/client/build-hydrated-tree.mjs +39 -8
  20. package/esm/client/build-hydrated-tree.mjs.map +1 -1
  21. package/esm/client/navigation/fetch-page-data.mjs.map +1 -1
  22. package/esm/client/navigation/prefetch.mjs.map +1 -1
  23. package/esm/client/runtime/index.d.mts +2 -1
  24. package/esm/client/runtime/index.mjs +2 -1
  25. package/esm/client/runtime/manifest.mjs +2 -1
  26. package/esm/client/runtime/manifest.mjs.map +1 -1
  27. package/esm/client/runtime/matcher.d.mts +12 -0
  28. package/esm/client/runtime/matcher.mjs +12 -0
  29. package/esm/client/runtime/matcher.mjs.map +1 -1
  30. package/esm/client/runtime/types.d.mts +14 -1
  31. package/esm/components/document-context.d.mts +39 -1
  32. package/esm/components/document-context.mjs.map +1 -1
  33. package/esm/components/link.mjs.map +1 -1
  34. package/esm/components/scripts.mjs +3 -1
  35. package/esm/components/scripts.mjs.map +1 -1
  36. package/esm/context.d.mts +5 -101
  37. package/esm/hydration-payload.d.mts +1 -1
  38. package/esm/hydration-payload.mjs +36 -7
  39. package/esm/hydration-payload.mjs.map +1 -1
  40. package/esm/index.d.mts +3 -2
  41. package/esm/loaders.d.mts +6 -35
  42. package/esm/props.d.mts +15 -7
  43. package/esm/route.d.mts +1 -16
  44. package/esm/routing/filesystem-route.mjs +45 -0
  45. package/esm/routing/filesystem-route.mjs.map +1 -0
  46. package/esm/routing/layout-policy.mjs.map +1 -1
  47. package/esm/routing/query-string.mjs.map +1 -1
  48. package/esm/routing/route-table.mjs.map +1 -1
  49. package/esm/runtime/register-modules.d.mts +19 -0
  50. package/esm/runtime/register-modules.mjs +22 -0
  51. package/esm/runtime/register-modules.mjs.map +1 -0
  52. package/esm/server/build-hydration-payload.mjs +1 -0
  53. package/esm/server/build-hydration-payload.mjs.map +1 -1
  54. package/esm/server/create-page-module-loader.mjs +1 -0
  55. package/esm/server/create-page-module-loader.mjs.map +1 -1
  56. package/esm/server/create-page-route-handler.d.mts +30 -5
  57. package/esm/server/create-page-route-handler.mjs +127 -42
  58. package/esm/server/create-page-route-handler.mjs.map +1 -1
  59. package/esm/server/dev-server.mjs +1 -12
  60. package/esm/server/dev-server.mjs.map +1 -1
  61. package/esm/server/error-page.d.mts +14 -0
  62. package/esm/server/error-page.mjs +39 -0
  63. package/esm/server/error-page.mjs.map +1 -0
  64. package/esm/server/execute-page-request.d.mts +6 -3
  65. package/esm/server/execute-page-request.mjs +78 -79
  66. package/esm/server/execute-page-request.mjs.map +1 -1
  67. package/esm/server/execute-page-request.types.d.mts +32 -91
  68. package/esm/server/hydration-client-url.mjs +1 -1
  69. package/esm/server/index.d.mts +5 -5
  70. package/esm/server/index.mjs +3 -4
  71. package/esm/server/install-page-routes-from-manifest.d.mts +16 -6
  72. package/esm/server/install-page-routes-from-manifest.mjs +70 -9
  73. package/esm/server/install-page-routes-from-manifest.mjs.map +1 -1
  74. package/esm/server/install-page-routes.d.mts +31 -14
  75. package/esm/server/install-page-routes.mjs +90 -38
  76. package/esm/server/install-page-routes.mjs.map +1 -1
  77. package/esm/server/install-production-page-routes.mjs +2 -35
  78. package/esm/server/install-production-page-routes.mjs.map +1 -1
  79. package/esm/server/match-page-route.mjs +1 -1
  80. package/esm/server/match-page-route.mjs.map +1 -1
  81. package/esm/server/not-found-page.mjs +1 -1
  82. package/esm/server/not-found-page.mjs.map +1 -1
  83. package/esm/server/page-context.d.mts +2 -8
  84. package/esm/server/page-context.mjs +2 -15
  85. package/esm/server/page-context.mjs.map +1 -1
  86. package/esm/server/page-file-change.mjs +77 -0
  87. package/esm/server/page-file-change.mjs.map +1 -0
  88. package/esm/server/page-manifest.d.mts +24 -9
  89. package/esm/server/page-manifest.mjs.map +1 -1
  90. package/esm/server/page-render-bundle.mjs +38 -0
  91. package/esm/server/page-render-bundle.mjs.map +1 -0
  92. package/esm/server/page-route-reload.mjs +54 -0
  93. package/esm/server/page-route-reload.mjs.map +1 -0
  94. package/esm/server/register-production-public-files.mjs +40 -0
  95. package/esm/server/register-production-public-files.mjs.map +1 -0
  96. package/esm/server/render-page.d.mts +10 -13
  97. package/esm/server/render-page.mjs +153 -27
  98. package/esm/server/render-page.mjs.map +1 -1
  99. package/esm/server/resolve-page-metadata.mjs +1 -1
  100. package/esm/server/resolve-page-metadata.mjs.map +1 -1
  101. package/esm/server/settle-page-response.d.mts +58 -1
  102. package/esm/server/settle-page-response.mjs +110 -45
  103. package/esm/server/settle-page-response.mjs.map +1 -1
  104. package/esm/server/stylesheet-urls.d.mts +40 -29
  105. package/esm/server/stylesheet-urls.mjs +136 -51
  106. package/esm/server/stylesheet-urls.mjs.map +1 -1
  107. package/esm/server/unregistered-pages.mjs +42 -0
  108. package/esm/server/unregistered-pages.mjs.map +1 -0
  109. package/esm/server/web-connector-factory.d.mts +1 -2
  110. package/esm/server/web-connector-factory.mjs +6 -5
  111. package/esm/server/web-connector-factory.mjs.map +1 -1
  112. package/esm/server/web-connector.mjs +137 -17
  113. package/esm/server/web-connector.mjs.map +1 -1
  114. package/esm/shared.d.mts +17 -2
  115. package/esm/shared.mjs +2 -6
  116. package/esm/shared.mjs.map +1 -1
  117. package/esm/vite/build-client.mjs +1 -1
  118. package/esm/vite/build-client.mjs.map +1 -1
  119. package/esm/vite/gate-a-resolve.mjs +66 -12
  120. package/esm/vite/gate-a-resolve.mjs.map +1 -1
  121. package/esm/vite/gate-b-secrets.mjs +34 -16
  122. package/esm/vite/gate-b-secrets.mjs.map +1 -1
  123. package/esm/vite/gate-c-verify.mjs +5 -5
  124. package/esm/vite/gate-c-verify.mjs.map +1 -1
  125. package/esm/vite/hydration-entries.mjs +1 -1
  126. package/esm/vite/hydration-entries.mjs.map +1 -1
  127. package/esm/vite/index.d.mts +8 -5
  128. package/esm/vite/index.mjs +123 -10
  129. package/esm/vite/index.mjs.map +1 -1
  130. package/esm/vite/page-registry-plugin.d.mts +21 -2
  131. package/esm/vite/page-registry-plugin.mjs +47 -13
  132. package/esm/vite/page-registry-plugin.mjs.map +1 -1
  133. package/esm/vite/projection.d.mts +1 -1
  134. package/esm/vite/projection.mjs +37 -14
  135. package/esm/vite/projection.mjs.map +1 -1
  136. package/llms-full.txt +220 -56
  137. package/llms.txt +5 -3
  138. package/package.json +3 -3
  139. package/skills/add-web-to-an-app/SKILL.md +3 -3
  140. package/skills/create-a-page/SKILL.md +117 -10
  141. package/skills/load-page-data/SKILL.md +92 -12
  142. package/skills/navigate-on-the-client/SKILL.md +1 -1
  143. package/skills/serve-styles/SKILL.md +13 -12
  144. package/skills/use-layouts/SKILL.md +14 -8
  145. package/skills/write-the-root/SKILL.md +3 -1
  146. package/esm/server/buffered-response.d.mts +0 -58
  147. package/esm/server/buffered-response.mjs +0 -115
  148. package/esm/server/buffered-response.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"route-table.mjs","names":[],"sources":["../../../../../../../web/src/routing/route-table.ts"],"sourcesContent":["/**\n * The name→URL primitive, and the one route table both sides read.\n *\n * `href(name, params, query)` is the DURABLE primitive; `<Link>` is sugar over\n * it. That ordering is deliberate and ratified: a function serves emails,\n * redirects, `Location` headers and non-React callers, none of which can render\n * a component — and it keeps client-side navigation, when it lands, a behaviour\n * change rather than an API change.\n *\n * ── Why a process-global table is correct HERE ───────────────────────────────\n * Module-level mutable state is normally a defect in a server that handles\n * concurrent requests, and this codebase has a real example of that defect to\n * point at: `@mongez/react-router`'s `RouterWrapper` keeps the RENDERED PAGE\n * CONTENT in a module-level binding, so request B overwrites the tree request A\n * is about to serialize. That is why it is not on the SSR path.\n *\n * A route table is the opposite kind of value. It is derived from the file\n * system at boot, identical for every request in the process, and never written\n * during a request — the same category as the compiled route table the server's\n * own router holds. Nothing here is per-request, so there is nothing for two\n * requests to race over.\n *\n * The rule that keeps it that way: `publishRouteTable` is called at INSTALL\n * time (server) or at hydration entry (browser), and never from a loader, a\n * middleware, or a component.\n */\n\nimport { queryStringOf, type QueryStringInput } from \"./query-string\";\n\n/** The two fields `href` needs. Callers may pass richer entries; the rest is ignored. */\nexport type RouteTableEntry = {\n readonly name: string;\n readonly path: string;\n};\n\n/** What `href` accepts for a `:param` segment. Rendered with `String(value)`. */\nexport type RouteParameters = Readonly<Record<string, unknown>>;\n\n/**\n * Query values; an `undefined` value is omitted rather than serialized.\n *\n * A value may be a scalar, an array of scalars, or an object one level deep —\n * the shapes `@warlock.js/core` parses back out of the URL. Anything deeper\n * throws `UnserializableQueryValueError`; the grammar and the measurements\n * behind it are documented in query-string.ts.\n */\nexport type RouteQuery = QueryStringInput;\n\nconst PARAMETER_PATTERN = /:([A-Za-z0-9_]+)|\\*/g;\n\n/**\n * ── WHY THIS LIVES ON `globalThis` AND NOT IN A MODULE BINDING ───────────────\n *\n * A plain `let` here does not work in development, and the failure is silent\n * enough to be worth spelling out.\n *\n * In dev the process runs TWO module graphs over the same files. Route\n * installation is loaded by tsx/Node (it is CLI bootstrap and imports core\n * directly), while page and layout modules are evaluated by Vite's SSR module\n * runner — which keeps its own registry and its own instance of every module it\n * transforms, `@warlock.js/web` included. So a module-level binding written by\n * the installer is not the binding `<Link>` reads during render: the installer\n * publishes into one instance and the component finds the other one empty.\n *\n * That was measured, not theorised. With a module-level `let`, every anchor on\n * a server-rendered page threw `RouteTableNotPublishedError` with an empty\n * known-names list while installation had demonstrably run.\n *\n * `Symbol.for` resolves through the per-ISOLATE symbol registry, which both\n * graphs share because they are the same isolate. So the table is one value no\n * matter which graph reaches it first, and the module keeps its module-shaped\n * API. `publishedBy` is carried for diagnosis only.\n */\nconst ROUTE_TABLE_SLOT = Symbol.for(\"warlock.web.routeTable\");\n\ntype RouteTableSlot = {\n table: Map<string, string>;\n publishedBy: string;\n};\n\ntype RouteTableHost = typeof globalThis & {\n [ROUTE_TABLE_SLOT]?: RouteTableSlot;\n};\n\n/**\n * `undefined` means \"nobody has published yet\", which is a DIFFERENT fault from\n * \"the table is published and this name is not in it\" — an empty Map would\n * conflate them and send the reader hunting a route that was never missing.\n */\nfunction readSlot(): RouteTableSlot | undefined {\n return (globalThis as RouteTableHost)[ROUTE_TABLE_SLOT];\n}\n\nexport class RouteTableNotPublishedError extends Error {\n public constructor(public readonly routeName: string) {\n super(\n `Warlock href(${JSON.stringify(routeName)}) was called before the route table was ` +\n \"published, so no route name resolves yet. The table is published once at boot — by \" +\n \"the server when it installs page routes, and by the hydration entry before it mounts. \" +\n \"Seeing this means href() ran outside both: typically a module evaluating at import \" +\n \"time, or a unit test that renders a component without publishing a table first.\",\n );\n this.name = \"RouteTableNotPublishedError\";\n }\n}\n\nexport class UnknownRouteNameError extends Error {\n public constructor(\n public readonly routeName: string,\n public readonly knownRouteNames: readonly string[],\n ) {\n super(\n `Warlock href(${JSON.stringify(routeName)}) does not name a known route. ` +\n (knownRouteNames.length === 0\n ? \"The route table is published but empty, so no page declared a `route` discovery could see.\"\n : `The table knows: ${knownRouteNames.map(name => JSON.stringify(name)).join(\", \")}.`),\n );\n this.name = \"UnknownRouteNameError\";\n }\n}\n\nexport class MissingRouteParameterError extends Error {\n public constructor(\n public readonly routeName: string,\n public readonly parameterName: string,\n public readonly routePath: string,\n ) {\n super(\n `Warlock href(${JSON.stringify(routeName)}) is missing the parameter ` +\n `${JSON.stringify(parameterName)}, required by the route path \"${routePath}\". ` +\n \"It is not defaulted: a missing parameter would otherwise be interpolated as the \" +\n \"literal text `undefined`, producing a link that renders correctly and 404s for a \" +\n \"visitor.\",\n );\n this.name = \"MissingRouteParameterError\";\n }\n}\n\nexport class UnknownRouteParameterError extends Error {\n public constructor(\n public readonly routeName: string,\n public readonly parameterNames: readonly string[],\n public readonly routePath: string,\n ) {\n super(\n `Warlock href(${JSON.stringify(routeName)}) was given ` +\n `${parameterNames.map(name => JSON.stringify(name)).join(\", \")}, which the route path ` +\n `\"${routePath}\" does not declare. Passing an undeclared parameter is a typo often ` +\n \"enough that it is refused rather than dropped; values meant for the query string go \" +\n \"in the third argument.\",\n );\n this.name = \"UnknownRouteParameterError\";\n }\n}\n\nexport class DuplicateRouteNameError extends Error {\n public constructor(\n public readonly routeName: string,\n public readonly paths: readonly [string, string],\n ) {\n super(\n `Warlock route table: two routes both claim the name ${JSON.stringify(routeName)} — ` +\n `\"${paths[0]}\" and \"${paths[1]}\". A name resolves to exactly one URL, so one of the ` +\n \"two would silently win and every link to it would be wrong half the time.\",\n );\n this.name = \"DuplicateRouteNameError\";\n }\n}\n\n/**\n * Publish the table. WHOLESALE — the previous one is discarded, not merged\n * into.\n *\n * Merging looks harmless until a page is deleted and the dev server restarts:\n * the dead name would stay resolvable, and `<Link>` would go on rendering a URL\n * the server no longer routes. The table has to be able to shrink.\n */\nexport function publishRouteTable(\n entries: readonly RouteTableEntry[],\n publishedBy = \"unnamed\",\n): void {\n const table = new Map<string, string>();\n\n for (const entry of entries) {\n const existing = table.get(entry.name);\n\n if (existing !== undefined) {\n throw new DuplicateRouteNameError(entry.name, [existing, entry.path]);\n }\n\n table.set(entry.name, entry.path);\n }\n\n (globalThis as RouteTableHost)[ROUTE_TABLE_SLOT] = { table, publishedBy };\n}\n\n/**\n * Drop the table, returning the module to its pre-boot state.\n *\n * Exists for tests: the table is process-global, so a suite that published one\n * would otherwise leak it into every later test in the same worker and pass in\n * file order while failing under `--shuffle`.\n */\nexport function resetRouteTable(): void {\n delete (globalThis as RouteTableHost)[ROUTE_TABLE_SLOT];\n}\n\n/** The published names, for diagnostics. Empty when nothing is published. */\nexport function knownRouteNames(): readonly string[] {\n const slot = readSlot();\n\n return slot === undefined ? [] : [...slot.table.keys()];\n}\n\n/** Who published the live table, for diagnosis. `undefined` when nothing has. */\nexport function routeTablePublisher(): string | undefined {\n return readSlot()?.publishedBy;\n}\n\nfunction parameterNamesOf(routePath: string): readonly string[] {\n const names: string[] = [];\n\n for (const match of routePath.matchAll(PARAMETER_PATTERN)) {\n names.push(match[1] ?? \"*\");\n }\n\n return names;\n}\n\nfunction interpolate(\n routeName: string,\n routePath: string,\n params: RouteParameters | undefined,\n): string {\n const declared = parameterNamesOf(routePath);\n const supplied = Object.keys(params ?? {}).filter(key => params?.[key] !== undefined);\n const undeclared = supplied.filter(key => !declared.includes(key));\n\n if (undeclared.length > 0) {\n throw new UnknownRouteParameterError(routeName, undeclared, routePath);\n }\n\n return routePath.replace(PARAMETER_PATTERN, match => {\n const name = match === \"*\" ? \"*\" : match.slice(1);\n const value = params?.[name];\n\n if (value === undefined) {\n throw new MissingRouteParameterError(routeName, name, routePath);\n }\n\n return encodeURIComponent(String(value));\n });\n}\n\n/**\n * Resolve a route NAME to a URL.\n *\n * A name, never a path: a moved page changes its URL and keeps its name, so\n * every call site keeps working. That is the property the hardcoded table in\n * the previous `<Link>` could not offer, because it restated six URLs by hand\n * and silently refused every other page in the app.\n *\n * The query half is delegated to `queryStringOf`, which lives next to the\n * DECODER it has to agree with. It used to live here, and being module-private\n * meant the read half could not share it — the one-writer rule held only\n * because nobody had written the second writer yet.\n *\n * @throws {UnserializableQueryValueError} when a query value nests deeper than\n * the wire format core parses can carry.\n */\nexport function href(\n name: string,\n params?: RouteParameters,\n query?: RouteQuery,\n): string {\n const slot = readSlot();\n\n if (slot === undefined) throw new RouteTableNotPublishedError(name);\n\n const routePath = slot.table.get(name);\n\n if (routePath === undefined) {\n throw new UnknownRouteNameError(name, [...slot.table.keys()]);\n }\n\n return `${interpolate(name, routePath, params)}${queryStringOf(query)}`;\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"route-table.mjs","names":[],"sources":["../../../../../../../web/src/routing/route-table.ts"],"sourcesContent":["/**\n * The name→URL primitive, and the one route table both sides read.\n *\n * `href(name, params, query)` is the DURABLE primitive; `<Link>` is sugar over\n * it. That ordering is deliberate and ratified: a function serves emails,\n * redirects, `Location` headers and non-React callers, none of which can render\n * a component — and it keeps client-side navigation, when it lands, a behaviour\n * change rather than an API change.\n *\n * ── Why a process-global table is correct HERE ───────────────────────────────\n * Module-level mutable state is normally a defect in a server that handles\n * concurrent requests, and this codebase has a real example of that defect to\n * point at: `@mongez/react-router`'s `RouterWrapper` keeps the RENDERED PAGE\n * CONTENT in a module-level binding, so request B overwrites the tree request A\n * is about to serialize. That is why it is not on the SSR path.\n *\n * A route table is the opposite kind of value. It is derived from the file\n * system at boot, identical for every request in the process, and never written\n * during a request — the same category as the compiled route table the server's\n * own router holds. Nothing here is per-request, so there is nothing for two\n * requests to race over.\n *\n * The rule that keeps it that way: `publishRouteTable` is called at INSTALL\n * time (server) or at hydration entry (browser), and never from a loader, a\n * middleware, or a component.\n */\n\nimport { queryStringOf, type QueryStringInput } from \"./query-string\";\n\n/** The two fields `href` needs. Callers may pass richer entries; the rest is ignored. */\nexport type RouteTableEntry = {\n readonly name: string;\n readonly path: string;\n};\n\n/** What `href` accepts for a `:param` segment. Rendered with `String(value)`. */\nexport type RouteParameters = Readonly<Record<string, unknown>>;\n\n/**\n * Query values; an `undefined` value is omitted rather than serialized.\n *\n * A value may be a scalar, an array of scalars, or an object one level deep —\n * the shapes `@warlock.js/core` parses back out of the URL. Anything deeper\n * throws `UnserializableQueryValueError`; the grammar and the measurements\n * behind it are documented in query-string.ts.\n */\nexport type RouteQuery = QueryStringInput;\n\nconst PARAMETER_PATTERN = /:([A-Za-z0-9_]+)|\\*/g;\n\n/**\n * ── WHY THIS LIVES ON `globalThis` AND NOT IN A MODULE BINDING ───────────────\n *\n * A plain `let` here does not work in development, and the failure is silent\n * enough to be worth spelling out.\n *\n * In dev the process runs TWO module graphs over the same files. Route\n * installation is loaded by tsx/Node (it is CLI bootstrap and imports core\n * directly), while page and layout modules are evaluated by Vite's SSR module\n * runner — which keeps its own registry and its own instance of every module it\n * transforms, `@warlock.js/web` included. So a module-level binding written by\n * the installer is not the binding `<Link>` reads during render: the installer\n * publishes into one instance and the component finds the other one empty.\n *\n * That was measured, not theorised. With a module-level `let`, every anchor on\n * a server-rendered page threw `RouteTableNotPublishedError` with an empty\n * known-names list while installation had demonstrably run.\n *\n * `Symbol.for` resolves through the per-ISOLATE symbol registry, which both\n * graphs share because they are the same isolate. So the table is one value no\n * matter which graph reaches it first, and the module keeps its module-shaped\n * API. `publishedBy` is carried for diagnosis only.\n */\nconst ROUTE_TABLE_SLOT = Symbol.for(\"warlock.web.routeTable\");\n\ntype RouteTableSlot = {\n table: Map<string, string>;\n publishedBy: string;\n};\n\ntype RouteTableHost = typeof globalThis & {\n [ROUTE_TABLE_SLOT]?: RouteTableSlot;\n};\n\n/**\n * `undefined` means \"nobody has published yet\", which is a DIFFERENT fault from\n * \"the table is published and this name is not in it\" — an empty Map would\n * conflate them and send the reader hunting a route that was never missing.\n */\nfunction readSlot(): RouteTableSlot | undefined {\n return (globalThis as RouteTableHost)[ROUTE_TABLE_SLOT];\n}\n\nexport class RouteTableNotPublishedError extends Error {\n public constructor(public readonly routeName: string) {\n super(\n `Warlock href(${JSON.stringify(routeName)}) was called before the route table was ` +\n \"published, so no route name resolves yet. The table is published once at boot — by \" +\n \"the server when it installs page routes, and by the hydration entry before it mounts. \" +\n \"Seeing this means href() ran outside both: typically a module evaluating at import \" +\n \"time, or a unit test that renders a component without publishing a table first.\",\n );\n this.name = \"RouteTableNotPublishedError\";\n }\n}\n\nexport class UnknownRouteNameError extends Error {\n public constructor(\n public readonly routeName: string,\n public readonly knownRouteNames: readonly string[],\n ) {\n super(\n `Warlock href(${JSON.stringify(routeName)}) does not name a known route. ` +\n (knownRouteNames.length === 0\n ? \"The route table is published but empty, so no page declared a `route` discovery could see.\"\n : `The table knows: ${knownRouteNames.map(name => JSON.stringify(name)).join(\", \")}.`),\n );\n this.name = \"UnknownRouteNameError\";\n }\n}\n\nexport class MissingRouteParameterError extends Error {\n public constructor(\n public readonly routeName: string,\n public readonly parameterName: string,\n public readonly routePath: string,\n ) {\n super(\n `Warlock href(${JSON.stringify(routeName)}) is missing the parameter ` +\n `${JSON.stringify(parameterName)}, required by the route path \"${routePath}\". ` +\n \"It is not defaulted: a missing parameter would otherwise be interpolated as the \" +\n \"literal text `undefined`, producing a link that renders correctly and 404s for a \" +\n \"visitor.\",\n );\n this.name = \"MissingRouteParameterError\";\n }\n}\n\nexport class UnknownRouteParameterError extends Error {\n public constructor(\n public readonly routeName: string,\n public readonly parameterNames: readonly string[],\n public readonly routePath: string,\n ) {\n super(\n `Warlock href(${JSON.stringify(routeName)}) was given ` +\n `${parameterNames.map(name => JSON.stringify(name)).join(\", \")}, which the route path ` +\n `\"${routePath}\" does not declare. Passing an undeclared parameter is a typo often ` +\n \"enough that it is refused rather than dropped; values meant for the query string go \" +\n \"in the third argument.\",\n );\n this.name = \"UnknownRouteParameterError\";\n }\n}\n\nexport class DuplicateRouteNameError extends Error {\n public constructor(\n public readonly routeName: string,\n public readonly paths: readonly [string, string],\n ) {\n super(\n `Warlock route table: two routes both claim the name ${JSON.stringify(routeName)} — ` +\n `\"${paths[0]}\" and \"${paths[1]}\". A name resolves to exactly one URL, so one of the ` +\n \"two would silently win and every link to it would be wrong half the time.\",\n );\n this.name = \"DuplicateRouteNameError\";\n }\n}\n\n/**\n * Publish the table. WHOLESALE — the previous one is discarded, not merged\n * into.\n *\n * Merging looks harmless until a page is deleted and the dev server restarts:\n * the dead name would stay resolvable, and `<Link>` would go on rendering a URL\n * the server no longer routes. The table has to be able to shrink.\n */\nexport function publishRouteTable(\n entries: readonly RouteTableEntry[],\n publishedBy = \"unnamed\",\n): void {\n const table = new Map<string, string>();\n\n for (const entry of entries) {\n const existing = table.get(entry.name);\n\n if (existing !== undefined) {\n throw new DuplicateRouteNameError(entry.name, [existing, entry.path]);\n }\n\n table.set(entry.name, entry.path);\n }\n\n (globalThis as RouteTableHost)[ROUTE_TABLE_SLOT] = { table, publishedBy };\n}\n\n/**\n * Drop the table, returning the module to its pre-boot state.\n *\n * Exists for tests: the table is process-global, so a suite that published one\n * would otherwise leak it into every later test in the same worker and pass in\n * file order while failing under `--shuffle`.\n */\nexport function resetRouteTable(): void {\n delete (globalThis as RouteTableHost)[ROUTE_TABLE_SLOT];\n}\n\n/** The published names, for diagnostics. Empty when nothing is published. */\nexport function knownRouteNames(): readonly string[] {\n const slot = readSlot();\n\n return slot === undefined ? [] : [...slot.table.keys()];\n}\n\n/** Who published the live table, for diagnosis. `undefined` when nothing has. */\nexport function routeTablePublisher(): string | undefined {\n return readSlot()?.publishedBy;\n}\n\nfunction parameterNamesOf(routePath: string): readonly string[] {\n const names: string[] = [];\n\n for (const match of routePath.matchAll(PARAMETER_PATTERN)) {\n names.push(match[1] ?? \"*\");\n }\n\n return names;\n}\n\nfunction interpolate(\n routeName: string,\n routePath: string,\n params: RouteParameters | undefined,\n): string {\n const declared = parameterNamesOf(routePath);\n const supplied = Object.keys(params ?? {}).filter(key => params?.[key] !== undefined);\n const undeclared = supplied.filter(key => !declared.includes(key));\n\n if (undeclared.length > 0) {\n throw new UnknownRouteParameterError(routeName, undeclared, routePath);\n }\n\n return routePath.replace(PARAMETER_PATTERN, match => {\n const name = match === \"*\" ? \"*\" : match.slice(1);\n const value = params?.[name];\n\n if (value === undefined) {\n throw new MissingRouteParameterError(routeName, name, routePath);\n }\n\n return encodeURIComponent(String(value));\n });\n}\n\n/**\n * Resolve a route NAME to a URL.\n *\n * A name, never a path: a moved page changes its URL and keeps its name, so\n * every call site keeps working. That is the property the hardcoded table in\n * the previous `<Link>` could not offer, because it restated six URLs by hand\n * and silently refused every other page in the app.\n *\n * The query half is delegated to `queryStringOf`, which lives next to the\n * DECODER it has to agree with. It used to live here, and being module-private\n * meant the read half could not share it — the one-writer rule held only\n * because nobody had written the second writer yet.\n *\n * @throws {UnserializableQueryValueError} when a query value nests deeper than\n * the wire format core parses can carry.\n */\nexport function href(\n name: string,\n params?: RouteParameters,\n query?: RouteQuery,\n): string {\n const slot = readSlot();\n\n if (slot === undefined) throw new RouteTableNotPublishedError(name);\n\n const routePath = slot.table.get(name);\n\n if (routePath === undefined) {\n throw new UnknownRouteNameError(name, [...slot.table.keys()]);\n }\n\n return `${interpolate(name, routePath, params)}${queryStringOf(query)}`;\n}\n"],"mappings":"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"}
@@ -0,0 +1,19 @@
1
+ //#region ../web/src/runtime/register-modules.d.ts
2
+ /**
3
+ * The universal portion of a page or layout module namespace.
4
+ *
5
+ * `register` deliberately has no arguments and must finish synchronously: it
6
+ * runs while both the server and browser evaluate the same module graph.
7
+ */
8
+ type RegisterableModuleNamespace = {
9
+ readonly register?: () => unknown;
10
+ };
11
+ /**
12
+ * Run each module's optional universal registration hook at most once for
13
+ * that module namespace instance. A replacement namespace from HMR naturally
14
+ * has a new identity and is therefore registered again.
15
+ */
16
+ declare function registerModules(modules: readonly RegisterableModuleNamespace[]): void;
17
+ //#endregion
18
+ export { RegisterableModuleNamespace, registerModules };
19
+ //# sourceMappingURL=register-modules.d.mts.map
@@ -0,0 +1,22 @@
1
+ //#region ../web/src/runtime/register-modules.ts
2
+ const registeredModules = /* @__PURE__ */ new WeakSet();
3
+ function isThenable(value) {
4
+ return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
5
+ }
6
+ /**
7
+ * Run each module's optional universal registration hook at most once for
8
+ * that module namespace instance. A replacement namespace from HMR naturally
9
+ * has a new identity and is therefore registered again.
10
+ */
11
+ function registerModules(modules) {
12
+ for (const module of modules) {
13
+ if (registeredModules.has(module)) continue;
14
+ const result = module.register?.();
15
+ if (isThenable(result)) throw new Error("Warlock register() hooks must be synchronous and must not return a Promise or thenable.");
16
+ registeredModules.add(module);
17
+ }
18
+ }
19
+
20
+ //#endregion
21
+ export { registerModules };
22
+ //# sourceMappingURL=register-modules.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-modules.mjs","names":[],"sources":["../../../../../../../web/src/runtime/register-modules.ts"],"sourcesContent":["/**\n * The universal portion of a page or layout module namespace.\n *\n * `register` deliberately has no arguments and must finish synchronously: it\n * runs while both the server and browser evaluate the same module graph.\n */\nexport type RegisterableModuleNamespace = {\n readonly register?: () => unknown;\n};\n\nconst registeredModules = new WeakSet<RegisterableModuleNamespace>();\n\nfunction isThenable(value: unknown): value is PromiseLike<unknown> {\n return (\n value !== null &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n typeof (value as { then?: unknown }).then === \"function\"\n );\n}\n\n/**\n * Run each module's optional universal registration hook at most once for\n * that module namespace instance. A replacement namespace from HMR naturally\n * has a new identity and is therefore registered again.\n */\nexport function registerModules(modules: readonly RegisterableModuleNamespace[]): void {\n for (const module of modules) {\n if (registeredModules.has(module)) continue;\n\n const result = module.register?.();\n\n if (isThenable(result)) {\n throw new Error(\n \"Warlock register() hooks must be synchronous and must not return a Promise or thenable.\",\n );\n }\n\n // A throwing hook (including one that returned a thenable above) is not\n // recorded, so a later route composition still exposes and can retry it.\n registeredModules.add(module);\n }\n}\n"],"mappings":";AAUA,MAAM,oCAAoB,IAAI,QAAqC;AAEnE,SAAS,WAAW,OAA+C;CACjE,OACE,UAAU,SACT,OAAO,UAAU,YAAY,OAAO,UAAU,eAC/C,OAAQ,MAA6B,SAAS;AAElD;;;;;;AAOA,SAAgB,gBAAgB,SAAuD;CACrF,KAAK,MAAM,UAAU,SAAS;EAC5B,IAAI,kBAAkB,IAAI,MAAM,GAAG;EAEnC,MAAM,SAAS,OAAO,WAAW;EAEjC,IAAI,WAAW,MAAM,GACnB,MAAM,IAAI,MACR,yFACF;EAKF,kBAAkB,IAAI,MAAM;CAC9B;AACF"}
@@ -18,6 +18,7 @@ function buildHydrationPayload(bundle) {
18
18
  shared: serializableData(bundle.shared),
19
19
  params: bundle.route.params,
20
20
  ...bundle.metadata === void 0 ? {} : { metadata: bundle.metadata },
21
+ ...bundle.errorPage === void 0 ? {} : { errorPage: bundle.errorPage },
21
22
  name: bundle.route.name
22
23
  };
23
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"build-hydration-payload.mjs","names":[],"sources":["../../../../../../../web/src/server/build-hydration-payload.ts"],"sourcesContent":["/**\n * The ONE place the hydration payload's shape is decided.\n *\n * Two callers need the identical object and must never drift:\n *\n * `render-page.ts` embeds it in the document as `#__WARLOCK_DATA__`, which\n * is what a FULL page load hands the browser.\n * the `_loader` route returns it as JSON, which is what a CLIENT navigation\n * fetches instead of re-rendering the document.\n *\n * Drift between those two is not a cosmetic bug: the browser builds the same\n * React tree from either source, so a key present on one path and absent on the\n * other produces a page that works when you land on it and breaks when you\n * navigate to it — or the reverse, which is worse, because the first visit is\n * the one everybody tests.\n *\n * Extracted rather than duplicated for exactly that reason. It was previously\n * assembled inline inside the renderer, where the loader route could not reach\n * it without copying five lines that would then be free to diverge.\n */\nimport type { HydrationDocumentPayloadSource } from \"../components/document-context\";\nimport type { PageDataBundle } from \"./execute-page-request\";\n\n/**\n * Levels without a loader resolve to `undefined`, but the hydration contract\n * requires every data key to be PRESENT.\n *\n * An intentional `null` is preserved — a loader that returned `null` said\n * something, and flattening it would erase that. Only \"no data at all\" becomes\n * an empty object.\n */\nfunction serializableData(data: unknown): unknown {\n return data === undefined ? {} : data;\n}\n\nexport function buildHydrationPayload(bundle: PageDataBundle): HydrationDocumentPayloadSource {\n return {\n appData: serializableData(bundle.appData),\n layoutData: serializableData(bundle.layoutData),\n pageData: serializableData(bundle.pageData),\n shared: serializableData(bundle.shared),\n // The server's own match, carried for the same reason `name` is: the params\n // are an ANSWER the router already gave, and re-deriving them in the\n // browser from `location.pathname` would be a second matcher disagreeing\n // with the server about the request it is hydrating. `{}` for a route with\n // no dynamic segments — a real answer, not a missing one.\n params: bundle.route.params,\n // Spread, so \"the page produced no metadata\" is the SAME shape here and on\n // the wire. `metadata: undefined` would be a key in the in-process object\n // and no key at all after `JSON.stringify` — one type, two payload shapes,\n // which is precisely the drift this file exists to prevent. Carried whole:\n // `<Head/>` renders every member of `MetadataOutput`, so anything narrowed\n // out here is a tag the first request has and a navigation does not.\n ...(bundle.metadata === undefined ? {} : { metadata: bundle.metadata }),\n // The matched entry's own name, carried untransformed from stage 1\n // (`bundle.route.name` IS `matched.entry.name`, execute-page-request.ts).\n // The browser reads it to look up the page the server resolved rather than\n // re-matching the pathname — a second matcher can disagree with the server\n // about the very request it is hydrating, and on a client navigation it\n // would be disagreeing about a request the server already answered.\n name: bundle.route.name,\n };\n}\n"],"mappings":";;;;;;;;;AA+BA,SAAS,iBAAiB,MAAwB;CAChD,OAAO,SAAS,SAAY,CAAC,IAAI;AACnC;AAEA,SAAgB,sBAAsB,QAAwD;CAC5F,OAAO;EACL,SAAS,iBAAiB,OAAO,OAAO;EACxC,YAAY,iBAAiB,OAAO,UAAU;EAC9C,UAAU,iBAAiB,OAAO,QAAQ;EAC1C,QAAQ,iBAAiB,OAAO,MAAM;EAMtC,QAAQ,OAAO,MAAM;EAOrB,GAAI,OAAO,aAAa,SAAY,CAAC,IAAI,EAAE,UAAU,OAAO,SAAS;EAOrE,MAAM,OAAO,MAAM;CACrB;AACF"}
1
+ {"version":3,"file":"build-hydration-payload.mjs","names":[],"sources":["../../../../../../../web/src/server/build-hydration-payload.ts"],"sourcesContent":["/**\n * The ONE place the hydration payload's shape is decided.\n *\n * Two callers need the identical object and must never drift:\n *\n * `render-page.ts` embeds it in the document as `#__WARLOCK_DATA__`, which\n * is what a FULL page load hands the browser.\n * the `_loader` route returns it as JSON, which is what a CLIENT navigation\n * fetches instead of re-rendering the document.\n *\n * Drift between those two is not a cosmetic bug: the browser builds the same\n * React tree from either source, so a key present on one path and absent on the\n * other produces a page that works when you land on it and breaks when you\n * navigate to it — or the reverse, which is worse, because the first visit is\n * the one everybody tests.\n *\n * Extracted rather than duplicated for exactly that reason. It was previously\n * assembled inline inside the renderer, where the loader route could not reach\n * it without copying five lines that would then be free to diverge.\n */\nimport type { HydrationDocumentPayloadSource } from \"../components/document-context\";\nimport type { PageDataBundle } from \"./execute-page-request\";\n\n/**\n * Levels without a loader resolve to `undefined`, but the hydration contract\n * requires every data key to be PRESENT.\n *\n * An intentional `null` is preserved — a loader that returned `null` said\n * something, and flattening it would erase that. Only \"no data at all\" becomes\n * an empty object.\n */\nfunction serializableData(data: unknown): unknown {\n return data === undefined ? {} : data;\n}\n\nexport function buildHydrationPayload(bundle: PageDataBundle): HydrationDocumentPayloadSource {\n return {\n appData: serializableData(bundle.appData),\n layoutData: serializableData(bundle.layoutData),\n pageData: serializableData(bundle.pageData),\n shared: serializableData(bundle.shared),\n // The server's own match, carried for the same reason `name` is: the params\n // are an ANSWER the router already gave, and re-deriving them in the\n // browser from `location.pathname` would be a second matcher disagreeing\n // with the server about the request it is hydrating. `{}` for a route with\n // no dynamic segments — a real answer, not a missing one.\n params: bundle.route.params,\n // Spread, so \"the page produced no metadata\" is the SAME shape here and on\n // the wire. `metadata: undefined` would be a key in the in-process object\n // and no key at all after `JSON.stringify` — one type, two payload shapes,\n // which is precisely the drift this file exists to prevent. Carried whole:\n // `<Head/>` renders every member of `MetadataOutput`, so anything narrowed\n // out here is a tag the first request has and a navigation does not.\n ...(bundle.metadata === undefined ? {} : { metadata: bundle.metadata }),\n ...(bundle.errorPage === undefined ? {} : { errorPage: bundle.errorPage }),\n // The matched entry's own name, carried untransformed from stage 1\n // (`bundle.route.name` IS `matched.entry.name`, execute-page-request.ts).\n // The browser reads it to look up the page the server resolved rather than\n // re-matching the pathname — a second matcher can disagree with the server\n // about the very request it is hydrating, and on a client navigation it\n // would be disagreeing about a request the server already answered.\n name: bundle.route.name,\n };\n}\n"],"mappings":";;;;;;;;;AA+BA,SAAS,iBAAiB,MAAwB;CAChD,OAAO,SAAS,SAAY,CAAC,IAAI;AACnC;AAEA,SAAgB,sBAAsB,QAAwD;CAC5F,OAAO;EACL,SAAS,iBAAiB,OAAO,OAAO;EACxC,YAAY,iBAAiB,OAAO,UAAU;EAC9C,UAAU,iBAAiB,OAAO,QAAQ;EAC1C,QAAQ,iBAAiB,OAAO,MAAM;EAMtC,QAAQ,OAAO,MAAM;EAOrB,GAAI,OAAO,aAAa,SAAY,CAAC,IAAI,EAAE,UAAU,OAAO,SAAS;EACrE,GAAI,OAAO,cAAc,SAAY,CAAC,IAAI,EAAE,WAAW,OAAO,UAAU;EAOxE,MAAM,OAAO,MAAM;CACrB;AACF"}
@@ -33,6 +33,7 @@ var PageModuleNotInManifestError = class extends Error {
33
33
  function createPageModuleLoader(manifest) {
34
34
  const modulesById = /* @__PURE__ */ new Map();
35
35
  if (manifest.app) modulesById.set(manifest.app.sourceFile, manifest.app.module);
36
+ if (manifest.errorPage) modulesById.set(manifest.errorPage.sourceFile, manifest.errorPage.module);
36
37
  for (const page of manifest.pages) {
37
38
  modulesById.set(page.sourceFile, page.module);
38
39
  for (const layout of page.layouts) modulesById.set(layout.sourceFile, layout.module);
@@ -1 +1 @@
1
- {"version":3,"file":"create-page-module-loader.mjs","names":[],"sources":["../../../../../../../web/src/server/create-page-module-loader.ts"],"sourcesContent":["/**\n * The production answer to \"how do I load a page module\".\n *\n * `createPageRouteHandler` takes loading a module as an INPUT\n * ({@link PageModuleLoader}) precisely so the two runtimes can answer it\n * differently. Dev hands it `moduleId => vite.ssrLoadModule(moduleId)`;\n * production has no Vite and nothing to evaluate — the generated `pages.ts`\n * barrel already imported every page, layout and the app root statically, and\n * {@link PageManifest} is the table those namespace objects arrived in. So the\n * production loader does not load anything: it is a LOOKUP over modules that\n * are already in memory, and this file is that lookup and nothing else.\n */\nimport type { PageModuleLoader } from \"./create-page-route-handler\";\nimport type { PageManifest } from \"./page-manifest\";\n\n/**\n * Asked for a module this build does not contain.\n *\n * Hard failure, deliberately. Every alternative — returning `undefined`, an\n * empty namespace, or falling back to a dynamic import — turns a build that\n * shipped the wrong module table into a page that renders blank, or into a\n * production process reaching for source files that are not deployed. The id\n * is in the message because the whole diagnosis is \"which id, and why is it\n * not in the table\"; the count is there because zero entries means the build\n * discovered no pages at all, which is a different fault from a mismatch.\n */\nexport class PageModuleNotInManifestError extends Error {\n public constructor(moduleId: string, knownIdCount: number) {\n super(\n `Cannot serve a page module: \"${moduleId}\" is not in this build's page manifest ` +\n `(${knownIdCount} module(s) available). Module ids are the manifest's \\`sourceFile\\` ` +\n \"values — app-root-relative POSIX paths, extension included — and must match exactly. \" +\n \"Re-run `warlock build` so the generated `pages.ts` barrel matches what is being served.\",\n );\n this.name = \"PageModuleNotInManifestError\";\n }\n}\n\n/**\n * Build the loader for ONE manifest.\n *\n * Ids are compared by exact string equality against the `sourceFile` each\n * entry carries — no lowercasing, no separator swapping, no extension\n * stripping. Both sides of that comparison come from the same generator\n * (`generatePagesBarrel` writes every `sourceFile` through one\n * app-root-relative POSIX derivation), so any spelling difference is a real\n * disagreement about which file is meant, and a normalizer would only hide it.\n *\n * A layout shared by several pages appears once per chain it belongs to; the\n * generator emits one identifier per layout file, so every occurrence of an id\n * carries the same namespace object and re-registering it is a no-op.\n */\nexport function createPageModuleLoader(manifest: PageManifest): PageModuleLoader {\n const modulesById = new Map<string, Record<string, unknown>>();\n\n if (manifest.app) {\n modulesById.set(manifest.app.sourceFile, manifest.app.module);\n }\n\n for (const page of manifest.pages) {\n modulesById.set(page.sourceFile, page.module);\n\n for (const layout of page.layouts) {\n modulesById.set(layout.sourceFile, layout.module);\n }\n }\n\n // `async` so an unknown id surfaces as a rejection rather than a synchronous\n // throw: the handler awaits every module through one `Promise.all`, and a\n // loader that fails both ways depending on the reason is a loader callers\n // have to guard twice.\n return async (moduleId: string) => {\n const module = modulesById.get(moduleId);\n\n if (module === undefined) {\n throw new PageModuleNotInManifestError(moduleId, modulesById.size);\n }\n\n return module;\n };\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,IAAa,+BAAb,cAAkD,MAAM;CACtD,AAAO,YAAY,UAAkB,cAAsB;EACzD,MACE,gCAAgC,SAAS,0CACnC,aAAa,qPAGrB;EACA,KAAK,OAAO;CACd;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,uBAAuB,UAA0C;CAC/E,MAAM,8BAAc,IAAI,IAAqC;CAE7D,IAAI,SAAS,KACX,YAAY,IAAI,SAAS,IAAI,YAAY,SAAS,IAAI,MAAM;CAG9D,KAAK,MAAM,QAAQ,SAAS,OAAO;EACjC,YAAY,IAAI,KAAK,YAAY,KAAK,MAAM;EAE5C,KAAK,MAAM,UAAU,KAAK,SACxB,YAAY,IAAI,OAAO,YAAY,OAAO,MAAM;CAEpD;CAMA,OAAO,OAAO,aAAqB;EACjC,MAAM,SAAS,YAAY,IAAI,QAAQ;EAEvC,IAAI,WAAW,QACb,MAAM,IAAI,6BAA6B,UAAU,YAAY,IAAI;EAGnE,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"create-page-module-loader.mjs","names":[],"sources":["../../../../../../../web/src/server/create-page-module-loader.ts"],"sourcesContent":["/**\n * The production answer to \"how do I load a page module\".\n *\n * `createPageRouteHandler` takes loading a module as an INPUT\n * ({@link PageModuleLoader}) precisely so the two runtimes can answer it\n * differently. Dev hands it `moduleId => vite.ssrLoadModule(moduleId)`;\n * production has no Vite and nothing to evaluate — the generated `pages.ts`\n * barrel already imported every page, layout and the app root statically, and\n * {@link PageManifest} is the table those namespace objects arrived in. So the\n * production loader does not load anything: it is a LOOKUP over modules that\n * are already in memory, and this file is that lookup and nothing else.\n */\nimport type { PageModuleLoader } from \"./create-page-route-handler\";\nimport type { PageManifest } from \"./page-manifest\";\n\n/**\n * Asked for a module this build does not contain.\n *\n * Hard failure, deliberately. Every alternative — returning `undefined`, an\n * empty namespace, or falling back to a dynamic import — turns a build that\n * shipped the wrong module table into a page that renders blank, or into a\n * production process reaching for source files that are not deployed. The id\n * is in the message because the whole diagnosis is \"which id, and why is it\n * not in the table\"; the count is there because zero entries means the build\n * discovered no pages at all, which is a different fault from a mismatch.\n */\nexport class PageModuleNotInManifestError extends Error {\n public constructor(moduleId: string, knownIdCount: number) {\n super(\n `Cannot serve a page module: \"${moduleId}\" is not in this build's page manifest ` +\n `(${knownIdCount} module(s) available). Module ids are the manifest's \\`sourceFile\\` ` +\n \"values — app-root-relative POSIX paths, extension included — and must match exactly. \" +\n \"Re-run `warlock build` so the generated `pages.ts` barrel matches what is being served.\",\n );\n this.name = \"PageModuleNotInManifestError\";\n }\n}\n\n/**\n * Build the loader for ONE manifest.\n *\n * Ids are compared by exact string equality against the `sourceFile` each\n * entry carries — no lowercasing, no separator swapping, no extension\n * stripping. Both sides of that comparison come from the same generator\n * (`generatePagesBarrel` writes every `sourceFile` through one\n * app-root-relative POSIX derivation), so any spelling difference is a real\n * disagreement about which file is meant, and a normalizer would only hide it.\n *\n * A layout shared by several pages appears once per chain it belongs to; the\n * generator emits one identifier per layout file, so every occurrence of an id\n * carries the same namespace object and re-registering it is a no-op.\n */\nexport function createPageModuleLoader(manifest: PageManifest): PageModuleLoader {\n const modulesById = new Map<string, Record<string, unknown>>();\n\n if (manifest.app) {\n modulesById.set(manifest.app.sourceFile, manifest.app.module);\n }\n\n if (manifest.errorPage) {\n modulesById.set(manifest.errorPage.sourceFile, manifest.errorPage.module);\n }\n\n for (const page of manifest.pages) {\n modulesById.set(page.sourceFile, page.module);\n\n for (const layout of page.layouts) {\n modulesById.set(layout.sourceFile, layout.module);\n }\n }\n\n // `async` so an unknown id surfaces as a rejection rather than a synchronous\n // throw: the handler awaits every module through one `Promise.all`, and a\n // loader that fails both ways depending on the reason is a loader callers\n // have to guard twice.\n return async (moduleId: string) => {\n const module = modulesById.get(moduleId);\n\n if (module === undefined) {\n throw new PageModuleNotInManifestError(moduleId, modulesById.size);\n }\n\n return module;\n };\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,IAAa,+BAAb,cAAkD,MAAM;CACtD,AAAO,YAAY,UAAkB,cAAsB;EACzD,MACE,gCAAgC,SAAS,0CACnC,aAAa,qPAGrB;EACA,KAAK,OAAO;CACd;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,uBAAuB,UAA0C;CAC/E,MAAM,8BAAc,IAAI,IAAqC;CAE7D,IAAI,SAAS,KACX,YAAY,IAAI,SAAS,IAAI,YAAY,SAAS,IAAI,MAAM;CAG9D,IAAI,SAAS,WACX,YAAY,IAAI,SAAS,UAAU,YAAY,SAAS,UAAU,MAAM;CAG1E,KAAK,MAAM,QAAQ,SAAS,OAAO;EACjC,YAAY,IAAI,KAAK,YAAY,KAAK,MAAM;EAE5C,KAAK,MAAM,UAAU,KAAK,SACxB,YAAY,IAAI,OAAO,YAAY,OAAO,MAAM;CAEpD;CAMA,OAAO,OAAO,aAAqB;EACjC,MAAM,SAAS,YAAY,IAAI,QAAQ;EAEvC,IAAI,WAAW,QACb,MAAM,IAAI,6BAA6B,UAAU,YAAY,IAAI;EAGnE,OAAO;CACT;AACF"}
@@ -1,4 +1,6 @@
1
- import { BufferedCookie } from "./buffered-response.mjs";
1
+ import { RegisterableModuleNamespace } from "../runtime/register-modules.mjs";
2
+ import { BufferedCookie } from "./settle-page-response.mjs";
3
+ import { ErrorPageModuleLoader } from "./error-page.mjs";
2
4
  import { HttpContext, Response } from "@warlock.js/core";
3
5
 
4
6
  //#region ../web/src/server/create-page-route-handler.d.ts
@@ -15,15 +17,24 @@ type PageRouteHandlerOptions = {
15
17
  appFile: string; /** The page module's id. */
16
18
  pageFile: string; /** The page's own-directory `layout.tsx`, when it has one. */
17
19
  layoutFile?: string | undefined;
18
- loadModule: PageModuleLoader; /** Browser module appended after the server-rendered document. */
20
+ loadModule: PageModuleLoader; /** Optional lazy application `error.page.tsx` loader. Never called on success. */
21
+ loadErrorPage?: ErrorPageModuleLoader;
22
+ /**
23
+ * Load the REAL layout module namespaces, outermost first, for universal
24
+ * registration. This stays separate from `loadModule(layoutFile)` because
25
+ * dev may answer that id with a synthetic wrapper whose middleware is the
26
+ * composition of several layouts. That wrapper is a render-pipeline detail,
27
+ * not a module identity, and must never enter `registerModules`' WeakSet.
28
+ */
29
+ loadRegistrationLayouts?: () => Promise<readonly RegisterableModuleNamespace[]>; /** Browser module appended after the server-rendered document. */
19
30
  hydrationClientModuleUrl?: string;
20
31
  /**
21
32
  * Stylesheet URLs for this page, emitted into `<head>` so the FIRST paint is
22
33
  * styled. Absent or empty means the application has no CSS — it never means
23
34
  * a stylesheet failed to resolve, which is the build's job to report.
24
35
  */
25
- stylesheetUrls?: readonly string[]; /** Same helper `dev-server.ts` exports — passed in, never imported. */
26
- applyBufferedCookie: (response: Response, cookie: BufferedCookie) => void;
36
+ stylesheetUrls?: readonly string[];
37
+ /** Same helper `dev-server.ts` exports — passed in, never imported. */
27
38
  /**
28
39
  * The pattern stage 1 matches `request.path` against, when it differs from
29
40
  * the REGISTERED path. Defaults to `path`, which is right for every route
@@ -51,8 +62,22 @@ type PageRouteHandlerOptions = {
51
62
  * a redirect — and overwriting it would report a broken page as a missing one.
52
63
  */
53
64
  statusForRenderedOk?: number;
65
+ /**
66
+ * Exclude the page module's loader from the request triple while preserving
67
+ * the real namespace for `register()` and rendering. Used only by the
68
+ * catch-all 404 page: a missing URL must not run application data work or
69
+ * turn a simple miss into a second failure path.
70
+ */
71
+ skipPageLoader?: boolean;
72
+ /**
73
+ * Replays one committed cookie through core's `Response.cookie()`. Defaults
74
+ * to doing exactly that (`defaultApplyBufferedCookie`, above); injectable so
75
+ * a caller with a different `Response` shape (or a test) can observe/replace
76
+ * the call.
77
+ */
78
+ applyBufferedCookie?: (response: Response, cookie: BufferedCookie) => void;
54
79
  };
55
- type PageRouteHandler = (context: HttpContext) => Promise<void>;
80
+ type PageRouteHandler = (context: HttpContext) => Promise<void | Response>;
56
81
  //#endregion
57
82
  export { PageModuleLoader, PageRouteHandler, PageRouteHandlerOptions };
58
83
  //# sourceMappingURL=create-page-route-handler.d.mts.map
@@ -1,8 +1,56 @@
1
1
  import { DATA_RESPONSE_CONTENT_TYPE, WARLOCK_DATA_REQUEST_HEADER, isDataRequest } from "../routing/data-request.mjs";
2
+ import { isNonHydrating } from "./page-render-bundle.mjs";
3
+ import { registerModules } from "../runtime/register-modules.mjs";
2
4
  import { buildHydrationPayload } from "./build-hydration-payload.mjs";
3
- import { renderPageRequest } from "./render-page.mjs";
5
+ import { renderPageFailure, renderPageRequest } from "./render-page.mjs";
6
+ import { Response } from "@warlock.js/core";
4
7
 
5
8
  //#region ../web/src/server/create-page-route-handler.ts
9
+ /**
10
+ * The page handler, as a named seam.
11
+ *
12
+ * This is the request handler `installPageRoutes` used to inline into its
13
+ * `router.get(...)` call (`install-page-routes.ts:236-275` before this
14
+ * extraction; the pre-extraction copy is `scratchpad/install-page-routes.ts.orig`).
15
+ * The behaviour is unchanged, byte for byte — what changes is that it is now
16
+ * a named, exported, independently constructible function instead of a closure
17
+ * over eight ambient bindings of `installPageRoutes`.
18
+ *
19
+ * WHY IT TAKES `loadModule` AND NOT A `ViteDevServer`: loading a module is the
20
+ * only capability the handler ever needed, and the two runtimes answer it
21
+ * differently — dev goes through Vite's SSR graph
22
+ * (`vite.ssrLoadModule`, `install-page-routes.ts:207`), production reads the
23
+ * already-built page manifest (`page-manifest.ts`). Taking "how to load a
24
+ * module" as an INPUT is what lets the same handler serve both, and what lets
25
+ * a test construct it with a plain async function — no Vite, no dev server, no
26
+ * `app/` directory on disk.
27
+ *
28
+ * Scope: this file creates a seam and nothing else. It does not implement
29
+ * `type: "page"` routing, HTML error pages, or any other new capability.
30
+ */
31
+ /**
32
+ * Replay ONE committed cookie through core's own `Response.cookie()` — the
33
+ * same serializer every ordinary controller's cookie goes through, so there
34
+ * is nothing here for a second implementation to drift from. The one-liner
35
+ * `dev-server.ts` wires as the production default; passed in (`applyBufferedCookie`
36
+ * option, below) rather than imported so this file stays free of anything
37
+ * Vite-shaped.
38
+ */
39
+ function defaultApplyBufferedCookie(response, cookie) {
40
+ response.cookie(cookie.name, cookie.value, cookie.options ?? {});
41
+ }
42
+ /**
43
+ * Stage 10a — apply the stage 7 commit (headers, then cookies) to the LIVE
44
+ * response, once, before either terminal write (10b: `html()` or `send()`).
45
+ * Both the document and data representations of a page route go through this
46
+ * so a client navigation never drops a `Set-Cookie` a full load would have
47
+ * kept (`create-page-route-handler.spec.ts` — "applies committed cookies and
48
+ * headers exactly as the document path does").
49
+ */
50
+ function applyCommit(response, rendered, applyBufferedCookie) {
51
+ response.headers(rendered.headers ?? {});
52
+ for (const cookie of rendered.cookies ?? []) applyBufferedCookie(response, cookie);
53
+ }
6
54
  function escapeHtmlAttribute(value) {
7
55
  return value.replace(/[&<>"']/g, (character) => {
8
56
  switch (character) {
@@ -49,58 +97,95 @@ function installStylesheets(html, stylesheetUrls) {
49
97
  /**
50
98
  * Build the handler for ONE page route. Per request it loads the App + layout
51
99
  * + page triple (concurrently, in that order), renders the URL through
52
- * `renderPageRequest`, splices in the hydration module, applies the committed
53
- * cookies and headers, and flushes the document.
100
+ * `renderPageRequest`, splices in the hydration module, and flushes the
101
+ * document.
54
102
  *
55
103
  * No try/catch, deliberately: loader/render throws are already absorbed by the
56
104
  * pipeline's boundary machinery inside `renderPageRequest`, and anything that
57
- * escapes (a module-load failure, the missing-`</body>` throw above) belongs to
58
- * the router's error path — which is exactly where it went before.
105
+ * escapes (a module-load or register failure, the missing-`</body>` throw
106
+ * above) belongs to the router's error path — which is exactly where it went
107
+ * before.
59
108
  */
60
109
  function createPageRouteHandler(options) {
61
- const { path, name, appFile, pageFile, layoutFile, loadModule, hydrationClientModuleUrl, stylesheetUrls, applyBufferedCookie, matchPath, statusForRenderedOk } = options;
110
+ const { path, name, appFile, pageFile, layoutFile, loadModule, loadErrorPage, loadRegistrationLayouts, hydrationClientModuleUrl, stylesheetUrls, matchPath, statusForRenderedOk, skipPageLoader = false, applyBufferedCookie = defaultApplyBufferedCookie } = options;
62
111
  return async ({ request, response }) => {
63
- const [appModule, layoutModule, ownPageModule] = await Promise.all([
64
- loadModule(appFile),
65
- layoutFile ? loadModule(layoutFile) : Promise.resolve({}),
66
- loadModule(pageFile)
67
- ]);
68
- const triple = {
69
- app: appModule,
70
- layout: layoutModule,
71
- page: ownPageModule
72
- };
73
- const routes = [{
74
- path: matchPath === void 0 ? path : matchPath(request.path),
75
- name,
76
- triple
77
- }];
78
112
  const wantsData = isDataRequest(request.header(WARLOCK_DATA_REQUEST_HEADER, void 0));
79
- const rendered = await renderPageRequest(request.path, {
80
- routes,
81
- createHttp: () => ({
82
- request,
83
- response
84
- })
85
- });
86
- const status = rendered.status === 200 && statusForRenderedOk !== void 0 ? statusForRenderedOk : rendered.status;
87
- if (wantsData) {
88
- for (const cookie of rendered.cookies) applyBufferedCookie(response, cookie);
89
- response.headers(rendered.headers);
90
- response.header("Vary", WARLOCK_DATA_REQUEST_HEADER);
91
- if (rendered.bundle === void 0) {
113
+ try {
114
+ const [appModule, layoutModule, ownPageModule, registrationLayouts] = await Promise.all([
115
+ loadModule(appFile),
116
+ layoutFile ? loadModule(layoutFile) : Promise.resolve({}),
117
+ loadModule(pageFile),
118
+ loadRegistrationLayouts?.() ?? Promise.resolve([])
119
+ ]);
120
+ registerModules([
121
+ appModule,
122
+ ...registrationLayouts,
123
+ ownPageModule
124
+ ]);
125
+ const pageModule = ownPageModule;
126
+ const triple = {
127
+ app: appModule,
128
+ layout: layoutModule,
129
+ page: skipPageLoader ? {
130
+ ...pageModule,
131
+ default: pageModule.default,
132
+ loader: void 0
133
+ } : pageModule
134
+ };
135
+ const requestUrl = request.path;
136
+ const [requestPathname] = requestUrl.split("?");
137
+ const rendered = await renderPageRequest(requestUrl, {
138
+ routes: [{
139
+ path: matchPath === void 0 ? path : matchPath(requestPathname),
140
+ name,
141
+ triple
142
+ }],
143
+ createHttp: () => ({
144
+ request,
145
+ response
146
+ }),
147
+ loadErrorPage
148
+ });
149
+ if (rendered instanceof Response) return rendered;
150
+ const status = rendered.status === 200 && statusForRenderedOk !== void 0 ? statusForRenderedOk : rendered.status;
151
+ applyCommit(response, rendered, applyBufferedCookie);
152
+ if (wantsData) {
153
+ response.header("Vary", WARLOCK_DATA_REQUEST_HEADER);
154
+ if (rendered.bundle === void 0) {
155
+ response.setContentType(DATA_RESPONSE_CONTENT_TYPE);
156
+ await response.send(JSON.stringify({ error: "not_found" }), status);
157
+ return;
158
+ }
92
159
  response.setContentType(DATA_RESPONSE_CONTENT_TYPE);
93
- await response.send(JSON.stringify({ error: "not_found" }), status);
160
+ await response.send(JSON.stringify(buildHydrationPayload(rendered.bundle)), status);
94
161
  return;
95
162
  }
96
- response.setContentType(DATA_RESPONSE_CONTENT_TYPE);
97
- await response.send(JSON.stringify(buildHydrationPayload(rendered.bundle)), status);
98
- return;
163
+ const html = installHydrationClientModule(installStylesheets(rendered.html, stylesheetUrls ?? []), hydrationClientModuleUrl, hydrationClientModuleUrl === void 0 ? void 0 : request.nonce);
164
+ await response.html(html, status);
165
+ } catch (thrown) {
166
+ try {
167
+ const rendered = await renderPageFailure({
168
+ name,
169
+ path: request.path,
170
+ request,
171
+ response,
172
+ thrown,
173
+ loadErrorPage
174
+ });
175
+ applyCommit(response, rendered, applyBufferedCookie);
176
+ if (wantsData) {
177
+ response.header("Vary", WARLOCK_DATA_REQUEST_HEADER);
178
+ response.setContentType(DATA_RESPONSE_CONTENT_TYPE);
179
+ await response.send(JSON.stringify(buildHydrationPayload(rendered.bundle)), 500);
180
+ return;
181
+ }
182
+ const styled = installStylesheets(rendered.html, stylesheetUrls ?? []);
183
+ const html = isNonHydrating(rendered.bundle) ? styled : installHydrationClientModule(styled, hydrationClientModuleUrl, hydrationClientModuleUrl === void 0 ? void 0 : request.nonce);
184
+ await response.html(html, 500);
185
+ } catch {
186
+ throw thrown;
187
+ }
99
188
  }
100
- const html = installHydrationClientModule(installStylesheets(rendered.html, stylesheetUrls ?? []), hydrationClientModuleUrl, hydrationClientModuleUrl === void 0 ? void 0 : request.nonce);
101
- for (const cookie of rendered.cookies) applyBufferedCookie(response, cookie);
102
- response.headers(rendered.headers);
103
- await response.html(html, status);
104
189
  };
105
190
  }
106
191
 
@@ -1 +1 @@
1
- {"version":3,"file":"create-page-route-handler.mjs","names":[],"sources":["../../../../../../../web/src/server/create-page-route-handler.ts"],"sourcesContent":["/**\n * The page handler, as a named seam.\n *\n * This is the request handler `installPageRoutes` used to inline into its\n * `router.get(...)` call (`install-page-routes.ts:236-275` before this\n * extraction; the pre-extraction copy is `scratchpad/install-page-routes.ts.orig`).\n * The behaviour is unchanged, byte for byte — what changes is that it is now\n * a named, exported, independently constructible function instead of a closure\n * over eight ambient bindings of `installPageRoutes`.\n *\n * WHY IT TAKES `loadModule` AND NOT A `ViteDevServer`: loading a module is the\n * only capability the handler ever needed, and the two runtimes answer it\n * differently — dev goes through Vite's SSR graph\n * (`vite.ssrLoadModule`, `install-page-routes.ts:207`), production reads the\n * already-built page manifest (`page-manifest.ts`). Taking \"how to load a\n * module\" as an INPUT is what lets the same handler serve both, and what lets\n * a test construct it with a plain async function — no Vite, no dev server, no\n * `app/` directory on disk.\n *\n * Scope: this file creates a seam and nothing else. It does not implement\n * `type: \"page\"` routing, HTML error pages, or any other new capability.\n */\nimport type { HttpContext, Response } from \"@warlock.js/core\";\n\nimport {\n DATA_RESPONSE_CONTENT_TYPE,\n isDataRequest,\n WARLOCK_DATA_REQUEST_HEADER,\n} from \"../routing/data-request\";\nimport { buildHydrationPayload } from \"./build-hydration-payload\";\nimport type { BufferedCookie } from \"./buffered-response\";\nimport type { PageRouteEntry, PageTripleModule } from \"./execute-page-request\";\nimport { renderPageRequest } from \"./render-page\";\n\n/**\n * How the handler obtains a page/layout/app module, by the same id\n * (`appFile`/`layoutFile`/`pageFile`) the caller registered it under. In dev\n * this is `moduleId => vite.ssrLoadModule(moduleId)`; the connector already\n * owns the dev/prod split, so the handler never learns which one it got.\n */\nexport type PageModuleLoader = (moduleId: string) => Promise<unknown>;\n\nexport type PageRouteHandlerOptions = {\n /** The composed, registered route path — `composeRoutePath`'s output. */\n path: string;\n /** The resolved route name; shared namespace with API routes. */\n name: string;\n /** The single global app-root file, e.g. `<appSrcRoot>/web/root.tsx`. */\n appFile: string;\n /** The page module's id. */\n pageFile: string;\n /** The page's own-directory `layout.tsx`, when it has one. */\n layoutFile?: string | undefined;\n loadModule: PageModuleLoader;\n /** Browser module appended after the server-rendered document. */\n hydrationClientModuleUrl?: string;\n /**\n * Stylesheet URLs for this page, emitted into `<head>` so the FIRST paint is\n * styled. Absent or empty means the application has no CSS — it never means\n * a stylesheet failed to resolve, which is the build's job to report.\n */\n stylesheetUrls?: readonly string[];\n /** Same helper `dev-server.ts` exports — passed in, never imported. */\n applyBufferedCookie: (response: Response, cookie: BufferedCookie) => void;\n /**\n * The pattern stage 1 matches `request.path` against, when it differs from\n * the REGISTERED path. Defaults to `path`, which is right for every route\n * whose URL is its own.\n *\n * Exactly one route needs it: the not-found page, registered on the catch-all\n * `*`. `matchRoute` compares segment by segment (`./match-page-route.ts`) and\n * has no wildcard token, so a route registered as `*` matches NOTHING — the\n * pipeline reports no match and `renderPageRequest` answers `{ html: \"\",\n * status: 404 }`. Correct status, empty document: a 404 page that never\n * renders its own body. Handing it `requestPath => requestPath` makes the\n * requested URL the route's pattern for that one request, so the match is\n * trivially true and the page renders for the URL the visitor actually asked\n * for.\n */\n matchPath?: (requestPath: string) => string;\n /**\n * The status this route answers with when the pipeline settles on a plain\n * `200` — the not-found route's `404`, and nothing else uses it.\n *\n * Applied ONLY to `200`, never as a blanket override: a `200` from this\n * pipeline means \"the document rendered and nobody objected\", which for this\n * route is precisely the not-found case. Any other settled status is a real\n * outcome that the page or the boundary decided — a 500 from a failed render,\n * a redirect — and overwriting it would report a broken page as a missing one.\n */\n statusForRenderedOk?: number;\n};\n\nexport type PageRouteHandler = (context: HttpContext) => Promise<void>;\n\nfunction escapeHtmlAttribute(value: string): string {\n return value.replace(/[&<>\"']/g, (character) => {\n switch (character) {\n case \"&\":\n return \"&amp;\";\n case \"<\":\n return \"&lt;\";\n case \">\":\n return \"&gt;\";\n case '\"':\n return \"&quot;\";\n default:\n return \"&#39;\";\n }\n });\n}\n\nfunction installHydrationClientModule(\n html: string,\n moduleUrl: string | undefined,\n nonce: string | undefined,\n): string {\n if (moduleUrl === undefined || html === \"\") return html;\n\n const closingBodyIndex = html.lastIndexOf(\"</body>\");\n if (closingBodyIndex === -1) {\n throw new Error(\n \"installPageRoutes: cannot install the hydration client module because the rendered document has no closing </body> tag.\",\n );\n }\n\n const nonceAttribute = nonce === undefined ? \"\" : ` nonce=\"${escapeHtmlAttribute(nonce)}\"`;\n const script = `<script type=\"module\"${nonceAttribute} src=\"${escapeHtmlAttribute(moduleUrl)}\"></script>`;\n return `${html.slice(0, closingBodyIndex)}${script}${html.slice(closingBodyIndex)}`;\n}\n\n/**\n * Put the page's stylesheets in `<head>`, so the first paint is styled.\n *\n * Without this the document carries no CSS at all. The stylesheet reaches the\n * browser only because the CLIENT bundle imports it, which means it is applied\n * by JavaScript after the module graph loads — the page renders unstyled first\n * and restyles a moment later. Correct markup, wrong-looking page, and nothing\n * in the console to explain it.\n *\n * A `<link>` in `<head>` is render-blocking, which is exactly what is wanted\n * here: the browser holds the first paint until the CSS is in, so there is no\n * flash rather than a faster ugly one.\n *\n * Inserted before `</head>` rather than after `<head>` so an application's own\n * `<link>`/`<style>` in the root document still comes FIRST and can be\n * overridden by these — matching how the framework's tags are documented to\n * behave, and keeping cascade order predictable.\n */\nfunction installStylesheets(html: string, stylesheetUrls: readonly string[]): string {\n if (stylesheetUrls.length === 0 || html === \"\") return html;\n\n const closingHeadIndex = html.lastIndexOf(\"</head>\");\n\n // No `<head>` is not an error the way a missing `</body>` is: a root that\n // renders no head is unusual but legal, and losing the stylesheet is a\n // cosmetic failure where losing hydration is a broken page. Silently\n // dropping it would be the wrong trade the other way, though — so the\n // document is left exactly as rendered and the caller's own missing-`</body>`\n // check remains the loud one.\n if (closingHeadIndex === -1) return html;\n\n const links = stylesheetUrls\n .map((url) => `<link rel=\"stylesheet\" href=\"${escapeHtmlAttribute(url)}\">`)\n .join(\"\");\n\n return `${html.slice(0, closingHeadIndex)}${links}${html.slice(closingHeadIndex)}`;\n}\n\n/**\n * Build the handler for ONE page route. Per request it loads the App + layout\n * + page triple (concurrently, in that order), renders the URL through\n * `renderPageRequest`, splices in the hydration module, applies the committed\n * cookies and headers, and flushes the document.\n *\n * No try/catch, deliberately: loader/render throws are already absorbed by the\n * pipeline's boundary machinery inside `renderPageRequest`, and anything that\n * escapes (a module-load failure, the missing-`</body>` throw above) belongs to\n * the router's error path — which is exactly where it went before.\n */\nexport function createPageRouteHandler(options: PageRouteHandlerOptions): PageRouteHandler {\n const {\n path,\n name,\n appFile,\n pageFile,\n layoutFile,\n loadModule,\n hydrationClientModuleUrl,\n stylesheetUrls,\n applyBufferedCookie,\n matchPath,\n statusForRenderedOk,\n } = options;\n\n return async ({ request, response }: HttpContext) => {\n const [appModule, layoutModule, ownPageModule] = await Promise.all([\n loadModule(appFile),\n layoutFile ? loadModule(layoutFile) : Promise.resolve({}),\n loadModule(pageFile),\n ]);\n\n const triple: PageRouteEntry[\"triple\"] = {\n app: appModule as PageTripleModule,\n layout: layoutModule as PageTripleModule,\n page: ownPageModule as PageTripleModule,\n };\n\n const routes: PageRouteEntry[] = [\n { path: matchPath === undefined ? path : matchPath(request.path), name, triple },\n ];\n\n // A DATA request runs everything above and below this line identically —\n // it is the same route, the same match and the same pipeline — and differs\n // only in what gets written at the end. Decided here, before the render, so\n // the branch is visibly about REPRESENTATION and not about behaviour.\n const wantsData = isDataRequest(request.header(WARLOCK_DATA_REQUEST_HEADER, undefined));\n\n const rendered = await renderPageRequest(request.path, {\n routes,\n createHttp: () => ({ request, response }),\n });\n\n // See `statusForRenderedOk`: a settled 200 is the only status this route is\n // allowed to restate, and both the document and the data branch below must\n // restate it the same way — a client navigation that received 200 with a\n // not-found payload would push the URL into history as a real page.\n const status =\n rendered.status === 200 && statusForRenderedOk !== undefined\n ? statusForRenderedOk\n : rendered.status;\n\n if (wantsData) {\n // Cookies and headers FIRST, exactly as the document path does below and\n // for the same reason: a client navigation must be able to log a user in,\n // set a flash cookie or be redirected, and dropping those on this path\n // would make a navigation behave differently from a page load of the same\n // URL — the one difference this branch is not allowed to introduce.\n for (const cookie of rendered.cookies) {\n applyBufferedCookie(response, cookie);\n }\n\n response.headers(rendered.headers);\n\n // So a shared cache can never serve a document to a client that asked for\n // JSON, or the reverse. See `data-request.ts` on why this stays even\n // while page responses are `no-store`.\n response.header(\"Vary\", WARLOCK_DATA_REQUEST_HEADER);\n\n // `bundle` is absent on exactly one path: nothing matched, so no pipeline\n // ran and there is no payload to build. Fastify already matched this\n // route to get here, so reaching it means `request.path` did not satisfy\n // the entry's own pattern — answered as the 404 it is, rather than\n // synthesising an empty payload the client would try to render as a page.\n if (rendered.bundle === undefined) {\n response.setContentType(DATA_RESPONSE_CONTENT_TYPE);\n await response.send(JSON.stringify({ error: \"not_found\" }), status);\n\n return;\n }\n\n // SERIALIZED HERE, and handed over as a STRING on purpose.\n //\n // `response.send(object)` runs the body through core's `Response.parse`,\n // which recurses the object, calls `toJSON()` on anything that has one\n // (assigning `request` onto it as it goes) and rebuilds arrays. That is\n // the right behaviour for a controller returning Resources; it is the\n // wrong behaviour here, because the DOCUMENT path serializes this exact\n // object with a plain `JSON.stringify` into `#__WARLOCK_DATA__`. Routing\n // one path through a transformer and not the other is precisely the\n // drift `build-hydration-payload.ts` exists to prevent — the browser\n // would build one tree on a page load and a different one on a\n // navigation to the same URL.\n //\n // A string body also bypasses `parseBody()` entirely, so the content type\n // has to be declared rather than inferred from an object body.\n response.setContentType(DATA_RESPONSE_CONTENT_TYPE);\n await response.send(JSON.stringify(buildHydrationPayload(rendered.bundle)), status);\n\n return;\n }\n\n // Stylesheets first: they go in `<head>`, the hydration module goes before\n // `</body>`, and doing the head work on the already-rendered string keeps\n // both splices in one place rather than threading CSS through the React\n // render just to reach the same bytes.\n const styled = installStylesheets(rendered.html, stylesheetUrls ?? []);\n\n const html = installHydrationClientModule(\n styled,\n hydrationClientModuleUrl,\n hydrationClientModuleUrl === undefined ? undefined : request.nonce,\n );\n\n // THE single site that puts a committed cookie on the wire. The commit\n // stage used to mirror the same list onto the live response as well\n // (`commitBuffers`, execute-page-request.ts), and because fastify's\n // `setCookie` APPENDS rather than sets, every page response carried two\n // identical `Set-Cookie` headers — happy path included. The mirror's\n // cookie half is gone; this loop is what remains, and it is the right\n // one: it runs at stage 10a, after the render, alongside the headers and\n // the final status, so it applies the answer the pipeline actually\n // settled on rather than the one it had at stage 7.\n for (const cookie of rendered.cookies) {\n applyBufferedCookie(response, cookie);\n }\n\n response.headers(rendered.headers);\n\n await response.html(html, status);\n };\n}\n"],"mappings":";;;;;AA+FA,SAAS,oBAAoB,OAAuB;CAClD,OAAO,MAAM,QAAQ,aAAa,cAAc;EAC9C,QAAQ,WAAR;GACE,KAAK,KACH,OAAO;GACT,KAAK,KACH,OAAO;GACT,KAAK,KACH,OAAO;GACT,KAAK,MACH,OAAO;GACT,SACE,OAAO;EACX;CACF,CAAC;AACH;AAEA,SAAS,6BACP,MACA,WACA,OACQ;CACR,IAAI,cAAc,UAAa,SAAS,IAAI,OAAO;CAEnD,MAAM,mBAAmB,KAAK,YAAY,SAAS;CACnD,IAAI,qBAAqB,IACvB,MAAM,IAAI,MACR,yHACF;CAIF,MAAM,SAAS,wBADQ,UAAU,SAAY,KAAK,WAAW,oBAAoB,KAAK,EAAE,GAClC,QAAQ,oBAAoB,SAAS,EAAE;CAC7F,OAAO,GAAG,KAAK,MAAM,GAAG,gBAAgB,IAAI,SAAS,KAAK,MAAM,gBAAgB;AAClF;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,mBAAmB,MAAc,gBAA2C;CACnF,IAAI,eAAe,WAAW,KAAK,SAAS,IAAI,OAAO;CAEvD,MAAM,mBAAmB,KAAK,YAAY,SAAS;CAQnD,IAAI,qBAAqB,IAAI,OAAO;CAEpC,MAAM,QAAQ,eACX,KAAK,QAAQ,gCAAgC,oBAAoB,GAAG,EAAE,GAAG,CAAC,CAC1E,KAAK,EAAE;CAEV,OAAO,GAAG,KAAK,MAAM,GAAG,gBAAgB,IAAI,QAAQ,KAAK,MAAM,gBAAgB;AACjF;;;;;;;;;;;;AAaA,SAAgB,uBAAuB,SAAoD;CACzF,MAAM,EACJ,MACA,MACA,SACA,UACA,YACA,YACA,0BACA,gBACA,qBACA,WACA,wBACE;CAEJ,OAAO,OAAO,EAAE,SAAS,eAA4B;EACnD,MAAM,CAAC,WAAW,cAAc,iBAAiB,MAAM,QAAQ,IAAI;GACjE,WAAW,OAAO;GAClB,aAAa,WAAW,UAAU,IAAI,QAAQ,QAAQ,CAAC,CAAC;GACxD,WAAW,QAAQ;EACrB,CAAC;EAED,MAAM,SAAmC;GACvC,KAAK;GACL,QAAQ;GACR,MAAM;EACR;EAEA,MAAM,SAA2B,CAC/B;GAAE,MAAM,cAAc,SAAY,OAAO,UAAU,QAAQ,IAAI;GAAG;GAAM;EAAO,CACjF;EAMA,MAAM,YAAY,cAAc,QAAQ,OAAO,6BAA6B,MAAS,CAAC;EAEtF,MAAM,WAAW,MAAM,kBAAkB,QAAQ,MAAM;GACrD;GACA,mBAAmB;IAAE;IAAS;GAAS;EACzC,CAAC;EAMD,MAAM,SACJ,SAAS,WAAW,OAAO,wBAAwB,SAC/C,sBACA,SAAS;EAEf,IAAI,WAAW;GAMb,KAAK,MAAM,UAAU,SAAS,SAC5B,oBAAoB,UAAU,MAAM;GAGtC,SAAS,QAAQ,SAAS,OAAO;GAKjC,SAAS,OAAO,QAAQ,2BAA2B;GAOnD,IAAI,SAAS,WAAW,QAAW;IACjC,SAAS,eAAe,0BAA0B;IAClD,MAAM,SAAS,KAAK,KAAK,UAAU,EAAE,OAAO,YAAY,CAAC,GAAG,MAAM;IAElE;GACF;GAiBA,SAAS,eAAe,0BAA0B;GAClD,MAAM,SAAS,KAAK,KAAK,UAAU,sBAAsB,SAAS,MAAM,CAAC,GAAG,MAAM;GAElF;EACF;EAQA,MAAM,OAAO,6BAFE,mBAAmB,SAAS,MAAM,kBAAkB,CAAC,CAG7D,GACL,0BACA,6BAA6B,SAAY,SAAY,QAAQ,KAC/D;EAWA,KAAK,MAAM,UAAU,SAAS,SAC5B,oBAAoB,UAAU,MAAM;EAGtC,SAAS,QAAQ,SAAS,OAAO;EAEjC,MAAM,SAAS,KAAK,MAAM,MAAM;CAClC;AACF"}
1
+ {"version":3,"file":"create-page-route-handler.mjs","names":[],"sources":["../../../../../../../web/src/server/create-page-route-handler.ts"],"sourcesContent":["/**\r\n * The page handler, as a named seam.\r\n *\r\n * This is the request handler `installPageRoutes` used to inline into its\r\n * `router.get(...)` call (`install-page-routes.ts:236-275` before this\r\n * extraction; the pre-extraction copy is `scratchpad/install-page-routes.ts.orig`).\r\n * The behaviour is unchanged, byte for byte — what changes is that it is now\r\n * a named, exported, independently constructible function instead of a closure\r\n * over eight ambient bindings of `installPageRoutes`.\r\n *\r\n * WHY IT TAKES `loadModule` AND NOT A `ViteDevServer`: loading a module is the\r\n * only capability the handler ever needed, and the two runtimes answer it\r\n * differently — dev goes through Vite's SSR graph\r\n * (`vite.ssrLoadModule`, `install-page-routes.ts:207`), production reads the\r\n * already-built page manifest (`page-manifest.ts`). Taking \"how to load a\r\n * module\" as an INPUT is what lets the same handler serve both, and what lets\r\n * a test construct it with a plain async function — no Vite, no dev server, no\r\n * `app/` directory on disk.\r\n *\r\n * Scope: this file creates a seam and nothing else. It does not implement\r\n * `type: \"page\"` routing, HTML error pages, or any other new capability.\r\n */\r\nimport { Response, type HttpContext } from \"@warlock.js/core\";\r\n\r\nimport {\r\n DATA_RESPONSE_CONTENT_TYPE,\r\n isDataRequest,\r\n WARLOCK_DATA_REQUEST_HEADER,\r\n} from \"../routing/data-request\";\r\nimport {\r\n registerModules,\r\n type RegisterableModuleNamespace,\r\n} from \"../runtime/register-modules\";\r\nimport { buildHydrationPayload } from \"./build-hydration-payload\";\r\nimport type { BufferedCookie, PageRouteEntry, PageTripleModule } from \"./execute-page-request\";\r\nimport { isNonHydrating } from \"./page-render-bundle\";\r\nimport { renderPageFailure, renderPageRequest, type RenderedPage } from \"./render-page\";\r\nimport type { ErrorPageModuleLoader } from \"./error-page\";\r\n\r\n/**\r\n * Replay ONE committed cookie through core's own `Response.cookie()` — the\r\n * same serializer every ordinary controller's cookie goes through, so there\r\n * is nothing here for a second implementation to drift from. The one-liner\r\n * `dev-server.ts` wires as the production default; passed in (`applyBufferedCookie`\r\n * option, below) rather than imported so this file stays free of anything\r\n * Vite-shaped.\r\n */\r\nfunction defaultApplyBufferedCookie(response: Response, cookie: BufferedCookie): void {\r\n response.cookie(cookie.name, cookie.value as never, cookie.options ?? {});\r\n}\r\n\r\n/**\r\n * Stage 10a — apply the stage 7 commit (headers, then cookies) to the LIVE\r\n * response, once, before either terminal write (10b: `html()` or `send()`).\r\n * Both the document and data representations of a page route go through this\r\n * so a client navigation never drops a `Set-Cookie` a full load would have\r\n * kept (`create-page-route-handler.spec.ts` — \"applies committed cookies and\r\n * headers exactly as the document path does\").\r\n */\r\nfunction applyCommit(\r\n response: Response,\r\n rendered: Pick<RenderedPage, \"headers\" | \"cookies\">,\r\n applyBufferedCookie: (response: Response, cookie: BufferedCookie) => void,\r\n): void {\r\n response.headers(rendered.headers ?? {});\r\n\r\n for (const cookie of rendered.cookies ?? []) {\r\n applyBufferedCookie(response, cookie);\r\n }\r\n}\r\n\r\n/**\r\n * How the handler obtains a page/layout/app module, by the same id\r\n * (`appFile`/`layoutFile`/`pageFile`) the caller registered it under. In dev\r\n * this is `moduleId => vite.ssrLoadModule(moduleId)`; the connector already\r\n * owns the dev/prod split, so the handler never learns which one it got.\r\n */\r\nexport type PageModuleLoader = (moduleId: string) => Promise<unknown>;\r\n\r\nexport type PageRouteHandlerOptions = {\r\n /** The composed, registered route path — `composeRoutePath`'s output. */\r\n path: string;\r\n /** The resolved route name; shared namespace with API routes. */\r\n name: string;\r\n /** The single global app-root file, e.g. `<appSrcRoot>/web/root.tsx`. */\r\n appFile: string;\r\n /** The page module's id. */\r\n pageFile: string;\r\n /** The page's own-directory `layout.tsx`, when it has one. */\r\n layoutFile?: string | undefined;\r\n loadModule: PageModuleLoader;\r\n /** Optional lazy application `error.page.tsx` loader. Never called on success. */\r\n loadErrorPage?: ErrorPageModuleLoader;\r\n /**\r\n * Load the REAL layout module namespaces, outermost first, for universal\r\n * registration. This stays separate from `loadModule(layoutFile)` because\r\n * dev may answer that id with a synthetic wrapper whose middleware is the\r\n * composition of several layouts. That wrapper is a render-pipeline detail,\r\n * not a module identity, and must never enter `registerModules`' WeakSet.\r\n */\r\n loadRegistrationLayouts?: () => Promise<readonly RegisterableModuleNamespace[]>;\r\n /** Browser module appended after the server-rendered document. */\r\n hydrationClientModuleUrl?: string;\r\n /**\r\n * Stylesheet URLs for this page, emitted into `<head>` so the FIRST paint is\r\n * styled. Absent or empty means the application has no CSS — it never means\r\n * a stylesheet failed to resolve, which is the build's job to report.\r\n */\r\n stylesheetUrls?: readonly string[];\r\n /** Same helper `dev-server.ts` exports — passed in, never imported. */\r\n /**\r\n * The pattern stage 1 matches `request.path` against, when it differs from\r\n * the REGISTERED path. Defaults to `path`, which is right for every route\r\n * whose URL is its own.\r\n *\r\n * Exactly one route needs it: the not-found page, registered on the catch-all\r\n * `*`. `matchRoute` compares segment by segment (`./match-page-route.ts`) and\r\n * has no wildcard token, so a route registered as `*` matches NOTHING — the\r\n * pipeline reports no match and `renderPageRequest` answers `{ html: \"\",\r\n * status: 404 }`. Correct status, empty document: a 404 page that never\r\n * renders its own body. Handing it `requestPath => requestPath` makes the\r\n * requested URL the route's pattern for that one request, so the match is\r\n * trivially true and the page renders for the URL the visitor actually asked\r\n * for.\r\n */\r\n matchPath?: (requestPath: string) => string;\r\n /**\r\n * The status this route answers with when the pipeline settles on a plain\r\n * `200` — the not-found route's `404`, and nothing else uses it.\r\n *\r\n * Applied ONLY to `200`, never as a blanket override: a `200` from this\r\n * pipeline means \"the document rendered and nobody objected\", which for this\r\n * route is precisely the not-found case. Any other settled status is a real\r\n * outcome that the page or the boundary decided — a 500 from a failed render,\r\n * a redirect — and overwriting it would report a broken page as a missing one.\r\n */\r\n statusForRenderedOk?: number;\n /**\n * Exclude the page module's loader from the request triple while preserving\n * the real namespace for `register()` and rendering. Used only by the\n * catch-all 404 page: a missing URL must not run application data work or\n * turn a simple miss into a second failure path.\n */\n skipPageLoader?: boolean;\n /**\r\n * Replays one committed cookie through core's `Response.cookie()`. Defaults\r\n * to doing exactly that (`defaultApplyBufferedCookie`, above); injectable so\r\n * a caller with a different `Response` shape (or a test) can observe/replace\r\n * the call.\r\n */\r\n applyBufferedCookie?: (response: Response, cookie: BufferedCookie) => void;\r\n};\r\n\r\nexport type PageRouteHandler = (context: HttpContext) => Promise<void | Response>;\r\n\r\nfunction escapeHtmlAttribute(value: string): string {\r\n return value.replace(/[&<>\"']/g, (character) => {\r\n switch (character) {\r\n case \"&\":\r\n return \"&amp;\";\r\n case \"<\":\r\n return \"&lt;\";\r\n case \">\":\r\n return \"&gt;\";\r\n case '\"':\r\n return \"&quot;\";\r\n default:\r\n return \"&#39;\";\r\n }\r\n });\r\n}\r\n\r\nfunction installHydrationClientModule(\r\n html: string,\r\n moduleUrl: string | undefined,\r\n nonce: string | undefined,\r\n): string {\r\n if (moduleUrl === undefined || html === \"\") return html;\r\n\r\n const closingBodyIndex = html.lastIndexOf(\"</body>\");\r\n if (closingBodyIndex === -1) {\r\n throw new Error(\r\n \"installPageRoutes: cannot install the hydration client module because the rendered document has no closing </body> tag.\",\r\n );\r\n }\r\n\r\n const nonceAttribute = nonce === undefined ? \"\" : ` nonce=\"${escapeHtmlAttribute(nonce)}\"`;\r\n const script = `<script type=\"module\"${nonceAttribute} src=\"${escapeHtmlAttribute(moduleUrl)}\"></script>`;\r\n return `${html.slice(0, closingBodyIndex)}${script}${html.slice(closingBodyIndex)}`;\r\n}\r\n\r\n/**\r\n * Put the page's stylesheets in `<head>`, so the first paint is styled.\r\n *\r\n * Without this the document carries no CSS at all. The stylesheet reaches the\r\n * browser only because the CLIENT bundle imports it, which means it is applied\r\n * by JavaScript after the module graph loads — the page renders unstyled first\r\n * and restyles a moment later. Correct markup, wrong-looking page, and nothing\r\n * in the console to explain it.\r\n *\r\n * A `<link>` in `<head>` is render-blocking, which is exactly what is wanted\r\n * here: the browser holds the first paint until the CSS is in, so there is no\r\n * flash rather than a faster ugly one.\r\n *\r\n * Inserted before `</head>` rather than after `<head>` so an application's own\r\n * `<link>`/`<style>` in the root document still comes FIRST and can be\r\n * overridden by these — matching how the framework's tags are documented to\r\n * behave, and keeping cascade order predictable.\r\n */\r\nfunction installStylesheets(html: string, stylesheetUrls: readonly string[]): string {\r\n if (stylesheetUrls.length === 0 || html === \"\") return html;\r\n\r\n const closingHeadIndex = html.lastIndexOf(\"</head>\");\r\n\r\n // No `<head>` is not an error the way a missing `</body>` is: a root that\r\n // renders no head is unusual but legal, and losing the stylesheet is a\r\n // cosmetic failure where losing hydration is a broken page. Silently\r\n // dropping it would be the wrong trade the other way, though — so the\r\n // document is left exactly as rendered and the caller's own missing-`</body>`\r\n // check remains the loud one.\r\n if (closingHeadIndex === -1) return html;\r\n\r\n const links = stylesheetUrls\r\n .map((url) => `<link rel=\"stylesheet\" href=\"${escapeHtmlAttribute(url)}\">`)\r\n .join(\"\");\r\n\r\n return `${html.slice(0, closingHeadIndex)}${links}${html.slice(closingHeadIndex)}`;\r\n}\r\n\r\n/**\r\n * Build the handler for ONE page route. Per request it loads the App + layout\r\n * + page triple (concurrently, in that order), renders the URL through\r\n * `renderPageRequest`, splices in the hydration module, and flushes the\r\n * document.\r\n *\r\n * No try/catch, deliberately: loader/render throws are already absorbed by the\r\n * pipeline's boundary machinery inside `renderPageRequest`, and anything that\r\n * escapes (a module-load or register failure, the missing-`</body>` throw\r\n * above) belongs to the router's error path — which is exactly where it went\r\n * before.\r\n */\r\nexport function createPageRouteHandler(options: PageRouteHandlerOptions): PageRouteHandler {\r\n const {\r\n path,\r\n name,\r\n appFile,\r\n pageFile,\r\n layoutFile,\r\n loadModule,\r\n loadErrorPage,\r\n loadRegistrationLayouts,\r\n hydrationClientModuleUrl,\r\n stylesheetUrls,\r\n matchPath,\n statusForRenderedOk,\n skipPageLoader = false,\n applyBufferedCookie = defaultApplyBufferedCookie,\n } = options;\n\r\n return async ({ request, response }: HttpContext) => {\r\n const wantsData = isDataRequest(request.header(WARLOCK_DATA_REQUEST_HEADER, undefined));\r\n\r\n try {\r\n const [appModule, layoutModule, ownPageModule, registrationLayouts] = await Promise.all([\r\n loadModule(appFile),\r\n layoutFile ? loadModule(layoutFile) : Promise.resolve({}),\r\n loadModule(pageFile),\r\n loadRegistrationLayouts?.() ?? Promise.resolve([]),\r\n ]);\r\n\r\n // Registration is the first lifecycle action after all module namespaces\r\n // have loaded and before `renderPageRequest` can run middleware, loaders or\r\n // render. App/page are already their real namespaces. Layouts deliberately\r\n // come from the separate raw chain above, never from `layoutModule`, which\r\n // may be the synthetic composed middleware wrapper used by dev.\r\n registerModules([\r\n appModule as RegisterableModuleNamespace,\r\n ...registrationLayouts,\r\n ownPageModule as RegisterableModuleNamespace,\r\n ]);\r\n\r\n const pageModule = ownPageModule as PageTripleModule;\n const triple: PageRouteEntry[\"triple\"] = {\n app: appModule as PageTripleModule,\n layout: layoutModule as PageTripleModule,\n // Registration above deliberately receives the REAL namespace. Only the\n // pipeline view is projected: spreading preserves the component,\n // metadata, middleware and boundary exports while making a custom 404's\n // loader uncallable.\n page: skipPageLoader\n ? {\n ...pageModule,\n // Vite and native ESM loaders hand us module namespace objects,\n // whose export descriptors are not an object-spread contract.\n // Keep the rendering export explicitly while hiding only loader.\n default: pageModule.default,\n loader: undefined,\n }\n : pageModule,\n };\n\r\n const requestUrl = request.path;\n const [requestPathname] = requestUrl.split(\"?\");\n const routes: PageRouteEntry[] = [\n { path: matchPath === undefined ? path : matchPath(requestPathname), name, triple },\n ];\n\r\n // A DATA request runs everything above and below this line identically —\r\n // it is the same route, the same match and the same pipeline — and differs\r\n // only in what gets written at the end. Decided here, before the render, so\r\n // the branch is visibly about REPRESENTATION and not about behaviour.\r\n const rendered = await renderPageRequest(requestUrl, {\n routes,\r\n createHttp: () => ({ request, response }),\r\n loadErrorPage,\r\n });\r\n\r\n if (rendered instanceof Response) return rendered;\r\n\r\n // See `statusForRenderedOk`: a settled 200 is the only status this route is\r\n // allowed to restate, and both the document and the data branch below must\r\n // restate it the same way — a client navigation that received 200 with a\r\n // not-found payload would push the URL into history as a real page.\r\n const status =\r\n rendered.status === 200 && statusForRenderedOk !== undefined\r\n ? statusForRenderedOk\r\n : rendered.status;\r\n\r\n // Stage 10a: the stage 7 commit (headers, then cookies), applied ONCE,\r\n // identically for the document and the data representation — see\r\n // `applyCommit`.\r\n applyCommit(response, rendered, applyBufferedCookie);\r\n\r\n if (wantsData) {\r\n // So a shared cache can never serve a document to a client that asked for\r\n // JSON, or the reverse. See `data-request.ts` on why this stays even\r\n // while page responses are `no-store`.\r\n response.header(\"Vary\", WARLOCK_DATA_REQUEST_HEADER);\r\n\r\n // `bundle` is absent on exactly one path: nothing matched, so no pipeline\r\n // ran and there is no payload to build. Fastify already matched this\r\n // route to get here, so reaching it means `request.path` did not satisfy\r\n // the entry's own pattern — answered as the 404 it is, rather than\r\n // synthesising an empty payload the client would try to render as a page.\r\n if (rendered.bundle === undefined) {\r\n response.setContentType(DATA_RESPONSE_CONTENT_TYPE);\r\n await response.send(JSON.stringify({ error: \"not_found\" }), status);\r\n\r\n return;\r\n }\r\n\r\n // SERIALIZED HERE, and handed over as a STRING on purpose.\r\n //\r\n // `response.send(object)` runs the body through core's `Response.parse`,\r\n // which recurses the object, calls `toJSON()` on anything that has one\r\n // (assigning `request` onto it as it goes) and rebuilds arrays. That is\r\n // the right behaviour for a controller returning Resources; it is the\r\n // wrong behaviour here, because the DOCUMENT path serializes this exact\r\n // object with a plain `JSON.stringify` into `#__WARLOCK_DATA__`. Routing\r\n // one path through a transformer and not the other is precisely the\r\n // drift `build-hydration-payload.ts` exists to prevent — the browser\r\n // would build one tree on a page load and a different one on a\r\n // navigation to the same URL.\r\n //\r\n // A string body also bypasses `parseBody()` entirely, so the content type\r\n // has to be declared rather than inferred from an object body.\r\n response.setContentType(DATA_RESPONSE_CONTENT_TYPE);\r\n await response.send(JSON.stringify(buildHydrationPayload(rendered.bundle)), status);\r\n\r\n return;\r\n }\r\n\r\n // Stylesheets first: they go in `<head>`, the hydration module goes before\r\n // `</body>`, and doing the head work on the already-rendered string keeps\r\n // both splices in one place rather than threading CSS through the React\r\n // render just to reach the same bytes.\r\n const styled = installStylesheets(rendered.html, stylesheetUrls ?? []);\r\n\r\n const html = installHydrationClientModule(\r\n styled,\r\n hydrationClientModuleUrl,\r\n hydrationClientModuleUrl === undefined ? undefined : request.nonce,\r\n );\r\n\r\n await response.html(html, status);\r\n } catch (thrown) {\r\n // This is outside the page pipeline: loading/registering a module can\r\n // fail before a triple exists for its authored boundaries to handle.\r\n // Reuse this request/response pair so headers, nonce and response\r\n // ownership remain exactly the same as the ordinary path.\r\n //\r\n // Nested try/catch, deliberately: this block's own job is to render a\r\n // NICER answer for `thrown` — it must never let a failure IN THAT\r\n // ATTEMPT (`renderPageFailure` itself throwing, or misbehaving) replace\r\n // `thrown` with a less useful error. If rendering the failure page\r\n // fails too, the original throw escapes exactly as it would have with\r\n // no try/catch at all (the file header's stated contract) — the\r\n // router's own error path is still the answer, just one throw later.\r\n try {\r\n const rendered = await renderPageFailure({\r\n name,\r\n path: request.path,\r\n request,\r\n response,\r\n thrown,\r\n loadErrorPage,\r\n });\r\n\r\n applyCommit(response, rendered, applyBufferedCookie);\r\n\r\n if (wantsData) {\r\n response.header(\"Vary\", WARLOCK_DATA_REQUEST_HEADER);\r\n response.setContentType(DATA_RESPONSE_CONTENT_TYPE);\r\n await response.send(JSON.stringify(buildHydrationPayload(rendered.bundle!)), 500);\r\n return;\r\n }\r\n\r\n const styled = installStylesheets(rendered.html, stylesheetUrls ?? []);\r\n\r\n // `renderPageFailure` marks its bundle non-hydrating (page-render-bundle.ts):\r\n // there is no triple, so there is nothing on the client the hydration\r\n // module could attach to. Injecting it anyway would ship a script that\r\n // hydrates against a composition the server never trusted.\r\n const html = isNonHydrating(rendered.bundle)\r\n ? styled\r\n : installHydrationClientModule(\r\n styled,\r\n hydrationClientModuleUrl,\r\n hydrationClientModuleUrl === undefined ? undefined : request.nonce,\r\n );\r\n await response.html(html, 500);\r\n } catch {\r\n throw thrown;\r\n }\r\n }\r\n };\r\n}\r\n"],"mappings":"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"}
@@ -2,17 +2,6 @@ import { stripVTControlCharacters } from "node:util";
2
2
 
3
3
  //#region ../web/src/server/dev-server.ts
4
4
  /**
5
- * Replay a buffered cookie onto the response that will actually be sent.
6
- *
7
- * `BufferedCookie.options` is a loosely-typed bag (`Record<string, unknown>`)
8
- * because the buffer is written by loader code before any response exists; the
9
- * cast hands it to `Response.cookie()`, which is where the option shape is
10
- * defined and enforced for every other caller in the framework.
11
- */
12
- function applyBufferedCookie(response, cookie) {
13
- response.cookie(cookie.name, cookie.value, cookie.options ?? {});
14
- }
15
- /**
16
5
  * Where a captured transform/resolve failure rides from Vite's connect stack to
17
6
  * the Fastify hook that mounted it.
18
7
  *
@@ -163,5 +152,5 @@ function sendCapturedDevError(request, response) {
163
152
  }
164
153
 
165
154
  //#endregion
166
- export { applyBufferedCookie, devErrorTransportPlugin, sendCapturedDevError };
155
+ export { devErrorTransportPlugin, sendCapturedDevError };
167
156
  //# sourceMappingURL=dev-server.mjs.map