@timber-js/app 0.2.0-alpha.18 → 0.2.0-alpha.181

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 (1026) hide show
  1. package/LICENSE +8 -0
  2. package/agent-skill.md +344 -0
  3. package/dist/_chunks/actions-O_LsyCE4.js +317 -0
  4. package/dist/_chunks/actions-O_LsyCE4.js.map +1 -0
  5. package/dist/_chunks/build-output-helper-DF5uScqS.js +158 -0
  6. package/dist/_chunks/build-output-helper-DF5uScqS.js.map +1 -0
  7. package/dist/_chunks/cache-api-B-lhk9p4.js +1202 -0
  8. package/dist/_chunks/cache-api-B-lhk9p4.js.map +1 -0
  9. package/dist/_chunks/canonicalize-DQHyFClh.js +248 -0
  10. package/dist/_chunks/canonicalize-DQHyFClh.js.map +1 -0
  11. package/dist/_chunks/cli-schema-sync-D3naS3eH.js +688 -0
  12. package/dist/_chunks/cli-schema-sync-D3naS3eH.js.map +1 -0
  13. package/dist/_chunks/cloudflare-AHoWYTYr.js +1188 -0
  14. package/dist/_chunks/cloudflare-AHoWYTYr.js.map +1 -0
  15. package/dist/_chunks/codec-registry-oOUxugz3.js +21 -0
  16. package/dist/_chunks/codec-registry-oOUxugz3.js.map +1 -0
  17. package/dist/_chunks/define-COtkxMRT.js +191 -0
  18. package/dist/_chunks/define-COtkxMRT.js.map +1 -0
  19. package/dist/_chunks/define-c4au4I9R.js +82 -0
  20. package/dist/_chunks/define-c4au4I9R.js.map +1 -0
  21. package/dist/_chunks/dist-BA3u1z3W.js +423 -0
  22. package/dist/_chunks/dist-BA3u1z3W.js.map +1 -0
  23. package/dist/_chunks/fast-hash-D6hIVt1Y.js +36 -0
  24. package/dist/_chunks/fast-hash-D6hIVt1Y.js.map +1 -0
  25. package/dist/_chunks/format-CfwjgPz9.js +14 -0
  26. package/dist/_chunks/format-CfwjgPz9.js.map +1 -0
  27. package/dist/_chunks/href-validation-CMc5JRls.js +141 -0
  28. package/dist/_chunks/href-validation-CMc5JRls.js.map +1 -0
  29. package/dist/_chunks/json-lossy-check-ClNvBM_3.js +63 -0
  30. package/dist/_chunks/json-lossy-check-ClNvBM_3.js.map +1 -0
  31. package/dist/_chunks/logger-AWfuX-KJ.js +1468 -0
  32. package/dist/_chunks/logger-AWfuX-KJ.js.map +1 -0
  33. package/dist/_chunks/navigation-root-bUDZLw74.js +124 -0
  34. package/dist/_chunks/navigation-root-bUDZLw74.js.map +1 -0
  35. package/dist/_chunks/plugin-context---kTF5v8.js +315 -0
  36. package/dist/_chunks/plugin-context---kTF5v8.js.map +1 -0
  37. package/dist/_chunks/registry-DbJPKoBp.js +20 -0
  38. package/dist/_chunks/registry-DbJPKoBp.js.map +1 -0
  39. package/dist/_chunks/resolve-schema-Dz3fcFUo.js +50 -0
  40. package/dist/_chunks/resolve-schema-Dz3fcFUo.js.map +1 -0
  41. package/dist/_chunks/router-ref-CtmF-aPv.js +28 -0
  42. package/dist/_chunks/router-ref-CtmF-aPv.js.map +1 -0
  43. package/dist/_chunks/schema-bridge-DT_Tn0Xf.js +119 -0
  44. package/dist/_chunks/schema-bridge-DT_Tn0Xf.js.map +1 -0
  45. package/dist/_chunks/segment-classify-Byy425ng.js +176 -0
  46. package/dist/_chunks/segment-classify-Byy425ng.js.map +1 -0
  47. package/dist/_chunks/segment-context-ZDnXDkbz.js +34 -0
  48. package/dist/_chunks/segment-context-ZDnXDkbz.js.map +1 -0
  49. package/dist/_chunks/sizeof-lXffQ1Vr.js +35 -0
  50. package/dist/_chunks/sizeof-lXffQ1Vr.js.map +1 -0
  51. package/dist/_chunks/{ssr-data-MjmprTmO.js → ssr-data-BOWsq18U.js} +1 -1
  52. package/dist/_chunks/ssr-data-BOWsq18U.js.map +1 -0
  53. package/dist/_chunks/{use-query-states-D5KaffOK.js → use-query-states-DFvWd-EA.js} +71 -26
  54. package/dist/_chunks/use-query-states-DFvWd-EA.js.map +1 -0
  55. package/dist/_chunks/use-segment-params-D1CzlgBo.js +151 -0
  56. package/dist/_chunks/use-segment-params-D1CzlgBo.js.map +1 -0
  57. package/dist/_chunks/walkers-BtTlKviE.js +1002 -0
  58. package/dist/_chunks/walkers-BtTlKviE.js.map +1 -0
  59. package/dist/adapters/build-output-helper.d.ts +29 -0
  60. package/dist/adapters/build-output-helper.d.ts.map +1 -0
  61. package/dist/adapters/cloudflare-dev.d.ts +109 -0
  62. package/dist/adapters/cloudflare-dev.d.ts.map +1 -0
  63. package/dist/adapters/cloudflare-dev.js +73 -0
  64. package/dist/adapters/cloudflare-dev.js.map +1 -0
  65. package/dist/adapters/cloudflare-kv-cache.d.ts +65 -0
  66. package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -0
  67. package/dist/adapters/cloudflare-kv-cache.js +124 -0
  68. package/dist/adapters/cloudflare-kv-cache.js.map +1 -0
  69. package/dist/adapters/cloudflare.d.ts +189 -21
  70. package/dist/adapters/cloudflare.d.ts.map +1 -1
  71. package/dist/adapters/cloudflare.js +2 -188
  72. package/dist/adapters/compress-module.d.ts +5 -4
  73. package/dist/adapters/compress-module.d.ts.map +1 -1
  74. package/dist/adapters/nitro.d.ts +41 -3
  75. package/dist/adapters/nitro.d.ts.map +1 -1
  76. package/dist/adapters/nitro.js +224 -172
  77. package/dist/adapters/nitro.js.map +1 -1
  78. package/dist/adapters/shared.d.ts +6 -0
  79. package/dist/adapters/shared.d.ts.map +1 -0
  80. package/dist/adapters/types.d.ts +2 -6
  81. package/dist/adapters/types.d.ts.map +1 -1
  82. package/dist/cache/cache-api.d.ts +48 -0
  83. package/dist/cache/cache-api.d.ts.map +1 -0
  84. package/dist/cache/handler-store.d.ts +33 -0
  85. package/dist/cache/handler-store.d.ts.map +1 -0
  86. package/dist/cache/index.d.ts +31 -8
  87. package/dist/cache/index.d.ts.map +1 -1
  88. package/dist/cache/index.js +3 -326
  89. package/dist/cache/invalidation-epoch.d.ts +43 -0
  90. package/dist/cache/invalidation-epoch.d.ts.map +1 -0
  91. package/dist/cache/json-lossy-check.d.ts +11 -0
  92. package/dist/cache/json-lossy-check.d.ts.map +1 -0
  93. package/dist/cache/redis-handler.d.ts +140 -8
  94. package/dist/cache/redis-handler.d.ts.map +1 -1
  95. package/dist/cache/singleflight.d.ts +19 -2
  96. package/dist/cache/singleflight.d.ts.map +1 -1
  97. package/dist/cache/sizeof.d.ts +22 -0
  98. package/dist/cache/sizeof.d.ts.map +1 -0
  99. package/dist/cache/stable-stringify.d.ts +9 -0
  100. package/dist/cache/stable-stringify.d.ts.map +1 -1
  101. package/dist/cache/store.d.ts +53 -0
  102. package/dist/cache/store.d.ts.map +1 -0
  103. package/dist/cache/stores/cloudflare-kv.d.ts +38 -0
  104. package/dist/cache/stores/cloudflare-kv.d.ts.map +1 -0
  105. package/dist/cache/stores/cloudflare-kv.js +29 -0
  106. package/dist/cache/stores/cloudflare-kv.js.map +1 -0
  107. package/dist/cache/stores/memory.d.ts +42 -0
  108. package/dist/cache/stores/memory.d.ts.map +1 -0
  109. package/dist/cache/stores/memory.js +90 -0
  110. package/dist/cache/stores/memory.js.map +1 -0
  111. package/dist/cache/stores/redis.d.ts +69 -0
  112. package/dist/cache/stores/redis.d.ts.map +1 -0
  113. package/dist/cache/stores/redis.js +35 -0
  114. package/dist/cache/stores/redis.js.map +1 -0
  115. package/dist/cache/stores/vercel.d.ts +36 -0
  116. package/dist/cache/stores/vercel.d.ts.map +1 -0
  117. package/dist/cache/stores/vercel.js +33 -0
  118. package/dist/cache/stores/vercel.js.map +1 -0
  119. package/dist/cache/tag-aware-handler.d.ts +52 -0
  120. package/dist/cache/tag-aware-handler.d.ts.map +1 -0
  121. package/dist/cache/timber-cache.d.ts +20 -10
  122. package/dist/cache/timber-cache.d.ts.map +1 -1
  123. package/dist/cdn/cloudflare-purge.d.ts +23 -0
  124. package/dist/cdn/cloudflare-purge.d.ts.map +1 -0
  125. package/dist/cdn/fastly-purge.d.ts +25 -0
  126. package/dist/cdn/fastly-purge.d.ts.map +1 -0
  127. package/dist/cdn/headers.d.ts +97 -0
  128. package/dist/cdn/headers.d.ts.map +1 -0
  129. package/dist/cdn/index.d.ts +5 -0
  130. package/dist/cdn/index.d.ts.map +1 -0
  131. package/dist/cdn/purge-store.d.ts +23 -0
  132. package/dist/cdn/purge-store.d.ts.map +1 -0
  133. package/dist/cdn/workers-cache-purge.d.ts +16 -0
  134. package/dist/cdn/workers-cache-purge.d.ts.map +1 -0
  135. package/dist/cli-schema-sync.d.ts +59 -0
  136. package/dist/cli-schema-sync.d.ts.map +1 -0
  137. package/dist/cli.d.ts +35 -2
  138. package/dist/cli.d.ts.map +1 -1
  139. package/dist/cli.js +113 -34
  140. package/dist/cli.js.map +1 -1
  141. package/dist/client/browser-dev.d.ts +37 -1
  142. package/dist/client/browser-dev.d.ts.map +1 -1
  143. package/dist/client/browser-entry/action-dispatch.d.ts +17 -0
  144. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -0
  145. package/dist/client/browser-entry/hmr.d.ts +21 -0
  146. package/dist/client/browser-entry/hmr.d.ts.map +1 -0
  147. package/dist/client/browser-entry/hydrate.d.ts +46 -0
  148. package/dist/client/browser-entry/hydrate.d.ts.map +1 -0
  149. package/dist/client/browser-entry/index.d.ts +29 -0
  150. package/dist/client/browser-entry/index.d.ts.map +1 -0
  151. package/dist/client/browser-entry/post-hydration.d.ts +26 -0
  152. package/dist/client/browser-entry/post-hydration.d.ts.map +1 -0
  153. package/dist/client/browser-entry/router-init.d.ts +27 -0
  154. package/dist/client/browser-entry/router-init.d.ts.map +1 -0
  155. package/dist/client/browser-entry/rsc-stream.d.ts +24 -0
  156. package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -0
  157. package/dist/client/browser-entry/scroll.d.ts +28 -0
  158. package/dist/client/browser-entry/scroll.d.ts.map +1 -0
  159. package/dist/client/error-boundary.d.ts +12 -5
  160. package/dist/client/error-boundary.d.ts.map +1 -1
  161. package/dist/client/error-boundary.js +47 -10
  162. package/dist/client/error-boundary.js.map +1 -1
  163. package/dist/client/error-reconstituter.d.ts +61 -0
  164. package/dist/client/error-reconstituter.d.ts.map +1 -0
  165. package/dist/client/form.d.ts +16 -27
  166. package/dist/client/form.d.ts.map +1 -1
  167. package/dist/client/history.d.ts +21 -6
  168. package/dist/client/history.d.ts.map +1 -1
  169. package/dist/client/index.d.ts +10 -24
  170. package/dist/client/index.d.ts.map +1 -1
  171. package/dist/client/index.js +185 -1134
  172. package/dist/client/index.js.map +1 -1
  173. package/dist/client/internal.d.ts +19 -0
  174. package/dist/client/internal.d.ts.map +1 -0
  175. package/dist/client/internal.js +938 -0
  176. package/dist/client/internal.js.map +1 -0
  177. package/dist/client/link.d.ts +69 -60
  178. package/dist/client/link.d.ts.map +1 -1
  179. package/dist/client/navigation-api.d.ts +121 -0
  180. package/dist/client/navigation-api.d.ts.map +1 -0
  181. package/dist/client/navigation-context.d.ts +3 -2
  182. package/dist/client/navigation-context.d.ts.map +1 -1
  183. package/dist/client/navigation-root.d.ts +119 -0
  184. package/dist/client/navigation-root.d.ts.map +1 -0
  185. package/dist/client/nuqs-adapter.d.ts +1 -1
  186. package/dist/client/nuqs-adapter.d.ts.map +1 -1
  187. package/dist/client/router-ref.d.ts +1 -1
  188. package/dist/client/router.d.ts +99 -14
  189. package/dist/client/router.d.ts.map +1 -1
  190. package/dist/client/rsc-fetch.d.ts +62 -15
  191. package/dist/client/rsc-fetch.d.ts.map +1 -1
  192. package/dist/client/segment-cache.d.ts +30 -7
  193. package/dist/client/segment-cache.d.ts.map +1 -1
  194. package/dist/client/segment-outlet.d.ts +57 -0
  195. package/dist/client/segment-outlet.d.ts.map +1 -0
  196. package/dist/client/segment-update-context.d.ts +21 -0
  197. package/dist/client/segment-update-context.d.ts.map +1 -0
  198. package/dist/client/shallow-url.d.ts +10 -0
  199. package/dist/client/shallow-url.d.ts.map +1 -0
  200. package/dist/client/slot-context.d.ts +31 -0
  201. package/dist/client/slot-context.d.ts.map +1 -0
  202. package/dist/client/slot-outlet.d.ts +16 -0
  203. package/dist/client/slot-outlet.d.ts.map +1 -0
  204. package/dist/client/slot-provider.d.ts +25 -0
  205. package/dist/client/slot-provider.d.ts.map +1 -0
  206. package/dist/client/ssr-data.d.ts +13 -4
  207. package/dist/client/ssr-data.d.ts.map +1 -1
  208. package/dist/client/state.d.ts +1 -1
  209. package/dist/client/top-loader.d.ts +5 -5
  210. package/dist/client/top-loader.d.ts.map +1 -1
  211. package/dist/client/use-cookie.d.ts +12 -0
  212. package/dist/client/use-cookie.d.ts.map +1 -1
  213. package/dist/client/use-link-status.d.ts +5 -5
  214. package/dist/client/use-link-status.d.ts.map +1 -1
  215. package/dist/client/use-pathname.d.ts.map +1 -1
  216. package/dist/client/use-pending-navigation.d.ts +23 -0
  217. package/dist/client/use-pending-navigation.d.ts.map +1 -0
  218. package/dist/client/use-query-states.d.ts +1 -1
  219. package/dist/client/use-query-states.d.ts.map +1 -1
  220. package/dist/client/use-router.d.ts +1 -1
  221. package/dist/client/use-router.d.ts.map +1 -1
  222. package/dist/client/use-search-params.d.ts +12 -5
  223. package/dist/client/use-search-params.d.ts.map +1 -1
  224. package/dist/client/{use-params.d.ts → use-segment-params.d.ts} +8 -6
  225. package/dist/client/use-segment-params.d.ts.map +1 -0
  226. package/dist/codec.d.ts +69 -0
  227. package/dist/codec.d.ts.map +1 -0
  228. package/dist/codec.js +76 -0
  229. package/dist/codec.js.map +1 -0
  230. package/dist/config-types.d.ts +284 -0
  231. package/dist/config-types.d.ts.map +1 -0
  232. package/dist/config-validation.d.ts +51 -0
  233. package/dist/config-validation.d.ts.map +1 -0
  234. package/dist/content/index.d.ts +1 -10
  235. package/dist/content/index.d.ts.map +1 -1
  236. package/dist/content/index.js +0 -2
  237. package/dist/cookies/define-cookie.d.ts +58 -25
  238. package/dist/cookies/define-cookie.d.ts.map +1 -1
  239. package/dist/cookies/index.d.ts +2 -1
  240. package/dist/cookies/index.d.ts.map +1 -1
  241. package/dist/cookies/index.js +257 -36
  242. package/dist/cookies/index.js.map +1 -1
  243. package/dist/cookies/json-cookie.d.ts +64 -0
  244. package/dist/cookies/json-cookie.d.ts.map +1 -0
  245. package/dist/cookies/validation.d.ts +34 -0
  246. package/dist/cookies/validation.d.ts.map +1 -0
  247. package/dist/dev-tools/404-page.d.ts +50 -0
  248. package/dist/dev-tools/404-page.d.ts.map +1 -0
  249. package/dist/dev-tools/browser-logs.d.ts +40 -0
  250. package/dist/dev-tools/browser-logs.d.ts.map +1 -0
  251. package/dist/dev-tools/dev-page-shell.d.ts +78 -0
  252. package/dist/dev-tools/dev-page-shell.d.ts.map +1 -0
  253. package/dist/dev-tools/error-page.d.ts +32 -0
  254. package/dist/dev-tools/error-page.d.ts.map +1 -0
  255. package/dist/dev-tools/holding-server.d.ts +54 -0
  256. package/dist/dev-tools/holding-server.d.ts.map +1 -0
  257. package/dist/dev-tools/hydration-overlay.d.ts +11 -0
  258. package/dist/dev-tools/hydration-overlay.d.ts.map +1 -0
  259. package/dist/dev-tools/index.d.ts +31 -0
  260. package/dist/dev-tools/index.d.ts.map +1 -0
  261. package/dist/dev-tools/instrumentation.d.ts +59 -0
  262. package/dist/dev-tools/instrumentation.d.ts.map +1 -0
  263. package/dist/{server/dev-logger.d.ts → dev-tools/logger.d.ts} +1 -1
  264. package/dist/dev-tools/logger.d.ts.map +1 -0
  265. package/dist/{plugins/dev-logs.d.ts → dev-tools/logs.d.ts} +17 -3
  266. package/dist/dev-tools/logs.d.ts.map +1 -0
  267. package/dist/dev-tools/overlay.d.ts +91 -0
  268. package/dist/dev-tools/overlay.d.ts.map +1 -0
  269. package/dist/dev-tools/stack-classifier.d.ts +34 -0
  270. package/dist/dev-tools/stack-classifier.d.ts.map +1 -0
  271. package/dist/dev-tools/terminal.d.ts +28 -0
  272. package/dist/dev-tools/terminal.d.ts.map +1 -0
  273. package/dist/fonts/ast-walk.d.ts +68 -0
  274. package/dist/fonts/ast-walk.d.ts.map +1 -0
  275. package/dist/fonts/ast.d.ts +110 -6
  276. package/dist/fonts/ast.d.ts.map +1 -1
  277. package/dist/fonts/bundle.d.ts +50 -0
  278. package/dist/fonts/bundle.d.ts.map +1 -0
  279. package/dist/fonts/dev-middleware.d.ts +22 -0
  280. package/dist/fonts/dev-middleware.d.ts.map +1 -0
  281. package/dist/fonts/fallbacks.d.ts +0 -7
  282. package/dist/fonts/fallbacks.d.ts.map +1 -1
  283. package/dist/fonts/google.d.ts +4 -2
  284. package/dist/fonts/google.d.ts.map +1 -1
  285. package/dist/fonts/local.d.ts +4 -4
  286. package/dist/fonts/local.d.ts.map +1 -1
  287. package/dist/fonts/paths.d.ts +43 -0
  288. package/dist/fonts/paths.d.ts.map +1 -0
  289. package/dist/fonts/pipeline.d.ts +177 -0
  290. package/dist/fonts/pipeline.d.ts.map +1 -0
  291. package/dist/fonts/transform.d.ts +82 -0
  292. package/dist/fonts/transform.d.ts.map +1 -0
  293. package/dist/fonts/types.d.ts +47 -1
  294. package/dist/fonts/types.d.ts.map +1 -1
  295. package/dist/fonts/virtual-modules.d.ts +77 -0
  296. package/dist/fonts/virtual-modules.d.ts.map +1 -0
  297. package/dist/index.d.ts +46 -180
  298. package/dist/index.d.ts.map +1 -1
  299. package/dist/index.js +9243 -14093
  300. package/dist/index.js.map +1 -1
  301. package/dist/params/codec-registry.d.ts +26 -0
  302. package/dist/params/codec-registry.d.ts.map +1 -0
  303. package/dist/params/define-schema.d.ts +81 -0
  304. package/dist/params/define-schema.d.ts.map +1 -0
  305. package/dist/params/index.d.ts +5 -0
  306. package/dist/params/index.d.ts.map +1 -0
  307. package/dist/params/index.js +34 -0
  308. package/dist/params/index.js.map +1 -0
  309. package/dist/params/resolve-schema.d.ts +34 -0
  310. package/dist/params/resolve-schema.d.ts.map +1 -0
  311. package/dist/plugin-context.d.ts +217 -0
  312. package/dist/plugin-context.d.ts.map +1 -0
  313. package/dist/plugins/adapter-build.d.ts +21 -1
  314. package/dist/plugins/adapter-build.d.ts.map +1 -1
  315. package/dist/plugins/build-manifest.d.ts +7 -3
  316. package/dist/plugins/build-manifest.d.ts.map +1 -1
  317. package/dist/plugins/build-report.d.ts +43 -7
  318. package/dist/plugins/build-report.d.ts.map +1 -1
  319. package/dist/plugins/cache.d.ts +64 -0
  320. package/dist/plugins/cache.d.ts.map +1 -0
  321. package/dist/plugins/callsite-ast.d.ts +117 -0
  322. package/dist/plugins/callsite-ast.d.ts.map +1 -0
  323. package/dist/plugins/callsite-jsx.d.ts +35 -0
  324. package/dist/plugins/callsite-jsx.d.ts.map +1 -0
  325. package/dist/plugins/chunks.d.ts +11 -4
  326. package/dist/plugins/chunks.d.ts.map +1 -1
  327. package/dist/plugins/client-chunks.d.ts +40 -0
  328. package/dist/plugins/client-chunks.d.ts.map +1 -0
  329. package/dist/plugins/cloudflare-wasm.d.ts +21 -0
  330. package/dist/plugins/cloudflare-wasm.d.ts.map +1 -0
  331. package/dist/plugins/content.d.ts +1 -1
  332. package/dist/plugins/content.d.ts.map +1 -1
  333. package/dist/plugins/dev-server.d.ts +17 -1
  334. package/dist/plugins/dev-server.d.ts.map +1 -1
  335. package/dist/plugins/entries.d.ts +28 -4
  336. package/dist/plugins/entries.d.ts.map +1 -1
  337. package/dist/plugins/fonts.d.ts +16 -73
  338. package/dist/plugins/fonts.d.ts.map +1 -1
  339. package/dist/plugins/mdx.d.ts +1 -1
  340. package/dist/plugins/mdx.d.ts.map +1 -1
  341. package/dist/plugins/prebuilt-capture.d.ts +60 -0
  342. package/dist/plugins/prebuilt-capture.d.ts.map +1 -0
  343. package/dist/plugins/prebuilt-options-analysis.d.ts +40 -0
  344. package/dist/plugins/prebuilt-options-analysis.d.ts.map +1 -0
  345. package/dist/plugins/prebuilt.d.ts +82 -0
  346. package/dist/plugins/prebuilt.d.ts.map +1 -0
  347. package/dist/plugins/prerender-sugar.d.ts +42 -0
  348. package/dist/plugins/prerender-sugar.d.ts.map +1 -0
  349. package/dist/plugins/request-dep.d.ts +21 -0
  350. package/dist/plugins/request-dep.d.ts.map +1 -0
  351. package/dist/plugins/routing.d.ts +1 -1
  352. package/dist/plugins/routing.d.ts.map +1 -1
  353. package/dist/plugins/server-bundle.d.ts.map +1 -1
  354. package/dist/plugins/shims.d.ts +29 -5
  355. package/dist/plugins/shims.d.ts.map +1 -1
  356. package/dist/plugins/static-build.d.ts +5 -26
  357. package/dist/plugins/static-build.d.ts.map +1 -1
  358. package/dist/routing/codegen-shared.d.ts +67 -0
  359. package/dist/routing/codegen-shared.d.ts.map +1 -0
  360. package/dist/routing/codegen-types.d.ts +64 -0
  361. package/dist/routing/codegen-types.d.ts.map +1 -0
  362. package/dist/routing/codegen.d.ts +7 -2
  363. package/dist/routing/codegen.d.ts.map +1 -1
  364. package/dist/routing/convention-lint.d.ts +41 -0
  365. package/dist/routing/convention-lint.d.ts.map +1 -0
  366. package/dist/routing/export-detect.d.ts +56 -0
  367. package/dist/routing/export-detect.d.ts.map +1 -0
  368. package/dist/routing/file-cache.d.ts +8 -0
  369. package/dist/routing/file-cache.d.ts.map +1 -0
  370. package/dist/routing/index.d.ts +7 -1
  371. package/dist/routing/index.d.ts.map +1 -1
  372. package/dist/routing/index.js +4 -2
  373. package/dist/routing/interception.d.ts +0 -5
  374. package/dist/routing/interception.d.ts.map +1 -1
  375. package/dist/routing/link-codegen.d.ts +90 -0
  376. package/dist/routing/link-codegen.d.ts.map +1 -0
  377. package/dist/routing/manifest-codegen.d.ts +32 -0
  378. package/dist/routing/manifest-codegen.d.ts.map +1 -0
  379. package/dist/routing/scanner.d.ts +1 -10
  380. package/dist/routing/scanner.d.ts.map +1 -1
  381. package/dist/routing/schema-validation.d.ts +35 -0
  382. package/dist/routing/schema-validation.d.ts.map +1 -0
  383. package/dist/routing/segment-classify.d.ts +81 -0
  384. package/dist/routing/segment-classify.d.ts.map +1 -0
  385. package/dist/routing/segment-codegen.d.ts +38 -0
  386. package/dist/routing/segment-codegen.d.ts.map +1 -0
  387. package/dist/routing/types.d.ts +81 -25
  388. package/dist/routing/types.d.ts.map +1 -1
  389. package/dist/routing/walkers.d.ts +51 -0
  390. package/dist/routing/walkers.d.ts.map +1 -0
  391. package/dist/rsc-runtime/rsc.d.ts +1 -1
  392. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  393. package/dist/rsc-runtime/ssr.d.ts +12 -0
  394. package/dist/rsc-runtime/ssr.d.ts.map +1 -1
  395. package/dist/schema-bridge.d.ts +91 -0
  396. package/dist/schema-bridge.d.ts.map +1 -0
  397. package/dist/search-params/define.d.ts +188 -0
  398. package/dist/search-params/define.d.ts.map +1 -0
  399. package/dist/search-params/index.d.ts +4 -7
  400. package/dist/search-params/index.d.ts.map +1 -1
  401. package/dist/search-params/index.js +34 -441
  402. package/dist/search-params/index.js.map +1 -1
  403. package/dist/search-params/registry.d.ts +2 -2
  404. package/dist/search-params/registry.d.ts.map +1 -1
  405. package/dist/search-params/wrappers.d.ts +53 -0
  406. package/dist/search-params/wrappers.d.ts.map +1 -0
  407. package/dist/segment-params/define.d.ts +89 -0
  408. package/dist/segment-params/define.d.ts.map +1 -0
  409. package/dist/segment-params/index.d.ts +3 -0
  410. package/dist/segment-params/index.d.ts.map +1 -0
  411. package/dist/segment-params/index.js +2 -0
  412. package/dist/server/access-gate.d.ts +8 -3
  413. package/dist/server/access-gate.d.ts.map +1 -1
  414. package/dist/server/action-client.d.ts +42 -7
  415. package/dist/server/action-client.d.ts.map +1 -1
  416. package/dist/server/action-encryption.d.ts +76 -0
  417. package/dist/server/action-encryption.d.ts.map +1 -0
  418. package/dist/server/action-handler.d.ts +35 -1
  419. package/dist/server/action-handler.d.ts.map +1 -1
  420. package/dist/server/actions.d.ts +6 -30
  421. package/dist/server/actions.d.ts.map +1 -1
  422. package/dist/server/als-registry.d.ts +93 -11
  423. package/dist/server/als-registry.d.ts.map +1 -1
  424. package/dist/server/asset-headers.d.ts +8 -18
  425. package/dist/server/asset-headers.d.ts.map +1 -1
  426. package/dist/server/body-limits.d.ts.map +1 -1
  427. package/dist/server/build-manifest.d.ts +12 -29
  428. package/dist/server/build-manifest.d.ts.map +1 -1
  429. package/dist/server/canonicalize.d.ts +10 -0
  430. package/dist/server/canonicalize.d.ts.map +1 -1
  431. package/dist/server/coalesce-tick.d.ts +40 -0
  432. package/dist/server/coalesce-tick.d.ts.map +1 -0
  433. package/dist/server/cookie-context.d.ts +170 -0
  434. package/dist/server/cookie-context.d.ts.map +1 -0
  435. package/dist/server/cookie-parsing.d.ts +65 -0
  436. package/dist/server/cookie-parsing.d.ts.map +1 -0
  437. package/dist/server/csrf.d.ts +3 -2
  438. package/dist/server/csrf.d.ts.map +1 -1
  439. package/dist/server/default-logger.d.ts +22 -0
  440. package/dist/server/default-logger.d.ts.map +1 -0
  441. package/dist/server/deny-boundary.d.ts +117 -0
  442. package/dist/server/deny-boundary.d.ts.map +1 -0
  443. package/dist/server/deny-renderer.d.ts +2 -2
  444. package/dist/server/deny-renderer.d.ts.map +1 -1
  445. package/dist/server/dev-source-map.d.ts +22 -0
  446. package/dist/server/dev-source-map.d.ts.map +1 -0
  447. package/dist/server/early-hints-sender.d.ts.map +1 -1
  448. package/dist/server/early-hints.d.ts +13 -11
  449. package/dist/server/early-hints.d.ts.map +1 -1
  450. package/dist/server/error-boundary-wrapper.d.ts +7 -1
  451. package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
  452. package/dist/server/fallback-error.d.ts +12 -7
  453. package/dist/server/fallback-error.d.ts.map +1 -1
  454. package/dist/server/flight-injection-state.d.ts +66 -0
  455. package/dist/server/flight-injection-state.d.ts.map +1 -0
  456. package/dist/server/flight-scripts.d.ts +42 -0
  457. package/dist/server/flight-scripts.d.ts.map +1 -0
  458. package/dist/server/form-data.d.ts +41 -0
  459. package/dist/server/form-data.d.ts.map +1 -1
  460. package/dist/server/html-injector-core.d.ts +242 -0
  461. package/dist/server/html-injector-core.d.ts.map +1 -0
  462. package/dist/server/html-injectors.d.ts +82 -41
  463. package/dist/server/html-injectors.d.ts.map +1 -1
  464. package/dist/server/index.d.ts +11 -47
  465. package/dist/server/index.d.ts.map +1 -1
  466. package/dist/server/index.js +182 -2906
  467. package/dist/server/index.js.map +1 -1
  468. package/dist/server/internal.d.ts +49 -0
  469. package/dist/server/internal.d.ts.map +1 -0
  470. package/dist/server/internal.js +3892 -0
  471. package/dist/server/internal.js.map +1 -0
  472. package/dist/server/logger.d.ts +39 -7
  473. package/dist/server/logger.d.ts.map +1 -1
  474. package/dist/server/metadata-routes.d.ts +60 -11
  475. package/dist/server/metadata-routes.d.ts.map +1 -1
  476. package/dist/server/metadata.d.ts +8 -0
  477. package/dist/server/metadata.d.ts.map +1 -1
  478. package/dist/server/middleware-runner.d.ts +19 -4
  479. package/dist/server/middleware-runner.d.ts.map +1 -1
  480. package/dist/server/node-stream-transforms.d.ts +119 -0
  481. package/dist/server/node-stream-transforms.d.ts.map +1 -0
  482. package/dist/server/param-coercion.d.ts +54 -0
  483. package/dist/server/param-coercion.d.ts.map +1 -0
  484. package/dist/server/pipeline-helpers.d.ts +95 -0
  485. package/dist/server/pipeline-helpers.d.ts.map +1 -0
  486. package/dist/server/pipeline-interception.d.ts +1 -1
  487. package/dist/server/pipeline-interception.d.ts.map +1 -1
  488. package/dist/server/pipeline-metadata.d.ts +6 -0
  489. package/dist/server/pipeline-metadata.d.ts.map +1 -1
  490. package/dist/server/pipeline-outcome.d.ts +49 -0
  491. package/dist/server/pipeline-outcome.d.ts.map +1 -0
  492. package/dist/server/pipeline-phases.d.ts +59 -0
  493. package/dist/server/pipeline-phases.d.ts.map +1 -0
  494. package/dist/server/pipeline.d.ts +140 -19
  495. package/dist/server/pipeline.d.ts.map +1 -1
  496. package/dist/server/port-resolution.d.ts +117 -0
  497. package/dist/server/port-resolution.d.ts.map +1 -0
  498. package/dist/server/prebuilt/cache-key.d.ts +62 -0
  499. package/dist/server/prebuilt/cache-key.d.ts.map +1 -0
  500. package/dist/server/prebuilt/capture-state.d.ts +57 -0
  501. package/dist/server/prebuilt/capture-state.d.ts.map +1 -0
  502. package/dist/server/prebuilt/key-discipline.d.ts +23 -0
  503. package/dist/server/prebuilt/key-discipline.d.ts.map +1 -0
  504. package/dist/server/prebuilt/manifest-tag-index.d.ts +27 -0
  505. package/dist/server/prebuilt/manifest-tag-index.d.ts.map +1 -0
  506. package/dist/server/prebuilt/overlay.d.ts +100 -0
  507. package/dist/server/prebuilt/overlay.d.ts.map +1 -0
  508. package/dist/server/prebuilt/payload-source.d.ts +78 -0
  509. package/dist/server/prebuilt/payload-source.d.ts.map +1 -0
  510. package/dist/server/prebuilt/slots.d.ts +99 -0
  511. package/dist/server/prebuilt/slots.d.ts.map +1 -0
  512. package/dist/server/prebuilt/synthetic-store.d.ts +66 -0
  513. package/dist/server/prebuilt/synthetic-store.d.ts.map +1 -0
  514. package/dist/server/prebuilt-builder.d.ts +120 -0
  515. package/dist/server/prebuilt-builder.d.ts.map +1 -0
  516. package/dist/server/prebuilt-runtime.d.ts +111 -0
  517. package/dist/server/prebuilt-runtime.d.ts.map +1 -0
  518. package/dist/server/primitives.d.ts +88 -43
  519. package/dist/server/primitives.d.ts.map +1 -1
  520. package/dist/server/render-timeout.d.ts +51 -0
  521. package/dist/server/render-timeout.d.ts.map +1 -0
  522. package/dist/server/render-utils.d.ts +25 -0
  523. package/dist/server/render-utils.d.ts.map +1 -0
  524. package/dist/server/request-context.d.ts +62 -107
  525. package/dist/server/request-context.d.ts.map +1 -1
  526. package/dist/server/request-dep.d.ts +15 -0
  527. package/dist/server/request-dep.d.ts.map +1 -0
  528. package/dist/server/route-element-builder.d.ts +53 -25
  529. package/dist/server/route-element-builder.d.ts.map +1 -1
  530. package/dist/server/route-handler.d.ts.map +1 -1
  531. package/dist/server/route-matcher.d.ts +25 -36
  532. package/dist/server/route-matcher.d.ts.map +1 -1
  533. package/dist/server/rsc-entry/action-middleware-runner.d.ts +66 -0
  534. package/dist/server/rsc-entry/action-middleware-runner.d.ts.map +1 -0
  535. package/dist/server/rsc-entry/api-handler.d.ts +12 -3
  536. package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
  537. package/dist/server/rsc-entry/deny-fallback.d.ts +29 -0
  538. package/dist/server/rsc-entry/deny-fallback.d.ts.map +1 -0
  539. package/dist/server/rsc-entry/error-renderer.d.ts +26 -13
  540. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  541. package/dist/server/rsc-entry/helpers.d.ts +69 -37
  542. package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
  543. package/dist/server/rsc-entry/index.d.ts +28 -6
  544. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  545. package/dist/server/rsc-entry/render-route.d.ts +51 -0
  546. package/dist/server/rsc-entry/render-route.d.ts.map +1 -0
  547. package/dist/server/rsc-entry/revalidate-renderer.d.ts +108 -0
  548. package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -0
  549. package/dist/server/rsc-entry/rsc-payload.d.ts +6 -6
  550. package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
  551. package/dist/server/rsc-entry/rsc-stream.d.ts +25 -1
  552. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  553. package/dist/server/rsc-entry/ssr-bridge.d.ts +5 -1
  554. package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
  555. package/dist/server/rsc-entry/ssr-renderer.d.ts +36 -4
  556. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  557. package/dist/server/rsc-entry/wrap-action-dispatch.d.ts +89 -0
  558. package/dist/server/rsc-entry/wrap-action-dispatch.d.ts.map +1 -0
  559. package/dist/server/safe-load.d.ts +46 -0
  560. package/dist/server/safe-load.d.ts.map +1 -0
  561. package/dist/server/sensitive-fields.d.ts +74 -0
  562. package/dist/server/sensitive-fields.d.ts.map +1 -0
  563. package/dist/server/sitemap-generator.d.ts +129 -0
  564. package/dist/server/sitemap-generator.d.ts.map +1 -0
  565. package/dist/server/sitemap-handler.d.ts +22 -0
  566. package/dist/server/sitemap-handler.d.ts.map +1 -0
  567. package/dist/server/slot-resolver.d.ts +66 -5
  568. package/dist/server/slot-resolver.d.ts.map +1 -1
  569. package/dist/server/ssr-bridge-types.d.ts +121 -0
  570. package/dist/server/ssr-bridge-types.d.ts.map +1 -0
  571. package/dist/server/ssr-entry.d.ts +2 -43
  572. package/dist/server/ssr-entry.d.ts.map +1 -1
  573. package/dist/server/ssr-render.d.ts +64 -21
  574. package/dist/server/ssr-render.d.ts.map +1 -1
  575. package/dist/server/ssr-wrappers.d.ts +50 -0
  576. package/dist/server/ssr-wrappers.d.ts.map +1 -0
  577. package/dist/server/state-tree-diff.d.ts +72 -9
  578. package/dist/server/state-tree-diff.d.ts.map +1 -1
  579. package/dist/server/status-code-resolver.d.ts +22 -11
  580. package/dist/server/status-code-resolver.d.ts.map +1 -1
  581. package/dist/server/stream-utils.d.ts +47 -0
  582. package/dist/server/stream-utils.d.ts.map +1 -0
  583. package/dist/server/tracing.d.ts +44 -9
  584. package/dist/server/tracing.d.ts.map +1 -1
  585. package/dist/server/tree-builder.d.ts +69 -30
  586. package/dist/server/tree-builder.d.ts.map +1 -1
  587. package/dist/server/tree-match.d.ts +49 -0
  588. package/dist/server/tree-match.d.ts.map +1 -0
  589. package/dist/server/types.d.ts +71 -6
  590. package/dist/server/types.d.ts.map +1 -1
  591. package/dist/server/utils/escape-html.d.ts +14 -0
  592. package/dist/server/utils/escape-html.d.ts.map +1 -0
  593. package/dist/server/utils/mdx-file.d.ts +15 -0
  594. package/dist/server/utils/mdx-file.d.ts.map +1 -0
  595. package/dist/server/version-skew.d.ts +61 -0
  596. package/dist/server/version-skew.d.ts.map +1 -0
  597. package/dist/server/workers-cache-bridge.d.ts +26 -0
  598. package/dist/server/workers-cache-bridge.d.ts.map +1 -0
  599. package/dist/shared/href-validation.d.ts +49 -0
  600. package/dist/shared/href-validation.d.ts.map +1 -0
  601. package/dist/shared/merge-search-params.d.ts +22 -0
  602. package/dist/shared/merge-search-params.d.ts.map +1 -0
  603. package/dist/shared/redirect-type.d.ts +17 -0
  604. package/dist/shared/redirect-type.d.ts.map +1 -0
  605. package/dist/shims/font-google.d.ts +1 -1
  606. package/dist/shims/font-google.d.ts.map +1 -1
  607. package/dist/shims/font-google.js +42 -0
  608. package/dist/shims/font-google.js.map +1 -0
  609. package/dist/shims/font-local.d.ts +26 -0
  610. package/dist/shims/font-local.d.ts.map +1 -0
  611. package/dist/shims/font-local.js +20 -0
  612. package/dist/shims/font-local.js.map +1 -0
  613. package/dist/shims/headers.d.ts +53 -1
  614. package/dist/shims/headers.d.ts.map +1 -1
  615. package/dist/shims/image.d.ts +120 -120
  616. package/dist/shims/image.d.ts.map +1 -1
  617. package/dist/shims/navigation-client.d.ts +35 -11
  618. package/dist/shims/navigation-client.d.ts.map +1 -1
  619. package/dist/shims/navigation.d.ts +11 -5
  620. package/dist/shims/navigation.d.ts.map +1 -1
  621. package/dist/utils/state-machine.d.ts +80 -0
  622. package/dist/utils/state-machine.d.ts.map +1 -0
  623. package/docs/api/30-api-server.mdx +233 -0
  624. package/docs/api/31-api-client.mdx +161 -0
  625. package/docs/api/32-api-cache.mdx +311 -0
  626. package/docs/api/33-api-search-params.mdx +154 -0
  627. package/docs/api/34-api-config.mdx +325 -0
  628. package/docs/api/35-api-typescript.mdx +170 -0
  629. package/docs/api/36-cli.mdx +143 -0
  630. package/docs/learn/00-introduction.mdx +109 -0
  631. package/docs/learn/01-quick-start.mdx +94 -0
  632. package/docs/learn/02-pages-and-layouts.mdx +147 -0
  633. package/docs/learn/03-fetching-data.mdx +211 -0
  634. package/docs/learn/03b-access-control.mdx +130 -0
  635. package/docs/learn/04-loading-states.mdx +67 -0
  636. package/docs/learn/04b-the-flush-point.mdx +115 -0
  637. package/docs/learn/05-typed-params.mdx +275 -0
  638. package/docs/learn/06-forms-and-actions.mdx +146 -0
  639. package/docs/learn/07-typed-routes.mdx +127 -0
  640. package/docs/learn/08-streaming.mdx +146 -0
  641. package/docs/learn/09-caching.mdx +252 -0
  642. package/docs/learn/10-middleware.mdx +157 -0
  643. package/docs/learn/11-error-handling.mdx +156 -0
  644. package/docs/learn/12-client-navigation.mdx +176 -0
  645. package/docs/learn/13-configuration.mdx +162 -0
  646. package/docs/learn/14-deploying.mdx +264 -0
  647. package/docs/more/01-advanced-routing.mdx +173 -0
  648. package/docs/more/02-advanced-forms.mdx +137 -0
  649. package/docs/more/03-coming-from-nextjs.mdx +186 -0
  650. package/docs/more/04-metadata-and-fonts.mdx +193 -0
  651. package/docs/more/04b-mdx.mdx +209 -0
  652. package/docs/more/05-content-collections.mdx +90 -0
  653. package/docs/more/06-instrumentation.mdx +214 -0
  654. package/docs/more/07-security.mdx +129 -0
  655. package/docs/more/08-developer-experience.mdx +134 -0
  656. package/docs/more/40-why-timber.mdx +50 -0
  657. package/docs/more/41-timber-vs-nextjs.mdx +81 -0
  658. package/docs/more/42-timber-vs-others.mdx +68 -0
  659. package/docs/more/50-ai-agent-instructions.mdx +169 -0
  660. package/llms.txt +55 -0
  661. package/package.json +105 -26
  662. package/src/adapters/build-output-helper.ts +199 -0
  663. package/src/adapters/cloudflare-dev.ts +177 -0
  664. package/src/adapters/cloudflare-kv-cache.ts +204 -0
  665. package/src/adapters/cloudflare.ts +620 -129
  666. package/src/adapters/compress-module.ts +27 -92
  667. package/src/adapters/nitro.ts +266 -122
  668. package/src/adapters/raw-imports.d.ts +5 -0
  669. package/src/adapters/shared.ts +68 -0
  670. package/src/adapters/types.ts +2 -7
  671. package/src/adapters/wrangler.d.ts +7 -0
  672. package/src/cache/cache-api.ts +107 -0
  673. package/src/cache/handler-store.ts +76 -0
  674. package/src/cache/index.ts +114 -21
  675. package/src/cache/invalidation-epoch.ts +93 -0
  676. package/src/cache/json-lossy-check.ts +75 -0
  677. package/src/cache/redis-handler.ts +197 -19
  678. package/src/cache/singleflight.ts +64 -6
  679. package/src/cache/sizeof.ts +33 -0
  680. package/src/cache/stable-stringify.ts +65 -2
  681. package/src/cache/store.ts +71 -0
  682. package/src/cache/stores/cloudflare-kv.ts +52 -0
  683. package/src/cache/stores/memory.ts +125 -0
  684. package/src/cache/stores/redis.ts +97 -0
  685. package/src/cache/stores/vercel.ts +59 -0
  686. package/src/cache/tag-aware-handler.ts +237 -0
  687. package/src/cache/timber-cache.ts +161 -36
  688. package/src/cdn/cloudflare-purge.ts +50 -0
  689. package/src/cdn/fastly-purge.ts +63 -0
  690. package/src/cdn/headers.ts +153 -0
  691. package/src/cdn/index.ts +17 -0
  692. package/src/cdn/purge-store.ts +34 -0
  693. package/src/cdn/workers-cache-purge.ts +30 -0
  694. package/src/cli-schema-sync.ts +401 -0
  695. package/src/cli.ts +167 -34
  696. package/src/client/browser-dev.ts +156 -1
  697. package/src/client/browser-entry/action-dispatch.ts +124 -0
  698. package/src/client/browser-entry/hmr.ts +70 -0
  699. package/src/client/browser-entry/hydrate.ts +187 -0
  700. package/src/client/browser-entry/index.ts +113 -0
  701. package/src/client/browser-entry/post-hydration.ts +110 -0
  702. package/src/client/browser-entry/router-init.ts +286 -0
  703. package/src/client/browser-entry/rsc-stream.ts +157 -0
  704. package/src/client/browser-entry/scroll.ts +50 -0
  705. package/src/client/error-boundary.tsx +127 -22
  706. package/src/client/error-reconstituter.tsx +79 -0
  707. package/src/client/form.tsx +31 -32
  708. package/src/client/history.ts +21 -6
  709. package/src/client/index.ts +67 -45
  710. package/src/client/internal.ts +58 -0
  711. package/src/client/link.tsx +349 -150
  712. package/src/client/navigation-api.ts +345 -0
  713. package/src/client/navigation-context.ts +15 -7
  714. package/src/client/navigation-root.tsx +355 -0
  715. package/src/client/nuqs-adapter.tsx +16 -3
  716. package/src/client/router-ref.ts +1 -1
  717. package/src/client/router.ts +589 -215
  718. package/src/client/rsc-fetch.ts +251 -34
  719. package/src/client/segment-cache.ts +105 -17
  720. package/src/client/segment-outlet.tsx +141 -0
  721. package/src/client/segment-update-context.ts +42 -0
  722. package/src/client/shallow-url.ts +22 -0
  723. package/src/client/slot-context.ts +50 -0
  724. package/src/client/slot-outlet.tsx +22 -0
  725. package/src/client/slot-provider.tsx +32 -0
  726. package/src/client/ssr-data.ts +13 -5
  727. package/src/client/state.ts +2 -2
  728. package/src/client/top-loader.tsx +11 -9
  729. package/src/client/use-cookie.ts +60 -15
  730. package/src/client/use-link-status.ts +7 -7
  731. package/src/client/use-pathname.ts +1 -0
  732. package/src/client/use-pending-navigation.ts +40 -0
  733. package/src/client/use-query-states.ts +108 -10
  734. package/src/client/use-router.ts +4 -1
  735. package/src/client/use-search-params.ts +31 -44
  736. package/src/client/{use-params.ts → use-segment-params.ts} +9 -6
  737. package/src/codec.ts +149 -0
  738. package/src/config-types.ts +282 -0
  739. package/src/config-validation.ts +330 -0
  740. package/src/content/index.ts +5 -13
  741. package/src/cookies/define-cookie.ts +217 -53
  742. package/src/cookies/index.ts +12 -1
  743. package/src/cookies/json-cookie.ts +105 -0
  744. package/src/cookies/validation.ts +192 -0
  745. package/src/dev-tools/404-page.ts +286 -0
  746. package/src/dev-tools/browser-logs.ts +55 -0
  747. package/src/dev-tools/dev-page-shell.ts +260 -0
  748. package/src/dev-tools/error-page.ts +331 -0
  749. package/src/dev-tools/holding-server.ts +187 -0
  750. package/src/dev-tools/hydration-overlay.ts +158 -0
  751. package/src/dev-tools/index.ts +83 -0
  752. package/src/dev-tools/instrumentation.ts +213 -0
  753. package/src/{server/dev-logger.ts → dev-tools/logger.ts} +33 -51
  754. package/src/{plugins/dev-logs.ts → dev-tools/logs.ts} +122 -26
  755. package/src/dev-tools/overlay.ts +469 -0
  756. package/src/dev-tools/stack-classifier.ts +75 -0
  757. package/src/dev-tools/terminal.ts +182 -0
  758. package/src/fonts/ast-walk.ts +235 -0
  759. package/src/fonts/ast.ts +477 -126
  760. package/src/fonts/bundle.ts +138 -0
  761. package/src/fonts/dev-middleware.ts +85 -0
  762. package/src/fonts/fallbacks.ts +0 -23
  763. package/src/fonts/google.ts +100 -18
  764. package/src/fonts/local.ts +9 -8
  765. package/src/fonts/paths.ts +58 -0
  766. package/src/fonts/pipeline.ts +348 -0
  767. package/src/fonts/transform.ts +311 -0
  768. package/src/fonts/types.ts +52 -1
  769. package/src/fonts/virtual-modules.ts +179 -0
  770. package/src/index.ts +446 -352
  771. package/src/params/codec-registry.ts +34 -0
  772. package/src/params/define-schema.ts +115 -0
  773. package/src/params/index.ts +17 -0
  774. package/src/params/resolve-schema.ts +84 -0
  775. package/src/plugin-context.ts +432 -0
  776. package/src/plugins/adapter-build.ts +220 -7
  777. package/src/plugins/build-manifest.ts +177 -23
  778. package/src/plugins/build-report.ts +253 -35
  779. package/src/plugins/cache.ts +243 -0
  780. package/src/plugins/callsite-ast.ts +472 -0
  781. package/src/plugins/callsite-jsx.ts +243 -0
  782. package/src/plugins/chunks.ts +74 -5
  783. package/src/plugins/client-chunks.ts +185 -0
  784. package/src/plugins/cloudflare-wasm.ts +141 -0
  785. package/src/plugins/content.ts +1 -1
  786. package/src/plugins/dev-server.ts +284 -94
  787. package/src/plugins/entries.ts +134 -16
  788. package/src/plugins/fonts.ts +225 -660
  789. package/src/plugins/mdx.ts +47 -10
  790. package/src/plugins/prebuilt-capture.ts +217 -0
  791. package/src/plugins/prebuilt-options-analysis.ts +175 -0
  792. package/src/plugins/prebuilt.ts +655 -0
  793. package/src/plugins/prerender-sugar.ts +328 -0
  794. package/src/plugins/request-dep.ts +458 -0
  795. package/src/plugins/routing.ts +237 -241
  796. package/src/plugins/server-bundle.ts +89 -12
  797. package/src/plugins/shims.ts +241 -64
  798. package/src/plugins/static-build.ts +15 -90
  799. package/src/routing/codegen-shared.ts +115 -0
  800. package/src/routing/codegen-types.ts +65 -0
  801. package/src/routing/codegen.ts +372 -178
  802. package/src/routing/convention-lint.ts +394 -0
  803. package/src/routing/export-detect.ts +304 -0
  804. package/src/routing/file-cache.ts +23 -0
  805. package/src/routing/index.ts +10 -1
  806. package/src/routing/interception.ts +3 -22
  807. package/src/routing/link-codegen.ts +313 -0
  808. package/src/routing/manifest-codegen.ts +287 -0
  809. package/src/routing/scanner.ts +338 -189
  810. package/src/routing/schema-validation.ts +155 -0
  811. package/src/routing/segment-classify.ts +223 -0
  812. package/src/routing/segment-codegen.ts +98 -0
  813. package/src/routing/types.ts +82 -25
  814. package/src/routing/walkers.ts +90 -0
  815. package/src/rsc-runtime/rsc.ts +9 -0
  816. package/src/rsc-runtime/ssr.ts +50 -0
  817. package/src/rsc-runtime/vendor-types.d.ts +7 -0
  818. package/src/schema-bridge.ts +253 -0
  819. package/src/search-params/define.ts +576 -0
  820. package/src/search-params/index.ts +14 -20
  821. package/src/search-params/registry.ts +2 -2
  822. package/src/search-params/wrappers.ts +101 -0
  823. package/src/segment-params/define.ts +249 -0
  824. package/src/segment-params/index.ts +9 -0
  825. package/src/server/access-gate.tsx +111 -34
  826. package/src/server/action-client.ts +120 -29
  827. package/src/server/action-encryption.ts +144 -0
  828. package/src/server/action-handler.ts +123 -33
  829. package/src/server/actions.ts +48 -54
  830. package/src/server/als-registry.ts +137 -20
  831. package/src/server/asset-headers.ts +15 -37
  832. package/src/server/body-limits.ts +10 -2
  833. package/src/server/build-manifest.ts +19 -56
  834. package/src/server/canonicalize.ts +6 -3
  835. package/src/server/coalesce-tick.ts +75 -0
  836. package/src/server/compress.ts +34 -7
  837. package/src/server/cookie-context.ts +484 -0
  838. package/src/server/cookie-parsing.ts +163 -0
  839. package/src/server/csrf.ts +39 -6
  840. package/src/server/default-logger.ts +99 -0
  841. package/src/server/deny-boundary.ts +314 -0
  842. package/src/server/deny-renderer.ts +85 -77
  843. package/src/server/dev-source-map.ts +31 -0
  844. package/src/server/early-hints-sender.ts +3 -2
  845. package/src/server/early-hints.ts +37 -27
  846. package/src/server/error-boundary-wrapper.ts +61 -22
  847. package/src/server/fallback-error.ts +79 -102
  848. package/src/server/flight-injection-state.ts +113 -0
  849. package/src/server/flight-scripts.ts +62 -0
  850. package/src/server/form-data.ts +124 -12
  851. package/src/server/html-injector-core.ts +495 -0
  852. package/src/server/html-injectors.ts +271 -254
  853. package/src/server/index.ts +31 -185
  854. package/src/server/internal.ts +181 -0
  855. package/src/server/logger.ts +72 -36
  856. package/src/server/metadata-routes.ts +205 -24
  857. package/src/server/metadata.ts +21 -0
  858. package/src/server/middleware-runner.ts +31 -4
  859. package/src/server/node-stream-transforms.ts +336 -0
  860. package/src/server/param-coercion.ts +207 -0
  861. package/src/server/pipeline-helpers.ts +204 -0
  862. package/src/server/pipeline-interception.ts +45 -18
  863. package/src/server/pipeline-metadata.ts +14 -0
  864. package/src/server/pipeline-outcome.ts +197 -0
  865. package/src/server/pipeline-phases.ts +545 -0
  866. package/src/server/pipeline.ts +274 -382
  867. package/src/server/port-resolution.ts +215 -0
  868. package/src/server/prebuilt/cache-key.ts +298 -0
  869. package/src/server/prebuilt/capture-state.ts +89 -0
  870. package/src/server/prebuilt/key-discipline.ts +53 -0
  871. package/src/server/prebuilt/manifest-tag-index.ts +46 -0
  872. package/src/server/prebuilt/overlay.ts +256 -0
  873. package/src/server/prebuilt/payload-source.ts +201 -0
  874. package/src/server/prebuilt/slots.ts +190 -0
  875. package/src/server/prebuilt/synthetic-store.ts +121 -0
  876. package/src/server/prebuilt-builder.ts +809 -0
  877. package/src/server/prebuilt-runtime.ts +815 -0
  878. package/src/server/primitives.ts +160 -83
  879. package/src/server/render-timeout.ts +108 -0
  880. package/src/server/render-utils.ts +31 -0
  881. package/src/server/request-context.ts +170 -337
  882. package/src/server/request-dep.ts +37 -0
  883. package/src/server/route-element-builder.ts +699 -295
  884. package/src/server/route-handler.ts +31 -4
  885. package/src/server/route-matcher.ts +158 -277
  886. package/src/server/rsc-entry/action-middleware-runner.ts +167 -0
  887. package/src/server/rsc-entry/api-handler.ts +69 -32
  888. package/src/server/rsc-entry/deny-fallback.ts +92 -0
  889. package/src/server/rsc-entry/error-renderer.ts +306 -89
  890. package/src/server/rsc-entry/helpers.ts +210 -85
  891. package/src/server/rsc-entry/index.ts +332 -332
  892. package/src/server/rsc-entry/render-route.ts +300 -0
  893. package/src/server/rsc-entry/revalidate-renderer.ts +349 -0
  894. package/src/server/rsc-entry/rsc-payload.ts +102 -42
  895. package/src/server/rsc-entry/rsc-stream.ts +93 -13
  896. package/src/server/rsc-entry/ssr-bridge.ts +18 -5
  897. package/src/server/rsc-entry/ssr-renderer.ts +275 -43
  898. package/src/server/rsc-entry/wrap-action-dispatch.ts +186 -0
  899. package/src/server/safe-load.ts +60 -0
  900. package/src/server/sensitive-fields.ts +230 -0
  901. package/src/server/server-only-guard-noop.js +3 -0
  902. package/src/server/sitemap-generator.ts +345 -0
  903. package/src/server/sitemap-handler.ts +157 -0
  904. package/src/server/slot-resolver.ts +574 -250
  905. package/src/server/ssr-bridge-types.ts +124 -0
  906. package/src/server/ssr-entry.ts +206 -86
  907. package/src/server/ssr-render.ts +345 -86
  908. package/src/server/ssr-wrappers.tsx +141 -0
  909. package/src/server/state-tree-diff.ts +177 -30
  910. package/src/server/status-code-resolver.ts +115 -130
  911. package/src/server/stream-utils.ts +288 -0
  912. package/src/server/tracing.ts +126 -14
  913. package/src/server/tree-builder.ts +214 -90
  914. package/src/server/tree-match.ts +262 -0
  915. package/src/server/types.ts +78 -9
  916. package/src/server/utils/escape-html.ts +20 -0
  917. package/src/server/utils/mdx-file.ts +22 -0
  918. package/src/server/version-skew.ts +104 -0
  919. package/src/server/workers-cache-bridge.ts +33 -0
  920. package/src/shared/href-validation.ts +159 -0
  921. package/src/shared/merge-search-params.ts +55 -0
  922. package/src/shared/redirect-type.ts +17 -0
  923. package/src/shims/font-google.ts +1 -1
  924. package/src/shims/font-local.ts +34 -0
  925. package/src/shims/headers.ts +122 -1
  926. package/src/shims/navigation-client.ts +51 -29
  927. package/src/shims/navigation.ts +14 -7
  928. package/src/utils/state-machine.ts +111 -0
  929. package/dist/_chunks/als-registry-B7DbZ2hS.js +0 -41
  930. package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
  931. package/dist/_chunks/debug-B3Gypr3D.js +0 -108
  932. package/dist/_chunks/debug-B3Gypr3D.js.map +0 -1
  933. package/dist/_chunks/format-RyoGQL74.js +0 -164
  934. package/dist/_chunks/format-RyoGQL74.js.map +0 -1
  935. package/dist/_chunks/interception-BOoWmLUA.js +0 -676
  936. package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
  937. package/dist/_chunks/metadata-routes-Cjmvi3rQ.js +0 -153
  938. package/dist/_chunks/metadata-routes-Cjmvi3rQ.js.map +0 -1
  939. package/dist/_chunks/request-context-BQUC8PHn.js +0 -330
  940. package/dist/_chunks/request-context-BQUC8PHn.js.map +0 -1
  941. package/dist/_chunks/ssr-data-MjmprTmO.js.map +0 -1
  942. package/dist/_chunks/tracing-CemImE6h.js +0 -187
  943. package/dist/_chunks/tracing-CemImE6h.js.map +0 -1
  944. package/dist/_chunks/use-cookie-DX-l1_5E.js +0 -91
  945. package/dist/_chunks/use-cookie-DX-l1_5E.js.map +0 -1
  946. package/dist/_chunks/use-query-states-D5KaffOK.js.map +0 -1
  947. package/dist/adapters/cloudflare.js.map +0 -1
  948. package/dist/cache/index.js.map +0 -1
  949. package/dist/cache/register-cached-function.d.ts +0 -17
  950. package/dist/cache/register-cached-function.d.ts.map +0 -1
  951. package/dist/client/browser-entry.d.ts +0 -21
  952. package/dist/client/browser-entry.d.ts.map +0 -1
  953. package/dist/client/head.d.ts +0 -16
  954. package/dist/client/head.d.ts.map +0 -1
  955. package/dist/client/link-status-provider.d.ts +0 -11
  956. package/dist/client/link-status-provider.d.ts.map +0 -1
  957. package/dist/client/segment-merger.d.ts +0 -119
  958. package/dist/client/segment-merger.d.ts.map +0 -1
  959. package/dist/client/stale-reload.d.ts +0 -44
  960. package/dist/client/stale-reload.d.ts.map +0 -1
  961. package/dist/client/transition-root.d.ts +0 -74
  962. package/dist/client/transition-root.d.ts.map +0 -1
  963. package/dist/client/use-navigation-pending.d.ts +0 -26
  964. package/dist/client/use-navigation-pending.d.ts.map +0 -1
  965. package/dist/client/use-params.d.ts.map +0 -1
  966. package/dist/plugins/cache-transform.d.ts +0 -36
  967. package/dist/plugins/cache-transform.d.ts.map +0 -1
  968. package/dist/plugins/dev-error-overlay.d.ts +0 -60
  969. package/dist/plugins/dev-error-overlay.d.ts.map +0 -1
  970. package/dist/plugins/dev-logs.d.ts.map +0 -1
  971. package/dist/plugins/dynamic-transform.d.ts +0 -72
  972. package/dist/plugins/dynamic-transform.d.ts.map +0 -1
  973. package/dist/plugins/server-action-exports.d.ts +0 -26
  974. package/dist/plugins/server-action-exports.d.ts.map +0 -1
  975. package/dist/routing/status-file-lint.d.ts +0 -33
  976. package/dist/routing/status-file-lint.d.ts.map +0 -1
  977. package/dist/search-params/analyze.d.ts +0 -54
  978. package/dist/search-params/analyze.d.ts.map +0 -1
  979. package/dist/search-params/builtin-codecs.d.ts +0 -105
  980. package/dist/search-params/builtin-codecs.d.ts.map +0 -1
  981. package/dist/search-params/codecs.d.ts +0 -53
  982. package/dist/search-params/codecs.d.ts.map +0 -1
  983. package/dist/search-params/create.d.ts +0 -106
  984. package/dist/search-params/create.d.ts.map +0 -1
  985. package/dist/server/client-module-map.d.ts +0 -47
  986. package/dist/server/client-module-map.d.ts.map +0 -1
  987. package/dist/server/dev-fetch-instrumentation.d.ts +0 -22
  988. package/dist/server/dev-fetch-instrumentation.d.ts.map +0 -1
  989. package/dist/server/dev-logger.d.ts.map +0 -1
  990. package/dist/server/dev-span-processor.d.ts +0 -29
  991. package/dist/server/dev-span-processor.d.ts.map +0 -1
  992. package/dist/server/dev-warnings.d.ts +0 -129
  993. package/dist/server/dev-warnings.d.ts.map +0 -1
  994. package/dist/server/flush.d.ts +0 -74
  995. package/dist/server/flush.d.ts.map +0 -1
  996. package/dist/server/manifest-status-resolver.d.ts +0 -58
  997. package/dist/server/manifest-status-resolver.d.ts.map +0 -1
  998. package/dist/server/prerender.d.ts +0 -77
  999. package/dist/server/prerender.d.ts.map +0 -1
  1000. package/dist/utils/directive-parser.d.ts +0 -70
  1001. package/dist/utils/directive-parser.d.ts.map +0 -1
  1002. package/src/cache/register-cached-function.ts +0 -103
  1003. package/src/client/browser-entry.ts +0 -678
  1004. package/src/client/head.ts +0 -61
  1005. package/src/client/link-status-provider.tsx +0 -30
  1006. package/src/client/segment-merger.ts +0 -339
  1007. package/src/client/stale-reload.ts +0 -87
  1008. package/src/client/transition-root.tsx +0 -166
  1009. package/src/client/use-navigation-pending.ts +0 -38
  1010. package/src/plugins/cache-transform.ts +0 -199
  1011. package/src/plugins/dev-error-overlay.ts +0 -230
  1012. package/src/plugins/dynamic-transform.ts +0 -161
  1013. package/src/plugins/server-action-exports.ts +0 -220
  1014. package/src/routing/status-file-lint.ts +0 -112
  1015. package/src/search-params/analyze.ts +0 -192
  1016. package/src/search-params/builtin-codecs.ts +0 -228
  1017. package/src/search-params/codecs.ts +0 -153
  1018. package/src/search-params/create.ts +0 -321
  1019. package/src/server/client-module-map.ts +0 -58
  1020. package/src/server/dev-fetch-instrumentation.ts +0 -96
  1021. package/src/server/dev-span-processor.ts +0 -78
  1022. package/src/server/dev-warnings.ts +0 -283
  1023. package/src/server/flush.ts +0 -182
  1024. package/src/server/manifest-status-resolver.ts +0 -215
  1025. package/src/server/prerender.ts +0 -139
  1026. package/src/utils/directive-parser.ts +0 -529
