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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (573) hide show
  1. package/LICENSE +8 -0
  2. package/dist/_chunks/actions-Dg-ANYHb.js +421 -0
  3. package/dist/_chunks/actions-Dg-ANYHb.js.map +1 -0
  4. package/dist/_chunks/{als-registry-B7DbZ2hS.js → als-registry-HS0LGUl2.js} +1 -1
  5. package/dist/_chunks/als-registry-HS0LGUl2.js.map +1 -0
  6. package/dist/_chunks/chunk-DYhsFzuS.js +33 -0
  7. package/dist/_chunks/{debug-gwlJkDuf.js → debug-ECi_61pb.js} +2 -2
  8. package/dist/_chunks/debug-ECi_61pb.js.map +1 -0
  9. package/dist/_chunks/define-C77ScO0m.js +106 -0
  10. package/dist/_chunks/define-C77ScO0m.js.map +1 -0
  11. package/dist/_chunks/define-CZqDwhSu.js +199 -0
  12. package/dist/_chunks/define-CZqDwhSu.js.map +1 -0
  13. package/dist/_chunks/define-cookie-C2IkoFGN.js +94 -0
  14. package/dist/_chunks/define-cookie-C2IkoFGN.js.map +1 -0
  15. package/dist/_chunks/{format-DviM89f0.js → dev-warnings-DpGRGoDi.js} +5 -44
  16. package/dist/_chunks/dev-warnings-DpGRGoDi.js.map +1 -0
  17. package/dist/_chunks/format-CYBGxKtc.js +14 -0
  18. package/dist/_chunks/format-CYBGxKtc.js.map +1 -0
  19. package/dist/_chunks/{interception-BOoWmLUA.js → interception-Dpn_UfAD.js} +171 -97
  20. package/dist/_chunks/interception-Dpn_UfAD.js.map +1 -0
  21. package/dist/_chunks/merge-search-params-Cm_KIWDX.js +41 -0
  22. package/dist/_chunks/merge-search-params-Cm_KIWDX.js.map +1 -0
  23. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js → metadata-routes-DS3eKNmf.js} +1 -1
  24. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js.map → metadata-routes-DS3eKNmf.js.map} +1 -1
  25. package/dist/_chunks/request-context-qMsWgy9C.js +478 -0
  26. package/dist/_chunks/request-context-qMsWgy9C.js.map +1 -0
  27. package/dist/_chunks/schema-bridge-C3xl_vfb.js +86 -0
  28. package/dist/_chunks/schema-bridge-C3xl_vfb.js.map +1 -0
  29. package/dist/_chunks/segment-classify-BDNn6EzD.js +65 -0
  30. package/dist/_chunks/segment-classify-BDNn6EzD.js.map +1 -0
  31. package/dist/_chunks/segment-context-fHFLF1PE.js +34 -0
  32. package/dist/_chunks/segment-context-fHFLF1PE.js.map +1 -0
  33. package/dist/_chunks/{ssr-data-MjmprTmO.js → ssr-data-DzuI0bIV.js} +1 -1
  34. package/dist/_chunks/{ssr-data-MjmprTmO.js.map → ssr-data-DzuI0bIV.js.map} +1 -1
  35. package/dist/_chunks/stale-reload-C2plcNtG.js +64 -0
  36. package/dist/_chunks/stale-reload-C2plcNtG.js.map +1 -0
  37. package/dist/_chunks/{tracing-CemImE6h.js → tracing-CCYbKn5n.js} +60 -9
  38. package/dist/_chunks/tracing-CCYbKn5n.js.map +1 -0
  39. package/dist/_chunks/use-params-Br9YSUFV.js +295 -0
  40. package/dist/_chunks/use-params-Br9YSUFV.js.map +1 -0
  41. package/dist/_chunks/{use-query-states-D5KaffOK.js → use-query-states-Lo_s_pw2.js} +4 -4
  42. package/dist/_chunks/use-query-states-Lo_s_pw2.js.map +1 -0
  43. package/dist/_chunks/wrappers-_DTmImGt.js +63 -0
  44. package/dist/_chunks/wrappers-_DTmImGt.js.map +1 -0
  45. package/dist/adapters/cloudflare-dev.d.ts +109 -0
  46. package/dist/adapters/cloudflare-dev.d.ts.map +1 -0
  47. package/dist/adapters/cloudflare-dev.js +73 -0
  48. package/dist/adapters/cloudflare-dev.js.map +1 -0
  49. package/dist/adapters/cloudflare-kv-cache.d.ts +64 -0
  50. package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -0
  51. package/dist/adapters/cloudflare-kv-cache.js +95 -0
  52. package/dist/adapters/cloudflare-kv-cache.js.map +1 -0
  53. package/dist/adapters/cloudflare.d.ts +148 -12
  54. package/dist/adapters/cloudflare.d.ts.map +1 -1
  55. package/dist/adapters/cloudflare.js +135 -11
  56. package/dist/adapters/cloudflare.js.map +1 -1
  57. package/dist/adapters/compress-module.d.ts.map +1 -1
  58. package/dist/adapters/nitro.d.ts +17 -1
  59. package/dist/adapters/nitro.d.ts.map +1 -1
  60. package/dist/adapters/nitro.js +56 -13
  61. package/dist/adapters/nitro.js.map +1 -1
  62. package/dist/cache/cache-api.d.ts +24 -0
  63. package/dist/cache/cache-api.d.ts.map +1 -0
  64. package/dist/cache/handler-store.d.ts +31 -0
  65. package/dist/cache/handler-store.d.ts.map +1 -0
  66. package/dist/cache/index.d.ts +23 -7
  67. package/dist/cache/index.d.ts.map +1 -1
  68. package/dist/cache/index.js +142 -80
  69. package/dist/cache/index.js.map +1 -1
  70. package/dist/cache/singleflight.d.ts +18 -1
  71. package/dist/cache/singleflight.d.ts.map +1 -1
  72. package/dist/cache/sizeof.d.ts +22 -0
  73. package/dist/cache/sizeof.d.ts.map +1 -0
  74. package/dist/cache/timber-cache.d.ts +1 -1
  75. package/dist/cache/timber-cache.d.ts.map +1 -1
  76. package/dist/cli.d.ts +6 -1
  77. package/dist/cli.d.ts.map +1 -1
  78. package/dist/cli.js +6 -1
  79. package/dist/cli.js.map +1 -1
  80. package/dist/client/browser-dev.d.ts +27 -1
  81. package/dist/client/browser-dev.d.ts.map +1 -1
  82. package/dist/client/browser-entry/action-dispatch.d.ts +17 -0
  83. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -0
  84. package/dist/client/browser-entry/hmr.d.ts +21 -0
  85. package/dist/client/browser-entry/hmr.d.ts.map +1 -0
  86. package/dist/client/browser-entry/hydrate.d.ts +46 -0
  87. package/dist/client/browser-entry/hydrate.d.ts.map +1 -0
  88. package/dist/client/browser-entry/index.d.ts +30 -0
  89. package/dist/client/browser-entry/index.d.ts.map +1 -0
  90. package/dist/client/browser-entry/post-hydration.d.ts +26 -0
  91. package/dist/client/browser-entry/post-hydration.d.ts.map +1 -0
  92. package/dist/client/browser-entry/router-init.d.ts +23 -0
  93. package/dist/client/browser-entry/router-init.d.ts.map +1 -0
  94. package/dist/client/browser-entry/rsc-stream.d.ts +24 -0
  95. package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -0
  96. package/dist/client/browser-entry/scroll.d.ts +19 -0
  97. package/dist/client/browser-entry/scroll.d.ts.map +1 -0
  98. package/dist/client/error-boundary.d.ts +12 -5
  99. package/dist/client/error-boundary.d.ts.map +1 -1
  100. package/dist/client/error-boundary.js +10 -4
  101. package/dist/client/error-boundary.js.map +1 -1
  102. package/dist/client/error-reconstituter.d.ts +54 -0
  103. package/dist/client/error-reconstituter.d.ts.map +1 -0
  104. package/dist/client/form.d.ts +2 -2
  105. package/dist/client/form.d.ts.map +1 -1
  106. package/dist/client/history.d.ts +19 -4
  107. package/dist/client/history.d.ts.map +1 -1
  108. package/dist/client/index.d.ts +7 -21
  109. package/dist/client/index.d.ts.map +1 -1
  110. package/dist/client/index.js +210 -1017
  111. package/dist/client/index.js.map +1 -1
  112. package/dist/client/internal.d.ts +18 -0
  113. package/dist/client/internal.d.ts.map +1 -0
  114. package/dist/client/internal.js +890 -0
  115. package/dist/client/internal.js.map +1 -0
  116. package/dist/client/link-pending-store.d.ts +63 -0
  117. package/dist/client/link-pending-store.d.ts.map +1 -0
  118. package/dist/client/link.d.ts +90 -32
  119. package/dist/client/link.d.ts.map +1 -1
  120. package/dist/client/nav-link-store.d.ts +36 -0
  121. package/dist/client/nav-link-store.d.ts.map +1 -0
  122. package/dist/client/navigation-api-types.d.ts +90 -0
  123. package/dist/client/navigation-api-types.d.ts.map +1 -0
  124. package/dist/client/navigation-api.d.ts +115 -0
  125. package/dist/client/navigation-api.d.ts.map +1 -0
  126. package/dist/client/navigation-context.d.ts +13 -2
  127. package/dist/client/navigation-context.d.ts.map +1 -1
  128. package/dist/client/{transition-root.d.ts → navigation-root.d.ts} +42 -8
  129. package/dist/client/navigation-root.d.ts.map +1 -0
  130. package/dist/client/nuqs-adapter.d.ts.map +1 -1
  131. package/dist/client/router-ref.d.ts +1 -1
  132. package/dist/client/router.d.ts +70 -4
  133. package/dist/client/router.d.ts.map +1 -1
  134. package/dist/client/rsc-fetch.d.ts +38 -3
  135. package/dist/client/rsc-fetch.d.ts.map +1 -1
  136. package/dist/client/segment-cache.d.ts +1 -1
  137. package/dist/client/segment-cache.d.ts.map +1 -1
  138. package/dist/client/segment-outlet.d.ts +63 -0
  139. package/dist/client/segment-outlet.d.ts.map +1 -0
  140. package/dist/client/ssr-data.d.ts +13 -4
  141. package/dist/client/ssr-data.d.ts.map +1 -1
  142. package/dist/client/stale-reload.d.ts +15 -0
  143. package/dist/client/stale-reload.d.ts.map +1 -1
  144. package/dist/client/top-loader.d.ts +5 -5
  145. package/dist/client/top-loader.d.ts.map +1 -1
  146. package/dist/client/use-link-status.d.ts +5 -5
  147. package/dist/client/use-link-status.d.ts.map +1 -1
  148. package/dist/client/use-params.d.ts +6 -4
  149. package/dist/client/use-params.d.ts.map +1 -1
  150. package/dist/client/{use-navigation-pending.d.ts → use-pending-navigation.d.ts} +4 -4
  151. package/dist/client/use-pending-navigation.d.ts.map +1 -0
  152. package/dist/client/use-query-states.d.ts +1 -1
  153. package/dist/client/use-query-states.d.ts.map +1 -1
  154. package/dist/client/use-router.d.ts +1 -1
  155. package/dist/codec.d.ts +33 -0
  156. package/dist/codec.d.ts.map +1 -0
  157. package/dist/codec.js +2 -0
  158. package/dist/config-types.d.ts +210 -0
  159. package/dist/config-types.d.ts.map +1 -0
  160. package/dist/content/index.d.ts +1 -10
  161. package/dist/content/index.d.ts.map +1 -1
  162. package/dist/content/index.js +0 -2
  163. package/dist/cookies/define-cookie.d.ts +35 -14
  164. package/dist/cookies/define-cookie.d.ts.map +1 -1
  165. package/dist/cookies/index.js +1 -83
  166. package/dist/fonts/css.d.ts +1 -0
  167. package/dist/fonts/css.d.ts.map +1 -1
  168. package/dist/index.d.ts +45 -192
  169. package/dist/index.d.ts.map +1 -1
  170. package/dist/index.js +12296 -11901
  171. package/dist/index.js.map +1 -1
  172. package/dist/plugin-context.d.ts +84 -0
  173. package/dist/plugin-context.d.ts.map +1 -0
  174. package/dist/plugins/adapter-build.d.ts +1 -1
  175. package/dist/plugins/adapter-build.d.ts.map +1 -1
  176. package/dist/plugins/build-manifest.d.ts +2 -2
  177. package/dist/plugins/build-manifest.d.ts.map +1 -1
  178. package/dist/plugins/build-report.d.ts +3 -3
  179. package/dist/plugins/build-report.d.ts.map +1 -1
  180. package/dist/plugins/client-chunks.d.ts +32 -0
  181. package/dist/plugins/client-chunks.d.ts.map +1 -0
  182. package/dist/plugins/content.d.ts +1 -1
  183. package/dist/plugins/content.d.ts.map +1 -1
  184. package/dist/plugins/dev-browser-logs.d.ts +84 -0
  185. package/dist/plugins/dev-browser-logs.d.ts.map +1 -0
  186. package/dist/plugins/dev-error-overlay.d.ts +26 -1
  187. package/dist/plugins/dev-error-overlay.d.ts.map +1 -1
  188. package/dist/plugins/dev-logs.d.ts +1 -1
  189. package/dist/plugins/dev-logs.d.ts.map +1 -1
  190. package/dist/plugins/dev-server.d.ts +1 -1
  191. package/dist/plugins/dev-server.d.ts.map +1 -1
  192. package/dist/plugins/entries.d.ts +1 -1
  193. package/dist/plugins/entries.d.ts.map +1 -1
  194. package/dist/plugins/fonts.d.ts +19 -5
  195. package/dist/plugins/fonts.d.ts.map +1 -1
  196. package/dist/plugins/mdx.d.ts +1 -1
  197. package/dist/plugins/mdx.d.ts.map +1 -1
  198. package/dist/plugins/routing.d.ts +1 -1
  199. package/dist/plugins/routing.d.ts.map +1 -1
  200. package/dist/plugins/server-bundle.d.ts.map +1 -1
  201. package/dist/plugins/shims.d.ts +6 -5
  202. package/dist/plugins/shims.d.ts.map +1 -1
  203. package/dist/plugins/static-build.d.ts +4 -4
  204. package/dist/plugins/static-build.d.ts.map +1 -1
  205. package/dist/routing/codegen.d.ts +2 -2
  206. package/dist/routing/codegen.d.ts.map +1 -1
  207. package/dist/routing/index.d.ts +2 -0
  208. package/dist/routing/index.d.ts.map +1 -1
  209. package/dist/routing/index.js +3 -2
  210. package/dist/routing/scanner.d.ts.map +1 -1
  211. package/dist/routing/segment-classify.d.ts +46 -0
  212. package/dist/routing/segment-classify.d.ts.map +1 -0
  213. package/dist/routing/status-file-lint.d.ts +2 -1
  214. package/dist/routing/status-file-lint.d.ts.map +1 -1
  215. package/dist/routing/types.d.ts +16 -4
  216. package/dist/routing/types.d.ts.map +1 -1
  217. package/dist/rsc-runtime/rsc.d.ts +1 -1
  218. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  219. package/dist/rsc-runtime/ssr.d.ts +12 -0
  220. package/dist/rsc-runtime/ssr.d.ts.map +1 -1
  221. package/dist/schema-bridge.d.ts +76 -0
  222. package/dist/schema-bridge.d.ts.map +1 -0
  223. package/dist/search-params/define.d.ts +139 -0
  224. package/dist/search-params/define.d.ts.map +1 -0
  225. package/dist/search-params/index.d.ts +4 -7
  226. package/dist/search-params/index.d.ts.map +1 -1
  227. package/dist/search-params/index.js +4 -474
  228. package/dist/search-params/registry.d.ts +2 -2
  229. package/dist/search-params/registry.d.ts.map +1 -1
  230. package/dist/search-params/wrappers.d.ts +53 -0
  231. package/dist/search-params/wrappers.d.ts.map +1 -0
  232. package/dist/segment-params/define.d.ts +78 -0
  233. package/dist/segment-params/define.d.ts.map +1 -0
  234. package/dist/segment-params/index.d.ts +6 -0
  235. package/dist/segment-params/index.d.ts.map +1 -0
  236. package/dist/segment-params/index.js +4 -0
  237. package/dist/server/access-gate.d.ts +4 -0
  238. package/dist/server/access-gate.d.ts.map +1 -1
  239. package/dist/server/action-client.d.ts +12 -1
  240. package/dist/server/action-client.d.ts.map +1 -1
  241. package/dist/server/action-encryption.d.ts +76 -0
  242. package/dist/server/action-encryption.d.ts.map +1 -0
  243. package/dist/server/action-handler.d.ts.map +1 -1
  244. package/dist/server/actions.d.ts +3 -6
  245. package/dist/server/actions.d.ts.map +1 -1
  246. package/dist/server/als-registry.d.ts +32 -4
  247. package/dist/server/als-registry.d.ts.map +1 -1
  248. package/dist/server/build-manifest.d.ts +2 -2
  249. package/dist/server/build-manifest.d.ts.map +1 -1
  250. package/dist/server/debug.d.ts +1 -1
  251. package/dist/server/default-logger.d.ts +22 -0
  252. package/dist/server/default-logger.d.ts.map +1 -0
  253. package/dist/server/deny-page-resolver.d.ts +52 -0
  254. package/dist/server/deny-page-resolver.d.ts.map +1 -0
  255. package/dist/server/deny-renderer.d.ts.map +1 -1
  256. package/dist/server/dev-holding-server.d.ts +52 -0
  257. package/dist/server/dev-holding-server.d.ts.map +1 -0
  258. package/dist/server/dev-warnings.d.ts +1 -21
  259. package/dist/server/dev-warnings.d.ts.map +1 -1
  260. package/dist/server/early-hints.d.ts +13 -5
  261. package/dist/server/early-hints.d.ts.map +1 -1
  262. package/dist/server/error-boundary-wrapper.d.ts +7 -1
  263. package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
  264. package/dist/server/fallback-error.d.ts +4 -3
  265. package/dist/server/fallback-error.d.ts.map +1 -1
  266. package/dist/server/flight-injection-state.d.ts +66 -0
  267. package/dist/server/flight-injection-state.d.ts.map +1 -0
  268. package/dist/server/flight-scripts.d.ts +42 -0
  269. package/dist/server/flight-scripts.d.ts.map +1 -0
  270. package/dist/server/flush.d.ts.map +1 -1
  271. package/dist/server/form-data.d.ts +29 -0
  272. package/dist/server/form-data.d.ts.map +1 -1
  273. package/dist/server/html-injectors.d.ts +51 -11
  274. package/dist/server/html-injectors.d.ts.map +1 -1
  275. package/dist/server/index.d.ts +6 -43
  276. package/dist/server/index.d.ts.map +1 -1
  277. package/dist/server/index.js +38 -2798
  278. package/dist/server/index.js.map +1 -1
  279. package/dist/server/internal.d.ts +46 -0
  280. package/dist/server/internal.d.ts.map +1 -0
  281. package/dist/server/internal.js +2883 -0
  282. package/dist/server/internal.js.map +1 -0
  283. package/dist/server/logger.d.ts +25 -7
  284. package/dist/server/logger.d.ts.map +1 -1
  285. package/dist/server/middleware-runner.d.ts +19 -4
  286. package/dist/server/middleware-runner.d.ts.map +1 -1
  287. package/dist/server/node-stream-transforms.d.ts +113 -0
  288. package/dist/server/node-stream-transforms.d.ts.map +1 -0
  289. package/dist/server/page-deny-boundary.d.ts +31 -0
  290. package/dist/server/page-deny-boundary.d.ts.map +1 -0
  291. package/dist/server/pipeline-interception.d.ts +1 -1
  292. package/dist/server/pipeline-interception.d.ts.map +1 -1
  293. package/dist/server/pipeline-metadata.d.ts +6 -0
  294. package/dist/server/pipeline-metadata.d.ts.map +1 -1
  295. package/dist/server/pipeline.d.ts +42 -10
  296. package/dist/server/pipeline.d.ts.map +1 -1
  297. package/dist/server/primitives.d.ts +69 -18
  298. package/dist/server/primitives.d.ts.map +1 -1
  299. package/dist/server/render-timeout.d.ts +51 -0
  300. package/dist/server/render-timeout.d.ts.map +1 -0
  301. package/dist/server/request-context.d.ts +112 -43
  302. package/dist/server/request-context.d.ts.map +1 -1
  303. package/dist/server/route-element-builder.d.ts +27 -1
  304. package/dist/server/route-element-builder.d.ts.map +1 -1
  305. package/dist/server/route-handler.d.ts.map +1 -1
  306. package/dist/server/route-matcher.d.ts +9 -2
  307. package/dist/server/route-matcher.d.ts.map +1 -1
  308. package/dist/server/rsc-entry/api-handler.d.ts +2 -2
  309. package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
  310. package/dist/server/rsc-entry/error-renderer.d.ts +26 -13
  311. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  312. package/dist/server/rsc-entry/helpers.d.ts +48 -5
  313. package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
  314. package/dist/server/rsc-entry/index.d.ts +8 -3
  315. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  316. package/dist/server/rsc-entry/rsc-payload.d.ts +3 -3
  317. package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
  318. package/dist/server/rsc-entry/rsc-stream.d.ts +4 -1
  319. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  320. package/dist/server/rsc-entry/ssr-bridge.d.ts +1 -1
  321. package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
  322. package/dist/server/rsc-entry/ssr-renderer.d.ts +19 -4
  323. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  324. package/dist/server/safe-load.d.ts +46 -0
  325. package/dist/server/safe-load.d.ts.map +1 -0
  326. package/dist/server/sitemap-generator.d.ts +129 -0
  327. package/dist/server/sitemap-generator.d.ts.map +1 -0
  328. package/dist/server/sitemap-handler.d.ts +22 -0
  329. package/dist/server/sitemap-handler.d.ts.map +1 -0
  330. package/dist/server/slot-resolver.d.ts +1 -1
  331. package/dist/server/slot-resolver.d.ts.map +1 -1
  332. package/dist/server/ssr-entry.d.ts +22 -0
  333. package/dist/server/ssr-entry.d.ts.map +1 -1
  334. package/dist/server/ssr-render.d.ts +39 -21
  335. package/dist/server/ssr-render.d.ts.map +1 -1
  336. package/dist/server/ssr-wrappers.d.ts +50 -0
  337. package/dist/server/ssr-wrappers.d.ts.map +1 -0
  338. package/dist/server/status-code-resolver.d.ts +1 -1
  339. package/dist/server/status-code-resolver.d.ts.map +1 -1
  340. package/dist/server/stream-utils.d.ts +36 -0
  341. package/dist/server/stream-utils.d.ts.map +1 -0
  342. package/dist/server/tracing.d.ts +4 -4
  343. package/dist/server/tracing.d.ts.map +1 -1
  344. package/dist/server/tree-builder.d.ts +22 -19
  345. package/dist/server/tree-builder.d.ts.map +1 -1
  346. package/dist/server/types.d.ts +1 -4
  347. package/dist/server/types.d.ts.map +1 -1
  348. package/dist/server/version-skew.d.ts +61 -0
  349. package/dist/server/version-skew.d.ts.map +1 -0
  350. package/dist/shared/merge-search-params.d.ts +22 -0
  351. package/dist/shared/merge-search-params.d.ts.map +1 -0
  352. package/dist/shims/font-google.d.ts +1 -1
  353. package/dist/shims/font-google.d.ts.map +1 -1
  354. package/dist/shims/font-google.js +42 -0
  355. package/dist/shims/font-google.js.map +1 -0
  356. package/dist/shims/font-local.d.ts +26 -0
  357. package/dist/shims/font-local.d.ts.map +1 -0
  358. package/dist/shims/font-local.js +20 -0
  359. package/dist/shims/font-local.js.map +1 -0
  360. package/dist/shims/headers.d.ts +2 -1
  361. package/dist/shims/headers.d.ts.map +1 -1
  362. package/dist/shims/navigation-client.d.ts +1 -1
  363. package/dist/shims/navigation-client.d.ts.map +1 -1
  364. package/dist/shims/navigation.d.ts +3 -2
  365. package/dist/shims/navigation.d.ts.map +1 -1
  366. package/dist/utils/directive-parser.d.ts +5 -2
  367. package/dist/utils/directive-parser.d.ts.map +1 -1
  368. package/dist/utils/state-machine.d.ts +80 -0
  369. package/dist/utils/state-machine.d.ts.map +1 -0
  370. package/package.json +53 -23
  371. package/src/adapters/cloudflare-dev.ts +177 -0
  372. package/src/adapters/cloudflare-kv-cache.ts +142 -0
  373. package/src/adapters/cloudflare.ts +342 -28
  374. package/src/adapters/compress-module.ts +24 -4
  375. package/src/adapters/nitro.ts +52 -8
  376. package/src/adapters/wrangler.d.ts +7 -0
  377. package/src/cache/cache-api.ts +38 -0
  378. package/src/cache/handler-store.ts +68 -0
  379. package/src/cache/index.ts +81 -18
  380. package/src/cache/singleflight.ts +62 -4
  381. package/src/cache/sizeof.ts +31 -0
  382. package/src/cache/timber-cache.ts +24 -20
  383. package/src/cli.ts +6 -1
  384. package/src/client/browser-dev.ts +128 -1
  385. package/src/client/browser-entry/action-dispatch.ts +116 -0
  386. package/src/client/browser-entry/hmr.ts +81 -0
  387. package/src/client/browser-entry/hydrate.ts +145 -0
  388. package/src/client/browser-entry/index.ts +138 -0
  389. package/src/client/browser-entry/post-hydration.ts +119 -0
  390. package/src/client/browser-entry/router-init.ts +193 -0
  391. package/src/client/browser-entry/rsc-stream.ts +157 -0
  392. package/src/client/browser-entry/scroll.ts +27 -0
  393. package/src/client/error-boundary.tsx +48 -16
  394. package/src/client/error-reconstituter.tsx +65 -0
  395. package/src/client/form.tsx +2 -2
  396. package/src/client/history.ts +26 -4
  397. package/src/client/index.ts +19 -38
  398. package/src/client/internal.ts +57 -0
  399. package/src/client/link-pending-store.ts +111 -0
  400. package/src/client/link.tsx +329 -97
  401. package/src/client/nav-link-store.ts +47 -0
  402. package/src/client/navigation-api-types.ts +112 -0
  403. package/src/client/navigation-api.ts +332 -0
  404. package/src/client/navigation-context.ts +31 -6
  405. package/src/client/navigation-root.tsx +342 -0
  406. package/src/client/nuqs-adapter.tsx +16 -3
  407. package/src/client/router-ref.ts +1 -1
  408. package/src/client/router.ts +299 -72
  409. package/src/client/rsc-fetch.ts +97 -8
  410. package/src/client/segment-cache.ts +1 -1
  411. package/src/client/segment-outlet.tsx +86 -0
  412. package/src/client/ssr-data.ts +13 -5
  413. package/src/client/stale-reload.ts +72 -3
  414. package/src/client/top-loader.tsx +16 -8
  415. package/src/client/use-link-status.ts +7 -7
  416. package/src/client/use-params.ts +7 -5
  417. package/src/client/{use-navigation-pending.ts → use-pending-navigation.ts} +6 -6
  418. package/src/client/use-query-states.ts +3 -3
  419. package/src/client/use-router.ts +1 -1
  420. package/src/codec.ts +49 -0
  421. package/src/config-types.ts +208 -0
  422. package/src/content/index.ts +5 -13
  423. package/src/cookies/define-cookie.ts +78 -25
  424. package/src/cookies/index.ts +8 -0
  425. package/src/fonts/css.ts +2 -1
  426. package/src/index.ts +258 -354
  427. package/src/plugin-context.ts +200 -0
  428. package/src/plugins/adapter-build.ts +8 -2
  429. package/src/plugins/build-manifest.ts +13 -2
  430. package/src/plugins/build-report.ts +3 -3
  431. package/src/plugins/client-chunks.ts +65 -0
  432. package/src/plugins/content.ts +1 -1
  433. package/src/plugins/dev-browser-logs.ts +288 -0
  434. package/src/plugins/dev-error-overlay.ts +70 -1
  435. package/src/plugins/dev-logs.ts +1 -1
  436. package/src/plugins/dev-server.ts +70 -9
  437. package/src/plugins/entries.ts +71 -10
  438. package/src/plugins/fonts.ts +168 -61
  439. package/src/plugins/mdx.ts +1 -1
  440. package/src/plugins/routing.ts +57 -17
  441. package/src/plugins/server-action-exports.ts +1 -1
  442. package/src/plugins/server-bundle.ts +32 -1
  443. package/src/plugins/shims.ts +135 -35
  444. package/src/plugins/static-build.ts +17 -11
  445. package/src/routing/codegen.ts +165 -105
  446. package/src/routing/index.ts +2 -0
  447. package/src/routing/scanner.ts +93 -23
  448. package/src/routing/segment-classify.ts +89 -0
  449. package/src/routing/status-file-lint.ts +3 -2
  450. package/src/routing/types.ts +17 -4
  451. package/src/rsc-runtime/rsc.ts +2 -0
  452. package/src/rsc-runtime/ssr.ts +50 -0
  453. package/src/rsc-runtime/vendor-types.d.ts +7 -0
  454. package/src/{search-params/codecs.ts → schema-bridge.ts} +57 -20
  455. package/src/search-params/define.ts +482 -0
  456. package/src/search-params/index.ts +14 -20
  457. package/src/search-params/registry.ts +2 -2
  458. package/src/search-params/wrappers.ts +85 -0
  459. package/src/segment-params/define.ts +279 -0
  460. package/src/segment-params/index.ts +29 -0
  461. package/src/server/access-gate.tsx +70 -29
  462. package/src/server/action-client.ts +21 -2
  463. package/src/server/action-encryption.ts +144 -0
  464. package/src/server/action-handler.ts +21 -4
  465. package/src/server/actions.ts +10 -9
  466. package/src/server/als-registry.ts +34 -6
  467. package/src/server/build-manifest.ts +10 -4
  468. package/src/server/compress.ts +25 -7
  469. package/src/server/debug.ts +1 -1
  470. package/src/server/default-logger.ts +99 -0
  471. package/src/server/deny-page-resolver.ts +154 -0
  472. package/src/server/deny-renderer.ts +24 -38
  473. package/src/server/dev-holding-server.ts +185 -0
  474. package/src/server/dev-warnings.ts +4 -49
  475. package/src/server/early-hints.ts +36 -15
  476. package/src/server/error-boundary-wrapper.ts +74 -22
  477. package/src/server/fallback-error.ts +31 -15
  478. package/src/server/flight-injection-state.ts +113 -0
  479. package/src/server/flight-scripts.ts +62 -0
  480. package/src/server/flush.ts +2 -1
  481. package/src/server/form-data.ts +76 -0
  482. package/src/server/html-injectors.ts +280 -120
  483. package/src/server/index.ts +26 -177
  484. package/src/server/internal.ts +169 -0
  485. package/src/server/logger.ts +44 -36
  486. package/src/server/middleware-runner.ts +31 -4
  487. package/src/server/node-stream-transforms.ts +509 -0
  488. package/src/server/page-deny-boundary.tsx +56 -0
  489. package/src/server/pipeline-interception.ts +17 -16
  490. package/src/server/pipeline-metadata.ts +13 -0
  491. package/src/server/pipeline.ts +227 -62
  492. package/src/server/primitives.ts +111 -28
  493. package/src/server/render-timeout.ts +108 -0
  494. package/src/server/request-context.ts +293 -132
  495. package/src/server/route-element-builder.ts +283 -191
  496. package/src/server/route-handler.ts +24 -4
  497. package/src/server/route-matcher.ts +24 -20
  498. package/src/server/rsc-entry/api-handler.ts +15 -16
  499. package/src/server/rsc-entry/error-renderer.ts +300 -89
  500. package/src/server/rsc-entry/helpers.ts +134 -5
  501. package/src/server/rsc-entry/index.ts +200 -112
  502. package/src/server/rsc-entry/rsc-payload.ts +65 -18
  503. package/src/server/rsc-entry/rsc-stream.ts +65 -13
  504. package/src/server/rsc-entry/ssr-bridge.ts +14 -5
  505. package/src/server/rsc-entry/ssr-renderer.ts +168 -38
  506. package/src/server/safe-load.ts +60 -0
  507. package/src/server/sitemap-generator.ts +338 -0
  508. package/src/server/sitemap-handler.ts +126 -0
  509. package/src/server/slot-resolver.ts +244 -229
  510. package/src/server/ssr-entry.ts +211 -32
  511. package/src/server/ssr-render.ts +289 -67
  512. package/src/server/ssr-wrappers.tsx +139 -0
  513. package/src/server/status-code-resolver.ts +1 -1
  514. package/src/server/stream-utils.ts +213 -0
  515. package/src/server/tracing.ts +20 -9
  516. package/src/server/tree-builder.ts +92 -58
  517. package/src/server/types.ts +3 -6
  518. package/src/server/version-skew.ts +104 -0
  519. package/src/shared/merge-search-params.ts +55 -0
  520. package/src/shims/font-google.ts +1 -1
  521. package/src/shims/font-local.ts +34 -0
  522. package/src/shims/headers.ts +5 -1
  523. package/src/shims/navigation-client.ts +1 -1
  524. package/src/shims/navigation.ts +7 -2
  525. package/src/utils/directive-parser.ts +5 -2
  526. package/src/utils/state-machine.ts +111 -0
  527. package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
  528. package/dist/_chunks/debug-gwlJkDuf.js.map +0 -1
  529. package/dist/_chunks/format-DviM89f0.js.map +0 -1
  530. package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
  531. package/dist/_chunks/request-context-DIkVh_jG.js +0 -330
  532. package/dist/_chunks/request-context-DIkVh_jG.js.map +0 -1
  533. package/dist/_chunks/tracing-CemImE6h.js.map +0 -1
  534. package/dist/_chunks/use-cookie-DX-l1_5E.js +0 -91
  535. package/dist/_chunks/use-cookie-DX-l1_5E.js.map +0 -1
  536. package/dist/_chunks/use-query-states-D5KaffOK.js.map +0 -1
  537. package/dist/cache/register-cached-function.d.ts +0 -17
  538. package/dist/cache/register-cached-function.d.ts.map +0 -1
  539. package/dist/client/browser-entry.d.ts +0 -21
  540. package/dist/client/browser-entry.d.ts.map +0 -1
  541. package/dist/client/link-status-provider.d.ts +0 -11
  542. package/dist/client/link-status-provider.d.ts.map +0 -1
  543. package/dist/client/transition-root.d.ts.map +0 -1
  544. package/dist/client/use-navigation-pending.d.ts.map +0 -1
  545. package/dist/cookies/index.js.map +0 -1
  546. package/dist/plugins/cache-transform.d.ts +0 -36
  547. package/dist/plugins/cache-transform.d.ts.map +0 -1
  548. package/dist/plugins/dynamic-transform.d.ts +0 -72
  549. package/dist/plugins/dynamic-transform.d.ts.map +0 -1
  550. package/dist/search-params/analyze.d.ts +0 -54
  551. package/dist/search-params/analyze.d.ts.map +0 -1
  552. package/dist/search-params/builtin-codecs.d.ts +0 -105
  553. package/dist/search-params/builtin-codecs.d.ts.map +0 -1
  554. package/dist/search-params/codecs.d.ts +0 -53
  555. package/dist/search-params/codecs.d.ts.map +0 -1
  556. package/dist/search-params/create.d.ts +0 -106
  557. package/dist/search-params/create.d.ts.map +0 -1
  558. package/dist/search-params/index.js.map +0 -1
  559. package/dist/server/prerender.d.ts +0 -77
  560. package/dist/server/prerender.d.ts.map +0 -1
  561. package/dist/server/response-cache.d.ts +0 -54
  562. package/dist/server/response-cache.d.ts.map +0 -1
  563. package/src/cache/register-cached-function.ts +0 -103
  564. package/src/client/browser-entry.ts +0 -678
  565. package/src/client/link-status-provider.tsx +0 -30
  566. package/src/client/transition-root.tsx +0 -166
  567. package/src/plugins/cache-transform.ts +0 -199
  568. package/src/plugins/dynamic-transform.ts +0 -161
  569. package/src/search-params/analyze.ts +0 -192
  570. package/src/search-params/builtin-codecs.ts +0 -228
  571. package/src/search-params/create.ts +0 -321
  572. package/src/server/prerender.ts +0 -139
  573. package/src/server/response-cache.ts +0 -410
