@rangojs/router 0.4.0 → 0.4.1

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 (482) hide show
  1. package/README.md +19 -1
  2. package/dist/types/browser/event-controller.d.ts +4 -0
  3. package/dist/types/browser/link-interceptor.d.ts +17 -7
  4. package/dist/types/browser/navigation-bridge.d.ts +13 -1
  5. package/dist/types/browser/notify-listeners.d.ts +2 -0
  6. package/dist/types/browser/prefetch/cache.d.ts +1 -1
  7. package/dist/types/browser/prefetch/default-strategy.d.ts +12 -3
  8. package/dist/types/browser/prefetch/invalidation.d.ts +6 -0
  9. package/dist/types/browser/prefetch/loader.d.ts +3 -1
  10. package/dist/types/browser/prefetch/observer.d.ts +3 -6
  11. package/dist/types/browser/rango-state.d.ts +4 -0
  12. package/dist/types/browser/react/Link.d.ts +4 -9
  13. package/dist/types/browser/react/context.d.ts +3 -0
  14. package/dist/types/browser/rsc-router.d.ts +7 -2
  15. package/dist/types/browser/types.d.ts +1 -0
  16. package/dist/types/cache/cache-key-utils.d.ts +11 -3
  17. package/dist/types/cache/cache-scope.d.ts +82 -3
  18. package/dist/types/cache/cf/cf-cache-store.d.ts +2 -2
  19. package/dist/types/cache/index.d.ts +3 -1
  20. package/dist/types/cache/search-params-filter.d.ts +64 -0
  21. package/dist/types/cache/shell-snapshot.d.ts +4 -4
  22. package/dist/types/cache/types.d.ts +30 -2
  23. package/dist/types/cache/vercel/vercel-cache-store.d.ts +2 -2
  24. package/dist/types/index.d.ts +1 -0
  25. package/dist/types/index.rsc.d.ts +1 -0
  26. package/dist/types/router/match-middleware/cache-lookup.d.ts +13 -0
  27. package/dist/types/router/navigation-snapshot.d.ts +29 -0
  28. package/dist/types/router/router-options.d.ts +27 -3
  29. package/dist/types/rsc/shell-build-manifest.d.ts +7 -1
  30. package/dist/types/rsc/shell-serve.d.ts +7 -1
  31. package/dist/types/rsc/types.d.ts +17 -0
  32. package/dist/types/server/request-context.d.ts +57 -4
  33. package/dist/types/testing/render-route.d.ts +10 -1
  34. package/dist/types/testing/shell-status.d.ts +6 -3
  35. package/dist/types/vite/plugin-types.d.ts +1 -1
  36. package/dist/vite/index.js +5 -5
  37. package/package.json +23 -22
  38. package/skills/caching/SKILL.md +39 -0
  39. package/skills/comparison/references/framework-comparison.md +7 -1
  40. package/skills/links/SKILL.md +24 -0
  41. package/skills/ppr/SKILL.md +53 -4
  42. package/skills/router-setup/SKILL.md +7 -2
  43. package/skills/testing/client-components.md +15 -14
  44. package/skills/vercel/SKILL.md +1 -1
  45. package/src/browser/event-controller.ts +110 -11
  46. package/src/browser/link-interceptor.ts +469 -20
  47. package/src/browser/navigation-bridge.ts +71 -2
  48. package/src/browser/navigation-store.ts +24 -1
  49. package/src/browser/notify-listeners.ts +22 -0
  50. package/src/browser/prefetch/cache.ts +4 -2
  51. package/src/browser/prefetch/default-strategy.ts +43 -3
  52. package/src/browser/prefetch/invalidation.ts +30 -0
  53. package/src/browser/prefetch/loader.ts +19 -12
  54. package/src/browser/prefetch/observer.ts +50 -22
  55. package/src/browser/rango-state.ts +21 -0
  56. package/src/browser/react/Link.tsx +97 -88
  57. package/src/browser/react/NavigationProvider.tsx +1 -0
  58. package/src/browser/react/context.ts +4 -0
  59. package/src/browser/rsc-router.tsx +22 -9
  60. package/src/browser/types.ts +1 -0
  61. package/src/cache/cache-key-utils.ts +18 -4
  62. package/src/cache/cache-runtime.ts +7 -2
  63. package/src/cache/cache-scope.ts +152 -23
  64. package/src/cache/cf/cf-cache-store.ts +51 -16
  65. package/src/cache/document-cache.ts +7 -1
  66. package/src/cache/index.ts +7 -0
  67. package/src/cache/search-params-filter.ts +118 -0
  68. package/src/cache/shell-snapshot.ts +8 -4
  69. package/src/cache/types.ts +33 -2
  70. package/src/cache/vercel/vercel-cache-store.ts +17 -3
  71. package/src/index.rsc.ts +4 -0
  72. package/src/index.ts +6 -0
  73. package/src/router/match-middleware/cache-lookup.ts +146 -33
  74. package/src/router/match-middleware/cache-store.ts +70 -0
  75. package/src/router/navigation-snapshot.ts +46 -6
  76. package/src/router/router-options.ts +31 -4
  77. package/src/rsc/handler.ts +9 -0
  78. package/src/rsc/response-cache-serve.ts +1 -1
  79. package/src/rsc/rsc-rendering.ts +252 -27
  80. package/src/rsc/shell-build-manifest.ts +8 -1
  81. package/src/rsc/shell-capture.ts +5 -0
  82. package/src/rsc/shell-serve.ts +8 -2
  83. package/src/rsc/types.ts +17 -0
  84. package/src/server/request-context.ts +62 -3
  85. package/src/testing/dispatch.ts +21 -3
  86. package/src/testing/render-route.tsx +86 -17
  87. package/src/testing/shell-status.ts +20 -3
  88. package/src/vite/plugin-types.ts +1 -1
  89. package/src/vite/plugins/vercel-output.ts +2 -2
  90. package/dist/types.backup/__internal.d.ts +0 -127
  91. package/dist/types.backup/bin/rango.d.ts +0 -1
  92. package/dist/types.backup/browser/action-coordinator.d.ts +0 -57
  93. package/dist/types.backup/browser/action-fence.d.ts +0 -33
  94. package/dist/types.backup/browser/app-shell.d.ts +0 -34
  95. package/dist/types.backup/browser/app-version.d.ts +0 -6
  96. package/dist/types.backup/browser/connection-warmup.d.ts +0 -31
  97. package/dist/types.backup/browser/cookie-name.d.ts +0 -66
  98. package/dist/types.backup/browser/event-controller.d.ts +0 -221
  99. package/dist/types.backup/browser/history-state.d.ts +0 -26
  100. package/dist/types.backup/browser/index.d.ts +0 -1
  101. package/dist/types.backup/browser/intercept-utils.d.ts +0 -30
  102. package/dist/types.backup/browser/invalidate-client-cache.d.ts +0 -17
  103. package/dist/types.backup/browser/link-interceptor.d.ts +0 -43
  104. package/dist/types.backup/browser/logging.d.ts +0 -33
  105. package/dist/types.backup/browser/merge-segment-loaders.d.ts +0 -38
  106. package/dist/types.backup/browser/navigation-bridge.d.ts +0 -27
  107. package/dist/types.backup/browser/navigation-client.d.ts +0 -17
  108. package/dist/types.backup/browser/navigation-store-handle.d.ts +0 -25
  109. package/dist/types.backup/browser/navigation-store.d.ts +0 -95
  110. package/dist/types.backup/browser/navigation-transaction.d.ts +0 -75
  111. package/dist/types.backup/browser/network-error-handler.d.ts +0 -35
  112. package/dist/types.backup/browser/partial-update.d.ts +0 -61
  113. package/dist/types.backup/browser/prefetch/cache.d.ts +0 -183
  114. package/dist/types.backup/browser/prefetch/fetch.d.ts +0 -52
  115. package/dist/types.backup/browser/prefetch/observer.d.ts +0 -27
  116. package/dist/types.backup/browser/prefetch/policy.d.ts +0 -13
  117. package/dist/types.backup/browser/prefetch/queue.d.ts +0 -48
  118. package/dist/types.backup/browser/prefetch/resource-ready.d.ts +0 -28
  119. package/dist/types.backup/browser/rango-state.d.ts +0 -52
  120. package/dist/types.backup/browser/react/Link.d.ts +0 -140
  121. package/dist/types.backup/browser/react/NavigationProvider.d.ts +0 -88
  122. package/dist/types.backup/browser/react/ScrollRestoration.d.ts +0 -78
  123. package/dist/types.backup/browser/react/context.d.ts +0 -54
  124. package/dist/types.backup/browser/react/filter-segment-order.d.ts +0 -35
  125. package/dist/types.backup/browser/react/index.d.ts +0 -1
  126. package/dist/types.backup/browser/react/location-state-shared.d.ts +0 -162
  127. package/dist/types.backup/browser/react/location-state.d.ts +0 -29
  128. package/dist/types.backup/browser/react/mount-context.d.ts +0 -23
  129. package/dist/types.backup/browser/react/nonce-context.d.ts +0 -14
  130. package/dist/types.backup/browser/react/shallow-equal.d.ts +0 -5
  131. package/dist/types.backup/browser/react/use-action.d.ts +0 -61
  132. package/dist/types.backup/browser/react/use-handle.d.ts +0 -21
  133. package/dist/types.backup/browser/react/use-href.d.ts +0 -32
  134. package/dist/types.backup/browser/react/use-link-status.d.ts +0 -36
  135. package/dist/types.backup/browser/react/use-mount.d.ts +0 -24
  136. package/dist/types.backup/browser/react/use-navigation.d.ts +0 -15
  137. package/dist/types.backup/browser/react/use-params.d.ts +0 -21
  138. package/dist/types.backup/browser/react/use-pathname.d.ts +0 -13
  139. package/dist/types.backup/browser/react/use-reverse.d.ts +0 -40
  140. package/dist/types.backup/browser/react/use-router.d.ts +0 -23
  141. package/dist/types.backup/browser/react/use-search-params.d.ts +0 -19
  142. package/dist/types.backup/browser/react/use-segments.d.ts +0 -29
  143. package/dist/types.backup/browser/response-adapter.d.ts +0 -58
  144. package/dist/types.backup/browser/rsc-router.d.ts +0 -141
  145. package/dist/types.backup/browser/scroll-restoration.d.ts +0 -103
  146. package/dist/types.backup/browser/segment-reconciler.d.ts +0 -74
  147. package/dist/types.backup/browser/segment-structure-assert.d.ts +0 -16
  148. package/dist/types.backup/browser/server-action-bridge.d.ts +0 -29
  149. package/dist/types.backup/browser/types.d.ts +0 -530
  150. package/dist/types.backup/browser/validate-redirect-origin.d.ts +0 -28
  151. package/dist/types.backup/build/collect-fallback-refs.d.ts +0 -5
  152. package/dist/types.backup/build/generate-manifest.d.ts +0 -100
  153. package/dist/types.backup/build/generate-route-types.d.ts +0 -8
  154. package/dist/types.backup/build/index.d.ts +0 -21
  155. package/dist/types.backup/build/prefix-tree-utils.d.ts +0 -56
  156. package/dist/types.backup/build/route-trie.d.ts +0 -89
  157. package/dist/types.backup/build/route-types/ast-helpers.d.ts +0 -3
  158. package/dist/types.backup/build/route-types/ast-route-extraction.d.ts +0 -13
  159. package/dist/types.backup/build/route-types/codegen.d.ts +0 -16
  160. package/dist/types.backup/build/route-types/include-resolution.d.ts +0 -74
  161. package/dist/types.backup/build/route-types/param-extraction.d.ts +0 -13
  162. package/dist/types.backup/build/route-types/per-module-writer.d.ts +0 -18
  163. package/dist/types.backup/build/route-types/router-processing.d.ts +0 -82
  164. package/dist/types.backup/build/route-types/scan-filter.d.ts +0 -17
  165. package/dist/types.backup/build/route-types/source-scan.d.ts +0 -13
  166. package/dist/types.backup/build/runtime-discovery.d.ts +0 -24
  167. package/dist/types.backup/cache/background-task.d.ts +0 -21
  168. package/dist/types.backup/cache/cache-error.d.ts +0 -71
  169. package/dist/types.backup/cache/cache-key-utils.d.ts +0 -35
  170. package/dist/types.backup/cache/cache-policy.d.ts +0 -59
  171. package/dist/types.backup/cache/cache-runtime.d.ts +0 -51
  172. package/dist/types.backup/cache/cache-scope.d.ts +0 -134
  173. package/dist/types.backup/cache/cache-tag.d.ts +0 -79
  174. package/dist/types.backup/cache/cf/cf-base64.d.ts +0 -4
  175. package/dist/types.backup/cache/cf/cf-cache-constants.d.ts +0 -105
  176. package/dist/types.backup/cache/cf/cf-cache-store.d.ts +0 -481
  177. package/dist/types.backup/cache/cf/cf-cache-types.d.ts +0 -300
  178. package/dist/types.backup/cache/cf/cf-kv-utils.d.ts +0 -22
  179. package/dist/types.backup/cache/cf/cf-tag-marker-memo.d.ts +0 -15
  180. package/dist/types.backup/cache/cf/index.d.ts +0 -3
  181. package/dist/types.backup/cache/document-cache.d.ts +0 -69
  182. package/dist/types.backup/cache/handle-capture.d.ts +0 -23
  183. package/dist/types.backup/cache/handle-snapshot.d.ts +0 -39
  184. package/dist/types.backup/cache/index.d.ts +0 -7
  185. package/dist/types.backup/cache/memory-segment-store.d.ts +0 -163
  186. package/dist/types.backup/cache/profile-registry.d.ts +0 -40
  187. package/dist/types.backup/cache/read-through-swr.d.ts +0 -60
  188. package/dist/types.backup/cache/segment-codec.d.ts +0 -78
  189. package/dist/types.backup/cache/shell-snapshot.d.ts +0 -162
  190. package/dist/types.backup/cache/tag-invalidation.d.ts +0 -74
  191. package/dist/types.backup/cache/taint.d.ts +0 -71
  192. package/dist/types.backup/cache/types.d.ts +0 -407
  193. package/dist/types.backup/cache/vercel/index.d.ts +0 -1
  194. package/dist/types.backup/cache/vercel/vercel-cache-store.d.ts +0 -267
  195. package/dist/types.backup/client.d.ts +0 -184
  196. package/dist/types.backup/client.rsc.d.ts +0 -39
  197. package/dist/types.backup/cloudflare/index.d.ts +0 -7
  198. package/dist/types.backup/cloudflare/tracing.d.ts +0 -53
  199. package/dist/types.backup/component-utils.d.ts +0 -46
  200. package/dist/types.backup/components/DefaultDocument.d.ts +0 -13
  201. package/dist/types.backup/context-var.d.ts +0 -84
  202. package/dist/types.backup/debug.d.ts +0 -57
  203. package/dist/types.backup/decode-loader-results.d.ts +0 -5
  204. package/dist/types.backup/default-error-boundary.d.ts +0 -10
  205. package/dist/types.backup/defer.d.ts +0 -89
  206. package/dist/types.backup/deps/browser.d.ts +0 -1
  207. package/dist/types.backup/deps/html-stream-client.d.ts +0 -1
  208. package/dist/types.backup/deps/html-stream-server.d.ts +0 -1
  209. package/dist/types.backup/deps/rsc.d.ts +0 -1
  210. package/dist/types.backup/deps/ssr.d.ts +0 -1
  211. package/dist/types.backup/encode-kv.d.ts +0 -35
  212. package/dist/types.backup/errors.d.ts +0 -226
  213. package/dist/types.backup/escape-script.d.ts +0 -44
  214. package/dist/types.backup/handle.d.ts +0 -93
  215. package/dist/types.backup/handles/MetaTags.d.ts +0 -17
  216. package/dist/types.backup/handles/Scripts.d.ts +0 -38
  217. package/dist/types.backup/handles/breadcrumbs.d.ts +0 -43
  218. package/dist/types.backup/handles/deferred-resolution.d.ts +0 -53
  219. package/dist/types.backup/handles/is-thenable.d.ts +0 -12
  220. package/dist/types.backup/handles/meta.d.ts +0 -43
  221. package/dist/types.backup/handles/script.d.ts +0 -139
  222. package/dist/types.backup/host/cookie-handler.d.ts +0 -8
  223. package/dist/types.backup/host/errors.d.ts +0 -40
  224. package/dist/types.backup/host/index.d.ts +0 -33
  225. package/dist/types.backup/host/pattern-matcher.d.ts +0 -30
  226. package/dist/types.backup/host/router.d.ts +0 -12
  227. package/dist/types.backup/host/testing.d.ts +0 -41
  228. package/dist/types.backup/host/types.d.ts +0 -148
  229. package/dist/types.backup/host/utils.d.ts +0 -20
  230. package/dist/types.backup/href-client.d.ts +0 -214
  231. package/dist/types.backup/index.d.ts +0 -112
  232. package/dist/types.backup/index.rsc.d.ts +0 -51
  233. package/dist/types.backup/internal-debug.d.ts +0 -1
  234. package/dist/types.backup/loader-store.d.ts +0 -193
  235. package/dist/types.backup/loader.d.ts +0 -18
  236. package/dist/types.backup/loader.rsc.d.ts +0 -18
  237. package/dist/types.backup/missing-id-error.d.ts +0 -1
  238. package/dist/types.backup/outlet-context.d.ts +0 -12
  239. package/dist/types.backup/outlet-provider.d.ts +0 -12
  240. package/dist/types.backup/prerender/build-shell-capture.d.ts +0 -104
  241. package/dist/types.backup/prerender/param-hash.d.ts +0 -6
  242. package/dist/types.backup/prerender/shell-manifest-key.d.ts +0 -18
  243. package/dist/types.backup/prerender/store.d.ts +0 -62
  244. package/dist/types.backup/prerender.d.ts +0 -292
  245. package/dist/types.backup/redirect-origin.d.ts +0 -55
  246. package/dist/types.backup/regex-escape.d.ts +0 -6
  247. package/dist/types.backup/render-error-thrower.d.ts +0 -13
  248. package/dist/types.backup/response-utils.d.ts +0 -35
  249. package/dist/types.backup/reverse.d.ts +0 -206
  250. package/dist/types.backup/root-error-boundary.d.ts +0 -32
  251. package/dist/types.backup/route-content-wrapper.d.ts +0 -40
  252. package/dist/types.backup/route-definition/dsl-helpers.d.ts +0 -130
  253. package/dist/types.backup/route-definition/helper-factories.d.ts +0 -22
  254. package/dist/types.backup/route-definition/helpers-types.d.ts +0 -392
  255. package/dist/types.backup/route-definition/index.d.ts +0 -7
  256. package/dist/types.backup/route-definition/redirect.d.ts +0 -48
  257. package/dist/types.backup/route-definition/resolve-handler-use.d.ts +0 -19
  258. package/dist/types.backup/route-definition/use-item-types.d.ts +0 -1
  259. package/dist/types.backup/route-definition.d.ts +0 -1
  260. package/dist/types.backup/route-map-builder.d.ts +0 -127
  261. package/dist/types.backup/route-name.d.ts +0 -27
  262. package/dist/types.backup/route-types.d.ts +0 -172
  263. package/dist/types.backup/router/basename.d.ts +0 -10
  264. package/dist/types.backup/router/content-negotiation.d.ts +0 -91
  265. package/dist/types.backup/router/debug-manifest.d.ts +0 -7
  266. package/dist/types.backup/router/error-handling.d.ts +0 -76
  267. package/dist/types.backup/router/find-match.d.ts +0 -19
  268. package/dist/types.backup/router/handler-context.d.ts +0 -41
  269. package/dist/types.backup/router/instrument.d.ts +0 -161
  270. package/dist/types.backup/router/intercept-resolution.d.ts +0 -79
  271. package/dist/types.backup/router/lazy-includes.d.ts +0 -26
  272. package/dist/types.backup/router/loader-resolution.d.ts +0 -63
  273. package/dist/types.backup/router/logging.d.ts +0 -41
  274. package/dist/types.backup/router/manifest.d.ts +0 -8
  275. package/dist/types.backup/router/match-api.d.ts +0 -19
  276. package/dist/types.backup/router/match-context.d.ts +0 -184
  277. package/dist/types.backup/router/match-handlers.d.ts +0 -49
  278. package/dist/types.backup/router/match-middleware/background-revalidation.d.ts +0 -113
  279. package/dist/types.backup/router/match-middleware/cache-lookup.d.ts +0 -113
  280. package/dist/types.backup/router/match-middleware/cache-store.d.ts +0 -112
  281. package/dist/types.backup/router/match-middleware/index.d.ts +0 -80
  282. package/dist/types.backup/router/match-middleware/intercept-resolution.d.ts +0 -116
  283. package/dist/types.backup/router/match-middleware/segment-resolution.d.ts +0 -94
  284. package/dist/types.backup/router/match-pipelines.d.ts +0 -103
  285. package/dist/types.backup/router/match-result.d.ts +0 -114
  286. package/dist/types.backup/router/metrics.d.ts +0 -6
  287. package/dist/types.backup/router/middleware-types.d.ts +0 -74
  288. package/dist/types.backup/router/middleware.d.ts +0 -116
  289. package/dist/types.backup/router/navigation-snapshot.d.ts +0 -22
  290. package/dist/types.backup/router/params-util.d.ts +0 -8
  291. package/dist/types.backup/router/parse-pattern.d.ts +0 -38
  292. package/dist/types.backup/router/pattern-matching.d.ts +0 -169
  293. package/dist/types.backup/router/prefetch-cache-ttl.d.ts +0 -27
  294. package/dist/types.backup/router/prefetch-limits.d.ts +0 -20
  295. package/dist/types.backup/router/prerender-match.d.ts +0 -50
  296. package/dist/types.backup/router/preview-match.d.ts +0 -22
  297. package/dist/types.backup/router/request-classification.d.ts +0 -104
  298. package/dist/types.backup/router/revalidation.d.ts +0 -57
  299. package/dist/types.backup/router/route-snapshot.d.ts +0 -112
  300. package/dist/types.backup/router/router-context.d.ts +0 -137
  301. package/dist/types.backup/router/router-interfaces.d.ts +0 -432
  302. package/dist/types.backup/router/router-options.d.ts +0 -738
  303. package/dist/types.backup/router/router-registry.d.ts +0 -15
  304. package/dist/types.backup/router/segment-resolution/fresh.d.ts +0 -55
  305. package/dist/types.backup/router/segment-resolution/helpers.d.ts +0 -93
  306. package/dist/types.backup/router/segment-resolution/loader-cache.d.ts +0 -33
  307. package/dist/types.backup/router/segment-resolution/loader-mask.d.ts +0 -44
  308. package/dist/types.backup/router/segment-resolution/loader-snapshot.d.ts +0 -90
  309. package/dist/types.backup/router/segment-resolution/mask-nested.d.ts +0 -53
  310. package/dist/types.backup/router/segment-resolution/revalidation.d.ts +0 -85
  311. package/dist/types.backup/router/segment-resolution/static-store.d.ts +0 -17
  312. package/dist/types.backup/router/segment-resolution/streamed-handler-telemetry.d.ts +0 -16
  313. package/dist/types.backup/router/segment-resolution/view-transition-default.d.ts +0 -28
  314. package/dist/types.backup/router/segment-resolution.d.ts +0 -3
  315. package/dist/types.backup/router/segment-wrappers.d.ts +0 -53
  316. package/dist/types.backup/router/state-cookie-name.d.ts +0 -1
  317. package/dist/types.backup/router/substitute-pattern-params.d.ts +0 -23
  318. package/dist/types.backup/router/telemetry-otel.d.ts +0 -113
  319. package/dist/types.backup/router/telemetry.d.ts +0 -215
  320. package/dist/types.backup/router/timeout.d.ts +0 -68
  321. package/dist/types.backup/router/tracing.d.ts +0 -125
  322. package/dist/types.backup/router/trie-matching.d.ts +0 -32
  323. package/dist/types.backup/router/types.d.ts +0 -98
  324. package/dist/types.backup/router/url-params.d.ts +0 -26
  325. package/dist/types.backup/router.d.ts +0 -7
  326. package/dist/types.backup/rsc/capture-queue.d.ts +0 -6
  327. package/dist/types.backup/rsc/full-payload.d.ts +0 -22
  328. package/dist/types.backup/rsc/handler-context.d.ts +0 -31
  329. package/dist/types.backup/rsc/handler.d.ts +0 -9
  330. package/dist/types.backup/rsc/helpers.d.ts +0 -213
  331. package/dist/types.backup/rsc/index.d.ts +0 -17
  332. package/dist/types.backup/rsc/json-route-result.d.ts +0 -20
  333. package/dist/types.backup/rsc/loader-fetch.d.ts +0 -14
  334. package/dist/types.backup/rsc/manifest-init.d.ts +0 -18
  335. package/dist/types.backup/rsc/nonce.d.ts +0 -28
  336. package/dist/types.backup/rsc/origin-guard.d.ts +0 -50
  337. package/dist/types.backup/rsc/progressive-enhancement.d.ts +0 -19
  338. package/dist/types.backup/rsc/redirect-guard.d.ts +0 -35
  339. package/dist/types.backup/rsc/response-cache-serve.d.ts +0 -46
  340. package/dist/types.backup/rsc/response-error.d.ts +0 -19
  341. package/dist/types.backup/rsc/response-route-handler.d.ts +0 -29
  342. package/dist/types.backup/rsc/rsc-rendering.d.ts +0 -23
  343. package/dist/types.backup/rsc/runtime-warnings.d.ts +0 -22
  344. package/dist/types.backup/rsc/server-action.d.ts +0 -68
  345. package/dist/types.backup/rsc/shell-build-manifest.d.ts +0 -84
  346. package/dist/types.backup/rsc/shell-capture-constants.d.ts +0 -27
  347. package/dist/types.backup/rsc/shell-capture.d.ts +0 -374
  348. package/dist/types.backup/rsc/shell-serve.d.ts +0 -136
  349. package/dist/types.backup/rsc/ssr-setup.d.ts +0 -48
  350. package/dist/types.backup/rsc/transition-gate.d.ts +0 -27
  351. package/dist/types.backup/rsc/types.d.ts +0 -290
  352. package/dist/types.backup/runtime-env.d.ts +0 -1
  353. package/dist/types.backup/search-params.d.ts +0 -125
  354. package/dist/types.backup/segment-content-promise.d.ts +0 -13
  355. package/dist/types.backup/segment-fragments.d.ts +0 -56
  356. package/dist/types.backup/segment-loader-promise.d.ts +0 -22
  357. package/dist/types.backup/segment-system.d.ts +0 -84
  358. package/dist/types.backup/serialize.d.ts +0 -164
  359. package/dist/types.backup/server/context.d.ts +0 -494
  360. package/dist/types.backup/server/cookie-parse.d.ts +0 -10
  361. package/dist/types.backup/server/cookie-store.d.ts +0 -107
  362. package/dist/types.backup/server/fetchable-loader-store.d.ts +0 -20
  363. package/dist/types.backup/server/handle-store.d.ts +0 -100
  364. package/dist/types.backup/server/loader-registry.d.ts +0 -32
  365. package/dist/types.backup/server/request-context.d.ts +0 -596
  366. package/dist/types.backup/server/root-layout.d.ts +0 -3
  367. package/dist/types.backup/server.d.ts +0 -15
  368. package/dist/types.backup/ssr/index.d.ts +0 -233
  369. package/dist/types.backup/ssr/inject-rsc-eager.d.ts +0 -3
  370. package/dist/types.backup/ssr/preinit-client-references.d.ts +0 -71
  371. package/dist/types.backup/ssr/ssr-root.d.ts +0 -69
  372. package/dist/types.backup/static-handler.d.ts +0 -57
  373. package/dist/types.backup/testing/cache-status.d.ts +0 -63
  374. package/dist/types.backup/testing/collect-handle.d.ts +0 -20
  375. package/dist/types.backup/testing/dispatch.d.ts +0 -123
  376. package/dist/types.backup/testing/dom.entry.d.ts +0 -15
  377. package/dist/types.backup/testing/e2e/fixture.d.ts +0 -37
  378. package/dist/types.backup/testing/e2e/index.d.ts +0 -30
  379. package/dist/types.backup/testing/e2e/matchers.d.ts +0 -17
  380. package/dist/types.backup/testing/e2e/page-helpers.d.ts +0 -62
  381. package/dist/types.backup/testing/e2e/parity.d.ts +0 -111
  382. package/dist/types.backup/testing/e2e/server.d.ts +0 -35
  383. package/dist/types.backup/testing/flight-matchers.d.ts +0 -55
  384. package/dist/types.backup/testing/flight-normalize.d.ts +0 -1
  385. package/dist/types.backup/testing/flight-tree.d.ts +0 -192
  386. package/dist/types.backup/testing/flight.d.ts +0 -115
  387. package/dist/types.backup/testing/flight.entry.d.ts +0 -27
  388. package/dist/types.backup/testing/generated-routes.d.ts +0 -66
  389. package/dist/types.backup/testing/index.d.ts +0 -52
  390. package/dist/types.backup/testing/internal/context.d.ts +0 -225
  391. package/dist/types.backup/testing/internal/flight-client-globals.d.ts +0 -1
  392. package/dist/types.backup/testing/internal/seed-vars.d.ts +0 -30
  393. package/dist/types.backup/testing/render-handler.d.ts +0 -160
  394. package/dist/types.backup/testing/render-route.d.ts +0 -246
  395. package/dist/types.backup/testing/run-loader.d.ts +0 -186
  396. package/dist/types.backup/testing/run-middleware.d.ts +0 -132
  397. package/dist/types.backup/testing/run-transition-when.d.ts +0 -77
  398. package/dist/types.backup/testing/vitest-stubs/cloudflare-email.d.ts +0 -6
  399. package/dist/types.backup/testing/vitest-stubs/cloudflare-workers.d.ts +0 -13
  400. package/dist/types.backup/testing/vitest-stubs/plugin-rsc.d.ts +0 -7
  401. package/dist/types.backup/testing/vitest-stubs/version.d.ts +0 -1
  402. package/dist/types.backup/testing/vitest.d.ts +0 -205
  403. package/dist/types.backup/theme/ThemeProvider.d.ts +0 -13
  404. package/dist/types.backup/theme/ThemeScript.d.ts +0 -45
  405. package/dist/types.backup/theme/constants.d.ts +0 -39
  406. package/dist/types.backup/theme/index.d.ts +0 -29
  407. package/dist/types.backup/theme/theme-context.d.ts +0 -21
  408. package/dist/types.backup/theme/theme-script.d.ts +0 -26
  409. package/dist/types.backup/theme/types.d.ts +0 -162
  410. package/dist/types.backup/theme/use-theme.d.ts +0 -8
  411. package/dist/types.backup/types/boundaries.d.ts +0 -93
  412. package/dist/types.backup/types/cache-types.d.ts +0 -191
  413. package/dist/types.backup/types/error-types.d.ts +0 -114
  414. package/dist/types.backup/types/global-namespace.d.ts +0 -90
  415. package/dist/types.backup/types/handler-context.d.ts +0 -658
  416. package/dist/types.backup/types/index.d.ts +0 -11
  417. package/dist/types.backup/types/loader-types.d.ts +0 -182
  418. package/dist/types.backup/types/request-scope.d.ts +0 -93
  419. package/dist/types.backup/types/route-config.d.ts +0 -105
  420. package/dist/types.backup/types/route-entry.d.ts +0 -95
  421. package/dist/types.backup/types/segments.d.ts +0 -234
  422. package/dist/types.backup/types.d.ts +0 -1
  423. package/dist/types.backup/urls/include-helper.d.ts +0 -17
  424. package/dist/types.backup/urls/include-provider.d.ts +0 -27
  425. package/dist/types.backup/urls/index.d.ts +0 -6
  426. package/dist/types.backup/urls/path-helper-types.d.ts +0 -197
  427. package/dist/types.backup/urls/path-helper.d.ts +0 -12
  428. package/dist/types.backup/urls/pattern-types.d.ts +0 -166
  429. package/dist/types.backup/urls/response-types.d.ts +0 -67
  430. package/dist/types.backup/urls/type-extraction.d.ts +0 -157
  431. package/dist/types.backup/urls/urls-function.d.ts +0 -24
  432. package/dist/types.backup/urls.d.ts +0 -1
  433. package/dist/types.backup/use-loader.d.ts +0 -150
  434. package/dist/types.backup/vercel/index.d.ts +0 -10
  435. package/dist/types.backup/vercel/tracing.d.ts +0 -70
  436. package/dist/types.backup/vite/debug.d.ts +0 -80
  437. package/dist/types.backup/vite/discovery/bundle-postprocess.d.ts +0 -12
  438. package/dist/types.backup/vite/discovery/dev-prerender-cache.d.ts +0 -65
  439. package/dist/types.backup/vite/discovery/discover-routers.d.ts +0 -17
  440. package/dist/types.backup/vite/discovery/discovery-errors.d.ts +0 -113
  441. package/dist/types.backup/vite/discovery/gate-state.d.ts +0 -79
  442. package/dist/types.backup/vite/discovery/prerender-collection.d.ts +0 -24
  443. package/dist/types.backup/vite/discovery/route-types-writer.d.ts +0 -32
  444. package/dist/types.backup/vite/discovery/self-gen-tracking.d.ts +0 -22
  445. package/dist/types.backup/vite/discovery/shell-prerender-phase.d.ts +0 -40
  446. package/dist/types.backup/vite/discovery/state.d.ts +0 -162
  447. package/dist/types.backup/vite/discovery/virtual-module-codegen.d.ts +0 -15
  448. package/dist/types.backup/vite/index.d.ts +0 -11
  449. package/dist/types.backup/vite/inject-client-debug.d.ts +0 -56
  450. package/dist/types.backup/vite/plugin-types.d.ts +0 -298
  451. package/dist/types.backup/vite/plugins/cjs-to-esm.d.ts +0 -6
  452. package/dist/types.backup/vite/plugins/client-ref-dedup.d.ts +0 -40
  453. package/dist/types.backup/vite/plugins/client-ref-hashing.d.ts +0 -35
  454. package/dist/types.backup/vite/plugins/cloudflare-protocol-stub.d.ts +0 -64
  455. package/dist/types.backup/vite/plugins/expose-action-id.d.ts +0 -18
  456. package/dist/types.backup/vite/plugins/expose-id-utils.d.ts +0 -37
  457. package/dist/types.backup/vite/plugins/expose-ids/export-analysis.d.ts +0 -19
  458. package/dist/types.backup/vite/plugins/expose-ids/handler-transform.d.ts +0 -10
  459. package/dist/types.backup/vite/plugins/expose-ids/loader-transform.d.ts +0 -8
  460. package/dist/types.backup/vite/plugins/expose-ids/router-transform.d.ts +0 -13
  461. package/dist/types.backup/vite/plugins/expose-ids/types.d.ts +0 -29
  462. package/dist/types.backup/vite/plugins/expose-internal-ids.d.ts +0 -6
  463. package/dist/types.backup/vite/plugins/performance-tracks.d.ts +0 -25
  464. package/dist/types.backup/vite/plugins/refresh-cmd.d.ts +0 -20
  465. package/dist/types.backup/vite/plugins/use-cache-transform.d.ts +0 -20
  466. package/dist/types.backup/vite/plugins/vercel-output.d.ts +0 -85
  467. package/dist/types.backup/vite/plugins/version-injector.d.ts +0 -21
  468. package/dist/types.backup/vite/plugins/version-plugin.d.ts +0 -19
  469. package/dist/types.backup/vite/plugins/virtual-entries.d.ts +0 -36
  470. package/dist/types.backup/vite/plugins/virtual-stub-plugin.d.ts +0 -7
  471. package/dist/types.backup/vite/rango.d.ts +0 -29
  472. package/dist/types.backup/vite/router-discovery.d.ts +0 -23
  473. package/dist/types.backup/vite/utils/ast-handler-extract.d.ts +0 -64
  474. package/dist/types.backup/vite/utils/banner.d.ts +0 -2
  475. package/dist/types.backup/vite/utils/bundle-analysis.d.ts +0 -28
  476. package/dist/types.backup/vite/utils/client-chunks.d.ts +0 -55
  477. package/dist/types.backup/vite/utils/directive-prologue.d.ts +0 -16
  478. package/dist/types.backup/vite/utils/forward-user-plugins.d.ts +0 -37
  479. package/dist/types.backup/vite/utils/manifest-utils.d.ts +0 -7
  480. package/dist/types.backup/vite/utils/package-resolution.d.ts +0 -6
  481. package/dist/types.backup/vite/utils/prerender-utils.d.ts +0 -32
  482. package/dist/types.backup/vite/utils/shared-utils.d.ts +0 -55
