@rangojs/router 0.1.1 → 0.4.0

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 (473) hide show
  1. package/README.md +2 -1
  2. package/dist/types/browser/prefetch/default-strategy.d.ts +22 -0
  3. package/dist/types/browser/prefetch/runtime.d.ts +0 -1
  4. package/dist/types/browser/react/Link.d.ts +8 -11
  5. package/dist/types/browser/types.d.ts +5 -0
  6. package/dist/types/cache/document-cache.d.ts +3 -1
  7. package/dist/types/cache/types.d.ts +10 -3
  8. package/dist/types/route-definition/helpers-types.d.ts +6 -6
  9. package/dist/types/router/match-handlers.d.ts +2 -3
  10. package/dist/types/router/prefetch-default.d.ts +28 -0
  11. package/dist/types/router/router-interfaces.d.ts +7 -0
  12. package/dist/types/router/router-options.d.ts +30 -0
  13. package/dist/types/router/segment-resolution/view-transition-default.d.ts +3 -4
  14. package/dist/types/router/transition-when.d.ts +13 -0
  15. package/dist/types/rsc/capture-queue.d.ts +6 -0
  16. package/dist/types/rsc/shell-capture.d.ts +15 -7
  17. package/dist/types/rsc/shell-serve.d.ts +6 -3
  18. package/dist/types/rsc/transition-gate.d.ts +10 -14
  19. package/dist/types/rsc/types.d.ts +2 -0
  20. package/dist/types/server/request-context.d.ts +5 -1
  21. package/dist/types/testing/e2e/index.d.ts +3 -3
  22. package/dist/types/testing/e2e/page-helpers.d.ts +24 -0
  23. package/dist/types/testing/index.d.ts +2 -2
  24. package/dist/types/testing/run-transition-when.d.ts +6 -5
  25. package/dist/types/testing/shell-status.d.ts +23 -3
  26. package/dist/types/types/segments.d.ts +27 -22
  27. package/dist/types/urls/path-helper-types.d.ts +4 -3
  28. package/dist/types.backup/__internal.d.ts +127 -0
  29. package/dist/types.backup/bin/rango.d.ts +1 -0
  30. package/dist/types.backup/browser/action-coordinator.d.ts +57 -0
  31. package/dist/types.backup/browser/action-fence.d.ts +33 -0
  32. package/dist/types.backup/browser/app-shell.d.ts +34 -0
  33. package/dist/types.backup/browser/app-version.d.ts +6 -0
  34. package/dist/types.backup/browser/connection-warmup.d.ts +31 -0
  35. package/dist/types.backup/browser/cookie-name.d.ts +66 -0
  36. package/dist/types.backup/browser/event-controller.d.ts +221 -0
  37. package/dist/types.backup/browser/history-state.d.ts +26 -0
  38. package/dist/types.backup/browser/index.d.ts +1 -0
  39. package/dist/types.backup/browser/intercept-utils.d.ts +30 -0
  40. package/dist/types.backup/browser/invalidate-client-cache.d.ts +17 -0
  41. package/dist/types.backup/browser/link-interceptor.d.ts +43 -0
  42. package/dist/types.backup/browser/logging.d.ts +33 -0
  43. package/dist/types.backup/browser/merge-segment-loaders.d.ts +38 -0
  44. package/dist/types.backup/browser/navigation-bridge.d.ts +27 -0
  45. package/dist/types.backup/browser/navigation-client.d.ts +17 -0
  46. package/dist/types.backup/browser/navigation-store-handle.d.ts +25 -0
  47. package/dist/types.backup/browser/navigation-store.d.ts +95 -0
  48. package/dist/types.backup/browser/navigation-transaction.d.ts +75 -0
  49. package/dist/types.backup/browser/network-error-handler.d.ts +35 -0
  50. package/dist/types.backup/browser/partial-update.d.ts +61 -0
  51. package/dist/types.backup/browser/prefetch/cache.d.ts +183 -0
  52. package/dist/types.backup/browser/prefetch/fetch.d.ts +52 -0
  53. package/dist/types.backup/browser/prefetch/observer.d.ts +27 -0
  54. package/dist/types.backup/browser/prefetch/policy.d.ts +13 -0
  55. package/dist/types.backup/browser/prefetch/queue.d.ts +48 -0
  56. package/dist/types.backup/browser/prefetch/resource-ready.d.ts +28 -0
  57. package/dist/types.backup/browser/rango-state.d.ts +52 -0
  58. package/dist/types.backup/browser/react/Link.d.ts +140 -0
  59. package/dist/types.backup/browser/react/NavigationProvider.d.ts +88 -0
  60. package/dist/types.backup/browser/react/ScrollRestoration.d.ts +78 -0
  61. package/dist/types.backup/browser/react/context.d.ts +54 -0
  62. package/dist/types.backup/browser/react/filter-segment-order.d.ts +35 -0
  63. package/dist/types.backup/browser/react/index.d.ts +1 -0
  64. package/dist/types.backup/browser/react/location-state-shared.d.ts +162 -0
  65. package/dist/types.backup/browser/react/location-state.d.ts +29 -0
  66. package/dist/types.backup/browser/react/mount-context.d.ts +23 -0
  67. package/dist/types.backup/browser/react/nonce-context.d.ts +14 -0
  68. package/dist/types.backup/browser/react/shallow-equal.d.ts +5 -0
  69. package/dist/types.backup/browser/react/use-action.d.ts +61 -0
  70. package/dist/types.backup/browser/react/use-handle.d.ts +21 -0
  71. package/dist/types.backup/browser/react/use-href.d.ts +32 -0
  72. package/dist/types.backup/browser/react/use-link-status.d.ts +36 -0
  73. package/dist/types.backup/browser/react/use-mount.d.ts +24 -0
  74. package/dist/types.backup/browser/react/use-navigation.d.ts +15 -0
  75. package/dist/types.backup/browser/react/use-params.d.ts +21 -0
  76. package/dist/types.backup/browser/react/use-pathname.d.ts +13 -0
  77. package/dist/types.backup/browser/react/use-reverse.d.ts +40 -0
  78. package/dist/types.backup/browser/react/use-router.d.ts +23 -0
  79. package/dist/types.backup/browser/react/use-search-params.d.ts +19 -0
  80. package/dist/types.backup/browser/react/use-segments.d.ts +29 -0
  81. package/dist/types.backup/browser/response-adapter.d.ts +58 -0
  82. package/dist/types.backup/browser/rsc-router.d.ts +141 -0
  83. package/dist/types.backup/browser/scroll-restoration.d.ts +103 -0
  84. package/dist/types.backup/browser/segment-reconciler.d.ts +74 -0
  85. package/dist/types.backup/browser/segment-structure-assert.d.ts +16 -0
  86. package/dist/types.backup/browser/server-action-bridge.d.ts +29 -0
  87. package/dist/types.backup/browser/types.d.ts +530 -0
  88. package/dist/types.backup/browser/validate-redirect-origin.d.ts +28 -0
  89. package/dist/types.backup/build/collect-fallback-refs.d.ts +5 -0
  90. package/dist/types.backup/build/generate-manifest.d.ts +100 -0
  91. package/dist/types.backup/build/generate-route-types.d.ts +8 -0
  92. package/dist/types.backup/build/index.d.ts +21 -0
  93. package/dist/types.backup/build/prefix-tree-utils.d.ts +56 -0
  94. package/dist/types.backup/build/route-trie.d.ts +89 -0
  95. package/dist/types.backup/build/route-types/ast-helpers.d.ts +3 -0
  96. package/dist/types.backup/build/route-types/ast-route-extraction.d.ts +13 -0
  97. package/dist/types.backup/build/route-types/codegen.d.ts +16 -0
  98. package/dist/types.backup/build/route-types/include-resolution.d.ts +74 -0
  99. package/dist/types.backup/build/route-types/param-extraction.d.ts +13 -0
  100. package/dist/types.backup/build/route-types/per-module-writer.d.ts +18 -0
  101. package/dist/types.backup/build/route-types/router-processing.d.ts +82 -0
  102. package/dist/types.backup/build/route-types/scan-filter.d.ts +17 -0
  103. package/dist/types.backup/build/route-types/source-scan.d.ts +13 -0
  104. package/dist/types.backup/build/runtime-discovery.d.ts +24 -0
  105. package/dist/types.backup/cache/background-task.d.ts +21 -0
  106. package/dist/types.backup/cache/cache-error.d.ts +71 -0
  107. package/dist/types.backup/cache/cache-key-utils.d.ts +35 -0
  108. package/dist/types.backup/cache/cache-policy.d.ts +59 -0
  109. package/dist/types.backup/cache/cache-runtime.d.ts +51 -0
  110. package/dist/types.backup/cache/cache-scope.d.ts +134 -0
  111. package/dist/types.backup/cache/cache-tag.d.ts +79 -0
  112. package/dist/types.backup/cache/cf/cf-base64.d.ts +4 -0
  113. package/dist/types.backup/cache/cf/cf-cache-constants.d.ts +105 -0
  114. package/dist/types.backup/cache/cf/cf-cache-store.d.ts +481 -0
  115. package/dist/types.backup/cache/cf/cf-cache-types.d.ts +300 -0
  116. package/dist/types.backup/cache/cf/cf-kv-utils.d.ts +22 -0
  117. package/dist/types.backup/cache/cf/cf-tag-marker-memo.d.ts +15 -0
  118. package/dist/types.backup/cache/cf/index.d.ts +3 -0
  119. package/dist/types.backup/cache/document-cache.d.ts +69 -0
  120. package/dist/types.backup/cache/handle-capture.d.ts +23 -0
  121. package/dist/types.backup/cache/handle-snapshot.d.ts +39 -0
  122. package/dist/types.backup/cache/index.d.ts +7 -0
  123. package/dist/types.backup/cache/memory-segment-store.d.ts +163 -0
  124. package/dist/types.backup/cache/profile-registry.d.ts +40 -0
  125. package/dist/types.backup/cache/read-through-swr.d.ts +60 -0
  126. package/dist/types.backup/cache/segment-codec.d.ts +78 -0
  127. package/dist/types.backup/cache/shell-snapshot.d.ts +162 -0
  128. package/dist/types.backup/cache/tag-invalidation.d.ts +74 -0
  129. package/dist/types.backup/cache/taint.d.ts +71 -0
  130. package/dist/types.backup/cache/types.d.ts +407 -0
  131. package/dist/types.backup/cache/vercel/index.d.ts +1 -0
  132. package/dist/types.backup/cache/vercel/vercel-cache-store.d.ts +267 -0
  133. package/dist/types.backup/client.d.ts +184 -0
  134. package/dist/types.backup/client.rsc.d.ts +39 -0
  135. package/dist/types.backup/cloudflare/index.d.ts +7 -0
  136. package/dist/types.backup/cloudflare/tracing.d.ts +53 -0
  137. package/dist/types.backup/component-utils.d.ts +46 -0
  138. package/dist/types.backup/components/DefaultDocument.d.ts +13 -0
  139. package/dist/types.backup/context-var.d.ts +84 -0
  140. package/dist/types.backup/debug.d.ts +57 -0
  141. package/dist/types.backup/decode-loader-results.d.ts +5 -0
  142. package/dist/types.backup/default-error-boundary.d.ts +10 -0
  143. package/dist/types.backup/defer.d.ts +89 -0
  144. package/dist/types.backup/deps/browser.d.ts +1 -0
  145. package/dist/types.backup/deps/html-stream-client.d.ts +1 -0
  146. package/dist/types.backup/deps/html-stream-server.d.ts +1 -0
  147. package/dist/types.backup/deps/rsc.d.ts +1 -0
  148. package/dist/types.backup/deps/ssr.d.ts +1 -0
  149. package/dist/types.backup/encode-kv.d.ts +35 -0
  150. package/dist/types.backup/errors.d.ts +226 -0
  151. package/dist/types.backup/escape-script.d.ts +44 -0
  152. package/dist/types.backup/handle.d.ts +93 -0
  153. package/dist/types.backup/handles/MetaTags.d.ts +17 -0
  154. package/dist/types.backup/handles/Scripts.d.ts +38 -0
  155. package/dist/types.backup/handles/breadcrumbs.d.ts +43 -0
  156. package/dist/types.backup/handles/deferred-resolution.d.ts +53 -0
  157. package/dist/types.backup/handles/is-thenable.d.ts +12 -0
  158. package/dist/types.backup/handles/meta.d.ts +43 -0
  159. package/dist/types.backup/handles/script.d.ts +139 -0
  160. package/dist/types.backup/host/cookie-handler.d.ts +8 -0
  161. package/dist/types.backup/host/errors.d.ts +40 -0
  162. package/dist/types.backup/host/index.d.ts +33 -0
  163. package/dist/types.backup/host/pattern-matcher.d.ts +30 -0
  164. package/dist/types.backup/host/router.d.ts +12 -0
  165. package/dist/types.backup/host/testing.d.ts +41 -0
  166. package/dist/types.backup/host/types.d.ts +148 -0
  167. package/dist/types.backup/host/utils.d.ts +20 -0
  168. package/dist/types.backup/href-client.d.ts +214 -0
  169. package/dist/types.backup/index.d.ts +112 -0
  170. package/dist/types.backup/index.rsc.d.ts +51 -0
  171. package/dist/types.backup/internal-debug.d.ts +1 -0
  172. package/dist/types.backup/loader-store.d.ts +193 -0
  173. package/dist/types.backup/loader.d.ts +18 -0
  174. package/dist/types.backup/loader.rsc.d.ts +18 -0
  175. package/dist/types.backup/missing-id-error.d.ts +1 -0
  176. package/dist/types.backup/outlet-context.d.ts +12 -0
  177. package/dist/types.backup/outlet-provider.d.ts +12 -0
  178. package/dist/types.backup/prerender/build-shell-capture.d.ts +104 -0
  179. package/dist/types.backup/prerender/param-hash.d.ts +6 -0
  180. package/dist/types.backup/prerender/shell-manifest-key.d.ts +18 -0
  181. package/dist/types.backup/prerender/store.d.ts +62 -0
  182. package/dist/types.backup/prerender.d.ts +292 -0
  183. package/dist/types.backup/redirect-origin.d.ts +55 -0
  184. package/dist/types.backup/regex-escape.d.ts +6 -0
  185. package/dist/types.backup/render-error-thrower.d.ts +13 -0
  186. package/dist/types.backup/response-utils.d.ts +35 -0
  187. package/dist/types.backup/reverse.d.ts +206 -0
  188. package/dist/types.backup/root-error-boundary.d.ts +32 -0
  189. package/dist/types.backup/route-content-wrapper.d.ts +40 -0
  190. package/dist/types.backup/route-definition/dsl-helpers.d.ts +130 -0
  191. package/dist/types.backup/route-definition/helper-factories.d.ts +22 -0
  192. package/dist/types.backup/route-definition/helpers-types.d.ts +392 -0
  193. package/dist/types.backup/route-definition/index.d.ts +7 -0
  194. package/dist/types.backup/route-definition/redirect.d.ts +48 -0
  195. package/dist/types.backup/route-definition/resolve-handler-use.d.ts +19 -0
  196. package/dist/types.backup/route-definition/use-item-types.d.ts +1 -0
  197. package/dist/types.backup/route-definition.d.ts +1 -0
  198. package/dist/types.backup/route-map-builder.d.ts +127 -0
  199. package/dist/types.backup/route-name.d.ts +27 -0
  200. package/dist/types.backup/route-types.d.ts +172 -0
  201. package/dist/types.backup/router/basename.d.ts +10 -0
  202. package/dist/types.backup/router/content-negotiation.d.ts +91 -0
  203. package/dist/types.backup/router/debug-manifest.d.ts +7 -0
  204. package/dist/types.backup/router/error-handling.d.ts +76 -0
  205. package/dist/types.backup/router/find-match.d.ts +19 -0
  206. package/dist/types.backup/router/handler-context.d.ts +41 -0
  207. package/dist/types.backup/router/instrument.d.ts +161 -0
  208. package/dist/types.backup/router/intercept-resolution.d.ts +79 -0
  209. package/dist/types.backup/router/lazy-includes.d.ts +26 -0
  210. package/dist/types.backup/router/loader-resolution.d.ts +63 -0
  211. package/dist/types.backup/router/logging.d.ts +41 -0
  212. package/dist/types.backup/router/manifest.d.ts +8 -0
  213. package/dist/types.backup/router/match-api.d.ts +19 -0
  214. package/dist/types.backup/router/match-context.d.ts +184 -0
  215. package/dist/types.backup/router/match-handlers.d.ts +49 -0
  216. package/dist/types.backup/router/match-middleware/background-revalidation.d.ts +113 -0
  217. package/dist/types.backup/router/match-middleware/cache-lookup.d.ts +113 -0
  218. package/dist/types.backup/router/match-middleware/cache-store.d.ts +112 -0
  219. package/dist/types.backup/router/match-middleware/index.d.ts +80 -0
  220. package/dist/types.backup/router/match-middleware/intercept-resolution.d.ts +116 -0
  221. package/dist/types.backup/router/match-middleware/segment-resolution.d.ts +94 -0
  222. package/dist/types.backup/router/match-pipelines.d.ts +103 -0
  223. package/dist/types.backup/router/match-result.d.ts +114 -0
  224. package/dist/types.backup/router/metrics.d.ts +6 -0
  225. package/dist/types.backup/router/middleware-types.d.ts +74 -0
  226. package/dist/types.backup/router/middleware.d.ts +116 -0
  227. package/dist/types.backup/router/navigation-snapshot.d.ts +22 -0
  228. package/dist/types.backup/router/params-util.d.ts +8 -0
  229. package/dist/types.backup/router/parse-pattern.d.ts +38 -0
  230. package/dist/types.backup/router/pattern-matching.d.ts +169 -0
  231. package/dist/types.backup/router/prefetch-cache-ttl.d.ts +27 -0
  232. package/dist/types.backup/router/prefetch-limits.d.ts +20 -0
  233. package/dist/types.backup/router/prerender-match.d.ts +50 -0
  234. package/dist/types.backup/router/preview-match.d.ts +22 -0
  235. package/dist/types.backup/router/request-classification.d.ts +104 -0
  236. package/dist/types.backup/router/revalidation.d.ts +57 -0
  237. package/dist/types.backup/router/route-snapshot.d.ts +112 -0
  238. package/dist/types.backup/router/router-context.d.ts +137 -0
  239. package/dist/types.backup/router/router-interfaces.d.ts +432 -0
  240. package/dist/types.backup/router/router-options.d.ts +738 -0
  241. package/dist/types.backup/router/router-registry.d.ts +15 -0
  242. package/dist/types.backup/router/segment-resolution/fresh.d.ts +55 -0
  243. package/dist/types.backup/router/segment-resolution/helpers.d.ts +93 -0
  244. package/dist/types.backup/router/segment-resolution/loader-cache.d.ts +33 -0
  245. package/dist/types.backup/router/segment-resolution/loader-mask.d.ts +44 -0
  246. package/dist/types.backup/router/segment-resolution/loader-snapshot.d.ts +90 -0
  247. package/dist/types.backup/router/segment-resolution/mask-nested.d.ts +53 -0
  248. package/dist/types.backup/router/segment-resolution/revalidation.d.ts +85 -0
  249. package/dist/types.backup/router/segment-resolution/static-store.d.ts +17 -0
  250. package/dist/types.backup/router/segment-resolution/streamed-handler-telemetry.d.ts +16 -0
  251. package/dist/types.backup/router/segment-resolution/view-transition-default.d.ts +28 -0
  252. package/dist/types.backup/router/segment-resolution.d.ts +3 -0
  253. package/dist/types.backup/router/segment-wrappers.d.ts +53 -0
  254. package/dist/types.backup/router/state-cookie-name.d.ts +1 -0
  255. package/dist/types.backup/router/substitute-pattern-params.d.ts +23 -0
  256. package/dist/types.backup/router/telemetry-otel.d.ts +113 -0
  257. package/dist/types.backup/router/telemetry.d.ts +215 -0
  258. package/dist/types.backup/router/timeout.d.ts +68 -0
  259. package/dist/types.backup/router/tracing.d.ts +125 -0
  260. package/dist/types.backup/router/trie-matching.d.ts +32 -0
  261. package/dist/types.backup/router/types.d.ts +98 -0
  262. package/dist/types.backup/router/url-params.d.ts +26 -0
  263. package/dist/types.backup/router.d.ts +7 -0
  264. package/dist/types.backup/rsc/capture-queue.d.ts +6 -0
  265. package/dist/types.backup/rsc/full-payload.d.ts +22 -0
  266. package/dist/types.backup/rsc/handler-context.d.ts +31 -0
  267. package/dist/types.backup/rsc/handler.d.ts +9 -0
  268. package/dist/types.backup/rsc/helpers.d.ts +213 -0
  269. package/dist/types.backup/rsc/index.d.ts +17 -0
  270. package/dist/types.backup/rsc/json-route-result.d.ts +20 -0
  271. package/dist/types.backup/rsc/loader-fetch.d.ts +14 -0
  272. package/dist/types.backup/rsc/manifest-init.d.ts +18 -0
  273. package/dist/types.backup/rsc/nonce.d.ts +28 -0
  274. package/dist/types.backup/rsc/origin-guard.d.ts +50 -0
  275. package/dist/types.backup/rsc/progressive-enhancement.d.ts +19 -0
  276. package/dist/types.backup/rsc/redirect-guard.d.ts +35 -0
  277. package/dist/types.backup/rsc/response-cache-serve.d.ts +46 -0
  278. package/dist/types.backup/rsc/response-error.d.ts +19 -0
  279. package/dist/types.backup/rsc/response-route-handler.d.ts +29 -0
  280. package/dist/types.backup/rsc/rsc-rendering.d.ts +23 -0
  281. package/dist/types.backup/rsc/runtime-warnings.d.ts +22 -0
  282. package/dist/types.backup/rsc/server-action.d.ts +68 -0
  283. package/dist/types.backup/rsc/shell-build-manifest.d.ts +84 -0
  284. package/dist/types.backup/rsc/shell-capture-constants.d.ts +27 -0
  285. package/dist/types.backup/rsc/shell-capture.d.ts +374 -0
  286. package/dist/types.backup/rsc/shell-serve.d.ts +136 -0
  287. package/dist/types.backup/rsc/ssr-setup.d.ts +48 -0
  288. package/dist/types.backup/rsc/transition-gate.d.ts +27 -0
  289. package/dist/types.backup/rsc/types.d.ts +290 -0
  290. package/dist/types.backup/runtime-env.d.ts +1 -0
  291. package/dist/types.backup/search-params.d.ts +125 -0
  292. package/dist/types.backup/segment-content-promise.d.ts +13 -0
  293. package/dist/types.backup/segment-fragments.d.ts +56 -0
  294. package/dist/types.backup/segment-loader-promise.d.ts +22 -0
  295. package/dist/types.backup/segment-system.d.ts +84 -0
  296. package/dist/types.backup/serialize.d.ts +164 -0
  297. package/dist/types.backup/server/context.d.ts +494 -0
  298. package/dist/types.backup/server/cookie-parse.d.ts +10 -0
  299. package/dist/types.backup/server/cookie-store.d.ts +107 -0
  300. package/dist/types.backup/server/fetchable-loader-store.d.ts +20 -0
  301. package/dist/types.backup/server/handle-store.d.ts +100 -0
  302. package/dist/types.backup/server/loader-registry.d.ts +32 -0
  303. package/dist/types.backup/server/request-context.d.ts +596 -0
  304. package/dist/types.backup/server/root-layout.d.ts +3 -0
  305. package/dist/types.backup/server.d.ts +15 -0
  306. package/dist/types.backup/ssr/index.d.ts +233 -0
  307. package/dist/types.backup/ssr/inject-rsc-eager.d.ts +3 -0
  308. package/dist/types.backup/ssr/preinit-client-references.d.ts +71 -0
  309. package/dist/types.backup/ssr/ssr-root.d.ts +69 -0
  310. package/dist/types.backup/static-handler.d.ts +57 -0
  311. package/dist/types.backup/testing/cache-status.d.ts +63 -0
  312. package/dist/types.backup/testing/collect-handle.d.ts +20 -0
  313. package/dist/types.backup/testing/dispatch.d.ts +123 -0
  314. package/dist/types.backup/testing/dom.entry.d.ts +15 -0
  315. package/dist/types.backup/testing/e2e/fixture.d.ts +37 -0
  316. package/dist/types.backup/testing/e2e/index.d.ts +30 -0
  317. package/dist/types.backup/testing/e2e/matchers.d.ts +17 -0
  318. package/dist/types.backup/testing/e2e/page-helpers.d.ts +62 -0
  319. package/dist/types.backup/testing/e2e/parity.d.ts +111 -0
  320. package/dist/types.backup/testing/e2e/server.d.ts +35 -0
  321. package/dist/types.backup/testing/flight-matchers.d.ts +55 -0
  322. package/dist/types.backup/testing/flight-normalize.d.ts +1 -0
  323. package/dist/types.backup/testing/flight-tree.d.ts +192 -0
  324. package/dist/types.backup/testing/flight.d.ts +115 -0
  325. package/dist/types.backup/testing/flight.entry.d.ts +27 -0
  326. package/dist/types.backup/testing/generated-routes.d.ts +66 -0
  327. package/dist/types.backup/testing/index.d.ts +52 -0
  328. package/dist/types.backup/testing/internal/context.d.ts +225 -0
  329. package/dist/types.backup/testing/internal/flight-client-globals.d.ts +1 -0
  330. package/dist/types.backup/testing/internal/seed-vars.d.ts +30 -0
  331. package/dist/types.backup/testing/render-handler.d.ts +160 -0
  332. package/dist/types.backup/testing/render-route.d.ts +246 -0
  333. package/dist/types.backup/testing/run-loader.d.ts +186 -0
  334. package/dist/types.backup/testing/run-middleware.d.ts +132 -0
  335. package/dist/types.backup/testing/run-transition-when.d.ts +77 -0
  336. package/dist/types.backup/testing/vitest-stubs/cloudflare-email.d.ts +6 -0
  337. package/dist/types.backup/testing/vitest-stubs/cloudflare-workers.d.ts +13 -0
  338. package/dist/types.backup/testing/vitest-stubs/plugin-rsc.d.ts +7 -0
  339. package/dist/types.backup/testing/vitest-stubs/version.d.ts +1 -0
  340. package/dist/types.backup/testing/vitest.d.ts +205 -0
  341. package/dist/types.backup/theme/ThemeProvider.d.ts +13 -0
  342. package/dist/types.backup/theme/ThemeScript.d.ts +45 -0
  343. package/dist/types.backup/theme/constants.d.ts +39 -0
  344. package/dist/types.backup/theme/index.d.ts +29 -0
  345. package/dist/types.backup/theme/theme-context.d.ts +21 -0
  346. package/dist/types.backup/theme/theme-script.d.ts +26 -0
  347. package/dist/types.backup/theme/types.d.ts +162 -0
  348. package/dist/types.backup/theme/use-theme.d.ts +8 -0
  349. package/dist/types.backup/types/boundaries.d.ts +93 -0
  350. package/dist/types.backup/types/cache-types.d.ts +191 -0
  351. package/dist/types.backup/types/error-types.d.ts +114 -0
  352. package/dist/types.backup/types/global-namespace.d.ts +90 -0
  353. package/dist/types.backup/types/handler-context.d.ts +658 -0
  354. package/dist/types.backup/types/index.d.ts +11 -0
  355. package/dist/types.backup/types/loader-types.d.ts +182 -0
  356. package/dist/types.backup/types/request-scope.d.ts +93 -0
  357. package/dist/types.backup/types/route-config.d.ts +105 -0
  358. package/dist/types.backup/types/route-entry.d.ts +95 -0
  359. package/dist/types.backup/types/segments.d.ts +234 -0
  360. package/dist/types.backup/types.d.ts +1 -0
  361. package/dist/types.backup/urls/include-helper.d.ts +17 -0
  362. package/dist/types.backup/urls/include-provider.d.ts +27 -0
  363. package/dist/types.backup/urls/index.d.ts +6 -0
  364. package/dist/types.backup/urls/path-helper-types.d.ts +197 -0
  365. package/dist/types.backup/urls/path-helper.d.ts +12 -0
  366. package/dist/types.backup/urls/pattern-types.d.ts +166 -0
  367. package/dist/types.backup/urls/response-types.d.ts +67 -0
  368. package/dist/types.backup/urls/type-extraction.d.ts +157 -0
  369. package/dist/types.backup/urls/urls-function.d.ts +24 -0
  370. package/dist/types.backup/urls.d.ts +1 -0
  371. package/dist/types.backup/use-loader.d.ts +150 -0
  372. package/dist/types.backup/vercel/index.d.ts +10 -0
  373. package/dist/types.backup/vercel/tracing.d.ts +70 -0
  374. package/dist/types.backup/vite/debug.d.ts +80 -0
  375. package/dist/types.backup/vite/discovery/bundle-postprocess.d.ts +12 -0
  376. package/dist/types.backup/vite/discovery/dev-prerender-cache.d.ts +65 -0
  377. package/dist/types.backup/vite/discovery/discover-routers.d.ts +17 -0
  378. package/dist/types.backup/vite/discovery/discovery-errors.d.ts +113 -0
  379. package/dist/types.backup/vite/discovery/gate-state.d.ts +79 -0
  380. package/dist/types.backup/vite/discovery/prerender-collection.d.ts +24 -0
  381. package/dist/types.backup/vite/discovery/route-types-writer.d.ts +32 -0
  382. package/dist/types.backup/vite/discovery/self-gen-tracking.d.ts +22 -0
  383. package/dist/types.backup/vite/discovery/shell-prerender-phase.d.ts +40 -0
  384. package/dist/types.backup/vite/discovery/state.d.ts +162 -0
  385. package/dist/types.backup/vite/discovery/virtual-module-codegen.d.ts +15 -0
  386. package/dist/types.backup/vite/index.d.ts +11 -0
  387. package/dist/types.backup/vite/inject-client-debug.d.ts +56 -0
  388. package/dist/types.backup/vite/plugin-types.d.ts +298 -0
  389. package/dist/types.backup/vite/plugins/cjs-to-esm.d.ts +6 -0
  390. package/dist/types.backup/vite/plugins/client-ref-dedup.d.ts +40 -0
  391. package/dist/types.backup/vite/plugins/client-ref-hashing.d.ts +35 -0
  392. package/dist/types.backup/vite/plugins/cloudflare-protocol-stub.d.ts +64 -0
  393. package/dist/types.backup/vite/plugins/expose-action-id.d.ts +18 -0
  394. package/dist/types.backup/vite/plugins/expose-id-utils.d.ts +37 -0
  395. package/dist/types.backup/vite/plugins/expose-ids/export-analysis.d.ts +19 -0
  396. package/dist/types.backup/vite/plugins/expose-ids/handler-transform.d.ts +10 -0
  397. package/dist/types.backup/vite/plugins/expose-ids/loader-transform.d.ts +8 -0
  398. package/dist/types.backup/vite/plugins/expose-ids/router-transform.d.ts +13 -0
  399. package/dist/types.backup/vite/plugins/expose-ids/types.d.ts +29 -0
  400. package/dist/types.backup/vite/plugins/expose-internal-ids.d.ts +6 -0
  401. package/dist/types.backup/vite/plugins/performance-tracks.d.ts +25 -0
  402. package/dist/types.backup/vite/plugins/refresh-cmd.d.ts +20 -0
  403. package/dist/types.backup/vite/plugins/use-cache-transform.d.ts +20 -0
  404. package/dist/types.backup/vite/plugins/vercel-output.d.ts +85 -0
  405. package/dist/types.backup/vite/plugins/version-injector.d.ts +21 -0
  406. package/dist/types.backup/vite/plugins/version-plugin.d.ts +19 -0
  407. package/dist/types.backup/vite/plugins/virtual-entries.d.ts +36 -0
  408. package/dist/types.backup/vite/plugins/virtual-stub-plugin.d.ts +7 -0
  409. package/dist/types.backup/vite/rango.d.ts +29 -0
  410. package/dist/types.backup/vite/router-discovery.d.ts +23 -0
  411. package/dist/types.backup/vite/utils/ast-handler-extract.d.ts +64 -0
  412. package/dist/types.backup/vite/utils/banner.d.ts +2 -0
  413. package/dist/types.backup/vite/utils/bundle-analysis.d.ts +28 -0
  414. package/dist/types.backup/vite/utils/client-chunks.d.ts +55 -0
  415. package/dist/types.backup/vite/utils/directive-prologue.d.ts +16 -0
  416. package/dist/types.backup/vite/utils/forward-user-plugins.d.ts +37 -0
  417. package/dist/types.backup/vite/utils/manifest-utils.d.ts +7 -0
  418. package/dist/types.backup/vite/utils/package-resolution.d.ts +6 -0
  419. package/dist/types.backup/vite/utils/prerender-utils.d.ts +32 -0
  420. package/dist/types.backup/vite/utils/shared-utils.d.ts +55 -0
  421. package/dist/vite/index.js +5 -2
  422. package/package.json +20 -21
  423. package/skills/cache-guide/SKILL.md +6 -3
  424. package/skills/catalog.json +7 -1
  425. package/skills/comparison/references/framework-comparison.md +2 -1
  426. package/skills/deployment-caching/SKILL.md +176 -0
  427. package/skills/document-cache/SKILL.md +30 -3
  428. package/skills/ppr/SKILL.md +81 -34
  429. package/skills/prerender/SKILL.md +15 -8
  430. package/skills/rango/SKILL.md +20 -17
  431. package/skills/router-setup/SKILL.md +4 -0
  432. package/skills/testing/SKILL.md +1 -1
  433. package/skills/testing/cache-prerender.md +5 -1
  434. package/skills/vercel/SKILL.md +22 -1
  435. package/skills/view-transitions/SKILL.md +12 -8
  436. package/src/browser/prefetch/default-strategy.ts +34 -0
  437. package/src/browser/prefetch/loader.ts +6 -12
  438. package/src/browser/prefetch/runtime.ts +0 -1
  439. package/src/browser/react/Link.tsx +22 -21
  440. package/src/browser/rsc-router.tsx +8 -0
  441. package/src/browser/types.ts +5 -0
  442. package/src/cache/cache-scope.ts +6 -1
  443. package/src/cache/cf/cf-cache-store.ts +4 -0
  444. package/src/cache/document-cache.ts +4 -2
  445. package/src/cache/types.ts +10 -3
  446. package/src/cache/vercel/vercel-cache-store.ts +6 -1
  447. package/src/route-definition/helpers-types.ts +6 -6
  448. package/src/router/match-handlers.ts +44 -6
  449. package/src/router/match-middleware/cache-lookup.ts +10 -3
  450. package/src/router/prefetch-default.ts +59 -0
  451. package/src/router/router-interfaces.ts +8 -0
  452. package/src/router/router-options.ts +31 -0
  453. package/src/router/segment-resolution/view-transition-default.ts +9 -5
  454. package/src/router/transition-when.ts +76 -0
  455. package/src/router.ts +7 -0
  456. package/src/rsc/capture-queue.ts +24 -1
  457. package/src/rsc/full-payload.ts +1 -0
  458. package/src/rsc/handler.ts +1 -0
  459. package/src/rsc/progressive-enhancement.ts +9 -14
  460. package/src/rsc/rsc-rendering.ts +261 -48
  461. package/src/rsc/shell-capture.ts +94 -50
  462. package/src/rsc/shell-serve.ts +9 -4
  463. package/src/rsc/transition-gate.ts +37 -40
  464. package/src/rsc/types.ts +2 -0
  465. package/src/server/request-context.ts +6 -0
  466. package/src/testing/e2e/index.ts +11 -0
  467. package/src/testing/e2e/page-helpers.ts +47 -0
  468. package/src/testing/e2e/parity.ts +13 -0
  469. package/src/testing/index.ts +9 -1
  470. package/src/testing/run-transition-when.ts +42 -9
  471. package/src/testing/shell-status.ts +92 -3
  472. package/src/types/segments.ts +27 -22
  473. package/src/urls/path-helper-types.ts +4 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rangojs/router",