package/src/index.ts CHANGED
@@ -1,10 +1,19 @@
1
+ /**
2
+ * @timber-js/app — Root entry point (public API).
3
+ *
4
+ * User-facing exports: timber(), defineConfig(), TimberUserConfig, Routes.
5
+ *
6
+ * Internal helpers (PluginContext, resolveAppDir, loadTimberConfigFile,
7
+ * warnConfigConflicts, resolveClientJavascript) live in plugin-context.ts
8
+ * and are NOT re-exported here. Sub-plugins import them via relative paths.
9
+ *
10
+ * Design doc: 18-build-system.md §"Plugin Architecture"
11
+ */
12
+
1
13
  import type { Plugin, PluginOption } from 'vite';
2
- import { existsSync } from 'node:fs';
3
- import { join } from 'node:path';
4
- import { pathToFileURL } from 'node:url';
14
+ import { join, resolve } from 'node:path';
5
15
  import { createRequire } from 'node:module';
6
- import react from '@vitejs/plugin-react';
7
- import { cacheTransformPlugin } from './plugins/cache-transform';
16
+ import react, { reactCompilerPreset } from '@vitejs/plugin-react';
8
17
  import { timberContent } from './plugins/content';
9
18
  import { timberDevServer } from './plugins/dev-server';
10
19
  import { timberEntries } from './plugins/entries';
