@timber-js/app 0.2.0-alpha.8 → 0.2.0-alpha.80

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 (573) hide show
  1. package/LICENSE +8 -0
  2. package/dist/_chunks/actions-Dg-ANYHb.js +421 -0
  3. package/dist/_chunks/actions-Dg-ANYHb.js.map +1 -0
  4. package/dist/_chunks/{als-registry-B7DbZ2hS.js → als-registry-HS0LGUl2.js} +1 -1
  5. package/dist/_chunks/als-registry-HS0LGUl2.js.map +1 -0
  6. package/dist/_chunks/chunk-DYhsFzuS.js +33 -0
  7. package/dist/_chunks/{debug-gwlJkDuf.js → debug-ECi_61pb.js} +2 -2
  8. package/dist/_chunks/debug-ECi_61pb.js.map +1 -0
  9. package/dist/_chunks/define-C77ScO0m.js +106 -0
  10. package/dist/_chunks/define-C77ScO0m.js.map +1 -0
  11. package/dist/_chunks/define-CZqDwhSu.js +199 -0
  12. package/dist/_chunks/define-CZqDwhSu.js.map +1 -0
  13. package/dist/_chunks/define-cookie-C2IkoFGN.js +94 -0
  14. package/dist/_chunks/define-cookie-C2IkoFGN.js.map +1 -0
  15. package/dist/_chunks/{format-DviM89f0.js → dev-warnings-DpGRGoDi.js} +5 -44
  16. package/dist/_chunks/dev-warnings-DpGRGoDi.js.map +1 -0
  17. package/dist/_chunks/format-CYBGxKtc.js +14 -0
  18. package/dist/_chunks/format-CYBGxKtc.js.map +1 -0
  19. package/dist/_chunks/{interception-BOoWmLUA.js → interception-Dpn_UfAD.js} +171 -97
  20. package/dist/_chunks/interception-Dpn_UfAD.js.map +1 -0
  21. package/dist/_chunks/merge-search-params-Cm_KIWDX.js +41 -0
  22. package/dist/_chunks/merge-search-params-Cm_KIWDX.js.map +1 -0
  23. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js → metadata-routes-DS3eKNmf.js} +1 -1
  24. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js.map → metadata-routes-DS3eKNmf.js.map} +1 -1
  25. package/dist/_chunks/request-context-qMsWgy9C.js +478 -0
  26. package/dist/_chunks/request-context-qMsWgy9C.js.map +1 -0
  27. package/dist/_chunks/schema-bridge-C3xl_vfb.js +86 -0
  28. package/dist/_chunks/schema-bridge-C3xl_vfb.js.map +1 -0
  29. package/dist/_chunks/segment-classify-BDNn6EzD.js +65 -0
  30. package/dist/_chunks/segment-classify-BDNn6EzD.js.map +1 -0
  31. package/dist/_chunks/segment-context-fHFLF1PE.js +34 -0
  32. package/dist/_chunks/segment-context-fHFLF1PE.js.map +1 -0
  33. package/dist/_chunks/{ssr-data-MjmprTmO.js → ssr-data-DzuI0bIV.js} +1 -1
  34. package/dist/_chunks/{ssr-data-MjmprTmO.js.map → ssr-data-DzuI0bIV.js.map} +1 -1
  35. package/dist/_chunks/stale-reload-C2plcNtG.js +64 -0
  36. package/dist/_chunks/stale-reload-C2plcNtG.js.map +1 -0
  37. package/dist/_chunks/{tracing-CemImE6h.js → tracing-CCYbKn5n.js} +60 -9
  38. package/dist/_chunks/tracing-CCYbKn5n.js.map +1 -0
  39. package/dist/_chunks/use-params-Br9YSUFV.js +295 -0
  40. package/dist/_chunks/use-params-Br9YSUFV.js.map +1 -0
  41. package/dist/_chunks/{use-query-states-D5KaffOK.js → use-query-states-Lo_s_pw2.js} +4 -4
  42. package/dist/_chunks/use-query-states-Lo_s_pw2.js.map +1 -0
  43. package/dist/_chunks/wrappers-_DTmImGt.js +63 -0
  44. package/dist/_chunks/wrappers-_DTmImGt.js.map +1 -0
  45. package/dist/adapters/cloudflare-dev.d.ts +109 -0
  46. package/dist/adapters/cloudflare-dev.d.ts.map +1 -0
  47. package/dist/adapters/cloudflare-dev.js +73 -0
  48. package/dist/adapters/cloudflare-dev.js.map +1 -0
  49. package/dist/adapters/cloudflare-kv-cache.d.ts +64 -0
  50. package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -0
  51. package/dist/adapters/cloudflare-kv-cache.js +95 -0
  52. package/dist/adapters/cloudflare-kv-cache.js.map +1 -0
  53. package/dist/adapters/cloudflare.d.ts +148 -12
  54. package/dist/adapters/cloudflare.d.ts.map +1 -1
  55. package/dist/adapters/cloudflare.js +135 -11
  56. package/dist/adapters/cloudflare.js.map +1 -1
  57. package/dist/adapters/compress-module.d.ts.map +1 -1
  58. package/dist/adapters/nitro.d.ts +17 -1
  59. package/dist/adapters/nitro.d.ts.map +1 -1
  60. package/dist/adapters/nitro.js +56 -13
  61. package/dist/adapters/nitro.js.map +1 -1
  62. package/dist/cache/cache-api.d.ts +24 -0
  63. package/dist/cache/cache-api.d.ts.map +1 -0
  64. package/dist/cache/handler-store.d.ts +31 -0
  65. package/dist/cache/handler-store.d.ts.map +1 -0
  66. package/dist/cache/index.d.ts +23 -7
  67. package/dist/cache/index.d.ts.map +1 -1
  68. package/dist/cache/index.js +142 -80
  69. package/dist/cache/index.js.map +1 -1
  70. package/dist/cache/singleflight.d.ts +18 -1
  71. package/dist/cache/singleflight.d.ts.map +1 -1
  72. package/dist/cache/sizeof.d.ts +22 -0
  73. package/dist/cache/sizeof.d.ts.map +1 -0
  74. package/dist/cache/timber-cache.d.ts +1 -1
  75. package/dist/cache/timber-cache.d.ts.map +1 -1
  76. package/dist/cli.d.ts +6 -1
  77. package/dist/cli.d.ts.map +1 -1
  78. package/dist/cli.js +6 -1
  79. package/dist/cli.js.map +1 -1
  80. package/dist/client/browser-dev.d.ts +27 -1
  81. package/dist/client/browser-dev.d.ts.map +1 -1
  82. package/dist/client/browser-entry/action-dispatch.d.ts +17 -0
  83. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -0
  84. package/dist/client/browser-entry/hmr.d.ts +21 -0
  85. package/dist/client/browser-entry/hmr.d.ts.map +1 -0
  86. package/dist/client/browser-entry/hydrate.d.ts +46 -0
  87. package/dist/client/browser-entry/hydrate.d.ts.map +1 -0
  88. package/dist/client/browser-entry/index.d.ts +30 -0
  89. package/dist/client/browser-entry/index.d.ts.map +1 -0
  90. package/dist/client/browser-entry/post-hydration.d.ts +26 -0
  91. package/dist/client/browser-entry/post-hydration.d.ts.map +1 -0
  92. package/dist/client/browser-entry/router-init.d.ts +23 -0
  93. package/dist/client/browser-entry/router-init.d.ts.map +1 -0
  94. package/dist/client/browser-entry/rsc-stream.d.ts +24 -0
  95. package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -0
  96. package/dist/client/browser-entry/scroll.d.ts +19 -0
  97. package/dist/client/browser-entry/scroll.d.ts.map +1 -0
  98. package/dist/client/error-boundary.d.ts +12 -5
  99. package/dist/client/error-boundary.d.ts.map +1 -1
  100. package/dist/client/error-boundary.js +10 -4
  101. package/dist/client/error-boundary.js.map +1 -1
  102. package/dist/client/error-reconstituter.d.ts +54 -0
  103. package/dist/client/error-reconstituter.d.ts.map +1 -0
  104. package/dist/client/form.d.ts +2 -2
  105. package/dist/client/form.d.ts.map +1 -1
  106. package/dist/client/history.d.ts +19 -4
  107. package/dist/client/history.d.ts.map +1 -1
  108. package/dist/client/index.d.ts +7 -21
  109. package/dist/client/index.d.ts.map +1 -1
  110. package/dist/client/index.js +210 -1017
  111. package/dist/client/index.js.map +1 -1
  112. package/dist/client/internal.d.ts +18 -0
  113. package/dist/client/internal.d.ts.map +1 -0
  114. package/dist/client/internal.js +890 -0
  115. package/dist/client/internal.js.map +1 -0
  116. package/dist/client/link-pending-store.d.ts +63 -0
  117. package/dist/client/link-pending-store.d.ts.map +1 -0
  118. package/dist/client/link.d.ts +90 -32
  119. package/dist/client/link.d.ts.map +1 -1
  120. package/dist/client/nav-link-store.d.ts +36 -0
  121. package/dist/client/nav-link-store.d.ts.map +1 -0
  122. package/dist/client/navigation-api-types.d.ts +90 -0
  123. package/dist/client/navigation-api-types.d.ts.map +1 -0
  124. package/dist/client/navigation-api.d.ts +115 -0
  125. package/dist/client/navigation-api.d.ts.map +1 -0
  126. package/dist/client/navigation-context.d.ts +13 -2
  127. package/dist/client/navigation-context.d.ts.map +1 -1
  128. package/dist/client/{transition-root.d.ts → navigation-root.d.ts} +42 -8
  129. package/dist/client/navigation-root.d.ts.map +1 -0
  130. package/dist/client/nuqs-adapter.d.ts.map +1 -1
  131. package/dist/client/router-ref.d.ts +1 -1
  132. package/dist/client/router.d.ts +70 -4
  133. package/dist/client/router.d.ts.map +1 -1
  134. package/dist/client/rsc-fetch.d.ts +38 -3
  135. package/dist/client/rsc-fetch.d.ts.map +1 -1
  136. package/dist/client/segment-cache.d.ts +1 -1
  137. package/dist/client/segment-cache.d.ts.map +1 -1
  138. package/dist/client/segment-outlet.d.ts +63 -0
  139. package/dist/client/segment-outlet.d.ts.map +1 -0
  140. package/dist/client/ssr-data.d.ts +13 -4
  141. package/dist/client/ssr-data.d.ts.map +1 -1
  142. package/dist/client/stale-reload.d.ts +15 -0
  143. package/dist/client/stale-reload.d.ts.map +1 -1
  144. package/dist/client/top-loader.d.ts +5 -5
  145. package/dist/client/top-loader.d.ts.map +1 -1
  146. package/dist/client/use-link-status.d.ts +5 -5
  147. package/dist/client/use-link-status.d.ts.map +1 -1
  148. package/dist/client/use-params.d.ts +6 -4
  149. package/dist/client/use-params.d.ts.map +1 -1
  150. package/dist/client/{use-navigation-pending.d.ts → use-pending-navigation.d.ts} +4 -4
  151. package/dist/client/use-pending-navigation.d.ts.map +1 -0
  152. package/dist/client/use-query-states.d.ts +1 -1
  153. package/dist/client/use-query-states.d.ts.map +1 -1
  154. package/dist/client/use-router.d.ts +1 -1
  155. package/dist/codec.d.ts +33 -0
  156. package/dist/codec.d.ts.map +1 -0
  157. package/dist/codec.js +2 -0
  158. package/dist/config-types.d.ts +210 -0
  159. package/dist/config-types.d.ts.map +1 -0
  160. package/dist/content/index.d.ts +1 -10
  161. package/dist/content/index.d.ts.map +1 -1
  162. package/dist/content/index.js +0 -2
  163. package/dist/cookies/define-cookie.d.ts +35 -14
  164. package/dist/cookies/define-cookie.d.ts.map +1 -1
  165. package/dist/cookies/index.js +1 -83
  166. package/dist/fonts/css.d.ts +1 -0
  167. package/dist/fonts/css.d.ts.map +1 -1
  168. package/dist/index.d.ts +45 -192
  169. package/dist/index.d.ts.map +1 -1
  170. package/dist/index.js +12296 -11901
  171. package/dist/index.js.map +1 -1
  172. package/dist/plugin-context.d.ts +84 -0
  173. package/dist/plugin-context.d.ts.map +1 -0
  174. package/dist/plugins/adapter-build.d.ts +1 -1
  175. package/dist/plugins/adapter-build.d.ts.map +1 -1
  176. package/dist/plugins/build-manifest.d.ts +2 -2
  177. package/dist/plugins/build-manifest.d.ts.map +1 -1
  178. package/dist/plugins/build-report.d.ts +3 -3
  179. package/dist/plugins/build-report.d.ts.map +1 -1
  180. package/dist/plugins/client-chunks.d.ts +32 -0
  181. package/dist/plugins/client-chunks.d.ts.map +1 -0
  182. package/dist/plugins/content.d.ts +1 -1
  183. package/dist/plugins/content.d.ts.map +1 -1
  184. package/dist/plugins/dev-browser-logs.d.ts +84 -0
  185. package/dist/plugins/dev-browser-logs.d.ts.map +1 -0
  186. package/dist/plugins/dev-error-overlay.d.ts +26 -1
  187. package/dist/plugins/dev-error-overlay.d.ts.map +1 -1
  188. package/dist/plugins/dev-logs.d.ts +1 -1
  189. package/dist/plugins/dev-logs.d.ts.map +1 -1
  190. package/dist/plugins/dev-server.d.ts +1 -1
  191. package/dist/plugins/dev-server.d.ts.map +1 -1
  192. package/dist/plugins/entries.d.ts +1 -1
  193. package/dist/plugins/entries.d.ts.map +1 -1
  194. package/dist/plugins/fonts.d.ts +19 -5
  195. package/dist/plugins/fonts.d.ts.map +1 -1
  196. package/dist/plugins/mdx.d.ts +1 -1
  197. package/dist/plugins/mdx.d.ts.map +1 -1
  198. package/dist/plugins/routing.d.ts +1 -1
  199. package/dist/plugins/routing.d.ts.map +1 -1
  200. package/dist/plugins/server-bundle.d.ts.map +1 -1
  201. package/dist/plugins/shims.d.ts +6 -5
  202. package/dist/plugins/shims.d.ts.map +1 -1
  203. package/dist/plugins/static-build.d.ts +4 -4
  204. package/dist/plugins/static-build.d.ts.map +1 -1
  205. package/dist/routing/codegen.d.ts +2 -2
  206. package/dist/routing/codegen.d.ts.map +1 -1
  207. package/dist/routing/index.d.ts +2 -0
  208. package/dist/routing/index.d.ts.map +1 -1
  209. package/dist/routing/index.js +3 -2
  210. package/dist/routing/scanner.d.ts.map +1 -1
  211. package/dist/routing/segment-classify.d.ts +46 -0
  212. package/dist/routing/segment-classify.d.ts.map +1 -0
  213. package/dist/routing/status-file-lint.d.ts +2 -1
  214. package/dist/routing/status-file-lint.d.ts.map +1 -1
  215. package/dist/routing/types.d.ts +16 -4
  216. package/dist/routing/types.d.ts.map +1 -1
  217. package/dist/rsc-runtime/rsc.d.ts +1 -1
  218. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  219. package/dist/rsc-runtime/ssr.d.ts +12 -0
  220. package/dist/rsc-runtime/ssr.d.ts.map +1 -1
  221. package/dist/schema-bridge.d.ts +76 -0
  222. package/dist/schema-bridge.d.ts.map +1 -0
  223. package/dist/search-params/define.d.ts +139 -0
  224. package/dist/search-params/define.d.ts.map +1 -0
  225. package/dist/search-params/index.d.ts +4 -7
  226. package/dist/search-params/index.d.ts.map +1 -1
  227. package/dist/search-params/index.js +4 -474
  228. package/dist/search-params/registry.d.ts +2 -2
  229. package/dist/search-params/registry.d.ts.map +1 -1
  230. package/dist/search-params/wrappers.d.ts +53 -0
  231. package/dist/search-params/wrappers.d.ts.map +1 -0
  232. package/dist/segment-params/define.d.ts +78 -0
  233. package/dist/segment-params/define.d.ts.map +1 -0
  234. package/dist/segment-params/index.d.ts +6 -0
  235. package/dist/segment-params/index.d.ts.map +1 -0
  236. package/dist/segment-params/index.js +4 -0
  237. package/dist/server/access-gate.d.ts +4 -0
  238. package/dist/server/access-gate.d.ts.map +1 -1
  239. package/dist/server/action-client.d.ts +12 -1
  240. package/dist/server/action-client.d.ts.map +1 -1
  241. package/dist/server/action-encryption.d.ts +76 -0
  242. package/dist/server/action-encryption.d.ts.map +1 -0
  243. package/dist/server/action-handler.d.ts.map +1 -1
  244. package/dist/server/actions.d.ts +3 -6
  245. package/dist/server/actions.d.ts.map +1 -1
  246. package/dist/server/als-registry.d.ts +32 -4
  247. package/dist/server/als-registry.d.ts.map +1 -1
  248. package/dist/server/build-manifest.d.ts +2 -2
  249. package/dist/server/build-manifest.d.ts.map +1 -1
  250. package/dist/server/debug.d.ts +1 -1
  251. package/dist/server/default-logger.d.ts +22 -0
  252. package/dist/server/default-logger.d.ts.map +1 -0
  253. package/dist/server/deny-page-resolver.d.ts +52 -0
  254. package/dist/server/deny-page-resolver.d.ts.map +1 -0
  255. package/dist/server/deny-renderer.d.ts.map +1 -1
  256. package/dist/server/dev-holding-server.d.ts +52 -0
  257. package/dist/server/dev-holding-server.d.ts.map +1 -0
  258. package/dist/server/dev-warnings.d.ts +1 -21
  259. package/dist/server/dev-warnings.d.ts.map +1 -1
  260. package/dist/server/early-hints.d.ts +13 -5
  261. package/dist/server/early-hints.d.ts.map +1 -1
  262. package/dist/server/error-boundary-wrapper.d.ts +7 -1
  263. package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
  264. package/dist/server/fallback-error.d.ts +4 -3
  265. package/dist/server/fallback-error.d.ts.map +1 -1
  266. package/dist/server/flight-injection-state.d.ts +66 -0
  267. package/dist/server/flight-injection-state.d.ts.map +1 -0
  268. package/dist/server/flight-scripts.d.ts +42 -0
  269. package/dist/server/flight-scripts.d.ts.map +1 -0
  270. package/dist/server/flush.d.ts.map +1 -1
  271. package/dist/server/form-data.d.ts +29 -0
  272. package/dist/server/form-data.d.ts.map +1 -1
  273. package/dist/server/html-injectors.d.ts +51 -11
  274. package/dist/server/html-injectors.d.ts.map +1 -1
  275. package/dist/server/index.d.ts +6 -43
  276. package/dist/server/index.d.ts.map +1 -1
  277. package/dist/server/index.js +38 -2798
  278. package/dist/server/index.js.map +1 -1
  279. package/dist/server/internal.d.ts +46 -0
  280. package/dist/server/internal.d.ts.map +1 -0
  281. package/dist/server/internal.js +2883 -0
  282. package/dist/server/internal.js.map +1 -0
  283. package/dist/server/logger.d.ts +25 -7
  284. package/dist/server/logger.d.ts.map +1 -1
  285. package/dist/server/middleware-runner.d.ts +19 -4
  286. package/dist/server/middleware-runner.d.ts.map +1 -1
  287. package/dist/server/node-stream-transforms.d.ts +113 -0
  288. package/dist/server/node-stream-transforms.d.ts.map +1 -0
  289. package/dist/server/page-deny-boundary.d.ts +31 -0
  290. package/dist/server/page-deny-boundary.d.ts.map +1 -0
  291. package/dist/server/pipeline-interception.d.ts +1 -1
  292. package/dist/server/pipeline-interception.d.ts.map +1 -1
  293. package/dist/server/pipeline-metadata.d.ts +6 -0
  294. package/dist/server/pipeline-metadata.d.ts.map +1 -1
  295. package/dist/server/pipeline.d.ts +42 -10
  296. package/dist/server/pipeline.d.ts.map +1 -1
  297. package/dist/server/primitives.d.ts +69 -18
  298. package/dist/server/primitives.d.ts.map +1 -1
  299. package/dist/server/render-timeout.d.ts +51 -0
  300. package/dist/server/render-timeout.d.ts.map +1 -0
  301. package/dist/server/request-context.d.ts +112 -43
  302. package/dist/server/request-context.d.ts.map +1 -1
  303. package/dist/server/route-element-builder.d.ts +27 -1
  304. package/dist/server/route-element-builder.d.ts.map +1 -1
  305. package/dist/server/route-handler.d.ts.map +1 -1
  306. package/dist/server/route-matcher.d.ts +9 -2
  307. package/dist/server/route-matcher.d.ts.map +1 -1
  308. package/dist/server/rsc-entry/api-handler.d.ts +2 -2
  309. package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
  310. package/dist/server/rsc-entry/error-renderer.d.ts +26 -13
  311. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  312. package/dist/server/rsc-entry/helpers.d.ts +48 -5
  313. package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
  314. package/dist/server/rsc-entry/index.d.ts +8 -3
  315. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  316. package/dist/server/rsc-entry/rsc-payload.d.ts +3 -3
  317. package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
  318. package/dist/server/rsc-entry/rsc-stream.d.ts +4 -1
  319. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  320. package/dist/server/rsc-entry/ssr-bridge.d.ts +1 -1
  321. package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
  322. package/dist/server/rsc-entry/ssr-renderer.d.ts +19 -4
  323. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  324. package/dist/server/safe-load.d.ts +46 -0
  325. package/dist/server/safe-load.d.ts.map +1 -0
  326. package/dist/server/sitemap-generator.d.ts +129 -0
  327. package/dist/server/sitemap-generator.d.ts.map +1 -0
  328. package/dist/server/sitemap-handler.d.ts +22 -0
  329. package/dist/server/sitemap-handler.d.ts.map +1 -0
  330. package/dist/server/slot-resolver.d.ts +1 -1
  331. package/dist/server/slot-resolver.d.ts.map +1 -1
  332. package/dist/server/ssr-entry.d.ts +22 -0
  333. package/dist/server/ssr-entry.d.ts.map +1 -1
  334. package/dist/server/ssr-render.d.ts +39 -21
  335. package/dist/server/ssr-render.d.ts.map +1 -1
  336. package/dist/server/ssr-wrappers.d.ts +50 -0
  337. package/dist/server/ssr-wrappers.d.ts.map +1 -0
  338. package/dist/server/status-code-resolver.d.ts +1 -1
  339. package/dist/server/status-code-resolver.d.ts.map +1 -1
  340. package/dist/server/stream-utils.d.ts +36 -0
  341. package/dist/server/stream-utils.d.ts.map +1 -0
  342. package/dist/server/tracing.d.ts +4 -4
  343. package/dist/server/tracing.d.ts.map +1 -1
  344. package/dist/server/tree-builder.d.ts +22 -19
  345. package/dist/server/tree-builder.d.ts.map +1 -1
  346. package/dist/server/types.d.ts +1 -4
  347. package/dist/server/types.d.ts.map +1 -1
  348. package/dist/server/version-skew.d.ts +61 -0
  349. package/dist/server/version-skew.d.ts.map +1 -0
  350. package/dist/shared/merge-search-params.d.ts +22 -0
  351. package/dist/shared/merge-search-params.d.ts.map +1 -0
  352. package/dist/shims/font-google.d.ts +1 -1
  353. package/dist/shims/font-google.d.ts.map +1 -1
  354. package/dist/shims/font-google.js +42 -0
  355. package/dist/shims/font-google.js.map +1 -0
  356. package/dist/shims/font-local.d.ts +26 -0
  357. package/dist/shims/font-local.d.ts.map +1 -0
  358. package/dist/shims/font-local.js +20 -0
  359. package/dist/shims/font-local.js.map +1 -0
  360. package/dist/shims/headers.d.ts +2 -1
  361. package/dist/shims/headers.d.ts.map +1 -1
  362. package/dist/shims/navigation-client.d.ts +1 -1
  363. package/dist/shims/navigation-client.d.ts.map +1 -1
  364. package/dist/shims/navigation.d.ts +3 -2
  365. package/dist/shims/navigation.d.ts.map +1 -1
  366. package/dist/utils/directive-parser.d.ts +5 -2
  367. package/dist/utils/directive-parser.d.ts.map +1 -1
  368. package/dist/utils/state-machine.d.ts +80 -0
  369. package/dist/utils/state-machine.d.ts.map +1 -0
  370. package/package.json +53 -23
  371. package/src/adapters/cloudflare-dev.ts +177 -0
  372. package/src/adapters/cloudflare-kv-cache.ts +142 -0
  373. package/src/adapters/cloudflare.ts +342 -28
  374. package/src/adapters/compress-module.ts +24 -4
  375. package/src/adapters/nitro.ts +52 -8
  376. package/src/adapters/wrangler.d.ts +7 -0
  377. package/src/cache/cache-api.ts +38 -0
  378. package/src/cache/handler-store.ts +68 -0
  379. package/src/cache/index.ts +81 -18
  380. package/src/cache/singleflight.ts +62 -4
  381. package/src/cache/sizeof.ts +31 -0
  382. package/src/cache/timber-cache.ts +24 -20
  383. package/src/cli.ts +6 -1
  384. package/src/client/browser-dev.ts +128 -1
  385. package/src/client/browser-entry/action-dispatch.ts +116 -0
  386. package/src/client/browser-entry/hmr.ts +81 -0
  387. package/src/client/browser-entry/hydrate.ts +145 -0
  388. package/src/client/browser-entry/index.ts +138 -0
  389. package/src/client/browser-entry/post-hydration.ts +119 -0
  390. package/src/client/browser-entry/router-init.ts +193 -0
  391. package/src/client/browser-entry/rsc-stream.ts +157 -0
  392. package/src/client/browser-entry/scroll.ts +27 -0
  393. package/src/client/error-boundary.tsx +48 -16
  394. package/src/client/error-reconstituter.tsx +65 -0
  395. package/src/client/form.tsx +2 -2
  396. package/src/client/history.ts +26 -4
  397. package/src/client/index.ts +19 -38
  398. package/src/client/internal.ts +57 -0
  399. package/src/client/link-pending-store.ts +111 -0
  400. package/src/client/link.tsx +329 -97
  401. package/src/client/nav-link-store.ts +47 -0
  402. package/src/client/navigation-api-types.ts +112 -0
  403. package/src/client/navigation-api.ts +332 -0
  404. package/src/client/navigation-context.ts +31 -6
  405. package/src/client/navigation-root.tsx +342 -0
  406. package/src/client/nuqs-adapter.tsx +16 -3
  407. package/src/client/router-ref.ts +1 -1
  408. package/src/client/router.ts +299 -72
  409. package/src/client/rsc-fetch.ts +97 -8
  410. package/src/client/segment-cache.ts +1 -1
  411. package/src/client/segment-outlet.tsx +86 -0
  412. package/src/client/ssr-data.ts +13 -5
  413. package/src/client/stale-reload.ts +72 -3
  414. package/src/client/top-loader.tsx +16 -8
  415. package/src/client/use-link-status.ts +7 -7
  416. package/src/client/use-params.ts +7 -5
  417. package/src/client/{use-navigation-pending.ts → use-pending-navigation.ts} +6 -6
  418. package/src/client/use-query-states.ts +3 -3
  419. package/src/client/use-router.ts +1 -1
  420. package/src/codec.ts +49 -0
  421. package/src/config-types.ts +208 -0
  422. package/src/content/index.ts +5 -13
  423. package/src/cookies/define-cookie.ts +78 -25
  424. package/src/cookies/index.ts +8 -0
  425. package/src/fonts/css.ts +2 -1
  426. package/src/index.ts +258 -354
  427. package/src/plugin-context.ts +200 -0
  428. package/src/plugins/adapter-build.ts +8 -2
  429. package/src/plugins/build-manifest.ts +13 -2
  430. package/src/plugins/build-report.ts +3 -3
  431. package/src/plugins/client-chunks.ts +65 -0
  432. package/src/plugins/content.ts +1 -1
  433. package/src/plugins/dev-browser-logs.ts +288 -0
  434. package/src/plugins/dev-error-overlay.ts +70 -1
  435. package/src/plugins/dev-logs.ts +1 -1
  436. package/src/plugins/dev-server.ts +70 -9
  437. package/src/plugins/entries.ts +71 -10
  438. package/src/plugins/fonts.ts +168 -61
  439. package/src/plugins/mdx.ts +1 -1
  440. package/src/plugins/routing.ts +57 -17
  441. package/src/plugins/server-action-exports.ts +1 -1
  442. package/src/plugins/server-bundle.ts +32 -1
  443. package/src/plugins/shims.ts +135 -35
  444. package/src/plugins/static-build.ts +17 -11
  445. package/src/routing/codegen.ts +165 -105
  446. package/src/routing/index.ts +2 -0
  447. package/src/routing/scanner.ts +93 -23
  448. package/src/routing/segment-classify.ts +89 -0
  449. package/src/routing/status-file-lint.ts +3 -2
  450. package/src/routing/types.ts +17 -4
  451. package/src/rsc-runtime/rsc.ts +2 -0
  452. package/src/rsc-runtime/ssr.ts +50 -0
  453. package/src/rsc-runtime/vendor-types.d.ts +7 -0
  454. package/src/{search-params/codecs.ts → schema-bridge.ts} +57 -20
  455. package/src/search-params/define.ts +482 -0
  456. package/src/search-params/index.ts +14 -20
  457. package/src/search-params/registry.ts +2 -2
  458. package/src/search-params/wrappers.ts +85 -0
  459. package/src/segment-params/define.ts +279 -0
  460. package/src/segment-params/index.ts +29 -0
  461. package/src/server/access-gate.tsx +70 -29
  462. package/src/server/action-client.ts +21 -2
  463. package/src/server/action-encryption.ts +144 -0
  464. package/src/server/action-handler.ts +21 -4
  465. package/src/server/actions.ts +10 -9
  466. package/src/server/als-registry.ts +34 -6
  467. package/src/server/build-manifest.ts +10 -4
  468. package/src/server/compress.ts +25 -7
  469. package/src/server/debug.ts +1 -1
  470. package/src/server/default-logger.ts +99 -0
  471. package/src/server/deny-page-resolver.ts +154 -0
  472. package/src/server/deny-renderer.ts +24 -38
  473. package/src/server/dev-holding-server.ts +185 -0
  474. package/src/server/dev-warnings.ts +4 -49
  475. package/src/server/early-hints.ts +36 -15
  476. package/src/server/error-boundary-wrapper.ts +74 -22
  477. package/src/server/fallback-error.ts +31 -15
  478. package/src/server/flight-injection-state.ts +113 -0
  479. package/src/server/flight-scripts.ts +62 -0
  480. package/src/server/flush.ts +2 -1
  481. package/src/server/form-data.ts +76 -0
  482. package/src/server/html-injectors.ts +280 -120
  483. package/src/server/index.ts +26 -177
  484. package/src/server/internal.ts +169 -0
  485. package/src/server/logger.ts +44 -36
  486. package/src/server/middleware-runner.ts +31 -4
  487. package/src/server/node-stream-transforms.ts +509 -0
  488. package/src/server/page-deny-boundary.tsx +56 -0
  489. package/src/server/pipeline-interception.ts +17 -16
  490. package/src/server/pipeline-metadata.ts +13 -0
  491. package/src/server/pipeline.ts +227 -62
  492. package/src/server/primitives.ts +111 -28
  493. package/src/server/render-timeout.ts +108 -0
  494. package/src/server/request-context.ts +293 -132
  495. package/src/server/route-element-builder.ts +283 -191
  496. package/src/server/route-handler.ts +24 -4
  497. package/src/server/route-matcher.ts +24 -20
  498. package/src/server/rsc-entry/api-handler.ts +15 -16
  499. package/src/server/rsc-entry/error-renderer.ts +300 -89
  500. package/src/server/rsc-entry/helpers.ts +134 -5
  501. package/src/server/rsc-entry/index.ts +200 -112
  502. package/src/server/rsc-entry/rsc-payload.ts +65 -18
  503. package/src/server/rsc-entry/rsc-stream.ts +65 -13
  504. package/src/server/rsc-entry/ssr-bridge.ts +14 -5
  505. package/src/server/rsc-entry/ssr-renderer.ts +168 -38
  506. package/src/server/safe-load.ts +60 -0
  507. package/src/server/sitemap-generator.ts +338 -0
  508. package/src/server/sitemap-handler.ts +126 -0
  509. package/src/server/slot-resolver.ts +244 -229
  510. package/src/server/ssr-entry.ts +211 -32
  511. package/src/server/ssr-render.ts +289 -67
  512. package/src/server/ssr-wrappers.tsx +139 -0
  513. package/src/server/status-code-resolver.ts +1 -1
  514. package/src/server/stream-utils.ts +213 -0
  515. package/src/server/tracing.ts +20 -9
  516. package/src/server/tree-builder.ts +92 -58
  517. package/src/server/types.ts +3 -6
  518. package/src/server/version-skew.ts +104 -0
  519. package/src/shared/merge-search-params.ts +55 -0
  520. package/src/shims/font-google.ts +1 -1
  521. package/src/shims/font-local.ts +34 -0
  522. package/src/shims/headers.ts +5 -1
  523. package/src/shims/navigation-client.ts +1 -1
  524. package/src/shims/navigation.ts +7 -2
  525. package/src/utils/directive-parser.ts +5 -2
  526. package/src/utils/state-machine.ts +111 -0
  527. package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
  528. package/dist/_chunks/debug-gwlJkDuf.js.map +0 -1
  529. package/dist/_chunks/format-DviM89f0.js.map +0 -1
  530. package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
  531. package/dist/_chunks/request-context-DIkVh_jG.js +0 -330
  532. package/dist/_chunks/request-context-DIkVh_jG.js.map +0 -1
  533. package/dist/_chunks/tracing-CemImE6h.js.map +0 -1
  534. package/dist/_chunks/use-cookie-DX-l1_5E.js +0 -91
  535. package/dist/_chunks/use-cookie-DX-l1_5E.js.map +0 -1
  536. package/dist/_chunks/use-query-states-D5KaffOK.js.map +0 -1
  537. package/dist/cache/register-cached-function.d.ts +0 -17
  538. package/dist/cache/register-cached-function.d.ts.map +0 -1
  539. package/dist/client/browser-entry.d.ts +0 -21
  540. package/dist/client/browser-entry.d.ts.map +0 -1
  541. package/dist/client/link-status-provider.d.ts +0 -11
  542. package/dist/client/link-status-provider.d.ts.map +0 -1
  543. package/dist/client/transition-root.d.ts.map +0 -1
  544. package/dist/client/use-navigation-pending.d.ts.map +0 -1
  545. package/dist/cookies/index.js.map +0 -1
  546. package/dist/plugins/cache-transform.d.ts +0 -36
  547. package/dist/plugins/cache-transform.d.ts.map +0 -1
  548. package/dist/plugins/dynamic-transform.d.ts +0 -72
  549. package/dist/plugins/dynamic-transform.d.ts.map +0 -1
  550. package/dist/search-params/analyze.d.ts +0 -54
  551. package/dist/search-params/analyze.d.ts.map +0 -1
  552. package/dist/search-params/builtin-codecs.d.ts +0 -105
  553. package/dist/search-params/builtin-codecs.d.ts.map +0 -1
  554. package/dist/search-params/codecs.d.ts +0 -53
  555. package/dist/search-params/codecs.d.ts.map +0 -1
  556. package/dist/search-params/create.d.ts +0 -106
  557. package/dist/search-params/create.d.ts.map +0 -1
  558. package/dist/search-params/index.js.map +0 -1
  559. package/dist/server/prerender.d.ts +0 -77
  560. package/dist/server/prerender.d.ts.map +0 -1
  561. package/dist/server/response-cache.d.ts +0 -54
  562. package/dist/server/response-cache.d.ts.map +0 -1
  563. package/src/cache/register-cached-function.ts +0 -103
  564. package/src/client/browser-entry.ts +0 -678
  565. package/src/client/link-status-provider.tsx +0 -30
  566. package/src/client/transition-root.tsx +0 -166
  567. package/src/plugins/cache-transform.ts +0 -199
  568. package/src/plugins/dynamic-transform.ts +0 -161
  569. package/src/search-params/analyze.ts +0 -192
  570. package/src/search-params/builtin-codecs.ts +0 -228
  571. package/src/search-params/create.ts +0 -321
  572. package/src/server/prerender.ts +0 -139
  573. package/src/server/response-cache.ts +0 -410