3
- "version": "0.1.1",
3
+ "version": "0.4.0",
4
4
  "description": "Django-inspired RSC router with composable URL patterns",
5
5
  "keywords": [
6
6
  "react",
@@ -176,19 +176,6 @@
176
176
  "access": "public",
177
177
  "tag": "latest"
178
178
  },
179
- "scripts": {
180
- "build": "pnpm run build:types && pnpm exec esbuild src/vite/index.ts --bundle --format=esm --outfile=dist/vite/index.js --platform=node --packages=external && mkdir -p dist/vite/plugins && cp src/vite/plugins/cloudflare-protocol-loader-hook.mjs dist/vite/plugins/cloudflare-protocol-loader-hook.mjs && pnpm exec esbuild src/testing/vitest.ts --bundle --format=esm --outfile=dist/testing/vitest.js --platform=node --packages=external && pnpm exec esbuild src/bin/rango.ts --bundle --format=esm --outfile=dist/bin/rango.js --platform=node --packages=external --banner:js='#!/usr/bin/env node' && chmod +x dist/bin/rango.js",
181
- "build:types": "rm -rf dist/types && pnpm exec tsc -p tsconfig.types.json",
182
- "prepublishOnly": "pnpm build",
183
- "typecheck": "tsc --noEmit && tsc -p tsconfig.strict-check.json --noEmit && tsc -p tsconfig.augment-check.json --noEmit",
184
- "test": "playwright test",
185
- "test:ui": "playwright test --ui",
186
- "test:hmr-local": "playwright test --project=dev-warmup --project=hmr-basename --project=hmr-prerender --no-deps --workers=1 && RANGO_E2E_ROUTE_HMR_ONLY=1 playwright test --project=hmr-routes --no-deps --workers=1",
187
- "test:hmr-routes-local": "RANGO_E2E_ROUTE_HMR_ONLY=1 playwright test --project=hmr-routes --no-deps --workers=1",
188
- "test:unit": "pnpm run build:types && vitest run",
189
- "test:unit:watch": "vitest",
190
- "test:unit:rsc": "vitest run --config vitest.rsc.config.ts"
191
- },
192
179
  "dependencies": {
193
180
  "@types/debug": "^4.1.12",
194
181
  "@vitejs/plugin-rsc": "^0.5.27",
@@ -204,19 +191,19 @@
204
191
  "@opentelemetry/context-async-hooks": "^2.9.0",
205
192
  "@opentelemetry/sdk-trace-base": "^2.9.0",
206
193
  "@playwright/test": "^1.49.1",
207
- "@shared/e2e": "workspace:*",
208
194
  "@testing-library/dom": "^10.4.1",
209
195
  "@testing-library/react": "^16.3.2",
210
196
  "@types/node": "^24.10.1",
211
- "@types/react": "catalog:",
212
- "@types/react-dom": "catalog:",
197
+ "@types/react": "^19.2.7",
198
+ "@types/react-dom": "^19.2.3",
213
199
  "esbuild": "^0.28.1",
214
200
  "happy-dom": "^20.10.1",
215
201
  "jiti": "^2.7.0",
216
- "react": "catalog:",
217
- "react-dom": "catalog:",
202
+ "react": "^19.2.6",
203
+ "react-dom": "^19.2.6",
218
204
  "typescript": "^5.3.0",
219
- "vitest": "^4.1.9"
205
+ "vitest": "^4.1.9",
206
+ "@shared/e2e": "0.0.1"
220
207
  },
