@timber-js/app 0.2.0-alpha.6 → 0.2.0-alpha.61

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 (406) hide show
  1. package/LICENSE +8 -0
  2. package/dist/_chunks/{als-registry-B7DbZ2hS.js → als-registry-Ba7URUIn.js} +1 -1
  3. package/dist/_chunks/als-registry-Ba7URUIn.js.map +1 -0
  4. package/dist/_chunks/chunk-DYhsFzuS.js +33 -0
  5. package/dist/_chunks/{debug-gwlJkDuf.js → debug-ECi_61pb.js} +2 -2
  6. package/dist/_chunks/debug-ECi_61pb.js.map +1 -0
  7. package/dist/_chunks/define-CT98cU9c.js +121 -0
  8. package/dist/_chunks/define-CT98cU9c.js.map +1 -0
  9. package/dist/_chunks/define-TK8C1M3x.js +279 -0
  10. package/dist/_chunks/define-TK8C1M3x.js.map +1 -0
  11. package/dist/_chunks/define-cookie-BWr_52kY.js +93 -0
  12. package/dist/_chunks/define-cookie-BWr_52kY.js.map +1 -0
  13. package/dist/_chunks/error-boundary-DpZJBCqh.js +211 -0
  14. package/dist/_chunks/error-boundary-DpZJBCqh.js.map +1 -0
  15. package/dist/_chunks/{format-DviM89f0.js → format-cX7wzEp2.js} +2 -2
  16. package/dist/_chunks/{format-DviM89f0.js.map → format-cX7wzEp2.js.map} +1 -1
  17. package/dist/_chunks/{interception-BOoWmLUA.js → interception-Cey5DCGr.js} +129 -77
  18. package/dist/_chunks/interception-Cey5DCGr.js.map +1 -0
  19. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js → metadata-routes-BU684ls2.js} +1 -1
  20. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js.map → metadata-routes-BU684ls2.js.map} +1 -1
  21. package/dist/_chunks/{request-context-DIkVh_jG.js → request-context-rju2rbga.js} +97 -69
  22. package/dist/_chunks/request-context-rju2rbga.js.map +1 -0
  23. package/dist/_chunks/segment-context-CyaM1mrD.js +72 -0
  24. package/dist/_chunks/segment-context-CyaM1mrD.js.map +1 -0
  25. package/dist/_chunks/stale-reload-BSSym1MJ.js +64 -0
  26. package/dist/_chunks/stale-reload-BSSym1MJ.js.map +1 -0
  27. package/dist/_chunks/{tracing-Cwn7697K.js → tracing-VYETCQsg.js} +17 -3
  28. package/dist/_chunks/{tracing-Cwn7697K.js.map → tracing-VYETCQsg.js.map} +1 -1
  29. package/dist/_chunks/{use-query-states-D5KaffOK.js → use-query-states-wEXY2JQB.js} +1 -1
  30. package/dist/_chunks/use-query-states-wEXY2JQB.js.map +1 -0
  31. package/dist/_chunks/wrappers-BaG1bnM3.js +63 -0
  32. package/dist/_chunks/wrappers-BaG1bnM3.js.map +1 -0
  33. package/dist/adapters/compress-module.d.ts.map +1 -1
  34. package/dist/adapters/nitro.d.ts +17 -1
  35. package/dist/adapters/nitro.d.ts.map +1 -1
  36. package/dist/adapters/nitro.js +56 -13
  37. package/dist/adapters/nitro.js.map +1 -1
  38. package/dist/cache/fast-hash.d.ts +22 -0
  39. package/dist/cache/fast-hash.d.ts.map +1 -0
  40. package/dist/cache/index.d.ts +5 -2
  41. package/dist/cache/index.d.ts.map +1 -1
  42. package/dist/cache/index.js +90 -20
  43. package/dist/cache/index.js.map +1 -1
  44. package/dist/cache/register-cached-function.d.ts.map +1 -1
  45. package/dist/cache/singleflight.d.ts +18 -1
  46. package/dist/cache/singleflight.d.ts.map +1 -1
  47. package/dist/cache/timber-cache.d.ts +1 -1
  48. package/dist/cache/timber-cache.d.ts.map +1 -1
  49. package/dist/client/error-boundary.d.ts +10 -1
  50. package/dist/client/error-boundary.d.ts.map +1 -1
  51. package/dist/client/error-boundary.js +1 -125
  52. package/dist/client/error-reconstituter.d.ts +54 -0
  53. package/dist/client/error-reconstituter.d.ts.map +1 -0
  54. package/dist/client/form.d.ts +2 -2
  55. package/dist/client/form.d.ts.map +1 -1
  56. package/dist/client/index.d.ts +3 -2
  57. package/dist/client/index.d.ts.map +1 -1
  58. package/dist/client/index.js +433 -252
  59. package/dist/client/index.js.map +1 -1
  60. package/dist/client/link-pending-store.d.ts +78 -0
  61. package/dist/client/link-pending-store.d.ts.map +1 -0
  62. package/dist/client/link.d.ts +23 -9
  63. package/dist/client/link.d.ts.map +1 -1
  64. package/dist/client/navigation-context.d.ts +2 -2
  65. package/dist/client/navigation-context.d.ts.map +1 -1
  66. package/dist/client/router.d.ts +25 -3
  67. package/dist/client/router.d.ts.map +1 -1
  68. package/dist/client/rsc-fetch.d.ts +36 -2
  69. package/dist/client/rsc-fetch.d.ts.map +1 -1
  70. package/dist/client/segment-cache.d.ts +1 -1
  71. package/dist/client/segment-cache.d.ts.map +1 -1
  72. package/dist/client/segment-context.d.ts +1 -1
  73. package/dist/client/segment-context.d.ts.map +1 -1
  74. package/dist/client/segment-merger.d.ts.map +1 -1
  75. package/dist/client/segment-outlet.d.ts +63 -0
  76. package/dist/client/segment-outlet.d.ts.map +1 -0
  77. package/dist/client/stale-reload.d.ts +15 -0
  78. package/dist/client/stale-reload.d.ts.map +1 -1
  79. package/dist/client/top-loader.d.ts +1 -1
  80. package/dist/client/top-loader.d.ts.map +1 -1
  81. package/dist/client/transition-root.d.ts +1 -1
  82. package/dist/client/transition-root.d.ts.map +1 -1
  83. package/dist/client/use-params.d.ts +3 -3
  84. package/dist/client/use-params.d.ts.map +1 -1
  85. package/dist/client/use-query-states.d.ts +1 -1
  86. package/dist/client/use-query-states.d.ts.map +1 -1
  87. package/dist/codec.d.ts +21 -0
  88. package/dist/codec.d.ts.map +1 -0
  89. package/dist/cookies/define-cookie.d.ts +34 -13
  90. package/dist/cookies/define-cookie.d.ts.map +1 -1
  91. package/dist/cookies/index.js +1 -83
  92. package/dist/fonts/css.d.ts +1 -0
  93. package/dist/fonts/css.d.ts.map +1 -1
  94. package/dist/index.d.ts +127 -35
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +665 -242
  97. package/dist/index.js.map +1 -1
  98. package/dist/params/define.d.ts +100 -0
  99. package/dist/params/define.d.ts.map +1 -0
  100. package/dist/params/index.d.ts +8 -0
  101. package/dist/params/index.d.ts.map +1 -0
  102. package/dist/params/index.js +4 -0
  103. package/dist/plugins/adapter-build.d.ts +1 -1
  104. package/dist/plugins/adapter-build.d.ts.map +1 -1
  105. package/dist/plugins/build-manifest.d.ts +2 -2
  106. package/dist/plugins/build-manifest.d.ts.map +1 -1
  107. package/dist/plugins/build-report.d.ts +3 -3
  108. package/dist/plugins/build-report.d.ts.map +1 -1
  109. package/dist/plugins/client-chunks.d.ts +32 -0
  110. package/dist/plugins/client-chunks.d.ts.map +1 -0
  111. package/dist/plugins/content.d.ts +1 -1
  112. package/dist/plugins/content.d.ts.map +1 -1
  113. package/dist/plugins/dev-browser-logs.d.ts +84 -0
  114. package/dist/plugins/dev-browser-logs.d.ts.map +1 -0
  115. package/dist/plugins/dev-error-overlay.d.ts +26 -1
  116. package/dist/plugins/dev-error-overlay.d.ts.map +1 -1
  117. package/dist/plugins/dev-logs.d.ts +1 -1
  118. package/dist/plugins/dev-logs.d.ts.map +1 -1
  119. package/dist/plugins/dev-server.d.ts +1 -1
  120. package/dist/plugins/dev-server.d.ts.map +1 -1
  121. package/dist/plugins/entries.d.ts +1 -1
  122. package/dist/plugins/entries.d.ts.map +1 -1
  123. package/dist/plugins/fonts.d.ts +9 -2
  124. package/dist/plugins/fonts.d.ts.map +1 -1
  125. package/dist/plugins/mdx.d.ts +1 -1
  126. package/dist/plugins/mdx.d.ts.map +1 -1
  127. package/dist/plugins/routing.d.ts +1 -1
  128. package/dist/plugins/routing.d.ts.map +1 -1
  129. package/dist/plugins/server-bundle.d.ts.map +1 -1
  130. package/dist/plugins/shims.d.ts +6 -5
  131. package/dist/plugins/shims.d.ts.map +1 -1
  132. package/dist/plugins/static-build.d.ts +1 -1
  133. package/dist/plugins/static-build.d.ts.map +1 -1
  134. package/dist/routing/codegen.d.ts +2 -2
  135. package/dist/routing/codegen.d.ts.map +1 -1
  136. package/dist/routing/index.js +1 -1
  137. package/dist/routing/scanner.d.ts.map +1 -1
  138. package/dist/routing/status-file-lint.d.ts +2 -1
  139. package/dist/routing/status-file-lint.d.ts.map +1 -1
  140. package/dist/routing/types.d.ts +16 -4
  141. package/dist/routing/types.d.ts.map +1 -1
  142. package/dist/rsc-runtime/rsc.d.ts +1 -1
  143. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  144. package/dist/rsc-runtime/ssr.d.ts +12 -0
  145. package/dist/rsc-runtime/ssr.d.ts.map +1 -1
  146. package/dist/search-params/codecs.d.ts +1 -1
  147. package/dist/search-params/define.d.ts +159 -0
  148. package/dist/search-params/define.d.ts.map +1 -0
  149. package/dist/search-params/index.d.ts +4 -5
  150. package/dist/search-params/index.d.ts.map +1 -1
  151. package/dist/search-params/index.js +4 -474
  152. package/dist/search-params/registry.d.ts +1 -1
  153. package/dist/search-params/wrappers.d.ts +53 -0
  154. package/dist/search-params/wrappers.d.ts.map +1 -0
  155. package/dist/server/access-gate.d.ts +4 -0
  156. package/dist/server/access-gate.d.ts.map +1 -1
  157. package/dist/server/action-client.d.ts.map +1 -1
  158. package/dist/server/action-encryption.d.ts +76 -0
  159. package/dist/server/action-encryption.d.ts.map +1 -0
  160. package/dist/server/action-handler.d.ts.map +1 -1
  161. package/dist/server/actions.d.ts +1 -1
  162. package/dist/server/actions.d.ts.map +1 -1
  163. package/dist/server/als-registry.d.ts +25 -4
  164. package/dist/server/als-registry.d.ts.map +1 -1
  165. package/dist/server/build-manifest.d.ts +2 -2
  166. package/dist/server/build-manifest.d.ts.map +1 -1
  167. package/dist/server/debug.d.ts +1 -1
  168. package/dist/server/default-logger.d.ts +22 -0
  169. package/dist/server/default-logger.d.ts.map +1 -0
  170. package/dist/server/deny-renderer.d.ts.map +1 -1
  171. package/dist/server/early-hints.d.ts +13 -5
  172. package/dist/server/early-hints.d.ts.map +1 -1
  173. package/dist/server/error-boundary-wrapper.d.ts +4 -0
  174. package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
  175. package/dist/server/fallback-error.d.ts +4 -3
  176. package/dist/server/fallback-error.d.ts.map +1 -1
  177. package/dist/server/flight-injection-state.d.ts +66 -0
  178. package/dist/server/flight-injection-state.d.ts.map +1 -0
  179. package/dist/server/flight-scripts.d.ts +42 -0
  180. package/dist/server/flight-scripts.d.ts.map +1 -0
  181. package/dist/server/flush.d.ts.map +1 -1
  182. package/dist/server/form-data.d.ts +29 -0
  183. package/dist/server/form-data.d.ts.map +1 -1
  184. package/dist/server/html-injectors.d.ts +51 -11
  185. package/dist/server/html-injectors.d.ts.map +1 -1
  186. package/dist/server/index.d.ts +4 -2
  187. package/dist/server/index.d.ts.map +1 -1
  188. package/dist/server/index.js +1977 -1648
  189. package/dist/server/index.js.map +1 -1
  190. package/dist/server/logger.d.ts +25 -7
  191. package/dist/server/logger.d.ts.map +1 -1
  192. package/dist/server/node-stream-transforms.d.ts +113 -0
  193. package/dist/server/node-stream-transforms.d.ts.map +1 -0
  194. package/dist/server/pipeline-interception.d.ts +1 -1
  195. package/dist/server/pipeline-interception.d.ts.map +1 -1
  196. package/dist/server/pipeline.d.ts +20 -6
  197. package/dist/server/pipeline.d.ts.map +1 -1
  198. package/dist/server/primitives.d.ts +30 -3
  199. package/dist/server/primitives.d.ts.map +1 -1
  200. package/dist/server/render-timeout.d.ts +51 -0
  201. package/dist/server/render-timeout.d.ts.map +1 -0
  202. package/dist/server/request-context.d.ts +65 -38
  203. package/dist/server/request-context.d.ts.map +1 -1
  204. package/dist/server/route-element-builder.d.ts +7 -0
  205. package/dist/server/route-element-builder.d.ts.map +1 -1
  206. package/dist/server/route-handler.d.ts.map +1 -1
  207. package/dist/server/route-matcher.d.ts +9 -2
  208. package/dist/server/route-matcher.d.ts.map +1 -1
  209. package/dist/server/rsc-entry/api-handler.d.ts +2 -2
  210. package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
  211. package/dist/server/rsc-entry/error-renderer.d.ts +26 -13
  212. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  213. package/dist/server/rsc-entry/helpers.d.ts +48 -5
  214. package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
  215. package/dist/server/rsc-entry/index.d.ts +8 -3
  216. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  217. package/dist/server/rsc-entry/rsc-payload.d.ts +3 -3
  218. package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
  219. package/dist/server/rsc-entry/rsc-stream.d.ts +10 -1
  220. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  221. package/dist/server/rsc-entry/ssr-bridge.d.ts +1 -1
  222. package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
  223. package/dist/server/rsc-entry/ssr-renderer.d.ts +19 -4
  224. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  225. package/dist/server/slot-resolver.d.ts +1 -1
  226. package/dist/server/slot-resolver.d.ts.map +1 -1
  227. package/dist/server/ssr-entry.d.ts +22 -0
  228. package/dist/server/ssr-entry.d.ts.map +1 -1
  229. package/dist/server/ssr-render.d.ts +39 -21
  230. package/dist/server/ssr-render.d.ts.map +1 -1
  231. package/dist/server/ssr-wrappers.d.ts +50 -0
  232. package/dist/server/ssr-wrappers.d.ts.map +1 -0
  233. package/dist/server/status-code-resolver.d.ts +1 -1
  234. package/dist/server/status-code-resolver.d.ts.map +1 -1
  235. package/dist/server/stream-utils.d.ts +36 -0
  236. package/dist/server/stream-utils.d.ts.map +1 -0
  237. package/dist/server/tracing.d.ts +10 -0
  238. package/dist/server/tracing.d.ts.map +1 -1
  239. package/dist/server/tree-builder.d.ts +20 -13
  240. package/dist/server/tree-builder.d.ts.map +1 -1
  241. package/dist/server/types.d.ts +1 -3
  242. package/dist/server/types.d.ts.map +1 -1
  243. package/dist/server/version-skew.d.ts +61 -0
  244. package/dist/server/version-skew.d.ts.map +1 -0
  245. package/dist/server/waituntil-bridge.d.ts.map +1 -1
  246. package/dist/shared/merge-search-params.d.ts +22 -0
  247. package/dist/shared/merge-search-params.d.ts.map +1 -0
  248. package/dist/shims/font-google.d.ts +1 -1
  249. package/dist/shims/font-google.d.ts.map +1 -1
  250. package/dist/shims/navigation-client.d.ts +1 -1
  251. package/dist/shims/navigation-client.d.ts.map +1 -1
  252. package/dist/shims/navigation.d.ts +1 -1
  253. package/dist/shims/navigation.d.ts.map +1 -1
  254. package/dist/utils/state-machine.d.ts +80 -0
  255. package/dist/utils/state-machine.d.ts.map +1 -0
  256. package/package.json +17 -17
  257. package/src/adapters/compress-module.ts +24 -4
  258. package/src/adapters/nitro.ts +58 -9
  259. package/src/cache/fast-hash.ts +34 -0
  260. package/src/cache/index.ts +5 -2
  261. package/src/cache/register-cached-function.ts +7 -3
  262. package/src/cache/singleflight.ts +62 -4
  263. package/src/cache/timber-cache.ts +40 -29
  264. package/src/cli.ts +0 -0
  265. package/src/client/browser-entry.ts +151 -99
  266. package/src/client/error-boundary.tsx +18 -1
  267. package/src/client/error-reconstituter.tsx +65 -0
  268. package/src/client/form.tsx +2 -2
  269. package/src/client/index.ts +10 -1
  270. package/src/client/link-pending-store.ts +136 -0
  271. package/src/client/link.tsx +137 -22
  272. package/src/client/navigation-context.ts +6 -5
  273. package/src/client/router.ts +117 -60
  274. package/src/client/rsc-fetch.ts +90 -2
  275. package/src/client/segment-cache.ts +1 -1
  276. package/src/client/segment-context.ts +6 -1
  277. package/src/client/segment-merger.ts +2 -8
  278. package/src/client/segment-outlet.tsx +86 -0
  279. package/src/client/stale-reload.ts +73 -6
  280. package/src/client/top-loader.tsx +10 -9
  281. package/src/client/transition-root.tsx +20 -2
  282. package/src/client/use-params.ts +4 -4
  283. package/src/client/use-query-states.ts +2 -2
  284. package/src/codec.ts +21 -0
  285. package/src/cookies/define-cookie.ts +71 -20
  286. package/src/fonts/css.ts +2 -1
  287. package/src/index.ts +297 -85
  288. package/src/params/define.ts +327 -0
  289. package/src/params/index.ts +28 -0
  290. package/src/plugins/adapter-build.ts +8 -2
  291. package/src/plugins/build-manifest.ts +13 -2
  292. package/src/plugins/build-report.ts +3 -3
  293. package/src/plugins/cache-transform.ts +1 -1
  294. package/src/plugins/client-chunks.ts +65 -0
  295. package/src/plugins/content.ts +1 -1
  296. package/src/plugins/dev-browser-logs.ts +284 -0
  297. package/src/plugins/dev-error-overlay.ts +70 -1
  298. package/src/plugins/dev-logs.ts +1 -1
  299. package/src/plugins/dev-server.ts +41 -7
  300. package/src/plugins/entries.ts +6 -8
  301. package/src/plugins/fonts.ts +102 -55
  302. package/src/plugins/mdx.ts +1 -1
  303. package/src/plugins/routing.ts +57 -17
  304. package/src/plugins/server-action-exports.ts +1 -1
  305. package/src/plugins/server-bundle.ts +32 -1
  306. package/src/plugins/shims.ts +69 -31
  307. package/src/plugins/static-build.ts +10 -6
  308. package/src/routing/codegen.ts +109 -88
  309. package/src/routing/scanner.ts +86 -7
  310. package/src/routing/status-file-lint.ts +3 -2
  311. package/src/routing/types.ts +17 -4
  312. package/src/rsc-runtime/rsc.ts +2 -0
  313. package/src/rsc-runtime/ssr.ts +50 -0
  314. package/src/rsc-runtime/vendor-types.d.ts +7 -0
  315. package/src/search-params/codecs.ts +1 -1
  316. package/src/search-params/define.ts +518 -0
  317. package/src/search-params/index.ts +12 -18
  318. package/src/search-params/registry.ts +1 -1
  319. package/src/search-params/wrappers.ts +85 -0
  320. package/src/server/access-gate.tsx +40 -9
  321. package/src/server/action-client.ts +8 -2
  322. package/src/server/action-encryption.ts +144 -0
  323. package/src/server/action-handler.ts +20 -3
  324. package/src/server/actions.ts +1 -1
  325. package/src/server/als-registry.ts +25 -4
  326. package/src/server/build-manifest.ts +10 -4
  327. package/src/server/compress.ts +25 -7
  328. package/src/server/debug.ts +1 -1
  329. package/src/server/default-logger.ts +99 -0
  330. package/src/server/deny-renderer.ts +5 -3
  331. package/src/server/early-hints.ts +36 -15
  332. package/src/server/error-boundary-wrapper.ts +58 -15
  333. package/src/server/fallback-error.ts +29 -14
  334. package/src/server/flight-injection-state.ts +113 -0
  335. package/src/server/flight-scripts.ts +62 -0
  336. package/src/server/flush.ts +2 -1
  337. package/src/server/form-data.ts +76 -0
  338. package/src/server/html-injectors.ts +277 -117
  339. package/src/server/index.ts +9 -4
  340. package/src/server/logger.ts +44 -36
  341. package/src/server/node-stream-transforms.ts +509 -0
  342. package/src/server/pipeline-interception.ts +1 -1
  343. package/src/server/pipeline.ts +148 -41
  344. package/src/server/primitives.ts +47 -5
  345. package/src/server/render-timeout.ts +108 -0
  346. package/src/server/request-context.ts +125 -119
  347. package/src/server/route-element-builder.ts +107 -115
  348. package/src/server/route-handler.ts +2 -1
  349. package/src/server/route-matcher.ts +9 -2
  350. package/src/server/rsc-entry/api-handler.ts +8 -8
  351. package/src/server/rsc-entry/error-renderer.ts +286 -81
  352. package/src/server/rsc-entry/helpers.ts +134 -5
  353. package/src/server/rsc-entry/index.ts +177 -76
  354. package/src/server/rsc-entry/rsc-payload.ts +91 -18
  355. package/src/server/rsc-entry/rsc-stream.ts +74 -18
  356. package/src/server/rsc-entry/ssr-bridge.ts +2 -2
  357. package/src/server/rsc-entry/ssr-renderer.ts +152 -34
  358. package/src/server/slot-resolver.ts +231 -220
  359. package/src/server/ssr-entry.ts +211 -32
  360. package/src/server/ssr-render.ts +289 -67
  361. package/src/server/ssr-wrappers.tsx +139 -0
  362. package/src/server/status-code-resolver.ts +1 -1
  363. package/src/server/stream-utils.ts +213 -0
  364. package/src/server/tracing.ts +23 -0
  365. package/src/server/tree-builder.ts +92 -58
  366. package/src/server/types.ts +1 -3
  367. package/src/server/version-skew.ts +104 -0
  368. package/src/server/waituntil-bridge.ts +4 -1
  369. package/src/shared/merge-search-params.ts +55 -0
  370. package/src/shims/font-google.ts +1 -1
  371. package/src/shims/navigation-client.ts +1 -1
  372. package/src/shims/navigation.ts +2 -1
  373. package/src/utils/state-machine.ts +111 -0
  374. package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
  375. package/dist/_chunks/debug-gwlJkDuf.js.map +0 -1
  376. package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
  377. package/dist/_chunks/request-context-DIkVh_jG.js.map +0 -1
  378. package/dist/_chunks/ssr-data-MjmprTmO.js +0 -88
  379. package/dist/_chunks/ssr-data-MjmprTmO.js.map +0 -1
  380. package/dist/_chunks/use-cookie-DX-l1_5E.js +0 -91
  381. package/dist/_chunks/use-cookie-DX-l1_5E.js.map +0 -1
  382. package/dist/_chunks/use-query-states-D5KaffOK.js.map +0 -1
  383. package/dist/client/error-boundary.js.map +0 -1
  384. package/dist/client/link-status-provider.d.ts +0 -11
  385. package/dist/client/link-status-provider.d.ts.map +0 -1
  386. package/dist/cookies/index.js.map +0 -1
  387. package/dist/plugins/dynamic-transform.d.ts +0 -72
  388. package/dist/plugins/dynamic-transform.d.ts.map +0 -1
  389. package/dist/search-params/analyze.d.ts +0 -54
  390. package/dist/search-params/analyze.d.ts.map +0 -1
  391. package/dist/search-params/builtin-codecs.d.ts +0 -105
  392. package/dist/search-params/builtin-codecs.d.ts.map +0 -1
  393. package/dist/search-params/create.d.ts +0 -106
  394. package/dist/search-params/create.d.ts.map +0 -1
  395. package/dist/search-params/index.js.map +0 -1
  396. package/dist/server/prerender.d.ts +0 -77
  397. package/dist/server/prerender.d.ts.map +0 -1
  398. package/dist/server/response-cache.d.ts +0 -53
  399. package/dist/server/response-cache.d.ts.map +0 -1
  400. package/src/client/link-status-provider.tsx +0 -30
  401. package/src/plugins/dynamic-transform.ts +0 -161
  402. package/src/search-params/analyze.ts +0 -192
  403. package/src/search-params/builtin-codecs.ts +0 -228
  404. package/src/search-params/create.ts +0 -321
  405. package/src/server/prerender.ts +0 -139
  406. package/src/server/response-cache.ts +0 -277
