@timber-js/app 0.2.0-alpha.240 → 0.2.0-alpha.241

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 (333) hide show
  1. package/dist/_chunks/{actions-DIgnvDrG.js → actions-BCYVyoFl.js} +117 -11
  2. package/dist/_chunks/actions-BCYVyoFl.js.map +1 -0
  3. package/dist/_chunks/{als-registry-PPYstxK0.js → als-registry-fabsRnPY.js} +4 -2
  4. package/dist/_chunks/{als-registry-PPYstxK0.js.map → als-registry-fabsRnPY.js.map} +1 -1
  5. package/dist/_chunks/{als-slots-kbQrHTzm.js → als-slots-CVTF-AMz.js} +3 -3
  6. package/dist/_chunks/als-slots-CVTF-AMz.js.map +1 -0
  7. package/dist/_chunks/{cache-api-uWQwuxWb.js → cache-api-n5FL4wFs.js} +5 -5
  8. package/dist/_chunks/{cache-api-uWQwuxWb.js.map → cache-api-n5FL4wFs.js.map} +1 -1
  9. package/dist/_chunks/chains-DPZAMMav.js +1 -0
  10. package/dist/_chunks/{chains-C7CExrUI.js → chains-IswOWMnq.js} +2 -2
  11. package/dist/_chunks/{chains-C7CExrUI.js.map → chains-IswOWMnq.js.map} +1 -1
  12. package/dist/_chunks/{classify-Cj9EeZoL.js → classify-B08RCF6s.js} +2 -2
  13. package/dist/_chunks/{classify-Cj9EeZoL.js.map → classify-B08RCF6s.js.map} +1 -1
  14. package/dist/_chunks/{cli-check-C3QOAru7.js → cli-check-tpFb6pBU.js} +7 -6
  15. package/dist/_chunks/cli-check-tpFb6pBU.js.map +1 -0
  16. package/dist/_chunks/{cli-schema-sync-BRxZz66D.js → cli-schema-sync-C0pXBtzG.js} +1 -1
  17. package/dist/_chunks/{cli-schema-sync-DQUS_o3V.js → cli-schema-sync-DRNJutey.js} +2 -2
  18. package/dist/_chunks/{cli-schema-sync-DQUS_o3V.js.map → cli-schema-sync-DRNJutey.js.map} +1 -1
  19. package/dist/_chunks/{client-dep-entries-ZETBdLgv.js → client-dep-entries-Dw5Dvatr.js} +2 -2
  20. package/dist/_chunks/{client-dep-entries-ZETBdLgv.js.map → client-dep-entries-Dw5Dvatr.js.map} +1 -1
  21. package/dist/_chunks/{cloudflare-Dk5Hqo-O.js → cloudflare-9dbhVOxS.js} +2 -2
  22. package/dist/_chunks/{cloudflare-Dk5Hqo-O.js.map → cloudflare-9dbhVOxS.js.map} +1 -1
  23. package/dist/_chunks/{convention-lint-BoVISNS6.js → convention-lint-BfC_dAhZ.js} +364 -10
  24. package/dist/_chunks/convention-lint-BfC_dAhZ.js.map +1 -0
  25. package/dist/_chunks/dev-server-3DNTXQV-.js +1 -0
  26. package/dist/_chunks/{dev-server-C5R6jx8Q.js → dev-server-3R6Bl9_R.js} +9 -2
  27. package/dist/_chunks/dev-server-3R6Bl9_R.js.map +1 -0
  28. package/dist/_chunks/{dist-C1Rjlo6s.js → dist-GyaJm4GA.js} +18 -2
  29. package/dist/_chunks/dist-GyaJm4GA.js.map +1 -0
  30. package/dist/_chunks/{error-boundary-DB51f9ih.js → error-boundary-Dfhxigko.js} +8 -4
  31. package/dist/_chunks/error-boundary-Dfhxigko.js.map +1 -0
  32. package/dist/_chunks/{flight-source-node-D9cHBhjP.js → flight-source-node-QOpWZATb.js} +2 -2
  33. package/dist/_chunks/{flight-source-node-D9cHBhjP.js.map → flight-source-node-QOpWZATb.js.map} +1 -1
  34. package/dist/_chunks/{json-lossy-check-Y1GxqVX_.js → json-lossy-check-5KFcC1yt.js} +2 -2
  35. package/dist/_chunks/{json-lossy-check-Y1GxqVX_.js.map → json-lossy-check-5KFcC1yt.js.map} +1 -1
  36. package/dist/_chunks/{live-graph-BDQWvnMm.js → live-graph-D1dfVqoT.js} +4 -4
  37. package/dist/_chunks/{live-graph-BDQWvnMm.js.map → live-graph-D1dfVqoT.js.map} +1 -1
  38. package/dist/_chunks/{logger-DmRR9tmZ.js → logger-BvGxPd1e.js} +2 -2
  39. package/dist/_chunks/{logger-DmRR9tmZ.js.map → logger-BvGxPd1e.js.map} +1 -1
  40. package/dist/_chunks/metadata-routes-MXNjWOt5.js.map +1 -1
  41. package/dist/_chunks/{node-response-yp8zdyRp.js → node-response-D5cfiyWP.js} +2 -2
  42. package/dist/_chunks/{node-response-yp8zdyRp.js.map → node-response-D5cfiyWP.js.map} +1 -1
  43. package/dist/_chunks/{poison-scan-WQgUydF_.js → poison-scan-CX02ilxN.js} +2 -2
  44. package/dist/_chunks/{poison-scan-WQgUydF_.js.map → poison-scan-CX02ilxN.js.map} +1 -1
  45. package/dist/_chunks/{rsc-cache-key-D0cb0Gmc.js → rsc-cache-key-BGvUtMtN.js} +40 -4
  46. package/dist/_chunks/{rsc-cache-key-D0cb0Gmc.js.map → rsc-cache-key-BGvUtMtN.js.map} +1 -1
  47. package/dist/_chunks/{scanner-C9Lrf77z.js → scanner-DneYxQoY.js} +14 -81
  48. package/dist/_chunks/scanner-DneYxQoY.js.map +1 -0
  49. package/dist/_chunks/{sizeof-BISkSaU0.js → sizeof-BtQ3ErLf.js} +2 -2
  50. package/dist/_chunks/{sizeof-BISkSaU0.js.map → sizeof-BtQ3ErLf.js.map} +1 -1
  51. package/dist/_chunks/{walkers-Bxv4v7tX.js → walkers-C9R2A4jN.js} +3 -3
  52. package/dist/_chunks/{walkers-Bxv4v7tX.js.map → walkers-C9R2A4jN.js.map} +1 -1
  53. package/dist/adapters/cloudflare-dev.js +1 -1
  54. package/dist/adapters/cloudflare-kv-cache.js +2 -2
  55. package/dist/adapters/cloudflare.js +1 -1
  56. package/dist/analyze/crawl-entry.js +3 -3
  57. package/dist/analyze/graph-command.js +2 -2
  58. package/dist/cache/index.js +2 -2
  59. package/dist/cache/stores/memory.js +1 -1
  60. package/dist/cdn/workers-cache-purge.js +1 -1
  61. package/dist/cli-check.d.ts +3 -0
  62. package/dist/cli-check.d.ts.map +1 -1
  63. package/dist/cli.js +3 -3
  64. package/dist/client/error-boundary.js +1 -1
  65. package/dist/client/index.js +1 -1
  66. package/dist/client/internal.js +3 -2
  67. package/dist/client/internal.js.map +1 -1
  68. package/dist/client/navigation-commit.d.ts +5 -0
  69. package/dist/client/navigation-commit.d.ts.map +1 -1
  70. package/dist/client/outlet-content-cache.d.ts +28 -7
  71. package/dist/client/outlet-content-cache.d.ts.map +1 -1
  72. package/dist/client/router.d.ts.map +1 -1
  73. package/dist/client/segment-outlet.d.ts +3 -1
  74. package/dist/client/segment-outlet.d.ts.map +1 -1
  75. package/dist/config-types.d.ts +24 -0
  76. package/dist/config-types.d.ts.map +1 -1
  77. package/dist/config-validation.d.ts.map +1 -1
  78. package/dist/cookies/define-cookie.d.ts.map +1 -1
  79. package/dist/cookies/index.js +5 -2
  80. package/dist/cookies/index.js.map +1 -1
  81. package/dist/index.d.ts +1 -0
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +109 -25
  84. package/dist/index.js.map +1 -1
  85. package/dist/native/rsc/cookies/define-cookie.js +6 -2
  86. package/dist/native/rsc/cookies/define-cookie.js.map +1 -1
  87. package/dist/native/rsc/manifest.json +10 -0
  88. package/dist/native/rsc/routing/segment-keys.js +11 -1
  89. package/dist/native/rsc/routing/segment-keys.js.map +1 -1
  90. package/dist/native/rsc/search-params/define.js +4 -1
  91. package/dist/native/rsc/search-params/define.js.map +1 -1
  92. package/dist/native/rsc/server/als-registry.js +2 -1
  93. package/dist/native/rsc/server/als-registry.js.map +1 -1
  94. package/dist/native/rsc/server/client-state-tree.js +14 -9
  95. package/dist/native/rsc/server/client-state-tree.js.map +1 -1
  96. package/dist/native/rsc/server/cookie-context.js +12 -0
  97. package/dist/native/rsc/server/cookie-context.js.map +1 -1
  98. package/dist/native/rsc/server/flight-source.js +5 -2
  99. package/dist/native/rsc/server/flight-source.js.map +1 -1
  100. package/dist/native/rsc/server/framework-stack-frames.js +18 -0
  101. package/dist/native/rsc/server/framework-stack-frames.js.map +1 -0
  102. package/dist/native/rsc/server/prebuilt-builder.js +15 -1
  103. package/dist/native/rsc/server/prebuilt-builder.js.map +1 -1
  104. package/dist/native/rsc/server/request-context.js +10 -4
  105. package/dist/native/rsc/server/request-context.js.map +1 -1
  106. package/dist/native/rsc/server/route-element-builder.js +25 -7
  107. package/dist/native/rsc/server/route-element-builder.js.map +1 -1
  108. package/dist/native/rsc/server/route-module-loader.js +14 -6
  109. package/dist/native/rsc/server/route-module-loader.js.map +1 -1
  110. package/dist/native/rsc/server/rsc-cache-key-guard.js +5 -1
  111. package/dist/native/rsc/server/rsc-cache-key-guard.js.map +1 -1
  112. package/dist/native/rsc/server/rsc-entry/render-route.js +8 -1
  113. package/dist/native/rsc/server/rsc-entry/render-route.js.map +1 -1
  114. package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js +8 -1
  115. package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js.map +1 -1
  116. package/dist/native/rsc/server/segment-hash/outlet.js +28 -8
  117. package/dist/native/rsc/server/segment-hash/outlet.js.map +1 -1
  118. package/dist/native/rsc/server/segment-lifetime/document-outlet.js +24 -0
  119. package/dist/native/rsc/server/segment-lifetime/document-outlet.js.map +1 -0
  120. package/dist/native/rsc/server/segment-lifetime/key-digest.js +74 -0
  121. package/dist/native/rsc/server/segment-lifetime/key-digest.js.map +1 -0
  122. package/dist/native/rsc/server/segment-lifetime/read-rule.js +56 -0
  123. package/dist/native/rsc/server/segment-lifetime/read-rule.js.map +1 -0
  124. package/dist/native/rsc/server/segment-lifetime/read-scope.js +40 -0
  125. package/dist/native/rsc/server/segment-lifetime/read-scope.js.map +1 -0
  126. package/dist/native/rsc/server/segment-lifetime/segment-key.js +50 -0
  127. package/dist/native/rsc/server/segment-lifetime/segment-key.js.map +1 -0
  128. package/dist/native/rsc/server/segment-lifetime/slot-outlets.js +72 -0
  129. package/dist/native/rsc/server/segment-lifetime/slot-outlets.js.map +1 -0
  130. package/dist/native/rsc/server/slot-resolver.js +50 -26
  131. package/dist/native/rsc/server/slot-resolver.js.map +1 -1
  132. package/dist/native/rsc/server/slot-subtree-contain.js +17 -89
  133. package/dist/native/rsc/server/slot-subtree-contain.js.map +1 -1
  134. package/dist/native/rsc/server/subtree-walk.js +140 -0
  135. package/dist/native/rsc/server/subtree-walk.js.map +1 -0
  136. package/dist/native/rsc/shared/als-slots.js +2 -2
  137. package/dist/native/rsc/shared/als-slots.js.map +1 -1
  138. package/dist/native/rsc/shared/cookie-read-through.js +5 -0
  139. package/dist/native/rsc/shared/cookie-read-through.js.map +1 -0
  140. package/dist/native/rsc/shared/outlet-decision.js.map +1 -1
  141. package/dist/native/rsc/shared/route-options-export.js +8 -0
  142. package/dist/native/rsc/shared/route-options-export.js.map +1 -0
  143. package/dist/native/rsc/shared/rsc-cache-key.js +19 -3
  144. package/dist/native/rsc/shared/rsc-cache-key.js.map +1 -1
  145. package/dist/native/rsc/shims/headers.js +3 -4
  146. package/dist/native/rsc/shims/headers.js.map +1 -1
  147. package/dist/native/ssr/client/outlet-content-cache.js +17 -3
  148. package/dist/native/ssr/client/outlet-content-cache.js.map +1 -1
  149. package/dist/native/ssr/client/segment-outlet.js +3 -3
  150. package/dist/native/ssr/client/segment-outlet.js.map +1 -1
  151. package/dist/native/ssr/cookies/define-cookie.js +6 -2
  152. package/dist/native/ssr/cookies/define-cookie.js.map +1 -1
  153. package/dist/native/ssr/manifest.json +4 -0
  154. package/dist/native/ssr/search-params/define.js +4 -1
  155. package/dist/native/ssr/search-params/define.js.map +1 -1
  156. package/dist/native/ssr/server/als-registry.js +2 -1
  157. package/dist/native/ssr/server/als-registry.js.map +1 -1
  158. package/dist/native/ssr/server/client-state-tree.js +14 -9
  159. package/dist/native/ssr/server/client-state-tree.js.map +1 -1
  160. package/dist/native/ssr/server/cookie-context.js +12 -0
  161. package/dist/native/ssr/server/cookie-context.js.map +1 -1
  162. package/dist/native/ssr/server/flight-source.js +1 -0
  163. package/dist/native/ssr/server/flight-source.js.map +1 -1
  164. package/dist/native/ssr/server/framework-stack-frames.js +18 -0
  165. package/dist/native/ssr/server/framework-stack-frames.js.map +1 -0
  166. package/dist/native/ssr/server/request-context.js +10 -4
  167. package/dist/native/ssr/server/request-context.js.map +1 -1
  168. package/dist/native/ssr/server/rsc-cache-key-guard.js +5 -1
  169. package/dist/native/ssr/server/rsc-cache-key-guard.js.map +1 -1
  170. package/dist/native/ssr/server/segment-lifetime/key-digest.js +6 -0
  171. package/dist/native/ssr/server/segment-lifetime/key-digest.js.map +1 -0
  172. package/dist/native/ssr/server/segment-lifetime/read-rule.js +56 -0
  173. package/dist/native/ssr/server/segment-lifetime/read-rule.js.map +1 -0
  174. package/dist/native/ssr/shared/als-slots.js +2 -2
  175. package/dist/native/ssr/shared/als-slots.js.map +1 -1
  176. package/dist/native/ssr/shared/cookie-read-through.js +5 -0
  177. package/dist/native/ssr/shared/cookie-read-through.js.map +1 -0
  178. package/dist/native/ssr/shared/rsc-cache-key.js +19 -3
  179. package/dist/native/ssr/shared/rsc-cache-key.js.map +1 -1
  180. package/dist/native/ssr/shims/headers.js +3 -4
  181. package/dist/native/ssr/shims/headers.js.map +1 -1
  182. package/dist/plugins/callsite-jsx.d.ts +8 -1
  183. package/dist/plugins/callsite-jsx.d.ts.map +1 -1
  184. package/dist/plugins/entries.d.ts.map +1 -1
  185. package/dist/plugins/prerender-sugar.d.ts +9 -8
  186. package/dist/plugins/prerender-sugar.d.ts.map +1 -1
  187. package/dist/plugins/routing.d.ts.map +1 -1
  188. package/dist/routing/convention-lint.d.ts +11 -3
  189. package/dist/routing/convention-lint.d.ts.map +1 -1
  190. package/dist/routing/export-detect.d.ts +50 -23
  191. package/dist/routing/export-detect.d.ts.map +1 -1
  192. package/dist/routing/index.js +2 -2
  193. package/dist/routing/route-options-lint.d.ts +36 -0
  194. package/dist/routing/route-options-lint.d.ts.map +1 -0
  195. package/dist/routing/route-options.d.ts +55 -0
  196. package/dist/routing/route-options.d.ts.map +1 -0
  197. package/dist/routing/segment-keys.d.ts +35 -0
  198. package/dist/routing/segment-keys.d.ts.map +1 -1
  199. package/dist/search-params/index.js +5 -2
  200. package/dist/search-params/index.js.map +1 -1
  201. package/dist/server/als-registry.d.ts +23 -0
  202. package/dist/server/als-registry.d.ts.map +1 -1
  203. package/dist/server/client-state-tree.d.ts +10 -3
  204. package/dist/server/client-state-tree.d.ts.map +1 -1
  205. package/dist/server/cookie-context.d.ts +3 -0
  206. package/dist/server/cookie-context.d.ts.map +1 -1
  207. package/dist/server/flight-source.d.ts +4 -1
  208. package/dist/server/flight-source.d.ts.map +1 -1
  209. package/dist/server/framework-stack-frames.d.ts +23 -0
  210. package/dist/server/framework-stack-frames.d.ts.map +1 -0
  211. package/dist/server/index.d.ts +1 -0
  212. package/dist/server/index.d.ts.map +1 -1
  213. package/dist/server/index.js +2 -2
  214. package/dist/server/internal.js +105 -21
  215. package/dist/server/internal.js.map +1 -1
  216. package/dist/server/prebuilt/capture-routes.d.ts +1 -1
  217. package/dist/server/prebuilt-builder.d.ts.map +1 -1
  218. package/dist/server/request-context.d.ts +6 -1
  219. package/dist/server/request-context.d.ts.map +1 -1
  220. package/dist/server/route-element-builder.d.ts.map +1 -1
  221. package/dist/server/route-module-loader.d.ts +10 -2
  222. package/dist/server/route-module-loader.d.ts.map +1 -1
  223. package/dist/server/rsc-cache-key-guard.d.ts +3 -1
  224. package/dist/server/rsc-cache-key-guard.d.ts.map +1 -1
  225. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  226. package/dist/server/rsc-entry/render-route.d.ts +10 -0
  227. package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
  228. package/dist/server/rsc-entry/revalidate-renderer.d.ts +12 -0
  229. package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -1
  230. package/dist/server/segment-hash/outlet.d.ts +28 -0
  231. package/dist/server/segment-hash/outlet.d.ts.map +1 -1
  232. package/dist/server/segment-lifetime/document-outlet.d.ts +66 -0
  233. package/dist/server/segment-lifetime/document-outlet.d.ts.map +1 -0
  234. package/dist/server/segment-lifetime/key-digest.d.ts +46 -0
  235. package/dist/server/segment-lifetime/key-digest.d.ts.map +1 -0
  236. package/dist/server/segment-lifetime/read-rule.d.ts +43 -0
  237. package/dist/server/segment-lifetime/read-rule.d.ts.map +1 -0
  238. package/dist/server/segment-lifetime/read-scope.d.ts +39 -0
  239. package/dist/server/segment-lifetime/read-scope.d.ts.map +1 -0
  240. package/dist/server/segment-lifetime/segment-key.d.ts +60 -0
  241. package/dist/server/segment-lifetime/segment-key.d.ts.map +1 -0
  242. package/dist/server/segment-lifetime/slot-outlets.d.ts +81 -0
  243. package/dist/server/segment-lifetime/slot-outlets.d.ts.map +1 -0
  244. package/dist/server/slot-resolver.d.ts +6 -1
  245. package/dist/server/slot-resolver.d.ts.map +1 -1
  246. package/dist/server/slot-subtree-contain.d.ts +2 -6
  247. package/dist/server/slot-subtree-contain.d.ts.map +1 -1
  248. package/dist/server/subtree-walk.d.ts +56 -0
  249. package/dist/server/subtree-walk.d.ts.map +1 -0
  250. package/dist/server/types.d.ts +69 -0
  251. package/dist/server/types.d.ts.map +1 -1
  252. package/dist/shared/als-slots.d.ts +12 -2
  253. package/dist/shared/als-slots.d.ts.map +1 -1
  254. package/dist/shared/cookie-read-through.d.ts +18 -0
  255. package/dist/shared/cookie-read-through.d.ts.map +1 -0
  256. package/dist/shared/outlet-decision.d.ts +23 -4
  257. package/dist/shared/outlet-decision.d.ts.map +1 -1
  258. package/dist/shared/route-options-export.d.ts +13 -0
  259. package/dist/shared/route-options-export.d.ts.map +1 -0
  260. package/dist/shared/rsc-cache-key.d.ts +22 -0
  261. package/dist/shared/rsc-cache-key.d.ts.map +1 -1
  262. package/dist/shared/segment-info.d.ts +6 -0
  263. package/dist/shared/segment-info.d.ts.map +1 -1
  264. package/dist/shims/headers.d.ts.map +1 -1
  265. package/docs/api/30-api-server.mdx +29 -0
  266. package/docs/api/32-api-cache.mdx +10 -4
  267. package/docs/api/34-api-config.mdx +5 -0
  268. package/docs/learn/09-streaming.mdx +6 -2
  269. package/docs/learn/10-caching.mdx +10 -4
  270. package/package.json +1 -1
  271. package/src/cli-check.ts +11 -3
  272. package/src/client/navigation-commit.ts +11 -2
  273. package/src/client/outlet-content-cache.ts +40 -8
  274. package/src/client/router.ts +1 -0
  275. package/src/client/segment-outlet.tsx +10 -4
  276. package/src/config-types.ts +25 -0
  277. package/src/config-validation.ts +17 -0
  278. package/src/cookies/define-cookie.ts +5 -1
  279. package/src/index.ts +2 -1
  280. package/src/plugins/callsite-jsx.ts +104 -6
  281. package/src/plugins/entries.ts +3 -0
  282. package/src/plugins/prerender-sugar.ts +34 -18
  283. package/src/plugins/routing.ts +3 -1
  284. package/src/routing/convention-lint.ts +18 -7
  285. package/src/routing/export-detect.ts +14 -117
  286. package/src/routing/route-options-lint.ts +153 -0
  287. package/src/routing/route-options.ts +423 -0
  288. package/src/routing/segment-keys.ts +50 -0
  289. package/src/rsc-runtime/vendor-types.d.ts +4 -0
  290. package/src/search-params/define.ts +1 -1
  291. package/src/server/als-registry.ts +29 -0
  292. package/src/server/client-state-tree.ts +30 -16
  293. package/src/server/cookie-context.ts +17 -0
  294. package/src/server/flight-source.ts +7 -1
  295. package/src/server/framework-stack-frames.ts +44 -0
  296. package/src/server/index.ts +7 -0
  297. package/src/server/prebuilt/capture-routes.ts +1 -1
  298. package/src/server/prebuilt-builder.ts +30 -2
  299. package/src/server/request-context.ts +28 -4
  300. package/src/server/route-element-builder.ts +80 -5
  301. package/src/server/route-module-loader.ts +43 -10
  302. package/src/server/rsc-cache-key-guard.ts +17 -2
  303. package/src/server/rsc-entry/index.ts +16 -0
  304. package/src/server/rsc-entry/render-route.ts +19 -1
  305. package/src/server/rsc-entry/revalidate-renderer.ts +17 -1
  306. package/src/server/segment-hash/outlet.ts +62 -18
  307. package/src/server/segment-lifetime/document-outlet.ts +98 -0
  308. package/src/server/segment-lifetime/key-digest.ts +139 -0
  309. package/src/server/segment-lifetime/read-rule.ts +136 -0
  310. package/src/server/segment-lifetime/read-scope.ts +99 -0
  311. package/src/server/segment-lifetime/segment-key.ts +140 -0
  312. package/src/server/segment-lifetime/slot-outlets.ts +180 -0
  313. package/src/server/slot-resolver.ts +99 -56
  314. package/src/server/slot-subtree-contain.ts +35 -182
  315. package/src/server/subtree-walk.ts +316 -0
  316. package/src/server/types.ts +85 -0
  317. package/src/shared/als-slots.ts +19 -8
  318. package/src/shared/cookie-read-through.ts +18 -0
  319. package/src/shared/outlet-decision.ts +25 -4
  320. package/src/shared/route-options-export.ts +14 -0
  321. package/src/shared/rsc-cache-key.ts +41 -2
  322. package/src/shared/segment-info.ts +6 -0
  323. package/src/shims/headers.ts +5 -4
  324. package/dist/_chunks/actions-DIgnvDrG.js.map +0 -1
  325. package/dist/_chunks/als-slots-kbQrHTzm.js.map +0 -1
  326. package/dist/_chunks/chains-CSslTUdI.js +0 -1
  327. package/dist/_chunks/cli-check-C3QOAru7.js.map +0 -1
  328. package/dist/_chunks/convention-lint-BoVISNS6.js.map +0 -1
  329. package/dist/_chunks/dev-server-B8roKA3Q.js +0 -1
  330. package/dist/_chunks/dev-server-C5R6jx8Q.js.map +0 -1
  331. package/dist/_chunks/dist-C1Rjlo6s.js.map +0 -1
  332. package/dist/_chunks/error-boundary-DB51f9ih.js.map +0 -1
  333. package/dist/_chunks/scanner-C9Lrf77z.js.map +0 -1