@@ -13,358 +22,247 @@ import { timberRouting } from './plugins/routing';
13
22
  import { timberShims } from './plugins/shims';
14
23
  import { timberFonts } from './plugins/fonts';
15
24
  import { timberStaticBuild } from './plugins/static-build';
16
- import { timberDynamicTransform } from './plugins/dynamic-transform';
17
25
  import { timberServerActionExports } from './plugins/server-action-exports';
18
26
  import { timberBuildManifest } from './plugins/build-manifest';
19
27
  import { timberDevLogs } from './plugins/dev-logs';
28
+ import { timberDevBrowserLogs } from './plugins/dev-browser-logs';
20
29
  import { timberReactProd } from './plugins/react-prod';
21
30
  import { timberChunks } from './plugins/chunks';
31
+ import { clientChunkGroup } from './plugins/client-chunks';
22
32
  import { timberServerBundle } from './plugins/server-bundle';
23
33
  import { timberAdapterBuild } from './plugins/adapter-build';
24
34
  import { timberBuildReport } from './plugins/build-report';
25
- import type { RouteTree } from './routing/types';
26
- import type { BuildManifest } from './server/build-manifest';
27
- import type { StartupTimer } from './utils/startup-timer';
28
- import { createStartupTimer, createNoopTimer } from './utils/startup-timer';
35
+ import { createNoopTimer } from './utils/startup-timer';
36
+ import { resolveEncryptionKeyExpression, shouldEnableEncryption } from './server/action-encryption';
37
+ import { createHoldingServer } from './server/dev-holding-server.js';
38
+ import type { TimberUserConfig } from './config-types.js';
39
+ import type { PluginContext } from './plugin-context.js';
40
+ import {
41
+ createPluginContext,
42
+ loadTimberConfigFile,
43
+ mergeFileConfig,
44
+ resolveAppDir,
45
+ resolveClientJavascript,
46
+ } from './plugin-context.js';
29
47
 
