@timber-js/app 0.2.0-alpha.10 → 0.2.0-alpha.101

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 (729) hide show
  1. package/LICENSE +8 -0
  2. package/dist/_chunks/actions-BsfxK6yu.js +1061 -0
  3. package/dist/_chunks/actions-BsfxK6yu.js.map +1 -0
  4. package/dist/_chunks/build-output-helper-DXnW0qjz.js +61 -0
  5. package/dist/_chunks/build-output-helper-DXnW0qjz.js.map +1 -0
  6. package/dist/_chunks/chunk-Cfpv9whK.js +32 -0
  7. package/dist/_chunks/define-B-Q_UMOD.js +195 -0
  8. package/dist/_chunks/define-B-Q_UMOD.js.map +1 -0
  9. package/dist/_chunks/define-cookie-BjpIt4UC.js +194 -0
  10. package/dist/_chunks/define-cookie-BjpIt4UC.js.map +1 -0
  11. package/dist/_chunks/define-k32T6NL2.js +123 -0
  12. package/dist/_chunks/define-k32T6NL2.js.map +1 -0
  13. package/dist/_chunks/format-Bcn-Iv1x.js +14 -0
  14. package/dist/_chunks/format-Bcn-Iv1x.js.map +1 -0
  15. package/dist/_chunks/handler-store-B-lqaGyh.js +54 -0
  16. package/dist/_chunks/handler-store-B-lqaGyh.js.map +1 -0
  17. package/dist/_chunks/logger-0m8MsKdc.js +291 -0
  18. package/dist/_chunks/logger-0m8MsKdc.js.map +1 -0
  19. package/dist/_chunks/merge-search-params-BphMdht_.js +122 -0
  20. package/dist/_chunks/merge-search-params-BphMdht_.js.map +1 -0
  21. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js → metadata-routes-BU684ls2.js} +1 -1
  22. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js.map → metadata-routes-BU684ls2.js.map} +1 -1
  23. package/dist/_chunks/navigation-root-yx917rG0.js +96 -0
  24. package/dist/_chunks/navigation-root-yx917rG0.js.map +1 -0
  25. package/dist/_chunks/registry-I2ss-lvy.js +20 -0
  26. package/dist/_chunks/registry-I2ss-lvy.js.map +1 -0
  27. package/dist/_chunks/router-ref-h3-UaCQv.js +28 -0
  28. package/dist/_chunks/router-ref-h3-UaCQv.js.map +1 -0
  29. package/dist/_chunks/schema-bridge-Cxu4l-7p.js +86 -0
  30. package/dist/_chunks/schema-bridge-Cxu4l-7p.js.map +1 -0
  31. package/dist/_chunks/segment-classify-BjfuctV2.js +137 -0
  32. package/dist/_chunks/segment-classify-BjfuctV2.js.map +1 -0
  33. package/dist/_chunks/segment-context-Dx_OizxD.js +34 -0
  34. package/dist/_chunks/segment-context-Dx_OizxD.js.map +1 -0
  35. package/dist/_chunks/{ssr-data-MjmprTmO.js → ssr-data-B4CdH7rE.js} +1 -1
  36. package/dist/_chunks/ssr-data-B4CdH7rE.js.map +1 -0
  37. package/dist/_chunks/stale-reload-Bab885FO.js +64 -0
  38. package/dist/_chunks/stale-reload-Bab885FO.js.map +1 -0
  39. package/dist/_chunks/tracing-C8V-YGsP.js +329 -0
  40. package/dist/_chunks/tracing-C8V-YGsP.js.map +1 -0
  41. package/dist/_chunks/{use-query-states-D5KaffOK.js → use-query-states-B2XTqxDR.js} +7 -20
  42. package/dist/_chunks/use-query-states-B2XTqxDR.js.map +1 -0
  43. package/dist/_chunks/use-segment-params-DlsOX1YS.js +185 -0
  44. package/dist/_chunks/use-segment-params-DlsOX1YS.js.map +1 -0
  45. package/dist/_chunks/walkers-Tg0Alwcg.js +850 -0
  46. package/dist/_chunks/walkers-Tg0Alwcg.js.map +1 -0
  47. package/dist/_chunks/{format-DviM89f0.js → warnings-Cg47l5sk.js} +6 -45
  48. package/dist/_chunks/warnings-Cg47l5sk.js.map +1 -0
  49. package/dist/adapters/build-output-helper.d.ts +28 -0
  50. package/dist/adapters/build-output-helper.d.ts.map +1 -0
  51. package/dist/adapters/cloudflare-dev.d.ts +109 -0
  52. package/dist/adapters/cloudflare-dev.d.ts.map +1 -0
  53. package/dist/adapters/cloudflare-dev.js +73 -0
  54. package/dist/adapters/cloudflare-dev.js.map +1 -0
  55. package/dist/adapters/cloudflare-kv-cache.d.ts +64 -0
  56. package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -0
  57. package/dist/adapters/cloudflare-kv-cache.js +95 -0
  58. package/dist/adapters/cloudflare-kv-cache.js.map +1 -0
  59. package/dist/adapters/cloudflare.d.ts +148 -12
  60. package/dist/adapters/cloudflare.d.ts.map +1 -1
  61. package/dist/adapters/cloudflare.js +142 -38
  62. package/dist/adapters/cloudflare.js.map +1 -1
  63. package/dist/adapters/compress-module.d.ts.map +1 -1
  64. package/dist/adapters/nitro.d.ts +17 -1
  65. package/dist/adapters/nitro.d.ts.map +1 -1
  66. package/dist/adapters/nitro.js +143 -45
  67. package/dist/adapters/nitro.js.map +1 -1
  68. package/dist/adapters/shared.d.ts +16 -0
  69. package/dist/adapters/shared.d.ts.map +1 -0
  70. package/dist/cache/cache-api.d.ts +24 -0
  71. package/dist/cache/cache-api.d.ts.map +1 -0
  72. package/dist/cache/handler-store.d.ts +31 -0
  73. package/dist/cache/handler-store.d.ts.map +1 -0
  74. package/dist/cache/index.d.ts +23 -7
  75. package/dist/cache/index.d.ts.map +1 -1
  76. package/dist/cache/index.js +150 -81
  77. package/dist/cache/index.js.map +1 -1
  78. package/dist/cache/singleflight.d.ts +18 -1
  79. package/dist/cache/singleflight.d.ts.map +1 -1
  80. package/dist/cache/sizeof.d.ts +22 -0
  81. package/dist/cache/sizeof.d.ts.map +1 -0
  82. package/dist/cache/timber-cache.d.ts +1 -1
  83. package/dist/cache/timber-cache.d.ts.map +1 -1
  84. package/dist/cli.d.ts +6 -1
  85. package/dist/cli.d.ts.map +1 -1
  86. package/dist/cli.js +8 -3
  87. package/dist/cli.js.map +1 -1
  88. package/dist/client/browser-dev.d.ts +34 -1
  89. package/dist/client/browser-dev.d.ts.map +1 -1
  90. package/dist/client/browser-entry/action-dispatch.d.ts +17 -0
  91. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -0
  92. package/dist/client/browser-entry/hmr.d.ts +21 -0
  93. package/dist/client/browser-entry/hmr.d.ts.map +1 -0
  94. package/dist/client/browser-entry/hydrate.d.ts +46 -0
  95. package/dist/client/browser-entry/hydrate.d.ts.map +1 -0
  96. package/dist/client/browser-entry/index.d.ts +30 -0
  97. package/dist/client/browser-entry/index.d.ts.map +1 -0
  98. package/dist/client/browser-entry/post-hydration.d.ts +26 -0
  99. package/dist/client/browser-entry/post-hydration.d.ts.map +1 -0
  100. package/dist/client/browser-entry/router-init.d.ts +23 -0
  101. package/dist/client/browser-entry/router-init.d.ts.map +1 -0
  102. package/dist/client/browser-entry/rsc-stream.d.ts +24 -0
  103. package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -0
  104. package/dist/client/browser-entry/scroll.d.ts +19 -0
  105. package/dist/client/browser-entry/scroll.d.ts.map +1 -0
  106. package/dist/client/error-boundary.d.ts +12 -5
  107. package/dist/client/error-boundary.d.ts.map +1 -1
  108. package/dist/client/error-boundary.js +26 -5
  109. package/dist/client/error-boundary.js.map +1 -1
  110. package/dist/client/error-reconstituter.d.ts +54 -0
  111. package/dist/client/error-reconstituter.d.ts.map +1 -0
  112. package/dist/client/form.d.ts +16 -27
  113. package/dist/client/form.d.ts.map +1 -1
  114. package/dist/client/history.d.ts +19 -4
  115. package/dist/client/history.d.ts.map +1 -1
  116. package/dist/client/index.d.ts +9 -24
  117. package/dist/client/index.d.ts.map +1 -1
  118. package/dist/client/index.js +261 -1100
  119. package/dist/client/index.js.map +1 -1
  120. package/dist/client/internal.d.ts +19 -0
  121. package/dist/client/internal.d.ts.map +1 -0
  122. package/dist/client/internal.js +964 -0
  123. package/dist/client/internal.js.map +1 -0
  124. package/dist/client/link-pending-store.d.ts +63 -0
  125. package/dist/client/link-pending-store.d.ts.map +1 -0
  126. package/dist/client/link.d.ts +62 -55
  127. package/dist/client/link.d.ts.map +1 -1
  128. package/dist/client/nav-link-store.d.ts +36 -0
  129. package/dist/client/nav-link-store.d.ts.map +1 -0
  130. package/dist/client/navigation-api-types.d.ts +90 -0
  131. package/dist/client/navigation-api-types.d.ts.map +1 -0
  132. package/dist/client/navigation-api.d.ts +115 -0
  133. package/dist/client/navigation-api.d.ts.map +1 -0
  134. package/dist/client/navigation-context.d.ts +13 -2
  135. package/dist/client/navigation-context.d.ts.map +1 -1
  136. package/dist/client/{transition-root.d.ts → navigation-root.d.ts} +42 -8
  137. package/dist/client/navigation-root.d.ts.map +1 -0
  138. package/dist/client/nuqs-adapter.d.ts.map +1 -1
  139. package/dist/client/router-ref.d.ts +1 -1
  140. package/dist/client/router.d.ts +70 -4
  141. package/dist/client/router.d.ts.map +1 -1
  142. package/dist/client/rsc-fetch.d.ts +38 -3
  143. package/dist/client/rsc-fetch.d.ts.map +1 -1
  144. package/dist/client/segment-cache.d.ts +1 -1
  145. package/dist/client/segment-cache.d.ts.map +1 -1
  146. package/dist/client/segment-outlet.d.ts +63 -0
  147. package/dist/client/segment-outlet.d.ts.map +1 -0
  148. package/dist/client/ssr-data.d.ts +13 -4
  149. package/dist/client/ssr-data.d.ts.map +1 -1
  150. package/dist/client/stale-reload.d.ts +15 -0
  151. package/dist/client/stale-reload.d.ts.map +1 -1
  152. package/dist/client/state.d.ts +1 -1
  153. package/dist/client/top-loader.d.ts +5 -5
  154. package/dist/client/top-loader.d.ts.map +1 -1
  155. package/dist/client/use-cookie.d.ts +8 -0
  156. package/dist/client/use-cookie.d.ts.map +1 -1
  157. package/dist/client/use-link-status.d.ts +5 -5
  158. package/dist/client/use-link-status.d.ts.map +1 -1
  159. package/dist/client/{use-navigation-pending.d.ts → use-pending-navigation.d.ts} +4 -4
  160. package/dist/client/use-pending-navigation.d.ts.map +1 -0
  161. package/dist/client/use-query-states.d.ts +1 -1
  162. package/dist/client/use-query-states.d.ts.map +1 -1
  163. package/dist/client/use-router.d.ts +1 -1
  164. package/dist/client/{use-params.d.ts → use-segment-params.d.ts} +7 -5
  165. package/dist/client/use-segment-params.d.ts.map +1 -0
  166. package/dist/codec.d.ts +33 -0
  167. package/dist/codec.d.ts.map +1 -0
  168. package/dist/codec.js +2 -0
  169. package/dist/config-types.d.ts +294 -0
  170. package/dist/config-types.d.ts.map +1 -0
  171. package/dist/config-validation.d.ts +51 -0
  172. package/dist/config-validation.d.ts.map +1 -0
  173. package/dist/content/index.d.ts +1 -10
  174. package/dist/content/index.d.ts.map +1 -1
  175. package/dist/content/index.js +0 -2
  176. package/dist/cookies/define-cookie.d.ts +98 -25
  177. package/dist/cookies/define-cookie.d.ts.map +1 -1
  178. package/dist/cookies/index.d.ts +2 -1
  179. package/dist/cookies/index.d.ts.map +1 -1
  180. package/dist/cookies/index.js +36 -72
  181. package/dist/cookies/index.js.map +1 -1
  182. package/dist/cookies/json-cookie.d.ts +64 -0
  183. package/dist/cookies/json-cookie.d.ts.map +1 -0
  184. package/dist/cookies/validation.d.ts +46 -0
  185. package/dist/cookies/validation.d.ts.map +1 -0
  186. package/dist/dev-tools/404-page.d.ts +46 -0
  187. package/dist/dev-tools/404-page.d.ts.map +1 -0
  188. package/dist/dev-tools/browser-logs.d.ts +84 -0
  189. package/dist/dev-tools/browser-logs.d.ts.map +1 -0
  190. package/dist/dev-tools/error-page.d.ts +58 -0
  191. package/dist/dev-tools/error-page.d.ts.map +1 -0
  192. package/dist/dev-tools/holding-server.d.ts +54 -0
  193. package/dist/dev-tools/holding-server.d.ts.map +1 -0
  194. package/dist/dev-tools/index.d.ts +31 -0
  195. package/dist/dev-tools/index.d.ts.map +1 -0
  196. package/dist/{server/dev-span-processor.d.ts → dev-tools/instrumentation.d.ts} +26 -6
  197. package/dist/dev-tools/instrumentation.d.ts.map +1 -0
  198. package/dist/{server/dev-logger.d.ts → dev-tools/logger.d.ts} +1 -1
  199. package/dist/dev-tools/logger.d.ts.map +1 -0
  200. package/dist/{plugins/dev-logs.d.ts → dev-tools/logs.d.ts} +2 -2
  201. package/dist/dev-tools/logs.d.ts.map +1 -0
  202. package/dist/dev-tools/overlay.d.ts +91 -0
  203. package/dist/dev-tools/overlay.d.ts.map +1 -0
  204. package/dist/dev-tools/stack-classifier.d.ts +34 -0
  205. package/dist/dev-tools/stack-classifier.d.ts.map +1 -0
  206. package/dist/dev-tools/terminal.d.ts +28 -0
  207. package/dist/dev-tools/terminal.d.ts.map +1 -0
  208. package/dist/{server/dev-warnings.d.ts → dev-tools/warnings.d.ts} +2 -22
  209. package/dist/dev-tools/warnings.d.ts.map +1 -0
  210. package/dist/fonts/ast.d.ts +98 -6
  211. package/dist/fonts/ast.d.ts.map +1 -1
  212. package/dist/fonts/bundle.d.ts +48 -0
  213. package/dist/fonts/bundle.d.ts.map +1 -0
  214. package/dist/fonts/css.d.ts +1 -0
  215. package/dist/fonts/css.d.ts.map +1 -1
  216. package/dist/fonts/dev-middleware.d.ts +22 -0
  217. package/dist/fonts/dev-middleware.d.ts.map +1 -0
  218. package/dist/fonts/local.d.ts +1 -1
  219. package/dist/fonts/pipeline.d.ts +167 -0
  220. package/dist/fonts/pipeline.d.ts.map +1 -0
  221. package/dist/fonts/transform.d.ts +78 -0
  222. package/dist/fonts/transform.d.ts.map +1 -0
  223. package/dist/fonts/types.d.ts +45 -1
  224. package/dist/fonts/types.d.ts.map +1 -1
  225. package/dist/fonts/virtual-modules.d.ts +103 -0
  226. package/dist/fonts/virtual-modules.d.ts.map +1 -0
  227. package/dist/index.d.ts +46 -190
  228. package/dist/index.d.ts.map +1 -1
  229. package/dist/index.js +5348 -13285
  230. package/dist/index.js.map +1 -1
  231. package/dist/plugin-context.d.ts +107 -0
  232. package/dist/plugin-context.d.ts.map +1 -0
  233. package/dist/plugins/adapter-build.d.ts +1 -1
  234. package/dist/plugins/adapter-build.d.ts.map +1 -1
  235. package/dist/plugins/build-manifest.d.ts +2 -2
  236. package/dist/plugins/build-manifest.d.ts.map +1 -1
  237. package/dist/plugins/build-report.d.ts +9 -7
  238. package/dist/plugins/build-report.d.ts.map +1 -1
  239. package/dist/plugins/client-chunks.d.ts +32 -0
  240. package/dist/plugins/client-chunks.d.ts.map +1 -0
  241. package/dist/plugins/content.d.ts +1 -1
  242. package/dist/plugins/content.d.ts.map +1 -1
  243. package/dist/plugins/dev-server.d.ts +1 -1
  244. package/dist/plugins/dev-server.d.ts.map +1 -1
  245. package/dist/plugins/entries.d.ts +1 -1
  246. package/dist/plugins/entries.d.ts.map +1 -1
  247. package/dist/plugins/fonts.d.ts +17 -73
  248. package/dist/plugins/fonts.d.ts.map +1 -1
  249. package/dist/plugins/mdx.d.ts +1 -1
  250. package/dist/plugins/mdx.d.ts.map +1 -1
  251. package/dist/plugins/routing.d.ts +1 -1
  252. package/dist/plugins/routing.d.ts.map +1 -1
  253. package/dist/plugins/server-bundle.d.ts.map +1 -1
  254. package/dist/plugins/shims.d.ts +6 -5
  255. package/dist/plugins/shims.d.ts.map +1 -1
  256. package/dist/plugins/static-build.d.ts +5 -26
  257. package/dist/plugins/static-build.d.ts.map +1 -1
  258. package/dist/routing/codegen-shared.d.ts +55 -0
  259. package/dist/routing/codegen-shared.d.ts.map +1 -0
  260. package/dist/routing/codegen-types.d.ts +52 -0
  261. package/dist/routing/codegen-types.d.ts.map +1 -0
  262. package/dist/routing/codegen.d.ts +2 -2
  263. package/dist/routing/codegen.d.ts.map +1 -1
  264. package/dist/routing/convention-lint.d.ts +41 -0
  265. package/dist/routing/convention-lint.d.ts.map +1 -0
  266. package/dist/routing/index.d.ts +5 -1
  267. package/dist/routing/index.d.ts.map +1 -1
  268. package/dist/routing/index.js +3 -2
  269. package/dist/routing/link-codegen.d.ts +90 -0
  270. package/dist/routing/link-codegen.d.ts.map +1 -0
  271. package/dist/routing/scanner.d.ts +1 -10
  272. package/dist/routing/scanner.d.ts.map +1 -1
  273. package/dist/routing/segment-classify.d.ts +75 -0
  274. package/dist/routing/segment-classify.d.ts.map +1 -0
  275. package/dist/routing/types.d.ts +77 -25
  276. package/dist/routing/types.d.ts.map +1 -1
  277. package/dist/routing/walkers.d.ts +51 -0
  278. package/dist/routing/walkers.d.ts.map +1 -0
  279. package/dist/rsc-runtime/rsc.d.ts +1 -1
  280. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  281. package/dist/rsc-runtime/ssr.d.ts +12 -0
  282. package/dist/rsc-runtime/ssr.d.ts.map +1 -1
  283. package/dist/schema-bridge.d.ts +76 -0
  284. package/dist/schema-bridge.d.ts.map +1 -0
  285. package/dist/search-params/define.d.ts +157 -0
  286. package/dist/search-params/define.d.ts.map +1 -0
  287. package/dist/search-params/index.d.ts +4 -7
  288. package/dist/search-params/index.d.ts.map +1 -1
  289. package/dist/search-params/index.js +34 -441
  290. package/dist/search-params/index.js.map +1 -1
  291. package/dist/search-params/registry.d.ts +2 -2
  292. package/dist/search-params/registry.d.ts.map +1 -1
  293. package/dist/search-params/wrappers.d.ts +53 -0
  294. package/dist/search-params/wrappers.d.ts.map +1 -0
  295. package/dist/segment-params/define.d.ts +95 -0
  296. package/dist/segment-params/define.d.ts.map +1 -0
  297. package/dist/segment-params/index.d.ts +3 -0
  298. package/dist/segment-params/index.d.ts.map +1 -0
  299. package/dist/segment-params/index.js +2 -0
  300. package/dist/server/access-gate.d.ts +8 -3
  301. package/dist/server/access-gate.d.ts.map +1 -1
  302. package/dist/server/action-client.d.ts +41 -6
  303. package/dist/server/action-client.d.ts.map +1 -1
  304. package/dist/server/action-encryption.d.ts +76 -0
  305. package/dist/server/action-encryption.d.ts.map +1 -0
  306. package/dist/server/action-handler.d.ts +35 -1
  307. package/dist/server/action-handler.d.ts.map +1 -1
  308. package/dist/server/actions.d.ts +3 -6
  309. package/dist/server/actions.d.ts.map +1 -1
  310. package/dist/server/als-registry.d.ts +33 -5
  311. package/dist/server/als-registry.d.ts.map +1 -1
  312. package/dist/server/asset-headers.d.ts +1 -15
  313. package/dist/server/asset-headers.d.ts.map +1 -1
  314. package/dist/server/build-manifest.d.ts +2 -2
  315. package/dist/server/build-manifest.d.ts.map +1 -1
  316. package/dist/server/cookie-context.d.ts +170 -0
  317. package/dist/server/cookie-context.d.ts.map +1 -0
  318. package/dist/server/cookie-parsing.d.ts +51 -0
  319. package/dist/server/cookie-parsing.d.ts.map +1 -0
  320. package/dist/server/debug.d.ts +1 -1
  321. package/dist/server/default-logger.d.ts +22 -0
  322. package/dist/server/default-logger.d.ts.map +1 -0
  323. package/dist/server/deny-boundary.d.ts +90 -0
  324. package/dist/server/deny-boundary.d.ts.map +1 -0
  325. package/dist/server/deny-renderer.d.ts.map +1 -1
  326. package/dist/server/dev-source-map.d.ts +22 -0
  327. package/dist/server/dev-source-map.d.ts.map +1 -0
  328. package/dist/server/early-hints-sender.d.ts.map +1 -1
  329. package/dist/server/early-hints.d.ts +13 -5
  330. package/dist/server/early-hints.d.ts.map +1 -1
  331. package/dist/server/error-boundary-wrapper.d.ts +7 -1
  332. package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
  333. package/dist/server/fallback-error.d.ts +12 -7
  334. package/dist/server/fallback-error.d.ts.map +1 -1
  335. package/dist/server/flight-injection-state.d.ts +66 -0
  336. package/dist/server/flight-injection-state.d.ts.map +1 -0
  337. package/dist/server/flight-scripts.d.ts +42 -0
  338. package/dist/server/flight-scripts.d.ts.map +1 -0
  339. package/dist/server/flush.d.ts.map +1 -1
  340. package/dist/server/form-data.d.ts +29 -0
  341. package/dist/server/form-data.d.ts.map +1 -1
  342. package/dist/server/html-injector-core.d.ts +212 -0
  343. package/dist/server/html-injector-core.d.ts.map +1 -0
  344. package/dist/server/html-injectors.d.ts +81 -41
  345. package/dist/server/html-injectors.d.ts.map +1 -1
  346. package/dist/server/index.d.ts +9 -46
  347. package/dist/server/index.d.ts.map +1 -1
  348. package/dist/server/index.js +155 -2905
  349. package/dist/server/index.js.map +1 -1
  350. package/dist/server/internal.d.ts +48 -0
  351. package/dist/server/internal.d.ts.map +1 -0
  352. package/dist/server/internal.js +2900 -0
  353. package/dist/server/internal.js.map +1 -0
  354. package/dist/server/logger.d.ts +39 -7
  355. package/dist/server/logger.d.ts.map +1 -1
  356. package/dist/server/middleware-runner.d.ts +36 -4
  357. package/dist/server/middleware-runner.d.ts.map +1 -1
  358. package/dist/server/node-stream-transforms.d.ts +110 -0
  359. package/dist/server/node-stream-transforms.d.ts.map +1 -0
  360. package/dist/server/param-coercion.d.ts +26 -0
  361. package/dist/server/param-coercion.d.ts.map +1 -0
  362. package/dist/server/pipeline-helpers.d.ts +95 -0
  363. package/dist/server/pipeline-helpers.d.ts.map +1 -0
  364. package/dist/server/pipeline-interception.d.ts +1 -1
  365. package/dist/server/pipeline-interception.d.ts.map +1 -1
  366. package/dist/server/pipeline-metadata.d.ts +6 -0
  367. package/dist/server/pipeline-metadata.d.ts.map +1 -1
  368. package/dist/server/pipeline-outcome.d.ts +49 -0
  369. package/dist/server/pipeline-outcome.d.ts.map +1 -0
  370. package/dist/server/pipeline-phases.d.ts +52 -0
  371. package/dist/server/pipeline-phases.d.ts.map +1 -0
  372. package/dist/server/pipeline.d.ts +93 -23
  373. package/dist/server/pipeline.d.ts.map +1 -1
  374. package/dist/server/port-resolution.d.ts +117 -0
  375. package/dist/server/port-resolution.d.ts.map +1 -0
  376. package/dist/server/primitives.d.ts +69 -18
  377. package/dist/server/primitives.d.ts.map +1 -1
  378. package/dist/server/render-timeout.d.ts +51 -0
  379. package/dist/server/render-timeout.d.ts.map +1 -0
  380. package/dist/server/request-context.d.ts +41 -109
  381. package/dist/server/request-context.d.ts.map +1 -1
  382. package/dist/server/route-element-builder.d.ts +27 -1
  383. package/dist/server/route-element-builder.d.ts.map +1 -1
  384. package/dist/server/route-handler.d.ts.map +1 -1
  385. package/dist/server/route-matcher.d.ts +21 -34
  386. package/dist/server/route-matcher.d.ts.map +1 -1
  387. package/dist/server/rsc-entry/action-middleware-runner.d.ts +66 -0
  388. package/dist/server/rsc-entry/action-middleware-runner.d.ts.map +1 -0
  389. package/dist/server/rsc-entry/api-handler.d.ts +2 -2
  390. package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
  391. package/dist/server/rsc-entry/error-renderer.d.ts +26 -13
  392. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  393. package/dist/server/rsc-entry/helpers.d.ts +49 -6
  394. package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
  395. package/dist/server/rsc-entry/index.d.ts +20 -3
  396. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  397. package/dist/server/rsc-entry/render-route.d.ts +50 -0
  398. package/dist/server/rsc-entry/render-route.d.ts.map +1 -0
  399. package/dist/server/rsc-entry/rsc-payload.d.ts +3 -3
  400. package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
  401. package/dist/server/rsc-entry/rsc-stream.d.ts +14 -1
  402. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  403. package/dist/server/rsc-entry/ssr-bridge.d.ts +1 -1
  404. package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
  405. package/dist/server/rsc-entry/ssr-renderer.d.ts +19 -4
  406. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  407. package/dist/server/rsc-entry/wrap-action-dispatch.d.ts +119 -0
  408. package/dist/server/rsc-entry/wrap-action-dispatch.d.ts.map +1 -0
  409. package/dist/server/safe-load.d.ts +46 -0
  410. package/dist/server/safe-load.d.ts.map +1 -0
  411. package/dist/server/sensitive-fields.d.ts +74 -0
  412. package/dist/server/sensitive-fields.d.ts.map +1 -0
  413. package/dist/server/sitemap-generator.d.ts +129 -0
  414. package/dist/server/sitemap-generator.d.ts.map +1 -0
  415. package/dist/server/sitemap-handler.d.ts +22 -0
  416. package/dist/server/sitemap-handler.d.ts.map +1 -0
  417. package/dist/server/slot-resolver.d.ts +1 -1
  418. package/dist/server/slot-resolver.d.ts.map +1 -1
  419. package/dist/server/ssr-entry.d.ts +23 -0
  420. package/dist/server/ssr-entry.d.ts.map +1 -1
  421. package/dist/server/ssr-render.d.ts +39 -21
  422. package/dist/server/ssr-render.d.ts.map +1 -1
  423. package/dist/server/ssr-wrappers.d.ts +50 -0
  424. package/dist/server/ssr-wrappers.d.ts.map +1 -0
  425. package/dist/server/state-tree-diff.d.ts.map +1 -1
  426. package/dist/server/status-code-resolver.d.ts +16 -11
  427. package/dist/server/status-code-resolver.d.ts.map +1 -1
  428. package/dist/server/stream-utils.d.ts +36 -0
  429. package/dist/server/stream-utils.d.ts.map +1 -0
  430. package/dist/server/tracing.d.ts +5 -5
  431. package/dist/server/tracing.d.ts.map +1 -1
  432. package/dist/server/tree-builder.d.ts +62 -30
  433. package/dist/server/tree-builder.d.ts.map +1 -1
  434. package/dist/server/types.d.ts +49 -4
  435. package/dist/server/types.d.ts.map +1 -1
  436. package/dist/server/utils/escape-html.d.ts +14 -0
  437. package/dist/server/utils/escape-html.d.ts.map +1 -0
  438. package/dist/server/version-skew.d.ts +61 -0
  439. package/dist/server/version-skew.d.ts.map +1 -0
  440. package/dist/shared/merge-search-params.d.ts +22 -0
  441. package/dist/shared/merge-search-params.d.ts.map +1 -0
  442. package/dist/shims/font-google.d.ts +1 -1
  443. package/dist/shims/font-google.d.ts.map +1 -1
  444. package/dist/shims/font-google.js +42 -0
  445. package/dist/shims/font-google.js.map +1 -0
  446. package/dist/shims/font-local.d.ts +26 -0
  447. package/dist/shims/font-local.d.ts.map +1 -0
  448. package/dist/shims/font-local.js +20 -0
  449. package/dist/shims/font-local.js.map +1 -0
  450. package/dist/shims/headers.d.ts +2 -1
  451. package/dist/shims/headers.d.ts.map +1 -1
  452. package/dist/shims/navigation-client.d.ts +3 -1
  453. package/dist/shims/navigation-client.d.ts.map +1 -1
  454. package/dist/shims/navigation.d.ts +11 -5
  455. package/dist/shims/navigation.d.ts.map +1 -1
  456. package/dist/utils/state-machine.d.ts +80 -0
  457. package/dist/utils/state-machine.d.ts.map +1 -0
  458. package/package.json +57 -22
  459. package/src/adapters/build-output-helper.ts +77 -0
  460. package/src/adapters/cloudflare-dev.ts +177 -0
  461. package/src/adapters/cloudflare-kv-cache.ts +142 -0
  462. package/src/adapters/cloudflare.ts +350 -76
  463. package/src/adapters/compress-module.ts +24 -4
  464. package/src/adapters/nitro.ts +142 -59
  465. package/src/adapters/shared.ts +40 -0
  466. package/src/adapters/wrangler.d.ts +7 -0
  467. package/src/cache/cache-api.ts +38 -0
  468. package/src/cache/handler-store.ts +68 -0
  469. package/src/cache/index.ts +81 -18
  470. package/src/cache/singleflight.ts +62 -4
  471. package/src/cache/sizeof.ts +31 -0
  472. package/src/cache/timber-cache.ts +25 -20
  473. package/src/cli.ts +16 -6
  474. package/src/client/browser-dev.ts +153 -1
  475. package/src/client/browser-entry/action-dispatch.ts +116 -0
  476. package/src/client/browser-entry/hmr.ts +81 -0
  477. package/src/client/browser-entry/hydrate.ts +145 -0
  478. package/src/client/browser-entry/index.ts +143 -0
  479. package/src/client/browser-entry/post-hydration.ts +119 -0
  480. package/src/client/browser-entry/router-init.ts +193 -0
  481. package/src/client/browser-entry/rsc-stream.ts +157 -0
  482. package/src/client/browser-entry/scroll.ts +27 -0
  483. package/src/client/error-boundary.tsx +97 -20
  484. package/src/client/error-reconstituter.tsx +65 -0
  485. package/src/client/form.tsx +31 -32
  486. package/src/client/history.ts +26 -4
  487. package/src/client/index.ts +77 -43
  488. package/src/client/internal.ts +58 -0
  489. package/src/client/link-pending-store.ts +111 -0
  490. package/src/client/link.tsx +342 -113
  491. package/src/client/nav-link-store.ts +47 -0
  492. package/src/client/navigation-api-types.ts +112 -0
  493. package/src/client/navigation-api.ts +332 -0
  494. package/src/client/navigation-context.ts +31 -6
  495. package/src/client/navigation-root.tsx +342 -0
  496. package/src/client/nuqs-adapter.tsx +16 -3
  497. package/src/client/router-ref.ts +1 -1
  498. package/src/client/router.ts +300 -73
  499. package/src/client/rsc-fetch.ts +112 -8
  500. package/src/client/segment-cache.ts +1 -1
  501. package/src/client/segment-outlet.tsx +86 -0
  502. package/src/client/ssr-data.ts +13 -5
  503. package/src/client/stale-reload.ts +72 -3
  504. package/src/client/state.ts +2 -2
  505. package/src/client/top-loader.tsx +18 -6
  506. package/src/client/use-cookie.ts +29 -0
  507. package/src/client/use-link-status.ts +7 -7
  508. package/src/client/{use-navigation-pending.ts → use-pending-navigation.ts} +6 -6
  509. package/src/client/use-query-states.ts +9 -3
  510. package/src/client/use-router.ts +1 -1
  511. package/src/client/{use-params.ts → use-segment-params.ts} +7 -5
  512. package/src/codec.ts +45 -0
  513. package/src/config-types.ts +292 -0
  514. package/src/config-validation.ts +303 -0
  515. package/src/content/index.ts +5 -13
  516. package/src/cookies/define-cookie.ts +301 -55
  517. package/src/cookies/index.ts +12 -1
  518. package/src/cookies/json-cookie.ts +105 -0
  519. package/src/cookies/validation.ts +134 -0
  520. package/src/dev-tools/404-page.ts +387 -0
  521. package/src/dev-tools/browser-logs.ts +288 -0
  522. package/src/dev-tools/error-page.ts +509 -0
  523. package/src/dev-tools/holding-server.ts +187 -0
  524. package/src/dev-tools/index.ts +90 -0
  525. package/src/dev-tools/instrumentation.ts +176 -0
  526. package/src/{plugins/dev-logs.ts → dev-tools/logs.ts} +3 -3
  527. package/src/dev-tools/overlay.ts +456 -0
  528. package/src/dev-tools/stack-classifier.ts +75 -0
  529. package/src/dev-tools/terminal.ts +183 -0
  530. package/src/{server/dev-warnings.ts → dev-tools/warnings.ts} +5 -50
  531. package/src/fonts/ast.ts +488 -16
  532. package/src/fonts/bundle.ts +142 -0
  533. package/src/fonts/css.ts +2 -1
  534. package/src/fonts/dev-middleware.ts +74 -0
  535. package/src/fonts/local.ts +1 -1
  536. package/src/fonts/pipeline.ts +314 -0
  537. package/src/fonts/transform.ts +317 -0
  538. package/src/fonts/types.ts +50 -1
  539. package/src/fonts/virtual-modules.ts +227 -0
  540. package/src/index.ts +390 -358
  541. package/src/plugin-context.ts +240 -0
  542. package/src/plugins/adapter-build.ts +12 -4
  543. package/src/plugins/build-manifest.ts +13 -2
  544. package/src/plugins/build-report.ts +16 -25
  545. package/src/plugins/client-chunks.ts +65 -0
  546. package/src/plugins/content.ts +1 -1
  547. package/src/plugins/dev-server.ts +162 -30
  548. package/src/plugins/entries.ts +111 -10
  549. package/src/plugins/fonts.ts +155 -654
  550. package/src/plugins/mdx.ts +43 -10
  551. package/src/plugins/routing.ts +217 -44
  552. package/src/plugins/server-bundle.ts +32 -1
  553. package/src/plugins/shims.ts +136 -35
  554. package/src/plugins/static-build.ts +15 -89
  555. package/src/routing/codegen-shared.ts +98 -0
  556. package/src/routing/codegen-types.ts +53 -0
  557. package/src/routing/codegen.ts +143 -176
  558. package/src/routing/convention-lint.ts +357 -0
  559. package/src/routing/index.ts +5 -1
  560. package/src/routing/interception.ts +1 -1
  561. package/src/routing/link-codegen.ts +294 -0
  562. package/src/routing/scanner.ts +107 -110
  563. package/src/routing/segment-classify.ts +188 -0
  564. package/src/routing/types.ts +78 -25
  565. package/src/routing/walkers.ts +90 -0
  566. package/src/rsc-runtime/rsc.ts +2 -0
  567. package/src/rsc-runtime/ssr.ts +50 -0
  568. package/src/rsc-runtime/vendor-types.d.ts +7 -0
  569. package/src/{search-params/codecs.ts → schema-bridge.ts} +57 -20
  570. package/src/search-params/define.ts +538 -0
  571. package/src/search-params/index.ts +14 -20
  572. package/src/search-params/registry.ts +2 -2
  573. package/src/search-params/wrappers.ts +92 -0
  574. package/src/segment-params/define.ts +332 -0
  575. package/src/segment-params/index.ts +9 -0
  576. package/src/server/access-gate.tsx +76 -34
  577. package/src/server/action-client.ts +88 -15
  578. package/src/server/action-encryption.ts +144 -0
  579. package/src/server/action-handler.ts +112 -14
  580. package/src/server/actions.ts +10 -9
  581. package/src/server/als-registry.ts +35 -7
  582. package/src/server/asset-headers.ts +8 -34
  583. package/src/server/build-manifest.ts +10 -4
  584. package/src/server/compress.ts +25 -7
  585. package/src/server/cookie-context.ts +468 -0
  586. package/src/server/cookie-parsing.ts +135 -0
  587. package/src/server/debug.ts +1 -1
  588. package/src/server/default-logger.ts +99 -0
  589. package/src/server/deny-boundary.ts +218 -0
  590. package/src/server/deny-renderer.ts +31 -50
  591. package/src/server/dev-source-map.ts +31 -0
  592. package/src/server/early-hints-sender.ts +3 -2
  593. package/src/server/early-hints.ts +36 -15
  594. package/src/server/error-boundary-wrapper.ts +74 -22
  595. package/src/server/fallback-error.ts +74 -102
  596. package/src/server/flight-injection-state.ts +113 -0
  597. package/src/server/flight-scripts.ts +62 -0
  598. package/src/server/flush.ts +2 -1
  599. package/src/server/form-data.ts +76 -0
  600. package/src/server/html-injector-core.ts +403 -0
  601. package/src/server/html-injectors.ts +244 -223
  602. package/src/server/index.ts +31 -184
  603. package/src/server/internal.ts +176 -0
  604. package/src/server/logger.ts +67 -36
  605. package/src/server/middleware-runner.ts +75 -4
  606. package/src/server/node-stream-transforms.ts +369 -0
  607. package/src/server/param-coercion.ts +76 -0
  608. package/src/server/pipeline-helpers.ts +204 -0
  609. package/src/server/pipeline-interception.ts +17 -16
  610. package/src/server/pipeline-metadata.ts +13 -0
  611. package/src/server/pipeline-outcome.ts +167 -0
  612. package/src/server/pipeline-phases.ts +409 -0
  613. package/src/server/pipeline.ts +128 -394
  614. package/src/server/port-resolution.ts +215 -0
  615. package/src/server/primitives.ts +111 -28
  616. package/src/server/render-timeout.ts +108 -0
  617. package/src/server/request-context.ts +94 -338
  618. package/src/server/route-element-builder.ts +288 -192
  619. package/src/server/route-handler.ts +24 -4
  620. package/src/server/route-matcher.ts +44 -65
  621. package/src/server/rsc-entry/action-middleware-runner.ts +167 -0
  622. package/src/server/rsc-entry/api-handler.ts +16 -17
  623. package/src/server/rsc-entry/error-renderer.ts +305 -89
  624. package/src/server/rsc-entry/helpers.ts +136 -12
  625. package/src/server/rsc-entry/index.ts +312 -341
  626. package/src/server/rsc-entry/render-route.ts +304 -0
  627. package/src/server/rsc-entry/rsc-payload.ts +65 -18
  628. package/src/server/rsc-entry/rsc-stream.ts +81 -13
  629. package/src/server/rsc-entry/ssr-bridge.ts +14 -5
  630. package/src/server/rsc-entry/ssr-renderer.ts +171 -38
  631. package/src/server/rsc-entry/wrap-action-dispatch.ts +449 -0
  632. package/src/server/safe-load.ts +60 -0
  633. package/src/server/sensitive-fields.ts +230 -0
  634. package/src/server/sitemap-generator.ts +338 -0
  635. package/src/server/sitemap-handler.ts +126 -0
  636. package/src/server/slot-resolver.ts +245 -230
  637. package/src/server/ssr-entry.ts +215 -32
  638. package/src/server/ssr-render.ts +289 -67
  639. package/src/server/ssr-wrappers.tsx +139 -0
  640. package/src/server/state-tree-diff.ts +4 -1
  641. package/src/server/status-code-resolver.ts +112 -128
  642. package/src/server/stream-utils.ts +213 -0
  643. package/src/server/tracing.ts +21 -10
  644. package/src/server/tree-builder.ts +202 -90
  645. package/src/server/types.ts +55 -6
  646. package/src/server/utils/escape-html.ts +20 -0
  647. package/src/server/version-skew.ts +104 -0
  648. package/src/shared/merge-search-params.ts +55 -0
  649. package/src/shims/font-google.ts +1 -1
  650. package/src/shims/font-local.ts +34 -0
  651. package/src/shims/headers.ts +5 -1
  652. package/src/shims/navigation-client.ts +4 -3
  653. package/src/shims/navigation.ts +14 -7
  654. package/src/utils/state-machine.ts +111 -0
  655. package/dist/_chunks/als-registry-B7DbZ2hS.js +0 -41
  656. package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
  657. package/dist/_chunks/debug-gwlJkDuf.js +0 -108
  658. package/dist/_chunks/debug-gwlJkDuf.js.map +0 -1
  659. package/dist/_chunks/format-DviM89f0.js.map +0 -1
  660. package/dist/_chunks/interception-BOoWmLUA.js +0 -676
  661. package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
  662. package/dist/_chunks/request-context-DIkVh_jG.js +0 -330
  663. package/dist/_chunks/request-context-DIkVh_jG.js.map +0 -1
  664. package/dist/_chunks/ssr-data-MjmprTmO.js.map +0 -1
  665. package/dist/_chunks/tracing-CemImE6h.js +0 -187
  666. package/dist/_chunks/tracing-CemImE6h.js.map +0 -1
  667. package/dist/_chunks/use-cookie-DX-l1_5E.js +0 -91
  668. package/dist/_chunks/use-cookie-DX-l1_5E.js.map +0 -1
  669. package/dist/_chunks/use-query-states-D5KaffOK.js.map +0 -1
  670. package/dist/cache/register-cached-function.d.ts +0 -17
  671. package/dist/cache/register-cached-function.d.ts.map +0 -1
  672. package/dist/client/browser-entry.d.ts +0 -21
  673. package/dist/client/browser-entry.d.ts.map +0 -1
  674. package/dist/client/link-status-provider.d.ts +0 -11
  675. package/dist/client/link-status-provider.d.ts.map +0 -1
  676. package/dist/client/transition-root.d.ts.map +0 -1
  677. package/dist/client/use-navigation-pending.d.ts.map +0 -1
  678. package/dist/client/use-params.d.ts.map +0 -1
  679. package/dist/plugins/cache-transform.d.ts +0 -36
  680. package/dist/plugins/cache-transform.d.ts.map +0 -1
  681. package/dist/plugins/dev-error-overlay.d.ts +0 -60
  682. package/dist/plugins/dev-error-overlay.d.ts.map +0 -1
  683. package/dist/plugins/dev-logs.d.ts.map +0 -1
  684. package/dist/plugins/dynamic-transform.d.ts +0 -72
  685. package/dist/plugins/dynamic-transform.d.ts.map +0 -1
  686. package/dist/plugins/server-action-exports.d.ts +0 -26
  687. package/dist/plugins/server-action-exports.d.ts.map +0 -1
  688. package/dist/routing/status-file-lint.d.ts +0 -33
  689. package/dist/routing/status-file-lint.d.ts.map +0 -1
  690. package/dist/search-params/analyze.d.ts +0 -54
  691. package/dist/search-params/analyze.d.ts.map +0 -1
  692. package/dist/search-params/builtin-codecs.d.ts +0 -105
  693. package/dist/search-params/builtin-codecs.d.ts.map +0 -1
  694. package/dist/search-params/codecs.d.ts +0 -53
  695. package/dist/search-params/codecs.d.ts.map +0 -1
  696. package/dist/search-params/create.d.ts +0 -106
  697. package/dist/search-params/create.d.ts.map +0 -1
  698. package/dist/server/dev-fetch-instrumentation.d.ts +0 -22
  699. package/dist/server/dev-fetch-instrumentation.d.ts.map +0 -1
  700. package/dist/server/dev-logger.d.ts.map +0 -1
  701. package/dist/server/dev-span-processor.d.ts.map +0 -1
  702. package/dist/server/dev-warnings.d.ts.map +0 -1
  703. package/dist/server/manifest-status-resolver.d.ts +0 -58
  704. package/dist/server/manifest-status-resolver.d.ts.map +0 -1
  705. package/dist/server/prerender.d.ts +0 -77
  706. package/dist/server/prerender.d.ts.map +0 -1
  707. package/dist/server/response-cache.d.ts +0 -54
  708. package/dist/server/response-cache.d.ts.map +0 -1
  709. package/dist/utils/directive-parser.d.ts +0 -70
  710. package/dist/utils/directive-parser.d.ts.map +0 -1
  711. package/src/cache/register-cached-function.ts +0 -103
  712. package/src/client/browser-entry.ts +0 -678
  713. package/src/client/link-status-provider.tsx +0 -30
  714. package/src/client/transition-root.tsx +0 -166
  715. package/src/plugins/cache-transform.ts +0 -199
  716. package/src/plugins/dev-error-overlay.ts +0 -230
  717. package/src/plugins/dynamic-transform.ts +0 -161
  718. package/src/plugins/server-action-exports.ts +0 -220
  719. package/src/routing/status-file-lint.ts +0 -112
  720. package/src/search-params/analyze.ts +0 -192
  721. package/src/search-params/builtin-codecs.ts +0 -228
  722. package/src/search-params/create.ts +0 -321
  723. package/src/server/dev-fetch-instrumentation.ts +0 -96
  724. package/src/server/dev-span-processor.ts +0 -78
  725. package/src/server/manifest-status-resolver.ts +0 -215
  726. package/src/server/prerender.ts +0 -139
  727. package/src/server/response-cache.ts +0 -410
  728. package/src/utils/directive-parser.ts +0 -529
  729. /package/src/{server/dev-logger.ts → dev-tools/logger.ts} +0 -0