@@ -106,14 +106,16 @@ Sometimes Suspense content resolves fast enough that you'd rather wait for it th
106
106
  ```tsx title="app/products/[id]/page.tsx" use="schema"
107
107
  import { Suspense } from 'react';
108
108
  import { SEGMENT_PATH } from './$segment';
109
- import { deny, getSegmentParams } from '@timber-js/app/server';
109
+ import { deny, getSegmentParams, type PageOptions } from '@timber-js/app/server';
110
110
 
111
111
  declare function getProduct(id: string): Promise<{ id: string; name: string } | null>;
112
112
  declare function ProductHeader(props: { product: { name: string } }): React.ReactElement;
113
113
  declare function ReviewsSkeleton(): React.ReactElement;
114
114
  declare function ProductReviews(props: { productId: string }): React.ReactElement;
115
115
 
116
- export const deferSuspenseFor = 200; // milliseconds
116
+ export const pageOptions = {
117
+ deferSuspenseFor: 200, // milliseconds
118
+ } satisfies PageOptions;
117
119
 
118
120
  export default async function ProductPage() {
119
121
  const { id } = getSegmentParams(SEGMENT_PATH);
@@ -133,6 +135,8 @@ export default async function ProductPage() {
133
135
 
134
136
  If reviews resolve within 200ms, they render inline — no fallback shown. If they take longer, the fallback flushes and reviews stream in when ready.
135
137
 
138
+ `deferSuspenseFor` works in a layout's `layoutOptions` too. The route holds for the longest value across its layouts and page. Parallel slots don't set the hold: `deferSuspenseFor` in a slot is a build error.
139
+
136
140
  ## Signal Promotion
137
141
 
138
142
  When `deny()` or `redirect()` fires inside a `<Suspense>` boundary:
@@ -237,23 +237,29 @@ export default async function BlogPost() {
237
237
 
238
238
  ### Route-Level Shorthand
239
239
 
240
- For fully static routes, export `prerender` instead of wrapping the component manually:
240
+ For fully static routes, set `prerender` in `pageOptions` instead of wrapping the component manually:
241
241
 
242
242
  ```ts title="app/about/page.tsx"
