@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,596 +0,0 @@
1
- /**
2
- * Request Context - AsyncLocalStorage for passing request-scoped data throughout rendering
3
- *
4
- * This is the unified context used everywhere:
5
- * - Middleware execution
6
- * - Route handlers and loaders
7
- * - Server components during rendering
8
- * - Error boundaries and streaming
9
- *
10
- * Available via getRequestContext() anywhere in the request lifecycle.
11
- */
12
- import { parseCookiesFromHeader } from "./cookie-parse.js";
13
- import type { CacheErrorCategory } from "../cache/cache-error.js";
14
- import type { CookieOptions } from "../router/middleware.js";
15
- import type { LoaderDefinition } from "../types.js";
16
- import type { ScopedReverseFunction } from "../reverse.js";
17
- import type { DefaultEnv, DefaultReverseRouteMap, DefaultRouteName } from "../types/global-namespace.js";
18
- import type { Handle } from "../handle.js";
19
- import { type ContextVar } from "../context-var.js";
20
- import { type HandleStore, type HandleData } from "./handle-store.js";
21
- import { type MetricsStore } from "./context.js";
22
- import type { SegmentCacheStore } from "../cache/types.js";
23
- import type { Theme, ResolvedThemeConfig } from "../theme/types.js";
24
- import type { ExecutionContext, RequestScope } from "../types/request-scope.js";
25
- import type { TransitionWhenFn } from "../types/segments.js";
26
- import type { ResolvedTracing } from "../router/tracing.js";
27
- import type { LocationStateEntry } from "../browser/react/location-state-shared.js";
28
- /**
29
- * Unified request context available via getRequestContext()
30
- *
31
- * This is the same context passed to middleware and handlers.
32
- * Use this when you need access to request data outside of route handlers.
33
- */
34
- export interface RequestContext<TEnv = DefaultEnv, TParams = Record<string, string>> extends RequestScope<TEnv> {
35
- /** @internal Shared variable backing store for ctx.get()/ctx.set(). */
36
- _variables: Record<string, any>;
37
- /** Get a variable set by middleware */
38
- get: {
39
- <T>(contextVar: ContextVar<T>): T | undefined;
40
- <K extends string>(key: K): any;
41
- };
42
- /** Set a variable (shared with middleware and handlers) */
43
- set: {
44
- <T>(contextVar: ContextVar<T>, value: T, options?: {
45
- cache?: boolean;
46
- }): void;
47
- <K extends string>(key: K, value: any, options?: {
48
- cache?: boolean;
49
- }): void;
50
- };
51
- /**
52
- * Route params (populated after route matching)
53
- * Initially empty, then set to matched params
54
- */
55
- params: TParams;
56
- /** @internal Stub response for collecting headers/cookies. Use ctx.headers or ctx.header() instead. */
57
- readonly res: Response;
58
- /**
59
- * True for build-time render/capture requests. Live requests use false.
60
- * Build-time shell capture sets this while replaying middleware so apps can
61
- * skip side-effectful runtime work.
62
- */
63
- readonly build: boolean;
64
- /**
65
- * Opt this request out of PPR shell serving/capture.
66
- * Runtime middleware can call this before the PPR commit point; handlers can
67
- * call it on a MISS to prevent the follow-up capture.
68
- *
69
- * Scope: the PPR SHELL axis only. It does NOT disable prerender B-segment
70
- * (Prerender/Static) serving, and it is inert in the prerender-collect /
71
- * static-render contexts (no live shell decision to influence there).
72
- */
73
- dynamic(): void;
74
- /** @internal Request-local PPR opt-out marker set by ctx.dynamic(). */
75
- _dynamic?: boolean;
76
- /** @internal Get a cookie value (effective: request + response mutations). Use cookies().get() instead. */
77
- cookie(name: string): string | undefined;
78
- /** @internal Get all cookies (effective merged view). Use cookies().getAll() instead. */
79
- cookies(): Record<string, string>;
80
- /** @internal Set a cookie on the response. Use cookies().set() instead. */
81
- setCookie(name: string, value: string, options?: CookieOptions): void;
82
- /** @internal Delete a cookie. Use cookies().delete() instead. */
83
- deleteCookie(name: string, options?: Pick<CookieOptions, "domain" | "path">): void;
84
- /** Set a response header */
85
- header(name: string, value: string): void;
86
- /** Set the response status code */
87
- setStatus(status: number): void;
88
- /** @internal Set status bypassing cache-exec guard (for framework error handling) */
89
- _setStatus(status: number): void;
90
- /** @internal Rotate the rango state cookie (server seat of invalidateClientCache). */
91
- _rotateStateCookie(): void;
92
- /** @internal Set the keepClientCache() directive header on the response. */
93
- _setKeepCacheDirective(): void;
94
- /**
95
- * Access loader data or push handle data.
96
- *
97
- * For loaders: Returns a promise that resolves to the loader data.
98
- * Loaders are executed in parallel and memoized per request.
99
- *
100
- * For handles: Returns a push function to add data for this segment.
101
- * Handle data accumulates across all matched route segments.
102
- *
103
- * @example
104
- * ```typescript
105
- * // Loader usage
106
- * const cart = await ctx.use(CartLoader);
107
- *
108
- * // Handle usage
109
- * const push = ctx.use(Breadcrumbs);
110
- * push({ label: "Shop", href: "/shop" });
111
- * ```
112
- */
113
- use: {
114
- <T, TLoaderParams = any>(loader: LoaderDefinition<T, TLoaderParams>): Promise<T>;
115
- <TData, TAccumulated = TData[]>(handle: Handle<TData, TAccumulated>): (data: TData | Promise<TData> | (() => Promise<TData>)) => void;
116
- };
117
- /** HTTP method (GET, POST, PUT, PATCH, DELETE, etc.) */
118
- method: string;
119
- /** @internal Handle store for tracking handle data across segments */
120
- _handleStore: HandleStore;
121
- /**
122
- * @internal transition({ when }) predicates for segments matched this request,
123
- * keyed by segment id. Collected during resolution (the function is stripped
124
- * from the serialized segment config), then evaluated post-handler in
125
- * rsc-rendering — outside any cache scope — to drop the transition of any
126
- * segment whose predicate returns false.
127
- */
128
- _transitionWhen?: Array<{
129
- id: string;
130
- when: TransitionWhenFn;
131
- }>;
132
- /** @internal Cache store for segment caching (optional, used by CacheScope) */
133
- _cacheStore?: SegmentCacheStore;
134
- /**
135
- * @internal PPR shell-capture ACTIVE marker. True ONLY inside the background
136
- * capture task's derived request context (built by shell-capture.ts). This is
137
- * the switch every capture-specific behavior reads: loader masking
138
- * (loader-mask.ts isShellCaptureActive / fresh.ts emitStreaming) and the
139
- * cookies()/headers() capture guard (cookie-store.ts
140
- * assertNotInsideShellCapture). The foreground render never sets it, so the
141
- * served response is byte-identical to axis 1. The capture descriptor itself
142
- * (key/ttl/swr/tags/store) is NOT threaded through the request context — the
143
- * integrated PPR serve path (rsc/shell-serve.ts + rsc-rendering.ts) builds it
144
- * locally and passes it to scheduleShellCapture directly.
145
- */
146
- _shellCaptureRun?: boolean;
147
- /**
148
- * @internal Bake-lane loader containers collected DURING a shell capture:
149
- * segment-key -> the loader's (pre-wrap) result promise. Populated by
150
- * resolveLoaderData for loaders on entries with no renderable loading() (the
151
- * bake lane — they execute at capture instead of being masked; see
152
- * docs/design/loader-container-bake.md). Drained by captureAndStoreShell
153
- * after the shell quiesces: settled containers are promise-elided,
154
- * Flight-serialized, and pinned into the snapshot's loader family; a
155
- * REJECTED container refuses the capture (error UI must never bake into the
156
- * shared shell). Own property of the capture's derived context only.
157
- */
158
- _shellCaptureLoaderRecords?: Map<string, Promise<unknown>>;
159
- /**
160
- * @internal Loader-family snapshot seed for a shell HIT's tail render:
161
- * segment-key -> the capture's elided container (already Flight-deserialized
162
- * by serveShellHit). resolveLoaderData overlays it onto the fresh run's
163
- * container (recorded paths pinned, hole-marker paths keep the fresh nested
164
- * promises) so the payload's baked bytes match the frozen prelude. Own
165
- * property of the HIT tail's derived context only.
166
- */
167
- _shellLoaderSeed?: Map<string, unknown>;
168
- /**
169
- * @internal Shell fast-path marker: makes the NEXT full match treat the whole
170
- * matched route as an implicit doc-level cache() boundary (see
171
- * resolveShellImplicitCacheScope in cache/cache-scope.ts). Set ONLY on
172
- * (a) the capture's derived context — with a record-only store so the
173
- * capture's cacheRoute write lands in the snapshot, never the real store —
174
- * and (b) a HIT tail's seeded context when the entry is eligible
175
- * (!handlerLiveHoles), where the SeededShellStore serves the recorded doc
176
- * entry and the match skips handler execution entirely. Routes with their
177
- * own cache() config (including cache(false)) are never overridden: the
178
- * marker only applies when the route tree derived NO cache scope.
179
- */
180
- _shellImplicitCache?: {
181
- ttl?: number;
182
- swr?: number;
183
- store?: SegmentCacheStore;
184
- };
185
- /**
186
- * @internal Shell-HIT tail marker: cache/prerender-store hits during THIS
187
- * render emit stored segment fragments VERBATIM into the payload
188
- * (segment-codec fragmentSegments) instead of deserialize -> re-serialize
189
- * per request; the payload consumers (SSR resume + browser hydration)
190
- * expand them (segment-fragments.ts, issue #700). Own property of
191
- * serveShellHit's derived tail context ONLY — it must never be visible to a
192
- * capture render: the capture SSR-prerenders the payload AND serializes
193
- * segments into records (cacheRoute), and an envelope reaching
194
- * serializeSegments would store a double-encoded fragment.
195
- */
196
- _shellFragmentPayload?: boolean;
197
- /**
198
- * @internal Handler-layer liveness observed DURING a shell capture, from
199
- * three sources: (a) the capture handle-store push wrapper (shell-capture.ts)
200
- * when a push made OUTSIDE a DSL loader scope carries a nested thenable
201
- * (masked to a never-filling hole); (b) still-pending top-level handler
202
- * pushes (liveness unknowable at the barrier); (c) a handler-invoked loader
203
- * executing during the capture (loader-resolution.ts — its consumption-lane
204
- * value would freeze on a handler-free HIT). captureAndStoreShell folds it
205
- * into ShellCacheEntry.handlerLiveHoles at the putShell barrier. Own
206
- * property of the capture's derived context only.
207
- */
208
- _shellCaptureHandleLiveness?: {
209
- holes: boolean;
210
- pendingPushes: number;
211
- handlerInvokedLoader: boolean;
212
- };
213
- /**
214
- * @internal Handle values pushed from a DSL loader scope DURING a shell
215
- * capture (identity set; populated by the capture push wrapper in
216
- * shell-capture.ts). cacheRoute threads it into captureHandles so those
217
- * values stay out of cache-write handle records — loaders re-run fresh on
218
- * every HIT, so replaying their captured (masked) values would duplicate
219
- * the fresh push and stall the Flight handle encode. Own property of the
220
- * capture's derived context only; render-time handle consumers are
221
- * unaffected (the exclusion applies only at the captureHandles call site).
222
- */
223
- _shellCaptureLoaderHandleValues?: WeakSet<object>;
224
- /**
225
- * @internal Set (to the offending fn name) by the cookies()/headers()
226
- * capture guard when it throws DURING a capture render. Load-bearing for the
227
- * bake lane: a guard throw inside an executing loader is swallowed by
228
- * wrapLoaderPromise into per-loader error UI, which would otherwise bake
229
- * silently into the shared shell — the capture checks this flag after the
230
- * render and refuses instead. Deterministic, so the capture does not retry.
231
- */
232
- _shellCaptureGuardTripped?: string;
233
- /**
234
- * @internal The loader $$id whose BODY was executing when the capture guard
235
- * tripped (read off the loader-body ALS scope at trip time), or undefined
236
- * when the read came from handler/render code. Only used to make the
237
- * once-per-key refusal warning name the real source — the old text
238
- * hardcoded "a bake-lane loader", which misattributed handler-land reads
239
- * and sent users debugging the wrong lane (issue #672, secondary).
240
- */
241
- _shellCaptureGuardTrippedLoaderId?: string;
242
- /**
243
- * @internal Handler-owned registry of explicit per-scope stores from
244
- * cache({ store }). Created once per createRSCHandler() and threaded into
245
- * every request context, so it accumulates every explicit store the handler
246
- * resolves. updateTag()/revalidateTag() iterate this set plus _cacheStore to
247
- * reach every store that may hold tagged entries. The app-level store is not
248
- * added here (it is always reachable via _cacheStore).
249
- */
250
- _explicitTaggedStores?: Set<SegmentCacheStore>;
251
- /**
252
- * @internal Union of every cache tag resolved while producing this request's
253
- * response (from cache({ tags }), runtime cacheTag(), and loader cache tags).
254
- * Populated at the tag-resolution sites via recordRequestTags(). Read by the
255
- * document cache middleware so a full-page entry is tagged with everything its
256
- * content used and can therefore be invalidated by updateTag()/revalidateTag().
257
- */
258
- _requestTags: Set<string>;
259
- /** @internal Cache profiles for "use cache" profile resolution (per-router) */
260
- _cacheProfiles?: Record<string, import("../cache/profile-registry.js").CacheProfile>;
261
- /**
262
- * Register a callback to run when the response is created.
263
- * Callbacks are sync and receive the response. They can:
264
- * - Inspect response status/headers
265
- * - Return a modified response
266
- * - Schedule async work via waitUntil
267
- *
268
- * @example
269
- * ```typescript
270
- * ctx.onResponse((res) => {
271
- * if (res.status === 200) {
272
- * ctx.waitUntil(async () => await cacheIt());
273
- * }
274
- * return res;
275
- * });
276
- * ```
277
- */
278
- onResponse(callback: (response: Response) => Response): void;
279
- /** @internal Registered onResponse callbacks */
280
- _onResponseCallbacks: Array<(response: Response) => Response>;
281
- /**
282
- * @internal Promises of the background tasks scheduled via this context's
283
- * waitUntil (deferred cache writes, revalidations, consumer tasks). The PPR
284
- * shell capture drains this list BEFORE its match/render as an ORDERING EDGE:
285
- * every foreground deferred cache write is scheduled here before the capture
286
- * task is, so settling the list first guarantees the capture's cache reads
287
- * observe the foreground's generation instead of racing it (see
288
- * shell-capture.ts). Tasks whose scheduling fn carries
289
- * UNTRACKED_BACKGROUND_TASK are not tracked (the capture task itself —
290
- * tracking it would make that drain await its own promise).
291
- */
292
- _pendingBackgroundTasks?: Array<Promise<unknown>>;
293
- /**
294
- * Current theme setting (only available when theme is enabled in router config)
295
- *
296
- * Returns the theme value from the cookie, or the default theme if not set.
297
- * This is the user's preference ("light", "dark", or "system"), not the resolved value.
298
- *
299
- * @example
300
- * ```typescript
301
- * route("settings", (ctx) => {
302
- * const currentTheme = ctx.theme; // "light" | "dark" | "system" | undefined
303
- * return <SettingsPage theme={currentTheme} />;
304
- * });
305
- * ```
306
- */
307
- theme?: Theme;
308
- /**
309
- * Set the theme (only available when theme is enabled in router config)
310
- *
311
- * Sets a cookie with the new theme value. The change takes effect on the next request.
312
- *
313
- * @example
314
- * ```typescript
315
- * route("settings", (ctx) => {
316
- * if (ctx.method === "POST") {
317
- * const formData = await ctx.request.formData();
318
- * const newTheme = formData.get("theme") as Theme;
319
- * ctx.setTheme(newTheme);
320
- * }
321
- * return <SettingsPage />;
322
- * });
323
- * ```
324
- */
325
- setTheme?: (theme: Theme) => void;
326
- /** @internal Theme configuration (null if theme not enabled) */
327
- _themeConfig?: ResolvedThemeConfig | null;
328
- /**
329
- * Attach location state entries to the current response.
330
- *
331
- * For partial (SPA) requests, the state is included in the RSC payload
332
- * metadata and merged into history.pushState on the client. For redirect
333
- * responses, the state travels through the redirect payload so the target
334
- * page can read it via useLocationState.
335
- *
336
- * Multiple calls accumulate entries.
337
- *
338
- * @example
339
- * ```typescript
340
- * ctx.setLocationState(Flash({ text: "Item saved!" }));
341
- * ```
342
- */
343
- setLocationState(entries: LocationStateEntry | LocationStateEntry[]): void;
344
- /** @internal Accumulated location state entries */
345
- _locationState?: LocationStateEntry[];
346
- /**
347
- * The matched route name, if the route has an explicit name.
348
- * Undefined before route matching or for unnamed routes.
349
- * Includes the namespace prefix from include() (e.g., "blog.post").
350
- */
351
- routeName?: DefaultRouteName;
352
- /**
353
- * Generate URLs from route names.
354
- * Uses the global route map. After route matching, scoped (`.name`) resolution
355
- * works within the matched include() scope.
356
- */
357
- reverse: ScopedReverseFunction<Record<string, string>, DefaultReverseRouteMap>;
358
- /** @internal Route name from route matching, used for scoped reverse resolution */
359
- _routeName?: string;
360
- /** @internal Previous route key (from the navigation source), used for revalidation */
361
- _prevRouteKey?: string;
362
- /**
363
- * @internal Navigation/action source data the transition({ when }) gate reads
364
- * to build its ShouldRevalidateFn-shaped predicate context. currentUrl/Params
365
- * come from the navigation snapshot (set at match time); action* are stashed
366
- * at the action-bearing gate call sites. All undefined when there is no source
367
- * (initial full load) or no action (plain navigation).
368
- */
369
- _gateCurrentUrl?: URL;
370
- _gateCurrentParams?: Record<string, string>;
371
- _gateActionId?: string;
372
- _gateActionUrl?: URL;
373
- _gateActionResult?: unknown;
374
- _gateFormData?: FormData;
375
- /**
376
- * @internal True while the post-action revalidation render is running (set by
377
- * revalidateAfterAction). The "use cache" runtime reads this to prefer
378
- * freshness over a fast stale response during an action: a stale entry
379
- * re-executes in the foreground (so the action response reflects the refreshed
380
- * value) with only the store write deferred, instead of serving stale and
381
- * revalidating in the background. A plain navigation (flag unset) keeps SWR.
382
- */
383
- _inActionRevalidation?: boolean;
384
- /**
385
- * @internal Render barrier for experimental `rendered()` API.
386
- * Resolves when all non-loader segments have settled and handle data
387
- * is available. Used by DSL loaders that call `ctx.rendered()`.
388
- */
389
- _renderBarrier: Promise<void>;
390
- /**
391
- * @internal Resolve the render barrier. Accepts resolved segments, filters
392
- * out loaders, and captures non-loader segment IDs as the handle ordering.
393
- * Called after segment resolution (fresh) or handle replay (cache/prerender).
394
- */
395
- _resolveRenderBarrier: (segments: Array<{
396
- type: string;
397
- id: string;
398
- }>) => void;
399
- /**
400
- * @internal Segment order at barrier resolution time, used by loader
401
- * ctx.use(handle) to collect handle data in correct order.
402
- */
403
- _renderBarrierSegmentOrder?: string[];
404
- /**
405
- * @internal Set to true when the matched entry tree contains any `loading()`
406
- * entries (streaming). On a streaming tree rendered() waits for the streaming
407
- * handlers to settle (via handleStore.settled) before resolving, and the
408
- * deadlock guard state is kept live until that wait completes.
409
- */
410
- _treeHasStreaming?: boolean;
411
- /**
412
- * @internal Loader IDs that have called rendered() and are waiting for the
413
- * barrier. Used to detect deadlocks when a handler tries to await the same
414
- * loader via ctx.use(Loader).
415
- */
416
- _renderBarrierWaiters?: Set<string>;
417
- /**
418
- * @internal Loader IDs that handlers have started awaiting via ctx.use().
419
- * Used for bidirectional deadlock detection: if a loader later calls
420
- * rendered() and a handler already awaits it, we can detect the deadlock.
421
- */
422
- _handlerLoaderDeps?: Set<string>;
423
- /**
424
- * @internal Cached HandleData snapshot built at barrier resolution time.
425
- * Avoids rebuilding the snapshot on every loader ctx.use(handle) call.
426
- */
427
- _renderBarrierHandleSnapshot?: HandleData;
428
- /**
429
- * @internal The deadlock guard window is closed (no further handler-awaits-
430
- * loader cycle is possible). For non-streaming trees this is set when the
431
- * barrier resolves. For streaming trees the window stays open until
432
- * handleStore.settled — rendered() keeps waiting past the barrier and a
433
- * loading() handler can still resume and await a still-waiting loader — so it
434
- * is set only after settled. The guard (loader-resolution `setupLoaderAccess`)
435
- * reads this instead of `_renderBarrierSegmentOrder` so it does not go blind
436
- * during the streaming settle wait.
437
- */
438
- _renderBarrierGuardClosed?: boolean;
439
- /** @internal Per-request error dedup set for onError reporting */
440
- _reportedErrors: WeakSet<object>;
441
- /**
442
- * @internal Report a non-fatal background error through the router's
443
- * onError callback. Wired by the RSC handler / router during request
444
- * creation. Cache-runtime and other subsystems call this to surface
445
- * errors without failing the response. `category` is surfaced to consumers as
446
- * `metadata.category` on the onError context (phase `cache`).
447
- */
448
- _reportBackgroundError?: (error: unknown, category: CacheErrorCategory) => void;
449
- /** @internal Per-request debug performance override (set via ctx.debugPerformance()) */
450
- _debugPerformance?: boolean;
451
- /** @internal Request-scoped performance metrics store */
452
- _metricsStore?: MetricsStore;
453
- /**
454
- * @internal True request entry timestamp (performance.now() at handler entry).
455
- * Set once at request-context creation (rsc/handler.ts) so a metrics store
456
- * created MID-request — ctx.debugPerformance() or the getMetricsStore wrapper —
457
- * anchors its timeline to the real request start instead of the opt-in moment,
458
- * keeping phases that began before the opt-in at their true (non-negative) offset.
459
- */
460
- _handlerStart?: number;
461
- /** @internal Resolved platform phase-span tracing for this request (Cloudflare or OTel) */
462
- _tracing?: ResolvedTracing;
463
- /** @internal Router basename for this request (used by redirect()) */
464
- _basename?: string;
465
- /**
466
- * @internal RouteSnapshot from classifyRequest, reused by match/matchPartial
467
- * to avoid a second resolveRoute call. Cleared on HMR invalidation.
468
- */
469
- _classifiedRoute?: import("../router/route-snapshot.js").RouteSnapshot;
470
- /**
471
- * @internal Coarse route-level cache signal for the X-Rango-Cache debug
472
- * header. Populated by match/matchPartial only when the debug cache signal
473
- * gate is enabled (debugCacheSignal option or RANGO_TEST_SIGNALS=1). Read by
474
- * the response-finalization path (createResponseWithMergedHeaders). Undefined
475
- * when the gate is off, so no header is emitted.
476
- */
477
- _cacheSignal?: import("../router/telemetry.js").CacheSegmentSignal[];
478
- }
479
- /**
480
- * Public view of RequestContext, without internal methods and fields.
481
- *
482
- * This is the type exported to library consumers. Internal code should
483
- * use the full RequestContext interface directly.
484
- */
485
- export type PublicRequestContext<TEnv = DefaultEnv, TParams = Record<string, string>> = Omit<RequestContext<TEnv, TParams>, "cookie" | "cookies" | "setCookie" | "deleteCookie" | "_handleStore" | "_transitionWhen" | "_cacheStore" | "_shellCaptureRun" | "_shellFragmentPayload" | "_shellCaptureGuardTrippedLoaderId" | "_explicitTaggedStores" | "_requestTags" | "_cacheProfiles" | "_onResponseCallbacks" | "_themeConfig" | "_locationState" | "_routeName" | "_prevRouteKey" | "_gateCurrentUrl" | "_gateCurrentParams" | "_gateActionId" | "_gateActionUrl" | "_gateActionResult" | "_gateFormData" | "_inActionRevalidation" | "_reportedErrors" | "_renderBarrier" | "_resolveRenderBarrier" | "_renderBarrierSegmentOrder" | "_treeHasStreaming" | "_renderBarrierWaiters" | "_handlerLoaderDeps" | "_renderBarrierHandleSnapshot" | "_renderBarrierGuardClosed" | "_reportBackgroundError" | "_debugPerformance" | "_metricsStore" | "_handlerStart" | "_basename" | "_setStatus" | "_rotateStateCookie" | "_setKeepCacheDirective" | "_variables" | "_classifiedRoute" | "_cacheSignal" | "_dynamic" | "res">;
486
- /**
487
- * Marker for a waitUntil-scheduled fn whose task promise must NOT enter
488
- * _pendingBackgroundTasks. Used by the PPR shell capture for its own task:
489
- * the capture's pre-render write barrier settles that list, so tracking the
490
- * capture itself would make the drain wait on its own (still-running) promise.
491
- * @internal
492
- */
493
- export declare const UNTRACKED_BACKGROUND_TASK: unique symbol;
494
- /**
495
- * Run a function within a request context
496
- * Used by the RSC handler to provide context to server actions
497
- */
498
- export declare function runWithRequestContext<TEnv, T>(context: RequestContext<TEnv>, fn: () => T): T;
499
- /**
500
- * Get the current request context
501
- * Throws if called outside of a request context
502
- */
503
- export declare function getRequestContext<TEnv = DefaultEnv>(): RequestContext<TEnv>;
504
- /**
505
- * @internal Get the request context without throwing — for internal code that
506
- * may run outside a request context (cache stores, optional handle lookups, etc.)
507
- */
508
- export declare function _getRequestContext<TEnv = DefaultEnv>(): RequestContext<TEnv> | undefined;
509
- /**
510
- * Update params on the current request context
511
- * Called after route matching to populate route params and route name
512
- */
513
- export declare function setRequestContextParams(params: Record<string, string>, routeName?: string, routeMap?: Record<string, string>): void;
514
- /**
515
- * Store the previous route key on the request context.
516
- * Called during partial-match context creation to make the navigation source
517
- * route key available for revalidation and intercept evaluation.
518
- * @internal
519
- */
520
- export declare function setRequestContextPrevRouteKey(prevRouteKey: string | undefined, currentUrl?: URL, currentParams?: Record<string, string>): void;
521
- /**
522
- * Get accumulated location state entries from the current request context.
523
- * Returns undefined if no state has been set.
524
- *
525
- * @internal Used by the RSC handler to include state in payload metadata.
526
- */
527
- export declare function getLocationState(): LocationStateEntry[] | undefined;
528
- export type { ExecutionContext };
529
- /**
530
- * Options for creating a request context
531
- */
532
- export interface CreateRequestContextOptions<TEnv> {
533
- env: TEnv;
534
- request: Request;
535
- url: URL;
536
- variables: Record<string, any>;
537
- /** Optional initial response stub headers/status to seed effective cookie reads */
538
- initialResponse?: Response;
539
- /** Optional cache store for segment caching (used by CacheScope) */
540
- cacheStore?: SegmentCacheStore;
541
- /**
542
- * Handler-owned registry of explicit per-scope stores for cross-store tag
543
- * invalidation. Created once per handler, reused across requests.
544
- */
545
- explicitTaggedStores?: Set<SegmentCacheStore>;
546
- /** Optional cache profiles for "use cache" resolution (per-router) */
547
- cacheProfiles?: Record<string, import("../cache/profile-registry.js").CacheProfile>;
548
- /** Optional Cloudflare execution context for waitUntil support */
549
- executionContext?: ExecutionContext;
550
- /** Build-time render/capture request marker. Defaults to false. */
551
- build?: boolean;
552
- /** Optional theme configuration (enables ctx.theme and ctx.setTheme) */
553
- themeConfig?: ResolvedThemeConfig | null;
554
- /** Resolved rango state cookie name, for the server seat of invalidateClientCache(). */
555
- stateCookieName?: string;
556
- /** Build version, used as the prefix of a server-rotated rango state value. */
557
- version?: string;
558
- }
559
- /**
560
- * Create a full request context with all methods implemented
561
- *
562
- * This is used by the RSC handler to create the unified context that's:
563
- * - Available via getRequestContext() throughout the request
564
- * - Passed to middleware as ctx
565
- * - Passed to handlers as ctx
566
- */
567
- export declare function createRequestContext<TEnv>(options: CreateRequestContextOptions<TEnv>): RequestContext<TEnv>;
568
- /**
569
- * Wire a fresh render barrier onto `ctx`, closure-bound to THIS ctx and THIS
570
- * handle store. Called by createRequestContext for every fresh context, and by
571
- * deriveShellCaptureContext (rsc/shell-capture.ts) for the PPR capture's
572
- * derived context.
573
- *
574
- * The derived-context call is load-bearing (issue #684, plan 009): the capture
575
- * context is `Object.create(reqCtx)`, so without its own wiring every
576
- * `_renderBarrier*` read fell through the prototype to the FOREGROUND
577
- * request's barrier — whose getter and resolver are closure-bound to the
578
- * foreground ctx and its handle store, and whose resolver no-ops once
579
- * resolved. A bake-lane loader's `await ctx.rendered()` during capture then
580
- * resolved instantly against the foreground's barrier and `ctx.use(handle)`
581
- * read the foreground's handle snapshot; the capture's fresh `_handleStore`
582
- * was invisible, so foreground per-request handle data could bake into the
583
- * shared shell.
584
- */
585
- export declare function wireRenderBarrier(ctx: RequestContext<any, any>, handleStore: HandleStore): void;
586
- export { parseCookiesFromHeader };
587
- export declare function serializeCookieValue(name: string, value: string, options?: CookieOptions): string;
588
- /**
589
- * Options for creating the use() function
590
- */
591
- export interface CreateUseFunctionOptions<TEnv> {
592
- handleStore: HandleStore;
593
- loaderPromises: Map<string, Promise<any>>;
594
- getContext: () => RequestContext<TEnv>;
595
- }
596
- export declare function createUseFunction<TEnv>(options: CreateUseFunctionOptions<TEnv>): RequestContext["use"];
@@ -1,3 +0,0 @@
1
- import type { ReactNode } from "react";
2
- declare const MapRootLayout: ReactNode;
3
- export default MapRootLayout;
@@ -1,15 +0,0 @@
1
- /**
2
- * @rangojs/router/server — Internal subpath
3
- *
4
- * This module is NOT user-facing. Import from "@rangojs/router" instead.
5
- *
6
- * Exports here are consumed by the Vite plugin (discovery, manifest injection,
7
- * virtual modules) and the RSC handler internals. They are not part of the
8
- * public API and may change without notice.
9
- */
10
- export { RSC_ROUTER_BRAND, RouterRegistry } from "./router.js";
11
- export { HostRouterRegistry, type HostRouterRegistryEntry, } from "./host/router.js";
12
- export { registerRouteMap, setCachedManifest, clearCachedManifest, clearAllRouterData, getGlobalRouteMap, getRouterManifest, setPrecomputedEntries, setRouteTrie, setManifestReadyPromise, setRouterManifest, setRouterTrie, setRouterPrecomputedEntries, registerRouterManifestLoader, ensureRouterManifest, } from "./route-map-builder.js";
13
- export { registerLoaderById, setLoaderImports, } from "./server/loader-registry.js";
14
- export { createRequestContext, type CreateRequestContextOptions, } from "./server/request-context.js";
15
- export { isClientComponent, assertClientComponent } from "./component-utils.js";