@timber-js/app 0.2.0-alpha.7 → 0.2.0-alpha.71

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 (500) hide show
  1. package/LICENSE +8 -0
  2. package/dist/_chunks/{als-registry-B7DbZ2hS.js → als-registry-BJARkOcu.js} +1 -1
  3. package/dist/_chunks/als-registry-BJARkOcu.js.map +1 -0
  4. package/dist/_chunks/chunk-DYhsFzuS.js +33 -0
  5. package/dist/_chunks/{debug-gwlJkDuf.js → debug-ECi_61pb.js} +2 -2
  6. package/dist/_chunks/debug-ECi_61pb.js.map +1 -0
  7. package/dist/_chunks/define-CGuYoRHU.js +199 -0
  8. package/dist/_chunks/define-CGuYoRHU.js.map +1 -0
  9. package/dist/_chunks/define-Dz1bqwaS.js +106 -0
  10. package/dist/_chunks/define-Dz1bqwaS.js.map +1 -0
  11. package/dist/_chunks/define-cookie-B5mewxwM.js +93 -0
  12. package/dist/_chunks/define-cookie-B5mewxwM.js.map +1 -0
  13. package/dist/_chunks/error-boundary-D9hzsveV.js +216 -0
  14. package/dist/_chunks/error-boundary-D9hzsveV.js.map +1 -0
  15. package/dist/_chunks/{format-DviM89f0.js → format-Rn922VH2.js} +3 -20
  16. package/dist/_chunks/format-Rn922VH2.js.map +1 -0
  17. package/dist/_chunks/{tracing-Cwn7697K.js → handler-store-BVePM7hp.js} +68 -3
  18. package/dist/_chunks/handler-store-BVePM7hp.js.map +1 -0
  19. package/dist/_chunks/{interception-BOoWmLUA.js → interception-CEdHHviP.js} +171 -97
  20. package/dist/_chunks/interception-CEdHHviP.js.map +1 -0
  21. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js → metadata-routes-DS3eKNmf.js} +1 -1
  22. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js.map → metadata-routes-DS3eKNmf.js.map} +1 -1
  23. package/dist/_chunks/{request-context-DIkVh_jG.js → request-context-CywiO4jV.js} +181 -69
  24. package/dist/_chunks/request-context-CywiO4jV.js.map +1 -0
  25. package/dist/_chunks/schema-bridge-C4SwjCQD.js +86 -0
  26. package/dist/_chunks/schema-bridge-C4SwjCQD.js.map +1 -0
  27. package/dist/_chunks/segment-classify-BDNn6EzD.js +65 -0
  28. package/dist/_chunks/segment-classify-BDNn6EzD.js.map +1 -0
  29. package/dist/_chunks/segment-context-hzuJ048X.js +72 -0
  30. package/dist/_chunks/segment-context-hzuJ048X.js.map +1 -0
  31. package/dist/_chunks/stale-reload-BLUC_Pl_.js +64 -0
  32. package/dist/_chunks/stale-reload-BLUC_Pl_.js.map +1 -0
  33. package/dist/_chunks/{use-query-states-D5KaffOK.js → use-query-states-DAhgj8Gx.js} +1 -1
  34. package/dist/_chunks/use-query-states-DAhgj8Gx.js.map +1 -0
  35. package/dist/_chunks/wrappers-LZbghvn0.js +63 -0
  36. package/dist/_chunks/wrappers-LZbghvn0.js.map +1 -0
  37. package/dist/adapters/cloudflare-dev.d.ts +109 -0
  38. package/dist/adapters/cloudflare-dev.d.ts.map +1 -0
  39. package/dist/adapters/cloudflare-dev.js +73 -0
  40. package/dist/adapters/cloudflare-dev.js.map +1 -0
  41. package/dist/adapters/cloudflare.d.ts +148 -12
  42. package/dist/adapters/cloudflare.d.ts.map +1 -1
  43. package/dist/adapters/cloudflare.js +135 -11
  44. package/dist/adapters/cloudflare.js.map +1 -1
  45. package/dist/adapters/compress-module.d.ts.map +1 -1
  46. package/dist/adapters/nitro.d.ts +17 -1
  47. package/dist/adapters/nitro.d.ts.map +1 -1
  48. package/dist/adapters/nitro.js +56 -13
  49. package/dist/adapters/nitro.js.map +1 -1
  50. package/dist/cache/cache-api.d.ts +24 -0
  51. package/dist/cache/cache-api.d.ts.map +1 -0
  52. package/dist/cache/fast-hash.d.ts +22 -0
  53. package/dist/cache/fast-hash.d.ts.map +1 -0
  54. package/dist/cache/handler-store.d.ts +31 -0
  55. package/dist/cache/handler-store.d.ts.map +1 -0
  56. package/dist/cache/index.d.ts +7 -5
  57. package/dist/cache/index.d.ts.map +1 -1
  58. package/dist/cache/index.js +111 -73
  59. package/dist/cache/index.js.map +1 -1
  60. package/dist/cache/singleflight.d.ts +18 -1
  61. package/dist/cache/singleflight.d.ts.map +1 -1
  62. package/dist/cache/timber-cache.d.ts +1 -1
  63. package/dist/cache/timber-cache.d.ts.map +1 -1
  64. package/dist/client/error-boundary.d.ts +12 -5
  65. package/dist/client/error-boundary.d.ts.map +1 -1
  66. package/dist/client/error-boundary.js +1 -125
  67. package/dist/client/error-reconstituter.d.ts +54 -0
  68. package/dist/client/error-reconstituter.d.ts.map +1 -0
  69. package/dist/client/form.d.ts +2 -2
  70. package/dist/client/form.d.ts.map +1 -1
  71. package/dist/client/history.d.ts +19 -4
  72. package/dist/client/history.d.ts.map +1 -1
  73. package/dist/client/index.d.ts +6 -5
  74. package/dist/client/index.d.ts.map +1 -1
  75. package/dist/client/index.js +537 -166
  76. package/dist/client/index.js.map +1 -1
  77. package/dist/client/link-pending-store.d.ts +78 -0
  78. package/dist/client/link-pending-store.d.ts.map +1 -0
  79. package/dist/client/link.d.ts +90 -32
  80. package/dist/client/link.d.ts.map +1 -1
  81. package/dist/client/nav-link-store.d.ts +36 -0
  82. package/dist/client/nav-link-store.d.ts.map +1 -0
  83. package/dist/client/navigation-api-types.d.ts +90 -0
  84. package/dist/client/navigation-api-types.d.ts.map +1 -0
  85. package/dist/client/navigation-api.d.ts +115 -0
  86. package/dist/client/navigation-api.d.ts.map +1 -0
  87. package/dist/client/navigation-context.d.ts +13 -2
  88. package/dist/client/navigation-context.d.ts.map +1 -1
  89. package/dist/client/{transition-root.d.ts → navigation-root.d.ts} +42 -8
  90. package/dist/client/navigation-root.d.ts.map +1 -0
  91. package/dist/client/nuqs-adapter.d.ts.map +1 -1
  92. package/dist/client/router.d.ts +70 -4
  93. package/dist/client/router.d.ts.map +1 -1
  94. package/dist/client/rsc-fetch.d.ts +38 -3
  95. package/dist/client/rsc-fetch.d.ts.map +1 -1
  96. package/dist/client/segment-cache.d.ts +1 -1
  97. package/dist/client/segment-cache.d.ts.map +1 -1
  98. package/dist/client/segment-context.d.ts +1 -1
  99. package/dist/client/segment-context.d.ts.map +1 -1
  100. package/dist/client/segment-merger.d.ts.map +1 -1
  101. package/dist/client/segment-outlet.d.ts +63 -0
  102. package/dist/client/segment-outlet.d.ts.map +1 -0
  103. package/dist/client/ssr-data.d.ts +13 -4
  104. package/dist/client/ssr-data.d.ts.map +1 -1
  105. package/dist/client/stale-reload.d.ts +15 -0
  106. package/dist/client/stale-reload.d.ts.map +1 -1
  107. package/dist/client/top-loader.d.ts +3 -3
  108. package/dist/client/top-loader.d.ts.map +1 -1
  109. package/dist/client/use-params.d.ts +6 -4
  110. package/dist/client/use-params.d.ts.map +1 -1
  111. package/dist/client/use-query-states.d.ts +1 -1
  112. package/dist/client/use-query-states.d.ts.map +1 -1
  113. package/dist/codec.d.ts +23 -0
  114. package/dist/codec.d.ts.map +1 -0
  115. package/dist/codec.js +2 -0
  116. package/dist/cookies/define-cookie.d.ts +35 -14
  117. package/dist/cookies/define-cookie.d.ts.map +1 -1
  118. package/dist/cookies/index.d.ts +2 -0
  119. package/dist/cookies/index.d.ts.map +1 -1
  120. package/dist/cookies/index.js +3 -84
  121. package/dist/fonts/css.d.ts +1 -0
  122. package/dist/fonts/css.d.ts.map +1 -1
  123. package/dist/index.d.ts +154 -38
  124. package/dist/index.d.ts.map +1 -1
  125. package/dist/index.js +12092 -11916
  126. package/dist/index.js.map +1 -1
  127. package/dist/plugins/adapter-build.d.ts +1 -1
  128. package/dist/plugins/adapter-build.d.ts.map +1 -1
  129. package/dist/plugins/build-manifest.d.ts +2 -2
  130. package/dist/plugins/build-manifest.d.ts.map +1 -1
  131. package/dist/plugins/build-report.d.ts +3 -3
  132. package/dist/plugins/build-report.d.ts.map +1 -1
  133. package/dist/plugins/client-chunks.d.ts +32 -0
  134. package/dist/plugins/client-chunks.d.ts.map +1 -0
  135. package/dist/plugins/content.d.ts +1 -1
  136. package/dist/plugins/content.d.ts.map +1 -1
  137. package/dist/plugins/dev-browser-logs.d.ts +84 -0
  138. package/dist/plugins/dev-browser-logs.d.ts.map +1 -0
  139. package/dist/plugins/dev-error-overlay.d.ts +26 -1
  140. package/dist/plugins/dev-error-overlay.d.ts.map +1 -1
  141. package/dist/plugins/dev-logs.d.ts +1 -1
  142. package/dist/plugins/dev-logs.d.ts.map +1 -1
  143. package/dist/plugins/dev-server.d.ts +1 -1
  144. package/dist/plugins/dev-server.d.ts.map +1 -1
  145. package/dist/plugins/entries.d.ts +1 -1
  146. package/dist/plugins/entries.d.ts.map +1 -1
  147. package/dist/plugins/fonts.d.ts +19 -5
  148. package/dist/plugins/fonts.d.ts.map +1 -1
  149. package/dist/plugins/mdx.d.ts +1 -1
  150. package/dist/plugins/mdx.d.ts.map +1 -1
  151. package/dist/plugins/routing.d.ts +1 -1
  152. package/dist/plugins/routing.d.ts.map +1 -1
  153. package/dist/plugins/server-bundle.d.ts.map +1 -1
  154. package/dist/plugins/shims.d.ts +6 -5
  155. package/dist/plugins/shims.d.ts.map +1 -1
  156. package/dist/plugins/static-build.d.ts +1 -1
  157. package/dist/plugins/static-build.d.ts.map +1 -1
  158. package/dist/routing/codegen.d.ts +2 -2
  159. package/dist/routing/codegen.d.ts.map +1 -1
  160. package/dist/routing/index.d.ts +2 -0
  161. package/dist/routing/index.d.ts.map +1 -1
  162. package/dist/routing/index.js +3 -2
  163. package/dist/routing/scanner.d.ts.map +1 -1
  164. package/dist/routing/segment-classify.d.ts +46 -0
  165. package/dist/routing/segment-classify.d.ts.map +1 -0
  166. package/dist/routing/status-file-lint.d.ts +2 -1
  167. package/dist/routing/status-file-lint.d.ts.map +1 -1
  168. package/dist/routing/types.d.ts +16 -4
  169. package/dist/routing/types.d.ts.map +1 -1
  170. package/dist/rsc-runtime/rsc.d.ts +1 -1
  171. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  172. package/dist/rsc-runtime/ssr.d.ts +12 -0
  173. package/dist/rsc-runtime/ssr.d.ts.map +1 -1
  174. package/dist/schema-bridge.d.ts +76 -0
  175. package/dist/schema-bridge.d.ts.map +1 -0
  176. package/dist/search-params/define.d.ts +139 -0
  177. package/dist/search-params/define.d.ts.map +1 -0
  178. package/dist/search-params/index.d.ts +4 -6
  179. package/dist/search-params/index.d.ts.map +1 -1
  180. package/dist/search-params/index.js +4 -474
  181. package/dist/search-params/registry.d.ts +1 -1
  182. package/dist/search-params/wrappers.d.ts +53 -0
  183. package/dist/search-params/wrappers.d.ts.map +1 -0
  184. package/dist/segment-params/define.d.ts +78 -0
  185. package/dist/segment-params/define.d.ts.map +1 -0
  186. package/dist/segment-params/index.d.ts +7 -0
  187. package/dist/segment-params/index.d.ts.map +1 -0
  188. package/dist/segment-params/index.js +4 -0
  189. package/dist/server/access-gate.d.ts +4 -0
  190. package/dist/server/access-gate.d.ts.map +1 -1
  191. package/dist/server/action-client.d.ts +12 -1
  192. package/dist/server/action-client.d.ts.map +1 -1
  193. package/dist/server/action-encryption.d.ts +76 -0
  194. package/dist/server/action-encryption.d.ts.map +1 -0
  195. package/dist/server/action-handler.d.ts.map +1 -1
  196. package/dist/server/actions.d.ts +3 -6
  197. package/dist/server/actions.d.ts.map +1 -1
  198. package/dist/server/als-registry.d.ts +32 -4
  199. package/dist/server/als-registry.d.ts.map +1 -1
  200. package/dist/server/build-manifest.d.ts +2 -2
  201. package/dist/server/build-manifest.d.ts.map +1 -1
  202. package/dist/server/debug.d.ts +1 -1
  203. package/dist/server/default-logger.d.ts +22 -0
  204. package/dist/server/default-logger.d.ts.map +1 -0
  205. package/dist/server/deny-page-resolver.d.ts +52 -0
  206. package/dist/server/deny-page-resolver.d.ts.map +1 -0
  207. package/dist/server/deny-renderer.d.ts.map +1 -1
  208. package/dist/server/dev-warnings.d.ts +0 -14
  209. package/dist/server/dev-warnings.d.ts.map +1 -1
  210. package/dist/server/early-hints.d.ts +13 -5
  211. package/dist/server/early-hints.d.ts.map +1 -1
  212. package/dist/server/error-boundary-wrapper.d.ts +7 -1
  213. package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
  214. package/dist/server/fallback-error.d.ts +4 -3
  215. package/dist/server/fallback-error.d.ts.map +1 -1
  216. package/dist/server/flight-injection-state.d.ts +66 -0
  217. package/dist/server/flight-injection-state.d.ts.map +1 -0
  218. package/dist/server/flight-scripts.d.ts +42 -0
  219. package/dist/server/flight-scripts.d.ts.map +1 -0
  220. package/dist/server/flush.d.ts.map +1 -1
  221. package/dist/server/form-data.d.ts +29 -0
  222. package/dist/server/form-data.d.ts.map +1 -1
  223. package/dist/server/html-injectors.d.ts +51 -11
  224. package/dist/server/html-injectors.d.ts.map +1 -1
  225. package/dist/server/index.d.ts +5 -3
  226. package/dist/server/index.d.ts.map +1 -1
  227. package/dist/server/index.js +2176 -1663
  228. package/dist/server/index.js.map +1 -1
  229. package/dist/server/logger.d.ts +25 -7
  230. package/dist/server/logger.d.ts.map +1 -1
  231. package/dist/server/middleware-runner.d.ts +19 -4
  232. package/dist/server/middleware-runner.d.ts.map +1 -1
  233. package/dist/server/node-stream-transforms.d.ts +113 -0
  234. package/dist/server/node-stream-transforms.d.ts.map +1 -0
  235. package/dist/server/page-deny-boundary.d.ts +31 -0
  236. package/dist/server/page-deny-boundary.d.ts.map +1 -0
  237. package/dist/server/pipeline-interception.d.ts +1 -1
  238. package/dist/server/pipeline-interception.d.ts.map +1 -1
  239. package/dist/server/pipeline-metadata.d.ts +6 -0
  240. package/dist/server/pipeline-metadata.d.ts.map +1 -1
  241. package/dist/server/pipeline.d.ts +32 -10
  242. package/dist/server/pipeline.d.ts.map +1 -1
  243. package/dist/server/primitives.d.ts +30 -3
  244. package/dist/server/primitives.d.ts.map +1 -1
  245. package/dist/server/render-timeout.d.ts +51 -0
  246. package/dist/server/render-timeout.d.ts.map +1 -0
  247. package/dist/server/request-context.d.ts +76 -37
  248. package/dist/server/request-context.d.ts.map +1 -1
  249. package/dist/server/route-element-builder.d.ts +27 -1
  250. package/dist/server/route-element-builder.d.ts.map +1 -1
  251. package/dist/server/route-handler.d.ts.map +1 -1
  252. package/dist/server/route-matcher.d.ts +9 -2
  253. package/dist/server/route-matcher.d.ts.map +1 -1
  254. package/dist/server/rsc-entry/api-handler.d.ts +2 -2
  255. package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
  256. package/dist/server/rsc-entry/error-renderer.d.ts +26 -13
  257. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  258. package/dist/server/rsc-entry/helpers.d.ts +48 -5
  259. package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
  260. package/dist/server/rsc-entry/index.d.ts +8 -3
  261. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  262. package/dist/server/rsc-entry/rsc-payload.d.ts +3 -3
  263. package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
  264. package/dist/server/rsc-entry/rsc-stream.d.ts +10 -1
  265. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  266. package/dist/server/rsc-entry/ssr-bridge.d.ts +1 -1
  267. package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
  268. package/dist/server/rsc-entry/ssr-renderer.d.ts +19 -4
  269. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  270. package/dist/server/safe-load.d.ts +46 -0
  271. package/dist/server/safe-load.d.ts.map +1 -0
  272. package/dist/server/sitemap-generator.d.ts +129 -0
  273. package/dist/server/sitemap-generator.d.ts.map +1 -0
  274. package/dist/server/sitemap-handler.d.ts +22 -0
  275. package/dist/server/sitemap-handler.d.ts.map +1 -0
  276. package/dist/server/slot-resolver.d.ts +1 -1
  277. package/dist/server/slot-resolver.d.ts.map +1 -1
  278. package/dist/server/ssr-entry.d.ts +22 -0
  279. package/dist/server/ssr-entry.d.ts.map +1 -1
  280. package/dist/server/ssr-render.d.ts +39 -21
  281. package/dist/server/ssr-render.d.ts.map +1 -1
  282. package/dist/server/ssr-wrappers.d.ts +50 -0
  283. package/dist/server/ssr-wrappers.d.ts.map +1 -0
  284. package/dist/server/status-code-resolver.d.ts +1 -1
  285. package/dist/server/status-code-resolver.d.ts.map +1 -1
  286. package/dist/server/stream-utils.d.ts +36 -0
  287. package/dist/server/stream-utils.d.ts.map +1 -0
  288. package/dist/server/tracing.d.ts +10 -0
  289. package/dist/server/tracing.d.ts.map +1 -1
  290. package/dist/server/tree-builder.d.ts +22 -19
  291. package/dist/server/tree-builder.d.ts.map +1 -1
  292. package/dist/server/types.d.ts +1 -4
  293. package/dist/server/types.d.ts.map +1 -1
  294. package/dist/server/version-skew.d.ts +61 -0
  295. package/dist/server/version-skew.d.ts.map +1 -0
  296. package/dist/server/waituntil-bridge.d.ts.map +1 -1
  297. package/dist/shared/merge-search-params.d.ts +22 -0
  298. package/dist/shared/merge-search-params.d.ts.map +1 -0
  299. package/dist/shims/font-google.d.ts +1 -1
  300. package/dist/shims/font-google.d.ts.map +1 -1
  301. package/dist/shims/font-google.js +42 -0
  302. package/dist/shims/font-google.js.map +1 -0
  303. package/dist/shims/font-local.d.ts +26 -0
  304. package/dist/shims/font-local.d.ts.map +1 -0
  305. package/dist/shims/font-local.js +20 -0
  306. package/dist/shims/font-local.js.map +1 -0
  307. package/dist/shims/navigation-client.d.ts +1 -1
  308. package/dist/shims/navigation-client.d.ts.map +1 -1
  309. package/dist/shims/navigation.d.ts +1 -1
  310. package/dist/shims/navigation.d.ts.map +1 -1
  311. package/dist/utils/directive-parser.d.ts +5 -2
  312. package/dist/utils/directive-parser.d.ts.map +1 -1
  313. package/dist/utils/state-machine.d.ts +80 -0
  314. package/dist/utils/state-machine.d.ts.map +1 -0
  315. package/package.json +37 -17
  316. package/src/adapters/cloudflare-dev.ts +177 -0
  317. package/src/adapters/cloudflare.ts +342 -28
  318. package/src/adapters/compress-module.ts +24 -4
  319. package/src/adapters/nitro.ts +58 -9
  320. package/src/adapters/wrangler.d.ts +7 -0
  321. package/src/cache/cache-api.ts +38 -0
  322. package/src/cache/fast-hash.ts +34 -0
  323. package/src/cache/handler-store.ts +68 -0
  324. package/src/cache/index.ts +9 -5
  325. package/src/cache/singleflight.ts +62 -4
  326. package/src/cache/timber-cache.ts +40 -29
  327. package/src/cli.ts +0 -0
  328. package/src/client/browser-entry.ts +314 -142
  329. package/src/client/error-boundary.tsx +48 -16
  330. package/src/client/error-reconstituter.tsx +65 -0
  331. package/src/client/form.tsx +2 -2
  332. package/src/client/history.ts +26 -4
  333. package/src/client/index.ts +13 -4
  334. package/src/client/link-pending-store.ts +136 -0
  335. package/src/client/link.tsx +346 -105
  336. package/src/client/nav-link-store.ts +47 -0
  337. package/src/client/navigation-api-types.ts +112 -0
  338. package/src/client/navigation-api.ts +332 -0
  339. package/src/client/navigation-context.ts +27 -6
  340. package/src/client/navigation-root.tsx +346 -0
  341. package/src/client/nuqs-adapter.tsx +16 -3
  342. package/src/client/router.ts +302 -77
  343. package/src/client/rsc-fetch.ts +93 -5
  344. package/src/client/segment-cache.ts +1 -1
  345. package/src/client/segment-context.ts +6 -1
  346. package/src/client/segment-merger.ts +2 -8
  347. package/src/client/segment-outlet.tsx +86 -0
  348. package/src/client/ssr-data.ts +13 -5
  349. package/src/client/stale-reload.ts +73 -6
  350. package/src/client/top-loader.tsx +22 -13
  351. package/src/client/use-navigation-pending.ts +1 -1
  352. package/src/client/use-params.ts +7 -5
  353. package/src/client/use-query-states.ts +2 -2
  354. package/src/codec.ts +34 -0
  355. package/src/cookies/define-cookie.ts +72 -21
  356. package/src/cookies/index.ts +7 -0
  357. package/src/fonts/css.ts +2 -1
  358. package/src/index.ts +328 -92
  359. package/src/plugins/adapter-build.ts +8 -2
  360. package/src/plugins/build-manifest.ts +13 -2
  361. package/src/plugins/build-report.ts +3 -3
  362. package/src/plugins/client-chunks.ts +65 -0
  363. package/src/plugins/content.ts +1 -1
  364. package/src/plugins/dev-browser-logs.ts +288 -0
  365. package/src/plugins/dev-error-overlay.ts +70 -1
  366. package/src/plugins/dev-logs.ts +1 -1
  367. package/src/plugins/dev-server.ts +55 -9
  368. package/src/plugins/entries.ts +70 -9
  369. package/src/plugins/fonts.ts +167 -61
  370. package/src/plugins/mdx.ts +1 -1
  371. package/src/plugins/routing.ts +57 -17
  372. package/src/plugins/server-action-exports.ts +1 -1
  373. package/src/plugins/server-bundle.ts +32 -1
  374. package/src/plugins/shims.ts +76 -33
  375. package/src/plugins/static-build.ts +10 -6
  376. package/src/routing/codegen.ts +165 -105
  377. package/src/routing/index.ts +2 -0
  378. package/src/routing/scanner.ts +93 -23
  379. package/src/routing/segment-classify.ts +89 -0
  380. package/src/routing/status-file-lint.ts +3 -2
  381. package/src/routing/types.ts +17 -4
  382. package/src/rsc-runtime/rsc.ts +2 -0
  383. package/src/rsc-runtime/ssr.ts +50 -0
  384. package/src/rsc-runtime/vendor-types.d.ts +7 -0
  385. package/src/{search-params/codecs.ts → schema-bridge.ts} +57 -20
  386. package/src/search-params/define.ts +482 -0
  387. package/src/search-params/index.ts +13 -19
  388. package/src/search-params/registry.ts +1 -1
  389. package/src/search-params/wrappers.ts +85 -0
  390. package/src/segment-params/define.ts +279 -0
  391. package/src/segment-params/index.ts +28 -0
  392. package/src/server/access-gate.tsx +70 -29
  393. package/src/server/action-client.ts +28 -3
  394. package/src/server/action-encryption.ts +144 -0
  395. package/src/server/action-handler.ts +20 -3
  396. package/src/server/actions.ts +10 -9
  397. package/src/server/als-registry.ts +32 -4
  398. package/src/server/build-manifest.ts +10 -4
  399. package/src/server/compress.ts +25 -7
  400. package/src/server/debug.ts +1 -1
  401. package/src/server/default-logger.ts +99 -0
  402. package/src/server/deny-page-resolver.ts +154 -0
  403. package/src/server/deny-renderer.ts +24 -38
  404. package/src/server/dev-warnings.ts +2 -28
  405. package/src/server/early-hints.ts +36 -15
  406. package/src/server/error-boundary-wrapper.ts +74 -22
  407. package/src/server/fallback-error.ts +31 -15
  408. package/src/server/flight-injection-state.ts +113 -0
  409. package/src/server/flight-scripts.ts +62 -0
  410. package/src/server/flush.ts +2 -1
  411. package/src/server/form-data.ts +76 -0
  412. package/src/server/html-injectors.ts +277 -117
  413. package/src/server/index.ts +9 -5
  414. package/src/server/logger.ts +44 -36
  415. package/src/server/middleware-runner.ts +31 -4
  416. package/src/server/node-stream-transforms.ts +509 -0
  417. package/src/server/page-deny-boundary.tsx +56 -0
  418. package/src/server/pipeline-interception.ts +17 -16
  419. package/src/server/pipeline-metadata.ts +13 -0
  420. package/src/server/pipeline.ts +195 -51
  421. package/src/server/primitives.ts +47 -5
  422. package/src/server/render-timeout.ts +108 -0
  423. package/src/server/request-context.ts +240 -117
  424. package/src/server/route-element-builder.ts +284 -197
  425. package/src/server/route-handler.ts +24 -4
  426. package/src/server/route-matcher.ts +24 -20
  427. package/src/server/rsc-entry/api-handler.ts +15 -16
  428. package/src/server/rsc-entry/error-renderer.ts +300 -89
  429. package/src/server/rsc-entry/helpers.ts +134 -5
  430. package/src/server/rsc-entry/index.ts +202 -113
  431. package/src/server/rsc-entry/rsc-payload.ts +100 -21
  432. package/src/server/rsc-entry/rsc-stream.ts +74 -18
  433. package/src/server/rsc-entry/ssr-bridge.ts +14 -5
  434. package/src/server/rsc-entry/ssr-renderer.ts +173 -40
  435. package/src/server/safe-load.ts +60 -0
  436. package/src/server/sitemap-generator.ts +338 -0
  437. package/src/server/sitemap-handler.ts +126 -0
  438. package/src/server/slot-resolver.ts +243 -228
  439. package/src/server/ssr-entry.ts +211 -32
  440. package/src/server/ssr-render.ts +289 -67
  441. package/src/server/ssr-wrappers.tsx +139 -0
  442. package/src/server/status-code-resolver.ts +1 -1
  443. package/src/server/stream-utils.ts +213 -0
  444. package/src/server/tracing.ts +37 -3
  445. package/src/server/tree-builder.ts +92 -58
  446. package/src/server/types.ts +3 -6
  447. package/src/server/version-skew.ts +104 -0
  448. package/src/server/waituntil-bridge.ts +4 -1
  449. package/src/shared/merge-search-params.ts +55 -0
  450. package/src/shims/font-google.ts +1 -1
  451. package/src/shims/font-local.ts +34 -0
  452. package/src/shims/navigation-client.ts +1 -1
  453. package/src/shims/navigation.ts +2 -1
  454. package/src/utils/directive-parser.ts +5 -2
  455. package/src/utils/state-machine.ts +111 -0
  456. package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
  457. package/dist/_chunks/debug-gwlJkDuf.js.map +0 -1
  458. package/dist/_chunks/format-DviM89f0.js.map +0 -1
  459. package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
  460. package/dist/_chunks/request-context-DIkVh_jG.js.map +0 -1
  461. package/dist/_chunks/ssr-data-MjmprTmO.js +0 -88
  462. package/dist/_chunks/ssr-data-MjmprTmO.js.map +0 -1
  463. package/dist/_chunks/tracing-Cwn7697K.js.map +0 -1
  464. package/dist/_chunks/use-cookie-DX-l1_5E.js +0 -91
  465. package/dist/_chunks/use-cookie-DX-l1_5E.js.map +0 -1
  466. package/dist/_chunks/use-query-states-D5KaffOK.js.map +0 -1
  467. package/dist/cache/register-cached-function.d.ts +0 -17
  468. package/dist/cache/register-cached-function.d.ts.map +0 -1
  469. package/dist/client/error-boundary.js.map +0 -1
  470. package/dist/client/link-status-provider.d.ts +0 -11
  471. package/dist/client/link-status-provider.d.ts.map +0 -1
  472. package/dist/client/transition-root.d.ts.map +0 -1
  473. package/dist/cookies/index.js.map +0 -1
  474. package/dist/plugins/cache-transform.d.ts +0 -36
  475. package/dist/plugins/cache-transform.d.ts.map +0 -1
  476. package/dist/plugins/dynamic-transform.d.ts +0 -72
  477. package/dist/plugins/dynamic-transform.d.ts.map +0 -1
  478. package/dist/search-params/analyze.d.ts +0 -54
  479. package/dist/search-params/analyze.d.ts.map +0 -1
  480. package/dist/search-params/builtin-codecs.d.ts +0 -105
  481. package/dist/search-params/builtin-codecs.d.ts.map +0 -1
  482. package/dist/search-params/codecs.d.ts +0 -53
  483. package/dist/search-params/codecs.d.ts.map +0 -1
  484. package/dist/search-params/create.d.ts +0 -106
  485. package/dist/search-params/create.d.ts.map +0 -1
  486. package/dist/search-params/index.js.map +0 -1
  487. package/dist/server/prerender.d.ts +0 -77
  488. package/dist/server/prerender.d.ts.map +0 -1
  489. package/dist/server/response-cache.d.ts +0 -53
  490. package/dist/server/response-cache.d.ts.map +0 -1
  491. package/src/cache/register-cached-function.ts +0 -99
  492. package/src/client/link-status-provider.tsx +0 -30
  493. package/src/client/transition-root.tsx +0 -160
  494. package/src/plugins/cache-transform.ts +0 -199
  495. package/src/plugins/dynamic-transform.ts +0 -161
  496. package/src/search-params/analyze.ts +0 -192
  497. package/src/search-params/builtin-codecs.ts +0 -228
  498. package/src/search-params/create.ts +0 -321
  499. package/src/server/prerender.ts +0 -139
  500. package/src/server/response-cache.ts +0 -277