30
- /** Configuration for client-side JavaScript output. */
31
- export interface ClientJavascriptConfig {
32
- /** When true, no client JS bundles are emitted or referenced in HTML. */
33
- disabled: boolean;
34
- /**
35
- * When `disabled` is true, still inject the Vite HMR client in dev mode
36
- * so hot reloading works during development. Default: true.
37
- */
38
- enableHMRInDev?: boolean;
39
- }
40
-
41
- /** Fully resolved client JavaScript configuration (no optionals). */
42
- export interface ResolvedClientJavascript {
43
- disabled: boolean;
44
- enableHMRInDev: boolean;
45
- }
48
+ // ── Public API ────────────────────────────────────────────────────────────
46
49
 
47
- export interface TimberUserConfig {
48
- output?: 'server' | 'static';
49
- /**
50
- * Enable timber debug logging in production builds.
51
- *
52
- * When `true`, timber's own diagnostics (dev warnings, verbose logging)
53
- * are active even in production mode. React stays in production mode —
54
- * only timber's logs are affected.
55
- *
56
- * Can also be enabled at runtime via the `TIMBER_DEBUG` environment variable.
57
- *
58
- * Default: `false`.
59
- */
60
- debug?: boolean;
61
- /**
62
- * Control client-side JavaScript output.
63
- *
64
- * Boolean shorthand:
65
- * `clientJavascript: false` disables all client JS (equivalent to `{ disabled: true }`).
66
- * `clientJavascript: true` enables client JS (the default).
67
- *
68
- * Object form:
69
- * `clientJavascript: { disabled: true, enableHMRInDev: true }` disables client JS
70
- * in production but preserves Vite HMR in dev mode.
71
- *
72
- * When `disabled` is true, `enableHMRInDev` defaults to `true`.
73
- * Server-side JS still runs — this only affects what is sent to the browser.
74
- */
75
- clientJavascript?: boolean | ClientJavascriptConfig;
76
- adapter?: unknown;
77
- cacheHandler?: unknown;
78
- allowedOrigins?: string[];
79
- csrf?: boolean;
80
- limits?: {
81
- actionBodySize?: string;
82
- uploadBodySize?: string;
83
- maxFields?: number;
84
- };
85
- pageExtensions?: string[];
86
- /**
87
- * Slow request threshold in milliseconds. Requests exceeding this emit
88
- * a warning via the logger. Set to 0 to disable. Default: 3000.
89
- *
90
- * See design/17-logging.md §"slowRequestMs".
91
- */
92
- slowRequestMs?: number;
93
- /** Dev-mode options. These have no effect in production builds. */
94
- dev?: {
95
- /** Threshold in ms to highlight slow phases in dev logging output. Default: 200. */
96
- slowPhaseMs?: number;
97
- };
98
- /**
99
- * Cookie signing configuration. See design/29-cookies.md §"Signed Cookies".
100
- *
101
- * Provide `secret` for a single key, or `secrets` (array) for key rotation.
102
- * When `secrets` is used, index 0 is the signing key; all are tried for verification.
103
- */
104
- cookies?: {
105
- /** Single signing secret. Shorthand for `secrets: [secret]`. */
106
- secret?: string;
107
- /** Array of signing secrets for key rotation. Index 0 signs; all verify. */
108
- secrets?: string[];
109
- };
110
- /**
111
- * Override the app directory location. By default, timber auto-detects
112
- * `app/` at the project root, falling back to `src/app/`.
113
- *
114
- * Set this to a relative path from the project root (e.g. `'src/app'`)
115
- * to use a custom location.
116
- */
117
- appDir?: string;
118
- /** MDX compilation options passed to @mdx-js/rollup. See design/20-content-collections.md. */
119
- mdx?: {
120
- remarkPlugins?: unknown[];
121
- rehypePlugins?: unknown[];
122
- recmaPlugins?: unknown[];
123
- remarkRehypeOptions?: Record<string, unknown>;
124
- };
125
- /**
126
- * Built-in top-loader progress bar for client navigations.
127
- * Shows an animated bar at the top of the viewport during RSC navigations.
128
- * Enabled by default — set `enabled: false` to opt out.
129
- *
130
- * Users who want a fully custom progress indicator should disable this
131
- * and use `useNavigationPending()` directly.
132
- *
133
- * See LOCAL-336 for design decisions.
134
- */
135
- topLoader?: {
136
- /** Whether the top-loader is enabled. Default: true. */
137
- enabled?: boolean;
138
- /** Bar color. Default: '#2299DD'. */
139
- color?: string;
140
- /** Bar height in pixels. Default: 3. */
141
- height?: number;
142
- /** Show subtle glow/shadow effect. Default: true. */
143
- shadow?: boolean;
144
- /** Delay in ms before showing the bar (avoids flash on fast navs). Default: 0. */
145
- delay?: number;
146
- /** CSS z-index. Default: 1600. */
147
- zIndex?: number;
148
- };
149
- /**
150
- * Response-level caching and deduplication.
151
- *
152
- * When enabled, concurrent requests to the same URL share a single render
153
- * (singleflight), and recently rendered responses are reused from a short-TTL
154
- * LRU cache without re-executing the RSC-to-SSR pipeline.
155
- *
156
- * Set to `false` to disable entirely. Default: enabled with sensible defaults.
157
- *
158
- * See design/31-benchmarking.md for performance context.
159
- */
160
- responseCache?:
161
- | false
162
- | {
163
- /** Maximum number of entries in the LRU cache. Default: 150. */
164
- maxSize?: number;
165
- /** TTL for cached entries in milliseconds. Default: 5000 (5s). */
166
- ttlMs?: number;
167
- /**
168
- * When true (default), requests with Cookie or Authorization headers
169
- * bypass the cache entirely. This prevents sharing user-specific
170
- * responses across requests.
171
- *
172
- * Set to false to cache all responses regardless of auth state.
173
- * Only do this if your pages are truly public and don't vary by user.
174
- */
175
- publicOnly?: boolean;
176
- };
177
- }
50
+ export type { TimberUserConfig } from './config-types.js';
178
51
 