@@ -0,0 +1,482 @@
1
+ /**
2
+ * defineSearchParams — factory for SearchParamsDefinition<T>.
3
+ *
4
+ * Creates a typed, composable definition for a route's search parameters.
5
+ * Accepts both SearchParamCodec values and Standard Schema objects (Zod,
6
+ * Valibot, ArkType) with auto-detection. Supports URL key aliasing via
7
+ * withUrlKey(), default-omission serialization, and composition via
8
+ * .extend() / .pick().
9
+ *
10
+ * Design doc: design/23-search-params.md §"defineSearchParams — The Factory"
11
+ */
12
+
13
+ import { useQueryStates as clientUseQueryStates } from '../client/use-query-states.js';
14
+ import { fromSchema, isStandardSchema, isCodec } from '../schema-bridge.js';
15
+ import type { StandardSchemaV1 } from '../schema-bridge.js';
16
+ import type { Codec } from '../codec.js';
17
+
18
+ // Server-only reference for .get() — avoids pulling server ALS into client bundles.
19
+ // In client environments, .get() throws before reaching this code path.
20
+ //
21
+ // IMPORTANT: This is set eagerly via _setGetSearchParamsFn() at server startup
22
+ // (called from request-context.ts module initialization). It must NOT use
23
+ // dynamic `await import()` at call time because the async microtask from the
24
+ // dynamic import loses AsyncLocalStorage context in React's RSC Flight renderer,
25
+ // breaking getSearchParams() in parallel slot pages. See TIM-523.
26
+ let _getSearchParamsFn: (() => Promise<URLSearchParams>) | undefined;
27
+
28
+ /**
29
+ * Register the getSearchParams function. Called once at module load time
30
+ * from request-context.ts to avoid dynamic import at call time.
31
+ * @internal
32
+ */
33
+ export function _setGetSearchParamsFn(fn: () => Promise<URLSearchParams>): void {
34
+ _getSearchParamsFn = fn;
35
+ }
36
+
37
+ function getSearchParamsFromAls(): Promise<URLSearchParams> {
38
+ if (!_getSearchParamsFn) {
39
+ throw new Error(
40
+ '[timber] searchParams.get() is only available on the server. ' +
41
+ 'Use searchParams.useQueryStates() on the client.'
42
+ );
43
+ }
44
+ return _getSearchParamsFn();
45
+ }
46
+
47
+ // ---------------------------------------------------------------------------
48
+ // Types
49
+ // ---------------------------------------------------------------------------
50
+
51
+ /**
52
+ * A codec that converts between URL string values and typed values.
53
+ *
54
+ * nuqs parsers implement this interface natively — no adapter needed.
55
+ * Standard Schema objects (Zod, Valibot, ArkType) are auto-detected
56
+ * by defineSearchParams and wrapped via fromSchema.
57
+ */
58
+ export interface SearchParamCodec<T> extends Codec<T> {
59
+ /** Optional URL key alias, set by withUrlKey(). */
60
+ urlKey?: string;
61
+ }
62
+
63
+ /** A codec with a URL key alias attached via withUrlKey(). */
64
+ export interface SearchParamCodecWithUrlKey<T> extends SearchParamCodec<T> {
65
+ urlKey: string;
66
+ }
67
+
68
+ /** Infer the output type of a codec. */
69
+ export type InferCodec<C> = C extends SearchParamCodec<infer T> ? T : never;
70
+
71
+ /** Map of property names to codecs. */
72
+ export type CodecMap<T extends Record<string, unknown>> = {
73
+ [K in keyof T]: SearchParamCodec<T[K]>;
74
+ };
75
+
76
+ /** Options for useQueryStates setter. */
77
+ export interface SetParamsOptions {
78
+ /** Update URL without server roundtrip (default: false). */
79
+ shallow?: boolean;
80
+ /** Scroll to top after update (default: true). */
81
+ scroll?: boolean;
82
+ /** 'push' (default) or 'replace' for history state. */
83
+ history?: 'push' | 'replace';
84
+ }
85
+
86
+ /** Setter function returned by useQueryStates. */
87
+ export type SetParams<T> = (values: Partial<T>, options?: SetParamsOptions) => void;
88
+
89
+ /** Options for useQueryStates hook. */
90
+ export interface QueryStatesOptions {
91
+ /** Update URL without server roundtrip (default: false). */
92
+ shallow?: boolean;
93
+ /** Scroll to top after update (default: true). */
94
+ scroll?: boolean;
95
+ /** 'push' (default) or 'replace' for history state. */
96
+ history?: 'push' | 'replace';
97
+ }
98
+
99
+ /**
100
+ * A fully typed, composable search params definition.
101
+ *
102
+ * Returned by defineSearchParams(). Carries a phantom _type property
103
+ * for build-time type extraction.
104
+ */
105
+ export interface SearchParamsDefinition<T extends Record<string, unknown>> {
106
+ /** Parse raw URL search params into typed values. */
107
+ parse(raw: URLSearchParams | Record<string, string | string[] | undefined>): T;
108
+ /** Parse a Promise of URLSearchParams (e.g., from the ALS `searchParams()` API). */
109
+ parse(raw: Promise<URLSearchParams | Record<string, string | string[] | undefined>>): Promise<T>;
110
+
111
+ /**
112
+ * Get typed search params from the current request context (ALS-backed).
113
+ *
114
+ * Server-only — reads getSearchParams() from ALS and parses through codecs.
115
+ * Throws on client. Eliminates the naming conflict between the definition
116
+ * export and the server helper.
117
+ *
118
+ * ```tsx
119
+ * // app/products/page.tsx
120
+ * import { searchParams } from './params'
121
+ * export default async function Page() {
122
+ * const { page, category } = await searchParams.get()
123
+ * }
124
+ * ```
125
+ */
126
+ get(): Promise<T>;
127
+
128
+ /** Client hook — reads current URL params and returns typed values + setter. */
129
+ useQueryStates(options?: QueryStatesOptions): [T, SetParams<T>];
130
+
131
+ /** Extend with additional codecs or Standard Schema objects. */
132
+ extend<U extends Record<string, SearchParamCodec<unknown> | StandardSchemaV1<unknown>>>(
133
+ codecs: U
134
+ ): SearchParamsDefinition<T & { [K in keyof U]: InferField<U[K]> }>;
135
+
136
+ /** Pick a subset of keys. Preserves codecs and aliases. */
137
+ pick<K extends keyof T & string>(...keys: K[]): SearchParamsDefinition<Pick<T, K>>;
138
+
139
+ /** Serialize values to a query string (no leading '?'), omitting defaults. */
140
+ serialize(values: Partial<T>): string;
141
+
142
+ /** Build a full path with query string, omitting defaults. */
143
+ href(pathname: string, values: Partial<T>): string;
144
+
145
+ /** Build a URLSearchParams instance, omitting defaults. */
146
+ toSearchParams(values: Partial<T>): URLSearchParams;
147
+
148
+ /** Read-only codec map for spreading into .extend(). */
149
+ codecs: { [K in keyof T]: SearchParamCodec<T[K]> };
150
+
151
+ /** Read-only URL key alias map. Maps property names to URL query parameter keys. */
152
+ readonly urlKeys: Readonly<Record<string, string>>;
153
+
154
+ /**
155
+ * Phantom property for build-time type extraction.
156
+ * Never set at runtime — exists only in the type system.
157
+ */
158
+ readonly _type?: T;
159
+ }
160
+
161
+ // StandardSchemaV1 is imported from schema-bridge.ts — single source of truth.
162
+ // Re-export for consumers that import it from this module.
163
+ export type { StandardSchemaV1 } from '../schema-bridge.js';
164
+
165
+ // ---------------------------------------------------------------------------
166
+ // Type-level helpers
167
+ // ---------------------------------------------------------------------------
168
+
169
+ /** Infer the output type from either a SearchParamCodec or a StandardSchemaV1. */
170
+ export type InferField<V> =
171
+ V extends SearchParamCodec<infer T> ? T : V extends StandardSchemaV1<infer T> ? T : never;
172
+
173
+ /** Acceptable field value for defineSearchParams: a codec or a Standard Schema. */
174
+ export type SearchParamField<T = unknown> = SearchParamCodec<T> | StandardSchemaV1<T>;
175
+
176
+ // ---------------------------------------------------------------------------
177
+ // Internal helpers
178
+ // ---------------------------------------------------------------------------
179
+
180
+ /**
181
+ * Convert URLSearchParams or a plain record to a normalized record
182
+ * where repeated keys produce arrays.
183
+ */
184
+ function normalizeRaw(
185
+ raw: URLSearchParams | Record<string, string | string[] | undefined>
186
+ ): Record<string, string | string[] | undefined> {
187
+ if (raw instanceof URLSearchParams) {
188
+ const result: Record<string, string | string[] | undefined> = {};
189
+ for (const key of new Set(raw.keys())) {
190
+ const values = raw.getAll(key);
191
+ result[key] = values.length === 1 ? values[0] : values;
192
+ }
193
+ return result;
194
+ }
195
+ return raw;
196
+ }
197
+
198
+ /**
199
+ * Compute the serialized default value for a codec. Used for
200
+ * default-omission: when serialize(value) === serialize(parse(undefined)),
201
+ * the field is omitted from the URL.
202
+ */
203
+ function getDefaultSerialized<T>(codec: SearchParamCodec<T>): string | null {
204
+ return codec.serialize(codec.parse(undefined));
205
+ }
206
+
207
+ // isStandardSchema and isCodec are imported from schema-bridge.ts.
208
+
209
+ /**
210
+ * Resolve a field value to a SearchParamCodec. Auto-detects Standard Schema
211
+ * objects and wraps them with fromSchema. Reads .urlKey from codecs.
212
+ */
213
+ function resolveField(
214
+ fieldName: string,
215
+ value: SearchParamField
216
+ ): { codec: SearchParamCodec<unknown>; urlKey?: string } {
217
+ // Check for codec first (codecs may also have '~standard' if they're nuqs parsers)
218
+ if (isCodec(value)) {
219
+ return { codec: value, urlKey: value.urlKey };
220
+ }
221
+
222
+ // Auto-detect Standard Schema
223
+ if (isStandardSchema(value)) {
224
+ return { codec: fromSchema(value) };
225
+ }
226
+
227
+ throw new Error(
228
+ `[timber] defineSearchParams: field '${fieldName}' is not a valid codec or Standard Schema. ` +
229
+ `Expected an object with { parse, serialize } methods, or a Standard Schema object ` +
230
+ `(Zod, Valibot, ArkType).`
231
+ );
232
+ }
233
+
234
+ /**
235
+ * Validate that all codecs handle absent params (parse(undefined) doesn't throw).
236
+ * Catches schemas that throw on missing input. `undefined` and `null` are both
237
+ * valid defaults — `undefined` is correct for optional fields (e.g., `z.string().optional()`).
238
+ */
239
+ function validateDefaults(codecMap: Record<string, SearchParamCodec<unknown>>): void {
240
+ for (const [key, codec] of Object.entries(codecMap)) {
241
+ try {
242
+ codec.parse(undefined);
243
+ } catch {
244
+ throw new Error(
245
+ `[timber] defineSearchParams: field '${key}' throws when the param is absent.\n` +
246
+ ` Search params are optional — the URL might not contain ?${key}=anything.\n` +
247
+ ` Add .default() or .optional() to your schema, or wrap with withDefault().`
248
+ );
249
+ }
250
+ }
251
+ }
252
+
253
+ // ---------------------------------------------------------------------------
254
+ // Factory
255
+ // ---------------------------------------------------------------------------
256
+
257
+ /**
258
+ * Create a SearchParamsDefinition from a map of codecs and/or Standard Schema
259
+ * objects. Accepts both SearchParamCodec values and raw Zod/Valibot/ArkType
260
+ * schemas with auto-detection.
261
+ *
262
+ * ```ts
263
+ * import { defineSearchParams, withDefault, withUrlKey } from '@timber-js/app/search-params'
264
+ * import { parseAsString, parseAsStringEnum } from 'nuqs'
265
+ * import { z } from 'zod/v4'
266
+ *
267
+ * export const searchParams = defineSearchParams({
268
+ * page: z.coerce.number().int().min(1).default(1), // Standard Schema — auto-wrapped
269
+ * q: withUrlKey(parseAsString, 'search'), // nuqs codec with URL alias
270
+ * sort: withDefault(parseAsStringEnum(['price', 'name']), 'price'),
271
+ * })
272
+ * ```
273
+ */
274
+ export function defineSearchParams<C extends Record<string, SearchParamField>>(
275
+ codecs: C
276
+ ): SearchParamsDefinition<{ [K in keyof C]: InferField<C[K]> }> {
277
+ type T = { [K in keyof C]: InferField<C[K]> };
278
+
279
+ const resolvedCodecs: Record<string, SearchParamCodec<unknown>> = {};
280
+ const urlKeys: Record<string, string> = {};
281
+
282
+ for (const [key, value] of Object.entries(codecs)) {
283
+ const resolved = resolveField(key, value as SearchParamField);
284
+ resolvedCodecs[key] = resolved.codec;
285
+ if (resolved.urlKey) {
286
+ urlKeys[key] = resolved.urlKey;
287
+ }
288
+ }
289
+
290
+ // Validate that all codecs handle absent params
291
+ validateDefaults(resolvedCodecs);
292
+
293
+ return buildDefinition<T>(resolvedCodecs as unknown as CodecMap<T>, urlKeys);
294
+ }
295
+
296
+ // ---------------------------------------------------------------------------
297
+ // Internal: build the definition object
298
+ // ---------------------------------------------------------------------------
299
+
300
+ /**
301
+ * Internal: build a SearchParamsDefinition from a typed codec map and url keys.
302
+ */
303
+ function buildDefinition<T extends Record<string, unknown>>(
304
+ codecMap: CodecMap<T>,
305
+ urlKeys: Record<string, string>
306
+ ): SearchParamsDefinition<T> {
307
+ // Pre-compute default serialized values for omission check
308
+ const defaultSerialized: Record<string, string | null> = {};
309
+ for (const key of Object.keys(codecMap)) {
310
+ defaultSerialized[key] = getDefaultSerialized(codecMap[key as keyof T]);
311
+ }
312
+
313
+ function getUrlKey(prop: string): string {
314
+ return urlKeys[prop] ?? prop;
315
+ }
316
+
317
+ // ---- parse ----
318
+ function parseSync(raw: URLSearchParams | Record<string, string | string[] | undefined>): T {
319
+ const normalized = normalizeRaw(raw);
320
+ const result: Record<string, unknown> = {};
321
+
322
+ for (const prop of Object.keys(codecMap)) {
323
+ const urlKey = getUrlKey(prop);
324
+ const rawValue = normalized[urlKey];
325
+ result[prop] = (codecMap[prop as keyof T] as SearchParamCodec<unknown>).parse(rawValue);
326
+ }
327
+
328
+ return result as T;
329
+ }
330
+
331
+ // Overloaded parse: sync when given raw params, async when given a Promise.
332
+ // This enables the ergonomic pattern: await def.parse(searchParams())
333
+ function parse(raw: URLSearchParams | Record<string, string | string[] | undefined>): T;
334
+ function parse(
335
+ raw: Promise<URLSearchParams | Record<string, string | string[] | undefined>>
336
+ ): Promise<T>;
337
+ function parse(
338
+ raw:
339
+ | URLSearchParams
340
+ | Record<string, string | string[] | undefined>
341
+ | Promise<URLSearchParams | Record<string, string | string[] | undefined>>
342
+ ): T | Promise<T> {
343
+ if (raw instanceof Promise) {
344
+ return raw.then(parseSync);
345
+ }
346
+ return parseSync(raw);
347
+ }
348
+
349
+ // ---- serialize ----
350
+ function serialize(values: Partial<T>): string {
351
+ const parts: string[] = [];
352
+
353
+ for (const prop of Object.keys(codecMap)) {
354
+ if (!(prop in values)) continue;
355
+ const codec = codecMap[prop as keyof T] as SearchParamCodec<unknown>;
356
+ const serialized = codec.serialize(values[prop as keyof T] as unknown);
357
+
358
+ // Omit if serialized value matches the default
359
+ if (serialized === defaultSerialized[prop]) continue;
360
+ if (serialized === null) continue;
361
+
362
+ parts.push(`${encodeURIComponent(getUrlKey(prop))}=${encodeURIComponent(serialized)}`);
363
+ }
364
+
365
+ return parts.join('&');
366
+ }
367
+
368
+ // ---- href ----
369
+ function href(pathname: string, values: Partial<T>): string {
370
+ const qs = serialize(values);
371
+ return qs ? `${pathname}?${qs}` : pathname;
372
+ }
373
+
374
+ // ---- toSearchParams ----
375
+ function toSearchParams(values: Partial<T>): URLSearchParams {
376
+ const usp = new URLSearchParams();
377
+
378
+ for (const prop of Object.keys(codecMap)) {
379
+ if (!(prop in values)) continue;
380
+ const codec = codecMap[prop as keyof T] as SearchParamCodec<unknown>;
381
+ const serialized = codec.serialize(values[prop as keyof T] as unknown);
382
+
383
+ if (serialized === defaultSerialized[prop]) continue;
384
+ if (serialized === null) continue;
385
+
386
+ usp.set(getUrlKey(prop), serialized);
387
+ }
388
+
389
+ return usp;
390
+ }
391
+
392
+ // ---- extend ----
393
+ function extend<U extends Record<string, SearchParamCodec<unknown> | StandardSchemaV1<unknown>>>(
394
+ newCodecs: U
395
+ ): SearchParamsDefinition<T & { [K in keyof U]: InferField<U[K]> }> {
396
+ type Combined = T & { [K in keyof U]: InferField<U[K]> };
397
+
398
+ // Resolve any Standard Schema objects in the extension
399
+ const resolvedNewCodecs: Record<string, SearchParamCodec<unknown>> = {};
400
+ const newUrlKeys: Record<string, string> = {};
401
+ for (const [key, value] of Object.entries(newCodecs)) {
402
+ const resolved = resolveField(key, value as SearchParamField);
403
+ resolvedNewCodecs[key] = resolved.codec;
404
+ if (resolved.urlKey) {
405
+ newUrlKeys[key] = resolved.urlKey;
406
+ }
407
+ }
408
+
409
+ const combinedCodecs = {
410
+ ...codecMap,
411
+ ...resolvedNewCodecs,
412
+ } as unknown as CodecMap<Combined>;
413
+
414
+ // Merge URL keys: base keys + new codec urlKeys from withUrlKey
415
+ const combinedUrlKeys: Record<string, string> = { ...urlKeys, ...newUrlKeys };
416
+
417
+ return buildDefinition<Combined>(combinedCodecs, combinedUrlKeys);
418
+ }
419
+
420
+ // ---- pick ----
421
+ function pick<K extends keyof T & string>(...keys: K[]): SearchParamsDefinition<Pick<T, K>> {
422
+ const pickedCodecs: Record<string, SearchParamCodec<unknown>> = {};
423
+ const pickedUrlKeys: Record<string, string> = {};
424
+
425
+ for (const key of keys) {
426
+ pickedCodecs[key] = codecMap[key] as SearchParamCodec<unknown>;
427
+ if (key in urlKeys) {
428
+ pickedUrlKeys[key] = urlKeys[key];
429
+ }
430
+ }
431
+
432
+ return buildDefinition<Pick<T, K>>(
433
+ pickedCodecs as unknown as CodecMap<Pick<T, K>>,
434
+ pickedUrlKeys
435
+ );
436
+ }
437
+
438
+ // ---- useQueryStates ----
439
+ // Delegates to the 'use client' implementation from use-query-states.ts.
440
+ //
441
+ // In the RSC environment: use-query-states.ts is transformed by the RSC
442
+ // plugin into a client reference proxy. Calling it throws — correct,
443
+ // because hooks can't run during server component rendering.
444
+ // In SSR: use-query-states.ts is the real nuqs-backed function. Hooks
445
+ // work during SSR's renderToReadableStream, so this works correctly.
446
+ // On the client: same as SSR — the real function is available.
447
+ function useQueryStates(options?: QueryStatesOptions): [T, SetParams<T>] {
448
+ return clientUseQueryStates(codecMap, options, Object.freeze({ ...urlKeys })) as [
449
+ T,
450
+ SetParams<T>,
451
+ ];
452
+ }
453
+
454
+ // ---- get ----
455
+ // ALS-backed: reads getSearchParams() from the current request context
456
+ // and parses through codecs. Server-only — throws on client.
457
+ async function get(): Promise<T> {
458
+ if (typeof window !== 'undefined') {
459
+ throw new Error(
460
+ '[timber] searchParams.get() is server-only. ' +
461
+ 'Use searchParams.useQueryStates() on the client.'
462
+ );
463
+ }
464
+ const raw = await getSearchParamsFromAls();
465
+ return parseSync(raw);
466
+ }
467
+
468
+ const definition: SearchParamsDefinition<T> = {
469
+ parse,
470
+ get,
471
+ useQueryStates,
472
+ extend,
473
+ pick,
474
+ serialize,
475
+ href,
476
+ toSearchParams,
477
+ codecs: codecMap,
478
+ urlKeys: Object.freeze({ ...urlKeys }),
479
+ };
480
+
481
+ return definition;
482
+ }
@@ -1,34 +1,28 @@
1
1
  // @timber-js/app/search-params — Typed search params
