@rangojs/router 0.5.1 → 0.5.2

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 (448) hide show
  1. package/README.md +5 -1
  2. package/dist/types/browser/event-controller.d.ts +6 -0
  3. package/dist/types/cache/cf/cf-cache-constants.d.ts +8 -1
  4. package/dist/types/cache/cf/cf-cache-store.d.ts +15 -1
  5. package/dist/types/cache/cf/cf-cache-types.d.ts +1 -1
  6. package/dist/types/cache/cf/cf-kv-utils.d.ts +21 -0
  7. package/dist/types/handles/is-thenable.d.ts +2 -4
  8. package/dist/types/rsc/helpers.d.ts +3 -0
  9. package/dist/types/rsc/render-pipeline.d.ts +9 -0
  10. package/dist/types/rsc/routine-plan.d.ts +124 -0
  11. package/dist/types/rsc/shell-capture-constants.d.ts +17 -0
  12. package/dist/types/server/request-context.d.ts +4 -1
  13. package/dist/types/vite/encryption-key.d.ts +2 -0
  14. package/dist/types/vite/plugins/expose-internal-ids.d.ts +10 -0
  15. package/dist/types/vite/plugins/server-ref-hashing.d.ts +24 -0
  16. package/dist/types/vite/plugins/server-reference-pattern.d.ts +1 -0
  17. package/dist/types/vite/utils/shared-utils.d.ts +12 -0
  18. package/dist/vite/index.js +154 -57
  19. package/package.json +3 -3
  20. package/skills/caching/SKILL.md +1 -1
  21. package/skills/mime-routes/SKILL.md +3 -1
  22. package/skills/response-routes/SKILL.md +4 -2
  23. package/skills/typesafety/generated-files-and-cli.md +16 -9
  24. package/skills/typesafety/route-types.md +5 -1
  25. package/skills/use-cache/SKILL.md +47 -0
  26. package/src/browser/event-controller.ts +40 -15
  27. package/src/browser/partial-update.ts +26 -11
  28. package/src/browser/react/NavigationProvider.tsx +7 -0
  29. package/src/cache/cache-runtime.ts +89 -15
  30. package/src/cache/cf/cf-cache-constants.ts +8 -1
  31. package/src/cache/cf/cf-cache-store.ts +41 -64
  32. package/src/cache/cf/cf-cache-types.ts +1 -1
  33. package/src/cache/cf/cf-kv-utils.ts +38 -0
  34. package/src/cache/segment-codec.ts +21 -5
  35. package/src/handles/is-thenable.ts +2 -4
  36. package/src/router/match-middleware/cache-lookup.ts +24 -15
  37. package/src/rsc/handler.ts +26 -5
  38. package/src/rsc/helpers.ts +13 -0
  39. package/src/rsc/progressive-enhancement.ts +247 -70
  40. package/src/rsc/render-pipeline.ts +68 -24
  41. package/src/rsc/routine-plan.ts +359 -0
  42. package/src/rsc/rsc-rendering.ts +555 -302
  43. package/src/rsc/server-action.ts +180 -71
  44. package/src/rsc/shell-capture-constants.ts +18 -0
  45. package/src/rsc/shell-capture.ts +92 -21
  46. package/src/server/request-context.ts +6 -0
  47. package/src/ssr/ssr-root.tsx +1 -0
  48. package/src/vite/encryption-key.ts +29 -0
  49. package/src/vite/plugins/expose-action-id.ts +2 -2
  50. package/src/vite/plugins/expose-internal-ids.ts +46 -0
  51. package/src/vite/plugins/server-ref-hashing.ts +74 -0
  52. package/src/vite/plugins/server-reference-pattern.ts +10 -0
  53. package/src/vite/rango.ts +9 -0
  54. package/src/vite/router-discovery.ts +21 -2
  55. package/src/vite/utils/shared-utils.ts +12 -7
  56. package/dist/types.backup/__internal.d.ts +0 -127
  57. package/dist/types.backup/bin/rango.d.ts +0 -1
  58. package/dist/types.backup/browser/action-coordinator.d.ts +0 -57
  59. package/dist/types.backup/browser/action-fence.d.ts +0 -33
  60. package/dist/types.backup/browser/app-shell.d.ts +0 -34
  61. package/dist/types.backup/browser/app-version.d.ts +0 -6
  62. package/dist/types.backup/browser/connection-warmup.d.ts +0 -31
  63. package/dist/types.backup/browser/cookie-name.d.ts +0 -66
  64. package/dist/types.backup/browser/event-controller.d.ts +0 -221
  65. package/dist/types.backup/browser/history-state.d.ts +0 -26
  66. package/dist/types.backup/browser/index.d.ts +0 -1
  67. package/dist/types.backup/browser/intercept-utils.d.ts +0 -30
  68. package/dist/types.backup/browser/invalidate-client-cache.d.ts +0 -17
  69. package/dist/types.backup/browser/link-interceptor.d.ts +0 -43
  70. package/dist/types.backup/browser/logging.d.ts +0 -33
  71. package/dist/types.backup/browser/merge-segment-loaders.d.ts +0 -38
  72. package/dist/types.backup/browser/navigation-bridge.d.ts +0 -27
  73. package/dist/types.backup/browser/navigation-client.d.ts +0 -17
  74. package/dist/types.backup/browser/navigation-store-handle.d.ts +0 -25
  75. package/dist/types.backup/browser/navigation-store.d.ts +0 -95
  76. package/dist/types.backup/browser/navigation-transaction.d.ts +0 -75
  77. package/dist/types.backup/browser/network-error-handler.d.ts +0 -35
  78. package/dist/types.backup/browser/partial-update.d.ts +0 -61
  79. package/dist/types.backup/browser/prefetch/cache.d.ts +0 -183
  80. package/dist/types.backup/browser/prefetch/fetch.d.ts +0 -52
  81. package/dist/types.backup/browser/prefetch/observer.d.ts +0 -27
  82. package/dist/types.backup/browser/prefetch/policy.d.ts +0 -13
  83. package/dist/types.backup/browser/prefetch/queue.d.ts +0 -48
  84. package/dist/types.backup/browser/prefetch/resource-ready.d.ts +0 -28
  85. package/dist/types.backup/browser/rango-state.d.ts +0 -52
  86. package/dist/types.backup/browser/react/Link.d.ts +0 -140
  87. package/dist/types.backup/browser/react/NavigationProvider.d.ts +0 -88
  88. package/dist/types.backup/browser/react/ScrollRestoration.d.ts +0 -78
  89. package/dist/types.backup/browser/react/context.d.ts +0 -54
  90. package/dist/types.backup/browser/react/filter-segment-order.d.ts +0 -35
  91. package/dist/types.backup/browser/react/index.d.ts +0 -1
  92. package/dist/types.backup/browser/react/location-state-shared.d.ts +0 -162
  93. package/dist/types.backup/browser/react/location-state.d.ts +0 -29
  94. package/dist/types.backup/browser/react/mount-context.d.ts +0 -23
  95. package/dist/types.backup/browser/react/nonce-context.d.ts +0 -14
  96. package/dist/types.backup/browser/react/shallow-equal.d.ts +0 -5
  97. package/dist/types.backup/browser/react/use-action.d.ts +0 -61
  98. package/dist/types.backup/browser/react/use-handle.d.ts +0 -21
  99. package/dist/types.backup/browser/react/use-href.d.ts +0 -32
  100. package/dist/types.backup/browser/react/use-link-status.d.ts +0 -36
  101. package/dist/types.backup/browser/react/use-mount.d.ts +0 -24
  102. package/dist/types.backup/browser/react/use-navigation.d.ts +0 -15
  103. package/dist/types.backup/browser/react/use-params.d.ts +0 -21
  104. package/dist/types.backup/browser/react/use-pathname.d.ts +0 -13
  105. package/dist/types.backup/browser/react/use-reverse.d.ts +0 -40
  106. package/dist/types.backup/browser/react/use-router.d.ts +0 -23
  107. package/dist/types.backup/browser/react/use-search-params.d.ts +0 -19
  108. package/dist/types.backup/browser/react/use-segments.d.ts +0 -29
  109. package/dist/types.backup/browser/response-adapter.d.ts +0 -58
  110. package/dist/types.backup/browser/rsc-router.d.ts +0 -141
  111. package/dist/types.backup/browser/scroll-restoration.d.ts +0 -103
  112. package/dist/types.backup/browser/segment-reconciler.d.ts +0 -74
  113. package/dist/types.backup/browser/segment-structure-assert.d.ts +0 -16
  114. package/dist/types.backup/browser/server-action-bridge.d.ts +0 -29
  115. package/dist/types.backup/browser/types.d.ts +0 -530
  116. package/dist/types.backup/browser/validate-redirect-origin.d.ts +0 -28
  117. package/dist/types.backup/build/collect-fallback-refs.d.ts +0 -5
  118. package/dist/types.backup/build/generate-manifest.d.ts +0 -100
  119. package/dist/types.backup/build/generate-route-types.d.ts +0 -8
  120. package/dist/types.backup/build/index.d.ts +0 -21
  121. package/dist/types.backup/build/prefix-tree-utils.d.ts +0 -56
  122. package/dist/types.backup/build/route-trie.d.ts +0 -89
  123. package/dist/types.backup/build/route-types/ast-helpers.d.ts +0 -3
  124. package/dist/types.backup/build/route-types/ast-route-extraction.d.ts +0 -13
  125. package/dist/types.backup/build/route-types/codegen.d.ts +0 -16
  126. package/dist/types.backup/build/route-types/include-resolution.d.ts +0 -74
  127. package/dist/types.backup/build/route-types/param-extraction.d.ts +0 -13
  128. package/dist/types.backup/build/route-types/per-module-writer.d.ts +0 -18
  129. package/dist/types.backup/build/route-types/router-processing.d.ts +0 -82
  130. package/dist/types.backup/build/route-types/scan-filter.d.ts +0 -17
  131. package/dist/types.backup/build/route-types/source-scan.d.ts +0 -13
  132. package/dist/types.backup/build/runtime-discovery.d.ts +0 -24
  133. package/dist/types.backup/cache/background-task.d.ts +0 -21
  134. package/dist/types.backup/cache/cache-error.d.ts +0 -71
  135. package/dist/types.backup/cache/cache-key-utils.d.ts +0 -35
  136. package/dist/types.backup/cache/cache-policy.d.ts +0 -59
  137. package/dist/types.backup/cache/cache-runtime.d.ts +0 -51
  138. package/dist/types.backup/cache/cache-scope.d.ts +0 -134
  139. package/dist/types.backup/cache/cache-tag.d.ts +0 -79
  140. package/dist/types.backup/cache/cf/cf-base64.d.ts +0 -4
  141. package/dist/types.backup/cache/cf/cf-cache-constants.d.ts +0 -105
  142. package/dist/types.backup/cache/cf/cf-cache-store.d.ts +0 -481
  143. package/dist/types.backup/cache/cf/cf-cache-types.d.ts +0 -300
  144. package/dist/types.backup/cache/cf/cf-kv-utils.d.ts +0 -22
  145. package/dist/types.backup/cache/cf/cf-tag-marker-memo.d.ts +0 -15
  146. package/dist/types.backup/cache/cf/index.d.ts +0 -3
  147. package/dist/types.backup/cache/document-cache.d.ts +0 -69
  148. package/dist/types.backup/cache/handle-capture.d.ts +0 -23
  149. package/dist/types.backup/cache/handle-snapshot.d.ts +0 -39
  150. package/dist/types.backup/cache/index.d.ts +0 -7
  151. package/dist/types.backup/cache/memory-segment-store.d.ts +0 -163
  152. package/dist/types.backup/cache/profile-registry.d.ts +0 -40
  153. package/dist/types.backup/cache/read-through-swr.d.ts +0 -60
  154. package/dist/types.backup/cache/segment-codec.d.ts +0 -78
  155. package/dist/types.backup/cache/shell-snapshot.d.ts +0 -162
  156. package/dist/types.backup/cache/tag-invalidation.d.ts +0 -74
  157. package/dist/types.backup/cache/taint.d.ts +0 -71
  158. package/dist/types.backup/cache/types.d.ts +0 -407
  159. package/dist/types.backup/cache/vercel/index.d.ts +0 -1
  160. package/dist/types.backup/cache/vercel/vercel-cache-store.d.ts +0 -267
  161. package/dist/types.backup/client.d.ts +0 -184
  162. package/dist/types.backup/client.rsc.d.ts +0 -39
  163. package/dist/types.backup/cloudflare/index.d.ts +0 -7
  164. package/dist/types.backup/cloudflare/tracing.d.ts +0 -53
  165. package/dist/types.backup/component-utils.d.ts +0 -46
  166. package/dist/types.backup/components/DefaultDocument.d.ts +0 -13
  167. package/dist/types.backup/context-var.d.ts +0 -84
  168. package/dist/types.backup/debug.d.ts +0 -57
  169. package/dist/types.backup/decode-loader-results.d.ts +0 -5
  170. package/dist/types.backup/default-error-boundary.d.ts +0 -10
  171. package/dist/types.backup/defer.d.ts +0 -89
  172. package/dist/types.backup/deps/browser.d.ts +0 -1
  173. package/dist/types.backup/deps/html-stream-client.d.ts +0 -1
  174. package/dist/types.backup/deps/html-stream-server.d.ts +0 -1
  175. package/dist/types.backup/deps/rsc.d.ts +0 -1
  176. package/dist/types.backup/deps/ssr.d.ts +0 -1
  177. package/dist/types.backup/encode-kv.d.ts +0 -35
  178. package/dist/types.backup/errors.d.ts +0 -226
  179. package/dist/types.backup/escape-script.d.ts +0 -44
  180. package/dist/types.backup/handle.d.ts +0 -93
  181. package/dist/types.backup/handles/MetaTags.d.ts +0 -17
  182. package/dist/types.backup/handles/Scripts.d.ts +0 -38
  183. package/dist/types.backup/handles/breadcrumbs.d.ts +0 -43
  184. package/dist/types.backup/handles/deferred-resolution.d.ts +0 -53
  185. package/dist/types.backup/handles/is-thenable.d.ts +0 -12
  186. package/dist/types.backup/handles/meta.d.ts +0 -43
  187. package/dist/types.backup/handles/script.d.ts +0 -139
  188. package/dist/types.backup/host/cookie-handler.d.ts +0 -8
  189. package/dist/types.backup/host/errors.d.ts +0 -40
  190. package/dist/types.backup/host/index.d.ts +0 -33
  191. package/dist/types.backup/host/pattern-matcher.d.ts +0 -30
  192. package/dist/types.backup/host/router.d.ts +0 -12
  193. package/dist/types.backup/host/testing.d.ts +0 -41
  194. package/dist/types.backup/host/types.d.ts +0 -148
  195. package/dist/types.backup/host/utils.d.ts +0 -20
  196. package/dist/types.backup/href-client.d.ts +0 -214
  197. package/dist/types.backup/index.d.ts +0 -112
  198. package/dist/types.backup/index.rsc.d.ts +0 -51
  199. package/dist/types.backup/internal-debug.d.ts +0 -1
  200. package/dist/types.backup/loader-store.d.ts +0 -193
  201. package/dist/types.backup/loader.d.ts +0 -18
  202. package/dist/types.backup/loader.rsc.d.ts +0 -18
  203. package/dist/types.backup/missing-id-error.d.ts +0 -1
  204. package/dist/types.backup/outlet-context.d.ts +0 -12
  205. package/dist/types.backup/outlet-provider.d.ts +0 -12
  206. package/dist/types.backup/prerender/build-shell-capture.d.ts +0 -104
  207. package/dist/types.backup/prerender/param-hash.d.ts +0 -6
  208. package/dist/types.backup/prerender/shell-manifest-key.d.ts +0 -18
  209. package/dist/types.backup/prerender/store.d.ts +0 -62
  210. package/dist/types.backup/prerender.d.ts +0 -292
  211. package/dist/types.backup/redirect-origin.d.ts +0 -55
  212. package/dist/types.backup/regex-escape.d.ts +0 -6
  213. package/dist/types.backup/render-error-thrower.d.ts +0 -13
  214. package/dist/types.backup/response-utils.d.ts +0 -35
  215. package/dist/types.backup/reverse.d.ts +0 -206
  216. package/dist/types.backup/root-error-boundary.d.ts +0 -32
  217. package/dist/types.backup/route-content-wrapper.d.ts +0 -40
  218. package/dist/types.backup/route-definition/dsl-helpers.d.ts +0 -130
  219. package/dist/types.backup/route-definition/helper-factories.d.ts +0 -22
  220. package/dist/types.backup/route-definition/helpers-types.d.ts +0 -392
  221. package/dist/types.backup/route-definition/index.d.ts +0 -7
  222. package/dist/types.backup/route-definition/redirect.d.ts +0 -48
  223. package/dist/types.backup/route-definition/resolve-handler-use.d.ts +0 -19
  224. package/dist/types.backup/route-definition/use-item-types.d.ts +0 -1
  225. package/dist/types.backup/route-definition.d.ts +0 -1
  226. package/dist/types.backup/route-map-builder.d.ts +0 -127
  227. package/dist/types.backup/route-name.d.ts +0 -27
  228. package/dist/types.backup/route-types.d.ts +0 -172
  229. package/dist/types.backup/router/basename.d.ts +0 -10
  230. package/dist/types.backup/router/content-negotiation.d.ts +0 -91
  231. package/dist/types.backup/router/debug-manifest.d.ts +0 -7
  232. package/dist/types.backup/router/error-handling.d.ts +0 -76
  233. package/dist/types.backup/router/find-match.d.ts +0 -19
  234. package/dist/types.backup/router/handler-context.d.ts +0 -41
  235. package/dist/types.backup/router/instrument.d.ts +0 -161
  236. package/dist/types.backup/router/intercept-resolution.d.ts +0 -79
  237. package/dist/types.backup/router/lazy-includes.d.ts +0 -26
  238. package/dist/types.backup/router/loader-resolution.d.ts +0 -63
  239. package/dist/types.backup/router/logging.d.ts +0 -41
  240. package/dist/types.backup/router/manifest.d.ts +0 -8
  241. package/dist/types.backup/router/match-api.d.ts +0 -19
  242. package/dist/types.backup/router/match-context.d.ts +0 -184
  243. package/dist/types.backup/router/match-handlers.d.ts +0 -49
  244. package/dist/types.backup/router/match-middleware/background-revalidation.d.ts +0 -113
  245. package/dist/types.backup/router/match-middleware/cache-lookup.d.ts +0 -113
  246. package/dist/types.backup/router/match-middleware/cache-store.d.ts +0 -112
  247. package/dist/types.backup/router/match-middleware/index.d.ts +0 -80
  248. package/dist/types.backup/router/match-middleware/intercept-resolution.d.ts +0 -116
  249. package/dist/types.backup/router/match-middleware/segment-resolution.d.ts +0 -94
  250. package/dist/types.backup/router/match-pipelines.d.ts +0 -103
  251. package/dist/types.backup/router/match-result.d.ts +0 -114
  252. package/dist/types.backup/router/metrics.d.ts +0 -6
  253. package/dist/types.backup/router/middleware-types.d.ts +0 -74
  254. package/dist/types.backup/router/middleware.d.ts +0 -116
  255. package/dist/types.backup/router/navigation-snapshot.d.ts +0 -22
  256. package/dist/types.backup/router/params-util.d.ts +0 -8
  257. package/dist/types.backup/router/parse-pattern.d.ts +0 -38
  258. package/dist/types.backup/router/pattern-matching.d.ts +0 -169
  259. package/dist/types.backup/router/prefetch-cache-ttl.d.ts +0 -27
  260. package/dist/types.backup/router/prefetch-limits.d.ts +0 -20
  261. package/dist/types.backup/router/prerender-match.d.ts +0 -50
  262. package/dist/types.backup/router/preview-match.d.ts +0 -22
  263. package/dist/types.backup/router/request-classification.d.ts +0 -104
  264. package/dist/types.backup/router/revalidation.d.ts +0 -57
  265. package/dist/types.backup/router/route-snapshot.d.ts +0 -112
  266. package/dist/types.backup/router/router-context.d.ts +0 -137
  267. package/dist/types.backup/router/router-interfaces.d.ts +0 -432
  268. package/dist/types.backup/router/router-options.d.ts +0 -738
  269. package/dist/types.backup/router/router-registry.d.ts +0 -15
  270. package/dist/types.backup/router/segment-resolution/fresh.d.ts +0 -55
  271. package/dist/types.backup/router/segment-resolution/helpers.d.ts +0 -93
  272. package/dist/types.backup/router/segment-resolution/loader-cache.d.ts +0 -33
  273. package/dist/types.backup/router/segment-resolution/loader-mask.d.ts +0 -44
  274. package/dist/types.backup/router/segment-resolution/loader-snapshot.d.ts +0 -90
  275. package/dist/types.backup/router/segment-resolution/mask-nested.d.ts +0 -53
  276. package/dist/types.backup/router/segment-resolution/revalidation.d.ts +0 -85
  277. package/dist/types.backup/router/segment-resolution/static-store.d.ts +0 -17
  278. package/dist/types.backup/router/segment-resolution/streamed-handler-telemetry.d.ts +0 -16
  279. package/dist/types.backup/router/segment-resolution/view-transition-default.d.ts +0 -28
  280. package/dist/types.backup/router/segment-resolution.d.ts +0 -3
  281. package/dist/types.backup/router/segment-wrappers.d.ts +0 -53
  282. package/dist/types.backup/router/state-cookie-name.d.ts +0 -1
  283. package/dist/types.backup/router/substitute-pattern-params.d.ts +0 -23
  284. package/dist/types.backup/router/telemetry-otel.d.ts +0 -113
  285. package/dist/types.backup/router/telemetry.d.ts +0 -215
  286. package/dist/types.backup/router/timeout.d.ts +0 -68
  287. package/dist/types.backup/router/tracing.d.ts +0 -125
  288. package/dist/types.backup/router/trie-matching.d.ts +0 -32
  289. package/dist/types.backup/router/types.d.ts +0 -98
  290. package/dist/types.backup/router/url-params.d.ts +0 -26
  291. package/dist/types.backup/router.d.ts +0 -7
  292. package/dist/types.backup/rsc/capture-queue.d.ts +0 -6
  293. package/dist/types.backup/rsc/full-payload.d.ts +0 -22
  294. package/dist/types.backup/rsc/handler-context.d.ts +0 -31
  295. package/dist/types.backup/rsc/handler.d.ts +0 -9
  296. package/dist/types.backup/rsc/helpers.d.ts +0 -213
  297. package/dist/types.backup/rsc/index.d.ts +0 -17
  298. package/dist/types.backup/rsc/json-route-result.d.ts +0 -20
  299. package/dist/types.backup/rsc/loader-fetch.d.ts +0 -14
  300. package/dist/types.backup/rsc/manifest-init.d.ts +0 -18
  301. package/dist/types.backup/rsc/nonce.d.ts +0 -28
  302. package/dist/types.backup/rsc/origin-guard.d.ts +0 -50
  303. package/dist/types.backup/rsc/progressive-enhancement.d.ts +0 -19
  304. package/dist/types.backup/rsc/redirect-guard.d.ts +0 -35
  305. package/dist/types.backup/rsc/response-cache-serve.d.ts +0 -46
  306. package/dist/types.backup/rsc/response-error.d.ts +0 -19
  307. package/dist/types.backup/rsc/response-route-handler.d.ts +0 -29
  308. package/dist/types.backup/rsc/rsc-rendering.d.ts +0 -23
  309. package/dist/types.backup/rsc/runtime-warnings.d.ts +0 -22
  310. package/dist/types.backup/rsc/server-action.d.ts +0 -68
  311. package/dist/types.backup/rsc/shell-build-manifest.d.ts +0 -84
  312. package/dist/types.backup/rsc/shell-capture-constants.d.ts +0 -27
  313. package/dist/types.backup/rsc/shell-capture.d.ts +0 -374
  314. package/dist/types.backup/rsc/shell-serve.d.ts +0 -136
  315. package/dist/types.backup/rsc/ssr-setup.d.ts +0 -48
  316. package/dist/types.backup/rsc/transition-gate.d.ts +0 -27
  317. package/dist/types.backup/rsc/types.d.ts +0 -290
  318. package/dist/types.backup/runtime-env.d.ts +0 -1
  319. package/dist/types.backup/search-params.d.ts +0 -125
  320. package/dist/types.backup/segment-content-promise.d.ts +0 -13
  321. package/dist/types.backup/segment-fragments.d.ts +0 -56
  322. package/dist/types.backup/segment-loader-promise.d.ts +0 -22
  323. package/dist/types.backup/segment-system.d.ts +0 -84
  324. package/dist/types.backup/serialize.d.ts +0 -164
  325. package/dist/types.backup/server/context.d.ts +0 -494
  326. package/dist/types.backup/server/cookie-parse.d.ts +0 -10
  327. package/dist/types.backup/server/cookie-store.d.ts +0 -107
  328. package/dist/types.backup/server/fetchable-loader-store.d.ts +0 -20
  329. package/dist/types.backup/server/handle-store.d.ts +0 -100
  330. package/dist/types.backup/server/loader-registry.d.ts +0 -32
  331. package/dist/types.backup/server/request-context.d.ts +0 -596
  332. package/dist/types.backup/server/root-layout.d.ts +0 -3
  333. package/dist/types.backup/server.d.ts +0 -15
  334. package/dist/types.backup/ssr/index.d.ts +0 -233
  335. package/dist/types.backup/ssr/inject-rsc-eager.d.ts +0 -3
  336. package/dist/types.backup/ssr/preinit-client-references.d.ts +0 -71
  337. package/dist/types.backup/ssr/ssr-root.d.ts +0 -69
  338. package/dist/types.backup/static-handler.d.ts +0 -57
  339. package/dist/types.backup/testing/cache-status.d.ts +0 -63
  340. package/dist/types.backup/testing/collect-handle.d.ts +0 -20
  341. package/dist/types.backup/testing/dispatch.d.ts +0 -123
  342. package/dist/types.backup/testing/dom.entry.d.ts +0 -15
  343. package/dist/types.backup/testing/e2e/fixture.d.ts +0 -37
  344. package/dist/types.backup/testing/e2e/index.d.ts +0 -30
  345. package/dist/types.backup/testing/e2e/matchers.d.ts +0 -17
  346. package/dist/types.backup/testing/e2e/page-helpers.d.ts +0 -62
  347. package/dist/types.backup/testing/e2e/parity.d.ts +0 -111
  348. package/dist/types.backup/testing/e2e/server.d.ts +0 -35
  349. package/dist/types.backup/testing/flight-matchers.d.ts +0 -55
  350. package/dist/types.backup/testing/flight-normalize.d.ts +0 -1
  351. package/dist/types.backup/testing/flight-tree.d.ts +0 -192
  352. package/dist/types.backup/testing/flight.d.ts +0 -115
  353. package/dist/types.backup/testing/flight.entry.d.ts +0 -27
  354. package/dist/types.backup/testing/generated-routes.d.ts +0 -66
  355. package/dist/types.backup/testing/index.d.ts +0 -52
  356. package/dist/types.backup/testing/internal/context.d.ts +0 -225
  357. package/dist/types.backup/testing/internal/flight-client-globals.d.ts +0 -1
  358. package/dist/types.backup/testing/internal/seed-vars.d.ts +0 -30
  359. package/dist/types.backup/testing/render-handler.d.ts +0 -160
  360. package/dist/types.backup/testing/render-route.d.ts +0 -246
  361. package/dist/types.backup/testing/run-loader.d.ts +0 -186
  362. package/dist/types.backup/testing/run-middleware.d.ts +0 -132
  363. package/dist/types.backup/testing/run-transition-when.d.ts +0 -77
  364. package/dist/types.backup/testing/vitest-stubs/cloudflare-email.d.ts +0 -6
  365. package/dist/types.backup/testing/vitest-stubs/cloudflare-workers.d.ts +0 -13
  366. package/dist/types.backup/testing/vitest-stubs/plugin-rsc.d.ts +0 -7
  367. package/dist/types.backup/testing/vitest-stubs/version.d.ts +0 -1
  368. package/dist/types.backup/testing/vitest.d.ts +0 -205
  369. package/dist/types.backup/theme/ThemeProvider.d.ts +0 -13
  370. package/dist/types.backup/theme/ThemeScript.d.ts +0 -45
  371. package/dist/types.backup/theme/constants.d.ts +0 -39
  372. package/dist/types.backup/theme/index.d.ts +0 -29
  373. package/dist/types.backup/theme/theme-context.d.ts +0 -21
  374. package/dist/types.backup/theme/theme-script.d.ts +0 -26
  375. package/dist/types.backup/theme/types.d.ts +0 -162
  376. package/dist/types.backup/theme/use-theme.d.ts +0 -8
  377. package/dist/types.backup/types/boundaries.d.ts +0 -93
  378. package/dist/types.backup/types/cache-types.d.ts +0 -191
  379. package/dist/types.backup/types/error-types.d.ts +0 -114
  380. package/dist/types.backup/types/global-namespace.d.ts +0 -90
  381. package/dist/types.backup/types/handler-context.d.ts +0 -658
  382. package/dist/types.backup/types/index.d.ts +0 -11
  383. package/dist/types.backup/types/loader-types.d.ts +0 -182
  384. package/dist/types.backup/types/request-scope.d.ts +0 -93
  385. package/dist/types.backup/types/route-config.d.ts +0 -105
  386. package/dist/types.backup/types/route-entry.d.ts +0 -95
  387. package/dist/types.backup/types/segments.d.ts +0 -234
  388. package/dist/types.backup/types.d.ts +0 -1
  389. package/dist/types.backup/urls/include-helper.d.ts +0 -17
  390. package/dist/types.backup/urls/include-provider.d.ts +0 -27
  391. package/dist/types.backup/urls/index.d.ts +0 -6
  392. package/dist/types.backup/urls/path-helper-types.d.ts +0 -197
  393. package/dist/types.backup/urls/path-helper.d.ts +0 -12
  394. package/dist/types.backup/urls/pattern-types.d.ts +0 -166
  395. package/dist/types.backup/urls/response-types.d.ts +0 -67
  396. package/dist/types.backup/urls/type-extraction.d.ts +0 -157
  397. package/dist/types.backup/urls/urls-function.d.ts +0 -24
  398. package/dist/types.backup/urls.d.ts +0 -1
  399. package/dist/types.backup/use-loader.d.ts +0 -150
  400. package/dist/types.backup/vercel/index.d.ts +0 -10
  401. package/dist/types.backup/vercel/tracing.d.ts +0 -70
  402. package/dist/types.backup/vite/debug.d.ts +0 -80
  403. package/dist/types.backup/vite/discovery/bundle-postprocess.d.ts +0 -12
  404. package/dist/types.backup/vite/discovery/dev-prerender-cache.d.ts +0 -65
  405. package/dist/types.backup/vite/discovery/discover-routers.d.ts +0 -17
  406. package/dist/types.backup/vite/discovery/discovery-errors.d.ts +0 -113
  407. package/dist/types.backup/vite/discovery/gate-state.d.ts +0 -79
  408. package/dist/types.backup/vite/discovery/prerender-collection.d.ts +0 -24
  409. package/dist/types.backup/vite/discovery/route-types-writer.d.ts +0 -32
  410. package/dist/types.backup/vite/discovery/self-gen-tracking.d.ts +0 -22
  411. package/dist/types.backup/vite/discovery/shell-prerender-phase.d.ts +0 -40
  412. package/dist/types.backup/vite/discovery/state.d.ts +0 -162
  413. package/dist/types.backup/vite/discovery/virtual-module-codegen.d.ts +0 -15
  414. package/dist/types.backup/vite/index.d.ts +0 -11
  415. package/dist/types.backup/vite/inject-client-debug.d.ts +0 -56
  416. package/dist/types.backup/vite/plugin-types.d.ts +0 -298
  417. package/dist/types.backup/vite/plugins/cjs-to-esm.d.ts +0 -6
  418. package/dist/types.backup/vite/plugins/client-ref-dedup.d.ts +0 -40
  419. package/dist/types.backup/vite/plugins/client-ref-hashing.d.ts +0 -35
  420. package/dist/types.backup/vite/plugins/cloudflare-protocol-stub.d.ts +0 -64
  421. package/dist/types.backup/vite/plugins/expose-action-id.d.ts +0 -18
  422. package/dist/types.backup/vite/plugins/expose-id-utils.d.ts +0 -37
  423. package/dist/types.backup/vite/plugins/expose-ids/export-analysis.d.ts +0 -19
  424. package/dist/types.backup/vite/plugins/expose-ids/handler-transform.d.ts +0 -10
  425. package/dist/types.backup/vite/plugins/expose-ids/loader-transform.d.ts +0 -8
  426. package/dist/types.backup/vite/plugins/expose-ids/router-transform.d.ts +0 -13
  427. package/dist/types.backup/vite/plugins/expose-ids/types.d.ts +0 -29
  428. package/dist/types.backup/vite/plugins/expose-internal-ids.d.ts +0 -6
  429. package/dist/types.backup/vite/plugins/performance-tracks.d.ts +0 -25
  430. package/dist/types.backup/vite/plugins/refresh-cmd.d.ts +0 -20
  431. package/dist/types.backup/vite/plugins/use-cache-transform.d.ts +0 -20
  432. package/dist/types.backup/vite/plugins/vercel-output.d.ts +0 -85
  433. package/dist/types.backup/vite/plugins/version-injector.d.ts +0 -21
  434. package/dist/types.backup/vite/plugins/version-plugin.d.ts +0 -19
  435. package/dist/types.backup/vite/plugins/virtual-entries.d.ts +0 -36
  436. package/dist/types.backup/vite/plugins/virtual-stub-plugin.d.ts +0 -7
  437. package/dist/types.backup/vite/rango.d.ts +0 -29
  438. package/dist/types.backup/vite/router-discovery.d.ts +0 -23
  439. package/dist/types.backup/vite/utils/ast-handler-extract.d.ts +0 -64
  440. package/dist/types.backup/vite/utils/banner.d.ts +0 -2
  441. package/dist/types.backup/vite/utils/bundle-analysis.d.ts +0 -28
  442. package/dist/types.backup/vite/utils/client-chunks.d.ts +0 -55
  443. package/dist/types.backup/vite/utils/directive-prologue.d.ts +0 -16
  444. package/dist/types.backup/vite/utils/forward-user-plugins.d.ts +0 -37
  445. package/dist/types.backup/vite/utils/manifest-utils.d.ts +0 -7
  446. package/dist/types.backup/vite/utils/package-resolution.d.ts +0 -6
  447. package/dist/types.backup/vite/utils/prerender-utils.d.ts +0 -32
  448. package/dist/types.backup/vite/utils/shared-utils.d.ts +0 -55
