@timber-js/app 0.2.0-alpha.186 → 0.2.0-alpha.187

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 (314) hide show
  1. package/dist/_chunks/{actions-C-Rw9vPc.js → actions-35jnMdeJ.js} +4 -3
  2. package/dist/_chunks/{actions-C-Rw9vPc.js.map → actions-35jnMdeJ.js.map} +1 -1
  3. package/dist/_chunks/als-registry-C6kcfprT.js +41 -0
  4. package/dist/_chunks/als-registry-C6kcfprT.js.map +1 -0
  5. package/dist/_chunks/{als-slots-mFweg276.js → als-slots-BEEIPKYm.js} +3 -4
  6. package/dist/_chunks/{als-slots-mFweg276.js.map → als-slots-BEEIPKYm.js.map} +1 -1
  7. package/dist/_chunks/{cache-api-Cd0VZ_Pd.js → cache-api-DjNrIWRR.js} +7 -13
  8. package/dist/_chunks/cache-api-DjNrIWRR.js.map +1 -0
  9. package/dist/_chunks/cli-check-CpmN7Nh-.js +256 -0
  10. package/dist/_chunks/cli-check-CpmN7Nh-.js.map +1 -0
  11. package/dist/_chunks/cli-schema-sync-CGMp_Psg.js +298 -0
  12. package/dist/_chunks/cli-schema-sync-CGMp_Psg.js.map +1 -0
  13. package/dist/_chunks/{cloudflare-Cs0uZXea.js → cloudflare-CGP6BZKO.js} +4 -3
  14. package/dist/_chunks/{cloudflare-Cs0uZXea.js.map → cloudflare-CGP6BZKO.js.map} +1 -1
  15. package/dist/_chunks/convention-lint-kXsgc_-7.js +784 -0
  16. package/dist/_chunks/convention-lint-kXsgc_-7.js.map +1 -0
  17. package/dist/_chunks/{error-boundary-DpYRI_I1.js → error-boundary-D-ODYX41.js} +25 -2
  18. package/dist/_chunks/error-boundary-D-ODYX41.js.map +1 -0
  19. package/dist/_chunks/file-cache-DmX7OqZP.js +454 -0
  20. package/dist/_chunks/file-cache-DmX7OqZP.js.map +1 -0
  21. package/dist/_chunks/{logger-N7e5auP0.js → logger-D8xJZXIN.js} +27 -40
  22. package/dist/_chunks/logger-D8xJZXIN.js.map +1 -0
  23. package/dist/_chunks/mdx-file-C005ay-P.js +25 -0
  24. package/dist/_chunks/mdx-file-C005ay-P.js.map +1 -0
  25. package/dist/_chunks/{plugin-context-DEGLSJs3.js → plugin-context-rCinWLiE.js} +7 -2
  26. package/dist/_chunks/{plugin-context-DEGLSJs3.js.map → plugin-context-rCinWLiE.js.map} +1 -1
  27. package/dist/_chunks/purge-store-Byr8XOjU.js +14 -0
  28. package/dist/_chunks/purge-store-Byr8XOjU.js.map +1 -0
  29. package/dist/_chunks/{resolve-schema-Dz3fcFUo.js → resolve-schema-5ma5pp1b.js} +2 -2
  30. package/dist/_chunks/{resolve-schema-Dz3fcFUo.js.map → resolve-schema-5ma5pp1b.js.map} +1 -1
  31. package/dist/_chunks/rsc-media-type-DRqE_lD_.js +46 -0
  32. package/dist/_chunks/rsc-media-type-DRqE_lD_.js.map +1 -0
  33. package/dist/_chunks/{cli-schema-sync-CKgHC2MB.js → scanner-C8b0Gcw3.js} +5 -298
  34. package/dist/_chunks/scanner-C8b0Gcw3.js.map +1 -0
  35. package/dist/_chunks/schema-bridge-Cc2Gngu1.js +199 -0
  36. package/dist/_chunks/schema-bridge-Cc2Gngu1.js.map +1 -0
  37. package/dist/_chunks/segment-classify-C539Pa2O.js.map +1 -1
  38. package/dist/_chunks/{param-value-C8TNYchQ.js → segment-context-CjOlyB8Y.js} +33 -2
  39. package/dist/_chunks/segment-context-CjOlyB8Y.js.map +1 -0
  40. package/dist/_chunks/{use-query-states-DFvWd-EA.js → use-query-states-BbU5Ge1V.js} +74 -26
  41. package/dist/_chunks/use-query-states-BbU5Ge1V.js.map +1 -0
  42. package/dist/_chunks/{navigation-root-B29qg0_T.js → use-segment-params-C4r4BD9T.js} +129 -5
  43. package/dist/_chunks/use-segment-params-C4r4BD9T.js.map +1 -0
  44. package/dist/_chunks/walkers-RzN6AFjr.js +141 -0
  45. package/dist/_chunks/walkers-RzN6AFjr.js.map +1 -0
  46. package/dist/adapters/cloudflare-dev.js +1 -1
  47. package/dist/adapters/cloudflare-kv-cache.js +1 -1
  48. package/dist/adapters/cloudflare.d.ts.map +1 -1
  49. package/dist/adapters/cloudflare.js +1 -1
  50. package/dist/adapters/compress-module.d.ts +12 -0
  51. package/dist/adapters/compress-module.d.ts.map +1 -1
  52. package/dist/adapters/nitro.js +54 -2
  53. package/dist/adapters/nitro.js.map +1 -1
  54. package/dist/cache/index.js +1 -1
  55. package/dist/cdn/cloudflare-purge.js +30 -0
  56. package/dist/cdn/cloudflare-purge.js.map +1 -0
  57. package/dist/cdn/fastly-purge.js +33 -0
  58. package/dist/cdn/fastly-purge.js.map +1 -0
  59. package/dist/cdn/index.js +94 -0
  60. package/dist/cdn/index.js.map +1 -0
  61. package/dist/cdn/workers-cache-purge.js +35 -0
  62. package/dist/cdn/workers-cache-purge.js.map +1 -0
  63. package/dist/cli-check.d.ts +153 -0
  64. package/dist/cli-check.d.ts.map +1 -0
  65. package/dist/cli.d.ts +34 -8
  66. package/dist/cli.d.ts.map +1 -1
  67. package/dist/cli.js +46 -21
  68. package/dist/cli.js.map +1 -1
  69. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -1
  70. package/dist/client/browser-entry/index.d.ts +1 -1
  71. package/dist/client/browser-entry/index.d.ts.map +1 -1
  72. package/dist/client/error-boundary.d.ts +6 -0
  73. package/dist/client/error-boundary.d.ts.map +1 -1
  74. package/dist/client/error-boundary.js +1 -1
  75. package/dist/client/index.d.ts +1 -0
  76. package/dist/client/index.d.ts.map +1 -1
  77. package/dist/client/index.js +27 -33
  78. package/dist/client/index.js.map +1 -1
  79. package/dist/client/internal.js +21 -14
  80. package/dist/client/internal.js.map +1 -1
  81. package/dist/client/link.d.ts +1 -7
  82. package/dist/client/link.d.ts.map +1 -1
  83. package/dist/client/navigation-commit.d.ts +16 -0
  84. package/dist/client/navigation-commit.d.ts.map +1 -1
  85. package/dist/client/router-pipeline.d.ts.map +1 -1
  86. package/dist/client/router.d.ts.map +1 -1
  87. package/dist/client/rsc-fetch.d.ts +9 -1
  88. package/dist/client/rsc-fetch.d.ts.map +1 -1
  89. package/dist/client/segment-cache.d.ts +8 -0
  90. package/dist/client/segment-cache.d.ts.map +1 -1
  91. package/dist/client/use-query-states.d.ts +9 -3
  92. package/dist/client/use-query-states.d.ts.map +1 -1
  93. package/dist/codec.js +1 -1
  94. package/dist/cookies/define-cookie.d.ts.map +1 -1
  95. package/dist/cookies/index.js +2 -2
  96. package/dist/cookies/index.js.map +1 -1
  97. package/dist/index.d.ts +4 -1
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +142 -477
  100. package/dist/index.js.map +1 -1
  101. package/dist/params/index.js +1 -1
  102. package/dist/plugin-context.d.ts +15 -0
  103. package/dist/plugin-context.d.ts.map +1 -1
  104. package/dist/plugins/routing.d.ts +0 -9
  105. package/dist/plugins/routing.d.ts.map +1 -1
  106. package/dist/plugins/shims.d.ts.map +1 -1
  107. package/dist/plugins/static-build.d.ts +24 -0
  108. package/dist/plugins/static-build.d.ts.map +1 -1
  109. package/dist/routing/codegen-shared.d.ts +3 -44
  110. package/dist/routing/codegen-shared.d.ts.map +1 -1
  111. package/dist/routing/codegen-types.d.ts +10 -31
  112. package/dist/routing/codegen-types.d.ts.map +1 -1
  113. package/dist/routing/codegen-write.d.ts +51 -0
  114. package/dist/routing/codegen-write.d.ts.map +1 -0
  115. package/dist/routing/codegen.d.ts.map +1 -1
  116. package/dist/routing/convention-lint.d.ts +18 -4
  117. package/dist/routing/convention-lint.d.ts.map +1 -1
  118. package/dist/routing/export-detect.d.ts +16 -0
  119. package/dist/routing/export-detect.d.ts.map +1 -1
  120. package/dist/routing/index.js +3 -2
  121. package/dist/routing/link-codegen.d.ts +19 -4
  122. package/dist/routing/link-codegen.d.ts.map +1 -1
  123. package/dist/routing/manifest-codegen.d.ts +1 -7
  124. package/dist/routing/manifest-codegen.d.ts.map +1 -1
  125. package/dist/routing/types.d.ts +0 -6
  126. package/dist/routing/types.d.ts.map +1 -1
  127. package/dist/schema-bridge.d.ts +60 -9
  128. package/dist/schema-bridge.d.ts.map +1 -1
  129. package/dist/search-params/define.d.ts +62 -8
  130. package/dist/search-params/define.d.ts.map +1 -1
  131. package/dist/search-params/index.d.ts +0 -1
  132. package/dist/search-params/index.d.ts.map +1 -1
  133. package/dist/search-params/index.js +66 -29
  134. package/dist/search-params/index.js.map +1 -1
  135. package/dist/search-params/parse-total.d.ts +70 -0
  136. package/dist/search-params/parse-total.d.ts.map +1 -0
  137. package/dist/search-params/wrappers.d.ts +26 -3
  138. package/dist/search-params/wrappers.d.ts.map +1 -1
  139. package/dist/server/access-gate.d.ts +19 -8
  140. package/dist/server/access-gate.d.ts.map +1 -1
  141. package/dist/server/action-handler.d.ts.map +1 -1
  142. package/dist/server/als-registry.d.ts +16 -0
  143. package/dist/server/als-registry.d.ts.map +1 -1
  144. package/dist/server/compress.d.ts.map +1 -1
  145. package/dist/server/deny-boundary.d.ts +148 -15
  146. package/dist/server/deny-boundary.d.ts.map +1 -1
  147. package/dist/server/deny-renderer.d.ts +2 -2
  148. package/dist/server/deny-renderer.d.ts.map +1 -1
  149. package/dist/server/error-boundary-wrapper.d.ts +85 -15
  150. package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
  151. package/dist/server/index.d.ts +0 -1
  152. package/dist/server/index.d.ts.map +1 -1
  153. package/dist/server/index.js +3 -2
  154. package/dist/server/index.js.map +1 -1
  155. package/dist/server/internal.d.ts +3 -1
  156. package/dist/server/internal.d.ts.map +1 -1
  157. package/dist/server/internal.js +343 -230
  158. package/dist/server/internal.js.map +1 -1
  159. package/dist/server/metadata-collector.d.ts +52 -0
  160. package/dist/server/metadata-collector.d.ts.map +1 -0
  161. package/dist/server/param-coercion.d.ts +12 -5
  162. package/dist/server/param-coercion.d.ts.map +1 -1
  163. package/dist/server/pipeline-helpers.d.ts.map +1 -1
  164. package/dist/server/pipeline-outcome.d.ts.map +1 -1
  165. package/dist/server/pipeline-phases.d.ts.map +1 -1
  166. package/dist/server/primitives.d.ts +23 -0
  167. package/dist/server/primitives.d.ts.map +1 -1
  168. package/dist/server/route-element-builder.d.ts +1 -12
  169. package/dist/server/route-element-builder.d.ts.map +1 -1
  170. package/dist/server/rsc-cache-key-guard.d.ts.map +1 -1
  171. package/dist/server/rsc-entry/deny-fallback.d.ts.map +1 -1
  172. package/dist/server/rsc-entry/error-renderer.d.ts +1 -1
  173. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  174. package/dist/server/rsc-entry/helpers.d.ts +0 -7
  175. package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
  176. package/dist/server/rsc-entry/index.d.ts +0 -1
  177. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  178. package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
  179. package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -1
  180. package/dist/server/rsc-entry/rsc-payload.d.ts +1 -3
  181. package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
  182. package/dist/server/rsc-entry/rsc-stream.d.ts +12 -0
  183. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  184. package/dist/server/rsc-entry/ssr-renderer.d.ts +0 -2
  185. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  186. package/dist/server/slot-resolver.d.ts.map +1 -1
  187. package/dist/server/ssr-bridge-types.d.ts +11 -0
  188. package/dist/server/ssr-bridge-types.d.ts.map +1 -1
  189. package/dist/server/ssr-entry.d.ts +0 -1
  190. package/dist/server/ssr-entry.d.ts.map +1 -1
  191. package/dist/server/static-generator.d.ts.map +1 -1
  192. package/dist/server/status-code-resolver.d.ts +8 -1
  193. package/dist/server/status-code-resolver.d.ts.map +1 -1
  194. package/dist/server/tree-builder.d.ts +28 -36
  195. package/dist/server/tree-builder.d.ts.map +1 -1
  196. package/dist/server/types.d.ts +12 -7
  197. package/dist/server/types.d.ts.map +1 -1
  198. package/dist/server/utils/element-type.d.ts +40 -0
  199. package/dist/server/utils/element-type.d.ts.map +1 -0
  200. package/dist/shared/rsc-media-type.d.ts +40 -0
  201. package/dist/shared/rsc-media-type.d.ts.map +1 -0
  202. package/docs/api/30-api-server.mdx +1 -1
  203. package/docs/api/33-api-search-params.mdx +38 -16
  204. package/docs/api/35-api-typescript.mdx +3 -3
  205. package/docs/api/36-cli.mdx +34 -7
  206. package/docs/learn/00-introduction.mdx +1 -1
  207. package/docs/learn/02-pages-and-layouts.mdx +1 -1
  208. package/docs/learn/05-typed-params.mdx +8 -8
  209. package/docs/learn/07-typed-routes.mdx +12 -7
  210. package/docs/learn/11-error-handling.mdx +16 -0
  211. package/docs/more/01-advanced-routing.mdx +1 -1
  212. package/docs/more/03-coming-from-nextjs.mdx +2 -2
  213. package/docs/more/50-ai-agent-instructions.mdx +6 -4
  214. package/package.json +8 -5
  215. package/src/adapters/cloudflare.ts +4 -1
  216. package/src/adapters/compress-module.ts +79 -1
  217. package/src/cli-check.ts +458 -0
  218. package/src/cli.ts +59 -24
  219. package/src/client/browser-entry/action-dispatch.ts +2 -1
  220. package/src/client/browser-entry/index.ts +0 -5
  221. package/src/client/error-boundary.tsx +65 -1
  222. package/src/client/index.ts +14 -3
  223. package/src/client/link.tsx +65 -64
  224. package/src/client/navigation-commit.ts +27 -4
  225. package/src/client/params-context.ts +4 -4
  226. package/src/client/router-pipeline.ts +4 -0
  227. package/src/client/router.ts +1 -0
  228. package/src/client/rsc-fetch.ts +14 -4
  229. package/src/client/segment-cache.ts +8 -0
  230. package/src/client/use-query-states.ts +102 -39
  231. package/src/cookies/define-cookie.ts +6 -1
  232. package/src/index.ts +20 -3
  233. package/src/plugin-context.ts +26 -0
  234. package/src/plugins/routing.ts +84 -146
  235. package/src/plugins/shims.ts +0 -1
  236. package/src/plugins/static-build.ts +78 -24
  237. package/src/routing/codegen-shared.ts +3 -79
  238. package/src/routing/codegen-types.ts +10 -31
  239. package/src/routing/codegen-write.ts +139 -0
  240. package/src/routing/codegen.ts +56 -182
  241. package/src/routing/convention-lint.ts +139 -40
  242. package/src/routing/export-detect.ts +151 -7
  243. package/src/routing/link-codegen.ts +32 -65
  244. package/src/routing/manifest-codegen.ts +1 -59
  245. package/src/routing/scanner.ts +3 -3
  246. package/src/routing/types.ts +0 -6
  247. package/src/schema-bridge.ts +180 -58
  248. package/src/search-params/define.ts +102 -37
  249. package/src/search-params/index.ts +0 -1
  250. package/src/search-params/parse-total.ts +78 -0
  251. package/src/search-params/wrappers.ts +60 -11
  252. package/src/server/access-gate.tsx +60 -40
  253. package/src/server/action-handler.ts +1 -4
  254. package/src/server/als-registry.ts +16 -0
  255. package/src/server/compress.ts +9 -1
  256. package/src/server/deny-boundary.ts +269 -41
  257. package/src/server/deny-renderer.ts +32 -21
  258. package/src/server/error-boundary-wrapper.ts +166 -79
  259. package/src/server/index.ts +1 -3
  260. package/src/server/internal.ts +2 -2
  261. package/src/server/metadata-collector.ts +115 -0
  262. package/src/server/param-coercion.ts +13 -61
  263. package/src/server/pipeline-helpers.ts +2 -2
  264. package/src/server/pipeline-outcome.ts +2 -1
  265. package/src/server/pipeline-phases.ts +9 -9
  266. package/src/server/primitives.ts +25 -0
  267. package/src/server/route-element-builder.ts +167 -170
  268. package/src/server/rsc-cache-key-guard.ts +2 -8
  269. package/src/server/rsc-entry/deny-fallback.ts +3 -2
  270. package/src/server/rsc-entry/error-renderer.ts +31 -11
  271. package/src/server/rsc-entry/helpers.ts +2 -12
  272. package/src/server/rsc-entry/index.ts +0 -5
  273. package/src/server/rsc-entry/render-route.ts +14 -11
  274. package/src/server/rsc-entry/revalidate-renderer.ts +2 -1
  275. package/src/server/rsc-entry/rsc-payload.ts +104 -20
  276. package/src/server/rsc-entry/rsc-stream.ts +25 -2
  277. package/src/server/rsc-entry/ssr-renderer.ts +28 -16
  278. package/src/server/slot-resolver.ts +10 -2
  279. package/src/server/ssr-bridge-types.ts +12 -0
  280. package/src/server/ssr-entry.ts +8 -6
  281. package/src/server/static-generator.ts +3 -2
  282. package/src/server/status-code-resolver.ts +28 -11
  283. package/src/server/tree-builder.ts +35 -218
  284. package/src/server/types.ts +12 -7
  285. package/src/server/utils/element-type.ts +72 -0
  286. package/src/shared/rsc-media-type.ts +43 -0
  287. package/dist/_chunks/cache-api-Cd0VZ_Pd.js.map +0 -1
  288. package/dist/_chunks/cli-schema-sync-CKgHC2MB.js.map +0 -1
  289. package/dist/_chunks/error-boundary-DpYRI_I1.js.map +0 -1
  290. package/dist/_chunks/logger-N7e5auP0.js.map +0 -1
  291. package/dist/_chunks/navigation-root-B29qg0_T.js.map +0 -1
  292. package/dist/_chunks/param-value-C8TNYchQ.js.map +0 -1
  293. package/dist/_chunks/registry-DbJPKoBp.js +0 -20
  294. package/dist/_chunks/registry-DbJPKoBp.js.map +0 -1
  295. package/dist/_chunks/schema-bridge-DT_Tn0Xf.js +0 -119
  296. package/dist/_chunks/schema-bridge-DT_Tn0Xf.js.map +0 -1
  297. package/dist/_chunks/segment-context-ZDnXDkbz.js +0 -34
  298. package/dist/_chunks/segment-context-ZDnXDkbz.js.map +0 -1
  299. package/dist/_chunks/use-query-states-DFvWd-EA.js.map +0 -1
  300. package/dist/_chunks/use-segment-params-ClyUNq4d.js +0 -128
  301. package/dist/_chunks/use-segment-params-ClyUNq4d.js.map +0 -1
  302. package/dist/_chunks/walkers-BhhwI9TD.js +0 -936
  303. package/dist/_chunks/walkers-BhhwI9TD.js.map +0 -1
  304. package/dist/search-params/registry.d.ts +0 -20
  305. package/dist/search-params/registry.d.ts.map +0 -1
  306. package/dist/segment-params/define.d.ts +0 -83
  307. package/dist/segment-params/define.d.ts.map +0 -1
  308. package/dist/segment-params/index.d.ts +0 -3
  309. package/dist/segment-params/index.d.ts.map +0 -1
  310. package/dist/segment-params/index.js +0 -70
  311. package/dist/segment-params/index.js.map +0 -1
  312. package/src/search-params/registry.ts +0 -31
  313. package/src/segment-params/define.ts +0 -226
  314. package/src/segment-params/index.ts +0 -9
