@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,246 +0,0 @@
1
- /**
2
- * renderRoute — a React-Testing-Library-style helper for unit-testing CLIENT
3
- * components that read @rangojs/router client context (useParams, useReverse,
4
- * Outlet, useNavigation, useLoader).
5
- *
6
- * Peer of React Router's createRoutesStub and Expo Router's renderRouter. It
7
- * mounts the router's NavigationProvider plus a synthetic segment tree so that
8
- * a component under test sees real router context, without spinning up a
9
- * server, a Vite build, or a real Flight round-trip.
10
- *
11
- * FIDELITY CONTRACT — read before relying on this helper:
12
- * This renders the CLIENT tree ONLY. The segment tree is built synthetically
13
- * from the `routes` you pass; there is no server render and no Flight
14
- * (de)serialization. Consequences:
15
- * - It will NOT catch server/client boundary reference-identity remount bugs
16
- * (a server-serialized component reference differing from the client
17
- * reference). Use renderServerTree / e2e for those.
18
- * - It will NOT catch real Flight serialization errors (non-serializable
19
- * props crossing the RSC boundary), loader execution on the server,
20
- * middleware, or handler ordering. Those are renderServerTree / renderHandler
21
- * / e2e territory.
22
- * - Loader data, location state, and handle output are SEEDED directly into
23
- * client context (see the `loaders` / `locationState` / `handles` options) —
24
- * nothing is executed on the server. This exercises the read path
25
- * (useLoader / useLocationState / useHandle from context), not the run path.
26
- * - navigate() commits synchronously, so it does NOT drive the navigation
27
- * lifecycle: useNavigation().state, useLinkStatus().pending, and
28
- * useAction().state stay "idle". Assert pending/loading/submitting transition
29
- * states with renderServerTree / e2e instead (navigate() warns once if used).
30
- * What it DOES cover: client hooks that read NavigationProvider /
31
- * OutletContext — useParams, useReverse, useHref, useMount, useNavigation,
32
- * useRouter, usePathname, useSearchParams, Outlet nesting, useLoader /
33
- * useFetchLoader (seeded data), useLocationState (seeded), and useHandle (seeded).
34
- * Basename-mounted apps: pass the `basename` option so useRouter().basename,
35
- * <Link> prefixing, and useMount/useHref resolve against the mount prefix
36
- * (without it they resolve at the root "/"). For an include("/shop", ...)
37
- * subtree, pass the `mount` option so useMount() returns the mounted prefix
38
- * (the segment chain is wrapped in a MountContext exactly as in production).
39
- */
40
- import type { ComponentType } from "react";
41
- import type { RenderResult } from "@testing-library/react";
42
- import type { NavigationStore } from "../browser/types.js";
43
- import type { EventController } from "../browser/event-controller.js";
44
- import type { LoaderDefinition } from "../types.js";
45
- import type { LocationStateDefinition } from "../browser/react/location-state-shared.js";
46
- import type { Handle } from "../handle.js";
47
- import type { ThemeConfig } from "../theme/types.js";
48
- /**
49
- * Seed shape for `options.handle`, matching the handle wire format:
50
- * `{ [handleName]: { [segmentId]: pushedValues[] } }` (each segment accumulates
51
- * an array of values pushed for that handle).
52
- */
53
- export type HandleDataSeed = Record<string, Record<string, unknown[]>>;
54
- export interface RenderRouteSpec {
55
- /**
56
- * The route pattern this node matches, e.g. "/products/:productId". The LAST
57
- * spec in the array is treated as the leaf route; earlier specs are layouts
58
- * wrapping it. Only the leaf pattern is matched against the `request` URL to
59
- * extract params; layout patterns are informational.
60
- */
61
- path: string;
62
- /** The component rendered for this node (the leaf route or a layout body). */
63
- Component: ComponentType;
64
- /**
65
- * Optional layout component. When set on the LEAF spec it wraps the route in
66
- * its own layout segment (useful for a route that owns a layout). Prefer
67
- * expressing layouts as their own array entries instead.
68
- */
69
- layout?: ComponentType;
70
- /**
71
- * Loader ids ($$id) whose seeded data (from `options.loaderData`) should be
72
- * attached to THIS node's segment so useLoader/useFetchLoader resolve it from
73
- * context. When omitted, every key in `options.loaderData` is attached to the
74
- * leaf route segment.
75
- */
76
- loaderIds?: string[];
77
- /** Optional route name (informational; not used for matching). */
78
- name?: string;
79
- }
80
- /**
81
- * Options for renderRoute.
82
- */
83
- export interface RenderRouteOptions {
84
- /**
85
- * The initial location to render at: a `Request`, or a URL string (absolute or
86
- * path). Only the URL is read (this is a client render — headers/method are
87
- * ignored); named `request` for parity with the other primitives. Defaults to
88
- * the leaf spec's static prefix or "/".
89
- */
90
- request?: Request | string;
91
- /**
92
- * Loader data to seed into client context, keyed by loader id ($$id). A
93
- * component calling useLoader(SomeLoader) reads `loaderData[SomeLoader.$$id]`.
94
- * Seeded values are placed in the route segment's OutletProvider context, so
95
- * the read path is exercised without executing any loader.
96
- */
97
- loaderData?: Record<string, unknown>;
98
- /**
99
- * Loaders to seed by REFERENCE — the robust way to test a component that calls
100
- * `useLoader(loader)`. A real `createLoader()` handle has an empty `$$id` in a
101
- * bare test (the id is injected by the Vite plugin at build time), so keying
102
- * `loaderData` by `$$id` collides under `""` and `useLoader` resolves nothing.
103
- * Passing `[loader, data]` pairs lets renderRoute assign a synthetic stable id
104
- * and wire `useLoader` to it. Prefer this over `loaderData` for real handles.
105
- *
106
- * NOTE: when a real handle has no `$$id`, renderRoute MUTATES it to assign a
107
- * synthetic stable id (so repeat renders key consistently). This is a side
108
- * effect on your input object; a handle reused across tests keeps that id.
109
- *
110
- * @example
111
- * // useLoader returns an ENVELOPE — destructure `data`, it is not the bare value.
112
- * function CartBadge() {
113
- * const { data } = useLoader(CartLoader); // NOT `useLoader(CartLoader).itemCount`
114
- * return <span>{data.itemCount}</span>;
115
- * }
116
- * renderRoute([{ path: "/cart", Component: CartBadge }], {
117
- * loaders: [[CartLoader, { itemCount: 3, total: 89.97 }]],
118
- * });
119
- */
120
- loaders?: ReadonlyArray<readonly [LoaderDefinition<any>, unknown]>;
121
- /**
122
- * Explicit params. Merged over (and overriding) params extracted from the
123
- * `request` URL. Use this when the URL alone cannot express the params, or to
124
- * avoid relying on URL parsing. Supplying params also OPTS OUT of the
125
- * request/leaf match check: a `request` whose pathname does not resolve the
126
- * leaf is normally rejected under the test runner, but passing params here
127
- * tells renderRoute the request is intentionally not the param source.
128
- */
129
- params?: Record<string, string>;
130
- /**
131
- * Location-state values to seed by REFERENCE, for components that call
132
- * `useLocationState(StateDef)`. Like loaders, a real `createLocationState()`
133
- * handle has an empty injected key in a bare test, so pass `[def, value]`
134
- * pairs; renderRoute assigns a synthetic key and writes it to `history.state`.
135
- *
136
- * @example
137
- * renderRoute([{ path: "/", Component: FlashBanner }], {
138
- * locationState: [[FlashMessage, { text: "Saved" }]],
139
- * });
140
- */
141
- locationState?: ReadonlyArray<readonly [LocationStateDefinition<any, any>, unknown]>;
142
- /**
143
- * Handles to seed by REFERENCE, for components that read handle output via
144
- * `useHandle(SomeHandle)` (e.g. a client `Breadcrumbs` trail). Each entry is
145
- * `[handle, pushedValues[]]` — the values a route's handlers would have pushed;
146
- * renderRoute attaches them to the leaf route segment under the handle's id.
147
- * Built-in handles (Breadcrumbs/Meta) have stable ids and work directly.
148
- *
149
- * Handle data is accumulated GLOBALLY on the event controller, not scoped per
150
- * segment like loaders — so ANY component in the chain reads the seeded values,
151
- * a LAYOUT (e.g. a DetailLayout/ActionToolbar reading a handle) just as much as
152
- * the leaf route. Most handle usage is server-side (`ctx.use(...)`) and is
153
- * better covered by `renderToFlightString`/e2e; this seeds the client read path
154
- * only.
155
- *
156
- * @example
157
- * renderRoute([{ path: "/p", Component: BreadcrumbTrail }], {
158
- * handles: [[Breadcrumbs, [{ label: "Home", href: "/" }, { label: "P", href: "/p" }]]],
159
- * });
160
- */
161
- handles?: ReadonlyArray<readonly [Handle<any, any>, unknown[]]>;
162
- /**
163
- * Advanced: raw handle data in wire format
164
- * `{ [handleId]: { [segmentId]: pushedValues[] } }`. Prefer `handles` (which
165
- * computes the segment id for you). Merged with `handles`.
166
- */
167
- handle?: HandleDataSeed;
168
- /**
169
- * Route name -> pattern map. Informational for parity with the server test
170
- * context; client useReverse takes its map directly as an argument, so this
171
- * is not consumed by the client hooks.
172
- */
173
- routeMap?: Record<string, string>;
174
- /**
175
- * Router basename (the `createRouter({ basename })` value). Wired into
176
- * NavigationProvider so `useRouter().basename`, `<Link>` href prefixing, and
177
- * `useMount`/`useHref` resolve against the mounted prefix instead of the root.
178
- * Normalized exactly like createRouter (leading slash forced, trailing
179
- * stripped, bare "/" -> undefined). Defaults to undefined (root mount).
180
- */
181
- basename?: string;
182
- /**
183
- * include() mount prefix, to model an `include("/shop", ...)` subtree so a
184
- * component (route OR layout in the chain) calling `useMount()` returns the
185
- * mounted prefix instead of "/". Wraps the segment chain in a MountContext
186
- * exactly as `renderSegments` does in production (a segment whose `mountPath`
187
- * is set is wrapped in a MountContextProvider). Normalized like a path prefix
188
- * (leading slash forced, trailing stripped, bare "/" -> root). Defaults to "/".
189
- * An explicitly-passed `request` must match the leaf `path` directly (paths are
190
- * include-RELATIVE; the mount does NOT rewrite the request) — pass the relative
191
- * path, not the mount-prefixed one, or renderRoute throws rather than silently
192
- * rendering empty params.
193
- *
194
- * @example
195
- * renderRoute([{ path: "/c/wine", Component: ProductPage }], { mount: "/shop" });
196
- * // useMount() inside ProductPage returns "/shop"
197
- */
198
- mount?: string;
199
- /**
200
- * Theme config in the `createRouter({ theme })` shape (resolved internally) to
201
- * wrap the tree in a ThemeProvider. Defaults to no provider. Note: a component
202
- * that calls `useTheme()` REQUIRES a provider — it throws "used outside
203
- * ThemeProvider" without one — so pass a config (e.g. `true`) to test such a
204
- * component.
205
- */
206
- theme?: ThemeConfig | true;
207
- /**
208
- * CSP nonce to seed via NonceContext, so a component calling `useNonce()`
209
- * (e.g. an analytics/GTM head-script component) sees this value — mirroring
210
- * what the SSR renderer provides per request. Defaults to undefined (the
211
- * browser default), matching production client behavior.
212
- *
213
- * @example
214
- * const { getByTestId } = await renderRoute(
215
- * [{ path: "/", Component: NonceProbe }],
216
- * { nonce: "test-nonce" },
217
- * );
218
- * expect(getByTestId("nonce").textContent).toBe("test-nonce");
219
- */
220
- nonce?: string;
221
- }
222
- /**
223
- * Imperative handle returned alongside the RTL result.
224
- */
225
- export interface TestRouterHandle {
226
- /**
227
- * Navigate to a new URL. Re-resolves the URL against the supplied `routes`,
228
- * updates params + location, and re-renders the segment tree. This is a
229
- * client-only navigation: no server fetch occurs, so only the components in
230
- * `routes` can be reached.
231
- */
232
- navigate(url: string): Promise<void>;
233
- /** The current committed pathname. */
234
- pathname(): string;
235
- /** The current committed params. */
236
- params(): Record<string, string>;
237
- /** The underlying navigation store (advanced use). */
238
- store: NavigationStore;
239
- /** The underlying event controller (advanced use). */
240
- eventController: EventController;
241
- }
242
- /** Result of renderRoute: RTL's render result plus the router handle. */
243
- export type RenderRouteResult = RenderResult & {
244
- router: TestRouterHandle;
245
- };
246
- export declare function renderRoute(routes: RenderRouteSpec[], options?: RenderRouteOptions): Promise<RenderRouteResult>;
@@ -1,186 +0,0 @@
1
- /**
2
- * runLoader — unit-test a loader function in isolation.
3
- *
4
- * Pass the RAW async loader body `(ctx) => ...`, or a registered `createLoader()`
5
- * handle (its fn is recovered from the fetchable registry by `$$id`). The raw
6
- * body needs no build step; the handle works because `createLoader` assigns a
7
- * runtime-fallback `$$id` and registers its fn even without the Vite plugin (when
8
- * imported through the server build — the consumer's `@rangojs/router` under the
9
- * `rangoTestConfig()` preset). Either way the function is invoked directly with a
10
- * constructed LoaderContext.
11
- *
12
- * The LoaderContext mirrors the canonical shape the router builds at runtime
13
- * (see createUseFunction in server/request-context.ts). The loader runs inside
14
- * runWithRequestContext so getRequestContext(), cookie reads, and header
15
- * mutations resolve exactly as in production.
16
- *
17
- * Limitations (v1):
18
- * - `ctx.rendered()` is not available — it requires the DSL render barrier,
19
- * which only exists inside a full match. Calling it throws.
20
- * - `ctx.reverse()` throws unless `routeMap` is provided (it does NOT fall back
21
- * to the global route map — that would leak whichever routes another test
22
- * registered).
23
- * - `ctx.use(handle)` follows the production rule: reading a handle before
24
- * `await ctx.rendered()` throws (pass `rendered` to mock the barrier).
25
- * - `use cache` functions only cache (and only fire their taint/profile guards)
26
- * when a `cacheStore` is provided — without one, registerCachedFunction
27
- * bypasses (it checks for a store first). Pass `cacheStore`/`cacheProfiles`
28
- * to exercise cached loaders; otherwise such a call runs uncached, like an
29
- * app with no cache configured.
30
- * - `formData` is exposed verbatim; no multipart parsing is performed.
31
- * - Scoped dot-local reverse (`.sibling`) uses only the supplied `routeMap`;
32
- * the production root-scoping signal (derived from the global registry) is
33
- * not modeled, so a dotted name resolves against `routeMap` as given.
34
- */
35
- import type { LoaderContext, LoaderDefinition } from "../types.js";
36
- import type { ContextVar } from "../context-var.js";
37
- import { type Handle } from "../handle.js";
38
- import type { ThemeConfig } from "../theme/types.js";
39
- import type { SegmentCacheStore } from "../cache/types.js";
40
- import type { CacheProfile } from "../cache/profile-registry.js";
41
- import { type VarsInit, type StateCookieSeed } from "./internal/context.js";
42
- /**
43
- * The loader context surfaced to a `runLoader` body. It mirrors the runtime
44
- * LoaderContext but RELAXES the two members that are otherwise bound to the
45
- * app's global route/var augmentation, because in a unit test they are driven by
46
- * the `routeMap` / `vars` options instead:
47
- * - `reverse` accepts any route name (the names come from `routeMap`, not the
48
- * registered route map), and
49
- * - `get` accepts any string key or ContextVar (keys come from `vars`).
50
- */
51
- export type TestLoaderContext<TEnv = any> = Omit<LoaderContext<any, TEnv>, "reverse" | "get"> & {
52
- reverse: (name: string, params?: Record<string, string>, search?: Record<string, unknown>) => string;
53
- get: {
54
- <T>(contextVar: ContextVar<T>): T | undefined;
55
- <T = unknown>(key: string): T | undefined;
56
- };
57
- };
58
- /**
59
- * A resolver for `ctx.use(OtherLoader)` composition. Receives the dependency
60
- * loader definition and returns its data (or a promise of it). When omitted,
61
- * `ctx.use` delegates to the real request-context use(), which executes the
62
- * dependency's own `fn` if present.
63
- */
64
- export type UseResolver = <T>(loader: LoaderDefinition<T, any>) => Promise<T> | T;
65
- /**
66
- * Options for runLoader.
67
- */
68
- export interface RunLoaderOptions<TEnv = any> {
69
- /** Route params surfaced as `ctx.params` and `ctx.routeParams`. */
70
- params?: Record<string, string>;
71
- /** Search params; merged into the request URL so `ctx.searchParams` reflects them. */
72
- search?: Record<string, string>;
73
- /**
74
- * The TYPED `ctx.search` object a route's search schema would produce. Distinct
75
- * from `search` (which sets the raw `ctx.searchParams`): a loader on a typed
76
- * search route reads `ctx.search`, which is otherwise `{}` in a test.
77
- */
78
- searchData?: Record<string, unknown>;
79
- /** Router basename surfaced on the context (drives redirect() prefixing). */
80
- basename?: string;
81
- /**
82
- * Theme config in the same shape `createRouter({ theme })` takes (e.g. `true`
83
- * or `{ themes: [...] }`). Seeds the request's theme config so nested handler
84
- * or cache contexts created from this loader observe it. Loaders themselves do
85
- * not expose `ctx.theme`/`ctx.setTheme` (those are handler/middleware-only).
86
- */
87
- theme?: ThemeConfig | true;
88
- /** Environment bindings surfaced as `ctx.env`. */
89
- env?: TEnv;
90
- /** Override the backing Request (string or Request). Defaults to a localhost GET. */
91
- request?: Request | string;
92
- /** Variables a prior middleware would have set (object or [key, value] list). */
93
- vars?: VarsInit;
94
- /** Route name -> pattern map enabling `ctx.reverse()`. */
95
- routeMap?: Record<string, string>;
96
- /** Matched route name for scoped `.name` reverse resolution. */
97
- routeName?: string;
98
- /** HTTP method surfaced as `ctx.method`. Defaults to "GET". */
99
- method?: string;
100
- /** Request body surfaced as `ctx.body`. */
101
- body?: unknown;
102
- /** Form data surfaced as `ctx.formData`. */
103
- formData?: FormData;
104
- /**
105
- * Seed the data `ctx.use(OtherLoader)` returns, by loader REFERENCE — the same
106
- * tuple form `renderHandler` / `renderRoute` use (`[[OtherLoader, data]]`).
107
- * Matched by reference, so a real `createLoader()` handle resolves regardless
108
- * of its build-injected `$$id`. For dynamic resolution (compute per dependency)
109
- * use `use` instead; `loaders` is checked first.
110
- */
111
- loaders?: ReadonlyArray<readonly [LoaderDefinition<any, any>, unknown]>;
112
- /** Resolver for `ctx.use(OtherLoader)` composition (dynamic; `loaders` wins if both match). */
113
- use?: UseResolver;
114
- /**
115
- * Cache store backing `use cache` functions the loader invokes. Without it,
116
- * a cached function bypasses (registerCachedFunction checks for a store
117
- * first) and runs uncached — its taint/profile guards never fire. Pass one
118
- * (e.g. `new MemorySegmentCacheStore()`) to test a cached loader.
119
- */
120
- cacheStore?: SegmentCacheStore;
121
- /** Cache profiles (the `createRouter({ cacheProfiles })` shape). */
122
- cacheProfiles?: Record<string, CacheProfile>;
123
- /**
124
- * Customize the rango state cookie a loader that calls
125
- * `invalidateClientCache()` rotates (the name is always seeded — default
126
- * `rango-state_router_0` — so it rotates like production). Assert via the
127
- * `Set-Cookie` on the request context's response.
128
- */
129
- stateCookie?: StateCookieSeed;
130
- /**
131
- * Mock the `ctx.rendered()` render barrier so a loader that does
132
- * `await ctx.rendered()` (to read handle data pushed during render) can be
133
- * unit-tested. By default `ctx.rendered()` throws, because the real barrier
134
- * only exists during a full route match. Pass `true` to resolve it
135
- * immediately, or a function to control its timing/side effects.
136
- *
137
- * This tests the loader's POST-barrier compute logic against the seeded
138
- * `handles` below — it does NOT exercise the real push -> accumulate -> barrier
139
- * wiring (that stays e2e). Pair with `handles` to feed `ctx.use(SomeHandle)`.
140
- */
141
- rendered?: boolean | (() => void | Promise<void>);
142
- /**
143
- * Seed the values `ctx.use(SomeHandle)` returns — the ACCUMULATED handle data a
144
- * loader reads after `await ctx.rendered()`. Matched by handle reference, so a
145
- * real handle works regardless of its (build-injected) `$$id`.
146
- *
147
- * @example
148
- * await runLoader(livePricesBody, {
149
- * rendered: true,
150
- * handles: [[RenderedProducts, ["widget-a", "widget-b"]]],
151
- * });
152
- */
153
- handles?: ReadonlyArray<readonly [Handle<any, any>, unknown]>;
154
- }
155
- /** A raw loader body, or a registered `createLoader()` handle (its fn is recovered). */
156
- export type RunnableLoader<T> = ((ctx: TestLoaderContext) => Promise<T> | T) | LoaderDefinition<T, any>;
157
- export declare function runLoader<T>(loader: RunnableLoader<T>, opts?: RunLoaderOptions): Promise<T>;
158
- export interface RunLoaderResult<T> {
159
- /**
160
- * The loader's resolved data (the value bare `runLoader` returns), or
161
- * `undefined` if it threw (see {@link thrown}). Named `result` for parity with
162
- * `runInRequestContext`'s envelope.
163
- */
164
- result: T | undefined;
165
- /**
166
- * What the loader threw (commonly a `Response` from `throw redirect(...)` on a
167
- * success path) — captured, NOT re-thrown; assert on it. `undefined` if the
168
- * loader returned normally.
169
- */
170
- thrown: unknown;
171
- /**
172
- * The merged `Response` (status + headers + Set-Cookie). On a thrown redirect,
173
- * that redirect's `Location` merged with the accumulated cookies/headers — so a
174
- * loader that sets a session cookie then `throw redirect("/")` exposes BOTH.
175
- */
176
- response: Response;
177
- /** Effective cookie view: request cookies + the loader's mutations, last-write-wins. */
178
- cookies: Record<string, string>;
179
- /** Response headers as `{ name: value }`, EXCLUDING set-cookie (use `cookies`). Lowercased. */
180
- headers: Record<string, string>;
181
- /** Location state the loader set (`ctx.setLocationState()` / `redirect({ state })`). */
182
- locationState: Record<string, unknown>;
183
- /** The resolved rango state cookie name seeded for the run (default `rango-state_router_0`). */
184
- stateCookieName: string;
185
- }
186
- export declare function runLoaderResult<T>(loader: RunnableLoader<T>, opts?: RunLoaderOptions): Promise<RunLoaderResult<T>>;
@@ -1,132 +0,0 @@
1
- /**
2
- * runMiddleware — unit-test one or more middleware functions in isolation.
3
- *
4
- * Executes the middleware chain via the SAME executeLoaderMiddleware the router
5
- * uses, so ordering, `next()`, short-circuit (return OR throw Response),
6
- * double-next guards, and header/cookie merging behave identically to
7
- * production. The chain runs inside runWithRequestContext, so cookie/header
8
- * mutations and getRequestContext() resolve.
9
- *
10
- * The returned `ctx` is the underlying RequestContext (not the per-middleware
11
- * MiddlewareContext), exposing `ctx.cookies()`, `ctx.get()`, and
12
- * `ctx.res.headers` for assertions on what the chain produced.
13
- *
14
- * `nextCalled` counts how many times the terminal `next()` (the finalHandler)
15
- * ran: 0 when the chain short-circuited, 1 when it ran to completion.
16
- */
17
- import { type RequestContext } from "../server/request-context.js";
18
- import type { MiddlewareFn } from "../router/middleware-types.js";
19
- import { type VarsInit, type StateCookieSeed } from "./internal/context.js";
20
- import type { ThemeConfig } from "../theme/types.js";
21
- import type { SegmentCacheStore } from "../cache/types.js";
22
- import type { CacheProfile } from "../cache/profile-registry.js";
23
- /**
24
- * Options for runMiddleware.
25
- */
26
- export interface RunMiddlewareOptions<TEnv = any> {
27
- /**
28
- * The request the chain runs under: a `Request`, or a URL string (absolute or
29
- * path). Optional for parity with `runLoader`/`runInRequestContext` — when
30
- * omitted it defaults to `http://localhost/`. Pass it for path-, header-, or
31
- * cookie-driven middleware.
32
- */
33
- request?: Request | string;
34
- /** Environment bindings surfaced as `ctx.env`. */
35
- env?: TEnv;
36
- /** Route params surfaced as `ctx.params`. */
37
- params?: Record<string, string>;
38
- /**
39
- * Seed `ctx.build` (default false) so a middleware that branches on the
40
- * build-time PPR shell-capture pass (e.g. `if (ctx.build) ctx.dynamic()`) is
41
- * unit-testable. With `build: true`, `ctx.waitUntil()` is inert, matching the
42
- * build producer. Assert a `ctx.dynamic()` call via `result.dynamic`.
43
- */
44
- build?: boolean;
45
- /** Variables a prior middleware would have set (object or [key, value] list). */
46
- vars?: VarsInit;
47
- /** Route name -> pattern map enabling `ctx.reverse()`. */
48
- routeMap?: Record<string, string>;
49
- /**
50
- * Matched route name surfaced as `ctx.routeName`. Does NOT scope `.name`
51
- * reverse: the chain receives a map-only `reverse` (built from `routeMap`
52
- * alone), matching production app/response middleware — see the reverse
53
- * construction below.
54
- */
55
- routeName?: string;
56
- /** Router basename surfaced on the context (drives redirect() prefixing). */
57
- basename?: string;
58
- /** Theme config in the `createRouter({ theme })` shape (enables ctx.theme). */
59
- theme?: ThemeConfig | true;
60
- /**
61
- * Terminal handler invoked when the chain calls `next()` all the way through.
62
- * Defaults to a 200 empty Response. Use this to model the downstream
63
- * route/handler response.
64
- */
65
- next?: () => Promise<Response>;
66
- /**
67
- * Cache store backing any `use cache` function a middleware invokes. Without
68
- * it, registerCachedFunction bypasses (it checks for a store first), so the
69
- * cached function runs uncached and its taint/profile guards never fire.
70
- */
71
- cacheStore?: SegmentCacheStore;
72
- /** Cache profiles (the `createRouter({ cacheProfiles })` shape). */
73
- cacheProfiles?: Record<string, CacheProfile>;
74
- /**
75
- * Customize the rango state cookie a middleware that calls
76
- * `invalidateClientCache()` rotates (the name is always seeded — default
77
- * `rango-state_router_0` — so it rotates like production). Assert via the
78
- * `Set-Cookie` on `result.response` / `result.cookies`.
79
- */
80
- stateCookie?: StateCookieSeed;
81
- }
82
- /**
83
- * Result of runMiddleware.
84
- */
85
- export interface RunMiddlewareResult<TEnv = any> {
86
- /** The final Response (downstream response, or a middleware short-circuit). */
87
- response: Response;
88
- /**
89
- * The underlying RequestContext. Read `ctx.cookies()`, `ctx.get(...)`, and
90
- * `ctx.res.headers` to assert on the chain's effects. (This is always the
91
- * RequestContext the chain ran under — not a per-middleware MiddlewareContext —
92
- * so `ctx.cookies()` and the other RequestContext accessors are available.)
93
- */
94
- ctx: RequestContext<TEnv>;
95
- /** Number of times the terminal handler ran (0 = short-circuited, 1 = passed through). */
96
- nextCalled: number;
97
- /**
98
- * Whether the chain called `ctx.dynamic()` (the PPR shell opt-out). The public
99
- * way to assert the opt-out without reading the `@internal` `ctx._dynamic`.
100
- */
101
- dynamic: boolean;
102
- /**
103
- * The effective cookie view after the chain ran: request cookies merged with
104
- * anything the chain set or deleted (last-write-wins), as `{ name: value }`.
105
- * The public way to assert a cookie a middleware set, without casting through
106
- * the `@internal` `ctx.cookies()`. Set-Cookie headers are also on `response`.
107
- */
108
- cookies: Record<string, string>;
109
- /**
110
- * The final response's headers as a plain `{ name: value }` object (the same
111
- * view as `response.headers`), EXCLUDING `set-cookie` (use `cookies`). The
112
- * public way to assert a header a middleware set (e.g. a security header)
113
- * without reading `ctx.res.headers`. Header names are lowercased.
114
- */
115
- headers: Record<string, string>;
116
- /**
117
- * Location state the chain set via `ctx.setLocationState()` / `redirect({ state })`,
118
- * resolved to the flat `{ key: value }` shape the client reads off
119
- * `history.state` (empty object when none) — parity with `runInRequestContext`
120
- * and `renderHandler`.
121
- */
122
- locationState: Record<string, unknown>;
123
- /**
124
- * The resolved rango state cookie name seeded for the run (default
125
- * `rango-state_router_0`, or composed from `opts.stateCookie`). Assert a
126
- * middleware's `invalidateClientCache()` rotation against it without
127
- * recomputing — parity with `runInRequestContext` / `runLoaderResult` /
128
- * `renderHandler`.
129
- */
130
- stateCookieName: string;
131
- }
132
- export declare function runMiddleware<TEnv = any>(mw: MiddlewareFn<TEnv> | MiddlewareFn<TEnv>[], opts: RunMiddlewareOptions<TEnv>): Promise<RunMiddlewareResult<TEnv>>;
@@ -1,77 +0,0 @@
1
- /**
2
- * runTransitionWhen — unit-test a transition({ when }) predicate in isolation.
3
- *
4
- * Runs the SAME two server functions the router uses — applyViewTransitionDefault
5
- * (strips the `when` function from the serialized config and records the
6
- * predicate on the request context) and gateTransitions (assembles the
7
- * TransitionWhenContext and evaluates the predicate post-handler). So the
8
- * predicate sees exactly the navigation/action metadata it would at runtime
9
- * (currentUrl/currentParams/fromRouteName, nextUrl/nextParams/toRouteName,
10
- * actionId/actionUrl/actionResult/formData/method, get/env), and `kept` reflects
11
- * whether the transition would apply this request. The result also exposes the
12
- * assembled `whenContext` so tests can assert the exact fields without reaching
13
- * into private request-context state.
14
- *
15
- * This is the public way to exercise a transition gate: the full
16
- * match -> render pipeline that wires these together only runs under real RSC
17
- * rendering (which the Flight primitives do not drive), so without this primitive
18
- * a consumer could not test their predicate through @rangojs/router/testing.
19
- *
20
- * Synchronous: a transition predicate returns a boolean and the gate has no I/O.
21
- */
22
- import { type RequestContext } from "../server/request-context.js";
23
- import { type VarsInit } from "./internal/context.js";
24
- import type { TransitionConfig, TransitionWhenContext } from "../types/segments.js";
25
- import type { OnErrorCallback } from "../types/error-types.js";
26
- /**
27
- * Options for runTransitionWhen. All navigation/action fields are optional and
28
- * default to "absent", matching what the gate sees for an initial full load with
29
- * no action: omit `currentUrl`/`currentParams`/`fromRouteName` to model the
30
- * navigation source being unavailable, and omit the `action*` fields to model a
31
- * plain (non-action) navigation.
32
- */
33
- export interface RunTransitionWhenOptions<TEnv = any> {
34
- /** The navigation TARGET request (drives `nextUrl`): a Request or URL/path string. Defaults to `http://localhost/`. */
35
- request?: Request | string;
36
- /** Route params for the target (`nextParams`). */
37
- params?: Record<string, string>;
38
- /** Target route name (`toRouteName`). */
39
- toRouteName?: string;
40
- /** Environment bindings surfaced as `env` (and `ctx.env`). */
41
- env?: TEnv;
42
- /** Variables a handler/middleware would have set this request, readable via the predicate's `get()`. */
43
- vars?: VarsInit;
44
- /** Navigation SOURCE url (`currentUrl`): a URL or path string. */
45
- currentUrl?: string | URL;
46
- /** Source route params (`currentParams`). */
47
- currentParams?: Record<string, string>;
48
- /** Source route name (`fromRouteName`). */
49
- fromRouteName?: string;
50
- /** Id of the action that triggered a revalidation (`actionId`). */
51
- actionId?: string;
52
- /** Url the action was submitted from (`actionUrl`). */
53
- actionUrl?: string | URL;
54
- /** The action's return value (`actionResult`). */
55
- actionResult?: unknown;
56
- /** FormData from a form action (`formData`). */
57
- formData?: FormData;
58
- /** Receives an error thrown by the predicate (the gate reports to `router.onError`, phase `"rendering"`). */
59
- onError?: OnErrorCallback;
60
- }
61
- /**
62
- * Result of runTransitionWhen.
63
- */
64
- export interface RunTransitionWhenResult<TEnv = any> {
65
- /** True if the transition would apply this request (predicate returned non-false, or there is no `when`). */
66
- kept: boolean;
67
- /** Convenience inverse of `kept`. */
68
- dropped: boolean;
69
- /**
70
- * The production-assembled predicate context. Undefined when the config has
71
- * no `when` predicate.
72
- */
73
- whenContext?: TransitionWhenContext<Record<string, string>, TEnv>;
74
- /** The underlying RequestContext, for additional assertions (`ctx.get(...)`, etc.). */
75
- ctx: RequestContext<TEnv>;
76
- }
77
- export declare function runTransitionWhen<TEnv = any>(config: TransitionConfig, opts?: RunTransitionWhenOptions<TEnv>): RunTransitionWhenResult<TEnv>;
@@ -1,6 +0,0 @@
1
- export declare class EmailMessage {
2
- from: string;
3
- to: string;
4
- raw: unknown;
5
- constructor(from: string, to: string, raw: unknown);
6
- }
@@ -1,13 +0,0 @@
1
- export declare const env: Record<string, unknown>;
2
- export declare class DurableObject<Env = unknown> {
3
- ctx: unknown;
4
- env: Env;
5
- constructor(ctx: unknown, env: Env);
6
- }
7
- export declare class WorkerEntrypoint<Env = unknown> {
8
- ctx: unknown;
9
- env: Env;
10
- constructor(ctx: unknown, env: Env);
11
- }
12
- export declare class RpcTarget {
13
- }