2
2
 
3
+ // Codec is the canonical home for the Codec type — import from
4
+ // @timber-js/app/codec. Re-export removed per TIM-721.
5
+
3
6
  // Core types and factory
4
7
  export type {
5
8
  SearchParamCodec,
9
+ SearchParamCodecWithUrlKey,
6
10
  InferCodec,
11
+ InferField,
12
+ CodecMap,
7
13
  SearchParamsDefinition,
8
14
  SetParams,
9
15
  SetParamsOptions,
10
16
  QueryStatesOptions,
11
- SearchParamsOptions,
12
- } from './create.js';
13
- export { createSearchParams } from './create.js';
17
+ StandardSchemaV1,
18
+ } from './define.js';
19
+ export { defineSearchParams } from './define.js';
14
20
 
15
- // Codec bridges
16
- export { fromSchema, fromArraySchema } from './codecs.js';
21
+ // Codec bridges moved to @timber-js/app/codec
22
+ // Import fromSchema / fromArraySchema from '@timber-js/app/codec' instead.
17
23
 
18
- // Built-in codecs
19
- export {
20
- parseAsString,
21
- parseAsInteger,
22
- parseAsFloat,
23
- parseAsBoolean,
24
- parseAsStringEnum,
25
- parseAsStringLiteral,
26
- withDefault,
27
- } from './builtin-codecs.js';
24
+ // Codec wrappers
25
+ export { withDefault, withUrlKey } from './wrappers.js';
28
26
 