221
208
  "peerDependencies": {
222
209
  "@cloudflare/vite-plugin": "^1.42.1",
@@ -255,5 +242,17 @@
255
242
  },
256
243
  "engines": {
257
244
  "node": ">=24.0.0"
245
+ },
246
+ "scripts": {
247
+ "build": "pnpm run build:types && pnpm exec esbuild src/vite/index.ts --bundle --format=esm --outfile=dist/vite/index.js --platform=node --packages=external && mkdir -p dist/vite/plugins && cp src/vite/plugins/cloudflare-protocol-loader-hook.mjs dist/vite/plugins/cloudflare-protocol-loader-hook.mjs && pnpm exec esbuild src/testing/vitest.ts --bundle --format=esm --outfile=dist/testing/vitest.js --platform=node --packages=external && pnpm exec esbuild src/bin/rango.ts --bundle --format=esm --outfile=dist/bin/rango.js --platform=node --packages=external --banner:js='#!/usr/bin/env node' && chmod +x dist/bin/rango.js",
248
+ "build:types": "rm -rf dist/types && pnpm exec tsc -p tsconfig.types.json",
249
+ "typecheck": "tsc --noEmit && tsc -p tsconfig.strict-check.json --noEmit && tsc -p tsconfig.augment-check.json --noEmit",
250
+ "test": "playwright test",
251
+ "test:ui": "playwright test --ui",
252
+ "test:hmr-local": "playwright test --project=dev-warmup --project=hmr-basename --project=hmr-prerender --no-deps --workers=1 && RANGO_E2E_ROUTE_HMR_ONLY=1 playwright test --project=hmr-routes --no-deps --workers=1",
253
+ "test:hmr-routes-local": "RANGO_E2E_ROUTE_HMR_ONLY=1 playwright test --project=hmr-routes --no-deps --workers=1",
254
+ "test:unit": "pnpm run build:types && vitest run",
255
+ "test:unit:watch": "vitest",
256
+ "test:unit:rsc": "vitest run --config vitest.rsc.config.ts"
258
257
  }