@@ -8,8 +8,8 @@
8
8
  * No runtime overhead — purely static type generation.
9
9
  */
10
10
 
11
- import { existsSync } from 'node:fs';
12
- import { join, relative, posix } from 'node:path';
11
+ import { existsSync, readFileSync } from 'node:fs';
12
+ import { relative, posix } from 'node:path';
13
13
  import type { RouteTree, SegmentNode } from './types.js';
14
14
 
15
15
  /** A single route entry extracted from the segment tree. */
@@ -18,10 +18,10 @@ interface RouteEntry {
18
18
  urlPath: string;
19
19
  /** Accumulated params from all ancestor dynamic segments */
20
20
  params: ParamEntry[];
21
- /** Whether this route has a co-located search-params.ts */
21
+ /** Whether the page.tsx exports searchParams */
22
22
  hasSearchParams: boolean;
23
- /** Absolute path to search-params.ts (for computing relative import paths) */
24
- searchParamsAbsPath?: string;
23
+ /** Absolute path to the page file that exports searchParams (for import paths) */
24
+ searchParamsPagePath?: string;
25
25
  /** Whether this is an API route (route.ts) vs page route */
26
26
  isApiRoute: boolean;
27
27
  }
@@ -29,15 +29,17 @@ interface RouteEntry {
29
29
  interface ParamEntry {
30
30
  name: string;
31
31
  type: 'string' | 'string[]' | 'string[] | undefined';
32
+ /** When a layout/page exports defineParams, the absolute path to that file. */
33
+ codecFilePath?: string;
32
34
  }
33
35
 
34
36
  /** Options for route map generation. */
35
37
  export interface CodegenOptions {
36
- /** Absolute path to the app/ directory. Required for search-params.ts detection. */
38
+ /** Absolute path to the app/ directory. Required for page searchParams detection. */
37
39
  appDir?: string;
38
40
  /**
39
41
  * Absolute path to the directory where the .d.ts file will be written.
40
- * Used to compute correct relative import paths for search-params.ts files.
42
+ * Used to compute correct relative import paths for page files.
41
43
  * Defaults to appDir when not provided (preserves backward compat for tests).
42
44
  */
43
45
  outputDir?: string;
@@ -51,7 +53,7 @@ export interface CodegenOptions {
51
53
  */
52
54
  export function generateRouteMap(tree: RouteTree, options: CodegenOptions = {}): string {
53
55
  const routes: RouteEntry[] = [];
54
- collectRoutes(tree.root, [], options.appDir, routes);
56
+ collectRoutes(tree.root, [], routes);
55
57
 
56
58
  // Sort routes alphabetically for deterministic output
57
59
  routes.sort((a, b) => a.urlPath.localeCompare(b.urlPath));
@@ -71,15 +73,17 @@ export function generateRouteMap(tree: RouteTree, options: CodegenOptions = {}):
71
73
  function collectRoutes(
72
74
  node: SegmentNode,
73
75
  ancestorParams: ParamEntry[],
74
- appDir: string | undefined,
75
76
  routes: RouteEntry[]
76
77
  ): void {
77
78
  // Accumulate params from this segment
78
79
  const params = [...ancestorParams];
79
80
  if (node.paramName) {
81
+ // Check if layout or page exports a params codec for this segment
82
+ const codecFile = findParamsExport(node);
80
83
  params.push({
81
84
  name: node.paramName,
82
85
  type: paramTypeForSegment(node.segmentType),
86
+ codecFilePath: codecFile,
83
87
  });
84
88
  }
85
89
 
@@ -95,13 +99,14 @@ function collectRoutes(
95
99
  isApiRoute,
96
100
  };
97
101
 
98
- // Detect co-located search-params.ts
99
- if (appDir && isPage) {
100
- const segmentDir = resolveSegmentDir(appDir, node);
101
- const searchParamsFile = findSearchParamsFile(segmentDir);
102
- if (searchParamsFile) {
102
+ // Detect searchParams export from params.ts (primary) or page.tsx (fallback)
103
+ if (isPage) {
104
+ if (node.params && fileHasExport(node.params.filePath, 'searchParams')) {
103
105
  entry.hasSearchParams = true;
104
- entry.searchParamsAbsPath = searchParamsFile;
106
+ entry.searchParamsPagePath = node.params.filePath;
107
+ } else if (node.page && fileHasExport(node.page.filePath, 'searchParams')) {
108
+ entry.hasSearchParams = true;
109
+ entry.searchParamsPagePath = node.page.filePath;
105
110
  }
106
111
  }
107
112
 
@@ -110,12 +115,12 @@ function collectRoutes(
110
115
 
111
116
  // Recurse into children
112
117
  for (const child of node.children) {
113
- collectRoutes(child, params, appDir, routes);
118
+ collectRoutes(child, params, routes);
114
119
  }
115
120
 
116
121
  // Recurse into slots (they share the parent's URL path, but may have their own pages)
117
122
  for (const [, slot] of node.slots) {
118
- collectRoutes(slot, params, appDir, routes);
123
+ collectRoutes(slot, params, routes);
119
124
  }
120
125
  }
121
126
 
@@ -134,33 +139,43 @@ function paramTypeForSegment(segmentType: string): ParamEntry['type'] {
134
139
  }
135
140
 
136
141
  /**
137
- * Resolve the absolute directory path for a segment node.
142
+ * Check if a file exports a specific named export.
138
143
  *
139
- * Reconstructs the filesystem path by walking from appDir through
140
- * the segment names encoded in the urlPath, accounting for groups and slots.
144
+ * Uses a lightweight regex check not full AST parsing. The actual type
145
+ * extraction happens via the TypeScript compiler in the generated .d.ts.
141
146
  */
142
- function resolveSegmentDir(appDir: string, node: SegmentNode): string {
143
- // The node's page/route file path gives us the actual directory
144
- const file = node.page ?? node.route;
145
- if (file) {
146
- // The file is in the segment directory — go up one level
147
- const parts = file.filePath.split('/');
148
- parts.pop(); // remove filename
149
- return parts.join('/');
147
+ function fileHasExport(filePath: string, exportName: string): boolean {
148
+ if (!existsSync(filePath)) return false;
149
+ try {
150
+ const content = readFileSync(filePath, 'utf-8');
151
+ const e = exportName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
152
+ return (
153
+ new RegExp(`export\\s+(const|let|var)\\s+${e}\\b`).test(content) ||
154
+ new RegExp(`export\\s*\\{[^}]*\\b${e}\\b[^}]*\\}`).test(content)
155
+ );
156
+ } catch {
157
+ return false;
150
158
  }
151
- // Fallback: construct from urlPath (imprecise for groups, but acceptable)
152
- return appDir;
153
159
  }
154
160
 
155
161
  /**
156
- * Find a search-params.ts file in a directory.
162
+ * Find which file exports `segmentParams` for a dynamic segment.
163
+ *
164
+ * Priority: params.ts (convention file) > layout > page.
165
+ * params.ts is the canonical location (TIM-508). Layout/page fallback
166
+ * exists for backward compat during migration.
157
167
  */
158
- function findSearchParamsFile(dirPath: string): string | undefined {
159
- for (const ext of ['ts', 'tsx']) {
160
- const candidate = join(dirPath, `search-params.${ext}`);
161
- if (existsSync(candidate)) {
162
- return candidate;
163
- }
168
+ function findParamsExport(node: SegmentNode): string | undefined {
169
+ // params.ts convention file primary location
170
+ if (node.params && fileHasExport(node.params.filePath, 'segmentParams')) {
171
+ return node.params.filePath;
172
+ }
173
+ // Fallback: layout or page export (legacy, will be removed)
174
+ if (node.layout && fileHasExport(node.layout.filePath, 'segmentParams')) {
175
+ return node.layout.filePath;
176
+ }
177
+ if (node.page && fileHasExport(node.page.filePath, 'segmentParams')) {
178
+ return node.page.filePath;
164
179
  }
165
180
  return undefined;
166
181
  }
@@ -184,7 +199,7 @@ function formatDeclarationFile(routes: RouteEntry[], importBase?: string): strin
184
199
  lines.push(' interface Routes {');
185
200
 
186
201
  for (const route of routes) {
187
- const paramsType = formatParamsType(route.params);
202
+ const paramsType = formatParamsType(route.params, importBase);
188
203
  const searchParamsType = formatSearchParamsType(route, importBase);
189
204
 
190
205
  lines.push(` '${route.urlPath}': {`);
@@ -200,15 +215,9 @@ function formatDeclarationFile(routes: RouteEntry[], importBase?: string): strin
200
215
  // Generate @timber-js/app/server augmentation — typed searchParams() generic
201
216
  const pageRoutes = routes.filter((r) => !r.isApiRoute);
202
217
 
203
- if (pageRoutes.length > 0) {
204
- lines.push("declare module '@timber-js/app/server' {");
205
- lines.push(" import type { Routes } from '@timber-js/app'");
206
- lines.push(
207
- " export function searchParams<R extends keyof Routes>(): Promise<Routes[R]['searchParams']>"
208
- );
209
- lines.push('}');
210
- lines.push('');
211
- }
218
+ // Note: searchParams() always returns Promise<URLSearchParams>.
219
+ // Typed parsing is done via definition.parse(searchParams()).
220
+ // No module augmentation needed for @timber-js/app/server.
212
221
 
213
222
  // Generate overloads for @timber-js/app/client
214
223
  const dynamicRoutes = routes.filter((r) => r.params.length > 0);
@@ -223,10 +232,10 @@ function formatDeclarationFile(routes: RouteEntry[], importBase?: string): strin
223
232
  // useParams overloads
224
233
  if (dynamicRoutes.length > 0) {
225
234
  for (const route of dynamicRoutes) {
226
- const paramsType = formatParamsType(route.params);
227
- lines.push(` export function useParams(route: '${route.urlPath}'): ${paramsType}`);
235
+ const paramsType = formatParamsType(route.params, importBase);
236
+ lines.push(` export function useSegmentParams(route: '${route.urlPath}'): ${paramsType}`);
228
237
  }
229
- lines.push(' export function useParams(): Record<string, string | string[]>');
238
+ lines.push(' export function useSegmentParams(): Record<string, string | string[]>');
230
239
  lines.push('');
231
240
  }
232
241
 
@@ -252,12 +261,27 @@ function formatDeclarationFile(routes: RouteEntry[], importBase?: string): strin
252
261
  /**
253
262
  * Format the params type for a route entry.
254
263
  */
255
- function formatParamsType(params: ParamEntry[]): string {
264
+ function formatParamsType(params: ParamEntry[], importBase?: string): string {
256
265
  if (params.length === 0) {
257
266
  return '{}';
258
267
  }
259
268
 
260
- const fields = params.map((p) => `${p.name}: ${p.type}`);
269
+ const fields = params.map((p) => {
270
+ if (p.codecFilePath) {
271
+ // Use the codec's inferred type from the layout/page file
272
+ const absPath = p.codecFilePath.replace(/\.(ts|tsx)$/, '');
273
+ let importPath: string;
274
+ if (importBase) {
275
+ importPath = './' + relative(importBase, absPath).replace(/\\/g, '/');
276
+ } else {
277
+ importPath = './' + posix.basename(absPath);
278
+ }
279
+ // Extract T from the 'segmentParams' named export's ParamsDefinition<T>
280
+ const codecType = `(typeof import('${importPath}'))['segmentParams'] extends import('@timber-js/app/params').ParamsDefinition<infer T> ? T[${JSON.stringify(p.name)}] : ${p.type}`;
281
+ return `${p.name}: ${codecType}`;
282
+ }
283
+ return `${p.name}: ${p.type}`;
284
+ });
261
285
  return `{ ${fields.join('; ')} }`;
262
286
  }
263
287
 
@@ -270,12 +294,24 @@ function formatParamsType(params: ParamEntry[]): string {
270
294
  *
271
295
  * See design/07-routing.md §"Typed params and searchParams on <Link>"
272
296
  */
273
- function formatLinkParamsType(params: ParamEntry[]): string {
297
+ function formatLinkParamsType(params: ParamEntry[], importBase?: string): string {
274
298
  if (params.length === 0) {
275
299
  return '{}';
276
300
  }
277
301
 
278
302
  const fields = params.map((p) => {
303
+ if (p.codecFilePath) {
304
+ // With a codec, Link params use the codec's output type
305
+ const absPath = p.codecFilePath.replace(/\.(ts|tsx)$/, '');
306
+ let importPath: string;
307
+ if (importBase) {
308
+ importPath = './' + relative(importBase, absPath).replace(/\\/g, '/');
309
+ } else {
310
+ importPath = './' + posix.basename(absPath);
311
+ }
312
+ const codecType = `(typeof import('${importPath}'))['segmentParams'] extends import('@timber-js/app/params').ParamsDefinition<infer T> ? T[${JSON.stringify(p.name)}] : ${p.type}`;
313
+ return `${p.name}: ${codecType}`;
314
+ }
279
315
  // Single dynamic segments accept string | number for convenience
280
316
  const type = p.type === 'string' ? 'string | number' : p.type;
281
317
  return `${p.name}: ${type}`;
@@ -286,13 +322,13 @@ function formatLinkParamsType(params: ParamEntry[]): string {
286
322
  /**
287
323
  * Format the searchParams type for a route entry.
288
324
  *
289
- * When a search-params.ts exists, we reference its inferred type via an import type.
325
+ * When a page.tsx exports searchParams, we reference its inferred type via an import type.
290
326
  * The import path is relative to `importBase` (the directory where the .d.ts will be
291
327
  * written). When importBase is undefined, falls back to a bare relative path.
292
328
  */
293
329
  function formatSearchParamsType(route: RouteEntry, importBase?: string): string {
294
- if (route.hasSearchParams && route.searchParamsAbsPath) {
295
- const absPath = route.searchParamsAbsPath.replace(/\.(ts|tsx)$/, '');
330
+ if (route.hasSearchParams && route.searchParamsPagePath) {
331
+ const absPath = route.searchParamsPagePath.replace(/\.(ts|tsx)$/, '');
296
332
  let importPath: string;
297
333
  if (importBase) {
298
334
  // Make the path relative to the output directory, converted to posix separators
@@ -300,10 +336,8 @@ function formatSearchParamsType(route: RouteEntry, importBase?: string): string
300
336
  } else {
301
337
  importPath = './' + posix.basename(absPath);
302
338
  }
303
- // Use (typeof import('...'))[' default'] instead of import('...').default
304
- // because with moduleResolution:"bundler", import('...').default is treated as
305
- // a namespace member access which doesn't work for default exports.
306
- return `(typeof import('${importPath}'))['default'] extends import('@timber-js/app/search-params').SearchParamsDefinition<infer T> ? T : never`;
339
+ // Extract the type from the named 'searchParams' export of the page module.
340
+ return `(typeof import('${importPath}'))['searchParams'] extends import('@timber-js/app/search-params').SearchParamsDefinition<infer T> ? T : never`;
307
341
  }
308
342
  return '{}';
309
343
  }
@@ -353,38 +387,25 @@ function formatTypedLinkOverloads(routes: RouteEntry[], importBase?: string): st
353
387
 
354
388
  for (const route of routes) {
355
389
  const hasDynamicParams = route.params.length > 0;
356
- const paramsType = formatLinkParamsType(route.params);
390
+ const paramsProp = hasDynamicParams
391
+ ? `segmentParams: ${formatLinkParamsType(route.params, importBase)}`
392
+ : 'segmentParams?: never';
393
+
357
394
  const searchParamsType = route.hasSearchParams
358
395
  ? formatSearchParamsType(route, importBase)
359
396
  : null;
397
+ const searchParamsProp = searchParamsType
398
+ ? `searchParams?: { definition: SearchParamsDefinition<${searchParamsType}>; values: Partial<${searchParamsType}> }`
399
+ : 'searchParams?: never';
360
400
 
361
- if (hasDynamicParams) {
362
- // Route with dynamic segments params prop required
363
- const spProp = searchParamsType
364
- ? `searchParams?: { definition: SearchParamsDefinition<${searchParamsType}>; values: Partial<${searchParamsType}> }`
365
- : `searchParams?: never`;
366
- lines.push(
367
- ` export function Link(props: Omit<import('react').AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> & {`
368
- );
369
- lines.push(` href: '${route.urlPath}'`);
370
- lines.push(` params: ${paramsType}`);
371
- lines.push(` ${spProp}`);
372
- lines.push(` prefetch?: boolean; scroll?: boolean; children?: import('react').ReactNode`);
373
- lines.push(` }): import('react').JSX.Element`);
374
- } else {
375
- // Static route — no params needed
376
- const spProp = searchParamsType
377
- ? `searchParams?: { definition: SearchParamsDefinition<${searchParamsType}>; values: Partial<${searchParamsType}> }`
378
- : `searchParams?: never`;
379
- lines.push(
380
- ` export function Link(props: Omit<import('react').AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> & {`
381
- );
382
- lines.push(` href: '${route.urlPath}'`);
383
- lines.push(` params?: never`);
384
- lines.push(` ${spProp}`);
385
- lines.push(` prefetch?: boolean; scroll?: boolean; children?: import('react').ReactNode`);
386
- lines.push(` }): import('react').JSX.Element`);
387
- }
401
+ lines.push(
402
+ ` export function Link(props: Omit<import('react').AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> & {`
403
+ );
404
+ lines.push(` href: '${route.urlPath}'`);
405
+ lines.push(` ${paramsProp}`);
406
+ lines.push(` ${searchParamsProp}`);
407
+ lines.push(` prefetch?: boolean; scroll?: boolean; children?: import('react').ReactNode`);
408
+ lines.push(` }): import('react').JSX.Element`);
388
409
  }
389
410
 
390
411
  // Fallback overload for arbitrary string hrefs (escape hatch)
@@ -19,7 +19,7 @@ import type {
19
19
  InterceptionMarker,
20
20
  } from './types.js';
21
21
  import { DEFAULT_PAGE_EXTENSIONS, INTERCEPTION_MARKERS } from './types.js';
22
- import { classifyMetadataRoute, isDynamicMetadataExtension } from '#/server/metadata-routes.js';
22
+ import { classifyMetadataRoute, isDynamicMetadataExtension } from '../server/metadata-routes.js';
23
23
 
24
24
  /**
25
25
  * Pattern matching encoded path delimiters that must be rejected during route discovery.
@@ -53,7 +53,7 @@ const LEGACY_STATUS_FILES: Record<string, number> = {
53
53
  /**
54
54
  * File convention names that are always .ts/.tsx (never .mdx etc.)
55
55
  */
56
- const FIXED_CONVENTIONS = new Set(['middleware', 'access', 'route', 'prerender', 'search-params']);
56
+ const FIXED_CONVENTIONS = new Set(['middleware', 'access', 'route', 'params']);
57
57
 
58
58
  /**
59
59
  * Status-code file patterns:
@@ -83,6 +83,14 @@ export function scanRoutes(appDir: string, config: ScannerConfig = {}): RouteTre
83
83
  tree.proxy = proxyFile;
84
84
  }
85
85
 
86
+ // Check for global-error.{tsx,ts,jsx,js} at app root.
87
+ // Tier 2 error page — renders standalone (no layouts) when no segment-level
88
+ // error file is found. See design/10-error-handling.md §"Tier 2".
89
+ const globalErrorFile = findPageExtFile(appDir, 'global-error', extSet);
90
+ if (globalErrorFile) {
91
+ tree.globalError = globalErrorFile;
92
+ }
93
+
86
94
  // Scan the root directory's files
87
95
  scanSegmentFiles(appDir, tree.root, extSet);
88
96
 
@@ -92,6 +100,10 @@ export function scanRoutes(appDir: string, config: ScannerConfig = {}): RouteTre
92
100
  // Validate: detect route group collisions (different groups producing pages at the same URL)
93
101
  validateRouteGroupCollisions(tree.root);
94
102
 
103
+ // Validate: detect duplicate param names in nested dynamic segments
104
+ // e.g., /[id]/items/[id] — same param name in ancestor and descendant
105
+ validateDuplicateParamNames(tree.root);
106
+
95
107
  return tree;
96
108
  }
97
109
 
@@ -278,11 +290,8 @@ function scanSegmentFiles(dirPath: string, node: SegmentNode, extSet: Set<string
278
290
  case 'route':
279
291
  node.route = file;
280
292
  break;
281
- case 'prerender':
282
- node.prerender = file;
283
- break;
284
- case 'search-params':
285
- node.searchParams = file;
293
+ case 'params':
294
+ node.params = file;
286
295
  break;
287
296
  }
288
297
  continue;
@@ -482,6 +491,54 @@ function collectRoutableLeaves(
482
491
  }
483
492
  }
484
493
 
494
+ /**
495
+ * Validate that no route chain contains duplicate dynamic param names.
496
+ *
497
+ * Example violation:
498
+ * app/[id]/items/[id]/page.tsx — 'id' appears twice in the ancestor chain.
499
+ *
500
+ * Route groups are transparent — params accumulate through them.
501
+ * Slots are independent — duplicate detection does NOT cross slot boundaries.
502
+ *
503
+ * See design/07-routing.md §"Duplicate Param Name Detection"
504
+ */
505
+ function validateDuplicateParamNames(root: SegmentNode): void {
506
+ walkForDuplicateParams(root, new Map());
507
+ }
508
+
509
+ /**
510
+ * Recursively walk the segment tree, tracking seen param names → segment paths.
511
+ * Throws on the first duplicate found.
512
+ */
513
+ function walkForDuplicateParams(node: SegmentNode, seen: Map<string, string>): void {
514
+ // If this node introduces a param name, check for duplicates
515
+ if (node.paramName) {
516
+ const existing = seen.get(node.paramName);
517
+ if (existing) {
518
+ throw new Error(
519
+ `[timber] Duplicate param name '${node.paramName}' in route chain.\n` +
520
+ ` First defined at: ${existing}\n` +
521
+ ` Duplicate at: ${node.urlPath || '/'}\n` +
522
+ ` Rename one of the segments to avoid ambiguity.`
523
+ );
524
+ }
525
+ // Add to seen for descendants (use a new Map to avoid polluting siblings)
526
+ seen = new Map(seen);
527
+ seen.set(node.paramName, node.urlPath || '/');
528
+ }
529
+
530
+ // Recurse into children (they inherit the accumulated params)
531
+ for (const child of node.children) {
532
+ walkForDuplicateParams(child, seen);
533
+ }
534
+
535
+ // Slots are independent parallel routes — start fresh param tracking
536
+ // (a slot's params don't conflict with the main route's params)
537
+ for (const [, slotNode] of node.slots) {
538
+ walkForDuplicateParams(slotNode, new Map(seen));
539
+ }
540
+ }
541
+
485
542
  /**
486
543
  * Find a fixed-extension file (proxy.ts) in a directory.
487
544
  */
@@ -498,3 +555,25 @@ function findFixedFile(dirPath: string, name: string): RouteFile | undefined {
498
555
  }
499
556
  return undefined;
500
557
  }
558
+
559
+ /**
560
+ * Find a file using the configured page extensions (tsx, ts, jsx, js, mdx, etc.).
561
+ * Used for app-root conventions like global-error that aren't per-segment.
562
+ */
563
+ function findPageExtFile(
564
+ dirPath: string,
565
+ name: string,
566
+ extSet: Set<string>
567
+ ): RouteFile | undefined {
568
+ for (const ext of extSet) {
569
+ const fullPath = join(dirPath, `${name}.${ext}`);
570
+ try {
571
+ if (statSync(fullPath).isFile()) {
572
+ return { filePath: fullPath, extension: ext };
573
+ }
574
+ } catch {
575
+ // File doesn't exist
576
+ }
577
+ }
578
+ return undefined;
579
+ }
@@ -15,7 +15,7 @@
15
15
 
16
16
  import { readFileSync } from 'node:fs';
17
17
  import type { RouteTree, SegmentNode } from './types.js';
18
- import { detectFileDirective } from '#/utils/directive-parser.js';
18
+ import { detectFileDirective } from '../utils/directive-parser.js';
19
19
 
20
20
  /** Extensions that require 'use client' (component files, not MDX/JSON). */
21
21
  const CLIENT_REQUIRED_EXTENSIONS = new Set(['tsx', 'jsx', 'ts', 'js']);
@@ -31,7 +31,8 @@ export interface StatusFileLintWarning {
31
31
  * that are missing it.
32
32
  *
33
33
  * MDX and JSON status files are excluded — MDX files are server components
34
- * by design, and JSON files are data, not components.
34
+ * by design (pre-rendered as elements via fallbackElement, see TIM-503),
35
+ * and JSON files are data, not components.
35
36
  */
36
37
  export function lintStatusFileDirectives(tree: RouteTree): StatusFileLintWarning[] {
37
38
  const warnings: StatusFileLintWarning[] = [];
@@ -59,6 +59,12 @@ export interface SegmentNode {
59
59
  middleware?: RouteFile;
60
60
  access?: RouteFile;
61
61
  route?: RouteFile;
62
+ /**
63
+ * params.ts — isomorphic convention file exporting segmentParams and/or searchParams.
64
+ * Discovered by the scanner like middleware.ts and access.ts.
65
+ * See design/07-routing.md §"params.ts Convention File"
66
+ */
67
+ params?: RouteFile;
62
68
  error?: RouteFile;
63
69
  default?: RouteFile;
64
70
  /** Status-code files: 4xx.tsx, 5xx.tsx, {status}.tsx (component format) */
@@ -69,10 +75,7 @@ export interface SegmentNode {
69
75
  denied?: RouteFile;
70
76
  /** Legacy compat: not-found.tsx (maps to 404), forbidden.tsx (403), unauthorized.tsx (401) */
71
77
  legacyStatusFiles?: Map<string, RouteFile>;
72
- /** prerender.ts — signals build-time pre-rendering for this segment's shell */
73
- prerender?: RouteFile;
74
- /** search-params.ts — typed search params definition for this route */
75
- searchParams?: RouteFile;
78
+
76
79
  /** Metadata route files (sitemap.ts, robots.ts, icon.tsx, etc.) keyed by base name */
77
80
  metadataRoutes?: Map<string, RouteFile>;
78
81
 
@@ -88,6 +91,16 @@ export interface RouteTree {
88
91
  root: SegmentNode;
89
92
  /** All discovered proxy.ts files (should be at most one, in app/) */
90
93
  proxy?: RouteFile;
94
+ /**
95
+ * Global error page: app/global-error.{tsx,ts,jsx,js}
96
+ *
97
+ * Rendered as a standalone full-page replacement (no layout wrapping)
98
+ * when no segment-level error file is found. SSR-only render path.
99
+ * Must provide its own <html> and <body>.
100
+ *
101
+ * See design/10-error-handling.md §"Tier 2 — Global Error Page"
102
+ */
103
+ globalError?: RouteFile;
91
104
  }
92
105
 
93
106
  /** Configuration passed to the scanner */
@@ -16,4 +16,6 @@ export {
16
16
  loadServerAction,
17
17
  decodeReply,
18
18
  decodeAction,
19
+ encryptActionBoundArgs,
20
+ decryptActionBoundArgs,
19
21
  } from '@vitejs/plugin-rsc/rsc';
@@ -11,3 +11,53 @@
11
11
  */
12
12
 
13
13
  export { createFromReadableStream } from '@vitejs/plugin-rsc/ssr';
14
+
15
+ // ─── Node.js Stream Path ─────────────────────────────────────────────────────
16
+ //
17
+ // On Node.js, createFromNodeStream reads RSC Flight data from a Node.js
18
+ // Readable (C++ backed) instead of a Web ReadableStream (JS reimplementation).
19
+ // Eliminates Promise-per-chunk overhead on the SSR decode path.
20
+ //
21
+ // The plugin only exports createFromReadableStream (via client.edge.js).
22
+ // createFromNodeStream lives in the vendored client.node.js. We import it
23
+ // directly and wire up the same serverConsumerManifest the plugin uses.
24
+
25
+ import { createServerConsumerManifest } from '@vitejs/plugin-rsc/ssr';
26
+
27
+ type CreateFromNodeStreamFn = (
28
+ stream: import('node:stream').Readable,
29
+ manifest: ReturnType<typeof createServerConsumerManifest>,
30
+ options?: Record<string, unknown>
31
+ ) => React.ReactNode;
32
+
33
+ let _createFromNodeStream: CreateFromNodeStreamFn | null = null;
34
+
35
+ try {
36
+ if (typeof process !== 'undefined' && process.release?.name === 'node') {
37
+ const clientNode = await import('@vitejs/plugin-rsc/vendor/react-server-dom/client.node');
38
+ if (typeof clientNode.createFromNodeStream === 'function') {
39
+ _createFromNodeStream = clientNode.createFromNodeStream;
40
+ }
41
+ }
42
+ } catch {
43
+ // Not available — fall back to createFromReadableStream
44
+ }
45
+
46
+ /**
47
+ * Decode an RSC Flight stream from a Node.js Readable.
48
+ *
49
+ * Uses the vendored createFromNodeStream which reads via Node.js native
50
+ * streams (C++ libuv) instead of Web ReadableStream (JS Promise per chunk).
51
+ *
52
+ * Returns null if createFromNodeStream isn't available (CF Workers, etc),
53
+ * signaling the caller to use createFromReadableStream instead.
54
+ */
55
+ export function createFromNodeStream(
56
+ stream: import('node:stream').Readable
57
+ ): React.ReactNode | null {
58
+ if (!_createFromNodeStream) return null;
59
+ return _createFromNodeStream(stream, createServerConsumerManifest());
60
+ }
61
+
62
+ /** Whether the Node.js stream RSC decode path is available. */
63
+ export const hasNodeStreamDecode = _createFromNodeStream !== null;
@@ -0,0 +1,7 @@
1
+ declare module '@vitejs/plugin-rsc/vendor/react-server-dom/client.node' {
2
+ export function createFromNodeStream(
3
+ stream: import('node:stream').Readable,
4
+ manifest: unknown,
5
+ options?: Record<string, unknown>
6
+ ): React.ReactNode;
7
+ }
@@ -5,7 +5,7 @@
5
5
  * Design doc: design/09-typescript.md §"The SearchParamCodec Protocol"
6
6
  */
7
7
 
8
- import type { SearchParamCodec } from './create.js';
8
+ import type { SearchParamCodec } from './define.js';
9
9
 
10
10
  // ---------------------------------------------------------------------------
11
11
  // Standard Schema interface (subset)