@timber-js/app 0.2.0-alpha.15 → 0.2.0-alpha.151

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 (854) hide show
  1. package/LICENSE +8 -0
  2. package/dist/_chunks/actions-a0RczDnB.js +1106 -0
  3. package/dist/_chunks/actions-a0RczDnB.js.map +1 -0
  4. package/dist/_chunks/build-output-helper-B20ZuTSA.js +102 -0
  5. package/dist/_chunks/build-output-helper-B20ZuTSA.js.map +1 -0
  6. package/dist/_chunks/cache-api-Co-yI-gP.js +424 -0
  7. package/dist/_chunks/cache-api-Co-yI-gP.js.map +1 -0
  8. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js → canonicalize-P41GR6tY.js} +94 -18
  9. package/dist/_chunks/canonicalize-P41GR6tY.js.map +1 -0
  10. package/dist/_chunks/cli-schema-sync-DJDdyEae.js +629 -0
  11. package/dist/_chunks/cli-schema-sync-DJDdyEae.js.map +1 -0
  12. package/dist/_chunks/cli-schema-sync-D_IhHEUW.js +2 -0
  13. package/dist/_chunks/codec-registry-oOUxugz3.js +21 -0
  14. package/dist/_chunks/codec-registry-oOUxugz3.js.map +1 -0
  15. package/dist/_chunks/define-Bssfp6ot.js +82 -0
  16. package/dist/_chunks/define-Bssfp6ot.js.map +1 -0
  17. package/dist/_chunks/define-CFmvb4Bt.js +203 -0
  18. package/dist/_chunks/define-CFmvb4Bt.js.map +1 -0
  19. package/dist/_chunks/fast-hash-D6hIVt1Y.js +36 -0
  20. package/dist/_chunks/fast-hash-D6hIVt1Y.js.map +1 -0
  21. package/dist/_chunks/format-CfwjgPz9.js +14 -0
  22. package/dist/_chunks/format-CfwjgPz9.js.map +1 -0
  23. package/dist/_chunks/href-validation-FiA_rToW.js +141 -0
  24. package/dist/_chunks/href-validation-FiA_rToW.js.map +1 -0
  25. package/dist/_chunks/logger-CM0clugc.js +645 -0
  26. package/dist/_chunks/logger-CM0clugc.js.map +1 -0
  27. package/dist/_chunks/navigation-root-bUDZLw74.js +124 -0
  28. package/dist/_chunks/navigation-root-bUDZLw74.js.map +1 -0
  29. package/dist/_chunks/plugin-context-DurqFBuY.js +2 -0
  30. package/dist/_chunks/plugin-context-GfDWsdd2.js +268 -0
  31. package/dist/_chunks/plugin-context-GfDWsdd2.js.map +1 -0
  32. package/dist/_chunks/registry-DbJPKoBp.js +20 -0
  33. package/dist/_chunks/registry-DbJPKoBp.js.map +1 -0
  34. package/dist/_chunks/resolve-schema-3iUvBV5T.js +50 -0
  35. package/dist/_chunks/resolve-schema-3iUvBV5T.js.map +1 -0
  36. package/dist/_chunks/router-ref-CtmF-aPv.js +28 -0
  37. package/dist/_chunks/router-ref-CtmF-aPv.js.map +1 -0
  38. package/dist/_chunks/schema-bridge-BY3QLBL7.js +119 -0
  39. package/dist/_chunks/schema-bridge-BY3QLBL7.js.map +1 -0
  40. package/dist/_chunks/segment-classify-CDDRVKs7.js +137 -0
  41. package/dist/_chunks/segment-classify-CDDRVKs7.js.map +1 -0
  42. package/dist/_chunks/segment-context-ZDnXDkbz.js +34 -0
  43. package/dist/_chunks/segment-context-ZDnXDkbz.js.map +1 -0
  44. package/dist/_chunks/{ssr-data-MjmprTmO.js → ssr-data-BOWsq18U.js} +1 -1
  45. package/dist/_chunks/ssr-data-BOWsq18U.js.map +1 -0
  46. package/dist/_chunks/tree-match-D2l830j2.js +102 -0
  47. package/dist/_chunks/tree-match-D2l830j2.js.map +1 -0
  48. package/dist/_chunks/{use-query-states-D5KaffOK.js → use-query-states-CbeQmext.js} +7 -20
  49. package/dist/_chunks/use-query-states-CbeQmext.js.map +1 -0
  50. package/dist/_chunks/use-segment-params-D1CzlgBo.js +151 -0
  51. package/dist/_chunks/use-segment-params-D1CzlgBo.js.map +1 -0
  52. package/dist/_chunks/validation-taUkvA4Q.js +113 -0
  53. package/dist/_chunks/validation-taUkvA4Q.js.map +1 -0
  54. package/dist/_chunks/walkers-DvWDj453.js +790 -0
  55. package/dist/_chunks/walkers-DvWDj453.js.map +1 -0
  56. package/dist/adapters/build-output-helper.d.ts +28 -0
  57. package/dist/adapters/build-output-helper.d.ts.map +1 -0
  58. package/dist/adapters/cloudflare-dev.d.ts +109 -0
  59. package/dist/adapters/cloudflare-dev.d.ts.map +1 -0
  60. package/dist/adapters/cloudflare-dev.js +73 -0
  61. package/dist/adapters/cloudflare-dev.js.map +1 -0
  62. package/dist/adapters/cloudflare-kv-cache.d.ts +64 -0
  63. package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -0
  64. package/dist/adapters/cloudflare-kv-cache.js +117 -0
  65. package/dist/adapters/cloudflare-kv-cache.js.map +1 -0
  66. package/dist/adapters/cloudflare.d.ts +142 -20
  67. package/dist/adapters/cloudflare.d.ts.map +1 -1
  68. package/dist/adapters/cloudflare.js +150 -64
  69. package/dist/adapters/cloudflare.js.map +1 -1
  70. package/dist/adapters/compress-module.d.ts +5 -4
  71. package/dist/adapters/compress-module.d.ts.map +1 -1
  72. package/dist/adapters/nitro.d.ts +17 -3
  73. package/dist/adapters/nitro.d.ts.map +1 -1
  74. package/dist/adapters/nitro.js +146 -147
  75. package/dist/adapters/nitro.js.map +1 -1
  76. package/dist/adapters/shared.d.ts +16 -0
  77. package/dist/adapters/shared.d.ts.map +1 -0
  78. package/dist/cache/cache-api.d.ts +24 -0
  79. package/dist/cache/cache-api.d.ts.map +1 -0
  80. package/dist/cache/handler-store.d.ts +31 -0
  81. package/dist/cache/handler-store.d.ts.map +1 -0
  82. package/dist/cache/index.d.ts +25 -7
  83. package/dist/cache/index.d.ts.map +1 -1
  84. package/dist/cache/index.js +100 -240
  85. package/dist/cache/index.js.map +1 -1
  86. package/dist/cache/invalidation-epoch.d.ts +43 -0
  87. package/dist/cache/invalidation-epoch.d.ts.map +1 -0
  88. package/dist/cache/redis-handler.d.ts +85 -8
  89. package/dist/cache/redis-handler.d.ts.map +1 -1
  90. package/dist/cache/singleflight.d.ts +18 -1
  91. package/dist/cache/singleflight.d.ts.map +1 -1
  92. package/dist/cache/sizeof.d.ts +22 -0
  93. package/dist/cache/sizeof.d.ts.map +1 -0
  94. package/dist/cache/stable-stringify.d.ts +9 -0
  95. package/dist/cache/stable-stringify.d.ts.map +1 -1
  96. package/dist/cache/timber-cache.d.ts +20 -10
  97. package/dist/cache/timber-cache.d.ts.map +1 -1
  98. package/dist/cli-schema-sync.d.ts +59 -0
  99. package/dist/cli-schema-sync.d.ts.map +1 -0
  100. package/dist/cli.d.ts +26 -2
  101. package/dist/cli.d.ts.map +1 -1
  102. package/dist/cli.js +70 -33
  103. package/dist/cli.js.map +1 -1
  104. package/dist/client/browser-dev.d.ts +34 -1
  105. package/dist/client/browser-dev.d.ts.map +1 -1
  106. package/dist/client/browser-entry/action-dispatch.d.ts +17 -0
  107. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -0
  108. package/dist/client/browser-entry/hmr.d.ts +21 -0
  109. package/dist/client/browser-entry/hmr.d.ts.map +1 -0
  110. package/dist/client/browser-entry/hydrate.d.ts +46 -0
  111. package/dist/client/browser-entry/hydrate.d.ts.map +1 -0
  112. package/dist/client/browser-entry/index.d.ts +29 -0
  113. package/dist/client/browser-entry/index.d.ts.map +1 -0
  114. package/dist/client/browser-entry/post-hydration.d.ts +26 -0
  115. package/dist/client/browser-entry/post-hydration.d.ts.map +1 -0
  116. package/dist/client/browser-entry/router-init.d.ts +26 -0
  117. package/dist/client/browser-entry/router-init.d.ts.map +1 -0
  118. package/dist/client/browser-entry/rsc-stream.d.ts +24 -0
  119. package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -0
  120. package/dist/client/browser-entry/scroll.d.ts +28 -0
  121. package/dist/client/browser-entry/scroll.d.ts.map +1 -0
  122. package/dist/client/error-boundary.d.ts +12 -5
  123. package/dist/client/error-boundary.d.ts.map +1 -1
  124. package/dist/client/error-boundary.js +47 -10
  125. package/dist/client/error-boundary.js.map +1 -1
  126. package/dist/client/error-reconstituter.d.ts +61 -0
  127. package/dist/client/error-reconstituter.d.ts.map +1 -0
  128. package/dist/client/form.d.ts +16 -27
  129. package/dist/client/form.d.ts.map +1 -1
  130. package/dist/client/history.d.ts +11 -3
  131. package/dist/client/history.d.ts.map +1 -1
  132. package/dist/client/index.d.ts +10 -24
  133. package/dist/client/index.d.ts.map +1 -1
  134. package/dist/client/index.js +183 -1134
  135. package/dist/client/index.js.map +1 -1
  136. package/dist/client/internal.d.ts +19 -0
  137. package/dist/client/internal.d.ts.map +1 -0
  138. package/dist/client/internal.js +900 -0
  139. package/dist/client/internal.js.map +1 -0
  140. package/dist/client/link.d.ts +69 -60
  141. package/dist/client/link.d.ts.map +1 -1
  142. package/dist/client/navigation-api-types.d.ts +90 -0
  143. package/dist/client/navigation-api-types.d.ts.map +1 -0
  144. package/dist/client/navigation-api.d.ts +122 -0
  145. package/dist/client/navigation-api.d.ts.map +1 -0
  146. package/dist/client/navigation-context.d.ts +3 -2
  147. package/dist/client/navigation-context.d.ts.map +1 -1
  148. package/dist/client/navigation-root.d.ts +119 -0
  149. package/dist/client/navigation-root.d.ts.map +1 -0
  150. package/dist/client/nuqs-adapter.d.ts +1 -1
  151. package/dist/client/nuqs-adapter.d.ts.map +1 -1
  152. package/dist/client/router-ref.d.ts +1 -1
  153. package/dist/client/router.d.ts +86 -10
  154. package/dist/client/router.d.ts.map +1 -1
  155. package/dist/client/rsc-fetch.d.ts +46 -3
  156. package/dist/client/rsc-fetch.d.ts.map +1 -1
  157. package/dist/client/segment-cache.d.ts +3 -1
  158. package/dist/client/segment-cache.d.ts.map +1 -1
  159. package/dist/client/segment-outlet.d.ts +49 -0
  160. package/dist/client/segment-outlet.d.ts.map +1 -0
  161. package/dist/client/segment-update-context.d.ts +21 -0
  162. package/dist/client/segment-update-context.d.ts.map +1 -0
  163. package/dist/client/shallow-url.d.ts +10 -0
  164. package/dist/client/shallow-url.d.ts.map +1 -0
  165. package/dist/client/ssr-data.d.ts +13 -4
  166. package/dist/client/ssr-data.d.ts.map +1 -1
  167. package/dist/client/state.d.ts +1 -1
  168. package/dist/client/top-loader.d.ts +5 -5
  169. package/dist/client/top-loader.d.ts.map +1 -1
  170. package/dist/client/use-cookie.d.ts +12 -0
  171. package/dist/client/use-cookie.d.ts.map +1 -1
  172. package/dist/client/use-link-status.d.ts +5 -5
  173. package/dist/client/use-link-status.d.ts.map +1 -1
  174. package/dist/client/use-pathname.d.ts.map +1 -1
  175. package/dist/client/use-pending-navigation.d.ts +23 -0
  176. package/dist/client/use-pending-navigation.d.ts.map +1 -0
  177. package/dist/client/use-query-states.d.ts +1 -1
  178. package/dist/client/use-query-states.d.ts.map +1 -1
  179. package/dist/client/use-router.d.ts +1 -1
  180. package/dist/client/use-router.d.ts.map +1 -1
  181. package/dist/client/use-search-params.d.ts +12 -5
  182. package/dist/client/use-search-params.d.ts.map +1 -1
  183. package/dist/client/{use-params.d.ts → use-segment-params.d.ts} +8 -6
  184. package/dist/client/use-segment-params.d.ts.map +1 -0
  185. package/dist/codec.d.ts +69 -0
  186. package/dist/codec.d.ts.map +1 -0
  187. package/dist/codec.js +75 -0
  188. package/dist/codec.js.map +1 -0
  189. package/dist/config-types.d.ts +294 -0
  190. package/dist/config-types.d.ts.map +1 -0
  191. package/dist/config-validation.d.ts +51 -0
  192. package/dist/config-validation.d.ts.map +1 -0
  193. package/dist/content/index.d.ts +1 -10
  194. package/dist/content/index.d.ts.map +1 -1
  195. package/dist/content/index.js +0 -2
  196. package/dist/cookies/define-cookie.d.ts +58 -25
  197. package/dist/cookies/define-cookie.d.ts.map +1 -1
  198. package/dist/cookies/index.d.ts +2 -1
  199. package/dist/cookies/index.d.ts.map +1 -1
  200. package/dist/cookies/index.js +249 -36
  201. package/dist/cookies/index.js.map +1 -1
  202. package/dist/cookies/json-cookie.d.ts +64 -0
  203. package/dist/cookies/json-cookie.d.ts.map +1 -0
  204. package/dist/cookies/validation.d.ts +34 -0
  205. package/dist/cookies/validation.d.ts.map +1 -0
  206. package/dist/dev-tools/404-page.d.ts +50 -0
  207. package/dist/dev-tools/404-page.d.ts.map +1 -0
  208. package/dist/dev-tools/browser-logs.d.ts +84 -0
  209. package/dist/dev-tools/browser-logs.d.ts.map +1 -0
  210. package/dist/dev-tools/dev-page-shell.d.ts +78 -0
  211. package/dist/dev-tools/dev-page-shell.d.ts.map +1 -0
  212. package/dist/dev-tools/error-page.d.ts +32 -0
  213. package/dist/dev-tools/error-page.d.ts.map +1 -0
  214. package/dist/dev-tools/holding-server.d.ts +54 -0
  215. package/dist/dev-tools/holding-server.d.ts.map +1 -0
  216. package/dist/dev-tools/hydration-overlay.d.ts +11 -0
  217. package/dist/dev-tools/hydration-overlay.d.ts.map +1 -0
  218. package/dist/dev-tools/index.d.ts +31 -0
  219. package/dist/dev-tools/index.d.ts.map +1 -0
  220. package/dist/dev-tools/instrumentation.d.ts +59 -0
  221. package/dist/dev-tools/instrumentation.d.ts.map +1 -0
  222. package/dist/{server/dev-logger.d.ts → dev-tools/logger.d.ts} +1 -1
  223. package/dist/dev-tools/logger.d.ts.map +1 -0
  224. package/dist/{plugins/dev-logs.d.ts → dev-tools/logs.d.ts} +2 -2
  225. package/dist/dev-tools/logs.d.ts.map +1 -0
  226. package/dist/dev-tools/overlay.d.ts +91 -0
  227. package/dist/dev-tools/overlay.d.ts.map +1 -0
  228. package/dist/dev-tools/stack-classifier.d.ts +34 -0
  229. package/dist/dev-tools/stack-classifier.d.ts.map +1 -0
  230. package/dist/dev-tools/terminal.d.ts +28 -0
  231. package/dist/dev-tools/terminal.d.ts.map +1 -0
  232. package/dist/fonts/ast-walk.d.ts +68 -0
  233. package/dist/fonts/ast-walk.d.ts.map +1 -0
  234. package/dist/fonts/ast.d.ts +110 -6
  235. package/dist/fonts/ast.d.ts.map +1 -1
  236. package/dist/fonts/bundle.d.ts +50 -0
  237. package/dist/fonts/bundle.d.ts.map +1 -0
  238. package/dist/fonts/dev-middleware.d.ts +22 -0
  239. package/dist/fonts/dev-middleware.d.ts.map +1 -0
  240. package/dist/fonts/fallbacks.d.ts +0 -7
  241. package/dist/fonts/fallbacks.d.ts.map +1 -1
  242. package/dist/fonts/google.d.ts +4 -2
  243. package/dist/fonts/google.d.ts.map +1 -1
  244. package/dist/fonts/local.d.ts +4 -4
  245. package/dist/fonts/local.d.ts.map +1 -1
  246. package/dist/fonts/paths.d.ts +43 -0
  247. package/dist/fonts/paths.d.ts.map +1 -0
  248. package/dist/fonts/pipeline.d.ts +158 -0
  249. package/dist/fonts/pipeline.d.ts.map +1 -0
  250. package/dist/fonts/transform.d.ts +78 -0
  251. package/dist/fonts/transform.d.ts.map +1 -0
  252. package/dist/fonts/types.d.ts +47 -1
  253. package/dist/fonts/types.d.ts.map +1 -1
  254. package/dist/fonts/virtual-modules.d.ts +77 -0
  255. package/dist/fonts/virtual-modules.d.ts.map +1 -0
  256. package/dist/index.d.ts +46 -180
  257. package/dist/index.d.ts.map +1 -1
  258. package/dist/index.js +6452 -13421
  259. package/dist/index.js.map +1 -1
  260. package/dist/params/codec-registry.d.ts +26 -0
  261. package/dist/params/codec-registry.d.ts.map +1 -0
  262. package/dist/params/define-schema.d.ts +81 -0
  263. package/dist/params/define-schema.d.ts.map +1 -0
  264. package/dist/params/index.d.ts +5 -0
  265. package/dist/params/index.d.ts.map +1 -0
  266. package/dist/params/index.js +34 -0
  267. package/dist/params/index.js.map +1 -0
  268. package/dist/params/resolve-schema.d.ts +34 -0
  269. package/dist/params/resolve-schema.d.ts.map +1 -0
  270. package/dist/plugin-context.d.ts +137 -0
  271. package/dist/plugin-context.d.ts.map +1 -0
  272. package/dist/plugins/adapter-build.d.ts +20 -1
  273. package/dist/plugins/adapter-build.d.ts.map +1 -1
  274. package/dist/plugins/build-manifest.d.ts +7 -3
  275. package/dist/plugins/build-manifest.d.ts.map +1 -1
  276. package/dist/plugins/build-report.d.ts +9 -7
  277. package/dist/plugins/build-report.d.ts.map +1 -1
  278. package/dist/plugins/cache.d.ts +73 -0
  279. package/dist/plugins/cache.d.ts.map +1 -0
  280. package/dist/plugins/client-chunks.d.ts +39 -0
  281. package/dist/plugins/client-chunks.d.ts.map +1 -0
  282. package/dist/plugins/cloudflare-wasm.d.ts +21 -0
  283. package/dist/plugins/cloudflare-wasm.d.ts.map +1 -0
  284. package/dist/plugins/content.d.ts +1 -1
  285. package/dist/plugins/content.d.ts.map +1 -1
  286. package/dist/plugins/dev-server.d.ts +17 -1
  287. package/dist/plugins/dev-server.d.ts.map +1 -1
  288. package/dist/plugins/entries.d.ts +1 -1
  289. package/dist/plugins/entries.d.ts.map +1 -1
  290. package/dist/plugins/fonts.d.ts +16 -73
  291. package/dist/plugins/fonts.d.ts.map +1 -1
  292. package/dist/plugins/mdx.d.ts +1 -1
  293. package/dist/plugins/mdx.d.ts.map +1 -1
  294. package/dist/plugins/routing.d.ts +1 -1
  295. package/dist/plugins/routing.d.ts.map +1 -1
  296. package/dist/plugins/server-bundle.d.ts.map +1 -1
  297. package/dist/plugins/shims.d.ts +29 -5
  298. package/dist/plugins/shims.d.ts.map +1 -1
  299. package/dist/plugins/static-build.d.ts +5 -26
  300. package/dist/plugins/static-build.d.ts.map +1 -1
  301. package/dist/routing/codegen-shared.d.ts +67 -0
  302. package/dist/routing/codegen-shared.d.ts.map +1 -0
  303. package/dist/routing/codegen-types.d.ts +64 -0
  304. package/dist/routing/codegen-types.d.ts.map +1 -0
  305. package/dist/routing/codegen.d.ts +7 -2
  306. package/dist/routing/codegen.d.ts.map +1 -1
  307. package/dist/routing/convention-lint.d.ts +41 -0
  308. package/dist/routing/convention-lint.d.ts.map +1 -0
  309. package/dist/routing/file-cache.d.ts +8 -0
  310. package/dist/routing/file-cache.d.ts.map +1 -0
  311. package/dist/routing/index.d.ts +7 -1
  312. package/dist/routing/index.d.ts.map +1 -1
  313. package/dist/routing/index.js +4 -2
  314. package/dist/routing/interception.d.ts +0 -5
  315. package/dist/routing/interception.d.ts.map +1 -1
  316. package/dist/routing/link-codegen.d.ts +90 -0
  317. package/dist/routing/link-codegen.d.ts.map +1 -0
  318. package/dist/routing/manifest-codegen.d.ts +32 -0
  319. package/dist/routing/manifest-codegen.d.ts.map +1 -0
  320. package/dist/routing/scanner.d.ts +1 -10
  321. package/dist/routing/scanner.d.ts.map +1 -1
  322. package/dist/routing/schema-validation.d.ts +35 -0
  323. package/dist/routing/schema-validation.d.ts.map +1 -0
  324. package/dist/routing/segment-classify.d.ts +75 -0
  325. package/dist/routing/segment-classify.d.ts.map +1 -0
  326. package/dist/routing/segment-codegen.d.ts +38 -0
  327. package/dist/routing/segment-codegen.d.ts.map +1 -0
  328. package/dist/routing/types.d.ts +77 -25
  329. package/dist/routing/types.d.ts.map +1 -1
  330. package/dist/routing/walkers.d.ts +51 -0
  331. package/dist/routing/walkers.d.ts.map +1 -0
  332. package/dist/rsc-runtime/rsc.d.ts +1 -1
  333. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  334. package/dist/rsc-runtime/ssr.d.ts +12 -0
  335. package/dist/rsc-runtime/ssr.d.ts.map +1 -1
  336. package/dist/schema-bridge.d.ts +91 -0
  337. package/dist/schema-bridge.d.ts.map +1 -0
  338. package/dist/search-params/define.d.ts +157 -0
  339. package/dist/search-params/define.d.ts.map +1 -0
  340. package/dist/search-params/index.d.ts +4 -7
  341. package/dist/search-params/index.d.ts.map +1 -1
  342. package/dist/search-params/index.js +37 -440
  343. package/dist/search-params/index.js.map +1 -1
  344. package/dist/search-params/registry.d.ts +2 -2
  345. package/dist/search-params/registry.d.ts.map +1 -1
  346. package/dist/search-params/wrappers.d.ts +53 -0
  347. package/dist/search-params/wrappers.d.ts.map +1 -0
  348. package/dist/segment-params/define.d.ts +89 -0
  349. package/dist/segment-params/define.d.ts.map +1 -0
  350. package/dist/segment-params/index.d.ts +3 -0
  351. package/dist/segment-params/index.d.ts.map +1 -0
  352. package/dist/segment-params/index.js +2 -0
  353. package/dist/server/access-gate.d.ts +8 -3
  354. package/dist/server/access-gate.d.ts.map +1 -1
  355. package/dist/server/action-client.d.ts +41 -6
  356. package/dist/server/action-client.d.ts.map +1 -1
  357. package/dist/server/action-encryption.d.ts +76 -0
  358. package/dist/server/action-encryption.d.ts.map +1 -0
  359. package/dist/server/action-handler.d.ts +35 -1
  360. package/dist/server/action-handler.d.ts.map +1 -1
  361. package/dist/server/actions.d.ts +9 -30
  362. package/dist/server/actions.d.ts.map +1 -1
  363. package/dist/server/als-registry.d.ts +70 -11
  364. package/dist/server/als-registry.d.ts.map +1 -1
  365. package/dist/server/asset-headers.d.ts +1 -15
  366. package/dist/server/asset-headers.d.ts.map +1 -1
  367. package/dist/server/body-limits.d.ts.map +1 -1
  368. package/dist/server/build-manifest.d.ts +6 -29
  369. package/dist/server/build-manifest.d.ts.map +1 -1
  370. package/dist/server/canonicalize.d.ts +10 -0
  371. package/dist/server/canonicalize.d.ts.map +1 -1
  372. package/dist/server/coalesce-tick.d.ts +40 -0
  373. package/dist/server/coalesce-tick.d.ts.map +1 -0
  374. package/dist/server/cookie-context.d.ts +170 -0
  375. package/dist/server/cookie-context.d.ts.map +1 -0
  376. package/dist/server/cookie-parsing.d.ts +51 -0
  377. package/dist/server/cookie-parsing.d.ts.map +1 -0
  378. package/dist/server/csrf.d.ts +3 -2
  379. package/dist/server/csrf.d.ts.map +1 -1
  380. package/dist/server/default-logger.d.ts +22 -0
  381. package/dist/server/default-logger.d.ts.map +1 -0
  382. package/dist/server/deny-boundary.d.ts +115 -0
  383. package/dist/server/deny-boundary.d.ts.map +1 -0
  384. package/dist/server/deny-renderer.d.ts +2 -2
  385. package/dist/server/deny-renderer.d.ts.map +1 -1
  386. package/dist/server/dev-source-map.d.ts +22 -0
  387. package/dist/server/dev-source-map.d.ts.map +1 -0
  388. package/dist/server/early-hints-sender.d.ts.map +1 -1
  389. package/dist/server/early-hints.d.ts +13 -11
  390. package/dist/server/early-hints.d.ts.map +1 -1
  391. package/dist/server/error-boundary-wrapper.d.ts +7 -1
  392. package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
  393. package/dist/server/fallback-error.d.ts +12 -7
  394. package/dist/server/fallback-error.d.ts.map +1 -1
  395. package/dist/server/flight-injection-state.d.ts +66 -0
  396. package/dist/server/flight-injection-state.d.ts.map +1 -0
  397. package/dist/server/flight-scripts.d.ts +42 -0
  398. package/dist/server/flight-scripts.d.ts.map +1 -0
  399. package/dist/server/form-data.d.ts +29 -0
  400. package/dist/server/form-data.d.ts.map +1 -1
  401. package/dist/server/html-injector-core.d.ts +221 -0
  402. package/dist/server/html-injector-core.d.ts.map +1 -0
  403. package/dist/server/html-injectors.d.ts +81 -41
  404. package/dist/server/html-injectors.d.ts.map +1 -1
  405. package/dist/server/index.d.ts +10 -46
  406. package/dist/server/index.d.ts.map +1 -1
  407. package/dist/server/index.js +170 -2911
  408. package/dist/server/index.js.map +1 -1
  409. package/dist/server/internal.d.ts +44 -0
  410. package/dist/server/internal.d.ts.map +1 -0
  411. package/dist/server/internal.js +3015 -0
  412. package/dist/server/internal.js.map +1 -0
  413. package/dist/server/logger.d.ts +39 -7
  414. package/dist/server/logger.d.ts.map +1 -1
  415. package/dist/server/metadata-routes.d.ts +23 -7
  416. package/dist/server/metadata-routes.d.ts.map +1 -1
  417. package/dist/server/middleware-runner.d.ts +36 -4
  418. package/dist/server/middleware-runner.d.ts.map +1 -1
  419. package/dist/server/node-stream-transforms.d.ts +119 -0
  420. package/dist/server/node-stream-transforms.d.ts.map +1 -0
  421. package/dist/server/param-coercion.d.ts +54 -0
  422. package/dist/server/param-coercion.d.ts.map +1 -0
  423. package/dist/server/pipeline-helpers.d.ts +95 -0
  424. package/dist/server/pipeline-helpers.d.ts.map +1 -0
  425. package/dist/server/pipeline-interception.d.ts +1 -1
  426. package/dist/server/pipeline-interception.d.ts.map +1 -1
  427. package/dist/server/pipeline-metadata.d.ts +6 -0
  428. package/dist/server/pipeline-metadata.d.ts.map +1 -1
  429. package/dist/server/pipeline-outcome.d.ts +49 -0
  430. package/dist/server/pipeline-outcome.d.ts.map +1 -0
  431. package/dist/server/pipeline-phases.d.ts +56 -0
  432. package/dist/server/pipeline-phases.d.ts.map +1 -0
  433. package/dist/server/pipeline.d.ts +122 -19
  434. package/dist/server/pipeline.d.ts.map +1 -1
  435. package/dist/server/port-resolution.d.ts +117 -0
  436. package/dist/server/port-resolution.d.ts.map +1 -0
  437. package/dist/server/primitives.d.ts +75 -31
  438. package/dist/server/primitives.d.ts.map +1 -1
  439. package/dist/server/render-timeout.d.ts +51 -0
  440. package/dist/server/render-timeout.d.ts.map +1 -0
  441. package/dist/server/render-utils.d.ts +25 -0
  442. package/dist/server/render-utils.d.ts.map +1 -0
  443. package/dist/server/request-context.d.ts +62 -107
  444. package/dist/server/request-context.d.ts.map +1 -1
  445. package/dist/server/route-element-builder.d.ts +30 -18
  446. package/dist/server/route-element-builder.d.ts.map +1 -1
  447. package/dist/server/route-handler.d.ts.map +1 -1
  448. package/dist/server/route-matcher.d.ts +25 -36
  449. package/dist/server/route-matcher.d.ts.map +1 -1
  450. package/dist/server/rsc-entry/action-middleware-runner.d.ts +66 -0
  451. package/dist/server/rsc-entry/action-middleware-runner.d.ts.map +1 -0
  452. package/dist/server/rsc-entry/api-handler.d.ts +12 -3
  453. package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
  454. package/dist/server/rsc-entry/error-renderer.d.ts +26 -13
  455. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  456. package/dist/server/rsc-entry/helpers.d.ts +51 -23
  457. package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
  458. package/dist/server/rsc-entry/index.d.ts +19 -8
  459. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  460. package/dist/server/rsc-entry/render-route.d.ts +50 -0
  461. package/dist/server/rsc-entry/render-route.d.ts.map +1 -0
  462. package/dist/server/rsc-entry/revalidate-renderer.d.ts +108 -0
  463. package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -0
  464. package/dist/server/rsc-entry/rsc-payload.d.ts +3 -3
  465. package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
  466. package/dist/server/rsc-entry/rsc-stream.d.ts +17 -1
  467. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  468. package/dist/server/rsc-entry/ssr-bridge.d.ts +5 -1
  469. package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
  470. package/dist/server/rsc-entry/ssr-renderer.d.ts +34 -4
  471. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  472. package/dist/server/rsc-entry/wrap-action-dispatch.d.ts +119 -0
  473. package/dist/server/rsc-entry/wrap-action-dispatch.d.ts.map +1 -0
  474. package/dist/server/safe-load.d.ts +46 -0
  475. package/dist/server/safe-load.d.ts.map +1 -0
  476. package/dist/server/sensitive-fields.d.ts +74 -0
  477. package/dist/server/sensitive-fields.d.ts.map +1 -0
  478. package/dist/server/sitemap-generator.d.ts +129 -0
  479. package/dist/server/sitemap-generator.d.ts.map +1 -0
  480. package/dist/server/sitemap-handler.d.ts +22 -0
  481. package/dist/server/sitemap-handler.d.ts.map +1 -0
  482. package/dist/server/slot-resolver.d.ts +7 -5
  483. package/dist/server/slot-resolver.d.ts.map +1 -1
  484. package/dist/server/ssr-bridge-types.d.ts +121 -0
  485. package/dist/server/ssr-bridge-types.d.ts.map +1 -0
  486. package/dist/server/ssr-entry.d.ts +2 -43
  487. package/dist/server/ssr-entry.d.ts.map +1 -1
  488. package/dist/server/ssr-render.d.ts +64 -21
  489. package/dist/server/ssr-render.d.ts.map +1 -1
  490. package/dist/server/ssr-wrappers.d.ts +50 -0
  491. package/dist/server/ssr-wrappers.d.ts.map +1 -0
  492. package/dist/server/state-tree-diff.d.ts +12 -5
  493. package/dist/server/state-tree-diff.d.ts.map +1 -1
  494. package/dist/server/status-code-resolver.d.ts +22 -11
  495. package/dist/server/status-code-resolver.d.ts.map +1 -1
  496. package/dist/server/stream-utils.d.ts +36 -0
  497. package/dist/server/stream-utils.d.ts.map +1 -0
  498. package/dist/server/tracing.d.ts +7 -6
  499. package/dist/server/tracing.d.ts.map +1 -1
  500. package/dist/server/tree-builder.d.ts +62 -30
  501. package/dist/server/tree-builder.d.ts.map +1 -1
  502. package/dist/server/tree-match.d.ts +49 -0
  503. package/dist/server/tree-match.d.ts.map +1 -0
  504. package/dist/server/types.d.ts +71 -6
  505. package/dist/server/types.d.ts.map +1 -1
  506. package/dist/server/utils/escape-html.d.ts +14 -0
  507. package/dist/server/utils/escape-html.d.ts.map +1 -0
  508. package/dist/server/utils/mdx-file.d.ts +15 -0
  509. package/dist/server/utils/mdx-file.d.ts.map +1 -0
  510. package/dist/server/version-skew.d.ts +61 -0
  511. package/dist/server/version-skew.d.ts.map +1 -0
  512. package/dist/shared/head-header.d.ts +54 -0
  513. package/dist/shared/head-header.d.ts.map +1 -0
  514. package/dist/shared/href-validation.d.ts +49 -0
  515. package/dist/shared/href-validation.d.ts.map +1 -0
  516. package/dist/shared/merge-search-params.d.ts +22 -0
  517. package/dist/shared/merge-search-params.d.ts.map +1 -0
  518. package/dist/shared/redirect-type.d.ts +17 -0
  519. package/dist/shared/redirect-type.d.ts.map +1 -0
  520. package/dist/shims/font-google.d.ts +1 -1
  521. package/dist/shims/font-google.d.ts.map +1 -1
  522. package/dist/shims/font-google.js +42 -0
  523. package/dist/shims/font-google.js.map +1 -0
  524. package/dist/shims/font-local.d.ts +26 -0
  525. package/dist/shims/font-local.d.ts.map +1 -0
  526. package/dist/shims/font-local.js +20 -0
  527. package/dist/shims/font-local.js.map +1 -0
  528. package/dist/shims/headers.d.ts +53 -1
  529. package/dist/shims/headers.d.ts.map +1 -1
  530. package/dist/shims/image.d.ts +16 -16
  531. package/dist/shims/navigation-client.d.ts +35 -11
  532. package/dist/shims/navigation-client.d.ts.map +1 -1
  533. package/dist/shims/navigation.d.ts +11 -5
  534. package/dist/shims/navigation.d.ts.map +1 -1
  535. package/dist/utils/state-machine.d.ts +80 -0
  536. package/dist/utils/state-machine.d.ts.map +1 -0
  537. package/package.json +63 -24
  538. package/src/adapters/build-output-helper.ts +139 -0
  539. package/src/adapters/cloudflare-dev.ts +177 -0
  540. package/src/adapters/cloudflare-kv-cache.ts +179 -0
  541. package/src/adapters/cloudflare.ts +356 -116
  542. package/src/adapters/compress-module.ts +27 -92
  543. package/src/adapters/nitro.ts +155 -99
  544. package/src/adapters/raw-imports.d.ts +5 -0
  545. package/src/adapters/shared.ts +40 -0
  546. package/src/adapters/wrangler.d.ts +7 -0
  547. package/src/cache/cache-api.ts +47 -0
  548. package/src/cache/handler-store.ts +68 -0
  549. package/src/cache/index.ts +84 -18
  550. package/src/cache/invalidation-epoch.ts +93 -0
  551. package/src/cache/redis-handler.ts +110 -15
  552. package/src/cache/singleflight.ts +62 -4
  553. package/src/cache/sizeof.ts +33 -0
  554. package/src/cache/stable-stringify.ts +65 -2
  555. package/src/cache/timber-cache.ts +132 -36
  556. package/src/cli-schema-sync.ts +388 -0
  557. package/src/cli.ts +98 -34
  558. package/src/client/browser-dev.ts +153 -1
  559. package/src/client/browser-entry/action-dispatch.ts +119 -0
  560. package/src/client/browser-entry/hmr.ts +70 -0
  561. package/src/client/browser-entry/hydrate.ts +187 -0
  562. package/src/client/browser-entry/index.ts +111 -0
  563. package/src/client/browser-entry/post-hydration.ts +104 -0
  564. package/src/client/browser-entry/router-init.ts +292 -0
  565. package/src/client/browser-entry/rsc-stream.ts +157 -0
  566. package/src/client/browser-entry/scroll.ts +50 -0
  567. package/src/client/error-boundary.tsx +127 -22
  568. package/src/client/error-reconstituter.tsx +79 -0
  569. package/src/client/form.tsx +31 -32
  570. package/src/client/history.ts +11 -3
  571. package/src/client/index.ts +67 -45
  572. package/src/client/internal.ts +58 -0
  573. package/src/client/link.tsx +346 -150
  574. package/src/client/navigation-api-types.ts +112 -0
  575. package/src/client/navigation-api.ts +347 -0
  576. package/src/client/navigation-context.ts +15 -7
  577. package/src/client/navigation-root.tsx +355 -0
  578. package/src/client/nuqs-adapter.tsx +16 -3
  579. package/src/client/router-ref.ts +1 -1
  580. package/src/client/router.ts +490 -140
  581. package/src/client/rsc-fetch.ts +220 -17
  582. package/src/client/segment-cache.ts +6 -3
  583. package/src/client/segment-outlet.tsx +77 -0
  584. package/src/client/segment-update-context.ts +42 -0
  585. package/src/client/shallow-url.ts +22 -0
  586. package/src/client/ssr-data.ts +13 -5
  587. package/src/client/state.ts +2 -2
  588. package/src/client/top-loader.tsx +11 -9
  589. package/src/client/use-cookie.ts +31 -2
  590. package/src/client/use-link-status.ts +7 -7
  591. package/src/client/use-pathname.ts +1 -0
  592. package/src/client/use-pending-navigation.ts +40 -0
  593. package/src/client/use-query-states.ts +9 -3
  594. package/src/client/use-router.ts +4 -1
  595. package/src/client/use-search-params.ts +31 -44
  596. package/src/client/{use-params.ts → use-segment-params.ts} +9 -6
  597. package/src/codec.ts +147 -0
  598. package/src/config-types.ts +292 -0
  599. package/src/config-validation.ts +311 -0
  600. package/src/content/index.ts +5 -13
  601. package/src/cookies/define-cookie.ts +217 -53
  602. package/src/cookies/index.ts +12 -1
  603. package/src/cookies/json-cookie.ts +105 -0
  604. package/src/cookies/validation.ts +192 -0
  605. package/src/dev-tools/404-page.ts +286 -0
  606. package/src/dev-tools/browser-logs.ts +291 -0
  607. package/src/dev-tools/dev-page-shell.ts +260 -0
  608. package/src/dev-tools/error-page.ts +331 -0
  609. package/src/dev-tools/holding-server.ts +187 -0
  610. package/src/dev-tools/hydration-overlay.ts +158 -0
  611. package/src/dev-tools/index.ts +83 -0
  612. package/src/dev-tools/instrumentation.ts +213 -0
  613. package/src/{plugins/dev-logs.ts → dev-tools/logs.ts} +9 -5
  614. package/src/dev-tools/overlay.ts +469 -0
  615. package/src/dev-tools/stack-classifier.ts +75 -0
  616. package/src/dev-tools/terminal.ts +183 -0
  617. package/src/fonts/ast-walk.ts +235 -0
  618. package/src/fonts/ast.ts +477 -126
  619. package/src/fonts/bundle.ts +138 -0
  620. package/src/fonts/dev-middleware.ts +85 -0
  621. package/src/fonts/fallbacks.ts +0 -23
  622. package/src/fonts/google.ts +7 -3
  623. package/src/fonts/local.ts +9 -8
  624. package/src/fonts/paths.ts +58 -0
  625. package/src/fonts/pipeline.ts +316 -0
  626. package/src/fonts/transform.ts +344 -0
  627. package/src/fonts/types.ts +52 -1
  628. package/src/fonts/virtual-modules.ts +179 -0
  629. package/src/index.ts +417 -346
  630. package/src/params/codec-registry.ts +34 -0
  631. package/src/params/define-schema.ts +115 -0
  632. package/src/params/index.ts +17 -0
  633. package/src/params/resolve-schema.ts +84 -0
  634. package/src/plugin-context.ts +325 -0
  635. package/src/plugins/adapter-build.ts +98 -4
  636. package/src/plugins/build-manifest.ts +168 -23
  637. package/src/plugins/build-report.ts +16 -25
  638. package/src/plugins/cache.ts +285 -0
  639. package/src/plugins/client-chunks.ts +113 -0
  640. package/src/plugins/cloudflare-wasm.ts +141 -0
  641. package/src/plugins/content.ts +1 -1
  642. package/src/plugins/dev-server.ts +293 -46
  643. package/src/plugins/entries.ts +110 -8
  644. package/src/plugins/fonts.ts +170 -663
  645. package/src/plugins/mdx.ts +47 -10
  646. package/src/plugins/routing.ts +237 -241
  647. package/src/plugins/server-bundle.ts +85 -12
  648. package/src/plugins/shims.ts +207 -64
  649. package/src/plugins/static-build.ts +15 -89
  650. package/src/routing/codegen-shared.ts +115 -0
  651. package/src/routing/codegen-types.ts +65 -0
  652. package/src/routing/codegen.ts +380 -178
  653. package/src/routing/convention-lint.ts +358 -0
  654. package/src/routing/file-cache.ts +23 -0
  655. package/src/routing/index.ts +10 -1
  656. package/src/routing/interception.ts +3 -22
  657. package/src/routing/link-codegen.ts +310 -0
  658. package/src/routing/manifest-codegen.ts +290 -0
  659. package/src/routing/scanner.ts +248 -188
  660. package/src/routing/schema-validation.ts +149 -0
  661. package/src/routing/segment-classify.ts +188 -0
  662. package/src/routing/segment-codegen.ts +98 -0
  663. package/src/routing/types.ts +78 -25
  664. package/src/routing/walkers.ts +90 -0
  665. package/src/rsc-runtime/rsc.ts +2 -0
  666. package/src/rsc-runtime/ssr.ts +50 -0
  667. package/src/rsc-runtime/vendor-types.d.ts +7 -0
  668. package/src/schema-bridge.ts +252 -0
  669. package/src/search-params/define.ts +570 -0
  670. package/src/search-params/index.ts +14 -20
  671. package/src/search-params/registry.ts +2 -2
  672. package/src/search-params/wrappers.ts +110 -0
  673. package/src/segment-params/define.ts +249 -0
  674. package/src/segment-params/index.ts +9 -0
  675. package/src/server/access-gate.tsx +84 -34
  676. package/src/server/action-client.ts +119 -28
  677. package/src/server/action-encryption.ts +144 -0
  678. package/src/server/action-handler.ts +122 -16
  679. package/src/server/actions.ts +39 -53
  680. package/src/server/als-registry.ts +108 -20
  681. package/src/server/asset-headers.ts +8 -34
  682. package/src/server/body-limits.ts +10 -2
  683. package/src/server/build-manifest.ts +13 -56
  684. package/src/server/canonicalize.ts +6 -3
  685. package/src/server/coalesce-tick.ts +75 -0
  686. package/src/server/compress.ts +34 -7
  687. package/src/server/cookie-context.ts +484 -0
  688. package/src/server/cookie-parsing.ts +147 -0
  689. package/src/server/csrf.ts +39 -6
  690. package/src/server/default-logger.ts +99 -0
  691. package/src/server/deny-boundary.ts +311 -0
  692. package/src/server/deny-renderer.ts +80 -64
  693. package/src/server/dev-source-map.ts +31 -0
  694. package/src/server/early-hints-sender.ts +3 -2
  695. package/src/server/early-hints.ts +37 -27
  696. package/src/server/error-boundary-wrapper.ts +61 -22
  697. package/src/server/fallback-error.ts +79 -102
  698. package/src/server/flight-injection-state.ts +113 -0
  699. package/src/server/flight-scripts.ts +62 -0
  700. package/src/server/form-data.ts +101 -5
  701. package/src/server/html-injector-core.ts +437 -0
  702. package/src/server/html-injectors.ts +256 -251
  703. package/src/server/index.ts +29 -183
  704. package/src/server/internal.ts +165 -0
  705. package/src/server/logger.ts +67 -36
  706. package/src/server/metadata-routes.ts +44 -19
  707. package/src/server/middleware-runner.ts +75 -4
  708. package/src/server/node-stream-transforms.ts +331 -0
  709. package/src/server/param-coercion.ts +206 -0
  710. package/src/server/pipeline-helpers.ts +204 -0
  711. package/src/server/pipeline-interception.ts +32 -18
  712. package/src/server/pipeline-metadata.ts +13 -0
  713. package/src/server/pipeline-outcome.ts +197 -0
  714. package/src/server/pipeline-phases.ts +527 -0
  715. package/src/server/pipeline.ts +213 -382
  716. package/src/server/port-resolution.ts +215 -0
  717. package/src/server/primitives.ts +126 -63
  718. package/src/server/render-timeout.ts +108 -0
  719. package/src/server/render-utils.ts +31 -0
  720. package/src/server/request-context.ts +168 -337
  721. package/src/server/route-element-builder.ts +481 -222
  722. package/src/server/route-handler.ts +31 -4
  723. package/src/server/route-matcher.ts +144 -277
  724. package/src/server/rsc-entry/action-middleware-runner.ts +167 -0
  725. package/src/server/rsc-entry/api-handler.ts +69 -32
  726. package/src/server/rsc-entry/error-renderer.ts +306 -89
  727. package/src/server/rsc-entry/helpers.ts +160 -59
  728. package/src/server/rsc-entry/index.ts +299 -329
  729. package/src/server/rsc-entry/render-route.ts +311 -0
  730. package/src/server/rsc-entry/revalidate-renderer.ts +344 -0
  731. package/src/server/rsc-entry/rsc-payload.ts +71 -26
  732. package/src/server/rsc-entry/rsc-stream.ts +85 -13
  733. package/src/server/rsc-entry/ssr-bridge.ts +18 -5
  734. package/src/server/rsc-entry/ssr-renderer.ts +273 -43
  735. package/src/server/rsc-entry/wrap-action-dispatch.ts +449 -0
  736. package/src/server/safe-load.ts +60 -0
  737. package/src/server/sensitive-fields.ts +230 -0
  738. package/src/server/sitemap-generator.ts +338 -0
  739. package/src/server/sitemap-handler.ts +148 -0
  740. package/src/server/slot-resolver.ts +258 -257
  741. package/src/server/ssr-bridge-types.ts +124 -0
  742. package/src/server/ssr-entry.ts +206 -78
  743. package/src/server/ssr-render.ts +345 -82
  744. package/src/server/ssr-wrappers.tsx +141 -0
  745. package/src/server/state-tree-diff.ts +30 -23
  746. package/src/server/status-code-resolver.ts +115 -130
  747. package/src/server/stream-utils.ts +213 -0
  748. package/src/server/tracing.ts +38 -11
  749. package/src/server/tree-builder.ts +204 -90
  750. package/src/server/tree-match.ts +220 -0
  751. package/src/server/types.ts +78 -9
  752. package/src/server/utils/escape-html.ts +20 -0
  753. package/src/server/utils/mdx-file.ts +22 -0
  754. package/src/server/version-skew.ts +104 -0
  755. package/src/shared/head-header.ts +69 -0
  756. package/src/shared/href-validation.ts +159 -0
  757. package/src/shared/merge-search-params.ts +55 -0
  758. package/src/shared/redirect-type.ts +17 -0
  759. package/src/shims/font-google.ts +1 -1
  760. package/src/shims/font-local.ts +34 -0
  761. package/src/shims/headers.ts +122 -1
  762. package/src/shims/navigation-client.ts +51 -29
  763. package/src/shims/navigation.ts +14 -7
  764. package/src/utils/state-machine.ts +111 -0
  765. package/dist/_chunks/als-registry-B7DbZ2hS.js +0 -41
  766. package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
  767. package/dist/_chunks/debug-B3Gypr3D.js +0 -108
  768. package/dist/_chunks/debug-B3Gypr3D.js.map +0 -1
  769. package/dist/_chunks/format-RyoGQL74.js +0 -164
  770. package/dist/_chunks/format-RyoGQL74.js.map +0 -1
  771. package/dist/_chunks/interception-BOoWmLUA.js +0 -676
  772. package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
  773. package/dist/_chunks/metadata-routes-Cjmvi3rQ.js.map +0 -1
  774. package/dist/_chunks/request-context-BQUC8PHn.js +0 -330
  775. package/dist/_chunks/request-context-BQUC8PHn.js.map +0 -1
  776. package/dist/_chunks/ssr-data-MjmprTmO.js.map +0 -1
  777. package/dist/_chunks/tracing-CemImE6h.js +0 -187
  778. package/dist/_chunks/tracing-CemImE6h.js.map +0 -1
  779. package/dist/_chunks/use-cookie-DX-l1_5E.js +0 -91
  780. package/dist/_chunks/use-cookie-DX-l1_5E.js.map +0 -1
  781. package/dist/_chunks/use-query-states-D5KaffOK.js.map +0 -1
  782. package/dist/cache/register-cached-function.d.ts +0 -17
  783. package/dist/cache/register-cached-function.d.ts.map +0 -1
  784. package/dist/client/browser-entry.d.ts +0 -21
  785. package/dist/client/browser-entry.d.ts.map +0 -1
  786. package/dist/client/link-status-provider.d.ts +0 -11
  787. package/dist/client/link-status-provider.d.ts.map +0 -1
  788. package/dist/client/segment-merger.d.ts +0 -119
  789. package/dist/client/segment-merger.d.ts.map +0 -1
  790. package/dist/client/stale-reload.d.ts +0 -44
  791. package/dist/client/stale-reload.d.ts.map +0 -1
  792. package/dist/client/transition-root.d.ts +0 -74
  793. package/dist/client/transition-root.d.ts.map +0 -1
  794. package/dist/client/use-navigation-pending.d.ts +0 -26
  795. package/dist/client/use-navigation-pending.d.ts.map +0 -1
  796. package/dist/client/use-params.d.ts.map +0 -1
  797. package/dist/plugins/cache-transform.d.ts +0 -36
  798. package/dist/plugins/cache-transform.d.ts.map +0 -1
  799. package/dist/plugins/dev-error-overlay.d.ts +0 -60
  800. package/dist/plugins/dev-error-overlay.d.ts.map +0 -1
  801. package/dist/plugins/dev-logs.d.ts.map +0 -1
  802. package/dist/plugins/dynamic-transform.d.ts +0 -72
  803. package/dist/plugins/dynamic-transform.d.ts.map +0 -1
  804. package/dist/plugins/server-action-exports.d.ts +0 -26
  805. package/dist/plugins/server-action-exports.d.ts.map +0 -1
  806. package/dist/routing/status-file-lint.d.ts +0 -33
  807. package/dist/routing/status-file-lint.d.ts.map +0 -1
  808. package/dist/search-params/analyze.d.ts +0 -54
  809. package/dist/search-params/analyze.d.ts.map +0 -1
  810. package/dist/search-params/builtin-codecs.d.ts +0 -105
  811. package/dist/search-params/builtin-codecs.d.ts.map +0 -1
  812. package/dist/search-params/codecs.d.ts +0 -53
  813. package/dist/search-params/codecs.d.ts.map +0 -1
  814. package/dist/search-params/create.d.ts +0 -106
  815. package/dist/search-params/create.d.ts.map +0 -1
  816. package/dist/server/dev-fetch-instrumentation.d.ts +0 -22
  817. package/dist/server/dev-fetch-instrumentation.d.ts.map +0 -1
  818. package/dist/server/dev-logger.d.ts.map +0 -1
  819. package/dist/server/dev-span-processor.d.ts +0 -29
  820. package/dist/server/dev-span-processor.d.ts.map +0 -1
  821. package/dist/server/dev-warnings.d.ts +0 -129
  822. package/dist/server/dev-warnings.d.ts.map +0 -1
  823. package/dist/server/flush.d.ts +0 -74
  824. package/dist/server/flush.d.ts.map +0 -1
  825. package/dist/server/manifest-status-resolver.d.ts +0 -58
  826. package/dist/server/manifest-status-resolver.d.ts.map +0 -1
  827. package/dist/server/prerender.d.ts +0 -77
  828. package/dist/server/prerender.d.ts.map +0 -1
  829. package/dist/utils/directive-parser.d.ts +0 -70
  830. package/dist/utils/directive-parser.d.ts.map +0 -1
  831. package/src/cache/register-cached-function.ts +0 -103
  832. package/src/client/browser-entry.ts +0 -678
  833. package/src/client/link-status-provider.tsx +0 -30
  834. package/src/client/segment-merger.ts +0 -339
  835. package/src/client/stale-reload.ts +0 -87
  836. package/src/client/transition-root.tsx +0 -166
  837. package/src/client/use-navigation-pending.ts +0 -38
  838. package/src/plugins/cache-transform.ts +0 -199
  839. package/src/plugins/dev-error-overlay.ts +0 -230
  840. package/src/plugins/dynamic-transform.ts +0 -161
  841. package/src/plugins/server-action-exports.ts +0 -220
  842. package/src/routing/status-file-lint.ts +0 -112
  843. package/src/search-params/analyze.ts +0 -192
  844. package/src/search-params/builtin-codecs.ts +0 -228
  845. package/src/search-params/codecs.ts +0 -153
  846. package/src/search-params/create.ts +0 -321
  847. package/src/server/dev-fetch-instrumentation.ts +0 -96
  848. package/src/server/dev-span-processor.ts +0 -78
  849. package/src/server/dev-warnings.ts +0 -283
  850. package/src/server/flush.ts +0 -182
  851. package/src/server/manifest-status-resolver.ts +0 -215
  852. package/src/server/prerender.ts +0 -139
  853. package/src/utils/directive-parser.ts +0 -529
  854. /package/src/{server/dev-logger.ts → dev-tools/logger.ts} +0 -0