@@ -0,0 +1,1202 @@
1
+ import { B as addSpanEventSync, I as getWaitUntil, d as logSwrRefetchFailed, h as swallow } from "./logger-AWfuX-KJ.js";
2
+ import { t as fnv1aHash } from "./fast-hash-D6hIVt1Y.js";
3
+ import { t as estimateByteSize } from "./sizeof-lXffQ1Vr.js";
4
+ import { t as warnLossyJsonValue } from "./json-lossy-check-ClNvBM_3.js";
5
+ //#region src/cache/stable-stringify.ts
6
+ /**
7
+ * Deterministic JSON serialization with sorted object keys.
8
+ * Used for cache key generation — ensures { a: 1, b: 2 } and { b: 2, a: 1 }
9
+ * produce the same string.
10
+ *
11
+ * Matches JSON.stringify semantics for toJSON: Date serializes to its ISO
12
+ * string, URL to its href, and class instances with a custom toJSON use it.
13
+ * Map and Set serialize their entries explicitly (insertion-order
14
+ * independent). Values that would serialize lossily — functions, symbols,
15
+ * and non-plain objects with no enumerable own state (RegExp, class
16
+ * instances holding data behind getters or internal slots) — throw instead:
17
+ * every such value would collapse to the same cache key, silently returning
18
+ * one argument's cached data for another (TIM-1020).
19
+ */
20
+ function stableStringify(value) {
21
+ if (value === null || value === void 0) return String(value);
22
+ const type = typeof value;
23
+ if (type === "function" || type === "symbol") throw new TypeError(`stableStringify: cannot serialize a ${type} into a stable cache key — all such values would collide. Provide an explicit \`key\` option to cache().`);
24
+ if (type !== "object") return JSON.stringify(value);
25
+ if (Array.isArray(value)) return "[" + value.map((item) => stableStringify(item)).join(",") + "]";
26
+ const withToJSON = value;
27
+ if (typeof withToJSON.toJSON === "function") {
28
+ const json = withToJSON.toJSON();
29
+ if (json !== value) return stableStringify(json);
30
+ }
31
+ if (value instanceof Map) return "Map(" + [...value.entries()].map(([k, v]) => stableStringify(k) + "=>" + stableStringify(v)).sort().join(",") + ")";
32
+ if (value instanceof Set) return "Set(" + [...value].map((member) => stableStringify(member)).sort().join(",") + ")";
33
+ const obj = value;
34
+ const keys = Object.keys(obj).sort();
35
+ const pairs = [];
36
+ for (const key of keys) {
37
+ if (obj[key] === void 0) continue;
38
+ if (key === "toJSON" && typeof obj[key] === "function") continue;
39
+ pairs.push(JSON.stringify(key) + ":" + stableStringify(obj[key]));
40
+ }
41
+ if (pairs.length === 0) {
42
+ const proto = Object.getPrototypeOf(value);
43
+ if (proto !== Object.prototype && proto !== null) {
44
+ const name = value.constructor?.name || "Object";
45
+ throw new TypeError(`stableStringify: ${name} instance has no serializable own state — all instances would share one cache key. Provide an explicit \`key\` option to cache(), or add a toJSON() method.`);
46
+ }
47
+ }
48
+ return "{" + pairs.join(",") + "}";
49
+ }
50
+ //#endregion
51
+ //#region src/cache/singleflight.ts
52
+ /**
53
+ * Error thrown when a singleflight call exceeds `timeoutMs`.
54
+ * Exported so callers can distinguish timeout from other errors.
55
+ */
56
+ var SingleflightTimeoutError = class extends Error {
57
+ constructor(key, timeoutMs) {
58
+ super(`Singleflight timeout: key "${key}" exceeded ${timeoutMs}ms`);
59
+ this.name = "SingleflightTimeoutError";
60
+ }
61
+ };
62
+ function createSingleflight(opts) {
63
+ const inflight = /* @__PURE__ */ new Map();
64
+ const timeoutMs = opts?.timeoutMs;
65
+ return { do(key, fn) {
66
+ const existing = inflight.get(key);
67
+ if (existing) return existing;
68
+ const ac = new AbortController();
69
+ let promise;
70
+ if (timeoutMs != null && timeoutMs > 0) promise = new Promise((resolve, reject) => {
71
+ const timer = setTimeout(() => {
72
+ ac.abort();
73
+ reject(new SingleflightTimeoutError(key, timeoutMs));
74
+ }, timeoutMs);
75
+ try {
76
+ fn(ac.signal).then((value) => {
77
+ clearTimeout(timer);
78
+ resolve(value);
79
+ }, (err) => {
80
+ clearTimeout(timer);
81
+ reject(err);
82
+ });
83
+ } catch (err) {
84
+ clearTimeout(timer);
85
+ reject(err);
86
+ }
87
+ });
88
+ else promise = fn(ac.signal);
89
+ const tracked = promise.finally(() => {
90
+ inflight.delete(key);
91
+ });
92
+ inflight.set(key, tracked);
93
+ return tracked;
94
+ } };
95
+ }
96
+ //#endregion
97
+ //#region src/cache/invalidation-epoch.ts
98
+ /**
99
+ * Per-process invalidation epoch tracking for timber.cache (TIM-1028).
100
+ *
101
+ * handler.set for a cache miss runs after `fn()` resolves. An explicit
102
+ * `cache.invalidate({ tag })` / `revalidateTag` that lands while fn is in
103
+ * flight would otherwise be silently undone — the just-invalidated value
104
+ * re-stored as fresh for the full TTL, resurrecting pre-mutation data.
105
+ *
106
+ * Every invalidation bumps a monotonic epoch and records it against the
107
+ * invalidated key/tag. Before storing a result, the cache wrapper checks
108
+ * whether its key or any of its tags were invalidated after fn started and
109
+ * skips the write if so. Skipping is always safe: the only cost is one
110
+ * extra cache miss on the next call.
111
+ *
112
+ * Scope: per-process, like the singleflight map. An invalidation issued by
113
+ * another instance against a shared handler (Redis/KV) during fn flight is
114
+ * not observable here — closing that window fully would require store-level
115
+ * versioning, which no CacheHandler backend offers.
116
+ */
117
+ var epoch = 0;
118
+ /**
119
+ * Last-invalidated epoch per `key:<k>` / `tag:<t>` entry. Insertion order is
120
+ * epoch order (entries are re-inserted on update), so the oldest entry is
121
+ * always first — pruning evicts lowest epochs.
122
+ */
123
+ var lastInvalidated = /* @__PURE__ */ new Map();
124
+ /**
125
+ * Bound on tracked entries so high-cardinality tag invalidation (e.g.
126
+ * per-user tags) cannot grow this map without limit.
127
+ */
128
+ var MAX_TRACKED_ENTRIES = 1e4;
129
+ /**
130
+ * Highest epoch evicted from the map. Any execution that started at or
131
+ * before this epoch conservatively counts as invalidated — history was
132
+ * truncated, so we can no longer prove it wasn't.
133
+ */
134
+ var evictedEpochFloor = 0;
135
+ /** The current epoch. Capture before running fn(), pass to wasInvalidatedSince. */
136
+ function currentInvalidationEpoch() {
137
+ return epoch;
138
+ }
139
+ /**
140
+ * Record an invalidation. Call BEFORE handler.invalidate() so an execution
141
+ * whose set-check races the invalidation errs toward skipping the write.
142
+ */
143
+ function recordInvalidation(opts) {
144
+ epoch++;
145
+ if (opts.key) track(`key:${opts.key}`);
146
+ if (opts.tag) track(`tag:${opts.tag}`);
147
+ }
148
+ function track(entry) {
149
+ lastInvalidated.delete(entry);
150
+ lastInvalidated.set(entry, epoch);
151
+ while (lastInvalidated.size > MAX_TRACKED_ENTRIES) {
152
+ const oldest = lastInvalidated.entries().next().value;
153
+ if (oldest === void 0) break;
154
+ evictedEpochFloor = Math.max(evictedEpochFloor, oldest[1]);
155
+ lastInvalidated.delete(oldest[0]);
156
+ }
157
+ }
158
+ /**
159
+ * Whether the key or any tag was invalidated after `startEpoch` (the epoch
160
+ * captured when fn started executing).
161
+ */
162
+ function wasInvalidatedSince(startEpoch, key, tags) {
163
+ return lastInvalidationEpochFor(key, tags) > startEpoch;
164
+ }
165
+ /**
166
+ * The highest epoch at which the key or any of the tags was invalidated
167
+ * (0 if never). Used to scope the singleflight key: callers arriving after
168
+ * an invalidation must not coalesce onto a flight that started before it —
169
+ * they would receive the pre-invalidation result the invalidation was
170
+ * issued to discard.
171
+ */
172
+ function lastInvalidationEpochFor(key, tags) {
173
+ let last = evictedEpochFloor;
174
+ const keyEpoch = lastInvalidated.get(`key:${key}`);
175
+ if (keyEpoch !== void 0 && keyEpoch > last) last = keyEpoch;
176
+ for (const tag of tags) {
177
+ const tagEpoch = lastInvalidated.get(`tag:${tag}`);
178
+ if (tagEpoch !== void 0 && tagEpoch > last) last = tagEpoch;
179
+ }
180
+ return last;
181
+ }
182
+ //#endregion
183
+ //#region src/cache/timber-cache.ts
184
+ var defaultSingleflight = createSingleflight();
185
+ /**
186
+ * Per-key monotonic generation counter for CAS writes (TIM-1158).
187
+ *
188
+ * Unbounded, like the singleflight map — the key space is the same set of
189
+ * cache keys the handler already tracks. Pruning was removed because it
190
+ * desyncs from MemoryCacheHandler.generations: a pruned key restarts at 1
191
+ * while the handler still holds the old higher generation, causing fresh
192
+ * writes to be rejected as stale.
193
+ */
194
+ var writeGenerations = /* @__PURE__ */ new Map();
195
+ function nextGeneration(key) {
196
+ const gen = (writeGenerations.get(key) ?? 0) + 1;
197
+ writeGenerations.set(key, gen);
198
+ return gen;
199
+ }
200
+ /**
201
+ * Set the timeout for the module-level default singleflight.
202
+ * Called at framework boot with renderTimeoutMs from timber.config.ts so that
203
+ * cache calls without a per-call timeoutMs still get deadlock protection.
204
+ * See design/06-caching.md §"Singleflight Timeout — Deadlock Risk".
205
+ */
206
+ function setDefaultSingleflightTimeout(timeoutMs) {
207
+ defaultSingleflight = createSingleflight({ timeoutMs });
208
+ }
209
+ /**
210
+ * Generate a cache key from function identity and serialized args.
211
+ *
212
+ * Uses FNV-1a (fast non-crypto hash) instead of SHA-256. Cache keys don't
213
+ * need collision resistance — they need speed. The fnId prefix provides
214
+ * namespace isolation; the hash covers the args.
215
+ *
216
+ * See TIM-370 for perf motivation.
217
+ */
218
+ function defaultKeyGenerator(fnId, args) {
219
+ const raw = fnId + ":" + stableStringify(args);
220
+ return fnId + ":" + fnv1aHash(raw);
221
+ }
222
+ /**
223
+ * Resolve tags from the options — supports static array or function form.
224
+ */
225
+ function resolveTags(opts, args) {
226
+ if (!opts.tags) return [];
227
+ if (Array.isArray(opts.tags)) return opts.tags;
228
+ return opts.tags(...args);
229
+ }
230
+ /** Per-process count of byte-identical fn sources seen by deriveFallbackFnId. */
231
+ var fallbackIdOccurrences = /* @__PURE__ */ new Map();
232
+ var hasWarnedFallbackId = false;
233
+ /**
234
+ * Derive a fallback fnId for callsites the timber-cache-transform Vite plugin
235
+ * could not statically detect (aliased bindings, user re-export wrappers).
236
+ *
237
+ * The base is fnv1a(fn.toString()) — deterministic across instances and cold
238
+ * starts of the same build, so two *different* functions can never swap fnIds
239
+ * by module-evaluation order (the TIM-997 poisoning scenario that the old
240
+ * process-local counter allowed; see TIM-1054). A per-process occurrence
241
+ * suffix disambiguates byte-identical duplicate sources. That residue is the
242
+ * one remaining hazard: closures produced by the same factory share source
243
+ * text but capture different values, and their occurrence order may differ
244
+ * across instances — such callsites need an explicit `key` option.
245
+ */
246
+ function deriveFallbackFnId(fn) {
247
+ const sourceHash = fnv1aHash(fn.toString());
248
+ const occurrence = fallbackIdOccurrences.get(sourceHash) ?? 0;
249
+ fallbackIdOccurrences.set(sourceHash, occurrence + 1);
250
+ if (!hasWarnedFallbackId && typeof process !== "undefined" && process.env.NODE_ENV !== "test") {
251
+ hasWarnedFallbackId = true;
252
+ console.warn("[timber] cache() callsite has no build-time stable ID and no explicit `key` option — the call is not statically visible to the timber Vite plugin (e.g. an aliased binding like `const c = cache` or a re-export wrapper module). Falling back to a function-source hash for the cache key. With a shared CacheHandler (Redis/KV) this is safe for distinct functions, but byte-identical closures from a factory can swap cache entries across instances. Provide an explicit `key` option to make the cache key contract stable and auditable.");
253
+ }
254
+ return `timber-cache:fn:${sourceHash}:${occurrence}`;
255
+ }
256
+ /**
257
+ * Creates a cached wrapper around an async function.
258
+ *
259
+ * - FNV-1a default keys with normalized JSON args
260
+ * - Singleflight: concurrent misses → single execution AND single
261
+ * handler.set — the write happens inside the coalesced callback (TIM-1028)
262
+ * - Writes are skipped when the key/tags were invalidated while fn was in
263
+ * flight, so explicit invalidation is never silently undone (TIM-1028)
264
+ * - SWR: serve stale immediately, background refetch
265
+ * - Tags as string[] or function of args
266
+ * - The handler is resolved per invocation via `getHandler`, never captured
267
+ * at wrapper-creation time — module-scope cache() wrappers created before
268
+ * the framework's boot wiring calls setCacheHandler() still use the
269
+ * configured handler once it arrives (TIM-1029)
270
+ * - No ALS dependency for correctness — cache() works outside a request
271
+ * context. The waitUntil ALS bridge is read optionally so the SWR
272
+ * background refetch survives handler return on Workers/Lambda.
273
+ *
274
+ * Cache hits/misses are recorded as OTEL span events on the enclosing
275
+ * span (not child spans). The DevSpanProcessor reads these for dev log output.
276
+ */
277
+ function createCache(fn, opts, getHandler, stableId) {
278
+ const fnId = stableId ?? (opts.key ? void 0 : deriveFallbackFnId(fn));
279
+ const perCallSf = opts.timeoutMs !== void 0 ? createSingleflight({ timeoutMs: opts.timeoutMs }) : void 0;
280
+ return (async (...args) => {
281
+ const sf = perCallSf ?? defaultSingleflight;
282
+ const key = opts.key ? opts.key(...args) : defaultKeyGenerator(fnId, args);
283
+ const cacheStart = performance.now();
284
+ const cached = await getHandler().get(key);
285
+ if (cached && !cached.stale) {
286
+ addSpanEventSync("timber.cache.hit", {
287
+ key,
288
+ duration_ms: Math.round(performance.now() - cacheStart)
289
+ });
290
+ return cached.value;
291
+ }
292
+ const tags = resolveTags(opts, args);
293
+ const flightKey = `${key}\u0000${lastInvalidationEpochFor(key, tags)}`;
294
+ /**
295
+ * Run fn and store the result — exactly once per coalesced execution,
296
+ * inside the singleflight callback. The write is skipped when:
297
+ * - the key/tags were invalidated after fn started (TIM-1028), or
298
+ * - the singleflight timed out (signal aborted) — the timed-out
299
+ * flight's write could overwrite a newer value from a subsequent
300
+ * flight (TIM-1092), or
301
+ * - the handler rejects the write because a newer generation has
302
+ * already been stored (TIM-1158 CAS guard).
303
+ */
304
+ const executeAndStore = async (signal) => {
305
+ const startEpoch = currentInvalidationEpoch();
306
+ const generation = nextGeneration(key);
307
+ const result = await fn(...args);
308
+ if (!signal.aborted && !wasInvalidatedSince(startEpoch, key, tags)) try {
309
+ await getHandler().set(key, result, {
310
+ ttl: opts.ttl,
311
+ tags,
312
+ generation
313
+ });
314
+ } catch (err) {
315
+ swallow(err, `cache set failed for key "${key}"`);
316
+ }
317
+ return result;
318
+ };
319
+ if (cached && cached.stale && opts.staleWhileRevalidate) {
320
+ addSpanEventSync("timber.cache.hit", {
321
+ key,
322
+ duration_ms: Math.round(performance.now() - cacheStart),
323
+ stale: true
324
+ });
325
+ const refetch = sf.do(`swr:${flightKey}`, async (signal) => {
326
+ try {
327
+ await executeAndStore(signal);
328
+ } catch (err) {
329
+ logSwrRefetchFailed({
330
+ cacheKey: key,
331
+ error: err
332
+ });
333
+ }
334
+ }).catch(() => {});
335
+ getWaitUntil()?.(refetch);
336
+ return cached.value;
337
+ }
338
+ const result = await sf.do(flightKey, executeAndStore);
339
+ addSpanEventSync("timber.cache.miss", {
340
+ key,
341
+ duration_ms: Math.round(performance.now() - cacheStart)
342
+ });
343
+ return result;
344
+ });
345
+ }
346
+ //#endregion
347
+ //#region src/cache/handler-store.ts
348
+ var handler$1 = null;
349
+ var explicitlyConfigured = false;
350
+ /** Replace the active cache handler. Called by the framework at boot. */
351
+ function setCacheHandler(h) {
352
+ handler$1 = h;
353
+ explicitlyConfigured = true;
354
+ }
355
+ /** Whether the handler was explicitly configured (vs the default in-memory fallback). */
356
+ function isCacheHandlerConfigured() {
357
+ return explicitlyConfigured;
358
+ }
359
+ /**
360
+ * Get the active cache handler. Creates a default MemoryCacheHandler on
361
+ * first access if none has been set via setCacheHandler().
362
+ */
363
+ function getCacheHandler() {
364
+ if (!handler$1) handler$1 = createDefaultHandler();
365
+ return handler$1;
366
+ }
367
+ function createDefaultHandler() {
368
+ const store = /* @__PURE__ */ new Map();
369
+ const maxEntries = 1e3;
370
+ return {
371
+ async get(key) {
372
+ const entry = store.get(key);
373
+ if (!entry) return null;
374
+ store.delete(key);
375
+ store.set(key, entry);
376
+ const stale = Date.now() > entry.expiresAt;
377
+ return {
378
+ value: entry.value,
379
+ stale
380
+ };
381
+ },
382
+ async set(key, value, opts) {
383
+ if (store.has(key)) store.delete(key);
384
+ while (store.size >= maxEntries) {
385
+ const oldest = store.keys().next().value;
386
+ if (oldest !== void 0) store.delete(oldest);
387
+ else break;
388
+ }
389
+ store.set(key, {
390
+ value,
391
+ expiresAt: Date.now() + opts.ttl * 1e3,
392
+ tags: opts.tags
393
+ });
394
+ },
395
+ async invalidate(opts) {
396
+ if (opts.key) store.delete(opts.key);
397
+ if (opts.tag) {
398
+ for (const [key, entry] of store) if (entry.tags.includes(opts.tag)) store.delete(key);
399
+ }
400
+ }
401
+ };
402
+ }
403
+ //#endregion
404
+ //#region src/cache/redis-handler.ts
405
+ var KEY_PREFIX = "timber:cache:";
406
+ var TAG_PREFIX = "timber:tag:";
407
+ /**
408
+ * Redis-backed CacheHandler for distributed caching.
409
+ *
410
+ * All instances sharing the same Redis see each other's cache entries and
411
+ * invalidations. Tag-based invalidation uses Redis Sets to track which keys
412
+ * belong to which tags.
413
+ *
414
+ * Bring your own Redis client wrapped to the {@link RedisClient} contract —
415
+ * see the adapter examples on the interface for ioredis, node-redis v4, and
416
+ * @upstash/redis.
417
+ */
418
+ var RedisCacheHandler = class {
419
+ client;
420
+ prefix;
421
+ constructor(client, opts) {
422
+ this.client = client;
423
+ this.prefix = opts?.prefix ?? "";
424
+ }
425
+ cacheKey(key) {
426
+ return `${this.prefix}${KEY_PREFIX}${key}`;
427
+ }
428
+ tagKey(tag) {
429
+ return `${this.prefix}${TAG_PREFIX}${tag}`;
430
+ }
431
+ async get(key) {
432
+ const raw = await this.client.get(this.cacheKey(key));
433
+ if (raw === null) return null;
434
+ const entry = JSON.parse(raw);
435
+ const stale = Date.now() > entry.expiresAt;
436
+ return {
437
+ value: entry.value,
438
+ stale
439
+ };
440
+ }
441
+ async set(key, value, opts) {
442
+ warnLossyJsonValue(value, key);
443
+ const ck = this.cacheKey(key);
444
+ const expiresAt = Date.now() + opts.ttl * 1e3;
445
+ const payload = JSON.stringify({
446
+ value,
447
+ expiresAt,
448
+ tags: opts.tags
449
+ });
450
+ const redisTtlSeconds = Math.max(opts.ttl * 2 + 60, 120);
451
+ const writeOps = [];
452
+ for (const tag of opts.tags) {
453
+ writeOps.push({
454
+ op: "sadd",
455
+ key: this.tagKey(tag),
456
+ members: [key]
457
+ });
458
+ writeOps.push({
459
+ op: "expireNX",
460
+ key: this.tagKey(tag),
461
+ seconds: redisTtlSeconds
462
+ });
463
+ writeOps.push({
464
+ op: "expireGT",
465
+ key: this.tagKey(tag),
466
+ seconds: redisTtlSeconds
467
+ });
468
+ }
469
+ writeOps.push({
470
+ op: "set",
471
+ key: ck,
472
+ value: payload,
473
+ ttlSeconds: redisTtlSeconds
474
+ });
475
+ if (this.client.execMulti) await this.client.execMulti(writeOps);
476
+ else for (const op of writeOps) await this.execOp(op);
477
+ }
478
+ async execOp(op) {
479
+ switch (op.op) {
480
+ case "set":
481
+ await this.client.set(op.key, op.value, op.ttlSeconds);
482
+ break;
483
+ case "sadd":
484
+ await this.client.sadd(op.key, ...op.members);
485
+ break;
486
+ case "expireNX":
487
+ await this.client.expireNX(op.key, op.seconds);
488
+ break;
489
+ case "expireGT":
490
+ await this.client.expireGT(op.key, op.seconds);
491
+ break;
492
+ case "del":
493
+ await this.client.del(op.key);
494
+ break;
495
+ }
496
+ }
497
+ async invalidate(opts) {
498
+ if (opts.key) {
499
+ const raw = await this.client.get(this.cacheKey(opts.key));
500
+ if (raw !== null) {
501
+ const entry = JSON.parse(raw);
502
+ if (entry.tags) await Promise.all(entry.tags.map((tag) => this.client.srem(this.tagKey(tag), opts.key)));
503
+ }
504
+ await this.client.del(this.cacheKey(opts.key));
505
+ }
506
+ if (opts.tag) {
507
+ const tk = this.tagKey(opts.tag);
508
+ const keys = await this.client.smembers(tk);
509
+ await Promise.all(keys.map(async (k) => {
510
+ const raw = await this.client.get(this.cacheKey(k));
511
+ if (raw === null) {
512
+ await this.client.srem(tk, k);
513
+ return;
514
+ }
515
+ if (JSON.parse(raw).tags?.includes(opts.tag)) await this.client.del(this.cacheKey(k));
516
+ await this.client.srem(tk, k);
517
+ }));
518
+ if ((await this.client.smembers(tk)).length === 0) await this.client.del(tk);
519
+ }
520
+ }
521
+ };
522
+ //#endregion
523
+ //#region src/cache/tag-aware-handler.ts
524
+ var DATA_PREFIX = "d:";
525
+ var TAG_SET_PREFIX = "ts:";
526
+ var TAG_VERSION_PREFIX = "tv:";
527
+ function detectStrategy(store) {
528
+ if (store.setWithTags && store.invalidateTag) return "native";
529
+ if (store.sadd && store.smembers && store.srem && store.sdel) return "eager";
530
+ return "lazy";
531
+ }
532
+ var TagAwareCacheHandler = class {
533
+ store;
534
+ prefix;
535
+ strategy;
536
+ constructor(store, opts) {
537
+ this.store = store;
538
+ this.prefix = opts?.prefix ?? "timber:";
539
+ this.strategy = detectStrategy(store);
540
+ }
541
+ get consistency() {
542
+ return this.store.consistency;
543
+ }
544
+ dataKey(key) {
545
+ return `${this.prefix}${DATA_PREFIX}${key}`;
546
+ }
547
+ /** Namespace tags for native stores so prefix isolates shared stores. */
548
+ prefixTags(tags) {
549
+ return tags.map((t) => `${this.prefix}${t}`);
550
+ }
551
+ tagSetKey(tag) {
552
+ return `${this.prefix}${TAG_SET_PREFIX}${tag}`;
553
+ }
554
+ tagVersionKey(tag) {
555
+ return `${this.prefix}${TAG_VERSION_PREFIX}${tag}`;
556
+ }
557
+ async get(key) {
558
+ const raw = await this.store.get(this.dataKey(key));
559
+ if (raw === null) return null;
560
+ if (this.strategy === "native" || this.strategy === "eager") {
561
+ const entry = JSON.parse(raw);
562
+ const stale = Date.now() > entry.expiresAt;
563
+ return {
564
+ value: entry.value,
565
+ stale
566
+ };
567
+ }
568
+ const entry = JSON.parse(raw);
569
+ if (entry.tags.length > 0) {
570
+ const currentVersions = await this.getTagVersions(entry.tags);
571
+ for (const tag of entry.tags) {
572
+ const stored = entry.tagVersions[tag] ?? 0;
573
+ if ((currentVersions[tag] ?? 0) > stored) return null;
574
+ }
575
+ }
576
+ const stale = Date.now() > entry.expiresAt;
577
+ return {
578
+ value: entry.value,
579
+ stale
580
+ };
581
+ }
582
+ async set(key, value, opts) {
583
+ const physicalTtl = Math.max(opts.ttl * 2 + 60, 120);
584
+ if (this.strategy === "native") {
585
+ const entry = {
586
+ value,
587
+ expiresAt: Date.now() + opts.ttl * 1e3,
588
+ tags: opts.tags
589
+ };
590
+ const payload = JSON.stringify(entry);
591
+ if (opts.tags.length > 0) await this.store.setWithTags(this.dataKey(key), payload, physicalTtl, this.prefixTags(opts.tags));
592
+ else await this.store.set(this.dataKey(key), payload, physicalTtl);
593
+ return;
594
+ }
595
+ if (this.strategy === "eager") {
596
+ const entry = {
597
+ value,
598
+ expiresAt: Date.now() + opts.ttl * 1e3,
599
+ tags: opts.tags
600
+ };
601
+ await this.store.set(this.dataKey(key), JSON.stringify(entry), physicalTtl);
602
+ if (opts.tags.length > 0) await Promise.all(opts.tags.map((tag) => this.store.sadd(this.tagSetKey(tag), [key], physicalTtl)));
603
+ return;
604
+ }
605
+ const tagVersions = opts.tags.length > 0 ? await this.getTagVersions(opts.tags) : {};
606
+ const entry = {
607
+ value,
608
+ expiresAt: Date.now() + opts.ttl * 1e3,
609
+ tags: opts.tags,
610
+ tagVersions
611
+ };
612
+ await this.store.set(this.dataKey(key), JSON.stringify(entry), physicalTtl);
613
+ }
614
+ async invalidate(opts) {
615
+ if (opts.key) {
616
+ if (this.strategy === "eager") {
617
+ const raw = await this.store.get(this.dataKey(opts.key));
618
+ if (raw !== null) {
619
+ const entry = JSON.parse(raw);
620
+ if (entry.tags.length > 0) await Promise.all(entry.tags.map((tag) => this.store.srem(this.tagSetKey(tag), [opts.key])));
621
+ }
622
+ }
623
+ await this.store.del(this.dataKey(opts.key));
624
+ }
625
+ if (opts.tag) {
626
+ const tag = opts.tag;
627
+ if (this.strategy === "native") await this.store.invalidateTag(`${this.prefix}${tag}`);
628
+ else if (this.strategy === "eager") {
629
+ const members = await this.store.smembers(this.tagSetKey(tag));
630
+ await Promise.all(members.map(async (k) => {
631
+ const raw = await this.store.get(this.dataKey(k));
632
+ if (raw === null) {
633
+ await this.store.srem(this.tagSetKey(tag), [k]);
634
+ return;
635
+ }
636
+ if (JSON.parse(raw).tags.includes(tag)) {
637
+ await this.store.del(this.dataKey(k));
638
+ await this.store.srem(this.tagSetKey(tag), [k]);
639
+ } else await this.store.srem(this.tagSetKey(tag), [k]);
640
+ }));
641
+ } else await this.bumpTagVersion(opts.tag);
642
+ }
643
+ }
644
+ async getTagVersions(tags) {
645
+ const versions = {};
646
+ await Promise.all(tags.map(async (tag) => {
647
+ const raw = await this.store.get(this.tagVersionKey(tag));
648
+ versions[tag] = raw !== null ? parseInt(raw, 10) : 0;
649
+ }));
650
+ return versions;
651
+ }
652
+ async bumpTagVersion(tag) {
653
+ const key = this.tagVersionKey(tag);
654
+ const raw = await this.store.get(key);
655
+ const version = Math.max(raw !== null ? parseInt(raw, 10) : 0, Date.now()) + 1;
656
+ await this.store.set(key, String(version), 365 * 86400);
657
+ }
658
+ };
659
+ //#endregion
660
+ //#region src/cache/index.ts
661
+ var MemoryCacheHandler = class {
662
+ store = /* @__PURE__ */ new Map();
663
+ generations = /* @__PURE__ */ new Map();
664
+ maxEntries;
665
+ maxBytes;
666
+ maxEntryBytes;
667
+ currentBytes = 0;
668
+ _trackBytes;
669
+ constructor(opts) {
670
+ this.maxEntries = opts?.maxEntries ?? opts?.maxSize ?? 1e3;
671
+ this.maxBytes = opts?.maxBytes;
672
+ this.maxEntryBytes = opts?.maxEntryBytes;
673
+ this._trackBytes = this.maxBytes !== void 0 || this.maxEntryBytes !== void 0;
674
+ }
675
+ async get(key) {
676
+ const entry = this.store.get(key);
677
+ if (!entry) return null;
678
+ this.store.delete(key);
679
+ this.store.set(key, entry);
680
+ const stale = Date.now() > entry.expiresAt;
681
+ return {
682
+ value: entry.value,
683
+ stale
684
+ };
685
+ }
686
+ async set(key, value, opts) {
687
+ if (opts.generation !== void 0) {
688
+ const current = this.generations.get(key) ?? 0;
689
+ if (opts.generation < current) return;
690
+ }
691
+ const byteSize = this._trackBytes ? estimateByteSize(value) : 0;
692
+ if (this.maxEntryBytes !== void 0 && byteSize > this.maxEntryBytes) return;
693
+ if (this.store.has(key)) {
694
+ const existing = this.store.get(key);
695
+ this.currentBytes -= existing.byteSize;
696
+ this.store.delete(key);
697
+ }
698
+ while (this.store.size >= this.maxEntries) this.evictOldest();
699
+ if (this.maxBytes !== void 0) {
700
+ while (this.currentBytes + byteSize > this.maxBytes && this.store.size > 0) this.evictOldest();
701
+ if (this.currentBytes + byteSize > this.maxBytes) return;
702
+ }
703
+ if (opts.generation !== void 0) this.generations.set(key, opts.generation);
704
+ this.store.set(key, {
705
+ value,
706
+ expiresAt: Date.now() + opts.ttl * 1e3,
707
+ tags: opts.tags,
708
+ byteSize
709
+ });
710
+ this.currentBytes += byteSize;
711
+ }
712
+ async invalidate(opts) {
713
+ if (opts.key) {
714
+ const entry = this.store.get(opts.key);
715
+ if (entry) {
716
+ this.currentBytes -= entry.byteSize;
717
+ this.store.delete(opts.key);
718
+ }
719
+ this.generations.delete(opts.key);
720
+ }
721
+ if (opts.tag) {
722
+ for (const [key, entry] of this.store) if (entry.tags.includes(opts.tag)) {
723
+ this.currentBytes -= entry.byteSize;
724
+ this.store.delete(key);
725
+ this.generations.delete(key);
726
+ }
727
+ }
728
+ }
729
+ /** Number of entries currently in the cache. */
730
+ get size() {
731
+ return this.store.size;
732
+ }
733
+ /** Estimated total byte size of all cached values. Only tracked when maxBytes or maxEntryBytes is configured; returns 0 otherwise. */
734
+ get bytes() {
735
+ return this.currentBytes;
736
+ }
737
+ /** Evict the oldest entry (front of Map). */
738
+ evictOldest() {
739
+ const oldest = this.store.keys().next().value;
740
+ if (oldest !== void 0) {
741
+ const entry = this.store.get(oldest);
742
+ this.currentBytes -= entry.byteSize;
743
+ this.store.delete(oldest);
744
+ this.generations.delete(oldest);
745
+ }
746
+ }
747
+ };
748
+ //#endregion
749
+ //#region src/server/version-skew.ts
750
+ /**
751
+ * Version Skew Detection — graceful recovery when stale clients hit new deployments.
752
+ *
753
+ * When a new version of the app is deployed, clients with open tabs still have
754
+ * the old JavaScript bundle. Without version skew handling, these stale clients
755
+ * will experience:
756
+ *
757
+ * 1. Server action calls that crash (action IDs are content-hashed)
758
+ * 2. Chunk load failures (old filenames gone from CDN)
759
+ * 3. RSC payload mismatches (component references differ between builds)
760
+ *
761
+ * This module implements deployment ID comparison:
762
+ * - A per-build deployment ID is generated at build time (see build-manifest.ts)
763
+ * - The client sends it via `X-Timber-Deployment-Id` header on every RSC/action request
764
+ * - The server compares it against the current build's ID
765
+ * - On mismatch: signal the client to reload (not crash)
766
+ *
767
+ * The deployment ID is always-on in production. Dev mode skips the check
768
+ * (HMR handles code updates without full reloads).
769
+ *
770
+ * See design/25-production-deployments.md, TIM-446
771
+ */
772
+ /** Header sent by the client with every RSC/action request. */
773
+ var DEPLOYMENT_ID_HEADER = "X-Timber-Deployment-Id";
774
+ /** Response header that signals the client to do a full page reload. */
775
+ var RELOAD_HEADER = "X-Timber-Reload";
776
+ /**
777
+ * The current build's deployment ID. Set at startup from the manifest init
778
+ * module (globalThis.__TIMBER_DEPLOYMENT_ID__). Null in dev mode.
779
+ */
780
+ var currentDeploymentId = null;
781
+ /**
782
+ * Get the current deployment ID. Returns null in dev mode.
783
+ */
784
+ function getDeploymentId() {
785
+ return currentDeploymentId;
786
+ }
787
+ /**
788
+ * Check if a request's deployment ID matches the current build.
789
+ *
790
+ * Returns `{ ok: true }` when:
791
+ * - Dev mode (no deployment ID set — HMR handles updates)
792
+ * - No deployment ID header (initial page load, non-RSC request)
793
+ * - Deployment IDs match
794
+ *
795
+ * Returns `{ ok: false }` when:
796
+ * - Client sends a deployment ID that differs from the current build
797
+ */
798
+ function checkVersionSkew(req) {
799
+ if (!currentDeploymentId) return {
800
+ ok: true,
801
+ clientId: null
802
+ };
803
+ const clientId = req.headers.get(DEPLOYMENT_ID_HEADER);
804
+ if (!clientId) return {
805
+ ok: true,
806
+ clientId: null
807
+ };
808
+ if (clientId === currentDeploymentId) return {
809
+ ok: true,
810
+ clientId
811
+ };
812
+ return {
813
+ ok: false,
814
+ clientId
815
+ };
816
+ }
817
+ /**
818
+ * Apply version skew reload headers to a response.
819
+ * Sets X-Timber-Reload: 1 to signal the client to do a full page reload.
820
+ */
821
+ function applyReloadHeaders(headers) {
822
+ headers.set(RELOAD_HEADER, "1");
823
+ }
824
+ //#endregion
825
+ //#region src/server/prebuilt/manifest-tag-index.ts
826
+ /**
827
+ * Build the inverted tag → seed key index from the manifest.
828
+ *
829
+ * Returns a Map where each tag maps to the set of (componentId, cacheKey)
830
+ * pairs whose manifest entries carry that tag. Only entries with non-empty
831
+ * `tags` arrays participate.
832
+ */
833
+ function buildTagIndex(manifest) {
834
+ const index = /* @__PURE__ */ new Map();
835
+ for (const [componentId, component] of Object.entries(manifest)) {
836
+ if (!component || typeof component !== "object" || !("entries" in component)) continue;
837
+ for (const [cacheKey, entry] of Object.entries(component.entries)) {
838
+ if (!entry.tags || entry.tags.length === 0) continue;
839
+ for (const tag of entry.tags) {
840
+ let list = index.get(tag);
841
+ if (!list) {
842
+ list = [];
843
+ index.set(tag, list);
844
+ }
845
+ list.push({
846
+ componentId,
847
+ cacheKey
848
+ });
849
+ }
850
+ }
851
+ }
852
+ return index;
853
+ }
854
+ //#endregion
855
+ //#region src/server/prebuilt/payload-source.ts
856
+ /**
857
+ * Prebuilt payload source — the adapter seam through which the runtime
858
+ * reads build-time flight artifacts (`.timber/dist/prebuilt/`).
859
+ *
860
+ * The runtime never touches the filesystem directly: adapters register a
861
+ * source at startup (Node: fs reads; Cloudflare: the assets binding —
862
+ * design/44-render-at-build-time.md §Adapter Integration). Artifacts are
863
+ * produced by the post-build capture pass (TIM-1119, prebuilt-builder.ts);
864
+ * adapter registration of the source is TIM-1122. Until a source is
865
+ * registered (adapter not wired yet, dev mode, no artifacts built), every
866
+ * lookup misses and cache.component wrappers render live — the designed
867
+ * dynamic-fallback behavior.
868
+ *
869
+ * Phase 3 (design/45 runtime tier) inserts the CacheHandler overlay lookup
870
+ * in front of `lookupPrebuiltPayload` — overlay first, then artifact. The
871
+ * single-lookup-function shape here is that seam.
872
+ */
873
+ var source = null;
874
+ var manifestPromise = null;
875
+ /**
876
+ * Ceiling on the memoized manifest load. Without it, a stalled
877
+ * `loadManifest()` would leave `manifestPromise` pending forever and every
878
+ * subsequent cache.component render would await the same hung promise —
879
+ * the coalesced-promise deadlock class from design/13-security.md (A5).
880
+ * On expiry the load memoizes as null (permanent dynamic fallback, same
881
+ * policy as a failed load) and callers proceed immediately.
882
+ */
883
+ var MANIFEST_LOAD_TIMEOUT_MS = 5e3;
884
+ /**
885
+ * Per-read ceiling on payload reads. The read is awaited inside a server
886
+ * component render — a stalled adapter promise would otherwise hang the
887
+ * RSC stream until the render timeout kills the whole page, when the
888
+ * correct degradation is a miss → live render (codex review round 4 on
889
+ * PR #835).
890
+ */
891
+ var PAYLOAD_READ_TIMEOUT_MS = 5e3;
892
+ /** Race a source promise against a timeout that resolves to `fallback`. */
893
+ async function withTimeout(work, timeoutMs, fallback, onTimeout) {
894
+ let timer;
895
+ try {
896
+ return await Promise.race([work, new Promise((resolve) => {
897
+ timer = setTimeout(() => {
898
+ onTimeout();
899
+ resolve(fallback);
900
+ }, timeoutMs);
901
+ })]);
902
+ } finally {
903
+ clearTimeout(timer);
904
+ }
905
+ }
906
+ async function loadManifestWithTimeout(src) {
907
+ let manifest;
908
+ try {
909
+ manifest = await withTimeout(src.loadManifest(), MANIFEST_LOAD_TIMEOUT_MS, null, () => {
910
+ console.error(`[timber] prebuilt manifest load exceeded ${MANIFEST_LOAD_TIMEOUT_MS}ms — all cache.component lookups will render dynamically`);
911
+ });
912
+ } catch (error) {
913
+ console.error("[timber] failed to load prebuilt manifest — all cache.component lookups will miss:", error);
914
+ return null;
915
+ }
916
+ if (manifest) initTagIndex(manifest);
917
+ return manifest;
918
+ }
919
+ /**
920
+ * Register the payload source. Called once at server startup by the
921
+ * adapter/entry wiring (TIM-1122); tests inject fakes. Passing null
922
+ * unregisters (and drops the memoized manifest).
923
+ */
924
+ function setPrebuiltPayloadSource(next) {
925
+ source = next;
926
+ manifestPromise = null;
927
+ if (!next) resetTagIndex();
928
+ }
929
+ /**
930
+ * Whether a source is registered — the gate for both marker emission and
931
+ * splice-transform installation. False means zero prebuilt overhead.
932
+ */
933
+ function hasPrebuiltPayloadSource() {
934
+ return source !== null;
935
+ }
936
+ /**
937
+ * Ensure the manifest is loaded (and the tag index initialized). No-op
938
+ * when no source is registered. Used by the tombstone path to avoid
939
+ * skipping tombstones on cold processes where the first request is an
940
+ * action rather than a page render.
941
+ */
942
+ async function ensureManifestLoaded() {
943
+ if (source === null) return;
944
+ manifestPromise ??= loadManifestWithTimeout(source);
945
+ await manifestPromise;
946
+ }
947
+ /**
948
+ * Look up a manifest entry (metadata only, no payload read).
949
+ * Used by the overlay to check seed existence and freshness.
950
+ */
951
+ async function isParamIndependent(componentId) {
952
+ if (source === null) return false;
953
+ manifestPromise ??= loadManifestWithTimeout(source);
954
+ return (await manifestPromise)?.[componentId]?.paramIndependent === true;
955
+ }
956
+ async function getManifestEntry(componentId, cacheKey) {
957
+ if (source === null) return null;
958
+ manifestPromise ??= loadManifestWithTimeout(source);
959
+ return (await manifestPromise)?.[componentId]?.entries?.[cacheKey] ?? null;
960
+ }
961
+ /**
962
+ * Look up a cached payload: manifest entry → payload bytes.
963
+ * Null on any miss or read failure — callers fall back to live render.
964
+ *
965
+ * The manifest is loaded once and memoized (design/44 §manifest.json:
966
+ * loaded at startup, held in memory; payloads read on demand). A failed
967
+ * manifest load is memoized as null rather than retried per-request — a
968
+ * broken artifact should degrade to dynamic rendering, not add a failing
969
+ * read to every request.
970
+ */
971
+ async function lookupPrebuiltPayload(componentId, cacheKey) {
972
+ if (source === null) return null;
973
+ manifestPromise ??= loadManifestWithTimeout(source);
974
+ const entry = (await manifestPromise)?.[componentId]?.entries?.[cacheKey];
975
+ if (!entry) return null;
976
+ try {
977
+ return await withTimeout(source.readPayload(entry.file), PAYLOAD_READ_TIMEOUT_MS, null, () => {
978
+ console.error(`[timber] prebuilt payload read for "${entry.file}" exceeded ${PAYLOAD_READ_TIMEOUT_MS}ms — rendering dynamically`);
979
+ });
980
+ } catch (error) {
981
+ console.error(`[timber] failed to read prebuilt payload "${entry.file}" for ${componentId} — rendering dynamically:`, error);
982
+ return null;
983
+ }
984
+ }
985
+ //#endregion
986
+ //#region src/server/prebuilt/overlay.ts
987
+ /**
988
+ * Component cache overlay — runtime CacheHandler layer for ISR.
989
+ *
990
+ * Sits in front of the immutable build artifact (`.flight` files) and
991
+ * stores replacement payloads and tombstones via the configured
992
+ * CacheHandler. Overlay entries are per-deploy namespaced:
993
+ * `timber:c:{deploymentId}:{componentId}:{hash}`
994
+ *
995
+ * The CacheHandler contract is untouched — tombstones and the tag index
996
+ * live above the interface as value conventions. Redis, KV, and custom
997
+ * handlers work unmodified.
998
+ *
999
+ * See design/45-cache-lifetimes.md §ISR mechanics.
1000
+ */
1001
+ /** Default ceiling TTL for tag-only entries (24 hours), in seconds. */
1002
+ var CEILING_TTL_SECONDS = 1440 * 60;
1003
+ /** Deploy-long physical TTL for seed-backed overlay records (90 days). */
1004
+ var DEPLOY_LONG_TTL_SECONDS = 2160 * 60 * 60;
1005
+ function isOverlayRecord(v) {
1006
+ return v !== null && typeof v === "object" && v._t === "co";
1007
+ }
1008
+ function isTombstone(v) {
1009
+ return v !== null && typeof v === "object" && v._t === "ct";
1010
+ }
1011
+ function overlayKey(componentId, cacheKey) {
1012
+ return `timber:c:${getDeploymentId() ?? "dev"}:${componentId}:${cacheKey}`;
1013
+ }
1014
+ /**
1015
+ * Look up an overlay entry in the cache handler.
1016
+ * Returns null on a clean miss (no overlay entry at all).
1017
+ */
1018
+ async function lookupOverlay(componentId, cacheKey) {
1019
+ const handler = getCacheHandler();
1020
+ const key = overlayKey(componentId, cacheKey);
1021
+ const result = await handler.get(key);
1022
+ if (!result) return null;
1023
+ const value = result.value;
1024
+ if (isTombstone(value)) return {
1025
+ kind: "tombstone",
1026
+ record: null,
1027
+ payload: null
1028
+ };
1029
+ if (isOverlayRecord(value)) return {
1030
+ kind: Date.now() > value.fu ? "stale" : "fresh",
1031
+ record: value,
1032
+ payload: base64ToBytes(value.p)
1033
+ };
1034
+ return null;
1035
+ }
1036
+ /**
1037
+ * Resolve the effective TTL for a component's runtime lifetime.
1038
+ * Tag-only entries (no explicit ttl) get the ceiling TTL (design/45
1039
+ * §Tag-only entries carry a ceiling TTL).
1040
+ */
1041
+ function effectiveTtl(ttl) {
1042
+ return ttl ?? CEILING_TTL_SECONDS;
1043
+ }
1044
+ /**
1045
+ * Store a component flight payload in the overlay.
1046
+ */
1047
+ async function storeOverlayEntry(componentId, cacheKey, payloadBytes, opts) {
1048
+ const handler = getCacheHandler();
1049
+ const key = overlayKey(componentId, cacheKey);
1050
+ const logicalTtl = effectiveTtl(opts.ttl);
1051
+ const physicalTtl = opts.hasSeed ? DEPLOY_LONG_TTL_SECONDS : logicalTtl;
1052
+ const record = {
1053
+ _t: "co",
1054
+ p: bytesToBase64(payloadBytes),
1055
+ fu: Date.now() + logicalTtl * 1e3,
1056
+ s: opts.hasSeed
1057
+ };
1058
+ await handler.set(key, record, {
1059
+ ttl: physicalTtl,
1060
+ tags: opts.tags
1061
+ });
1062
+ }
1063
+ var tagIndex = null;
1064
+ /**
1065
+ * Initialize the tag index from the prebuilt manifest. Called once when the
1066
+ * manifest is loaded. Without a manifest (no prebuilt components), this is
1067
+ * never called and revalidateTag skips the tombstone path entirely.
1068
+ */
1069
+ function initTagIndex(manifest) {
1070
+ tagIndex = buildTagIndex(manifest);
1071
+ emitIsrDiagnosticIfNeeded(manifest);
1072
+ }
1073
+ /**
1074
+ * Reset the tag index (for tests).
1075
+ * @internal
1076
+ */
1077
+ function resetTagIndex() {
1078
+ tagIndex = null;
1079
+ }
1080
+ /**
1081
+ * Write tombstones for all seed entries carrying the given tag.
1082
+ * Called from cache.invalidate (cache-api.ts) AFTER the handler's own
1083
+ * invalidation clears overlay entries.
1084
+ *
1085
+ * The tombstone prevents the immutable seed from being served after
1086
+ * invalidation — without it, a handler.invalidate that clears the overlay
1087
+ * would expose the (now-stale) build artifact on the next request.
1088
+ *
1089
+ * Ensures the manifest is loaded first so cold-process actions that
1090
+ * invalidate before any page render still write tombstones.
1091
+ */
1092
+ async function writeTombstonesForTag(tag) {
1093
+ if (!tagIndex) await ensureManifestLoaded();
1094
+ if (!tagIndex) return;
1095
+ const seeds = tagIndex.get(tag);
1096
+ if (!seeds || seeds.length === 0) return;
1097
+ const handler = getCacheHandler();
1098
+ const tombstone = { _t: "ct" };
1099
+ await Promise.all(seeds.map((seed) => {
1100
+ const key = overlayKey(seed.componentId, seed.cacheKey);
1101
+ return handler.set(key, tombstone, {
1102
+ ttl: DEPLOY_LONG_TTL_SECONDS,
1103
+ tags: [tag]
1104
+ });
1105
+ }));
1106
+ }
1107
+ var isrDiagnosticEmitted = false;
1108
+ function emitIsrDiagnosticIfNeeded(manifest) {
1109
+ if (isrDiagnosticEmitted) return;
1110
+ if (!(getCacheHandler() instanceof MemoryCacheHandler || !isCacheHandlerConfigured())) return;
1111
+ for (const [, component] of Object.entries(manifest)) {
1112
+ if (!component || typeof component !== "object" || !("entries" in component)) continue;
1113
+ for (const [, entry] of Object.entries(component.entries)) if (entry.tags && entry.tags.length > 0) {
1114
+ isrDiagnosticEmitted = true;
1115
+ console.warn("[timber] tag revalidation of prerendered components requires a shared cache handler in multi-instance deployments. The current MemoryCacheHandler is per-process — revalidateTag on one instance will not purge the build seed on others. Configure a shared handler (Redis, KV) for production ISR.");
1116
+ return;
1117
+ }
1118
+ }
1119
+ }
1120
+ function bytesToBase64(bytes) {
1121
+ return Buffer.from(bytes).toString("base64");
1122
+ }
1123
+ function base64ToBytes(b64) {
1124
+ return new Uint8Array(Buffer.from(b64, "base64"));
1125
+ }
1126
+ //#endregion
1127
+ //#region src/cdn/purge-store.ts
1128
+ var handler;
1129
+ /** Get the current CDN purge handler, if configured. */
1130
+ function getCdnPurgeHandler() {
1131
+ return handler;
1132
+ }
1133
+ //#endregion
1134
+ //#region src/cache/cache-api.ts
1135
+ var componentFallbackWarned = /* @__PURE__ */ new WeakSet();
1136
+ /**
1137
+ * Cache namespace — `cache.data`, `cache.component`, `cache.invalidate`.
1138
+ *
1139
+ * ```ts
1140
+ * import { cache } from '@timber-js/app/cache';
1141
+ *
1142
+ * const getUser = cache.data(
1143
+ * async (id: string) => db.users.findUnique({ where: { id } }),
1144
+ * { ttl: 60, tags: (id) => [`user:${id}`] }
1145
+ * );
1146
+ * ```
1147
+ */
1148
+ var cache = {
1149
+ /**
1150
+ * Wrap an async function with cross-request caching.
1151
+ *
1152
+ * The configured cache handler (defaults to MemoryCacheHandler, overridable
1153
+ * via timber.config.ts) is re-resolved on every call, so module-scope
1154
+ * wrappers created before `setCacheHandler()` still pick up the configured
1155
+ * handler (TIM-1029).
1156
+ */
1157
+ data(fn, opts, stableId) {
1158
+ return createCache(fn, opts, getCacheHandler, stableId);
1159
+ },
1160
+ /**
1161
+ * Invalidate cache entries by tag or key.
1162
+ *
1163
+ * ```ts
1164
+ * cache.invalidate({ tag: 'products' });
1165
+ * cache.invalidate({ key: 'user:abc' });
1166
+ * ```
1167
+ */
1168
+ async invalidate(opts) {
1169
+ recordInvalidation(opts);
1170
+ await getCacheHandler().invalidate(opts);
1171
+ if (opts.tag) await writeTombstonesForTag(opts.tag);
1172
+ if (opts.tag) {
1173
+ const purgeHandler = getCdnPurgeHandler();
1174
+ if (purgeHandler) try {
1175
+ await Promise.race([purgeHandler.purgeTags([opts.tag]), new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("CDN purge timed out (10s)")), 1e4))]);
1176
+ } catch (err) {
1177
+ console.error("[timber] CDN purge failed for tag:", err);
1178
+ }
1179
+ }
1180
+ },
1181
+ /**
1182
+ * Runtime fallback for `cache.component(...)` callsites the timber-prebuilt
1183
+ * transform does not rewrite — nested/computed/argument-position forms (see
1184
+ * plugins/prebuilt.ts). Only module-scope `const X = cache.component(...)`
1185
+ * declarations are transformed and eligible for prebuilding; everything else
1186
+ * lands here, warns once per component, and renders dynamically. Same
1187
+ * safety-net pattern as the data cache's runtime fnId fallback (TIM-1054):
1188
+ * an untraceable callsite degrades in performance, never in correctness.
1189
+ */
1190
+ component(componentFn, _options) {
1191
+ if (!componentFallbackWarned.has(componentFn)) {
1192
+ componentFallbackWarned.add(componentFn);
1193
+ const name = componentFn.name || "anonymous component";
1194
+ console.warn(`[timber] cache.component: "${name}" was not transformed at build time — rendering dynamically. Only module-scope declarations (const X = cache.component(...)) are prebuilt.`);
1195
+ }
1196
+ return componentFn;
1197
+ }
1198
+ };
1199
+ //#endregion
1200
+ export { setDefaultSingleflightTimeout as _, getManifestEntry as a, wasInvalidatedSince as b, lookupPrebuiltPayload as c, checkVersionSkew as d, MemoryCacheHandler as f, setCacheHandler as g, getCacheHandler as h, storeOverlayEntry as i, setPrebuiltPayloadSource as l, RedisCacheHandler as m, lookupOverlay as n, hasPrebuiltPayloadSource as o, TagAwareCacheHandler as p, overlayKey as r, isParamIndependent as s, cache as t, applyReloadHeaders as u, currentInvalidationEpoch as v, createSingleflight as x, lastInvalidationEpochFor as y };
1201
+
1202
+ //# sourceMappingURL=cache-api-B-lhk9p4.js.map