@timber-js/app 0.2.0-alpha.13 → 0.2.0-alpha.131

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 (785) hide show
  1. package/LICENSE +8 -0
  2. package/dist/_chunks/actions-BNhpxrnV.js +1104 -0
  3. package/dist/_chunks/actions-BNhpxrnV.js.map +1 -0
  4. package/dist/_chunks/build-output-helper-K7oUCRqU.js +102 -0
  5. package/dist/_chunks/build-output-helper-K7oUCRqU.js.map +1 -0
  6. package/dist/_chunks/cli-schema-sync-CObqjGWF.js +2 -0
  7. package/dist/_chunks/cli-schema-sync-q-Ce6-iG.js +785 -0
  8. package/dist/_chunks/cli-schema-sync-q-Ce6-iG.js.map +1 -0
  9. package/dist/_chunks/codec-registry-DqkeAydt.js +21 -0
  10. package/dist/_chunks/codec-registry-DqkeAydt.js.map +1 -0
  11. package/dist/_chunks/define-DMq-Yjp7.js +112 -0
  12. package/dist/_chunks/define-DMq-Yjp7.js.map +1 -0
  13. package/dist/_chunks/define-jeHDXZGq.js +195 -0
  14. package/dist/_chunks/define-jeHDXZGq.js.map +1 -0
  15. package/dist/_chunks/format-BjN9HLu9.js +14 -0
  16. package/dist/_chunks/format-BjN9HLu9.js.map +1 -0
  17. package/dist/_chunks/handler-store-bIAstrxQ.js +54 -0
  18. package/dist/_chunks/handler-store-bIAstrxQ.js.map +1 -0
  19. package/dist/_chunks/logger-CMd9P1xQ.js +291 -0
  20. package/dist/_chunks/logger-CMd9P1xQ.js.map +1 -0
  21. package/dist/_chunks/merge-search-params-Cm1j99HC.js +41 -0
  22. package/dist/_chunks/merge-search-params-Cm1j99HC.js.map +1 -0
  23. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js → metadata-routes-DESG8uk5.js} +32 -19
  24. package/dist/_chunks/metadata-routes-DESG8uk5.js.map +1 -0
  25. package/dist/_chunks/navigation-root-B5-RmsPi.js +103 -0
  26. package/dist/_chunks/navigation-root-B5-RmsPi.js.map +1 -0
  27. package/dist/_chunks/registry-BI9cgCt7.js +20 -0
  28. package/dist/_chunks/registry-BI9cgCt7.js.map +1 -0
  29. package/dist/_chunks/resolve-schema-DU2nbVOi.js +77 -0
  30. package/dist/_chunks/resolve-schema-DU2nbVOi.js.map +1 -0
  31. package/dist/_chunks/router-ref-B2-2kIIC.js +28 -0
  32. package/dist/_chunks/router-ref-B2-2kIIC.js.map +1 -0
  33. package/dist/_chunks/schema-bridge-o0SwFtXW.js +86 -0
  34. package/dist/_chunks/schema-bridge-o0SwFtXW.js.map +1 -0
  35. package/dist/_chunks/segment-classify-BjfuctV2.js +137 -0
  36. package/dist/_chunks/segment-classify-BjfuctV2.js.map +1 -0
  37. package/dist/_chunks/segment-context-Bg0pFbLT.js +34 -0
  38. package/dist/_chunks/segment-context-Bg0pFbLT.js.map +1 -0
  39. package/dist/_chunks/{ssr-data-MjmprTmO.js → ssr-data-DVX8S7vj.js} +1 -1
  40. package/dist/_chunks/ssr-data-DVX8S7vj.js.map +1 -0
  41. package/dist/_chunks/stale-reload-CCqb62Z3.js +84 -0
  42. package/dist/_chunks/stale-reload-CCqb62Z3.js.map +1 -0
  43. package/dist/_chunks/tracing-DP5djRq5.js +358 -0
  44. package/dist/_chunks/tracing-DP5djRq5.js.map +1 -0
  45. package/dist/_chunks/{use-query-states-D5KaffOK.js → use-query-states-C9G6LP0F.js} +7 -20
  46. package/dist/_chunks/use-query-states-C9G6LP0F.js.map +1 -0
  47. package/dist/_chunks/use-segment-params-CIeinIx2.js +151 -0
  48. package/dist/_chunks/use-segment-params-CIeinIx2.js.map +1 -0
  49. package/dist/_chunks/validation-AfEFM5ze.js +84 -0
  50. package/dist/_chunks/validation-AfEFM5ze.js.map +1 -0
  51. package/dist/_chunks/walkers-BbEu2_Pp.js +724 -0
  52. package/dist/_chunks/walkers-BbEu2_Pp.js.map +1 -0
  53. package/dist/_chunks/{format-DviM89f0.js → warnings-CAzunaGo.js} +6 -45
  54. package/dist/_chunks/warnings-CAzunaGo.js.map +1 -0
  55. package/dist/adapters/build-output-helper.d.ts +28 -0
  56. package/dist/adapters/build-output-helper.d.ts.map +1 -0
  57. package/dist/adapters/cloudflare-dev.d.ts +109 -0
  58. package/dist/adapters/cloudflare-dev.d.ts.map +1 -0
  59. package/dist/adapters/cloudflare-dev.js +73 -0
  60. package/dist/adapters/cloudflare-dev.js.map +1 -0
  61. package/dist/adapters/cloudflare-kv-cache.d.ts +64 -0
  62. package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -0
  63. package/dist/adapters/cloudflare-kv-cache.js +95 -0
  64. package/dist/adapters/cloudflare-kv-cache.js.map +1 -0
  65. package/dist/adapters/cloudflare.d.ts +148 -12
  66. package/dist/adapters/cloudflare.d.ts.map +1 -1
  67. package/dist/adapters/cloudflare.js +142 -38
  68. package/dist/adapters/cloudflare.js.map +1 -1
  69. package/dist/adapters/compress-module.d.ts.map +1 -1
  70. package/dist/adapters/nitro.d.ts +17 -1
  71. package/dist/adapters/nitro.d.ts.map +1 -1
  72. package/dist/adapters/nitro.js +143 -45
  73. package/dist/adapters/nitro.js.map +1 -1
  74. package/dist/adapters/shared.d.ts +16 -0
  75. package/dist/adapters/shared.d.ts.map +1 -0
  76. package/dist/cache/cache-api.d.ts +24 -0
  77. package/dist/cache/cache-api.d.ts.map +1 -0
  78. package/dist/cache/handler-store.d.ts +31 -0
  79. package/dist/cache/handler-store.d.ts.map +1 -0
  80. package/dist/cache/index.d.ts +23 -7
  81. package/dist/cache/index.d.ts.map +1 -1
  82. package/dist/cache/index.js +151 -81
  83. package/dist/cache/index.js.map +1 -1
  84. package/dist/cache/singleflight.d.ts +18 -1
  85. package/dist/cache/singleflight.d.ts.map +1 -1
  86. package/dist/cache/sizeof.d.ts +22 -0
  87. package/dist/cache/sizeof.d.ts.map +1 -0
  88. package/dist/cache/timber-cache.d.ts +1 -1
  89. package/dist/cache/timber-cache.d.ts.map +1 -1
  90. package/dist/cli-schema-sync.d.ts +39 -0
  91. package/dist/cli-schema-sync.d.ts.map +1 -0
  92. package/dist/cli.d.ts +14 -2
  93. package/dist/cli.d.ts.map +1 -1
  94. package/dist/cli.js +48 -6
  95. package/dist/cli.js.map +1 -1
  96. package/dist/client/browser-dev.d.ts +34 -1
  97. package/dist/client/browser-dev.d.ts.map +1 -1
  98. package/dist/client/browser-entry/action-dispatch.d.ts +17 -0
  99. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -0
  100. package/dist/client/browser-entry/hmr.d.ts +21 -0
  101. package/dist/client/browser-entry/hmr.d.ts.map +1 -0
  102. package/dist/client/browser-entry/hydrate.d.ts +46 -0
  103. package/dist/client/browser-entry/hydrate.d.ts.map +1 -0
  104. package/dist/client/browser-entry/index.d.ts +30 -0
  105. package/dist/client/browser-entry/index.d.ts.map +1 -0
  106. package/dist/client/browser-entry/post-hydration.d.ts +26 -0
  107. package/dist/client/browser-entry/post-hydration.d.ts.map +1 -0
  108. package/dist/client/browser-entry/router-init.d.ts +26 -0
  109. package/dist/client/browser-entry/router-init.d.ts.map +1 -0
  110. package/dist/client/browser-entry/rsc-stream.d.ts +24 -0
  111. package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -0
  112. package/dist/client/browser-entry/scroll.d.ts +19 -0
  113. package/dist/client/browser-entry/scroll.d.ts.map +1 -0
  114. package/dist/client/error-boundary.d.ts +12 -5
  115. package/dist/client/error-boundary.d.ts.map +1 -1
  116. package/dist/client/error-boundary.js +29 -6
  117. package/dist/client/error-boundary.js.map +1 -1
  118. package/dist/client/error-reconstituter.d.ts +54 -0
  119. package/dist/client/error-reconstituter.d.ts.map +1 -0
  120. package/dist/client/form.d.ts +16 -27
  121. package/dist/client/form.d.ts.map +1 -1
  122. package/dist/client/history.d.ts +19 -4
  123. package/dist/client/history.d.ts.map +1 -1
  124. package/dist/client/index.d.ts +10 -24
  125. package/dist/client/index.d.ts.map +1 -1
  126. package/dist/client/index.js +180 -1119
  127. package/dist/client/index.js.map +1 -1
  128. package/dist/client/internal.d.ts +19 -0
  129. package/dist/client/internal.d.ts.map +1 -0
  130. package/dist/client/internal.js +845 -0
  131. package/dist/client/internal.js.map +1 -0
  132. package/dist/client/link-pending-store.d.ts +65 -0
  133. package/dist/client/link-pending-store.d.ts.map +1 -0
  134. package/dist/client/link.d.ts +67 -56
  135. package/dist/client/link.d.ts.map +1 -1
  136. package/dist/client/nav-link-store.d.ts +27 -0
  137. package/dist/client/nav-link-store.d.ts.map +1 -0
  138. package/dist/client/navigation-api-types.d.ts +90 -0
  139. package/dist/client/navigation-api-types.d.ts.map +1 -0
  140. package/dist/client/navigation-api.d.ts +115 -0
  141. package/dist/client/navigation-api.d.ts.map +1 -0
  142. package/dist/client/navigation-context.d.ts +14 -2
  143. package/dist/client/navigation-context.d.ts.map +1 -1
  144. package/dist/client/{transition-root.d.ts → navigation-root.d.ts} +46 -9
  145. package/dist/client/navigation-root.d.ts.map +1 -0
  146. package/dist/client/nuqs-adapter.d.ts.map +1 -1
  147. package/dist/client/router-ref.d.ts +1 -1
  148. package/dist/client/router.d.ts +79 -10
  149. package/dist/client/router.d.ts.map +1 -1
  150. package/dist/client/rsc-fetch.d.ts +46 -3
  151. package/dist/client/rsc-fetch.d.ts.map +1 -1
  152. package/dist/client/segment-cache.d.ts +3 -1
  153. package/dist/client/segment-cache.d.ts.map +1 -1
  154. package/dist/client/segment-outlet.d.ts +49 -0
  155. package/dist/client/segment-outlet.d.ts.map +1 -0
  156. package/dist/client/segment-update-context.d.ts +21 -0
  157. package/dist/client/segment-update-context.d.ts.map +1 -0
  158. package/dist/client/shallow-url.d.ts +10 -0
  159. package/dist/client/shallow-url.d.ts.map +1 -0
  160. package/dist/client/ssr-data.d.ts +13 -4
  161. package/dist/client/ssr-data.d.ts.map +1 -1
  162. package/dist/client/stale-reload.d.ts +15 -0
  163. package/dist/client/stale-reload.d.ts.map +1 -1
  164. package/dist/client/state.d.ts +1 -1
  165. package/dist/client/top-loader.d.ts +5 -5
  166. package/dist/client/top-loader.d.ts.map +1 -1
  167. package/dist/client/use-cookie.d.ts +12 -0
  168. package/dist/client/use-cookie.d.ts.map +1 -1
  169. package/dist/client/use-link-status.d.ts +5 -5
  170. package/dist/client/use-link-status.d.ts.map +1 -1
  171. package/dist/client/use-pending-navigation.d.ts +23 -0
  172. package/dist/client/use-pending-navigation.d.ts.map +1 -0
  173. package/dist/client/use-query-states.d.ts +1 -1
  174. package/dist/client/use-query-states.d.ts.map +1 -1
  175. package/dist/client/use-router.d.ts +1 -1
  176. package/dist/client/use-search-params.d.ts +7 -5
  177. package/dist/client/use-search-params.d.ts.map +1 -1
  178. package/dist/client/{use-params.d.ts → use-segment-params.d.ts} +8 -6
  179. package/dist/client/use-segment-params.d.ts.map +1 -0
  180. package/dist/codec.d.ts +69 -0
  181. package/dist/codec.d.ts.map +1 -0
  182. package/dist/codec.js +75 -0
  183. package/dist/codec.js.map +1 -0
  184. package/dist/config-types.d.ts +294 -0
  185. package/dist/config-types.d.ts.map +1 -0
  186. package/dist/config-validation.d.ts +51 -0
  187. package/dist/config-validation.d.ts.map +1 -0
  188. package/dist/content/index.d.ts +1 -10
  189. package/dist/content/index.d.ts.map +1 -1
  190. package/dist/content/index.js +0 -2
  191. package/dist/cookies/define-cookie.d.ts +58 -25
  192. package/dist/cookies/define-cookie.d.ts.map +1 -1
  193. package/dist/cookies/index.d.ts +2 -1
  194. package/dist/cookies/index.d.ts.map +1 -1
  195. package/dist/cookies/index.js +251 -36
  196. package/dist/cookies/index.js.map +1 -1
  197. package/dist/cookies/json-cookie.d.ts +64 -0
  198. package/dist/cookies/json-cookie.d.ts.map +1 -0
  199. package/dist/cookies/validation.d.ts +46 -0
  200. package/dist/cookies/validation.d.ts.map +1 -0
  201. package/dist/dev-tools/404-page.d.ts +46 -0
  202. package/dist/dev-tools/404-page.d.ts.map +1 -0
  203. package/dist/dev-tools/browser-logs.d.ts +84 -0
  204. package/dist/dev-tools/browser-logs.d.ts.map +1 -0
  205. package/dist/dev-tools/error-page.d.ts +58 -0
  206. package/dist/dev-tools/error-page.d.ts.map +1 -0
  207. package/dist/dev-tools/holding-server.d.ts +54 -0
  208. package/dist/dev-tools/holding-server.d.ts.map +1 -0
  209. package/dist/dev-tools/index.d.ts +31 -0
  210. package/dist/dev-tools/index.d.ts.map +1 -0
  211. package/dist/{server/dev-span-processor.d.ts → dev-tools/instrumentation.d.ts} +26 -6
  212. package/dist/dev-tools/instrumentation.d.ts.map +1 -0
  213. package/dist/{server/dev-logger.d.ts → dev-tools/logger.d.ts} +1 -1
  214. package/dist/dev-tools/logger.d.ts.map +1 -0
  215. package/dist/{plugins/dev-logs.d.ts → dev-tools/logs.d.ts} +2 -2
  216. package/dist/dev-tools/logs.d.ts.map +1 -0
  217. package/dist/dev-tools/overlay.d.ts +91 -0
  218. package/dist/dev-tools/overlay.d.ts.map +1 -0
  219. package/dist/dev-tools/stack-classifier.d.ts +34 -0
  220. package/dist/dev-tools/stack-classifier.d.ts.map +1 -0
  221. package/dist/dev-tools/terminal.d.ts +28 -0
  222. package/dist/dev-tools/terminal.d.ts.map +1 -0
  223. package/dist/{server/dev-warnings.d.ts → dev-tools/warnings.d.ts} +2 -22
  224. package/dist/dev-tools/warnings.d.ts.map +1 -0
  225. package/dist/fonts/ast.d.ts +98 -6
  226. package/dist/fonts/ast.d.ts.map +1 -1
  227. package/dist/fonts/bundle.d.ts +48 -0
  228. package/dist/fonts/bundle.d.ts.map +1 -0
  229. package/dist/fonts/dev-middleware.d.ts +22 -0
  230. package/dist/fonts/dev-middleware.d.ts.map +1 -0
  231. package/dist/fonts/local.d.ts +1 -1
  232. package/dist/fonts/pipeline.d.ts +167 -0
  233. package/dist/fonts/pipeline.d.ts.map +1 -0
  234. package/dist/fonts/transform.d.ts +78 -0
  235. package/dist/fonts/transform.d.ts.map +1 -0
  236. package/dist/fonts/types.d.ts +45 -1
  237. package/dist/fonts/types.d.ts.map +1 -1
  238. package/dist/fonts/virtual-modules.d.ts +94 -0
  239. package/dist/fonts/virtual-modules.d.ts.map +1 -0
  240. package/dist/index.d.ts +46 -164
  241. package/dist/index.d.ts.map +1 -1
  242. package/dist/index.js +5584 -13386
  243. package/dist/index.js.map +1 -1
  244. package/dist/params/codec-registry.d.ts +26 -0
  245. package/dist/params/codec-registry.d.ts.map +1 -0
  246. package/dist/params/define-schema.d.ts +81 -0
  247. package/dist/params/define-schema.d.ts.map +1 -0
  248. package/dist/params/index.d.ts +5 -0
  249. package/dist/params/index.d.ts.map +1 -0
  250. package/dist/params/index.js +34 -0
  251. package/dist/params/index.js.map +1 -0
  252. package/dist/params/resolve-schema.d.ts +34 -0
  253. package/dist/params/resolve-schema.d.ts.map +1 -0
  254. package/dist/plugin-context.d.ts +107 -0
  255. package/dist/plugin-context.d.ts.map +1 -0
  256. package/dist/plugins/adapter-build.d.ts +1 -1
  257. package/dist/plugins/adapter-build.d.ts.map +1 -1
  258. package/dist/plugins/build-manifest.d.ts +2 -2
  259. package/dist/plugins/build-manifest.d.ts.map +1 -1
  260. package/dist/plugins/build-report.d.ts +9 -7
  261. package/dist/plugins/build-report.d.ts.map +1 -1
  262. package/dist/plugins/client-chunks.d.ts +32 -0
  263. package/dist/plugins/client-chunks.d.ts.map +1 -0
  264. package/dist/plugins/cloudflare-wasm.d.ts +18 -0
  265. package/dist/plugins/cloudflare-wasm.d.ts.map +1 -0
  266. package/dist/plugins/content.d.ts +1 -1
  267. package/dist/plugins/content.d.ts.map +1 -1
  268. package/dist/plugins/dev-server.d.ts +1 -1
  269. package/dist/plugins/dev-server.d.ts.map +1 -1
  270. package/dist/plugins/entries.d.ts +1 -1
  271. package/dist/plugins/entries.d.ts.map +1 -1
  272. package/dist/plugins/fonts.d.ts +17 -73
  273. package/dist/plugins/fonts.d.ts.map +1 -1
  274. package/dist/plugins/mdx.d.ts +1 -1
  275. package/dist/plugins/mdx.d.ts.map +1 -1
  276. package/dist/plugins/routing.d.ts +1 -1
  277. package/dist/plugins/routing.d.ts.map +1 -1
  278. package/dist/plugins/server-bundle.d.ts.map +1 -1
  279. package/dist/plugins/shims.d.ts +6 -5
  280. package/dist/plugins/shims.d.ts.map +1 -1
  281. package/dist/plugins/static-build.d.ts +5 -26
  282. package/dist/plugins/static-build.d.ts.map +1 -1
  283. package/dist/routing/codegen-shared.d.ts +67 -0
  284. package/dist/routing/codegen-shared.d.ts.map +1 -0
  285. package/dist/routing/codegen-types.d.ts +60 -0
  286. package/dist/routing/codegen-types.d.ts.map +1 -0
  287. package/dist/routing/codegen.d.ts +7 -2
  288. package/dist/routing/codegen.d.ts.map +1 -1
  289. package/dist/routing/convention-lint.d.ts +41 -0
  290. package/dist/routing/convention-lint.d.ts.map +1 -0
  291. package/dist/routing/index.d.ts +7 -1
  292. package/dist/routing/index.d.ts.map +1 -1
  293. package/dist/routing/index.js +4 -2
  294. package/dist/routing/link-codegen.d.ts +90 -0
  295. package/dist/routing/link-codegen.d.ts.map +1 -0
  296. package/dist/routing/scanner.d.ts +1 -10
  297. package/dist/routing/scanner.d.ts.map +1 -1
  298. package/dist/routing/schema-validation.d.ts +35 -0
  299. package/dist/routing/schema-validation.d.ts.map +1 -0
  300. package/dist/routing/segment-classify.d.ts +75 -0
  301. package/dist/routing/segment-classify.d.ts.map +1 -0
  302. package/dist/routing/segment-codegen.d.ts +38 -0
  303. package/dist/routing/segment-codegen.d.ts.map +1 -0
  304. package/dist/routing/types.d.ts +77 -25
  305. package/dist/routing/types.d.ts.map +1 -1
  306. package/dist/routing/walkers.d.ts +51 -0
  307. package/dist/routing/walkers.d.ts.map +1 -0
  308. package/dist/rsc-runtime/rsc.d.ts +1 -1
  309. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  310. package/dist/rsc-runtime/ssr.d.ts +12 -0
  311. package/dist/rsc-runtime/ssr.d.ts.map +1 -1
  312. package/dist/schema-bridge.d.ts +76 -0
  313. package/dist/schema-bridge.d.ts.map +1 -0
  314. package/dist/search-params/define.d.ts +157 -0
  315. package/dist/search-params/define.d.ts.map +1 -0
  316. package/dist/search-params/index.d.ts +4 -7
  317. package/dist/search-params/index.d.ts.map +1 -1
  318. package/dist/search-params/index.js +34 -441
  319. package/dist/search-params/index.js.map +1 -1
  320. package/dist/search-params/registry.d.ts +2 -2
  321. package/dist/search-params/registry.d.ts.map +1 -1
  322. package/dist/search-params/wrappers.d.ts +53 -0
  323. package/dist/search-params/wrappers.d.ts.map +1 -0
  324. package/dist/segment-params/define.d.ts +89 -0
  325. package/dist/segment-params/define.d.ts.map +1 -0
  326. package/dist/segment-params/index.d.ts +3 -0
  327. package/dist/segment-params/index.d.ts.map +1 -0
  328. package/dist/segment-params/index.js +2 -0
  329. package/dist/server/access-gate.d.ts +8 -3
  330. package/dist/server/access-gate.d.ts.map +1 -1
  331. package/dist/server/action-client.d.ts +41 -6
  332. package/dist/server/action-client.d.ts.map +1 -1
  333. package/dist/server/action-encryption.d.ts +76 -0
  334. package/dist/server/action-encryption.d.ts.map +1 -0
  335. package/dist/server/action-handler.d.ts +35 -1
  336. package/dist/server/action-handler.d.ts.map +1 -1
  337. package/dist/server/actions.d.ts +6 -14
  338. package/dist/server/actions.d.ts.map +1 -1
  339. package/dist/server/als-registry.d.ts +70 -11
  340. package/dist/server/als-registry.d.ts.map +1 -1
  341. package/dist/server/asset-headers.d.ts +1 -15
  342. package/dist/server/asset-headers.d.ts.map +1 -1
  343. package/dist/server/build-manifest.d.ts +8 -2
  344. package/dist/server/build-manifest.d.ts.map +1 -1
  345. package/dist/server/coalesce-tick.d.ts +40 -0
  346. package/dist/server/coalesce-tick.d.ts.map +1 -0
  347. package/dist/server/cookie-context.d.ts +170 -0
  348. package/dist/server/cookie-context.d.ts.map +1 -0
  349. package/dist/server/cookie-parsing.d.ts +51 -0
  350. package/dist/server/cookie-parsing.d.ts.map +1 -0
  351. package/dist/server/debug.d.ts +1 -1
  352. package/dist/server/default-logger.d.ts +22 -0
  353. package/dist/server/default-logger.d.ts.map +1 -0
  354. package/dist/server/deny-boundary.d.ts +90 -0
  355. package/dist/server/deny-boundary.d.ts.map +1 -0
  356. package/dist/server/deny-renderer.d.ts +1 -1
  357. package/dist/server/deny-renderer.d.ts.map +1 -1
  358. package/dist/server/dev-source-map.d.ts +22 -0
  359. package/dist/server/dev-source-map.d.ts.map +1 -0
  360. package/dist/server/early-hints-sender.d.ts.map +1 -1
  361. package/dist/server/early-hints.d.ts +13 -5
  362. package/dist/server/early-hints.d.ts.map +1 -1
  363. package/dist/server/error-boundary-wrapper.d.ts +7 -1
  364. package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
  365. package/dist/server/fallback-error.d.ts +12 -7
  366. package/dist/server/fallback-error.d.ts.map +1 -1
  367. package/dist/server/flight-injection-state.d.ts +66 -0
  368. package/dist/server/flight-injection-state.d.ts.map +1 -0
  369. package/dist/server/flight-scripts.d.ts +42 -0
  370. package/dist/server/flight-scripts.d.ts.map +1 -0
  371. package/dist/server/flush.d.ts.map +1 -1
  372. package/dist/server/form-data.d.ts +29 -0
  373. package/dist/server/form-data.d.ts.map +1 -1
  374. package/dist/server/html-injector-core.d.ts +213 -0
  375. package/dist/server/html-injector-core.d.ts.map +1 -0
  376. package/dist/server/html-injectors.d.ts +81 -41
  377. package/dist/server/html-injectors.d.ts.map +1 -1
  378. package/dist/server/index.d.ts +10 -46
  379. package/dist/server/index.d.ts.map +1 -1
  380. package/dist/server/index.js +155 -2905
  381. package/dist/server/index.js.map +1 -1
  382. package/dist/server/internal.d.ts +48 -0
  383. package/dist/server/internal.d.ts.map +1 -0
  384. package/dist/server/internal.js +3027 -0
  385. package/dist/server/internal.js.map +1 -0
  386. package/dist/server/logger.d.ts +39 -7
  387. package/dist/server/logger.d.ts.map +1 -1
  388. package/dist/server/metadata-routes.d.ts +23 -7
  389. package/dist/server/metadata-routes.d.ts.map +1 -1
  390. package/dist/server/middleware-runner.d.ts +36 -4
  391. package/dist/server/middleware-runner.d.ts.map +1 -1
  392. package/dist/server/node-stream-transforms.d.ts +112 -0
  393. package/dist/server/node-stream-transforms.d.ts.map +1 -0
  394. package/dist/server/param-coercion.d.ts +54 -0
  395. package/dist/server/param-coercion.d.ts.map +1 -0
  396. package/dist/server/pipeline-helpers.d.ts +95 -0
  397. package/dist/server/pipeline-helpers.d.ts.map +1 -0
  398. package/dist/server/pipeline-interception.d.ts +1 -1
  399. package/dist/server/pipeline-interception.d.ts.map +1 -1
  400. package/dist/server/pipeline-metadata.d.ts +6 -0
  401. package/dist/server/pipeline-metadata.d.ts.map +1 -1
  402. package/dist/server/pipeline-outcome.d.ts +49 -0
  403. package/dist/server/pipeline-outcome.d.ts.map +1 -0
  404. package/dist/server/pipeline-phases.d.ts +52 -0
  405. package/dist/server/pipeline-phases.d.ts.map +1 -0
  406. package/dist/server/pipeline.d.ts +118 -23
  407. package/dist/server/pipeline.d.ts.map +1 -1
  408. package/dist/server/port-resolution.d.ts +117 -0
  409. package/dist/server/port-resolution.d.ts.map +1 -0
  410. package/dist/server/primitives.d.ts +69 -18
  411. package/dist/server/primitives.d.ts.map +1 -1
  412. package/dist/server/render-timeout.d.ts +51 -0
  413. package/dist/server/render-timeout.d.ts.map +1 -0
  414. package/dist/server/request-context.d.ts +62 -107
  415. package/dist/server/request-context.d.ts.map +1 -1
  416. package/dist/server/route-element-builder.d.ts +28 -2
  417. package/dist/server/route-element-builder.d.ts.map +1 -1
  418. package/dist/server/route-handler.d.ts.map +1 -1
  419. package/dist/server/route-matcher.d.ts +25 -36
  420. package/dist/server/route-matcher.d.ts.map +1 -1
  421. package/dist/server/rsc-entry/action-middleware-runner.d.ts +66 -0
  422. package/dist/server/rsc-entry/action-middleware-runner.d.ts.map +1 -0
  423. package/dist/server/rsc-entry/api-handler.d.ts +2 -2
  424. package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
  425. package/dist/server/rsc-entry/error-renderer.d.ts +26 -13
  426. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  427. package/dist/server/rsc-entry/helpers.d.ts +50 -6
  428. package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
  429. package/dist/server/rsc-entry/index.d.ts +19 -8
  430. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  431. package/dist/server/rsc-entry/render-route.d.ts +50 -0
  432. package/dist/server/rsc-entry/render-route.d.ts.map +1 -0
  433. package/dist/server/rsc-entry/rsc-payload.d.ts +3 -3
  434. package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
  435. package/dist/server/rsc-entry/rsc-stream.d.ts +17 -1
  436. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  437. package/dist/server/rsc-entry/ssr-bridge.d.ts +5 -1
  438. package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
  439. package/dist/server/rsc-entry/ssr-renderer.d.ts +19 -4
  440. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  441. package/dist/server/rsc-entry/wrap-action-dispatch.d.ts +119 -0
  442. package/dist/server/rsc-entry/wrap-action-dispatch.d.ts.map +1 -0
  443. package/dist/server/safe-load.d.ts +46 -0
  444. package/dist/server/safe-load.d.ts.map +1 -0
  445. package/dist/server/sensitive-fields.d.ts +74 -0
  446. package/dist/server/sensitive-fields.d.ts.map +1 -0
  447. package/dist/server/sitemap-generator.d.ts +129 -0
  448. package/dist/server/sitemap-generator.d.ts.map +1 -0
  449. package/dist/server/sitemap-handler.d.ts +22 -0
  450. package/dist/server/sitemap-handler.d.ts.map +1 -0
  451. package/dist/server/slot-resolver.d.ts +1 -1
  452. package/dist/server/slot-resolver.d.ts.map +1 -1
  453. package/dist/server/ssr-bridge-types.d.ts +121 -0
  454. package/dist/server/ssr-bridge-types.d.ts.map +1 -0
  455. package/dist/server/ssr-entry.d.ts +2 -43
  456. package/dist/server/ssr-entry.d.ts.map +1 -1
  457. package/dist/server/ssr-render.d.ts +64 -21
  458. package/dist/server/ssr-render.d.ts.map +1 -1
  459. package/dist/server/ssr-wrappers.d.ts +50 -0
  460. package/dist/server/ssr-wrappers.d.ts.map +1 -0
  461. package/dist/server/state-tree-diff.d.ts +12 -5
  462. package/dist/server/state-tree-diff.d.ts.map +1 -1
  463. package/dist/server/status-code-resolver.d.ts +16 -11
  464. package/dist/server/status-code-resolver.d.ts.map +1 -1
  465. package/dist/server/stream-utils.d.ts +36 -0
  466. package/dist/server/stream-utils.d.ts.map +1 -0
  467. package/dist/server/tracing.d.ts +5 -5
  468. package/dist/server/tracing.d.ts.map +1 -1
  469. package/dist/server/tree-builder.d.ts +62 -30
  470. package/dist/server/tree-builder.d.ts.map +1 -1
  471. package/dist/server/tree-match.d.ts +49 -0
  472. package/dist/server/tree-match.d.ts.map +1 -0
  473. package/dist/server/types.d.ts +49 -4
  474. package/dist/server/types.d.ts.map +1 -1
  475. package/dist/server/utils/escape-html.d.ts +14 -0
  476. package/dist/server/utils/escape-html.d.ts.map +1 -0
  477. package/dist/server/version-skew.d.ts +61 -0
  478. package/dist/server/version-skew.d.ts.map +1 -0
  479. package/dist/shared/merge-search-params.d.ts +22 -0
  480. package/dist/shared/merge-search-params.d.ts.map +1 -0
  481. package/dist/shims/font-google.d.ts +1 -1
  482. package/dist/shims/font-google.d.ts.map +1 -1
  483. package/dist/shims/font-google.js +42 -0
  484. package/dist/shims/font-google.js.map +1 -0
  485. package/dist/shims/font-local.d.ts +26 -0
  486. package/dist/shims/font-local.d.ts.map +1 -0
  487. package/dist/shims/font-local.js +20 -0
  488. package/dist/shims/font-local.js.map +1 -0
  489. package/dist/shims/headers.d.ts +2 -1
  490. package/dist/shims/headers.d.ts.map +1 -1
  491. package/dist/shims/navigation-client.d.ts +3 -1
  492. package/dist/shims/navigation-client.d.ts.map +1 -1
  493. package/dist/shims/navigation.d.ts +11 -5
  494. package/dist/shims/navigation.d.ts.map +1 -1
  495. package/dist/utils/state-machine.d.ts +80 -0
  496. package/dist/utils/state-machine.d.ts.map +1 -0
  497. package/package.json +61 -22
  498. package/src/adapters/build-output-helper.ts +139 -0
  499. package/src/adapters/cloudflare-dev.ts +177 -0
  500. package/src/adapters/cloudflare-kv-cache.ts +142 -0
  501. package/src/adapters/cloudflare.ts +350 -76
  502. package/src/adapters/compress-module.ts +24 -4
  503. package/src/adapters/nitro.ts +142 -59
  504. package/src/adapters/shared.ts +40 -0
  505. package/src/adapters/wrangler.d.ts +7 -0
  506. package/src/cache/cache-api.ts +38 -0
  507. package/src/cache/handler-store.ts +68 -0
  508. package/src/cache/index.ts +81 -18
  509. package/src/cache/singleflight.ts +62 -4
  510. package/src/cache/sizeof.ts +33 -0
  511. package/src/cache/timber-cache.ts +25 -20
  512. package/src/cli-schema-sync.ts +295 -0
  513. package/src/cli.ts +76 -8
  514. package/src/client/browser-dev.ts +153 -1
  515. package/src/client/browser-entry/action-dispatch.ts +125 -0
  516. package/src/client/browser-entry/hmr.ts +81 -0
  517. package/src/client/browser-entry/hydrate.ts +153 -0
  518. package/src/client/browser-entry/index.ts +151 -0
  519. package/src/client/browser-entry/post-hydration.ts +113 -0
  520. package/src/client/browser-entry/router-init.ts +219 -0
  521. package/src/client/browser-entry/rsc-stream.ts +157 -0
  522. package/src/client/browser-entry/scroll.ts +27 -0
  523. package/src/client/error-boundary.tsx +99 -22
  524. package/src/client/error-reconstituter.tsx +65 -0
  525. package/src/client/form.tsx +31 -32
  526. package/src/client/history.ts +26 -4
  527. package/src/client/index.ts +66 -45
  528. package/src/client/internal.ts +58 -0
  529. package/src/client/link-pending-store.ts +116 -0
  530. package/src/client/link.tsx +336 -119
  531. package/src/client/nav-link-store.ts +37 -0
  532. package/src/client/navigation-api-types.ts +112 -0
  533. package/src/client/navigation-api.ts +332 -0
  534. package/src/client/navigation-context.ts +33 -7
  535. package/src/client/navigation-root.tsx +347 -0
  536. package/src/client/nuqs-adapter.tsx +16 -3
  537. package/src/client/router-ref.ts +1 -1
  538. package/src/client/router.ts +418 -128
  539. package/src/client/rsc-fetch.ts +208 -10
  540. package/src/client/segment-cache.ts +6 -3
  541. package/src/client/segment-outlet.tsx +77 -0
  542. package/src/client/segment-update-context.ts +42 -0
  543. package/src/client/shallow-url.ts +22 -0
  544. package/src/client/ssr-data.ts +13 -5
  545. package/src/client/stale-reload.ts +72 -3
  546. package/src/client/state.ts +2 -2
  547. package/src/client/top-loader.tsx +11 -9
  548. package/src/client/use-cookie.ts +31 -2
  549. package/src/client/use-link-status.ts +7 -7
  550. package/src/client/use-pending-navigation.ts +40 -0
  551. package/src/client/use-query-states.ts +9 -3
  552. package/src/client/use-router.ts +1 -1
  553. package/src/client/use-search-params.ts +25 -44
  554. package/src/client/{use-params.ts → use-segment-params.ts} +8 -6
  555. package/src/codec.ts +147 -0
  556. package/src/config-types.ts +292 -0
  557. package/src/config-validation.ts +303 -0
  558. package/src/content/index.ts +5 -13
  559. package/src/cookies/define-cookie.ts +233 -53
  560. package/src/cookies/index.ts +12 -1
  561. package/src/cookies/json-cookie.ts +105 -0
  562. package/src/cookies/validation.ts +134 -0
  563. package/src/dev-tools/404-page.ts +387 -0
  564. package/src/dev-tools/browser-logs.ts +291 -0
  565. package/src/dev-tools/error-page.ts +506 -0
  566. package/src/dev-tools/holding-server.ts +187 -0
  567. package/src/dev-tools/index.ts +90 -0
  568. package/src/dev-tools/instrumentation.ts +176 -0
  569. package/src/{plugins/dev-logs.ts → dev-tools/logs.ts} +9 -5
  570. package/src/dev-tools/overlay.ts +469 -0
  571. package/src/dev-tools/stack-classifier.ts +75 -0
  572. package/src/dev-tools/terminal.ts +183 -0
  573. package/src/{server/dev-warnings.ts → dev-tools/warnings.ts} +5 -50
  574. package/src/fonts/ast.ts +525 -16
  575. package/src/fonts/bundle.ts +142 -0
  576. package/src/fonts/dev-middleware.ts +74 -0
  577. package/src/fonts/local.ts +1 -1
  578. package/src/fonts/pipeline.ts +314 -0
  579. package/src/fonts/transform.ts +317 -0
  580. package/src/fonts/types.ts +50 -1
  581. package/src/fonts/virtual-modules.ts +233 -0
  582. package/src/index.ts +411 -329
  583. package/src/params/codec-registry.ts +34 -0
  584. package/src/params/define-schema.ts +114 -0
  585. package/src/params/index.ts +17 -0
  586. package/src/params/resolve-schema.ts +116 -0
  587. package/src/plugin-context.ts +240 -0
  588. package/src/plugins/adapter-build.ts +12 -4
  589. package/src/plugins/build-manifest.ts +69 -6
  590. package/src/plugins/build-report.ts +16 -25
  591. package/src/plugins/client-chunks.ts +65 -0
  592. package/src/plugins/cloudflare-wasm.ts +103 -0
  593. package/src/plugins/content.ts +1 -1
  594. package/src/plugins/dev-server.ts +179 -37
  595. package/src/plugins/entries.ts +111 -8
  596. package/src/plugins/fonts.ts +165 -654
  597. package/src/plugins/mdx.ts +47 -10
  598. package/src/plugins/routing.ts +386 -47
  599. package/src/plugins/server-bundle.ts +59 -3
  600. package/src/plugins/shims.ts +136 -35
  601. package/src/plugins/static-build.ts +15 -89
  602. package/src/routing/codegen-shared.ts +115 -0
  603. package/src/routing/codegen-types.ts +61 -0
  604. package/src/routing/codegen.ts +321 -177
  605. package/src/routing/convention-lint.ts +357 -0
  606. package/src/routing/index.ts +10 -1
  607. package/src/routing/interception.ts +1 -1
  608. package/src/routing/link-codegen.ts +308 -0
  609. package/src/routing/scanner.ts +165 -110
  610. package/src/routing/schema-validation.ts +149 -0
  611. package/src/routing/segment-classify.ts +188 -0
  612. package/src/routing/segment-codegen.ts +98 -0
  613. package/src/routing/types.ts +78 -25
  614. package/src/routing/walkers.ts +90 -0
  615. package/src/rsc-runtime/rsc.ts +2 -0
  616. package/src/rsc-runtime/ssr.ts +50 -0
  617. package/src/rsc-runtime/vendor-types.d.ts +7 -0
  618. package/src/{search-params/codecs.ts → schema-bridge.ts} +57 -20
  619. package/src/search-params/define.ts +538 -0
  620. package/src/search-params/index.ts +14 -20
  621. package/src/search-params/registry.ts +2 -2
  622. package/src/search-params/wrappers.ts +92 -0
  623. package/src/segment-params/define.ts +309 -0
  624. package/src/segment-params/index.ts +9 -0
  625. package/src/server/access-gate.tsx +76 -34
  626. package/src/server/action-client.ts +88 -15
  627. package/src/server/action-encryption.ts +144 -0
  628. package/src/server/action-handler.ts +112 -14
  629. package/src/server/actions.ts +14 -23
  630. package/src/server/als-registry.ts +108 -20
  631. package/src/server/asset-headers.ts +8 -34
  632. package/src/server/build-manifest.ts +17 -4
  633. package/src/server/coalesce-tick.ts +75 -0
  634. package/src/server/compress.ts +25 -7
  635. package/src/server/cookie-context.ts +468 -0
  636. package/src/server/cookie-parsing.ts +135 -0
  637. package/src/server/debug.ts +1 -1
  638. package/src/server/default-logger.ts +99 -0
  639. package/src/server/deny-boundary.ts +218 -0
  640. package/src/server/deny-renderer.ts +32 -51
  641. package/src/server/dev-source-map.ts +31 -0
  642. package/src/server/early-hints-sender.ts +3 -2
  643. package/src/server/early-hints.ts +36 -15
  644. package/src/server/error-boundary-wrapper.ts +74 -22
  645. package/src/server/fallback-error.ts +74 -102
  646. package/src/server/flight-injection-state.ts +113 -0
  647. package/src/server/flight-scripts.ts +62 -0
  648. package/src/server/flush.ts +2 -1
  649. package/src/server/form-data.ts +101 -5
  650. package/src/server/html-injector-core.ts +417 -0
  651. package/src/server/html-injectors.ts +235 -223
  652. package/src/server/index.ts +29 -183
  653. package/src/server/internal.ts +182 -0
  654. package/src/server/logger.ts +67 -36
  655. package/src/server/metadata-routes.ts +44 -19
  656. package/src/server/middleware-runner.ts +75 -4
  657. package/src/server/node-stream-transforms.ts +361 -0
  658. package/src/server/param-coercion.ts +206 -0
  659. package/src/server/pipeline-helpers.ts +204 -0
  660. package/src/server/pipeline-interception.ts +17 -16
  661. package/src/server/pipeline-metadata.ts +13 -0
  662. package/src/server/pipeline-outcome.ts +197 -0
  663. package/src/server/pipeline-phases.ts +468 -0
  664. package/src/server/pipeline.ts +154 -394
  665. package/src/server/port-resolution.ts +215 -0
  666. package/src/server/primitives.ts +111 -28
  667. package/src/server/render-timeout.ts +108 -0
  668. package/src/server/request-context.ts +168 -337
  669. package/src/server/route-element-builder.ts +435 -208
  670. package/src/server/route-handler.ts +24 -4
  671. package/src/server/route-matcher.ts +128 -277
  672. package/src/server/rsc-entry/action-middleware-runner.ts +167 -0
  673. package/src/server/rsc-entry/api-handler.ts +16 -17
  674. package/src/server/rsc-entry/error-renderer.ts +315 -89
  675. package/src/server/rsc-entry/helpers.ts +155 -26
  676. package/src/server/rsc-entry/index.ts +316 -327
  677. package/src/server/rsc-entry/render-route.ts +313 -0
  678. package/src/server/rsc-entry/rsc-payload.ts +65 -18
  679. package/src/server/rsc-entry/rsc-stream.ts +85 -13
  680. package/src/server/rsc-entry/ssr-bridge.ts +18 -5
  681. package/src/server/rsc-entry/ssr-renderer.ts +193 -40
  682. package/src/server/rsc-entry/wrap-action-dispatch.ts +449 -0
  683. package/src/server/safe-load.ts +60 -0
  684. package/src/server/sensitive-fields.ts +230 -0
  685. package/src/server/sitemap-generator.ts +338 -0
  686. package/src/server/sitemap-handler.ts +126 -0
  687. package/src/server/slot-resolver.ts +228 -246
  688. package/src/server/ssr-bridge-types.ts +124 -0
  689. package/src/server/ssr-entry.ts +217 -78
  690. package/src/server/ssr-render.ts +344 -71
  691. package/src/server/ssr-wrappers.tsx +139 -0
  692. package/src/server/state-tree-diff.ts +30 -23
  693. package/src/server/status-code-resolver.ts +112 -128
  694. package/src/server/stream-utils.ts +213 -0
  695. package/src/server/tracing.ts +21 -10
  696. package/src/server/tree-builder.ts +202 -90
  697. package/src/server/tree-match.ts +210 -0
  698. package/src/server/types.ts +55 -6
  699. package/src/server/utils/escape-html.ts +20 -0
  700. package/src/server/version-skew.ts +104 -0
  701. package/src/shared/merge-search-params.ts +55 -0
  702. package/src/shims/font-google.ts +1 -1
  703. package/src/shims/font-local.ts +34 -0
  704. package/src/shims/headers.ts +5 -1
  705. package/src/shims/navigation-client.ts +4 -3
  706. package/src/shims/navigation.ts +14 -7
  707. package/src/utils/state-machine.ts +111 -0
  708. package/dist/_chunks/als-registry-B7DbZ2hS.js +0 -41
  709. package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
  710. package/dist/_chunks/debug-gwlJkDuf.js +0 -108
  711. package/dist/_chunks/debug-gwlJkDuf.js.map +0 -1
  712. package/dist/_chunks/format-DviM89f0.js.map +0 -1
  713. package/dist/_chunks/interception-BOoWmLUA.js +0 -676
  714. package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
  715. package/dist/_chunks/metadata-routes-Cjmvi3rQ.js.map +0 -1
  716. package/dist/_chunks/request-context-DIkVh_jG.js +0 -330
  717. package/dist/_chunks/request-context-DIkVh_jG.js.map +0 -1
  718. package/dist/_chunks/ssr-data-MjmprTmO.js.map +0 -1
  719. package/dist/_chunks/tracing-CemImE6h.js +0 -187
  720. package/dist/_chunks/tracing-CemImE6h.js.map +0 -1
  721. package/dist/_chunks/use-cookie-DX-l1_5E.js +0 -91
  722. package/dist/_chunks/use-cookie-DX-l1_5E.js.map +0 -1
  723. package/dist/_chunks/use-query-states-D5KaffOK.js.map +0 -1
  724. package/dist/cache/register-cached-function.d.ts +0 -17
  725. package/dist/cache/register-cached-function.d.ts.map +0 -1
  726. package/dist/client/browser-entry.d.ts +0 -21
  727. package/dist/client/browser-entry.d.ts.map +0 -1
  728. package/dist/client/link-status-provider.d.ts +0 -11
  729. package/dist/client/link-status-provider.d.ts.map +0 -1
  730. package/dist/client/segment-merger.d.ts +0 -119
  731. package/dist/client/segment-merger.d.ts.map +0 -1
  732. package/dist/client/transition-root.d.ts.map +0 -1
  733. package/dist/client/use-navigation-pending.d.ts +0 -26
  734. package/dist/client/use-navigation-pending.d.ts.map +0 -1
  735. package/dist/client/use-params.d.ts.map +0 -1
  736. package/dist/plugins/cache-transform.d.ts +0 -36
  737. package/dist/plugins/cache-transform.d.ts.map +0 -1
  738. package/dist/plugins/dev-error-overlay.d.ts +0 -60
  739. package/dist/plugins/dev-error-overlay.d.ts.map +0 -1
  740. package/dist/plugins/dev-logs.d.ts.map +0 -1
  741. package/dist/plugins/dynamic-transform.d.ts +0 -72
  742. package/dist/plugins/dynamic-transform.d.ts.map +0 -1
  743. package/dist/plugins/server-action-exports.d.ts +0 -26
  744. package/dist/plugins/server-action-exports.d.ts.map +0 -1
  745. package/dist/routing/status-file-lint.d.ts +0 -33
  746. package/dist/routing/status-file-lint.d.ts.map +0 -1
  747. package/dist/search-params/analyze.d.ts +0 -54
  748. package/dist/search-params/analyze.d.ts.map +0 -1
  749. package/dist/search-params/builtin-codecs.d.ts +0 -105
  750. package/dist/search-params/builtin-codecs.d.ts.map +0 -1
  751. package/dist/search-params/codecs.d.ts +0 -53
  752. package/dist/search-params/codecs.d.ts.map +0 -1
  753. package/dist/search-params/create.d.ts +0 -106
  754. package/dist/search-params/create.d.ts.map +0 -1
  755. package/dist/server/dev-fetch-instrumentation.d.ts +0 -22
  756. package/dist/server/dev-fetch-instrumentation.d.ts.map +0 -1
  757. package/dist/server/dev-logger.d.ts.map +0 -1
  758. package/dist/server/dev-span-processor.d.ts.map +0 -1
  759. package/dist/server/dev-warnings.d.ts.map +0 -1
  760. package/dist/server/manifest-status-resolver.d.ts +0 -58
  761. package/dist/server/manifest-status-resolver.d.ts.map +0 -1
  762. package/dist/server/prerender.d.ts +0 -77
  763. package/dist/server/prerender.d.ts.map +0 -1
  764. package/dist/utils/directive-parser.d.ts +0 -70
  765. package/dist/utils/directive-parser.d.ts.map +0 -1
  766. package/src/cache/register-cached-function.ts +0 -103
  767. package/src/client/browser-entry.ts +0 -678
  768. package/src/client/link-status-provider.tsx +0 -30
  769. package/src/client/segment-merger.ts +0 -339
  770. package/src/client/transition-root.tsx +0 -166
  771. package/src/client/use-navigation-pending.ts +0 -38
  772. package/src/plugins/cache-transform.ts +0 -199
  773. package/src/plugins/dev-error-overlay.ts +0 -230
  774. package/src/plugins/dynamic-transform.ts +0 -161
  775. package/src/plugins/server-action-exports.ts +0 -220
  776. package/src/routing/status-file-lint.ts +0 -112
  777. package/src/search-params/analyze.ts +0 -192
  778. package/src/search-params/builtin-codecs.ts +0 -228
  779. package/src/search-params/create.ts +0 -321
  780. package/src/server/dev-fetch-instrumentation.ts +0 -96
  781. package/src/server/dev-span-processor.ts +0 -78
  782. package/src/server/manifest-status-resolver.ts +0 -215
  783. package/src/server/prerender.ts +0 -139
  784. package/src/utils/directive-parser.ts +0 -529
  785. /package/src/{server/dev-logger.ts → dev-tools/logger.ts} +0 -0