@@ -0,0 +1,1106 @@
1
+ import { A as requestContextAls, D as withSpan, g as isDebug, j as revalidationAls } from "./logger-CM0clugc.js";
2
+ import { t as _setGetSearchParamsFn } from "./define-CFmvb4Bt.js";
3
+ import { t as _setGetSegmentParamsFn } from "./define-Bssfp6ot.js";
4
+ import { n as assertValidCookieOptions, r as assertValidCookieValue, t as assertValidCookieName } from "./validation-taUkvA4Q.js";
5
+ import { a as getWaitUntil, t as cache } from "./cache-api-Co-yI-gP.js";
6
+ import { a as mergePreservedSearchParams, r as validateExternalRedirectUrl, t as assertRelativeRedirectPath } from "./href-validation-FiA_rToW.js";
7
+ //#region src/server/cookie-parsing.ts
8
+ /**
9
+ * Parse a Cookie header string into a Map of name → value pairs.
10
+ * Follows RFC 6265 §4.2.1: cookies are semicolon-separated key=value pairs.
11
+ *
12
+ * Values are auto-decoded with `decodeURIComponent` so they round-trip
13
+ * losslessly with `getCookies().set()` (which auto-encodes). Malformed
14
+ * `%`-escapes from third-party cookies fall back to the raw byte sequence
15
+ * — the parser must be total over arbitrary inbound headers, including
16
+ * non-conforming values from other servers, browser extensions, etc.
17
+ */
18
+ function parseCookieHeader(header) {
19
+ const map = /* @__PURE__ */ new Map();
20
+ if (!header) return map;
21
+ for (const pair of header.split(";")) {
22
+ const eqIndex = pair.indexOf("=");
23
+ if (eqIndex === -1) continue;
24
+ const name = pair.slice(0, eqIndex).trim();
25
+ const value = pair.slice(eqIndex + 1).trim();
26
+ if (name && !map.has(name)) map.set(name, safeDecodeCookieValue(value));
27
+ }
28
+ return map;
29
+ }
30
+ /**
31
+ * Decode a single cookie value with `decodeURIComponent`, falling back to
32
+ * the raw byte sequence if the input contains a malformed `%`-escape.
33
+ *
34
+ * Used by both `parseCookieHeader` (incoming Cookie: header) and the
35
+ * `setRaw` forwarding path (outgoing Set-Cookie from upstream services).
36
+ * Total — never throws.
37
+ */
38
+ function safeDecodeCookieValue(raw) {
39
+ try {
40
+ return decodeURIComponent(raw);
41
+ } catch {
42
+ return raw;
43
+ }
44
+ }
45
+ /** Serialize a CookieEntry into a Set-Cookie header value. */
46
+ function serializeCookieEntry(entry) {
47
+ const parts = [`${entry.name}=${entry.value}`];
48
+ const opts = entry.options;
49
+ if (opts.domain) parts.push(`Domain=${opts.domain}`);
50
+ if (opts.path) parts.push(`Path=${opts.path}`);
51
+ if (opts.expires) parts.push(`Expires=${opts.expires.toUTCString()}`);
52
+ if (opts.maxAge !== void 0) parts.push(`Max-Age=${opts.maxAge}`);
53
+ if (opts.httpOnly) parts.push("HttpOnly");
54
+ if (opts.secure) parts.push("Secure");
55
+ if (opts.sameSite) parts.push(`SameSite=${opts.sameSite.charAt(0).toUpperCase()}${opts.sameSite.slice(1)}`);
56
+ if (opts.partitioned) parts.push("Partitioned");
57
+ return parts.join("; ");
58
+ }
59
+ /**
60
+ * Parse a raw `Set-Cookie` header string into name, value, and options.
61
+ * Handles all standard attributes: Path, Domain, Max-Age, Expires,
62
+ * SameSite, Secure, HttpOnly, Partitioned.
63
+ *
64
+ * Does NOT apply DEFAULT_COOKIE_OPTIONS — the caller decides whether
65
+ * to merge defaults (e.g. `set()` does, but `setRaw()` should preserve
66
+ * the original header's intent).
67
+ */
68
+ function parseSetCookie(header) {
69
+ const segments = header.split(";");
70
+ const nameValue = segments[0];
71
+ const eqIdx = nameValue.indexOf("=");
72
+ if (eqIdx <= 0) return null;
73
+ const name = nameValue.slice(0, eqIdx).trim();
74
+ const value = nameValue.slice(eqIdx + 1).trim();
75
+ const options = {};
76
+ for (let i = 1; i < segments.length; i++) {
77
+ const seg = segments[i].trim();
78
+ if (!seg) continue;
79
+ const [attrName, ...rest] = seg.split("=");
80
+ const key = attrName.trim().toLowerCase();
81
+ const val = rest.join("=").trim();
82
+ switch (key) {
83
+ case "path":
84
+ options.path = val || "/";
85
+ break;
86
+ case "domain":
87
+ options.domain = val;
88
+ break;
89
+ case "max-age": {
90
+ const maxAge = Number(val);
91
+ if (Number.isFinite(maxAge)) options.maxAge = maxAge;
92
+ break;
93
+ }
94
+ case "expires":
95
+ options.expires = new Date(val);
96
+ break;
97
+ case "samesite": {
98
+ const sameSite = val.toLowerCase();
99
+ if (sameSite === "strict" || sameSite === "lax" || sameSite === "none") options.sameSite = sameSite;
100
+ break;
101
+ }
102
+ case "secure":
103
+ options.secure = true;
104
+ break;
105
+ case "httponly":
106
+ options.httpOnly = true;
107
+ break;
108
+ case "partitioned":
109
+ options.partitioned = true;
110
+ break;
111
+ }
112
+ }
113
+ return {
114
+ name,
115
+ value,
116
+ options
117
+ };
118
+ }
119
+ //#endregion
120
+ //#region src/server/cookie-context.ts
121
+ /**
122
+ * Cookie Context — per-request cookie API and on-the-wire helpers.
123
+ *
124
+ * Split out of `request-context.ts` (TIM-853) so the cookie subsystem
125
+ * — encoding contract, options grammar, parser, serializer, RYW map,
126
+ * and rerender seed — lives in one file. The headers/scope/params APIs
127
+ * stay in `request-context.ts` and call into this module via the
128
+ * exported helpers.
129
+ *
130
+ * See design/29-cookies.md for the encoding contract and read-your-own-
131
+ * writes semantics. See ONGOING_SECURITY.md H-3 (TIM-868) for the
132
+ * smuggling primitive that the encoding contract closes.
133
+ */
134
+ /**
135
+ * Returns a cookie accessor for the current request.
136
+ *
137
+ * Available in middleware, access checks, server components, and server actions.
138
+ * Throws if called outside a request context (security principle #2: no global fallback).
139
+ *
140
+ * Read methods (.get, .has, .getAll) are always available and reflect
141
+ * read-your-own-writes from .set() calls in the same request.
142
+ *
143
+ * Mutation methods (.set, .delete, .clear) are only available in mutable
144
+ * contexts (middleware.ts, server actions, route.ts handlers). Calling them
145
+ * in read-only contexts (access.ts, server components) throws.
146
+ *
147
+ * This is the escape hatch for direct cookie jar operations. For typed
148
+ * cookie access, use `defineCookie()` instead.
149
+ *
150
+ * See design/29-cookies.md
151
+ */
152
+ function getCookieJar() {
153
+ const store = requestContextAls.getStore();
154
+ if (!store) throw new Error("[timber] getCookieJar() called outside of a request context. It can only be used in middleware, access checks, server components, and server actions.");
155
+ if (!store.parsedCookies) store.parsedCookies = parseCookieHeader(store.cookieHeader);
156
+ const map = store.parsedCookies;
157
+ return {
158
+ get(name) {
159
+ return map.get(name);
160
+ },
161
+ has(name) {
162
+ return map.has(name);
163
+ },
164
+ getAll() {
165
+ return Array.from(map.entries()).map(([name, value]) => ({
166
+ name,
167
+ value
168
+ }));
169
+ },
170
+ get size() {
171
+ return map.size;
172
+ },
173
+ set(name, value, options) {
174
+ assertMutable(store, "set");
175
+ assertValidCookieName(name);
176
+ if (typeof value !== "string") throw new Error(`[timber] getCookieJar().set(${JSON.stringify(name)}, …): value must be a string, got ${typeof value}.\n To store a JSON-serializable value, use defineCookie + jsonCookieCodec:\n\n import { defineCookie, jsonCookieCodec } from '@timber-js/app/cookies';\n\n export const ${name}Cookie = defineCookie(${JSON.stringify(name)}, {\n codec: jsonCookieCodec(),\n });\n\n ${name}Cookie.set(value);\n\n See design/29-cookies.md §"Typed Cookies with Schema Validation".`);
177
+ const raw = options?.raw === true;
178
+ const wireValue = raw ? value : encodeURIComponent(value);
179
+ if (raw) assertValidCookieValue(name, wireValue);
180
+ if (store.flushed) {
181
+ if (isDebug()) console.warn(`[timber] warn: getCookieJar().set('${name}') called after response headers were committed.\n The cookie will NOT be sent. Move cookie mutations to middleware.ts, a server action,\n or a route.ts handler.`);
182
+ return;
183
+ }
184
+ const { raw: _raw, ...attributeOptions } = options ?? {};
185
+ const opts = {
186
+ ...DEFAULT_COOKIE_OPTIONS,
187
+ ...attributeOptions
188
+ };
189
+ assertValidCookieOptions(opts);
190
+ store.cookieJar.set(name, {
191
+ name,
192
+ value: wireValue,
193
+ options: opts
194
+ });
195
+ map.set(name, raw ? wireValue : value);
196
+ },
197
+ setFromHeaders(headers) {
198
+ assertMutable(store, "setFromHeaders");
199
+ if (store.flushed) {
200
+ console.warn("[timber] warn: getCookieJar().setFromHeaders() called after response headers were committed.\n The cookies will NOT be sent. Move cookie mutations to middleware.ts, a server action,\n or a route.ts handler.");
201
+ return;
202
+ }
203
+ for (const raw of headers.getSetCookie()) {
204
+ const parsed = parseSetCookie(raw);
205
+ if (parsed) setRaw(store, map, parsed.name, parsed.value, parsed.options);
206
+ }
207
+ },
208
+ delete(name, options) {
209
+ assertMutable(store, "delete");
210
+ assertValidCookieName(name);
211
+ if (store.flushed) {
212
+ if (isDebug()) console.warn(`[timber] warn: getCookieJar().delete('${name}') called after response headers were committed.\n The cookie will NOT be deleted. Move cookie mutations to middleware.ts, a server action,\n or a route.ts handler.`);
213
+ return;
214
+ }
215
+ const opts = {
216
+ ...DEFAULT_COOKIE_OPTIONS,
217
+ ...options,
218
+ maxAge: 0,
219
+ expires: /* @__PURE__ */ new Date(0)
220
+ };
221
+ assertValidCookieOptions(opts);
222
+ store.cookieJar.set(name, {
223
+ name,
224
+ value: "",
225
+ options: opts
226
+ });
227
+ map.delete(name);
228
+ },
229
+ clear() {
230
+ assertMutable(store, "clear");
231
+ if (store.flushed) return;
232
+ for (const name of Array.from(map.keys())) store.cookieJar.set(name, {
233
+ name,
234
+ value: "",
235
+ options: {
236
+ ...DEFAULT_COOKIE_OPTIONS,
237
+ maxAge: 0,
238
+ expires: /* @__PURE__ */ new Date(0)
239
+ }
240
+ });
241
+ map.clear();
242
+ },
243
+ toString() {
244
+ return Array.from(map.entries()).map(([name, value]) => `${name}=${encodeURIComponent(value)}`).join("; ");
245
+ }
246
+ };
247
+ }
248
+ /**
249
+ * Returns the value of a single cookie, or undefined if absent.
250
+ *
251
+ * @internal — not part of the public API. Use `defineCookie().get()` or `getCookieJar().get()` instead.
252
+ */
253
+ function getCookie(name) {
254
+ return getCookieJar().get(name);
255
+ }
256
+ var DEFAULT_COOKIE_OPTIONS = {
257
+ path: "/",
258
+ httpOnly: true,
259
+ secure: true,
260
+ sameSite: "lax"
261
+ };
262
+ /**
263
+ * Per-request seed map of cookie name → value, registered out-of-band so the
264
+ * pipeline's `runWithRequestContext` call can pick it up without changing
265
+ * the function's calling convention. Stored in a WeakMap keyed by the
266
+ * synthetic Request object built for the rerender path, so the seed lives
267
+ * exactly as long as the request and is collected with it.
268
+ *
269
+ * The seed exists to eliminate the parse/serialize round-trip on the no-JS
270
+ * form-rerender path — see ONGOING_SECURITY.md H-3 (TIM-868). The action's
271
+ * post-mutation RYW snapshot is threaded directly into the rerender scope's
272
+ * `parsedCookies` map, bypassing `parseCookieHeader` entirely.
273
+ */
274
+ var seededRequestCookies = /* @__PURE__ */ new WeakMap();
275
+ /**
276
+ * Pop the seed (if any) for `req` and return it. Called from
277
+ * `runWithRequestContext` exactly once per request — the seed is consumed
278
+ * eagerly so it cannot leak into a hypothetical future re-use of the same
279
+ * Request reference.
280
+ *
281
+ * @internal — framework use only.
282
+ */
283
+ function consumeSeededCookies(req) {
284
+ const seed = seededRequestCookies.get(req);
285
+ if (seed) seededRequestCookies.delete(req);
286
+ return seed;
287
+ }
288
+ /**
289
+ * Collect all Set-Cookie headers from the cookie jar.
290
+ * Called by the framework at flush time to apply cookies to the response.
291
+ *
292
+ * Returns an array of serialized Set-Cookie header values.
293
+ */
294
+ function getSetCookieHeaders() {
295
+ const store = requestContextAls.getStore();
296
+ if (!store) return [];
297
+ return Array.from(store.cookieJar.values()).map(serializeCookieEntry);
298
+ }
299
+ /** Throw if cookie mutation is attempted in a read-only context. */
300
+ function assertMutable(store, method) {
301
+ if (!store.mutableContext) throw new Error(`[timber] getCookieJar().${method}() cannot be called in this context.\n Set cookies in middleware.ts, server actions, or route.ts handlers.`);
302
+ }
303
+ /**
304
+ * Write a cookie to the jar WITHOUT merging DEFAULT_COOKIE_OPTIONS.
305
+ * Used by setFromHeaders to preserve the original header's attributes exactly.
306
+ *
307
+ * For deletion cookies (maxAge=0), the jar entry is still created so the
308
+ * Set-Cookie header is emitted, but the cookie is NOT added to the read map
309
+ * (it would be misleading — the cookie is being deleted).
310
+ */
311
+ function setRaw(store, readMap, name, value, options) {
312
+ assertValidCookieName(name);
313
+ assertValidCookieValue(name, value);
314
+ assertValidCookieOptions(options);
315
+ store.cookieJar.set(name, {
316
+ name,
317
+ value,
318
+ options
319
+ });
320
+ if (options.maxAge === 0) readMap.delete(name);
321
+ else readMap.set(name, safeDecodeCookieValue(value));
322
+ }
323
+ //#endregion
324
+ //#region src/server/request-context.ts
325
+ /**
326
+ * Request Context — per-request ALS store for headers, search params,
327
+ * segment params, and request scope lifecycle.
328
+ *
329
+ * Follows the same pattern as tracing.ts: a module-level AsyncLocalStorage
330
+ * instance, public accessor functions that throw outside request scope,
331
+ * and a framework-internal `runWithRequestContext()` to establish scope.
332
+ *
333
+ * Cookie state lives in `cookie-context.ts` (split out in TIM-853). The
334
+ * scope set up here owns the cookie jar / parsedCookies fields on the
335
+ * store, but the cookie API and helpers are in the cookie module.
336
+ *
337
+ * See design/04-authorization.md §"AccessContext does not include cookies or headers"
338
+ * and design/11-platform.md §"AsyncLocalStorage".
339
+ */
340
+ /**
341
+ * Returns a read-only view of the current request's headers.
342
+ *
343
+ * Available in middleware, access checks, server components, and server actions.
344
+ * Throws if called outside a request context (security principle #2: no global fallback).
345
+ */
346
+ function getHeaders() {
347
+ const store = requestContextAls.getStore();
348
+ if (!store) throw new Error("[timber] getHeaders() called outside of a request context. It can only be used in middleware, access checks, server components, and server actions.");
349
+ return store.headers;
350
+ }
351
+ /**
352
+ * Returns the value of a single request header, or undefined if absent.
353
+ *
354
+ * Thin wrapper over `getHeaders().get(name)` for the common case where
355
+ * you need exactly one header.
356
+ *
357
+ * @internal — not part of the public API. Use `getHeaders().get(name)` instead.
358
+ */
359
+ function getHeader(name) {
360
+ return getHeaders().get(name) ?? void 0;
361
+ }
362
+ /**
363
+ * Returns the current request's raw URLSearchParams.
364
+ *
365
+ * @internal — not part of the public API. Use `defineSearchParams().get()` instead.
366
+ */
367
+ function getSearchParams() {
368
+ const store = requestContextAls.getStore();
369
+ if (!store) throw new Error("[timber] getSearchParams() called outside of a request context. It can only be used in middleware, access checks, server components, and server actions.");
370
+ return store.searchParams;
371
+ }
372
+ _setGetSearchParamsFn(getSearchParams);
373
+ _setGetSegmentParamsFn(getSegmentParams);
374
+ /**
375
+ * Returns the current request's coerced segment params.
376
+ *
377
+ * The optional `segmentPath` argument exists only for TypeScript narrowing —
378
+ * it does not affect the runtime return value. Pass a segment path
379
+ * (e.g. `'/(browse)/[artistSlug]/[year]'`) to narrow the return type to the
380
+ * exact params shape for that segment.
381
+ *
382
+ * Without an argument, returns all coerced params with optional types.
383
+ *
384
+ * See design/41-global-params.md §Function Signatures
385
+ */
386
+ function getSegmentParams(segmentPath) {
387
+ const store = requestContextAls.getStore();
388
+ if (!store) throw new Error("[timber] getSegmentParams() called outside of a request context. It can only be used in middleware, access checks, server components, and server actions.");
389
+ if (!store.segmentParams) throw new Error("[timber] getSegmentParams() called before route matching completed. Segment params are not available until after the route is matched.");
390
+ if (segmentPath && store.slotParamsMap?.has(segmentPath)) {
391
+ const slotParams = store.slotParamsMap.get(segmentPath);
392
+ return {
393
+ ...store.segmentParams,
394
+ ...slotParams
395
+ };
396
+ }
397
+ if (segmentPath && isDebug() && store.matchedSegmentPath) {
398
+ const expected = extractDynamicSegments(segmentPath);
399
+ const actual = extractDynamicSegments(store.matchedSegmentPath);
400
+ const missing = expected.filter((s) => !actual.includes(s));
401
+ if (missing.length > 0) console.warn(`[timber] getSegmentParams('${segmentPath}') called but current segment is '${store.matchedSegmentPath}'\n Missing params: ${missing.join(", ")}\n These will be undefined at runtime despite the type annotation.`);
402
+ }
403
+ return store.segmentParams;
404
+ }
405
+ /**
406
+ * Set the segment params on the current request context.
407
+ * Called by the pipeline after route matching and param coercion.
408
+ *
409
+ * @internal — framework use only
410
+ */
411
+ function setSegmentParams(params) {
412
+ const store = requestContextAls.getStore();
413
+ if (!store) throw new Error("[timber] setSegmentParams() called outside of a request context.");
414
+ store.segmentParams = params;
415
+ }
416
+ /**
417
+ * Store the matched segment path (e.g. '/(browse)/[artistSlug]/[year]') for
418
+ * dev-mode validation in getSegmentParams().
419
+ *
420
+ * @internal — framework use only
421
+ */
422
+ function setMatchedSegmentPath(segmentPath) {
423
+ const store = requestContextAls.getStore();
424
+ if (!store) return;
425
+ store.matchedSegmentPath = segmentPath;
426
+ }
427
+ /**
428
+ * Extract dynamic segment names from a route pattern.
429
+ * '/[artistSlug]/[year]' → ['artistSlug', 'year']
430
+ * '/docs/[...slug]' → ['slug']
431
+ */
432
+ function extractDynamicSegments(route) {
433
+ const segments = [];
434
+ const re = /\[{1,2}\.{0,3}(\w+)\]{1,2}/g;
435
+ let m;
436
+ while ((m = re.exec(route)) !== null) segments.push(m[1]);
437
+ return segments;
438
+ }
439
+ /**
440
+ * Returns the raw search string from the current request URL (e.g. "?foo=bar").
441
+ * Synchronous — safe for use in `redirect()` which throws synchronously.
442
+ *
443
+ * Returns empty string if called outside a request context (non-throwing for
444
+ * use in redirect's optional preserveSearchParams path).
445
+ *
446
+ * @internal — used by redirect() for preserveSearchParams support.
447
+ */
448
+ function getRequestSearchString() {
449
+ return requestContextAls.getStore()?.searchString ?? "";
450
+ }
451
+ /**
452
+ * Run a callback within a request context. Used by the pipeline to establish
453
+ * per-request ALS scope so that `getHeaders()` and `getCookies()` work.
454
+ *
455
+ * If the request was previously registered via `seedRequestCookies`, the
456
+ * resulting context's `parsedCookies` map is initialized from the seed and
457
+ * the raw `cookieHeader` is left empty — `parseCookieHeader` is never called
458
+ * for that request. This is the no-JS form-rerender path. See TIM-868.
459
+ *
460
+ * @param req - The incoming Request object.
461
+ * @param fn - The function to run within the request context.
462
+ */
463
+ function runWithRequestContext(req, fn) {
464
+ const originalCopy = new Headers(req.headers);
465
+ const parsedUrl = new URL(req.url);
466
+ const seed = consumeSeededCookies(req);
467
+ const store = {
468
+ headers: freezeHeaders(req.headers),
469
+ originalHeaders: originalCopy,
470
+ cookieHeader: seed ? "" : req.headers.get("cookie") ?? "",
471
+ parsedCookies: seed,
472
+ searchParams: parsedUrl.searchParams,
473
+ searchString: parsedUrl.search,
474
+ cookieJar: /* @__PURE__ */ new Map(),
475
+ flushed: false,
476
+ mutableContext: false
477
+ };
478
+ return requestContextAls.run(store, fn);
479
+ }
480
+ /**
481
+ * Enable cookie mutation for the current context. Called by the framework
482
+ * when entering middleware.ts, server actions, or route.ts handlers.
483
+ *
484
+ * See design/29-cookies.md §"Context Tracking"
485
+ */
486
+ function setMutableCookieContext(mutable) {
487
+ const store = requestContextAls.getStore();
488
+ if (store) store.mutableContext = mutable;
489
+ }
490
+ /**
491
+ * Mark the response as flushed (headers committed). After this point,
492
+ * cookie mutations log a warning instead of throwing.
493
+ *
494
+ * See design/29-cookies.md §"Streaming Constraint: Post-Flush Cookie Warning"
495
+ */
496
+ function markResponseFlushed() {
497
+ const store = requestContextAls.getStore();
498
+ if (store) store.flushed = true;
499
+ }
500
+ /**
501
+ * Apply middleware-injected request headers to the current request context.
502
+ *
503
+ * Called by the pipeline after middleware.ts runs. Merges overlay headers
504
+ * on top of the original request headers so downstream code (access.ts,
505
+ * server components, server actions) sees them via `getHeaders()`.
506
+ *
507
+ * The original request headers are never mutated — a new frozen Headers
508
+ * object is created with the overlay applied on top.
509
+ *
510
+ * See design/07-routing.md §"Request Header Injection"
511
+ */
512
+ function applyRequestHeaderOverlay(overlay) {
513
+ const store = requestContextAls.getStore();
514
+ if (!store) throw new Error("[timber] applyRequestHeaderOverlay() called outside of a request context.");
515
+ let hasOverlay = false;
516
+ overlay.forEach(() => {
517
+ hasOverlay = true;
518
+ });
519
+ if (!hasOverlay) return;
520
+ const merged = new Headers(store.originalHeaders);
521
+ overlay.forEach((value, key) => {
522
+ merged.set(key, value);
523
+ });
524
+ store.headers = freezeHeaders(merged);
525
+ }
526
+ var MUTATING_METHODS = new Set([
527
+ "set",
528
+ "append",
529
+ "delete"
530
+ ]);
531
+ /**
532
+ * Wrap a Headers object in a Proxy that throws on mutating methods.
533
+ * Object.freeze doesn't work on Headers (native internal slots), so we
534
+ * intercept property access and reject set/append/delete at runtime.
535
+ *
536
+ * Read methods (get, has, entries, etc.) must be bound to the underlying
537
+ * Headers instance because they access private #headersList slots.
538
+ */
539
+ function freezeHeaders(source) {
540
+ const copy = new Headers(source);
541
+ return new Proxy(copy, { get(target, prop) {
542
+ if (typeof prop === "string" && MUTATING_METHODS.has(prop)) return () => {
543
+ throw new Error(`[timber] getHeaders() returns a read-only Headers object. Calling .${prop}() is not allowed. Use ctx.requestHeaders in middleware to inject headers for downstream components.`);
544
+ };
545
+ const value = Reflect.get(target, prop);
546
+ if (typeof value === "function") return value.bind(target);
547
+ return value;
548
+ } });
549
+ }
550
+ //#endregion
551
+ //#region src/shared/redirect-type.ts
552
+ /**
553
+ * Next.js redirect type discriminator.
554
+ *
555
+ * Provided for API compatibility with libraries that import `RedirectType`
556
+ * from `next/navigation`. In timber, `redirect()` always uses `replace`
557
+ * semantics (no history entry for the redirect itself).
558
+ *
559
+ * Lives in shared/ (isomorphic) so both the server primitives and the
560
+ * client-only next/navigation shim export the same definition without the
561
+ * client shim pulling in server code.
562
+ */
563
+ var RedirectType = {
564
+ push: "push",
565
+ replace: "replace"
566
+ };
567
+ //#endregion
568
+ //#region src/server/primitives.ts
569
+ /**
570
+ * Check if a value is JSON-serializable without data loss.
571
+ * Returns a description of the first non-serializable value found, or null if OK.
572
+ *
573
+ * @internal Exported for testing only.
574
+ */
575
+ function findNonSerializable(value, path = "data") {
576
+ if (value === null || value === void 0) return null;
577
+ switch (typeof value) {
578
+ case "string":
579
+ case "number":
580
+ case "boolean": return null;
581
+ case "bigint": return `${path} contains a BigInt — BigInt throws in JSON.stringify`;
582
+ case "function": return `${path} is a function — functions are not JSON-serializable`;
583
+ case "symbol": return `${path} is a symbol — symbols are not JSON-serializable`;
584
+ case "object": break;
585
+ default: return `${path} has unsupported type "${typeof value}"`;
586
+ }
587
+ if (value instanceof Date) return `${path} is a Date — Dates silently coerce to strings in JSON.stringify`;
588
+ if (value instanceof Map) return `${path} is a Map — Maps serialize as {} in JSON.stringify (data loss)`;
589
+ if (value instanceof Set) return `${path} is a Set — Sets serialize as {} in JSON.stringify (data loss)`;
590
+ if (value instanceof RegExp) return `${path} is a RegExp — RegExps serialize as {} in JSON.stringify`;
591
+ if (value instanceof Error) return `${path} is an Error — Errors serialize as {} in JSON.stringify`;
592
+ if (Array.isArray(value)) {
593
+ for (let i = 0; i < value.length; i++) {
594
+ const result = findNonSerializable(value[i], `${path}[${i}]`);
595
+ if (result) return result;
596
+ }
597
+ return null;
598
+ }
599
+ const proto = Object.getPrototypeOf(value);
600
+ if (proto === null) return `${path} is a null-prototype object — React Flight rejects null prototypes`;
601
+ if (proto !== Object.prototype) return `${path} is a ${value.constructor?.name ?? "unknown"} instance — class instances may lose data in JSON.stringify`;
602
+ for (const key of Object.keys(value)) {
603
+ const result = findNonSerializable(value[key], `${path}.${key}`);
604
+ if (result) return result;
605
+ }
606
+ return null;
607
+ }
608
+ /**
609
+ * Emit a dev-mode warning if data is not JSON-serializable.
610
+ * No-op in production.
611
+ */
612
+ function warnIfNotSerializable(data, callerName) {
613
+ if (!isDebug()) return;
614
+ if (data === void 0) return;
615
+ const issue = findNonSerializable(data);
616
+ if (issue) console.warn(`[timber] ${callerName}: ${issue}. Data passed to deny() or RenderError must be JSON-serializable because the post-flush path uses JSON.stringify, not React Flight.`);
617
+ }
618
+ /**
619
+ * Render-phase signal thrown by `deny()`. Caught by the framework to produce
620
+ * the correct HTTP status code (segment context) or graceful degradation (slot context).
621
+ */
622
+ var DenySignal = class extends Error {
623
+ status;
624
+ data;
625
+ constructor(status, data) {
626
+ super(`Access denied with status ${status}`);
627
+ this.name = "DenySignal";
628
+ this.status = status;
629
+ this.data = data;
630
+ }
631
+ /**
632
+ * Extract the file that called deny() from the stack trace.
633
+ * Returns a short path (e.g. "app/auth/access.ts") or undefined if
634
+ * the stack can't be parsed. Dev-only — used for dev log output.
635
+ */
636
+ get sourceFile() {
637
+ if (!this.stack) return void 0;
638
+ const frames = this.stack.split("\n");
639
+ for (let i = 2; i < frames.length; i++) {
640
+ const frame = frames[i];
641
+ if (!frame) continue;
642
+ if (frame.includes("primitives.ts") || frame.includes("node_modules")) continue;
643
+ const match = frame.match(/\(([^)]+?)(?::\d+:\d+)\)/) ?? frame.match(/at\s+([^\s]+?)(?::\d+:\d+)/);
644
+ if (match?.[1]) {
645
+ const full = match[1];
646
+ const appIdx = full.indexOf("/app/");
647
+ return appIdx >= 0 ? full.slice(appIdx + 1) : full;
648
+ }
649
+ }
650
+ }
651
+ };
652
+ /**
653
+ * Universal denial/error primitive. Throws a `DenySignal` that the framework catches.
654
+ *
655
+ * - In segment context (outside Suspense): produces HTTP status code
656
+ * - In slot context: graceful degradation → denied.tsx → default.tsx → null
657
+ * - Inside Suspense (hold window): promoted to pre-flush behavior
658
+ * - Inside Suspense (after flush): error boundary + noindex meta
659
+ *
660
+ * Supports both positional and object signatures:
661
+ * ```ts
662
+ * deny() // 403 (default)
663
+ * deny(404) // 404
664
+ * deny(503, { retry: true }) // 503 with data
665
+ * deny({ status: 503, message: 'Maintenance' }) // object form
666
+ * ```
667
+ *
668
+ * Accepts any 4xx or 5xx status code. This replaces the need for
669
+ * `throw new RenderError(...)` in user code — RenderError is now an
670
+ * internal pipeline detail.
671
+ *
672
+ * @param statusOrOptions - Status code (number) or options object. Default: 403.
673
+ * @param data - Optional JSON-serializable data (positional form only).
674
+ */
675
+ function deny(statusOrOptions, data) {
676
+ let status;
677
+ let resolvedData;
678
+ if (typeof statusOrOptions === "object" && statusOrOptions !== null) {
679
+ status = statusOrOptions.status ?? 403;
680
+ resolvedData = statusOrOptions.data;
681
+ } else {
682
+ status = statusOrOptions ?? 403;
683
+ resolvedData = data;
684
+ }
685
+ if (status < 400 || status > 599) throw new Error(`deny() requires a 4xx or 5xx status code, got ${status}.`);
686
+ warnIfNotSerializable(resolvedData, "deny()");
687
+ throw new DenySignal(status, resolvedData);
688
+ }
689
+ /**
690
+ * Render-phase signal thrown by `redirect()` and `redirectExternal()`.
691
+ * Caught by the framework to produce a 3xx response or client-side navigation.
692
+ */
693
+ var RedirectSignal = class extends Error {
694
+ location;
695
+ status;
696
+ constructor(location, status) {
697
+ super(`Redirect to ${location}`);
698
+ this.name = "RedirectSignal";
699
+ this.location = location;
700
+ this.status = status;
701
+ }
702
+ };
703
+ /**
704
+ * Redirect to a relative path. Rejects absolute and protocol-relative URLs.
705
+ * Use `redirectExternal()` for external redirects with an allow-list.
706
+ *
707
+ * @param path - Relative path (e.g. '/login', 'settings', '/login?returnTo=/dash')
708
+ * @param statusOrOptions - HTTP status code (3xx, default 302) or options object.
709
+ *
710
+ * @example
711
+ * // Simple redirect
712
+ * redirect('/login');
713
+ *
714
+ * // With status code
715
+ * redirect('/login', 301);
716
+ *
717
+ * // With preserved search params
718
+ * redirect(`/docs/${version}/${slug}`, { preserveSearchParams: ['foo'] });
719
+ */
720
+ function redirect(path, statusOrOptions) {
721
+ let status;
722
+ let preserveSearchParams;
723
+ if (typeof statusOrOptions === "number") status = statusOrOptions;
724
+ else if (statusOrOptions) {
725
+ status = statusOrOptions.status ?? (statusOrOptions.permanent ? 308 : 302);
726
+ preserveSearchParams = statusOrOptions.preserveSearchParams;
727
+ } else status = 302;
728
+ if (status < 300 || status > 399) throw new Error(`redirect() requires a 3xx status code, got ${status}.`);
729
+ assertRelativeRedirectPath(path);
730
+ let resolvedPath = path;
731
+ if (preserveSearchParams) resolvedPath = mergePreservedSearchParams(path, getRequestSearchString(), preserveSearchParams);
732
+ throw new RedirectSignal(resolvedPath, status);
733
+ }
734
+ /**
735
+ * Redirect to an external URL. The origin must be in the provided allow-list.
736
+ *
737
+ * Only http: and https: schemes are permitted. The allow-list is matched
738
+ * against full origins (scheme + host + port), not bare hostnames.
739
+ *
740
+ * @param url - Absolute URL to redirect to.
741
+ * @param allowList - Array of allowed origins (e.g. ['https://example.com', 'https://auth.example.com']).
742
+ * @param status - HTTP redirect status code (3xx). Defaults to 302.
743
+ */
744
+ function redirectExternal(url, allowList, status = 302) {
745
+ if (status < 300 || status > 399) throw new Error(`redirectExternal() requires a 3xx status code, got ${status}.`);
746
+ throw new RedirectSignal(validateExternalRedirectUrl(url, allowList), status);
747
+ }
748
+ /**
749
+ * Typed throw for render-phase errors that carry structured context to error boundaries.
750
+ *
751
+ * The `digest` (code + data) is serialized into the RSC stream separately from the
752
+ * Error instance — only the digest crosses the RSC → client boundary.
753
+ *
754
+ * @example
755
+ * ```ts
756
+ * throw new RenderError('PRODUCT_NOT_FOUND', {
757
+ * title: 'Product not found',
758
+ * resourceId: params.id,
759
+ * })
760
+ * ```
761
+ */
762
+ var RenderError = class extends Error {
763
+ code;
764
+ digest;
765
+ status;
766
+ constructor(code, data, options) {
767
+ super(`RenderError: ${code}`);
768
+ this.name = "RenderError";
769
+ this.code = code;
770
+ this.digest = {
771
+ code,
772
+ data
773
+ };
774
+ warnIfNotSerializable(data, "RenderError");
775
+ const status = options?.status ?? 500;
776
+ if (status < 400 || status > 599) throw new Error(`RenderError status must be 4xx or 5xx, got ${status}.`);
777
+ this.status = status;
778
+ }
779
+ };
780
+ var _waitUntilWarned = false;
781
+ /**
782
+ * Register a promise to be kept alive after the response is sent.
783
+ * Maps to `ctx.waitUntil()` on Cloudflare Workers and similar platforms.
784
+ *
785
+ * In production, the platform adapter installs a per-request waitUntil
786
+ * function via ALS (see waituntil-bridge.ts). This function checks the
787
+ * ALS bridge first, then falls back to the legacy adapter argument.
788
+ *
789
+ * If neither is available, a warning is logged once and the promise is
790
+ * left to resolve (or reject) without being tracked.
791
+ *
792
+ * @param promise - The background work to keep alive.
793
+ * @param adapter - Optional legacy adapter (prefer ALS bridge in production).
794
+ */
795
+ function waitUntil(promise, adapter) {
796
+ const alsFn = getWaitUntil();
797
+ if (alsFn) {
798
+ alsFn(promise);
799
+ return;
800
+ }
801
+ if (adapter && typeof adapter.waitUntil === "function") {
802
+ adapter.waitUntil(promise);
803
+ return;
804
+ }
805
+ if (!_waitUntilWarned) {
806
+ _waitUntilWarned = true;
807
+ console.warn("[timber] waitUntil() is not supported by the current adapter. Background work will not be tracked. This warning is shown once.");
808
+ }
809
+ }
810
+ //#endregion
811
+ //#region src/server/form-data.ts
812
+ /**
813
+ * FormData preprocessing — schema-agnostic conversion of FormData to typed objects.
814
+ *
815
+ * FormData is all strings. Schema validation expects typed values. This module
816
+ * bridges the gap with intelligent coercion that runs *before* schema validation.
817
+ *
818
+ * Inspired by zod-form-data, but schema-agnostic — works with any Standard Schema
819
+ * library (Zod, Valibot, ArkType).
820
+ *
821
+ * See design/08-forms-and-actions.md §"parseFormData() and coerce helpers"
822
+ */
823
+ /**
824
+ * Convert FormData into a plain object with intelligent coercion.
825
+ *
826
+ * Handles:
827
+ * - **Duplicate keys → arrays**: `tags=js&tags=ts` → `{ tags: ["js", "ts"] }`
828
+ * - **Nested dot-paths**: `user.name=Alice` → `{ user: { name: "Alice" } }`
829
+ * - **Empty strings → undefined**: Enables `.optional()` semantics in schemas
830
+ * - **Empty Files → undefined**: File inputs with no selection become `undefined`
831
+ * - **Strips `$ACTION_*` fields**: React's internal hidden fields are excluded
832
+ */
833
+ function parseFormData(formData) {
834
+ const flat = {};
835
+ for (const key of new Set(formData.keys())) {
836
+ if (key.startsWith("$ACTION_")) continue;
837
+ if (DANGEROUS_KEYS.has(key)) continue;
838
+ const processed = formData.getAll(key).map(normalizeValue);
839
+ if (processed.length === 1) flat[key] = processed[0];
840
+ else flat[key] = processed.filter((v) => v !== void 0);
841
+ }
842
+ return expandDotPaths(flat);
843
+ }
844
+ /**
845
+ * Normalize a single FormData entry value.
846
+ * - Empty strings → undefined (enables .optional() semantics)
847
+ * - Empty File objects (no selection) → undefined
848
+ * - Everything else passes through as-is
849
+ */
850
+ function normalizeValue(value) {
851
+ if (typeof value === "string") return value === "" ? void 0 : value;
852
+ if (value instanceof File && value.size === 0 && value.name === "") return;
853
+ return value;
854
+ }
855
+ /**
856
+ * Expand dot-notation keys into nested objects.
857
+ * `{ "user.name": "Alice", "user.age": "30" }` → `{ user: { name: "Alice", age: "30" } }`
858
+ *
859
+ * Keys without dots are left as-is. Bracket notation (e.g. `items[0]`) is NOT
860
+ * supported — use dot notation (`items.0`) instead.
861
+ */
862
+ function expandDotPaths(flat) {
863
+ const result = {};
864
+ let hasDotPaths = false;
865
+ for (const key of Object.keys(flat)) if (key.includes(".")) {
866
+ hasDotPaths = true;
867
+ break;
868
+ }
869
+ if (!hasDotPaths) return flat;
870
+ for (const [key, value] of Object.entries(flat)) {
871
+ const parts = key.split(".");
872
+ if (parts.some((p) => DANGEROUS_KEYS.has(p))) continue;
873
+ if (parts.length === 1) {
874
+ result[parts[0]] = value;
875
+ continue;
876
+ }
877
+ let current = result;
878
+ for (let i = 0; i < parts.length - 1; i++) {
879
+ const part = parts[i];
880
+ if (current[part] === void 0 || current[part] === null) current[part] = {};
881
+ if (typeof current[part] !== "object" || current[part] instanceof File) current[part] = {};
882
+ current = current[part];
883
+ }
884
+ current[parts[parts.length - 1]] = value;
885
+ }
886
+ return result;
887
+ }
888
+ var DANGEROUS_KEYS = new Set(["__proto__"]);
889
+ /**
890
+ * Schema-agnostic coercion primitives for common FormData patterns.
891
+ *
892
+ * These are plain transform functions — they compose with any schema library's
893
+ * `transform`/`preprocess` pipeline:
894
+ *
895
+ * ```ts
896
+ * // Zod
897
+ * z.preprocess(coerce.number, z.number())
898
+ * // Valibot
899
+ * v.pipe(v.unknown(), v.transform(coerce.number), v.number())
900
+ * ```
901
+ */
902
+ var coerce = {
903
+ /**
904
+ * Coerce a string to a number.
905
+ * - `"42"` → `42`
906
+ * - `"3.14"` → `3.14`
907
+ * - `""` / `undefined` / `null` → `undefined`
908
+ * - Non-numeric strings → `undefined` (schema validation will catch this)
909
+ */
910
+ number(value) {
911
+ if (value === void 0 || value === null || value === "") return void 0;
912
+ if (typeof value === "number") return value;
913
+ if (typeof value !== "string") return void 0;
914
+ const num = Number(value);
915
+ if (Number.isNaN(num)) return void 0;
916
+ return num;
917
+ },
918
+ /**
919
+ * Coerce a checkbox value to a boolean.
920
+ * HTML checkboxes submit "on" when checked and are absent when unchecked.
921
+ * - `"on"` / any truthy string → `true`
922
+ * - `undefined` / `null` / `""` → `false`
923
+ */
924
+ checkbox(value) {
925
+ if (value === void 0 || value === null || value === "") return false;
926
+ if (typeof value === "boolean") return value;
927
+ return typeof value === "string" && value.length > 0;
928
+ },
929
+ /**
930
+ * Parse a JSON string into an object.
931
+ * - Valid JSON string → parsed object
932
+ * - `""` / `undefined` / `null` → `undefined`
933
+ * - Invalid JSON → `undefined` (schema validation will catch this)
934
+ */
935
+ json(value) {
936
+ if (value === void 0 || value === null || value === "") return void 0;
937
+ if (typeof value !== "string") return value;
938
+ try {
939
+ return JSON.parse(value);
940
+ } catch {
941
+ return;
942
+ }
943
+ },
944
+ /**
945
+ * Coerce a date string to a Date object.
946
+ * Handles `<input type="date">` (`"2024-01-15"`), `<input type="datetime-local">`
947
+ * (`"2024-01-15T10:30"`), and full ISO 8601 strings.
948
+ * - Valid date string → `Date`
949
+ * - `""` / `undefined` / `null` → `undefined`
950
+ * - Invalid date strings → `undefined` (schema validation will catch this)
951
+ * - Impossible dates that `new Date()` silently normalizes (e.g. Feb 31) → `undefined`
952
+ */
953
+ date(value) {
954
+ if (value === void 0 || value === null || value === "") return void 0;
955
+ if (value instanceof Date) return value;
956
+ if (typeof value !== "string") return void 0;
957
+ const date = new Date(value);
958
+ if (Number.isNaN(date.getTime())) return void 0;
959
+ const ymdMatch = value.match(/^(\d{4})-(\d{2})-(\d{2})/);
960
+ if (ymdMatch) {
961
+ const inputYear = Number(ymdMatch[1]);
962
+ const inputMonth = Number(ymdMatch[2]);
963
+ const inputDay = Number(ymdMatch[3]);
964
+ const isUTC = value.length === 10 || value.endsWith("Z");
965
+ const parsedYear = isUTC ? date.getUTCFullYear() : date.getFullYear();
966
+ const parsedMonth = isUTC ? date.getUTCMonth() + 1 : date.getMonth() + 1;
967
+ const parsedDay = isUTC ? date.getUTCDate() : date.getDate();
968
+ if (inputYear !== parsedYear || inputMonth !== parsedMonth || inputDay !== parsedDay) return;
969
+ }
970
+ return date;
971
+ },
972
+ /**
973
+ * Create a File coercion function with optional size and mime type validation.
974
+ * Returns the File if valid, `undefined` otherwise.
975
+ *
976
+ * ```ts
977
+ * // Basic — just checks it's a real File
978
+ * z.preprocess(coerce.file(), z.instanceof(File))
979
+ *
980
+ * // With constraints
981
+ * z.preprocess(
982
+ * coerce.file({ maxSize: 5 * 1024 * 1024, accept: ['image/png', 'image/jpeg'] }),
983
+ * z.instanceof(File)
984
+ * )
985
+ * ```
986
+ */
987
+ file(options) {
988
+ return (value) => {
989
+ if (value === void 0 || value === null || value === "") return void 0;
990
+ if (!(value instanceof File)) return void 0;
991
+ if (value.size === 0 && value.name === "") return void 0;
992
+ if (options?.maxSize !== void 0 && value.size > options.maxSize) return;
993
+ if (options?.accept !== void 0 && !options.accept.includes(value.type)) return;
994
+ return value;
995
+ };
996
+ }
997
+ };
998
+ //#endregion
999
+ //#region src/server/actions.ts
1000
+ /**
1001
+ * Server action primitives: revalidatePath, revalidateTag, and the action handler.
1002
+ *
1003
+ * - revalidatePath(path) re-renders the route at that path and returns the RSC
1004
+ * flight payload for inline reconciliation.
1005
+ * - revalidateTag(tag) invalidates timber.cache entries by tag.
1006
+ *
1007
+ * Both are callable from anywhere on the server — actions, API routes, handlers.
1008
+ *
1009
+ * The action handler processes incoming action requests, validates CSRF,
1010
+ * enforces body limits, executes the action, and returns the response
1011
+ * (with piggybacked RSC payload if revalidatePath was called).
1012
+ *
1013
+ * See design/08-forms-and-actions.md
1014
+ */
1015
+ /**
1016
+ * Get the current revalidation state. Throws if called outside an action context.
1017
+ * @internal
1018
+ */
1019
+ function getRevalidationState() {
1020
+ const state = revalidationAls.getStore();
1021
+ if (!state) throw new Error("revalidatePath/revalidateTag called outside of a server action context. These functions can only be called during action execution.");
1022
+ return state;
1023
+ }
1024
+ /**
1025
+ * Re-render the route at `path` and include the RSC flight payload in the
1026
+ * action response. The client reconciles inline — no separate fetch needed.
1027
+ *
1028
+ * Can be called from server actions, API routes, or any server-side context.
1029
+ *
1030
+ * @param path - The path to re-render (e.g. '/dashboard', '/todos').
1031
+ */
1032
+ function revalidatePath(path) {
1033
+ const state = getRevalidationState();
1034
+ if (!state.paths.includes(path)) state.paths.push(path);
1035
+ }
1036
+ /**
1037
+ * Invalidate all timber.cache entries tagged with `tag`.
1038
+ * Does not return a payload — the next request for an invalidated entry re-executes.
1039
+ *
1040
+ * @param tag - The cache tag to invalidate (e.g. 'products', 'user:123').
1041
+ */
1042
+ function revalidateTag(tag) {
1043
+ const state = getRevalidationState();
1044
+ if (!state.tags.includes(tag)) state.tags.push(tag);
1045
+ }
1046
+ /**
1047
+ * Execute a server action and process revalidation.
1048
+ *
1049
+ * 1. Sets up revalidation state
1050
+ * 2. Calls the action function
1051
+ * 3. Processes revalidateTag calls (invalidates cache entries)
1052
+ * 4. Processes revalidatePath calls (re-renders and captures RSC payload)
1053
+ * 5. Returns the action result + optional RSC payload
1054
+ *
1055
+ * @param actionFn - The server action function to execute.
1056
+ * @param args - Arguments to pass to the action.
1057
+ * @param config - Handler configuration (cache handler, renderer).
1058
+ */
1059
+ async function executeAction(actionFn, args, config = {}, spanMeta) {
1060
+ const state = {
1061
+ paths: [],
1062
+ tags: []
1063
+ };
1064
+ let actionResult;
1065
+ let redirectTo;
1066
+ let redirectStatus;
1067
+ await revalidationAls.run(state, async () => {
1068
+ try {
1069
+ actionResult = await withSpan("timber.action", {
1070
+ ...spanMeta?.actionFile ? { "timber.action_file": spanMeta.actionFile } : {},
1071
+ ...spanMeta?.actionName ? { "timber.action_name": spanMeta.actionName } : {}
1072
+ }, () => actionFn(...args));
1073
+ } catch (error) {
1074
+ if (error instanceof RedirectSignal) {
1075
+ redirectTo = error.location;
1076
+ redirectStatus = error.status;
1077
+ } else throw error;
1078
+ }
1079
+ });
1080
+ if (state.tags.length > 0) await Promise.all(state.tags.map((tag) => cache.invalidate({ tag })));
1081
+ let revalidation;
1082
+ if (state.paths.length > 0 && config.renderer) {
1083
+ const path = state.paths[0];
1084
+ try {
1085
+ revalidation = await config.renderer(path);
1086
+ } catch (renderError) {
1087
+ if (renderError instanceof RedirectSignal) {
1088
+ redirectTo = renderError.location;
1089
+ redirectStatus = renderError.status;
1090
+ } else if (renderError instanceof DenySignal) console.error(`[timber] revalidatePath dropped — target middleware denied (status ${renderError.status})`);
1091
+ else console.error("[timber] revalidatePath render failed:", renderError);
1092
+ }
1093
+ }
1094
+ return {
1095
+ actionResult,
1096
+ revalidation,
1097
+ ...redirectTo ? {
1098
+ redirectTo,
1099
+ redirectStatus
1100
+ } : {}
1101
+ };
1102
+ }
1103
+ //#endregion
1104
+ export { setSegmentParams as C, getSetCookieHeaders as E, setMutableCookieContext as S, getCookieJar as T, getSearchParams as _, parseFormData as a, runWithRequestContext as b, RenderError as c, redirectExternal as d, waitUntil as f, getHeaders as g, getHeader as h, coerce as i, deny as l, applyRequestHeaderOverlay as m, revalidatePath as n, DenySignal as o, RedirectType as p, revalidateTag as r, RedirectSignal as s, executeAction as t, redirect as u, getSegmentParams as v, getCookie as w, setMatchedSegmentPath as x, markResponseFlushed as y };
1105
+
1106
+ //# sourceMappingURL=actions-a0RczDnB.js.map