@timber-js/app 0.2.0-alpha.215 → 0.2.0-alpha.217

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 (63) hide show
  1. package/dist/_chunks/als-registry-BZqHCtq-.js.map +1 -1
  2. package/dist/_chunks/{chains-CjK1Eu6a.js → chains-YKZ8WpIW.js} +2 -2
  3. package/dist/_chunks/{chains-CjK1Eu6a.js.map → chains-YKZ8WpIW.js.map} +1 -1
  4. package/dist/_chunks/{classify-GAdt6aiA.js → classify-2Yp3xJY1.js} +3 -3
  5. package/dist/_chunks/{classify-GAdt6aiA.js.map → classify-2Yp3xJY1.js.map} +1 -1
  6. package/dist/_chunks/{cli-check-DOzjlycg.js → cli-check-D2WtbNqo.js} +3 -3
  7. package/dist/_chunks/{cli-check-DOzjlycg.js.map → cli-check-D2WtbNqo.js.map} +1 -1
  8. package/dist/_chunks/{cli-schema-sync-B9wDaQvW.js → cli-schema-sync-CySLKrO3.js} +2 -2
  9. package/dist/_chunks/{cli-schema-sync-B9wDaQvW.js.map → cli-schema-sync-CySLKrO3.js.map} +1 -1
  10. package/dist/_chunks/{client-dep-entries-DEp8ZHce.js → client-dep-entries-BOkpKjj1.js} +2 -2
  11. package/dist/_chunks/{client-dep-entries-DEp8ZHce.js.map → client-dep-entries-BOkpKjj1.js.map} +1 -1
  12. package/dist/_chunks/{convention-lint-B3QEGJX7.js → convention-lint-ByKJ6aqD.js} +2 -2
  13. package/dist/_chunks/{convention-lint-B3QEGJX7.js.map → convention-lint-ByKJ6aqD.js.map} +1 -1
  14. package/dist/_chunks/{dev-server-_9L4KWC-.js → dev-server-B8zsT-ee.js} +4 -4
  15. package/dist/_chunks/{dev-server-_9L4KWC-.js.map → dev-server-B8zsT-ee.js.map} +1 -1
  16. package/dist/_chunks/{live-graph-Cd3YHvrH.js → live-graph-BhtrZpRd.js} +4 -4
  17. package/dist/_chunks/{live-graph-Cd3YHvrH.js.map → live-graph-BhtrZpRd.js.map} +1 -1
  18. package/dist/_chunks/{metadata-routes-DSDjM_hJ.js → metadata-routes-B3XJNyIH.js} +1 -2
  19. package/dist/_chunks/metadata-routes-B3XJNyIH.js.map +1 -0
  20. package/dist/_chunks/{poison-scan-BnJjBOkn.js → poison-scan-C4FgMxFl.js} +2 -2
  21. package/dist/_chunks/{poison-scan-BnJjBOkn.js.map → poison-scan-C4FgMxFl.js.map} +1 -1
  22. package/dist/_chunks/{scanner-CKAT5gRx.js → scanner-Cb3fSjAC.js} +4 -4
  23. package/dist/_chunks/{scanner-CKAT5gRx.js.map → scanner-Cb3fSjAC.js.map} +1 -1
  24. package/dist/_chunks/{walkers-DwCXEyRu.js → walkers-Ber9bamD.js} +3 -3
  25. package/dist/_chunks/{walkers-DwCXEyRu.js.map → walkers-Ber9bamD.js.map} +1 -1
  26. package/dist/adapters/nitro-immutable-assets.d.ts +47 -0
  27. package/dist/adapters/nitro-immutable-assets.d.ts.map +1 -0
  28. package/dist/adapters/nitro-preview.d.ts +3 -2
  29. package/dist/adapters/nitro-preview.d.ts.map +1 -1
  30. package/dist/adapters/nitro.d.ts +16 -2
  31. package/dist/adapters/nitro.d.ts.map +1 -1
  32. package/dist/adapters/nitro.js +130 -10
  33. package/dist/adapters/nitro.js.map +1 -1
  34. package/dist/analyze/crawl-entry.js +3 -3
  35. package/dist/analyze/graph-command.js +2 -2
  36. package/dist/cli.js +3 -3
  37. package/dist/index.js +6 -6
  38. package/dist/routing/index.js +2 -2
  39. package/dist/server/als-registry.d.ts +2 -0
  40. package/dist/server/als-registry.d.ts.map +1 -1
  41. package/dist/server/internal.js +2 -2
  42. package/dist/server/internal.js.map +1 -1
  43. package/dist/server/metadata-collector.d.ts +2 -0
  44. package/dist/server/metadata-collector.d.ts.map +1 -1
  45. package/dist/server/metadata-route-links.d.ts +70 -0
  46. package/dist/server/metadata-route-links.d.ts.map +1 -0
  47. package/dist/server/metadata-routes.d.ts +0 -24
  48. package/dist/server/metadata-routes.d.ts.map +1 -1
  49. package/dist/server/route-element-builder.d.ts.map +1 -1
  50. package/dist/server/route-matcher.d.ts +7 -0
  51. package/dist/server/route-matcher.d.ts.map +1 -1
  52. package/docs/api/34-api-config.mdx +1 -1
  53. package/package.json +1 -1
  54. package/src/adapters/nitro-immutable-assets.ts +142 -0
  55. package/src/adapters/nitro-preview.ts +12 -3
  56. package/src/adapters/nitro.ts +31 -17
  57. package/src/server/als-registry.ts +2 -0
  58. package/src/server/metadata-collector.ts +15 -17
  59. package/src/server/metadata-route-links.ts +200 -0
  60. package/src/server/metadata-routes.ts +0 -106
  61. package/src/server/route-element-builder.ts +1 -0
  62. package/src/server/route-matcher.ts +2 -2
  63. package/dist/_chunks/metadata-routes-DSDjM_hJ.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { n as classifyUrlSegment } from "./segment-classify-C539Pa2O.js";