@@ -1,68 +0,0 @@
1
- /**
2
- * Server Action Handler
3
- *
4
- * Handles server action execution and post-action revalidation as two
5
- * separate phases:
6
- *
7
- * 1. executeServerAction — decodes args, runs the action, handles redirects
8
- * and error boundaries. Returns either a final Response (redirect/error)
9
- * or an ActionContinuation for the revalidation phase.
10
- *
11
- * 2. revalidateAfterAction — takes the continuation, matches affected
12
- * segments, builds the RSC payload, and returns the Flight response.
13
- *
14
- * The handler (handler.ts) runs the action BEFORE route middleware, then
15
- * wraps revalidation inside route middleware — identical to a normal render.
16
- */
17
- import { getRequestContext } from "../server/request-context.js";
18
- import type { HandlerContext } from "./handler-context.js";
19
- import type { MatchResult } from "../types.js";
20
- /**
21
- * Data flowing from action execution to the revalidation phase.
22
- * When the action completes without redirect, the handler passes this to route
23
- * middleware → revalidateAfterAction.
24
- *
25
- * `errorBoundary` carries the matched error-boundary result when the action
26
- * threw and a boundary matched. The error-boundary render is then performed in
27
- * the revalidation phase so it runs INSIDE the same route-middleware wrapper as
28
- * a successful revalidation — route middleware (context vars, headers, cookies)
29
- * must apply to the error render too, matching the module doc's "identical to a
30
- * normal render". When `errorBoundary` is set, `actionContext` is unused (the
31
- * boundary is already matched; no matchPartial is run).
32
- */
33
- export interface ActionContinuation {
34
- returnValue: {
35
- ok: boolean;
36
- data: unknown;
37
- };
38
- actionStatus: number;
39
- temporaryReferences: ReturnType<HandlerContext["createTemporaryReferenceSet"]>;
40
- actionContext: {
41
- actionId: string;
42
- actionUrl: URL;
43
- actionResult: unknown;
44
- formData?: FormData;
45
- };
46
- errorBoundary?: MatchResult;
47
- }
48
- /**
49
- * Phase 1: Execute the server action.
50
- *
51
- * Decodes arguments, runs the action, handles redirects and error
52
- * boundaries. Returns a final Response (redirect, error boundary render)
53
- * or an ActionContinuation for the revalidation phase.
54
- */
55
- export declare function executeServerAction<TEnv>(ctx: HandlerContext<TEnv>, request: Request, env: TEnv, url: URL, actionId: string, handleStore: ReturnType<typeof getRequestContext>["_handleStore"]): Promise<Response | ActionContinuation>;
56
- /**
57
- * Phase 2: Revalidate after action.
58
- *
59
- * Matches affected segments, builds the RSC payload, and returns the
60
- * Flight response. Called inside route middleware (same as a normal render).
61
- *
62
- * Invariant: the response payload MUST have isPartial: true. The client
63
- * (server-action-bridge) rejects non-partial payloads because partial
64
- * reconciliation requires matched/diff semantics that full renders don't
65
- * provide. Redirects are the only non-partial outcome and are handled via
66
- * X-RSC-Redirect headers before Flight deserialization.
67
- */
68
- export declare function revalidateAfterAction<TEnv>(ctx: HandlerContext<TEnv>, request: Request, env: TEnv, url: URL, handleStore: ReturnType<typeof getRequestContext>["_handleStore"], continuation: ActionContinuation): Promise<Response>;
@@ -1,84 +0,0 @@
1
- /**
2
- * Build-time shell entry read-through (producer B, issue #699).
3
- *
4
- * The build stages one ShellCacheEntry per Prerender+ppr URL as a lazy
5
- * manifest module injected into the RSC bundle
6
- * (`globalThis.__loadShellManifestModule`, mirroring the prerender payload
7
- * manifest — the worker handles every request; nothing is served from
8
- * assets). The serve path consults this on a runtime shell-store MISS, so the
9
- * FIRST request after a deploy is already a shell HIT with zero runtime
10
- * capture. The worker cannot tell where an entry came from: a build hit is
11
- * served through the same serveShellHit as a captured one.
12
- *
13
- * Lifecycle:
14
- * - No expiry until the next deploy — the buildVersion gate retires entries
15
- * the moment a new build ships (a new manifest replaces them anyway).
16
- * - `ppr.ttl` drives STALENESS ONLY: past createdAt + ttl the entry still
17
- * serves, but a runtime recapture is scheduled — SWR is the UPGRADE path
18
- * from build entry to fresher runtime entry, not the bootstrap path. The
19
- * runtime store is consulted first, so a captured entry supersedes the
20
- * build entry as soon as it lands.
21
- * - `updateTag()` evicts build entries like runtime ones: the read-through
22
- * validates the entry's baked tag union against the store's tag
23
- * invalidation markers (isTagsInvalidatedSince) with the entry's createdAt
24
- * as the reference instant. No tombstones — the manifest is immutable; the
25
- * markers say whether it is still current.
26
- */
27
- import type { SegmentCacheStore, ShellCacheEntry } from "../cache/types.js";
28
- /** One baked manifest record (the __ps asset module's default export). */
29
- export interface BuildShellEntry {
30
- entry: ShellCacheEntry;
31
- /** Resolved ppr ttl (seconds) — drives staleness/recapture, never expiry. */
32
- ttl: number;
33
- swr?: number;
34
- /** The putShell-barrier tag union baked at build (static + recorded). */
35
- tags?: string[];
36
- routeName: string;
37
- }
38
- interface ShellManifestModule {
39
- /** Manifest key (pathname — see shell-manifest-key.ts) -> asset specifier. */
40
- default: Record<string, string>;
41
- loadShellAsset: (spec: string) => Promise<{
42
- default: BuildShellEntry;
43
- }>;
44
- }
45
- declare global {
46
- var __loadShellManifestModule: (() => Promise<ShellManifestModule>) | undefined;
47
- }
48
- /** Reset the memoized manifest (unit tests swap the global loader). */
49
- export declare function resetBuildShellManifestForTests(): void;
50
- export interface BuildShellHit {
51
- entry: ShellCacheEntry;
52
- /** Past createdAt + ttl: serve, but schedule the runtime recapture. */
53
- stale: boolean;
54
- }
55
- /**
56
- * Dev-mode lookup context: there is no build manifest in dev, so producer B
57
- * runs ON DEMAND through the Vite dev server's /__rsc_shell endpoint
58
- * (memoized per router HMR generation), mirroring the dev prerender store's
59
- * /__rsc_prerender flow. Only armed for PRERENDERED routes (matched.pr) —
60
- * exactly production's candidate set; everything else keeps runtime capture.
61
- */
62
- export interface DevShellLookup {
63
- /** True when the classified route is trie-flagged pr (Prerender-backed). */
64
- isPrerenderRoute: boolean;
65
- /** Canonical route key of the classified route (endpoint verification). */
66
- routeName: string | undefined;
67
- /** Resolved ppr policy from the serve gate (the endpoint is policy-free). */
68
- ttl: number;
69
- swr?: number;
70
- tags?: string[];
71
- maxSnapshotBytes?: number;
72
- /** Resolved `ppr.captureTimeout` (ms) — the endpoint's capture honors it. */
73
- captureTimeout?: number;
74
- }
75
- /**
76
- * Look up the baked shell entry for a request, applying every serve gate:
77
- * search-less requests only (the build captured the bare pathname; a
78
- * search-bearing URL has its own shell identity owned by runtime capture),
79
- * version validity, payload integrity, and tag-invalidation markers. Returns
80
- * null on any gate failure — the caller degrades to the ordinary MISS path
81
- * (axis 1 + runtime capture), never a broken serve.
82
- */
83
- export declare function lookupBuildShell(url: URL, buildVersion: string, store: SegmentCacheStore, dev?: DevShellLookup): Promise<BuildShellHit | null>;
84
- export {};
@@ -1,27 +0,0 @@
1
- /**
2
- * Default upper bound on the capture prerender wait before forcing the abort
3
- * that freezes the shell — the ONLY wall-clock on the capture path, and a
4
- * pathological guard: it should never fire once the caller's `quiesce` is a
5
- * task-quantized, frozen-byte signal (the capture gate in shell-capture.ts).
6
- *
7
- * Leaf module on purpose (imports nothing): shell-capture.ts re-exports it
8
- * (single import site for the rsc graph — shell-build-manifest.ts sizes the
9
- * dev fetch envelope from that re-export) and ssr/index.tsx uses it as
10
- * captureShellHTML's own fallback; the ssr graph must not pull the capture
11
- * orchestration module for one number.
12
- *
13
- * 15s, raised from 5s: captures are background work (waitUntil), so the budget
14
- * costs latency-to-HIT only — never a served response — and 5s spuriously
15
- * refused legitimately-slow deferred shell material (a real storefront's meta
16
- * chains settle at ~7s). Ceiling math: workerd's waitUntil lifetime is ~30s
17
- * past response completion, and a guaranteed two-attempt envelope needs
18
- * 2x budget + the in-place retry delay + store I/O, i.e. budget <= ~14s. The
19
- * 15s default deliberately sits just past that: attempt 1 always gets its
20
- * full 15s, but when it consumed the whole budget the in-place RETRY may be
21
- * truncated by the platform kill on workerd — degrading to the existing
22
- * best-effort contract (the key stays MISS; a later request re-captures).
23
- * Node/dev and build-time captures have no waitUntil ceiling. The per-route
24
- * `ppr.captureTimeout` knob remains for tightening below the default. See
25
- * docs/design/ppr-shell-resume.md (Cost model).
26
- */
27
- export declare const SHELL_CAPTURE_MAX_WAIT_MS = 15000;
@@ -1,374 +0,0 @@
1
- /**
2
- * PPR shell capture orchestration (Axis 2, see docs/design/ppr-shell-resume.md).
3
- *
4
- * Capture does NOT flow through the HTTP middleware pipeline. The integrated PPR
5
- * serve path (rsc-rendering.ts + shell-serve.ts) builds a ShellCaptureDescriptor
6
- * from the route's `ppr` path option after the served response is built and calls
7
- * scheduleShellCapture. The capture then runs as a background task that re-derives
8
- * the page via `ctx.router.match()` under its OWN derived request context — fresh
9
- * handle store, `_shellCaptureRun: true` so loaders mask (loader-mask.ts) and every
10
- * loading() subtree postpones. The render is MIXED-CHAIN: cache()'d segments replay
11
- * from ring 3, uncached segments execute their handlers fresh. It drives the static
12
- * prerender to a quiescent shell, aborts to freeze the prelude + postponed state,
13
- * and stores the pair via putShell. Because it uses match() rather than the HTTP
14
- * pipeline, the middleware chain (auth, logging) never re-runs — it already ran for
15
- * the triggering request, and the derived context inherits its post-middleware
16
- * state (variables, cache store). Guarding is serve-time.
17
- */
18
- import { SHELL_CAPTURE_MAX_WAIT_MS } from "./shell-capture-constants.js";
19
- import { type RequestContext } from "../server/request-context.js";
20
- import { type HandleStore } from "../server/handle-store.js";
21
- import type { SegmentCacheStore } from "../cache/types.js";
22
- import type { HandlerContext } from "./handler-context.js";
23
- import type { SSRModule } from "./types.js";
24
- /**
25
- * Default capture budget. Canonical value, raise rationale, and ceiling math
26
- * live on the leaf module (shell-capture-constants.ts, importable from the ssr
27
- * graph too). Re-exported here so shell-build-manifest.ts's envelope math
28
- * keeps its existing import site and cannot drift from the capture.
29
- */
30
- export { SHELL_CAPTURE_MAX_WAIT_MS };
31
- /**
32
- * Delay before the in-place retry of a capture that produced no usable shell.
33
- *
34
- * The dominant reason a first capture comes back with a trivial prelude is a
35
- * COLD render: in dev the module transform graph (route modules, the SSR/Flight
36
- * transforms) is being built lazily and outlasts the task-quantized quiesce, so
37
- * the shell has not finished rendering when we freeze it; on a cold worker the
38
- * first invocation pays the same one-time cost. The first attempt WARMS that
39
- * graph, so a second attempt a short beat later usually completes the shell in
40
- * the SAME background task — no extra HTTP request needed. Short enough to feel
41
- * instant, long enough for the module graph to settle. See
42
- * docs/design/ppr-shell-resume.md ("Capture retry-in-place").
43
- */
44
- declare const SHELL_CAPTURE_RETRY_DELAY_MS = 400;
45
- /** Sleep `ms`, unref'd so a Node dev process is never kept alive by the timer. */
46
- declare function delay(ms: number): Promise<void>;
47
- /**
48
- * Refused-capture backoff bounds. The window is EXPONENTIAL in the consecutive
49
- * failure count: `min(BASE * 2^(failures-1), ceiling)` — 1s, 2s, 4s, … up to the
50
- * mode's ceiling (60s in production, {@link REFUSED_CAPTURE_DEV_MAX_MS} in dev).
51
- *
52
- * Why exponential and not a flat 60s: a flat long window conflates two very
53
- * different failures. A STRUCTURALLY ineligible route (no loading(), a cookie
54
- * reader) fails forever and wants the long 60s cap. But a cold-but-ELIGIBLE route
55
- * can also fail the in-place retry under a truly cold graph (dev module transform,
56
- * or a cold worker under parallel load) — and it must recover FAST, on the next
57
- * request or two, not be frozen for 60s (that would re-break the very cold-start DX
58
- * the retry fixes; it bit the cloudflare dev e2e). Escalating from 1s means the
59
- * eligible route re-probes almost immediately (warm now → HIT and clear), while the
60
- * doomed route ramps to the ceiling within a handful of failures. Either way an
61
- * app-wide mount never re-renders a doomed route on EVERY request.
62
- */
63
- declare const REFUSED_CAPTURE_BASE_MS = 1000;
64
- declare const REFUSED_CAPTURE_MAX_MS = 60000;
65
- /**
66
- * DEV-only backoff ceiling. In dev the 60s production cap is pure harm: the
67
- * dominant no-shell cause is a COLD module graph (route modules, SSR/Flight
68
- * transforms built lazily), and the very attempt that failed WARMS that graph, so
69
- * the next attempt a beat later usually completes the shell. Capping the dev window
70
- * low keeps a cold-but-eligible route re-probing every ~2s instead of freezing for
71
- * up to 60s once the exponential climbs (1s→2s→4s→…→60s). A 60s freeze outlasts the
72
- * e2e warm windows on cold CI runners: the capture races an unfinished shell,
73
- * escalates the backoff past the poll window, and every subsequent request inside
74
- * that window is skipped as backed-off — an eternal MISS for the test even though
75
- * the modules are warm by then. Production keeps the full 60s cap: there the
76
- * no-shell cause is far more likely to be a genuinely ineligible route (no
77
- * loading()), which SHOULD be re-probed rarely. See #652 (item 3) and
78
- * docs/design/ppr-shell-resume.md ("Refused-capture backoff").
79
- */
80
- declare const REFUSED_CAPTURE_DEV_MAX_MS = 2000;
81
- /** True iff `key` is still inside its (exponential) backoff window. */
82
- declare function isCaptureBackedOff(key: string): boolean;
83
- /**
84
- * Record a refused/failed capture, escalating the backoff window exponentially up
85
- * to the current mode's ceiling. The failure count keeps climbing across attempts
86
- * (so a genuinely doomed route still ramps toward its cap), but the WINDOW is
87
- * clamped: 60s in production, {@link REFUSED_CAPTURE_DEV_MAX_MS} in dev so a
88
- * cold-but-eligible route re-probes fast instead of freezing out the e2e warm
89
- * window on a cold CI runner (#652 item 3).
90
- */
91
- declare function markCaptureBackoff(key: string): void;
92
- /** Clear any backoff for a key that just captured successfully. */
93
- declare function clearCaptureBackoff(key: string): void;
94
- /**
95
- * Default cap (serialized UTF-8 bytes) on the capture data snapshot riding
96
- * inside a shell entry, when the route's `ppr` option does not set
97
- * `maxSnapshotBytes`. 8 MiB: the snapshot shares the stored envelope with the
98
- * base64 prelude and the postponed blob, and the tightest store value limit is
99
- * Cloudflare KV's 25 MiB — 8 MiB of snapshot leaves the envelope well under it
100
- * while still fitting any sane pinned-ring payload. Applied ONLY in
101
- * captureAndStoreShell (the single defaulting site — resolvePprConfig passes
102
- * the option through undefaulted), so every producer and direct caller gets
103
- * the same policy. Over the cap the snapshot is skipped (shell still stored;
104
- * pinned reads drift — see PartialPrerenderProps.maxSnapshotBytes).
105
- */
106
- export declare const DEFAULT_PPR_MAX_SNAPSHOT_BYTES: number;
107
- /**
108
- * One structured event from the background capture pipeline, mirroring the
109
- * CFCacheReadDebugEvent pattern (cache/cf/cf-cache-types.ts): typed fields an
110
- * operator can assert against, emitted per attempt and per skip, so the
111
- * stored / no-shell / refused / backed-off lifecycle is observable outside
112
- * dev console warnings. Configured via `createRouter({ debugShellCapture })`.
113
- */
114
- export interface ShellCaptureDebugEvent {
115
- /** Shell cache key the event is about. */
116
- key: string;
117
- /**
118
- * What happened:
119
- * - stored / redirect / no-shell / refused: one capture ATTEMPT's outcome
120
- * (see CaptureAttemptOutcome for the semantics of each)
121
- * - error: the capture task failed with a genuine error (also routed through
122
- * reportCacheError; the key is backed off)
123
- * - skip-in-flight: scheduleShellCapture found a capture already running for
124
- * the key (stampede guard) and scheduled nothing
125
- * - skip-backoff: the key is inside its refused-capture backoff window and
126
- * the capture was not attempted
127
- * - backoff: the key entered (or escalated) backoff after a terminal
128
- * no-shell — carries the new backoff state
129
- */
130
- outcome: "stored" | "redirect" | "no-shell" | "refused" | "error" | "skip-in-flight" | "skip-backoff" | "backoff";
131
- /** Attempt number (1 = first, 2 = in-place retry). Absent on skips. */
132
- attempt?: number;
133
- /** Wall-clock ms of the whole attempt (barrier + render + drain + put). */
134
- attemptMs?: number;
135
- /**
136
- * Wall-clock ms the pre-render WRITE BARRIER waited on the foreground
137
- * request's deferred cache writes (bounded by SHELL_CAPTURE_WRITE_BARRIER_MS).
138
- */
139
- barrierWaitMs?: number;
140
- /**
141
- * Wall-clock ms spent awaiting the capture's own deferred cache writes
142
- * before the snapshot drain (bounded by SHELL_SNAPSHOT_WRITE_SETTLE_MS).
143
- */
144
- writeSettleMs?: number;
145
- /** Stored prelude size in bytes (pre-base64). */
146
- preludeBytes?: number;
147
- /** Serialized snapshot size in UTF-8 bytes. Absent when nothing was recorded. */
148
- snapshotBytes?: number;
149
- /** True when the snapshot exceeded maxSnapshotBytes and was dropped. */
150
- snapshotSkipped?: boolean;
151
- /** Consecutive failure count in the key's backoff entry, when one exists. */
152
- backoffFailures?: number;
153
- /** Ms remaining in the key's backoff window, when one exists. */
154
- backoffRemainingMs?: number;
155
- }
156
- /**
157
- * Debug sink for the capture pipeline, mirroring {@link CFCacheDebug}: `true`
158
- * logs each event to console (visible via `wrangler tail`), a function
159
- * receives the events for programmatic capture. Off by default.
160
- */
161
- export type ShellCaptureDebug = boolean | ((event: ShellCaptureDebugEvent) => void);
162
- /**
163
- * Compact single-line form of an event's fields, shared by the console sink
164
- * and the dev Server-Timing mirror's `desc` (rsc-rendering). Plain
165
- * alphanumerics/`=`/`-`/`()` only, so it needs no quoted-string escaping.
166
- */
167
- export declare function describeShellCaptureEvent(event: ShellCaptureDebugEvent): string;
168
- /**
169
- * Resolve the `debugShellCapture` router option to a callable sink, or
170
- * undefined when off. The INTERNAL_RANGO_DEBUG env-flag fallback lives HERE
171
- * (not at a call site) so every producer that resolves a sink inherits it;
172
- * an explicit `false` wins over the env flag.
173
- */
174
- export declare function resolveShellCaptureDebugSink(option: ShellCaptureDebug | undefined): ((event: ShellCaptureDebugEvent) => void) | undefined;
175
- /**
176
- * Consume (read-and-clear) the buffered terminal capture event for `key`, so
177
- * one capture reports into exactly one later response's Server-Timing.
178
- */
179
- export declare function takeCaptureDebugEventForTiming(key: string): ShellCaptureDebugEvent | undefined;
180
- export interface FlightCaptureGate {
181
- /** Identity passthrough of the source stream; feed this to captureShellHTML. */
182
- stream: ReadableStream<Uint8Array>;
183
- /**
184
- * Resolves once the source has been byte-quiet for FLIGHT_QUIET_HOPS macrotask
185
- * hops (or has closed — the DATA variant). At that instant the gate FREEZES:
186
- * no further source byte reaches the fizz side, and the readable is left open
187
- * (never closed / errored) so fizz postpones the still-pending references
188
- * instead of seeing "Connection closed".
189
- */
190
- quiesce: Promise<void>;
191
- /**
192
- * Stop the internal macrotask-hop loop. captureShellHTML's maxWaitMs bounds the
193
- * overall wait; dispose() is the clean shutdown for the pathological case where
194
- * the source never goes byte-quiet (quiesce never fires), so the hop loop would
195
- * otherwise keep rescheduling after captureShellHTML has already aborted and
196
- * returned.
197
- */
198
- dispose(): void;
199
- }
200
- /**
201
- * Wrap the capture Flight stream so the fizz shell prerender reads a stream that
202
- * (a) forwards the shell rows unchanged, (b) resolves `quiesce` after the rows go
203
- * byte-silent for FLIGHT_QUIET_HOPS macrotask hops, and (c) FREEZES at that
204
- * instant — dropping any later byte without closing or erroring the readable, so
205
- * the pending masked-loader references stay pending and fizz postpones them (the
206
- * "unclosing stream" property, here for free because the masked rows never emit).
207
- * Freezing also guarantees no post-quiesce byte — including an error row from any
208
- * later abort/cancel of the underlying render — can corrupt the frozen prelude.
209
- *
210
- * Quiet is measured in TASKS, not wall-clock: after the first byte a macrotask
211
- * hop loop compares a byte counter each turn and fires after K quiet turns. The
212
- * hop timers are unref'd so they never keep a Node process alive, and the source
213
- * closing (no holes) fires quiesce immediately for the DATA variant — the
214
- * TransformStream then closes the readable, so fizz completes with postponed null.
215
- *
216
- * `holdUntil` keeps the gate from FREEZING before shell material with real latency
217
- * has emitted. The hole doctrine bakes TOP-LEVEL pushed handle promises into the
218
- * shell (resolvedHandleStream awaits them before the handles row emits), but a
219
- * pushed promise that takes longer than the quiet window would otherwise be frozen
220
- * out — the handles row would never reach fizz and the prelude would come back
221
- * trivial. While `holdUntil` is pending, byte-quiet detection keeps running but the
222
- * gate neither fires nor freezes; once it resolves, the quiet counter restarts so a
223
- * burst of rows unblocked by it (the resolved handles row) is still captured. It
224
- * never delays a HOLE from postponing: holes are pending promises that emit no
225
- * bytes, so holding the gate open longer only ever admits shell rows. Bounded by
226
- * captureShellHTML's maxWaitMs like every other quiesce input.
227
- */
228
- export declare function gateFlightForCapture(source: ReadableStream<Uint8Array>, quietHops?: number, holdUntil?: Promise<unknown>): FlightCaptureGate;
229
- /**
230
- * The background shell-capture descriptor: everything the capture task needs to
231
- * store the shell. Built by the integrated PPR serve path (rsc-rendering.ts) from
232
- * the route's `ppr` path option (`PartialPrerenderProps`) and the app-level cache
233
- * store, and passed to scheduleShellCapture directly — it is NOT threaded through
234
- * the request context. `tags` carries the route's OPERATIONAL `ppr.tags`; the
235
- * capture UNIONS them with the shell's own auto-collected (non-loader) request
236
- * tags from its derived render (the collected set stays authoritative). That
237
- * union happens at the putShell WRITE BARRIER in captureAndStoreShell — after the
238
- * capture quiesces — not at stream construction, so a tag recorded after an await
239
- * in async shell content is still collected (issue #676). `store` is the same
240
- * store the serve path resolved for its getShell read (requestCtx._cacheStore),
241
- * so the capture writes where the serve reads.
242
- */
243
- export interface ShellCaptureDescriptor {
244
- key: string;
245
- /**
246
- * The RSC handler's build version (HandlerContext.version), stamped into the
247
- * stored entry as ShellCacheEntry.buildVersion — the serve-side
248
- * isValidShellHit gate compares it against the running build so a persistent
249
- * store can never resume a stale build's postponed blob.
250
- */
251
- buildVersion: string;
252
- ttl?: number;
253
- swr?: number;
254
- tags?: string[];
255
- /**
256
- * Per-route capture settle budget in ms (`ppr.captureTimeout`, resolved by
257
- * resolvePprConfig). Feeds captureShellHTML's maxWaitMs — the ONE deadline
258
- * bounding the whole capture, so it covers BOTH the fizz prerender AND the
259
- * deferred-material settle window (the handlesBaked/loader-container
260
- * holdUntil that keeps the gate from freezing while top-level pushes are
261
- * pending). Undefined = SHELL_CAPTURE_MAX_WAIT_MS (15_000).
262
- */
263
- captureTimeout?: number;
264
- store?: SegmentCacheStore<any>;
265
- /** Gates the concise per-attempt capture breadcrumbs (INTERNAL_RANGO_DEBUG). */
266
- debug?: boolean;
267
- /**
268
- * Cap (serialized UTF-8 bytes) on the entry's capture data snapshot; over it
269
- * the snapshot is skipped and the shell stored without it (reported once per
270
- * key). Absent = DEFAULT_PPR_MAX_SNAPSHOT_BYTES, applied in
271
- * captureAndStoreShell — the single defaulting site.
272
- */
273
- maxSnapshotBytes?: number;
274
- /**
275
- * Structured capture-pipeline debug sink, resolved from
276
- * `createRouter({ debugShellCapture })` (or INTERNAL_RANGO_DEBUG) via
277
- * {@link resolveShellCaptureDebugSink}. Receives one
278
- * {@link ShellCaptureDebugEvent} per attempt/skip.
279
- */
280
- debugSink?: (event: ShellCaptureDebugEvent) => void;
281
- }
282
- /**
283
- * Schedule the background shell capture for a served document. Stampede-guarded:
284
- * one capture per key per isolate. Runs via runBackground (waitUntil on workerd,
285
- * fire-and-forget in Node dev), so the served response is never blocked on it. Any
286
- * error is routed through reportCacheError — capture is best-effort; a failure just
287
- * means the next request recaptures.
288
- *
289
- * Eligibility (nonce/allReady/partial/status/strategy) is decided by the caller
290
- * (rsc-rendering.ts maybeScheduleShellCapture); this function only owns the
291
- * stampede guard and the background dispatch.
292
- */
293
- export declare function scheduleShellCapture(ctx: HandlerContext<any>, request: Request, env: any, url: URL, reqCtx: RequestContext<any>, ssrModule: SSRModule, descriptor: ShellCaptureDescriptor): void;
294
- /**
295
- * The outcome of one capture attempt.
296
- * - `stored`: a usable shell was captured (and a putShell was attempted; a store
297
- * I/O failure is reported separately and does NOT make the attempt retryable —
298
- * the capture itself worked).
299
- * - `redirect`: the matched route redirects, so there is no shell to capture.
300
- * - `no-shell`: the prelude came back trivial (no <body>) OR captureShellHTML
301
- * rejected with our own abort. This is the only RETRYABLE outcome.
302
- */
303
- type CaptureAttemptOutcome = "stored" | "redirect" | "no-shell" | "refused";
304
- /**
305
- * Per-attempt observability fields, filled along the capture path (barrier in
306
- * attemptCapture, the rest in captureAndStoreShell) and folded into the
307
- * attempt's {@link ShellCaptureDebugEvent} by runShellCapture. A plain mutable
308
- * bag, not a return value: captureAndStoreShell's outcome type stays a string
309
- * union its existing callers (producer B, tests) consume unchanged.
310
- */
311
- interface CaptureAttemptStats {
312
- barrierWaitMs?: number;
313
- writeSettleMs?: number;
314
- preludeBytes?: number;
315
- snapshotBytes?: number;
316
- snapshotSkipped?: boolean;
317
- }
318
- /**
319
- * Run the shell capture with a single in-place retry, then store the result.
320
- *
321
- * Each attempt re-derives EVERYTHING (fresh context, fresh router.match, fresh
322
- * Flight render) via {@link attemptCapture} — a capture consumes its handle store,
323
- * its request-tag set, and its one-shot Flight stream, so none of them are
324
- * reusable across attempts. A first attempt that comes back `no-shell` is almost
325
- * always a cold render (dev module transform / cold worker) that had not finished
326
- * when we froze the shell; the attempt itself warmed the module graph, so a second
327
- * attempt a short beat later usually completes the shell in the SAME background
328
- * task. That kills the old multi-request warmup where the caller had to re-issue
329
- * several HTTP requests before a capture stuck. We retry ONLY on `no-shell` (and a
330
- * defensively-caught abort); a genuine render error is NOT retried — it propagates
331
- * to scheduleShellCapture's reportCacheError. See docs/design/ppr-shell-resume.md.
332
- *
333
- * `retryDelayMs` is a parameter (defaulting to the module const) so unit tests can
334
- * drive the retry without a real 400ms wall-clock wait.
335
- */
336
- declare function runShellCapture(ctx: HandlerContext<any>, request: Request, env: any, url: URL, reqCtx: RequestContext<any>, ssrModule: SSRModule, descriptor: ShellCaptureDescriptor, retryDelayMs?: number): Promise<CaptureAttemptOutcome>;
337
- /**
338
- * The derived capture context and its fresh (mask-funneled) handle store,
339
- * shared by BOTH shell producers: the runtime background capture
340
- * (attemptCapture, producer A) and the build-time prerender shell capture
341
- * (prerender/build-shell-capture.ts, producer B — issue #699). One
342
- * implementation so the capture semantics — the nested-thenable mask funnel,
343
- * handler-liveness bookkeeping, snapshot recording, the implicit doc-cache
344
- * scope — cannot drift between producers.
345
- */
346
- export interface CaptureContextDerivation {
347
- derivedCtx: RequestContext;
348
- freshHandleStore: HandleStore;
349
- }
350
- /**
351
- * Derive the capture request context from a base context. Producer A passes
352
- * the foreground request's post-middleware context (the derived context
353
- * inherits its variables/env/cookie machinery through the prototype);
354
- * producer B passes a synthetic build-request context created by
355
- * createRequestContext over the build env, with a fresh MemorySegmentCacheStore
356
- * as `_cacheStore` so the recording/snapshot machinery arms identically.
357
- */
358
- export declare function deriveShellCaptureContext(reqCtx: RequestContext<any>, descriptor: Pick<ShellCaptureDescriptor, "ttl" | "swr">): CaptureContextDerivation;
359
- /**
360
- * Seal handles, derive the quiesce signal, prerender + abort via the SSR module's
361
- * captureShellHTML, and store the result. Returns the attempt outcome (the caller
362
- * owns retry/warn decisions — this function no longer warns). Never throws out of
363
- * the store write: a failed putShell is routed through reportCacheError so the
364
- * background task stays best-effort, and the attempt still counts as `stored` (the
365
- * capture worked; only the store I/O failed). `ssrModule.captureShellHTML` MUST be
366
- * present (eligibility is checked before scheduling).
367
- *
368
- * A `no-shell` result (trivial prelude, or a defensively-caught abort) is the only
369
- * retryable outcome; a genuine (non-abort) captureShellHTML error propagates so it
370
- * reaches reportCacheError and is NOT retried.
371
- */
372
- declare function captureAndStoreShell(ssrModule: SSRModule, rscStream: ReadableStream<Uint8Array>, handleStore: HandleStore, reqCtx: RequestContext<any>, capture: ShellCaptureDescriptor, stats?: CaptureAttemptStats): Promise<Exclude<CaptureAttemptOutcome, "redirect">>;
373
- export { runShellCapture, captureAndStoreShell, delay, SHELL_CAPTURE_RETRY_DELAY_MS, };
374
- export { isCaptureBackedOff, markCaptureBackoff, clearCaptureBackoff, REFUSED_CAPTURE_BASE_MS, REFUSED_CAPTURE_MAX_MS, REFUSED_CAPTURE_DEV_MAX_MS, };