@@ -0,0 +1,850 @@
1
+ import { r as DEFAULT_PAGE_EXTENSIONS, t as classifySegment } from "./segment-classify-BjfuctV2.js";
2
+ import { a as isDynamicMetadataExtension, n as classifyMetadataRoute } from "./metadata-routes-BU684ls2.js";
3
+ import { h as swallow } from "./logger-0m8MsKdc.js";
4
+ import { basename, extname, join, posix, relative } from "node:path";
5
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
6
+ //#region src/routing/scanner.ts
7
+ /**
8
+ * Route discovery scanner.
9
+ *
10
+ * Pure function: (appDir, config) → RouteTree
11
+ *
12
+ * Scans the app/ directory and builds a segment tree recognizing all
13
+ * timber.js file conventions. Does NOT handle request matching — this
14
+ * is discovery only.
15
+ */
16
+ /**
17
+ * Pattern matching encoded path delimiters that must be rejected during route discovery.
18
+ * %2F / %2f (forward slash) and %5C / %5c (backslash) can cause route collisions
19
+ * when decoded. See design/13-security.md §"Encoded separators rejected".
20
+ */
21
+ var ENCODED_SEPARATOR_PATTERN = /%(?:2[fF]|5[cC])/;
22
+ /**
23
+ * Pattern matching encoded null bytes (%00) that must be rejected.
24
+ * See design/13-security.md §"Null bytes rejected".
25
+ */
26
+ var ENCODED_NULL_PATTERN = /%00/;
27
+ /**
28
+ * File convention names that use pageExtensions (can be .tsx, .ts, .jsx, .js, .mdx, etc.)
29
+ */
30
+ var PAGE_EXT_CONVENTIONS = new Set([
31
+ "page",
32
+ "layout",
33
+ "error",
34
+ "default",
35
+ "denied"
36
+ ]);
37
+ /**
38
+ * Legacy compat status-code files.
39
+ * Maps legacy file name → HTTP status code for the fallback chain.
40
+ * See design/10-error-handling.md §"Fallback Chain".
41
+ */
42
+ var LEGACY_STATUS_FILES = {
43
+ "not-found": 404,
44
+ "forbidden": 403,
45
+ "unauthorized": 401
46
+ };
47
+ /**
48
+ * File convention names that are always .ts/.tsx (never .mdx etc.)
49
+ */
50
+ var FIXED_CONVENTIONS = new Set([
51
+ "middleware",
52
+ "access",
53
+ "route",
54
+ "params"
55
+ ]);
56
+ /**
57
+ * Status-code file patterns:
58
+ * - Exact 3-digit codes: 401.tsx, 429.tsx, 503.tsx
59
+ * - Category catch-alls: 4xx.tsx, 5xx.tsx
60
+ */
61
+ var STATUS_CODE_PATTERN = /^(\d{3}|[45]xx)$/;
62
+ /**
63
+ * Scan the app/ directory and build the route tree.
64
+ *
65
+ * @param appDir - Absolute path to the app/ directory
66
+ * @param config - Scanner configuration
67
+ * @returns The complete route tree
68
+ */
69
+ function scanRoutes(appDir, config = {}) {
70
+ const pageExtensions = config.pageExtensions ?? DEFAULT_PAGE_EXTENSIONS;
71
+ const extSet = new Set(pageExtensions);
72
+ const tree = { root: createSegmentNode("", "static", "/") };
73
+ const proxyFile = findFixedFile(appDir, "proxy");
74
+ if (proxyFile) tree.proxy = proxyFile;
75
+ const globalErrorFile = findPageExtFile(appDir, "global-error", extSet);
76
+ if (globalErrorFile) tree.globalError = globalErrorFile;
77
+ scanSegmentFiles(appDir, tree.root, extSet);
78
+ scanChildren(appDir, tree.root, extSet);
79
+ validateRouteGroupCollisions(tree.root);
80
+ validateDuplicateParamNames(tree.root);
81
+ return tree;
82
+ }
83
+ /**
84
+ * Create an empty segment node.
85
+ */
86
+ function createSegmentNode(segmentName, segmentType, urlPath, paramName, interceptionMarker, interceptedSegmentName) {
87
+ return {
88
+ segmentName,
89
+ segmentType,
90
+ urlPath,
91
+ paramName,
92
+ interceptionMarker,
93
+ interceptedSegmentName,
94
+ children: [],
95
+ slots: {}
96
+ };
97
+ }
98
+ /**
99
+ * Compute the URL path for a child segment given its parent's URL path.
100
+ * Route groups, slots, and intercepting routes do NOT add URL depth.
101
+ */
102
+ function computeUrlPath(parentUrlPath, dirName, segmentType) {
103
+ if (segmentType === "group" || segmentType === "slot" || segmentType === "intercepting") return parentUrlPath;
104
+ return `${parentUrlPath === "/" ? "" : parentUrlPath}/${dirName}`;
105
+ }
106
+ /**
107
+ * Scan a directory for file conventions and populate the segment node.
108
+ */
109
+ function scanSegmentFiles(dirPath, node, extSet) {
110
+ let entries;
111
+ try {
112
+ entries = readdirSync(dirPath);
113
+ } catch (err) {
114
+ swallow(err, `scanSegmentFiles: unreadable directory ${dirPath}`, { level: "warn" });
115
+ return;
116
+ }
117
+ for (const entry of entries) {
118
+ const fullPath = join(dirPath, entry);
119
+ try {
120
+ if (statSync(fullPath).isDirectory()) continue;
121
+ } catch {
122
+ continue;
123
+ }
124
+ const ext = extname(entry).slice(1);
125
+ const name = basename(entry, `.${ext}`);
126
+ if (PAGE_EXT_CONVENTIONS.has(name) && extSet.has(ext)) {
127
+ const file = {
128
+ filePath: fullPath,
129
+ extension: ext
130
+ };
131
+ switch (name) {
132
+ case "page":
133
+ node.page = file;
134
+ break;
135
+ case "layout":
136
+ node.layout = file;
137
+ break;
138
+ case "error":
139
+ node.error = file;
140
+ break;
141
+ case "default":
142
+ node.default = file;
143
+ break;
144
+ case "denied":
145
+ node.denied = file;
146
+ break;
147
+ }
148
+ continue;
149
+ }
150
+ if (FIXED_CONVENTIONS.has(name) && /\.?[jt]sx?$/.test(ext)) {
151
+ const file = {
152
+ filePath: fullPath,
153
+ extension: ext
154
+ };
155
+ switch (name) {
156
+ case "middleware":
157
+ node.middleware = file;
158
+ break;
159
+ case "access":
160
+ node.access = file;
161
+ break;
162
+ case "route":
163
+ node.route = file;
164
+ break;
165
+ case "params":
166
+ node.params = file;
167
+ break;
168
+ }
169
+ continue;
170
+ }
171
+ if (STATUS_CODE_PATTERN.test(name) && ext === "json") {
172
+ if (!node.jsonStatusFiles) node.jsonStatusFiles = {};
173
+ node.jsonStatusFiles[name] = {
174
+ filePath: fullPath,
175
+ extension: ext
176
+ };
177
+ continue;
178
+ }
179
+ if (STATUS_CODE_PATTERN.test(name) && extSet.has(ext)) {
180
+ if (!node.statusFiles) node.statusFiles = {};
181
+ node.statusFiles[name] = {
182
+ filePath: fullPath,
183
+ extension: ext
184
+ };
185
+ continue;
186
+ }
187
+ if (name in LEGACY_STATUS_FILES && extSet.has(ext)) {
188
+ if (!node.legacyStatusFiles) node.legacyStatusFiles = {};
189
+ node.legacyStatusFiles[name] = {
190
+ filePath: fullPath,
191
+ extension: ext
192
+ };
193
+ continue;
194
+ }
195
+ if (classifyMetadataRoute(entry)) {
196
+ if (!node.metadataRoutes) node.metadataRoutes = {};
197
+ const existing = node.metadataRoutes[name];
198
+ if (existing) {
199
+ const existingIsDynamic = isDynamicMetadataExtension(name, existing.extension);
200
+ if (isDynamicMetadataExtension(name, ext) || !existingIsDynamic) node.metadataRoutes[name] = {
201
+ filePath: fullPath,
202
+ extension: ext
203
+ };
204
+ } else node.metadataRoutes[name] = {
205
+ filePath: fullPath,
206
+ extension: ext
207
+ };
208
+ }
209
+ }
210
+ if (node.route && node.page) throw new Error(`Build error: route.ts and page.* cannot coexist in the same segment.\n route.ts: ${node.route.filePath}\n page: ${node.page.filePath}\nA URL is either an API endpoint or a rendered page, not both.`);
211
+ }
212
+ /**
213
+ * Recursively scan child directories and build the segment tree.
214
+ */
215
+ function scanChildren(dirPath, parentNode, extSet) {
216
+ let entries;
217
+ try {
218
+ entries = readdirSync(dirPath);
219
+ } catch (err) {
220
+ swallow(err, `scanChildren: unreadable directory ${dirPath}`, { level: "warn" });
221
+ return;
222
+ }
223
+ for (const entry of entries) {
224
+ const fullPath = join(dirPath, entry);
225
+ try {
226
+ if (!statSync(fullPath).isDirectory()) continue;
227
+ } catch {
228
+ continue;
229
+ }
230
+ if (ENCODED_SEPARATOR_PATTERN.test(entry)) throw new Error(`Build error: directory name contains an encoded path delimiter (%%2F or %%5C).\n Directory: ${fullPath}\nEncoded separators in directory names cause route collisions when decoded. Rename the directory to remove the encoded delimiter.`);
231
+ if (ENCODED_NULL_PATTERN.test(entry)) throw new Error(`Build error: directory name contains an encoded null byte (%%00).\n Directory: ${fullPath}\nEncoded null bytes in directory names are not allowed. Rename the directory to remove the null byte encoding.`);
232
+ const { type, paramName, interceptionMarker, interceptedSegmentName } = classifySegment(entry);
233
+ if (type === "private") continue;
234
+ const childNode = createSegmentNode(entry, type, computeUrlPath(parentNode.urlPath, entry, type), paramName, interceptionMarker, interceptedSegmentName);
235
+ scanSegmentFiles(fullPath, childNode, extSet);
236
+ scanChildren(fullPath, childNode, extSet);
237
+ if (type === "slot") {
238
+ const slotName = entry.slice(1);
239
+ parentNode.slots[slotName] = childNode;
240
+ } else parentNode.children.push(childNode);
241
+ }
242
+ }
243
+ /**
244
+ * Validate that route groups don't produce conflicting pages/routes at the same URL path.
245
+ *
246
+ * Two route groups like (auth)/login/page.tsx and (marketing)/login/page.tsx both claim
247
+ * /login — the scanner must detect and reject this at build time.
248
+ *
249
+ * Parallel slots are excluded from collision detection — they intentionally coexist at
250
+ * the same URL path as their parent (that's the whole point of parallel routes).
251
+ */
252
+ function validateRouteGroupCollisions(root) {
253
+ collectRoutableLeaves(root, /* @__PURE__ */ new Map(), "", false);
254
+ }
255
+ /**
256
+ * Walk the segment tree and collect all routable leaves (page or route files),
257
+ * throwing on collision. Slots are tracked in their own collision space since
258
+ * they are parallel routes that intentionally share URL paths with their parent.
259
+ */
260
+ function collectRoutableLeaves(node, seen, segmentPath, insideSlot) {
261
+ const currentPath = segmentPath ? `${segmentPath}/${node.segmentName}` : node.segmentName || "(root)";
262
+ if (!insideSlot) {
263
+ const routableFile = node.page ?? node.route;
264
+ if (routableFile) {
265
+ const existing = seen.get(node.urlPath);
266
+ if (existing) throw new Error(`Build error: route collision — multiple route groups produce a page/route at the same URL path.\n URL path: ${node.urlPath}\n File 1: ${existing.filePath} (via ${existing.segmentPath})\n File 2: ${routableFile.filePath} (via ${currentPath})\nEach URL path must map to exactly one page or route handler. Rename or move one of the conflicting files.`);
267
+ seen.set(node.urlPath, {
268
+ filePath: routableFile.filePath,
269
+ segmentPath: currentPath
270
+ });
271
+ }
272
+ }
273
+ for (const child of node.children) collectRoutableLeaves(child, seen, currentPath, insideSlot);
274
+ for (const slotNode of Object.values(node.slots)) collectRoutableLeaves(slotNode, seen, currentPath, true);
275
+ }
276
+ /**
277
+ * Validate that no route chain contains duplicate dynamic param names.
278
+ *
279
+ * Example violation:
280
+ * app/[id]/items/[id]/page.tsx — 'id' appears twice in the ancestor chain.
281
+ *
282
+ * Route groups are transparent — params accumulate through them.
283
+ * Slots are independent — duplicate detection does NOT cross slot boundaries.
284
+ *
285
+ * See design/07-routing.md §"Duplicate Param Name Detection"
286
+ */
287
+ function validateDuplicateParamNames(root) {
288
+ walkForDuplicateParams(root, /* @__PURE__ */ new Map());
289
+ }
290
+ /**
291
+ * Recursively walk the segment tree, tracking seen param names → segment paths.
292
+ * Throws on the first duplicate found.
293
+ */
294
+ function walkForDuplicateParams(node, seen) {
295
+ if (node.paramName) {
296
+ const existing = seen.get(node.paramName);
297
+ if (existing) throw new Error(`[timber] Duplicate param name '${node.paramName}' in route chain.\n First defined at: ${existing}\n Duplicate at: ${node.urlPath || "/"}\n Rename one of the segments to avoid ambiguity.`);
298
+ seen = new Map(seen);
299
+ seen.set(node.paramName, node.urlPath || "/");
300
+ }
301
+ for (const child of node.children) walkForDuplicateParams(child, seen);
302
+ for (const slotNode of Object.values(node.slots)) walkForDuplicateParams(slotNode, new Map(seen));
303
+ }
304
+ /**
305
+ * Find a fixed-extension file (proxy.ts) in a directory.
306
+ */
307
+ function findFixedFile(dirPath, name) {
308
+ for (const ext of ["ts", "tsx"]) {
309
+ const fullPath = join(dirPath, `${name}.${ext}`);
310
+ try {
311
+ if (statSync(fullPath).isFile()) return {
312
+ filePath: fullPath,
313
+ extension: ext
314
+ };
315
+ } catch {}
316
+ }
317
+ }
318
+ /**
319
+ * Find a file using the configured page extensions (tsx, ts, jsx, js, mdx, etc.).
320
+ * Used for app-root conventions like global-error that aren't per-segment.
321
+ */
322
+ function findPageExtFile(dirPath, name, extSet) {
323
+ for (const ext of extSet) {
324
+ const fullPath = join(dirPath, `${name}.${ext}`);
325
+ try {
326
+ if (statSync(fullPath).isFile()) return {
327
+ filePath: fullPath,
328
+ extension: ext
329
+ };
330
+ } catch {}
331
+ }
332
+ }
333
+ //#endregion
334
+ //#region src/routing/codegen-shared.ts
335
+ /**
336
+ * Shared codegen helpers — import-path computation, codec chain type
337
+ * builder, and searchParams type formatter.
338
+ *
339
+ * Extracted from `codegen.ts` so `link-codegen.ts` can use the same
340
+ * helpers without a cyclic import.
341
+ */
342
+ /**
343
+ * Compute a relative import specifier for a codec/page file, stripping
344
+ * the .ts/.tsx extension and resolving against the codegen output dir.
345
+ */
346
+ function codecImportPath(codecFilePath, importBase) {
347
+ const absPath = codecFilePath.replace(/\.(ts|tsx)$/, "");
348
+ if (importBase) return "./" + relative(importBase, absPath).replace(/\\/g, "/");
349
+ return "./" + posix.basename(absPath);
350
+ }
351
+ /** Name of the shared helper type emitted at the top of the .d.ts. */
352
+ var RESOLVE_SEGMENT_FIELD_TYPE_NAME = "_TimberResolveSegmentField";
353
+ /**
354
+ * Helper type emitted once at the top of the generated `.d.ts` and
355
+ * referenced by every codec-chain conditional. Without this shared
356
+ * helper, the inline expansion would duplicate the fallback branch on
357
+ * every step and grow O(2^N) in chain depth (a single deep nested route
358
+ * could blow up the file size and TS performance). With the helper,
359
+ * each step reuses the named type and growth is O(N).
360
+ *
361
+ * The helper is a 2-arg conditional: given a typeof import expression
362
+ * (`Def`), a key (`K`), and a fallback (`F`), it returns `T[K]` if
363
+ * `Def extends ParamsDefinition<T>` and `K extends keyof T`, otherwise
364
+ * `F`. The codec chain composes calls to this helper.
365
+ */
366
+ function emitResolveSegmentFieldHelper() {
367
+ return [
368
+ `type ${RESOLVE_SEGMENT_FIELD_TYPE_NAME}<Def, K extends string, F> =`,
369
+ ` Def extends import('@timber-js/app/segment-params').ParamsDefinition<infer T>`,
370
+ ` ? K extends keyof T ? T[K] : F`,
371
+ ` : F;`
372
+ ].join("\n");
373
+ }
374
+ /**
375
+ * Build a TypeScript type expression that resolves a single param's
376
+ * codec by walking a chain of params.ts files in priority order.
377
+ *
378
+ * Each entry in the chain emits one application of the shared
379
+ * `_TimberResolveSegmentField` helper type. Composing N applications
380
+ * grows linearly with chain depth (O(N) characters), unlike an inline
381
+ * conditional that would duplicate the fallback in each branch and
382
+ * grow O(2^N).
383
+ *
384
+ * The closest match (position 0 in the chain) is checked first; if its
385
+ * `segmentParams` definition declares the key, its inferred type wins.
386
+ * Otherwise we fall through to the next entry, and finally to the
387
+ * provided fallback. See TIM-834.
388
+ */
389
+ function buildCodecChainType(p, importBase, fallback) {
390
+ const files = p.codecFilePaths;
391
+ if (!files || files.length === 0) return fallback;
392
+ const key = JSON.stringify(p.name);
393
+ let inner = fallback;
394
+ for (let i = files.length - 1; i >= 0; i--) inner = `${RESOLVE_SEGMENT_FIELD_TYPE_NAME}<(typeof import('${codecImportPath(files[i], importBase)}'))['segmentParams'], ${key}, ${inner}>`;
395
+ return inner;
396
+ }
397
+ /**
398
+ * Format the searchParams type for a route entry.
399
+ *
400
+ * When a page.tsx (or params.ts) exports searchParams, we reference its
401
+ * inferred type via an import type. The import path is relative to
402
+ * `importBase` (the directory where the .d.ts will be written). When
403
+ * importBase is undefined, falls back to a bare relative path.
404
+ */
405
+ function formatSearchParamsType(route, importBase) {
406
+ if (route.hasSearchParams && route.searchParamsPagePath) return `(typeof import('${codecImportPath(route.searchParamsPagePath, importBase)}'))['searchParams'] extends import('@timber-js/app/search-params').SearchParamsDefinition<infer T> ? T : never`;
407
+ return "{}";
408
+ }
409
+ //#endregion
410
+ //#region src/routing/link-codegen.ts
411
+ /** Shared Link base-props type literal used in every emitted call signature. */
412
+ var LINK_BASE_PROPS_TYPE = "Omit<import('react').AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> & { prefetch?: boolean; scroll?: boolean; preserveSearchParams?: true | string[]; onNavigate?: import('./client/link.js').OnNavigateHandler; children?: import('react').ReactNode }";
413
+ /**
414
+ * Build a TypeScript template literal pattern for a dynamic route.
415
+ * e.g. '/products/[id]' → '/products/${string}'
416
+ * '/blog/[...slug]' → '/blog/${string}'
417
+ * '/docs/[[...path]]' → '/docs/${string}' (also matches /docs)
418
+ * '/[org]/[repo]' → '/${string}/${string}'
419
+ */
420
+ function buildResolvedPattern(route) {
421
+ return route.urlPath.split("/").map((part) => {
422
+ if (part.startsWith("[[...") && part.endsWith("]]")) return "${string}";
423
+ if (part.startsWith("[...") && part.endsWith("]")) return "${string}";
424
+ if (part.startsWith("[") && part.endsWith("]")) return "${string}";
425
+ return part;
426
+ }).join("/");
427
+ }
428
+ /**
429
+ * Format the segmentParams type for Link overloads.
430
+ *
431
+ * Link params accept `string | number` for single dynamic segments
432
+ * (convenience — values are stringified at runtime). Catch-all and
433
+ * optional catch-all remain `string[]` / `string[] | undefined`.
434
+ *
435
+ * When the segment's params chain (TIM-834) declares a typed codec, the
436
+ * inferred type from the codec wins via a nested conditional.
437
+ */
438
+ function formatLinkParamsType(params, importBase) {
439
+ if (params.length === 0) return "{}";
440
+ return `{ ${params.map((p) => {
441
+ const codecType = buildCodecChainType(p, importBase, p.type === "string" ? "string | number" : p.type);
442
+ return `${p.name}: ${codecType}`;
443
+ }).join("; ")} }`;
444
+ }
445
+ /**
446
+ * Catch-all call signatures for `<Link>` — external hrefs and computed
447
+ * `string` variables. Emitted from codegen in a SEPARATE
448
+ * `declare module` block (declared AFTER the per-route block) so the TS
449
+ * "later overload set ordered first" rule places these catch-all
450
+ * signatures ahead of per-route in resolution order, leaving per-route
451
+ * as the final overload whose error message is reported on failure.
452
+ *
453
+ * The conditional `string extends H ? ... : never` protection preserves
454
+ * TIM-624's guarantee that unknown internal path literals don't match
455
+ * the catch-all — typos like `<Link href="/typo" />` still error.
456
+ */
457
+ function formatLinkCatchAllOverloads() {
458
+ const lines = [];
459
+ const baseProps = LINK_BASE_PROPS_TYPE;
460
+ const catchAllSearchParams = "{ definition: SearchParamsDefinition<Record<string, unknown>>; values: Record<string, unknown> } | Record<string, unknown>";
461
+ const externalHref = "`http://${string}` | `https://${string}` | `mailto:${string}` | `tel:${string}` | `ftp://${string}` | `//${string}` | `#${string}` | `?${string}`";
462
+ lines.push(" // Typed Link overloads — catch-all (block 2 / emitted second)");
463
+ lines.push(" interface LinkFunction {");
464
+ lines.push(` (props: ${baseProps} & {`);
465
+ lines.push(` href: ${externalHref}`);
466
+ lines.push(` segmentParams?: Record<string, unknown>`);
467
+ lines.push(` searchParams?: ${catchAllSearchParams}`);
468
+ lines.push(` }): import('react').JSX.Element`);
469
+ lines.push(` <H extends string>(`);
470
+ lines.push(` props: ${baseProps} & {`);
471
+ lines.push(` href: string extends H ? H : never`);
472
+ lines.push(` segmentParams?: Record<string, string | number | string[]>`);
473
+ lines.push(` searchParams?: ${catchAllSearchParams}`);
474
+ lines.push(` }`);
475
+ lines.push(` ): import('react').JSX.Element`);
476
+ lines.push(" }");
477
+ return lines;
478
+ }
479
+ /**
480
+ * Generate typed per-route Link call signatures via LinkFunction
481
+ * interface merging.
482
+ *
483
+ * TIM-835: This emits a SINGLE call signature whose props is a
484
+ * discriminated union keyed on `href`. TypeScript narrows the union by
485
+ * the literal `href` at the call site, then checks the rest of the
486
+ * props against the matched variant. When `segmentParams` or
487
+ * `searchParams` is wrong, TS reports the error against the matched
488
+ * variant — naming the user's actual `href` and the offending field.
489
+ *
490
+ * Before TIM-835, this function emitted N separate per-route overloads
491
+ * (one per route, sometimes two for dynamic routes). When ALL overloads
492
+ * failed, TS would pick an arbitrary failed overload (heuristically the
493
+ * "last tried") to render the diagnostic, often pointing at a route
494
+ * completely unrelated to the one the user wrote. The discriminated
495
+ * union sidesteps overload-resolution heuristics entirely.
496
+ *
497
+ * Open property shapes (`Record<string, unknown>` instead of `never`)
498
+ * for `segmentParams` on routes that don't declare them keep generic
499
+ * `LinkProps`-spreading wrappers compiling. (Aligned with TIM-833.)
500
+ *
501
+ * TIM-832: this function still emits the per-route block FIRST and the
502
+ * catch-all block follows, so per-route remains the LAST overload set in
503
+ * resolution order — the one TS reports against on failure. With a
504
+ * discriminated union there is only one call signature in this block,
505
+ * so the resolved-template-vs-pattern ordering reduces to placing the
506
+ * pattern variant before the resolved-template variant inside the union.
507
+ */
508
+ function formatTypedLinkOverloads(routes, importBase) {
509
+ const lines = [];
510
+ const baseProps = LINK_BASE_PROPS_TYPE;
511
+ const variants = [];
512
+ for (const route of routes) {
513
+ const hasDynamicParams = route.params.length > 0;
514
+ const paramsProp = hasDynamicParams ? `segmentParams: ${formatLinkParamsType(route.params, importBase)}` : "segmentParams?: Record<string, unknown>";
515
+ const searchParamsType = route.hasSearchParams ? formatSearchParamsType(route, importBase) : null;
516
+ const patternSearchParamsProp = searchParamsType ? `searchParams?: Partial<${searchParamsType}>` : "searchParams?: Record<string, unknown>";
517
+ variants.push(`${baseProps} & { href: '${route.urlPath}'; ${paramsProp}; ${patternSearchParamsProp} }`);
518
+ if (hasDynamicParams) {
519
+ const templatePattern = buildResolvedPattern(route);
520
+ if (templatePattern) {
521
+ const resolvedSearchParamsProp = searchParamsType ? `searchParams?: { definition: SearchParamsDefinition<${searchParamsType}>; values: Partial<${searchParamsType}> }` : "searchParams?: Record<string, unknown>";
522
+ variants.push(`${baseProps} & { href: \`${templatePattern}\`; segmentParams?: Record<string, never>; ${resolvedSearchParamsProp} }`);
523
+ }
524
+ }
525
+ }
526
+ lines.push(" interface LinkFunction {");
527
+ if (variants.length === 0) {
528
+ lines.push(" }");
529
+ return lines;
530
+ }
531
+ lines.push(" (");
532
+ lines.push(" props:");
533
+ for (const variant of variants) lines.push(` | (${variant})`);
534
+ lines.push(` ): import('react').JSX.Element`);
535
+ lines.push(" }");
536
+ return lines;
537
+ }
538
+ //#endregion
539
+ //#region src/routing/codegen.ts
540
+ /**
541
+ * Route map codegen.
542
+ *
543
+ * Walks the scanned RouteTree and generates a TypeScript declaration file
544
+ * mapping every route to its params and searchParams shapes.
545
+ *
546
+ * This runs at build time and in dev (regenerated on file changes).
547
+ * No runtime overhead — purely static type generation.
548
+ */
549
+ /**
550
+ * Generate a TypeScript declaration file string from a scanned route tree.
551
+ *
552
+ * The output is a `declare module '@timber-js/app'` block containing the Routes
553
+ * interface that maps every route path to its params and searchParams shape.
554
+ */
555
+ function generateRouteMap(tree, options = {}) {
556
+ const routes = [];
557
+ collectRoutes(tree.root, [], [], routes);
558
+ routes.sort((a, b) => a.urlPath.localeCompare(b.urlPath));
559
+ return formatDeclarationFile(routes, options.outputDir ?? options.appDir);
560
+ }
561
+ /**
562
+ * Recursively walk the segment tree and collect route entries.
563
+ *
564
+ * A route entry is created for any segment that has a `page` or `route` file.
565
+ * Params accumulate from ancestor dynamic segments.
566
+ */
567
+ function collectRoutes(node, ancestorParams, ancestorParamsFiles, routes) {
568
+ const ownParamsFile = node.params && fileHasExport(node.params.filePath, "segmentParams") ? node.params.filePath : void 0;
569
+ const params = [...ancestorParams];
570
+ if (node.paramName) {
571
+ const legacyFallback = ownParamsFile ? void 0 : findLegacyParamsExport(node);
572
+ params.push({
573
+ name: node.paramName,
574
+ type: paramTypeForSegment(node.segmentType),
575
+ legacyCodecFilePath: legacyFallback
576
+ });
577
+ }
578
+ const nextAncestorFiles = ownParamsFile ? [...ancestorParamsFiles, ownParamsFile] : ancestorParamsFiles;
579
+ const isPage = !!node.page;
580
+ const isApiRoute = !!node.route;
581
+ if (isPage || isApiRoute) {
582
+ const leafFirstChain = nextAncestorFiles.length > 0 ? [...nextAncestorFiles].reverse() : [];
583
+ const resolvedParams = params.map((p) => {
584
+ const codecFilePaths = leafFirstChain.length > 0 ? leafFirstChain : p.legacyCodecFilePath ? [p.legacyCodecFilePath] : void 0;
585
+ return {
586
+ name: p.name,
587
+ type: p.type,
588
+ codecFilePaths
589
+ };
590
+ });
591
+ const entry = {
592
+ urlPath: node.urlPath,
593
+ params: resolvedParams,
594
+ hasSearchParams: false,
595
+ isApiRoute
596
+ };
597
+ if (isPage) {
598
+ if (node.params && fileHasExport(node.params.filePath, "searchParams")) {
599
+ entry.hasSearchParams = true;
600
+ entry.searchParamsPagePath = node.params.filePath;
601
+ } else if (node.page && fileHasExport(node.page.filePath, "searchParams")) {
602
+ entry.hasSearchParams = true;
603
+ entry.searchParamsPagePath = node.page.filePath;
604
+ }
605
+ }
606
+ routes.push(entry);
607
+ }
608
+ for (const child of node.children) collectRoutes(child, params, nextAncestorFiles, routes);
609
+ for (const slot of Object.values(node.slots)) collectRoutes(slot, params, nextAncestorFiles, routes);
610
+ }
611
+ /**
612
+ * Determine the TypeScript type for a segment's param.
613
+ */
614
+ function paramTypeForSegment(segmentType) {
615
+ switch (segmentType) {
616
+ case "catch-all": return "string[]";
617
+ case "optional-catch-all": return "string[] | undefined";
618
+ default: return "string";
619
+ }
620
+ }
621
+ /**
622
+ * Check if a file exports a specific named export.
623
+ *
624
+ * Uses a lightweight regex check — not full AST parsing. The actual type
625
+ * extraction happens via the TypeScript compiler in the generated .d.ts.
626
+ */
627
+ function fileHasExport(filePath, exportName) {
628
+ if (!existsSync(filePath)) return false;
629
+ try {
630
+ const content = readFileSync(filePath, "utf-8");
631
+ const e = exportName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
632
+ return new RegExp(`export\\s+(const|let|var)\\s+${e}\\b`).test(content) || new RegExp(`export\\s*\\{[^}]*\\b${e}\\b[^}]*\\}`).test(content);
633
+ } catch {
634
+ return false;
635
+ }
636
+ }
637
+ /**
638
+ * Find a legacy `segmentParams` export on layout.tsx or page.tsx.
639
+ *
640
+ * Backward-compat shim: TIM-508 made params.ts the canonical location
641
+ * for `segmentParams`. Layout/page exports are still accepted for the
642
+ * OWN segment only (not inherited by descendants — see TIM-834).
643
+ */
644
+ function findLegacyParamsExport(node) {
645
+ if (node.layout && fileHasExport(node.layout.filePath, "segmentParams")) return node.layout.filePath;
646
+ if (node.page && fileHasExport(node.page.filePath, "segmentParams")) return node.page.filePath;
647
+ }
648
+ /**
649
+ * Format the collected routes into a TypeScript declaration file.
650
+ */
651
+ function formatDeclarationFile(routes, importBase) {
652
+ const lines = [];
653
+ lines.push("// This file is auto-generated by timber.js route map codegen.");
654
+ lines.push("// Do not edit manually. Regenerated on build and in dev mode.");
655
+ lines.push("");
656
+ lines.push("export {};");
657
+ lines.push("");
658
+ lines.push(emitResolveSegmentFieldHelper());
659
+ lines.push("");
660
+ lines.push("declare module '@timber-js/app' {");
661
+ lines.push(" interface Routes {");
662
+ for (const route of routes) {
663
+ const paramsType = formatParamsType(route.params, importBase);
664
+ const searchParamsType = formatSearchParamsType(route, importBase);
665
+ lines.push(` '${route.urlPath}': {`);
666
+ lines.push(` segmentParams: ${paramsType}`);
667
+ lines.push(` searchParams: ${searchParamsType}`);
668
+ lines.push(` }`);
669
+ }
670
+ lines.push(" }");
671
+ lines.push("}");
672
+ lines.push("");
673
+ const pageRoutes = routes.filter((r) => !r.isApiRoute);
674
+ const dynamicRoutes = routes.filter((r) => r.params.length > 0);
675
+ if (dynamicRoutes.length > 0 || pageRoutes.length > 0) {
676
+ lines.push("declare module '@timber-js/app/client' {");
677
+ lines.push(" import type { SearchParamsDefinition, SetParams, QueryStatesOptions, SearchParamCodec } from '@timber-js/app/search-params'");
678
+ lines.push("");
679
+ if (dynamicRoutes.length > 0) {
680
+ for (const route of dynamicRoutes) {
681
+ const paramsType = formatParamsType(route.params, importBase);
682
+ lines.push(` export function useSegmentParams(route: '${route.urlPath}'): ${paramsType}`);
683
+ }
684
+ lines.push(" export function useSegmentParams(): Record<string, string | string[]>");
685
+ lines.push("");
686
+ }
687
+ if (pageRoutes.length > 0) {
688
+ lines.push(...formatUseQueryStatesOverloads(pageRoutes, importBase));
689
+ lines.push("");
690
+ }
691
+ if (pageRoutes.length > 0) {
692
+ lines.push(" // Typed Link overloads — per-route (block 1 / emitted first)");
693
+ lines.push(...formatTypedLinkOverloads(pageRoutes, importBase));
694
+ lines.push("");
695
+ }
696
+ lines.push("}");
697
+ lines.push("");
698
+ }
699
+ lines.push("declare module '@timber-js/app/client' {");
700
+ lines.push(" import type { SearchParamsDefinition } from '@timber-js/app/search-params'");
701
+ lines.push("");
702
+ lines.push(...formatLinkCatchAllOverloads());
703
+ lines.push("}");
704
+ lines.push("");
705
+ return lines.join("\n");
706
+ }
707
+ /**
708
+ * Format the params type for a route entry.
709
+ */
710
+ function formatParamsType(params, importBase) {
711
+ if (params.length === 0) return "{}";
712
+ return `{ ${params.map((p) => {
713
+ const codecType = buildCodecChainType(p, importBase, p.type);
714
+ return `${p.name}: ${codecType}`;
715
+ }).join("; ")} }`;
716
+ }
717
+ /**
718
+ * Generate useQueryStates overloads.
719
+ *
720
+ * For each page route:
721
+ * - Routes with search-params.ts get a typed overload returning the inferred T
722
+ * - Routes without search-params.ts get an overload returning [{}, SetParams<{}>]
723
+ *
724
+ * A fallback overload for standalone codecs (existing API) is emitted last.
725
+ */
726
+ function formatUseQueryStatesOverloads(routes, importBase) {
727
+ const lines = [];
728
+ for (const route of routes) {
729
+ const searchParamsType = route.hasSearchParams ? formatSearchParamsType(route, importBase) : "{}";
730
+ lines.push(` export function useQueryStates<R extends '${route.urlPath}'>(route: R, options?: QueryStatesOptions): [${searchParamsType}, SetParams<${searchParamsType}>]`);
731
+ }
732
+ lines.push(" export function useQueryStates<T extends Record<string, unknown>>(codecs: { [K in keyof T]: SearchParamCodec<T[K]> }, options?: QueryStatesOptions): [T, SetParams<T>]");
733
+ return lines;
734
+ }
735
+ //#endregion
736
+ //#region src/routing/interception.ts
737
+ /**
738
+ * Collect all interception rewrite rules from the route tree.
739
+ *
740
+ * Walks the tree recursively. For each intercepting segment, computes the
741
+ * intercepted URL based on the marker and the segment's position.
742
+ */
743
+ function collectInterceptionRewrites(root) {
744
+ const rewrites = [];
745
+ walkForInterceptions(root, [root], rewrites);
746
+ return rewrites;
747
+ }
748
+ /**
749
+ * Recursively walk the segment tree to find intercepting routes.
750
+ */
751
+ function walkForInterceptions(node, ancestors, rewrites) {
752
+ for (const child of node.children) if (child.segmentType === "intercepting" && child.interceptionMarker) collectFromInterceptingNode(child, ancestors, rewrites);
753
+ else walkForInterceptions(child, [...ancestors, child], rewrites);
754
+ for (const slot of Object.values(node.slots)) walkForInterceptions(slot, ancestors, rewrites);
755
+ }
756
+ /**
757
+ * For an intercepting segment, find all leaf pages in its sub-tree and
758
+ * generate rewrite rules for each.
759
+ */
760
+ function collectFromInterceptingNode(interceptingNode, ancestors, rewrites) {
761
+ const marker = interceptingNode.interceptionMarker;
762
+ const segmentName = interceptingNode.interceptedSegmentName;
763
+ const parentUrlPath = ancestors[ancestors.length - 1].urlPath;
764
+ const interceptedBase = computeInterceptedBase(parentUrlPath, marker);
765
+ collectLeavesWithRewrites(interceptingNode, interceptedBase === "/" ? `/${segmentName}` : `${interceptedBase}/${segmentName}`, parentUrlPath, [...ancestors, interceptingNode], rewrites);
766
+ }
767
+ /**
768
+ * Recursively find leaf pages in an intercepting sub-tree and generate
769
+ * rewrite rules for each.
770
+ */
771
+ function collectLeavesWithRewrites(node, interceptedUrlPath, interceptingPrefix, segmentPath, rewrites) {
772
+ if (node.page) rewrites.push({
773
+ interceptedPattern: interceptedUrlPath,
774
+ interceptingPrefix,
775
+ segmentPath: [...segmentPath]
776
+ });
777
+ for (const child of node.children) collectLeavesWithRewrites(child, child.segmentType === "group" ? interceptedUrlPath : `${interceptedUrlPath}/${child.segmentName}`, interceptingPrefix, [...segmentPath, child], rewrites);
778
+ }
779
+ /**
780
+ * Compute the base URL that an intercepting route intercepts, given the
781
+ * parent's URL path and the interception marker.
782
+ *
783
+ * - (.) — same level: parent's URL path
784
+ * - (..) — one level up: parent's parent URL path
785
+ * - (...) — root level: /
786
+ * - (..)(..) — two levels up: parent's grandparent URL path
787
+ *
788
+ * Level counting operates on URL path segments, NOT filesystem directories.
789
+ * Route groups and parallel slots are already excluded from urlPath (they
790
+ * don't add URL depth), so (..) correctly climbs visible segments. This
791
+ * avoids the Vinext bug where path.dirname() on filesystem paths would
792
+ * waste climbs on invisible route groups.
793
+ */
794
+ function computeInterceptedBase(parentUrlPath, marker) {
795
+ switch (marker) {
796
+ case "(.)": return parentUrlPath;
797
+ case "(..)": {
798
+ const parts = parentUrlPath.split("/").filter(Boolean);
799
+ parts.pop();
800
+ return parts.length === 0 ? "/" : `/${parts.join("/")}`;
801
+ }
802
+ case "(...)": return "/";
803
+ case "(..)(..)": {
804
+ const parts = parentUrlPath.split("/").filter(Boolean);
805
+ parts.pop();
806
+ parts.pop();
807
+ return parts.length === 0 ? "/" : `/${parts.join("/")}`;
808
+ }
809
+ }
810
+ }
811
+ //#endregion
812
+ //#region src/routing/walkers.ts
813
+ /**
814
+ * Walk a segment tree and collect every leaf with a `page` or `route`
815
+ * handler. Generic over `TFile` so it works on both the build-time
816
+ * scanner output and the runtime manifest tree.
817
+ *
818
+ * - Pages and route handlers at the same URL produce two distinct
819
+ * entries (the build report deduplicates by URL afterward).
820
+ * - Parallel slots are skipped unless `includeSlots: true` (slots
821
+ * share their parent's URL and are not addressable on their own).
822
+ * - Result is sorted by `urlPath` for deterministic output.
823
+ */
824
+ function collectLeafRoutes(root, options = {}) {
825
+ const { includeSlots = false } = options;
826
+ const result = [];
827
+ walk(root, [], result, includeSlots);
828
+ result.sort((a, b) => a.urlPath.localeCompare(b.urlPath));
829
+ return result;
830
+ }
831
+ function walk(node, chain, result, includeSlots) {
832
+ const currentChain = [...chain, node];
833
+ const path = node.urlPath || "/";
834
+ if (node.page) result.push({
835
+ urlPath: path,
836
+ segments: currentChain,
837
+ page: node.page
838
+ });
839
+ if (node.route) result.push({
840
+ urlPath: path,
841
+ segments: currentChain,
842
+ route: node.route
843
+ });
844
+ for (const child of node.children) walk(child, currentChain, result, includeSlots);
845
+ if (includeSlots) for (const slotNode of Object.values(node.slots)) walk(slotNode, currentChain, result, includeSlots);
846
+ }
847
+ //#endregion
848
+ export { scanRoutes as i, collectInterceptionRewrites as n, generateRouteMap as r, collectLeafRoutes as t };
849
+
850
+ //# sourceMappingURL=walkers-Tg0Alwcg.js.map