@@ -17,18 +17,29 @@ import type { ReactNode } from 'react';
17
17
  /**
18
18
  * Framework-injected access gate for segments.
19
19
  *
20
- * When a pre-computed `verdict` prop is provided (from the pre-render pass
21
- * in route-element-builder.ts), AccessGate replays it synchronously — no
22
- * async, no re-execution of access.ts, immune to Suspense timing. The OTEL
23
- * span was already emitted during the pre-render pass.
24
- *
25
- * When no verdict is provided (backward compat with tree-builder.ts),
26
- * AccessGate calls accessFn directly with OTEL instrumentation.
20
+ * Calls accessFn during render — inside `renderToReadableStream`, sharing
21
+ * the same `React.cache` scope as layouts and pages. A `requireUser()`
22
+ * call in access.ts populates the cache; the same call in any layout is
23
+ * a free hit. Access executes exactly once per request. See TIM-1363.
27
24
  *
28
25
  * access.ts is a pure gate — return values are discarded. The layout below
29
26
  * gets the same data by calling the same cached functions (React.cache dedup).
27
+ *
28
+ * On denial the gate renders the matching deny page only when this segment
29
+ * owns it. Because the gate is wrapped OUTSIDE its own layout, that render
30
+ * omits the denying segment's layout — deliberate, and the one place the
31
+ * in-tree path diverges from `renderDenyPage`'s inclusive slice: a layout
32
+ * whose access.ts denied must never run and serialize protected data into
33
+ * the Flight stream (TIM-1074). An ancestor-owned page is hoisted instead,
34
+ * because the gate also sits inside every layout above it and rendering
35
+ * here would wrap the deny page in all of them (TIM-1356).
36
+ *
37
+ * For skipped segments (skippedSegment=true), deny pages are NOT rendered
38
+ * in-tree — the client's cached layout chrome would wrap them incorrectly.
39
+ * Instead, the deny is recorded in ALS and rethrown so the response path
40
+ * can return rscErrorEnvelope for a client hard-navigate.
30
41
  */
