@timber-js/app 0.2.0-alpha.242 → 0.2.0-alpha.244

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 (248) hide show
  1. package/dist/_chunks/{actions-BkwgRwCl.js → actions-D_LiN5xG.js} +57 -39
  2. package/dist/_chunks/actions-D_LiN5xG.js.map +1 -0
  3. package/dist/_chunks/als-registry-C-iwbtvI.js.map +1 -1
  4. package/dist/_chunks/{cache-api-BGA7c5qJ.js → cache-api-D3HmgsFh.js} +4 -4
  5. package/dist/_chunks/{cache-api-BGA7c5qJ.js.map → cache-api-D3HmgsFh.js.map} +1 -1
  6. package/dist/_chunks/{chains-Cuwwjv6T.js → chains-BpvDwp08.js} +2 -2
  7. package/dist/_chunks/{chains-Cuwwjv6T.js.map → chains-BpvDwp08.js.map} +1 -1
  8. package/dist/_chunks/chains-CjlZZ5ad.js +1 -0
  9. package/dist/_chunks/{classify-Y8S9C0Na.js → classify-Bbb_lKjH.js} +2 -2
  10. package/dist/_chunks/{classify-Y8S9C0Na.js.map → classify-Bbb_lKjH.js.map} +1 -1
  11. package/dist/_chunks/{cli-check-KeE1QaIx.js → cli-check-BE9BnXwi.js} +6 -6
  12. package/dist/_chunks/cli-check-BE9BnXwi.js.map +1 -0
  13. package/dist/_chunks/{cli-schema-sync-DZEF31wd.js → cli-schema-sync-CWkGFlYu.js} +2 -2
  14. package/dist/_chunks/{cli-schema-sync-DZEF31wd.js.map → cli-schema-sync-CWkGFlYu.js.map} +1 -1
  15. package/dist/_chunks/{cli-schema-sync-_y5O6MIg.js → cli-schema-sync-Dyvdkv_I.js} +1 -1
  16. package/dist/_chunks/{client-dep-entries-DpiwvoDi.js → client-dep-entries-Dka67elj.js} +2 -2
  17. package/dist/_chunks/{client-dep-entries-DpiwvoDi.js.map → client-dep-entries-Dka67elj.js.map} +1 -1
  18. package/dist/_chunks/{convention-lint-0AEsPK2T.js → convention-lint-DkSDlsPH.js} +38 -10
  19. package/dist/_chunks/convention-lint-DkSDlsPH.js.map +1 -0
  20. package/dist/_chunks/{dev-server-DYDr8KIc.js → dev-server-BZxFJNih.js} +68 -11
  21. package/dist/_chunks/{dev-server-DYDr8KIc.js.map → dev-server-BZxFJNih.js.map} +1 -1
  22. package/dist/_chunks/dev-server-C72bB9Kg.js +1 -0
  23. package/dist/_chunks/error-boundary-wuNvAJ4n.js.map +1 -1
  24. package/dist/_chunks/{flight-source-node-KQsX_OhS.js → flight-source-node-BeF00Wo_.js} +2 -2
  25. package/dist/_chunks/{flight-source-node-KQsX_OhS.js.map → flight-source-node-BeF00Wo_.js.map} +1 -1
  26. package/dist/_chunks/{interception-CtNt9jPt.js → interception-D1dCGNmQ.js} +6 -6
  27. package/dist/_chunks/{interception-CtNt9jPt.js.map → interception-D1dCGNmQ.js.map} +1 -1
  28. package/dist/_chunks/{json-lossy-check-BVDALqMf.js → json-lossy-check-DpXneTBm.js} +2 -2
  29. package/dist/_chunks/{json-lossy-check-BVDALqMf.js.map → json-lossy-check-DpXneTBm.js.map} +1 -1
  30. package/dist/_chunks/{key-headers-uIig1_mU.js → key-headers-CVpa6fpW.js} +6 -2
  31. package/dist/_chunks/key-headers-CVpa6fpW.js.map +1 -0
  32. package/dist/_chunks/{live-graph-VhzO7Ol9.js → live-graph-DXhz6A_X.js} +4 -4
  33. package/dist/_chunks/{live-graph-VhzO7Ol9.js.map → live-graph-DXhz6A_X.js.map} +1 -1
  34. package/dist/_chunks/{logger-C4m8rfMy.js → logger-D1sWX2I0.js} +17 -2
  35. package/dist/_chunks/logger-D1sWX2I0.js.map +1 -0
  36. package/dist/_chunks/{node-response-8Vz29cGS.js → node-response-Cp62CtH1.js} +2 -2
  37. package/dist/_chunks/{node-response-8Vz29cGS.js.map → node-response-Cp62CtH1.js.map} +1 -1
  38. package/dist/_chunks/{poison-scan-Dpl3ibG-.js → poison-scan-DdkJoHvP.js} +2 -2
  39. package/dist/_chunks/{poison-scan-Dpl3ibG-.js.map → poison-scan-DdkJoHvP.js.map} +1 -1
  40. package/dist/_chunks/{scanner-CCEHN9Jg.js → scanner-B6V2RqqF.js} +20 -3
  41. package/dist/_chunks/scanner-B6V2RqqF.js.map +1 -0
  42. package/dist/_chunks/{sizeof-CIF7fwSJ.js → sizeof-BKA6qOZq.js} +2 -2
  43. package/dist/_chunks/{sizeof-CIF7fwSJ.js.map → sizeof-BKA6qOZq.js.map} +1 -1
  44. package/dist/_chunks/{walkers-BbotBhNG.js → walkers-BAZoAlfI.js} +3 -3
  45. package/dist/_chunks/{walkers-BbotBhNG.js.map → walkers-BAZoAlfI.js.map} +1 -1
  46. package/dist/adapters/cloudflare-kv-cache.js +1 -1
  47. package/dist/analyze/crawl-entry.js +3 -3
  48. package/dist/analyze/graph-command.js +2 -2
  49. package/dist/cache/index.js +2 -2
  50. package/dist/cache/stores/memory.js +1 -1
  51. package/dist/cli-check.d.ts +3 -3
  52. package/dist/cli-check.d.ts.map +1 -1
  53. package/dist/cli.js +3 -3
  54. package/dist/client/document-withdrawal.d.ts +2 -0
  55. package/dist/client/document-withdrawal.d.ts.map +1 -0
  56. package/dist/client/outlet-content-cache.d.ts +13 -1
  57. package/dist/client/outlet-content-cache.d.ts.map +1 -1
  58. package/dist/client/outlet-scope-context.d.ts +5 -0
  59. package/dist/client/outlet-scope-context.d.ts.map +1 -1
  60. package/dist/client/segment-outlet.d.ts.map +1 -1
  61. package/dist/config-types.d.ts +43 -21
  62. package/dist/config-types.d.ts.map +1 -1
  63. package/dist/config-validation.d.ts.map +1 -1
  64. package/dist/index.d.ts +1 -1
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +9 -9
  67. package/dist/index.js.map +1 -1
  68. package/dist/native/rsc/manifest.json +2 -0
  69. package/dist/native/rsc/server/als-registry.js.map +1 -1
  70. package/dist/native/rsc/server/cookie-context.js +7 -7
  71. package/dist/native/rsc/server/cookie-context.js.map +1 -1
  72. package/dist/native/rsc/server/deny-boundary.js +2 -1
  73. package/dist/native/rsc/server/deny-boundary.js.map +1 -1
  74. package/dist/native/rsc/server/dev-overlay-report.js +13 -0
  75. package/dist/native/rsc/server/dev-overlay-report.js.map +1 -0
  76. package/dist/native/rsc/server/logger.js +6 -1
  77. package/dist/native/rsc/server/logger.js.map +1 -1
  78. package/dist/native/rsc/server/pipeline-interception.js +4 -1
  79. package/dist/native/rsc/server/pipeline-interception.js.map +1 -1
  80. package/dist/native/rsc/server/pipeline.js.map +1 -1
  81. package/dist/native/rsc/server/request-context.js +4 -4
  82. package/dist/native/rsc/server/request-context.js.map +1 -1
  83. package/dist/native/rsc/server/route-element-builder.js +1 -1
  84. package/dist/native/rsc/server/route-element-builder.js.map +1 -1
  85. package/dist/native/rsc/server/route-module-loader.js +5 -4
  86. package/dist/native/rsc/server/route-module-loader.js.map +1 -1
  87. package/dist/native/rsc/server/rsc-entry/render-route.js +1 -1
  88. package/dist/native/rsc/server/rsc-entry/render-route.js.map +1 -1
  89. package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js +1 -1
  90. package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js.map +1 -1
  91. package/dist/native/rsc/server/segment-lifetime/outlet-gate.js +2 -1
  92. package/dist/native/rsc/server/segment-lifetime/outlet-gate.js.map +1 -1
  93. package/dist/native/rsc/server/segment-lifetime/read-rule.js +31 -20
  94. package/dist/native/rsc/server/segment-lifetime/read-rule.js.map +1 -1
  95. package/dist/native/rsc/server/segment-lifetime/read-scope.js +48 -7
  96. package/dist/native/rsc/server/segment-lifetime/read-scope.js.map +1 -1
  97. package/dist/native/rsc/server/segment-lifetime/segment-key.js +13 -8
  98. package/dist/native/rsc/server/segment-lifetime/segment-key.js.map +1 -1
  99. package/dist/native/rsc/server/segment-lifetime/slot-outlets.js +5 -4
  100. package/dist/native/rsc/server/segment-lifetime/slot-outlets.js.map +1 -1
  101. package/dist/native/rsc/server/slot-resolver.js +5 -4
  102. package/dist/native/rsc/server/slot-resolver.js.map +1 -1
  103. package/dist/native/rsc/server/slot-subtree-contain.js +2 -1
  104. package/dist/native/rsc/server/slot-subtree-contain.js.map +1 -1
  105. package/dist/native/rsc/server/subtree-walk.js +14 -5
  106. package/dist/native/rsc/server/subtree-walk.js.map +1 -1
  107. package/dist/native/rsc/server/vite-handoff-rsc.js.map +1 -1
  108. package/dist/native/rsc/shared/key-headers.js +4 -1
  109. package/dist/native/rsc/shared/key-headers.js.map +1 -1
  110. package/dist/native/rsc/shared/layout-defaults.js +19 -0
  111. package/dist/native/rsc/shared/layout-defaults.js.map +1 -0
  112. package/dist/native/ssr/client/document-withdrawal.js +17 -0
  113. package/dist/native/ssr/client/document-withdrawal.js.map +1 -0
  114. package/dist/native/ssr/client/outlet-content-cache.js +6 -1
  115. package/dist/native/ssr/client/outlet-content-cache.js.map +1 -1
  116. package/dist/native/ssr/client/outlet-scope-context.js.map +1 -1
  117. package/dist/native/ssr/client/segment-outlet.js +11 -2
  118. package/dist/native/ssr/client/segment-outlet.js.map +1 -1
  119. package/dist/native/ssr/manifest.json +6 -0
  120. package/dist/native/ssr/server/als-registry.js.map +1 -1
  121. package/dist/native/ssr/server/cookie-context.js +7 -7
  122. package/dist/native/ssr/server/cookie-context.js.map +1 -1
  123. package/dist/native/ssr/server/deny-boundary.js +2 -1
  124. package/dist/native/ssr/server/deny-boundary.js.map +1 -1
  125. package/dist/native/ssr/server/dev-overlay-report.js +6 -0
  126. package/dist/native/ssr/server/dev-overlay-report.js.map +1 -0
  127. package/dist/native/ssr/server/logger.js +6 -1
  128. package/dist/native/ssr/server/logger.js.map +1 -1
  129. package/dist/native/ssr/server/pipeline-interception.js +4 -1
  130. package/dist/native/ssr/server/pipeline-interception.js.map +1 -1
  131. package/dist/native/ssr/server/pipeline.js.map +1 -1
  132. package/dist/native/ssr/server/request-context.js +4 -4
  133. package/dist/native/ssr/server/request-context.js.map +1 -1
  134. package/dist/native/ssr/server/segment-lifetime/outlet-gate.js +12 -0
  135. package/dist/native/ssr/server/segment-lifetime/outlet-gate.js.map +1 -0
  136. package/dist/native/ssr/server/segment-lifetime/read-rule.js +31 -20
  137. package/dist/native/ssr/server/segment-lifetime/read-rule.js.map +1 -1
  138. package/dist/native/ssr/server/segment-lifetime/read-scope.js +16 -0
  139. package/dist/native/ssr/server/segment-lifetime/read-scope.js.map +1 -0
  140. package/dist/native/ssr/server/subtree-walk.js +149 -0
  141. package/dist/native/ssr/server/subtree-walk.js.map +1 -0
  142. package/dist/native/ssr/server/utils/element-type.js +21 -9
  143. package/dist/native/ssr/server/utils/element-type.js.map +1 -1
  144. package/dist/native/ssr/server/vite-handoff-rsc.js.map +1 -1
  145. package/dist/native/ssr/shared/key-headers.js +4 -1
  146. package/dist/native/ssr/shared/key-headers.js.map +1 -1
  147. package/dist/native/ssr/shared/layout-defaults.js +9 -0
  148. package/dist/native/ssr/shared/layout-defaults.js.map +1 -0
  149. package/dist/plugins/entries.d.ts.map +1 -1
  150. package/dist/routing/convention-lint.d.ts +2 -2
  151. package/dist/routing/convention-lint.d.ts.map +1 -1
  152. package/dist/routing/index.js +3 -3
  153. package/dist/routing/route-options-lint.d.ts +2 -2
  154. package/dist/routing/route-options-lint.d.ts.map +1 -1
  155. package/dist/routing/slot-placement.d.ts +23 -4
  156. package/dist/routing/slot-placement.d.ts.map +1 -1
  157. package/dist/server/als-registry.d.ts +18 -0
  158. package/dist/server/als-registry.d.ts.map +1 -1
  159. package/dist/server/deny-boundary.d.ts.map +1 -1
  160. package/dist/server/dev-overlay-report.d.ts +13 -0
  161. package/dist/server/dev-overlay-report.d.ts.map +1 -0
  162. package/dist/server/index.js +2 -2
  163. package/dist/server/internal.js +97 -8
  164. package/dist/server/internal.js.map +1 -1
  165. package/dist/server/logger.d.ts +10 -0
  166. package/dist/server/logger.d.ts.map +1 -1
  167. package/dist/server/pipeline-interception.d.ts.map +1 -1
  168. package/dist/server/pipeline.d.ts +13 -1
  169. package/dist/server/pipeline.d.ts.map +1 -1
  170. package/dist/server/route-module-loader.d.ts +4 -3
  171. package/dist/server/route-module-loader.d.ts.map +1 -1
  172. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  173. package/dist/server/rsc-entry/render-route.d.ts +3 -3
  174. package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
  175. package/dist/server/rsc-entry/revalidate-renderer.d.ts +3 -3
  176. package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -1
  177. package/dist/server/segment-lifetime/outlet-gate.d.ts +5 -5
  178. package/dist/server/segment-lifetime/outlet-gate.d.ts.map +1 -1
  179. package/dist/server/segment-lifetime/read-rule.d.ts +14 -18
  180. package/dist/server/segment-lifetime/read-rule.d.ts.map +1 -1
  181. package/dist/server/segment-lifetime/read-scope.d.ts +47 -6
  182. package/dist/server/segment-lifetime/read-scope.d.ts.map +1 -1
  183. package/dist/server/segment-lifetime/segment-key.d.ts +21 -18
  184. package/dist/server/segment-lifetime/segment-key.d.ts.map +1 -1
  185. package/dist/server/segment-lifetime/slot-outlets.d.ts +3 -4
  186. package/dist/server/segment-lifetime/slot-outlets.d.ts.map +1 -1
  187. package/dist/server/slot-resolver.d.ts.map +1 -1
  188. package/dist/server/slot-subtree-contain.d.ts.map +1 -1
  189. package/dist/server/subtree-walk.d.ts +17 -3
  190. package/dist/server/subtree-walk.d.ts.map +1 -1
  191. package/dist/server/types.d.ts +4 -3
  192. package/dist/server/types.d.ts.map +1 -1
  193. package/dist/server/vite-handoff-rsc.d.ts +2 -0
  194. package/dist/server/vite-handoff-rsc.d.ts.map +1 -1
  195. package/dist/shared/key-headers.d.ts +2 -0
  196. package/dist/shared/key-headers.d.ts.map +1 -1
  197. package/dist/shared/layout-defaults.d.ts +30 -0
  198. package/dist/shared/layout-defaults.d.ts.map +1 -0
  199. package/docs/api/30-api-server.mdx +1 -1
  200. package/docs/api/34-api-config.mdx +20 -3
  201. package/package.json +1 -1
  202. package/src/cli-check.ts +6 -6
  203. package/src/client/document-withdrawal.tsx +41 -0
  204. package/src/client/outlet-content-cache.ts +18 -2
  205. package/src/client/outlet-scope-context.ts +5 -0
  206. package/src/client/segment-outlet.tsx +9 -3
  207. package/src/config-types.ts +44 -21
  208. package/src/config-validation.ts +96 -20
  209. package/src/index.ts +1 -1
  210. package/src/plugins/entries.ts +6 -3
  211. package/src/plugins/routing.ts +1 -1
  212. package/src/routing/convention-lint.ts +5 -3
  213. package/src/routing/interception.ts +5 -5
  214. package/src/routing/route-options-lint.ts +6 -6
  215. package/src/routing/slot-placement.ts +41 -4
  216. package/src/server/als-registry.ts +14 -0
  217. package/src/server/cookie-context.ts +7 -7
  218. package/src/server/deny-boundary.ts +4 -1
  219. package/src/server/dev-overlay-report.ts +22 -0
  220. package/src/server/logger.ts +13 -0
  221. package/src/server/pipeline-interception.ts +11 -2
  222. package/src/server/pipeline.ts +13 -1
  223. package/src/server/request-context.ts +6 -6
  224. package/src/server/route-element-builder.ts +3 -3
  225. package/src/server/route-module-loader.ts +7 -6
  226. package/src/server/rsc-entry/index.ts +14 -8
  227. package/src/server/rsc-entry/render-route.ts +4 -4
  228. package/src/server/rsc-entry/revalidate-renderer.ts +4 -4
  229. package/src/server/segment-lifetime/outlet-gate.ts +6 -6
  230. package/src/server/segment-lifetime/read-rule.ts +67 -33
  231. package/src/server/segment-lifetime/read-scope.ts +128 -14
  232. package/src/server/segment-lifetime/segment-key.ts +32 -24
  233. package/src/server/segment-lifetime/slot-outlets.ts +8 -12
  234. package/src/server/slot-resolver.ts +22 -10
  235. package/src/server/slot-subtree-contain.ts +2 -1
  236. package/src/server/subtree-walk.ts +34 -9
  237. package/src/server/types.ts +4 -3
  238. package/src/server/vite-handoff-rsc.ts +2 -0
  239. package/src/shared/key-headers.ts +5 -0
  240. package/src/shared/layout-defaults.ts +43 -0
  241. package/dist/_chunks/actions-BkwgRwCl.js.map +0 -1
  242. package/dist/_chunks/chains-LGjBHfSN.js +0 -1
  243. package/dist/_chunks/cli-check-KeE1QaIx.js.map +0 -1
  244. package/dist/_chunks/convention-lint-0AEsPK2T.js.map +0 -1
  245. package/dist/_chunks/dev-server-CboXr8zX.js +0 -1
  246. package/dist/_chunks/key-headers-uIig1_mU.js.map +0 -1
  247. package/dist/_chunks/logger-C4m8rfMy.js.map +0 -1
  248. package/dist/_chunks/scanner-CCEHN9Jg.js.map +0 -1