2
- import { u as readFileCached } from "./scanner-CKAT5gRx.js";
3
- import { n as findSchemaFile, r as parseExistingSchemaKeys } from "./cli-schema-sync-B9wDaQvW.js";
2
+ import { u as readFileCached } from "./scanner-Cb3fSjAC.js";
3
+ import { n as findSchemaFile, r as parseExistingSchemaKeys } from "./cli-schema-sync-CySLKrO3.js";
4
4
  //#region src/routing/schema-validation.ts
5
5
  /**
6
6
  * Schema key/value validation against the filesystem route tree.
@@ -141,4 +141,4 @@ function walk(node, chain, result, includeSlots) {
141
141
  //#endregion
142
142
  export { collectDynamicSegmentsFromTree as n, validateSchemaAgainstRoutes as r, collectLeafRoutes as t };
143
143
 
144
- //# sourceMappingURL=walkers-DwCXEyRu.js.map
144
+ //# sourceMappingURL=walkers-Ber9bamD.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"walkers-DwCXEyRu.js","names":[],"sources":["../../src/routing/schema-validation.ts","../../src/routing/walkers.ts"],"sourcesContent":["/**\n * Schema key/value validation against the filesystem route tree.\n *\n * Runs at codegen time (build + dev) to catch mismatches between\n * app/schema.ts keys and the actual dynamic segments on disk.\n *\n * Design doc: design/41-global-params.md\n */\n\nimport { readFileCached } from './file-cache.ts';\nimport type { RouteTree, SegmentNode } from './types.ts';\nimport { findSchemaFile, parseExistingSchemaKeys } from '../cli-schema-sync.ts';\nimport { classifyUrlSegment } from './segment-classify.ts';\n\nexport interface SchemaWarning {\n type: 'stale-key' | 'missing-key' | 'bracket-mismatch';\n key: string;\n message: string;\n filesystemKey?: string;\n}\n\n/**\n * Collect all unique bracket-keyed dynamic segment names from a route tree.\n * Returns entries like '[artistSlug]', '[...slug]', '[[...topic]]'.\n */\nexport function collectDynamicSegmentsFromTree(tree: RouteTree): Set<string> {\n const segments = new Set<string>();\n walkTree(tree.root, segments);\n return segments;\n}\n\nfunction walkTree(node: SegmentNode, segments: Set<string>): void {\n if (node.paramName && node.segmentName) {\n const classified = classifyUrlSegment(node.segmentName);\n if (classified.kind !== 'static') {\n // Use bare bracket form for schema keys — affixed segments like\n // `img-[id].png` register as `[id]`, matching runtime codec lookup.\n if (classified.kind === 'dynamic' && (classified.prefix || classified.suffix)) {\n segments.add(`[${classified.name}]`);\n } else {\n segments.add(node.segmentName);\n }\n }\n }\n for (const child of node.children) {\n walkTree(child, segments);\n }\n for (const slot of Object.values(node.slots)) {\n walkTree(slot, segments);\n }\n}\n\n/**\n * Extract the param name from a bracket key.\n * '[id]' → 'id', '[...slug]' → 'slug', '[[...topic]]' → 'topic'\n */\nfunction extractParamName(bracketKey: string): string | null {\n const seg = classifyUrlSegment(bracketKey);\n if (seg.kind === 'static') return null;\n return seg.name;\n}\n\n/**\n * Validate schema keys against the filesystem route tree.\n *\n * Returns warnings for:\n * - Stale keys: schema keys that don't match any filesystem segment\n * - Bracket form mismatches: same param name, different bracket form\n * - Missing keys: filesystem segments not registered in schema (informational)\n */\nexport function validateSchemaAgainstRoutes(tree: RouteTree, appDir: string): SchemaWarning[] {\n const schemaPath = findSchemaFile(appDir);\n if (!schemaPath) return [];\n\n const content = readFileCached(schemaPath);\n const schemaKeys = parseExistingSchemaKeys(content);\n\n if (schemaKeys.length === 0) return [];\n\n const filesystemSegments = collectDynamicSegmentsFromTree(tree);\n\n return validateKeys(schemaKeys, filesystemSegments);\n}\n\n/**\n * Core validation: compare schema keys against filesystem segments.\n * Exported separately for testing without filesystem dependencies.\n */\nexport function validateKeys(\n schemaKeys: string[],\n filesystemSegments: Set<string>\n): SchemaWarning[] {\n const warnings: SchemaWarning[] = [];\n\n // Build a map of param name → bracket form for filesystem segments\n const fsParamToKey = new Map<string, string>();\n for (const fsKey of filesystemSegments) {\n const name = extractParamName(fsKey);\n if (name) {\n fsParamToKey.set(name, fsKey);\n }\n }\n\n // Build a set of schema param names for the missing-key check\n const schemaParamNames = new Set<string>();\n\n for (const schemaKey of schemaKeys) {\n const schemaParamName = extractParamName(schemaKey);\n if (!schemaParamName) continue;\n\n schemaParamNames.add(schemaParamName);\n\n if (filesystemSegments.has(schemaKey)) {\n // Exact match — no issue\n continue;\n }\n\n // Check if the param name exists but with a different bracket form\n const fsKey = fsParamToKey.get(schemaParamName);\n if (fsKey) {\n warnings.push({\n type: 'bracket-mismatch',\n key: schemaKey,\n filesystemKey: fsKey,\n message:\n `Schema key '${schemaKey}' does not match filesystem bracket form '${fsKey}'. ` +\n `Update the schema key to '${fsKey}'.`,\n });\n } else {\n warnings.push({\n type: 'stale-key',\n key: schemaKey,\n message:\n `Schema key '${schemaKey}' does not match any dynamic segment in the filesystem. ` +\n `Remove it from app/schema.ts or create the corresponding route segment.`,\n });\n }\n }\n\n // Check for filesystem segments not in schema (informational)\n for (const fsKey of filesystemSegments) {\n const name = extractParamName(fsKey);\n if (name && !schemaParamNames.has(name)) {\n warnings.push({\n type: 'missing-key',\n key: fsKey,\n message:\n `Dynamic segment '${fsKey}' has no codec in app/schema.ts (defaults to string). ` +\n `Run: timber schema sync`,\n });\n }\n }\n\n return warnings;\n}\n","/**\n * Shared route-tree walkers (TIM-848).\n *\n * Tiny helpers that walk a `SegmentNode<TFile>` tree generically. Both the\n * build-time tree (`SegmentNode<RouteFile>`) and the runtime manifest\n * tree (`SegmentNode<ManifestFile>`) flow through these helpers because\n * the walker only reads the structural fields shared by both shapes\n * (`children`, `slots`, `page`, `route`, `urlPath`).\n *\n * Before this module, three near-identical `collectRoutes` functions\n * lived in `plugins/dev-404-page.ts`, `plugins/build-report.ts`, and\n * `routing/codegen.ts`. The codegen one is special-purpose (it\n * accumulates `ParamEntry[]` and resolves codec chains) and stays\n * local; the other two now share `collectLeafRoutes` from this file.\n */\n\nimport type { SegmentNode } from './types.ts';\n\n/** A leaf route discovered while walking the segment tree. */\nexport interface LeafRoute<TFile> {\n /** URL path of the leaf (root is \"/\"). */\n urlPath: string;\n /** Segment chain from root to this leaf, inclusive. */\n segments: SegmentNode<TFile>[];\n /** The page file at this leaf, if any. */\n page?: TFile;\n /** The route handler file at this leaf, if any. */\n route?: TFile;\n}\n\n/** Options for `collectLeafRoutes`. */\nexport interface CollectLeafRoutesOptions {\n /**\n * If true, recurse into parallel slots and emit slot leaves alongside\n * the main route tree. Defaults to `false` because slots render\n * alongside their parent at the same URL and are not separately\n * URL-addressable. The build report excludes slots; route-listing\n * UIs that want to show \"all leaves with a page handler\" can opt in.\n */\n includeSlots?: boolean;\n}\n\n/**\n * Walk a segment tree and collect every leaf with a `page` or `route`\n * handler. Generic over `TFile` so it works on both the build-time\n * scanner output and the runtime manifest tree.\n *\n * - Pages and route handlers at the same URL produce two distinct\n * entries (the build report deduplicates by URL afterward).\n * - Parallel slots are skipped unless `includeSlots: true` (slots\n * share their parent's URL and are not addressable on their own).\n * - Intercepting subtrees are skipped unconditionally. They render only\n * on soft navigation and add no URL depth, so their computed `urlPath`s\n * are not addresses — listing them would advertise routes (`/[year]`)\n * that no request can reach. This matches every other consumer of the\n * tree that produces URLs: the sitemap generator, the static generator,\n * prerendering and the prebuilt-payload builder all skip them too.\n * - Result is sorted by `urlPath` for deterministic output.\n */\nexport function collectLeafRoutes<TFile>(\n root: SegmentNode<TFile>,\n options: CollectLeafRoutesOptions = {}\n): LeafRoute<TFile>[] {\n const { includeSlots = false } = options;\n const result: LeafRoute<TFile>[] = [];\n walk(root, [], result, includeSlots);\n result.sort((a, b) => a.urlPath.localeCompare(b.urlPath));\n return result;\n}\n\nfunction walk<TFile>(\n node: SegmentNode<TFile>,\n chain: SegmentNode<TFile>[],\n result: LeafRoute<TFile>[],\n includeSlots: boolean\n): void {\n if (node.segmentType === 'intercepting') return;\n\n const currentChain = [...chain, node];\n const path = node.urlPath || '/';\n\n if (node.page) {\n result.push({ urlPath: path, segments: currentChain, page: node.page });\n }\n if (node.route) {\n result.push({ urlPath: path, segments: currentChain, route: node.route });\n }\n\n for (const child of node.children) {\n walk(child, currentChain, result, includeSlots);\n }\n\n if (includeSlots) {\n for (const slotNode of Object.values(node.slots)) {\n walk(slotNode, currentChain, result, includeSlots);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyBA,SAAgB,+BAA+B,MAA8B;CAC3E,MAAM,2BAAW,IAAI,IAAY;CACjC,SAAS,KAAK,MAAM,QAAQ;CAC5B,OAAO;AACT;AAEA,SAAS,SAAS,MAAmB,UAA6B;CAChE,IAAI,KAAK,aAAa,KAAK,aAAa;EACtC,MAAM,aAAa,mBAAmB,KAAK,WAAW;EACtD,IAAI,WAAW,SAAS,UAAU;GAGhC,IAAI,WAAW,SAAS,cAAc,WAAW,UAAU,WAAW,SACpE,SAAS,IAAI,IAAI,WAAW,KAAK,EAAE;QAEnC,SAAS,IAAI,KAAK,WAAW;EAEjC;CACF;CACA,KAAK,MAAM,SAAS,KAAK,UACvB,SAAS,OAAO,QAAQ;CAE1B,KAAK,MAAM,QAAQ,OAAO,OAAO,KAAK,KAAK,GACzC,SAAS,MAAM,QAAQ;AAE3B;;;;;AAMA,SAAS,iBAAiB,YAAmC;CAC3D,MAAM,MAAM,mBAAmB,UAAU;CACzC,IAAI,IAAI,SAAS,UAAU,OAAO;CAClC,OAAO,IAAI;AACb;;;;;;;;;AAUA,SAAgB,4BAA4B,MAAiB,QAAiC;CAC5F,MAAM,aAAa,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ACnC,OAAO,MAAM,GAAG,MAAM,EAAE,QAAQ,cAAc,EAAE,OAAO,CAAC;CACxD,OAAO;AACT;AAEA,SAAS,KACP,MACA,OACA,QACA,cACM;CACN,IAAI,KAAK,gBAAgB,gBAAgB;CAEzC,MAAM,eAAe,CAAC,GAAG,OAAO,IAAI;CACpC,MAAM,OAAO,KAAK,WAAW;CAE7B,IAAI,KAAK,MACP,OAAO,KAAK;EAAE,SAAS;EAAM,UAAU;EAAc,MAAM,KAAK;CAAK,CAAC;CAExE,IAAI,KAAK,OACP,OAAO,KAAK;EAAE,SAAS;EAAM,UAAU;EAAc,OAAO,KAAK;CAAM,CAAC;CAG1E,KAAK,MAAM,SAAS,KAAK,UACvB,KAAK,OAAO,cAAc,QAAQ,YAAY;CAGhD,IAAI,cACF,KAAK,MAAM,YAAY,OAAO,OAAO,KAAK,KAAK,GAC7C,KAAK,UAAU,cAAc,QAAQ,YAAY;AAGvD"}
1
+ {"version":3,"file":"walkers-Ber9bamD.js","names":[],"sources":["../../src/routing/schema-validation.ts","../../src/routing/walkers.ts"],"sourcesContent":["/**\n * Schema key/value validation against the filesystem route tree.\n *\n * Runs at codegen time (build + dev) to catch mismatches between\n * app/schema.ts keys and the actual dynamic segments on disk.\n *\n * Design doc: design/41-global-params.md\n */\n\nimport { readFileCached } from './file-cache.ts';\nimport type { RouteTree, SegmentNode } from './types.ts';\nimport { findSchemaFile, parseExistingSchemaKeys } from '../cli-schema-sync.ts';\nimport { classifyUrlSegment } from './segment-classify.ts';\n\nexport interface SchemaWarning {\n type: 'stale-key' | 'missing-key' | 'bracket-mismatch';\n key: string;\n message: string;\n filesystemKey?: string;\n}\n\n/**\n * Collect all unique bracket-keyed dynamic segment names from a route tree.\n * Returns entries like '[artistSlug]', '[...slug]', '[[...topic]]'.\n */\nexport function collectDynamicSegmentsFromTree(tree: RouteTree): Set<string> {\n const segments = new Set<string>();\n walkTree(tree.root, segments);\n return segments;\n}\n\nfunction walkTree(node: SegmentNode, segments: Set<string>): void {\n if (node.paramName && node.segmentName) {\n const classified = classifyUrlSegment(node.segmentName);\n if (classified.kind !== 'static') {\n // Use bare bracket form for schema keys — affixed segments like\n // `img-[id].png` register as `[id]`, matching runtime codec lookup.\n if (classified.kind === 'dynamic' && (classified.prefix || classified.suffix)) {\n segments.add(`[${classified.name}]`);\n } else {\n segments.add(node.segmentName);\n }\n }\n }\n for (const child of node.children) {\n walkTree(child, segments);\n }\n for (const slot of Object.values(node.slots)) {\n walkTree(slot, segments);\n }\n}\n\n/**\n * Extract the param name from a bracket key.\n * '[id]' → 'id', '[...slug]' → 'slug', '[[...topic]]' → 'topic'\n */\nfunction extractParamName(bracketKey: string): string | null {\n const seg = classifyUrlSegment(bracketKey);\n if (seg.kind === 'static') return null;\n return seg.name;\n}\n\n/**\n * Validate schema keys against the filesystem route tree.\n *\n * Returns warnings for:\n * - Stale keys: schema keys that don't match any filesystem segment\n * - Bracket form mismatches: same param name, different bracket form\n * - Missing keys: filesystem segments not registered in schema (informational)\n */\nexport function validateSchemaAgainstRoutes(tree: RouteTree, appDir: string): SchemaWarning[] {\n const schemaPath = findSchemaFile(appDir);\n if (!schemaPath) return [];\n\n const content = readFileCached(schemaPath);\n const schemaKeys = parseExistingSchemaKeys(content);\n\n if (schemaKeys.length === 0) return [];\n\n const filesystemSegments = collectDynamicSegmentsFromTree(tree);\n\n return validateKeys(schemaKeys, filesystemSegments);\n}\n\n/**\n * Core validation: compare schema keys against filesystem segments.\n * Exported separately for testing without filesystem dependencies.\n */\nexport function validateKeys(\n schemaKeys: string[],\n filesystemSegments: Set<string>\n): SchemaWarning[] {\n const warnings: SchemaWarning[] = [];\n\n // Build a map of param name → bracket form for filesystem segments\n const fsParamToKey = new Map<string, string>();\n for (const fsKey of filesystemSegments) {\n const name = extractParamName(fsKey);\n if (name) {\n fsParamToKey.set(name, fsKey);\n }\n }\n\n // Build a set of schema param names for the missing-key check\n const schemaParamNames = new Set<string>();\n\n for (const schemaKey of schemaKeys) {\n const schemaParamName = extractParamName(schemaKey);\n if (!schemaParamName) continue;\n\n schemaParamNames.add(schemaParamName);\n\n if (filesystemSegments.has(schemaKey)) {\n // Exact match — no issue\n continue;\n }\n\n // Check if the param name exists but with a different bracket form\n const fsKey = fsParamToKey.get(schemaParamName);\n if (fsKey) {\n warnings.push({\n type: 'bracket-mismatch',\n key: schemaKey,\n filesystemKey: fsKey,\n message:\n `Schema key '${schemaKey}' does not match filesystem bracket form '${fsKey}'. ` +\n `Update the schema key to '${fsKey}'.`,\n });\n } else {\n warnings.push({\n type: 'stale-key',\n key: schemaKey,\n message:\n `Schema key '${schemaKey}' does not match any dynamic segment in the filesystem. ` +\n `Remove it from app/schema.ts or create the corresponding route segment.`,\n });\n }\n }\n\n // Check for filesystem segments not in schema (informational)\n for (const fsKey of filesystemSegments) {\n const name = extractParamName(fsKey);\n if (name && !schemaParamNames.has(name)) {\n warnings.push({\n type: 'missing-key',\n key: fsKey,\n message:\n `Dynamic segment '${fsKey}' has no codec in app/schema.ts (defaults to string). ` +\n `Run: timber schema sync`,\n });\n }\n }\n\n return warnings;\n}\n","/**\n * Shared route-tree walkers (TIM-848).\n *\n * Tiny helpers that walk a `SegmentNode<TFile>` tree generically. Both the\n * build-time tree (`SegmentNode<RouteFile>`) and the runtime manifest\n * tree (`SegmentNode<ManifestFile>`) flow through these helpers because\n * the walker only reads the structural fields shared by both shapes\n * (`children`, `slots`, `page`, `route`, `urlPath`).\n *\n * Before this module, three near-identical `collectRoutes` functions\n * lived in `plugins/dev-404-page.ts`, `plugins/build-report.ts`, and\n * `routing/codegen.ts`. The codegen one is special-purpose (it\n * accumulates `ParamEntry[]` and resolves codec chains) and stays\n * local; the other two now share `collectLeafRoutes` from this file.\n */\n\nimport type { SegmentNode } from './types.ts';\n\n/** A leaf route discovered while walking the segment tree. */\nexport interface LeafRoute<TFile> {\n /** URL path of the leaf (root is \"/\"). */\n urlPath: string;\n /** Segment chain from root to this leaf, inclusive. */\n segments: SegmentNode<TFile>[];\n /** The page file at this leaf, if any. */\n page?: TFile;\n /** The route handler file at this leaf, if any. */\n route?: TFile;\n}\n\n/** Options for `collectLeafRoutes`. */\nexport interface CollectLeafRoutesOptions {\n /**\n * If true, recurse into parallel slots and emit slot leaves alongside\n * the main route tree. Defaults to `false` because slots render\n * alongside their parent at the same URL and are not separately\n * URL-addressable. The build report excludes slots; route-listing\n * UIs that want to show \"all leaves with a page handler\" can opt in.\n */\n includeSlots?: boolean;\n}\n\n/**\n * Walk a segment tree and collect every leaf with a `page` or `route`\n * handler. Generic over `TFile` so it works on both the build-time\n * scanner output and the runtime manifest tree.\n *\n * - Pages and route handlers at the same URL produce two distinct\n * entries (the build report deduplicates by URL afterward).\n * - Parallel slots are skipped unless `includeSlots: true` (slots\n * share their parent's URL and are not addressable on their own).\n * - Intercepting subtrees are skipped unconditionally. They render only\n * on soft navigation and add no URL depth, so their computed `urlPath`s\n * are not addresses — listing them would advertise routes (`/[year]`)\n * that no request can reach. This matches every other consumer of the\n * tree that produces URLs: the sitemap generator, the static generator,\n * prerendering and the prebuilt-payload builder all skip them too.\n * - Result is sorted by `urlPath` for deterministic output.\n */\nexport function collectLeafRoutes<TFile>(\n root: SegmentNode<TFile>,\n options: CollectLeafRoutesOptions = {}\n): LeafRoute<TFile>[] {\n const { includeSlots = false } = options;\n const result: LeafRoute<TFile>[] = [];\n walk(root, [], result, includeSlots);\n result.sort((a, b) => a.urlPath.localeCompare(b.urlPath));\n return result;\n}\n\nfunction walk<TFile>(\n node: SegmentNode<TFile>,\n chain: SegmentNode<TFile>[],\n result: LeafRoute<TFile>[],\n includeSlots: boolean\n): void {\n if (node.segmentType === 'intercepting') return;\n\n const currentChain = [...chain, node];\n const path = node.urlPath || '/';\n\n if (node.page) {\n result.push({ urlPath: path, segments: currentChain, page: node.page });\n }\n if (node.route) {\n result.push({ urlPath: path, segments: currentChain, route: node.route });\n }\n\n for (const child of node.children) {\n walk(child, currentChain, result, includeSlots);\n }\n\n if (includeSlots) {\n for (const slotNode of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vB,KAAK,OAAO,cAAc,QAAQ,YAAY;CAGhD,IAAI,cACF,KAAK,MAAM,YAAY,OAAO,OAAO,KAAK,KAAK,GAC7C,KAAK,UAAU,cAAc,QAAQ,YAAY;AAGvD"}
@@ -0,0 +1,47 @@
1
+ /** One Nitro `publicAssets` entry. */
2
+ interface NitroPublicAssetDir {
3
+ dir: string;
4
+ baseURL: string;
5
+ fallthrough: false;
6
+ }
7
+ /** The Nitro config that serves `immutableDirs` from `<nitroDir>/public`. */
8
+ export interface ImmutableAssetsNitroConfig {
9
+ publicAssets: NitroPublicAssetDir[];
10
+ plugins: string[];
11
+ }
12
+ /**
13
+ * Write the generated module into `nitroDir` and return the Nitro config that
14
+ * serves the build's content-hashed directories from `<nitroDir>/public`.
15
+ *
16
+ * No `maxAge`: Nitro would turn it into a route rule (see the module header),
17
+ * and Vercel already gives a non-fallthrough directory a one-year immutable
18
+ * header on hits and `no-store` on misses by default.
19
+ */
20
+ export declare function prepareImmutableAssets(nitroDir: string, immutableDirs: readonly string[]): Promise<ImmutableAssetsNitroConfig>;
21
+ /**
22
+ * The lines timber's Nitro entry needs to answer a request under the
23
+ * content-hashed directories itself: an import, and a guard to run before
24
+ * the handler, with the h3 event in scope as `event`. Empty when the build
25
+ * has no such directories, which also means `prepareImmutableAssets()`
26
+ * writes no module to import.
27
+ */
28
+ export declare function immutableAssetsEntryGuard(immutableDirs: readonly string[]): {
29
+ imports: string;
30
+ guard: string;
31
+ };
32
+ /**
33
+ * Generate the module shared by the Nitro entry and runtime: the path matcher
34
+ * for the content-hashed directories, and the runtime plugin that owns
35
+ * Cache-Control under them — `IMMUTABLE_CACHE` on a GET or HEAD that served
36
+ * the file (200, or 304 revalidating it), `no-store` on everything else.
37
+ *
38
+ * Status is a sound signal only because the entry answers everything else
39
+ * under these directories with a 404 (see `immutableAssetsEntryGuard`). The
40
+ * prefixes are matched against the decoded path, the one Nitro's static
41
+ * handler looks the file up by.
42
+ *
43
+ * @internal Exported for testing.
44
+ */
45
+ export declare function generateImmutableAssetsModule(immutableDirs: readonly string[]): string;
46
+ export {};
47
+ //# sourceMappingURL=nitro-immutable-assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nitro-immutable-assets.d.ts","sourceRoot":"","sources":["../../src/adapters/nitro-immutable-assets.ts"],"names":[],"mappings":"AAiCA,sCAAsC;AACtC,UAAU,mBAAmB;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,KAAK,CAAC;CACpB;AAED,6EAA6E;AAC7E,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,mBAAmB,EAAE,CAAC;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,SAAS,MAAM,EAAE,GAC/B,OAAO,CAAC,0BAA0B,CAAC,CAYrC;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG;IAC3E,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAeA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CA8BtF"}
@@ -2,8 +2,9 @@
2
2
  export type PreviewScriptOptions = StaticPreviewScriptOptions | ServerPreviewScriptOptions;
3
3
  interface PreviewScriptOptionsBase {
4
4
  /**
5
- * `BuildArtifacts.immutableDirs` — served with a one-year immutable
6
- * `Cache-Control`, every other file with a revalidating one.
5
+ * `BuildArtifacts.immutableDirs` — files there are served with a one-year
6
+ * immutable `Cache-Control`, every other file with a revalidating one. In
7
+ * a server build, a miss there is a plain `no-store` 404.
7
8
  */
8
9
  immutableDirs: readonly string[];
9
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"nitro-preview.d.ts","sourceRoot":"","sources":["../../src/adapters/nitro-preview.ts"],"names":[],"mappings":"AAuEA,2EAA2E;AAC3E,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,GAAG,0BAA0B,CAAC;AAE3F,UAAU,wBAAwB;IAChC;;;OAGG;IACH,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED,oEAAoE;AACpE,MAAM,WAAW,0BAA2B,SAAQ,wBAAwB;IAC1E,MAAM,EAAE,QAAQ,CAAC;IACjB,6EAA6E;IAC7E,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAChD;AAED,iFAAiF;AACjF,MAAM,WAAW,0BAA2B,SAAQ,wBAAwB;IAC1E,MAAM,EAAE,QAAQ,CAAC;IACjB,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CA0R3E;AAED,oDAAoD;AACpD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAS7F;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAuDnD"}
1
+ {"version":3,"file":"nitro-preview.d.ts","sourceRoot":"","sources":["../../src/adapters/nitro-preview.ts"],"names":[],"mappings":"AAuEA,2EAA2E;AAC3E,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,GAAG,0BAA0B,CAAC;AAE3F,UAAU,wBAAwB;IAChC;;;;OAIG;IACH,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED,oEAAoE;AACpE,MAAM,WAAW,0BAA2B,SAAQ,wBAAwB;IAC1E,MAAM,EAAE,QAAQ,CAAC;IACjB,6EAA6E;IAC7E,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAChD;AAED,iFAAiF;AACjF,MAAM,WAAW,0BAA2B,SAAQ,wBAAwB;IAC1E,MAAM,EAAE,QAAQ,CAAC;IACjB,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAkS3E;AAED,oDAAoD;AACpD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAS7F;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAuDnD"}
@@ -1,3 +1,4 @@
1
+ import type { NitroConfig } from 'nitro/types';
1
2
  import { type NitroPreset } from './nitro-presets.ts';
2
3
  import type { TimberPlatformAdapter } from './types.ts';
3
4
  export type { NitroPreset } from './nitro-presets.ts';
@@ -42,7 +43,7 @@ export interface NitroAdapterOptions {
42
43
  * Additional Nitro configuration to merge into the generated config.
43
44
  * Overrides default values for the selected preset.
44
45
  */
45
- nitroConfig?: Record<string, unknown>;
46
+ nitroConfig?: NitroConfig;
46
47
  }
47
48
  /**
48
49
  * Create a Nitro-based adapter for multi-platform deployment.
@@ -62,7 +63,7 @@ export interface NitroAdapterOptions {
62
63
  */
63
64
  export declare function nitro(options?: NitroAdapterOptions): TimberPlatformAdapter;
64
65
  /** @internal Exported for testing. */
65
- export declare function generateNitroEntry(preset: NitroPreset, compress?: boolean): string;
66
+ export declare function generateNitroEntry(preset: NitroPreset, compress?: boolean, immutableDirs?: readonly string[]): string;
66
67
  /** @internal Exported for testing. */
67
68
  export declare function isSuppressedNitroHint(message: unknown, prefixes?: readonly string[]): boolean;
68
69
  /**
@@ -100,6 +101,19 @@ export declare function wrapNitroLoggerForBuild(logger: NitroBuildLogger, prefix
100
101
  * @internal Exported for testing.
101
102
  */
102
103
  export declare function getPostBuildHint(preset: NitroPreset): string | null;
104
+ interface NitroBuildResult {
105
+ /** Resolved output.serverDir — where the server bundle + _chunks/ live. */
106
+ serverDir: string;
107
+ }
108
+ /**
109
+ * Run the Nitro production build using the programmatic API.
110
+ * Uses dynamic import so nitro is only loaded at build time.
111
+ * Externalizes the timber RSC/SSR output — those files are pre-built
112
+ * by timber and have internal references that nitro's bundler can't follow.
113
+ *
114
+ * @internal Exported for testing.
115
+ */
116
+ export declare function runNitroBuild(nitroDir: string, preset: NitroPreset, immutableDirs: readonly string[], userConfig?: NitroConfig): Promise<NitroBuildResult>;
103
117
  /**
104
118
  * Copy prebuilt payloads into cloned Vercel function directories.
105
119
  *
@@ -1 +1 @@
1
- {"version":3,"file":"nitro.d.ts","sourceRoot":"","sources":["../../src/adapters/nitro.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAuC,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAO3F,OAAO,KAAK,EAIV,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAIpB,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAItD;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,SAAS,CAAC;AAEtD,qCAAqC;AACrC,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;OAIG;IACH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rC,MAAM,EAAE,gBAAgB,EACxB,QAAQ,GAAE,SAAS,MAAM,EAAmC,GAC3D,gBAAgB,CAAC,SAAS,CAAC,CAS7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAInE;AAED,UAAU,gBAAgB;IACxB,2EAA2E;IAC3E,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,WAAW,EACnB,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,UAAU,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAgE3B;AAGD;;;;;;;;;GASG;AACH,wBAAsB,8BAA8B,CAClD,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAcf"}
@@ -99,6 +99,104 @@ async function generateCanonicalizeModule() {
99
99
  return "// Generated by @timber-js/app — compiled from server/canonicalize.ts.\n// Do not edit — this file is regenerated on each build.\n" + result.code;
100
100
  }
101
101
  //#endregion
102
+ //#region src/adapters/nitro-immutable-assets.ts
103
+ /** The generated module, written beside the Nitro entry that imports it. */
104
+ var IMMUTABLE_ASSETS_MODULE = "_immutable-assets.mjs";
105
+ /**
106
+ * Write the generated module into `nitroDir` and return the Nitro config that
107
+ * serves the build's content-hashed directories from `<nitroDir>/public`.
108
+ *
109
+ * No `maxAge`: Nitro would turn it into a route rule (see the module header),
110
+ * and Vercel already gives a non-fallthrough directory a one-year immutable
111
+ * header on hits and `no-store` on misses by default.
112
+ */
113
+ async function prepareImmutableAssets(nitroDir, immutableDirs) {
114
+ if (immutableDirs.length === 0) return {
115
+ publicAssets: [],
116
+ plugins: []
117
+ };
118
+ const plugin = join(nitroDir, IMMUTABLE_ASSETS_MODULE);
119
+ await writeFile(plugin, generateImmutableAssetsModule(immutableDirs));
120
+ return {
121
+ publicAssets: immutableDirs.map((dir) => ({
122
+ dir: join(nitroDir, "public", dir),
123
+ baseURL: `/${dir}`,
124
+ fallthrough: false
125
+ })),
126
+ plugins: [plugin]
127
+ };
128
+ }
129
+ /**
130
+ * The lines timber's Nitro entry needs to answer a request under the
131
+ * content-hashed directories itself: an import, and a guard to run before
132
+ * the handler, with the h3 event in scope as `event`. Empty when the build
133
+ * has no such directories, which also means `prepareImmutableAssets()`
134
+ * writes no module to import.
135
+ */
136
+ function immutableAssetsEntryGuard(immutableDirs) {
137
+ if (immutableDirs.length === 0) return {
138
+ imports: "",
139
+ guard: ""
140
+ };
141
+ return {
142
+ imports: `import { isImmutableAssetPath } from './${IMMUTABLE_ASSETS_MODULE}'\n`,
143
+ guard: ` // Under a content-hashed directory only a served file may answer; the
144
+ // static handler already sent any file there is. A no-store 404, never a
145
+ // page — see _immutable-assets.mjs.
146
+ if (isImmutableAssetPath(event.url.pathname)) {
147
+ return new Response('Not Found', {
148
+ status: 404,
149
+ headers: { 'content-type': 'text/plain; charset=utf-8', 'cache-control': 'no-store' },
150
+ })
151
+ }
152
+ `
153
+ };
154
+ }
155
+ /**
156
+ * Generate the module shared by the Nitro entry and runtime: the path matcher
157
+ * for the content-hashed directories, and the runtime plugin that owns
158
+ * Cache-Control under them — `IMMUTABLE_CACHE` on a GET or HEAD that served
159
+ * the file (200, or 304 revalidating it), `no-store` on everything else.
160
+ *
161
+ * Status is a sound signal only because the entry answers everything else
162
+ * under these directories with a 404 (see `immutableAssetsEntryGuard`). The
163
+ * prefixes are matched against the decoded path, the one Nitro's static
164
+ * handler looks the file up by.
165
+ *
166
+ * @internal Exported for testing.
167
+ */
168
+ function generateImmutableAssetsModule(immutableDirs) {
169
+ const prefixes = immutableDirs.map((dir) => `/${dir}/`);
170
+ return `// Generated by @timber-js/app — Cache-Control for content-hashed directories.
171
+ // Do not edit — this file is regenerated on each build.
172
+
173
+ const PREFIXES = ${JSON.stringify(prefixes)};
174
+ const IMMUTABLE_CACHE = ${JSON.stringify(IMMUTABLE_CACHE)};
175
+
176
+ export function isImmutableAssetPath(pathname) {
177
+ let path = pathname;
178
+ try {
179
+ path = decodeURI(pathname);
180
+ } catch {
181
+ // Malformed escapes: match the path as received.
182
+ }
183
+ return PREFIXES.some((prefix) => path.startsWith(prefix));
184
+ }
185
+
186
+ export default function immutableAssets(nitroApp) {
187
+ // Hooks are off only if a user's nitroConfig disables them; files then go
188
+ // without the long-lived header rather than failing every request.
189
+ nitroApp.hooks?.hook('response', (res, event) => {
190
+ if (!isImmutableAssetPath(event.url.pathname)) return;
191
+ const method = event.req.method;
192
+ const served =
193
+ (method === 'GET' || method === 'HEAD') && (res.status === 200 || res.status === 304);
194
+ res.headers.set('Cache-Control', served ? IMMUTABLE_CACHE : 'no-store');
195
+ });
196
+ }
197
+ `;
198
+ }
199
+ //#endregion
102
200
  //#region src/adapters/nitro-presets.ts
103
201
  var PRESET_CONFIGS = {
104
202
  "vercel": {
@@ -269,7 +367,15 @@ const { sendNodeResponse } = await import('./_send-response.mjs');
269
367
  }
270
368
  res.writeHead(404, { 'Content-Type': 'text/plain' });
271
369
  res.end('Not Found');
272
- ` : ` await handleDynamic(req, res, url);
370
+ ` : ` // A request under a content-hashed directory that names no file is a
371
+ // plain no-store 404, never a render of the app — as timber's Nitro entry
372
+ // answers it in production (TIM-1578).
373
+ if (pathname !== null && IMMUTABLE_PREFIXES.some((prefix) => pathname.startsWith(prefix))) {
374
+ res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8', 'Cache-Control': 'no-store' });
375
+ res.end('Not Found');
376
+ return;
377
+ }
378
+ await handleDynamic(req, res, url);
273
379
  `;
274
380
  const dynamicHandler = options.output === "server" ? `
275
381
  async function handleDynamic(req, res, url) {
@@ -644,7 +750,7 @@ function nitro(options = {}) {
644
750
  const rscContent = await readFile(rscEntry, "utf-8");
645
751
  await writeFile(rscEntry, `${artifacts.manifestInit}\n${rscContent}`);
646
752
  }
647
- const entry = generateNitroEntry(preset, compress);
753
+ const entry = generateNitroEntry(preset, compress, artifacts.immutableDirs);
648
754
  await writeFile(join(outDir, "entry.ts"), entry);
649
755
  const { serverDir } = await runNitroBuild(outDir, preset, artifacts.immutableDirs, options.nitroConfig);
650
756
  if (artifacts.prebuilt) {
@@ -672,7 +778,7 @@ function importSpecifier(fromDir, file) {
672
778
  return path.startsWith("../") ? path : "./" + path;
673
779
  }
674
780
  /** @internal Exported for testing. */
675
- function generateNitroEntry(preset, compress = true) {
781
+ function generateNitroEntry(preset, compress = true, immutableDirs = []) {
676
782
  const serverEntryRelative = "./rsc/index.js";
677
783
  const runtimeName = PRESET_CONFIGS[preset].runtimeName;
678
784
  const earlyHints = PRESET_CONFIGS[preset].supportsEarlyHints;
@@ -710,11 +816,15 @@ function generateNitroEntry(preset, compress = true) {
710
816
  ? await runWithWaitUntil(waitUntilFn, () => handler(webRequest))
711
817
  : await handler(webRequest)`;
712
818
  else handlerCall = ` const webResponse = await handler(webRequest)`;
819
+ const waitUntilImport = supportsWaitUntil ? ", runWithWaitUntil" : "";
820
+ const compressImport = compress ? "import { compressResponse } from './_compress.mjs'\n" : "";
821
+ const compressCall = compress ? "compressResponse(webRequest, webResponse)" : "webResponse";
822
+ const immutableAssets = immutableAssetsEntryGuard(immutableDirs);
713
823
  return `// Generated by @timber-js/app/adapters/nitro
714
824
  // Do not edit — this file is regenerated on each build.
715
825
 
716
- import handler, { runWithEarlyHintsSender${supportsWaitUntil ? ", runWithWaitUntil" : ""} } from '${serverEntryRelative}'
717
- ${compress ? "import { compressResponse } from './_compress.mjs'\n" : ""}
826
+ import handler, { runWithEarlyHintsSender${waitUntilImport} } from '${serverEntryRelative}'
827
+ ${compressImport}${immutableAssets.imports}
718
828
  // Set TIMBER_RUNTIME for instrumentation.ts conditional SDK initialization.
719
829
  // See design/25-production-deployments.md §"TIMBER_RUNTIME".
720
830
  process.env.TIMBER_RUNTIME = '${runtimeName}'
@@ -725,10 +835,10 @@ process.env.TIMBER_RUNTIME = '${runtimeName}'
725
835
  // Nitro bundles h3 into its internal _libs/ directory but doesn't make
726
836
  // it available as a bare specifier in the output's node_modules.
727
837
  export default async function timberHandler(event) {
728
- // h3 v2: event.req is the Web Request
838
+ ${immutableAssets.guard} // h3 v2: event.req is the Web Request
729
839
  const webRequest = event.req
730
840
  ${handlerCall}
731
- return ${compress ? "compressResponse(webRequest, webResponse)" : "webResponse"}
841
+ return ${compressCall}
732
842
  }
733
843
  `;
734
844
  }
@@ -789,18 +899,28 @@ function wrapNitroLoggerForBuild(logger, prefixes = SUPPRESSED_NITRO_HINT_PREFIX
789
899
  function getPostBuildHint(preset) {
790
900
  return LOCALLY_PREVIEWABLE.has(preset) ? "You can preview this build using `timber preview`" : null;
791
901
  }
902
+ /**
903
+ * Run the Nitro production build using the programmatic API.
904
+ * Uses dynamic import so nitro is only loaded at build time.
905
+ * Externalizes the timber RSC/SSR output — those files are pre-built
906
+ * by timber and have internal references that nitro's bundler can't follow.
907
+ *
908
+ * @internal Exported for testing.
909
+ */
792
910
  async function runNitroBuild(nitroDir, preset, immutableDirs, userConfig) {
793
911
  const presetConfig = PRESET_CONFIGS[preset];
912
+ const immutableAssets = await prepareImmutableAssets(nitroDir, immutableDirs);
794
913
  const { createNitro, build: nitroBuild, prepare, copyPublicAssets } = await import("nitro/builder");
795
914
  const nitro = await createNitro({
796
915
  rootDir: nitroDir,
797
916
  preset: presetConfig.nitroPreset,
798
917
  renderer: { handler: join(nitroDir, "entry.ts") },
799
918
  output: { dir: join(nitroDir, presetConfig.outputDir) },
800
- routeRules: Object.fromEntries(immutableDirs.map((dir) => [`/${dir}/**`, { headers: { "Cache-Control": IMMUTABLE_CACHE } }])),
801
919
  rollupConfig: { external: [/\.\.\/rsc\//] },
802
920
  ...presetConfig.extraConfig,
803
- ...userConfig
921
+ ...userConfig,
922
+ publicAssets: [...immutableAssets.publicAssets, ...userConfig?.publicAssets ?? []],
923
+ plugins: [...immutableAssets.plugins, ...userConfig?.plugins ?? []]
804
924
  });
805
925
  const framework = nitro.options.builder === "rollup" ? void 0 : nitro.options.framework;
806
926
  const logSuccess = wrapNitroLoggerForBuild(nitro.logger, selectSuppressedHintPrefixes(framework));
@@ -834,6 +954,6 @@ async function copyPrebuiltToVercelFuncClones(functionsDir, prebuiltSrc, baseFun
834
954
  await Promise.all(funcDirs.map((dir) => cp(prebuiltSrc, join(dir, "prebuilt"), { recursive: true })));
835
955
  }
836
956
  //#endregion
837
- export { copyPrebuiltToVercelFuncClones, generateNitroEntry, getPostBuildHint, isSuppressedNitroHint, nitro, selectSuppressedHintPrefixes, wrapNitroLoggerForBuild };
957
+ export { copyPrebuiltToVercelFuncClones, generateNitroEntry, getPostBuildHint, isSuppressedNitroHint, nitro, runNitroBuild, selectSuppressedHintPrefixes, wrapNitroLoggerForBuild };
838
958
 
839
959
  //# sourceMappingURL=nitro.js.map