31
- export declare function AccessGate(props: AccessGateProps): ReactNode | Promise<ReactNode>;
42
+ export declare function AccessGate(props: AccessGateProps): Promise<ReactNode>;
32
43
  /**
33
44
  * Framework-injected access gate for parallel slots.
34
45
  *
@@ -1 +1 @@
1
- {"version":3,"file":"access-gate.d.ts","sourceRoot":"","sources":["../../src/server/access-gate.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAK9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAuBjF;AAiDD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC,CA6EnF"}
1
+ {"version":3,"file":"access-gate.d.ts","sourceRoot":"","sources":["../../src/server/access-gate.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAK9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAsBrE;AA2DD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC,CA6EnF"}
@@ -1 +1 @@
1
- {"version":3,"file":"action-handler.d.ts","sourceRoot":"","sources":["../../src/server/action-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AASH,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAItE,OAAO,EAAwC,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE/F,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMrD,4CAA4C;AAC5C,MAAM,WAAW,oBAAoB;IACnC,0BAA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C;IAC9B;;;;OAIG;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC;CACzC;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAarD;AAID;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,aAAa,CAAC;IACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,QAAQ,GAAG,YAAY,GAAG,IAAI,CAAC,CA6EzC"}
@@ -111,6 +111,22 @@ export interface RequestContextStore {
111
111
  * context for render-phase errors without module-level shared state.
112
112
  */