@@ -30,6 +30,7 @@ import type { StatusPageMarker } from '../client/status-page-marker.tsx';
30
30
  import type { SlotOutlet } from '../client/slot-outlet.tsx';
31
31
  import type { SlotsProvider } from '../client/slot-provider.tsx';
32
32
  import type { DenyLastResort } from '../client/deny-last-resort.tsx';
33
+ import type { DocumentWithdrawal } from '../client/document-withdrawal.tsx';
33
34
  /**
34
35
  * plugin-rsc's Flight runtime, as `rsc-runtime/rsc.ts` adapts it, typed as
35
36
  * the runtime calls it. `createFromReadableStream` is plugin-rsc's generic
@@ -59,6 +60,7 @@ export interface RscClientComponents {
59
60
  SlotOutlet: typeof SlotOutlet;
60
61
  SlotsProvider: typeof SlotsProvider;
61
62
  DenyLastResort: typeof DenyLastResort;
63
+ DocumentWithdrawal: typeof DocumentWithdrawal;
62
64
  }
63
65
  export interface RscViteHandoff {
64
66
  /** Partial so a test provides only the functions it exercises. */
@@ -1 +1 @@
1
- {"version":3,"file":"vite-handoff-rsc.d.ts","sourceRoot":"","sources":["../../src/server/vite-handoff-rsc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,KAAK,aAAa,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,iBAAiB,MAAM,mCAAmC,CAAC;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OA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F;AAsBD,kDAAkD;AAClD,wBAAgB,gBAAgB,IAAI,mBAAmB,CAEtD;AAMD,eAAO,MAAM,YAAY,EAAE,gBAAgB,CAAC,cAAc,CACvB,CAAC;AACpC,eAAO,MAAM,gBAAgB,EAAE,gBAAgB,CAAC,kBAAkB,CAC3B,CAAC;AACxC,eAAO,MAAM,WAAW,EAAE,gBAAgB,CAAC,aAAa,CACtB,CAAC;AACnC,eAAO,MAAM,YAAY,EAAE,gBAAgB,CAAC,cAAc,CACvB,CAAC;AACpC,eAAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,iBAAiB,CAC1B,CAAC;AACvC,eAAO,MAAM,wBAAwB,EAAE,gBAAgB,CAAC,0BAA0B,CACnC,CAAC;AAChD,eAAO,MAAM,OAAO,EAAE,OAAO,OAA+C,CAAC"}
@@ -6,6 +6,8 @@
6
6
  * the build cannot read every file kind (MDX pages are not linted), and a
7
7
  * credential must not become keyable by skipping the lint.
8
8
  */
9
+ /** Whether `value` has the shape of `key.headers`: an array of strings. */
10
+ export declare function isHeaderList(value: unknown): value is readonly string[];
9
11
  /** Why a key may not name `name`, or undefined when it may. */
10
12
  export declare function headerKeyProblem(name: string): string | undefined;
11
13
  /** Whether a key may never name `name` (case-insensitive): a cookie or credential header. */
@@ -1 +1 @@
1
- {"version":3,"file":"key-headers.d.ts","sourceRoot":"","sources":["../../src/shared/key-headers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAuBH,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKjE;AAED,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD"}
1
+ {"version":3,"file":"key-headers.d.ts","sourceRoot":"","sources":["../../src/shared/key-headers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAuBH,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,MAAM,EAAE,CAEvE;AAED,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKjE;AAED,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The app's layout defaults (`layoutDefaults` in `timber.config.ts`), as every
3
+ * reader takes them: the build lint (`routing/route-options-lint.ts`), the
4
+ * runtime config the RSC entry reads (`plugins/entries.ts`), and through it
5
+ * the main chain and slot layouts (`server/segment-lifetime/segment-key.ts`).
6
+ *
7
+ * See design/53-segment-lifetime.md §"App-wide defaults".
8
+ */
9
+ import type { SegmentLifetime } from '../server/types.ts';
10
+ /** What a layout takes when it declares no lifetime, or a key without `headers`. */
11
+ export interface ResolvedLayoutDefaults {
12
+ lifetime: SegmentLifetime;
13
+ /** The `key.headers` of a `'document'` layout whose key omits `headers`. */
14
+ headers: readonly string[] | undefined;
15
+ }
16
+ /**
17
+ * No defaults: what a page takes, and a layout at or below an intercepting
18
+ * directory, which could not opt out of one.
19
+ */
20
+ export declare const NO_LAYOUT_DEFAULTS: ResolvedLayoutDefaults;
21
+ /**
22
+ * Resolve the configured value. Anything config validation reports as
23
+ * malformed reads as no default: a lifetime other than `'document'` is
24
+ * `'request'`, and headers that are not an array of strings are none —
25
+ * slower, never wrong. A header the key may not name is a fatal config error
26
+ * (`config-validation.ts`), and the runtime refuses it again when it reads a
27
+ * layout's key.
28
+ */
29
+ export declare function resolveLayoutDefaults(value: unknown): ResolvedLayoutDefaults;
30
+ //# sourceMappingURL=layout-defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-defaults.d.ts","sourceRoot":"","sources":["../../src/shared/layout-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,oFAAoF;AACpF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,eAAe,CAAC;IAC1B,4EAA4E;IAC5E,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CACxC;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,sBAGhC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,sBAAsB,CAM5E"}
@@ -221,7 +221,7 @@ export const pageOptions = {
221
221
  | `prerender` | layout, page | Render at build time ([route-level sugar](/docs/api-cache#route-level-sugar)). Layouts cascade it to pages, slot pages included. |
222
222
  | `deferSuspenseFor` | layout, page | Hold the SSR stream up to N ms ([`deferSuspenseFor`](/docs/streaming#defersuspensefor)). Main route only, not parallel slots. |
223
223
 
224
- The build reads these objects from source, so write them as one object literal with literal values. The exception is `key.searchParams` and `key.cookies`, which name the definitions you import. A `key.segmentParams` name that is not on the segment's path, or a `key` on a segment that is not `'document'`, fails the build. A layout that declares no `lifetime` takes the app's [`defaultLayoutLifetime`](/docs/client-navigation#making-layouts-document-by-default), so under a `'document'` default it may declare `key` alone. A spread, a computed key, a value from a variable, an unknown key, or `layoutOptions` in a page (or the reverse) fails the build with a message naming the fix. An option where it would do nothing also fails the build: in a `'use client'` file, in `default.tsx`, on an intercepting route, or `deferSuspenseFor` in a parallel slot. `satisfies` adds editor completion and type errors; the build checks the object either way. MDX pages are not checked, and `prerender` has no effect in them. `metadata`, `searchParams` and `segmentParams` stay separate exports.
224
+ The build reads these objects from source, so write them as one object literal with literal values. The exception is `key.searchParams` and `key.cookies`, which name the definitions you import. A `key.segmentParams` name that is not on the segment's path, or a `key` on a segment that is not `'document'`, fails the build. A layout that declares no `lifetime` takes the app's [`layoutDefaults.lifetime`](/docs/client-navigation#making-layouts-document-by-default), so under a `'document'` default it may declare `key` alone. A spread, a computed key, a value from a variable, an unknown key, or `layoutOptions` in a page (or the reverse) fails the build with a message naming the fix. An option where it would do nothing also fails the build: in a `'use client'` file, in `default.tsx`, on an intercepting route, or `deferSuspenseFor` in a parallel slot. `satisfies` adds editor completion and type errors; the build checks the object either way. MDX pages are not checked, and `prerender` has no effect in them. `metadata`, `searchParams` and `segmentParams` stay separate exports.
225
225
 
226
226
  ## Tracing
227
227
 
@@ -32,7 +32,10 @@ interface TimberUserConfig {
32
32
  optimizePackageImports?: string[];
33
33
  slowRequestMs?: number;
34
34
  renderTimeoutMs?: number;
35
- defaultLayoutLifetime?: 'request' | 'document';
35
+ layoutDefaults?: {
36
+ lifetime?: 'request' | 'document';
37
+ key?: { headers?: readonly string[] };
38
+ };
36
39
  devBrowserLogs?: 'error' | 'warn' | 'info' | 'none';
37
40
  dev?: {
38
41
  slowPhaseMs?: number;
@@ -211,9 +214,23 @@ Slow request threshold in milliseconds. Requests exceeding this emit a warning v
211
214
 
212
215
  Render timeout in milliseconds. If an SSR render or RSC stream read does not complete within this duration, the render is aborted and the connection is closed. Protects against hung fetches and Suspense components that never resolve. Setting `0` uses a 120-second safety ceiling rather than disabling the timeout entirely. The same value bounds how long concurrent `timber.cache` callers wait on a shared fill, and how long static generation waits for each page.
213
216
 
214
- ### `defaultLayoutLifetime`
217
+ ### `layoutDefaults`
218
+
219
+ Defaults for every layout, slot layouts included. Pages are unaffected. Layouts in and below an intercepting directory take neither default and stay `'request'`. See [Making layouts `'document'` by default](/docs/client-navigation#making-layouts-document-by-default).
220
+
221
+ #### `layoutDefaults.lifetime`
222
+
223
+ - **Type:** `'request' | 'document'`
224
+ - **Default:** `'request'`
225
+
226
+ The lifetime of every layout that does not declare one. A layout's own `layoutOptions.lifetime` wins. Under `'document'`, a layout that reads a request input outside its key is reported (the dev overlay, or a warning in production) and renders as `'request'`, one that shows data that changes during a visit keeps its load-time value, and one that hides its children in its body no longer keeps them out of the payload.
227
+
228
+ #### `layoutDefaults.key.headers`
229
+
230
+ - **Type:** `readonly string[]`
231
+ - **Default:** none
215
232
 
216
- The lifetime of every layout that does not declare one, slot layouts included. `'request'` (the default) or `'document'`. Pages are unaffected, and a layout's own `layoutOptions.lifetime` wins. Under `'document'`, a layout that reads a request input outside its key throws, one that shows data that changes during a visit keeps its load-time value, and one that hides its children in its body no longer keeps them out of the payload. Layouts in and below an intercepting directory stay `'request'`. See [Making layouts `'document'` by default](/docs/client-navigation#making-layouts-document-by-default).
233
+ The `key.headers` of every `'document'` layout whose key does not list `headers`, whether the layout declares `'document'` or takes it from `layoutDefaults.lifetime`. Those layouts may read these headers, and render again when one changes. A layout that declares `key.headers` replaces this list. `cookie`, credential headers (`authorization`, `proxy-authorization`, `x-api-key`) and invalid header names stop the server from starting.
217
234
 
218
235
  ### `devBrowserLogs`
219
236
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timber-js/app",
3
- "version": "0.2.0-alpha.242",
3
+ "version": "0.2.0-alpha.244",
4
4
  "description": "Vite-native React framework built for Servers and Serverless Platforms — correct HTTP semantics, real status codes, pages that work without JavaScript",
5
5
  "keywords": [
6
6
  "cloudflare-workers",
package/src/cli-check.ts CHANGED
@@ -37,7 +37,7 @@ import { scanRoutes } from './routing/scanner.ts';
37
37
  import { lintConventions, formatConventionWarnings } from './routing/convention-lint.ts';
38
38
  import { writeRouteCodegen, CODEGEN_OUTPUT, ENV_DTS_FILENAME } from './routing/codegen-write.ts';
39
39
  import { resolveTimberContext, type ResolveViteConfig } from './cli-context.ts';
40
- import type { SegmentLifetime } from './server/types.ts';
40
+ import type { LayoutDefaults } from './config-types.ts';
41
41
 
42
42
  /** The npm package that provides tsgo. Named in the missing-tool message. */
43
43
  const TSGO_PACKAGE = '@typescript/native-preview';
@@ -143,8 +143,8 @@ export interface RouteInputs {
143
143
  root: string;
144
144
  appDir: string;
145
145
  pageExtensions: string[] | undefined;
146
- /** Read by the route-options lint (design/53 §"App-wide default"). */
147
- defaultLayoutLifetime: SegmentLifetime | undefined;
146
+ /** Read by the route-options lint (design/53 §"App-wide defaults"). */
147
+ layoutDefaults: LayoutDefaults | undefined;
148
148
  }
149
149
 
150
150
  /**
@@ -164,7 +164,7 @@ export async function resolveRouteInputs(
164
164
  root: ctx.root,
165
165
  appDir: ctx.appDir,
166
166
  pageExtensions: ctx.config.pageExtensions,
167
- defaultLayoutLifetime: ctx.config.defaultLayoutLifetime,
167
+ layoutDefaults: ctx.config.layoutDefaults,
168
168
  };
169
169
  }
170
170
 
@@ -184,11 +184,11 @@ export async function checkRoutes(
184
184
  deps: CheckDeps = {}
185
185
  ): Promise<RouteInputs> {
186
186
  const inputs = await resolveRouteInputs(options, deps);
187
- const { root, appDir, pageExtensions, defaultLayoutLifetime } = inputs;
187
+ const { root, appDir, pageExtensions, layoutDefaults } = inputs;
188
188
 
189
189
  const tree = scanRoutes(appDir, { pageExtensions });
190
190
 
191
- const warnings = lintConventions(tree, appDir, { defaultLayoutLifetime });
191
+ const warnings = lintConventions(tree, appDir, { layoutDefaults });
192
192
  const fatal = warnings.filter((w) => w.level === 'error');
193
193
  if (fatal.length > 0) {
194
194
  throw new Error(formatConventionWarnings(fatal, { color: false }));
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * DocumentWithdrawal — a `'document'` segment's content telling the client
5
+ * not to keep it.
6
+ *
7
+ * A `'document'` segment that reads a request input outside its key is not
8
+ * failed: the read is reported, it returns its real value, and the server
9
+ * appends this marker to the segment's content
10
+ * (`server/segment-lifetime/read-scope.ts`). The outlet's key digest was sent
11
+ * before the segment rendered, so the content has to withdraw itself.
12
+ *
13
+ * It carries no outlet path: it withdraws the nearest `SegmentOutlet` above it
14
+ * (`OutletScopeContext`), which is the outlet whose committed content holds it.
15
+ * For a marker the segment's own call placed, that is the segment's outlet.
16
+ * For one a catcher placed beside its fallback (a deny page, a slot's
17
+ * `default.tsx`), it is wherever that fallback landed — after a hoisted deny,
18
+ * an ancestor's outlet.
19
+ *
20
+ * On commit the marker withdraws that outlet from the router's outlet content
21
+ * cache: the entry is dropped and no later content is recorded for it, so
22
+ * the client never advertises a digest for it and every navigation renders
23
+ * it live — the segment is `'request'` for the rest of the document.
24
+ * A layout effect, and layout effects run child before parent: in the commit
25
+ * that brings the outlet's content, this runs before the outlet records it.
26
+ *
27
+ * Renders nothing. See design/53-segment-lifetime.md §"Reads outside the key".
28
+ */
29
+
30
+ import { useContext, useLayoutEffect } from 'react';
31
+ import { OutletContentCacheContext } from './outlet-content-cache.ts';
32
+ import { OutletScopeContext } from './outlet-scope-context.ts';
33
+
34
+ export function DocumentWithdrawal(): null {
35
+ const cache = useContext(OutletContentCacheContext);
36
+ const { segmentPath } = useContext(OutletScopeContext);
37
+ useLayoutEffect(() => {
38
+ if (segmentPath !== undefined) cache?.withdraw(segmentPath);
39
+ }, [cache, segmentPath]);
40
+ return null;
41
+ }
@@ -53,13 +53,20 @@ const MAX_PATHS = 64;
53
53
 
54
54
  export class OutletContentCache {
55
55
  private readonly byPath = new Map<string, Entry[]>();
56
+ /**
57
+ * Outlets whose content withdrew itself (`DocumentWithdrawal`): a
58
+ * `'document'` segment that read outside its key. Never
59
+ * recorded again in this document, so it renders live on every navigation.
60
+ */
61
+ private readonly withdrawn = new Set<string>();
56
62
 
57
63
  /**
58
64
  * Record content an outlet committed. Only a `'document'` segment's
59
- * content, which carries the key digest it rendered under, is kept.
65
+ * content, which carries the key digest it rendered under, is kept, and
66
+ * not a withdrawn one's.
60
67
  */
61
68
  record(segmentPath: string, content: ReactNode, digest: string | undefined): void {
62
- if (digest === undefined) return;
69
+ if (digest === undefined || this.withdrawn.has(segmentPath)) return;
63
70
  const entries = this.byPath.get(segmentPath) ?? [];
64
71
  entries.unshift({ content, digest });
65
72
  if (entries.length > ENTRIES_PER_PATH) entries.length = ENTRIES_PER_PATH;
@@ -72,6 +79,15 @@ export class OutletContentCache {
72
79
  }
73
80
  }
74
81
 
82
+ /**
83
+ * Stop holding `segmentPath` for the rest of the document: drop what is
84
+ * held and record nothing later (design/53 §"Reads outside the key").
85
+ */
86
+ withdraw(segmentPath: string): void {
87
+ this.withdrawn.add(segmentPath);
88
+ this.byPath.delete(segmentPath);
89
+ }
90
+
75
91
  /** The content committed under `digest` at `segmentPath`, if held. */
76
92
  lookup(segmentPath: string, digest: string): { content: ReactNode } | undefined {
77
93
  return this.byPath.get(segmentPath)?.find((e) => e.digest === digest);
@@ -29,6 +29,11 @@ export interface OutletScope {
29
29
  */
30
30
  skipped: boolean;
31
31
  decisions: ReadonlyMap<string, OutletDecision>;
32
+ /**
33
+ * The outlet this content belongs to: the nearest `SegmentOutlet` above.
34
+ * A `DocumentWithdrawal` marker withdraws it. Undefined outside any outlet.
35
+ */
36
+ segmentPath?: string;
32
37
  }
33
38
 
34
39
  export const LIVE_OUTLET_SCOPE: OutletScope = Object.freeze({
@@ -59,12 +59,18 @@ export function SegmentOutlet({ segmentPath, decision }: SegmentOutletProps): Re
59
59
  const cached = resolved.skip ? cache?.lookup(segmentPath, resolved.digest) : undefined;
60
60
  if (resolved.skip && !cached) throw staleSegmentError(segmentPath);
61
61
  const content: ReactNode = resolved.skip ? cached!.content : resolved.children;
62
+ // One live scope per outlet, so its identity changes only with a skip's
63
+ // new decisions (`ResetOnNewDecisions` in error-boundary.tsx reads that).
64
+ const liveScope = useMemo<OutletScope>(
65
+ () => ({ ...LIVE_OUTLET_SCOPE, segmentPath }),
66
+ [segmentPath]
67
+ );
62
68
  const childScope = useMemo<OutletScope>(
63
69
  () =>
64
70
  resolved.skip
65
- ? { skipped: true, decisions: new Map(Object.entries(resolved.outlets)) }
66
- : LIVE_OUTLET_SCOPE,
67
- [resolved]
71
+ ? { skipped: true, decisions: new Map(Object.entries(resolved.outlets)), segmentPath }
72
+ : liveScope,
73
+ [resolved, liveScope, segmentPath]
68
74
  );
69
75
 
70
76
  // Commit-time write: live content is recorded once React commits it.
@@ -18,6 +18,47 @@ export interface ClientJavascriptConfig {
18
18
  enableHMRInDev?: boolean;
19
19
  }
20
20
 
21
+ /**
22
+ * What every layout takes when it does not declare its own (`layoutDefaults`).
23
+ * An explicit subset of `LayoutOptions`: options that already apply app-wide
24
+ * from a root layout (`prerender`, `deferSuspenseFor`) are not here.
25
+ */
26
+ export interface LayoutDefaults {
27
+ /**
28
+ * The lifetime of every layout that does not declare one. A layout's own
29
+ * `layoutOptions.lifetime` wins.
30
+ *
31
+ * `'document'` renders each layout on the document request and skips it on
32
+ * client navigations until its key changes. Every `'document'` rule
33
+ * applies: the default key is every param on the layout's path (plus
34
+ * `key.headers` below), and the layout may read only the request inputs in
35
+ * its key. Check three things before turning it on: a layout that reads
36
+ * anything else (a header, a cookie outside its key) is reported (the dev
37
+ * overlay, or a warning) and renders as `'request'` for that visitor; a
38
+ * layout that shows data that changes during a visit (a cart badge) keeps
39
+ * the value it had at load; and a layout that hides its children in its
40
+ * body no longer keeps them out of the payload, since a skip never runs it.
41
+ * Declare `layoutOptions = { lifetime: 'request' }` on those, and gate in
42
+ * `access.ts`. Layouts in and below an intercepting directory take no
43
+ * options and no defaults, and stay `'request'`.
44
+ *
45
+ * Default: `'request'`.
46
+ */
47
+ lifetime?: SegmentLifetime;
48
+ key?: {
49
+ /**
50
+ * The `key.headers` of every `'document'` layout whose key does not
51
+ * declare `headers` — declared `'document'` or defaulted. A layout that
52
+ * declares `key.headers` replaces this list rather than adding to it.
53
+ * Each header in it makes those layouts re-render when its value changes,
54
+ * so name headers that are stable across a visit (`user-agent`). The
55
+ * same names are refused as in a layout's own key: `cookie`, credential
56
+ * headers and invalid names stop startup.
57
+ */
58
+ headers?: readonly string[];
59
+ };
60
+ }
61
+
21
62
  export interface TimberUserConfig {
22
63
  output?: 'server' | 'static';
23
64
  /**
@@ -329,28 +370,10 @@ export interface TimberUserConfig {
329
370
  */
330
371
  buildDir?: string;
331
372
  /**
332
- * The lifetime of every layout that does not declare one, slot layouts
333
- * included. Pages are unaffected, and a layout's own
334
- * `layoutOptions.lifetime` wins.
335
- *
336
- * `'document'` renders each layout on the document request and skips it on
337
- * client navigations until its key changes. Every `'document'` rule
338
- * applies: the default key is every param on the layout's path, and the
339
- * layout may read only the request inputs in its key. Check three things
340
- * before turning it on: a layout that reads anything else (a header, a
341
- * cookie outside its key) throws; a layout that shows data that changes
342
- * during a visit (a cart badge) keeps the value it had at load; and a layout
343
- * that hides its children in its body no longer keeps them out of the
344
- * payload, since a skip never runs it. Declare
345
- * `layoutOptions = { lifetime: 'request' }` on those, and gate in
346
- * `access.ts`. Layouts in and below an intercepting directory take no
347
- * options and stay `'request'`.
348
- *
349
- * Default: `'request'`.
350
- *
351
- * See design/53-segment-lifetime.md §"App-wide default".
373
+ * Defaults for every layout, slot layouts included. Pages are unaffected.
374
+ * See `LayoutDefaults` and design/53-segment-lifetime.md §"App-wide defaults".
352
375
  */
353
- defaultLayoutLifetime?: SegmentLifetime;
376
+ layoutDefaults?: LayoutDefaults;
354
377
  /**
355
378
  * Cache behavior configuration.
356
379
  */
@@ -9,8 +9,9 @@
9
9
  */
10
10
 
11
11
  import { createRequire } from 'node:module';
12
- import type { TimberUserConfig } from './config-types.ts';
12
+ import type { LayoutDefaults, TimberUserConfig } from './config-types.ts';
13
13
  import { devHostnameError } from './plugins/dev-hostname.ts';
14
+ import { headerKeyProblem, isHeaderList } from './shared/key-headers.ts';
14
15
  import { DEFAULT_RENDER_TIMEOUT_MS, RENDER_TIMEOUT_CEILING_MS } from './server/render-timeout.ts';
15
16
 
16
17
  // ─── Types ──────────────────────────────────────────────────────────────────
@@ -56,7 +57,7 @@ const KNOWN_CONFIG_KEYS = {
56
57
  sitemap: true,
57
58
  buildDir: true,
58
59
  cache: true,
59
- defaultLayoutLifetime: true,
60
+ layoutDefaults: true,
60
61
  topLoader: true,
61
62
  budget: true,
62
63
  } satisfies Record<keyof TimberUserConfig, true>;
@@ -193,21 +194,8 @@ export function validateConfig(config: TimberUserConfig): ConfigError[] {
193
194
  }
194
195
  }
195
196
 
196
- // defaultLayoutLifetime — not fatal: every reader treats a value other than
197
- // 'document' as 'request', the default, which is slower but never wrong
198
- // (design/53 §"App-wide default").
199
- if (
200
- config.defaultLayoutLifetime !== undefined &&
201
- config.defaultLayoutLifetime !== 'request' &&
202
- config.defaultLayoutLifetime !== 'document'
203
- ) {
204
- errors.push({
205
- field: 'defaultLayoutLifetime',
206
- message: `Invalid defaultLayoutLifetime value: ${JSON.stringify(config.defaultLayoutLifetime)}.`,
207
- value: config.defaultLayoutLifetime,
208
- suggestion: "Use 'request' (the default) or 'document'.",
209
- });
210
- }
197
+ if (config.layoutDefaults !== undefined)
198
+ errors.push(...layoutDefaultsErrors(config.layoutDefaults));
211
199
 
212
200
  // devBrowserLogs
213
201
  if (config.devBrowserLogs !== undefined) {
@@ -308,15 +296,23 @@ export function validateConfig(config: TimberUserConfig): ConfigError[] {
308
296
  }
309
297
 
310
298
  const MOVED_TO_CACHE_FILE = new Set(['cacheHandler', 'cdnPurge']);
299
+ // Removed, not aliased (design/53 §"App-wide defaults"); without this hint
300
+ // every layout would silently fall back to 'request'.
301
+ const REPLACED: Record<string, string> = {
302
+ defaultLayoutLifetime:
303
+ '"defaultLayoutLifetime" was replaced by layoutDefaults: use layoutDefaults: { lifetime: \'document\' }.',
304
+ };
311
305
 
312
306
  for (const key of Object.keys(config)) {
313
307
  if (!knownKeys.has(key)) {
314
308
  errors.push({
315
309
  field: key,
316
310
  message: `Unknown config option: "${key}".`,
317
- suggestion: MOVED_TO_CACHE_FILE.has(key)
318
- ? `"${key}" has moved to timber.cache.ts. Export cacheHandler as default, cdnPurge as a named export.`
319
- : `Check for typos. Known options: ${[...knownKeys].sort().join(', ')}.`,
311
+ suggestion: Object.hasOwn(REPLACED, key)
312
+ ? REPLACED[key]
313
+ : MOVED_TO_CACHE_FILE.has(key)
314
+ ? `"${key}" has moved to timber.cache.ts. Export cacheHandler as default, cdnPurge as a named export.`
315
+ : `Check for typos. Known options: ${[...knownKeys].sort().join(', ')}.`,
320
316
  });
321
317
  }
322
318
  }
@@ -532,3 +528,83 @@ export function formatMissingPeers(results: PeerDepResult[]): string {
532
528
 
533
529
  return lines.join('\n');
534
530
  }
531
+
532
+ // Drift-proof, like KNOWN_CONFIG_KEYS: a field added to `LayoutDefaults`
533
+ // without listing it here is a compile error, not an "unknown option" warning.
534
+ const LAYOUT_DEFAULTS_KEYS = { lifetime: true, key: true } satisfies Record<
535
+ keyof LayoutDefaults,
536
+ true
537
+ >;
538
+ const LAYOUT_DEFAULTS_KEY_PARTS = { headers: true } satisfies Record<
539
+ keyof NonNullable<LayoutDefaults['key']>,
540
+ true
541
+ >;
542
+
543
+ /**
544
+ * `layoutDefaults` (design/53 §"App-wide defaults"). A malformed shape is not
545
+ * fatal: `resolveLayoutDefaults` reads it as no default, which is slower but
546
+ * never wrong. A header the key may not name is: it would make a credential
547
+ * keyable, and readable, in every defaulted layout.
548
+ */
549
+ function layoutDefaultsErrors(defaults: unknown): ConfigError[] {
550
+ const field = 'layoutDefaults';
551
+ if (typeof defaults !== 'object' || defaults === null || Array.isArray(defaults)) {
552
+ return [{ field, message: 'layoutDefaults must be an object.', value: defaults }];
553
+ }
554
+ const errors: ConfigError[] = [];
555
+ for (const name of Object.keys(defaults)) {
556
+ if (!Object.hasOwn(LAYOUT_DEFAULTS_KEYS, name)) {
557
+ errors.push({
558
+ field: `${field}.${name}`,
559
+ message: `Unknown layoutDefaults option: ${name}.`,
560
+ suggestion:
561
+ 'layoutDefaults takes lifetime and key.headers. prerender and deferSuspenseFor ' +
562
+ 'already apply app-wide from the root layout.',
563
+ });
564
+ }
565
+ }
566
+ const lifetime = 'lifetime' in defaults ? defaults.lifetime : undefined;
567
+ if (lifetime !== undefined && lifetime !== 'request' && lifetime !== 'document') {
568
+ errors.push({
569
+ field: `${field}.lifetime`,
570
+ message: `Invalid layoutDefaults.lifetime value: ${JSON.stringify(lifetime)}.`,
571
+ value: lifetime,
572
+ suggestion: "Use 'request' (the default) or 'document'.",
573
+ });
574
+ }
575
+ const key = 'key' in defaults ? defaults.key : undefined;
576
+ if (key === undefined) return errors;
577
+ if (typeof key !== 'object' || key === null || Array.isArray(key)) {
578
+ return [...errors, { field: `${field}.key`, message: 'layoutDefaults.key must be an object.' }];
579
+ }
580
+ for (const name of Object.keys(key)) {
581
+ if (!Object.hasOwn(LAYOUT_DEFAULTS_KEY_PARTS, name)) {
582
+ errors.push({
583
+ field: `${field}.key.${name}`,
584
+ message: `layoutDefaults.key takes only headers, not ${name}.`,
585
+ suggestion:
586
+ 'Params default per path, and cookie or search-param keys belong on the layout ' +
587
+ 'that reads them.',
588
+ });
589
+ }
590
+ }
591
+ const headers = 'headers' in key ? key.headers : undefined;
592
+ if (headers === undefined) return errors;
593
+ if (!isHeaderList(headers)) {
594
+ return [
595
+ ...errors,
596
+ {
597
+ field: `${field}.key.headers`,
598
+ message: 'layoutDefaults.key.headers must be an array of header names.',
599
+ value: headers,
600
+ },
601
+ ];
602
+ }
603
+ for (const name of headers) {
604
+ const problem = headerKeyProblem(name);
605
+ if (problem) {
606
+ errors.push({ field: `${field}.key.headers`, message: problem, value: name, fatal: true });
607
+ }
608
+ }
609
+ return errors;
610
+ }
package/src/index.ts CHANGED
@@ -70,7 +70,7 @@ import {
70
70
 
71
71
  // ── Public API ────────────────────────────────────────────────────────────
72
72
 
73
- export type { TimberUserConfig } from './config-types.ts';
73
+ export type { LayoutDefaults, TimberUserConfig } from './config-types.ts';
74
74
 
75
75
  // Metadata route handler types — re-exported so user-authored metadata
76
76
  // route files (sitemap.ts, robots.ts, manifest.ts, icon.tsx, etc.) can
@@ -164,9 +164,12 @@ function generateConfigModule(ctx: PluginContext): string {
164
164
  // Per-build deployment ID for version skew detection (TIM-446).
165
165
  // Null in dev mode — HMR handles code updates without full reloads.
166
166
  deploymentId: ctx.deploymentId ?? null,
167
- // Read by the RSC entry only: the lifetime of a layout that declares none
168
- // (design/53 §"App-wide default").
169
- defaultLayoutLifetime: ctx.config.defaultLayoutLifetime === 'document' ? 'document' : 'request',
167
+ // What a layout takes when it declares no lifetime, or a key without
168
+ // headers (design/53 §"App-wide defaults"). Written in its config shape:
169
+ // the RSC entry resolves it with `resolveLayoutDefaults`, the one reader
170
+ // of that shape. It reaches the browser bundle too (the browser entry
171
+ // imports this module whole); header names are not secret.
172
+ layoutDefaults: ctx.config.layoutDefaults ?? null,
170
173
  cache: {
171
174
  strictKeyDiscipline: ctx.config.cache?.strictKeyDiscipline ?? false,
172
175
  },
@@ -115,7 +115,7 @@ export function timberRouting(ctx: PluginContext): Plugin {
115
115
  // deduplicated against `warnedFiles`: an error must not be downgraded to
116
116
  // silence by an earlier scan in the same process.
117
117
  const conventionWarnings = lintConventions(tree, ctx.appDir, {
118
- defaultLayoutLifetime: ctx.config.defaultLayoutLifetime,
118
+ layoutDefaults: ctx.config.layoutDefaults,
119
119
  });
120
120
  const fatal = conventionWarnings.filter((w) => w.level === 'error');
121
121
  if (fatal.length > 0) {
@@ -34,7 +34,8 @@ import {
34
34
  isScriptExtension,
35
35
  } from './export-detect.ts';
36
36
  import { checkRouteOptions } from './route-options-lint.ts';
37
- import type { SegmentLifetime } from '../server/types.ts';
37
+ import type { LayoutDefaults } from '../config-types.ts';
38
+ import { resolveLayoutDefaults } from '../shared/layout-defaults.ts';
38
39
 
39
40
  // ─── Types ──────────────────────────────────────────────────────────────────
40
41
 
@@ -60,7 +61,7 @@ export function lintConventions(
60
61
  tree: RouteTree,
61
62
  appDir: string,
62
63
  /** The config the checks depend on, as the build resolved it. */
63
- config: { defaultLayoutLifetime: SegmentLifetime | undefined }
64
+ config: { layoutDefaults: LayoutDefaults | undefined }
64
65
  ): ConventionWarning[] {
65
66
  const warnings: ConventionWarning[] = [];
66
67
 
@@ -103,7 +104,8 @@ export function lintConventions(
103
104
 
104
105
  // Check 10: layoutOptions / pageOptions the build cannot read, unknown
105
106
  // keys, and the removed floating exports (design/53)
106
- checkRouteOptions(tree.root, warnings, 'main', config.defaultLayoutLifetime ?? 'request');
107
+ const { lifetime } = resolveLayoutDefaults(config.layoutDefaults);
108
+ checkRouteOptions(tree.root, warnings, 'main', lifetime);
107
109
 
108
110
  return warnings;
109
111
  }
@@ -350,11 +350,11 @@ export function validateInterceptionPlacement(root: SegmentNode): void {
350
350
  * layout-bearing segment**, because those are the segments the client needs an
351
351
  * outlet and a cache node for. `buildSegmentInfo` skips the rest.
352
352
  *
353
- * For the modal shape that set is exactly the set of possible scope owners, by
354
- * construction: a slot is only resolved inside a rendering layout
355
- * (`route-element-builder.ts`), so a layoutless segment can never own one. A
356
- * children-path interception broke that equivalence — its owner is an ordinary
357
- * directory and needs no layout.
353
+ * For the modal shape that set is exactly the set of possible scope owners:
354
+ * a slot is only resolved inside its owner's layout, and `validateSlotPlacement`
355
+ * rejects a slot whose owner has none (TIM-1443). A children-path
356
+ * interception's owner is an ordinary directory rather than a slot owner, so
357
+ * that rule does not reach it — this one does.
358
358
  *
359
359
  * Left unchecked the result is a swap that works exactly once: the first soft
360
360
  * navigation renders, then the client reports no such tree path, and the next