259
- }
258
+ }
@@ -131,8 +131,10 @@ recompute for a merely-aging entry.
131
131
  layer.
132
132
  - **Client forward/back** is SWR after a mutation — see "Correctness &
133
133
  invalidation" → Client cache.
134
- - **Edge / document layer** uses the HTTP `stale-while-revalidate` directive; see
135
- `/document-cache`.
134
+ - **Store-backed document layer** uses the HTTP `stale-while-revalidate`
135
+ directive as policy for `createDocumentCacheMiddleware`; see
136
+ `/document-cache`. A platform CDN may independently consume the same header
137
+ and bypass the function on hits; see `/deployment-caching`.
136
138
 
137
139
  SWR softens normal TTL expiry, **not** a cross-deploy cold cache — a new build
138
140
  has no stale entry to serve (see version-segmented store keys above).
@@ -485,5 +487,6 @@ overrides — see `/loader` for the full reference.
485
487
 
486
488
  - `/caching` — cache() DSL setup, stores, nested boundaries
487
489
  - `/use-cache` — "use cache" directive details, profiles, transforms, guards
488
- - `/document-cache` — Edge caching with Cache-Control headers (different layer)
490
+ - `/document-cache` — store-backed complete-response middleware
491
+ - `/deployment-caching` — in-function versus external CDN cache boundaries
489
492
  - `/ppr` — PPR shell caching: cached HTML shell + live loader holes (different layer)