243
- export const prerender = true;
243
+ import type { PageOptions } from '@timber-js/app/server';
244
+
245
+ export const pageOptions = { prerender: true } satisfies PageOptions;
244
246
  ```
245
247
 
246
248
  This desugars to `cache.component(...)` around the page's default export. For dynamic routes (`[slug]`), pair it with `generateStaticSegmentParams` so the build knows which params to prerender:
247
249
 
248
250
  ```ts title="app/docs/[slug]/page.tsx"
249
- export const prerender = { ttl: 3600, tags: ['docs'] };
251
+ import type { PageOptions } from '@timber-js/app/server';
252
+
253
+ export const pageOptions = {
254
+ prerender: { ttl: 3600, tags: ['docs'] },
255
+ } satisfies PageOptions;
250
256
 
251
257
  export async function generateStaticSegmentParams() {
252
258
  return allDocs.map((d) => ({ slug: d.slug }));
253
259
  }
254
260
  ```
255
261
 
256
- Layout `prerender` cascades to descendant pages unless a closer layout or page overrides it.
262
+ `layoutOptions.prerender` on a layout cascades to descendant pages unless a closer layout or page overrides it.
257
263
 
258
264
  ### In Development
259
265
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timber-js/app",
3
- "version": "0.2.0-alpha.240",
3
+ "version": "0.2.0-alpha.241",
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,6 +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
41
 
41
42
  /** The npm package that provides tsgo. Named in the missing-tool message. */
42
43
  const TSGO_PACKAGE = '@typescript/native-preview';
@@ -142,6 +143,8 @@ export interface RouteInputs {
142
143
  root: string;
143
144
  appDir: string;
144
145
  pageExtensions: string[] | undefined;
146
+ /** Read by the route-options lint (design/53 §"App-wide default"). */
147
+ defaultLayoutLifetime: SegmentLifetime | undefined;
145
148
  }
146
149
 
147
150
  /**
@@ -157,7 +160,12 @@ export async function resolveRouteInputs(
157
160
  deps: CheckDeps = {}
158
161
  ): Promise<RouteInputs> {
159
162
  const ctx = await resolveTimberContext('check', options.viteConfigFile, deps.resolveViteConfig);
160
- return { root: ctx.root, appDir: ctx.appDir, pageExtensions: ctx.config.pageExtensions };
163
+ return {
164
+ root: ctx.root,
165
+ appDir: ctx.appDir,
166
+ pageExtensions: ctx.config.pageExtensions,
167
+ defaultLayoutLifetime: ctx.config.defaultLayoutLifetime,
168
+ };
161
169
  }
162
170
 
163
171
  /**
@@ -176,11 +184,11 @@ export async function checkRoutes(
176
184
  deps: CheckDeps = {}
177
185
  ): Promise<RouteInputs> {
178
186
  const inputs = await resolveRouteInputs(options, deps);
179
- const { root, appDir, pageExtensions } = inputs;
187
+ const { root, appDir, pageExtensions, defaultLayoutLifetime } = inputs;
180
188
 
181
189
  const tree = scanRoutes(appDir, { pageExtensions });
182
190
 
183
- const warnings = lintConventions(tree, appDir);
191
+ const warnings = lintConventions(tree, appDir, { defaultLayoutLifetime });
184
192
  const fatal = warnings.filter((w) => w.level === 'error');
185
193
  if (fatal.length > 0) {
186
194
  throw new Error(formatConventionWarnings(fatal, { color: false }));
@@ -148,6 +148,11 @@ export function createNavigationCommitter(deps: {
148
148
  * (`OutletContentCache.hashes()`). Empty outside a browser router.
149
149
  */
150
150
  outletHashes: () => Record<string, string>;
151
+ /**
152
+ * The key digests of the `'document'` segments the client holds content
153
+ * for (`OutletContentCache.documents()`). Empty outside a browser router.
154
+ */
155
+ outletDocuments: () => Record<string, string>;
151
156
  }): NavigationCommitter {
152
157
  const { segmentCache, historyStack } = deps;
153
158
 
@@ -166,7 +171,9 @@ export function createNavigationCommitter(deps: {
166
171
  *
167
172
  * Two different things travel on one header. `hashes` are the caching
168
173
  * opt-in — the segment hashes the client holds content for — and are
169
- * omitted unless `clientSegmentCache` is on (design/52).
174
+ * omitted unless `clientSegmentCache` is on (design/52). `documents` are
175
+ * the key digests of 'document' segments (design/53), sent whenever the
176
+ * client holds one.
170
177
  * `treePaths` is how the server learns which route is actually mounted,
171
178
  * which stops being derivable from the address bar as soon as a modal is
172
179
  * open — so it crosses regardless (TIM-1282). Undefined when there is
@@ -184,7 +191,9 @@ export function createNavigationCommitter(deps: {
184
191
  const hashes = deps.outletHashes();
185
192
  if (Object.keys(hashes).length > 0) tree.hashes = hashes;
186
193
  }
187
- return tree.treePaths || tree.hashes ? tree : undefined;
194
+ const documents = deps.outletDocuments();
195
+ if (Object.keys(documents).length > 0) tree.documents = documents;
196
+ return tree.treePaths || tree.hashes || tree.documents ? tree : undefined;
188
197
  },
189
198
 
190
199
  /**
@@ -1,9 +1,12 @@
1
1
  /**
2
2
  * The router-owned record of outlet content the client has *committed*, by
3
- * segment path and the hash the server advertised for it.
3
+ * segment path and the hash the server advertised for it — or, for a
4
+ * `'document'` segment (design/53-segment-lifetime.md), the key digest it
5
+ * rendered under.
4
6
  *
5
7
  * A skipped outlet renders the content it holds under the skip's hash, so
6
- * the record is content-addressed: an outlet looks up `(path, hash)`, never
8
+ * the record is content-addressed: an outlet looks up `(path, hash)` or
9
+ * `(path, digest)`, never
7
10
  * "whatever was last at this path". A stored payload replayed later, or a
8
11
  * prefetch consumed after the tree moved on, therefore either finds exactly
9
12
  * the content the server matched or finds nothing — never a newer or older
@@ -36,6 +39,8 @@ import { createGlobalContext } from './global-context.ts';
36
39
  interface Entry {
37
40
  content: ReactNode;
38
41
  hash: string | null;
42
+ /** A `'document'` segment's key digest, known when the content arrives. */
43
+ digest: string | null;
39
44
  }
40
45
 
41
46
  /**
@@ -56,10 +61,13 @@ const MAX_PATHS = 64;
56
61
  export class OutletContentCache {
57
62
  private readonly byPath = new Map<string, Entry[]>();
58
63
 
59
- /** Record content an outlet committed. Returns the entry to attach its hash to. */
60
- record(segmentPath: string, content: ReactNode): Entry {
64
+ /**
65
+ * Record content an outlet committed, with the key digest it rendered under
66
+ * if it is a `'document'` segment. Returns the entry to attach its hash to.
67
+ */
68
+ record(segmentPath: string, content: ReactNode, digest?: string): Entry {
61
69
  const entries = this.byPath.get(segmentPath) ?? [];
62
- const entry: Entry = { content, hash: null };
70
+ const entry: Entry = { content, hash: null, digest: digest ?? null };
63
71
  entries.unshift(entry);
64
72
  if (entries.length > ENTRIES_PER_PATH) entries.length = ENTRIES_PER_PATH;
65
73
  // Re-inserted, so the Map's order is least recently committed first.
@@ -87,6 +95,11 @@ export class OutletContentCache {
87
95
  return this.byPath.get(segmentPath)?.find((e) => e.hash === hash);
88
96
  }
89
97
 
98
+ /** The `'document'` content committed under `digest` at `segmentPath`, if held. */
99
+ lookupDocument(segmentPath: string, digest: string): { content: ReactNode } | undefined {
100
+ return this.byPath.get(segmentPath)?.find((e) => e.digest === digest);
101
+ }
102
+
90
103
  /**
91
104
  * What to advertise in `X-Timber-State-Tree`: per path, the hash of the
92
105
  * most recently committed content — only when it is known. A path whose
@@ -102,12 +115,31 @@ export class OutletContentCache {
102
115
  }
103
116
 
104
117
  /**
105
- * A skip committed content held at `segmentPath`: it is in use, so it moves
106
- * to the back of the eviction order.
118
+ * What to advertise as `documents` in `X-Timber-State-Tree`: per path, the
119
+ * key digest of the most recently committed content, when that content is
120
+ * a `'document'` segment's. Sent on every navigation — it is not part of
121
+ * the `clientSegmentCache` opt-in — and kept out of the `_rsc` key.
122
+ */
123
+ documents(): Record<string, string> {
124
+ const out: Record<string, string> = {};
125
+ for (const [path, entries] of this.byPath) {
126
+ const latest = entries[0];
127
+ if (latest?.digest) out[path] = latest.digest;
128
+ }
129
+ return out;
130
+ }
131
+
132
+ /**
133
+ * A skip committed the held `content` at `segmentPath`: it is on screen
134
+ * again, so it becomes the entry advertised for the path (a back navigation
135
+ * that skipped to an older version must not keep advertising the newer one
136
+ * it left), and the path moves to the back of the eviction order.
107
137
  */
108
- touch(segmentPath: string): void {
138
+ touch(segmentPath: string, content: ReactNode): void {
109
139
  const entries = this.byPath.get(segmentPath);
110
140
  if (!entries) return;
141
+ const used = entries.findIndex((e) => e.content === content);
142
+ if (used > 0) entries.unshift(...entries.splice(used, 1));
111
143
  this.byPath.delete(segmentPath);
112
144
  this.byPath.set(segmentPath, entries);
113
145
  }
@@ -57,6 +57,7 @@ export function createRouter(deps: RouterDeps): RouterInstance {
57
57
  historyStack,
58
58
  clientSegmentCache: () => deps.clientSegmentCache,
59
59
  outletHashes: () => deps.outletContentCache?.hashes() ?? {},
60
+ outletDocuments: () => deps.outletContentCache?.documents() ?? {},
60
61
  });
61
62
 
62
63
  // Ownership of the router: who is navigating, whose fetch may be cut, and
@@ -7,7 +7,9 @@
7
7
  * - **Live** — the outlet renders the content it was sent, and once React
8
8
  * commits it, records it in the router's outlet content cache beside the
9
9
  * hash the server computed from the rows that carried it.
10
- * - **Skip** — the client already holds content with this hash. The outlet
10
+ * - **Skip** — the client already holds content with this hash (or, for a
11
+ * `'document'` segment, rendered under this key digest — the server did
12
+ * not render it at all). The outlet
11
13
  * renders the cached copy, and provides the nested outlets' new decisions
12
14
  * to the outlet elements inside that copy (client/outlet-scope-context.ts),
13
15
  * so each renders its segment's new decision in place.
@@ -72,7 +74,11 @@ export function SegmentOutlet({ segmentPath, decision }: SegmentOutletProps): Re
72
74
  if (value === undefined || isCaptureHole(value)) throw staleSegmentError(segmentPath);
73
75
  const resolved = isThenable(value) ? use(value) : value;
74
76
 
75
- const cached = resolved.skip ? cache?.lookup(segmentPath, resolved.hash) : undefined;
77
+ const cached = !resolved.skip
78
+ ? undefined
79
+ : resolved.digest !== undefined
80
+ ? cache?.lookupDocument(segmentPath, resolved.digest)
81
+ : cache?.lookup(segmentPath, resolved.hash);
76
82
  if (resolved.skip && !cached) throw staleSegmentError(segmentPath);
77
83
  const content: ReactNode = resolved.skip ? cached!.content : resolved.children;
78
84
  const childScope = useMemo<OutletScope>(
@@ -88,10 +94,10 @@ export function SegmentOutlet({ segmentPath, decision }: SegmentOutletProps): Re
88
94
  useLayoutEffect(() => {
89
95
  if (cache === null) return;
90
96
  if (resolved.skip) {
91
- cache.touch(segmentPath);
97
+ cache.touch(segmentPath, content);
92
98
  return;
93
99
  }
94
- const entry = cache.record(segmentPath, content);
100
+ const entry = cache.record(segmentPath, content, resolved.digest);
95
101
  resolved.hash?.then(
96
102
  (hash) => {
97
103
  if (hash) cache.attachHash(segmentPath, entry, hash);
@@ -5,6 +5,8 @@
5
5
  * and internal plugin-context.ts can import them without circular deps.
6
6
  */
7
7
 
8
+ import type { SegmentLifetime } from './server/types.ts';
9
+
8
10
  /** Configuration for client-side JavaScript output. */
9
11
  export interface ClientJavascriptConfig {
10
12
  /** When true, no client JS bundles are emitted or referenced in HTML. */
@@ -343,6 +345,29 @@ export interface TimberUserConfig {
343
345
  * See design/52-segment-hash-dedupe.md
344
346
  */
345
347
  clientSegmentCache?: boolean;
348
+ /**
349
+ * The lifetime of every layout that does not declare one, slot layouts
350
+ * included. Pages are unaffected, and a layout's own
351
+ * `layoutOptions.lifetime` wins.
352
+ *
353
+ * `'document'` renders each layout on the document request and skips it on
354
+ * client navigations until its key changes. Every `'document'` rule
355
+ * applies: the default key is every param on the layout's path, and the
356
+ * layout may read only the request inputs in its key. Check three things
357
+ * before turning it on: a layout that reads anything else (a header, a
358
+ * cookie outside its key) throws; a layout that shows data that changes
359
+ * during a visit (a cart badge) keeps the value it had at load; and a layout
360
+ * that hides its children in its body no longer keeps them out of the
361
+ * payload, since a skip never runs it. Declare
362
+ * `layoutOptions = { lifetime: 'request' }` on those, and gate in
363
+ * `access.ts`. Layouts in and below an intercepting directory take no
364
+ * options and stay `'request'`.
365
+ *
366
+ * Default: `'request'`.
367
+ *
368
+ * See design/53-segment-lifetime.md §"App-wide default".
369
+ */
370
+ defaultLayoutLifetime?: SegmentLifetime;
346
371
  /**
347
372
  * Cache behavior configuration.
348
373
  */
@@ -57,6 +57,7 @@ const KNOWN_CONFIG_KEYS = {
57
57
  buildDir: true,
58
58
  cache: true,
59
59
  clientSegmentCache: true,
60
+ defaultLayoutLifetime: true,
60
61
  topLoader: true,
61
62
  budget: true,
62
63
  } satisfies Record<keyof TimberUserConfig, true>;
@@ -193,6 +194,22 @@ export function validateConfig(config: TimberUserConfig): ConfigError[] {
193
194
  }
194
195
  }
195
196
 
197
+ // defaultLayoutLifetime — not fatal: every reader treats a value other than
198
+ // 'document' as 'request', the default, which is slower but never wrong
199
+ // (design/53 §"App-wide default").
200
+ if (
201
+ config.defaultLayoutLifetime !== undefined &&
202
+ config.defaultLayoutLifetime !== 'request' &&
203
+ config.defaultLayoutLifetime !== 'document'
204
+ ) {
205
+ errors.push({
206
+ field: 'defaultLayoutLifetime',
207
+ message: `Invalid defaultLayoutLifetime value: ${JSON.stringify(config.defaultLayoutLifetime)}.`,
208
+ value: config.defaultLayoutLifetime,
209
+ suggestion: "Use 'request' (the default) or 'document'.",
210
+ });
211
+ }
212
+
196
213
  // devBrowserLogs
197
214
  if (config.devBrowserLogs !== undefined) {
198
215
  const valid = ['error', 'warn', 'info', 'none'];
@@ -88,6 +88,7 @@ export interface CookieDefinition<T> extends ServerOnlyCookieDefinition<T> {
88
88
  // Schema: fromSchema is a pure function — safe in all environments.
89
89
 
90
90
  import { getCookieJar } from '@timber-js/app/server';
91
+ import { COOKIE_READ_THROUGH } from '../shared/cookie-read-through.ts';
91
92
  import {
92
93
  useCookie as useRawCookie,
93
94
  getCookieValue,
@@ -184,7 +185,10 @@ export function defineCookie<T, HttpOnly extends boolean = true>(
184
185
  get(): T {
185
186
  const serverJar = tryGetServerCookieJar();
186
187
  if (serverJar) {
187
- return codec.parse(serverJar.get(name));
188
+ // Through the jar's typed read, naming this codec: a 'document'
189
+ // segment may read a keyed cookie only through its key's definition.
190
+ const readThrough = serverJar[COOKIE_READ_THROUGH];
191
+ return codec.parse(readThrough ? readThrough(name, codec) : serverJar.get(name));
188
192
  }
189
193
  // Client path
190
194
  if (isHttpOnly) {
package/src/index.ts CHANGED
@@ -79,6 +79,7 @@ export type { TimberUserConfig } from './config-types.ts';
79
79
  // root re-export is a convenience for typed metadata route handlers.
80
80
  // See design/16-metadata.md §"Metadata Routes".
81
81
  export type { Metadata, MetadataRoute, MetadataHandler, MetadataResult } from './server/types.ts';
82
+ export type { LayoutOptions, PageOptions, RoutePrerender } from './server/types.ts';
82
83
 
83
84
  /**
84
85
  * Route map interface — augmented by the generated timber-routes.d.ts.
@@ -592,7 +593,7 @@ export function timber(config?: TimberUserConfig): PluginOption[] {
592
593
  timberOptimizePackageImports(ctx), // Listed barrels → the modules that define the imported names
593
594
  timberClientInServerPackageDeps(), // Dev: a package's inner 'use client' file → its bare path, so the browser pre-bundles it
594
595
  timberCacheTransform(ctx),
595
- timberPrerenderSugar(ctx), // export const prerender → cache.component() desugaring
596
+ timberPrerenderSugar(ctx), // pageOptions/layoutOptions.prerender → cache.component() desugaring
596
597
  prebuilt, // cache.component() → __prebuilt() callsite rewrite
597
598
  timberStaticBuild(ctx), // Static mode: validate dynamic API usage
598
599
  timberContent(ctx),
@@ -12,7 +12,14 @@
12
12
  */
13
13
 
14
14
  import type { PluginContext } from '../plugin-context.ts';
15
- import type { IdentifierNode, PositionedNode, ProgramNode } from './callsite-ast.ts';
15
+ import type {
16
+ CallExpressionNode,
17
+ IdentifierNode,
18
+ ImportDeclarationNode,
19
+ MemberExpressionNode,
20
+ PositionedNode,
21
+ ProgramNode,
22
+ } from './callsite-ast.ts';
16
23
 
17
24
  interface JSXElementNode extends PositionedNode {
18
25
  type: 'JSXElement';
@@ -156,18 +163,112 @@ export function extractStaticJsxProps(
156
163
  }
157
164
 
158
165
  /**
159
- * Walk an AST tree and collect JSX usages of the given binding names,
166
+ * Extract static props from the props argument of a compiled JSX call —
167
+ * `_jsx(Embed, { url: "…", imagesFirst: true })`. The automatic runtime
168
+ * puts children in the props object and the key in the third argument, so
169
+ * the same rules as `extractStaticJsxProps` apply: a `children` prop bails
170
+ * (matching the JSX children rule), `key`/`ref` are stripped, and anything
171
+ * non-literal — spreads, computed keys, identifiers, methods — bails to null.
172
+ * A props argument that is not an object literal (`Object.assign(…)`, what
173
+ * compilers emit for spreads) is dynamic too.
174
+ */
175
+ function extractStaticCallProps(
176
+ node: PositionedNode | undefined
177
+ ): Record<string, JsonValue> | null {
178
+ if (node?.type !== 'ObjectExpression') return null;
179
+ const value = tryExtractStaticValue(node);
180
+ if (value === undefined || value === null || typeof value !== 'object' || Array.isArray(value)) {
181
+ return null;
182
+ }
183
+ if (Object.hasOwn(value, 'children')) return null;
184
+ delete value.key;
185
+ delete value.ref;
186
+ return value;
187
+ }
188
+
189
+ /** The automatic JSX runtime's element factories (react/jsx-runtime, react/jsx-dev-runtime). */
190
+ const JSX_RUNTIME_FACTORIES = new Set(['jsx', 'jsxs', 'jsxDEV']);
191
+ const JSX_RUNTIME_SOURCE = /(^|\/)jsx(-dev)?-runtime$/;
192
+
193
+ /**
194
+ * The local names under which this module imports the automatic runtime's
195
+ * factories: `factories` for `import { jsx as _jsx }`, `namespaces` for
196
+ * `import * as runtime`. Calls are matched by these bindings rather than by
197
+ * callee name, so a user function that happens to be called `jsx` is never
198
+ * read as an element.
199
+ */
200
+ function collectJsxRuntimeBindings(program: ProgramNode): {
201
+ factories: Set<string>;
202
+ namespaces: Set<string>;
203
+ } {
204
+ const factories = new Set<string>();
205
+ const namespaces = new Set<string>();
206
+ for (const stmt of program.body) {
207
+ if (stmt.type !== 'ImportDeclaration') continue;
208
+ const decl = stmt as ImportDeclarationNode;
209
+ if (!JSX_RUNTIME_SOURCE.test(decl.source.value)) continue;
210
+ for (const spec of decl.specifiers) {
211
+ if (spec.type === 'ImportNamespaceSpecifier') namespaces.add(spec.local.name);
212
+ else if (
213
+ spec.type === 'ImportSpecifier' &&
214
+ JSX_RUNTIME_FACTORIES.has(spec.imported?.name ?? '')
215
+ ) {
216
+ factories.add(spec.local.name);
217
+ }
218
+ }
219
+ }
220
+ return { factories, namespaces };
221
+ }
222
+
223
+ /**
224
+ * Walk an AST tree and collect element usages of the given binding names,
160
225
  * returning the static props for each usage. Returns a map of
161
226
  * bindingName → array of static prop objects (or null for dynamic props).
227
+ *
228
+ * Usages are found in both forms an element can take in the code being
229
+ * scanned: JSX syntax (`<Embed url="…" />`, what the transform hook sees in
230
+ * a .tsx module) and compiled automatic-runtime calls
231
+ * (`_jsx(Embed, { url: "…" })`). The second is what MDX compiles to, and
232
+ * what `generateBundle`'s module info holds for every importer — Vite has
233
+ * already compiled the JSX away by then.
162
234
  */
163
235
  export function collectJsxUsages(
164
236
  program: ProgramNode,
165
237
  bindingNames: Set<string>
166
238
  ): Map<string, Array<Record<string, JsonValue> | null>> {
167
239
  const result = new Map<string, Array<Record<string, JsonValue> | null>>();
240
+ const record = (name: string, props: Record<string, JsonValue> | null) => {
241
+ const usages = result.get(name) ?? [];
242
+ usages.push(props);
243
+ result.set(name, usages);
244
+ };
245
+ const runtime = collectJsxRuntimeBindings(program);
246
+ const isJsxFactory = (callee: PositionedNode): boolean => {
247
+ if (callee.type === 'Identifier') return runtime.factories.has((callee as IdentifierNode).name);
248
+ if (callee.type !== 'MemberExpression') return false;
249
+ const member = callee as MemberExpressionNode;
250
+ return (
251
+ !member.computed &&
252
+ member.object.type === 'Identifier' &&
253
+ runtime.namespaces.has((member.object as IdentifierNode).name) &&
254
+ member.property.type === 'Identifier' &&
255
+ JSX_RUNTIME_FACTORIES.has((member.property as IdentifierNode).name)
256
+ );
257
+ };
168
258
  const walk = (node: unknown) => {
169
259
  if (!node || typeof node !== 'object') return;
170
260
  const n = node as PositionedNode;
261
+ if (n.type === 'CallExpression') {
262
+ const call = n as CallExpressionNode;
263
+ const [type, props] = call.arguments;
264
+ if (
265
+ type?.type === 'Identifier' &&
266
+ bindingNames.has((type as IdentifierNode).name) &&
267
+ isJsxFactory(call.callee)
268
+ ) {
269
+ record((type as IdentifierNode).name, extractStaticCallProps(props));
270
+ }
271
+ }
171
272
  if (n.type === 'JSXElement') {
172
273
  const jsx = n as unknown as JSXElementNode;
173
274
  const tagName = jsx.openingElement.name;
@@ -188,10 +289,7 @@ export function collectJsxUsages(
188
289
  }
189
290
  return true;
190
291
  });
191
- const props = hasChildren ? null : extractStaticJsxProps(jsx.openingElement.attributes);
192
- const usages = result.get(name) ?? [];
193
- usages.push(props);
194
- result.set(name, usages);
292
+ record(name, hasChildren ? null : extractStaticJsxProps(jsx.openingElement.attributes));
195
293
  }
196
294
  }
197
295
  }
@@ -165,6 +165,9 @@ function generateConfigModule(ctx: PluginContext): string {
165
165
  // Null in dev mode — HMR handles code updates without full reloads.
166
166
  deploymentId: ctx.deploymentId ?? null,
167
167
  clientSegmentCache: ctx.config.clientSegmentCache ?? false,
168
+ // Read by the RSC entry only: the lifetime of a layout that declares none
169
+ // (design/53 §"App-wide default").
170
+ defaultLayoutLifetime: ctx.config.defaultLayoutLifetime === 'document' ? 'document' : 'request',
168
171
  cache: {
169
172
  strictKeyDiscipline: ctx.config.cache?.strictKeyDiscipline ?? false,
170
173
  },