@@ -1,74 +0,0 @@
1
- import type { ContextVar } from "../context-var.js";
2
- import type { DefaultReverseRouteMap, DefaultRouteName, DefaultVars } from "../types/global-namespace.js";
3
- import type { ScopedReverseFunction } from "../reverse.js";
4
- import type { Theme } from "../theme/types.js";
5
- import type { LocationStateEntry } from "../browser/react/location-state-shared.js";
6
- import type { RequestScope } from "../types/request-scope.js";
7
- type GetVariableFn = {
8
- <T>(contextVar: ContextVar<T>): T | undefined;
9
- <K extends keyof DefaultVars>(key: K): DefaultVars[K];
10
- };
11
- type SetVariableFn = {
12
- <T>(contextVar: ContextVar<T>, value: T, options?: {
13
- cache?: boolean;
14
- }): void;
15
- <K extends keyof DefaultVars>(key: K, value: DefaultVars[K], options?: {
16
- cache?: boolean;
17
- }): void;
18
- };
19
- export interface CookieOptions {
20
- domain?: string;
21
- path?: string;
22
- maxAge?: number;
23
- expires?: Date;
24
- httpOnly?: boolean;
25
- secure?: boolean;
26
- sameSite?: "strict" | "lax" | "none";
27
- }
28
- export interface MiddlewareContext<TEnv = any, TParams = Record<string, string | undefined>> extends RequestScope<TEnv> {
29
- params: TParams;
30
- /**
31
- * True for build-time render/capture requests. Live requests use false.
32
- * Build-time PPR shell capture sets this while replaying middleware.
33
- */
34
- readonly build: boolean;
35
- /**
36
- * Opt this request out of PPR shell serving/capture.
37
- * During middleware this runs before the shell HIT commit point, so it can
38
- * force the request onto the dynamic axis.
39
- *
40
- * Scope: the PPR SHELL axis only. It does NOT disable prerender B-segment
41
- * (Prerender/Static) serving — a Prerender() route still replays its
42
- * build-baked segments at runtime.
43
- */
44
- dynamic(): void;
45
- readonly headers: Headers;
46
- get: GetVariableFn;
47
- set: SetVariableFn;
48
- header(name: string, value: string): void;
49
- routeName?: DefaultRouteName;
50
- debugPerformance(): void;
51
- theme?: Theme;
52
- setTheme?: (theme: Theme) => void;
53
- setLocationState(entries: LocationStateEntry | LocationStateEntry[]): void;
54
- reverse: ScopedReverseFunction<Record<string, string>, DefaultReverseRouteMap>;
55
- }
56
- export type MiddlewareFn<TEnv = any, TParams = Record<string, string | undefined>> = (ctx: MiddlewareContext<TEnv, TParams>, next: () => Promise<Response>) => Response | void | Promise<Response | void>;
57
- export interface MiddlewareEntry<TEnv = any> {
58
- pattern: string | null;
59
- regex: RegExp | null;
60
- paramNames: string[];
61
- handler: MiddlewareFn<TEnv>;
62
- }
63
- export interface ResponseHolder {
64
- response: Response | null;
65
- }
66
- export interface MiddlewareCollectableEntry {
67
- middleware?: MiddlewareFn<any, any>[];
68
- layout?: MiddlewareCollectableEntry[];
69
- }
70
- export interface CollectedMiddleware {
71
- handler: MiddlewareFn<any, any>;
72
- params: Record<string, string>;
73
- }
74
- export {};
@@ -1,116 +0,0 @@
1
- import type { CollectedMiddleware, MiddlewareCollectableEntry, MiddlewareContext, MiddlewareEntry, MiddlewareFn, ResponseHolder } from "./middleware-types.js";
2
- export type { CookieOptions, MiddlewareContext, MiddlewareEntry, MiddlewareFn, } from "./middleware-types.js";
3
- /**
4
- * Compile a middleware scope pattern to a regex + param names.
5
- *
6
- * Middleware scopes reuse the route pattern parser (`parsePattern` from
7
- * pattern-matching.ts), so they support the same param forms as routes —
8
- * optional (`:x?`), constrained (`:x(en|gb)`), and suffix (`:x.html`) — in
9
- * addition to the trailing-`*` wildcard middleware relies on. Before this
10
- * unification the middleware-side parser handled only static, bare `:param`,
11
- * and trailing `*`, so e.g. `router.use("/:locale(en|gb)/*", mw)` silently
12
- * named the param "locale(en|gb)" and never enforced the constraint.
13
- *
14
- * Middleware matching semantics deliberately differ from route matching, so we
15
- * emit the regex here rather than route through `compilePattern`:
16
- * - `*` alone matches every path (`/^.*$/`).
17
- * - A trailing `*` segment is an OPTIONAL subtree match (`(?:/.*)?`): `/admin/*`
18
- * matches `/admin`, `/admin/`, and `/admin/users`. It contributes no param
19
- * name (unlike route wildcards, which capture `*`).
20
- * - A NON-trailing `*` is also OPTIONAL (`(?:/.*)?`), matching zero-or-more
21
- * intermediate segments: `/a/<star>/b` matches both `/a/b` and `/a/x/b`. This
22
- * mirrors the pre-unification parser, which compiled every `*` part as
23
- * optional regardless of position.
24
- * - A pattern without a trailing `*` tolerates a trailing slash (`/?$`).
25
- * - Constraints are baked into the regex as an alternation so `matchMiddleware`
26
- * (a bare `regex.test`) enforces them without extra validation. Constraint
27
- * values are matched against the raw (still URL-encoded) path segment, which
28
- * matches the pre-unification middleware behavior (it never decoded for
29
- * matching); the constraint string is regex-escaped so values like `en.gb`
30
- * are treated literally.
31
- *
32
- * The route segment parser only recognizes `/`-prefixed segments, but the
33
- * pre-unification middleware parser split on `/` and dropped empty parts, so a
34
- * leading slash was irrelevant: `use("admin/*")` and `use("/admin/*")` scoped
35
- * identically. Normalize a non-`*` pattern to have a leading slash before
36
- * parsing so that behavior is preserved (without it, `parseRoutePattern("admin/*")`
37
- * drops the static `admin` and the scope explodes to every path).
38
- */
39
- export declare function compileMiddlewarePattern(pattern: string): {
40
- regex: RegExp;
41
- paramNames: string[];
42
- };
43
- /**
44
- * Extract params from a pathname using a pattern's regex and param names.
45
- *
46
- * Values are URL-decoded so apps see the raw string (e.g. "ivo@example.com")
47
- * instead of the percent-encoded form ("ivo%40example.com"). This matches the
48
- * contract assumed by ctx.reverse (which re-encodes) and aligns with
49
- * Express/React Router/Fastify/Koa.
50
- */
51
- export declare function extractParams(pathname: string, regex: RegExp, paramNames: string[]): Record<string, string>;
52
- /**
53
- * Create middleware context
54
- *
55
- * Note: The implementation uses runtime values while the interface provides
56
- * compile-time type safety. The env/get/set types are resolved at call sites
57
- * via conditional types based on TEnv from createRouter<TBindings>().
58
- */
59
- export declare function createMiddlewareContext<TEnv>(request: Request, env: TEnv, params: Record<string, string>, variables: Record<string, unknown>, responseHolder: ResponseHolder, reverse?: (name: string, params?: Record<string, string>, search?: Record<string, unknown>) => string): MiddlewareContext<TEnv>;
60
- /**
61
- * Match middleware entries against a pathname
62
- * Returns entries that match, with extracted params
63
- */
64
- export declare function matchMiddleware<TEnv>(pathname: string, entries: MiddlewareEntry<TEnv>[]): Array<{
65
- entry: MiddlewareEntry<TEnv>;
66
- params: Record<string, string>;
67
- }>;
68
- /**
69
- * Execute middleware chain
70
- *
71
- * Features:
72
- * - `await next()` returns actual Response
73
- * - `ctx.headers` available before and after `await next()`
74
- * - `ctx.header()` shorthand for setting a single header
75
- * - Forgiving: if middleware doesn't return, uses the downstream response
76
- * - Short-circuit: return OR throw a Response to stop chain
77
- * - Error catching: try/catch around `next()` works
78
- */
79
- export declare function executeMiddleware<TEnv>(middlewares: Array<{
80
- entry: MiddlewareEntry<TEnv>;
81
- params: Record<string, string>;
82
- }>, request: Request, env: TEnv, variables: Record<string, any>, finalHandler: () => Promise<Response>, reverse?: (name: string, params?: Record<string, string>, search?: Record<string, unknown>) => string): Promise<Response>;
83
- /**
84
- * Execute middleware for intercepts (simplified execution)
85
- *
86
- * Intercepts use a shared stubResponse from the request context. This function:
87
- * - Runs middleware in sequence with a simple next() chain
88
- * - Returns Response if any middleware short-circuits (returns OR throws a Response, or redirects, BEFORE next())
89
- * - Returns null if all middleware calls next() - headers set after next() remain on stubResponse
90
- *
91
- * @param middlewares - Array of middleware functions
92
- * @param request - Original request
93
- * @param env - Environment bindings
94
- * @param params - Route params
95
- * @param variables - Shared variables object
96
- * @param stubResponse - Response from request context for collecting headers/cookies
97
- */
98
- export declare function executeInterceptMiddleware<TEnv>(middlewares: MiddlewareFn<TEnv>[], request: Request, env: TEnv, params: Record<string, string>, variables: Record<string, any>, stubResponse: Response, reverse?: (name: string, params?: Record<string, string>, search?: Record<string, unknown>) => string): Promise<Response | null>;
99
- /**
100
- * Execute middleware chain for loaders (simpler signature)
101
- *
102
- * Takes an array of MiddlewareFn directly (no entry wrapper needed).
103
- * Used for fetchable loader middleware execution.
104
- */
105
- export declare function executeLoaderMiddleware<TEnv>(middlewares: MiddlewareFn<TEnv>[], request: Request, env: TEnv, params: Record<string, string>, variables: Record<string, any>, finalHandler: () => Promise<Response>, reverse?: (name: string, params?: Record<string, string>, search?: Record<string, unknown>) => string): Promise<Response>;
106
- /**
107
- * Collect route-level middleware from an entry tree
108
- *
109
- * Recursively collects middleware from entries and their orphan layouts.
110
- * Used by match(), matchPartial(), and previewMatch() to gather route middleware.
111
- *
112
- * @param entries - Iterable of entries to collect middleware from (typically from traverseBack)
113
- * @param params - Route params to attach to each middleware entry
114
- * @returns Array of collected middleware with params
115
- */
116
- export declare function collectRouteMiddleware(entries: Iterable<MiddlewareCollectableEntry>, params: Record<string, string>): CollectedMiddleware[];
@@ -1,22 +0,0 @@
1
- import type { RouteMatchResult } from "./pattern-matching.js";
2
- export interface NavigationSnapshot {
3
- prevUrl: URL;
4
- prevParams: Record<string, string>;
5
- prevMatch: RouteMatchResult | null;
6
- interceptContextUrl: URL;
7
- interceptContextMatch: RouteMatchResult | null;
8
- clientSegmentIds: string[];
9
- clientSegmentSet: Set<string>;
10
- filteredSegmentIds: string[];
11
- stale: boolean;
12
- isSameRouteNavigation: boolean;
13
- effectiveFromUrl: URL;
14
- effectiveFromMatch: RouteMatchResult | null;
15
- hasInterceptSource: boolean;
16
- isHmr: boolean;
17
- }
18
- export interface ResolveNavigationDeps {
19
- findMatch: (pathname: string) => RouteMatchResult | null | Promise<RouteMatchResult | null>;
20
- }
21
- export declare function resolveNavigation(request: Request, url: URL, currentRouteKey: string, deps: ResolveNavigationDeps): Promise<NavigationSnapshot | null>;
22
- export declare function createNavigationSnapshot(overrides?: Partial<NavigationSnapshot>): NavigationSnapshot;
@@ -1,8 +0,0 @@
1
- /**
2
- * Shared route-param comparison helpers.
3
- */
4
- /**
5
- * Shallow equality for two route-param records. Same-reference is a fast path;
6
- * otherwise compares key count then each value.
7
- */
8
- export declare function paramsEqual(a: Record<string, string>, b: Record<string, string>): boolean;
@@ -1,38 +0,0 @@
1
- /**
2
- * Route pattern parsing (grammar only).
3
- *
4
- * Deliberately dependency-free so it is safe to bundle into the CLIENT — the
5
- * reverse helper (`substitute-pattern-params.ts` -> `use-reverse`) needs it, and
6
- * pulling it from `pattern-matching.ts` would drag that module's server-only
7
- * transitive imports (`node:async_hooks` via `logging.ts`) into the browser.
8
- * `pattern-matching.ts` re-exports these so existing importers are unaffected.
9
- */
10
- /**
11
- * Parsed segment info
12
- */
13
- export interface ParsedSegment {
14
- type: "static" | "param" | "wildcard";
15
- value: string;
16
- optional: boolean;
17
- constraint?: string[];
18
- suffix?: string;
19
- /**
20
- * Named catch-all repeat modifier. On a `wildcard` segment whose `value` is a
21
- * param name (`:name+` / `:name*`), `true` marks one-or-more (`+`, rejects the
22
- * zero-segment case); absent/false marks zero-or-more (`*`, and the bare `/*`).
23
- */
24
- oneOrMore?: boolean;
25
- }
26
- /**
27
- * Parse a route pattern into segments
28
- *
29
- * Supports:
30
- * - Static: /blog, /about
31
- * - Params: /:slug, /:id
32
- * - Optional: /:locale?, /:page?
33
- * - Constrained: /:locale(en|gb), /:type(post|page)
34
- * - Optional + Constrained: /:locale(en|gb)?
35
- * - Wildcard: /*
36
- * - Named catch-all: /:slug* (zero-or-more), /:path+ (one-or-more)
37
- */
38
- export declare function parsePattern(pattern: string): ParsedSegment[];
@@ -1,169 +0,0 @@
1
- /**
2
- * Router Pattern Matching
3
- *
4
- * Route pattern compilation and matching utilities.
5
- */
6
- import type { RouteEntry } from "../types";
7
- import type { EntryData } from "../server/context";
8
- import { parsePattern, type ParsedSegment } from "./parse-pattern.js";
9
- export { parsePattern, type ParsedSegment };
10
- /**
11
- * Compiled pattern result containing regex, param metadata, and trailing slash info.
12
- */
13
- export interface CompiledPattern {
14
- regex: RegExp;
15
- paramNames: string[];
16
- hasTrailingSlash: boolean;
17
- /**
18
- * Param-name → allowed values for constrained params (e.g. `:lang(en|gb)`).
19
- * Validated against the **decoded** param value after regex extraction so
20
- * a URL like `/en%20GB` still matches `:lang(en GB)` — matching the trie
21
- * path's behavior (trie-matching.ts:validateAndBuild).
22
- */
23
- constraints?: Record<string, string[]>;
24
- /**
25
- * The pattern's catch-all param, if any (`*` for bare `/*`, the name for a
26
- * named `:name+`/`:name*`). A zero-or-more catch-all (`oneOrMore: false`)
27
- * whose optional group is absent binds "" rather than being omitted — so
28
- * `/docs` matches `/docs/:slug*` with `slug === ""`. `oneOrMore` keeps the
29
- * same polarity as `ParsedSegment.oneOrMore` and the trie's `w1`.
30
- */
31
- catchAll?: {
32
- name: string;
33
- oneOrMore: boolean;
34
- };
35
- }
36
- /**
37
- * Get a compiled pattern from cache or compile and cache it.
38
- * Avoids O(routes) regex compilations per request in the fallback path.
39
- */
40
- export declare function getCompiledPattern(pattern: string): CompiledPattern;
41
- /**
42
- * Return the current size of the compiled pattern cache.
43
- * Exposed for testing.
44
- */
45
- export declare function getPatternCacheSize(): number;
46
- /**
47
- * Clear the compiled pattern cache.
48
- * Exposed for testing.
49
- */
50
- export declare function clearPatternCache(): void;
51
- /**
52
- * Compile a route pattern to regex
53
- *
54
- * Supports:
55
- * - Static segments: /blog, /about
56
- * - Dynamic params: /:slug, /:id
57
- * - Optional params: /:locale?, /:page?
58
- * - Constrained params: /:locale(en|gb)
59
- * - Optional + constrained: /:locale(en|gb)?
60
- * - Wildcard: /*
61
- *
62
- * @example
63
- * compilePattern("/blog/:slug") // matches /blog/hello
64
- * compilePattern("/:locale?/blog") // matches /blog or /en/blog
65
- * compilePattern("/:locale(en|gb)/blog") // matches /en/blog or /gb/blog
66
- * compilePattern("/:locale(en|gb)?/blog") // matches /blog, /en/blog, or /gb/blog
67
- */
68
- export declare function compilePattern(pattern: string): CompiledPattern;
69
- /**
70
- * Build the named-params record from a regex match. Optional segments that
71
- * didn't capture leave the corresponding group `undefined`; we skip those
72
- * keys so `ctx.params.<name>` reads as `undefined` rather than `""`. This
73
- * keeps the runtime aligned with the `ExtractParams` type and matches the
74
- * trie matcher's contract (see `trie-matching.ts:validateAndBuild`).
75
- *
76
- * A zero-or-more catch-all (`compiled.catchAll`, `oneOrMore: false`) whose
77
- * optional group didn't capture binds "" instead of being omitted, so `/docs`
78
- * matches `/docs/:slug*` with `slug === ""`. Exported so the `renderRoute`
79
- * testing harness (`matchLeaf`) shares this exact logic instead of forking it.
80
- */
81
- export declare function buildParamsFromMatch(match: RegExpExecArray, paramNames: string[], catchAll?: {
82
- name: string;
83
- oneOrMore: boolean;
84
- }): Record<string, string>;
85
- /**
86
- * Extract the static prefix from a route pattern.
87
- * Returns everything before the first param/wildcard.
88
- *
89
- * Called ONCE at registration time, not at match time.
90
- *
91
- * Examples:
92
- * - "/api" → "/api"
93
- * - "/site/:locale" → "/site"
94
- * - "/:locale" → ""
95
- * - "/admin/users/:id" → "/admin/users"
96
- * - "/api/*" → "/api"
97
- */
98
- export declare function extractStaticPrefix(pattern: string): string;
99
- /**
100
- * Join a URL prefix to a sub-prefix, collapsing the duplicate slash when the
101
- * base ends with "/" and the sub-prefix starts with "/". This mirrors the
102
- * canonical join in `include()` (urls/include-helper.ts) and `runWithPrefixes`
103
- * (server/context.ts) so a nested lazy include's runtime staticPrefix matches
104
- * the build-time trie's `sp` (e.g. `include("/parent/", …)` containing
105
- * `include("/child", …)` resolves to `/parent/child`, not `/parent//child`).
106
- */
107
- export declare function joinPrefix(base: string | undefined, prefix: string): string;
108
- /**
109
- * Match a pathname against registered routes
110
- *
111
- * Note: Optional params that are absent in the path are omitted from the
112
- * returned `params` (read as `undefined`), matching the trie matcher and
113
- * the `ExtractParams<"/:locale?/...">` type. Use the pattern definition to
114
- * determine which keys are optional.
115
- *
116
- * Trailing slash handling (priority order):
117
- * 1. Per-route `trailingSlash` config from route()
118
- * 2. Pattern-based detection (pattern ending with `/`)
119
- *
120
- * Modes:
121
- * - "never": Redirect to no trailing slash
122
- * - "always": Redirect to with trailing slash
123
- * - "ignore": Match both, no redirect
124
- */
125
- /**
126
- * Result of a route match
127
- */
128
- export interface RouteMatchResult<TEnv = any> {
129
- entry: RouteEntry<TEnv>;
130
- routeKey: string;
131
- params: Record<string, string>;
132
- redirectTo?: string;
133
- /** Route has pre-rendered data available (from trie) */
134
- pr?: true;
135
- /** Passthrough: handler kept for live fallback on unknown params (from trie) */
136
- pt?: true;
137
- /** Response type for non-RSC routes (json, text, image, any) */
138
- responseType?: string;
139
- /** Negotiate variants: response-type routes sharing this path */
140
- negotiateVariants?: Array<{
141
- routeKey: string;
142
- responseType: string;
143
- }>;
144
- /** RSC-first: RSC route was defined before response-type variants */
145
- rscFirst?: true;
146
- }
147
- /**
148
- * Result when a lazy entry needs evaluation before matching
149
- */
150
- export interface LazyEvaluationNeeded<TEnv = any> {
151
- lazyEntry: RouteEntry<TEnv>;
152
- }
153
- /**
154
- * Type guard to check if result is a lazy evaluation needed response
155
- */
156
- export declare function isLazyEvaluationNeeded<TEnv>(result: RouteMatchResult<TEnv> | LazyEvaluationNeeded<TEnv> | null): result is LazyEvaluationNeeded<TEnv>;
157
- interface MatchDebugStats {
158
- entriesChecked: number;
159
- entriesSkipped: number;
160
- routesChecked: number;
161
- }
162
- export declare function enableMatchDebug(enabled: boolean): void;
163
- export declare function getMatchDebugStats(): MatchDebugStats;
164
- export declare function findMatch<TEnv>(pathname: string, routesEntries: RouteEntry<TEnv>[]): RouteMatchResult<TEnv> | LazyEvaluationNeeded<TEnv> | null;
165
- /**
166
- * Traverse from entry to bottom to top, yielding each EntryData
167
- * e.g. {child -> parent -> grandparent ...}
168
- */
169
- export declare function traverseBack(entry: EntryData): Generator<EntryData>;
@@ -1,27 +0,0 @@
1
- /**
2
- * Resolve the prefetch cache TTL once, at router init, into the three derived
3
- * values the rest of the router consumes: seconds (for the Cache-Control
4
- * max-age), milliseconds (for the client-side in-memory cache), and the
5
- * Cache-Control header string (or false when caching is disabled).
6
- *
7
- * `false` disables prefetch caching (seconds 0). A non-finite input
8
- * (NaN/Infinity, e.g. from an env-derived number that failed to parse) is
9
- * treated as the default rather than producing a malformed
10
- * `Cache-Control: max-age=NaN` header; CDNs/browsers ignore such a directive,
11
- * which would silently disable caching on EVERY prefetch response. Negative
12
- * finite values clamp to 0 (disabled).
13
- *
14
- * Policy note: this is the prefetch-TTL policy specifically. Other finite-number
15
- * guards in the codebase deliberately differ — defer.ts treats Infinity as an
16
- * intentional disable, and profile-registry.ts THROWS on non-finite/negative ttl
17
- * at config time. They are NOT the same guard, so don't unify them.
18
- */
19
- export interface ResolvedPrefetchCacheTTL {
20
- /** TTL in seconds for the Cache-Control max-age directive. */
21
- seconds: number;
22
- /** TTL in milliseconds for the client-side in-memory prefetch cache. */
23
- ms: number;
24
- /** Cache-Control header value, or false when caching is disabled. */
25
- cacheControl: string | false;
26
- }
27
- export declare function resolvePrefetchCacheTTL(rawTTL: number | false | undefined): ResolvedPrefetchCacheTTL;
@@ -1,20 +0,0 @@
1
- /**
2
- * Resolve the client-side prefetch limits — the in-memory prefetch cache size
3
- * and the speculative-prefetch queue concurrency — once, at router init. Both
4
- * are positive-integer counts shipped to the browser in payload metadata; the
5
- * browser entry feeds them to the prefetch cache (`initPrefetchCache`) and the
6
- * prefetch queue (`setPrefetchConcurrency`) at startup.
7
- *
8
- * Policy note: this is a SEPARATE policy from resolvePrefetchCacheTTL
9
- * (prefetch-cache-ttl.ts). These are counts, not durations, so the disable
10
- * paths differ: a TTL of `false`/0 intentionally turns prefetching off, but a
11
- * cache size or concurrency of 0 would silently break prefetching while leaving
12
- * it nominally enabled — never the intent of passing a number. So any value
13
- * that is not a finite integer >= 1 (0, negative, fractional below 1, NaN,
14
- * Infinity, undefined) falls back to the default. Finite values >= 1 are
15
- * floored. Do not unify this guard with the TTL guard.
16
- */
17
- export declare const DEFAULT_PREFETCH_CACHE_SIZE = 100;
18
- export declare const DEFAULT_PREFETCH_CONCURRENCY = 2;
19
- export declare function resolvePrefetchCacheSize(raw: number | undefined): number;
20
- export declare function resolvePrefetchConcurrency(raw: number | undefined): number;
@@ -1,50 +0,0 @@
1
- import type { RouterContext } from "./router-context.js";
2
- import type { ResolveSegmentOptions } from "./segment-resolution.js";
3
- import type { EntryData } from "../server/context";
4
- import type { PartialPrerenderProps } from "../urls/pattern-types.js";
5
- import type { HandlerContext, ResolvedSegment } from "../types";
6
- import type { SerializedSegmentData } from "../cache/types.js";
7
- import type { RouteMatchResult } from "./pattern-matching.js";
8
- export interface PrerenderMatchDeps<TEnv = any> {
9
- findMatch: (pathname: string) => RouteMatchResult<TEnv> | null | Promise<RouteMatchResult<TEnv> | null>;
10
- buildRouterContext: () => RouterContext<TEnv>;
11
- mergedRouteMap: Record<string, string>;
12
- resolveAllSegments: (entries: EntryData[], routeKey: string, params: Record<string, string>, context: HandlerContext<any, TEnv>, loaderPromises: Map<string, Promise<any>>, options?: ResolveSegmentOptions) => Promise<ResolvedSegment[]>;
13
- }
14
- /**
15
- * Build-time pre-render match. Resolves segments with a BuildContext
16
- * (no request/env/headers/cookies), skipping middleware and loaders.
17
- */
18
- export declare function matchForPrerender<TEnv = any>(pathname: string, params: Record<string, string>, deps: PrerenderMatchDeps<TEnv>, buildVars?: Record<string, any>, isPassthroughRoute?: boolean, buildEnv?: TEnv,
19
- /** Dev-only: check getParams() for passthrough routes to skip unknown params. */
20
- devMode?: boolean): Promise<{
21
- segments: SerializedSegmentData[];
22
- /** RSC-encoded handle map ("" when none) — see handle-snapshot.ts. Encoded in
23
- * the producer (where the Flight codec resolves) so the node-side build/dev
24
- * sinks can persist it without touching the codec. */
25
- handles: string;
26
- routeName: string;
27
- params: Record<string, string>;
28
- interceptSegments?: SerializedSegmentData[];
29
- /** RSC-encoded MERGED (main + intercept) handle map for the intercept artifact;
30
- * the sinks store it as-is (no longer merge raw records). */
31
- interceptHandles?: string;
32
- passthrough?: true;
33
- /**
34
- * The matched route entry's `ppr` path option, surfaced so the build
35
- * collection can flag Prerender+ppr routes as build-time shell candidates
36
- * (issue #699 producer B). Runtime-only today; the build otherwise never
37
- * sees the option (it lives on EntryData, not the trie).
38
- */
39
- ppr?: boolean | PartialPrerenderProps;
40
- } | null>;
41
- /**
42
- * Render a single Static handler at build time.
43
- * Creates a minimal BuildContext, calls the handler, and RSC-serializes
44
- * the component. Returns the encoded Flight string (or null on failure).
45
- * Used by the Vite plugin to collect static segment data at build time.
46
- */
47
- export declare function renderStaticSegment<TEnv = any>(handler: Function, handlerId: string, mergedRouteMap: Record<string, string>, routeName?: string, buildEnv?: TEnv, devMode?: boolean): Promise<{
48
- encoded: string;
49
- handles: string;
50
- } | null>;
@@ -1,22 +0,0 @@
1
- import type { EntryData } from "../server/context";
2
- import type { RouteMatchResult } from "./pattern-matching.js";
3
- import type { MiddlewareFn } from "./middleware.js";
4
- export interface PreviewMatchDeps<TEnv = any> {
5
- findMatch: (pathname: string) => RouteMatchResult<TEnv> | null | Promise<RouteMatchResult<TEnv> | null>;
6
- }
7
- /**
8
- * Preview match - returns route middleware without segment resolution.
9
- * Also returns responseType and handler for response routes (non-RSC short-circuit).
10
- */
11
- export declare function previewMatch<TEnv = any>(request: Request, _context: TEnv, deps: PreviewMatchDeps<TEnv>): Promise<{
12
- routeMiddleware?: Array<{
13
- handler: MiddlewareFn;
14
- params: Record<string, string>;
15
- }>;
16
- responseType?: string;
17
- handler?: Function;
18
- params?: Record<string, string>;
19
- negotiated?: boolean;
20
- manifestEntry?: EntryData;
21
- routeKey?: string;
22
- } | null>;
@@ -1,104 +0,0 @@
1
- /**
2
- * Request Classification
3
- *
4
- * Replaces the implicit "preview then match again" model with a clean
5
- * two-stage architecture:
6
- *
7
- * 1. Classification — classifyRequest() produces a RequestPlan that answers
8
- * all routing questions once: target route, request mode, route middleware,
9
- * response-route info, negotiation state.
10
- *
11
- * 2. Execution — executeRequest() dispatches on the plan to the appropriate
12
- * handler (response route, loader fetch, full render, partial render,
13
- * action revalidation, PE render).
14
- *
15
- * Builds on RouteSnapshot from route-snapshot.ts.
16
- */
17
- import type { EntryData } from "../server/context.js";
18
- import type { CollectedMiddleware } from "./middleware-types.js";
19
- import type { RouteMatchResult } from "./pattern-matching.js";
20
- import { type RouteSnapshot } from "./route-snapshot.js";
21
- interface RedirectPlan<TEnv = any> {
22
- mode: "redirect";
23
- route: RouteSnapshot<TEnv>;
24
- redirectUrl: string;
25
- }
26
- interface VersionMismatchPlan<TEnv = any> {
27
- mode: "version-mismatch";
28
- /** May be undefined when version mismatch is detected before route resolution */
29
- route?: RouteSnapshot<TEnv>;
30
- reloadUrl: string;
31
- }
32
- interface AppSwitchReloadPlan {
33
- mode: "app-switch";
34
- /** Clean target URL (internal _rsc_* params stripped) to navigate to. */
35
- reloadUrl: string;
36
- }
37
- interface ResponseRoutePlan<TEnv = any> {
38
- mode: "response";
39
- route: RouteSnapshot<TEnv>;
40
- handler: Function;
41
- responseType: string;
42
- negotiated: boolean;
43
- manifestEntry: EntryData;
44
- routeMiddleware: CollectedMiddleware[];
45
- }
46
- interface LoaderFetchPlan<TEnv = any> {
47
- mode: "loader";
48
- route: RouteSnapshot<TEnv>;
49
- }
50
- interface PeRenderPlan<TEnv = any> {
51
- mode: "pe-render";
52
- route: RouteSnapshot<TEnv>;
53
- }
54
- interface ActionPlan<TEnv = any> {
55
- mode: "action";
56
- route: RouteSnapshot<TEnv>;
57
- actionId: string;
58
- negotiated: boolean;
59
- }
60
- interface FullRenderPlan<TEnv = any> {
61
- mode: "full-render";
62
- route: RouteSnapshot<TEnv>;
63
- negotiated: boolean;
64
- }
65
- interface PartialRenderPlan<TEnv = any> {
66
- mode: "partial-render";
67
- route: RouteSnapshot<TEnv>;
68
- negotiated: boolean;
69
- }
70
- /**
71
- * The output of request classification. A discriminated union where each
72
- * variant carries exactly the fields needed for its execution path.
73
- */
74
- export type RequestPlan<TEnv = any> = RedirectPlan<TEnv> | VersionMismatchPlan<TEnv> | AppSwitchReloadPlan | ResponseRoutePlan<TEnv> | LoaderFetchPlan<TEnv> | PeRenderPlan<TEnv> | ActionPlan<TEnv> | FullRenderPlan<TEnv> | PartialRenderPlan<TEnv>;
75
- /**
76
- * Plans that have passed the terminal-check gate (version-mismatch and
77
- * app-switch reloads handled) and are ready for execution. Always have a
78
- * `route` field.
79
- */
80
- export type ExecutableRequestPlan<TEnv = any> = Exclude<RequestPlan<TEnv>, VersionMismatchPlan<TEnv> | AppSwitchReloadPlan>;
81
- /**
82
- * Re-export individual plan types for consumers that need to narrow.
83
- */
84
- export type { RedirectPlan, VersionMismatchPlan, ResponseRoutePlan, LoaderFetchPlan, PeRenderPlan, ActionPlan, FullRenderPlan, PartialRenderPlan, };
85
- export interface ClassifyRequestDeps<TEnv = any> {
86
- findMatch: (pathname: string) => RouteMatchResult<TEnv> | null | Promise<RouteMatchResult<TEnv> | null>;
87
- routerVersion: string;
88
- routerId: string;
89
- }
90
- /**
91
- * Classify an incoming request into a RequestPlan.
92
- *
93
- * This is the single source of truth for request mode detection. It replaces
94
- * the scattered previewMatch + isAction/isLoaderFetch/isPartial checks in
95
- * handler.ts.
96
- *
97
- * Classification order:
98
- * 1. Route resolution (findMatch + loadManifest via resolveRoute lite)
99
- * 2. Redirect detection
100
- * 3. Version mismatch
101
- * 4. Response route + content negotiation
102
- * 5. Mode detection from headers/params
103
- */
104
- export declare function classifyRequest<TEnv = any>(request: Request, url: URL, deps: ClassifyRequestDeps<TEnv>): Promise<RequestPlan<TEnv>>;