@@ -69,9 +69,15 @@
69
69
  "argumentHint": "",
70
70
  "path": "skills/defer-hydration/SKILL.md"
71
71
  },
72
+ {
73
+ "name": "deployment-caching",
74
+ "description": "Choose the deployment cache boundary for a Rango app: in-function segment/prerender/PPR caches, store-backed whole-response caching, or an external CDN cache. Use when comparing Cloudflare, Vercel, and Node deployments; deciding whether Cache-Control can reduce origin work; or reasoning about middleware, live loaders, PPR, and CDN behavior.",
75
+ "argumentHint": "[cloudflare|vercel|node]",
76
+ "path": "skills/deployment-caching/SKILL.md"
77
+ },
72
78
  {
73
79
  "name": "document-cache",
74
- "description": "Cache the whole HTTP response at the edge with Cache-Control headers. Use when caching an entire page or response at a CDN edge, setting Cache-Control headers, or cutting origin hits for public pages not for caching a single segment or function.",
80
+ "description": "Cache complete HTTP responses in Rango's configured app store with createDocumentCacheMiddleware, using Cache-Control s-maxage as policy. Use when reusing a whole HTML/RSC response, comparing the store-backed middleware with a platform CDN cache, or deciding whether full-response caching is safe.",
75
81
  "argumentHint": "[setup]",
76
82
  "path": "skills/document-cache/SKILL.md"
77
83
  },
@@ -539,7 +539,8 @@ analog but operates on loader/query reload, not RSC-segment render.
539
539
 
540
540
  ### Prefetching: stability and control
541
541
 
542
- `<Link prefetch="hover|viewport|render|adaptive|none">` (default `"none"`), plus
542
+ `<Link prefetch="hover|viewport|render|adaptive|none">` (default: the router's
543
+ `defaultPrefetch`, `"none"` in development and `"viewport"` in production), plus
543
544
  `prefetchKey` (`":source"` scopes a prefetch to the originating page for routes
544
545
  whose response branches on `currentUrl`). The distinguishing part is the stability
545
546
  gating: a queued prefetch (`viewport`/`render`) will not fire until **both** the