179
52
  /**
180
- * Resolve `clientJavascript` into a fully resolved config.
53
+ * Route map interface augmented by the generated timber-routes.d.ts.
54
+ *
55
+ * Each key is a route path pattern. Values have:
56
+ * segmentParams: shape of URL segment params (e.g. { id: string })
57
+ * searchParams: parsed type from search-params.ts, or {} if none
58
+ *
59
+ * This interface is empty by default and populated via codegen.
60
+ * See design/09-typescript.md §"Typed Routes".
181
61
  */
182
- export function resolveClientJavascript(config: TimberUserConfig): ResolvedClientJavascript {
183
- if (config.clientJavascript !== undefined) {
184
- if (typeof config.clientJavascript === 'boolean') {
185
- // `clientJavascript: false` → disabled
186
- // `clientJavascript: true` → enabled (default)
187
- return {
188
- disabled: !config.clientJavascript,
189
- enableHMRInDev: !config.clientJavascript, // default true when disabled
190
- };
191
- }
192
- // Object form
193
- return {
194
- disabled: config.clientJavascript.disabled,
195
- enableHMRInDev: config.clientJavascript.enableHMRInDev ?? config.clientJavascript.disabled,
196
- };
197
- }
198
-
199
- // Default: client JS enabled
200
- return { disabled: false, enableHMRInDev: false };
201
- }
62
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
63
+ export interface Routes {}
202
64
 