113
113
  debugComponentsGetter?: () => DebugComponentEntry[];
114
+ /**
115
+ * Index of the first segment whose AccessGate denied during render.
116
+ * Recorded by AccessGate when it catches a DenySignal so post-render
117
+ * consumers (buildSegmentInfo, X-Timber-Segments header) can bound
118
+ * the segment list without a pre-render access pass. Infinity when
119
+ * no segment denied. See TIM-1363.
120
+ */
121
+ _firstDeniedSegmentIndex?: number;
122
+ /**
123
+ * Metadata entries collected during render by MetadataCollector.
124
+ * Populated per-segment in tree order (root→page) during
125
+ * renderToReadableStream. MetadataHead reads all entries,
126
+ * merges them, and renders Float-hoisted head elements.
127
+ * See TIM-1363, design/16-metadata.md.
128
+ */
129
+ _metadataEntries?: import('./metadata.js').SegmentMetadataEntry[];
114
130
  }
115
131
  /** A single outgoing cookie entry in the cookie jar. */
116
132
  export interface CookieEntry {
@@ -1 +1 @@
1
- {"version":3,"file":"als-registry.d.ts","sourceRoot":"","sources":["../../src/server/als-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,oB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D,4DAA4D;AAC5D,eAAO,MAAM,YAAY,gCAAmE,CAAC;AAM7F,2EAA2E;AAC3E,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAED,gEAAgE;AAChE,eAAO,MAAM,oBAAoB,yCAEhC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../../src/server/compress.ts"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,aAc7B,CAAC;AASH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4BvE;AAID;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAmB1D;AAID;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAiC/E"}
1
+ {"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../../src/server/compress.ts"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,aAc7B,CAAC;AASH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4BvE;AAID;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAmB1D;AAID;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAiC/E"}
@@ -8,10 +8,14 @@
8
8
  * `DenyPageEntry` records ordered by specificity (specific status →
9
9
  * category catch-all → `error.tsx`).
10
10
  *
11
- * 2. **Runtime matching** (`renderMatchingDenyPage`) — picks the first
12
- * chain entry whose status filter matches the thrown DenySignal and
13
- * returns a React element for the matching component. Used by
14
- * `AccessGate` and `PageDenyBoundary` when they catch a deny.
11
+ * 2. **Runtime matching and placement** (`matchDenyEntry`, `placeDenyPage`,
12
+ * `handleCaughtDeny`) — picks the first chain entry whose status filter
13
+ * matches the thrown DenySignal, then decides whether the catch site may
14
+ * render it where it stands. A chain spans the catcher outward to root,
15
+ * so a match may belong to an ancestor segment; rendering it in place
16
+ * would wrap it in every layout in between. Ancestor-owned matches are
17
+ * re-thrown with `ownerKey` stamped on the signal so the error boundary
18
+ * at the owning segment renders it. See TIM-1356.
15
19
  *
16
20
  * 3. **The page boundary itself** (`PageDenyBoundary`) — the async server
17
21
  * component that wraps a server-component page, calls it, and catches
@@ -28,6 +32,7 @@
28
32
  *
29
33
  * See design/04-authorization.md, design/10-error-handling.md, TIM-666.
30
34
  */
35
+ import { DenySignal } from './primitives.js';
31
36
  import type { ManifestSegmentNode } from './route-matcher.js';
32
37
  /** A single entry in the deny page fallback chain. */
33
38
  export interface DenyPageEntry {
@@ -43,27 +48,116 @@ export interface DenyPageEntry {
43
48
  kind: 'status' | 'error';
44
49
  /** MDX files are server components — rendered with plain props, never ErrorReconstituter. */
45
50
  isMdx: boolean;
51
+ /**
52
+ * Position in the segment chain (0 = root, ascending toward leaf).
53
+ * Used by `matchDenyEntry` to reconstruct per-segment ordering for 5xx
54
+ * statuses — `resolve5xx` walks per-segment (status files then error.tsx
55
+ * at each segment before moving outward), while the chain is stored in
56
+ * the 4xx two-pass order. Without this, `deny(503)` resolves to a
57
+ * different file depending on which path serves it. See TIM-1360.
58
+ */
59
+ segmentIndex: number;
60
+ /**
61
+ * Segment key of the segment whose directory holds this file — where the
62
+ * deny page must render, which is not necessarily where it was caught.
63
+ *
64
+ * A chain flattens every segment from the catcher outward to root, so
65
+ * without this a catcher cannot tell a file it owns from an ancestor's,
66
+ * and renders both at its own position — wrapping the deny page in every
67
+ * layout in between (TIM-1356).
68
+ *
69
+ * A **key**, not an index: `computeSegmentKeys` produces the identity the
70
+ * client segment cache already navigates by, and it survives the trip
71
+ * through the Flight digest to a boundary the client mounted on an
72
+ * earlier navigation. A chain position would not — depth varies with
73
+ * route groups and interception.
74
+ *
75
+ * It inherits that key's known collision rather than fixing it: keys reset
76
+ * to `urlPath` at each URL-visible segment, so `(browse)/feed` and
77
+ * `(landing)/feed` are both `/feed` (see `routing/segment-keys.ts`). Two
78
+ * such branches are already indistinguishable to the skip decision and the
79
+ * client cache, so a deny addressed across them can land in the wrong
80
+ * branch's layout. Fixing that means fixing the key for every reader, not
81
+ * minting a second identity here.
82
+ */
83
+ ownerKey: string;
46
84
  }
85
+ /**
86
+ * What `renderDenyEntry` needs to build the element: which component, and
87
+ * which props contract it expects. Deliberately excludes `ownerKey` — the
88
+ * re-render fallback path builds an entry from a `resolveStatusFile`
89
+ * resolution that already carries the position, and would otherwise have to
90
+ * invent an owner it never reads.
91
+ */
92
+ export type DenyEntryShape = Pick<DenyPageEntry, 'component' | 'kind' | 'isMdx'>;
93
+ /**
94
+ * Where a matched deny page must render, relative to the catcher that
95
+ * matched it.
96
+ *
97
+ * `render` — the catcher owns the file and is already at the right
98
+ * position. `hoist` — an ancestor owns it; the catcher must re-throw so the
99
+ * boundary at `ownerKey` renders it, outside the layouts in between.
100
+ */
101
+ export type DenyPlacement = {
102
+ kind: 'render';
103
+ element: React.ReactElement;
104
+ } | {
105
+ kind: 'hoist';
106
+ ownerKey: string;
107
+ };
47
108
  /**
48
109
  * Build the deny page fallback chain from the segment chain.
49
110
  *
50
111
  * Walks segments from `startIndex` outward (toward root) and collects
51
112
  * status-code file components in fallback order:
52
113
  * 1. Specific status files (403.tsx, 404.tsx) — exact match
53
- * 2. Category catch-alls (4xx.tsx) — matches any 4xx
114
+ * 2. Category catch-alls (4xx.tsx, 5xx.tsx) — matches any in category
54
115
  * 3. error.tsx — catches everything
55
116
  *
56
- * Each segment is checked in this order. The chain is ordered so the
57
- * FIRST match wins at catch time. This mirrors resolveStatusFile's 4xx
58
- * component chain (status-code-resolver.ts) — the two walks must stay in
59
- * sync or in-tree and re-render deny paths resolve different files.
117
+ * The chain is stored in the 4xx two-pass order (all status files across
118
+ * segments, then all error.tsx), which mirrors `resolve4xx`. For 5xx,
119
+ * `matchDenyEntry` reconstructs the per-segment walk from each entry's
120
+ * `segmentIndex` — matching `resolve5xx`'s single-pass ordering where a
121
+ * leaf `error.tsx` beats a root `5xx.tsx`. See TIM-1360.
60
122
  */
61
- export declare function buildDenyPageChain(segments: ManifestSegmentNode[], startIndex: number): Promise<DenyPageEntry[]>;
123
+ export declare function buildDenyPageChain(segments: ManifestSegmentNode[], startIndex: number, segmentKeys: string[]): Promise<DenyPageEntry[]>;
62
124
  /**
63
- * Find the first deny page in the chain that matches the given status code.
64
- * Returns a React element for the matching component, or null if no match.
125
+ * Find the first deny page in the chain whose status filter matches.
126
+ * Returns null when nothing in the chain accepts this status.
127
+ *
128
+ * For 4xx statuses, the chain's stored order is correct: every status file
129
+ * across all segments (inner→outer) before any error.tsx — so a root
130
+ * `404.tsx` beats a leaf `error.tsx`. This matches `resolve4xx`.
131
+ *
132
+ * For 5xx statuses, the match walks per-segment (inner→outer): at each
133
+ * segment, status files (`503.tsx` → `5xx.tsx`) then `error.tsx`, before
134
+ * moving to the next segment outward. A leaf `error.tsx` therefore beats a
135
+ * root `5xx.tsx` — the intentional inverse of the 4xx chain, matching
136
+ * `resolve5xx`. See TIM-1360.
137
+ */
138
+ export declare function matchDenyEntry(chain: DenyPageEntry[], status: number): DenyPageEntry | null;
139
+ /**
140
+ * Decide where the deny page for `status` renders, from the perspective of
141
+ * the catch site at `selfKey`.
142
+ *
143
+ * The match itself is unchanged — first entry in fallback order wins, so
144
+ * every path picks the same file. What this adds is the position: a chain
145
+ * built at segment i spans i outward to root, so a matched entry is owned
146
+ * either by the catcher or by one of its ancestors.
147
+ *
148
+ * - Owned by the catcher → `render`. The catcher already sits at the
149
+ * owning segment's position.
150
+ * - Owned by an ancestor → `hoist`. Rendering here would wrap the deny page
151
+ * in every layout between the owner and the catcher. The caller re-throws
152
+ * with `ownerKey` stamped on the signal so the boundary at that segment
153
+ * renders it instead — inside the owner's layout, outside the rest.
154
+ *
155
+ * Returns null when no entry matches; the caller re-throws unannotated and
156
+ * the re-render fallback resolves it.
157
+ *
158
+ * See design/04-authorization.md §"Where a Deny Page Renders", TIM-1356.
65
159
  */
66
- export declare function renderMatchingDenyPage(chain: DenyPageEntry[], status: number, data: unknown): React.ReactElement | null;
160
+ export declare function placeDenyPage(chain: DenyPageEntry[], status: number, data: unknown, selfKey: string | undefined): DenyPlacement | null;
67
161
  /**
68
162
  * Build the element for a matched deny chain entry with the props contract
69
163
  * the file's convention documents:
@@ -75,7 +169,27 @@ export declare function renderMatchingDenyPage(chain: DenyPageEntry[], status: n
75
169
  * error.message) crashes — turning a clean deny(404) into a 500. TIM-1081.
76
170
  * - error.mdx: plain { status } — server component, static content.
77
171
  */
78
- export declare function renderDenyEntry(entry: DenyPageEntry, status: number, data: unknown): React.ReactElement;
172
+ export declare function renderDenyEntry(entry: DenyEntryShape, status: number, data: unknown): React.ReactElement;
173
+ /**
174
+ * The whole of what an in-tree catch site does with a `DenySignal`, shared
175
+ * by all three of them (`PageDenyBoundary`, `TracedLayout`, `AccessGate`).
176
+ *
177
+ * Returns the deny page element when this catch site owns the matched file.
178
+ * Otherwise it throws — annotated with `ownerKey` when an ancestor owns the
179
+ * file, bare when nothing matched at all.
180
+ *
181
+ * `setDenyStatus` runs on the hoist path too, and must run *before* the
182
+ * throw: on the RSC payload path no boundary executes server-side, so the
183
+ * ALS status is the only thing standing between the response and a 200
184
+ * (`rsc-payload.ts` reads it after the stream settles).
185
+ *
186
+ * Either branch leaves part of the matched chain unmounted — hoisting sends
187
+ * the render to a boundary that discards everything below it, and a layout
188
+ * that denies returns the deny page instead of its own child outlet. What the
189
+ * response then says about the tree is decided from the deny status alone in
190
+ * `rsc-payload.ts`, not tracked here; see the note there for why.
191
+ */
192
+ export declare function handleCaughtDeny(chain: DenyPageEntry[] | undefined, error: DenySignal, selfKey: string | undefined): React.ReactElement;
79
193
  /**
80
194
  * Async server component that wraps a page call with DenySignal catching.
81
195
  *
@@ -90,13 +204,19 @@ export declare function renderDenyEntry(entry: DenyPageEntry, status: number, da
90
204
  * No error reaches React Flight — the Flight stream is clean, SSR succeeds,
91
205
  * and the entire request uses a single renderToReadableStream call.
92
206
  */
93
- export declare function PageDenyBoundary({ Page, route, denyPages, onSettled, }: {
207
+ export declare function PageDenyBoundary({ Page, route, denyPages, segmentKey, onSettled, }: {
94
208
  /** The page server component function. */
95
209
  Page: (...args: unknown[]) => unknown;
96
210
  /** Route path for OTEL tracing. */
97
211
  route: string;
98
212
  /** Deny page fallback chain from the segment chain. */
99
213
  denyPages: DenyPageEntry[];
214
+ /**
215
+ * Segment key of the leaf. The page renders inside the leaf's layout, so
216
+ * a leaf-owned deny page is already at the right position; anything the
217
+ * chain matched further up is hoisted to its owner.
218
+ */
219
+ segmentKey: string;
100
220
  /** Called when the page component finishes (success or deny). See TIM-1045. */
101
221
  onSettled?: () => void;
102
222
  }): Promise<React.ReactElement>;
@@ -111,4 +231,17 @@ export declare function setDenyStatus(status: number): void;
111
231
  * Returns undefined if no deny was caught during render.
112
232
  */
113
233
  export declare function getDenyStatus(): number | undefined;
234
+ /**
235
+ * Record the first denied segment index in the request context ALS.
236
+ * Called from AccessGate when a DenySignal is caught during render.
237
+ * Only the first (shallowest) denial is recorded — deeper denials are
238
+ * unreachable because the gate short-circuits the subtree.
239
+ * See TIM-1363.
240
+ */
241
+ export declare function setFirstDeniedSegmentIndex(index: number): void;
242
+ /**
243
+ * Read the first denied segment index from the request context ALS.
244
+ * Returns Infinity if no segment denied during render.
245
+ */
246
+ export declare function getFirstDeniedSegmentIndex(): number;
114
247
  //# sourceMappingURL=deny-boundary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deny-boundary.d.ts","sour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AAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAY9B;AAID;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAMlD;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAK9D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAEnD"}
@@ -49,12 +49,12 @@ export type DefaultPageRenderer = (status: number, responseHeaders: Headers) =>
49
49
  * on format preference. Returns an HTML Response (component), a JSON Response,
50
50
  * or the framework default status page.
51
51
  */
52
- export declare function renderDenyPage(deny: DenySignal, segments: ManifestSegmentNode[], layoutComponents: LayoutEntry[], req: Request, match: RouteMatch, responseHeaders: Headers, clientBootstrap: ClientBootstrapConfig, createDebugChannelSink: DebugChannelFactory, callSsr: CallSsrFn, defaultPage?: DefaultPageRenderer): Promise<Response>;
52
+ export declare function renderDenyPage(deny: DenySignal, segments: ManifestSegmentNode[], layoutComponents: LayoutEntry[], req: Request, match: RouteMatch, responseHeaders: Headers, clientBootstrap: ClientBootstrapConfig, createDebugChannelSink: DebugChannelFactory, callSsr: CallSsrFn, defaultPage?: DefaultPageRenderer, firstDeniedIndex?: number): Promise<Response>;
53
53
  /**
54
54
  * Render a status-code error page as a raw RSC Flight stream for client navigation.
55
55
  *
56
56
  * Same as renderDenyPage but skips SSR — returns the RSC stream directly
57
57
  * so the client can reconcile the error page into the existing DOM.
58
58
  */
59
- export declare function renderDenyPageAsRsc(deny: DenySignal, segments: ManifestSegmentNode[], layoutComponents: LayoutEntry[], req: Request, responseHeaders: Headers, createDebugChannelSink: DebugChannelFactory): Promise<Response>;
59
+ export declare function renderDenyPageAsRsc(deny: DenySignal, segments: ManifestSegmentNode[], layoutComponents: LayoutEntry[], req: Request, responseHeaders: Headers, createDebugChannelSink: DebugChannelFactory, firstDeniedIndex?: number): Promise<Response>;
60
60
  //# sourceMappingURL=deny-renderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deny-renderer.d.ts","sourceRoot":"","sources":["../../src/server/deny-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAe7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAOjE,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;IAC3C,OAAO,EAAE,mBAAmB,CAAC;CAC9B;AAED,iEAAiE;AACjE,MAAM,MAAM,mBAAmB,GAAG,MAAM;IACtC,QAAQ,EAAE,cAAc,CAAC;IACzB,QAAQ,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GAAG,CACtB,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,EACrC,UAAU,EAAE,UAAU,KACnB,OAAO,CAAC,QAAQ,CAAC,CAAC;AAiCvB;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,KAAK,QAAQ,GAAG,IAAI,CAAC;AAEhG;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,gBAAgB,EAAE,WAAW,EAAE,EAC/B,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,UAAU,EACjB,eAAe,EAAE,OAAO,EACxB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;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,KAAK,QAAQ,GAAG,IAAI,CAAC;AAEhG;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,gBAAgB,EAAE,WAAW,EAAE,EAC/B,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,UAAU,EACjB,eAAe,EAAE,OAAO,EACxB,eAAe,EAAE,qBAAqB,EACtC,sBAAsB,EAAE,mBAAmB,EAC3C,OAAO,EAAE,SAAS,EAClB,WAAW,CAAC,EAAE,mBAAmB,EACjC,gBAAgB,SAAW,GAC1B,OAAO,CAAC,QAAQ,CAAC,CAmInB;AAgBD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,gBAAgB,EAAE,WAAW,EAAE,EAC/B,GAAG,EAAE,OAAO,EACZ,eAAe,EAAE,OAAO,EACxB,sBAAsB,EAAE,mBAAmB,EAC3C,gBAAgB,SAAW,GAC1B,OAAO,CAAC,QAAQ,CAAC,CA6CnB"}
@@ -1,23 +1,93 @@
1
1
  /**
2
- * Error boundary wrapper — wraps a React element in error boundaries from a route segment.
2
+ * Error boundary wrapper — wraps a React element in the error boundaries
3
+ * declared by a route segment (`{status}.tsx`, `4xx.tsx`/`5xx.tsx`, `error.tsx`).
3
4
  *
4
- * Extracted to allow reuse by both rsc-entry.ts and route-element-builder.ts.
5
- * See design/10-error-handling.md.
5
+ * This is the single implementation of that walk. It is driven by both
6
+ * construction sites:
7
+ *
8
+ * - `route-element-builder.ts` / `slot-resolver.ts` — the request-time
9
+ * renderer, walking the runtime manifest (`SegmentNode<ManifestFile>`).
10
+ * - `tree-builder.ts` — the build-time tree walker
11
+ * (`SegmentNode<RouteFile>`), with its loader and `createElement` injected.
12
+ *
13
+ * `errorBoundaryComponent` is injected rather than imported: `TimberErrorBoundary`
14
+ * is a `'use client'` module, and importing it here would pull client code into
15
+ * every consumer — including `tree-builder.ts`, which the server barrel reaches.
16
+ * `tests/use-client-pipeline.test.ts` walks the import graph to enforce this.
17
+ *
18
+ * See design/10-error-handling.md §"Status-Code File Variants".
19
+ */
20
+ import type { ReactNode } from 'react';
21
+ import type { SegmentNode } from '../routing/types.js';
22
+ import { type LoadedComponent } from './utils/element-type.js';
23
+ /** The minimum a route file must carry for the walk: a path to classify as MDX. */
24
+ interface BoundaryFile {
25
+ filePath: string;
26
+ }
27
+ /**
28
+ * Framework-injected error boundary wrapper.
29
+ * Wraps content with status-code error boundary handling.
30
+ *
31
+ * Field types must agree with `TimberErrorBoundaryProps` in
32
+ * `client/error-boundary.tsx`. The two are kept structurally compatible by
33
+ * convention rather than by direct type import — this is the server-side
34
+ * construction site and may not import types from a 'use client' module.
6
35
  */
7
- import type { ManifestSegmentNode } from './route-matcher.js';
36
+ export interface ErrorBoundaryProps {
37
+ /** The component to render when an error is caught (TSX status files). */
38
+ fallbackComponent?: LoadedComponent;
39
+ /** Pre-rendered fallback element (MDX status files — see TIM-503). */
40
+ fallbackElement?: ReactNode;
41
+ /** Status code filter: 400 = any 4xx, 500 = any 5xx, specific number = exact match. */
42
+ status?: number;
43
+ /**
44
+ * Segment key of the segment that declared this boundary. An in-tree deny
45
+ * catch site that matched a file it may not render in place re-throws with
46
+ * that file's owning key on the signal; boundaries whose key differs
47
+ * decline, so the deny page lands at its owner rather than at the first
48
+ * boundary the throw happens to pass. Unset for slot boundaries and for
49
+ * construction sites with no deny chains — an unkeyed boundary declines
50
+ * every owner-addressed deny. See TIM-1356.
51
+ */
52
+ segmentKey?: string;
53
+ children: ReactNode;
54
+ }
55
+ /** How to load a route file's module. Only `default` is read. */
56
+ type BoundaryModuleLoader<TFile> = (file: TFile) => {
57
+ default?: unknown;
58
+ } | Promise<{
59
+ default?: unknown;
60
+ }>;
61
+ /** Everything the walk needs from its host environment. */
62
+ export interface ErrorBoundaryWrapConfig<TFile, TElement> {
63
+ /** `React.createElement` or an equivalent element factory. */
64
+ createElement: (type: unknown, props: object) => TElement;
65
+ /** Loads a route file's module. Failures skip the boundary — see below. */
66
+ loadModule: BoundaryModuleLoader<TFile>;
67
+ /**
68
+ * The error boundary component to instantiate (`TimberErrorBoundary`, or a
69
+ * host-specific stand-in). Injected — see the module docstring.
70
+ */
71
+ errorBoundaryComponent: unknown;
72
+ /** When true, skip 4xx error boundaries — deny catching handles them in-tree. See TIM-666. */
73
+ skipDenyBoundaries?: boolean;
74
+ /** Segment key stamped on every boundary this walk creates. See `ErrorBoundaryProps`. */
75
+ segmentKey?: string;
76
+ }
8
77
  /**
9
- * Wrap an element in error boundaries defined by a route segment.
78
+ * Wrap an element in the error boundaries declared by a route segment.
79
+ *
80
+ * Wrapping is applied inside-out — the last wrap produces the outermost
81
+ * boundary — so the processing order below is innermost to outermost:
82
+ *
83
+ * 1. Specific status files (e.g. `404.tsx`, `503.tsx`) — highest priority at runtime
84
+ * 2. Category catch-alls (`4xx.tsx`, `5xx.tsx`)
85
+ * 3. `error.tsx` — catches anything not matched by a status file
10
86
  *
11
- * Processing order (innermost to outermost):
12
- * 1. Specific status files (e.g., 404.tsx, 500.tsx) — highest priority at runtime
13
- * 2. Category catch-alls (4xx.tsx, 5xx.tsx)
14
- * 3. error.tsx — catches anything not matched by status files
87
+ * The order is load-bearing: it decides which boundary catches a given throw.
15
88
  *
16
- * MDX status files are server components and cannot be passed as function
17
- * props to TimberErrorBoundary (a 'use client' component). Instead, they
18
- * are pre-rendered as elements and passed as fallbackElement. See TIM-503.
89
+ * See design/10-error-handling.md §"Format-Aware Fallback Chains".
19
90
  */
20
- export declare function wrapSegmentWithErrorBoundaries(segment: ManifestSegmentNode, element: React.ReactElement, h: (...args: unknown[]) => React.ReactElement,
21
- /** When true, skip 4xx error boundaries — deny catching handles them in-tree. See TIM-666. */
22
- skipDenyBoundaries?: boolean): Promise<React.ReactElement>;
91
+ export declare function wrapSegmentWithErrorBoundaries<TFile extends BoundaryFile, TElement extends ReactNode>(segment: SegmentNode<TFile>, element: TElement, config: ErrorBoundaryWrapConfig<TFile, TElement>): Promise<TElement>;
92
+ export {};
23
93
  //# sourceMappingURL=error-boundary-wrapper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-boundary-wrapper.d.ts","sourceRoot":"","sources":["../../src/server/error-boundary-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI9D;;;;;;;;;;;GAWG;AACH,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,KAAK,CAAC,YAAY,EAC3B,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,KAAK,CAAC,YAAY;AAC7C,8FAA8F;AAC9F,kBAAkB,UAAQ,GACzB,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CA6E7B"}
1
+ {"version":3,"file":"error-boundary-wrapper.d.ts","sourceRoot":"","sources":["../../src/server/error-boundary-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAGnF,mFAAmF;AACnF,UAAU,YAAY;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,eAAe,CAAC;IACpC,sEAAsE;IACtE,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,uFAAuF;IACvF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,iEAAiE;AACjE,KAAK,oBAAoB,CAAC,KAAK,IAAI,CACjC,IAAI,EAAE,KAAK,KACR;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAE5D,2DAA2D;AAC3D,MAAM,WAAW,uBAAuB,CAAC,KAAK,EAAE,QAAQ;IACtD,8DAA8D;IAC9D,aAAa,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,QAAQ,CAAC;IAC1D,2EAA2E;IAC3E,UAAU,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACxC;;;OAGG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC,8FAA8F;IAC9F,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,yFAAyF;IACzF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAkDD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,8BAA8B,CAClD,KAAK,SAAS,YAAY,EAC1B,QAAQ,SAAS,SAAS,EAE1B,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,EAC3B,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,uBAAuB,CAAC,KAAK,EAAE,QAAQ,CAAC,GAC/C,OAAO,CAAC,QAAQ,CAAC,CA4CnB"}
@@ -15,5 +15,4 @@ export { getFormFlash } from './form-flash';
15
15
  export type { FormFlashData } from './form-flash';
16
16
  export { revalidatePath, revalidateTag } from './actions';
17
17
  export { getTraceId, getSpanId, withSpan, addSpanEvent } from './tracing';
18
- export type { ParamsDefinition, InferParamField, ParamField } from '../segment-params/define.js';
19
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts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,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
@@ -1,6 +1,7 @@
1
- import { D as getSegmentParams, J as withSpan, L as isDebug, P as getCookieJar, R as isDevMode, S as waitUntil, T as getHeaders, U as getSpanId, W as getTraceId, X as formFlashAls, _ as RedirectSignal, b as redirect, g as DenySignal, x as redirectExternal, y as deny, z as addSpanEvent } from "../_chunks/logger-N7e5auP0.js";
1
+ import { n as formFlashAls } from "../_chunks/als-registry-C6kcfprT.js";
2
+ import { D as getSegmentParams, J as withSpan, L as isDebug, P as getCookieJar, R as isDevMode, S as waitUntil, T as getHeaders, U as getSpanId, W as getTraceId, _ as RedirectSignal, b as redirect, g as DenySignal, x as redirectExternal, y as deny, z as addSpanEvent } from "../_chunks/logger-D8xJZXIN.js";
2
3
  import { t as formatSize } from "../_chunks/format-CfwjgPz9.js";
3
- import { a as parseFormData, i as coerce, n as revalidatePath, r as revalidateTag } from "../_chunks/actions-C-Rw9vPc.js";
4
+ import { a as parseFormData, i as coerce, n as revalidatePath, r as revalidateTag } from "../_chunks/actions-35jnMdeJ.js";
4
5
  //#region src/shared/redirect-type.ts
5
6
  /**
6
7
  * Next.js redirect type discriminator.