@@ -0,0 +1,176 @@
1
+ ---
2
+ name: deployment-caching
3
+ description: "Choose the deployment cache boundary for a Rango app: in-function segment/prerender/PPR caches, store-backed whole-response caching, or an external CDN cache. Use when comparing Cloudflare, Vercel, and Node deployments; deciding whether Cache-Control can reduce origin work; or reasoning about middleware, live loaders, PPR, and CDN behavior."
4
+ argument-hint: [cloudflare|vercel|node]
5
+ ---
6
+
7
+ # Deployment caching boundaries
8
+
9
+ Start with one question: **does the request reach Rango before shared bytes are
10
+ served?** That boundary decides whether middleware runs, whether loaders stay
11
+ live, and which invalidation system owns the result.
12
+
13
+ ## The execution matrix
14
+
15
+ | Mechanism | Stored artifact | Function/worker runs on a hit? | Rango middleware on a hit? | What stays live? |
16
+ | --------------------------------- | ----------------------------------------------- | -----------------------------: | -----------------------------------------------------------: | ------------------------------------ |
17
+ | `"use cache"` | one function result | yes | yes | caller, handlers, loaders, rendering |
18
+ | `cache()` | serialized Flight segments | yes | yes | middleware, loaders, HTML rendering |
19
+ | `Prerender()` | build-time Flight segments in the server bundle | yes | yes | middleware, loaders, HTML rendering |
20
+ | `ppr` | HTML prelude + React postponed state | yes | **yes, before shell commit** | middleware, holes, hydration payload |
21
+ | `createDocumentCacheMiddleware()` | complete response in the app cache store | yes | outer middleware runs; the hit skips its downstream pipeline | nothing downstream |
22
+ | HTTP CDN cache (`s-maxage`) | complete HTTP response outside the app | **no** | **no** | nothing |
23
+
24
+ The first five rows enter the app. The first four preserve the complete request
25
+ model; a document-cache middleware hit intentionally short-circuits its
26
+ downstream pipeline. The last row is a platform cache: on a hit it serves bytes
27
+ without invoking Rango at all.
28
+
29
+ ## Rango PPR is in-function PPR
30
+
31
+ Rango's `ppr` path option does not make the HTML shell a public static asset.
32
+ The worker or function handles every document request:
33
+
34
+ ```text
35
+ request
36
+ -> global middleware
37
+ -> route middleware
38
+ -> shell lookup
39
+ -> flush stored prelude
40
+ -> run live loaders + Flight + React resume
41
+ ```
42
+
43
+ That ordering is the security contract. A redirect, 401, tenant decision,
44
+ `ctx.dynamic()`, cookie, or response header from middleware wins before a shell
45
+ byte is committed.
46
+
47
+ There are two shell producers:
48
+
49
+ - An ordinary `ppr` route captures after a runtime MISS.
50
+ - A route that combines `Prerender()` with the `ppr` path option captures during
51
+ `vite build`, so its first production request can already be a shell HIT.
52
+
53
+ Both producers feed the same in-function serve path. Build-time shells are
54
+ content-hashed modules in the server bundle, not CDN-served HTML files.
55
+
56
+ `ppr.ttl`, `ppr.swr`, and `ppr.tags` govern that shell entry. They do **not**
57
+ emit HTTP `Cache-Control` and do not configure a platform CDN.
58
+
59
+ ## Platform deployment shapes
60
+
61
+ ### Cloudflare
62
+
63
+ The Cloudflare preset runs the RSC app in a Worker. The request reaches the
64
+ Worker at the edge, middleware runs there, and PPR shell lookup/resume stays in
65
+ that Worker. `CFCacheStore` supplies the app cache families; client assets are
66
+ served separately as assets.
67
+
68
+ ### Vercel
69
+
70
+ The Vercel preset emits static client assets plus one streaming Node Function.
71
+ HTML, Flight, prerender payloads, and PPR shells are served from that function.
72
+ `VercelCacheStore` uses Runtime Cache inside the function; Runtime Cache is not
73
+ Vercel's CDN/ISR cache.
74
+
75
+ The preset deliberately emits no Vercel `.prerender-config.json`, response
76
+ `chain`, or CDN-stitched resume function. Vercel's open-source Build Output
77
+ parser accepts a generic `chain`, but the production CDN stitching protocol is
78
+ not a documented third-party Build Output contract. More importantly, a CDN
79
+ that emits the shell before invoking Rango cannot preserve the middleware
80
+ ordering above. Parser support does not solve that semantic mismatch.
81
+
82
+ ### Generic Node
83
+
84
+ The Node preset runs the same in-function model behind your server or reverse
85
+ proxy. A CDN in front may cache complete responses when you emit shared-cache
86
+ headers, but that CDN is outside Rango and follows the HTTP CDN row in the
87
+ matrix.
88
+
89
+ ## Cache-Control is the full-response mitigation
90
+
91
+ If a response is completely public and shared, HTTP caching can eliminate more
92
+ origin work than CDN-stitched PPR:
93
+
94
+ ```http
95
+ Cache-Control: public, s-maxage=300, stale-while-revalidate=3600
96
+ ```
97
+
98
+ On a CDN hit the function does not run and no shell or dynamic tail crosses the
99
+ origin boundary. The tradeoff is exact: the CDN stores the **completed** HTML
100
+ response, including loader output, resumed holes, and hydration payload. It
101
+ does not cache only the PPR prelude.
102
+
103
+ Use shared HTTP caching only when all of these are true:
104
+
105
+ - the complete response is identical for every request sharing the cache key;
106
+ - no authorization, redirect, rate-limit, tenant, or preview middleware must
107
+ run on every request;
108
+ - no loader or rendered value contains session, cart, account, experiment, or
109
+ other per-user data;
110
+ - replaying the response headers is safe, with no per-client `Set-Cookie`;
111
+ - TTL/SWR freshness for the whole response is acceptable.
112
+
113
+ Do not use `Vary: Cookie` as a general escape hatch. It creates a variant for
114
+ every cookie combination, destroys cache reuse, and makes the safety contract
115
+ hard to audit.
116
+
117
+ ### One header, two possible consumers
118
+
119
+ `createDocumentCacheMiddleware()` parses `Cache-Control: s-maxage` as policy for
120
+ the configured app store's response family. The deployment platform may also
121
+ interpret the same header and cache the response at its CDN.
122
+
123
+ These are independent caches:
124
+
125
+ ```text
126
+ CDN HIT
127
+ -> function never runs
128
+
129
+ CDN MISS
130
+ -> function
131
+ -> Rango document-cache middleware HIT or MISS
132
+ ```
133
+
134
+ Consequences:
135
+
136
+ - `skipPaths`, `isEnabled`, and `keyGenerator` only control the Rango
137
+ middleware. They cannot guard a response already served by the CDN.
138
+ - `x-document-cache-status` reports the Rango store only when the function
139
+ executes. A CDN may replay an old status header; use the platform's own cache
140
+ header or logs to identify CDN hits.
141
+ - Platform CDN invalidation and the app store's tags/TTL are separate systems.
142
+ Do not assume `updateTag()` purges an external CDN response.
143
+
144
+ Use a platform-targeted header such as `Vercel-CDN-Cache-Control` when you need
145
+ to keep CDN policy out of browser/downstream `Cache-Control`, but the complete
146
+ response and middleware-bypass rules are unchanged. Rango's document middleware
147
+ does not parse that platform-specific header; use it when the CDN, rather than
148
+ the app store, should own the complete response.
149
+
150
+ ## Decision guide
151
+
152
+ | Requirement | Choose |
153
+ | --------------------------------------------------- | ------------------------------------------ |
154
+ | Per-request auth or request shaping | in-function caching; never shared CDN HTML |
155
+ | Stable shell with cart/session/live prices | `ppr` with live holes |
156
+ | Build-known segments with live loaders | `Prerender()` |
157
+ | Fully public response, whole-page TTL is acceptable | HTTP `s-maxage` + SWR |
158
+ | Whole response reused inside the app store | `createDocumentCacheMiddleware()` |
159
+ | One query or component is expensive | `"use cache"` |
160
+ | One route subtree is expensive | `cache()` |
161
+
162
+ For a large dynamic app, CDN-stitched PPR would mainly improve shell first-byte
163
+ latency and avoid sending the prelude from the function. It would not remove the
164
+ per-request function invocation, live loaders, Flight payload, or React resume.
165
+ If the current in-function path is already fast, preserve middleware semantics
166
+ and apply full-response CDN caching only to the smaller set of routes that are
167
+ provably public and shared.
168
+
169
+ ## Related skills
170
+
171
+ - `/ppr` — shell capture, holes, middleware commit point, invalidation
172
+ - `/prerender` — build-time Flight segments and `Prerender + ppr`
173
+ - `/document-cache` — store-backed complete-response middleware
174
+ - `/vercel` — Vercel Build Output preset and Runtime Cache wiring
175
+ - `/cloudflare` — Worker deployment and bindings
176
+ - `/cache-guide` — function, loader, and segment cache selection
@@ -1,12 +1,18 @@
1
1
  ---
2
2
  name: document-cache
3
- description: Cache the whole HTTP response at the edge with Cache-Control headers. Use when caching an entire page or response at a CDN edge, setting Cache-Control headers, or cutting origin hits for public pages not for caching a single segment or function.
3
+ description: Cache complete HTTP responses in Rango's configured app store with createDocumentCacheMiddleware, using Cache-Control s-maxage as policy. Use when reusing a whole HTML/RSC response, comparing the store-backed middleware with a platform CDN cache, or deciding whether full-response caching is safe.
4
4
  argument-hint: [setup]