29
27
  // Runtime registry (route-scoped useQueryStates)
30
- export { registerSearchParams, getSearchParams } from './registry.js';
31
-
32
- // Static analysis (build-time only)
33
- export type { AnalyzeResult, AnalyzeError } from './analyze.js';
34
- export { analyzeSearchParams, formatAnalyzeError } from './analyze.js';
28
+ export { registerSearchParams, getSearchParamsDefinition } from './registry.js';
@@ -7,7 +7,7 @@
7
7
  * Design doc: design/23-search-params.md §"Runtime: Registration at Route Load"
8
8
  */
9
9
 
10
- import type { SearchParamsDefinition } from './create.js';
10
+ import type { SearchParamsDefinition } from './define.js';
11
11
 
12
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
13
  const registry = new Map<string, SearchParamsDefinition<any>>();
@@ -26,6 +26,6 @@ export function registerSearchParams(route: string, definition: SearchParamsDefi
26
26
  * Returns undefined if the route hasn't been loaded yet.
27
27
  */
28
28
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
- export function getSearchParams(route: string): SearchParamsDefinition<any> | undefined {
29
+ export function getSearchParamsDefinition(route: string): SearchParamsDefinition<any> | undefined {
30
30
  return registry.get(route);
31
31
  }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Codec wrappers — withDefault and withUrlKey.
3
+ *
4
+ * These are timber-specific utilities that work with any SearchParamCodec.
5
+ * For actual codecs (string, integer, boolean, etc.), use nuqs parsers
6
+ * or Standard Schema objects (Zod, Valibot, ArkType) with auto-detection.
7
+ *
8
+ * Design doc: design/23-search-params.md
9
+ */
10
+
11
+ import type { SearchParamCodec, SearchParamCodecWithUrlKey } from './define.js';
12
+
13
+ // ---------------------------------------------------------------------------
14
+ // withDefault
15
+ // ---------------------------------------------------------------------------
16
+
17
+ /**
18
+ * Wrap a nullable codec with a default value. When the inner codec returns
19
+ * null, the default is used instead. The output type becomes non-nullable.
20
+ *
21
+ * Works with any codec — nuqs parsers, custom codecs, fromSchema results.
22
+ *
23
+ * ```ts
24
+ * import { parseAsInteger } from 'nuqs'
25
+ * import { withDefault } from '@timber-js/app/search-params'
26
+ *
27
+ * const page = withDefault(parseAsInteger, 1)
28
+ * // page.parse(undefined) → 1 (not null)
29
+ * // page.parse('5') → 5
30
+ * ```
31
+ */
32
+ export function withDefault<T>(
33
+ codec: SearchParamCodec<T | null>,
34
+ defaultValue: T
35
+ ): SearchParamCodec<T> {
36
+ return {
37
+ parse(value: string | string[] | undefined): T {
38
+ const result = codec.parse(value);
39
+ return result === null ? defaultValue : result;
40
+ },
41
+ serialize(value: T): string | null {
42
+ return codec.serialize(value);
43
+ },
44
+ };
45
+ }
46
+
47
+ // ---------------------------------------------------------------------------
48
+ // withUrlKey
49
+ // ---------------------------------------------------------------------------
50
+
51
+ /**
52
+ * Attach a URL key alias to a codec. The alias determines what query
53
+ * parameter key is used in the URL, while the TypeScript property name
54
+ * stays descriptive.
55
+ *
56
+ * Aliases travel with codecs through object spread composition — when
57
+ * you spread a bundle containing aliased codecs into defineSearchParams,
58
+ * the aliases come along automatically.
59
+ *
60
+ * ```ts
61
+ * import { parseAsString } from 'nuqs'
62
+ * import { withUrlKey } from '@timber-js/app/search-params'
63
+ *
64
+ * export const searchable = {
65
+ * q: withUrlKey(parseAsString, 'search'),
66
+ * // ?search=shoes → { q: 'shoes' }
67
+ * }
68
+ * ```
69
+ *
70
+ * Composes with withDefault:
71
+ * ```ts
72
+ * import { parseAsInteger } from 'nuqs'
73
+ * withUrlKey(withDefault(parseAsInteger, 1), 'p')
74
+ * ```
75
+ */
76
+ export function withUrlKey<T>(
77
+ codec: SearchParamCodec<T>,
78
+ urlKey: string
79
+ ): SearchParamCodecWithUrlKey<T> {
80
+ return {
81
+ parse: codec.parse.bind(codec),
82
+ serialize: codec.serialize.bind(codec),
83
+ urlKey,
84
+ };
85
+ }