203
65
  /**
204
- * Shared context object passed to all sub-plugins via closure.
66
+ * Type-safe helper for timber.config.ts files.
205
67
  *
206
- * Sub-plugins communicate through this context not through Vite's
207
- * plugin API or global state.
208
- * See design/18-build-system.md §"Shared Plugin Context".
68
+ * A pass-through identity function that provides autocomplete and
69
+ * type checking for timber configuration. No runtime validation —
70
+ * purely a DX convenience (same pattern as Vite's defineConfig).
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * // timber.config.ts
75
+ * import { defineConfig } from '@timber-js/app';
76
+ *
77
+ * export default defineConfig({
78
+ * output: 'server',
79
+ * pageExtensions: ['tsx', 'ts', 'mdx'],
80
+ * });
81
+ * ```
209
82
  */
210
- export interface PluginContext {
211
- config: TimberUserConfig;
212
- /** Resolved client JavaScript configuration */
213
- clientJavascript: ResolvedClientJavascript;
214
- /** The scanned route tree (populated by timber-routing, consumed by timber-entries) */
215
- routeTree: RouteTree | null;
216
- /** Absolute path to the app/ directory */
217
- appDir: string;
218
- /** Absolute path to the project root */
219
- root: string;
220
- /** Whether the dev server is running (set by timber-root-sync in configResolved) */
221
- dev: boolean;
222
- /** CSS build manifest (populated by adapter after client build, null in dev) */
223
- buildManifest: BuildManifest | null;
224
- /** Startup timer for profiling cold start phases (active in dev, no-op in prod) */
225
- timer: StartupTimer;
226
- /** URL path to font CSS file, set by timber-fonts when fonts are registered */
227
- fontCssUrl?: string;
83
+ export function defineConfig(config: TimberUserConfig): TimberUserConfig {
84
+ return config;
228
85
  }
229
86
 
87
+ // ── Private helpers ───────────────────────────────────────────────────────
88
+
230
89
  /**
231
- * Resolve the app directory. Checks (in order):
232
- * 1. Explicit `configAppDir` from timber.config.ts
233
- * 2. `<root>/app`
234
- * 3. `<root>/src/app`
90
+ * Resolve the React Compiler plugin via @rolldown/plugin-babel.
235
91
  *
236
- * Throws if none exist.
92
+ * Uses the `reactCompilerPreset` from @vitejs/plugin-react, which:
93
+ * - Uses Babel ONLY for the compiler pass (OXC handles JSX)
94
+ * - Automatically scopes to client environment via applyToEnvironmentHook
95
+ * - Uses react/compiler-runtime built into React 19
96
+ *
97
+ * @rolldown/plugin-babel and babel-plugin-react-compiler are optional peer deps.
98
+ * If either is missing, require() fails with a clear error message.
237
99
  */
238
- export function resolveAppDir(root: string, configAppDir?: string): string {
239
- if (configAppDir) {
240
- const explicit = join(root, configAppDir);
241
- if (!existsSync(explicit)) {
242
- throw new Error(`[timber] Configured appDir "${configAppDir}" does not exist at ${explicit}`);
243
- }
244
- return explicit;
100
+ function resolveReactCompilerPlugin(
101
+ config: true | { compilationMode?: string; target?: string },
102
+ req: NodeRequire
103
+ ): PluginOption {
104
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
+ let babel: any;
106
+ try {
107
+ babel = req('@rolldown/plugin-babel');
108
+ } catch {
109
+ throw new Error(
110
+ '[timber] reactCompiler requires @rolldown/plugin-babel. ' +
111
+ 'Install it: pnpm add -D @rolldown/plugin-babel babel-plugin-react-compiler'
112
+ );
245
113
  }
246
-
247
- const rootApp = join(root, 'app');
248
- if (existsSync(rootApp)) return rootApp;
249
-
250
- const srcApp = join(root, 'src', 'app');
251
- if (existsSync(srcApp)) return srcApp;
252
-
253
- throw new Error(
254
- `[timber] Could not find app directory. Expected "app/" or "src/app/" in ${root}. ` +
255
- `You can set appDir in timber.config.ts to specify a custom location.`
256
- );
257
- }
258
-
259
- function createPluginContext(config?: TimberUserConfig, root?: string): PluginContext {
260
- const projectRoot = root ?? process.cwd();
261
- const resolvedConfig: TimberUserConfig = { output: 'server', ...config };
262
- // Timer starts as active — swapped to noop in configResolved for production builds
263
- return {
264
- config: resolvedConfig,
265
- clientJavascript: resolveClientJavascript(resolvedConfig),
266
- routeTree: null,
267
- appDir: join(projectRoot, 'app'),
268
- root: projectRoot,
269
- dev: false,
270
- buildManifest: null,
271
- timer: createStartupTimer(),
272
- };
114
+ const options = typeof config === 'object' ? config : {};
115
+ const babelPlugin = babel.default ?? babel;
116
+ return babelPlugin({
117
+ presets: [reactCompilerPreset(options as Parameters<typeof reactCompilerPreset>[0])],
118
+ }) as PluginOption;
273
119
  }
274
120
 
275
121
  /**
276
- * Load timber.config.ts (or .js, .mjs) from the project root.
277
- * Returns the config object or null if no config file is found.
122
+ * Build the options object for @vitejs/plugin-rsc.
123
+ *
124
+ * Uses a getter for `enableActionEncryption` so the RSC plugin reads
125
+ * the value lazily — after ctx.dev is set in configResolved. This lets
126
+ * `actionEncryption.disableInDev` work correctly even though the RSC
127
+ * plugin is created before Vite resolves the command.
278
128
  */
279
- async function loadTimberConfigFile(root: string): Promise<TimberUserConfig | null> {
280
- const configNames = ['timber.config.ts', 'timber.config.js', 'timber.config.mjs'];
129
+ function createRscOptions(
130
+ ctx: PluginContext,
131
+ encryptionKeyExpr: string | undefined
132
+ ): Record<string, unknown> {
133
+ const options: Record<string, unknown> = {
134
+ serverHandler: false,
135
+ customClientEntry: true,
136
+ entries: {
137
+ rsc: 'virtual:timber-rsc-entry',
138
+ ssr: 'virtual:timber-ssr-entry',
139
+ client: 'virtual:timber-browser-entry',
140
+ },
141
+ // Group client references by layout boundary to balance route-scoped code
142
+ // splitting with HTTP request count. A constant group name ('client-refs')
143
+ // would collapse all routes into one chunk — any page downloads every
144
+ // client component. Per-serverChunk grouping creates many sub-500B files.
145
+ // Layout-boundary grouping is the middle ground: components under the same
146
+ // layout segment share a chunk. See design/27-chunking-strategy.md, TIM-440, TIM-499.
147
+ clientChunks: (meta: { id: string; normalizedId: string; serverChunk: string }) =>
148
+ clientChunkGroup(meta, ctx.appDir),
149
+ };
150
+
151
+ // Bound args encryption — AES-256-GCM authenticated encryption for
152
+ // closure variables in 'use server' functions. Always on in production,
153
+ // configurable in dev. See design/08-forms-and-actions.md §"Bound Args Encryption".
154
+ //
155
+ // Uses a getter so the RSC plugin reads the value lazily in its transform
156
+ // hooks, after ctx.dev is set in configResolved. This lets disableInDev
157
+ // work correctly — ctx.dev is false at construction time but true during
158
+ // dev server transforms.
159
+ Object.defineProperty(options, 'enableActionEncryption', {
160
+ get() {
161
+ return shouldEnableEncryption(ctx.dev, ctx.config.actionEncryption);
162
+ },
163
+ enumerable: true,
164
+ });
281
165
 
282
- for (const name of configNames) {
283
- const configPath = join(root, name);
284
- if (existsSync(configPath)) {
285
- const mod = await import(pathToFileURL(configPath).href);
286
- return (mod.default ?? mod) as TimberUserConfig;
287
- }
166
+ // When TIMBER_ACTIONS_ENCRYPTION_KEY is set, pass it as a runtime expression
167
+ // so the RSC plugin uses it instead of auto-generating a per-build key.
168
+ if (encryptionKeyExpr) {
169
+ options.defineEncryptionKey = encryptionKeyExpr;
288
170
  }
289
- return null;
171
+
172
+ return options;
290
173
  }
291
174
 
175
+ // NOTE: 'use cache' directive transform removed — future feature pending design doc.
176
+ // The timber.cache() API (createCache) remains available for explicit caching.
177
+ // See design/06-caching.md.
178
+
179
+ // ── Main plugin factory ──────────────────────────────────────────────────
180
+
292
181
  /**
293
- * Detect config keys set in both inline (vite.config.ts) and file (timber.config.ts)
294
- * and warn the user. The `output` key is excluded because it defaults to 'server'
295
- * in createPluginContext and would always appear as an inline key.
182
+ * Create the timber Vite plugin array.
183
+ *
184
+ * Loads timber.config.ts and all dependencies synchronously before
185
+ * constructing the plugin array. This ensures ALL plugins — including
186
+ * the RSC plugin and React Compiler — see the fully merged config
187
+ * (inline + file-based). No async, no deferred config, no stale reads.
296
188
  *
297
- * Returns the list of conflicting key names (for testing).
189
+ * Requires Node >= 22.12 for synchronous require() of ESM modules
190
+ * (@vitejs/plugin-rsc is ESM-only).
191
+ *
192
+ * Previous versions used async loading and deferred config merging,
193
+ * causing file-based config for reactCompiler, actionEncryption, and
194
+ * output mode to be silently ignored. See TIM-451.
298
195
  */
299
- export function warnConfigConflicts(
300
- inline: TimberUserConfig,
301
- fileConfig: TimberUserConfig
302
- ): string[] {
303
- const conflicts: string[] = [];
304
- for (const key of Object.keys(fileConfig) as (keyof TimberUserConfig)[]) {
305
- if (key === 'output') continue;
306
- if (key in inline && inline[key] !== undefined) {
307
- conflicts.push(key);
308
- }
309
- }
310
- if (conflicts.length > 0) {
311
- console.warn(
312
- `[timber] Config conflict: ${conflicts.map((k) => `"${k}"`).join(', ')} set in both ` +
313
- `vite.config.ts (inline) and timber.config.ts. ` +
314
- `Move all config to timber.config.ts to avoid confusion. ` +
315
- `The inline value from vite.config.ts will be used.`
316
- );
317
- }
318
- return conflicts;
319
- }
196
+ export function timber(config?: TimberUserConfig): PluginOption[] {
197
+ const ctx = createPluginContext(config);
320
198
 
321
- /**
322
- * Merge file-based config into ctx.config. Inline config (already in ctx.config)
323
- * takes precedence file config only fills in missing fields.
324
- */
325
- function mergeFileConfig(ctx: PluginContext, fileConfig: TimberUserConfig): void {
326
- const inline = ctx.config;
199
+ // Resolve dependencies from the consumer's project (process.cwd()),
200
+ // not from timber's own node_modules. This is critical for pnpm link:
201
+ // when linked, timber's node_modules has a separate vite instance, and
202
+ // the RSC plugin must use the same vite instance as the dev server.
203
+ const consumerRequire = createRequire(join(process.cwd(), 'package.json'));
327
204
 
328
- // Warn if the same key is set in both places
329
- warnConfigConflicts(inline, fileConfig);
205
+ // ── Step 1: Load @vitejs/plugin-rsc ─────────────────────────────────
206
+ // Synchronous require() works for ESM modules on Node 22.12+.
207
+ ctx.timer.start('rsc-plugin-import');
208
+ const rscMod = consumerRequire('@vitejs/plugin-rsc');
209
+ const vitePluginRsc = rscMod.default ?? rscMod;
210
+ ctx.timer.end('rsc-plugin-import');
330
211
 
331
- // For each top-level key, use inline value if present, otherwise file value
332
- ctx.config = {
333
- ...fileConfig,
334
- ...inline,
335
- // Deep merge for nested objects where both exist
336
- ...(fileConfig.limits && inline.limits
337
- ? { limits: { ...fileConfig.limits, ...inline.limits } }
338
- : {}),
339
- ...(fileConfig.dev && inline.dev ? { dev: { ...fileConfig.dev, ...inline.dev } } : {}),
340
- ...(fileConfig.mdx && inline.mdx ? { mdx: { ...fileConfig.mdx, ...inline.mdx } } : {}),
341
- };
342
- }
212
+ // ── Step 2: Compute config-dependent options ────────────────────────
213
+ // encryptionKeyExpr is env-based and doesn't depend on file config.
214
+ const encryptionKeyExpr = resolveEncryptionKeyExpression();
343
215
 
344
- function timberCache(_ctx: PluginContext): Plugin {
345
- return cacheTransformPlugin();
346
- }
216
+ // ── Step 3: Pre-load file config for plugin resolution ──────────────
217
+ // Load timber.config.ts eagerly from process.cwd() so we can resolve
218
+ // plugins (like React Compiler) and add them to the top-level array.
219
+ // Vite's config() hook return type is Omit<UserConfig, 'plugins'> —
220
+ // plugins returned from config() are silently ignored. See TIM-632.
221
+ //
222
+ // The config() hook still loads from the correct Vite root (which may
223
+ // differ from cwd in monorepo setups — see TIM-498), but only for
224
+ // non-plugin config merging.
225
+ const earlyFileConfig = loadTimberConfigFile(process.cwd());
347
226
 
348
- export function timber(config?: TimberUserConfig): PluginOption[] {
349
- const ctx = createPluginContext(config);
350
- // Sync ctx.root and ctx.appDir with Vite's resolved root, which may
351
- // differ from process.cwd() when --config points to a subdirectory.
352
- // Also loads timber.config.ts and merges it into ctx.config (inline config wins).
227
+ // ── Step 4: Build rootSync plugin ───────────────────────────────────
228
+ // rootSync loads timber.config.ts from Vite's resolved root and merges
229
+ // it into ctx.config. Plugin resolution is handled eagerly above the
230
+ // config() hook must NOT return a `plugins` field (Vite ignores it).
353
231
  const rootSync: Plugin = {
354
232
  name: 'timber-root-sync',
355
- async config(userConfig, { command }) {
356
- // Load timber.config.ts early before configResolved/buildStart — so
357
- // all plugins (including timber-mdx) see the merged config in their
358
- // buildStart hooks. The config hook runs once and supports async.
359
- const root = userConfig.root ?? process.cwd();
233
+ config(userConfig, { command }) {
234
+ // ── Load timber.config.ts from the correct root ───────────────
235
+ // Vite's `config` hook fires before `configResolved`. The user's
236
+ // `root` option (if set) tells us where the project lives.
237
+ // `resolve()` mirrors Vite's own root resolution logic.
238
+ const viteRoot = resolve(userConfig.root ?? process.cwd());
360
239
  ctx.timer.start('config-load');
361
- const fileConfig = await loadTimberConfigFile(root);
240
+ const fileConfig = loadTimberConfigFile(viteRoot);
362
241
  if (fileConfig) {
363
242
  mergeFileConfig(ctx, fileConfig);
364
243
  ctx.clientJavascript = resolveClientJavascript(ctx.config);
365
244
  }
245
+ // Apply defaults AFTER merge so file-based config isn't overridden
246
+ // by defaults that were baked into the inline config object.
247
+ ctx.config.output ??= 'server';
366
248
  ctx.timer.end('config-load');
367
249
 
250
+ // Warn if the Vite root differs from cwd and the re-loaded config
251
+ // has reactCompiler but the early cwd-based load missed it. In this
252
+ // edge case the user must move reactCompiler to inline config.
253
+ if (viteRoot !== process.cwd()) {
254
+ const hasCompilerInReloaded = !config?.reactCompiler && ctx.config.reactCompiler;
255
+ const hadCompilerInEarly = !config?.reactCompiler && earlyFileConfig?.reactCompiler;
256
+ if (hasCompilerInReloaded && !hadCompilerInEarly) {
257
+ console.warn(
258
+ '[timber] reactCompiler is set in timber.config.ts but could not be ' +
259
+ 'registered because the config file is in a non-cwd root directory. ' +
260
+ 'Move reactCompiler to the inline timber() config in vite.config.ts, or ' +
261
+ 'run vite from the project root directory.'
262
+ );
263
+ }
264
+ }
265
+
368
266
  // Force production JSX transform for builds.
369
267
  //
370
268
  // Vite determines dev vs prod JSX via `isProduction`, which checks
@@ -378,6 +276,38 @@ export function timber(config?: TimberUserConfig): PluginOption[] {
378
276
  // We explicitly set `oxc.jsx.development: false` for builds so
379
277
  // the client bundle always uses jsx/jsxs from react/jsx-runtime,
380
278
  // regardless of the ambient NODE_ENV value.
279
+ // ── Start holding server for dev mode ───────────────────────
280
+ // Bind the port immediately so browsers see a loading page
281
+ // instead of ERR_CONNECTION_REFUSED during the ~6-8s startup.
282
+ // The holding server is closed in timber-dev-server's
283
+ // configureServer hook (the last plugin), right before Vite
284
+ // calls server.listen().
285
+ // See design/21-dev-server.md §"Startup Holding Server", TIM-665.
286
+ if (command === 'serve') {
287
+ const port = (userConfig.server?.port as number) ?? 5173;
288
+ try {
289
+ ctx.holdingServer = createHoldingServer();
290
+ // listen() is async but we fire-and-forget — the server
291
+ // starts binding immediately and will be ready well before
292
+ // any browser request arrives. We can't await here because
293
+ // config() must return synchronously.
294
+ ctx.holdingServer.listen(port).then(
295
+ (boundPort) => {
296
+ const url = `http://localhost:${boundPort}`;
297
+ console.log(
298
+ `\n \x1b[2m🪵 timber.js dev server starting at\x1b[0m \x1b[36m${url}\x1b[0m\n`
299
+ );
300
+ },
301
+ () => {
302
+ // Port already in use — skip gracefully.
303
+ ctx.holdingServer = null;
304
+ }
305
+ );
306
+ } catch {
307
+ ctx.holdingServer = null;
308
+ }
309
+ }
310
+
381
311
  if (command === 'build') {
382
312
  return {
383
313
  oxc: {
@@ -401,17 +331,28 @@ export function timber(config?: TimberUserConfig): PluginOption[] {
401
331
  }
402
332
  },
403
333
  };
334
+
335
+ // ── Step 5: Resolve optional plugins ────────────────────────────────
336
+ // React Compiler — resolved eagerly from either inline or file config.
337
+ // Vite's config() hook return type is Omit<UserConfig, 'plugins'>, so
338
+ // plugins MUST be in the top-level array — returning them from config()
339
+ // silently drops them. See TIM-632.
340
+ //
341
+ // Inline config takes precedence. File config (from the early cwd-based
342
+ // load) is used when inline config doesn't set reactCompiler.
343
+ const reactCompilerPlugins: PluginOption[] = [];
344
+ const effectiveReactCompiler = config?.reactCompiler ?? earlyFileConfig?.reactCompiler;
345
+ if (effectiveReactCompiler) {
346
+ reactCompilerPlugins.push(resolveReactCompilerPlugin(effectiveReactCompiler, consumerRequire));
347
+ }
348
+
349
+ // ── Step 6: Assemble plugin array ─────────────────────────────────────
404
350
  // @vitejs/plugin-rsc handles:
405
351
  // - RSC/SSR/client environment setup
406
352
  // - "use client" directive → client reference proxy transformation
407
353
  // - "use server" directive → server reference transformation
408
354
  // - Client reference tracking and module map generation
409
355
  //
410
- // Loaded via dynamic import() because @vitejs/plugin-rsc is ESM-only.
411
- // Vite's config loader uses esbuild to transpile to CJS, which breaks
412
- // static imports of ESM-only packages. The dynamic import() is preserved
413
- // by esbuild and runs natively in ESM at runtime.
414
- //
415
356
  // serverHandler: false — timber has its own dev server (timber-dev-server)
416
357
  // entries — tells the RSC plugin about timber's virtual entry modules so
417
358
  // it correctly wires up the browser entry (needed for React Fast Refresh
@@ -424,30 +365,6 @@ export function timber(config?: TimberUserConfig): PluginOption[] {
424
365
  // We do NOT set customBuildApp — the RSC plugin's orchestration is correct
425
366
  // and handles bundle ordering, asset manifest generation, and environment
426
367
  // imports manifest. See @vitejs/plugin-rsc's buildApp implementation.
427
- // Resolve @vitejs/plugin-rsc from the consumer's project (process.cwd()),
428
- // not from timber's own node_modules. This is critical for pnpm link:
429
- // when linked, timber's node_modules has a separate vite instance, and
430
- // the RSC plugin must use the same vite instance as the dev server.
431
- const consumerRequire = createRequire(join(process.cwd(), 'package.json'));
432
- const rscPluginPath = consumerRequire.resolve('@vitejs/plugin-rsc');
433
- ctx.timer.start('rsc-plugin-import');
434
- const rscPluginsPromise = import(pathToFileURL(rscPluginPath).href).then(
435
- ({ default: vitePluginRsc }) => {
436
- ctx.timer.end('rsc-plugin-import');
437
- return vitePluginRsc({
438
- serverHandler: false,
439
- customClientEntry: true,
440
- entries: {
441
- rsc: 'virtual:timber-rsc-entry',
442
- ssr: 'virtual:timber-ssr-entry',
443
- client: 'virtual:timber-browser-entry',
444
- },
445
- // No custom clientChunks — Rolldown handles natural code splitting.
446
- // See design/27-chunking-strategy.md and LOCAL-337.
447
- });
448
- }
449
- );
450
-
451
368
  return [
452
369
  rootSync,
453
370
  timberReactProd(),
@@ -456,15 +373,14 @@ export function timber(config?: TimberUserConfig): PluginOption[] {
456
373
  // following Vinext's convention — the RSC plugin's virtual browser entry
457
374
  // coordinates with plugin-react via __vite_plugin_react_preamble_installed__.
458
375
  react(),
376
+ ...reactCompilerPlugins,
459
377
  timberServerActionExports(),
460
- rscPluginsPromise,
378
+ vitePluginRsc(createRscOptions(ctx, encryptionKeyExpr)),
461
379
  timberShims(ctx),
462
380
  timberRouting(ctx),
463
381
  timberEntries(ctx),
464
382
  timberBuildManifest(ctx),
465
- timberCache(ctx),
466
383
  timberStaticBuild(ctx),
467
- timberDynamicTransform(ctx),
468
384
  timberFonts(ctx),
469
385
  timberMdx(ctx),
470
386
  timberContent(ctx),
@@ -473,21 +389,9 @@ export function timber(config?: TimberUserConfig): PluginOption[] {
473
389
  timberBuildReport(ctx), // Post-build: route table with bundle sizes
474
390
  timberAdapterBuild(ctx), // Post-build: invoke adapter.buildOutput()
475
391
  timberDevLogs(ctx), // Dev-only: forward server console.* to browser console
392
+ timberDevBrowserLogs(ctx), // Dev-only: forward browser console.* to server terminal
476
393
  timberDevServer(ctx), // Must be last — configureServer post-hook runs after all watchers
477
394
  ];
478
395
  }
479
396
 
480
- /**
481
- * Route map interface — augmented by the generated timber-routes.d.ts.
482
- *
483
- * Each key is a route path pattern. Values have:
484
- * params: shape of URL params (e.g. { id: string })
485
- * searchParams: parsed type from search-params.ts, or {} if none
486
- *
487
- * This interface is empty by default and populated via codegen.
488
- * See design/09-typescript.md §"Typed Routes".
489
- */
490
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
491
- export interface Routes {}
492
-
493
397
  export default timber;