5
5
  ---
6
6
 
7
- # Document Cache
7
+ # Store-backed Document Cache
8
8
 
9
- Caches complete HTTP responses (HTML/RSC) at the edge based on Cache-Control headers. Routes opt-in by setting `s-maxage`.
9
+ Caches complete HTTP responses (HTML/RSC) in the app-level cache store based on
10
+ `Cache-Control`. Routes opt in by setting `s-maxage`.
11
+
12
+ This middleware runs **inside** the worker/function. It is not itself a platform
13
+ CDN cache. With `CFCacheStore` the response family can use Cloudflare's edge/KV
14
+ tiers; with `VercelCacheStore` it uses Vercel Runtime Cache. The request still
15
+ reaches Rango before the middleware can return a store hit.
10
16
 
11
17
  ## Not this skill if…
12
18
 
@@ -15,6 +21,8 @@ Caches complete HTTP responses (HTML/RSC) at the edge based on Cache-Control hea
15
21
  is `cache()`: see `/caching`.
16
22
  - You want a cached HTML shell with per-request live holes — see `/ppr`.
17
23
  - You are unsure which cache layer you need — start at `/cache-guide`.
24
+ - You mean a platform CDN that serves a complete response without invoking the
25
+ app — see `/deployment-caching` first.
18
26
 
19
27
  ## Setup
20
28
 
@@ -55,6 +63,13 @@ Routes opt-in to document caching by setting a `Cache-Control` response header
55
63
  with `s-maxage`. The middleware caches responses whose `Cache-Control` includes
56
64
  `s-maxage`; `stale-while-revalidate` enables background revalidation (SWR).
57
65
 
66
+ The deployment platform may independently interpret the same `s-maxage` header
67
+ and cache the completed response at its CDN. A CDN hit bypasses the function,
68
+ all Rango middleware, handlers, and loaders. Therefore these headers are safe
69
+ only when the **complete** response is public and identical for every request
70
+ sharing the cache key. The middleware's `skipPaths`, `isEnabled`, and
71
+ `keyGenerator` cannot protect a response once an outer CDN serves it.
72
+
58
73
  ```typescript
59
74
  // Cache full page for 5 min, serve stale for 1 hour
60
75
  function BlogIndexHandler(ctx) {
@@ -116,6 +131,11 @@ Request → Check Cache
116
131
  background (SWR)
117
132
  ```
118
133
 
134
+ This diagram starts after the request reaches the Rango middleware. A store hit
135
+ short-circuits the middleware's downstream pipeline; global middleware that
136
+ wraps it can still run. Route middleware, handlers, and loaders below it do not.
137
+ An external CDN hit is different: the function never runs at all.
138
+
119
139
  ## Cache Status Header
120
140
 
121
141
  Response includes `x-document-cache-status`:
@@ -124,6 +144,10 @@ Response includes `x-document-cache-status`:
124
144
  - `STALE` - Served stale, revalidating in background
125
145
  - `MISS` - Cache miss, response was generated fresh
126
146
 
147
+ This header reports the Rango store-backed middleware, not the platform CDN. A
148
+ CDN may replay a previously cached status header, so use the platform's cache
149
+ header or logs to identify an actual CDN hit.
150
+
127
151
  ## Cache Key Generation
128
152
 
129
153
  Default keys differentiate:
@@ -211,3 +235,6 @@ function BlogPost(ctx) {
211
235
  | Key includes | URL + segment hash | Route params |
212
236
 
213
237
  Use document cache for mostly-static pages. Use segment cache when different parts of a page have different cache requirements.
238
+
239
+ See `/deployment-caching` for the full in-function versus CDN execution matrix,
240
+ middleware implications, and the shared-response safety checklist.
@@ -7,16 +7,21 @@ argument-hint: "[setup]"
7
7
  # PPR Shell Caching
8
8
 
9
9
  Caches the rendered HTML **shell** of a page route (React `prerender` prelude
10
- bytes plus `postponed` state) and, on a later request, flushes those bytes
11
- before any render work happens, then resumes fizz for just the live holes. The
12
- browser sees one ordinary streamed document; loaders stay fresh on every
13
- request. This is the second render axis the default axis-1 path is untouched,
14
- and every ineligible request falls open to it.
10
+ bytes plus `postponed` state) and, on a later request, flushes those bytes after
11
+ route classification and the complete middleware chain, but before downstream
12
+ tail rendering. It then resumes fizz for just the live holes. The browser sees
13
+ one ordinary streamed document; loaders stay fresh on every request. This is
14
+ the second render axis the default axis-1 path is untouched, and every
15
+ ineligible request falls open to it.
15
16
 
16
17
  Compare `/document-cache`, which freezes the WHOLE response including loader
17
18
  output. Shell caching is for pages that mix a stable shell with live data: the
18
19
  shell is shared per host+URL, the holes are per request.
19
20
 
21
+ This is in-function PPR on every deployment. The worker/function serves the
22
+ prelude; it is not a CDN static file. See `/deployment-caching` before combining
23
+ PPR with HTTP shared-cache headers.
24
+
20
25
  ## Not this skill if…
21
26
 
22
27
  - You want the WHOLE response frozen, loader output included — see
@@ -170,12 +175,14 @@ On a document GET to a ppr route the router runs:
170
175
  point is after the chain, an unauthorized request NEVER sees shell bytes — put
171
176
  auth middleware anywhere (global or route DSL) and it guards PPR for free.
172
177
 
173
- ### Soft navigation reuses the captured segment shell
178
+ ### Soft navigation caches and reuses the handler layer
174
179
 
175
- A usable shell snapshot also accelerates ordinary partial RSC navigations to
176
- the same URL. The capture records the canonical document segment tree alongside
177
- the HTML prelude. On a partial request the server replays only that segment
178
- record through the normal `matchPartial()` pipeline, which then:
180
+ Ordinary partial RSC navigations to a `ppr` URL use the same handler-layer cache
181
+ contract even when no document request has captured an HTML shell yet. When a
182
+ shell snapshot exists, the server replays its canonical document segment record.
183
+ On a cold partial request, normal matching renders the response and schedules a
184
+ background navigation-only shell capture; later navigations and prefetches
185
+ replay its eligible snapshot. In both cases `matchPartial()`:
179
186
 
180
187
  - preserves client-owned shared layouts by segment id;
181
188
  - returns only new or revalidating destination segments;
@@ -186,23 +193,41 @@ This is deliberately invisible to the browser: the response is the same
186
193
  `RscPayload` shape as any other partial navigation. Captured item/response values
187
194
  and loader-container pins are NOT replayed on this path, so loader reads stay
188
195
  live. A route's own `cache()` scope still resolves its normal store, key, TTL,
189
- SWR, tags, and condition; only the implicit document scope sees the replay
190
- overlay, and fresh segment writes there stay request-local rather than polluting
191
- the canonical `doc:` namespace. Intercepts, handler-live holes,
192
- `transition({ when })`, an active nonce, and an absent/corrupt segment snapshot
193
- fall open to the ordinary partial path when encountered by the fresh shell
194
- capture. A transition already replayed from an explicit cache tier remains
195
- frozen by that tier's normal semantics.
196
-
197
- Only fresh shells replay. Production may use either a runtime entry or the
198
- local build manifest; development uses runtime entries only, because probing
199
- `/__rsc_shell` would block the foreground navigation on an on-demand capture.
200
- A passive stale read does not claim SWR ownership because partial requests
201
- cannot recapture the HTML shell. Custom `SegmentCacheStore` implementations
202
- must set `supportsPassiveShellReads: true` and honor
203
- `getShell(key, { claimRevalidation: false })` to opt into navigation replay.
204
- There is still no Flight resume API; this is segment replay followed by normal
205
- Flight streaming, not reuse of the HTML `prelude`/`postponed` bytes.
196
+ SWR, tags, and condition; only the implicit PPR scope sees this behavior.
197
+ `transition({ when })` is evaluated from the
198
+ matched manifest before route handlers on every PPR match, so it can vary by
199
+ URL/params/action or middleware context without disabling replay; handler-set
200
+ context is unavailable by design. Intercepts, handler-live holes, an active
201
+ nonce, and an absent/corrupt segment snapshot fall open to the ordinary partial
202
+ path when encountered by the shell capture. A transition already replayed from
203
+ an explicit cache tier remains frozen by that tier's normal semantics.
204
+
205
+ Fresh and stale-within-SWR runtime shells replay. The stale read is passive: it
206
+ uses `getShell(key, { claimRevalidation: false })`, does not claim SWR ownership,
207
+ and cannot recapture HTML. A later document request owns the background
208
+ recapture; hard-expired entries schedule a navigation-only capture. Production
209
+ may also use a fresh local build manifest. Development does not probe
210
+ `/__rsc_shell`; it schedules the same local background capture instead. Custom `SegmentCacheStore`
211
+ implementations must set `supportsPassiveShellReads: true` and honor the
212
+ non-claiming read option.
213
+
214
+ The first cold partial request reports `BYPASS; reason=no-entry` because no
215
+ artifact could supply that response; its successful render schedules
216
+ `scheduleShellCapture` with a navigation-only marker. The next request reports
217
+ `HIT` when the capture produced an eligible snapshot. Navigation snapshots use
218
+ a separate shell key, so they cannot overwrite or be served as a document shell.
219
+ The capture runs with the stripped target document URL and loads SSR support in
220
+ the bounded background queue, outside the triggering partial response's latency.
221
+ An `allReady` decision still declines capture.
222
+
223
+ Partial responses expose the actual decision as `x-rango-ppr-replay`:
224
+ `HIT; freshness=fresh|stale` or `BYPASS; reason=<bounded-token>`. With
225
+ performance metrics enabled, the same decision appears as
226
+ `ppr-navigation-replay` in `Server-Timing`. `HIT` means matching consumed the
227
+ seeded segment record after it decoded successfully, not merely that a snapshot
228
+ existed. An explicit `cache()` scope that supplies the match cannot produce a
229
+ false HIT. There is still no Flight resume API; this is segment replay followed
230
+ by normal Flight streaming, not reuse of the HTML `prelude`/`postponed` bytes.
206
231
 