@@ -29,6 +29,12 @@ export function parseFormData(formData: FormData): Record<string, unknown> {
29
29
  // Skip React internal fields
30
30
  if (key.startsWith('$ACTION_')) continue;
31
31
 
32
+ // Skip prototype-pollution keys at the top level — assigning to
33
+ // `flat['__proto__']` invokes the prototype setter and can splice
34
+ // attacker-controlled data into `flat`'s prototype chain.
35
+ // The dot-path case is filtered separately in `expandDotPaths`.
36
+ if (DANGEROUS_KEYS.has(key)) continue;
37
+
32
38
  const values = formData.getAll(key);
33
39
  const processed = values.map(normalizeValue);
34
40
 
@@ -82,18 +88,23 @@ function expandDotPaths(flat: Record<string, unknown>): Record<string, unknown>
82
88
  }
83
89
  }
84
90
 
85
- // Fast path: no dot-notation keys, return as-is
91
+ // Fast path: no dot-notation keys, return as-is.
92
+ // Top-level dangerous keys are already filtered in `parseFormData` above.
86
93
  if (!hasDotPaths) return flat;
87
94
 
88
95
  for (const [key, value] of Object.entries(flat)) {
89
- if (!key.includes('.')) {
90
- result[key] = value;
96
+ // Reject any path that contains __proto__ / constructor / prototype.
97
+ // Without this, `__proto__.x=1` writes to Object.prototype because
98
+ // `result['__proto__']` resolves to the prototype object itself.
99
+ const parts = key.split('.');
100
+ if (parts.some((p) => DANGEROUS_KEYS.has(p))) continue;
101
+
102
+ if (parts.length === 1) {
103
+ result[parts[0]] = value;
91
104
  continue;
92
105
  }
93
106
 
94
- const parts = key.split('.');
95
107
  let current: Record<string, unknown> = result;
96
-
97
108
  for (let i = 0; i < parts.length - 1; i++) {
98
109
  const part = parts[i];
99
110
  if (current[part] === undefined || current[part] === null) {
@@ -113,6 +124,15 @@ function expandDotPaths(flat: Record<string, unknown>): Record<string, unknown>
113
124
  return result;
114
125
  }
115
126
 
127
+ // `__proto__` is the only key in this parser that escapes the dot-path
128
+ // walk's `typeof !== 'object'` reset: accessing `obj['__proto__']` returns
129
+ // `Object.prototype` (itself an object), so the walk steps into the global
130
+ // prototype and the leaf write mutates it. `constructor` resolves to a
131
+ // function (reset fires) and `prototype` is undefined on fresh objects
132
+ // (reset fires), so neither escapes the walk — they parse as legit nested
133
+ // keys and do not mutate anything global.
134
+ const DANGEROUS_KEYS = new Set(['__proto__']);
135
+
116
136
  // ─── Coercion Helpers ────────────────────────────────────────────────────
117
137
 
118
138
  /**
@@ -173,4 +193,80 @@ export const coerce = {
173
193
  return undefined;
174
194
  }
175
195
  },
196
+
197
+ /**
198
+ * Coerce a date string to a Date object.
199
+ * Handles `<input type="date">` (`"2024-01-15"`), `<input type="datetime-local">`
200
+ * (`"2024-01-15T10:30"`), and full ISO 8601 strings.
201
+ * - Valid date string → `Date`
202
+ * - `""` / `undefined` / `null` → `undefined`
203
+ * - Invalid date strings → `undefined` (schema validation will catch this)
204
+ * - Impossible dates that `new Date()` silently normalizes (e.g. Feb 31) → `undefined`
205
+ */
206
+ date(value: unknown): Date | undefined {
207
+ if (value === undefined || value === null || value === '') return undefined;
208
+ if (value instanceof Date) return value;
209
+ if (typeof value !== 'string') return undefined;
210
+ const date = new Date(value);
211
+ if (Number.isNaN(date.getTime())) return undefined;
212
+
213
+ // Overflow detection: extract Y/M/D from the input string and verify
214
+ // they match the parsed Date components. new Date('2024-02-31') silently
215
+ // normalizes to March 2nd — we reject such inputs.
216
+ const ymdMatch = value.match(/^(\d{4})-(\d{2})-(\d{2})/);
217
+ if (ymdMatch) {
218
+ const inputYear = Number(ymdMatch[1]);
219
+ const inputMonth = Number(ymdMatch[2]);
220
+ const inputDay = Number(ymdMatch[3]);
221
+
222
+ // Use UTC methods for date-only and Z-suffixed strings to avoid
223
+ // timezone offset shifting the day. For datetime-local (no Z suffix),
224
+ // the Date constructor parses in local time, so use local methods.
225
+ const isUTC = value.length === 10 || value.endsWith('Z');
226
+ const parsedYear = isUTC ? date.getUTCFullYear() : date.getFullYear();
227
+ const parsedMonth = isUTC ? date.getUTCMonth() + 1 : date.getMonth() + 1;
228
+ const parsedDay = isUTC ? date.getUTCDate() : date.getDate();
229
+
230
+ if (inputYear !== parsedYear || inputMonth !== parsedMonth || inputDay !== parsedDay) {
231
+ return undefined;
232
+ }
233
+ }
234
+
235
+ return date;
236
+ },
237
+
238
+ /**
239
+ * Create a File coercion function with optional size and mime type validation.
240
+ * Returns the File if valid, `undefined` otherwise.
241
+ *
242
+ * ```ts
243
+ * // Basic — just checks it's a real File
244
+ * z.preprocess(coerce.file(), z.instanceof(File))
245
+ *
246
+ * // With constraints
247
+ * z.preprocess(
248
+ * coerce.file({ maxSize: 5 * 1024 * 1024, accept: ['image/png', 'image/jpeg'] }),
249
+ * z.instanceof(File)
250
+ * )
251
+ * ```
252
+ */
253
+ file(options?: { maxSize?: number; accept?: string[] }): (value: unknown) => File | undefined {
254
+ return (value: unknown): File | undefined => {
255
+ if (value === undefined || value === null || value === '') return undefined;
256
+ if (!(value instanceof File)) return undefined;
257
+
258
+ // Empty file input (no selection): browsers submit File with name="" and size=0
259
+ if (value.size === 0 && value.name === '') return undefined;
260
+
261
+ if (options?.maxSize !== undefined && value.size > options.maxSize) {
262
+ return undefined;
263
+ }
264
+
265
+ if (options?.accept !== undefined && !options.accept.includes(value.type)) {
266
+ return undefined;
267
+ }
268
+
269
+ return value;
270
+ };
271
+ },
176
272
  };
@@ -0,0 +1,417 @@
1
+ /**
2
+ * HTML injector core — pure stateful helpers for streaming HTML post-processing.
3
+ *
4
+ * These helpers contain the actual byte/string logic for the held-flush
5
+ * streaming pipeline (buffered transforms, suffix moving, head injection,
6
+ * RSC flight interleaving). They are stream-shape agnostic: they know
7
+ * nothing about Web `TransformStream` or Node.js `Transform` and contain
8
+ * no `setImmediate` scheduling or controller plumbing.
9
+ *
10
+ * The Web Stream wrapper (`html-injectors.ts`) and the Node Stream wrapper
11
+ * (`node-stream-transforms.ts`) compose these helpers behind whichever
12
+ * stream shape their target runtime needs:
13
+ *
14
+ * - On Cloudflare/edge: Web `TransformStream` wraps the helpers.
15
+ * - On Node.js/Bun: Node `Transform` wraps the helpers (faster — C++ streams).
16
+ *
17
+ * Keeping this module split per-shape (rather than one file exporting both)
18
+ * preserves the build-time tree-shake: Cloudflare bundles never import
19
+ * `node:stream` even transitively. Only the helpers below are shared.
20
+ *
21
+ * **Pure functions only.** Anything that touches a stream API, schedules
22
+ * a tick, or owns a controller belongs in the wrapper, not here.
23
+ *
24
+ * Design docs: 02-rendering-pipeline.md §"Streaming Constraints", 18-build-system.md §"Entry Files"
25
+ */
26
+
27
+ import { createMachine, type Machine } from '../utils/state-machine.js';
28
+ import { flightChunkScript } from './flight-scripts.js';
29
+ import {
30
+ flightInjectionTransitions,
31
+ isHtmlDone,
32
+ isPullDone,
33
+ type FlightInjectionState,
34
+ type FlightInjectionEvent,
35
+ } from './flight-injection-state.js';
36
+ import { withTimeout, RenderTimeoutError } from './render-timeout.js';
37
+
38
+ // ─── Encoders / Constants ────────────────────────────────────────────────────
39
+
40
+ const encoder = new TextEncoder();
41
+
42
+ /** Closing tags React Fizz emits inside the shell chunk. */
43
+ export const SUFFIX = '</body></html>';
44
+ /** UTF-8 bytes of {@link SUFFIX}. Cached so wrappers don't re-encode per request. */
45
+ export const SUFFIX_BYTES: Uint8Array = encoder.encode(SUFFIX);
46
+
47
+ /** Encode a UTF-8 string. Convenience for wrappers that need a single source of truth. */
48
+ export function encodeUtf8(text: string): Uint8Array {
49
+ return encoder.encode(text);
50
+ }
51
+
52
+ // ─── Buffered Aggregator ─────────────────────────────────────────────────────
53
+
54
+ /**
55
+ * Pure buffer state for the buffered transform.
56
+ *
57
+ * Both Web and Node wrappers want the same behaviour: collect chunks that
58
+ * arrive in the same event-loop tick, decide whether the buffer has grown
59
+ * beyond `maxBufferByteLength` and must flush synchronously, then emit a
60
+ * single concatenated chunk on the next tick.
61
+ *
62
+ * The only thing the two wrappers disagree on is *who schedules the tick*
63
+ * (`setImmediate` callback vs Promise-based) and *how to push the merged
64
+ * chunk* (`controller.enqueue` vs `transform.push`). This class owns
65
+ * everything else.
66
+ */
67
+ export class BufferAggregator {
68
+ private chunks: Uint8Array[] = [];
69
+ private byteLength = 0;
70
+
71
+ constructor(private readonly maxBufferByteLength: number = Infinity) {}
72
+
73
+ /**
74
+ * Append a chunk. Returns `true` if the caller should flush synchronously
75
+ * right now (the buffer has reached the byte cap), `false` if a deferred
76
+ * tick-end flush is sufficient.
77
+ */
78
+ append(chunk: Uint8Array): boolean {
79
+ this.chunks.push(chunk);
80
+ this.byteLength += chunk.byteLength;
81
+ return this.byteLength >= this.maxBufferByteLength;
82
+ }
83
+
84
+ /** Drain the buffer into a single concatenated chunk, or `null` if empty. */
85
+ drain(): Uint8Array | null {
86
+ if (this.chunks.length === 0) return null;
87
+
88
+ const merged = new Uint8Array(this.byteLength);
89
+ let offset = 0;
90
+ for (const chunk of this.chunks) {
91
+ merged.set(chunk, offset);
92
+ offset += chunk.byteLength;
93
+ }
94
+ this.chunks = [];
95
+ this.byteLength = 0;
96
+ return merged;
97
+ }
98
+
99
+ get bufferedByteLength(): number {
100
+ return this.byteLength;
101
+ }
102
+
103
+ get isEmpty(): boolean {
104
+ return this.chunks.length === 0;
105
+ }
106
+ }
107
+
108
+ // ─── Suffix Mover ────────────────────────────────────────────────────────────
109
+
110
+ /**
111
+ * Result of feeding one chunk through the suffix-mover state.
112
+ *
113
+ * - `passthrough` — already found and removed the suffix on a previous chunk.
114
+ * Caller emits the chunk unchanged.
115
+ * - `noSuffix` — current chunk does not contain the suffix. Caller emits unchanged.
116
+ * - `suffixFound` — caller emits `before` and `after` (skipping the suffix
117
+ * itself). The suffix will be re-emitted later by {@link suffixFlush}.
118
+ */
119
+ export type SuffixChunkResult =
120
+ | { kind: 'passthrough' }
121
+ | { kind: 'noSuffix' }
122
+ | { kind: 'suffixFound'; before: Uint8Array | null; after: Uint8Array | null };
123
+
124
+ export interface SuffixState {
125
+ found: boolean;
126
+ }
127
+
128
+ export function createSuffixState(): SuffixState {
129
+ return { found: false };
130
+ }
131
+
132
+ /**
133
+ * Search a chunk for {@link SUFFIX}. If found, mark state and return the
134
+ * surrounding bytes (the caller emits them; the suffix is held for the
135
+ * end of the stream). The bytes-vs-text dance matches what both Web and
136
+ * Node implementations did before extraction — search via decoded UTF-8
137
+ * to avoid splitting multi-byte characters at the suffix boundary.
138
+ */
139
+ export function processSuffixChunk(state: SuffixState, chunk: Uint8Array): SuffixChunkResult {
140
+ if (state.found) return { kind: 'passthrough' };
141
+
142
+ const text = new TextDecoder().decode(chunk, { stream: true });
143
+ const idx = text.indexOf(SUFFIX);
144
+ if (idx === -1) return { kind: 'noSuffix' };
145
+
146
+ state.found = true;
147
+
148
+ // Whole chunk was the suffix — nothing to emit before/after.
149
+ if (chunk.byteLength === SUFFIX_BYTES.byteLength) {
150
+ return { kind: 'suffixFound', before: null, after: null };
151
+ }
152
+
153
+ const beforeText = text.slice(0, idx);
154
+ const afterText = text.slice(idx + SUFFIX.length);
155
+ return {
156
+ kind: 'suffixFound',
157
+ before: beforeText ? encoder.encode(beforeText) : null,
158
+ after: afterText ? encoder.encode(afterText) : null,
159
+ };
160
+ }
161
+
162
+ /**
163
+ * Final emit for the suffix mover. Always returns the suffix bytes — even
164
+ * if no suffix was ever observed in the input — so output is well-formed.
165
+ */
166
+ export function suffixFlush(_state: SuffixState): Uint8Array {
167
+ return SUFFIX_BYTES;
168
+ }
169
+
170
+ // ─── Tag Injector (head / body) ──────────────────────────────────────────────
171
+
172
+ /**
173
+ * Pure state for `injectHead`-style transforms: scan for a target tag,
174
+ * inject `content` once at the matching position, then pass everything
175
+ * else through. We keep a small trailing string buffer (just under the
176
+ * length of the target tag) so the tag can be detected even when split
177
+ * across chunk boundaries.
178
+ *
179
+ * The `decoder` is a long-lived `TextDecoder` reused across every chunk
180
+ * with `{ stream: true }`. This is required so a UTF-8 codepoint that
181
+ * spans two chunks (e.g. the bytes of `é` arriving in two halves) is
182
+ * reassembled correctly. A fresh decoder per chunk would drop or
183
+ * replace the partial codepoint and corrupt streamed HTML.
184
+ */
185
+ export interface InjectorState {
186
+ injected: boolean;
187
+ tail: string;
188
+ readonly content: string;
189
+ readonly targetTag: string;
190
+ readonly position: 'before' | 'after';
191
+ readonly tailLen: number;
192
+ readonly decoder: TextDecoder;
193
+ }
194
+
195
+ export interface InjectorOptions {
196
+ content: string;
197
+ targetTag: string;
198
+ position?: 'before' | 'after';
199
+ }
200
+
201
+ export function createInjectorState(options: InjectorOptions): InjectorState {
202
+ return {
203
+ injected: false,
204
+ tail: '',
205
+ content: options.content,
206
+ targetTag: options.targetTag,
207
+ position: options.position ?? 'before',
208
+ tailLen: options.targetTag.length - 1,
209
+ decoder: new TextDecoder('utf-8'),
210
+ };
211
+ }
212
+
213
+ /**
214
+ * Result of feeding one chunk through {@link processInjectorChunk}.
215
+ *
216
+ * - `passthrough` — already injected. Emit `chunk` unchanged.
217
+ * - `emit` — emit the returned bytes (or nothing if `null`).
218
+ *
219
+ * Note: when not yet injected and the target tag is not present, the
220
+ * helper still emits the *safe head* of the buffer — everything except
221
+ * the trailing `tailLen` characters that might be the start of the
222
+ * target tag spilled into the next chunk. The unsafe tail is held in
223
+ * `state.tail` for the next call.
224
+ */
225
+ export type InjectorChunkResult =
226
+ | { kind: 'passthrough' }
227
+ | { kind: 'emit'; bytes: Uint8Array | null };
228
+
229
+ export function processInjectorChunk(state: InjectorState, chunk: Uint8Array): InjectorChunkResult {
230
+ if (state.injected) return { kind: 'passthrough' };
231
+
232
+ // Reuse the long-lived decoder so split UTF-8 codepoints are preserved
233
+ // across chunk boundaries. See comment on InjectorState.decoder.
234
+ const decoded = state.decoder.decode(chunk, { stream: true });
235
+ const text = state.tail + decoded;
236
+ const tagIndex = text.indexOf(state.targetTag);
237
+
238
+ if (tagIndex !== -1) {
239
+ const splitPoint = state.position === 'before' ? tagIndex : tagIndex + state.targetTag.length;
240
+ const before = text.slice(0, splitPoint);
241
+ const after = text.slice(splitPoint);
242
+ state.injected = true;
243
+ state.tail = '';
244
+ return { kind: 'emit', bytes: encoder.encode(before + state.content + after) };
245
+ }
246
+
247
+ // Tag not yet seen — flush everything except the last tailLen chars,
248
+ // which might be the start of the target tag split across chunks.
249
+ const safeEnd = Math.max(0, text.length - state.tailLen);
250
+ const safe = safeEnd > 0 ? text.slice(0, safeEnd) : '';
251
+ state.tail = text.slice(safeEnd);
252
+ return { kind: 'emit', bytes: safe ? encoder.encode(safe) : null };
253
+ }
254
+
255
+ /**
256
+ * Final emit for the injector. If the target tag never appeared, the
257
+ * leftover tail bytes are returned so they aren't lost. (The injection
258
+ * itself is silently skipped — same behaviour as before extraction.)
259
+ */
260
+ export function injectorFlush(state: InjectorState): Uint8Array | null {
261
+ if (!state.injected && state.tail) return encoder.encode(state.tail);
262
+ return null;
263
+ }
264
+
265
+ // ─── Flight Injection Core ───────────────────────────────────────────────────
266
+
267
+ /**
268
+ * Pure async core of the RSC flight-injection transform.
269
+ *
270
+ * Both wrappers (Web `TransformStream` and Node `Transform`) implement the
271
+ * exact same protocol around an RSC reader:
272
+ *
273
+ * 1. On the first HTML chunk, send `FIRST_CHUNK` and start the pull loop.
274
+ * 2. The pull loop reads from `rscReader` (timeout-guarded), wraps each
275
+ * chunk in a `<script>` via `flightChunkScript`, and pushes it onto a
276
+ * pending queue. Between reads, it yields with a single-shot
277
+ * `setImmediate` so HTML chunks get event-loop priority — and after
278
+ * yielding, it drains the queue (via the wrapper's `onYieldDrain`)
279
+ * so flight data reaches the client at shell-flush time.
280
+ * 3. After every emitted HTML chunk, the wrapper drains the queue.
281
+ * 4. On `flush()` the wrapper sends `HTML_DONE` and awaits `pullPromise`.
282
+ * No polling — just `.then()`.
283
+ *
284
+ * The wrappers only differ in:
285
+ * - How they push bytes (controller.enqueue vs transform.push).
286
+ * - How they signal a terminal error (controller.error vs transform.destroy).
287
+ *
288
+ * This class owns the state machine, the pending queue, and the pull
289
+ * loop itself. The wrapper supplies the drain callback and consumes the
290
+ * pending queue + machine state to decide what to push.
291
+ *
292
+ * **No polling.** See design/02-rendering-pipeline.md §"No Polling".
293
+ * **Always timeout-guarded reads.** Per design/02 §"Streaming Constraints".
294
+ */
295
+ export class FlightInjectorCore {
296
+ readonly machine: Machine<FlightInjectionState, FlightInjectionEvent>;
297
+ /** Script chunks waiting to be drained between HTML chunks. */
298
+ readonly pending: Uint8Array[] = [];
299
+
300
+ private readonly rscReader: ReadableStreamDefaultReader<Uint8Array>;
301
+ private readonly timeoutMs: number;
302
+ private readonly errorSignal?: AbortSignal;
303
+ private readonly decoder = new TextDecoder('utf-8', { fatal: true });
304
+ private pullPromise: Promise<void> | null = null;
305
+
306
+ constructor(
307
+ rscStream: ReadableStream<Uint8Array>,
308
+ renderTimeoutMs?: number,
309
+ errorSignal?: AbortSignal
310
+ ) {
311
+ this.rscReader = rscStream.getReader();
312
+ this.timeoutMs = renderTimeoutMs ?? 30_000;
313
+ this.errorSignal = errorSignal;
314
+ this.machine = createMachine<FlightInjectionState, FlightInjectionEvent>({
315
+ initial: { phase: 'init' },
316
+ transitions: flightInjectionTransitions,
317
+ });
318
+ }
319
+
320
+ /** Tell the machine the first HTML chunk has arrived. Idempotent-ish: caller checks. */
321
+ notifyFirstChunk(): void {
322
+ this.machine.send({ type: 'FIRST_CHUNK' });
323
+ }
324
+
325
+ /** Tell the machine HTML output is finished — pull loop will stop yielding. */
326
+ notifyHtmlDone(): void {
327
+ this.machine.send({ type: 'HTML_DONE' });
328
+ }
329
+
330
+ get isInit(): boolean {
331
+ return this.machine.state.phase === 'init';
332
+ }
333
+
334
+ get isPullDone(): boolean {
335
+ return isPullDone(this.machine.state);
336
+ }
337
+
338
+ get hasPullPromise(): boolean {
339
+ return this.pullPromise !== null;
340
+ }
341
+
342
+ /**
343
+ * Get (or start) the pull-loop promise. The wrapper calls this from
344
+ * `flush()` and chains `.then()` onto it — never `await` without an
345
+ * existing finish callback (we don't want to block transform()).
346
+ *
347
+ * `onYieldDrain` is invoked between RSC reads while HTML is still
348
+ * streaming. It must drain the pending queue into the output stream.
349
+ */
350
+ ensurePullLoop(onYieldDrain: () => void): Promise<void> {
351
+ if (!this.pullPromise) {
352
+ this.pullPromise = this.runPullLoop(onYieldDrain);
353
+ }
354
+ return this.pullPromise;
355
+ }
356
+
357
+ /**
358
+ * Get the current terminal error if the machine is in the error phase,
359
+ * else `null`. Wrappers use this after a drain to decide whether to
360
+ * `controller.error()` / `transform.destroy()`.
361
+ */
362
+ get terminalError(): unknown {
363
+ return this.machine.state.phase === 'error' ? this.machine.state.error : null;
364
+ }
365
+
366
+ private async runPullLoop(onYieldDrain: () => void): Promise<void> {
367
+ // Yield once so the first HTML shell chunk flows through the wrapper
368
+ // before we start reading RSC data.
369
+ await new Promise<void>((r) => setImmediate(r));
370
+
371
+ try {
372
+ for (;;) {
373
+ // Guard each read with a timeout so a permanently hung RSC stream
374
+ // eventually aborts. See design/02 §"Streaming Constraints".
375
+ const readPromise = this.rscReader.read();
376
+ const { done, value } =
377
+ this.timeoutMs > 0
378
+ ? await withTimeout(readPromise, this.timeoutMs, 'RSC stream read timed out')
379
+ : await readPromise;
380
+
381
+ if (done) {
382
+ this.machine.send({ type: 'PULL_DONE' });
383
+ return;
384
+ }
385
+
386
+ // If an unhandled RSC error was detected, stop injecting Flight
387
+ // data. Continue reading (to prevent tee buffer divergence) but
388
+ // discard the chunks so corrupted data never reaches the client.
389
+ // See TIM-938.
390
+ if (this.errorSignal?.aborted) {
391
+ continue;
392
+ }
393
+
394
+ const decoded = this.decoder.decode(value, { stream: true });
395
+ this.pending.push(encoder.encode(flightChunkScript(decoded)));
396
+
397
+ // Yield between reads so HTML chunks get priority — but only while
398
+ // HTML is still streaming. Once flush() fires (HTML_DONE), drain
399
+ // without yielding so remaining RSC data doesn't stall.
400
+ if (!isHtmlDone(this.machine.state)) {
401
+ await new Promise<void>((r) => setImmediate(r));
402
+ // After yielding, drain. Without this, hydration blocks waiting
403
+ // for flight data stuck in pending[]. Safe because we're between
404
+ // event-loop ticks (no transform() call mid-execution → no
405
+ // mid-tag risk; the buffered transform upstream coalesced HTML
406
+ // chunks to coherent fragments).
407
+ if (this.pending.length > 0) onYieldDrain();
408
+ }
409
+ }
410
+ } catch (err) {
411
+ if (err instanceof RenderTimeoutError) {
412
+ this.rscReader.cancel(err).catch(() => {});
413
+ }
414
+ this.machine.send({ type: 'PULL_ERROR', error: err });
415
+ }
416
+ }
417
+ }