@@ -1,228 +0,0 @@
1
- /**
2
- * Built-in search param codecs for common types.
3
- *
4
- * These provide zero-dependency alternatives to nuqs parsers for the most
5
- * common cases: strings, integers, floats, booleans, and string enums.
6
- *
7
- * All codecs implement SearchParamCodec<T | null> — returning null when the
8
- * param is absent or unparseable. Use withDefault() to replace null with a
9
- * concrete fallback value.
10
- *
11
- * Design doc: design/23-search-params.md §"Identified Gaps" #1
12
- * Task: TIM-362
13
- */
14
-
15
- import type { SearchParamCodec } from './create.js';
16
-
17
- // ---------------------------------------------------------------------------
18
- // Helpers
19
- // ---------------------------------------------------------------------------
20
-
21
- /**
22
- * Normalize array inputs to a single string (last value wins, matching
23
- * URLSearchParams.get() semantics). Returns undefined if absent or empty.
24
- */
25
- function normalizeInput(value: string | string[] | undefined): string | undefined {
26
- if (Array.isArray(value)) {
27
- return value.length > 0 ? value[value.length - 1] : undefined;
28
- }
29
- return value;
30
- }
31
-
32
- // ---------------------------------------------------------------------------
33
- // parseAsString
34
- // ---------------------------------------------------------------------------
35
-
36
- /**
37
- * String codec. Returns the raw string value, or null if absent.
38
- *
39
- * ```ts
40
- * import { parseAsString } from '@timber-js/app/search-params'
41
- *
42
- * const def = createSearchParams({ q: parseAsString })
43
- * // ?q=shoes → { q: 'shoes' }
44
- * // (absent) → { q: null }
45
- * ```
46
- */
47
- export const parseAsString: SearchParamCodec<string | null> = {
48
- parse(value: string | string[] | undefined): string | null {
49
- const v = normalizeInput(value);
50
- return v !== undefined ? v : null;
51
- },
52
- serialize(value: string | null): string | null {
53
- return value;
54
- },
55
- };
56
-
57
- // ---------------------------------------------------------------------------
58
- // parseAsInteger
59
- // ---------------------------------------------------------------------------
60
-
61
- /**
62
- * Integer codec. Parses a base-10 integer, or returns null if absent or
63
- * not a valid integer. Rejects floats, NaN, Infinity, and non-numeric strings.
64
- *
65
- * ```ts
66
- * import { parseAsInteger, withDefault } from '@timber-js/app/search-params'
67
- *
68
- * const def = createSearchParams({ page: withDefault(parseAsInteger, 1) })
69
- * // ?page=2 → { page: 2 }
70
- * // ?page=abc → { page: 1 }
71
- * // (absent) → { page: 1 }
72
- * ```
73
- */
74
- export const parseAsInteger: SearchParamCodec<number | null> = {
75
- parse(value: string | string[] | undefined): number | null {
76
- const v = normalizeInput(value);
77
- if (v === undefined || v === '') return null;
78
- const n = Number(v);
79
- if (!Number.isFinite(n) || !Number.isInteger(n)) return null;
80
- return n;
81
- },
82
- serialize(value: number | null): string | null {
83
- return value === null ? null : String(value);
84
- },
85
- };
86
-
87
- // ---------------------------------------------------------------------------
88
- // parseAsFloat
89
- // ---------------------------------------------------------------------------
90
-
91
- /**
92
- * Float codec. Parses a finite number, or returns null if absent or invalid.
93
- * Rejects NaN and Infinity.
94
- *
95
- * ```ts
96
- * import { parseAsFloat, withDefault } from '@timber-js/app/search-params'
97
- *
98
- * const def = createSearchParams({ price: withDefault(parseAsFloat, 0) })
99
- * ```
100
- */
101
- export const parseAsFloat: SearchParamCodec<number | null> = {
102
- parse(value: string | string[] | undefined): number | null {
103
- const v = normalizeInput(value);
104
- if (v === undefined || v === '') return null;
105
- const n = Number(v);
106
- if (!Number.isFinite(n)) return null;
107
- return n;
108
- },
109
- serialize(value: number | null): string | null {
110
- return value === null ? null : String(value);
111
- },
112
- };
113
-
114
- // ---------------------------------------------------------------------------
115
- // parseAsBoolean
116
- // ---------------------------------------------------------------------------
117
-
118
- /**
119
- * Boolean codec. Accepts "true"/"1" as true, "false"/"0" as false.
120
- * Returns null for absent or unrecognized values.
121
- *
122
- * ```ts
123
- * import { parseAsBoolean, withDefault } from '@timber-js/app/search-params'
124
- *
125
- * const def = createSearchParams({ debug: withDefault(parseAsBoolean, false) })
126
- * // ?debug=true → { debug: true }
127
- * // ?debug=0 → { debug: false }
128
- * ```
129
- */
130
- export const parseAsBoolean: SearchParamCodec<boolean | null> = {
131
- parse(value: string | string[] | undefined): boolean | null {
132
- const v = normalizeInput(value);
133
- if (v === undefined) return null;
134
- if (v === 'true' || v === '1') return true;
135
- if (v === 'false' || v === '0') return false;
136
- return null;
137
- },
138
- serialize(value: boolean | null): string | null {
139
- return value === null ? null : String(value);
140
- },
141
- };
142
-
143
- // ---------------------------------------------------------------------------
144
- // parseAsStringEnum
145
- // ---------------------------------------------------------------------------
146
-
147
- /**
148
- * String enum codec. Accepts only values in the provided list.
149
- * Returns null for absent or invalid values.
150
- *
151
- * ```ts
152
- * import { parseAsStringEnum, withDefault } from '@timber-js/app/search-params'
153
- *
154
- * const sortCodec = withDefault(
155
- * parseAsStringEnum(['price', 'name', 'date']),
156
- * 'date'
157
- * )
158
- * ```
159
- */
160
- export function parseAsStringEnum<T extends string>(
161
- values: readonly T[]
162
- ): SearchParamCodec<T | null> {
163
- const allowed = new Set<string>(values);
164
- return {
165
- parse(value: string | string[] | undefined): T | null {
166
- const v = normalizeInput(value);
167
- if (v === undefined) return null;
168
- return allowed.has(v) ? (v as T) : null;
169
- },
170
- serialize(value: T | null): string | null {
171
- return value;
172
- },
173
- };
174
- }
175
-
176
- // ---------------------------------------------------------------------------
177
- // parseAsStringLiteral
178
- // ---------------------------------------------------------------------------
179
-
180
- /**
181
- * String literal codec. Functionally identical to parseAsStringEnum but
182
- * accepts `as const` tuples for narrower type inference.
183
- *
184
- * ```ts
185
- * import { parseAsStringLiteral } from '@timber-js/app/search-params'
186
- *
187
- * const sizes = ['sm', 'md', 'lg', 'xl'] as const
188
- * const codec = parseAsStringLiteral(sizes)
189
- * // Type: SearchParamCodec<'sm' | 'md' | 'lg' | 'xl' | null>
190
- * ```
191
- */
192
- export function parseAsStringLiteral<const T extends readonly string[]>(
193
- values: T
194
- ): SearchParamCodec<T[number] | null> {
195
- // Delegates to parseAsStringEnum — same runtime behavior, different type
196
- return parseAsStringEnum<T[number]>(values);
197
- }
198
-
199
- // ---------------------------------------------------------------------------
200
- // withDefault
201
- // ---------------------------------------------------------------------------
202
-
203
- /**
204
- * Wrap a nullable codec with a default value. When the inner codec returns
205
- * null, the default is used instead. The output type becomes non-nullable.
206
- *
207
- * ```ts
208
- * import { parseAsInteger, withDefault } from '@timber-js/app/search-params'
209
- *
210
- * const page = withDefault(parseAsInteger, 1)
211
- * // page.parse(undefined) → 1 (not null)
212
- * // page.parse('5') → 5
213
- * ```
214
- */
215
- export function withDefault<T>(
216
- codec: SearchParamCodec<T | null>,
217
- defaultValue: T
218
- ): SearchParamCodec<T> {
219
- return {
220
- parse(value: string | string[] | undefined): T {
221
- const result = codec.parse(value);
222
- return result === null ? defaultValue : result;
223
- },
224
- serialize(value: T): string | null {
225
- return codec.serialize(value);
226
- },
227
- };
228
- }
@@ -1,321 +0,0 @@
1
- /**
2
- * createSearchParams — factory for SearchParamsDefinition<T>.
3
- *
4
- * Creates a typed, composable definition for a route's search parameters.
5
- * Supports codec protocol, URL key aliasing, default-omission serialization,
6
- * and composition via .extend() / .pick().
7
- *
8
- * Design doc: design/09-typescript.md §"Typed searchParams — search-params.ts"
9
- */
10
-
11
- import { useQueryStates as clientUseQueryStates } from '#/client/use-query-states.js';
12
-
13
- // ---------------------------------------------------------------------------
14
- // Types
15
- // ---------------------------------------------------------------------------
16
-
17
- /**
18
- * A codec that converts between URL string values and typed values.
19
- *
20
- * nuqs parsers (parseAsInteger, parseAsString, etc.) implement this
21
- * interface natively — no adapter needed.
22
- */
23
- export interface SearchParamCodec<T> {
24
- /** URL string → typed value. Receives undefined when the param is absent. */
25
- parse(value: string | string[] | undefined): T;
26
- /** Typed value → URL string. Return null to omit from URL. */
27
- serialize(value: T): string | null;
28
- }
29
-
30
- /** Infer the output type of a codec. */
31
- export type InferCodec<C> = C extends SearchParamCodec<infer T> ? T : never;
32
-
33
- /** Map of property names to codecs. */
34
- export type CodecMap<T extends Record<string, unknown>> = {
35
- [K in keyof T]: SearchParamCodec<T[K]>;
36
- };
37
-
38
- /** Options for useQueryStates setter. */
39
- export interface SetParamsOptions {
40
- /** Update URL without server roundtrip (default: false). */
41
- shallow?: boolean;
42
- /** Scroll to top after update (default: true). */
43
- scroll?: boolean;
44
- /** 'push' (default) or 'replace' for history state. */
45
- history?: 'push' | 'replace';
46
- }
47
-
48
- /** Setter function returned by useQueryStates. */
49
- export type SetParams<T> = (values: Partial<T>, options?: SetParamsOptions) => void;
50
-
51
- /** Options for useQueryStates hook. */
52
- export interface QueryStatesOptions {
53
- /** Update URL without server roundtrip (default: false). */
54
- shallow?: boolean;
55
- /** Scroll to top after update (default: true). */
56
- scroll?: boolean;
57
- /** 'push' (default) or 'replace' for history state. */
58
- history?: 'push' | 'replace';
59
- }
60
-
61
- /** Options for createSearchParams and .extend(). */
62
- export interface SearchParamsOptions<Keys extends string = string> {
63
- /** Map property names to different URL query parameter keys. */
64
- urlKeys?: Partial<Record<Keys, string>>;
65
- }
66
-
67
- /**
68
- * A fully typed, composable search params definition.
69
- *
70
- * Returned by createSearchParams(). Carries a phantom _type property
71
- * for build-time type extraction.
72
- */
73
- export interface SearchParamsDefinition<T extends Record<string, unknown>> {
74
- /** Parse raw URL search params into typed values. */
75
- parse(raw: URLSearchParams | Record<string, string | string[] | undefined>): T;
76
-
77
- /** Client hook — reads current URL params and returns typed values + setter. */
78
- useQueryStates(options?: QueryStatesOptions): [T, SetParams<T>];
79
-
80
- /** Extend with additional codecs. Key collisions are a type error. */
81
- extend<U extends Record<string, SearchParamCodec<unknown>>>(
82
- codecs: U,
83
- options?: SearchParamsOptions<string>
84
- ): SearchParamsDefinition<T & { [K in keyof U]: InferCodec<U[K]> }>;
85
-
86
- /** Pick a subset of keys. Preserves codecs and aliases. */
87
- pick<K extends keyof T & string>(...keys: K[]): SearchParamsDefinition<Pick<T, K>>;
88
-
89
- /** Serialize values to a query string (no leading '?'), omitting defaults. */
90
- serialize(values: Partial<T>): string;
91
-
92
- /** Build a full path with query string, omitting defaults. */
93
- href(pathname: string, values: Partial<T>): string;
94
-
95
- /** Build a URLSearchParams instance, omitting defaults. */
96
- toSearchParams(values: Partial<T>): URLSearchParams;
97
-
98
- /** Read-only codec map for spreading into .extend(). Aliases NOT carried. */
99
- codecs: { [K in keyof T]: SearchParamCodec<T[K]> };
100
-
101
- /** Read-only URL key alias map. Maps property names to URL query parameter keys. */
102
- readonly urlKeys: Readonly<Record<string, string>>;
103
-
104
- /**
105
- * Phantom property for build-time type extraction.
106
- * Never set at runtime — exists only in the type system.
107
- */
108
- readonly _type?: T;
109
- }
110
-
111
- // ---------------------------------------------------------------------------
112
- // Internal helpers
113
- // ---------------------------------------------------------------------------
114
-
115
- /**
116
- * Convert URLSearchParams or a plain record to a normalized record
117
- * where repeated keys produce arrays.
118
- */
119
- function normalizeRaw(
120
- raw: URLSearchParams | Record<string, string | string[] | undefined>
121
- ): Record<string, string | string[] | undefined> {
122
- if (raw instanceof URLSearchParams) {
123
- const result: Record<string, string | string[] | undefined> = {};
124
- for (const key of new Set(raw.keys())) {
125
- const values = raw.getAll(key);
126
- result[key] = values.length === 1 ? values[0] : values;
127
- }
128
- return result;
129
- }
130
- return raw;
131
- }
132
-
133
- /**
134
- * Compute the serialized default value for a codec. Used for
135
- * default-omission: when serialize(value) === serialize(parse(undefined)),
136
- * the field is omitted from the URL.
137
- */
138
- function getDefaultSerialized<T>(codec: SearchParamCodec<T>): string | null {
139
- return codec.serialize(codec.parse(undefined));
140
- }
141
-
142
- // ---------------------------------------------------------------------------
143
- // Factory
144
- // ---------------------------------------------------------------------------
145
-
146
- /**
147
- * Create a SearchParamsDefinition from a codec map and optional URL key aliases.
148
- *
149
- * ```ts
150
- * import { createSearchParams, fromSchema } from '@timber-js/app/search-params'
151
- * import { z } from 'zod/v4'
152
- *
153
- * export default createSearchParams({
154
- * page: fromSchema(z.coerce.number().int().min(1).default(1)),
155
- * q: { parse: (v) => v ?? null, serialize: (v) => v },
156
- * }, {
157
- * urlKeys: { q: 'search' },
158
- * })
159
- * ```
160
- */
161
- export function createSearchParams<C extends Record<string, SearchParamCodec<unknown>>>(
162
- codecs: C,
163
- options?: SearchParamsOptions<Extract<keyof C, string>>
164
- ): SearchParamsDefinition<{ [K in keyof C]: InferCodec<C[K]> }> {
165
- type T = { [K in keyof C]: InferCodec<C[K]> };
166
- const urlKeys: Record<string, string> = {};
167
- if (options?.urlKeys) {
168
- for (const [k, v] of Object.entries(options.urlKeys)) {
169
- if (v !== undefined) urlKeys[k] = v;
170
- }
171
- }
172
-
173
- return buildDefinition<T>(codecs as unknown as CodecMap<T>, urlKeys);
174
- }
175
-
176
- /**
177
- * Internal: build a SearchParamsDefinition from a typed codec map and url keys.
178
- */
179
- function buildDefinition<T extends Record<string, unknown>>(
180
- codecMap: CodecMap<T>,
181
- urlKeys: Record<string, string>
182
- ): SearchParamsDefinition<T> {
183
- // Pre-compute default serialized values for omission check
184
- const defaultSerialized: Record<string, string | null> = {};
185
- for (const key of Object.keys(codecMap)) {
186
- defaultSerialized[key] = getDefaultSerialized(codecMap[key as keyof T]);
187
- }
188
-
189
- function getUrlKey(prop: string): string {
190
- return urlKeys[prop] ?? prop;
191
- }
192
-
193
- // ---- parse ----
194
- function parse(raw: URLSearchParams | Record<string, string | string[] | undefined>): T {
195
- const normalized = normalizeRaw(raw);
196
- const result: Record<string, unknown> = {};
197
-
198
- for (const prop of Object.keys(codecMap)) {
199
- const urlKey = getUrlKey(prop);
200
- const rawValue = normalized[urlKey];
201
- result[prop] = (codecMap[prop as keyof T] as SearchParamCodec<unknown>).parse(rawValue);
202
- }
203
-
204
- return result as T;
205
- }
206
-
207
- // ---- serialize ----
208
- function serialize(values: Partial<T>): string {
209
- const parts: string[] = [];
210
-
211
- for (const prop of Object.keys(codecMap)) {
212
- if (!(prop in values)) continue;
213
- const codec = codecMap[prop as keyof T] as SearchParamCodec<unknown>;
214
- const serialized = codec.serialize(values[prop as keyof T] as unknown);
215
-
216
- // Omit if serialized value matches the default
217
- if (serialized === defaultSerialized[prop]) continue;
218
- if (serialized === null) continue;
219
-
220
- parts.push(`${encodeURIComponent(getUrlKey(prop))}=${encodeURIComponent(serialized)}`);
221
- }
222
-
223
- return parts.join('&');
224
- }
225
-
226
- // ---- href ----
227
- function href(pathname: string, values: Partial<T>): string {
228
- const qs = serialize(values);
229
- return qs ? `${pathname}?${qs}` : pathname;
230
- }
231
-
232
- // ---- toSearchParams ----
233
- function toSearchParams(values: Partial<T>): URLSearchParams {
234
- const usp = new URLSearchParams();
235
-
236
- for (const prop of Object.keys(codecMap)) {
237
- if (!(prop in values)) continue;
238
- const codec = codecMap[prop as keyof T] as SearchParamCodec<unknown>;
239
- const serialized = codec.serialize(values[prop as keyof T] as unknown);
240
-
241
- if (serialized === defaultSerialized[prop]) continue;
242
- if (serialized === null) continue;
243
-
244
- usp.set(getUrlKey(prop), serialized);
245
- }
246
-
247
- return usp;
248
- }
249
-
250
- // ---- extend ----
251
- function extend<U extends Record<string, SearchParamCodec<unknown>>>(
252
- newCodecs: U,
253
- extendOptions?: SearchParamsOptions<string>
254
- ): SearchParamsDefinition<T & { [K in keyof U]: InferCodec<U[K]> }> {
255
- type Combined = T & { [K in keyof U]: InferCodec<U[K]> };
256
-
257
- const combinedCodecs = {
258
- ...codecMap,
259
- ...newCodecs,
260
- } as unknown as CodecMap<Combined>;
261
-
262
- // Merge URL keys: extend options override, but do NOT inherit from base
263
- // (aliases are route-level, not carried through .codecs)
264
- const combinedUrlKeys: Record<string, string> = { ...urlKeys };
265
- if (extendOptions?.urlKeys) {
266
- for (const [k, v] of Object.entries(extendOptions.urlKeys)) {
267
- if (v !== undefined) combinedUrlKeys[k] = v;
268
- }
269
- }
270
-
271
- return buildDefinition<Combined>(combinedCodecs, combinedUrlKeys);
272
- }
273
-
274
- // ---- pick ----
275
- function pick<K extends keyof T & string>(...keys: K[]): SearchParamsDefinition<Pick<T, K>> {
276
- const pickedCodecs: Record<string, SearchParamCodec<unknown>> = {};
277
- const pickedUrlKeys: Record<string, string> = {};
278
-
279
- for (const key of keys) {
280
- pickedCodecs[key] = codecMap[key] as SearchParamCodec<unknown>;
281
- if (key in urlKeys) {
282
- pickedUrlKeys[key] = urlKeys[key];
283
- }
284
- }
285
-
286
- return buildDefinition<Pick<T, K>>(
287
- pickedCodecs as unknown as CodecMap<Pick<T, K>>,
288
- pickedUrlKeys
289
- );
290
- }
291
-
292
- // ---- useQueryStates ----
293
- // Delegates to the 'use client' implementation from use-query-states.ts.
294
- //
295
- // In the RSC environment: use-query-states.ts is transformed by the RSC
296
- // plugin into a client reference proxy. Calling it throws — correct,
297
- // because hooks can't run during server component rendering.
298
- // In SSR: use-query-states.ts is the real nuqs-backed function. Hooks
299
- // work during SSR's renderToReadableStream, so this works correctly.
300
- // On the client: same as SSR — the real function is available.
301
- function useQueryStates(options?: QueryStatesOptions): [T, SetParams<T>] {
302
- return clientUseQueryStates(codecMap, options, Object.freeze({ ...urlKeys })) as [
303
- T,
304
- SetParams<T>,
305
- ];
306
- }
307
-
308
- const definition: SearchParamsDefinition<T> = {
309
- parse,
310
- useQueryStates,
311
- extend,
312
- pick,
313
- serialize,
314
- href,
315
- toSearchParams,
316
- codecs: codecMap,
317
- urlKeys: Object.freeze({ ...urlKeys }),
318
- };
319
-
320
- return definition;
321
- }
@@ -1,139 +0,0 @@
1
- /**
2
- * Pre-rendering types and utilities.
3
- *
4
- * A `prerender.ts` file in a route segment signals the framework to
5
- * pre-render the route's shell at build time. This module defines the
6
- * types that a user exports from `prerender.ts` and utilities for
7
- * loading and validating those exports.
8
- *
9
- * Design doc: design/15-future-prerendering.md
10
- */
11
-
12
- import { parseCacheLife } from '#/plugins/cache-transform.js';
13
-
14
- // ---------------------------------------------------------------------------
15
- // Types — user-facing exports from prerender.ts
16
- // ---------------------------------------------------------------------------
17
-
18
- /**
19
- * The shape of a prerender.ts module's exports.
20
- *
21
- * ```ts
22
- * // app/docs/[slug]/prerender.ts
23
- * export async function generateParams() {
24
- * return docs.map(d => ({ slug: d.slug }))
25
- * }
26
- * export const ttl = '1h'
27
- * export const tags = ['docs']
28
- * ```
29
- */
30
- export interface PrerenderConfig {
31
- /**
32
- * Generate the set of params to pre-render at build time.
33
- * Required for dynamic segments (`[param]`).
34
- * Optional for static segments (the single URL is pre-rendered automatically).
35
- */
36
- generateParams?: () => Promise<Record<string, string>[]> | Record<string, string>[];
37
-
38
- /**
39
- * How long the pre-rendered shell is considered fresh.
40
- * Accepts duration strings ('30s', '5m', '1h', '2d', '1w') or seconds as a number.
41
- * Default: Infinity (cache until explicit invalidation).
42
- */
43
- ttl?: string | number;
44
-
45
- /**
46
- * Invalidation tags. Calling `revalidateTag('docs')` purges all
47
- * pre-rendered shells with that tag.
48
- */
49
- tags?: string[];
50
-
51
- /**
52
- * Fallback strategy for dynamic routes without `generateParams`.
53
- * Only valid in `output: 'static'` mode.
54
- * - `'shell'`: emit a single pre-rendered shell that serves as client-side fallback
55
- */
56
- fallback?: 'shell';
57
- }
58
-
59
- // ---------------------------------------------------------------------------
60
- // Parsed prerender config — framework-internal, with TTL resolved to seconds
61
- // ---------------------------------------------------------------------------
62
-
63
- export interface ResolvedPrerenderConfig {
64
- /** TTL in seconds. Infinity if not set. */
65
- ttlSeconds: number;
66
- /** Invalidation tags */
67
- tags: string[];
68
- /** The generateParams function, if provided */
69
- generateParams?: () => Promise<Record<string, string>[]> | Record<string, string>[];
70
- /** Fallback strategy */
71
- fallback?: 'shell';
72
- }
73
-
74
- /**
75
- * Resolve raw prerender.ts exports into a normalized config.
76
- *
77
- * Validates:
78
- * - `ttl` is a valid duration string or number
79
- * - `tags` is an array of strings
80
- * - `fallback` is 'shell' or undefined
81
- */
82
- export function resolvePrerenderConfig(raw: PrerenderConfig): ResolvedPrerenderConfig {
83
- const ttlSeconds = raw.ttl != null ? parseCacheLife(raw.ttl) : Infinity;
84
-
85
- const tags = raw.tags ?? [];
86
- if (!Array.isArray(tags) || tags.some((t) => typeof t !== 'string')) {
87
- throw new Error(
88
- `prerender.ts: tags must be an array of strings. Got: ${JSON.stringify(raw.tags)}`
89
- );
90
- }
91
-
92
- if (raw.fallback != null && raw.fallback !== 'shell') {
93
- throw new Error(
94
- `prerender.ts: fallback must be 'shell' or omitted. Got: ${JSON.stringify(raw.fallback)}`
95
- );
96
- }
97
-
98
- return {
99
- ttlSeconds,
100
- tags,
101
- generateParams: raw.generateParams,
102
- fallback: raw.fallback,
103
- };
104
- }
105
-
106
- // ---------------------------------------------------------------------------
107
- // Build diagnostics
108
- // ---------------------------------------------------------------------------
109
-
110
- export interface PrerenderDiagnostic {
111
- type: 'DYNAMIC_SEGMENT_NO_PARAMS';
112
- segmentPath: string;
113
- message: string;
114
- }
115
-
116
- /**
117
- * Check if a dynamic segment has `generateParams` when prerender.ts is present.
118
- * If not, emit a diagnostic — the route falls back to SSR.
119
- */
120
- export function checkDynamicSegmentParams(
121
- segmentPath: string,
122
- isDynamic: boolean,
123
- hasGenerateParams: boolean,
124
- fallback?: 'shell'
125
- ): PrerenderDiagnostic | null {
126
- if (!isDynamic) return null;
127
- if (hasGenerateParams) return null;
128
- if (fallback === 'shell') return null;
129
-
130
- return {
131
- type: 'DYNAMIC_SEGMENT_NO_PARAMS',
132
- segmentPath,
133
- message:
134
- `Dynamic segment "${segmentPath}" has prerender.ts but no generateParams(). ` +
135
- `The route will fall back to SSR at request time. ` +
136
- `Add generateParams() to pre-render specific param values, ` +
137
- `or set fallback: 'shell' (static mode only) for a client-side fallback shell.`,
138
- };
139
- }