@timber-js/app 0.2.0-alpha.19 → 0.2.0-alpha.190

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 (1192) hide show
  1. package/LICENSE +8 -0
  2. package/agent-skill.md +344 -0
  3. package/dist/_chunks/actions-35jnMdeJ.js +318 -0
  4. package/dist/_chunks/actions-35jnMdeJ.js.map +1 -0
  5. package/dist/_chunks/als-registry-C6kcfprT.js +41 -0
  6. package/dist/_chunks/als-registry-C6kcfprT.js.map +1 -0
  7. package/dist/_chunks/als-slots-BEEIPKYm.js +26 -0
  8. package/dist/_chunks/als-slots-BEEIPKYm.js.map +1 -0
  9. package/dist/_chunks/base-path-DaQrzbez.js +80 -0
  10. package/dist/_chunks/base-path-DaQrzbez.js.map +1 -0
  11. package/dist/_chunks/build-manifest-DWppEdLB.js +86 -0
  12. package/dist/_chunks/build-manifest-DWppEdLB.js.map +1 -0
  13. package/dist/_chunks/build-output-helper-C3DrfzZR.js +369 -0
  14. package/dist/_chunks/build-output-helper-C3DrfzZR.js.map +1 -0
  15. package/dist/_chunks/cache-api-DjNrIWRR.js +1196 -0
  16. package/dist/_chunks/cache-api-DjNrIWRR.js.map +1 -0
  17. package/dist/_chunks/cli-check-CpmN7Nh-.js +256 -0
  18. package/dist/_chunks/cli-check-CpmN7Nh-.js.map +1 -0
  19. package/dist/_chunks/cli-schema-sync-CGMp_Psg.js +298 -0
  20. package/dist/_chunks/cli-schema-sync-CGMp_Psg.js.map +1 -0
  21. package/dist/_chunks/cloudflare-CGP6BZKO.js +1284 -0
  22. package/dist/_chunks/cloudflare-CGP6BZKO.js.map +1 -0
  23. package/dist/_chunks/codec-registry-oOUxugz3.js +21 -0
  24. package/dist/_chunks/codec-registry-oOUxugz3.js.map +1 -0
  25. package/dist/_chunks/convention-lint-kXsgc_-7.js +784 -0
  26. package/dist/_chunks/convention-lint-kXsgc_-7.js.map +1 -0
  27. package/dist/_chunks/dist-BA3u1z3W.js +423 -0
  28. package/dist/_chunks/dist-BA3u1z3W.js.map +1 -0
  29. package/dist/_chunks/error-boundary-D-ODYX41.js +353 -0
  30. package/dist/_chunks/error-boundary-D-ODYX41.js.map +1 -0
  31. package/dist/_chunks/fast-hash-C-tVYrLb.js +41 -0
  32. package/dist/_chunks/fast-hash-C-tVYrLb.js.map +1 -0
  33. package/dist/_chunks/file-cache-DmX7OqZP.js +454 -0
  34. package/dist/_chunks/file-cache-DmX7OqZP.js.map +1 -0
  35. package/dist/_chunks/format-CfwjgPz9.js +14 -0
  36. package/dist/_chunks/format-CfwjgPz9.js.map +1 -0
  37. package/dist/_chunks/fs-identity-D7vb6GdI.js +208 -0
  38. package/dist/_chunks/fs-identity-D7vb6GdI.js.map +1 -0
  39. package/dist/_chunks/href-validation-CMc5JRls.js +141 -0
  40. package/dist/_chunks/href-validation-CMc5JRls.js.map +1 -0
  41. package/dist/_chunks/json-lossy-check-ClNvBM_3.js +63 -0
  42. package/dist/_chunks/json-lossy-check-ClNvBM_3.js.map +1 -0
  43. package/dist/_chunks/logger-D8xJZXIN.js +1451 -0
  44. package/dist/_chunks/logger-D8xJZXIN.js.map +1 -0
  45. package/dist/_chunks/mdx-file-C005ay-P.js +25 -0
  46. package/dist/_chunks/mdx-file-C005ay-P.js.map +1 -0
  47. package/dist/_chunks/plugin-context-rCinWLiE.js +321 -0
  48. package/dist/_chunks/plugin-context-rCinWLiE.js.map +1 -0
  49. package/dist/_chunks/purge-store-Byr8XOjU.js +14 -0
  50. package/dist/_chunks/purge-store-Byr8XOjU.js.map +1 -0
  51. package/dist/_chunks/resolve-schema-CBR6Lm4i.js +50 -0
  52. package/dist/_chunks/resolve-schema-CBR6Lm4i.js.map +1 -0
  53. package/dist/_chunks/router-ref-DuYuV_0Q.js +28 -0
  54. package/dist/_chunks/router-ref-DuYuV_0Q.js.map +1 -0
  55. package/dist/_chunks/rsc-cache-key-DD0fl_-s.js +243 -0
  56. package/dist/_chunks/rsc-cache-key-DD0fl_-s.js.map +1 -0
  57. package/dist/_chunks/rsc-error-envelope-tT5PJs4q.js +40 -0
  58. package/dist/_chunks/rsc-error-envelope-tT5PJs4q.js.map +1 -0
  59. package/dist/_chunks/rsc-media-type-DRqE_lD_.js +46 -0
  60. package/dist/_chunks/rsc-media-type-DRqE_lD_.js.map +1 -0
  61. package/dist/_chunks/rsc-payload-path-B_LBodc2.js +48 -0
  62. package/dist/_chunks/rsc-payload-path-B_LBodc2.js.map +1 -0
  63. package/dist/_chunks/scanner-C8b0Gcw3.js +1564 -0
  64. package/dist/_chunks/scanner-C8b0Gcw3.js.map +1 -0
  65. package/dist/_chunks/schema-bridge-C83xa9lT.js +199 -0
  66. package/dist/_chunks/schema-bridge-C83xa9lT.js.map +1 -0
  67. package/dist/_chunks/segment-classify-C539Pa2O.js +197 -0
  68. package/dist/_chunks/segment-classify-C539Pa2O.js.map +1 -0
  69. package/dist/_chunks/segment-context-CjOlyB8Y.js +97 -0
  70. package/dist/_chunks/segment-context-CjOlyB8Y.js.map +1 -0
  71. package/dist/_chunks/segment-keys-BawYuNFO.js +307 -0
  72. package/dist/_chunks/segment-keys-BawYuNFO.js.map +1 -0
  73. package/dist/_chunks/sizeof-lXffQ1Vr.js +35 -0
  74. package/dist/_chunks/sizeof-lXffQ1Vr.js.map +1 -0
  75. package/dist/_chunks/slot-params-BCTmZkQB.js +76 -0
  76. package/dist/_chunks/slot-params-BCTmZkQB.js.map +1 -0
  77. package/dist/_chunks/{ssr-data-MjmprTmO.js → ssr-data-14MXm7Pj.js} +17 -2
  78. package/dist/_chunks/ssr-data-14MXm7Pj.js.map +1 -0
  79. package/dist/_chunks/use-query-states-I3JMng6J.js +226 -0
  80. package/dist/_chunks/use-query-states-I3JMng6J.js.map +1 -0
  81. package/dist/_chunks/use-segment-params-C4r4BD9T.js +398 -0
  82. package/dist/_chunks/use-segment-params-C4r4BD9T.js.map +1 -0
  83. package/dist/_chunks/walkers-RzN6AFjr.js +141 -0
  84. package/dist/_chunks/walkers-RzN6AFjr.js.map +1 -0
  85. package/dist/adapters/build-output-helper.d.ts +72 -0
  86. package/dist/adapters/build-output-helper.d.ts.map +1 -0
  87. package/dist/adapters/cloudflare-dev.d.ts +109 -0
  88. package/dist/adapters/cloudflare-dev.d.ts.map +1 -0
  89. package/dist/adapters/cloudflare-dev.js +73 -0
  90. package/dist/adapters/cloudflare-dev.js.map +1 -0
  91. package/dist/adapters/cloudflare-kv-cache.d.ts +65 -0
  92. package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -0
  93. package/dist/adapters/cloudflare-kv-cache.js +124 -0
  94. package/dist/adapters/cloudflare-kv-cache.js.map +1 -0
  95. package/dist/adapters/cloudflare.d.ts +199 -21
  96. package/dist/adapters/cloudflare.d.ts.map +1 -1
  97. package/dist/adapters/cloudflare.js +2 -188
  98. package/dist/adapters/compress-module.d.ts +17 -4
  99. package/dist/adapters/compress-module.d.ts.map +1 -1
  100. package/dist/adapters/fs-identity.d.ts +64 -0
  101. package/dist/adapters/fs-identity.d.ts.map +1 -0
  102. package/dist/adapters/nitro.d.ts +55 -3
  103. package/dist/adapters/nitro.d.ts.map +1 -1
  104. package/dist/adapters/nitro.js +287 -171
  105. package/dist/adapters/nitro.js.map +1 -1
  106. package/dist/adapters/shared.d.ts +62 -0
  107. package/dist/adapters/shared.d.ts.map +1 -0
  108. package/dist/adapters/types.d.ts +28 -6
  109. package/dist/adapters/types.d.ts.map +1 -1
  110. package/dist/cache/cache-api.d.ts +48 -0
  111. package/dist/cache/cache-api.d.ts.map +1 -0
  112. package/dist/cache/fast-hash.d.ts +5 -0
  113. package/dist/cache/fast-hash.d.ts.map +1 -1
  114. package/dist/cache/handler-store.d.ts +33 -0
  115. package/dist/cache/handler-store.d.ts.map +1 -0
  116. package/dist/cache/index.d.ts +31 -8
  117. package/dist/cache/index.d.ts.map +1 -1
  118. package/dist/cache/index.js +3 -326
  119. package/dist/cache/invalidation-epoch.d.ts +43 -0
  120. package/dist/cache/invalidation-epoch.d.ts.map +1 -0
  121. package/dist/cache/json-lossy-check.d.ts +11 -0
  122. package/dist/cache/json-lossy-check.d.ts.map +1 -0
  123. package/dist/cache/redis-handler.d.ts +140 -8
  124. package/dist/cache/redis-handler.d.ts.map +1 -1
  125. package/dist/cache/singleflight.d.ts +19 -2
  126. package/dist/cache/singleflight.d.ts.map +1 -1
  127. package/dist/cache/sizeof.d.ts +22 -0
  128. package/dist/cache/sizeof.d.ts.map +1 -0
  129. package/dist/cache/stable-stringify.d.ts +9 -0
  130. package/dist/cache/stable-stringify.d.ts.map +1 -1
  131. package/dist/cache/store.d.ts +53 -0
  132. package/dist/cache/store.d.ts.map +1 -0
  133. package/dist/cache/stores/cloudflare-kv.d.ts +38 -0
  134. package/dist/cache/stores/cloudflare-kv.d.ts.map +1 -0
  135. package/dist/cache/stores/cloudflare-kv.js +29 -0
  136. package/dist/cache/stores/cloudflare-kv.js.map +1 -0
  137. package/dist/cache/stores/memory.d.ts +42 -0
  138. package/dist/cache/stores/memory.d.ts.map +1 -0
  139. package/dist/cache/stores/memory.js +90 -0
  140. package/dist/cache/stores/memory.js.map +1 -0
  141. package/dist/cache/stores/redis.d.ts +69 -0
  142. package/dist/cache/stores/redis.d.ts.map +1 -0
  143. package/dist/cache/stores/redis.js +35 -0
  144. package/dist/cache/stores/redis.js.map +1 -0
  145. package/dist/cache/stores/vercel.d.ts +36 -0
  146. package/dist/cache/stores/vercel.d.ts.map +1 -0
  147. package/dist/cache/stores/vercel.js +33 -0
  148. package/dist/cache/stores/vercel.js.map +1 -0
  149. package/dist/cache/tag-aware-handler.d.ts +52 -0
  150. package/dist/cache/tag-aware-handler.d.ts.map +1 -0
  151. package/dist/cache/timber-cache.d.ts +20 -10
  152. package/dist/cache/timber-cache.d.ts.map +1 -1
  153. package/dist/cdn/cloudflare-purge.d.ts +23 -0
  154. package/dist/cdn/cloudflare-purge.d.ts.map +1 -0
  155. package/dist/cdn/cloudflare-purge.js +30 -0
  156. package/dist/cdn/cloudflare-purge.js.map +1 -0
  157. package/dist/cdn/fastly-purge.d.ts +25 -0
  158. package/dist/cdn/fastly-purge.d.ts.map +1 -0
  159. package/dist/cdn/fastly-purge.js +33 -0
  160. package/dist/cdn/fastly-purge.js.map +1 -0
  161. package/dist/cdn/headers.d.ts +97 -0
  162. package/dist/cdn/headers.d.ts.map +1 -0
  163. package/dist/cdn/index.d.ts +5 -0
  164. package/dist/cdn/index.d.ts.map +1 -0
  165. package/dist/cdn/index.js +94 -0
  166. package/dist/cdn/index.js.map +1 -0
  167. package/dist/cdn/purge-store.d.ts +23 -0
  168. package/dist/cdn/purge-store.d.ts.map +1 -0
  169. package/dist/cdn/workers-cache-purge.d.ts +16 -0
  170. package/dist/cdn/workers-cache-purge.d.ts.map +1 -0
  171. package/dist/cdn/workers-cache-purge.js +35 -0
  172. package/dist/cdn/workers-cache-purge.js.map +1 -0
  173. package/dist/cli-check.d.ts +153 -0
  174. package/dist/cli-check.d.ts.map +1 -0
  175. package/dist/cli-schema-sync.d.ts +59 -0
  176. package/dist/cli-schema-sync.d.ts.map +1 -0
  177. package/dist/cli.d.ts +66 -7
  178. package/dist/cli.d.ts.map +1 -1
  179. package/dist/cli.js +151 -47
  180. package/dist/cli.js.map +1 -1
  181. package/dist/client/browser-dev.d.ts +37 -1
  182. package/dist/client/browser-dev.d.ts.map +1 -1
  183. package/dist/client/browser-entry/action-dispatch.d.ts +17 -0
  184. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -0
  185. package/dist/client/browser-entry/hmr.d.ts +21 -0
  186. package/dist/client/browser-entry/hmr.d.ts.map +1 -0
  187. package/dist/client/browser-entry/hydrate.d.ts +57 -0
  188. package/dist/client/browser-entry/hydrate.d.ts.map +1 -0
  189. package/dist/client/browser-entry/index.d.ts +29 -0
  190. package/dist/client/browser-entry/index.d.ts.map +1 -0
  191. package/dist/client/browser-entry/post-hydration.d.ts +29 -0
  192. package/dist/client/browser-entry/post-hydration.d.ts.map +1 -0
  193. package/dist/client/browser-entry/router-init.d.ts +30 -0
  194. package/dist/client/browser-entry/router-init.d.ts.map +1 -0
  195. package/dist/client/browser-entry/rsc-stream.d.ts +32 -0
  196. package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -0
  197. package/dist/client/browser-entry/scroll.d.ts +28 -0
  198. package/dist/client/browser-entry/scroll.d.ts.map +1 -0
  199. package/dist/client/error-boundary.d.ts +19 -5
  200. package/dist/client/error-boundary.d.ts.map +1 -1
  201. package/dist/client/error-boundary.js +1 -125
  202. package/dist/client/error-reconstituter.d.ts +61 -0
  203. package/dist/client/error-reconstituter.d.ts.map +1 -0
  204. package/dist/client/form.d.ts +16 -27
  205. package/dist/client/form.d.ts.map +1 -1
  206. package/dist/client/history.d.ts +29 -7
  207. package/dist/client/history.d.ts.map +1 -1
  208. package/dist/client/index.d.ts +11 -24
  209. package/dist/client/index.d.ts.map +1 -1
  210. package/dist/client/index.js +186 -1134
  211. package/dist/client/index.js.map +1 -1
  212. package/dist/client/internal.d.ts +20 -0
  213. package/dist/client/internal.d.ts.map +1 -0
  214. package/dist/client/internal.js +1624 -0
  215. package/dist/client/internal.js.map +1 -0
  216. package/dist/client/link.d.ts +63 -60
  217. package/dist/client/link.d.ts.map +1 -1
  218. package/dist/client/navigation-api.d.ts +121 -0
  219. package/dist/client/navigation-api.d.ts.map +1 -0
  220. package/dist/client/navigation-commit.d.ts +87 -0
  221. package/dist/client/navigation-commit.d.ts.map +1 -0
  222. package/dist/client/navigation-context.d.ts +38 -20
  223. package/dist/client/navigation-context.d.ts.map +1 -1
  224. package/dist/client/navigation-root.d.ts +159 -0
  225. package/dist/client/navigation-root.d.ts.map +1 -0
  226. package/dist/client/nuqs-adapter.d.ts +1 -1
  227. package/dist/client/nuqs-adapter.d.ts.map +1 -1
  228. package/dist/client/params-context.d.ts +81 -0
  229. package/dist/client/params-context.d.ts.map +1 -0
  230. package/dist/client/router-effects.d.ts +129 -0
  231. package/dist/client/router-effects.d.ts.map +1 -0
  232. package/dist/client/router-lifecycle.d.ts +55 -0
  233. package/dist/client/router-lifecycle.d.ts.map +1 -0
  234. package/dist/client/router-pipeline.d.ts +84 -0
  235. package/dist/client/router-pipeline.d.ts.map +1 -0
  236. package/dist/client/router-ref.d.ts +2 -2
  237. package/dist/client/router-ref.d.ts.map +1 -1
  238. package/dist/client/router-skew.d.ts +21 -0
  239. package/dist/client/router-skew.d.ts.map +1 -0
  240. package/dist/client/router-types.d.ts +207 -0
  241. package/dist/client/router-types.d.ts.map +1 -0
  242. package/dist/client/router.d.ts +1 -97
  243. package/dist/client/router.d.ts.map +1 -1
  244. package/dist/client/rsc-fetch.d.ts +113 -26
  245. package/dist/client/rsc-fetch.d.ts.map +1 -1
  246. package/dist/client/segment-cache.d.ts +107 -25
  247. package/dist/client/segment-cache.d.ts.map +1 -1
  248. package/dist/client/segment-outlet.d.ts +57 -0
  249. package/dist/client/segment-outlet.d.ts.map +1 -0
  250. package/dist/client/segment-update-context.d.ts +21 -0
  251. package/dist/client/segment-update-context.d.ts.map +1 -0
  252. package/dist/client/shallow-url.d.ts +10 -0
  253. package/dist/client/shallow-url.d.ts.map +1 -0
  254. package/dist/client/slot-context.d.ts +31 -0
  255. package/dist/client/slot-context.d.ts.map +1 -0
  256. package/dist/client/slot-outlet.d.ts +16 -0
  257. package/dist/client/slot-outlet.d.ts.map +1 -0
  258. package/dist/client/slot-provider.d.ts +25 -0
  259. package/dist/client/slot-provider.d.ts.map +1 -0
  260. package/dist/client/ssr-data.d.ts +19 -4
  261. package/dist/client/ssr-data.d.ts.map +1 -1
  262. package/dist/client/stale-client.d.ts +69 -0
  263. package/dist/client/stale-client.d.ts.map +1 -0
  264. package/dist/client/state.d.ts +11 -2
  265. package/dist/client/state.d.ts.map +1 -1
  266. package/dist/client/top-loader.d.ts +7 -6
  267. package/dist/client/top-loader.d.ts.map +1 -1
  268. package/dist/client/unload-guard.d.ts +5 -0
  269. package/dist/client/unload-guard.d.ts.map +1 -1
  270. package/dist/client/use-cookie.d.ts +12 -0
  271. package/dist/client/use-cookie.d.ts.map +1 -1
  272. package/dist/client/use-link-status.d.ts +5 -5
  273. package/dist/client/use-link-status.d.ts.map +1 -1
  274. package/dist/client/use-pathname.d.ts.map +1 -1
  275. package/dist/client/use-pending-navigation.d.ts +23 -0
  276. package/dist/client/use-pending-navigation.d.ts.map +1 -0
  277. package/dist/client/use-query-states.d.ts +10 -4
  278. package/dist/client/use-query-states.d.ts.map +1 -1
  279. package/dist/client/use-router.d.ts +2 -2
  280. package/dist/client/use-router.d.ts.map +1 -1
  281. package/dist/client/use-search-params.d.ts +12 -5
  282. package/dist/client/use-search-params.d.ts.map +1 -1
  283. package/dist/client/{use-params.d.ts → use-segment-params.d.ts} +26 -14
  284. package/dist/client/use-segment-params.d.ts.map +1 -0
  285. package/dist/codec.d.ts +69 -0
  286. package/dist/codec.d.ts.map +1 -0
  287. package/dist/codec.js +76 -0
  288. package/dist/codec.js.map +1 -0
  289. package/dist/config-types.d.ts +284 -0
  290. package/dist/config-types.d.ts.map +1 -0
  291. package/dist/config-validation.d.ts +51 -0
  292. package/dist/config-validation.d.ts.map +1 -0
  293. package/dist/content/index.d.ts +1 -10
  294. package/dist/content/index.d.ts.map +1 -1
  295. package/dist/content/index.js +0 -2
  296. package/dist/cookies/define-cookie.d.ts +58 -25
  297. package/dist/cookies/define-cookie.d.ts.map +1 -1
  298. package/dist/cookies/index.d.ts +2 -1
  299. package/dist/cookies/index.d.ts.map +1 -1
  300. package/dist/cookies/index.js +257 -36
  301. package/dist/cookies/index.js.map +1 -1
  302. package/dist/cookies/json-cookie.d.ts +64 -0
  303. package/dist/cookies/json-cookie.d.ts.map +1 -0
  304. package/dist/cookies/validation.d.ts +34 -0
  305. package/dist/cookies/validation.d.ts.map +1 -0
  306. package/dist/dev-tools/404-page.d.ts +50 -0
  307. package/dist/dev-tools/404-page.d.ts.map +1 -0
  308. package/dist/dev-tools/browser-logs.d.ts +40 -0
  309. package/dist/dev-tools/browser-logs.d.ts.map +1 -0
  310. package/dist/dev-tools/dev-page-shell.d.ts +78 -0
  311. package/dist/dev-tools/dev-page-shell.d.ts.map +1 -0
  312. package/dist/dev-tools/error-page.d.ts +32 -0
  313. package/dist/dev-tools/error-page.d.ts.map +1 -0
  314. package/dist/dev-tools/holding-server.d.ts +54 -0
  315. package/dist/dev-tools/holding-server.d.ts.map +1 -0
  316. package/dist/dev-tools/hydration-overlay.d.ts +11 -0
  317. package/dist/dev-tools/hydration-overlay.d.ts.map +1 -0
  318. package/dist/dev-tools/index.d.ts +31 -0
  319. package/dist/dev-tools/index.d.ts.map +1 -0
  320. package/dist/dev-tools/instrumentation.d.ts +59 -0
  321. package/dist/dev-tools/instrumentation.d.ts.map +1 -0
  322. package/dist/{server/dev-logger.d.ts → dev-tools/logger.d.ts} +1 -1
  323. package/dist/dev-tools/logger.d.ts.map +1 -0
  324. package/dist/{plugins/dev-logs.d.ts → dev-tools/logs.d.ts} +17 -3
  325. package/dist/dev-tools/logs.d.ts.map +1 -0
  326. package/dist/dev-tools/overlay.d.ts +91 -0
  327. package/dist/dev-tools/overlay.d.ts.map +1 -0
  328. package/dist/dev-tools/stack-classifier.d.ts +34 -0
  329. package/dist/dev-tools/stack-classifier.d.ts.map +1 -0
  330. package/dist/dev-tools/terminal.d.ts +28 -0
  331. package/dist/dev-tools/terminal.d.ts.map +1 -0
  332. package/dist/fonts/ast-walk.d.ts +68 -0
  333. package/dist/fonts/ast-walk.d.ts.map +1 -0
  334. package/dist/fonts/ast.d.ts +110 -6
  335. package/dist/fonts/ast.d.ts.map +1 -1
  336. package/dist/fonts/bundle.d.ts +50 -0
  337. package/dist/fonts/bundle.d.ts.map +1 -0
  338. package/dist/fonts/dev-middleware.d.ts +22 -0
  339. package/dist/fonts/dev-middleware.d.ts.map +1 -0
  340. package/dist/fonts/fallbacks.d.ts +0 -7
  341. package/dist/fonts/fallbacks.d.ts.map +1 -1
  342. package/dist/fonts/google.d.ts +4 -2
  343. package/dist/fonts/google.d.ts.map +1 -1
  344. package/dist/fonts/local.d.ts +4 -4
  345. package/dist/fonts/local.d.ts.map +1 -1
  346. package/dist/fonts/paths.d.ts +43 -0
  347. package/dist/fonts/paths.d.ts.map +1 -0
  348. package/dist/fonts/pipeline.d.ts +177 -0
  349. package/dist/fonts/pipeline.d.ts.map +1 -0
  350. package/dist/fonts/transform.d.ts +82 -0
  351. package/dist/fonts/transform.d.ts.map +1 -0
  352. package/dist/fonts/types.d.ts +47 -1
  353. package/dist/fonts/types.d.ts.map +1 -1
  354. package/dist/fonts/virtual-modules.d.ts +77 -0
  355. package/dist/fonts/virtual-modules.d.ts.map +1 -0
  356. package/dist/index.d.ts +50 -181
  357. package/dist/index.d.ts.map +1 -1
  358. package/dist/index.js +9805 -14134
  359. package/dist/index.js.map +1 -1
  360. package/dist/params/codec-registry.d.ts +26 -0
  361. package/dist/params/codec-registry.d.ts.map +1 -0
  362. package/dist/params/define-schema.d.ts +81 -0
  363. package/dist/params/define-schema.d.ts.map +1 -0
  364. package/dist/params/index.d.ts +5 -0
  365. package/dist/params/index.d.ts.map +1 -0
  366. package/dist/params/index.js +34 -0
  367. package/dist/params/index.js.map +1 -0
  368. package/dist/params/resolve-schema.d.ts +34 -0
  369. package/dist/params/resolve-schema.d.ts.map +1 -0
  370. package/dist/plugin-context.d.ts +276 -0
  371. package/dist/plugin-context.d.ts.map +1 -0
  372. package/dist/plugins/adapter-build.d.ts +21 -1
  373. package/dist/plugins/adapter-build.d.ts.map +1 -1
  374. package/dist/plugins/build-manifest.d.ts +7 -3
  375. package/dist/plugins/build-manifest.d.ts.map +1 -1
  376. package/dist/plugins/build-report.d.ts +47 -10
  377. package/dist/plugins/build-report.d.ts.map +1 -1
  378. package/dist/plugins/cache.d.ts +64 -0
  379. package/dist/plugins/cache.d.ts.map +1 -0
  380. package/dist/plugins/callsite-ast.d.ts +117 -0
  381. package/dist/plugins/callsite-ast.d.ts.map +1 -0
  382. package/dist/plugins/callsite-jsx.d.ts +35 -0
  383. package/dist/plugins/callsite-jsx.d.ts.map +1 -0
  384. package/dist/plugins/chunks.d.ts +11 -4
  385. package/dist/plugins/chunks.d.ts.map +1 -1
  386. package/dist/plugins/client-chunks.d.ts +40 -0
  387. package/dist/plugins/client-chunks.d.ts.map +1 -0
  388. package/dist/plugins/cloudflare-wasm.d.ts +21 -0
  389. package/dist/plugins/cloudflare-wasm.d.ts.map +1 -0
  390. package/dist/plugins/content.d.ts +1 -1
  391. package/dist/plugins/content.d.ts.map +1 -1
  392. package/dist/plugins/dev-server.d.ts +17 -1
  393. package/dist/plugins/dev-server.d.ts.map +1 -1
  394. package/dist/plugins/entries.d.ts +28 -4
  395. package/dist/plugins/entries.d.ts.map +1 -1
  396. package/dist/plugins/fonts.d.ts +16 -73
  397. package/dist/plugins/fonts.d.ts.map +1 -1
  398. package/dist/plugins/mdx.d.ts +1 -1
  399. package/dist/plugins/mdx.d.ts.map +1 -1
  400. package/dist/plugins/prebuilt-capture.d.ts +60 -0
  401. package/dist/plugins/prebuilt-capture.d.ts.map +1 -0
  402. package/dist/plugins/prebuilt-options-analysis.d.ts +40 -0
  403. package/dist/plugins/prebuilt-options-analysis.d.ts.map +1 -0
  404. package/dist/plugins/prebuilt.d.ts +82 -0
  405. package/dist/plugins/prebuilt.d.ts.map +1 -0
  406. package/dist/plugins/prerender-sugar.d.ts +42 -0
  407. package/dist/plugins/prerender-sugar.d.ts.map +1 -0
  408. package/dist/plugins/request-dep/analysis.d.ts +106 -0
  409. package/dist/plugins/request-dep/analysis.d.ts.map +1 -0
  410. package/dist/plugins/request-dep/index.d.ts +75 -0
  411. package/dist/plugins/request-dep/index.d.ts.map +1 -0
  412. package/dist/plugins/request-dep/origin.d.ts +61 -0
  413. package/dist/plugins/request-dep/origin.d.ts.map +1 -0
  414. package/dist/plugins/routing.d.ts +1 -1
  415. package/dist/plugins/routing.d.ts.map +1 -1
  416. package/dist/plugins/server-bundle.d.ts.map +1 -1
  417. package/dist/plugins/shims.d.ts +29 -5
  418. package/dist/plugins/shims.d.ts.map +1 -1
  419. package/dist/plugins/static-build.d.ts +218 -21
  420. package/dist/plugins/static-build.d.ts.map +1 -1
  421. package/dist/routing/codegen-shared.d.ts +26 -0
  422. package/dist/routing/codegen-shared.d.ts.map +1 -0
  423. package/dist/routing/codegen-types.d.ts +61 -0
  424. package/dist/routing/codegen-types.d.ts.map +1 -0
  425. package/dist/routing/codegen-write.d.ts +51 -0
  426. package/dist/routing/codegen-write.d.ts.map +1 -0
  427. package/dist/routing/codegen.d.ts +7 -2
  428. package/dist/routing/codegen.d.ts.map +1 -1
  429. package/dist/routing/collision-probe.d.ts +104 -0
  430. package/dist/routing/collision-probe.d.ts.map +1 -0
  431. package/dist/routing/collision-spaces.d.ts +26 -0
  432. package/dist/routing/collision-spaces.d.ts.map +1 -0
  433. package/dist/routing/convention-lint.d.ts +55 -0
  434. package/dist/routing/convention-lint.d.ts.map +1 -0
  435. package/dist/routing/export-detect.d.ts +72 -0
  436. package/dist/routing/export-detect.d.ts.map +1 -0
  437. package/dist/routing/file-cache.d.ts +8 -0
  438. package/dist/routing/file-cache.d.ts.map +1 -0
  439. package/dist/routing/index.d.ts +7 -1
  440. package/dist/routing/index.d.ts.map +1 -1
  441. package/dist/routing/index.js +5 -2
  442. package/dist/routing/interception.d.ts +234 -10
  443. package/dist/routing/interception.d.ts.map +1 -1
  444. package/dist/routing/link-codegen.d.ts +105 -0
  445. package/dist/routing/link-codegen.d.ts.map +1 -0
  446. package/dist/routing/manifest-codegen.d.ts +26 -0
  447. package/dist/routing/manifest-codegen.d.ts.map +1 -0
  448. package/dist/routing/scanner.d.ts +1 -10
  449. package/dist/routing/scanner.d.ts.map +1 -1
  450. package/dist/routing/schema-validation.d.ts +35 -0
  451. package/dist/routing/schema-validation.d.ts.map +1 -0
  452. package/dist/routing/segment-classify.d.ts +114 -0
  453. package/dist/routing/segment-classify.d.ts.map +1 -0
  454. package/dist/routing/segment-codegen.d.ts +38 -0
  455. package/dist/routing/segment-codegen.d.ts.map +1 -0
  456. package/dist/routing/segment-keys.d.ts +117 -0
  457. package/dist/routing/segment-keys.d.ts.map +1 -0
  458. package/dist/routing/slot-placement.d.ts +48 -0
  459. package/dist/routing/slot-placement.d.ts.map +1 -0
  460. package/dist/routing/types.d.ts +74 -26
  461. package/dist/routing/types.d.ts.map +1 -1
  462. package/dist/routing/walkers.d.ts +57 -0
  463. package/dist/routing/walkers.d.ts.map +1 -0
  464. package/dist/rsc-runtime/rsc.d.ts +1 -1
  465. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  466. package/dist/rsc-runtime/ssr.d.ts +12 -0
  467. package/dist/rsc-runtime/ssr.d.ts.map +1 -1
  468. package/dist/schema-bridge.d.ts +145 -0
  469. package/dist/schema-bridge.d.ts.map +1 -0
  470. package/dist/search-params/define.d.ts +262 -0
  471. package/dist/search-params/define.d.ts.map +1 -0
  472. package/dist/search-params/index.d.ts +3 -7
  473. package/dist/search-params/index.d.ts.map +1 -1
  474. package/dist/search-params/index.js +179 -360
  475. package/dist/search-params/index.js.map +1 -1
  476. package/dist/search-params/parse-total.d.ts +81 -0
  477. package/dist/search-params/parse-total.d.ts.map +1 -0
  478. package/dist/search-params/serialize-equal.d.ts +9 -0
  479. package/dist/search-params/serialize-equal.d.ts.map +1 -0
  480. package/dist/search-params/wrappers.d.ts +76 -0
  481. package/dist/search-params/wrappers.d.ts.map +1 -0
  482. package/dist/server/access-gate.d.ts +26 -10
  483. package/dist/server/access-gate.d.ts.map +1 -1
  484. package/dist/server/action-client.d.ts +42 -7
  485. package/dist/server/action-client.d.ts.map +1 -1
  486. package/dist/server/action-encryption.d.ts +76 -0
  487. package/dist/server/action-encryption.d.ts.map +1 -0
  488. package/dist/server/action-handler.d.ts +35 -1
  489. package/dist/server/action-handler.d.ts.map +1 -1
  490. package/dist/server/actions.d.ts +12 -33
  491. package/dist/server/actions.d.ts.map +1 -1
  492. package/dist/server/als-registry.d.ts +110 -11
  493. package/dist/server/als-registry.d.ts.map +1 -1
  494. package/dist/server/asset-headers.d.ts +8 -18
  495. package/dist/server/asset-headers.d.ts.map +1 -1
  496. package/dist/server/body-limits.d.ts.map +1 -1
  497. package/dist/server/build-manifest.d.ts +25 -30
  498. package/dist/server/build-manifest.d.ts.map +1 -1
  499. package/dist/server/canonicalize.d.ts +10 -0
  500. package/dist/server/canonicalize.d.ts.map +1 -1
  501. package/dist/server/chain-url-parts.d.ts +81 -0
  502. package/dist/server/chain-url-parts.d.ts.map +1 -0
  503. package/dist/server/children-interception.d.ts +49 -0
  504. package/dist/server/children-interception.d.ts.map +1 -0
  505. package/dist/server/coalesce-tick.d.ts +40 -0
  506. package/dist/server/coalesce-tick.d.ts.map +1 -0
  507. package/dist/server/compress.d.ts.map +1 -1
  508. package/dist/server/cookie-context.d.ts +170 -0
  509. package/dist/server/cookie-context.d.ts.map +1 -0
  510. package/dist/server/cookie-parsing.d.ts +65 -0
  511. package/dist/server/cookie-parsing.d.ts.map +1 -0
  512. package/dist/server/csrf.d.ts +3 -2
  513. package/dist/server/csrf.d.ts.map +1 -1
  514. package/dist/server/default-logger.d.ts +22 -0
  515. package/dist/server/default-logger.d.ts.map +1 -0
  516. package/dist/server/default-status-page.d.ts +45 -0
  517. package/dist/server/default-status-page.d.ts.map +1 -0
  518. package/dist/server/deny-boundary.d.ts +247 -0
  519. package/dist/server/deny-boundary.d.ts.map +1 -0
  520. package/dist/server/deny-renderer.d.ts +16 -5
  521. package/dist/server/deny-renderer.d.ts.map +1 -1
  522. package/dist/server/dev-source-map.d.ts +22 -0
  523. package/dist/server/dev-source-map.d.ts.map +1 -0
  524. package/dist/server/early-hints-sender.d.ts.map +1 -1
  525. package/dist/server/early-hints.d.ts +13 -11
  526. package/dist/server/early-hints.d.ts.map +1 -1
  527. package/dist/server/error-boundary-wrapper.d.ts +86 -10
  528. package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
  529. package/dist/server/fallback-error.d.ts +12 -7
  530. package/dist/server/fallback-error.d.ts.map +1 -1
  531. package/dist/server/flight-injection-state.d.ts +66 -0
  532. package/dist/server/flight-injection-state.d.ts.map +1 -0
  533. package/dist/server/flight-scripts.d.ts +42 -0
  534. package/dist/server/flight-scripts.d.ts.map +1 -0
  535. package/dist/server/form-data.d.ts +41 -0
  536. package/dist/server/form-data.d.ts.map +1 -1
  537. package/dist/server/head-response.d.ts +35 -0
  538. package/dist/server/head-response.d.ts.map +1 -0
  539. package/dist/server/html-injector-core.d.ts +242 -0
  540. package/dist/server/html-injector-core.d.ts.map +1 -0
  541. package/dist/server/html-injectors.d.ts +82 -41
  542. package/dist/server/html-injectors.d.ts.map +1 -1
  543. package/dist/server/index.d.ts +10 -47
  544. package/dist/server/index.d.ts.map +1 -1
  545. package/dist/server/index.js +183 -2906
  546. package/dist/server/index.js.map +1 -1
  547. package/dist/server/internal.d.ts +51 -0
  548. package/dist/server/internal.d.ts.map +1 -0
  549. package/dist/server/internal.js +4154 -0
  550. package/dist/server/internal.js.map +1 -0
  551. package/dist/server/logger.d.ts +39 -7
  552. package/dist/server/logger.d.ts.map +1 -1
  553. package/dist/server/metadata-collector.d.ts +52 -0
  554. package/dist/server/metadata-collector.d.ts.map +1 -0
  555. package/dist/server/metadata-routes.d.ts +60 -11
  556. package/dist/server/metadata-routes.d.ts.map +1 -1
  557. package/dist/server/metadata.d.ts +8 -0
  558. package/dist/server/metadata.d.ts.map +1 -1
  559. package/dist/server/middleware-runner.d.ts +19 -4
  560. package/dist/server/middleware-runner.d.ts.map +1 -1
  561. package/dist/server/node-stream-transforms.d.ts +119 -0
  562. package/dist/server/node-stream-transforms.d.ts.map +1 -0
  563. package/dist/server/param-coercion.d.ts +70 -0
  564. package/dist/server/param-coercion.d.ts.map +1 -0
  565. package/dist/server/pipeline-helpers.d.ts +77 -0
  566. package/dist/server/pipeline-helpers.d.ts.map +1 -0
  567. package/dist/server/pipeline-interception.d.ts +59 -9
  568. package/dist/server/pipeline-interception.d.ts.map +1 -1
  569. package/dist/server/pipeline-metadata.d.ts +6 -0
  570. package/dist/server/pipeline-metadata.d.ts.map +1 -1
  571. package/dist/server/pipeline-outcome.d.ts +49 -0
  572. package/dist/server/pipeline-outcome.d.ts.map +1 -0
  573. package/dist/server/pipeline-phases.d.ts +59 -0
  574. package/dist/server/pipeline-phases.d.ts.map +1 -0
  575. package/dist/server/pipeline.d.ts +151 -19
  576. package/dist/server/pipeline.d.ts.map +1 -1
  577. package/dist/server/port-resolution.d.ts +117 -0
  578. package/dist/server/port-resolution.d.ts.map +1 -0
  579. package/dist/server/prebuilt/cache-key.d.ts +62 -0
  580. package/dist/server/prebuilt/cache-key.d.ts.map +1 -0
  581. package/dist/server/prebuilt/capture-state.d.ts +57 -0
  582. package/dist/server/prebuilt/capture-state.d.ts.map +1 -0
  583. package/dist/server/prebuilt/key-discipline.d.ts +23 -0
  584. package/dist/server/prebuilt/key-discipline.d.ts.map +1 -0
  585. package/dist/server/prebuilt/manifest-tag-index.d.ts +27 -0
  586. package/dist/server/prebuilt/manifest-tag-index.d.ts.map +1 -0
  587. package/dist/server/prebuilt/overlay.d.ts +100 -0
  588. package/dist/server/prebuilt/overlay.d.ts.map +1 -0
  589. package/dist/server/prebuilt/payload-source.d.ts +78 -0
  590. package/dist/server/prebuilt/payload-source.d.ts.map +1 -0
  591. package/dist/server/prebuilt/slots.d.ts +99 -0
  592. package/dist/server/prebuilt/slots.d.ts.map +1 -0
  593. package/dist/server/prebuilt/synthetic-store.d.ts +66 -0
  594. package/dist/server/prebuilt/synthetic-store.d.ts.map +1 -0
  595. package/dist/server/prebuilt-builder.d.ts +120 -0
  596. package/dist/server/prebuilt-builder.d.ts.map +1 -0
  597. package/dist/server/prebuilt-runtime.d.ts +111 -0
  598. package/dist/server/prebuilt-runtime.d.ts.map +1 -0
  599. package/dist/server/primitives.d.ts +100 -44
  600. package/dist/server/primitives.d.ts.map +1 -1
  601. package/dist/server/publish-params.d.ts +33 -0
  602. package/dist/server/publish-params.d.ts.map +1 -0
  603. package/dist/server/render-timeout.d.ts +51 -0
  604. package/dist/server/render-timeout.d.ts.map +1 -0
  605. package/dist/server/render-utils.d.ts +25 -0
  606. package/dist/server/render-utils.d.ts.map +1 -0
  607. package/dist/server/request-context.d.ts +109 -106
  608. package/dist/server/request-context.d.ts.map +1 -1
  609. package/dist/server/request-dep.d.ts +15 -0
  610. package/dist/server/request-dep.d.ts.map +1 -0
  611. package/dist/server/route-element-builder.d.ts +74 -27
  612. package/dist/server/route-element-builder.d.ts.map +1 -1
  613. package/dist/server/route-handler.d.ts.map +1 -1
  614. package/dist/server/route-matcher.d.ts +38 -36
  615. package/dist/server/route-matcher.d.ts.map +1 -1
  616. package/dist/server/rsc-cache-key-guard.d.ts +78 -0
  617. package/dist/server/rsc-cache-key-guard.d.ts.map +1 -0
  618. package/dist/server/rsc-entry/action-middleware-runner.d.ts +66 -0
  619. package/dist/server/rsc-entry/action-middleware-runner.d.ts.map +1 -0
  620. package/dist/server/rsc-entry/api-handler.d.ts +12 -3
  621. package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
  622. package/dist/server/rsc-entry/deny-fallback.d.ts +29 -0
  623. package/dist/server/rsc-entry/deny-fallback.d.ts.map +1 -0
  624. package/dist/server/rsc-entry/error-renderer.d.ts +38 -13
  625. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  626. package/dist/server/rsc-entry/helpers.d.ts +59 -42
  627. package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
  628. package/dist/server/rsc-entry/index.d.ts +39 -6
  629. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  630. package/dist/server/rsc-entry/render-route.d.ts +51 -0
  631. package/dist/server/rsc-entry/render-route.d.ts.map +1 -0
  632. package/dist/server/rsc-entry/revalidate-renderer.d.ts +108 -0
  633. package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -0
  634. package/dist/server/rsc-entry/rsc-payload.d.ts +5 -6
  635. package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
  636. package/dist/server/rsc-entry/rsc-stream.d.ts +40 -3
  637. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  638. package/dist/server/rsc-entry/ssr-bridge.d.ts +5 -1
  639. package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
  640. package/dist/server/rsc-entry/ssr-renderer.d.ts +36 -4
  641. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  642. package/dist/server/rsc-entry/wrap-action-dispatch.d.ts +89 -0
  643. package/dist/server/rsc-entry/wrap-action-dispatch.d.ts.map +1 -0
  644. package/dist/server/safe-load.d.ts +46 -0
  645. package/dist/server/safe-load.d.ts.map +1 -0
  646. package/dist/server/sensitive-fields.d.ts +74 -0
  647. package/dist/server/sensitive-fields.d.ts.map +1 -0
  648. package/dist/server/sitemap-generator.d.ts +129 -0
  649. package/dist/server/sitemap-generator.d.ts.map +1 -0
  650. package/dist/server/sitemap-handler.d.ts +22 -0
  651. package/dist/server/sitemap-handler.d.ts.map +1 -0
  652. package/dist/server/skippable-prefix.d.ts +26 -0
  653. package/dist/server/skippable-prefix.d.ts.map +1 -0
  654. package/dist/server/slot-interception.d.ts +80 -0
  655. package/dist/server/slot-interception.d.ts.map +1 -0
  656. package/dist/server/slot-resolver.d.ts +139 -5
  657. package/dist/server/slot-resolver.d.ts.map +1 -1
  658. package/dist/server/ssr-bridge-types.d.ts +138 -0
  659. package/dist/server/ssr-bridge-types.d.ts.map +1 -0
  660. package/dist/server/ssr-entry.d.ts +1 -43
  661. package/dist/server/ssr-entry.d.ts.map +1 -1
  662. package/dist/server/ssr-render.d.ts +64 -21
  663. package/dist/server/ssr-render.d.ts.map +1 -1
  664. package/dist/server/ssr-wrappers.d.ts +61 -0
  665. package/dist/server/ssr-wrappers.d.ts.map +1 -0
  666. package/dist/server/state-tree-diff.d.ts +44 -9
  667. package/dist/server/state-tree-diff.d.ts.map +1 -1
  668. package/dist/server/static-generator.d.ts +112 -0
  669. package/dist/server/static-generator.d.ts.map +1 -0
  670. package/dist/server/static-not-found.d.ts +52 -0
  671. package/dist/server/static-not-found.d.ts.map +1 -0
  672. package/dist/server/status-code-resolver.d.ts +26 -15
  673. package/dist/server/status-code-resolver.d.ts.map +1 -1
  674. package/dist/server/stream-utils.d.ts +47 -0
  675. package/dist/server/stream-utils.d.ts.map +1 -0
  676. package/dist/server/tracing.d.ts +44 -9
  677. package/dist/server/tracing.d.ts.map +1 -1
  678. package/dist/server/tree-builder.d.ts +66 -42
  679. package/dist/server/tree-builder.d.ts.map +1 -1
  680. package/dist/server/tree-match.d.ts +49 -0
  681. package/dist/server/tree-match.d.ts.map +1 -0
  682. package/dist/server/types.d.ts +76 -6
  683. package/dist/server/types.d.ts.map +1 -1
  684. package/dist/server/utils/element-type.d.ts +40 -0
  685. package/dist/server/utils/element-type.d.ts.map +1 -0
  686. package/dist/server/utils/escape-html.d.ts +14 -0
  687. package/dist/server/utils/escape-html.d.ts.map +1 -0
  688. package/dist/server/utils/mdx-file.d.ts +15 -0
  689. package/dist/server/utils/mdx-file.d.ts.map +1 -0
  690. package/dist/server/version-skew.d.ts +61 -0
  691. package/dist/server/version-skew.d.ts.map +1 -0
  692. package/dist/server/workers-cache-bridge.d.ts +26 -0
  693. package/dist/server/workers-cache-bridge.d.ts.map +1 -0
  694. package/dist/shared/als-slots.d.ts +41 -0
  695. package/dist/shared/als-slots.d.ts.map +1 -0
  696. package/dist/shared/base-path.d.ts +56 -0
  697. package/dist/shared/base-path.d.ts.map +1 -0
  698. package/dist/shared/href-validation.d.ts +49 -0
  699. package/dist/shared/href-validation.d.ts.map +1 -0
  700. package/dist/shared/merge-search-params.d.ts +22 -0
  701. package/dist/shared/merge-search-params.d.ts.map +1 -0
  702. package/dist/shared/param-value.d.ts +80 -0
  703. package/dist/shared/param-value.d.ts.map +1 -0
  704. package/dist/shared/payload-root.d.ts +108 -0
  705. package/dist/shared/payload-root.d.ts.map +1 -0
  706. package/dist/shared/redirect-type.d.ts +17 -0
  707. package/dist/shared/redirect-type.d.ts.map +1 -0
  708. package/dist/shared/rsc-cache-key.d.ts +163 -0
  709. package/dist/shared/rsc-cache-key.d.ts.map +1 -0
  710. package/dist/shared/rsc-error-envelope.d.ts +25 -0
  711. package/dist/shared/rsc-error-envelope.d.ts.map +1 -0
  712. package/dist/shared/rsc-manifest.d.ts +28 -0
  713. package/dist/shared/rsc-manifest.d.ts.map +1 -0
  714. package/dist/shared/rsc-media-type.d.ts +40 -0
  715. package/dist/shared/rsc-media-type.d.ts.map +1 -0
  716. package/dist/shared/rsc-payload-path.d.ts +42 -0
  717. package/dist/shared/rsc-payload-path.d.ts.map +1 -0
  718. package/dist/shared/segment-info.d.ts +66 -0
  719. package/dist/shared/segment-info.d.ts.map +1 -0
  720. package/dist/shared/slot-params.d.ts +51 -0
  721. package/dist/shared/slot-params.d.ts.map +1 -0
  722. package/dist/shared/static-platform-files.d.ts +71 -0
  723. package/dist/shared/static-platform-files.d.ts.map +1 -0
  724. package/dist/shims/font-google.d.ts +1 -1
  725. package/dist/shims/font-google.d.ts.map +1 -1
  726. package/dist/shims/font-google.js +42 -0
  727. package/dist/shims/font-google.js.map +1 -0
  728. package/dist/shims/font-local.d.ts +26 -0
  729. package/dist/shims/font-local.d.ts.map +1 -0
  730. package/dist/shims/font-local.js +20 -0
  731. package/dist/shims/font-local.js.map +1 -0
  732. package/dist/shims/headers.d.ts +53 -1
  733. package/dist/shims/headers.d.ts.map +1 -1
  734. package/dist/shims/image.d.ts +120 -120
  735. package/dist/shims/image.d.ts.map +1 -1
  736. package/dist/shims/navigation-client.d.ts +25 -12
  737. package/dist/shims/navigation-client.d.ts.map +1 -1
  738. package/dist/shims/navigation.d.ts +10 -5
  739. package/dist/shims/navigation.d.ts.map +1 -1
  740. package/dist/utils/state-machine.d.ts +80 -0
  741. package/dist/utils/state-machine.d.ts.map +1 -0
  742. package/docs/api/30-api-server.mdx +233 -0
  743. package/docs/api/31-api-client.mdx +163 -0
  744. package/docs/api/32-api-cache.mdx +311 -0
  745. package/docs/api/33-api-search-params.mdx +176 -0
  746. package/docs/api/34-api-config.mdx +325 -0
  747. package/docs/api/35-api-typescript.mdx +170 -0
  748. package/docs/api/36-cli.mdx +170 -0
  749. package/docs/learn/00-introduction.mdx +109 -0
  750. package/docs/learn/01-quick-start.mdx +94 -0
  751. package/docs/learn/02-pages-and-layouts.mdx +147 -0
  752. package/docs/learn/03-fetching-data.mdx +211 -0
  753. package/docs/learn/03b-access-control.mdx +130 -0
  754. package/docs/learn/04-loading-states.mdx +67 -0
  755. package/docs/learn/04b-the-flush-point.mdx +115 -0
  756. package/docs/learn/05-typed-params.mdx +275 -0
  757. package/docs/learn/06-forms-and-actions.mdx +146 -0
  758. package/docs/learn/07-typed-routes.mdx +132 -0
  759. package/docs/learn/08-streaming.mdx +146 -0
  760. package/docs/learn/09-caching.mdx +252 -0
  761. package/docs/learn/10-middleware.mdx +157 -0
  762. package/docs/learn/11-error-handling.mdx +173 -0
  763. package/docs/learn/12-client-navigation.mdx +176 -0
  764. package/docs/learn/13-configuration.mdx +166 -0
  765. package/docs/learn/14-deploying.mdx +287 -0
  766. package/docs/more/01-advanced-routing.mdx +343 -0
  767. package/docs/more/02-advanced-forms.mdx +137 -0
  768. package/docs/more/03-coming-from-nextjs.mdx +186 -0
  769. package/docs/more/04-metadata-and-fonts.mdx +193 -0
  770. package/docs/more/04b-mdx.mdx +209 -0
  771. package/docs/more/05-content-collections.mdx +90 -0
  772. package/docs/more/06-instrumentation.mdx +214 -0
  773. package/docs/more/07-security.mdx +129 -0
  774. package/docs/more/08-developer-experience.mdx +134 -0
  775. package/docs/more/40-why-timber.mdx +50 -0
  776. package/docs/more/41-timber-vs-nextjs.mdx +81 -0
  777. package/docs/more/42-timber-vs-others.mdx +68 -0
  778. package/docs/more/50-ai-agent-instructions.mdx +171 -0
  779. package/llms.txt +55 -0
  780. package/package.json +108 -26
  781. package/src/adapters/build-output-helper.ts +351 -0
  782. package/src/adapters/cloudflare-dev.ts +177 -0
  783. package/src/adapters/cloudflare-kv-cache.ts +204 -0
  784. package/src/adapters/cloudflare.ts +740 -129
  785. package/src/adapters/compress-module.ts +101 -88
  786. package/src/adapters/fs-identity.ts +156 -0
  787. package/src/adapters/nitro.ts +320 -120
  788. package/src/adapters/raw-imports.d.ts +5 -0
  789. package/src/adapters/shared.ts +274 -0
  790. package/src/adapters/types.ts +28 -7
  791. package/src/adapters/wrangler.d.ts +7 -0
  792. package/src/cache/cache-api.ts +107 -0
  793. package/src/cache/fast-hash.ts +5 -0
  794. package/src/cache/handler-store.ts +76 -0
  795. package/src/cache/index.ts +114 -21
  796. package/src/cache/invalidation-epoch.ts +93 -0
  797. package/src/cache/json-lossy-check.ts +75 -0
  798. package/src/cache/redis-handler.ts +197 -19
  799. package/src/cache/singleflight.ts +64 -6
  800. package/src/cache/sizeof.ts +33 -0
  801. package/src/cache/stable-stringify.ts +65 -2
  802. package/src/cache/store.ts +71 -0
  803. package/src/cache/stores/cloudflare-kv.ts +52 -0
  804. package/src/cache/stores/memory.ts +125 -0
  805. package/src/cache/stores/redis.ts +97 -0
  806. package/src/cache/stores/vercel.ts +59 -0
  807. package/src/cache/tag-aware-handler.ts +237 -0
  808. package/src/cache/timber-cache.ts +161 -36
  809. package/src/cdn/cloudflare-purge.ts +50 -0
  810. package/src/cdn/fastly-purge.ts +63 -0
  811. package/src/cdn/headers.ts +153 -0
  812. package/src/cdn/index.ts +17 -0
  813. package/src/cdn/purge-store.ts +34 -0
  814. package/src/cdn/workers-cache-purge.ts +30 -0
  815. package/src/cli-check.ts +458 -0
  816. package/src/cli-schema-sync.ts +401 -0
  817. package/src/cli.ts +221 -53
  818. package/src/client/browser-dev.ts +156 -1
  819. package/src/client/browser-entry/action-dispatch.ts +130 -0
  820. package/src/client/browser-entry/hmr.ts +70 -0
  821. package/src/client/browser-entry/hydrate.ts +198 -0
  822. package/src/client/browser-entry/index.ts +121 -0
  823. package/src/client/browser-entry/post-hydration.ts +122 -0
  824. package/src/client/browser-entry/router-init.ts +342 -0
  825. package/src/client/browser-entry/rsc-stream.ts +166 -0
  826. package/src/client/browser-entry/scroll.ts +50 -0
  827. package/src/client/error-boundary.tsx +210 -36
  828. package/src/client/error-reconstituter.tsx +79 -0
  829. package/src/client/form.tsx +31 -32
  830. package/src/client/history.ts +29 -7
  831. package/src/client/index.ts +78 -45
  832. package/src/client/internal.ts +59 -0
  833. package/src/client/link.tsx +397 -150
  834. package/src/client/navigation-api.ts +345 -0
  835. package/src/client/navigation-commit.ts +197 -0
  836. package/src/client/navigation-context.ts +43 -62
  837. package/src/client/navigation-root.tsx +580 -0
  838. package/src/client/nuqs-adapter.tsx +16 -3
  839. package/src/client/params-context.ts +192 -0
  840. package/src/client/router-effects.ts +231 -0
  841. package/src/client/router-lifecycle.ts +288 -0
  842. package/src/client/router-pipeline.ts +393 -0
  843. package/src/client/router-ref.ts +2 -2
  844. package/src/client/router-skew.ts +30 -0
  845. package/src/client/router-types.ts +230 -0
  846. package/src/client/router.ts +339 -410
  847. package/src/client/rsc-fetch.ts +530 -73
  848. package/src/client/segment-cache.ts +224 -38
  849. package/src/client/segment-outlet.tsx +141 -0
  850. package/src/client/segment-update-context.ts +42 -0
  851. package/src/client/shallow-url.ts +22 -0
  852. package/src/client/slot-context.ts +50 -0
  853. package/src/client/slot-outlet.tsx +22 -0
  854. package/src/client/slot-provider.tsx +32 -0
  855. package/src/client/ssr-data.ts +19 -5
  856. package/src/client/stale-client.ts +191 -0
  857. package/src/client/state.ts +16 -3
  858. package/src/client/top-loader.tsx +13 -10
  859. package/src/client/unload-guard.ts +34 -2
  860. package/src/client/use-cookie.ts +69 -17
  861. package/src/client/use-link-status.ts +7 -7
  862. package/src/client/use-pathname.ts +1 -0
  863. package/src/client/use-pending-navigation.ts +40 -0
  864. package/src/client/use-query-states.ts +206 -36
  865. package/src/client/use-router.ts +5 -2
  866. package/src/client/use-search-params.ts +31 -44
  867. package/src/client/{use-params.ts → use-segment-params.ts} +49 -23
  868. package/src/codec.ts +149 -0
  869. package/src/config-types.ts +282 -0
  870. package/src/config-validation.ts +330 -0
  871. package/src/content/index.ts +5 -13
  872. package/src/cookies/define-cookie.ts +222 -53
  873. package/src/cookies/index.ts +12 -1
  874. package/src/cookies/json-cookie.ts +105 -0
  875. package/src/cookies/validation.ts +192 -0
  876. package/src/dev-tools/404-page.ts +286 -0
  877. package/src/dev-tools/browser-logs.ts +55 -0
  878. package/src/dev-tools/dev-page-shell.ts +260 -0
  879. package/src/dev-tools/error-page.ts +331 -0
  880. package/src/dev-tools/holding-server.ts +187 -0
  881. package/src/dev-tools/hydration-overlay.ts +158 -0
  882. package/src/dev-tools/index.ts +83 -0
  883. package/src/dev-tools/instrumentation.ts +213 -0
  884. package/src/{server/dev-logger.ts → dev-tools/logger.ts} +33 -51
  885. package/src/{plugins/dev-logs.ts → dev-tools/logs.ts} +122 -26
  886. package/src/dev-tools/overlay.ts +469 -0
  887. package/src/dev-tools/stack-classifier.ts +75 -0
  888. package/src/dev-tools/terminal.ts +182 -0
  889. package/src/fonts/ast-walk.ts +235 -0
  890. package/src/fonts/ast.ts +477 -126
  891. package/src/fonts/bundle.ts +138 -0
  892. package/src/fonts/dev-middleware.ts +85 -0
  893. package/src/fonts/fallbacks.ts +0 -23
  894. package/src/fonts/google.ts +100 -18
  895. package/src/fonts/local.ts +9 -8
  896. package/src/fonts/paths.ts +58 -0
  897. package/src/fonts/pipeline.ts +348 -0
  898. package/src/fonts/transform.ts +311 -0
  899. package/src/fonts/types.ts +52 -1
  900. package/src/fonts/virtual-modules.ts +179 -0
  901. package/src/index.ts +468 -353
  902. package/src/params/codec-registry.ts +34 -0
  903. package/src/params/define-schema.ts +115 -0
  904. package/src/params/index.ts +17 -0
  905. package/src/params/resolve-schema.ts +84 -0
  906. package/src/plugin-context.ts +503 -0
  907. package/src/plugins/adapter-build.ts +229 -7
  908. package/src/plugins/build-manifest.ts +201 -26
  909. package/src/plugins/build-report.ts +259 -47
  910. package/src/plugins/cache.ts +243 -0
  911. package/src/plugins/callsite-ast.ts +472 -0
  912. package/src/plugins/callsite-jsx.ts +243 -0
  913. package/src/plugins/chunks.ts +74 -5
  914. package/src/plugins/client-chunks.ts +185 -0
  915. package/src/plugins/cloudflare-wasm.ts +141 -0
  916. package/src/plugins/content.ts +1 -1
  917. package/src/plugins/dev-server.ts +284 -94
  918. package/src/plugins/entries.ts +138 -16
  919. package/src/plugins/fonts.ts +228 -660
  920. package/src/plugins/mdx.ts +47 -10
  921. package/src/plugins/prebuilt-capture.ts +217 -0
  922. package/src/plugins/prebuilt-options-analysis.ts +175 -0
  923. package/src/plugins/prebuilt.ts +655 -0
  924. package/src/plugins/prerender-sugar.ts +328 -0
  925. package/src/plugins/request-dep/analysis.ts +447 -0
  926. package/src/plugins/request-dep/index.ts +376 -0
  927. package/src/plugins/request-dep/origin.ts +310 -0
  928. package/src/plugins/routing.ts +268 -277
  929. package/src/plugins/server-bundle.ts +89 -12
  930. package/src/plugins/shims.ts +240 -64
  931. package/src/plugins/static-build.ts +704 -66
  932. package/src/routing/codegen-shared.ts +39 -0
  933. package/src/routing/codegen-types.ts +62 -0
  934. package/src/routing/codegen-write.ts +139 -0
  935. package/src/routing/codegen.ts +339 -231
  936. package/src/routing/collision-probe.ts +438 -0
  937. package/src/routing/collision-spaces.ts +281 -0
  938. package/src/routing/convention-lint.ts +493 -0
  939. package/src/routing/export-detect.ts +448 -0
  940. package/src/routing/file-cache.ts +23 -0
  941. package/src/routing/index.ts +10 -1
  942. package/src/routing/interception.ts +894 -67
  943. package/src/routing/link-codegen.ts +280 -0
  944. package/src/routing/manifest-codegen.ts +226 -0
  945. package/src/routing/scanner.ts +368 -218
  946. package/src/routing/schema-validation.ts +155 -0
  947. package/src/routing/segment-classify.ts +280 -0
  948. package/src/routing/segment-codegen.ts +98 -0
  949. package/src/routing/segment-keys.ts +183 -0
  950. package/src/routing/slot-placement.ts +97 -0
  951. package/src/routing/types.ts +75 -26
  952. package/src/routing/walkers.ts +98 -0
  953. package/src/rsc-runtime/rsc.ts +9 -0
  954. package/src/rsc-runtime/ssr.ts +50 -0
  955. package/src/rsc-runtime/vendor-types.d.ts +7 -0
  956. package/src/schema-bridge.ts +380 -0
  957. package/src/search-params/define.ts +677 -0
  958. package/src/search-params/index.ts +14 -20
  959. package/src/search-params/parse-total.ts +91 -0
  960. package/src/search-params/serialize-equal.ts +14 -0
  961. package/src/search-params/wrappers.ts +150 -0
  962. package/src/server/access-gate.tsx +121 -51
  963. package/src/server/action-client.ts +120 -29
  964. package/src/server/action-encryption.ts +144 -0
  965. package/src/server/action-handler.ts +127 -38
  966. package/src/server/actions.ts +54 -57
  967. package/src/server/als-registry.ts +154 -20
  968. package/src/server/asset-headers.ts +15 -37
  969. package/src/server/body-limits.ts +10 -2
  970. package/src/server/build-manifest.ts +33 -57
  971. package/src/server/canonicalize.ts +6 -3
  972. package/src/server/chain-url-parts.ts +162 -0
  973. package/src/server/children-interception.ts +115 -0
  974. package/src/server/coalesce-tick.ts +75 -0
  975. package/src/server/compress.ts +43 -8
  976. package/src/server/cookie-context.ts +484 -0
  977. package/src/server/cookie-parsing.ts +163 -0
  978. package/src/server/csrf.ts +39 -6
  979. package/src/server/default-logger.ts +99 -0
  980. package/src/server/default-status-page.ts +127 -0
  981. package/src/server/deny-boundary.ts +516 -0
  982. package/src/server/deny-renderer.ts +181 -101
  983. package/src/server/dev-source-map.ts +31 -0
  984. package/src/server/early-hints-sender.ts +3 -2
  985. package/src/server/early-hints.ts +37 -27
  986. package/src/server/error-boundary-wrapper.ts +170 -44
  987. package/src/server/fallback-error.ts +79 -102
  988. package/src/server/flight-injection-state.ts +113 -0
  989. package/src/server/flight-scripts.ts +62 -0
  990. package/src/server/form-data.ts +124 -12
  991. package/src/server/head-response.ts +54 -0
  992. package/src/server/html-injector-core.ts +495 -0
  993. package/src/server/html-injectors.ts +271 -254
  994. package/src/server/index.ts +29 -185
  995. package/src/server/internal.ts +181 -0
  996. package/src/server/logger.ts +72 -36
  997. package/src/server/metadata-collector.ts +115 -0
  998. package/src/server/metadata-routes.ts +205 -24
  999. package/src/server/metadata.ts +21 -0
  1000. package/src/server/middleware-runner.ts +31 -4
  1001. package/src/server/node-stream-transforms.ts +336 -0
  1002. package/src/server/param-coercion.ts +189 -0
  1003. package/src/server/pipeline-helpers.ts +159 -0
  1004. package/src/server/pipeline-interception.ts +109 -33
  1005. package/src/server/pipeline-metadata.ts +14 -0
  1006. package/src/server/pipeline-outcome.ts +196 -0
  1007. package/src/server/pipeline-phases.ts +597 -0
  1008. package/src/server/pipeline.ts +321 -382
  1009. package/src/server/port-resolution.ts +215 -0
  1010. package/src/server/prebuilt/cache-key.ts +298 -0
  1011. package/src/server/prebuilt/capture-state.ts +89 -0
  1012. package/src/server/prebuilt/key-discipline.ts +53 -0
  1013. package/src/server/prebuilt/manifest-tag-index.ts +46 -0
  1014. package/src/server/prebuilt/overlay.ts +256 -0
  1015. package/src/server/prebuilt/payload-source.ts +201 -0
  1016. package/src/server/prebuilt/slots.ts +190 -0
  1017. package/src/server/prebuilt/synthetic-store.ts +121 -0
  1018. package/src/server/prebuilt-builder.ts +803 -0
  1019. package/src/server/prebuilt-runtime.ts +815 -0
  1020. package/src/server/primitives.ts +174 -90
  1021. package/src/server/publish-params.ts +42 -0
  1022. package/src/server/render-timeout.ts +108 -0
  1023. package/src/server/render-utils.ts +31 -0
  1024. package/src/server/request-context.ts +245 -333
  1025. package/src/server/request-dep.ts +37 -0
  1026. package/src/server/route-element-builder.ts +687 -307
  1027. package/src/server/route-handler.ts +39 -12
  1028. package/src/server/route-matcher.ts +162 -269
  1029. package/src/server/rsc-cache-key-guard.ts +164 -0
  1030. package/src/server/rsc-entry/action-middleware-runner.ts +167 -0
  1031. package/src/server/rsc-entry/api-handler.ts +67 -32
  1032. package/src/server/rsc-entry/deny-fallback.ts +93 -0
  1033. package/src/server/rsc-entry/error-renderer.ts +370 -94
  1034. package/src/server/rsc-entry/helpers.ts +226 -95
  1035. package/src/server/rsc-entry/index.ts +357 -330
  1036. package/src/server/rsc-entry/render-route.ts +308 -0
  1037. package/src/server/rsc-entry/revalidate-renderer.ts +350 -0
  1038. package/src/server/rsc-entry/rsc-payload.ts +188 -55
  1039. package/src/server/rsc-entry/rsc-stream.ts +122 -18
  1040. package/src/server/rsc-entry/ssr-bridge.ts +18 -5
  1041. package/src/server/rsc-entry/ssr-renderer.ts +299 -80
  1042. package/src/server/rsc-entry/wrap-action-dispatch.ts +186 -0
  1043. package/src/server/safe-load.ts +60 -0
  1044. package/src/server/sensitive-fields.ts +230 -0
  1045. package/src/server/server-only-guard-noop.js +3 -0
  1046. package/src/server/sitemap-generator.ts +339 -0
  1047. package/src/server/sitemap-handler.ts +157 -0
  1048. package/src/server/skippable-prefix.ts +74 -0
  1049. package/src/server/slot-interception.ts +168 -0
  1050. package/src/server/slot-resolver.ts +677 -294
  1051. package/src/server/ssr-bridge-types.ts +142 -0
  1052. package/src/server/ssr-entry.ts +216 -78
  1053. package/src/server/ssr-render.ts +345 -82
  1054. package/src/server/ssr-wrappers.tsx +142 -0
  1055. package/src/server/state-tree-diff.ts +85 -30
  1056. package/src/server/static-generator.ts +715 -0
  1057. package/src/server/static-not-found.ts +134 -0
  1058. package/src/server/status-code-resolver.ts +107 -148
  1059. package/src/server/stream-utils.ts +288 -0
  1060. package/src/server/tracing.ts +126 -14
  1061. package/src/server/tree-builder.ts +99 -168
  1062. package/src/server/tree-match.ts +262 -0
  1063. package/src/server/types.ts +83 -9
  1064. package/src/server/utils/element-type.ts +72 -0
  1065. package/src/server/utils/escape-html.ts +20 -0
  1066. package/src/server/utils/mdx-file.ts +22 -0
  1067. package/src/server/version-skew.ts +104 -0
  1068. package/src/server/workers-cache-bridge.ts +33 -0
  1069. package/src/shared/als-slots.ts +72 -0
  1070. package/src/shared/base-path.ts +80 -0
  1071. package/src/shared/href-validation.ts +159 -0
  1072. package/src/shared/merge-search-params.ts +55 -0
  1073. package/src/shared/param-value.ts +244 -0
  1074. package/src/shared/payload-root.ts +151 -0
  1075. package/src/shared/redirect-type.ts +17 -0
  1076. package/src/shared/rsc-cache-key.ts +269 -0
  1077. package/src/shared/rsc-error-envelope.ts +31 -0
  1078. package/src/shared/rsc-manifest.ts +29 -0
  1079. package/src/shared/rsc-media-type.ts +43 -0
  1080. package/src/shared/rsc-payload-path.ts +45 -0
  1081. package/src/shared/segment-info.ts +67 -0
  1082. package/src/shared/slot-params.ts +111 -0
  1083. package/src/shared/static-platform-files.ts +75 -0
  1084. package/src/shims/font-google.ts +1 -1
  1085. package/src/shims/font-local.ts +34 -0
  1086. package/src/shims/headers.ts +122 -1
  1087. package/src/shims/navigation-client.ts +36 -32
  1088. package/src/shims/navigation.ts +10 -7
  1089. package/src/utils/state-machine.ts +111 -0
  1090. package/dist/_chunks/als-registry-B7DbZ2hS.js +0 -41
  1091. package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
  1092. package/dist/_chunks/debug-B3Gypr3D.js +0 -108
  1093. package/dist/_chunks/debug-B3Gypr3D.js.map +0 -1
  1094. package/dist/_chunks/format-RyoGQL74.js +0 -164
  1095. package/dist/_chunks/format-RyoGQL74.js.map +0 -1
  1096. package/dist/_chunks/interception-BOoWmLUA.js +0 -676
  1097. package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
  1098. package/dist/_chunks/metadata-routes-Cjmvi3rQ.js +0 -153
  1099. package/dist/_chunks/metadata-routes-Cjmvi3rQ.js.map +0 -1
  1100. package/dist/_chunks/request-context-BQUC8PHn.js +0 -330
  1101. package/dist/_chunks/request-context-BQUC8PHn.js.map +0 -1
  1102. package/dist/_chunks/ssr-data-MjmprTmO.js.map +0 -1
  1103. package/dist/_chunks/tracing-CemImE6h.js +0 -187
  1104. package/dist/_chunks/tracing-CemImE6h.js.map +0 -1
  1105. package/dist/_chunks/use-cookie-DX-l1_5E.js +0 -91
  1106. package/dist/_chunks/use-cookie-DX-l1_5E.js.map +0 -1
  1107. package/dist/_chunks/use-query-states-D5KaffOK.js +0 -109
  1108. package/dist/_chunks/use-query-states-D5KaffOK.js.map +0 -1
  1109. package/dist/adapters/cloudflare.js.map +0 -1
  1110. package/dist/cache/index.js.map +0 -1
  1111. package/dist/cache/register-cached-function.d.ts +0 -17
  1112. package/dist/cache/register-cached-function.d.ts.map +0 -1
  1113. package/dist/client/browser-entry.d.ts +0 -21
  1114. package/dist/client/browser-entry.d.ts.map +0 -1
  1115. package/dist/client/error-boundary.js.map +0 -1
  1116. package/dist/client/head.d.ts +0 -16
  1117. package/dist/client/head.d.ts.map +0 -1
  1118. package/dist/client/link-status-provider.d.ts +0 -11
  1119. package/dist/client/link-status-provider.d.ts.map +0 -1
  1120. package/dist/client/segment-merger.d.ts +0 -119
  1121. package/dist/client/segment-merger.d.ts.map +0 -1
  1122. package/dist/client/stale-reload.d.ts +0 -44
  1123. package/dist/client/stale-reload.d.ts.map +0 -1
  1124. package/dist/client/transition-root.d.ts +0 -74
  1125. package/dist/client/transition-root.d.ts.map +0 -1
  1126. package/dist/client/use-navigation-pending.d.ts +0 -26
  1127. package/dist/client/use-navigation-pending.d.ts.map +0 -1
  1128. package/dist/client/use-params.d.ts.map +0 -1
  1129. package/dist/plugins/cache-transform.d.ts +0 -36
  1130. package/dist/plugins/cache-transform.d.ts.map +0 -1
  1131. package/dist/plugins/dev-error-overlay.d.ts +0 -60
  1132. package/dist/plugins/dev-error-overlay.d.ts.map +0 -1
  1133. package/dist/plugins/dev-logs.d.ts.map +0 -1
  1134. package/dist/plugins/dynamic-transform.d.ts +0 -72
  1135. package/dist/plugins/dynamic-transform.d.ts.map +0 -1
  1136. package/dist/plugins/server-action-exports.d.ts +0 -26
  1137. package/dist/plugins/server-action-exports.d.ts.map +0 -1
  1138. package/dist/routing/status-file-lint.d.ts +0 -33
  1139. package/dist/routing/status-file-lint.d.ts.map +0 -1
  1140. package/dist/search-params/analyze.d.ts +0 -54
  1141. package/dist/search-params/analyze.d.ts.map +0 -1
  1142. package/dist/search-params/builtin-codecs.d.ts +0 -105
  1143. package/dist/search-params/builtin-codecs.d.ts.map +0 -1
  1144. package/dist/search-params/codecs.d.ts +0 -53
  1145. package/dist/search-params/codecs.d.ts.map +0 -1
  1146. package/dist/search-params/create.d.ts +0 -106
  1147. package/dist/search-params/create.d.ts.map +0 -1
  1148. package/dist/search-params/registry.d.ts +0 -20
  1149. package/dist/search-params/registry.d.ts.map +0 -1
  1150. package/dist/server/client-module-map.d.ts +0 -47
  1151. package/dist/server/client-module-map.d.ts.map +0 -1
  1152. package/dist/server/dev-fetch-instrumentation.d.ts +0 -22
  1153. package/dist/server/dev-fetch-instrumentation.d.ts.map +0 -1
  1154. package/dist/server/dev-logger.d.ts.map +0 -1
  1155. package/dist/server/dev-span-processor.d.ts +0 -29
  1156. package/dist/server/dev-span-processor.d.ts.map +0 -1
  1157. package/dist/server/dev-warnings.d.ts +0 -129
  1158. package/dist/server/dev-warnings.d.ts.map +0 -1
  1159. package/dist/server/flush.d.ts +0 -74
  1160. package/dist/server/flush.d.ts.map +0 -1
  1161. package/dist/server/manifest-status-resolver.d.ts +0 -58
  1162. package/dist/server/manifest-status-resolver.d.ts.map +0 -1
  1163. package/dist/server/prerender.d.ts +0 -77
  1164. package/dist/server/prerender.d.ts.map +0 -1
  1165. package/dist/utils/directive-parser.d.ts +0 -70
  1166. package/dist/utils/directive-parser.d.ts.map +0 -1
  1167. package/src/cache/register-cached-function.ts +0 -103
  1168. package/src/client/browser-entry.ts +0 -678
  1169. package/src/client/head.ts +0 -61
  1170. package/src/client/link-status-provider.tsx +0 -30
  1171. package/src/client/segment-merger.ts +0 -339
  1172. package/src/client/stale-reload.ts +0 -87
  1173. package/src/client/transition-root.tsx +0 -166
  1174. package/src/client/use-navigation-pending.ts +0 -38
  1175. package/src/plugins/cache-transform.ts +0 -199
  1176. package/src/plugins/dev-error-overlay.ts +0 -230
  1177. package/src/plugins/dynamic-transform.ts +0 -161
  1178. package/src/plugins/server-action-exports.ts +0 -220
  1179. package/src/routing/status-file-lint.ts +0 -112
  1180. package/src/search-params/analyze.ts +0 -192
  1181. package/src/search-params/builtin-codecs.ts +0 -228
  1182. package/src/search-params/codecs.ts +0 -153
  1183. package/src/search-params/create.ts +0 -321
  1184. package/src/search-params/registry.ts +0 -31
  1185. package/src/server/client-module-map.ts +0 -58
  1186. package/src/server/dev-fetch-instrumentation.ts +0 -96
  1187. package/src/server/dev-span-processor.ts +0 -78
  1188. package/src/server/dev-warnings.ts +0 -283
  1189. package/src/server/flush.ts +0 -182
  1190. package/src/server/manifest-status-resolver.ts +0 -215
  1191. package/src/server/prerender.ts +0 -139
  1192. package/src/utils/directive-parser.ts +0 -529
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-api-DjNrIWRR.js","names":[],"sources":["../../src/cache/stable-stringify.ts","../../src/cache/singleflight.ts","../../src/cache/invalidation-epoch.ts","../../src/cache/timber-cache.ts","../../src/cache/handler-store.ts","../../src/cache/redis-handler.ts","../../src/cache/tag-aware-handler.ts","../../src/cache/index.ts","../../src/server/version-skew.ts","../../src/server/prebuilt/manifest-tag-index.ts","../../src/server/prebuilt/payload-source.ts","../../src/server/prebuilt/overlay.ts","../../src/cache/cache-api.ts"],"sourcesContent":["/**\n * Deterministic JSON serialization with sorted object keys.\n * Used for cache key generation — ensures { a: 1, b: 2 } and { b: 2, a: 1 }\n * produce the same string.\n *\n * Matches JSON.stringify semantics for toJSON: Date serializes to its ISO\n * string, URL to its href, and class instances with a custom toJSON use it.\n * Map and Set serialize their entries explicitly (insertion-order\n * independent). Values that would serialize lossily — functions, symbols,\n * and non-plain objects with no enumerable own state (RegExp, class\n * instances holding data behind getters or internal slots) — throw instead:\n * every such value would collapse to the same cache key, silently returning\n * one argument's cached data for another (TIM-1020).\n */\nexport function stableStringify(value: unknown): string {\n if (value === null || value === undefined) return String(value);\n\n const type = typeof value;\n if (type === 'function' || type === 'symbol') {\n throw new TypeError(\n `stableStringify: cannot serialize a ${type} into a stable cache key — ` +\n 'all such values would collide. Provide an explicit `key` option to cache().'\n );\n }\n if (type !== 'object') return JSON.stringify(value);\n\n if (Array.isArray(value)) {\n return '[' + value.map((item) => stableStringify(item)).join(',') + ']';\n }\n\n // Honor toJSON like JSON.stringify does (Date → ISO string, URL → href,\n // custom class serialization). JSON.stringify does not re-invoke toJSON\n // on the value it returns, so a toJSON that returns `this` falls through\n // to plain own-property serialization instead of recursing forever.\n const withToJSON = value as { toJSON?: () => unknown };\n if (typeof withToJSON.toJSON === 'function') {\n const json = withToJSON.toJSON();\n if (json !== value) return stableStringify(json);\n }\n\n // Map/Set have no enumerable own properties — serialize entries explicitly.\n // Entries are sorted after serialization so insertion order doesn't change\n // the key. The Map(/Set( prefixes can't collide with object ('{'), array\n // ('['), or string ('\"') output.\n if (value instanceof Map) {\n const entries = [...value.entries()].map(\n ([k, v]) => stableStringify(k) + '=>' + stableStringify(v)\n );\n return 'Map(' + entries.sort().join(',') + ')';\n }\n if (value instanceof Set) {\n const members = [...value].map((member) => stableStringify(member));\n return 'Set(' + members.sort().join(',') + ')';\n }\n\n const obj = value as Record<string, unknown>;\n const keys = Object.keys(obj).sort();\n const pairs: string[] = [];\n for (const key of keys) {\n if (obj[key] === undefined) continue;\n // A callable own toJSON only reaches this loop via the returns-`this`\n // fall-through above. It's the serialization protocol, not data —\n // JSON.stringify omits it too.\n if (key === 'toJSON' && typeof obj[key] === 'function') continue;\n pairs.push(JSON.stringify(key) + ':' + stableStringify(obj[key]));\n }\n\n // A non-plain object that serializes to '{}' carries its state behind\n // getters or internal slots (RegExp, sessions, ORM entities). Serializing\n // it would give every instance the same cache key.\n if (pairs.length === 0) {\n const proto = Object.getPrototypeOf(value);\n if (proto !== Object.prototype && proto !== null) {\n const name = (value as object).constructor?.name || 'Object';\n throw new TypeError(\n `stableStringify: ${name} instance has no serializable own state — ` +\n 'all instances would share one cache key. Provide an explicit `key` ' +\n 'option to cache(), or add a toJSON() method.'\n );\n }\n }\n\n return '{' + pairs.join(',') + '}';\n}\n","/**\n * Singleflight coalesces concurrent calls with the same key into a single\n * execution. All callers receive the same result (or error).\n *\n * Per-process, in-memory. Each process coalesces independently.\n *\n * An optional `timeoutMs` prevents hung `fn()` calls from permanently\n * blocking all future callers for that key. When set, `fn()` is raced\n * against a timeout — if the timeout fires first, the promise rejects\n * with `SingleflightTimeoutError`, `finally` cleans up the key, and\n * subsequent callers can retry. See TIM-518.\n */\n\nexport interface SingleflightOptions {\n /** Maximum time (ms) a coalesced call may run before being rejected. */\n timeoutMs?: number;\n}\n\nexport interface Singleflight {\n do<T>(key: string, fn: (signal: AbortSignal) => Promise<T>): Promise<T>;\n}\n\n/**\n * Error thrown when a singleflight call exceeds `timeoutMs`.\n * Exported so callers can distinguish timeout from other errors.\n */\nexport class SingleflightTimeoutError extends Error {\n constructor(key: string, timeoutMs: number) {\n super(`Singleflight timeout: key \"${key}\" exceeded ${timeoutMs}ms`);\n this.name = 'SingleflightTimeoutError';\n }\n}\n\nexport function createSingleflight(opts?: SingleflightOptions): Singleflight {\n const inflight = new Map<string, Promise<unknown>>();\n const timeoutMs = opts?.timeoutMs;\n\n return {\n do<T>(key: string, fn: (signal: AbortSignal) => Promise<T>): Promise<T> {\n const existing = inflight.get(key);\n if (existing) return existing as Promise<T>;\n\n const ac = new AbortController();\n let promise: Promise<T>;\n\n if (timeoutMs != null && timeoutMs > 0) {\n // Race fn() against a timeout to prevent hung calls from\n // permanently blocking the key. See TIM-518.\n // Abort the signal on timeout so the callback can skip\n // side effects (e.g. cache writes). See TIM-1092.\n promise = new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n ac.abort();\n reject(new SingleflightTimeoutError(key, timeoutMs));\n }, timeoutMs);\n try {\n fn(ac.signal).then(\n (value) => {\n clearTimeout(timer);\n resolve(value);\n },\n (err) => {\n clearTimeout(timer);\n reject(err);\n }\n );\n } catch (err) {\n clearTimeout(timer);\n reject(err);\n }\n });\n } else {\n promise = fn(ac.signal);\n }\n\n const tracked = promise.finally(() => {\n inflight.delete(key);\n });\n\n inflight.set(key, tracked);\n return tracked as Promise<T>;\n },\n };\n}\n","/**\n * Per-process invalidation epoch tracking for timber.cache (TIM-1028).\n *\n * handler.set for a cache miss runs after `fn()` resolves. An explicit\n * `cache.invalidate({ tag })` / `revalidateTag` that lands while fn is in\n * flight would otherwise be silently undone — the just-invalidated value\n * re-stored as fresh for the full TTL, resurrecting pre-mutation data.\n *\n * Every invalidation bumps a monotonic epoch and records it against the\n * invalidated key/tag. Before storing a result, the cache wrapper checks\n * whether its key or any of its tags were invalidated after fn started and\n * skips the write if so. Skipping is always safe: the only cost is one\n * extra cache miss on the next call.\n *\n * Scope: per-process, like the singleflight map. An invalidation issued by\n * another instance against a shared handler (Redis/KV) during fn flight is\n * not observable here — closing that window fully would require store-level\n * versioning, which no CacheHandler backend offers.\n */\n\nlet epoch = 0;\n\n/**\n * Last-invalidated epoch per `key:<k>` / `tag:<t>` entry. Insertion order is\n * epoch order (entries are re-inserted on update), so the oldest entry is\n * always first — pruning evicts lowest epochs.\n */\nconst lastInvalidated = new Map<string, number>();\n\n/**\n * Bound on tracked entries so high-cardinality tag invalidation (e.g.\n * per-user tags) cannot grow this map without limit.\n */\nconst MAX_TRACKED_ENTRIES = 10_000;\n\n/**\n * Highest epoch evicted from the map. Any execution that started at or\n * before this epoch conservatively counts as invalidated — history was\n * truncated, so we can no longer prove it wasn't.\n */\nlet evictedEpochFloor = 0;\n\n/** The current epoch. Capture before running fn(), pass to wasInvalidatedSince. */\nexport function currentInvalidationEpoch(): number {\n return epoch;\n}\n\n/**\n * Record an invalidation. Call BEFORE handler.invalidate() so an execution\n * whose set-check races the invalidation errs toward skipping the write.\n */\nexport function recordInvalidation(opts: { key?: string; tag?: string }): void {\n epoch++;\n if (opts.key) track(`key:${opts.key}`);\n if (opts.tag) track(`tag:${opts.tag}`);\n}\n\nfunction track(entry: string): void {\n lastInvalidated.delete(entry);\n lastInvalidated.set(entry, epoch);\n while (lastInvalidated.size > MAX_TRACKED_ENTRIES) {\n const oldest = lastInvalidated.entries().next().value;\n if (oldest === undefined) break;\n evictedEpochFloor = Math.max(evictedEpochFloor, oldest[1]);\n lastInvalidated.delete(oldest[0]);\n }\n}\n\n/**\n * Whether the key or any tag was invalidated after `startEpoch` (the epoch\n * captured when fn started executing).\n */\nexport function wasInvalidatedSince(startEpoch: number, key: string, tags: string[]): boolean {\n return lastInvalidationEpochFor(key, tags) > startEpoch;\n}\n\n/**\n * The highest epoch at which the key or any of the tags was invalidated\n * (0 if never). Used to scope the singleflight key: callers arriving after\n * an invalidation must not coalesce onto a flight that started before it —\n * they would receive the pre-invalidation result the invalidation was\n * issued to discard.\n */\nexport function lastInvalidationEpochFor(key: string, tags: string[]): number {\n let last = evictedEpochFloor;\n const keyEpoch = lastInvalidated.get(`key:${key}`);\n if (keyEpoch !== undefined && keyEpoch > last) last = keyEpoch;\n for (const tag of tags) {\n const tagEpoch = lastInvalidated.get(`tag:${tag}`);\n if (tagEpoch !== undefined && tagEpoch > last) last = tagEpoch;\n }\n return last;\n}\n","import type { CacheHandler, CacheOptions } from './index';\nimport { stableStringify } from './stable-stringify';\nimport { createSingleflight } from './singleflight';\nimport {\n currentInvalidationEpoch,\n lastInvalidationEpochFor,\n wasInvalidatedSince,\n} from './invalidation-epoch';\nimport { addSpanEventSync } from '../server/tracing.js';\nimport { logSwrRefetchFailed, swallow } from '../server/logger.js';\nimport { getWaitUntil } from '../server/waituntil-bridge.js';\nimport { fnv1aHash } from './fast-hash.js';\n\nlet defaultSingleflight = createSingleflight();\n\n/**\n * Per-key monotonic generation counter for CAS writes (TIM-1158).\n *\n * Unbounded, like the singleflight map — the key space is the same set of\n * cache keys the handler already tracks. Pruning was removed because it\n * desyncs from MemoryCacheHandler.generations: a pruned key restarts at 1\n * while the handler still holds the old higher generation, causing fresh\n * writes to be rejected as stale.\n */\nconst writeGenerations = new Map<string, number>();\nfunction nextGeneration(key: string): number {\n const gen = (writeGenerations.get(key) ?? 0) + 1;\n writeGenerations.set(key, gen);\n return gen;\n}\n\n/**\n * Set the timeout for the module-level default singleflight.\n * Called at framework boot with renderTimeoutMs from timber.config.ts so that\n * cache calls without a per-call timeoutMs still get deadlock protection.\n * See design/06-caching.md §\"Singleflight Timeout — Deadlock Risk\".\n */\nexport function setDefaultSingleflightTimeout(timeoutMs: number): void {\n defaultSingleflight = createSingleflight({ timeoutMs });\n}\n\n/**\n * Generate a cache key from function identity and serialized args.\n *\n * Uses FNV-1a (fast non-crypto hash) instead of SHA-256. Cache keys don't\n * need collision resistance — they need speed. The fnId prefix provides\n * namespace isolation; the hash covers the args.\n *\n * See TIM-370 for perf motivation.\n */\nfunction defaultKeyGenerator(fnId: string, args: unknown[]): string {\n const raw = fnId + ':' + stableStringify(args);\n return fnId + ':' + fnv1aHash(raw);\n}\n\n/**\n * Resolve tags from the options — supports static array or function form.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction resolveTags<Fn extends (...args: any[]) => any>(\n opts: CacheOptions<Fn>,\n args: Parameters<Fn>\n): string[] {\n if (!opts.tags) return [];\n if (Array.isArray(opts.tags)) return opts.tags;\n return opts.tags(...args);\n}\n\n/** Per-process count of byte-identical fn sources seen by deriveFallbackFnId. */\nconst fallbackIdOccurrences = new Map<string, number>();\nlet hasWarnedFallbackId = false;\n\n/**\n * Derive a fallback fnId for callsites the timber-cache-transform Vite plugin\n * could not statically detect (aliased bindings, user re-export wrappers).\n *\n * The base is fnv1a(fn.toString()) — deterministic across instances and cold\n * starts of the same build, so two *different* functions can never swap fnIds\n * by module-evaluation order (the TIM-997 poisoning scenario that the old\n * process-local counter allowed; see TIM-1054). A per-process occurrence\n * suffix disambiguates byte-identical duplicate sources. That residue is the\n * one remaining hazard: closures produced by the same factory share source\n * text but capture different values, and their occurrence order may differ\n * across instances — such callsites need an explicit `key` option.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction deriveFallbackFnId(fn: (...args: any[]) => any): string {\n const sourceHash = fnv1aHash(fn.toString());\n const occurrence = fallbackIdOccurrences.get(sourceHash) ?? 0;\n fallbackIdOccurrences.set(sourceHash, occurrence + 1);\n\n if (!hasWarnedFallbackId && typeof process !== 'undefined' && process.env?.NODE_ENV !== 'test') {\n hasWarnedFallbackId = true;\n console.warn(\n '[timber] cache() callsite has no build-time stable ID and no explicit `key` option — ' +\n 'the call is not statically visible to the timber Vite plugin (e.g. an aliased ' +\n 'binding like `const c = cache` or a re-export wrapper module). Falling back to a ' +\n 'function-source hash for the cache key. With a shared CacheHandler (Redis/KV) this ' +\n 'is safe for distinct functions, but byte-identical closures from a factory can swap ' +\n 'cache entries across instances. Provide an explicit `key` option to make the cache ' +\n 'key contract stable and auditable.'\n );\n }\n\n return `timber-cache:fn:${sourceHash}:${occurrence}`;\n}\n\n/**\n * Creates a cached wrapper around an async function.\n *\n * - FNV-1a default keys with normalized JSON args\n * - Singleflight: concurrent misses → single execution AND single\n * handler.set — the write happens inside the coalesced callback (TIM-1028)\n * - Writes are skipped when the key/tags were invalidated while fn was in\n * flight, so explicit invalidation is never silently undone (TIM-1028)\n * - SWR: serve stale immediately, background refetch\n * - Tags as string[] or function of args\n * - The handler is resolved per invocation via `getHandler`, never captured\n * at wrapper-creation time — module-scope cache() wrappers created before\n * the framework's boot wiring calls setCacheHandler() still use the\n * configured handler once it arrives (TIM-1029)\n * - No ALS dependency for correctness — cache() works outside a request\n * context. The waitUntil ALS bridge is read optionally so the SWR\n * background refetch survives handler return on Workers/Lambda.\n *\n * Cache hits/misses are recorded as OTEL span events on the enclosing\n * span (not child spans). The DevSpanProcessor reads these for dev log output.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createCache<Fn extends (...args: any[]) => Promise<any>>(\n fn: Fn,\n opts: CacheOptions<Fn>,\n getHandler: () => CacheHandler,\n stableId?: string\n): Fn {\n // With an explicit `key` option the fnId never reaches key generation, so\n // no fallback derivation (or warning) is needed in that case.\n const fnId = stableId ?? (opts.key ? undefined : deriveFallbackFnId(fn));\n\n // Per-call timeoutMs gets a dedicated singleflight instance. Otherwise\n // resolve defaultSingleflight per invocation (not captured at creation\n // time) so wrappers created before boot pick up the timeout once\n // setDefaultSingleflightTimeout is called (TIM-1032, same rationale as\n // getCacheHandler for TIM-1029).\n const perCallSf =\n opts.timeoutMs !== undefined ? createSingleflight({ timeoutMs: opts.timeoutMs }) : undefined;\n\n // Cast to Fn to preserve the original function's generic call signature.\n // Without this, generic type parameters (e.g. <T> in apiFetch<T>) are\n // erased and callers lose type safety on the return type.\n return (async (...args: Parameters<Fn>): Promise<Awaited<ReturnType<Fn>>> => {\n const sf = perCallSf ?? defaultSingleflight;\n const key = opts.key ? opts.key(...args) : defaultKeyGenerator(fnId as string, args);\n\n const cacheStart = performance.now();\n const cached = await getHandler().get(key);\n\n if (cached && !cached.stale) {\n // Record as OTEL span event on enclosing span (not a child span).\n // Fire-and-forget — no microtask overhead on the cache hot path.\n addSpanEventSync('timber.cache.hit', {\n key,\n duration_ms: Math.round(performance.now() - cacheStart),\n });\n return cached.value as Awaited<ReturnType<Fn>>;\n }\n\n // From here fn() will execute (SWR refetch or miss). Scope the\n // singleflight key by the last invalidation epoch affecting this\n // key/tags: a caller arriving after an invalidation must not coalesce\n // onto a flight that started before it — it would receive the\n // pre-invalidation result the invalidation was issued to discard.\n // NUL separator: cannot collide with user-provided key strings.\n const tags = resolveTags(opts, args);\n const flightKey = `${key}\\u0000${lastInvalidationEpochFor(key, tags)}`;\n\n /**\n * Run fn and store the result — exactly once per coalesced execution,\n * inside the singleflight callback. The write is skipped when:\n * - the key/tags were invalidated after fn started (TIM-1028), or\n * - the singleflight timed out (signal aborted) — the timed-out\n * flight's write could overwrite a newer value from a subsequent\n * flight (TIM-1092), or\n * - the handler rejects the write because a newer generation has\n * already been stored (TIM-1158 CAS guard).\n */\n const executeAndStore = async (signal: AbortSignal): Promise<Awaited<ReturnType<Fn>>> => {\n const startEpoch = currentInvalidationEpoch();\n const generation = nextGeneration(key);\n const result = await fn(...args);\n if (!signal.aborted && !wasInvalidatedSince(startEpoch, key, tags)) {\n try {\n await getHandler().set(key, result, { ttl: opts.ttl, tags, generation });\n } catch (err) {\n // Cache-write failure must not fail the request (TIM-1046).\n // JSON-serializing handlers (Redis, KV) throw on BigInt; network\n // errors can surface from any shared handler. The result is valid\n // — serve it uncached rather than rejecting a successful fn().\n swallow(err, `cache set failed for key \"${key}\"`);\n }\n }\n return result;\n };\n\n if (cached && cached.stale && opts.staleWhileRevalidate) {\n // Record stale cache hit as OTEL span event (fire-and-forget).\n addSpanEventSync('timber.cache.hit', {\n key,\n duration_ms: Math.round(performance.now() - cacheStart),\n stale: true,\n });\n // Serve stale immediately, trigger background refetch\n const refetch = sf\n .do(`swr:${flightKey}`, async (signal) => {\n try {\n await executeAndStore(signal);\n } catch (err) {\n // Failed refetch — stale entry continues to be served.\n logSwrRefetchFailed({ cacheKey: key, error: err });\n }\n })\n .catch(() => {\n // Singleflight promise rejection handled — stale continues.\n });\n // Platforms that cancel work when the handler returns (Cloudflare\n // Workers, Lambda) would otherwise kill the refetch mid-flight —\n // stale data re-served forever. Register the (never-rejecting)\n // refetch with the request's waitUntil; undefined outside a request\n // context or on platforms without lifecycle extension (Node servers\n // keep floating promises alive, so behavior there is unchanged).\n getWaitUntil()?.(refetch);\n return cached.value as Awaited<ReturnType<Fn>>;\n }\n\n // Cache miss (or stale without SWR) — execute with singleflight.\n // The handler.set lives inside the coalesced callback, so N concurrent\n // misses produce exactly one write (TIM-1028).\n const result = await sf.do(flightKey, executeAndStore);\n\n // Record cache miss as OTEL span event (fire-and-forget).\n addSpanEventSync('timber.cache.miss', {\n key,\n duration_ms: Math.round(performance.now() - cacheStart),\n });\n\n return result;\n }) as unknown as Fn;\n}\n","/**\n * Module-level cache handler singleton.\n *\n * Lazily initialized to MemoryCacheHandler on first access. The framework\n * replaces this at boot from timber.config.ts via setCacheHandler().\n *\n * This module avoids importing from ./index to prevent circular dependencies.\n */\n\n// Inline the interface to avoid circular import with index.ts\ninterface CacheHandlerLike {\n get(key: string): Promise<{ value: unknown; stale: boolean } | null>;\n set(key: string, value: unknown, opts: { ttl: number; tags: string[] }): Promise<void>;\n invalidate(opts: { key?: string; tag?: string }): Promise<void>;\n}\n\nlet handler: CacheHandlerLike | null = null;\n\nlet explicitlyConfigured = false;\n\n/** Replace the active cache handler. Called by the framework at boot. */\nexport function setCacheHandler(h: CacheHandlerLike): void {\n handler = h;\n explicitlyConfigured = true;\n}\n\n/** Whether the handler was explicitly configured (vs the default in-memory fallback). */\nexport function isCacheHandlerConfigured(): boolean {\n return explicitlyConfigured;\n}\n\n/**\n * Get the active cache handler. Creates a default MemoryCacheHandler on\n * first access if none has been set via setCacheHandler().\n */\nexport function getCacheHandler(): CacheHandlerLike {\n if (!handler) {\n // Inline a minimal LRU cache to avoid circular dep with index.ts.\n // In production, the framework always calls setCacheHandler() at boot.\n handler = createDefaultHandler();\n }\n return handler;\n}\n\nfunction createDefaultHandler(): CacheHandlerLike {\n const store = new Map<string, { value: unknown; expiresAt: number; tags: string[] }>();\n const maxEntries = 1000;\n\n return {\n async get(key) {\n const entry = store.get(key);\n if (!entry) return null;\n store.delete(key);\n store.set(key, entry);\n const stale = Date.now() > entry.expiresAt;\n return { value: entry.value, stale };\n },\n async set(key, value, opts) {\n if (store.has(key)) store.delete(key);\n while (store.size >= maxEntries) {\n const oldest = store.keys().next().value;\n if (oldest !== undefined) store.delete(oldest);\n else break;\n }\n store.set(key, { value, expiresAt: Date.now() + opts.ttl * 1000, tags: opts.tags });\n },\n async invalidate(opts) {\n if (opts.key) store.delete(opts.key);\n if (opts.tag) {\n for (const [key, entry] of store) {\n if (entry.tags.includes(opts.tag)) store.delete(key);\n }\n }\n },\n };\n}\n","import type { CacheHandler } from './index';\nimport { warnLossyJsonValue } from './json-lossy-check.js';\n\n/**\n * Minimal Redis client contract for `RedisCacheHandler`.\n *\n * This is deliberately NOT the native shape of any client library. ioredis,\n * node-redis v4, and @upstash/redis all disagree on TTL argument shapes\n * (positional `'EX'` vs `{ EX }` vs `{ ex }`), method casing (`sadd` vs\n * `sAdd`), and array handling in `del` — a contract that pattern-matches one\n * client lets another silently drop the expiry (TIM-1030: node-redis ignored\n * the positional `'EX'` and wrote keys with no TTL). Instead, TTL semantics\n * are explicit in the signature and you adapt your client with a thin\n * wrapper, so a mismatch is a type error rather than silent unbounded\n * keyspace growth.\n *\n * @example ioredis\n * ```ts\n * import Redis from 'ioredis';\n * const redis = new Redis(process.env.REDIS_URL);\n * const client: RedisClient = {\n * get: (k) => redis.get(k),\n * set: (k, v, ttl) => redis.set(k, v, 'EX', ttl),\n * expireNX: (k, s) => redis.expire(k, s, 'NX'),\n * expireGT: (k, s) => redis.expire(k, s, 'GT'),\n * del: (k) => redis.del(k),\n * sadd: (k, ...m) => redis.sadd(k, ...m),\n * srem: (k, ...m) => redis.srem(k, ...m),\n * smembers: (k) => redis.smembers(k),\n * ttl: (k) => redis.ttl(k),\n * execMulti: async (ops) => {\n * const p = redis.multi();\n * for (const op of ops) {\n * switch (op.op) {\n * case 'set': p.set(op.key, op.value, 'EX', op.ttlSeconds); break;\n * case 'sadd': p.sadd(op.key, ...op.members); break;\n * case 'expireNX': p.expire(op.key, op.seconds, 'NX'); break;\n * case 'expireGT': p.expire(op.key, op.seconds, 'GT'); break;\n * case 'del': p.del(op.key); break;\n * }\n * }\n * await p.exec();\n * },\n * };\n * ```\n *\n * @example node-redis v4\n * ```ts\n * import { createClient } from 'redis';\n * const redis = createClient({ url: process.env.REDIS_URL });\n * await redis.connect();\n * const client: RedisClient = {\n * get: (k) => redis.get(k),\n * set: (k, v, ttl) => redis.set(k, v, { EX: ttl }),\n * expireNX: (k, s) => redis.expire(k, s, 'NX'),\n * expireGT: (k, s) => redis.expire(k, s, 'GT'),\n * del: (k) => redis.del(k),\n * sadd: (k, ...m) => redis.sAdd(k, m),\n * srem: (k, ...m) => redis.sRem(k, m),\n * smembers: (k) => redis.sMembers(k),\n * ttl: (k) => redis.ttl(k),\n * };\n * ```\n *\n * @example @upstash/redis\n * ```ts\n * import { Redis } from '@upstash/redis';\n * // automaticDeserialization must be off: the handler stores JSON strings\n * // and parses them itself — auto-parsing would hand back objects.\n * const redis = new Redis({ url, token, automaticDeserialization: false });\n * const client: RedisClient = {\n * get: (k) => redis.get(k),\n * set: (k, v, ttl) => redis.set(k, v, { ex: ttl }),\n * expireNX: (k, s) => redis.expire(k, s, 'NX'),\n * expireGT: (k, s) => redis.expire(k, s, 'GT'),\n * del: (k) => redis.del(k),\n * sadd: (k, ...m) => redis.sadd(k, m[0], ...m.slice(1)),\n * srem: (k, ...m) => redis.srem(k, m[0], ...m.slice(1)),\n * smembers: (k) => redis.smembers(k),\n * ttl: (k) => redis.ttl(k),\n * };\n * ```\n */\nexport type RedisWriteOp =\n | { op: 'set'; key: string; value: string; ttlSeconds: number }\n | { op: 'sadd'; key: string; members: string[] }\n | { op: 'expireNX'; key: string; seconds: number }\n | { op: 'expireGT'; key: string; seconds: number }\n | { op: 'del'; key: string };\n\nexport interface RedisClient {\n /** `GET key` — the stored string, or null when absent. */\n get(key: string): Promise<string | null>;\n /**\n * `SET key value EX ttlSeconds` — store with an expiry. The TTL is a\n * required positional argument so no adapter can forget it.\n */\n set(key: string, value: string, ttlSeconds: number): Promise<unknown>;\n /**\n * `EXPIRE key seconds NX` — set the TTL only if the key has no existing\n * expiry (Redis 7.0+). Used to set the initial TTL on new tag sets.\n */\n expireNX(key: string, seconds: number): Promise<unknown>;\n /**\n * `EXPIRE key seconds GT` — update the TTL only if the new value is greater\n * than the current one (Redis 7.0+). Used to extend tag set TTLs without\n * allowing a short-TTL writer to shrink them.\n */\n expireGT(key: string, seconds: number): Promise<unknown>;\n /** `DEL key` — delete a single key. Multi-key deletes loop per key. */\n del(key: string): Promise<unknown>;\n /** `SADD key member [member ...]` — add members to a set. */\n sadd(key: string, ...members: string[]): Promise<unknown>;\n /** `SREM key member [member ...]` — remove members from a set. */\n srem(key: string, ...members: string[]): Promise<unknown>;\n /** `SMEMBERS key` — all members of a set. */\n smembers(key: string): Promise<string[]>;\n /**\n * `TTL key` — remaining time-to-live in seconds. Returns -2 if the key does\n * not exist, -1 if the key exists but has no expiry.\n */\n ttl(key: string): Promise<number>;\n /**\n * Execute a batch of write operations atomically via `MULTI/EXEC`.\n * When provided, `set()` uses this to make tag-index writes and the data\n * write atomic — no `invalidate({tag})` can interleave. Optional: when\n * absent, operations run sequentially (correct but not race-free).\n */\n execMulti?(ops: RedisWriteOp[]): Promise<void>;\n}\n\nconst KEY_PREFIX = 'timber:cache:';\nconst TAG_PREFIX = 'timber:tag:';\n\n/**\n * Redis-backed CacheHandler for distributed caching.\n *\n * All instances sharing the same Redis see each other's cache entries and\n * invalidations. Tag-based invalidation uses Redis Sets to track which keys\n * belong to which tags.\n *\n * Bring your own Redis client wrapped to the {@link RedisClient} contract —\n * see the adapter examples on the interface for ioredis, node-redis v4, and\n * @upstash/redis.\n */\nexport class RedisCacheHandler implements CacheHandler {\n private client: RedisClient;\n private prefix: string;\n\n constructor(client: RedisClient, opts?: { prefix?: string }) {\n this.client = client;\n this.prefix = opts?.prefix ?? '';\n }\n\n private cacheKey(key: string): string {\n return `${this.prefix}${KEY_PREFIX}${key}`;\n }\n\n private tagKey(tag: string): string {\n return `${this.prefix}${TAG_PREFIX}${tag}`;\n }\n\n async get(key: string): Promise<{ value: unknown; stale: boolean } | null> {\n const raw = await this.client.get(this.cacheKey(key));\n if (raw === null) return null;\n\n const entry = JSON.parse(raw) as { value: unknown; expiresAt: number };\n const stale = Date.now() > entry.expiresAt;\n return { value: entry.value, stale };\n }\n\n async set(\n key: string,\n value: unknown,\n opts: { ttl: number; tags: string[]; generation?: number }\n ): Promise<void> {\n warnLossyJsonValue(value, key);\n const ck = this.cacheKey(key);\n const expiresAt = Date.now() + opts.ttl * 1000;\n\n // Serialize upfront so BigInt/non-serializable errors throw before any\n // writes — prevents tag indexes pointing at stale data from a prior set().\n const payload = JSON.stringify({ value, expiresAt, tags: opts.tags });\n\n // Redis TTL with generous margin beyond the logical TTL to allow SWR reads\n // on stale entries. The logical staleness is determined by expiresAt.\n // We use 2x TTL + 60s as the Redis expiry so stale entries remain\n // available for SWR background refetches.\n const redisTtlSeconds = Math.max(opts.ttl * 2 + 60, 120);\n\n const writeOps: RedisWriteOp[] = [];\n for (const tag of opts.tags) {\n writeOps.push({ op: 'sadd', key: this.tagKey(tag), members: [key] });\n writeOps.push({ op: 'expireNX', key: this.tagKey(tag), seconds: redisTtlSeconds });\n writeOps.push({ op: 'expireGT', key: this.tagKey(tag), seconds: redisTtlSeconds });\n }\n writeOps.push({ op: 'set', key: ck, value: payload, ttlSeconds: redisTtlSeconds });\n\n if (this.client.execMulti) {\n await this.client.execMulti(writeOps);\n } else {\n for (const op of writeOps) {\n await this.execOp(op);\n }\n }\n }\n\n private async execOp(op: RedisWriteOp): Promise<void> {\n switch (op.op) {\n case 'set':\n await this.client.set(op.key, op.value, op.ttlSeconds);\n break;\n case 'sadd':\n await this.client.sadd(op.key, ...op.members);\n break;\n case 'expireNX':\n await this.client.expireNX(op.key, op.seconds);\n break;\n case 'expireGT':\n await this.client.expireGT(op.key, op.seconds);\n break;\n case 'del':\n await this.client.del(op.key);\n break;\n }\n }\n\n async invalidate(opts: { key?: string; tag?: string }): Promise<void> {\n if (opts.key) {\n const raw = await this.client.get(this.cacheKey(opts.key));\n if (raw !== null) {\n const entry = JSON.parse(raw) as { tags?: string[] };\n if (entry.tags) {\n await Promise.all(entry.tags.map((tag) => this.client.srem(this.tagKey(tag), opts.key!)));\n }\n }\n await this.client.del(this.cacheKey(opts.key));\n }\n\n if (opts.tag) {\n const tk = this.tagKey(opts.tag);\n const keys = await this.client.smembers(tk);\n\n // Re-check each member before deleting — the tag set can contain stale\n // memberships from entries whose tags changed since they were added.\n // Mirrors TagAwareCacheHandler's eager strategy (tag-aware-handler.ts:183-198).\n await Promise.all(\n keys.map(async (k) => {\n const raw = await this.client.get(this.cacheKey(k));\n if (raw === null) {\n await this.client.srem(tk, k);\n return;\n }\n const entry = JSON.parse(raw) as { tags?: string[] };\n if (entry.tags?.includes(opts.tag!)) {\n await this.client.del(this.cacheKey(k));\n }\n await this.client.srem(tk, k);\n })\n );\n\n // Clean up the now-empty tag set so it doesn't consume memory\n const remaining = await this.client.smembers(tk);\n if (remaining.length === 0) {\n await this.client.del(tk);\n }\n }\n }\n}\n","/**\n * TagAwareCacheHandler — wraps any CacheStore and adds tag-based invalidation.\n *\n * Three strategies, selected by store capabilities (best available wins):\n *\n * 1. **Native** (store has setWithTags + invalidateTag): Delegates entirely.\n * The store owns tag indexing. Used for Vercel Runtime Cache, DO-backed\n * stores, or any platform with first-class tag support.\n *\n * 2. **Eager** (store has sadd/smembers/srem/sdel): Maintains an inverted\n * index via atomic set operations. Invalidation enumerates the set and\n * deletes entries. Used for Redis.\n *\n * 3. **Lazy** (bare get/set/del only): Version-stamps entries with tag\n * counters. Invalidation bumps a counter (O(1)). Reads validate stored\n * versions against current. Race-free, correct under eventual consistency.\n * Used for Cloudflare KV.\n *\n * Implements the CacheHandler interface consumed by timber-cache.ts.\n */\n\nimport type { CacheHandler } from './index';\nimport type { CacheStore } from './store';\n\nconst DATA_PREFIX = 'd:';\nconst TAG_SET_PREFIX = 'ts:';\nconst TAG_VERSION_PREFIX = 'tv:';\n\ntype Strategy = 'native' | 'eager' | 'lazy';\n\n/** Stored entry format for eager strategy. */\ninterface EagerEntry {\n value: unknown;\n expiresAt: number;\n tags: string[];\n}\n\n/** Stored entry format for lazy (version-stamp) strategy. */\ninterface LazyEntry {\n value: unknown;\n expiresAt: number;\n tags: string[];\n tagVersions: Record<string, number>;\n}\n\nfunction detectStrategy(store: CacheStore): Strategy {\n if (store.setWithTags && store.invalidateTag) return 'native';\n if (store.sadd && store.smembers && store.srem && store.sdel) return 'eager';\n return 'lazy';\n}\n\nexport class TagAwareCacheHandler implements CacheHandler {\n private store: CacheStore;\n private prefix: string;\n private strategy: Strategy;\n\n constructor(store: CacheStore, opts?: { prefix?: string }) {\n this.store = store;\n this.prefix = opts?.prefix ?? 'timber:';\n this.strategy = detectStrategy(store);\n }\n\n get consistency(): 'strong' | 'eventual' | 'local' {\n return this.store.consistency;\n }\n\n private dataKey(key: string): string {\n return `${this.prefix}${DATA_PREFIX}${key}`;\n }\n\n /** Namespace tags for native stores so prefix isolates shared stores. */\n private prefixTags(tags: string[]): string[] {\n return tags.map((t) => `${this.prefix}${t}`);\n }\n\n private tagSetKey(tag: string): string {\n return `${this.prefix}${TAG_SET_PREFIX}${tag}`;\n }\n\n private tagVersionKey(tag: string): string {\n return `${this.prefix}${TAG_VERSION_PREFIX}${tag}`;\n }\n\n async get(key: string): Promise<{ value: unknown; stale: boolean } | null> {\n const raw = await this.store.get(this.dataKey(key));\n if (raw === null) return null;\n\n if (this.strategy === 'native' || this.strategy === 'eager') {\n const entry = JSON.parse(raw) as EagerEntry;\n const stale = Date.now() > entry.expiresAt;\n return { value: entry.value, stale };\n }\n\n // Lazy: validate tag versions before returning\n const entry = JSON.parse(raw) as LazyEntry;\n if (entry.tags.length > 0) {\n const currentVersions = await this.getTagVersions(entry.tags);\n for (const tag of entry.tags) {\n const stored = entry.tagVersions[tag] ?? 0;\n const current = currentVersions[tag] ?? 0;\n if (current > stored) return null;\n }\n }\n const stale = Date.now() > entry.expiresAt;\n return { value: entry.value, stale };\n }\n\n async set(\n key: string,\n value: unknown,\n opts: { ttl: number; tags: string[]; generation?: number }\n ): Promise<void> {\n const physicalTtl = Math.max(opts.ttl * 2 + 60, 120);\n\n if (this.strategy === 'native') {\n const entry: EagerEntry = {\n value,\n expiresAt: Date.now() + opts.ttl * 1000,\n tags: opts.tags,\n };\n const payload = JSON.stringify(entry);\n if (opts.tags.length > 0) {\n await this.store.setWithTags!(\n this.dataKey(key),\n payload,\n physicalTtl,\n this.prefixTags(opts.tags)\n );\n } else {\n await this.store.set(this.dataKey(key), payload, physicalTtl);\n }\n return;\n }\n\n if (this.strategy === 'eager') {\n const entry: EagerEntry = {\n value,\n expiresAt: Date.now() + opts.ttl * 1000,\n tags: opts.tags,\n };\n await this.store.set(this.dataKey(key), JSON.stringify(entry), physicalTtl);\n if (opts.tags.length > 0) {\n await Promise.all(\n opts.tags.map((tag) => this.store.sadd!(this.tagSetKey(tag), [key], physicalTtl))\n );\n }\n return;\n }\n\n // Lazy: snapshot current tag versions into the entry\n const tagVersions = opts.tags.length > 0 ? await this.getTagVersions(opts.tags) : {};\n const entry: LazyEntry = {\n value,\n expiresAt: Date.now() + opts.ttl * 1000,\n tags: opts.tags,\n tagVersions,\n };\n await this.store.set(this.dataKey(key), JSON.stringify(entry), physicalTtl);\n }\n\n async invalidate(opts: { key?: string; tag?: string }): Promise<void> {\n if (opts.key) {\n if (this.strategy === 'eager') {\n const raw = await this.store.get(this.dataKey(opts.key));\n if (raw !== null) {\n const entry = JSON.parse(raw) as EagerEntry;\n if (entry.tags.length > 0) {\n await Promise.all(\n entry.tags.map((tag) => this.store.srem!(this.tagSetKey(tag), [opts.key!]))\n );\n }\n }\n }\n await this.store.del(this.dataKey(opts.key));\n }\n\n if (opts.tag) {\n const tag = opts.tag;\n if (this.strategy === 'native') {\n await this.store.invalidateTag!(`${this.prefix}${tag}`);\n } else if (this.strategy === 'eager') {\n const members = await this.store.smembers!(this.tagSetKey(tag));\n // Verify each member still carries the tag before deleting — the set\n // can contain stale memberships from overwritten entries or LRU eviction.\n // Remove only the snapshot members (via srem, not sdel) so concurrent\n // writes that add new members between smembers() and cleanup are preserved.\n await Promise.all(\n members.map(async (k) => {\n const raw = await this.store.get(this.dataKey(k));\n if (raw === null) {\n await this.store.srem!(this.tagSetKey(tag), [k]);\n return;\n }\n const entry = JSON.parse(raw) as EagerEntry;\n if (entry.tags.includes(tag)) {\n await this.store.del(this.dataKey(k));\n await this.store.srem!(this.tagSetKey(tag), [k]);\n } else {\n await this.store.srem!(this.tagSetKey(tag), [k]);\n }\n })\n );\n } else {\n await this.bumpTagVersion(opts.tag);\n }\n }\n }\n\n // --- Lazy strategy helpers ---\n\n private async getTagVersions(tags: string[]): Promise<Record<string, number>> {\n const versions: Record<string, number> = {};\n await Promise.all(\n tags.map(async (tag) => {\n const raw = await this.store.get(this.tagVersionKey(tag));\n versions[tag] = raw !== null ? parseInt(raw, 10) : 0;\n })\n );\n return versions;\n }\n\n private async bumpTagVersion(tag: string): Promise<void> {\n const key = this.tagVersionKey(tag);\n const raw = await this.store.get(key);\n const stored = raw !== null ? parseInt(raw, 10) : 0;\n // max(stored, now) + 1: strictly advancing even within the same\n // millisecond (two bumps in 1ms produce N, N+1 not N, N). On\n // eventually-consistent stores the read can be stale, but Date.now()\n // provides a floor — regression only if BOTH the read is stale AND the\n // clock is behind, bounded by the store's propagation window (~60s).\n const version = Math.max(stored, Date.now()) + 1;\n // Version keys must outlive all data entries stamped with them. Data\n // entries use physical TTL of max(ttl*2+60, 120); 365 days exceeds any\n // practical cache lifetime.\n await this.store.set(key, String(version), 365 * 86400);\n }\n}\n","// @timber-js/app/cache — Caching primitives\n\nimport { estimateByteSize } from './sizeof.js';\n\nexport interface CacheHandler {\n get(key: string): Promise<{ value: unknown; stale: boolean } | null>;\n set(\n key: string,\n value: unknown,\n opts: { ttl: number; tags: string[]; generation?: number }\n ): Promise<void>;\n invalidate(opts: { key?: string; tag?: string }): Promise<void>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface CacheOptions<Fn extends (...args: any[]) => any> {\n ttl: number;\n key?: (...args: Parameters<Fn>) => string;\n staleWhileRevalidate?: boolean;\n tags?: string[] | ((...args: Parameters<Fn>) => string[]);\n /** Timeout (ms) for singleflight-coalesced calls. Prevents hung fn() from\n * permanently blocking all future callers for the same cache key. See TIM-518. */\n timeoutMs?: number;\n}\n\nexport interface MemoryCacheHandlerOptions {\n /** Maximum number of entries. Oldest accessed entries are evicted first. Default: 1000. */\n maxEntries?: number;\n /**\n * @deprecated Use `maxEntries` instead. Will be removed in a future release.\n * Alias for `maxEntries` — maximum number of entries (not bytes).\n */\n maxSize?: number;\n /** Maximum total byte budget for all cached values. Oldest entries are evicted when exceeded. Default: no limit. */\n maxBytes?: number;\n /** Maximum byte size for a single cache entry. Entries exceeding this are silently dropped. Default: no limit. */\n maxEntryBytes?: number;\n}\n\nexport class MemoryCacheHandler implements CacheHandler {\n private store = new Map<\n string,\n { value: unknown; expiresAt: number; tags: string[]; byteSize: number }\n >();\n private generations = new Map<string, number>();\n private maxEntries: number;\n private maxBytes: number | undefined;\n private maxEntryBytes: number | undefined;\n private currentBytes = 0;\n private readonly _trackBytes: boolean;\n\n constructor(opts?: MemoryCacheHandlerOptions) {\n // maxEntries takes precedence over deprecated maxSize\n this.maxEntries = opts?.maxEntries ?? opts?.maxSize ?? 1000;\n this.maxBytes = opts?.maxBytes;\n this.maxEntryBytes = opts?.maxEntryBytes;\n this._trackBytes = this.maxBytes !== undefined || this.maxEntryBytes !== undefined;\n }\n\n async get(key: string) {\n const entry = this.store.get(key);\n if (!entry) return null;\n\n // Move to end of Map (most recently used) for LRU ordering\n this.store.delete(key);\n this.store.set(key, entry);\n\n const stale = Date.now() > entry.expiresAt;\n return { value: entry.value, stale };\n }\n\n async set(\n key: string,\n value: unknown,\n opts: { ttl: number; tags: string[]; generation?: number }\n ) {\n // CAS guard: skip write if a newer generation has already been written\n if (opts.generation !== undefined) {\n const current = this.generations.get(key) ?? 0;\n if (opts.generation < current) return;\n }\n\n const byteSize = this._trackBytes ? estimateByteSize(value) : 0;\n\n // Reject entries exceeding per-entry byte limit\n if (this.maxEntryBytes !== undefined && byteSize > this.maxEntryBytes) {\n return;\n }\n\n // If key already exists, delete first to refresh insertion order and reclaim bytes\n if (this.store.has(key)) {\n const existing = this.store.get(key)!;\n this.currentBytes -= existing.byteSize;\n this.store.delete(key);\n }\n\n // Evict oldest entries (front of Map) if at entry count capacity\n while (this.store.size >= this.maxEntries) {\n this.evictOldest();\n }\n\n // Evict oldest entries if byte budget would be exceeded\n if (this.maxBytes !== undefined) {\n while (this.currentBytes + byteSize > this.maxBytes && this.store.size > 0) {\n this.evictOldest();\n }\n // If the single entry exceeds the total byte budget, don't store it\n if (this.currentBytes + byteSize > this.maxBytes) {\n return;\n }\n }\n\n // Record generation only after all admission checks pass\n if (opts.generation !== undefined) {\n this.generations.set(key, opts.generation);\n }\n\n this.store.set(key, {\n value,\n expiresAt: Date.now() + opts.ttl * 1000,\n tags: opts.tags,\n byteSize,\n });\n this.currentBytes += byteSize;\n }\n\n async invalidate(opts: { key?: string; tag?: string }) {\n if (opts.key) {\n const entry = this.store.get(opts.key);\n if (entry) {\n this.currentBytes -= entry.byteSize;\n this.store.delete(opts.key);\n }\n this.generations.delete(opts.key);\n }\n if (opts.tag) {\n for (const [key, entry] of this.store) {\n if (entry.tags.includes(opts.tag)) {\n this.currentBytes -= entry.byteSize;\n this.store.delete(key);\n this.generations.delete(key);\n }\n }\n }\n }\n\n /** Number of entries currently in the cache. */\n get size(): number {\n return this.store.size;\n }\n\n /** Estimated total byte size of all cached values. Only tracked when maxBytes or maxEntryBytes is configured; returns 0 otherwise. */\n get bytes(): number {\n return this.currentBytes;\n }\n\n /** Evict the oldest entry (front of Map). */\n private evictOldest(): void {\n const oldest = this.store.keys().next().value;\n if (oldest !== undefined) {\n const entry = this.store.get(oldest)!;\n this.currentBytes -= entry.byteSize;\n this.store.delete(oldest);\n this.generations.delete(oldest);\n }\n }\n}\n\nexport { RedisCacheHandler } from './redis-handler';\nexport type { RedisClient, RedisWriteOp } from './redis-handler';\nexport { cache } from './cache-api';\nexport { setCacheHandler, getCacheHandler } from './handler-store';\nexport { setDefaultSingleflightTimeout } from './timber-cache';\n// NOTE: registerCachedFunction (runtime for 'use cache' directive) removed.\n// Future feature pending design doc. See design/06-caching.md.\nexport { estimateByteSize } from './sizeof';\n\n// --- Cache Store layering (design/46) ---\nexport { TagAwareCacheHandler } from './tag-aware-handler';\nexport type { CacheStore } from './store';\n// stableStringify, createSingleflight, and SingleflightTimeoutError are\n// internal utilities used by the cache implementation. They are not\n// re-exported here — import directly from the source files if needed\n// within the package. See TIM-720.\n","/**\n * Version Skew Detection — graceful recovery when stale clients hit new deployments.\n *\n * When a new version of the app is deployed, clients with open tabs still have\n * the old JavaScript bundle. Without version skew handling, these stale clients\n * will experience:\n *\n * 1. Server action calls that crash (action IDs are content-hashed)\n * 2. Chunk load failures (old filenames gone from CDN)\n * 3. RSC payload mismatches (component references differ between builds)\n *\n * This module implements deployment ID comparison:\n * - A per-build deployment ID is generated at build time (see build-manifest.ts)\n * - The client sends it via `X-Timber-Deployment-Id` header on every RSC/action request\n * - The server compares it against the current build's ID\n * - On mismatch: signal the client to reload (not crash)\n *\n * The deployment ID is always-on in production. Dev mode skips the check\n * (HMR handles code updates without full reloads).\n *\n * See design/25-production-deployments.md, TIM-446\n */\n\n// ─── Constants ───────────────────────────────────────────────────\n\n/** Header sent by the client with every RSC/action request. */\nexport const DEPLOYMENT_ID_HEADER = 'X-Timber-Deployment-Id';\n\n/** Response header that signals the client to do a full page reload. */\nexport const RELOAD_HEADER = 'X-Timber-Reload';\n\n// ─── Deployment ID ───────────────────────────────────────────────\n\n/**\n * The current build's deployment ID. Set at startup from the manifest init\n * module (globalThis.__TIMBER_DEPLOYMENT_ID__). Null in dev mode.\n */\nlet currentDeploymentId: string | null = null;\n\n/**\n * Set the current deployment ID. Called once at server startup from the\n * manifest init module. In dev mode this is never called (deployment ID\n * checks are skipped).\n */\nexport function setDeploymentId(id: string): void {\n currentDeploymentId = id;\n}\n\n/**\n * Get the current deployment ID. Returns null in dev mode.\n */\nexport function getDeploymentId(): string | null {\n return currentDeploymentId;\n}\n\n// ─── Skew Detection ──────────────────────────────────────────────\n\n/** Result of a version skew check. */\nexport interface SkewCheckResult {\n /** Whether the client's deployment ID matches the server's. */\n ok: boolean;\n /** The client's deployment ID (null if header not sent — e.g., initial page load). */\n clientId: string | null;\n}\n\n/**\n * Check if a request's deployment ID matches the current build.\n *\n * Returns `{ ok: true }` when:\n * - Dev mode (no deployment ID set — HMR handles updates)\n * - No deployment ID header (initial page load, non-RSC request)\n * - Deployment IDs match\n *\n * Returns `{ ok: false }` when:\n * - Client sends a deployment ID that differs from the current build\n */\nexport function checkVersionSkew(req: Request): SkewCheckResult {\n // Dev mode — no deployment ID checks (HMR handles updates)\n if (!currentDeploymentId) {\n return { ok: true, clientId: null };\n }\n\n const clientId = req.headers.get(DEPLOYMENT_ID_HEADER);\n\n // No header — initial page load or non-RSC request. Always OK.\n if (!clientId) {\n return { ok: true, clientId: null };\n }\n\n // Compare deployment IDs\n if (clientId === currentDeploymentId) {\n return { ok: true, clientId };\n }\n\n return { ok: false, clientId };\n}\n\n/**\n * Apply version skew reload headers to a response.\n * Sets X-Timber-Reload: 1 to signal the client to do a full page reload.\n */\nexport function applyReloadHeaders(headers: Headers): void {\n headers.set(RELOAD_HEADER, '1');\n}\n","/**\n * Manifest tag index — maps tags to seed cache keys for tombstone writes.\n *\n * When `revalidateTag(tag)` fires, the framework must write tombstones for\n * every build-seed entry carrying that tag. The manifest records tags per\n * entry; this module inverts the index at startup so the lookup is O(1) per\n * tag instead of a full manifest scan per invalidation.\n *\n * The index is built lazily on first access and cached for the process\n * lifetime — the manifest is immutable within a deploy.\n *\n * See design/45-cache-lifetimes.md §ISR mechanics.\n */\n\nimport type { PrebuiltManifest } from './payload-source.js';\n\nexport interface SeedKeyInfo {\n componentId: string;\n cacheKey: string;\n}\n\n/**\n * Build the inverted tag → seed key index from the manifest.\n *\n * Returns a Map where each tag maps to the set of (componentId, cacheKey)\n * pairs whose manifest entries carry that tag. Only entries with non-empty\n * `tags` arrays participate.\n */\nexport function buildTagIndex(manifest: PrebuiltManifest): Map<string, SeedKeyInfo[]> {\n const index = new Map<string, SeedKeyInfo[]>();\n for (const [componentId, component] of Object.entries(manifest)) {\n if (!component || typeof component !== 'object' || !('entries' in component)) continue;\n for (const [cacheKey, entry] of Object.entries(component.entries)) {\n if (!entry.tags || entry.tags.length === 0) continue;\n for (const tag of entry.tags) {\n let list = index.get(tag);\n if (!list) {\n list = [];\n index.set(tag, list);\n }\n list.push({ componentId, cacheKey });\n }\n }\n }\n return index;\n}\n","/**\n * Prebuilt payload source — the adapter seam through which the runtime\n * reads build-time flight artifacts (`.timber/dist/prebuilt/`).\n *\n * The runtime never touches the filesystem directly: adapters register a\n * source at startup (Node: fs reads; Cloudflare: the assets binding —\n * design/44-render-at-build-time.md §Adapter Integration). Artifacts are\n * produced by the post-build capture pass (TIM-1119, prebuilt-builder.ts);\n * adapter registration of the source is TIM-1122. Until a source is\n * registered (adapter not wired yet, dev mode, no artifacts built), every\n * lookup misses and cache.component wrappers render live — the designed\n * dynamic-fallback behavior.\n *\n * Phase 3 (design/45 runtime tier) inserts the CacheHandler overlay lookup\n * in front of `lookupPrebuiltPayload` — overlay first, then artifact. The\n * single-lookup-function shape here is that seam.\n */\n\nimport { initTagIndex, resetTagIndex } from './overlay.js';\n\nexport interface PrebuiltManifestEntry {\n /** Segment params this entry was captured under. */\n params: Record<string, string | string[]>;\n /** Payload path relative to the prebuilt/ directory. */\n file: string;\n /** Payload size in bytes (build report / diagnostics). */\n bytes?: number;\n /** Runtime invalidation tags (design/45 ISR tier). */\n tags?: string[];\n /** Epoch ms when this entry was captured (seed freshness for ISR). */\n buildTimestamp?: number;\n}\n\nexport interface PrebuiltManifest {\n [componentId: string]: {\n entries: Record<string, PrebuiltManifestEntry>;\n /** When true, the component does not read segment params — the cache key uses `{}`. */\n paramIndependent?: boolean;\n };\n}\n\nexport interface PrebuiltPayloadSource {\n /** Load prebuilt/manifest.json. Null when no artifacts exist. */\n loadManifest(): Promise<PrebuiltManifest | null>;\n /** Read a `.flight` payload by manifest file path. Null when missing. */\n readPayload(file: string): Promise<Uint8Array | null>;\n}\n\nlet source: PrebuiltPayloadSource | null = null;\nlet manifestPromise: Promise<PrebuiltManifest | null> | null = null;\n\n/**\n * Ceiling on the memoized manifest load. Without it, a stalled\n * `loadManifest()` would leave `manifestPromise` pending forever and every\n * subsequent cache.component render would await the same hung promise —\n * the coalesced-promise deadlock class from design/13-security.md (A5).\n * On expiry the load memoizes as null (permanent dynamic fallback, same\n * policy as a failed load) and callers proceed immediately.\n */\nconst MANIFEST_LOAD_TIMEOUT_MS = 5_000;\n\n/**\n * Per-read ceiling on payload reads. The read is awaited inside a server\n * component render — a stalled adapter promise would otherwise hang the\n * RSC stream until the render timeout kills the whole page, when the\n * correct degradation is a miss → live render (codex review round 4 on\n * PR #835).\n */\nconst PAYLOAD_READ_TIMEOUT_MS = 5_000;\n\n/** Race a source promise against a timeout that resolves to `fallback`. */\nasync function withTimeout<T>(\n work: Promise<T>,\n timeoutMs: number,\n fallback: T,\n onTimeout: () => void\n): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n work,\n new Promise<T>((resolve) => {\n timer = setTimeout(() => {\n onTimeout();\n resolve(fallback);\n }, timeoutMs);\n }),\n ]);\n } finally {\n clearTimeout(timer);\n }\n}\n\nasync function loadManifestWithTimeout(\n src: PrebuiltPayloadSource\n): Promise<PrebuiltManifest | null> {\n let manifest: PrebuiltManifest | null;\n try {\n manifest = await withTimeout(src.loadManifest(), MANIFEST_LOAD_TIMEOUT_MS, null, () => {\n console.error(\n `[timber] prebuilt manifest load exceeded ${MANIFEST_LOAD_TIMEOUT_MS}ms — all cache.component lookups will render dynamically`\n );\n });\n } catch (error) {\n console.error(\n '[timber] failed to load prebuilt manifest — all cache.component lookups will miss:',\n error\n );\n return null;\n }\n if (manifest) {\n initTagIndex(manifest);\n }\n return manifest;\n}\n\n/**\n * Register the payload source. Called once at server startup by the\n * adapter/entry wiring (TIM-1122); tests inject fakes. Passing null\n * unregisters (and drops the memoized manifest).\n */\nexport function setPrebuiltPayloadSource(next: PrebuiltPayloadSource | null): void {\n source = next;\n manifestPromise = null;\n if (!next) resetTagIndex();\n}\n\n/**\n * Whether a source is registered — the gate for both marker emission and\n * splice-transform installation. False means zero prebuilt overhead.\n */\nexport function hasPrebuiltPayloadSource(): boolean {\n return source !== null;\n}\n\n/**\n * Ensure the manifest is loaded (and the tag index initialized). No-op\n * when no source is registered. Used by the tombstone path to avoid\n * skipping tombstones on cold processes where the first request is an\n * action rather than a page render.\n */\nexport async function ensureManifestLoaded(): Promise<void> {\n if (source === null) return;\n manifestPromise ??= loadManifestWithTimeout(source);\n await manifestPromise;\n}\n\n/**\n * Look up a manifest entry (metadata only, no payload read).\n * Used by the overlay to check seed existence and freshness.\n */\nexport async function isParamIndependent(componentId: string): Promise<boolean> {\n if (source === null) return false;\n manifestPromise ??= loadManifestWithTimeout(source);\n const manifest = await manifestPromise;\n return manifest?.[componentId]?.paramIndependent === true;\n}\n\nexport async function getManifestEntry(\n componentId: string,\n cacheKey: string\n): Promise<PrebuiltManifestEntry | null> {\n if (source === null) return null;\n manifestPromise ??= loadManifestWithTimeout(source);\n const manifest = await manifestPromise;\n return manifest?.[componentId]?.entries?.[cacheKey] ?? null;\n}\n\n/**\n * Look up a cached payload: manifest entry → payload bytes.\n * Null on any miss or read failure — callers fall back to live render.\n *\n * The manifest is loaded once and memoized (design/44 §manifest.json:\n * loaded at startup, held in memory; payloads read on demand). A failed\n * manifest load is memoized as null rather than retried per-request — a\n * broken artifact should degrade to dynamic rendering, not add a failing\n * read to every request.\n */\nexport async function lookupPrebuiltPayload(\n componentId: string,\n cacheKey: string\n): Promise<Uint8Array | null> {\n if (source === null) return null;\n manifestPromise ??= loadManifestWithTimeout(source);\n const manifest = await manifestPromise;\n const entry = manifest?.[componentId]?.entries?.[cacheKey];\n if (!entry) return null;\n try {\n return await withTimeout(source.readPayload(entry.file), PAYLOAD_READ_TIMEOUT_MS, null, () => {\n console.error(\n `[timber] prebuilt payload read for \"${entry.file}\" exceeded ${PAYLOAD_READ_TIMEOUT_MS}ms — rendering dynamically`\n );\n });\n } catch (error) {\n console.error(\n `[timber] failed to read prebuilt payload \"${entry.file}\" for ${componentId} — rendering dynamically:`,\n error\n );\n return null;\n }\n}\n","/**\n * Component cache overlay — runtime CacheHandler layer for ISR.\n *\n * Sits in front of the immutable build artifact (`.flight` files) and\n * stores replacement payloads and tombstones via the configured\n * CacheHandler. Overlay entries are per-deploy namespaced:\n * `timber:c:{deploymentId}:{componentId}:{hash}`\n *\n * The CacheHandler contract is untouched — tombstones and the tag index\n * live above the interface as value conventions. Redis, KV, and custom\n * handlers work unmodified.\n *\n * See design/45-cache-lifetimes.md §ISR mechanics.\n */\n\nimport { getCacheHandler, isCacheHandlerConfigured } from '../../cache/handler-store.js';\nimport { MemoryCacheHandler } from '../../cache/index.js';\nimport { getDeploymentId } from '../version-skew.js';\nimport { buildTagIndex, type SeedKeyInfo } from './manifest-tag-index.js';\nimport type { PrebuiltManifest } from './payload-source.js';\nimport { ensureManifestLoaded } from './payload-source.js';\n\n/** Default ceiling TTL for tag-only entries (24 hours), in seconds. */\nconst CEILING_TTL_SECONDS = 24 * 60 * 60;\n\n/** Deploy-long physical TTL for seed-backed overlay records (90 days). */\nconst DEPLOY_LONG_TTL_SECONDS = 90 * 24 * 60 * 60;\n\n// ─── Overlay record shapes (value conventions above CacheHandler) ────────\n\n/**\n * A cached component flight payload stored in the overlay.\n * The `_t` discriminant distinguishes this from a tombstone.\n */\nexport interface ComponentOverlayRecord {\n _t: 'co';\n /** Base64-encoded flight payload bytes. */\n p: string;\n /** Logical freshness deadline (Date.now() + ttl * 1000). */\n fu: number;\n /** Whether a build-artifact seed exists for this key. */\n s: boolean;\n}\n\n/**\n * A tombstone marking a build seed as invalidated.\n * Written by revalidateTag for seeds carrying the invalidated tag.\n */\nexport interface ComponentTombstoneRecord {\n _t: 'ct';\n}\n\ntype OverlayValue = ComponentOverlayRecord | ComponentTombstoneRecord;\n\nexport function isOverlayRecord(v: unknown): v is ComponentOverlayRecord {\n return v !== null && typeof v === 'object' && (v as Record<string, unknown>)._t === 'co';\n}\n\nexport function isTombstone(v: unknown): v is ComponentTombstoneRecord {\n return v !== null && typeof v === 'object' && (v as Record<string, unknown>)._t === 'ct';\n}\n\n// ─── Overlay key generation ──────────────────────────────────────────────\n\nexport function overlayKey(componentId: string, cacheKey: string): string {\n const deploymentId = getDeploymentId() ?? 'dev';\n return `timber:c:${deploymentId}:${componentId}:${cacheKey}`;\n}\n\n// ─── Overlay read ────────────────────────────────────────────────────────\n\nexport interface OverlayLookupResult {\n kind: 'fresh' | 'stale' | 'tombstone';\n /** The overlay value (null for tombstones). */\n record: ComponentOverlayRecord | null;\n /** Raw flight payload bytes (decoded from base64). Null for tombstones. */\n payload: Uint8Array | null;\n}\n\n/**\n * Look up an overlay entry in the cache handler.\n * Returns null on a clean miss (no overlay entry at all).\n */\nexport async function lookupOverlay(\n componentId: string,\n cacheKey: string\n): Promise<OverlayLookupResult | null> {\n const handler = getCacheHandler();\n const key = overlayKey(componentId, cacheKey);\n const result = await handler.get(key);\n if (!result) return null;\n\n const value = result.value as OverlayValue;\n if (isTombstone(value)) {\n return { kind: 'tombstone', record: null, payload: null };\n }\n if (isOverlayRecord(value)) {\n const logicallyStale = Date.now() > value.fu;\n return {\n kind: logicallyStale ? 'stale' : 'fresh',\n record: value,\n payload: base64ToBytes(value.p),\n };\n }\n // Unknown value shape — treat as miss (forward compatibility).\n return null;\n}\n\n// ─── Overlay write ───────────────────────────────────────────────────────\n\n/**\n * Resolve the effective TTL for a component's runtime lifetime.\n * Tag-only entries (no explicit ttl) get the ceiling TTL (design/45\n * §Tag-only entries carry a ceiling TTL).\n */\nexport function effectiveTtl(ttl: number | undefined): number {\n return ttl ?? CEILING_TTL_SECONDS;\n}\n\n/**\n * Store a component flight payload in the overlay.\n */\nexport async function storeOverlayEntry(\n componentId: string,\n cacheKey: string,\n payloadBytes: Uint8Array,\n opts: {\n ttl?: number;\n tags: string[];\n hasSeed: boolean;\n }\n): Promise<void> {\n const handler = getCacheHandler();\n const key = overlayKey(componentId, cacheKey);\n const logicalTtl = effectiveTtl(opts.ttl);\n const physicalTtl = opts.hasSeed ? DEPLOY_LONG_TTL_SECONDS : logicalTtl;\n\n const record: ComponentOverlayRecord = {\n _t: 'co',\n p: bytesToBase64(payloadBytes),\n fu: Date.now() + logicalTtl * 1000,\n s: opts.hasSeed,\n };\n\n await handler.set(key, record, { ttl: physicalTtl, tags: opts.tags });\n}\n\n// ─── Tombstone writes ────────────────────────────────────────────────────\n\nlet tagIndex: Map<string, SeedKeyInfo[]> | null = null;\n\n/**\n * Initialize the tag index from the prebuilt manifest. Called once when the\n * manifest is loaded. Without a manifest (no prebuilt components), this is\n * never called and revalidateTag skips the tombstone path entirely.\n */\nexport function initTagIndex(manifest: PrebuiltManifest): void {\n tagIndex = buildTagIndex(manifest);\n emitIsrDiagnosticIfNeeded(manifest);\n}\n\n/**\n * Get the tag index, if initialized.\n * @internal — exported for testing.\n */\nexport function getTagIndex(): Map<string, SeedKeyInfo[]> | null {\n return tagIndex;\n}\n\n/**\n * Reset the tag index (for tests).\n * @internal\n */\nexport function resetTagIndex(): void {\n tagIndex = null;\n}\n\n/**\n * Write tombstones for all seed entries carrying the given tag.\n * Called from cache.invalidate (cache-api.ts) AFTER the handler's own\n * invalidation clears overlay entries.\n *\n * The tombstone prevents the immutable seed from being served after\n * invalidation — without it, a handler.invalidate that clears the overlay\n * would expose the (now-stale) build artifact on the next request.\n *\n * Ensures the manifest is loaded first so cold-process actions that\n * invalidate before any page render still write tombstones.\n */\nexport async function writeTombstonesForTag(tag: string): Promise<void> {\n if (!tagIndex) {\n await ensureManifestLoaded();\n }\n if (!tagIndex) return;\n const seeds = tagIndex.get(tag);\n if (!seeds || seeds.length === 0) return;\n\n const handler = getCacheHandler();\n const tombstone: ComponentTombstoneRecord = { _t: 'ct' };\n\n await Promise.all(\n seeds.map((seed) => {\n const key = overlayKey(seed.componentId, seed.cacheKey);\n return handler.set(key, tombstone, {\n ttl: DEPLOY_LONG_TTL_SECONDS,\n tags: [tag],\n });\n })\n );\n}\n\n// ─── ISR build diagnostic ────────────────────────────────────────────────\n\nlet isrDiagnosticEmitted = false;\n\nfunction emitIsrDiagnosticIfNeeded(manifest: PrebuiltManifest): void {\n if (isrDiagnosticEmitted) return;\n\n const handler = getCacheHandler();\n const isMemoryBased = handler instanceof MemoryCacheHandler || !isCacheHandlerConfigured();\n if (!isMemoryBased) return;\n\n for (const [, component] of Object.entries(manifest)) {\n if (!component || typeof component !== 'object' || !('entries' in component)) continue;\n for (const [, entry] of Object.entries(component.entries)) {\n if (entry.tags && entry.tags.length > 0) {\n isrDiagnosticEmitted = true;\n console.warn(\n '[timber] tag revalidation of prerendered components requires a shared cache ' +\n 'handler in multi-instance deployments. The current MemoryCacheHandler is ' +\n 'per-process — revalidateTag on one instance will not purge the build seed ' +\n 'on others. Configure a shared handler (Redis, KV) for production ISR.'\n );\n return;\n }\n }\n }\n}\n\n/**\n * Reset the diagnostic flag (for tests).\n * @internal\n */\nexport function resetIsrDiagnostic(): void {\n isrDiagnosticEmitted = false;\n}\n\n// ─── Encoding helpers ────────────────────────────────────────────────────\n\nfunction bytesToBase64(bytes: Uint8Array): string {\n return Buffer.from(bytes).toString('base64');\n}\n\nfunction base64ToBytes(b64: string): Uint8Array {\n return new Uint8Array(Buffer.from(b64, 'base64'));\n}\n","import type { CacheOptions } from './index';\nimport type { PrebuiltComponentOptions } from '../server/prebuilt-runtime';\nimport { createCache } from './timber-cache';\nimport { getCacheHandler } from './handler-store';\nimport { recordInvalidation } from './invalidation-epoch';\nimport { writeTombstonesForTag } from '../server/prebuilt/overlay.js';\nimport { getCdnPurgeHandler } from '../cdn/purge-store.js';\n\nconst componentFallbackWarned = new WeakSet<object>();\n\n/**\n * Cache namespace — `cache.data`, `cache.component`, `cache.invalidate`.\n *\n * ```ts\n * import { cache } from '@timber-js/app/cache';\n *\n * const getUser = cache.data(\n * async (id: string) => db.users.findUnique({ where: { id } }),\n * { ttl: 60, tags: (id) => [`user:${id}`] }\n * );\n * ```\n */\nexport const cache = {\n /**\n * Wrap an async function with cross-request caching.\n *\n * The configured cache handler (defaults to MemoryCacheHandler, overridable\n * via timber.config.ts) is re-resolved on every call, so module-scope\n * wrappers created before `setCacheHandler()` still pick up the configured\n * handler (TIM-1029).\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data<Fn extends (...args: any[]) => Promise<any>>(\n fn: Fn,\n opts: CacheOptions<Fn>,\n stableId?: string\n ): Fn {\n return createCache(fn, opts, getCacheHandler, stableId);\n },\n\n /**\n * Invalidate cache entries by tag or key.\n *\n * ```ts\n * cache.invalidate({ tag: 'products' });\n * cache.invalidate({ key: 'user:abc' });\n * ```\n */\n async invalidate(opts: { key?: string; tag?: string }): Promise<void> {\n // Record before the handler delete so a cached fn in flight skips its\n // post-resolve set instead of resurrecting the invalidated value (TIM-1028).\n recordInvalidation(opts);\n await getCacheHandler().invalidate(opts);\n // Write tombstones for build-seed entries carrying the tag (design/45\n // §ISR mechanics). Runs AFTER handler.invalidate so the tombstone\n // overwrites the cleared overlay slot. This covers ALL invalidation\n // paths — actions, webhooks, route handlers — not just executeAction.\n if (opts.tag) {\n await writeTombstonesForTag(opts.tag);\n }\n // Trigger CDN purge if a handler is configured (design/25 §Layer 2).\n // Purge is best-effort: a CDN API failure or timeout must not block\n // cache invalidation. 10s ceiling prevents a hung CDN API from stalling\n // the entire revalidateTag/action flow.\n if (opts.tag) {\n const purgeHandler = getCdnPurgeHandler();\n if (purgeHandler) {\n try {\n await Promise.race([\n purgeHandler.purgeTags([opts.tag]),\n new Promise<void>((_, reject) =>\n setTimeout(() => reject(new Error('CDN purge timed out (10s)')), 10_000)\n ),\n ]);\n } catch (err) {\n console.error('[timber] CDN purge failed for tag:', err);\n }\n }\n }\n },\n\n /**\n * Runtime fallback for `cache.component(...)` callsites the timber-prebuilt\n * transform does not rewrite — nested/computed/argument-position forms (see\n * plugins/prebuilt.ts). Only module-scope `const X = cache.component(...)`\n * declarations are transformed and eligible for prebuilding; everything else\n * lands here, warns once per component, and renders dynamically. Same\n * safety-net pattern as the data cache's runtime fnId fallback (TIM-1054):\n * an untraceable callsite degrades in performance, never in correctness.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n component<C extends (props: any) => unknown>(\n componentFn: C,\n _options?: PrebuiltComponentOptions\n ): C {\n if (!componentFallbackWarned.has(componentFn)) {\n componentFallbackWarned.add(componentFn);\n const name = componentFn.name || 'anonymous component';\n console.warn(\n `[timber] cache.component: \"${name}\" was not transformed at build time — ` +\n `rendering dynamically.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UACE,aACA,UACG;EACH,IAAI,CAAC,wBAAwB,IAAI,WAAW,GAAG;GAC7C,wBAAwB,IAAI,WAAW;GACvC,MAAM,OAAO,YAAY,QAAQ;GACjC,QAAQ,KACN,8BAA8B,KAAK,2IAGrC;EACF;EACA,OAAO;CACT;AACF"}
@@ -0,0 +1,256 @@
1
+ import { t as scanRoutes } from "./scanner-C8b0Gcw3.js";
2
+ import { a as CODEGEN_OUTPUT, c as writeRouteCodegen, n as formatConventionWarnings, o as ENV_DTS_FILENAME, r as lintConventions } from "./convention-lint-kXsgc_-7.js";
3
+ import { n as isTimberPluginApi } from "./plugin-context-rCinWLiE.js";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { createRequire } from "node:module";
6
+ //#region src/cli-check.ts
7
+ /**
8
+ * `timber check` — the implementation behind the CLI command.
9
+ *
10
+ * Two passes, in order:
11
+ *
12
+ * 1. **Routes.** Resolve the project through Vite — so root, `appDir`, and
13
+ * `pageExtensions` are the ones `timber build` uses, including config
14
+ * passed inline to `timber()` — then scan, run the convention linter, and
15
+ * write the route codegen (`.timber/timber-routes.d.ts`,
16
+ * `.timber/segment-types.d.ts`, `timber-env.d.ts`).
17
+ *
18
+ * Codegen runs *before* the type pass on purpose: those
19
+ * files are what give `<Link href>`, `useSegmentParams()` and
20
+ * `MiddlewareContext` their per-route types (design/09-typescript.md
21
+ * §"Typed Routes"), and they are build artifacts — a fresh clone that has
22
+ * never run `timber dev` or `timber build` does not have them, so a type
23
+ * pass on its own would report errors about correct code. A clone whose
24
+ * routes changed since the last build has the same problem with stale ones.
25
+ * 2. **Types.** `tsgo --noEmit` over the project.
26
+ *
27
+ * tsgo is spawned as `node <@typescript/native-preview>/lib/tsgo.js`, never as
28
+ * a bare `tsgo` off PATH — the package is an *optional peer dependency*, so
29
+ * there is no reason for its shim to be on a user's PATH, and the shim is a
30
+ * `.cmd` on Windows which cannot be spawned without a shell. `shell: true`
31
+ * would then concatenate the argv into an unescaped command string, so a
32
+ * project path containing a space would break on exactly the platform the
33
+ * shell was there to support. This mirrors `scripts/build-types.js`, whose
34
+ * header comment is the specification for the pattern.
35
+ *
36
+ * Design docs: 11-platform.md §CLI, 09-typescript.md, 28-npm-packaging.md
37
+ */
38
+ /** The plugin that publishes timber's resolved context on its Vite `api`. */
39
+ var TIMBER_ROOT_SYNC_PLUGIN = "timber-root-sync";
40
+ /** The npm package that provides tsgo. Named in the missing-tool message. */
41
+ var TSGO_PACKAGE = "@typescript/native-preview";
42
+ /**
43
+ * The two generated declaration paths, relative to the project root, as they
44
+ * appear in a resolved tsconfig file list. Derived from the writer's own
45
+ * constants — a rename there cannot leave this check hunting for a file nothing
46
+ * writes.
47
+ */
48
+ var GENERATED_TYPE_PATHS = [ENV_DTS_FILENAME, CODEGEN_OUTPUT];
49
+ /**
50
+ * Locate `@typescript/native-preview`'s JS entry.
51
+ *
52
+ * Resolution is attempted from this package first (it is declared an optional
53
+ * peer dependency, so a package manager links it here when the user installs
54
+ * it) and then from the project root (covering a hoisted install, or a user who
55
+ * added it without the peer link). Throws if neither finds it.
56
+ */
57
+ function resolveTsgoEntry(root, resolveFrom = (from, specifier) => createRequire(from).resolve(specifier)) {
58
+ const candidates = [import.meta.url, join(root, "package.json")];
59
+ let lastError;
60
+ for (const from of candidates) try {
61
+ return join(dirname(resolveFrom(from, `${TSGO_PACKAGE}/package.json`)), "lib", "tsgo.js");
62
+ } catch (err) {
63
+ lastError = err;
64
+ }
65
+ throw new Error(`[timber] Cannot find ${TSGO_PACKAGE}, which \`timber check\` uses to type-check.\n\n Install it as a dev dependency:\n\n pnpm add -D ${TSGO_PACKAGE}\n\n (resolution failed: ${lastError instanceof Error ? lastError.message : String(lastError)})`);
66
+ }
67
+ /**
68
+ * Ask Vite for the resolved config, which is what carries timber's context.
69
+ *
70
+ * `resolveConfig` runs the whole config pipeline — config file discovery,
71
+ * `config` and `configResolved` hooks — so the context it produces is the one
72
+ * `timber build` would use. Measured at ~300-400ms on a real app; the type pass
73
+ * it precedes costs far more.
74
+ */
75
+ var defaultResolveViteConfig = async (inlineConfig, command, defaultMode, defaultNodeEnv) => {
76
+ const { resolveConfig } = await import("vite");
77
+ return resolveConfig(inlineConfig, command, defaultMode, defaultNodeEnv);
78
+ };
79
+ /**
80
+ * The mode defaults `timber build` resolves under.
81
+ *
82
+ * `resolveConfig`'s own defaults are `'development'` for both, but nothing
83
+ * reaches it with those on a build: `createBuilder` goes through Vite's
84
+ * internal `resolveConfigToBuild`, which calls
85
+ * `resolveConfig(inlineConfig, 'build', 'production', 'production')`. A config
86
+ * written as `defineConfig(({ mode }) => …)`, or one that loads `.env.production`,
87
+ * therefore resolves to a *different* app under the two. Passing the defaults
88
+ * explicitly is what makes "check validates what build builds" true rather than
89
+ * true-by-coincidence for configs that ignore mode (TIM-1332, round 6).
90
+ */
91
+ var BUILD_MODE_DEFAULTS = ["production", "production"];
92
+ /**
93
+ * Resolve root, appDir and pageExtensions the way `timber build` resolves them.
94
+ *
95
+ * Reading `timber.config.ts` directly is **not** equivalent, which is the whole
96
+ * reason this goes through Vite (TIM-1332, review round 3):
97
+ *
98
+ * - Config passed inline — `timber({ pageExtensions: [...] })` in
99
+ * `vite.config.ts` — lives only in the plugin's closure. Nothing that
100
+ * re-reads the config file can see it, so a scan built that way silently uses
101
+ * default page extensions and writes a route map missing the app's pages.
102
+ * `examples/next-playground-migration` is exactly this shape.
103
+ * - `root` is Vite's resolved root, not the caller's cwd, and the two differ in
104
+ * the monorepo layouts TIM-498 describes. `appDir` resolves against it.
105
+ *
106
+ * There is no fallback to a second, hand-rolled resolution. A project whose
107
+ * Vite config does not produce the timber plugin cannot be built either, so a
108
+ * check that quietly proceeded on a guessed tree would report a verdict about
109
+ * an app that does not exist.
110
+ */
111
+ async function resolveRouteInputs(options = {}, deps = {}) {
112
+ const { plugins } = await (deps.resolveViteConfig ?? defaultResolveViteConfig)({ configFile: options.viteConfigFile }, "build", ...BUILD_MODE_DEFAULTS);
113
+ const rootSync = plugins.find((plugin) => plugin.name === TIMBER_ROOT_SYNC_PLUGIN);
114
+ if (!rootSync || !isTimberPluginApi(rootSync.api)) throw new Error("[timber] Could not read the resolved timber configuration from your Vite config.\n\n `timber check` resolves your project through Vite so it validates the same\n routes `timber build` builds — including config passed inline to timber().\n\n Check that vite.config.ts exists and lists the timber plugin:\n\n import { timber } from '@timber-js/app';\n export default { plugins: [timber()] };\n");
115
+ const ctx = rootSync.api.getContext();
116
+ return {
117
+ root: ctx.root,
118
+ appDir: ctx.appDir,
119
+ pageExtensions: ctx.config.pageExtensions
120
+ };
121
+ }
122
+ /**
123
+ * Resolve the app directory, scan it, fail on proven-fatal route
124
+ * misconfigurations, print warnings, and write the route codegen the type pass
125
+ * depends on.
126
+ *
127
+ * Error-level lint findings throw rather than print, matching what
128
+ * `plugins/routing.ts` does at build time: the tree is not fit to publish, so
129
+ * it must not reach codegen either. Warnings are printed and do not fail the
130
+ * command — same severity contract as dev and build, so `timber check` cannot
131
+ * disagree with them about what a valid app is.
132
+ */
133
+ async function checkRoutes(options = {}, deps = {}) {
134
+ const inputs = await resolveRouteInputs(options, deps);
135
+ const { root, appDir, pageExtensions } = inputs;
136
+ const tree = scanRoutes(appDir, { pageExtensions });
137
+ const warnings = lintConventions(tree, appDir);
138
+ const fatal = warnings.filter((w) => w.level === "error");
139
+ if (fatal.length > 0) throw new Error(formatConventionWarnings(fatal, { color: false }));
140
+ if (warnings.length > 0) process.stderr.write(`${formatConventionWarnings(warnings)}\n`);
141
+ try {
142
+ await writeRouteCodegen(tree, appDir, root);
143
+ } catch (err) {
144
+ throw new Error(`[timber] Failed to write the generated route types, which the type check reads: ${err instanceof Error ? err.message : String(err)}`);
145
+ }
146
+ return inputs;
147
+ }
148
+ /**
149
+ * The production `RunTsgo`: spawn the compiler with its stdio inherited, so its
150
+ * diagnostics stream to the terminal as they are produced (and are not capped
151
+ * by a buffer, as `execFile` output would be).
152
+ */
153
+ var spawnTsgo = async (command, args, cwd) => {
154
+ const { spawn } = await import("node:child_process");
155
+ return new Promise((resolve, reject) => {
156
+ const child = spawn(command, args, {
157
+ stdio: "inherit",
158
+ cwd
159
+ });
160
+ child.on("error", reject);
161
+ child.on("close", (code) => resolve(code));
162
+ });
163
+ };
164
+ /**
165
+ * The production `ReadTsgoConfig`: `--showConfig`, with stdout captured.
166
+ *
167
+ * `maxBuffer` is raised well past `execFile`'s 1 MB default because the output
168
+ * is one line per file in the program — a large app can exceed that, and
169
+ * overflowing it would make this advisory go quiet on exactly the projects
170
+ * where a misconfigured `include` costs the most. A size-dependent silence is
171
+ * indistinguishable from "everything is fine".
172
+ */
173
+ var execTsgoConfig = async (command, args, cwd) => {
174
+ const { execFile } = await import("node:child_process");
175
+ return new Promise((resolve, reject) => {
176
+ execFile(command, args, {
177
+ cwd,
178
+ maxBuffer: 64 * 1024 * 1024
179
+ }, (err, stdout) => err ? reject(err) : resolve(stdout));
180
+ });
181
+ };
182
+ /**
183
+ * Warn when the generated route declarations will not reach the type checker.
184
+ *
185
+ * Writing `.timber/timber-routes.d.ts` and `timber-env.d.ts` is only half the
186
+ * job: TypeScript loads them only if the project's `include`/`files` actually
187
+ * pull `timber-env.d.ts` in (it is what `/// <reference>`s the route map). A
188
+ * tsconfig with an explicit `include` that lists only source directories —
189
+ * `["app", "*.config.ts"]`, which is what `create-timber-app` shipped before
190
+ * TIM-1332 — silently omits it, and every `<Link href>` then type-checks
191
+ * against the empty placeholder instead of the generated route union. The
192
+ * check would pass while answering the wrong question.
193
+ *
194
+ * The resolved file list comes from `tsgo --showConfig` rather than from our
195
+ * own reading of the tsconfig: `include`, `exclude`, `files`, and `extends`
196
+ * compose in ways that are the compiler's to decide, and a second
197
+ * implementation of them would be a duplicate that drifts. `--showConfig` only
198
+ * resolves globs, so it costs no type checking.
199
+ *
200
+ * This warns rather than fails. An app that never uses typed routes is
201
+ * correct without those declarations, and a hard error would refuse it — the
202
+ * one outcome a check must not produce for a working project. When the answer
203
+ * cannot be determined (tsgo errored, output was not the expected JSON), the
204
+ * warning is skipped: an advisory that fires on an unknown is noise.
205
+ */
206
+ async function warnIfRouteTypesUnreachable(tsgoEntry, configArgs, cwd, readConfig) {
207
+ let files;
208
+ try {
209
+ const raw = await readConfig(process.execPath, [
210
+ tsgoEntry,
211
+ "--showConfig",
212
+ ...configArgs
213
+ ], cwd);
214
+ files = JSON.parse(raw).files;
215
+ } catch {
216
+ return;
217
+ }
218
+ if (!Array.isArray(files)) return;
219
+ if (files.some((file) => {
220
+ if (typeof file !== "string") return false;
221
+ const normalized = file.replace(/\\/g, "/");
222
+ return GENERATED_TYPE_PATHS.some((path) => normalized === path || normalized.endsWith(`/${path}`));
223
+ })) return;
224
+ process.stderr.write("[timber] The generated route types are not part of this TypeScript project, so\n `<Link href>` and `useSegmentParams()` are being checked against empty\n placeholders. Your tsconfig's \"include\" does not pull in timber-env.d.ts.\n\n To fix: add it to \"include\":\n\n \"include\": [\"app\", \"*.config.ts\", \"timber-env.d.ts\"]\n\n");
225
+ }
226
+ /**
227
+ * Run `tsgo --noEmit`, streaming its output.
228
+ *
229
+ * Rejects with the real numeric exit status on type errors. A failure to *start*
230
+ * the compiler is reported separately — the historical bug this replaces
231
+ * surfaced ENOENT as "Type check failed with exit code undefined", which read
232
+ * as a type error and sent users looking at their own code.
233
+ */
234
+ async function runTypeCheck(options = {}, deps = {}) {
235
+ const root = options.root ?? process.cwd();
236
+ const tsgoEntry = (deps.resolveTsgoEntry ?? (() => resolveTsgoEntry(root)))();
237
+ const runTsgo = deps.runTsgo ?? spawnTsgo;
238
+ const configArgs = options.config ? ["--project", resolve(process.cwd(), options.config)] : [];
239
+ await warnIfRouteTypesUnreachable(tsgoEntry, configArgs, root, deps.readTsgoConfig ?? execTsgoConfig);
240
+ let code;
241
+ try {
242
+ code = await runTsgo(process.execPath, [
243
+ tsgoEntry,
244
+ "--noEmit",
245
+ ...configArgs
246
+ ], root);
247
+ } catch (err) {
248
+ throw new Error(`[timber] Failed to start the type checker: ${err instanceof Error ? err.message : String(err)}`);
249
+ }
250
+ if (code === 0) return;
251
+ throw new Error(code === null ? "Type check terminated before it finished" : `Type check failed with exit code ${code}`);
252
+ }
253
+ //#endregion
254
+ export { checkRoutes, runTypeCheck };
255
+
256
+ //# sourceMappingURL=cli-check-CpmN7Nh-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-check-CpmN7Nh-.js","names":[],"sources":["../../src/cli-check.ts"],"sourcesContent":["/**\n * `timber check` — the implementation behind the CLI command.\n *\n * Two passes, in order:\n *\n * 1. **Routes.** Resolve the project through Vite — so root, `appDir`, and\n * `pageExtensions` are the ones `timber build` uses, including config\n * passed inline to `timber()` — then scan, run the convention linter, and\n * write the route codegen (`.timber/timber-routes.d.ts`,\n * `.timber/segment-types.d.ts`, `timber-env.d.ts`).\n *\n * Codegen runs *before* the type pass on purpose: those\n * files are what give `<Link href>`, `useSegmentParams()` and\n * `MiddlewareContext` their per-route types (design/09-typescript.md\n * §\"Typed Routes\"), and they are build artifacts — a fresh clone that has\n * never run `timber dev` or `timber build` does not have them, so a type\n * pass on its own would report errors about correct code. A clone whose\n * routes changed since the last build has the same problem with stale ones.\n * 2. **Types.** `tsgo --noEmit` over the project.\n *\n * tsgo is spawned as `node <@typescript/native-preview>/lib/tsgo.js`, never as\n * a bare `tsgo` off PATH — the package is an *optional peer dependency*, so\n * there is no reason for its shim to be on a user's PATH, and the shim is a\n * `.cmd` on Windows which cannot be spawned without a shell. `shell: true`\n * would then concatenate the argv into an unescaped command string, so a\n * project path containing a space would break on exactly the platform the\n * shell was there to support. This mirrors `scripts/build-types.js`, whose\n * header comment is the specification for the pattern.\n *\n * Design docs: 11-platform.md §CLI, 09-typescript.md, 28-npm-packaging.md\n */\n\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\nimport { scanRoutes } from './routing/scanner.js';\nimport { lintConventions, formatConventionWarnings } from './routing/convention-lint.js';\nimport { writeRouteCodegen, CODEGEN_OUTPUT, ENV_DTS_FILENAME } from './routing/codegen-write.js';\nimport { isTimberPluginApi } from './plugin-context.js';\n\n/** The plugin that publishes timber's resolved context on its Vite `api`. */\nconst TIMBER_ROOT_SYNC_PLUGIN = 'timber-root-sync';\n\n/** The npm package that provides tsgo. Named in the missing-tool message. */\nconst TSGO_PACKAGE = '@typescript/native-preview';\n\n/**\n * The two generated declaration paths, relative to the project root, as they\n * appear in a resolved tsconfig file list. Derived from the writer's own\n * constants — a rename there cannot leave this check hunting for a file nothing\n * writes.\n */\nconst GENERATED_TYPE_PATHS = [ENV_DTS_FILENAME, CODEGEN_OUTPUT];\n\n/**\n * Run the compiler to completion.\n *\n * Resolves with its exit status (`null` when a signal killed it) and rejects\n * only when the process could not be started — the two outcomes `runTypeCheck`\n * has to keep apart. The seam is this narrow on purpose: a test double is a\n * plain async function, with no `ChildProcess` shape to imitate.\n */\nexport type RunTsgo = (command: string, args: string[], cwd: string) => Promise<number | null>;\n\n/**\n * Run the compiler and capture its stdout — used for `--showConfig`, whose\n * output is data we read rather than diagnostics the user reads.\n */\nexport type ReadTsgoConfig = (command: string, args: string[], cwd: string) => Promise<string>;\n\n/**\n * Vite's own `resolveConfig`, narrowed to what this module passes and reads.\n *\n * The seam sits at `resolveConfig` rather than at \"give me the plugins\" so the\n * *arguments* are the thing under test: which config file, which command, and\n * which mode defaults. Those arguments have been wrong three separate times\n * (TIM-1332 rounds 4-6), and a double that answered \"here are the plugins\"\n * could not see any of it. The double returns what Vite returns — plugins with\n * an opaque `api` — so the lookup and narrowing under test stay the real ones.\n */\nexport type ResolveViteConfig = (\n inlineConfig: { configFile: string | undefined },\n command: 'build',\n defaultMode: string,\n defaultNodeEnv: string\n) => Promise<{ plugins: readonly PluginWithApi[] }>;\n\n/** @internal Dependency injection for testing. */\nexport interface CheckDeps {\n /**\n * Resolve tsgo's own JS entry point. Throws when the package is not\n * installed — the caller turns that into an install instruction.\n */\n resolveTsgoEntry?: () => string;\n runTsgo?: RunTsgo;\n readTsgoConfig?: ReadTsgoConfig;\n resolveViteConfig?: ResolveViteConfig;\n}\n\nexport interface CheckOptions {\n /** Project root, for resolving tsgo. Defaults to `process.cwd()`. */\n root?: string;\n /**\n * Path to a **tsconfig**, forwarded to tsgo as `--project` and sourced from\n * the CLI's own `--project`. The route pass takes no part in it: it resolves\n * the app's configuration through Vite, as `timber build` does.\n */\n config?: string;\n}\n\n/**\n * Locate `@typescript/native-preview`'s JS entry.\n *\n * Resolution is attempted from this package first (it is declared an optional\n * peer dependency, so a package manager links it here when the user installs\n * it) and then from the project root (covering a hoisted install, or a user who\n * added it without the peer link). Throws if neither finds it.\n */\nexport function resolveTsgoEntry(\n root: string,\n resolveFrom: (from: string, specifier: string) => string = (from, specifier) =>\n createRequire(from).resolve(specifier)\n): string {\n // `createRequire` takes a filename or a file URL; a plain absolute path is\n // the portable spelling for the project root (a `file://` prefix on a Windows\n // path is not a valid URL). Same form as `checkPeerDependencies`.\n const candidates = [import.meta.url, join(root, 'package.json')];\n let lastError: unknown;\n\n for (const from of candidates) {\n try {\n // The package exports no subpath for its entry, so resolve the manifest\n // and walk to the module its `bin/tsgo` shim imports.\n const manifest = resolveFrom(from, `${TSGO_PACKAGE}/package.json`);\n return join(dirname(manifest), 'lib', 'tsgo.js');\n } catch (err) {\n lastError = err;\n }\n }\n\n throw new Error(\n `[timber] Cannot find ${TSGO_PACKAGE}, which \\`timber check\\` uses to type-check.\\n\\n` +\n ` Install it as a dev dependency:\\n\\n` +\n ` pnpm add -D ${TSGO_PACKAGE}\\n\\n` +\n ` (resolution failed: ${lastError instanceof Error ? lastError.message : String(lastError)})`\n );\n}\n\n/** What the route pass needs from the command line. */\nexport interface RouteOptions {\n /**\n * Path to a **Vite** config file, from `--config`. Undefined means Vite's own\n * discovery, the same as `timber dev`/`build` without the flag. A project\n * that builds with a custom Vite config has to be checkable with it too, or\n * `check` resolves a different app than `build` does (TIM-1332, round 4).\n */\n viteConfigFile?: string;\n}\n\n/** Everything the route scan needs, as the build itself resolves it. */\nexport interface RouteInputs {\n root: string;\n appDir: string;\n pageExtensions: string[] | undefined;\n}\n\n/** The subset of a resolved Vite plugin this module reads. */\nexport interface PluginWithApi {\n name: string;\n api?: unknown;\n}\n\n/**\n * Ask Vite for the resolved config, which is what carries timber's context.\n *\n * `resolveConfig` runs the whole config pipeline — config file discovery,\n * `config` and `configResolved` hooks — so the context it produces is the one\n * `timber build` would use. Measured at ~300-400ms on a real app; the type pass\n * it precedes costs far more.\n */\nconst defaultResolveViteConfig: ResolveViteConfig = async (\n inlineConfig,\n command,\n defaultMode,\n defaultNodeEnv\n) => {\n const { resolveConfig } = await import('vite');\n return resolveConfig(inlineConfig, command, defaultMode, defaultNodeEnv);\n};\n\n/**\n * The mode defaults `timber build` resolves under.\n *\n * `resolveConfig`'s own defaults are `'development'` for both, but nothing\n * reaches it with those on a build: `createBuilder` goes through Vite's\n * internal `resolveConfigToBuild`, which calls\n * `resolveConfig(inlineConfig, 'build', 'production', 'production')`. A config\n * written as `defineConfig(({ mode }) => …)`, or one that loads `.env.production`,\n * therefore resolves to a *different* app under the two. Passing the defaults\n * explicitly is what makes \"check validates what build builds\" true rather than\n * true-by-coincidence for configs that ignore mode (TIM-1332, round 6).\n */\nconst BUILD_MODE_DEFAULTS = ['production', 'production'] as const;\n\n/**\n * Resolve root, appDir and pageExtensions the way `timber build` resolves them.\n *\n * Reading `timber.config.ts` directly is **not** equivalent, which is the whole\n * reason this goes through Vite (TIM-1332, review round 3):\n *\n * - Config passed inline — `timber({ pageExtensions: [...] })` in\n * `vite.config.ts` — lives only in the plugin's closure. Nothing that\n * re-reads the config file can see it, so a scan built that way silently uses\n * default page extensions and writes a route map missing the app's pages.\n * `examples/next-playground-migration` is exactly this shape.\n * - `root` is Vite's resolved root, not the caller's cwd, and the two differ in\n * the monorepo layouts TIM-498 describes. `appDir` resolves against it.\n *\n * There is no fallback to a second, hand-rolled resolution. A project whose\n * Vite config does not produce the timber plugin cannot be built either, so a\n * check that quietly proceeded on a guessed tree would report a verdict about\n * an app that does not exist.\n */\nexport async function resolveRouteInputs(\n options: RouteOptions = {},\n deps: CheckDeps = {}\n): Promise<RouteInputs> {\n const resolveViteConfig = deps.resolveViteConfig ?? defaultResolveViteConfig;\n // `configFile: undefined` is Vite's own \"discover it\" value, so the default\n // path stays exactly what Vite does for `timber build` without `--config`.\n const { plugins } = await resolveViteConfig(\n { configFile: options.viteConfigFile },\n 'build',\n ...BUILD_MODE_DEFAULTS\n );\n\n const rootSync = plugins.find((plugin) => plugin.name === TIMBER_ROOT_SYNC_PLUGIN);\n if (!rootSync || !isTimberPluginApi(rootSync.api)) {\n throw new Error(\n `[timber] Could not read the resolved timber configuration from your Vite config.\\n\\n` +\n ` \\`timber check\\` resolves your project through Vite so it validates the same\\n` +\n ` routes \\`timber build\\` builds — including config passed inline to timber().\\n\\n` +\n ` Check that vite.config.ts exists and lists the timber plugin:\\n\\n` +\n ` import { timber } from '@timber-js/app';\\n` +\n ` export default { plugins: [timber()] };\\n`\n );\n }\n\n const ctx = rootSync.api.getContext();\n return { root: ctx.root, appDir: ctx.appDir, pageExtensions: ctx.config.pageExtensions };\n}\n\n/**\n * Resolve the app directory, scan it, fail on proven-fatal route\n * misconfigurations, print warnings, and write the route codegen the type pass\n * depends on.\n *\n * Error-level lint findings throw rather than print, matching what\n * `plugins/routing.ts` does at build time: the tree is not fit to publish, so\n * it must not reach codegen either. Warnings are printed and do not fail the\n * command — same severity contract as dev and build, so `timber check` cannot\n * disagree with them about what a valid app is.\n */\nexport async function checkRoutes(\n options: RouteOptions = {},\n deps: CheckDeps = {}\n): Promise<RouteInputs> {\n const inputs = await resolveRouteInputs(options, deps);\n const { root, appDir, pageExtensions } = inputs;\n\n const tree = scanRoutes(appDir, { pageExtensions });\n\n const warnings = lintConventions(tree, appDir);\n const fatal = warnings.filter((w) => w.level === 'error');\n if (fatal.length > 0) {\n throw new Error(formatConventionWarnings(fatal, { color: false }));\n }\n if (warnings.length > 0) {\n process.stderr.write(`${formatConventionWarnings(warnings)}\\n`);\n }\n\n // Awaited, unlike the dev/build path: the type pass reads these files, so a\n // failed write would be reported as type errors in the user's own code.\n // Reported as a codegen failure rather than surfaced as a bare `EROFS`/\n // `EACCES` from somewhere unnamed — the raw error says which path could not\n // be written but not which pass wanted it.\n try {\n await writeRouteCodegen(tree, appDir, root);\n } catch (err) {\n throw new Error(\n `[timber] Failed to write the generated route types, which the type check reads: ` +\n `${err instanceof Error ? err.message : String(err)}`\n );\n }\n\n // Returned so the type pass runs against the same root these files landed in.\n return inputs;\n}\n\n/**\n * The production `RunTsgo`: spawn the compiler with its stdio inherited, so its\n * diagnostics stream to the terminal as they are produced (and are not capped\n * by a buffer, as `execFile` output would be).\n */\nconst spawnTsgo: RunTsgo = async (command, args, cwd) => {\n const { spawn } = await import('node:child_process');\n return new Promise<number | null>((resolve, reject) => {\n // No `shell: true`: Node would concatenate the argv into an unescaped\n // command string, so a project path containing a space would break.\n const child = spawn(command, args, { stdio: 'inherit', cwd });\n child.on('error', reject);\n child.on('close', (code) => resolve(code));\n });\n};\n\n/**\n * The production `ReadTsgoConfig`: `--showConfig`, with stdout captured.\n *\n * `maxBuffer` is raised well past `execFile`'s 1 MB default because the output\n * is one line per file in the program — a large app can exceed that, and\n * overflowing it would make this advisory go quiet on exactly the projects\n * where a misconfigured `include` costs the most. A size-dependent silence is\n * indistinguishable from \"everything is fine\".\n */\nconst execTsgoConfig: ReadTsgoConfig = async (command, args, cwd) => {\n const { execFile } = await import('node:child_process');\n return new Promise<string>((resolve, reject) => {\n execFile(command, args, { cwd, maxBuffer: 64 * 1024 * 1024 }, (err, stdout) =>\n err ? reject(err) : resolve(stdout)\n );\n });\n};\n\n/**\n * Warn when the generated route declarations will not reach the type checker.\n *\n * Writing `.timber/timber-routes.d.ts` and `timber-env.d.ts` is only half the\n * job: TypeScript loads them only if the project's `include`/`files` actually\n * pull `timber-env.d.ts` in (it is what `/// <reference>`s the route map). A\n * tsconfig with an explicit `include` that lists only source directories —\n * `[\"app\", \"*.config.ts\"]`, which is what `create-timber-app` shipped before\n * TIM-1332 — silently omits it, and every `<Link href>` then type-checks\n * against the empty placeholder instead of the generated route union. The\n * check would pass while answering the wrong question.\n *\n * The resolved file list comes from `tsgo --showConfig` rather than from our\n * own reading of the tsconfig: `include`, `exclude`, `files`, and `extends`\n * compose in ways that are the compiler's to decide, and a second\n * implementation of them would be a duplicate that drifts. `--showConfig` only\n * resolves globs, so it costs no type checking.\n *\n * This warns rather than fails. An app that never uses typed routes is\n * correct without those declarations, and a hard error would refuse it — the\n * one outcome a check must not produce for a working project. When the answer\n * cannot be determined (tsgo errored, output was not the expected JSON), the\n * warning is skipped: an advisory that fires on an unknown is noise.\n */\nasync function warnIfRouteTypesUnreachable(\n tsgoEntry: string,\n configArgs: string[],\n cwd: string,\n readConfig: ReadTsgoConfig\n): Promise<void> {\n let files: unknown;\n try {\n const raw = await readConfig(process.execPath, [tsgoEntry, '--showConfig', ...configArgs], cwd);\n files = (JSON.parse(raw) as { files?: unknown }).files;\n } catch {\n return;\n }\n if (!Array.isArray(files)) return;\n\n // Suffix match, not path resolution: `--showConfig` prints paths relative to\n // whichever tsconfig the compiler *found*, which for a bare `timber check`\n // is a directory we never learn. Over-matching only suppresses an advisory.\n //\n // The bare form is matched as well as the `/`-prefixed one. tsgo emits\n // `./timber-env.d.ts` today, but a leading `./` is cosmetic and an emitter\n // that dropped it would turn this into a warning printed at every correctly\n // configured project — the failure direction that trains people to ignore it.\n const reaches = files.some((file) => {\n if (typeof file !== 'string') return false;\n const normalized = file.replace(/\\\\/g, '/');\n return GENERATED_TYPE_PATHS.some(\n (path) => normalized === path || normalized.endsWith(`/${path}`)\n );\n });\n if (reaches) return;\n\n process.stderr.write(\n `[timber] The generated route types are not part of this TypeScript project, so\\n` +\n ` \\`<Link href>\\` and \\`useSegmentParams()\\` are being checked against empty\\n` +\n ` placeholders. Your tsconfig's \"include\" does not pull in timber-env.d.ts.\\n\\n` +\n ` To fix: add it to \"include\":\\n\\n` +\n ` \"include\": [\"app\", \"*.config.ts\", \"timber-env.d.ts\"]\\n\\n`\n );\n}\n\n/**\n * Run `tsgo --noEmit`, streaming its output.\n *\n * Rejects with the real numeric exit status on type errors. A failure to *start*\n * the compiler is reported separately — the historical bug this replaces\n * surfaced ENOENT as \"Type check failed with exit code undefined\", which read\n * as a type error and sent users looking at their own code.\n */\nexport async function runTypeCheck(\n options: CheckOptions = {},\n deps: CheckDeps = {}\n): Promise<void> {\n // The *resolved* root, handed over by the route pass — not `process.cwd()`.\n // The two differ whenever `--config` names a Vite config elsewhere, and the\n // route pass wrote `.timber/*` and `timber-env.d.ts` under the resolved one.\n // Running tsgo from cwd would then discover a different tsconfig entirely and\n // type-check a different project than the one just validated (TIM-1332, round\n // 5) — routes checked for the app, types checked for the monorepo around it.\n const root = options.root ?? process.cwd();\n const tsgoEntry = (deps.resolveTsgoEntry ?? (() => resolveTsgoEntry(root)))();\n const runTsgo = deps.runTsgo ?? spawnTsgo;\n\n // An explicit `--project` is a path the user typed at their own prompt, so it\n // is resolved against *their* cwd before the compiler is moved to the project\n // root. Without `--project`, tsgo discovers `tsconfig.json` from `root`,\n // which is where the declarations it needs were just written.\n const configArgs = options.config ? ['--project', resolve(process.cwd(), options.config)] : [];\n\n // Before checking: say so if the declarations the route pass just wrote will\n // not be part of the program. Otherwise the check passes while `<Link href>`\n // is measured against a placeholder. Same root and same argv as the check\n // itself, or it would inspect a different program than the one tsgo reads.\n await warnIfRouteTypesUnreachable(\n tsgoEntry,\n configArgs,\n root,\n deps.readTsgoConfig ?? execTsgoConfig\n );\n\n let code: number | null;\n try {\n code = await runTsgo(process.execPath, [tsgoEntry, '--noEmit', ...configArgs], root);\n } catch (err) {\n // Could not start the compiler at all. Kept distinct from a nonzero exit:\n // the version this replaced reported ENOENT as \"Type check failed with\n // exit code undefined\", which reads as a verdict on the user's types.\n throw new Error(\n `[timber] Failed to start the type checker: ${err instanceof Error ? err.message : String(err)}`\n );\n }\n\n if (code === 0) return;\n\n // A null code means a signal killed the process rather than it exiting.\n // Say so instead of printing \"exit code null\".\n throw new Error(\n code === null\n ? 'Type check terminated before it finished'\n : `Type check failed with exit code ${code}`\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAM,0BAA0B;;AAGhC,IAAM,eAAe;;;;;;;AAQrB,IAAM,uBAAuB,CAAC,kBAAkB,cAAc;;;;;;;;;AAkE9D,SAAgB,iBACd,MACA,eAA4D,MAAM,cAChE,cAAc,IAAI,CAAC,CAAC,QAAQ,SAAS,GAC/B;CAIR,MAAM,aAAa,CAAC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;CAC/D,IAAI;CAEJ,KAAK,MAAM,QAAQ,YACjB,IAAI;EAIF,OAAO,KAAK,QADK,YAAY,MAAM,GAAG,aAAa,cAC/B,CAAQ,GAAG,OAAO,SAAS;CACjD,SAAS,KAAK;EACZ,YAAY;CACd;CAGF,MAAM,IAAI,MACR,wBAAwB,aAAa,uGAEhB,aAAa,4BACP,qBAAqB,QAAQ,UAAU,UAAU,OAAO,SAAS,EAAE,EAChG;AACF;;;;;;;;;AAkCA,IAAM,2BAA8C,OAClD,cACA,SACA,aACA,mBACG;CACH,MAAM,EAAE,kBAAkB,MAAM,OAAO;CACvC,OAAO,cAAc,cAAc,SAAS,aAAa,cAAc;AACzE;;;;;;;;;;;;;AAcA,IAAM,sBAAsB,CAAC,cAAc,YAAY;;;;;;;;;;;;;;;;;;;;AAqBvD,eAAsB,mBACpB,UAAwB,CAAC,GACzB,OAAkB,CAAC,GACG;CAItB,MAAM,EAAE,YAAY,OAHM,KAAK,qBAAqB,yBAAA,CAIlD,EAAE,YAAY,QAAQ,eAAe,GACrC,SACA,GAAG,mBACL;CAEA,MAAM,WAAW,QAAQ,MAAM,WAAW,OAAO,SAAS,uBAAuB;CACjF,IAAI,CAAC,YAAY,CAAC,kBAAkB,SAAS,GAAG,GAC9C,MAAM,IAAI,MACR,kZAMF;CAGF,MAAM,MAAM,SAAS,IAAI,WAAW;CACpC,OA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