207
232
  ### Capture-generation invalidation
208
233
 
@@ -252,7 +277,12 @@ sees the header directly; only an explicit Flight request shape lacks it:
252
277
  curl -s -D - -o /dev/null https://app.example.com/products/1 | grep -i x-rango-shell
253
278
  ```
254
279
 
255
- - First document GET: `MISS`, plus a background capture.
280
+ - Runtime-captured route: first document GET is `MISS`, plus a background
281
+ capture; a later request becomes a `HIT`.
282
+ - `Prerender + ppr` route: the shell is produced during `vite build`, so the
283
+ first production document request can already be a `HIT`. In dev, producer B
284
+ runs on demand and can return a `HIT`; if capture outlasts the bounded
285
+ foreground wait, the request falls open to `MISS` and runtime capture.
256
286
  - Production (workerd/node): the SECOND request is a `HIT`.
257
287
  - Dev: expect a few extra MISSes — cold module transforms abort the capture
258
288
  window (per-attempt breadcrumbs: start the server with
@@ -272,7 +302,9 @@ curl -s -D - -o /dev/null https://app.example.com/products/1 | grep -i x-rango-s
272
302
  - Structured capture diagnostics: `createRouter({ debugShellCapture: true })`
273
303
  logs one line per capture attempt/skip (outcome, durations, prelude and
274
304
  snapshot bytes, backoff state); pass a function to receive each
275
- `ShellCaptureDebugEvent` instead. In dev, with `debugPerformance` on, the
305
+ `ShellCaptureDebugEvent` instead. `skip-capacity` means the isolate already
306
+ has 32 queued/running captures; the dropped best-effort capture can retry on a
307
+ later request. In dev, with `debugPerformance` on, the
276
308
  last capture outcome for a key also rides the next document GET's
277
309
  `Server-Timing` as `ppr-capture;desc="…"`.
278
310
 
@@ -284,6 +316,8 @@ Import from `@rangojs/router/testing` (Vitest) or `@rangojs/router/testing/e2e`
284
316
  | Helper | Use for |
285
317
  | ------------------------------------------------- | ------------------------------------------------------------ |
286
318
  | `assertShellStatus(res, "HIT" \| "MISS")` | Document Response from a real RSC serve / e2e `page.request` |
319
+ | `assertPprReplayStatus(res, expected)` | Partial response fresh/stale replay or bounded bypass |
320
+ | `parsePprReplayStatus(res)` | Read structured replay/bypass status or null |
287
321
  | `shellCacheKey(url)` | Production store key for `store.getShell` / custom stores |
288
322
  | `MemorySegmentCacheStore` + `getShell`/`putShell` | Custom store contract / tag eviction (no faked HIT) |
289
323
 
@@ -639,11 +673,18 @@ path(
639
673
  | `swr` | — | stale window: serve the stale shell + background recapture |
640
674
  | `tags` | — | operational tags UNIONED with the tags the capture render auto-collects — see "Invalidation" below |
641
675
  | `maxSnapshotBytes` | 8 MiB | cap on the entry's capture data snapshot; over it the snapshot is skipped (shell still stored, warned once per key) so the entry stays under store limits |
676
+ | `captureTimeout` | 15000ms | capture settle budget; a timed-out capture is refused rather than storing a partial shell |
642
677
 
643
678
  The shell store is always the app-level `createRouter({ cache })` store; the
644
679
  default key is `${host}${pathname}${sortedSearch}:shell` (host-scoped so
645
680
  multi-tenant shells never collide).
646
681
 
682
+ These options control the in-function shell entry only. They do not emit HTTP
683
+ `Cache-Control`. Adding `s-maxage` separately allows a platform CDN to cache the
684
+ completed response, including the live-hole output, and CDN hits bypass Rango
685
+ middleware entirely. Only do that for a fully public response whose complete
686
+ output is shared; see `/deployment-caching`.
687
+
647
688
  ## Invalidation: tags vs revalidate()
648
689
 
649
690
  `updateTag()`/`revalidateTag()` is the ONLY lever that changes the frozen shell
@@ -676,8 +717,9 @@ evicted by tag at all — move always-fresh data under a `loading()` hole.
676
717
  - **A bake-lane container that must be fresh per document GET**: it is
677
718
  snapshot-pinned for the shell's lifetime by design. Use the live lane
678
719
  (`loading()`) or a nested promise instead.
679
- - **A bake-lane loader slower than the capture guard (~5s)**: the capture
680
- cannot hold for it eternal MISS with the once-per-key warning.
720
+ - **A bake-lane loader slower than `ppr.captureTimeout` (15s by default)**: the
721
+ capture is refused rather than storing a partial shell. Increase the route's
722
+ budget only when the deployment can keep the background/build work alive.
681
723
  - **Per-user value in shell material**: baked into the shared shell —
682
724
  deterministically, not by race (handler promises deep-settle at the ring-3
683
725
  write on cached chains; awaited/resolved values bake everywhere). Put
@@ -720,7 +762,10 @@ cache"` value baked into the shell is PINNED at capture (the capture data
720
762
  it: call `cacheTag(...)` from the shell-material render code (the render-time
721
763
  lever), or add the tag to `ppr.tags` (operational tags the render cannot know —
722
764
  a tenant id, a deploy marker). Ring-1/ring-3 tag invalidation does NOT drop the
723
- shell.
765
+ shell. Tags are optional: if TTL/SWR is the complete freshness policy, leave
766
+ the shell untagged. Rango does not warn for that choice; with
767
+ `debugShellCapture` enabled, a stored event reports `untaggedBake: true` when
768
+ bake-lane loader material uses TTL/SWR-only invalidation.
724
769
  - **Uncached nondeterminism in the shell is a hydration hazard**: a raw
725
770
  `Date.now()` / `Math.random()` / uncached `fetch` rendered directly in shell
726
771
  material (outside any cache ring) drifts between capture and hit and the
@@ -728,8 +773,10 @@ cache"` value baked into the shell is PINNED at capture (the capture data
728
773
  prelude and detonate hydration. Wrap it in `cache()`/`"use cache"` (then it is
729
774
  pinned) or move it under a hole (`loading()`, or a pending-promise
730
775
  `<Suspense>` region).
731
- - **Stacking with `/document-cache`**: pick one per route the document cache
732
- would cache the composite.
776
+ - **Stacking with `/document-cache` or HTTP CDN caching**: both cache the
777
+ completed composite, including live-hole output, so PPR becomes redundant on
778
+ a hit. A platform CDN also bypasses every Rango middleware. Restrict this to
779
+ fully public, shared responses; see `/deployment-caching`.
733
780
  - **Dev + HMR**: works, but edits produce stale shells until TTL/recapture.
734
781
  - **Dev cold-start cadence**: expect `MISS -> (in-place retry) -> HIT`. A
735
782
  refused capture is negatively cached with an exponential window (1s doubling
@@ -326,18 +326,25 @@ This only applies when `__PRERENDER_DEV_URL` is set by the plugin.
326
326
 
327
327
  ## Storage Layout
328
328
 
329
- Pre-rendered Flight payloads are stored in the build output:
329
+ Pre-rendered Flight payloads are stored as content-hashed modules behind a lazy
330
+ manifest in the RSC server bundle. They are not public `.rsc` files:
330
331
 
331
332
  ```
332
- dist/static/__<hash>/
333
- prerender/
334
- blog.post/
335
- d4e5f6a7.flight # hash of { slug: "hello-world" }
336
- b8c9d0e1.flight # hash of { slug: "getting-started" }
337
- about/
338
- _.flight # static route, no params
333
+ dist/rsc/
334
+ __prerender-manifest.js
335
+ assets/
336
+ __pr-<content-hash>.js
337
+
338
+ # When a Prerender route also declares ppr:
339
+ __shell-manifest.js
340
+ assets/
341
+ __ps-<content-hash>.js
339
342
  ```
340
343
 
344
+ The worker/function handles every request and reads these modules as build-time
345
+ cache entries. See `/deployment-caching` for how this differs from a platform
346
+ CDN static or prerender output.
347
+
341
348
  ## Concurrency
342
349
 
343
350
  Prerender handlers can specify how many param sets render in parallel: