@rangojs/router 0.0.0-experimental.d20dd405 → 0.0.0-experimental.d5d3070a

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 (1186) hide show
  1. package/AGENTS.md +8 -0
  2. package/README.md +57 -14
  3. package/dist/bin/rango.js +312 -93
  4. package/dist/testing/vitest.js +82 -0
  5. package/dist/vite/index.js +1632 -705
  6. package/package.json +64 -12
  7. package/skills/api-client/SKILL.md +211 -0
  8. package/skills/breadcrumbs/SKILL.md +61 -1
  9. package/skills/bundle-analysis/SKILL.md +159 -0
  10. package/skills/cache-guide/SKILL.md +224 -32
  11. package/skills/caching/SKILL.md +279 -17
  12. package/skills/composability/SKILL.md +27 -2
  13. package/skills/css/SKILL.md +76 -0
  14. package/skills/debug-manifest/SKILL.md +4 -2
  15. package/skills/document-cache/SKILL.md +78 -55
  16. package/skills/handler-use/SKILL.md +2 -2
  17. package/skills/hooks/SKILL.md +217 -31
  18. package/skills/host-router/SKILL.md +83 -23
  19. package/skills/intercept/SKILL.md +5 -6
  20. package/skills/layout/SKILL.md +11 -9
  21. package/skills/links/SKILL.md +22 -10
  22. package/skills/loader/SKILL.md +172 -23
  23. package/skills/middleware/SKILL.md +16 -10
  24. package/skills/migrate-nextjs/SKILL.md +38 -16
  25. package/skills/migrate-react-router/SKILL.md +4 -2
  26. package/skills/mime-routes/SKILL.md +28 -1
  27. package/skills/observability/SKILL.md +172 -0
  28. package/skills/parallel/SKILL.md +9 -7
  29. package/skills/prerender/SKILL.md +45 -43
  30. package/skills/rango/SKILL.md +251 -26
  31. package/skills/react-compiler/SKILL.md +168 -0
  32. package/skills/response-routes/SKILL.md +115 -48
  33. package/skills/route/SKILL.md +22 -5
  34. package/skills/router-setup/SKILL.md +29 -6
  35. package/skills/scripts/SKILL.md +179 -0
  36. package/skills/server-actions/SKILL.md +78 -42
  37. package/skills/tailwind/SKILL.md +27 -3
  38. package/skills/testing/SKILL.md +129 -0
  39. package/skills/testing/bindings.md +103 -0
  40. package/skills/testing/cache-prerender.md +127 -0
  41. package/skills/testing/client-components.md +124 -0
  42. package/skills/testing/e2e-parity.md +125 -0
  43. package/skills/testing/flight.md +91 -0
  44. package/skills/testing/handles.md +129 -0
  45. package/skills/testing/loader.md +128 -0
  46. package/skills/testing/middleware.md +99 -0
  47. package/skills/testing/render-handler.md +121 -0
  48. package/skills/testing/response-routes.md +95 -0
  49. package/skills/testing/reverse-and-types.md +84 -0
  50. package/skills/testing/server-actions.md +107 -0
  51. package/skills/testing/server-tree.md +128 -0
  52. package/skills/testing/setup.md +123 -0
  53. package/skills/typesafety/SKILL.md +313 -28
  54. package/skills/use-cache/SKILL.md +46 -14
  55. package/skills/view-transitions/SKILL.md +85 -3
  56. package/src/__augment-tests__/augment.ts +81 -0
  57. package/src/__augment-tests__/augmented.check.ts +116 -0
  58. package/src/__internal.ts +0 -65
  59. package/src/browser/action-coordinator.ts +53 -36
  60. package/src/browser/action-fence.ts +47 -0
  61. package/src/browser/app-shell.ts +14 -27
  62. package/src/browser/connection-warmup.ts +134 -0
  63. package/src/browser/cookie-name.ts +140 -0
  64. package/src/browser/event-controller.ts +151 -149
  65. package/src/browser/history-state.ts +21 -0
  66. package/src/browser/index.ts +3 -3
  67. package/src/browser/invalidate-client-cache.ts +52 -0
  68. package/src/browser/navigation-bridge.ts +67 -126
  69. package/src/browser/navigation-client.ts +110 -84
  70. package/src/browser/navigation-store-handle.ts +38 -0
  71. package/src/browser/navigation-store.ts +32 -82
  72. package/src/browser/navigation-transaction.ts +9 -59
  73. package/src/browser/network-error-handler.ts +34 -7
  74. package/src/browser/partial-update.ts +108 -144
  75. package/src/browser/prefetch/cache.ts +107 -72
  76. package/src/browser/prefetch/fetch.ts +186 -34
  77. package/src/browser/prefetch/queue.ts +6 -3
  78. package/src/browser/rango-state.ts +157 -115
  79. package/src/browser/react/Link.tsx +30 -7
  80. package/src/browser/react/NavigationProvider.tsx +173 -160
  81. package/src/browser/react/ScrollRestoration.tsx +10 -6
  82. package/src/browser/react/filter-segment-order.ts +17 -2
  83. package/src/browser/react/index.ts +0 -51
  84. package/src/browser/react/location-state-shared.ts +178 -8
  85. package/src/browser/react/location-state.ts +39 -14
  86. package/src/browser/react/use-action.ts +6 -15
  87. package/src/browser/react/use-handle.ts +17 -14
  88. package/src/browser/react/use-href.tsx +8 -1
  89. package/src/browser/react/use-link-status.ts +33 -8
  90. package/src/browser/react/use-navigation.ts +10 -5
  91. package/src/browser/react/use-params.ts +3 -6
  92. package/src/browser/react/use-reverse.ts +19 -12
  93. package/src/browser/react/use-router.ts +20 -5
  94. package/src/browser/react/use-search-params.ts +0 -5
  95. package/src/browser/react/use-segments.ts +0 -13
  96. package/src/browser/response-adapter.ts +80 -5
  97. package/src/browser/rsc-router.tsx +73 -34
  98. package/src/browser/scroll-restoration.ts +38 -28
  99. package/src/browser/segment-structure-assert.ts +2 -2
  100. package/src/browser/server-action-bridge.ts +214 -55
  101. package/src/browser/types.ts +51 -21
  102. package/src/browser/validate-redirect-origin.ts +43 -16
  103. package/src/build/collect-fallback-refs.ts +107 -0
  104. package/src/build/generate-manifest.ts +60 -35
  105. package/src/build/generate-route-types.ts +2 -1
  106. package/src/build/index.ts +8 -2
  107. package/src/build/prefix-tree-utils.ts +123 -0
  108. package/src/build/route-trie.ts +117 -15
  109. package/src/build/route-types/ast-route-extraction.ts +15 -8
  110. package/src/build/route-types/codegen.ts +16 -5
  111. package/src/build/route-types/include-resolution.ts +117 -23
  112. package/src/build/route-types/param-extraction.ts +6 -3
  113. package/src/build/route-types/per-module-writer.ts +22 -6
  114. package/src/build/route-types/router-processing.ts +55 -28
  115. package/src/build/route-types/scan-filter.ts +1 -1
  116. package/src/build/route-types/source-scan.ts +216 -0
  117. package/src/build/runtime-discovery.ts +9 -20
  118. package/src/cache/cache-error.ts +104 -0
  119. package/src/cache/cache-key-utils.ts +29 -13
  120. package/src/cache/cache-policy.ts +108 -34
  121. package/src/cache/cache-runtime.ts +199 -37
  122. package/src/cache/cache-scope.ts +188 -82
  123. package/src/cache/cache-tag.ts +103 -0
  124. package/src/cache/cf/cf-base64.ts +33 -0
  125. package/src/cache/cf/cf-cache-constants.ts +127 -0
  126. package/src/cache/cf/cf-cache-store.ts +1990 -377
  127. package/src/cache/cf/cf-cache-types.ts +349 -0
  128. package/src/cache/cf/cf-kv-utils.ts +46 -0
  129. package/src/cache/cf/cf-tag-marker-memo.ts +105 -0
  130. package/src/cache/cf/index.ts +6 -16
  131. package/src/cache/document-cache.ts +72 -20
  132. package/src/cache/handle-snapshot.ts +70 -0
  133. package/src/cache/index.ts +10 -20
  134. package/src/cache/memory-segment-store.ts +136 -37
  135. package/src/cache/profile-registry.ts +31 -31
  136. package/src/cache/read-through-swr.ts +41 -11
  137. package/src/cache/segment-codec.ts +9 -17
  138. package/src/cache/tag-invalidation.ts +230 -0
  139. package/src/cache/types.ts +37 -100
  140. package/src/client.rsc.tsx +42 -22
  141. package/src/client.tsx +33 -62
  142. package/src/cloudflare/index.ts +11 -0
  143. package/src/cloudflare/tracing.ts +109 -0
  144. package/src/component-utils.ts +19 -0
  145. package/src/components/DefaultDocument.tsx +8 -2
  146. package/src/context-var.ts +18 -6
  147. package/src/decode-loader-results.ts +52 -0
  148. package/src/defer.ts +196 -0
  149. package/src/deps/ssr.ts +0 -1
  150. package/src/encode-kv.ts +49 -0
  151. package/src/errors.ts +30 -4
  152. package/src/escape-script.ts +52 -0
  153. package/src/handle.ts +31 -23
  154. package/src/handles/MetaTags.tsx +62 -19
  155. package/src/handles/Scripts.tsx +183 -0
  156. package/src/handles/breadcrumbs.ts +37 -8
  157. package/src/handles/is-thenable.ts +19 -0
  158. package/src/handles/meta.ts +51 -40
  159. package/src/handles/script.ts +244 -0
  160. package/src/host/cookie-handler.ts +9 -60
  161. package/src/host/errors.ts +0 -24
  162. package/src/host/index.ts +8 -2
  163. package/src/host/pattern-matcher.ts +23 -52
  164. package/src/host/router.ts +107 -99
  165. package/src/host/testing.ts +40 -27
  166. package/src/host/types.ts +37 -4
  167. package/src/host/utils.ts +1 -1
  168. package/src/href-client.ts +136 -24
  169. package/src/index.rsc.ts +87 -11
  170. package/src/index.ts +85 -10
  171. package/src/internal-debug.ts +11 -10
  172. package/src/loader-store.ts +500 -0
  173. package/src/loader.rsc.ts +20 -13
  174. package/src/loader.ts +12 -11
  175. package/src/missing-id-error.ts +68 -0
  176. package/src/outlet-provider.tsx +1 -5
  177. package/src/prerender/param-hash.ts +16 -16
  178. package/src/prerender/store.ts +32 -37
  179. package/src/prerender.ts +61 -6
  180. package/src/redirect-origin.ts +100 -0
  181. package/src/regex-escape.ts +8 -0
  182. package/src/render-error-thrower.tsx +20 -0
  183. package/src/response-utils.ts +34 -0
  184. package/src/reverse.ts +16 -13
  185. package/src/root-error-boundary.tsx +1 -19
  186. package/src/route-content-wrapper.tsx +7 -72
  187. package/src/route-definition/dsl-helpers.ts +276 -283
  188. package/src/route-definition/helper-factories.ts +29 -139
  189. package/src/route-definition/helpers-types.ts +40 -17
  190. package/src/route-definition/redirect.ts +44 -11
  191. package/src/route-definition/resolve-handler-use.ts +6 -0
  192. package/src/route-definition/use-item-types.ts +32 -0
  193. package/src/route-map-builder.ts +0 -16
  194. package/src/route-types.ts +19 -41
  195. package/src/router/basename.ts +14 -0
  196. package/src/router/content-negotiation.ts +73 -25
  197. package/src/router/error-handling.ts +45 -18
  198. package/src/router/find-match.ts +44 -23
  199. package/src/router/handler-context.ts +6 -1
  200. package/src/router/instrument.ts +350 -0
  201. package/src/router/intercept-resolution.ts +39 -20
  202. package/src/router/lazy-includes.ts +9 -46
  203. package/src/router/loader-resolution.ts +152 -72
  204. package/src/router/logging.ts +0 -6
  205. package/src/router/manifest.ts +18 -29
  206. package/src/router/match-api.ts +0 -20
  207. package/src/router/match-context.ts +0 -22
  208. package/src/router/match-handlers.ts +57 -58
  209. package/src/router/match-middleware/background-revalidation.ts +6 -7
  210. package/src/router/match-middleware/cache-lookup.ts +159 -285
  211. package/src/router/match-middleware/cache-store.ts +31 -34
  212. package/src/router/match-middleware/intercept-resolution.ts +0 -22
  213. package/src/router/match-middleware/segment-resolution.ts +0 -22
  214. package/src/router/match-pipelines.ts +1 -42
  215. package/src/router/match-result.ts +31 -80
  216. package/src/router/metrics.ts +0 -34
  217. package/src/router/middleware-types.ts +0 -116
  218. package/src/router/middleware.ts +216 -163
  219. package/src/router/navigation-snapshot.ts +0 -51
  220. package/src/router/params-util.ts +23 -0
  221. package/src/router/pattern-matching.ts +47 -89
  222. package/src/router/prefetch-cache-ttl.ts +51 -0
  223. package/src/router/prerender-match.ts +104 -65
  224. package/src/router/preview-match.ts +3 -1
  225. package/src/router/request-classification.ts +28 -62
  226. package/src/router/revalidation.ts +110 -74
  227. package/src/router/route-snapshot.ts +0 -1
  228. package/src/router/router-context.ts +3 -28
  229. package/src/router/router-interfaces.ts +83 -35
  230. package/src/router/router-options.ts +136 -5
  231. package/src/router/router-registry.ts +2 -5
  232. package/src/router/segment-resolution/fresh.ts +85 -84
  233. package/src/router/segment-resolution/helpers.ts +86 -6
  234. package/src/router/segment-resolution/loader-cache.ts +62 -37
  235. package/src/router/segment-resolution/revalidation.ts +227 -306
  236. package/src/router/segment-resolution/static-store.ts +19 -5
  237. package/src/router/segment-resolution/streamed-handler-telemetry.ts +52 -0
  238. package/src/router/segment-resolution/view-transition-default.ts +36 -0
  239. package/src/router/segment-resolution.ts +5 -1
  240. package/src/router/segment-wrappers.ts +6 -5
  241. package/src/router/state-cookie-name.ts +33 -0
  242. package/src/router/telemetry-otel.ts +161 -199
  243. package/src/router/telemetry.ts +96 -19
  244. package/src/router/timeout.ts +0 -20
  245. package/src/router/tracing.ts +206 -0
  246. package/src/router/trie-matching.ts +163 -64
  247. package/src/router/types.ts +9 -63
  248. package/src/router/url-params.ts +0 -5
  249. package/src/router.ts +109 -53
  250. package/src/rsc/handler-context.ts +3 -2
  251. package/src/rsc/handler.ts +262 -219
  252. package/src/rsc/helpers.ts +100 -6
  253. package/src/rsc/index.ts +2 -5
  254. package/src/rsc/json-route-result.ts +38 -0
  255. package/src/rsc/loader-fetch.ts +114 -38
  256. package/src/rsc/manifest-init.ts +28 -41
  257. package/src/rsc/origin-guard.ts +39 -25
  258. package/src/rsc/progressive-enhancement.ts +59 -9
  259. package/src/rsc/redirect-guard.ts +99 -0
  260. package/src/rsc/response-cache-serve.ts +238 -0
  261. package/src/rsc/response-error.ts +79 -12
  262. package/src/rsc/response-route-handler.ts +85 -188
  263. package/src/rsc/rsc-rendering.ts +91 -77
  264. package/src/rsc/runtime-warnings.ts +23 -10
  265. package/src/rsc/server-action.ts +256 -117
  266. package/src/rsc/ssr-setup.ts +16 -0
  267. package/src/rsc/types.ts +17 -5
  268. package/src/runtime-env.ts +18 -0
  269. package/src/search-params.ts +35 -30
  270. package/src/segment-loader-promise.ts +31 -4
  271. package/src/segment-system.tsx +151 -136
  272. package/src/serialize.ts +243 -0
  273. package/src/server/context.ts +150 -51
  274. package/src/server/cookie-parse.ts +32 -0
  275. package/src/server/cookie-store.ts +80 -5
  276. package/src/server/handle-store.ts +21 -38
  277. package/src/server/loader-registry.ts +21 -42
  278. package/src/server/request-context.ts +225 -133
  279. package/src/ssr/index.tsx +19 -18
  280. package/src/static-handler.ts +10 -13
  281. package/src/testing/cache-status.ts +162 -0
  282. package/src/testing/collect-handle.ts +40 -0
  283. package/src/testing/dispatch.ts +701 -0
  284. package/src/testing/dom.entry.ts +22 -0
  285. package/src/testing/e2e/fixture.ts +188 -0
  286. package/src/testing/e2e/index.ts +128 -0
  287. package/src/testing/e2e/matchers.ts +35 -0
  288. package/src/testing/e2e/page-helpers.ts +272 -0
  289. package/src/testing/e2e/parity.ts +387 -0
  290. package/src/testing/e2e/server.ts +195 -0
  291. package/src/testing/flight-matchers.ts +97 -0
  292. package/src/testing/flight-normalize.ts +11 -0
  293. package/src/testing/flight-runtime.d.ts +57 -0
  294. package/src/testing/flight-tree.ts +682 -0
  295. package/src/testing/flight.entry.ts +52 -0
  296. package/src/testing/flight.ts +257 -0
  297. package/src/testing/generated-routes.ts +183 -0
  298. package/src/testing/index.ts +99 -0
  299. package/src/testing/internal/context.ts +371 -0
  300. package/src/testing/internal/flight-client-globals.ts +30 -0
  301. package/src/testing/internal/seed-vars.ts +54 -0
  302. package/src/testing/render-handler.ts +343 -0
  303. package/src/testing/render-route.tsx +581 -0
  304. package/src/testing/run-loader.ts +385 -0
  305. package/src/testing/run-middleware.ts +205 -0
  306. package/src/testing/vitest-stubs/cloudflare-email.ts +9 -0
  307. package/src/testing/vitest-stubs/cloudflare-workers.ts +21 -0
  308. package/src/testing/vitest-stubs/plugin-rsc.ts +16 -0
  309. package/src/testing/vitest-stubs/version.ts +5 -0
  310. package/src/testing/vitest.ts +305 -0
  311. package/src/theme/ThemeProvider.tsx +20 -58
  312. package/src/theme/ThemeScript.tsx +7 -9
  313. package/src/theme/constants.ts +52 -13
  314. package/src/theme/index.ts +0 -7
  315. package/src/theme/theme-context.ts +1 -5
  316. package/src/theme/theme-script.ts +22 -21
  317. package/src/theme/use-theme.ts +0 -3
  318. package/src/types/boundaries.ts +0 -35
  319. package/src/types/cache-types.ts +13 -4
  320. package/src/types/error-types.ts +30 -90
  321. package/src/types/global-namespace.ts +54 -41
  322. package/src/types/handler-context.ts +97 -22
  323. package/src/types/index.ts +1 -10
  324. package/src/types/loader-types.ts +6 -3
  325. package/src/types/request-scope.ts +8 -22
  326. package/src/types/route-config.ts +6 -50
  327. package/src/types/route-entry.ts +0 -6
  328. package/src/types/segments.ts +18 -14
  329. package/src/urls/include-helper.ts +9 -56
  330. package/src/urls/index.ts +1 -11
  331. package/src/urls/path-helper-types.ts +19 -5
  332. package/src/urls/path-helper.ts +17 -106
  333. package/src/urls/pattern-types.ts +36 -19
  334. package/src/urls/response-types.ts +20 -19
  335. package/src/urls/type-extraction.ts +58 -139
  336. package/src/urls/urls-function.ts +1 -18
  337. package/src/use-loader.tsx +292 -107
  338. package/src/vite/debug.ts +1 -0
  339. package/src/vite/discovery/bundle-postprocess.ts +8 -7
  340. package/src/vite/discovery/discover-routers.ts +95 -82
  341. package/src/vite/discovery/discovery-errors.ts +194 -0
  342. package/src/vite/discovery/prerender-collection.ts +48 -67
  343. package/src/vite/discovery/route-types-writer.ts +40 -84
  344. package/src/vite/discovery/state.ts +44 -0
  345. package/src/vite/discovery/virtual-module-codegen.ts +14 -34
  346. package/src/vite/index.ts +2 -0
  347. package/src/vite/inject-client-debug.ts +36 -0
  348. package/src/vite/plugin-types.ts +126 -8
  349. package/src/vite/plugins/cjs-to-esm.ts +11 -19
  350. package/src/vite/plugins/client-ref-dedup.ts +0 -11
  351. package/src/vite/plugins/client-ref-hashing.ts +12 -11
  352. package/src/vite/plugins/cloudflare-protocol-stub.ts +1 -21
  353. package/src/vite/plugins/expose-action-id.ts +4 -75
  354. package/src/vite/plugins/expose-id-utils.ts +88 -55
  355. package/src/vite/plugins/expose-ids/export-analysis.ts +101 -34
  356. package/src/vite/plugins/expose-ids/handler-transform.ts +11 -90
  357. package/src/vite/plugins/expose-ids/loader-transform.ts +14 -24
  358. package/src/vite/plugins/expose-ids/router-transform.ts +98 -26
  359. package/src/vite/plugins/expose-internal-ids.ts +57 -68
  360. package/src/vite/plugins/performance-tracks.ts +9 -16
  361. package/src/vite/plugins/refresh-cmd.ts +1 -1
  362. package/src/vite/plugins/use-cache-transform.ts +26 -49
  363. package/src/vite/plugins/version-injector.ts +2 -32
  364. package/src/vite/plugins/version-plugin.ts +37 -40
  365. package/src/vite/plugins/virtual-entries.ts +13 -18
  366. package/src/vite/rango.ts +60 -104
  367. package/src/vite/router-discovery.ts +236 -83
  368. package/src/vite/utils/ast-handler-extract.ts +26 -35
  369. package/src/vite/utils/bundle-analysis.ts +10 -15
  370. package/src/vite/utils/client-chunks.ts +184 -0
  371. package/src/vite/utils/directive-prologue.ts +40 -0
  372. package/src/vite/utils/forward-user-plugins.ts +171 -0
  373. package/src/vite/utils/manifest-utils.ts +4 -59
  374. package/src/vite/utils/package-resolution.ts +1 -73
  375. package/src/vite/utils/prerender-utils.ts +54 -40
  376. package/src/vite/utils/shared-utils.ts +90 -41
  377. package/dist/__internal.d.ts +0 -83
  378. package/dist/__internal.d.ts.map +0 -1
  379. package/dist/__internal.js +0 -19
  380. package/dist/__internal.js.map +0 -1
  381. package/dist/__mocks__/version.d.ts +0 -7
  382. package/dist/__mocks__/version.d.ts.map +0 -1
  383. package/dist/__mocks__/version.js +0 -7
  384. package/dist/__mocks__/version.js.map +0 -1
  385. package/dist/__tests__/client-href.test.d.ts +0 -2
  386. package/dist/__tests__/client-href.test.d.ts.map +0 -1
  387. package/dist/__tests__/client-href.test.js +0 -74
  388. package/dist/__tests__/client-href.test.js.map +0 -1
  389. package/dist/__tests__/component-utils.test.d.ts +0 -2
  390. package/dist/__tests__/component-utils.test.d.ts.map +0 -1
  391. package/dist/__tests__/component-utils.test.js +0 -51
  392. package/dist/__tests__/component-utils.test.js.map +0 -1
  393. package/dist/__tests__/event-controller.test.d.ts +0 -2
  394. package/dist/__tests__/event-controller.test.d.ts.map +0 -1
  395. package/dist/__tests__/event-controller.test.js +0 -538
  396. package/dist/__tests__/event-controller.test.js.map +0 -1
  397. package/dist/__tests__/helpers/route-tree.d.ts +0 -118
  398. package/dist/__tests__/helpers/route-tree.d.ts.map +0 -1
  399. package/dist/__tests__/helpers/route-tree.js +0 -374
  400. package/dist/__tests__/helpers/route-tree.js.map +0 -1
  401. package/dist/__tests__/match-result.test.d.ts +0 -2
  402. package/dist/__tests__/match-result.test.d.ts.map +0 -1
  403. package/dist/__tests__/match-result.test.js +0 -154
  404. package/dist/__tests__/match-result.test.js.map +0 -1
  405. package/dist/__tests__/navigation-store.test.d.ts +0 -2
  406. package/dist/__tests__/navigation-store.test.d.ts.map +0 -1
  407. package/dist/__tests__/navigation-store.test.js +0 -440
  408. package/dist/__tests__/navigation-store.test.js.map +0 -1
  409. package/dist/__tests__/partial-update.test.d.ts +0 -2
  410. package/dist/__tests__/partial-update.test.d.ts.map +0 -1
  411. package/dist/__tests__/partial-update.test.js +0 -1009
  412. package/dist/__tests__/partial-update.test.js.map +0 -1
  413. package/dist/__tests__/reverse-types.test.d.ts +0 -8
  414. package/dist/__tests__/reverse-types.test.d.ts.map +0 -1
  415. package/dist/__tests__/reverse-types.test.js +0 -656
  416. package/dist/__tests__/reverse-types.test.js.map +0 -1
  417. package/dist/__tests__/route-definition.test.d.ts +0 -2
  418. package/dist/__tests__/route-definition.test.d.ts.map +0 -1
  419. package/dist/__tests__/route-definition.test.js +0 -55
  420. package/dist/__tests__/route-definition.test.js.map +0 -1
  421. package/dist/__tests__/router-helpers.test.d.ts +0 -2
  422. package/dist/__tests__/router-helpers.test.d.ts.map +0 -1
  423. package/dist/__tests__/router-helpers.test.js +0 -377
  424. package/dist/__tests__/router-helpers.test.js.map +0 -1
  425. package/dist/__tests__/router-integration-2.test.d.ts +0 -2
  426. package/dist/__tests__/router-integration-2.test.d.ts.map +0 -1
  427. package/dist/__tests__/router-integration-2.test.js +0 -426
  428. package/dist/__tests__/router-integration-2.test.js.map +0 -1
  429. package/dist/__tests__/router-integration.test.d.ts +0 -2
  430. package/dist/__tests__/router-integration.test.d.ts.map +0 -1
  431. package/dist/__tests__/router-integration.test.js +0 -1051
  432. package/dist/__tests__/router-integration.test.js.map +0 -1
  433. package/dist/__tests__/search-params.test.d.ts +0 -5
  434. package/dist/__tests__/search-params.test.d.ts.map +0 -1
  435. package/dist/__tests__/search-params.test.js +0 -306
  436. package/dist/__tests__/search-params.test.js.map +0 -1
  437. package/dist/__tests__/segment-system.test.d.ts +0 -2
  438. package/dist/__tests__/segment-system.test.d.ts.map +0 -1
  439. package/dist/__tests__/segment-system.test.js +0 -627
  440. package/dist/__tests__/segment-system.test.js.map +0 -1
  441. package/dist/__tests__/static-handler-types.test.d.ts +0 -8
  442. package/dist/__tests__/static-handler-types.test.d.ts.map +0 -1
  443. package/dist/__tests__/static-handler-types.test.js +0 -63
  444. package/dist/__tests__/static-handler-types.test.js.map +0 -1
  445. package/dist/__tests__/urls.test.d.ts +0 -2
  446. package/dist/__tests__/urls.test.d.ts.map +0 -1
  447. package/dist/__tests__/urls.test.js +0 -421
  448. package/dist/__tests__/urls.test.js.map +0 -1
  449. package/dist/__tests__/use-mount.test.d.ts +0 -2
  450. package/dist/__tests__/use-mount.test.d.ts.map +0 -1
  451. package/dist/__tests__/use-mount.test.js +0 -35
  452. package/dist/__tests__/use-mount.test.js.map +0 -1
  453. package/dist/bin/rango.d.ts +0 -2
  454. package/dist/bin/rango.d.ts.map +0 -1
  455. package/dist/bin/rango.js.map +0 -1
  456. package/dist/browser/event-controller.d.ts +0 -191
  457. package/dist/browser/event-controller.d.ts.map +0 -1
  458. package/dist/browser/event-controller.js +0 -559
  459. package/dist/browser/event-controller.js.map +0 -1
  460. package/dist/browser/index.d.ts +0 -2
  461. package/dist/browser/index.d.ts.map +0 -1
  462. package/dist/browser/index.js +0 -14
  463. package/dist/browser/index.js.map +0 -1
  464. package/dist/browser/link-interceptor.d.ts +0 -38
  465. package/dist/browser/link-interceptor.d.ts.map +0 -1
  466. package/dist/browser/link-interceptor.js +0 -99
  467. package/dist/browser/link-interceptor.js.map +0 -1
  468. package/dist/browser/logging.d.ts +0 -10
  469. package/dist/browser/logging.d.ts.map +0 -1
  470. package/dist/browser/logging.js +0 -29
  471. package/dist/browser/logging.js.map +0 -1
  472. package/dist/browser/lru-cache.d.ts +0 -17
  473. package/dist/browser/lru-cache.d.ts.map +0 -1
  474. package/dist/browser/lru-cache.js +0 -50
  475. package/dist/browser/lru-cache.js.map +0 -1
  476. package/dist/browser/merge-segment-loaders.d.ts +0 -39
  477. package/dist/browser/merge-segment-loaders.d.ts.map +0 -1
  478. package/dist/browser/merge-segment-loaders.js +0 -102
  479. package/dist/browser/merge-segment-loaders.js.map +0 -1
  480. package/dist/browser/navigation-bridge.d.ts +0 -102
  481. package/dist/browser/navigation-bridge.d.ts.map +0 -1
  482. package/dist/browser/navigation-bridge.js +0 -708
  483. package/dist/browser/navigation-bridge.js.map +0 -1
  484. package/dist/browser/navigation-client.d.ts +0 -25
  485. package/dist/browser/navigation-client.d.ts.map +0 -1
  486. package/dist/browser/navigation-client.js +0 -157
  487. package/dist/browser/navigation-client.js.map +0 -1
  488. package/dist/browser/navigation-store.d.ts +0 -101
  489. package/dist/browser/navigation-store.d.ts.map +0 -1
  490. package/dist/browser/navigation-store.js +0 -625
  491. package/dist/browser/navigation-store.js.map +0 -1
  492. package/dist/browser/partial-update.d.ts +0 -75
  493. package/dist/browser/partial-update.d.ts.map +0 -1
  494. package/dist/browser/partial-update.js +0 -426
  495. package/dist/browser/partial-update.js.map +0 -1
  496. package/dist/browser/react/Link.d.ts +0 -86
  497. package/dist/browser/react/Link.d.ts.map +0 -1
  498. package/dist/browser/react/Link.js +0 -128
  499. package/dist/browser/react/Link.js.map +0 -1
  500. package/dist/browser/react/NavigationProvider.d.ts +0 -63
  501. package/dist/browser/react/NavigationProvider.d.ts.map +0 -1
  502. package/dist/browser/react/NavigationProvider.js +0 -216
  503. package/dist/browser/react/NavigationProvider.js.map +0 -1
  504. package/dist/browser/react/ScrollRestoration.d.ts +0 -75
  505. package/dist/browser/react/ScrollRestoration.d.ts.map +0 -1
  506. package/dist/browser/react/ScrollRestoration.js +0 -57
  507. package/dist/browser/react/ScrollRestoration.js.map +0 -1
  508. package/dist/browser/react/context.d.ts +0 -46
  509. package/dist/browser/react/context.d.ts.map +0 -1
  510. package/dist/browser/react/context.js +0 -10
  511. package/dist/browser/react/context.js.map +0 -1
  512. package/dist/browser/react/index.d.ts +0 -11
  513. package/dist/browser/react/index.d.ts.map +0 -1
  514. package/dist/browser/react/index.js +0 -22
  515. package/dist/browser/react/index.js.map +0 -1
  516. package/dist/browser/react/location-state-shared.d.ts +0 -63
  517. package/dist/browser/react/location-state-shared.d.ts.map +0 -1
  518. package/dist/browser/react/location-state-shared.js +0 -81
  519. package/dist/browser/react/location-state-shared.js.map +0 -1
  520. package/dist/browser/react/location-state.d.ts +0 -23
  521. package/dist/browser/react/location-state.d.ts.map +0 -1
  522. package/dist/browser/react/location-state.js +0 -29
  523. package/dist/browser/react/location-state.js.map +0 -1
  524. package/dist/browser/react/mount-context.d.ts +0 -24
  525. package/dist/browser/react/mount-context.d.ts.map +0 -1
  526. package/dist/browser/react/mount-context.js +0 -24
  527. package/dist/browser/react/mount-context.js.map +0 -1
  528. package/dist/browser/react/use-action.d.ts +0 -64
  529. package/dist/browser/react/use-action.d.ts.map +0 -1
  530. package/dist/browser/react/use-action.js +0 -134
  531. package/dist/browser/react/use-action.js.map +0 -1
  532. package/dist/browser/react/use-client-cache.d.ts +0 -41
  533. package/dist/browser/react/use-client-cache.d.ts.map +0 -1
  534. package/dist/browser/react/use-client-cache.js +0 -39
  535. package/dist/browser/react/use-client-cache.js.map +0 -1
  536. package/dist/browser/react/use-handle.d.ts +0 -31
  537. package/dist/browser/react/use-handle.d.ts.map +0 -1
  538. package/dist/browser/react/use-handle.js +0 -144
  539. package/dist/browser/react/use-handle.js.map +0 -1
  540. package/dist/browser/react/use-href.d.ts +0 -33
  541. package/dist/browser/react/use-href.d.ts.map +0 -1
  542. package/dist/browser/react/use-href.js +0 -39
  543. package/dist/browser/react/use-href.js.map +0 -1
  544. package/dist/browser/react/use-link-status.d.ts +0 -37
  545. package/dist/browser/react/use-link-status.d.ts.map +0 -1
  546. package/dist/browser/react/use-link-status.js +0 -99
  547. package/dist/browser/react/use-link-status.js.map +0 -1
  548. package/dist/browser/react/use-mount.d.ts +0 -25
  549. package/dist/browser/react/use-mount.d.ts.map +0 -1
  550. package/dist/browser/react/use-mount.js +0 -30
  551. package/dist/browser/react/use-mount.js.map +0 -1
  552. package/dist/browser/react/use-navigation.d.ts +0 -27
  553. package/dist/browser/react/use-navigation.d.ts.map +0 -1
  554. package/dist/browser/react/use-navigation.js +0 -87
  555. package/dist/browser/react/use-navigation.js.map +0 -1
  556. package/dist/browser/react/use-segments.d.ts +0 -38
  557. package/dist/browser/react/use-segments.d.ts.map +0 -1
  558. package/dist/browser/react/use-segments.js +0 -130
  559. package/dist/browser/react/use-segments.js.map +0 -1
  560. package/dist/browser/request-controller.d.ts +0 -26
  561. package/dist/browser/request-controller.d.ts.map +0 -1
  562. package/dist/browser/request-controller.js +0 -147
  563. package/dist/browser/request-controller.js.map +0 -1
  564. package/dist/browser/rsc-router.d.ts +0 -129
  565. package/dist/browser/rsc-router.d.ts.map +0 -1
  566. package/dist/browser/rsc-router.js +0 -195
  567. package/dist/browser/rsc-router.js.map +0 -1
  568. package/dist/browser/scroll-restoration.d.ts +0 -93
  569. package/dist/browser/scroll-restoration.d.ts.map +0 -1
  570. package/dist/browser/scroll-restoration.js +0 -321
  571. package/dist/browser/scroll-restoration.js.map +0 -1
  572. package/dist/browser/segment-structure-assert.d.ts +0 -17
  573. package/dist/browser/segment-structure-assert.d.ts.map +0 -1
  574. package/dist/browser/segment-structure-assert.js +0 -59
  575. package/dist/browser/segment-structure-assert.js.map +0 -1
  576. package/dist/browser/server-action-bridge.d.ts +0 -26
  577. package/dist/browser/server-action-bridge.d.ts.map +0 -1
  578. package/dist/browser/server-action-bridge.js +0 -668
  579. package/dist/browser/server-action-bridge.js.map +0 -1
  580. package/dist/browser/shallow.d.ts +0 -12
  581. package/dist/browser/shallow.d.ts.map +0 -1
  582. package/dist/browser/shallow.js +0 -34
  583. package/dist/browser/shallow.js.map +0 -1
  584. package/dist/browser/types.d.ts +0 -369
  585. package/dist/browser/types.d.ts.map +0 -1
  586. package/dist/browser/types.js +0 -2
  587. package/dist/browser/types.js.map +0 -1
  588. package/dist/build/__tests__/generate-cli.test.d.ts +0 -2
  589. package/dist/build/__tests__/generate-cli.test.d.ts.map +0 -1
  590. package/dist/build/__tests__/generate-cli.test.js +0 -237
  591. package/dist/build/__tests__/generate-cli.test.js.map +0 -1
  592. package/dist/build/__tests__/generate-manifest.test.d.ts +0 -2
  593. package/dist/build/__tests__/generate-manifest.test.d.ts.map +0 -1
  594. package/dist/build/__tests__/generate-manifest.test.js +0 -119
  595. package/dist/build/__tests__/generate-manifest.test.js.map +0 -1
  596. package/dist/build/__tests__/generate-route-types.test.d.ts +0 -2
  597. package/dist/build/__tests__/generate-route-types.test.d.ts.map +0 -1
  598. package/dist/build/__tests__/generate-route-types.test.js +0 -620
  599. package/dist/build/__tests__/generate-route-types.test.js.map +0 -1
  600. package/dist/build/__tests__/per-router-manifest.test.d.ts +0 -2
  601. package/dist/build/__tests__/per-router-manifest.test.d.ts.map +0 -1
  602. package/dist/build/__tests__/per-router-manifest.test.js +0 -308
  603. package/dist/build/__tests__/per-router-manifest.test.js.map +0 -1
  604. package/dist/build/generate-manifest.d.ts +0 -81
  605. package/dist/build/generate-manifest.d.ts.map +0 -1
  606. package/dist/build/generate-manifest.js +0 -276
  607. package/dist/build/generate-manifest.js.map +0 -1
  608. package/dist/build/generate-route-types.d.ts +0 -115
  609. package/dist/build/generate-route-types.d.ts.map +0 -1
  610. package/dist/build/generate-route-types.js +0 -740
  611. package/dist/build/generate-route-types.js.map +0 -1
  612. package/dist/build/index.d.ts +0 -21
  613. package/dist/build/index.d.ts.map +0 -1
  614. package/dist/build/index.js +0 -21
  615. package/dist/build/index.js.map +0 -1
  616. package/dist/build/route-trie.d.ts +0 -71
  617. package/dist/build/route-trie.d.ts.map +0 -1
  618. package/dist/build/route-trie.js +0 -175
  619. package/dist/build/route-trie.js.map +0 -1
  620. package/dist/cache/__tests__/cache-scope.test.d.ts +0 -2
  621. package/dist/cache/__tests__/cache-scope.test.d.ts.map +0 -1
  622. package/dist/cache/__tests__/cache-scope.test.js +0 -208
  623. package/dist/cache/__tests__/cache-scope.test.js.map +0 -1
  624. package/dist/cache/__tests__/document-cache.test.d.ts +0 -2
  625. package/dist/cache/__tests__/document-cache.test.d.ts.map +0 -1
  626. package/dist/cache/__tests__/document-cache.test.js +0 -345
  627. package/dist/cache/__tests__/document-cache.test.js.map +0 -1
  628. package/dist/cache/__tests__/memory-segment-store.test.d.ts +0 -2
  629. package/dist/cache/__tests__/memory-segment-store.test.d.ts.map +0 -1
  630. package/dist/cache/__tests__/memory-segment-store.test.js +0 -425
  631. package/dist/cache/__tests__/memory-segment-store.test.js.map +0 -1
  632. package/dist/cache/__tests__/memory-store.test.d.ts +0 -2
  633. package/dist/cache/__tests__/memory-store.test.d.ts.map +0 -1
  634. package/dist/cache/__tests__/memory-store.test.js +0 -367
  635. package/dist/cache/__tests__/memory-store.test.js.map +0 -1
  636. package/dist/cache/cache-scope.d.ts +0 -102
  637. package/dist/cache/cache-scope.d.ts.map +0 -1
  638. package/dist/cache/cache-scope.js +0 -440
  639. package/dist/cache/cache-scope.js.map +0 -1
  640. package/dist/cache/cf/__tests__/cf-cache-store.test.d.ts +0 -2
  641. package/dist/cache/cf/__tests__/cf-cache-store.test.d.ts.map +0 -1
  642. package/dist/cache/cf/__tests__/cf-cache-store.test.js +0 -330
  643. package/dist/cache/cf/__tests__/cf-cache-store.test.js.map +0 -1
  644. package/dist/cache/cf/cf-cache-store.d.ts +0 -165
  645. package/dist/cache/cf/cf-cache-store.d.ts.map +0 -1
  646. package/dist/cache/cf/cf-cache-store.js +0 -242
  647. package/dist/cache/cf/cf-cache-store.js.map +0 -1
  648. package/dist/cache/cf/index.d.ts +0 -14
  649. package/dist/cache/cf/index.d.ts.map +0 -1
  650. package/dist/cache/cf/index.js +0 -17
  651. package/dist/cache/cf/index.js.map +0 -1
  652. package/dist/cache/document-cache.d.ts +0 -64
  653. package/dist/cache/document-cache.d.ts.map +0 -1
  654. package/dist/cache/document-cache.js +0 -228
  655. package/dist/cache/document-cache.js.map +0 -1
  656. package/dist/cache/index.d.ts +0 -19
  657. package/dist/cache/index.d.ts.map +0 -1
  658. package/dist/cache/index.js +0 -21
  659. package/dist/cache/index.js.map +0 -1
  660. package/dist/cache/memory-segment-store.d.ts +0 -110
  661. package/dist/cache/memory-segment-store.d.ts.map +0 -1
  662. package/dist/cache/memory-segment-store.js +0 -117
  663. package/dist/cache/memory-segment-store.js.map +0 -1
  664. package/dist/cache/memory-store.d.ts +0 -41
  665. package/dist/cache/memory-store.d.ts.map +0 -1
  666. package/dist/cache/memory-store.js +0 -191
  667. package/dist/cache/memory-store.js.map +0 -1
  668. package/dist/cache/types.d.ts +0 -317
  669. package/dist/cache/types.d.ts.map +0 -1
  670. package/dist/cache/types.js +0 -12
  671. package/dist/cache/types.js.map +0 -1
  672. package/dist/client.d.ts +0 -248
  673. package/dist/client.d.ts.map +0 -1
  674. package/dist/client.js +0 -367
  675. package/dist/client.js.map +0 -1
  676. package/dist/client.rsc.d.ts +0 -26
  677. package/dist/client.rsc.d.ts.map +0 -1
  678. package/dist/client.rsc.js +0 -46
  679. package/dist/client.rsc.js.map +0 -1
  680. package/dist/component-utils.d.ts +0 -36
  681. package/dist/component-utils.d.ts.map +0 -1
  682. package/dist/component-utils.js +0 -61
  683. package/dist/component-utils.js.map +0 -1
  684. package/dist/components/DefaultDocument.d.ts +0 -13
  685. package/dist/components/DefaultDocument.d.ts.map +0 -1
  686. package/dist/components/DefaultDocument.js +0 -15
  687. package/dist/components/DefaultDocument.js.map +0 -1
  688. package/dist/debug.d.ts +0 -58
  689. package/dist/debug.d.ts.map +0 -1
  690. package/dist/debug.js +0 -157
  691. package/dist/debug.js.map +0 -1
  692. package/dist/default-error-boundary.d.ts +0 -11
  693. package/dist/default-error-boundary.d.ts.map +0 -1
  694. package/dist/default-error-boundary.js +0 -45
  695. package/dist/default-error-boundary.js.map +0 -1
  696. package/dist/deps/browser.d.ts +0 -2
  697. package/dist/deps/browser.d.ts.map +0 -1
  698. package/dist/deps/browser.js +0 -3
  699. package/dist/deps/browser.js.map +0 -1
  700. package/dist/deps/html-stream-client.d.ts +0 -2
  701. package/dist/deps/html-stream-client.d.ts.map +0 -1
  702. package/dist/deps/html-stream-client.js +0 -3
  703. package/dist/deps/html-stream-client.js.map +0 -1
  704. package/dist/deps/html-stream-server.d.ts +0 -2
  705. package/dist/deps/html-stream-server.d.ts.map +0 -1
  706. package/dist/deps/html-stream-server.js +0 -3
  707. package/dist/deps/html-stream-server.js.map +0 -1
  708. package/dist/deps/rsc.d.ts +0 -2
  709. package/dist/deps/rsc.d.ts.map +0 -1
  710. package/dist/deps/rsc.js +0 -4
  711. package/dist/deps/rsc.js.map +0 -1
  712. package/dist/deps/ssr.d.ts +0 -2
  713. package/dist/deps/ssr.d.ts.map +0 -1
  714. package/dist/deps/ssr.js +0 -3
  715. package/dist/deps/ssr.js.map +0 -1
  716. package/dist/errors.d.ts +0 -174
  717. package/dist/errors.d.ts.map +0 -1
  718. package/dist/errors.js +0 -241
  719. package/dist/errors.js.map +0 -1
  720. package/dist/handle.d.ts +0 -78
  721. package/dist/handle.d.ts.map +0 -1
  722. package/dist/handle.js +0 -82
  723. package/dist/handle.js.map +0 -1
  724. package/dist/handles/MetaTags.d.ts +0 -14
  725. package/dist/handles/MetaTags.d.ts.map +0 -1
  726. package/dist/handles/MetaTags.js +0 -136
  727. package/dist/handles/MetaTags.js.map +0 -1
  728. package/dist/handles/index.d.ts +0 -6
  729. package/dist/handles/index.d.ts.map +0 -1
  730. package/dist/handles/index.js +0 -6
  731. package/dist/handles/index.js.map +0 -1
  732. package/dist/handles/meta.d.ts +0 -39
  733. package/dist/handles/meta.d.ts.map +0 -1
  734. package/dist/handles/meta.js +0 -202
  735. package/dist/handles/meta.js.map +0 -1
  736. package/dist/host/__tests__/errors.test.d.ts +0 -2
  737. package/dist/host/__tests__/errors.test.d.ts.map +0 -1
  738. package/dist/host/__tests__/errors.test.js +0 -76
  739. package/dist/host/__tests__/errors.test.js.map +0 -1
  740. package/dist/host/__tests__/pattern-comprehensive.test.d.ts +0 -2
  741. package/dist/host/__tests__/pattern-comprehensive.test.d.ts.map +0 -1
  742. package/dist/host/__tests__/pattern-comprehensive.test.js +0 -732
  743. package/dist/host/__tests__/pattern-comprehensive.test.js.map +0 -1
  744. package/dist/host/__tests__/pattern-matcher.test.d.ts +0 -2
  745. package/dist/host/__tests__/pattern-matcher.test.d.ts.map +0 -1
  746. package/dist/host/__tests__/pattern-matcher.test.js +0 -251
  747. package/dist/host/__tests__/pattern-matcher.test.js.map +0 -1
  748. package/dist/host/__tests__/router.test.d.ts +0 -2
  749. package/dist/host/__tests__/router.test.d.ts.map +0 -1
  750. package/dist/host/__tests__/router.test.js +0 -241
  751. package/dist/host/__tests__/router.test.js.map +0 -1
  752. package/dist/host/__tests__/testing.test.d.ts +0 -2
  753. package/dist/host/__tests__/testing.test.d.ts.map +0 -1
  754. package/dist/host/__tests__/testing.test.js +0 -64
  755. package/dist/host/__tests__/testing.test.js.map +0 -1
  756. package/dist/host/__tests__/utils.test.d.ts +0 -2
  757. package/dist/host/__tests__/utils.test.d.ts.map +0 -1
  758. package/dist/host/__tests__/utils.test.js +0 -29
  759. package/dist/host/__tests__/utils.test.js.map +0 -1
  760. package/dist/host/cookie-handler.d.ts +0 -34
  761. package/dist/host/cookie-handler.d.ts.map +0 -1
  762. package/dist/host/cookie-handler.js +0 -124
  763. package/dist/host/cookie-handler.js.map +0 -1
  764. package/dist/host/errors.d.ts +0 -56
  765. package/dist/host/errors.d.ts.map +0 -1
  766. package/dist/host/errors.js +0 -79
  767. package/dist/host/errors.js.map +0 -1
  768. package/dist/host/index.d.ts +0 -29
  769. package/dist/host/index.d.ts.map +0 -1
  770. package/dist/host/index.js +0 -32
  771. package/dist/host/index.js.map +0 -1
  772. package/dist/host/pattern-matcher.d.ts +0 -36
  773. package/dist/host/pattern-matcher.d.ts.map +0 -1
  774. package/dist/host/pattern-matcher.js +0 -172
  775. package/dist/host/pattern-matcher.js.map +0 -1
  776. package/dist/host/router.d.ts +0 -26
  777. package/dist/host/router.d.ts.map +0 -1
  778. package/dist/host/router.js +0 -218
  779. package/dist/host/router.js.map +0 -1
  780. package/dist/host/testing.d.ts +0 -36
  781. package/dist/host/testing.d.ts.map +0 -1
  782. package/dist/host/testing.js +0 -55
  783. package/dist/host/testing.js.map +0 -1
  784. package/dist/host/types.d.ts +0 -115
  785. package/dist/host/types.d.ts.map +0 -1
  786. package/dist/host/types.js +0 -7
  787. package/dist/host/types.js.map +0 -1
  788. package/dist/host/utils.d.ts +0 -21
  789. package/dist/host/utils.d.ts.map +0 -1
  790. package/dist/host/utils.js +0 -23
  791. package/dist/host/utils.js.map +0 -1
  792. package/dist/href-client.d.ts +0 -131
  793. package/dist/href-client.d.ts.map +0 -1
  794. package/dist/href-client.js +0 -64
  795. package/dist/href-client.js.map +0 -1
  796. package/dist/href-context.d.ts +0 -29
  797. package/dist/href-context.d.ts.map +0 -1
  798. package/dist/href-context.js +0 -21
  799. package/dist/href-context.js.map +0 -1
  800. package/dist/index.d.ts +0 -73
  801. package/dist/index.d.ts.map +0 -1
  802. package/dist/index.js +0 -91
  803. package/dist/index.js.map +0 -1
  804. package/dist/index.rsc.d.ts +0 -32
  805. package/dist/index.rsc.d.ts.map +0 -1
  806. package/dist/index.rsc.js +0 -40
  807. package/dist/index.rsc.js.map +0 -1
  808. package/dist/internal-debug.d.ts +0 -2
  809. package/dist/internal-debug.d.ts.map +0 -1
  810. package/dist/internal-debug.js +0 -5
  811. package/dist/internal-debug.js.map +0 -1
  812. package/dist/loader.d.ts +0 -14
  813. package/dist/loader.d.ts.map +0 -1
  814. package/dist/loader.js +0 -20
  815. package/dist/loader.js.map +0 -1
  816. package/dist/loader.rsc.d.ts +0 -19
  817. package/dist/loader.rsc.d.ts.map +0 -1
  818. package/dist/loader.rsc.js +0 -99
  819. package/dist/loader.rsc.js.map +0 -1
  820. package/dist/network-error-thrower.d.ts +0 -17
  821. package/dist/network-error-thrower.d.ts.map +0 -1
  822. package/dist/network-error-thrower.js +0 -14
  823. package/dist/network-error-thrower.js.map +0 -1
  824. package/dist/outlet-context.d.ts +0 -13
  825. package/dist/outlet-context.d.ts.map +0 -1
  826. package/dist/outlet-context.js +0 -3
  827. package/dist/outlet-context.js.map +0 -1
  828. package/dist/prerender/__tests__/param-hash.test.d.ts +0 -2
  829. package/dist/prerender/__tests__/param-hash.test.d.ts.map +0 -1
  830. package/dist/prerender/__tests__/param-hash.test.js +0 -148
  831. package/dist/prerender/__tests__/param-hash.test.js.map +0 -1
  832. package/dist/prerender/param-hash.d.ts +0 -16
  833. package/dist/prerender/param-hash.d.ts.map +0 -1
  834. package/dist/prerender/param-hash.js +0 -36
  835. package/dist/prerender/param-hash.js.map +0 -1
  836. package/dist/prerender/store.d.ts +0 -38
  837. package/dist/prerender/store.d.ts.map +0 -1
  838. package/dist/prerender/store.js +0 -61
  839. package/dist/prerender/store.js.map +0 -1
  840. package/dist/prerender.d.ts +0 -66
  841. package/dist/prerender.d.ts.map +0 -1
  842. package/dist/prerender.js +0 -57
  843. package/dist/prerender.js.map +0 -1
  844. package/dist/reverse.d.ts +0 -196
  845. package/dist/reverse.d.ts.map +0 -1
  846. package/dist/reverse.js +0 -78
  847. package/dist/reverse.js.map +0 -1
  848. package/dist/root-error-boundary.d.ts +0 -33
  849. package/dist/root-error-boundary.d.ts.map +0 -1
  850. package/dist/root-error-boundary.js +0 -165
  851. package/dist/root-error-boundary.js.map +0 -1
  852. package/dist/route-content-wrapper.d.ts +0 -46
  853. package/dist/route-content-wrapper.d.ts.map +0 -1
  854. package/dist/route-content-wrapper.js +0 -77
  855. package/dist/route-content-wrapper.js.map +0 -1
  856. package/dist/route-definition.d.ts +0 -421
  857. package/dist/route-definition.d.ts.map +0 -1
  858. package/dist/route-definition.js +0 -868
  859. package/dist/route-definition.js.map +0 -1
  860. package/dist/route-map-builder.d.ts +0 -155
  861. package/dist/route-map-builder.d.ts.map +0 -1
  862. package/dist/route-map-builder.js +0 -237
  863. package/dist/route-map-builder.js.map +0 -1
  864. package/dist/route-types.d.ts +0 -165
  865. package/dist/route-types.d.ts.map +0 -1
  866. package/dist/route-types.js +0 -7
  867. package/dist/route-types.js.map +0 -1
  868. package/dist/router/__tests__/handler-context.test.d.ts +0 -2
  869. package/dist/router/__tests__/handler-context.test.d.ts.map +0 -1
  870. package/dist/router/__tests__/handler-context.test.js +0 -65
  871. package/dist/router/__tests__/handler-context.test.js.map +0 -1
  872. package/dist/router/__tests__/loader-cycle-detection.test.d.ts +0 -2
  873. package/dist/router/__tests__/loader-cycle-detection.test.d.ts.map +0 -1
  874. package/dist/router/__tests__/loader-cycle-detection.test.js +0 -221
  875. package/dist/router/__tests__/loader-cycle-detection.test.js.map +0 -1
  876. package/dist/router/__tests__/match-context.test.d.ts +0 -2
  877. package/dist/router/__tests__/match-context.test.d.ts.map +0 -1
  878. package/dist/router/__tests__/match-context.test.js +0 -92
  879. package/dist/router/__tests__/match-context.test.js.map +0 -1
  880. package/dist/router/__tests__/match-pipelines.test.d.ts +0 -2
  881. package/dist/router/__tests__/match-pipelines.test.d.ts.map +0 -1
  882. package/dist/router/__tests__/match-pipelines.test.js +0 -417
  883. package/dist/router/__tests__/match-pipelines.test.js.map +0 -1
  884. package/dist/router/__tests__/match-result.test.d.ts +0 -2
  885. package/dist/router/__tests__/match-result.test.d.ts.map +0 -1
  886. package/dist/router/__tests__/match-result.test.js +0 -457
  887. package/dist/router/__tests__/match-result.test.js.map +0 -1
  888. package/dist/router/__tests__/on-error.test.d.ts +0 -2
  889. package/dist/router/__tests__/on-error.test.d.ts.map +0 -1
  890. package/dist/router/__tests__/on-error.test.js +0 -678
  891. package/dist/router/__tests__/on-error.test.js.map +0 -1
  892. package/dist/router/__tests__/pattern-matching.test.d.ts +0 -2
  893. package/dist/router/__tests__/pattern-matching.test.d.ts.map +0 -1
  894. package/dist/router/__tests__/pattern-matching.test.js +0 -629
  895. package/dist/router/__tests__/pattern-matching.test.js.map +0 -1
  896. package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts +0 -2
  897. package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts.map +0 -1
  898. package/dist/router/__tests__/segment-resolution-parallel-loading.test.js +0 -155
  899. package/dist/router/__tests__/segment-resolution-parallel-loading.test.js.map +0 -1
  900. package/dist/router/error-handling.d.ts +0 -77
  901. package/dist/router/error-handling.d.ts.map +0 -1
  902. package/dist/router/error-handling.js +0 -202
  903. package/dist/router/error-handling.js.map +0 -1
  904. package/dist/router/handler-context.d.ts +0 -20
  905. package/dist/router/handler-context.d.ts.map +0 -1
  906. package/dist/router/handler-context.js +0 -198
  907. package/dist/router/handler-context.js.map +0 -1
  908. package/dist/router/intercept-resolution.d.ts +0 -66
  909. package/dist/router/intercept-resolution.d.ts.map +0 -1
  910. package/dist/router/intercept-resolution.js +0 -246
  911. package/dist/router/intercept-resolution.js.map +0 -1
  912. package/dist/router/loader-resolution.d.ts +0 -64
  913. package/dist/router/loader-resolution.d.ts.map +0 -1
  914. package/dist/router/loader-resolution.js +0 -284
  915. package/dist/router/loader-resolution.js.map +0 -1
  916. package/dist/router/logging.d.ts +0 -15
  917. package/dist/router/logging.d.ts.map +0 -1
  918. package/dist/router/logging.js +0 -99
  919. package/dist/router/logging.js.map +0 -1
  920. package/dist/router/manifest.d.ts +0 -22
  921. package/dist/router/manifest.d.ts.map +0 -1
  922. package/dist/router/manifest.js +0 -181
  923. package/dist/router/manifest.js.map +0 -1
  924. package/dist/router/match-api.d.ts +0 -35
  925. package/dist/router/match-api.d.ts.map +0 -1
  926. package/dist/router/match-api.js +0 -406
  927. package/dist/router/match-api.js.map +0 -1
  928. package/dist/router/match-context.d.ts +0 -206
  929. package/dist/router/match-context.d.ts.map +0 -1
  930. package/dist/router/match-context.js +0 -17
  931. package/dist/router/match-context.js.map +0 -1
  932. package/dist/router/match-middleware/background-revalidation.d.ts +0 -127
  933. package/dist/router/match-middleware/background-revalidation.d.ts.map +0 -1
  934. package/dist/router/match-middleware/background-revalidation.js +0 -75
  935. package/dist/router/match-middleware/background-revalidation.js.map +0 -1
  936. package/dist/router/match-middleware/cache-lookup.d.ts +0 -112
  937. package/dist/router/match-middleware/cache-lookup.d.ts.map +0 -1
  938. package/dist/router/match-middleware/cache-lookup.js +0 -257
  939. package/dist/router/match-middleware/cache-lookup.js.map +0 -1
  940. package/dist/router/match-middleware/cache-store.d.ts +0 -113
  941. package/dist/router/match-middleware/cache-store.d.ts.map +0 -1
  942. package/dist/router/match-middleware/cache-store.js +0 -108
  943. package/dist/router/match-middleware/cache-store.js.map +0 -1
  944. package/dist/router/match-middleware/index.d.ts +0 -81
  945. package/dist/router/match-middleware/index.d.ts.map +0 -1
  946. package/dist/router/match-middleware/index.js +0 -80
  947. package/dist/router/match-middleware/index.js.map +0 -1
  948. package/dist/router/match-middleware/intercept-resolution.d.ts +0 -117
  949. package/dist/router/match-middleware/intercept-resolution.d.ts.map +0 -1
  950. package/dist/router/match-middleware/intercept-resolution.js +0 -134
  951. package/dist/router/match-middleware/intercept-resolution.js.map +0 -1
  952. package/dist/router/match-middleware/segment-resolution.d.ts +0 -99
  953. package/dist/router/match-middleware/segment-resolution.d.ts.map +0 -1
  954. package/dist/router/match-middleware/segment-resolution.js +0 -53
  955. package/dist/router/match-middleware/segment-resolution.js.map +0 -1
  956. package/dist/router/match-pipelines.d.ts +0 -147
  957. package/dist/router/match-pipelines.d.ts.map +0 -1
  958. package/dist/router/match-pipelines.js +0 -82
  959. package/dist/router/match-pipelines.js.map +0 -1
  960. package/dist/router/match-result.d.ts +0 -126
  961. package/dist/router/match-result.d.ts.map +0 -1
  962. package/dist/router/match-result.js +0 -93
  963. package/dist/router/match-result.js.map +0 -1
  964. package/dist/router/metrics.d.ts +0 -20
  965. package/dist/router/metrics.d.ts.map +0 -1
  966. package/dist/router/metrics.js +0 -47
  967. package/dist/router/metrics.js.map +0 -1
  968. package/dist/router/middleware.d.ts +0 -249
  969. package/dist/router/middleware.d.ts.map +0 -1
  970. package/dist/router/middleware.js +0 -434
  971. package/dist/router/middleware.js.map +0 -1
  972. package/dist/router/middleware.test.d.ts +0 -2
  973. package/dist/router/middleware.test.d.ts.map +0 -1
  974. package/dist/router/middleware.test.js +0 -816
  975. package/dist/router/middleware.test.js.map +0 -1
  976. package/dist/router/pattern-matching.d.ts +0 -149
  977. package/dist/router/pattern-matching.d.ts.map +0 -1
  978. package/dist/router/pattern-matching.js +0 -349
  979. package/dist/router/pattern-matching.js.map +0 -1
  980. package/dist/router/revalidation.d.ts +0 -44
  981. package/dist/router/revalidation.d.ts.map +0 -1
  982. package/dist/router/revalidation.js +0 -147
  983. package/dist/router/revalidation.js.map +0 -1
  984. package/dist/router/router-context.d.ts +0 -135
  985. package/dist/router/router-context.d.ts.map +0 -1
  986. package/dist/router/router-context.js +0 -36
  987. package/dist/router/router-context.js.map +0 -1
  988. package/dist/router/segment-resolution.d.ts +0 -127
  989. package/dist/router/segment-resolution.d.ts.map +0 -1
  990. package/dist/router/segment-resolution.js +0 -919
  991. package/dist/router/segment-resolution.js.map +0 -1
  992. package/dist/router/trie-matching.d.ts +0 -40
  993. package/dist/router/trie-matching.d.ts.map +0 -1
  994. package/dist/router/trie-matching.js +0 -127
  995. package/dist/router/trie-matching.js.map +0 -1
  996. package/dist/router/types.d.ts +0 -136
  997. package/dist/router/types.d.ts.map +0 -1
  998. package/dist/router/types.js +0 -7
  999. package/dist/router/types.js.map +0 -1
  1000. package/dist/router.d.ts +0 -753
  1001. package/dist/router.d.ts.map +0 -1
  1002. package/dist/router.gen.d.ts +0 -6
  1003. package/dist/router.gen.d.ts.map +0 -1
  1004. package/dist/router.gen.js +0 -6
  1005. package/dist/router.gen.js.map +0 -1
  1006. package/dist/router.js +0 -1304
  1007. package/dist/router.js.map +0 -1
  1008. package/dist/rsc/__tests__/helpers.test.d.ts +0 -2
  1009. package/dist/rsc/__tests__/helpers.test.d.ts.map +0 -1
  1010. package/dist/rsc/__tests__/helpers.test.js +0 -140
  1011. package/dist/rsc/__tests__/helpers.test.js.map +0 -1
  1012. package/dist/rsc/handler.d.ts +0 -45
  1013. package/dist/rsc/handler.d.ts.map +0 -1
  1014. package/dist/rsc/handler.js +0 -1172
  1015. package/dist/rsc/handler.js.map +0 -1
  1016. package/dist/rsc/helpers.d.ts +0 -16
  1017. package/dist/rsc/helpers.d.ts.map +0 -1
  1018. package/dist/rsc/helpers.js +0 -55
  1019. package/dist/rsc/helpers.js.map +0 -1
  1020. package/dist/rsc/index.d.ts +0 -22
  1021. package/dist/rsc/index.d.ts.map +0 -1
  1022. package/dist/rsc/index.js +0 -23
  1023. package/dist/rsc/index.js.map +0 -1
  1024. package/dist/rsc/nonce.d.ts +0 -9
  1025. package/dist/rsc/nonce.d.ts.map +0 -1
  1026. package/dist/rsc/nonce.js +0 -18
  1027. package/dist/rsc/nonce.js.map +0 -1
  1028. package/dist/rsc/types.d.ts +0 -206
  1029. package/dist/rsc/types.d.ts.map +0 -1
  1030. package/dist/rsc/types.js +0 -8
  1031. package/dist/rsc/types.js.map +0 -1
  1032. package/dist/search-params.d.ts +0 -103
  1033. package/dist/search-params.d.ts.map +0 -1
  1034. package/dist/search-params.js +0 -74
  1035. package/dist/search-params.js.map +0 -1
  1036. package/dist/segment-system.d.ts +0 -75
  1037. package/dist/segment-system.d.ts.map +0 -1
  1038. package/dist/segment-system.js +0 -336
  1039. package/dist/segment-system.js.map +0 -1
  1040. package/dist/server/context.d.ts +0 -245
  1041. package/dist/server/context.d.ts.map +0 -1
  1042. package/dist/server/context.js +0 -197
  1043. package/dist/server/context.js.map +0 -1
  1044. package/dist/server/fetchable-loader-store.d.ts +0 -18
  1045. package/dist/server/fetchable-loader-store.d.ts.map +0 -1
  1046. package/dist/server/fetchable-loader-store.js +0 -18
  1047. package/dist/server/fetchable-loader-store.js.map +0 -1
  1048. package/dist/server/handle-store.d.ts +0 -85
  1049. package/dist/server/handle-store.d.ts.map +0 -1
  1050. package/dist/server/handle-store.js +0 -142
  1051. package/dist/server/handle-store.js.map +0 -1
  1052. package/dist/server/loader-registry.d.ts +0 -55
  1053. package/dist/server/loader-registry.d.ts.map +0 -1
  1054. package/dist/server/loader-registry.js +0 -132
  1055. package/dist/server/loader-registry.js.map +0 -1
  1056. package/dist/server/request-context.d.ts +0 -226
  1057. package/dist/server/request-context.d.ts.map +0 -1
  1058. package/dist/server/request-context.js +0 -290
  1059. package/dist/server/request-context.js.map +0 -1
  1060. package/dist/server/root-layout.d.ts +0 -4
  1061. package/dist/server/root-layout.d.ts.map +0 -1
  1062. package/dist/server/root-layout.js +0 -5
  1063. package/dist/server/root-layout.js.map +0 -1
  1064. package/dist/server.d.ts +0 -15
  1065. package/dist/server.d.ts.map +0 -1
  1066. package/dist/server.js +0 -20
  1067. package/dist/server.js.map +0 -1
  1068. package/dist/ssr/__tests__/ssr-handler.test.d.ts +0 -2
  1069. package/dist/ssr/__tests__/ssr-handler.test.d.ts.map +0 -1
  1070. package/dist/ssr/__tests__/ssr-handler.test.js +0 -132
  1071. package/dist/ssr/__tests__/ssr-handler.test.js.map +0 -1
  1072. package/dist/ssr/index.d.ts +0 -98
  1073. package/dist/ssr/index.d.ts.map +0 -1
  1074. package/dist/ssr/index.js +0 -158
  1075. package/dist/ssr/index.js.map +0 -1
  1076. package/dist/static-handler.d.ts +0 -50
  1077. package/dist/static-handler.d.ts.map +0 -1
  1078. package/dist/static-handler.gen.d.ts +0 -5
  1079. package/dist/static-handler.gen.d.ts.map +0 -1
  1080. package/dist/static-handler.gen.js +0 -5
  1081. package/dist/static-handler.gen.js.map +0 -1
  1082. package/dist/static-handler.js +0 -29
  1083. package/dist/static-handler.js.map +0 -1
  1084. package/dist/theme/ThemeProvider.d.ts +0 -20
  1085. package/dist/theme/ThemeProvider.d.ts.map +0 -1
  1086. package/dist/theme/ThemeProvider.js +0 -240
  1087. package/dist/theme/ThemeProvider.js.map +0 -1
  1088. package/dist/theme/ThemeScript.d.ts +0 -48
  1089. package/dist/theme/ThemeScript.d.ts.map +0 -1
  1090. package/dist/theme/ThemeScript.js +0 -13
  1091. package/dist/theme/ThemeScript.js.map +0 -1
  1092. package/dist/theme/__tests__/theme.test.d.ts +0 -2
  1093. package/dist/theme/__tests__/theme.test.d.ts.map +0 -1
  1094. package/dist/theme/__tests__/theme.test.js +0 -103
  1095. package/dist/theme/__tests__/theme.test.js.map +0 -1
  1096. package/dist/theme/constants.d.ts +0 -29
  1097. package/dist/theme/constants.d.ts.map +0 -1
  1098. package/dist/theme/constants.js +0 -48
  1099. package/dist/theme/constants.js.map +0 -1
  1100. package/dist/theme/index.d.ts +0 -31
  1101. package/dist/theme/index.d.ts.map +0 -1
  1102. package/dist/theme/index.js +0 -36
  1103. package/dist/theme/index.js.map +0 -1
  1104. package/dist/theme/theme-context.d.ts +0 -40
  1105. package/dist/theme/theme-context.d.ts.map +0 -1
  1106. package/dist/theme/theme-context.js +0 -60
  1107. package/dist/theme/theme-context.js.map +0 -1
  1108. package/dist/theme/theme-script.d.ts +0 -27
  1109. package/dist/theme/theme-script.d.ts.map +0 -1
  1110. package/dist/theme/theme-script.js +0 -147
  1111. package/dist/theme/theme-script.js.map +0 -1
  1112. package/dist/theme/types.d.ts +0 -163
  1113. package/dist/theme/types.d.ts.map +0 -1
  1114. package/dist/theme/types.js +0 -11
  1115. package/dist/theme/types.js.map +0 -1
  1116. package/dist/theme/use-theme.d.ts +0 -12
  1117. package/dist/theme/use-theme.d.ts.map +0 -1
  1118. package/dist/theme/use-theme.js +0 -40
  1119. package/dist/theme/use-theme.js.map +0 -1
  1120. package/dist/types.d.ts +0 -1479
  1121. package/dist/types.d.ts.map +0 -1
  1122. package/dist/types.js +0 -10
  1123. package/dist/types.js.map +0 -1
  1124. package/dist/urls.d.ts +0 -441
  1125. package/dist/urls.d.ts.map +0 -1
  1126. package/dist/urls.gen.d.ts +0 -8
  1127. package/dist/urls.gen.d.ts.map +0 -1
  1128. package/dist/urls.gen.js +0 -8
  1129. package/dist/urls.gen.js.map +0 -1
  1130. package/dist/urls.js +0 -443
  1131. package/dist/urls.js.map +0 -1
  1132. package/dist/use-loader.d.ts +0 -127
  1133. package/dist/use-loader.d.ts.map +0 -1
  1134. package/dist/use-loader.js +0 -237
  1135. package/dist/use-loader.js.map +0 -1
  1136. package/dist/vite/__tests__/ast-handler-extract.test.d.ts +0 -2
  1137. package/dist/vite/__tests__/ast-handler-extract.test.d.ts.map +0 -1
  1138. package/dist/vite/__tests__/ast-handler-extract.test.js +0 -294
  1139. package/dist/vite/__tests__/ast-handler-extract.test.js.map +0 -1
  1140. package/dist/vite/__tests__/expose-id-utils.test.d.ts +0 -2
  1141. package/dist/vite/__tests__/expose-id-utils.test.d.ts.map +0 -1
  1142. package/dist/vite/__tests__/expose-id-utils.test.js +0 -224
  1143. package/dist/vite/__tests__/expose-id-utils.test.js.map +0 -1
  1144. package/dist/vite/__tests__/expose-internal-ids.test.d.ts +0 -2
  1145. package/dist/vite/__tests__/expose-internal-ids.test.d.ts.map +0 -1
  1146. package/dist/vite/__tests__/expose-internal-ids.test.js +0 -647
  1147. package/dist/vite/__tests__/expose-internal-ids.test.js.map +0 -1
  1148. package/dist/vite/__tests__/expose-router-id.test.d.ts +0 -2
  1149. package/dist/vite/__tests__/expose-router-id.test.d.ts.map +0 -1
  1150. package/dist/vite/__tests__/expose-router-id.test.js +0 -39
  1151. package/dist/vite/__tests__/expose-router-id.test.js.map +0 -1
  1152. package/dist/vite/ast-handler-extract.d.ts +0 -49
  1153. package/dist/vite/ast-handler-extract.d.ts.map +0 -1
  1154. package/dist/vite/ast-handler-extract.js +0 -249
  1155. package/dist/vite/ast-handler-extract.js.map +0 -1
  1156. package/dist/vite/expose-action-id.d.ts +0 -19
  1157. package/dist/vite/expose-action-id.d.ts.map +0 -1
  1158. package/dist/vite/expose-action-id.js +0 -250
  1159. package/dist/vite/expose-action-id.js.map +0 -1
  1160. package/dist/vite/expose-id-utils.d.ts +0 -69
  1161. package/dist/vite/expose-id-utils.d.ts.map +0 -1
  1162. package/dist/vite/expose-id-utils.js +0 -289
  1163. package/dist/vite/expose-id-utils.js.map +0 -1
  1164. package/dist/vite/expose-internal-ids.d.ts +0 -22
  1165. package/dist/vite/expose-internal-ids.d.ts.map +0 -1
  1166. package/dist/vite/expose-internal-ids.js +0 -886
  1167. package/dist/vite/expose-internal-ids.js.map +0 -1
  1168. package/dist/vite/index.d.ts +0 -149
  1169. package/dist/vite/index.d.ts.map +0 -1
  1170. package/dist/vite/index.js.bak +0 -5448
  1171. package/dist/vite/index.js.map +0 -1
  1172. package/dist/vite/index.named-routes.gen.ts +0 -103
  1173. package/dist/vite/package-resolution.d.ts +0 -43
  1174. package/dist/vite/package-resolution.d.ts.map +0 -1
  1175. package/dist/vite/package-resolution.js +0 -112
  1176. package/dist/vite/package-resolution.js.map +0 -1
  1177. package/dist/vite/virtual-entries.d.ts +0 -25
  1178. package/dist/vite/virtual-entries.d.ts.map +0 -1
  1179. package/dist/vite/virtual-entries.js +0 -110
  1180. package/dist/vite/virtual-entries.js.map +0 -1
  1181. package/src/browser/action-response-classifier.ts +0 -99
  1182. package/src/browser/react/use-client-cache.ts +0 -58
  1183. package/src/browser/shallow.ts +0 -40
  1184. package/src/handles/index.ts +0 -7
  1185. package/src/network-error-thrower.tsx +0 -23
  1186. package/src/router/middleware-cookies.ts +0 -55
@@ -10,6 +10,13 @@ import fs from "node:fs";
10
10
  // src/vite/plugins/expose-id-utils.ts
11
11
  import path from "node:path";
12
12
  import crypto from "node:crypto";
13
+
14
+ // src/regex-escape.ts
15
+ function escapeRegExp(input) {
16
+ return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17
+ }
18
+
19
+ // src/vite/plugins/expose-id-utils.ts
13
20
  function normalizePath(p) {
14
21
  return p.split(path.sep).join("/");
15
22
  }
@@ -21,8 +28,8 @@ function hashId(filePath, exportName) {
21
28
  function makeStubId(filePath, exportName, isBuild) {
22
29
  return isBuild ? hashId(filePath, exportName) : `${filePath}#${exportName}`;
23
30
  }
24
- function hashInlineId(filePath, lineNumber, index) {
25
- const input = index !== void 0 && index > 0 ? `${filePath}:${lineNumber}:${index}` : `${filePath}:${lineNumber}`;
31
+ function hashInlineId(filePath, fnName, index) {
32
+ const input = `${filePath}:${fnName}:${index}`;
26
33
  return crypto.createHash("sha256").update(input).digest("hex").slice(0, 8);
27
34
  }
28
35
  function buildExportMap(program) {
@@ -158,7 +165,9 @@ function countArgs(code, startPos, endPos) {
158
165
  while (i < endPos) {
159
166
  const skipped = skipStringOrComment(code, i);
160
167
  if (skipped > i) {
161
- hasContent = true;
168
+ const ch = code[i];
169
+ const isComment = ch === "/" && i + 1 < code.length && (code[i + 1] === "/" || code[i + 1] === "*");
170
+ if (!isComment) hasContent = true;
162
171
  i = skipped;
163
172
  continue;
164
173
  }
@@ -187,8 +196,59 @@ function findStatementEnd(code, pos) {
187
196
  }
188
197
  return i;
189
198
  }
190
- function escapeRegExp(input) {
191
- return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
199
+ function findCallParenAfterGenerics(code, afterCalleeIndex) {
200
+ let i = afterCalleeIndex;
201
+ while (i < code.length) {
202
+ const skipped = skipStringOrComment(code, i);
203
+ if (skipped > i) {
204
+ i = skipped;
205
+ continue;
206
+ }
207
+ if (/\s/.test(code[i])) {
208
+ i++;
209
+ continue;
210
+ }
211
+ break;
212
+ }
213
+ if (i >= code.length) return -1;
214
+ if (code[i] === "(") return i;
215
+ if (code[i] === "<") {
216
+ let depth = 0;
217
+ while (i < code.length) {
218
+ const skipped = skipStringOrComment(code, i);
219
+ if (skipped > i) {
220
+ i = skipped;
221
+ continue;
222
+ }
223
+ const ch = code[i];
224
+ if (ch === "<") {
225
+ depth++;
226
+ } else if (ch === ">") {
227
+ depth--;
228
+ if (depth === 0) {
229
+ i++;
230
+ break;
231
+ }
232
+ }
233
+ i++;
234
+ }
235
+ if (depth !== 0) return -1;
236
+ while (i < code.length) {
237
+ const skipped = skipStringOrComment(code, i);
238
+ if (skipped > i) {
239
+ i = skipped;
240
+ continue;
241
+ }
242
+ if (/\s/.test(code[i])) {
243
+ i++;
244
+ continue;
245
+ }
246
+ break;
247
+ }
248
+ if (i < code.length && code[i] === "(") return i;
249
+ return -1;
250
+ }
251
+ return -1;
192
252
  }
193
253
 
194
254
  // src/vite/debug.ts
@@ -200,7 +260,8 @@ var NS = {
200
260
  prerender: "rango:prerender",
201
261
  build: "rango:build",
202
262
  dev: "rango:dev",
203
- transform: "rango:transform"
263
+ transform: "rango:transform",
264
+ chunks: "rango:chunks"
204
265
  };
205
266
  if (process.env.INTERNAL_RANGO_DEBUG) {
206
267
  const existing = debugFactory.disable();
@@ -292,7 +353,7 @@ function getRscPluginApi(config) {
292
353
  );
293
354
  if (plugin) {
294
355
  console.warn(
295
- `[rsc-router:expose-action-id] RSC plugin found by API structure (name: "${plugin.name}"). Consider updating the name lookup if the plugin was renamed.`
356
+ `[rango:expose-action-id] RSC plugin found by API structure (name: "${plugin.name}"). Consider updating the name lookup if the plugin was renamed.`
296
357
  );
297
358
  }
298
359
  }
@@ -393,7 +454,7 @@ function exposeActionId() {
393
454
  }
394
455
  if (!rscPluginApi) {
395
456
  throw new Error(
396
- "[rsc-router] Could not find @vitejs/plugin-rsc. @rangojs/router requires the Vite RSC plugin, which is included automatically by rango()."
457
+ "[rango] Could not find @vitejs/plugin-rsc. @rangojs/router requires the Vite RSC plugin, which is included automatically by rango()."
397
458
  );
398
459
  }
399
460
  if (!isBuild) return;
@@ -430,7 +491,6 @@ function exposeActionId() {
430
491
  counterTransform?.record(id, performance.now() - start);
431
492
  }
432
493
  },
433
- // Build mode: renderChunk runs after all transforms and bundling complete
434
494
  renderChunk(code, chunk) {
435
495
  const start = counterRender ? performance.now() : 0;
436
496
  try {
@@ -465,17 +525,17 @@ function exposeActionId() {
465
525
 
466
526
  // src/vite/plugins/expose-internal-ids.ts
467
527
  import { parseAst as parseAst2 } from "vite";
468
- import MagicString4 from "magic-string";
528
+ import MagicString3 from "magic-string";
469
529
  import path4 from "node:path";
470
530
 
471
531
  // src/vite/utils/ast-handler-extract.ts
472
532
  function isDirectivePrologueStatement(node) {
473
533
  return node?.type === "ExpressionStatement" && typeof node.directive === "string";
474
534
  }
475
- function findImportInsertionPos(code, parseAst4) {
535
+ function findImportInsertionPos(code, parseAst5) {
476
536
  let program;
477
537
  try {
478
- program = parseAst4(code, { jsx: true });
538
+ program = parseAst5(code, { lang: "tsx" });
479
539
  } catch {
480
540
  return 0;
481
541
  }
@@ -512,10 +572,10 @@ function walkNode(node, parent, ancestors, enter) {
512
572
  }
513
573
  ancestors.pop();
514
574
  }
515
- function findHandlerCalls(code, fnName, parseAst4) {
575
+ function findHandlerCalls(code, fnName, parseAst5) {
516
576
  let program;
517
577
  try {
518
- program = parseAst4(code, { jsx: true });
578
+ program = parseAst5(code, { lang: "tsx" });
519
579
  } catch {
520
580
  return [];
521
581
  }
@@ -587,18 +647,18 @@ function getImportedLocalNamesFromProgram(program, importedName) {
587
647
  }
588
648
  return localNames;
589
649
  }
590
- function getImportedLocalNames(code, importedName, parseAst4) {
650
+ function getImportedLocalNames(code, importedName, parseAst5) {
591
651
  try {
592
- const program = parseAst4(code, { jsx: true });
652
+ const program = parseAst5(code, { lang: "tsx" });
593
653
  return getImportedLocalNamesFromProgram(program, importedName);
594
654
  } catch {
595
655
  return /* @__PURE__ */ new Set();
596
656
  }
597
657
  }
598
- function extractImportDeclarations(code, parseAst4) {
658
+ function extractImportDeclarations(code, parseAst5) {
599
659
  let program;
600
660
  try {
601
- program = parseAst4(code, { jsx: true });
661
+ program = parseAst5(code, { lang: "tsx" });
602
662
  } catch {
603
663
  return [];
604
664
  }
@@ -622,13 +682,18 @@ function isInertExpression(node) {
622
682
  (e) => e === null || isInertExpression(e)
623
683
  );
624
684
  case "ObjectExpression":
625
- return (node.properties ?? []).every(
626
- (p) => p.type === "Property" && (!p.computed || isInertExpression(p.key)) && isInertExpression(p.value)
627
- );
685
+ return (node.properties ?? []).every((p) => {
686
+ if (p.type === "SpreadElement" || p.type === "RestElement") {
687
+ return isInertExpression(p.argument);
688
+ }
689
+ return p.type === "Property" && (!p.computed || isInertExpression(p.key)) && isInertExpression(p.value);
690
+ });
628
691
  case "UnaryExpression":
629
692
  return isInertExpression(node.argument);
630
693
  case "BinaryExpression":
631
694
  return isInertExpression(node.left) && isInertExpression(node.right);
695
+ case "LogicalExpression":
696
+ return isInertExpression(node.left) && isInertExpression(node.right);
632
697
  case "ConditionalExpression":
633
698
  return isInertExpression(node.test) && isInertExpression(node.consequent) && isInertExpression(node.alternate);
634
699
  case "SpreadElement":
@@ -650,10 +715,10 @@ function isSafeVariableDeclaration(node, handlerNames) {
650
715
  (d) => isSafeDeclaratorInit(d.init) && !(d.init?.type === "CallExpression" && d.init.callee?.type === "Identifier" && handlerNames.has(d.init.callee.name))
651
716
  );
652
717
  }
653
- function extractModuleLevelDeclarations(code, parseAst4, handlerNames) {
718
+ function extractModuleLevelDeclarations(code, parseAst5, handlerNames) {
654
719
  let program;
655
720
  try {
656
- program = parseAst4(code, { jsx: true });
721
+ program = parseAst5(code, { lang: "tsx" });
657
722
  } catch {
658
723
  return [];
659
724
  }
@@ -684,27 +749,25 @@ function extractModuleLevelDeclarations(code, parseAst4, handlerNames) {
684
749
  }
685
750
  return declarations;
686
751
  }
687
- function transformInlineHandlers(fnName, virtualPrefix, s, code, filePath, virtualRegistry, moduleId, parseAst4) {
688
- const sites = findHandlerCalls(code, fnName, parseAst4);
752
+ function transformInlineHandlers(fnName, virtualPrefix, s, code, filePath, virtualRegistry, moduleId, parseAst5) {
753
+ const sites = findHandlerCalls(code, fnName, parseAst5);
689
754
  const inlineSites = sites.filter((site) => site.exportInfo === null);
690
755
  if (inlineSites.length === 0) return false;
691
- const imports = extractImportDeclarations(code, parseAst4);
692
- const staticNames = getImportedLocalNames(code, "Static", parseAst4);
693
- const prerenderNames = getImportedLocalNames(code, "Prerender", parseAst4);
756
+ const imports = extractImportDeclarations(code, parseAst5);
757
+ const staticNames = getImportedLocalNames(code, "Static", parseAst5);
758
+ const prerenderNames = getImportedLocalNames(code, "Prerender", parseAst5);
694
759
  const handlerNames = /* @__PURE__ */ new Set([...staticNames, ...prerenderNames]);
695
760
  const declarations = extractModuleLevelDeclarations(
696
761
  code,
697
- parseAst4,
762
+ parseAst5,
698
763
  handlerNames
699
764
  );
700
- const lineCounts = /* @__PURE__ */ new Map();
701
765
  const importStatements = [];
702
- for (const site of inlineSites) {
703
- const lineCount = lineCounts.get(site.lineNumber) ?? 0;
704
- lineCounts.set(site.lineNumber, lineCount + 1);
705
- const hash = hashInlineId(filePath, site.lineNumber, lineCount);
766
+ for (const [siteIndex, site] of inlineSites.entries()) {
767
+ const hash = hashInlineId(filePath, fnName, siteIndex);
706
768
  const exportName = `__sh_${hash}`;
707
- const virtualId = `\0${virtualPrefix}${filePath}:${site.lineNumber}${lineCount > 0 ? `:${lineCount}` : ""}`;
769
+ const idSuffix = `${filePath}:${fnName}:${siteIndex}`;
770
+ const virtualId = `\0${virtualPrefix}${idSuffix}`;
708
771
  const handlerCode = code.slice(site.callStart, site.callEnd);
709
772
  virtualRegistry.set(virtualId, {
710
773
  originalModuleId: moduleId,
@@ -714,12 +777,12 @@ function transformInlineHandlers(fnName, virtualPrefix, s, code, filePath, virtu
714
777
  exportName
715
778
  });
716
779
  s.overwrite(site.callStart, site.callEnd, exportName);
717
- const importId = `${virtualPrefix}${filePath}:${site.lineNumber}${lineCount > 0 ? `:${lineCount}` : ""}`;
780
+ const importId = `${virtualPrefix}${idSuffix}`;
718
781
  importStatements.push(`import { ${exportName} } from "${importId}";`);
719
782
  }
720
783
  if (importStatements.length > 0) {
721
784
  const importBlock = importStatements.join("\n") + "\n";
722
- const insertionPos = findImportInsertionPos(code, parseAst4);
785
+ const insertionPos = findImportInsertionPos(code, parseAst5);
723
786
  if (insertionPos === 0) {
724
787
  s.prepend(importBlock);
725
788
  } else {
@@ -746,6 +809,138 @@ var STRICT_CREATE_CONFIGS = [
746
809
 
747
810
  // src/vite/plugins/expose-ids/export-analysis.ts
748
811
  import { parseAst } from "vite";
812
+
813
+ // src/build/route-types/source-scan.ts
814
+ function isLineTerminator(ch) {
815
+ const c = ch.charCodeAt(0);
816
+ return c === 10 || c === 13 || c === 8232 || c === 8233;
817
+ }
818
+ var REGEX_PRECEDING_KEYWORDS = /* @__PURE__ */ new Set([
819
+ "return",
820
+ "typeof",
821
+ "instanceof",
822
+ "in",
823
+ "of",
824
+ "new",
825
+ "delete",
826
+ "void",
827
+ "do",
828
+ "else",
829
+ "yield",
830
+ "await",
831
+ "case",
832
+ "throw"
833
+ ]);
834
+ function isRegexPositionAt(code, slashPos, prevChar) {
835
+ if (prevChar === void 0) return true;
836
+ if (prevChar === ")" || prevChar === "]" || prevChar === "}") return false;
837
+ if (!/[\w$]/.test(prevChar)) return true;
838
+ let k = slashPos - 1;
839
+ while (k >= 0 && /\s/.test(code[k])) k--;
840
+ const wordEnd = k + 1;
841
+ while (k >= 0 && /[\w$]/.test(code[k])) k--;
842
+ return REGEX_PRECEDING_KEYWORDS.has(code.slice(k + 1, wordEnd));
843
+ }
844
+ function makeCodeClassifier(code) {
845
+ const n = code.length;
846
+ let i = 0;
847
+ let skipStart = -1;
848
+ let skipEnd = -1;
849
+ let lastSig;
850
+ return (q) => {
851
+ if (q >= skipStart && q < skipEnd) return false;
852
+ while (i < n && i <= q) {
853
+ const c = code[i];
854
+ const d = i + 1 < n ? code[i + 1] : "";
855
+ let end = -1;
856
+ let transparent = false;
857
+ if (c === "/" && d === "/") {
858
+ let j = i + 2;
859
+ while (j < n && !isLineTerminator(code[j])) j++;
860
+ end = j;
861
+ transparent = true;
862
+ } else if (c === "/" && d === "*") {
863
+ let j = i + 2;
864
+ while (j < n && !(code[j] === "*" && code[j + 1] === "/")) j++;
865
+ end = Math.min(n, j + 2);
866
+ transparent = true;
867
+ } else if (c === '"' || c === "'" || c === "`") {
868
+ let j = i + 1;
869
+ while (j < n) {
870
+ if (code[j] === "\\") {
871
+ j += 2;
872
+ continue;
873
+ }
874
+ if (code[j] === c) {
875
+ j++;
876
+ break;
877
+ }
878
+ j++;
879
+ }
880
+ end = j;
881
+ } else if (c === "/" && d !== "/" && d !== "*" && isRegexPositionAt(code, i, lastSig)) {
882
+ let j = i + 1;
883
+ let inClass = false;
884
+ let closed = false;
885
+ while (j < n && !isLineTerminator(code[j])) {
886
+ const r = code[j];
887
+ if (r === "\\") {
888
+ j += 2;
889
+ continue;
890
+ }
891
+ if (r === "[") inClass = true;
892
+ else if (r === "]") inClass = false;
893
+ else if (r === "/" && !inClass) {
894
+ j++;
895
+ closed = true;
896
+ break;
897
+ }
898
+ j++;
899
+ }
900
+ if (closed) {
901
+ while (j < n && /[a-z]/.test(code[j])) j++;
902
+ end = j;
903
+ }
904
+ }
905
+ if (end >= 0) {
906
+ if (q < end) {
907
+ skipStart = i;
908
+ skipEnd = end;
909
+ return false;
910
+ }
911
+ i = end;
912
+ if (!transparent) lastSig = "x";
913
+ } else {
914
+ if (!/\s/.test(c)) lastSig = c;
915
+ i++;
916
+ }
917
+ }
918
+ return true;
919
+ };
920
+ }
921
+ function firstCodeMatchIndex(code, pattern) {
922
+ const inCode = makeCodeClassifier(code);
923
+ pattern.lastIndex = 0;
924
+ let m;
925
+ while ((m = pattern.exec(code)) !== null) {
926
+ if (inCode(m.index)) return m.index;
927
+ if (pattern.lastIndex <= m.index) pattern.lastIndex = m.index + 1;
928
+ }
929
+ return -1;
930
+ }
931
+ function codeMatchIndices(code, pattern) {
932
+ const inCode = makeCodeClassifier(code);
933
+ const indices = [];
934
+ pattern.lastIndex = 0;
935
+ let m;
936
+ while ((m = pattern.exec(code)) !== null) {
937
+ if (inCode(m.index)) indices.push(m.index);
938
+ if (pattern.lastIndex <= m.index) pattern.lastIndex = m.index + 1;
939
+ }
940
+ return indices;
941
+ }
942
+
943
+ // src/vite/plugins/expose-ids/export-analysis.ts
749
944
  function isExportOnlyFile(code, bindings) {
750
945
  if (bindings.length === 0) return false;
751
946
  const knownLocals = /* @__PURE__ */ new Set();
@@ -774,12 +969,40 @@ function isExportOnlyFile(code, bindings) {
774
969
  }
775
970
  return true;
776
971
  }
777
- function countCreateCallsForNames(code, fnNames) {
778
- const pattern = new RegExp(
779
- `\\b(?:${fnNames.map(escapeRegExp).join("|")})\\s*(?:<[^>]*>\\s*)?\\(`,
780
- "g"
972
+ function createCallPattern(fnNames) {
973
+ return new RegExp(`\\b(?:${fnNames.map(escapeRegExp).join("|")})\\b`, "g");
974
+ }
975
+ function createCallStartIndices(code, fnNames) {
976
+ return codeMatchIndices(code, createCallPattern(fnNames)).filter(
977
+ (index) => findCallParenAfterGenerics(
978
+ code,
979
+ index + matchedNameLength(code, index)
980
+ ) !== -1
781
981
  );
782
- return (code.match(pattern) || []).length;
982
+ }
983
+ function matchedNameLength(code, index) {
984
+ let i = index;
985
+ while (i < code.length && /[A-Za-z0-9_$]/.test(code[i])) i++;
986
+ return i - index;
987
+ }
988
+ function countCreateCallsForNames(code, fnNames) {
989
+ return createCallStartIndices(code, fnNames).length;
990
+ }
991
+ function offsetToLineColumn(code, index) {
992
+ let line = 1;
993
+ let lineStart = 0;
994
+ const end = Math.min(index, code.length);
995
+ for (let i = 0; i < end; i++) {
996
+ if (code[i] === "\n") {
997
+ line++;
998
+ lineStart = i + 1;
999
+ }
1000
+ }
1001
+ return { line, column: index - lineStart + 1 };
1002
+ }
1003
+ function findUnsupportedCreateCallSites(code, fnNames, supportedBindings) {
1004
+ const supported = new Set(supportedBindings.map((b) => b.callExprStart));
1005
+ return createCallStartIndices(code, fnNames).filter((index) => !supported.has(index)).map((index) => offsetToLineColumn(code, index));
783
1006
  }
784
1007
  function getImportedFnNames(code, importedName) {
785
1008
  const importPattern = /import\s*\{([^}]*)\}\s*from\s*["']@rangojs\/router(?:\/[^"']*)?["']/g;
@@ -810,6 +1033,17 @@ function getCalledIdentifierFromCall(callExpr) {
810
1033
  }
811
1034
  return null;
812
1035
  }
1036
+ function unwrapSignatureWrappedCall(init, fnNameSet) {
1037
+ if (init?.type !== "CallExpression") return init;
1038
+ const directId = getCalledIdentifierFromCall(init);
1039
+ if (directId && fnNameSet.has(directId)) return init;
1040
+ const firstArg = init.arguments?.[0];
1041
+ if (firstArg?.type === "CallExpression") {
1042
+ const innerId = getCalledIdentifierFromCall(firstArg);
1043
+ if (innerId && fnNameSet.has(innerId)) return firstArg;
1044
+ }
1045
+ return init;
1046
+ }
813
1047
  function collectCreateExportBindingsFallback(code, fnNames) {
814
1048
  const alternation = fnNames.map(escapeRegExp).join("|");
815
1049
  const exportConstPattern = new RegExp(
@@ -869,7 +1103,7 @@ function collectCreateExportBindingsFallback(code, fnNames) {
869
1103
  function collectCreateExportBindings(code, fnNames, program) {
870
1104
  if (!program) {
871
1105
  try {
872
- program = parseAst(code, { jsx: true });
1106
+ program = parseAst(code, { lang: "tsx" });
873
1107
  } catch {
874
1108
  return collectCreateExportBindingsFallback(code, fnNames);
875
1109
  }
@@ -882,16 +1116,16 @@ function collectCreateExportBindings(code, fnNames, program) {
882
1116
  return;
883
1117
  }
884
1118
  for (const decl of varDecl.declarations ?? []) {
885
- const calledIdentifier = getCalledIdentifierFromCall(decl?.init);
886
- if (decl?.id?.type !== "Identifier" || decl?.init?.type !== "CallExpression" || !calledIdentifier || !fnNameSet.has(calledIdentifier)) {
1119
+ const callExpr = unwrapSignatureWrappedCall(decl?.init, fnNameSet);
1120
+ const calledIdentifier = getCalledIdentifierFromCall(callExpr);
1121
+ if (decl?.id?.type !== "Identifier" || callExpr?.type !== "CallExpression" || !calledIdentifier || !fnNameSet.has(calledIdentifier)) {
887
1122
  continue;
888
1123
  }
889
1124
  const localName = decl.id.name;
890
1125
  const exportNames = exportMap.get(localName) ?? [];
891
1126
  if (exportNames.length === 0) continue;
892
- const callStart = decl.init.start;
893
- const callEnd = decl.init.end;
894
- const calleeEnd = decl.init.callee.end;
1127
+ const callEnd = callExpr.end;
1128
+ const calleeEnd = callExpr.callee.end;
895
1129
  let openParenPos = -1;
896
1130
  for (let i = calleeEnd; i < callEnd; i++) {
897
1131
  if (code[i] === "(") {
@@ -905,10 +1139,10 @@ function collectCreateExportBindings(code, fnNames, program) {
905
1139
  bindings.push({
906
1140
  localName,
907
1141
  exportNames,
908
- callExprStart: decl.init.start,
1142
+ callExprStart: callExpr.start,
909
1143
  callOpenParenPos: openParenPos,
910
1144
  callCloseParenPos: closeParenPos,
911
- argCount: decl.init.arguments?.length ?? 0,
1145
+ argCount: callExpr.arguments?.length ?? 0,
912
1146
  statementEnd
913
1147
  });
914
1148
  }
@@ -927,9 +1161,20 @@ function collectCreateExportBindings(code, fnNames, program) {
927
1161
  }
928
1162
  return bindings;
929
1163
  }
930
- function buildUnsupportedShapeWarning(filePath, fnName) {
931
- return [
932
- `[rsc-router] Unsupported ${fnName} shape in "${filePath}".`,
1164
+ function buildUnsupportedShapeWarning(filePath, fnName, sites = []) {
1165
+ const lines = [`[rango] Unsupported ${fnName} shape in "${filePath}".`];
1166
+ if (sites.length === 1) {
1167
+ const s = sites[0];
1168
+ lines.push(
1169
+ `The ${fnName}(...) call at ${filePath}:${s.line}:${s.column} has no stable $$id injected \u2014 it is not in a supported shape.`
1170
+ );
1171
+ } else if (sites.length > 1) {
1172
+ lines.push(
1173
+ `These ${fnName}(...) calls have no stable $$id injected \u2014 they are not in a supported shape:`
1174
+ );
1175
+ for (const s of sites) lines.push(` - ${filePath}:${s.line}:${s.column}`);
1176
+ }
1177
+ lines.push(
933
1178
  `Supported shapes are:`,
934
1179
  ` - export const X = ${fnName}(...)`,
935
1180
  ` - const X = ${fnName}(...); export { X }`,
@@ -937,7 +1182,8 @@ function buildUnsupportedShapeWarning(filePath, fnName) {
937
1182
  `Potentially unsupported forms include:`,
938
1183
  ` - export let/var X = ${fnName}(...)`,
939
1184
  ` - inline ${fnName}(...) calls`
940
- ].join("\n");
1185
+ );
1186
+ return lines.join("\n");
941
1187
  }
942
1188
 
943
1189
  // src/vite/plugins/expose-ids/loader-transform.ts
@@ -950,11 +1196,13 @@ function generateClientLoaderStubs(bindings, code, filePath, isBuild) {
950
1196
  if (!isExportOnlyFile(code, bindings)) return null;
951
1197
  const lines = [];
952
1198
  for (const binding of bindings) {
953
- for (const name of binding.exportNames) {
954
- const loaderId = isBuild ? hashId(filePath, name) : `${filePath}#${name}`;
955
- lines.push(
956
- `export const ${name} = { __brand: "loader", $$id: "${loaderId}" };`
957
- );
1199
+ const primaryName = binding.exportNames[0];
1200
+ const loaderId = makeStubId(filePath, primaryName, isBuild);
1201
+ lines.push(
1202
+ `export const ${primaryName} = { __brand: "loader", $$id: "${loaderId}" };`
1203
+ );
1204
+ for (const alias of binding.exportNames.slice(1)) {
1205
+ lines.push(`export const ${alias} = ${primaryName};`);
958
1206
  }
959
1207
  }
960
1208
  return { code: lines.join("\n") + "\n" };
@@ -963,7 +1211,7 @@ function transformLoaders(bindings, s, filePath, isBuild) {
963
1211
  let hasChanges = false;
964
1212
  for (const binding of bindings) {
965
1213
  const exportName = binding.exportNames[0];
966
- const loaderId = isBuild ? hashId(filePath, exportName) : `${filePath}#${exportName}`;
1214
+ const loaderId = makeStubId(filePath, exportName, isBuild);
967
1215
  const paramInjection = binding.argCount === 1 ? `, undefined, "${loaderId}"` : `, "${loaderId}"`;
968
1216
  s.appendLeft(binding.callCloseParenPos, paramInjection);
969
1217
  const propInjection = `
@@ -975,23 +1223,13 @@ ${binding.localName}.$$id = "${loaderId}";`;
975
1223
  }
976
1224
 
977
1225
  // src/vite/plugins/expose-ids/handler-transform.ts
978
- import MagicString2 from "magic-string";
979
- function analyzeCreateHandleArgs(code, startPos, endPos) {
980
- const content = code.slice(startPos, endPos).trim();
981
- return { hasArgs: content.length > 0 };
982
- }
983
- function transformHandles(bindings, s, code, filePath, isBuild) {
1226
+ function transformHandles(bindings, s, filePath, isBuild) {
984
1227
  let hasChanges = false;
985
1228
  for (const binding of bindings) {
986
1229
  const exportName = binding.exportNames[0];
987
- const args = analyzeCreateHandleArgs(
988
- code,
989
- binding.callOpenParenPos + 1,
990
- binding.callCloseParenPos
991
- );
992
- const handleId = isBuild ? hashId(filePath, exportName) : `${filePath}#${exportName}`;
1230
+ const handleId = makeStubId(filePath, exportName, isBuild);
993
1231
  let paramInjection;
994
- if (!args.hasArgs) {
1232
+ if (binding.argCount === 0) {
995
1233
  paramInjection = `undefined, "${handleId}"`;
996
1234
  } else {
997
1235
  paramInjection = `, "${handleId}"`;
@@ -1008,7 +1246,7 @@ function transformLocationState(bindings, s, filePath, isBuild) {
1008
1246
  let hasChanges = false;
1009
1247
  for (const binding of bindings) {
1010
1248
  const exportName = binding.exportNames[0];
1011
- const stateKey = isBuild ? hashId(filePath, exportName) : `${filePath}#${exportName}`;
1249
+ const stateKey = makeStubId(filePath, exportName, isBuild);
1012
1250
  const propInjection = `
1013
1251
  ${binding.localName}.__rsc_ls_key = "__rsc_ls_${stateKey}";`;
1014
1252
  s.appendRight(binding.statementEnd, propInjection);
@@ -1020,7 +1258,7 @@ function generateWholeFileStubs(cfg, bindings, code, filePath, isBuild) {
1020
1258
  if (!isExportOnlyFile(code, bindings)) return null;
1021
1259
  const exportNames = bindings.flatMap((b) => b.exportNames);
1022
1260
  const stubs = exportNames.map((name) => {
1023
- const handlerId = isBuild ? hashId(filePath, name) : `${filePath}#${name}`;
1261
+ const handlerId = makeStubId(filePath, name, isBuild);
1024
1262
  return `export const ${name} = { __brand: "${cfg.brand}", $$id: "${handlerId}" };`;
1025
1263
  });
1026
1264
  return { code: stubs.join("\n") + "\n", map: null };
@@ -1029,7 +1267,7 @@ function stubHandlerExprs(cfg, bindings, s, filePath, isBuild) {
1029
1267
  let hasChanges = false;
1030
1268
  for (const binding of bindings) {
1031
1269
  const exportName = binding.exportNames[0];
1032
- const handlerId = isBuild ? hashId(filePath, exportName) : `${filePath}#${exportName}`;
1270
+ const handlerId = makeStubId(filePath, exportName, isBuild);
1033
1271
  s.overwrite(
1034
1272
  binding.callExprStart,
1035
1273
  binding.callCloseParenPos + 1,
@@ -1043,7 +1281,7 @@ function transformHandlerIds(cfg, bindings, s, filePath, isBuild) {
1043
1281
  let hasChanges = false;
1044
1282
  for (const binding of bindings) {
1045
1283
  const exportName = binding.exportNames[0];
1046
- const handlerId = isBuild ? hashId(filePath, exportName) : `${filePath}#${exportName}`;
1284
+ const handlerId = makeStubId(filePath, exportName, isBuild);
1047
1285
  let paramInjection;
1048
1286
  if (binding.argCount === 0) {
1049
1287
  paramInjection = `undefined, "${handlerId}"`;
@@ -1062,40 +1300,72 @@ ${binding.localName}.$$id = "${handlerId}";`;
1062
1300
  }
1063
1301
 
1064
1302
  // src/vite/plugins/expose-ids/router-transform.ts
1065
- import MagicString3 from "magic-string";
1303
+ import MagicString2 from "magic-string";
1066
1304
  import path3 from "node:path";
1067
1305
  import { createHash } from "node:crypto";
1068
1306
  var debug2 = createRangoDebugger(NS.transform);
1069
- function transformRouter(code, filePath, routerFnNames, absolutePath) {
1307
+ function skipLeadingTrivia(code, start, end) {
1308
+ let i = start;
1309
+ while (i < end) {
1310
+ const skipped = skipStringOrComment(code, i);
1311
+ if (skipped > i) {
1312
+ i = skipped;
1313
+ continue;
1314
+ }
1315
+ if (/\s/.test(code[i])) {
1316
+ i++;
1317
+ continue;
1318
+ }
1319
+ break;
1320
+ }
1321
+ return i;
1322
+ }
1323
+ function transformRouter(code, filePath, routerFnNames, absolutePath, warn) {
1070
1324
  const pat = new RegExp(
1071
- `\\b(?:${routerFnNames.map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})\\s*(?:<[^>]*>)?\\s*\\(`,
1325
+ `\\b(?:${routerFnNames.map(escapeRegExp).join("|")})\\b`,
1072
1326
  "g"
1073
1327
  );
1074
1328
  let match;
1075
- const s = new MagicString3(code);
1329
+ const s = new MagicString2(code);
1076
1330
  let changed = false;
1077
- const basename3 = path3.basename(filePath).replace(/\.(tsx?|jsx?)$/, "");
1078
- const routeNamesImport = `./${basename3}.named-routes.gen.js`;
1331
+ const unsupportedSites = [];
1332
+ const basename2 = path3.basename(filePath).replace(/\.(tsx?|jsx?)$/, "");
1333
+ const routeNamesImport = `./${basename2}.named-routes.gen.js`;
1079
1334
  const routeNamesVar = `__rsc_rn`;
1335
+ const codeOffsets = new Set(codeMatchIndices(code, pat));
1336
+ pat.lastIndex = 0;
1080
1337
  while ((match = pat.exec(code)) !== null) {
1338
+ if (!codeOffsets.has(match.index)) continue;
1081
1339
  const callStart = match.index;
1082
- const parenPos = match.index + match[0].length - 1;
1340
+ const calleeEnd = match.index + match[0].length;
1341
+ const parenPos = findCallParenAfterGenerics(code, calleeEnd);
1342
+ if (parenPos === -1) continue;
1083
1343
  const closeParen = findMatchingParen(code, parenPos + 1);
1084
1344
  const callArgs = code.slice(parenPos + 1, closeParen);
1085
- if (callArgs.includes("$$id")) continue;
1345
+ if (callArgs.includes(`$$routeNames: ${routeNamesVar}`)) continue;
1346
+ const sourceFilePath = absolutePath ?? filePath;
1086
1347
  const lineNumber = code.slice(0, callStart).split("\n").length;
1087
1348
  const hash = createHash("sha256").update(`${filePath}:${lineNumber}`).digest("hex").slice(0, 8);
1088
- changed = true;
1089
- const sourceFilePath = absolutePath ?? filePath;
1090
1349
  const injected = ` $$id: "${hash}", $$sourceFile: "${sourceFilePath}", $$routeNames: ${routeNamesVar},`;
1091
- const afterParen = callArgs.trimStart();
1092
- if (afterParen.startsWith("{")) {
1093
- const bracePos = code.indexOf("{", parenPos + 1);
1094
- s.appendRight(bracePos + 1, injected);
1095
- } else if (afterParen.startsWith(")")) {
1350
+ const argsContentStart = skipLeadingTrivia(code, parenPos + 1, closeParen);
1351
+ const firstArgChar = code[argsContentStart];
1352
+ if (firstArgChar === "{") {
1353
+ changed = true;
1354
+ s.appendRight(argsContentStart + 1, injected);
1355
+ } else if (argsContentStart >= closeParen - 1) {
1356
+ changed = true;
1096
1357
  s.appendRight(parenPos + 1, `{${injected} }`);
1358
+ } else {
1359
+ const lastNl = code.lastIndexOf("\n", callStart - 1);
1360
+ const column = callStart - (lastNl + 1) + 1;
1361
+ unsupportedSites.push({ line: lineNumber, column });
1097
1362
  }
1098
1363
  }
1364
+ if (unsupportedSites.length > 0 && warn) {
1365
+ warn(
1366
+ buildUnsupportedShapeWarning(filePath, "createRouter", unsupportedSites)
1367
+ );
1368
+ }
1099
1369
  if (!changed) return null;
1100
1370
  s.prepend(
1101
1371
  `import { NamedRoutes as ${routeNamesVar} } from "${routeNamesImport}";
@@ -1129,11 +1399,13 @@ function exposeRouterId() {
1129
1399
  try {
1130
1400
  const filePath = normalizePath(path3.relative(projectRoot, id));
1131
1401
  const routerFnNames = getImportedFnNames(code, "createRouter");
1402
+ const warn = typeof this.warn === "function" ? (message) => this.warn(message) : void 0;
1132
1403
  return transformRouter(
1133
1404
  code,
1134
1405
  filePath,
1135
1406
  routerFnNames,
1136
- normalizePath(id)
1407
+ normalizePath(id),
1408
+ warn
1137
1409
  );
1138
1410
  } finally {
1139
1411
  counter?.record(id, performance.now() - start);
@@ -1229,6 +1501,7 @@ ${lazyImports.join(",\n")}
1229
1501
  // --------------- Loader pre-scan (build mode) ---------------
1230
1502
  async buildStart() {
1231
1503
  if (!isBuild) return;
1504
+ if (this.environment && this.environment.name !== "rsc") return;
1232
1505
  const fs2 = await import("node:fs/promises");
1233
1506
  const SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage"]);
1234
1507
  async function scanDir(dir) {
@@ -1335,7 +1608,7 @@ ${lazyImports.join(",\n")}
1335
1608
  }
1336
1609
  if (_cachedAst !== void 0 || _astParseFailed) return _cachedAst;
1337
1610
  try {
1338
- _cachedAst = parseAst2(code, { jsx: true });
1611
+ _cachedAst = parseAst2(code, { lang: "tsx" });
1339
1612
  } catch {
1340
1613
  _astParseFailed = true;
1341
1614
  }
@@ -1358,13 +1631,16 @@ ${lazyImports.join(",\n")}
1358
1631
  const hasCode = cfg.fnName === "createLoader" ? hasLoaderCode : cfg.fnName === "createHandle" ? hasHandleCode : hasLocationStateCode;
1359
1632
  if (!hasCode) continue;
1360
1633
  const fnNames = getFnNames(cfg.fnName);
1361
- const totalCalls = countCreateCallsForNames(code, fnNames);
1362
- const supportedBindings = getBindings(code, fnNames).length;
1363
- if (totalCalls <= supportedBindings) continue;
1634
+ const sites = findUnsupportedCreateCallSites(
1635
+ code,
1636
+ fnNames,
1637
+ getBindings(code, fnNames)
1638
+ );
1639
+ if (sites.length === 0) continue;
1364
1640
  const warnKey = `${id}::${cfg.fnName}`;
1365
1641
  if (unsupportedShapeWarnings.has(warnKey)) continue;
1366
1642
  unsupportedShapeWarnings.add(warnKey);
1367
- this.warn(buildUnsupportedShapeWarning(filePath, cfg.fnName));
1643
+ this.warn(buildUnsupportedShapeWarning(filePath, cfg.fnName, sites));
1368
1644
  }
1369
1645
  if (hasLoaderCode && isRscEnv) {
1370
1646
  const fnNames = getFnNames("createLoader");
@@ -1401,15 +1677,6 @@ ${lazyImports.join(",\n")}
1401
1677
  );
1402
1678
  if (wholeFile) return wholeFile;
1403
1679
  }
1404
- if (hasPrerenderHandlerCode && isRscEnv && isBuild) {
1405
- const fnNames = getFnNames(PRERENDER_CONFIG.fnName);
1406
- const exportNames = getBindings(code, fnNames).map(
1407
- (b) => b.exportNames[0]
1408
- );
1409
- if (exportNames.length > 0) {
1410
- prerenderHandlerModules.set(id, exportNames);
1411
- }
1412
- }
1413
1680
  let changed = false;
1414
1681
  const handlerConfigs = [
1415
1682
  hasStaticHandlerCode && STATIC_CONFIG,
@@ -1422,7 +1689,7 @@ ${lazyImports.join(",\n")}
1422
1689
  const totalCalls = countCreateCallsForNames(code, fnNames);
1423
1690
  const supportedBindings = getBindings(code, fnNames).length;
1424
1691
  if (totalCalls > supportedBindings) {
1425
- const iterS = new MagicString4(code);
1692
+ const iterS = new MagicString3(code);
1426
1693
  const result = transformInlineHandlers(
1427
1694
  cfg.fnName,
1428
1695
  VIRTUAL_HANDLER_PREFIX,
@@ -1587,16 +1854,24 @@ ${lazyImports.join(",\n")}
1587
1854
  return { code: lines.join("\n") + "\n", map: null };
1588
1855
  }
1589
1856
  }
1590
- if (hasStaticHandlerCode && isRscEnv && isBuild) {
1591
- const fnNames = getFnNames(STATIC_CONFIG.fnName);
1592
- const exportNames = getBindings(code, fnNames).map(
1593
- (b) => b.exportNames[0]
1594
- );
1595
- if (exportNames.length > 0) {
1596
- staticHandlerModules.set(id, exportNames);
1857
+ if (isRscEnv && isBuild) {
1858
+ const trackTypes = [
1859
+ [
1860
+ hasPrerenderHandlerCode,
1861
+ PRERENDER_CONFIG,
1862
+ prerenderHandlerModules
1863
+ ],
1864
+ [hasStaticHandlerCode, STATIC_CONFIG, staticHandlerModules]
1865
+ ];
1866
+ for (const [has2, cfg, trackMap] of trackTypes) {
1867
+ if (!has2) continue;
1868
+ const exportNames = getBindings(code, getFnNames(cfg.fnName)).map(
1869
+ (b) => b.exportNames[0]
1870
+ );
1871
+ if (exportNames.length > 0) trackMap.set(id, exportNames);
1597
1872
  }
1598
1873
  }
1599
- const s = new MagicString4(code);
1874
+ const s = new MagicString3(code);
1600
1875
  if (hasLoaderCode) {
1601
1876
  const fnNames = getFnNames("createLoader");
1602
1877
  changed = transformLoaders(
@@ -1611,7 +1886,6 @@ ${lazyImports.join(",\n")}
1611
1886
  changed = transformHandles(
1612
1887
  getBindings(code, fnNames),
1613
1888
  s,
1614
- code,
1615
1889
  filePath,
1616
1890
  isBuild
1617
1891
  ) || changed;
@@ -1625,41 +1899,13 @@ ${lazyImports.join(",\n")}
1625
1899
  isBuild
1626
1900
  ) || changed;
1627
1901
  }
1628
- if (hasPrerenderHandlerCode) {
1629
- const fnNames = getFnNames(PRERENDER_CONFIG.fnName);
1630
- const bindings = getBindings(code, fnNames);
1631
- if (isRscEnv) {
1632
- changed = transformHandlerIds(
1633
- PRERENDER_CONFIG,
1634
- bindings,
1635
- s,
1636
- filePath,
1637
- isBuild
1638
- ) || changed;
1639
- } else {
1640
- changed = stubHandlerExprs(
1641
- PRERENDER_CONFIG,
1642
- bindings,
1643
- s,
1644
- filePath,
1645
- isBuild
1646
- ) || changed;
1647
- }
1648
- }
1649
- if (hasStaticHandlerCode) {
1650
- const fnNames = getFnNames(STATIC_CONFIG.fnName);
1651
- const bindings = getBindings(code, fnNames);
1652
- if (isRscEnv) {
1653
- changed = transformHandlerIds(
1654
- STATIC_CONFIG,
1655
- bindings,
1656
- s,
1657
- filePath,
1658
- isBuild
1659
- ) || changed;
1660
- } else {
1661
- changed = stubHandlerExprs(STATIC_CONFIG, bindings, s, filePath, isBuild) || changed;
1662
- }
1902
+ const finalHandlerConfigs = [
1903
+ hasPrerenderHandlerCode && PRERENDER_CONFIG,
1904
+ hasStaticHandlerCode && STATIC_CONFIG
1905
+ ].filter((c) => !!c);
1906
+ for (const cfg of finalHandlerConfigs) {
1907
+ const bindings = getBindings(code, getFnNames(cfg.fnName));
1908
+ changed = (isRscEnv ? transformHandlerIds(cfg, bindings, s, filePath, isBuild) : stubHandlerExprs(cfg, bindings, s, filePath, isBuild)) || changed;
1663
1909
  }
1664
1910
  if (!changed) return;
1665
1911
  return {
@@ -1675,10 +1921,11 @@ ${lazyImports.join(",\n")}
1675
1921
 
1676
1922
  // src/vite/plugins/use-cache-transform.ts
1677
1923
  import path5 from "node:path";
1678
- import MagicString5 from "magic-string";
1924
+ import MagicString4 from "magic-string";
1679
1925
  var debug4 = createRangoDebugger(NS.transform);
1680
1926
  var CACHE_RUNTIME_IMPORT = "@rangojs/router/cache-runtime";
1681
1927
  var LAYOUT_TEMPLATE_PATTERN = /\/(layout|template)\.(tsx?|jsx?)$/;
1928
+ var USE_CACHE_DIRECTIVE_RE = /^use cache(:\s*[\w-]+)?$/;
1682
1929
  function useCacheTransform() {
1683
1930
  let projectRoot = "";
1684
1931
  let isBuild = false;
@@ -1715,8 +1962,8 @@ function useCacheTransform() {
1715
1962
  } = rscTransforms;
1716
1963
  let ast;
1717
1964
  try {
1718
- const { parseAst: parseAst4 } = await import("vite");
1719
- ast = parseAst4(code);
1965
+ const { parseAst: parseAst5 } = await import("vite");
1966
+ ast = parseAst5(code, { lang: "tsx" });
1720
1967
  } catch {
1721
1968
  return;
1722
1969
  }
@@ -1750,7 +1997,7 @@ function useCacheTransform() {
1750
1997
  };
1751
1998
  }
1752
1999
  function transformFileLevelUseCache(code, ast, filePath, sourceId, isBuild, isLayoutOrTemplate, transformWrapExport) {
1753
- const nonFunctionExports = [];
2000
+ const unconfirmedExports = [];
1754
2001
  const { exportNames, output } = transformWrapExport(code, ast, {
1755
2002
  runtime: (value, name) => {
1756
2003
  const funcId = isBuild ? hashId(filePath, name) : `${filePath}#${name}`;
@@ -1759,20 +2006,21 @@ function transformFileLevelUseCache(code, ast, filePath, sourceId, isBuild, isLa
1759
2006
  rejectNonAsyncFunction: false,
1760
2007
  filter: (name, meta) => {
1761
2008
  if (name === "default" && isLayoutOrTemplate) return false;
1762
- if (meta.isFunction === false) {
1763
- nonFunctionExports.push(name);
2009
+ if (meta.isFunction !== true) {
2010
+ unconfirmedExports.push(name);
1764
2011
  return false;
1765
2012
  }
1766
2013
  return true;
1767
2014
  }
1768
2015
  });
1769
- if (nonFunctionExports.length > 0) {
2016
+ if (unconfirmedExports.length > 0) {
2017
+ const plural = unconfirmedExports.length > 1;
1770
2018
  throw new Error(
1771
- `[rango:use-cache] File-level "use cache" in ${sourceId} cannot wrap non-function export${nonFunctionExports.length > 1 ? "s" : ""}: ${nonFunctionExports.map((n) => `"${n}"`).join(", ")}. Only function exports can be cached. Either remove "use cache" from the file level and add it inside individual functions, or move the non-function exports to a separate module.`
2019
+ `[rango:use-cache] File-level "use cache" in ${sourceId} only wraps exports that are statically-confirmed functions. ${plural ? "These exports are" : "This export is"} not: ${unconfirmedExports.map((n) => `"${n}"`).join(", ")}. Declare them directly (export async function foo() {} or export const foo = async () => {}). A factory or otherwise statically-indeterminate initializer (export const foo = makeCached(fn)) is rejected even if it returns a function at runtime -- rewrite it as a direct async function, or move non-function exports to a separate module.`
1772
2020
  );
1773
2021
  }
1774
2022
  if (exportNames.length === 0) {
1775
- const s = new MagicString5(code);
2023
+ const s = new MagicString4(code);
1776
2024
  const directive2 = findFileLevelDirective(ast);
1777
2025
  if (directive2) {
1778
2026
  s.overwrite(
@@ -1807,7 +2055,7 @@ function transformFileLevelUseCache(code, ast, filePath, sourceId, isBuild, isLa
1807
2055
  function transformFunctionLevelUseCache(code, ast, filePath, sourceId, isBuild, transformHoistInlineDirective) {
1808
2056
  try {
1809
2057
  const { output, names } = transformHoistInlineDirective(code, ast, {
1810
- directive: /^use cache(:\s*[\w-]+)?$/,
2058
+ directive: USE_CACHE_DIRECTIVE_RE,
1811
2059
  runtime: (value, name, meta) => {
1812
2060
  const funcId = isBuild ? hashId(filePath, name) : `${filePath}#${name}`;
1813
2061
  const profileMatch = meta.directiveMatch[1];
@@ -1837,14 +2085,13 @@ function findFileLevelDirective(ast) {
1837
2085
  }
1838
2086
  return null;
1839
2087
  }
1840
- var VALID_DIRECTIVE_RE = /^use cache(:\s*[\w-]+)?$/;
1841
2088
  var NEAR_MISS_RE = /^use cache:\s*.+$/;
1842
2089
  function warnOnNearMissDirectives(ast, fileId, warn) {
1843
2090
  const visit = (node) => {
1844
2091
  if (!node || typeof node !== "object") return;
1845
2092
  if (node.type === "ExpressionStatement" && node.expression?.type === "Literal" && typeof node.expression.value === "string") {
1846
2093
  const value = node.expression.value;
1847
- if (value.startsWith("use cache") && NEAR_MISS_RE.test(value) && !VALID_DIRECTIVE_RE.test(value)) {
2094
+ if (value.startsWith("use cache") && NEAR_MISS_RE.test(value) && !USE_CACHE_DIRECTIVE_RE.test(value)) {
1848
2095
  const profilePart = value.slice("use cache:".length).trim();
1849
2096
  warn(
1850
2097
  `[rango:use-cache] "${value}" in ${fileId} has an invalid profile name "${profilePart}". Profile names must match [a-zA-Z0-9_-]+. This directive will be ignored.`
@@ -1907,7 +2154,6 @@ function clientRefDedup() {
1907
2154
  if (this.environment?.name !== "client") return;
1908
2155
  if (!importer?.includes(CLIENT_IN_SERVER_PROXY_PREFIX)) return;
1909
2156
  if (!source.includes("/node_modules/")) return;
1910
- if (!importer) return;
1911
2157
  const packageName = extractPackageName(source);
1912
2158
  if (!packageName) return;
1913
2159
  if (clientExclude.includes(packageName)) return;
@@ -1938,7 +2184,7 @@ import {
1938
2184
  import { createElement, StrictMode } from "react";
1939
2185
  import { hydrateRoot } from "react-dom/client";
1940
2186
  import { rscStream } from "@rangojs/router/internal/deps/html-stream-client";
1941
- import { initBrowserApp, RSCRouter } from "@rangojs/router/browser";
2187
+ import { initBrowserApp, Rango } from "@rangojs/router/browser";
1942
2188
 
1943
2189
  async function initializeApp() {
1944
2190
  const deps = {
@@ -1949,11 +2195,16 @@ async function initializeApp() {
1949
2195
  createTemporaryReferenceSet,
1950
2196
  };
1951
2197
 
1952
- await initBrowserApp({ rscStream, deps });
2198
+ // initBrowserApp resolves the initial payload and returns the browser app
2199
+ // context, including strictMode (default true) from createRouter. StrictMode
2200
+ // is the default; createRouter({ strictMode: false }) ships the opt-out in the
2201
+ // payload metadata. StrictMode emits no DOM, so toggling never changes markup.
2202
+ const { strictMode } = await initBrowserApp({ rscStream, deps });
1953
2203
 
2204
+ const app = createElement(Rango);
1954
2205
  hydrateRoot(
1955
2206
  document,
1956
- createElement(StrictMode, null, createElement(RSCRouter))
2207
+ strictMode === false ? app : createElement(StrictMode, null, app)
1957
2208
  );
1958
2209
  }
1959
2210
 
@@ -2006,6 +2257,11 @@ export default function handler(request, env) {
2006
2257
  _handler = createRSCHandler({
2007
2258
  router,
2008
2259
  version: VERSION,
2260
+ // Forward the router's CSP nonce provider. createRSCHandler reads the
2261
+ // provider only from options.nonce; without this, createRouter({ nonce })
2262
+ // is silently dropped on the Node preset (the Cloudflare path wires it via
2263
+ // router.fetch). router.nonce is undefined when unconfigured, a safe no-op.
2264
+ nonce: router.nonce,
2009
2265
  deps: {
2010
2266
  renderToReadableStream,
2011
2267
  decodeReply,
@@ -2040,7 +2296,7 @@ import { resolve } from "node:path";
2040
2296
  // package.json
2041
2297
  var package_default = {
2042
2298
  name: "@rangojs/router",
2043
- version: "0.0.0-experimental.d20dd405",
2299
+ version: "0.0.0-experimental.d5d3070a",
2044
2300
  description: "Django-inspired RSC router with composable URL patterns",
2045
2301
  keywords: [
2046
2302
  "react",
@@ -2150,6 +2406,11 @@ var package_default = {
2150
2406
  "react-server": "./src/cache/cache-runtime.ts",
2151
2407
  default: "./src/cache/cache-runtime.ts"
2152
2408
  },
2409
+ "./cloudflare": {
2410
+ types: "./src/cloudflare/index.ts",
2411
+ "react-server": "./src/cloudflare/index.ts",
2412
+ default: "./src/cloudflare/index.ts"
2413
+ },
2153
2414
  "./theme": {
2154
2415
  types: "./src/theme/index.ts",
2155
2416
  default: "./src/theme/index.ts"
@@ -2166,6 +2427,31 @@ var package_default = {
2166
2427
  "./host/testing": {
2167
2428
  types: "./src/host/testing.ts",
2168
2429
  default: "./src/host/testing.ts"
2430
+ },
2431
+ "./testing": {
2432
+ types: "./src/testing/index.ts",
2433
+ default: "./src/testing/index.ts"
2434
+ },
2435
+ "./testing/vitest": {
2436
+ types: "./src/testing/vitest.ts",
2437
+ default: "./dist/testing/vitest.js"
2438
+ },
2439
+ "./testing/dom": {
2440
+ types: "./src/testing/dom.entry.ts",
2441
+ default: "./src/testing/dom.entry.ts"
2442
+ },
2443
+ "./testing/e2e": {
2444
+ types: "./src/testing/e2e/index.ts",
2445
+ default: "./src/testing/e2e/index.ts"
2446
+ },
2447
+ "./testing/flight": {
2448
+ types: "./src/testing/flight.entry.ts",
2449
+ "react-server": "./src/testing/flight.entry.ts",
2450
+ default: "./src/testing/flight.entry.ts"
2451
+ },
2452
+ "./testing/flight-matchers": {
2453
+ types: "./src/testing/flight-matchers.ts",
2454
+ default: "./src/testing/flight-matchers.ts"
2169
2455
  }
2170
2456
  },
2171
2457
  publishConfig: {
@@ -2173,48 +2459,70 @@ var package_default = {
2173
2459
  tag: "experimental"
2174
2460
  },
2175
2461
  scripts: {
2176
- build: "pnpm dlx esbuild src/vite/index.ts --bundle --format=esm --outfile=dist/vite/index.js --platform=node --packages=external && mkdir -p dist/vite/plugins && cp src/vite/plugins/cloudflare-protocol-loader-hook.mjs dist/vite/plugins/cloudflare-protocol-loader-hook.mjs && pnpm dlx esbuild src/bin/rango.ts --bundle --format=esm --outfile=dist/bin/rango.js --platform=node --packages=external --banner:js='#!/usr/bin/env node' && chmod +x dist/bin/rango.js",
2462
+ build: "pnpm exec esbuild src/vite/index.ts --bundle --format=esm --outfile=dist/vite/index.js --platform=node --packages=external && mkdir -p dist/vite/plugins && cp src/vite/plugins/cloudflare-protocol-loader-hook.mjs dist/vite/plugins/cloudflare-protocol-loader-hook.mjs && pnpm exec esbuild src/testing/vitest.ts --bundle --format=esm --outfile=dist/testing/vitest.js --platform=node --packages=external && pnpm exec esbuild src/bin/rango.ts --bundle --format=esm --outfile=dist/bin/rango.js --platform=node --packages=external --banner:js='#!/usr/bin/env node' && chmod +x dist/bin/rango.js",
2177
2463
  prepublishOnly: "pnpm build",
2178
- typecheck: "tsc --noEmit && tsc -p tsconfig.strict-check.json --noEmit",
2464
+ typecheck: "tsc --noEmit && tsc -p tsconfig.strict-check.json --noEmit && tsc -p tsconfig.augment-check.json --noEmit",
2179
2465
  test: "playwright test",
2180
2466
  "test:ui": "playwright test --ui",
2467
+ "test:hmr-local": "playwright test --project=dev-warmup --project=hmr-routes --project=hmr-basename --project=hmr-prerender --no-deps --workers=1",
2181
2468
  "test:unit": "vitest run",
2182
- "test:unit:watch": "vitest"
2469
+ "test:unit:watch": "vitest",
2470
+ "test:unit:rsc": "vitest run --config vitest.rsc.config.ts"
2183
2471
  },
2184
2472
  dependencies: {
2185
2473
  "@types/debug": "^4.1.12",
2186
- "@vitejs/plugin-rsc": "^0.5.23",
2474
+ "@vitejs/plugin-rsc": "^0.5.26",
2187
2475
  debug: "^4.4.1",
2188
2476
  "magic-string": "^0.30.17",
2189
- picomatch: "^4.0.3",
2190
- "rsc-html-stream": "^0.0.7"
2477
+ picomatch: "^4.0.4",
2478
+ "rsc-html-stream": "^0.0.7",
2479
+ tinyexec: "^0.3.2"
2191
2480
  },
2192
2481
  devDependencies: {
2193
2482
  "@playwright/test": "^1.49.1",
2483
+ "@shared/e2e": "workspace:*",
2484
+ "@testing-library/dom": "^10.4.1",
2485
+ "@testing-library/react": "^16.3.2",
2194
2486
  "@types/node": "^24.10.1",
2195
2487
  "@types/react": "catalog:",
2196
2488
  "@types/react-dom": "catalog:",
2197
2489
  esbuild: "^0.27.0",
2490
+ "happy-dom": "^20.10.1",
2198
2491
  jiti: "^2.6.1",
2199
2492
  react: "catalog:",
2200
2493
  "react-dom": "catalog:",
2201
- tinyexec: "^0.3.2",
2202
2494
  typescript: "^5.3.0",
2203
2495
  vitest: "^4.0.0"
2204
2496
  },
2205
2497
  peerDependencies: {
2206
- "@cloudflare/vite-plugin": "^1.25.0",
2207
- "@vitejs/plugin-rsc": "^0.5.23",
2208
- react: "^18.0.0 || ^19.0.0",
2209
- vite: "^7.3.0"
2498
+ "@cloudflare/vite-plugin": "^1.38.0",
2499
+ "@playwright/test": "^1.49.1",
2500
+ "@testing-library/react": ">=16",
2501
+ "@vitejs/plugin-rsc": "^0.5.26",
2502
+ react: ">=19.2.6 <20",
2503
+ "react-dom": ">=19.2.6 <20",
2504
+ vite: "^8.0.0",
2505
+ vitest: ">=3"
2210
2506
  },
2211
2507
  peerDependenciesMeta: {
2212
2508
  "@cloudflare/vite-plugin": {
2213
2509
  optional: true
2214
2510
  },
2511
+ "@playwright/test": {
2512
+ optional: true
2513
+ },
2514
+ "@testing-library/react": {
2515
+ optional: true
2516
+ },
2215
2517
  vite: {
2216
2518
  optional: true
2519
+ },
2520
+ vitest: {
2521
+ optional: true
2217
2522
  }
2523
+ },
2524
+ engines: {
2525
+ node: "^20.19.0 || >=22.12.0"
2218
2526
  }
2219
2527
  };
2220
2528
 
@@ -2288,10 +2596,10 @@ function extractParamsFromPattern(pattern) {
2288
2596
  function formatRouteEntry(key, pattern, _params, search) {
2289
2597
  const hasSearch = search && Object.keys(search).length > 0;
2290
2598
  if (!hasSearch) {
2291
- return ` ${key}: "${pattern}",`;
2599
+ return ` ${key}: ${JSON.stringify(pattern)},`;
2292
2600
  }
2293
- const searchBody = Object.entries(search).map(([k, v]) => `${k}: "${v}"`).join(", ");
2294
- return ` ${key}: { path: "${pattern}", search: { ${searchBody} } },`;
2601
+ const searchBody = Object.entries(search).map(([k, v]) => `${k}: ${JSON.stringify(v)}`).join(", ");
2602
+ return ` ${key}: { path: ${JSON.stringify(pattern)}, search: { ${searchBody} } },`;
2295
2603
  }
2296
2604
 
2297
2605
  // src/build/route-types/ast-route-extraction.ts
@@ -2317,8 +2625,8 @@ function extractObjectStringProperties(node) {
2317
2625
  }
2318
2626
 
2319
2627
  // src/build/route-types/ast-route-extraction.ts
2320
- function extractRoutesFromSource(code) {
2321
- const sourceFile = ts2.createSourceFile(
2628
+ function extractRoutesFromSource(code, sourceFileArg) {
2629
+ const sourceFile = sourceFileArg ?? ts2.createSourceFile(
2322
2630
  "input.tsx",
2323
2631
  code,
2324
2632
  ts2.ScriptTarget.Latest,
@@ -2398,16 +2706,44 @@ export const NamedRoutes = {
2398
2706
  ${objectBody}
2399
2707
  } as const;
2400
2708
 
2709
+ // Aliased so the augmentation below does not pay a homomorphic mapped-type
2710
+ // instantiation per route; \`as const\` already makes the members readonly.
2711
+ type NamedRoutesShape = typeof NamedRoutes;
2712
+
2401
2713
  declare global {
2402
- namespace RSCRouter {
2403
- interface GeneratedRouteMap extends Readonly<typeof NamedRoutes> {}
2714
+ namespace Rango {
2715
+ interface GeneratedRouteMap extends NamedRoutesShape {}
2404
2716
  }
2405
2717
  }
2406
2718
  `;
2407
2719
  }
2408
2720
 
2409
2721
  // src/build/route-types/scan-filter.ts
2722
+ import { join, relative } from "node:path";
2410
2723
  import picomatch from "picomatch";
2724
+ var DEFAULT_EXCLUDE_PATTERNS = [
2725
+ "**/__tests__/**",
2726
+ "**/__mocks__/**",
2727
+ "**/dist/**",
2728
+ "**/coverage/**",
2729
+ "**/*.test.{ts,tsx,js,jsx}",
2730
+ "**/*.spec.{ts,tsx,js,jsx}"
2731
+ ];
2732
+ function createScanFilter(root, opts) {
2733
+ const { include, exclude } = opts;
2734
+ const hasInclude = include && include.length > 0;
2735
+ const hasCustomExclude = exclude !== void 0;
2736
+ if (!hasInclude && !hasCustomExclude) return void 0;
2737
+ const effectiveExclude = exclude ?? DEFAULT_EXCLUDE_PATTERNS;
2738
+ const includeMatcher = hasInclude ? picomatch(include) : null;
2739
+ const excludeMatcher = effectiveExclude.length > 0 ? picomatch(effectiveExclude) : null;
2740
+ return (absolutePath) => {
2741
+ const rel = relative(root, absolutePath);
2742
+ if (excludeMatcher && excludeMatcher(rel)) return false;
2743
+ if (includeMatcher) return includeMatcher(rel);
2744
+ return true;
2745
+ };
2746
+ }
2411
2747
 
2412
2748
  // src/build/route-types/per-module-writer.ts
2413
2749
  import ts4 from "typescript";
@@ -2416,6 +2752,33 @@ import ts4 from "typescript";
2416
2752
  import { readFileSync, existsSync as existsSync2 } from "node:fs";
2417
2753
  import { dirname, resolve as resolve2 } from "node:path";
2418
2754
  import ts3 from "typescript";
2755
+ function createScanMemo() {
2756
+ return { files: /* @__PURE__ */ new Map(), blockSourceFiles: /* @__PURE__ */ new Map() };
2757
+ }
2758
+ function parseBlock(memo, block) {
2759
+ if (memo) {
2760
+ const cached = memo.blockSourceFiles.get(block);
2761
+ if (cached) return cached;
2762
+ }
2763
+ const sf = ts3.createSourceFile(
2764
+ "input.tsx",
2765
+ block,
2766
+ ts3.ScriptTarget.Latest,
2767
+ true,
2768
+ ts3.ScriptKind.TSX
2769
+ );
2770
+ if (memo) memo.blockSourceFiles.set(block, sf);
2771
+ return sf;
2772
+ }
2773
+ function readSourceMemoized(memo, realPath) {
2774
+ if (memo) {
2775
+ const cached = memo.files.get(realPath);
2776
+ if (cached !== void 0) return cached;
2777
+ }
2778
+ const source = readFileSync(realPath, "utf-8");
2779
+ if (memo) memo.files.set(realPath, source);
2780
+ return source;
2781
+ }
2419
2782
  function extractNamePrefixFromInclude(node) {
2420
2783
  if (node.arguments.length >= 3) {
2421
2784
  const thirdArg = node.arguments[2];
@@ -2431,8 +2794,8 @@ function extractNamePrefixFromInclude(node) {
2431
2794
  }
2432
2795
  return null;
2433
2796
  }
2434
- function extractIncludesWithDiagnostics(code) {
2435
- const sourceFile = ts3.createSourceFile(
2797
+ function extractIncludesWithDiagnostics(code, sourceFileArg) {
2798
+ const sourceFile = sourceFileArg ?? ts3.createSourceFile(
2436
2799
  "input.tsx",
2437
2800
  code,
2438
2801
  ts3.ScriptTarget.Latest,
@@ -2486,7 +2849,7 @@ function extractIncludesWithDiagnostics(code) {
2486
2849
  return { resolved, unresolvable };
2487
2850
  }
2488
2851
  function resolveImportedVariable(code, localName) {
2489
- const importRegex = /import\s*\{([^}]+)\}\s*from\s*["']([^"']+)["']/g;
2852
+ const importRegex = /import\s*(?:[\w$]+\s*,\s*)?\{([^}]+)\}\s*from\s*["']([^"']+)["']/g;
2490
2853
  let match;
2491
2854
  while ((match = importRegex.exec(code)) !== null) {
2492
2855
  const imports = match[1];
@@ -2523,8 +2886,8 @@ function resolveImportPath(importSpec, fromFile) {
2523
2886
  }
2524
2887
  return null;
2525
2888
  }
2526
- function extractUrlsBlockForVariable(code, varName) {
2527
- const sourceFile = ts3.createSourceFile(
2889
+ function extractUrlsBlockForVariable(code, varName, sourceFileArg) {
2890
+ const sourceFile = sourceFileArg ?? ts3.createSourceFile(
2528
2891
  "input.tsx",
2529
2892
  code,
2530
2893
  ts3.ScriptTarget.Latest,
@@ -2546,16 +2909,20 @@ function extractUrlsBlockForVariable(code, varName) {
2546
2909
  visit(sourceFile);
2547
2910
  return result;
2548
2911
  }
2549
- function buildRouteMapFromBlock(block, fullSource, filePath, visited, searchSchemasOut, diagnosticsOut) {
2912
+ function buildRouteMapFromBlock(block, fullSource, filePath, visited, searchSchemasOut, diagnosticsOut, memo) {
2550
2913
  const routeMap = {};
2551
- const localRoutes = extractRoutesFromSource(block);
2914
+ const blockSourceFile = parseBlock(memo, block);
2915
+ const localRoutes = extractRoutesFromSource(block, blockSourceFile);
2552
2916
  for (const { name, pattern, search } of localRoutes) {
2553
2917
  routeMap[name] = pattern;
2554
2918
  if (search && searchSchemasOut) {
2555
2919
  searchSchemasOut[name] = search;
2556
2920
  }
2557
2921
  }
2558
- const { resolved: includes, unresolvable } = extractIncludesWithDiagnostics(block);
2922
+ const { resolved: includes, unresolvable } = extractIncludesWithDiagnostics(
2923
+ block,
2924
+ blockSourceFile
2925
+ );
2559
2926
  if (diagnosticsOut) {
2560
2927
  for (const entry of unresolvable) {
2561
2928
  diagnosticsOut.push({ ...entry, sourceFile: filePath });
@@ -2582,12 +2949,15 @@ function buildRouteMapFromBlock(block, fullSource, filePath, visited, searchSche
2582
2949
  targetFile,
2583
2950
  imported.exportedName,
2584
2951
  visited,
2585
- diagnosticsOut
2952
+ diagnosticsOut,
2953
+ void 0,
2954
+ memo
2586
2955
  );
2587
2956
  } else {
2588
2957
  const sameFileBlock = extractUrlsBlockForVariable(
2589
2958
  fullSource,
2590
- variableName
2959
+ variableName,
2960
+ parseBlock(memo, fullSource)
2591
2961
  );
2592
2962
  if (!sameFileBlock) {
2593
2963
  if (diagnosticsOut) {
@@ -2605,7 +2975,9 @@ function buildRouteMapFromBlock(block, fullSource, filePath, visited, searchSche
2605
2975
  filePath,
2606
2976
  variableName,
2607
2977
  visited,
2608
- diagnosticsOut
2978
+ diagnosticsOut,
2979
+ void 0,
2980
+ memo
2609
2981
  );
2610
2982
  }
2611
2983
  if (namePrefix === null) {
@@ -2629,18 +3001,19 @@ function buildRouteMapFromBlock(block, fullSource, filePath, visited, searchSche
2629
3001
  }
2630
3002
  return routeMap;
2631
3003
  }
2632
- function buildCombinedRouteMapWithSearch(filePath, variableName, visited, diagnosticsOut, inlineBlock) {
3004
+ function buildCombinedRouteMapWithSearch(filePath, variableName, visited, diagnosticsOut, inlineBlock, memo) {
2633
3005
  visited = visited ?? /* @__PURE__ */ new Set();
3006
+ memo = memo ?? createScanMemo();
2634
3007
  const realPath = resolve2(filePath);
2635
3008
  const key = variableName ? `${realPath}:${variableName}` : realPath;
2636
3009
  if (visited.has(key)) {
2637
- console.warn(`[rsc-router] Circular include detected, skipping: ${key}`);
3010
+ console.warn(`[rango] Circular include detected, skipping: ${key}`);
2638
3011
  return { routes: {}, searchSchemas: {} };
2639
3012
  }
2640
3013
  visited.add(key);
2641
3014
  let source;
2642
3015
  try {
2643
- source = readFileSync(realPath, "utf-8");
3016
+ source = readSourceMemoized(memo, realPath);
2644
3017
  } catch {
2645
3018
  return { routes: {}, searchSchemas: {} };
2646
3019
  }
@@ -2648,7 +3021,11 @@ function buildCombinedRouteMapWithSearch(filePath, variableName, visited, diagno
2648
3021
  if (inlineBlock) {
2649
3022
  block = inlineBlock;
2650
3023
  } else if (variableName) {
2651
- const extracted = extractUrlsBlockForVariable(source, variableName);
3024
+ const extracted = extractUrlsBlockForVariable(
3025
+ source,
3026
+ variableName,
3027
+ parseBlock(memo, source)
3028
+ );
2652
3029
  if (!extracted) return { routes: {}, searchSchemas: {} };
2653
3030
  block = extracted;
2654
3031
  } else {
@@ -2661,7 +3038,8 @@ function buildCombinedRouteMapWithSearch(filePath, variableName, visited, diagno
2661
3038
  realPath,
2662
3039
  visited,
2663
3040
  searchSchemas,
2664
- diagnosticsOut
3041
+ diagnosticsOut,
3042
+ memo
2665
3043
  );
2666
3044
  visited.delete(key);
2667
3045
  return { routes, searchSchemas };
@@ -2676,7 +3054,7 @@ import {
2676
3054
  readdirSync
2677
3055
  } from "node:fs";
2678
3056
  import {
2679
- join,
3057
+ join as join2,
2680
3058
  dirname as dirname2,
2681
3059
  resolve as resolve3,
2682
3060
  sep,
@@ -2695,6 +3073,7 @@ function countPublicRouteEntries(source) {
2695
3073
  return count;
2696
3074
  }
2697
3075
  var ROUTER_CALL_PATTERN = /\bcreateRouter\s*[<(]/;
3076
+ var ROUTER_CALL_PATTERN_G = /\bcreateRouter\s*[<(]/g;
2698
3077
  function isRoutableSourceFile(name) {
2699
3078
  return (name.endsWith(".ts") || name.endsWith(".tsx") || name.endsWith(".js") || name.endsWith(".jsx")) && !name.includes(".gen.") && !name.includes(".test.") && !name.includes(".spec.");
2700
3079
  }
@@ -2704,14 +3083,14 @@ function findRouterFilesRecursive(dir, filter, results) {
2704
3083
  entries = readdirSync(dir, { withFileTypes: true });
2705
3084
  } catch (err) {
2706
3085
  console.warn(
2707
- `[rsc-router] Failed to scan directory ${dir}: ${err.message}`
3086
+ `[rango] Failed to scan directory ${dir}: ${err.message}`
2708
3087
  );
2709
3088
  return;
2710
3089
  }
2711
3090
  const childDirs = [];
2712
3091
  const routerFilesInDir = [];
2713
3092
  for (const entry of entries) {
2714
- const fullPath = join(dir, entry.name);
3093
+ const fullPath = join2(dir, entry.name);
2715
3094
  if (entry.isDirectory()) {
2716
3095
  if (entry.name === "node_modules" || entry.name === "dist" || entry.name === "coverage" || entry.name === "__tests__" || entry.name === "__mocks__" || entry.name.startsWith("."))
2717
3096
  continue;
@@ -2722,7 +3101,7 @@ function findRouterFilesRecursive(dir, filter, results) {
2722
3101
  if (filter && !filter(fullPath)) continue;
2723
3102
  try {
2724
3103
  const source = readFileSync2(fullPath, "utf-8");
2725
- if (ROUTER_CALL_PATTERN.test(source)) {
3104
+ if (ROUTER_CALL_PATTERN.test(source) && firstCodeMatchIndex(source, ROUTER_CALL_PATTERN_G) >= 0) {
2726
3105
  routerFilesInDir.push(fullPath);
2727
3106
  }
2728
3107
  } catch {
@@ -2760,7 +3139,7 @@ function findNestedRouterConflict(routerFiles) {
2760
3139
  }
2761
3140
  return null;
2762
3141
  }
2763
- function formatNestedRouterConflictError(conflict, prefix = "[rsc-router]") {
3142
+ function formatNestedRouterConflictError(conflict, prefix = "[rango]") {
2764
3143
  return `${prefix} Nested router roots are not supported.
2765
3144
  Router root: ${conflict.ancestor}
2766
3145
  Nested router: ${conflict.nested}
@@ -2856,19 +3235,38 @@ function extractBasenameFromRouter(code) {
2856
3235
  visit(sourceFile);
2857
3236
  return result;
2858
3237
  }
2859
- function applyBasenameToRoutes(result, basename3) {
3238
+ function applyBasenameToRoutes(result, basename2) {
2860
3239
  const prefixed = {};
2861
3240
  for (const [name, pattern] of Object.entries(result.routes)) {
2862
3241
  if (pattern === "/") {
2863
- prefixed[name] = basename3;
2864
- } else if (basename3.endsWith("/") && pattern.startsWith("/")) {
2865
- prefixed[name] = basename3 + pattern.slice(1);
3242
+ prefixed[name] = basename2;
3243
+ } else if (basename2.endsWith("/") && pattern.startsWith("/")) {
3244
+ prefixed[name] = basename2 + pattern.slice(1);
2866
3245
  } else {
2867
- prefixed[name] = basename3 + pattern;
3246
+ prefixed[name] = basename2 + pattern;
2868
3247
  }
2869
3248
  }
2870
3249
  return { routes: prefixed, searchSchemas: result.searchSchemas };
2871
3250
  }
3251
+ function genFileTsPath(sourceFile) {
3252
+ const base = pathBasename(sourceFile).replace(/\.(tsx?|jsx?)$/, "");
3253
+ return join2(dirname2(sourceFile), `${base}.named-routes.gen.ts`);
3254
+ }
3255
+ function resolveSearchSchemas(publicRouteNames, runtimeSchemas, sourceFile) {
3256
+ if (runtimeSchemas && Object.keys(runtimeSchemas).length > 0) {
3257
+ return runtimeSchemas;
3258
+ }
3259
+ const staticParsed = buildCombinedRouteMapForRouterFile(sourceFile);
3260
+ if (Object.keys(staticParsed.searchSchemas).length === 0) {
3261
+ return runtimeSchemas;
3262
+ }
3263
+ const filtered = {};
3264
+ for (const name of publicRouteNames) {
3265
+ const schema = staticParsed.searchSchemas[name];
3266
+ if (schema) filtered[name] = schema;
3267
+ }
3268
+ return Object.keys(filtered).length > 0 ? filtered : runtimeSchemas;
3269
+ }
2872
3270
  function buildCombinedRouteMapForRouterFile(routerFilePath) {
2873
3271
  let routerSource;
2874
3272
  try {
@@ -2881,7 +3279,7 @@ function buildCombinedRouteMapForRouterFile(routerFilePath) {
2881
3279
  return { routes: {}, searchSchemas: {} };
2882
3280
  }
2883
3281
  const rawBasename = extractBasenameFromRouter(routerSource);
2884
- const basename3 = rawBasename ? ("/" + rawBasename.replace(/^\/+|\/+$/g, "")).replace(/^\/$/, "") : void 0;
3282
+ const basename2 = rawBasename ? ("/" + rawBasename.replace(/^\/+|\/+$/g, "")).replace(/^\/$/, "") : void 0;
2885
3283
  let result;
2886
3284
  if (extraction.kind === "inline") {
2887
3285
  result = buildCombinedRouteMapWithSearch(
@@ -2906,8 +3304,8 @@ function buildCombinedRouteMapForRouterFile(routerFilePath) {
2906
3304
  result = buildCombinedRouteMapWithSearch(routerFilePath, extraction.name);
2907
3305
  }
2908
3306
  }
2909
- if (basename3) {
2910
- result = applyBasenameToRoutes(result, basename3);
3307
+ if (basename2) {
3308
+ result = applyBasenameToRoutes(result, basename2);
2911
3309
  }
2912
3310
  return result;
2913
3311
  }
@@ -2918,11 +3316,11 @@ function findRouterFiles(root, filter) {
2918
3316
  }
2919
3317
  function writeCombinedRouteTypes(root, knownRouterFiles, opts) {
2920
3318
  try {
2921
- const oldCombinedPath = join(root, "src", "named-routes.gen.ts");
3319
+ const oldCombinedPath = join2(root, "src", "named-routes.gen.ts");
2922
3320
  if (existsSync3(oldCombinedPath)) {
2923
3321
  unlinkSync(oldCombinedPath);
2924
3322
  console.log(
2925
- `[rsc-router] Removed stale combined route types: ${oldCombinedPath}`
3323
+ `[rango] Removed stale combined route types: ${oldCombinedPath}`
2926
3324
  );
2927
3325
  }
2928
3326
  } catch {
@@ -2944,18 +3342,12 @@ function writeCombinedRouteTypes(root, knownRouterFiles, opts) {
2944
3342
  }
2945
3343
  if (!extractUrlsFromRouter(routerSource)) continue;
2946
3344
  }
2947
- const routerBasename = pathBasename(routerFilePath).replace(
2948
- /\.(tsx?|jsx?)$/,
2949
- ""
2950
- );
2951
- const outPath = join(
2952
- dirname2(routerFilePath),
2953
- `${routerBasename}.named-routes.gen.ts`
2954
- );
3345
+ const outPath = genFileTsPath(routerFilePath);
2955
3346
  const existing = existsSync3(outPath) ? readFileSync2(outPath, "utf-8") : null;
2956
3347
  if (Object.keys(result.routes).length === 0) {
2957
3348
  if (!existing) {
2958
3349
  const emptySource = generateRouteTypesSource({});
3350
+ opts?.onWrite?.(outPath, emptySource);
2959
3351
  writeFileSync(outPath, emptySource);
2960
3352
  }
2961
3353
  continue;
@@ -2975,16 +3367,38 @@ function writeCombinedRouteTypes(root, knownRouterFiles, opts) {
2975
3367
  continue;
2976
3368
  }
2977
3369
  }
3370
+ opts?.onWrite?.(outPath, source);
2978
3371
  writeFileSync(outPath, source);
2979
3372
  console.log(
2980
- `[rsc-router] Generated route types (${Object.keys(result.routes).length} routes) -> ${outPath}`
3373
+ `[rango] Generated route types (${Object.keys(result.routes).length} routes) -> ${outPath}`
2981
3374
  );
2982
3375
  }
2983
3376
  }
2984
3377
  }
2985
3378
 
2986
3379
  // src/vite/plugins/version-plugin.ts
3380
+ import { parseAst as parseAst4 } from "vite";
3381
+
3382
+ // src/vite/utils/directive-prologue.ts
2987
3383
  import { parseAst as parseAst3 } from "vite";
3384
+ function hasUseClientDirective(source) {
3385
+ let program;
3386
+ try {
3387
+ program = parseAst3(source, { lang: "tsx" });
3388
+ } catch {
3389
+ return false;
3390
+ }
3391
+ for (const node of program.body ?? []) {
3392
+ if (node?.type === "ExpressionStatement" && node.expression?.type === "Literal" && typeof node.expression.value === "string") {
3393
+ if (node.expression.value === "use client") return true;
3394
+ continue;
3395
+ }
3396
+ break;
3397
+ }
3398
+ return false;
3399
+ }
3400
+
3401
+ // src/vite/plugins/version-plugin.ts
2988
3402
  function isCodeModule(id) {
2989
3403
  return /\.(tsx?|jsx?)($|\?)/.test(id);
2990
3404
  }
@@ -2992,23 +3406,13 @@ function normalizeModuleId(id) {
2992
3406
  return id.split("?", 1)[0];
2993
3407
  }
2994
3408
  function getClientModuleSignature(source) {
3409
+ if (!hasUseClientDirective(source)) return void 0;
2995
3410
  let program;
2996
3411
  try {
2997
- program = parseAst3(source, { jsx: true });
3412
+ program = parseAst4(source, { lang: "tsx" });
2998
3413
  } catch {
2999
3414
  return void 0;
3000
3415
  }
3001
- let isUseClient = false;
3002
- for (const node of program.body ?? []) {
3003
- if (node?.type === "ExpressionStatement" && node.expression?.type === "Literal" && typeof node.expression.value === "string") {
3004
- if (node.expression.value === "use client") {
3005
- isUseClient = true;
3006
- }
3007
- continue;
3008
- }
3009
- break;
3010
- }
3011
- if (!isUseClient) return void 0;
3012
3416
  const exports = /* @__PURE__ */ new Set();
3013
3417
  let hasDefault = false;
3014
3418
  let hasExportAll = false;
@@ -3077,11 +3481,12 @@ function createVersionPlugin() {
3077
3481
  let currentVersion = buildVersion;
3078
3482
  let isDev = false;
3079
3483
  let server = null;
3484
+ let resolvedCacheDir;
3080
3485
  const clientModuleSignatures = /* @__PURE__ */ new Map();
3081
3486
  let versionCounter = 0;
3082
3487
  const bumpVersion = (reason) => {
3083
3488
  currentVersion = Date.now().toString(16) + String(++versionCounter);
3084
- console.log(`[rsc-router] ${reason}, version updated: ${currentVersion}`);
3489
+ console.log(`[rango] ${reason}, version updated: ${currentVersion}`);
3085
3490
  const rscEnv = server?.environments?.rsc;
3086
3491
  const versionMod = rscEnv?.moduleGraph?.getModuleById(
3087
3492
  "\0" + VIRTUAL_IDS.version
@@ -3095,6 +3500,7 @@ function createVersionPlugin() {
3095
3500
  enforce: "pre",
3096
3501
  configResolved(config) {
3097
3502
  isDev = config.command === "serve";
3503
+ resolvedCacheDir = config.cacheDir ? String(config.cacheDir).replace(/\\/g, "/") : void 0;
3098
3504
  },
3099
3505
  configureServer(devServer) {
3100
3506
  server = devServer;
@@ -3131,11 +3537,11 @@ function createVersionPlugin() {
3131
3537
  }
3132
3538
  return null;
3133
3539
  },
3134
- // Track RSC module changes and update version
3135
3540
  async hotUpdate(ctx) {
3136
3541
  if (!isDev) return;
3137
3542
  const isRscModule = this.environment?.name === "rsc";
3138
3543
  if (!isRscModule) return;
3544
+ if (isViteDepCachePath(ctx.file, resolvedCacheDir)) return;
3139
3545
  if (ctx.modules.length === 1 && ctx.modules[0].id === "\0" + VIRTUAL_IDS.version) {
3140
3546
  return;
3141
3547
  }
@@ -3165,6 +3571,17 @@ function createVersionPlugin() {
3165
3571
  }
3166
3572
  };
3167
3573
  }
3574
+ function isViteDepCachePath(filePath, cacheDir) {
3575
+ if (!filePath) return false;
3576
+ const normalized = filePath.replace(/\\/g, "/");
3577
+ if (cacheDir) {
3578
+ const normalizedCacheDir = cacheDir.replace(/\\/g, "/").replace(/\/+$/, "");
3579
+ if (normalized === normalizedCacheDir || normalized.startsWith(normalizedCacheDir + "/")) {
3580
+ return true;
3581
+ }
3582
+ }
3583
+ return /\/node_modules\/\.vite[^/]*\//.test(normalized) || normalized.includes("/.vite-isolated/");
3584
+ }
3168
3585
 
3169
3586
  // src/vite/utils/shared-utils.ts
3170
3587
  import * as Vite from "vite";
@@ -3193,22 +3610,15 @@ function patchRsdwClientDebugInfoRecovery(code) {
3193
3610
  };
3194
3611
  }
3195
3612
  function performanceTracksOptimizeDepsPlugin() {
3613
+ const RSDW_CLIENT_RE = /react-server-dom-webpack-client\.browser\.(development|production)\.js$/;
3196
3614
  return {
3197
3615
  name: "@rangojs/router:performance-tracks-optimize-deps",
3198
- setup(build) {
3199
- build.onLoad(
3200
- {
3201
- filter: /react-server-dom-webpack-client\.browser\.(development|production)\.js$/
3202
- },
3203
- async (args) => {
3204
- const code = await readFile(args.path, "utf8");
3205
- const patched = patchRsdwClientDebugInfoRecovery(code);
3206
- return {
3207
- contents: patched.code,
3208
- loader: "js"
3209
- };
3210
- }
3211
- );
3616
+ async load(id) {
3617
+ const cleanId = id.split("?")[0] ?? id;
3618
+ if (!RSDW_CLIENT_RE.test(cleanId)) return null;
3619
+ const code = await readFile(cleanId, "utf8");
3620
+ const patched = patchRsdwClientDebugInfoRecovery(code);
3621
+ return { code: patched.code };
3212
3622
  }
3213
3623
  };
3214
3624
  }
@@ -3235,24 +3645,27 @@ function performanceTracksPlugin() {
3235
3645
  }
3236
3646
 
3237
3647
  // src/vite/utils/shared-utils.ts
3238
- var versionEsbuildPlugin = {
3648
+ function resolveRscEntryFromConfig(config) {
3649
+ const entries = config.environments?.["rsc"]?.optimizeDeps?.entries;
3650
+ if (typeof entries === "string") return entries;
3651
+ if (Array.isArray(entries) && entries.length > 0) return entries[0];
3652
+ return void 0;
3653
+ }
3654
+ var versionRolldownPlugin = {
3239
3655
  name: "@rangojs/router-version",
3240
- setup(build) {
3241
- build.onResolve({ filter: /^rsc-router:version$/ }, (args) => ({
3242
- path: args.path,
3243
- namespace: "@rangojs/router-virtual"
3244
- }));
3245
- build.onLoad(
3246
- { filter: /.*/, namespace: "@rangojs/router-virtual" },
3247
- () => ({
3248
- contents: `export const VERSION = "dev";`,
3249
- loader: "js"
3250
- })
3251
- );
3656
+ resolveId(id) {
3657
+ if (id === VIRTUAL_IDS.version) return "\0" + VIRTUAL_IDS.version;
3658
+ return void 0;
3659
+ },
3660
+ load(id) {
3661
+ if (id === "\0" + VIRTUAL_IDS.version) {
3662
+ return getVirtualVersionContent("dev");
3663
+ }
3664
+ return void 0;
3252
3665
  }
3253
3666
  };
3254
- var sharedEsbuildOptions = {
3255
- plugins: [versionEsbuildPlugin, performanceTracksOptimizeDepsPlugin()]
3667
+ var sharedRolldownOptions = {
3668
+ plugins: [versionRolldownPlugin, performanceTracksOptimizeDepsPlugin()]
3256
3669
  };
3257
3670
  function createVirtualEntriesPlugin(entries, routerPathRef) {
3258
3671
  const virtualModules = {};
@@ -3294,8 +3707,29 @@ function createVirtualEntriesPlugin(entries, routerPathRef) {
3294
3707
  }
3295
3708
  };
3296
3709
  }
3710
+ function isContentHashedAssetConflict(message) {
3711
+ if (!message) return false;
3712
+ const match = /The emitted file "?([^"\s]+)"? overwrites a previously emitted file/.exec(
3713
+ message
3714
+ );
3715
+ if (!match) return false;
3716
+ const fileName = match[1];
3717
+ const base = fileName.slice(fileName.lastIndexOf("/") + 1);
3718
+ const dot = base.lastIndexOf(".");
3719
+ if (dot <= 0) return false;
3720
+ const stem = base.slice(0, dot);
3721
+ const HASH_LEN = 8;
3722
+ if (stem.length < HASH_LEN + 1 || stem[stem.length - HASH_LEN - 1] !== "-") {
3723
+ return false;
3724
+ }
3725
+ const hash = stem.slice(-HASH_LEN);
3726
+ return /^[A-Za-z0-9_-]+$/.test(hash) && /[A-Z0-9]/.test(hash);
3727
+ }
3297
3728
  function onwarn(warning, defaultHandler) {
3298
- if (warning.code === "MODULE_LEVEL_DIRECTIVE" || warning.code === "SOURCEMAP_ERROR" || warning.code === "EMPTY_BUNDLE") {
3729
+ if (warning.code === "MODULE_LEVEL_DIRECTIVE" || warning.code === "SOURCEMAP_ERROR" || warning.code === "EMPTY_BUNDLE" || warning.code === "INEFFECTIVE_DYNAMIC_IMPORT") {
3730
+ return;
3731
+ }
3732
+ if (warning.code === "FILE_NAME_CONFLICT" && isContentHashedAssetConflict(warning.message)) {
3299
3733
  return;
3300
3734
  }
3301
3735
  if (warning.message?.includes("Sourcemap is likely to be incorrect")) {
@@ -3314,40 +3748,165 @@ function getManualChunks(id) {
3314
3748
  return "react";
3315
3749
  }
3316
3750
  const packageName = getPublishedPackageName();
3317
- if (normalized.includes(`node_modules/${packageName}/`) || normalized.includes("packages/rsc-router/") || normalized.includes("packages/rangojs-router/")) {
3751
+ if (normalized.includes(`node_modules/${packageName}/`) || /\/packages\/(rsc-router|rangojs-router)\/(src|dist)\//.test(normalized)) {
3318
3752
  return "router";
3319
3753
  }
3320
3754
  return void 0;
3321
3755
  }
3322
3756
 
3323
- // src/vite/utils/banner.ts
3324
- var rangoVersion = package_default.version;
3325
- var _bannerPrinted = false;
3326
- function printBanner(mode, preset, version) {
3327
- if (_bannerPrinted) return;
3328
- _bannerPrinted = true;
3329
- const dim = "\x1B[2m";
3330
- const bold = "\x1B[1m";
3331
- const reset = "\x1B[0m";
3332
- const banner = `
3333
- ${dim} \u2726 \u2726 \u2727. . .${reset}
3334
- ${dim} \u2571${reset} ${bold}\u2554\u2550\u2557${reset}${dim} * \u2571 \u2726 *${reset}
3335
- ${dim} ${reset}${bold}\u2551 \u2551${reset} ${bold}\u2554\u2550\u2557${reset}${dim} * \u2727. \u2571${reset}
3336
- ${dim} ${reset}${bold}\u2554\u2557 \u2551 \u2551 \u2551 \u2551${reset}${dim} * \u2571${reset}
3337
- ${dim} ${reset}${bold}\u2551\u2551 \u2551 \u2551 \u2551 \u2551 \u2566\u2550\u2557\u2554\u2550\u2557\u2554\u2557\u2554\u2554\u2550\u2557\u2554\u2550\u2557${reset}${dim} \u2727 \u2726${reset}
3338
- ${dim} ${reset}${bold}\u2551\u2551 \u2551 \u2560\u2550\u255D \u2551 \u2560\u2566\u255D\u2560\u2550\u2563\u2551\u2551\u2551\u2551 \u2566\u2551 \u2551${reset}${dim} * \u2727${reset}
3339
- ${dim} ${reset}${bold}\u2551\u255A\u2550\u255D \u2554\u2550\u2550\u2550\u255D \u2569\u255A\u2550\u2569 \u2569\u255D\u255A\u255D\u255A\u2550\u255D\u255A\u2550\u255D${reset}${dim} \u2726 . *${reset}
3340
- ${dim} ${reset}${bold}\u255A\u2550\u2550\u2557 \u2551${reset}${dim} * RSC Wrangler \u2727 \u2726${reset}
3341
- ${dim} * ${reset}${bold}\u2551 \u2551${reset}${dim} * \u2727. \u2571${reset}
3342
- ${dim} ${reset}${bold}\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550${reset}${dim} \u2726 *${reset}
3343
-
3344
- v${version} \xB7 ${preset} \xB7 ${mode}
3345
- `;
3346
- console.log(banner);
3347
- }
3348
-
3349
- // src/vite/plugins/version-injector.ts
3350
- import { resolve as resolve4 } from "node:path";
3757
+ // src/vite/plugins/client-ref-hashing.ts
3758
+ import { relative as relative2 } from "node:path";
3759
+ import { createHash as createHash2 } from "node:crypto";
3760
+ var debug7 = createRangoDebugger(NS.transform);
3761
+ var CLIENT_PKG_PROXY_PREFIX = "/@id/__x00__virtual:vite-rsc/client-package-proxy/";
3762
+ var CLIENT_IN_SERVER_PKG_PROXY_PREFIX = "/@id/__x00__virtual:vite-rsc/client-in-server-package-proxy/";
3763
+ var FS_PREFIX = "/@fs/";
3764
+ function hashRefKey(relativeId) {
3765
+ return createHash2("sha256").update(relativeId).digest("hex").slice(0, 12);
3766
+ }
3767
+ function computeProductionHash(projectRoot, refKey) {
3768
+ let toHash;
3769
+ if (refKey.startsWith(CLIENT_PKG_PROXY_PREFIX)) {
3770
+ toHash = refKey.slice(CLIENT_PKG_PROXY_PREFIX.length);
3771
+ } else if (refKey.startsWith(CLIENT_IN_SERVER_PKG_PROXY_PREFIX)) {
3772
+ const absPath = decodeURIComponent(
3773
+ refKey.slice(CLIENT_IN_SERVER_PKG_PROXY_PREFIX.length)
3774
+ );
3775
+ toHash = relative2(projectRoot, absPath).replaceAll("\\", "/");
3776
+ } else if (refKey.startsWith(FS_PREFIX)) {
3777
+ const absPath = refKey.slice(FS_PREFIX.length - 1);
3778
+ toHash = relative2(projectRoot, absPath).replaceAll("\\", "/");
3779
+ } else if (refKey.startsWith("/")) {
3780
+ toHash = refKey.slice(1);
3781
+ } else {
3782
+ return refKey;
3783
+ }
3784
+ return hashRefKey(toHash);
3785
+ }
3786
+ var REGISTER_CLIENT_REF_RE = /registerClientReference\(\s*(?:(?:\([^)]*\))|(?:\(\)[\s\S]*?\}))\s*,\s*"([^"]+)"\s*,\s*"[^"]+"\s*\)/g;
3787
+ function transformClientRefs(code, projectRoot) {
3788
+ if (!code.includes("registerClientReference")) return null;
3789
+ let hasReplacement = false;
3790
+ const result = code.replace(
3791
+ REGISTER_CLIENT_REF_RE,
3792
+ (match, refKey) => {
3793
+ const hash = computeProductionHash(projectRoot, refKey);
3794
+ if (hash === refKey) return match;
3795
+ hasReplacement = true;
3796
+ return match.replace(`"${refKey}"`, `"${hash}"`);
3797
+ }
3798
+ );
3799
+ return hasReplacement ? result : null;
3800
+ }
3801
+ function hashClientRefs(projectRoot) {
3802
+ const counter = createCounter(debug7, "hash-client-refs");
3803
+ return {
3804
+ name: "@rangojs/router:hash-client-refs",
3805
+ enforce: "post",
3806
+ applyToEnvironment(env) {
3807
+ return env.name === "rsc";
3808
+ },
3809
+ buildEnd() {
3810
+ counter?.flush();
3811
+ },
3812
+ transform(code, id) {
3813
+ const start = counter ? performance.now() : 0;
3814
+ try {
3815
+ const result = transformClientRefs(code, projectRoot);
3816
+ if (result === null) return;
3817
+ return { code: result, map: null };
3818
+ } finally {
3819
+ counter?.record(id, performance.now() - start);
3820
+ }
3821
+ }
3822
+ };
3823
+ }
3824
+
3825
+ // src/vite/utils/client-chunks.ts
3826
+ var debugChunks = createRangoDebugger(NS.chunks);
3827
+ function isSharedRuntime(meta) {
3828
+ return [meta.id, meta.normalizedId].some(
3829
+ (path6) => path6.includes("/node_modules/") || /\/@rangojs\/router\//.test(path6) || /\/packages\/(rangojs-router|rsc-router)\/(src|dist)\//.test(path6)
3830
+ );
3831
+ }
3832
+ function sanitizeGroup(name) {
3833
+ return name.replace(/[^a-zA-Z0-9_-]+/g, "_").replace(/^_+|_+$/g, "") || "app";
3834
+ }
3835
+ var ROUTE_ROOT_DIRS = /* @__PURE__ */ new Set([
3836
+ "routes",
3837
+ "route",
3838
+ "pages",
3839
+ "page",
3840
+ "app",
3841
+ "features",
3842
+ "feature",
3843
+ "views",
3844
+ "view",
3845
+ "handlers",
3846
+ "urls",
3847
+ "modules",
3848
+ "screens",
3849
+ "sections"
3850
+ ]);
3851
+ function directoryClientChunks(meta, ctx) {
3852
+ if (isSharedRuntime(meta)) {
3853
+ return void 0;
3854
+ }
3855
+ if (ctx?.fallbackRefs.size && ctx.fallbackRefs.has(hashRefKey(meta.normalizedId))) {
3856
+ debugChunks?.("fallback %s -> app-fallback", meta.normalizedId);
3857
+ return "app-fallback";
3858
+ }
3859
+ const segments = meta.normalizedId.split("/").filter(Boolean);
3860
+ const dirCount = segments.length - 1;
3861
+ if (dirCount >= 1) {
3862
+ for (let i = 0; i < dirCount - 1; i++) {
3863
+ if (ROUTE_ROOT_DIRS.has(segments[i].toLowerCase())) {
3864
+ const group = `app-${sanitizeGroup(segments[i + 1])}`;
3865
+ debugChunks?.("split %s -> %s", meta.normalizedId, group);
3866
+ return group;
3867
+ }
3868
+ }
3869
+ }
3870
+ debugChunks?.(
3871
+ "shared %s (no route-root marker; inherits default grouping)",
3872
+ meta.normalizedId
3873
+ );
3874
+ return void 0;
3875
+ }
3876
+ function resolveClientChunks(option, ctx) {
3877
+ if (!option) return void 0;
3878
+ if (option === true) return (meta) => directoryClientChunks(meta, ctx);
3879
+ return option;
3880
+ }
3881
+
3882
+ // src/vite/utils/banner.ts
3883
+ var rangoVersion = package_default.version;
3884
+ var _bannerPrinted = false;
3885
+ function printBanner(mode, preset, version) {
3886
+ if (_bannerPrinted) return;
3887
+ _bannerPrinted = true;
3888
+ const dim = "\x1B[2m";
3889
+ const bold = "\x1B[1m";
3890
+ const reset = "\x1B[0m";
3891
+ const banner = `
3892
+ ${dim} \u2726 \u2726 \u2727. . .${reset}
3893
+ ${dim} \u2571${reset} ${bold}\u2554\u2550\u2557${reset}${dim} * \u2571 \u2726 *${reset}
3894
+ ${dim} ${reset}${bold}\u2551 \u2551${reset} ${bold}\u2554\u2550\u2557${reset}${dim} * \u2727. \u2571${reset}
3895
+ ${dim} ${reset}${bold}\u2554\u2557 \u2551 \u2551 \u2551 \u2551${reset}${dim} * \u2571${reset}
3896
+ ${dim} ${reset}${bold}\u2551\u2551 \u2551 \u2551 \u2551 \u2551 \u2566\u2550\u2557\u2554\u2550\u2557\u2554\u2557\u2554\u2554\u2550\u2557\u2554\u2550\u2557${reset}${dim} \u2727 \u2726${reset}
3897
+ ${dim} ${reset}${bold}\u2551\u2551 \u2551 \u2560\u2550\u255D \u2551 \u2560\u2566\u255D\u2560\u2550\u2563\u2551\u2551\u2551\u2551 \u2566\u2551 \u2551${reset}${dim} * \u2727${reset}
3898
+ ${dim} ${reset}${bold}\u2551\u255A\u2550\u255D \u2554\u2550\u2550\u2550\u255D \u2569\u255A\u2550\u2569 \u2569\u255D\u255A\u255D\u255A\u2550\u255D\u255A\u2550\u255D${reset}${dim} \u2726 . *${reset}
3899
+ ${dim} ${reset}${bold}\u255A\u2550\u2550\u2557 \u2551${reset}${dim} * RSC Wrangler \u2727 \u2726${reset}
3900
+ ${dim} * ${reset}${bold}\u2551 \u2551${reset}${dim} * \u2727. \u2571${reset}
3901
+ ${dim} ${reset}${bold}\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550${reset}${dim} \u2726 *${reset}
3902
+
3903
+ v${version} \xB7 ${preset} \xB7 ${mode}
3904
+ `;
3905
+ console.log(banner);
3906
+ }
3907
+
3908
+ // src/vite/plugins/version-injector.ts
3909
+ import { resolve as resolve4 } from "node:path";
3351
3910
  import * as Vite2 from "vite";
3352
3911
  function createVersionInjectorPlugin(rscEntryPath) {
3353
3912
  let resolvedEntryPath = "";
@@ -3356,15 +3915,7 @@ function createVersionInjectorPlugin(rscEntryPath) {
3356
3915
  enforce: "pre",
3357
3916
  configResolved(config) {
3358
3917
  let entryPath = rscEntryPath;
3359
- if (!entryPath) {
3360
- const rscEnvConfig = config.environments?.["rsc"];
3361
- const entries = rscEnvConfig?.optimizeDeps?.entries;
3362
- if (typeof entries === "string") {
3363
- entryPath = entries;
3364
- } else if (Array.isArray(entries) && entries.length > 0) {
3365
- entryPath = entries[0];
3366
- }
3367
- }
3918
+ if (!entryPath) entryPath = resolveRscEntryFromConfig(config);
3368
3919
  if (entryPath) {
3369
3920
  resolvedEntryPath = resolve4(config.root, entryPath);
3370
3921
  }
@@ -3412,23 +3963,27 @@ function createVersionInjectorPlugin(rscEntryPath) {
3412
3963
  }
3413
3964
 
3414
3965
  // src/vite/plugins/cjs-to-esm.ts
3415
- var debug7 = createRangoDebugger(NS.transform);
3966
+ var debug8 = createRangoDebugger(NS.transform);
3416
3967
  function createCjsToEsmPlugin() {
3968
+ let isProduction = false;
3417
3969
  return {
3418
3970
  name: "@rangojs/router:cjs-to-esm",
3419
3971
  enforce: "pre",
3972
+ configResolved(config) {
3973
+ isProduction = config.isProduction;
3974
+ },
3420
3975
  transform(code, id) {
3421
- const cleanId = id.split("?")[0];
3422
- if (cleanId.includes("vendor/react-server-dom/client.browser.js") || cleanId.includes("vendor\\react-server-dom\\client.browser.js")) {
3423
- const isProd = process.env.NODE_ENV === "production";
3976
+ const cleanId = id.split("?")[0].replaceAll("\\", "/");
3977
+ if (cleanId.includes("vendor/react-server-dom/client.browser.js")) {
3978
+ const isProd = isProduction;
3424
3979
  const cjsFile = isProd ? "./cjs/react-server-dom-webpack-client.browser.production.js" : "./cjs/react-server-dom-webpack-client.browser.development.js";
3425
- debug7?.("cjs-to-esm entry redirect %s", id);
3980
+ debug8?.("cjs-to-esm entry redirect %s", id);
3426
3981
  return {
3427
3982
  code: `export * from "${cjsFile}";`,
3428
3983
  map: null
3429
3984
  };
3430
3985
  }
3431
- if ((cleanId.includes("vendor/react-server-dom/cjs/") || cleanId.includes("vendor\\react-server-dom\\cjs\\")) && cleanId.includes("client.browser")) {
3986
+ if (cleanId.includes("vendor/react-server-dom/cjs/") && cleanId.includes("client.browser")) {
3432
3987
  let transformed = code;
3433
3988
  const licenseMatch = transformed.match(/^\/\*\*[\s\S]*?\*\//);
3434
3989
  const license = licenseMatch ? licenseMatch[0] : "";
@@ -3458,7 +4013,7 @@ function createCjsToEsmPlugin() {
3458
4013
  "export const $1 ="
3459
4014
  );
3460
4015
  transformed = license + "\n" + transformed;
3461
- debug7?.("cjs-to-esm body rewrite %s", id);
4016
+ debug8?.("cjs-to-esm body rewrite %s", id);
3462
4017
  return {
3463
4018
  code: transformed,
3464
4019
  map: null
@@ -3476,6 +4031,19 @@ import { readFileSync as readFileSync6 } from "node:fs";
3476
4031
  import { createRequire as createRequire2, register } from "node:module";
3477
4032
  import { pathToFileURL } from "node:url";
3478
4033
 
4034
+ // src/vite/inject-client-debug.ts
4035
+ function injectClientDebugFlag(id) {
4036
+ if (!id.includes("internal-debug")) return null;
4037
+ const norm = id.replace(/\\/g, "/");
4038
+ const isInternalDebug = /\/internal-debug\.[cm]?[jt]sx?(\?|$)/.test(norm) && (norm.includes("/@rangojs/router/") || norm.includes("/packages/rangojs-router/"));
4039
+ if (!isInternalDebug) return null;
4040
+ return {
4041
+ code: `export const INTERNAL_RANGO_DEBUG = ${!!process.env.INTERNAL_RANGO_DEBUG};
4042
+ `,
4043
+ map: null
4044
+ };
4045
+ }
4046
+
3479
4047
  // src/vite/plugins/virtual-stub-plugin.ts
3480
4048
  function createVirtualStubPlugin() {
3481
4049
  const STUB_PREFIXES = [
@@ -3547,7 +4115,7 @@ function createCloudflareProtocolStubPlugin() {
3547
4115
  if (!code.includes(CF_PREFIX)) return null;
3548
4116
  let ast;
3549
4117
  try {
3550
- ast = this.parse(code);
4118
+ ast = this.parse(code, { lang: "tsx" });
3551
4119
  } catch {
3552
4120
  return null;
3553
4121
  }
@@ -3607,72 +4175,6 @@ function walk(node, visit) {
3607
4175
  }
3608
4176
  }
3609
4177
 
3610
- // src/vite/plugins/client-ref-hashing.ts
3611
- import { relative } from "node:path";
3612
- import { createHash as createHash2 } from "node:crypto";
3613
- var debug8 = createRangoDebugger(NS.transform);
3614
- var CLIENT_PKG_PROXY_PREFIX = "/@id/__x00__virtual:vite-rsc/client-package-proxy/";
3615
- var CLIENT_IN_SERVER_PKG_PROXY_PREFIX = "/@id/__x00__virtual:vite-rsc/client-in-server-package-proxy/";
3616
- var FS_PREFIX = "/@fs/";
3617
- function computeProductionHash(projectRoot, refKey) {
3618
- let toHash;
3619
- if (refKey.startsWith(CLIENT_PKG_PROXY_PREFIX)) {
3620
- toHash = refKey.slice(CLIENT_PKG_PROXY_PREFIX.length);
3621
- } else if (refKey.startsWith(CLIENT_IN_SERVER_PKG_PROXY_PREFIX)) {
3622
- const absPath = decodeURIComponent(
3623
- refKey.slice(CLIENT_IN_SERVER_PKG_PROXY_PREFIX.length)
3624
- );
3625
- toHash = relative(projectRoot, absPath).replaceAll("\\", "/");
3626
- } else if (refKey.startsWith(FS_PREFIX)) {
3627
- const absPath = refKey.slice(FS_PREFIX.length - 1);
3628
- toHash = relative(projectRoot, absPath).replaceAll("\\", "/");
3629
- } else if (refKey.startsWith("/")) {
3630
- toHash = refKey.slice(1);
3631
- } else {
3632
- return refKey;
3633
- }
3634
- return createHash2("sha256").update(toHash).digest("hex").slice(0, 12);
3635
- }
3636
- var REGISTER_CLIENT_REF_RE = /registerClientReference\(\s*(?:(?:\([^)]*\))|(?:\(\)[\s\S]*?\}))\s*,\s*"([^"]+)"\s*,\s*"[^"]+"\s*\)/g;
3637
- function transformClientRefs(code, projectRoot) {
3638
- if (!code.includes("registerClientReference")) return null;
3639
- let hasReplacement = false;
3640
- const result = code.replace(
3641
- REGISTER_CLIENT_REF_RE,
3642
- (match, refKey) => {
3643
- const hash = computeProductionHash(projectRoot, refKey);
3644
- if (hash === refKey) return match;
3645
- hasReplacement = true;
3646
- return match.replace(`"${refKey}"`, `"${hash}"`);
3647
- }
3648
- );
3649
- return hasReplacement ? result : null;
3650
- }
3651
- function hashClientRefs(projectRoot) {
3652
- const counter = createCounter(debug8, "hash-client-refs");
3653
- return {
3654
- name: "@rangojs/router:hash-client-refs",
3655
- // Run after the RSC plugin's transform (default enforce is normal)
3656
- enforce: "post",
3657
- applyToEnvironment(env) {
3658
- return env.name === "rsc";
3659
- },
3660
- buildEnd() {
3661
- counter?.flush();
3662
- },
3663
- transform(code, id) {
3664
- const start = counter ? performance.now() : 0;
3665
- try {
3666
- const result = transformClientRefs(code, projectRoot);
3667
- if (result === null) return;
3668
- return { code: result, map: null };
3669
- } finally {
3670
- counter?.record(id, performance.now() - start);
3671
- }
3672
- }
3673
- };
3674
- }
3675
-
3676
4178
  // src/vite/utils/bundle-analysis.ts
3677
4179
  function findMatchingParenInBundle(code, openParenPos) {
3678
4180
  let depth = 1;
@@ -3703,7 +4205,7 @@ function extractHandlerExportsFromChunk(chunkCode, handlerModules, fnName, detec
3703
4205
  if (detectPassthrough) {
3704
4206
  const eFnName = escapeRegExp(fnName);
3705
4207
  const callStartRe = new RegExp(
3706
- `const\\s+${eName}\\s*=\\s*${eFnName}\\s*(?:<[^>]*>)?\\s*\\(`
4208
+ `(?:const|let|var)\\s+${eName}\\s*=\\s*${eFnName}\\s*(?:<[^>]*>)?\\s*\\(`
3707
4209
  );
3708
4210
  const callStart = callStartRe.exec(chunkCode);
3709
4211
  if (callStart) {
@@ -3728,7 +4230,7 @@ function evictHandlerCode(code, exports, fnName, brand) {
3728
4230
  if (passthrough) continue;
3729
4231
  const eName = escapeRegExp(name);
3730
4232
  const callStartRe = new RegExp(
3731
- `const\\s+${eName}\\s*=\\s*${eFnName}\\s*(?:<[^>]*>)?\\s*\\(`
4233
+ `(?:const|let|var)\\s+${eName}\\s*=\\s*${eFnName}\\s*(?:<[^>]*>)?\\s*\\(`
3732
4234
  );
3733
4235
  const startMatch = callStartRe.exec(modified);
3734
4236
  if (!startMatch) continue;
@@ -3763,6 +4265,8 @@ function createDiscoveryState(entryPath, opts) {
3763
4265
  projectRoot: "",
3764
4266
  isBuildMode: false,
3765
4267
  userResolveAlias: void 0,
4268
+ userRunnerConfig: void 0,
4269
+ userResolvePlugins: [],
3766
4270
  scanFilter: void 0,
3767
4271
  cachedRouterFiles: void 0,
3768
4272
  opts,
@@ -3784,7 +4288,8 @@ function createDiscoveryState(entryPath, opts) {
3784
4288
  devServerOrigin: null,
3785
4289
  devServer: null,
3786
4290
  selfWrittenGenFiles: /* @__PURE__ */ new Map(),
3787
- SELF_WRITE_WINDOW_MS: 5e3
4291
+ SELF_WRITE_WINDOW_MS: 5e3,
4292
+ lastDiscoveryError: null
3788
4293
  };
3789
4294
  }
3790
4295
 
@@ -3822,11 +4327,57 @@ function checkSelfGenWrite(state, filePath, consume) {
3822
4327
  }
3823
4328
  }
3824
4329
 
3825
- // src/vite/utils/manifest-utils.ts
4330
+ // src/router/logging.ts
4331
+ import { AsyncLocalStorage } from "node:async_hooks";
4332
+
4333
+ // src/internal-debug.ts
4334
+ var INTERNAL_RANGO_DEBUG = typeof process !== "undefined" && Boolean(process.env?.INTERNAL_RANGO_DEBUG);
4335
+
4336
+ // src/router/logging.ts
4337
+ var routerLogContext = new AsyncLocalStorage();
4338
+
4339
+ // src/router/pattern-matching.ts
4340
+ function parsePattern(pattern) {
4341
+ const segments = [];
4342
+ const segmentRegex = /\/(:([a-zA-Z_][a-zA-Z0-9_]*)(\(([^)]+)\))?(\?)?([^/]*)|(\*)|([^/]+))/g;
4343
+ let match;
4344
+ while ((match = segmentRegex.exec(pattern)) !== null) {
4345
+ const [
4346
+ ,
4347
+ ,
4348
+ paramName,
4349
+ ,
4350
+ constraint,
4351
+ optional,
4352
+ suffix,
4353
+ wildcard,
4354
+ staticText
4355
+ ] = match;
4356
+ if (wildcard) {
4357
+ segments.push({ type: "wildcard", value: "*", optional: false });
4358
+ } else if (paramName) {
4359
+ segments.push({
4360
+ type: "param",
4361
+ value: paramName,
4362
+ optional: optional === "?",
4363
+ constraint: constraint ? constraint.split("|") : void 0,
4364
+ suffix: suffix || void 0
4365
+ });
4366
+ } else if (staticText) {
4367
+ segments.push({ type: "static", value: staticText, optional: false });
4368
+ }
4369
+ }
4370
+ return segments;
4371
+ }
4372
+
4373
+ // src/build/prefix-tree-utils.ts
3826
4374
  function flattenLeafEntries(prefixTree, routeManifest, result) {
3827
- function visit(node) {
4375
+ function visit(node, ancestorStaticPrefixes) {
3828
4376
  const children = node.children || {};
3829
4377
  if (Object.keys(children).length === 0 && node.routes && node.routes.length > 0) {
4378
+ if (ancestorStaticPrefixes.has(node.staticPrefix)) {
4379
+ return;
4380
+ }
3830
4381
  const routes = {};
3831
4382
  for (const name of node.routes) {
3832
4383
  if (name in routeManifest) {
@@ -3835,13 +4386,15 @@ function flattenLeafEntries(prefixTree, routeManifest, result) {
3835
4386
  }
3836
4387
  result.push({ staticPrefix: node.staticPrefix, routes });
3837
4388
  } else {
4389
+ const nextAncestors = new Set(ancestorStaticPrefixes);
4390
+ nextAncestors.add(node.staticPrefix);
3838
4391
  for (const child of Object.values(children)) {
3839
- visit(child);
4392
+ visit(child, nextAncestors);
3840
4393
  }
3841
4394
  }
3842
4395
  }
3843
4396
  for (const node of Object.values(prefixTree)) {
3844
- visit(node);
4397
+ visit(node, /* @__PURE__ */ new Set());
3845
4398
  }
3846
4399
  }
3847
4400
  function buildRouteToStaticPrefix(prefixTree, result) {
@@ -3858,6 +4411,219 @@ function buildRouteToStaticPrefix(prefixTree, result) {
3858
4411
  visit(node);
3859
4412
  }
3860
4413
  }
4414
+
4415
+ // src/build/route-trie.ts
4416
+ function buildRouteTrie(routeManifest, routeAncestry, routeToStaticPrefix, routeTrailingSlash, prerenderRouteNames, passthroughRouteNames, responseTypeRoutes) {
4417
+ const root = {};
4418
+ for (const [routeName, pattern] of Object.entries(routeManifest)) {
4419
+ const ancestry = routeAncestry[routeName] || [];
4420
+ const staticPrefix = routeToStaticPrefix[routeName] || "";
4421
+ const trailingSlash = routeTrailingSlash?.[routeName];
4422
+ const responseType = responseTypeRoutes?.[routeName];
4423
+ const hasTrailingSlash = pattern.length > 1 && pattern.endsWith("/");
4424
+ const normalizedPattern = hasTrailingSlash ? pattern.slice(0, -1) : pattern;
4425
+ const segments = parsePattern(normalizedPattern);
4426
+ insertRoute(root, segments, 0, {
4427
+ n: routeName,
4428
+ sp: staticPrefix,
4429
+ a: ancestry,
4430
+ ...trailingSlash ? { ts: trailingSlash } : {},
4431
+ ...prerenderRouteNames?.has(routeName) ? { pr: true } : {},
4432
+ ...passthroughRouteNames?.has(routeName) ? { pt: true } : {},
4433
+ ...responseType ? { rt: responseType } : {}
4434
+ });
4435
+ }
4436
+ sortSuffixParams(root);
4437
+ return root;
4438
+ }
4439
+ function sortSuffixParams(node) {
4440
+ if (node.xp) {
4441
+ const sorted = {};
4442
+ for (const suffix of Object.keys(node.xp).sort(
4443
+ (a, b) => b.length - a.length
4444
+ )) {
4445
+ sorted[suffix] = node.xp[suffix];
4446
+ }
4447
+ node.xp = sorted;
4448
+ for (const child of Object.values(node.xp)) {
4449
+ sortSuffixParams(child.c);
4450
+ }
4451
+ }
4452
+ if (node.s) {
4453
+ for (const child of Object.values(node.s)) {
4454
+ sortSuffixParams(child);
4455
+ }
4456
+ }
4457
+ if (node.p) {
4458
+ sortSuffixParams(node.p.c);
4459
+ }
4460
+ }
4461
+ function buildPerRouterTrie(manifest) {
4462
+ const ancestry = manifest._routeAncestry;
4463
+ if (!ancestry || Object.keys(ancestry).length === 0) {
4464
+ return null;
4465
+ }
4466
+ const routeToStaticPrefix = {};
4467
+ for (const name of Object.keys(manifest.routeManifest)) {
4468
+ routeToStaticPrefix[name] = "";
4469
+ }
4470
+ if (manifest.prefixTree) {
4471
+ buildRouteToStaticPrefix(manifest.prefixTree, routeToStaticPrefix);
4472
+ }
4473
+ return buildRouteTrie(
4474
+ manifest.routeManifest,
4475
+ ancestry,
4476
+ routeToStaticPrefix,
4477
+ manifest.routeTrailingSlash,
4478
+ manifest.prerenderRoutes ? new Set(manifest.prerenderRoutes) : void 0,
4479
+ manifest.passthroughRoutes ? new Set(manifest.passthroughRoutes) : void 0,
4480
+ manifest.responseTypeRoutes
4481
+ );
4482
+ }
4483
+ function insertRoute(node, segments, index, leaf) {
4484
+ const constraints = {};
4485
+ for (const seg of segments) {
4486
+ if (seg.type === "param") {
4487
+ if (seg.constraint) {
4488
+ constraints[seg.value] = seg.constraint;
4489
+ }
4490
+ }
4491
+ }
4492
+ const leafBase = {
4493
+ ...leaf,
4494
+ ...Object.keys(constraints).length > 0 ? { cv: constraints } : {}
4495
+ };
4496
+ insertSegments(node, segments, index, leafBase, []);
4497
+ }
4498
+ function toVariant(leaf, responseType) {
4499
+ return leaf.pa ? { routeKey: leaf.n, responseType, pa: leaf.pa } : { routeKey: leaf.n, responseType };
4500
+ }
4501
+ function mergeLeaves(existing, leaf) {
4502
+ if (!existing) return leaf;
4503
+ if (existing.rt && leaf.rt) {
4504
+ const merged = leaf;
4505
+ merged.nv = existing.nv || [];
4506
+ merged.nv.push(toVariant(existing, existing.rt));
4507
+ return merged;
4508
+ }
4509
+ if (leaf.rt && !existing.rt) {
4510
+ if (!existing.nv) {
4511
+ existing.nv = [];
4512
+ existing.rf = true;
4513
+ }
4514
+ existing.nv.push(toVariant(leaf, leaf.rt));
4515
+ return existing;
4516
+ }
4517
+ if (!leaf.rt && existing.rt) {
4518
+ if (!leaf.nv) leaf.nv = [];
4519
+ if (existing.nv) leaf.nv.push(...existing.nv);
4520
+ leaf.nv.push(toVariant(existing, existing.rt));
4521
+ return leaf;
4522
+ }
4523
+ return leaf;
4524
+ }
4525
+ function mergeLeaf(node, leaf) {
4526
+ node.r = mergeLeaves(node.r, leaf);
4527
+ }
4528
+ function buildLeaf(leafBase, paramNames) {
4529
+ return paramNames.length > 0 ? { ...leafBase, pa: [...paramNames] } : { ...leafBase };
4530
+ }
4531
+ function insertSegments(node, segments, index, leafBase, paramNames) {
4532
+ if (index >= segments.length) {
4533
+ mergeLeaf(node, buildLeaf(leafBase, paramNames));
4534
+ return;
4535
+ }
4536
+ const segment = segments[index];
4537
+ if (segment.type === "static") {
4538
+ if (!node.s) node.s = {};
4539
+ if (!node.s[segment.value]) node.s[segment.value] = {};
4540
+ insertSegments(
4541
+ node.s[segment.value],
4542
+ segments,
4543
+ index + 1,
4544
+ leafBase,
4545
+ paramNames
4546
+ );
4547
+ } else if (segment.type === "param") {
4548
+ if (segment.optional) {
4549
+ insertSegments(node, segments, index + 1, leafBase, paramNames);
4550
+ }
4551
+ if (segment.suffix) {
4552
+ if (!node.xp) node.xp = {};
4553
+ if (!node.xp[segment.suffix]) {
4554
+ node.xp[segment.suffix] = { n: segment.value, c: {} };
4555
+ }
4556
+ insertSegments(node.xp[segment.suffix].c, segments, index + 1, leafBase, [
4557
+ ...paramNames,
4558
+ segment.value
4559
+ ]);
4560
+ } else {
4561
+ if (!node.p) {
4562
+ node.p = { n: segment.value, c: {} };
4563
+ }
4564
+ insertSegments(node.p.c, segments, index + 1, leafBase, [
4565
+ ...paramNames,
4566
+ segment.value
4567
+ ]);
4568
+ }
4569
+ } else if (segment.type === "wildcard") {
4570
+ const wildLeaf = {
4571
+ ...buildLeaf(leafBase, paramNames),
4572
+ pn: "*"
4573
+ };
4574
+ const existing = node.w ? { ...node.w } : void 0;
4575
+ const merged = mergeLeaves(existing, wildLeaf);
4576
+ node.w = merged;
4577
+ }
4578
+ }
4579
+
4580
+ // src/build/collect-fallback-refs.ts
4581
+ var CLIENT_REF = /* @__PURE__ */ Symbol.for("react.client.reference");
4582
+ var MAX_DEPTH = 40;
4583
+ var SYNTHETIC_PROPS = {
4584
+ error: new Error("rango: build-time fallback-chunk discovery"),
4585
+ reset: () => {
4586
+ },
4587
+ pathname: "/",
4588
+ info: { componentStack: "" }
4589
+ };
4590
+ function isReactNodeLike(v) {
4591
+ return Array.isArray(v) || typeof v === "object" && v !== null && "$$typeof" in v;
4592
+ }
4593
+ function walkElementTree(node, report, depth) {
4594
+ if (node == null || depth > MAX_DEPTH) return;
4595
+ if (Array.isArray(node)) {
4596
+ for (const child of node) walkElementTree(child, report, depth + 1);
4597
+ return;
4598
+ }
4599
+ if (typeof node !== "object") return;
4600
+ const el = node;
4601
+ const type = el.type;
4602
+ if (type?.$$typeof === CLIENT_REF && typeof type.$$id === "string") {
4603
+ report(type.$$id.split("#")[0]);
4604
+ }
4605
+ const props = el.props;
4606
+ if (props && typeof props === "object") {
4607
+ walkElementTree(props.children, report, depth + 1);
4608
+ for (const key in props) {
4609
+ if (key === "children") continue;
4610
+ const value = props[key];
4611
+ if (isReactNodeLike(value)) walkElementTree(value, report, depth + 1);
4612
+ }
4613
+ }
4614
+ }
4615
+ function collectFallbackClientRefs(boundary, report) {
4616
+ try {
4617
+ let node = boundary;
4618
+ if (typeof node === "function") {
4619
+ node = node(SYNTHETIC_PROPS);
4620
+ }
4621
+ walkElementTree(node, report, 0);
4622
+ } catch {
4623
+ }
4624
+ }
4625
+
4626
+ // src/vite/utils/manifest-utils.ts
3861
4627
  function jsonParseExpression(value) {
3862
4628
  const json = JSON.stringify(value);
3863
4629
  const escaped = json.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
@@ -3865,6 +4631,9 @@ function jsonParseExpression(value) {
3865
4631
  }
3866
4632
 
3867
4633
  // src/context-var.ts
4634
+ function hasContextVars(variables) {
4635
+ return Object.keys(variables).length > 0 || Object.getOwnPropertySymbols(variables).length > 0;
4636
+ }
3868
4637
  var NON_CACHEABLE_KEYS = /* @__PURE__ */ Symbol.for(
3869
4638
  "rango:non-cacheable-keys"
3870
4639
  );
@@ -3905,9 +4674,6 @@ import {
3905
4674
  writeFileSync as writeFileSync2
3906
4675
  } from "node:fs";
3907
4676
  import { resolve as resolve5 } from "node:path";
3908
- function escapeRegExp2(str) {
3909
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3910
- }
3911
4677
  function encodePathParam(value) {
3912
4678
  return String(value).split("/").map((segment) => encodeURIComponent(segment)).join("/");
3913
4679
  }
@@ -3915,7 +4681,7 @@ function substituteRouteParams(pattern, params, encode = encodeURIComponent) {
3915
4681
  let result = pattern;
3916
4682
  let hadOmittedOptional = false;
3917
4683
  for (const [key, value] of Object.entries(params)) {
3918
- const escaped = escapeRegExp2(key);
4684
+ const escaped = escapeRegExp(key);
3919
4685
  if (value === "") {
3920
4686
  result = result.replace(
3921
4687
  new RegExp(`:${escaped}(\\([^)]*\\))?(?!\\?)`),
@@ -3948,13 +4714,24 @@ async function runWithConcurrency(items, concurrency, fn) {
3948
4714
  return;
3949
4715
  }
3950
4716
  let nextIndex = 0;
4717
+ let firstError;
4718
+ let failed = false;
3951
4719
  async function worker() {
3952
- while (nextIndex < items.length) {
4720
+ while (nextIndex < items.length && !failed) {
3953
4721
  const idx = nextIndex++;
3954
- await fn(items[idx]);
4722
+ try {
4723
+ await fn(items[idx]);
4724
+ } catch (err) {
4725
+ if (!failed) {
4726
+ failed = true;
4727
+ firstError = err;
4728
+ }
4729
+ return;
4730
+ }
3955
4731
  }
3956
4732
  }
3957
4733
  await Promise.all(Array.from({ length: limit }, () => worker()));
4734
+ if (failed) throw firstError;
3958
4735
  }
3959
4736
  function groupByConcurrency(entries) {
3960
4737
  const map = /* @__PURE__ */ new Map();
@@ -4001,6 +4778,23 @@ function notifyOnError(registry, error, phase, routeKey, pathname, skipped) {
4001
4778
  break;
4002
4779
  }
4003
4780
  }
4781
+ function resolvePrerenderError(registry, error, onError, label, elapsed, phase, routeKey, pathname) {
4782
+ const isSkip = error?.name === "Skip";
4783
+ if (isSkip || onError === "warn") {
4784
+ if (isSkip) {
4785
+ console.log(`[rango] SKIP ${label} (${elapsed}ms) - ${error.message}`);
4786
+ } else {
4787
+ console.warn(
4788
+ `[rango] WARN ${label} (${elapsed}ms) - render error, not pre-rendered (prerender.onError: "warn"): ${error.message}`
4789
+ );
4790
+ }
4791
+ notifyOnError(registry, error, phase, routeKey, pathname, true);
4792
+ return;
4793
+ }
4794
+ console.error(`[rango] FAIL ${label} (${elapsed}ms) - ${error.message}`);
4795
+ notifyOnError(registry, error, phase, routeKey, pathname);
4796
+ throw error;
4797
+ }
4004
4798
  function getStagedAssetDir(projectRoot) {
4005
4799
  return resolve5(projectRoot, "node_modules/.rangojs-router-build/rsc-assets");
4006
4800
  }
@@ -4068,7 +4862,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
4068
4862
  const progressInterval = totalDynamic > 0 ? setInterval(() => {
4069
4863
  const elapsed = ((performance.now() - paramsStart) / 1e3).toFixed(1);
4070
4864
  console.log(
4071
- `[rsc-router] Resolving prerender params... ${resolvedRoutes}/${totalDynamic} routes (${elapsed}s)`
4865
+ `[rango] Resolving prerender params... ${resolvedRoutes}/${totalDynamic} routes (${elapsed}s)`
4072
4866
  );
4073
4867
  }, 5e3) : void 0;
4074
4868
  try {
@@ -4105,7 +4899,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
4105
4899
  get env() {
4106
4900
  if (buildEnv !== void 0) return buildEnv;
4107
4901
  throw new Error(
4108
- "[rsc-router] ctx.env is not available during build-time getParams(). Configure buildEnv in your rango() plugin options to enable build-time env access."
4902
+ "[rango] ctx.env is not available during build-time getParams(). Configure buildEnv in your rango() plugin options to enable build-time env access."
4109
4903
  );
4110
4904
  }
4111
4905
  };
@@ -4117,7 +4911,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
4117
4911
  (performance.now() - getParamsStart).toFixed(1)
4118
4912
  );
4119
4913
  const concurrency = def.options?.concurrency ?? 1;
4120
- const hasBuildVars = Object.keys(buildVars).length > 0 || Object.getOwnPropertySymbols(buildVars).length > 0;
4914
+ const hasBuildVars = hasContextVars(buildVars);
4121
4915
  for (const params of paramsList) {
4122
4916
  let url = substituteRouteParams(
4123
4917
  pattern,
@@ -4146,7 +4940,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
4146
4940
  resolvedRoutes++;
4147
4941
  if (err.name === "Skip") {
4148
4942
  console.log(
4149
- `[rsc-router] SKIP route "${routeName}" - ${err.message}`
4943
+ `[rango] SKIP route "${routeName}" - ${err.message}`
4150
4944
  );
4151
4945
  notifyOnError(
4152
4946
  registry,
@@ -4159,14 +4953,14 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
4159
4953
  continue;
4160
4954
  }
4161
4955
  console.error(
4162
- `[rsc-router] Failed to get params for prerender route "${routeName}": ${err.message}`
4956
+ `[rango] Failed to get params for prerender route "${routeName}": ${err.message}`
4163
4957
  );
4164
4958
  notifyOnError(registry, err, "prerender", routeName);
4165
4959
  throw err;
4166
4960
  }
4167
4961
  } else {
4168
4962
  console.warn(
4169
- `[rsc-router] Dynamic prerender route "${routeName}" has no getParams(), skipping`
4963
+ `[rango] Dynamic prerender route "${routeName}" has no getParams(), skipping`
4170
4964
  );
4171
4965
  }
4172
4966
  }
@@ -4177,7 +4971,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
4177
4971
  clearInterval(progressInterval);
4178
4972
  const elapsed = ((performance.now() - paramsStart) / 1e3).toFixed(1);
4179
4973
  console.log(
4180
- `[rsc-router] Resolved prerender params: ${resolvedRoutes}/${totalDynamic} routes (${elapsed}s)`
4974
+ `[rango] Resolved prerender params: ${resolvedRoutes}/${totalDynamic} routes (${elapsed}s)`
4181
4975
  );
4182
4976
  }
4183
4977
  }
@@ -4191,7 +4985,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
4191
4985
  const maxConcurrency = Math.max(...entries.map((e) => e.concurrency));
4192
4986
  const concurrencyNote = maxConcurrency > 1 ? ` (concurrency: ${maxConcurrency})` : "";
4193
4987
  console.log(
4194
- `[rsc-router] Pre-rendering ${entries.length} URL(s)${concurrencyNote}...`
4988
+ `[rango] Pre-rendering ${entries.length} URL(s)${concurrencyNote}...`
4195
4989
  );
4196
4990
  debug9?.(
4197
4991
  "prerender loop: %d entries, max concurrency %d",
@@ -4202,6 +4996,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
4202
4996
  const manifestEntries = {};
4203
4997
  let doneCount = 0;
4204
4998
  let skipCount = 0;
4999
+ const prerenderOnError = state.opts?.prerenderOnError ?? "fail";
4205
5000
  const startTotal = performance.now();
4206
5001
  const groups = groupByConcurrency(entries);
4207
5002
  for (const group of groups) {
@@ -4224,7 +5019,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
4224
5019
  if (result.passthrough) {
4225
5020
  const elapsed2 = (performance.now() - startUrl).toFixed(0);
4226
5021
  console.log(
4227
- `[rsc-router] PASS ${entry.urlPath.padEnd(40)} (${elapsed2}ms) - live fallback`
5022
+ `[rango] PASS ${entry.urlPath.padEnd(40)} (${elapsed2}ms) - live fallback`
4228
5023
  );
4229
5024
  doneCount++;
4230
5025
  break;
@@ -4244,10 +5039,9 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
4244
5039
  const interceptKey = `${result.routeName}/${paramHash}/i`;
4245
5040
  const interceptValue = JSON.stringify({
4246
5041
  segments: [...result.segments, ...result.interceptSegments],
4247
- handles: {
4248
- ...result.handles,
4249
- ...result.interceptHandles || {}
4250
- }
5042
+ // interceptHandles is the pre-encoded MERGED (main + intercept)
5043
+ // handle string (the producer merged before encoding).
5044
+ handles: result.interceptHandles ?? ""
4251
5045
  });
4252
5046
  manifestEntries[interceptKey] = stageBuildAssetModule(
4253
5047
  state.projectRoot,
@@ -4257,39 +5051,24 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
4257
5051
  }
4258
5052
  const elapsed = (performance.now() - startUrl).toFixed(0);
4259
5053
  console.log(
4260
- `[rsc-router] OK ${entry.urlPath.padEnd(40)} (${elapsed}ms)`
5054
+ `[rango] OK ${entry.urlPath.padEnd(40)} (${elapsed}ms)`
4261
5055
  );
4262
5056
  doneCount++;
4263
5057
  break;
4264
5058
  } catch (err) {
4265
- if (err.name === "Skip") {
4266
- const elapsed2 = (performance.now() - startUrl).toFixed(0);
4267
- console.log(
4268
- `[rsc-router] SKIP ${entry.urlPath.padEnd(40)} (${elapsed2}ms) - ${err.message}`
4269
- );
4270
- skipCount++;
4271
- notifyOnError(
4272
- registry,
4273
- err,
4274
- "prerender",
4275
- entry.routeName,
4276
- entry.urlPath,
4277
- true
4278
- );
4279
- break;
4280
- }
4281
5059
  const elapsed = (performance.now() - startUrl).toFixed(0);
4282
- console.error(
4283
- `[rsc-router] FAIL ${entry.urlPath.padEnd(40)} (${elapsed}ms) - ${err.message}`
4284
- );
4285
- notifyOnError(
5060
+ resolvePrerenderError(
4286
5061
  registry,
4287
5062
  err,
5063
+ prerenderOnError,
5064
+ entry.urlPath.padEnd(40),
5065
+ elapsed,
4288
5066
  "prerender",
4289
5067
  entry.routeName,
4290
5068
  entry.urlPath
4291
5069
  );
4292
- throw err;
5070
+ skipCount++;
5071
+ break;
4293
5072
  }
4294
5073
  }
4295
5074
  }
@@ -4302,7 +5081,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
4302
5081
  const parts = [`${doneCount} done`];
4303
5082
  if (skipCount > 0) parts.push(`${skipCount} skipped`);
4304
5083
  console.log(
4305
- `[rsc-router] Pre-render complete: ${parts.join(", ")} (${totalElapsed}ms total)`
5084
+ `[rango] Pre-render complete: ${parts.join(", ")} (${totalElapsed}ms total)`
4306
5085
  );
4307
5086
  debug9?.(
4308
5087
  "expandPrerenderRoutes done: %d done, %d skipped, %sms (overall %sms)",
@@ -4324,20 +5103,19 @@ async function renderStaticHandlers(state, rscEnv, registry) {
4324
5103
  let staticDone = 0;
4325
5104
  let staticSkip = 0;
4326
5105
  let totalStaticCount = 0;
5106
+ const prerenderOnError = state.opts?.prerenderOnError ?? "fail";
4327
5107
  for (const [, exportNames] of state.resolvedStaticModules) {
4328
5108
  totalStaticCount += exportNames.length;
4329
5109
  }
4330
5110
  const startStatic = performance.now();
4331
- console.log(
4332
- `[rsc-router] Rendering ${totalStaticCount} static handler(s)...`
4333
- );
5111
+ console.log(`[rango] Rendering ${totalStaticCount} static handler(s)...`);
4334
5112
  for (const [moduleId, exportNames] of state.resolvedStaticModules) {
4335
5113
  let mod;
4336
5114
  try {
4337
5115
  mod = await rscEnv.runner.import(moduleId);
4338
5116
  } catch (err) {
4339
5117
  console.error(
4340
- `[rsc-router] Failed to import static module ${moduleId}: ${err.message}`
5118
+ `[rango] Failed to import static module ${moduleId}: ${err.message}`
4341
5119
  );
4342
5120
  notifyOnError(registry, err, "static");
4343
5121
  throw err;
@@ -4359,7 +5137,7 @@ async function renderStaticHandlers(state, rscEnv, registry) {
4359
5137
  !state.isBuildMode
4360
5138
  );
4361
5139
  if (result) {
4362
- const hasHandles = Object.keys(result.handles).length > 0;
5140
+ const hasHandles = result.handles !== "";
4363
5141
  const exportValue = hasHandles ? JSON.stringify(result) : JSON.stringify(result.encoded);
4364
5142
  manifestEntries[def.$$id] = stageBuildAssetModule(
4365
5143
  state.projectRoot,
@@ -4367,36 +5145,28 @@ async function renderStaticHandlers(state, rscEnv, registry) {
4367
5145
  exportValue
4368
5146
  );
4369
5147
  const elapsed = (performance.now() - startHandler).toFixed(0);
4370
- console.log(
4371
- `[rsc-router] OK ${name.padEnd(40)} (${elapsed}ms)`
4372
- );
5148
+ console.log(`[rango] OK ${name.padEnd(40)} (${elapsed}ms)`);
4373
5149
  staticDone++;
4374
5150
  handled = true;
4375
5151
  break;
4376
5152
  }
4377
5153
  } catch (err) {
4378
- if (err.name === "Skip") {
4379
- const elapsed2 = (performance.now() - startHandler).toFixed(0);
4380
- console.log(
4381
- `[rsc-router] SKIP ${name.padEnd(40)} (${elapsed2}ms) - ${err.message}`
4382
- );
4383
- staticSkip++;
4384
- notifyOnError(registry, err, "static", void 0, void 0, true);
4385
- handled = true;
4386
- break;
4387
- }
4388
5154
  const elapsed = (performance.now() - startHandler).toFixed(0);
4389
- console.error(
4390
- `[rsc-router] FAIL ${name.padEnd(40)} (${elapsed}ms) - ${err.message}`
5155
+ resolvePrerenderError(
5156
+ registry,
5157
+ err,
5158
+ prerenderOnError,
5159
+ name.padEnd(40),
5160
+ elapsed,
5161
+ "static"
4391
5162
  );
4392
- notifyOnError(registry, err, "static");
4393
- throw err;
5163
+ staticSkip++;
5164
+ handled = true;
5165
+ break;
4394
5166
  }
4395
5167
  }
4396
5168
  if (!handled) {
4397
- console.warn(
4398
- `[rsc-router] No router could render static handler "${name}"`
4399
- );
5169
+ console.warn(`[rango] No router could render static handler "${name}"`);
4400
5170
  }
4401
5171
  }
4402
5172
  }
@@ -4407,7 +5177,7 @@ async function renderStaticHandlers(state, rscEnv, registry) {
4407
5177
  const staticParts = [`${staticDone} done`];
4408
5178
  if (staticSkip > 0) staticParts.push(`${staticSkip} skipped`);
4409
5179
  console.log(
4410
- `[rsc-router] Static render complete: ${staticParts.join(", ")} (${totalStaticElapsed}ms total)`
5180
+ `[rango] Static render complete: ${staticParts.join(", ")} (${totalStaticElapsed}ms total)`
4411
5181
  );
4412
5182
  debug9?.(
4413
5183
  "renderStaticHandlers done: %d done, %d skipped, %sms (overall %sms)",
@@ -4418,6 +5188,80 @@ async function renderStaticHandlers(state, rscEnv, registry) {
4418
5188
  );
4419
5189
  }
4420
5190
 
5191
+ // src/vite/discovery/discovery-errors.ts
5192
+ function indent(text, pad) {
5193
+ return text.split("\n").map((line) => line.length > 0 ? pad + line : line).join("\n");
5194
+ }
5195
+ async function invokeLazyMount(loader, context, errors) {
5196
+ try {
5197
+ await loader();
5198
+ } catch (error) {
5199
+ errors.push({ context, error });
5200
+ }
5201
+ }
5202
+ function isLazyMount(route) {
5203
+ return !!route && route.kind === "lazy" && typeof route.handler === "function";
5204
+ }
5205
+ async function resolveHostRouterHandlers(hostRegistry) {
5206
+ const errors = [];
5207
+ for (const [hostId, entry] of hostRegistry) {
5208
+ for (const route of entry.routes) {
5209
+ if (isLazyMount(route)) {
5210
+ await invokeLazyMount(
5211
+ route.handler,
5212
+ `host "${hostId}" route handler`,
5213
+ errors
5214
+ );
5215
+ }
5216
+ }
5217
+ if (isLazyMount(entry.fallback)) {
5218
+ await invokeLazyMount(
5219
+ entry.fallback.handler,
5220
+ `host "${hostId}" fallback handler`,
5221
+ errors
5222
+ );
5223
+ }
5224
+ }
5225
+ return errors;
5226
+ }
5227
+ function formatNoRoutersError(entryPath, errors) {
5228
+ const base = `[rango] No routers found in registry after importing ${entryPath}`;
5229
+ if (errors.length === 0) {
5230
+ return base;
5231
+ }
5232
+ const formatted = errors.map(({ context, error }) => {
5233
+ const err = error instanceof Error ? error : new Error(String(error));
5234
+ const detail = err.stack ?? err.message;
5235
+ return ` - while resolving ${context}:
5236
+ ${indent(detail, " ")}`;
5237
+ }).join("\n");
5238
+ return `${base}
5239
+
5240
+ ${errors.length} error(s) were caught during host-router discovery and likely explain why no routers were registered:
5241
+ ${formatted}`;
5242
+ }
5243
+ function toCause(errors) {
5244
+ if (errors.length === 0) return void 0;
5245
+ if (errors.length === 1) return errors[0].error;
5246
+ return new AggregateError(
5247
+ errors.map((e) => e.error),
5248
+ "Multiple host-router handlers failed during discovery"
5249
+ );
5250
+ }
5251
+ var DiscoveryError = class _DiscoveryError extends Error {
5252
+ constructor(entryPath, caught) {
5253
+ super(formatNoRoutersError(entryPath, caught));
5254
+ const cause = toCause(caught);
5255
+ if (cause !== void 0) {
5256
+ this.cause = cause;
5257
+ }
5258
+ this.name = "DiscoveryError";
5259
+ this.entryPath = entryPath;
5260
+ this.caught = caught;
5261
+ Object.setPrototypeOf(this, _DiscoveryError.prototype);
5262
+ }
5263
+ };
5264
+
4421
5265
  // src/vite/discovery/discover-routers.ts
4422
5266
  var debug10 = createRangoDebugger(NS.discovery);
4423
5267
  async function discoverRouters(state, rscEnv) {
@@ -4434,27 +5278,17 @@ async function discoverRouters(state, rscEnv) {
4434
5278
  );
4435
5279
  let registry = serverMod.RouterRegistry;
4436
5280
  if (!registry || registry.size === 0) {
5281
+ const discoveryErrors = [];
4437
5282
  try {
4438
5283
  const hostRegistry = serverMod.HostRouterRegistry;
4439
5284
  if (hostRegistry && hostRegistry.size > 0) {
4440
5285
  console.log(
4441
- `[rsc-router] Found ${hostRegistry.size} host router(s), resolving lazy handlers...`
5286
+ `[rango] Found ${hostRegistry.size} host router(s), resolving lazy handlers...`
4442
5287
  );
4443
- for (const [, entry] of hostRegistry) {
4444
- for (const route of entry.routes) {
4445
- if (typeof route.handler === "function") {
4446
- try {
4447
- await route.handler();
4448
- } catch {
4449
- }
4450
- }
4451
- }
4452
- if (entry.fallback && typeof entry.fallback.handler === "function") {
4453
- try {
4454
- await entry.fallback.handler();
4455
- } catch {
4456
- }
4457
- }
5288
+ const handlerErrors = await resolveHostRouterHandlers(hostRegistry);
5289
+ discoveryErrors.push(...handlerErrors);
5290
+ for (const { context, error } of handlerErrors) {
5291
+ debug10?.("caught error while resolving %s: %O", context, error);
4458
5292
  }
4459
5293
  const freshServerMod = await rscEnv.runner.import(
4460
5294
  "@rangojs/router/server"
@@ -4465,12 +5299,11 @@ async function discoverRouters(state, rscEnv) {
4465
5299
  registry = freshRegistry;
4466
5300
  }
4467
5301
  }
4468
- } catch {
5302
+ } catch (error) {
5303
+ discoveryErrors.push({ context: "host-router discovery", error });
4469
5304
  }
4470
5305
  if (!registry || registry.size === 0) {
4471
- throw new Error(
4472
- `[rsc-router] No routers found in registry after importing ${state.resolvedEntryPath}`
4473
- );
5306
+ throw new DiscoveryError(state.resolvedEntryPath, discoveryErrors);
4474
5307
  }
4475
5308
  }
4476
5309
  const buildMod = await timed(
@@ -4498,6 +5331,15 @@ async function discoverRouters(state, rscEnv) {
4498
5331
  let mergedRouteTrailingSlash = {};
4499
5332
  let routerMountIndex = 0;
4500
5333
  const allManifests = [];
5334
+ const clientChunkCtx = state.opts?.clientChunkCtx;
5335
+ const collectClientFallbackRef = clientChunkCtx ? (refKey) => clientChunkCtx.fallbackRefs.add(
5336
+ computeProductionHash(state.projectRoot, refKey)
5337
+ ) : void 0;
5338
+ const collectFromBoundaryNode = (node) => {
5339
+ if (collectClientFallbackRef) {
5340
+ collectFallbackClientRefs(node, collectClientFallbackRef);
5341
+ }
5342
+ };
4501
5343
  const manifestGenStart = debug10 ? performance.now() : 0;
4502
5344
  for (const [id, router] of registry) {
4503
5345
  if (!router.urlpatterns || !generateManifestFull) {
@@ -4506,10 +5348,18 @@ async function discoverRouters(state, rscEnv) {
4506
5348
  const manifest = generateManifestFull(
4507
5349
  router.urlpatterns,
4508
5350
  routerMountIndex,
4509
- router.__basename ? { urlPrefix: router.__basename } : void 0
5351
+ {
5352
+ ...router.__basename ? { urlPrefix: router.__basename } : {},
5353
+ ...collectClientFallbackRef ? { collectClientFallbackRef } : {}
5354
+ }
4510
5355
  );
4511
5356
  routerMountIndex++;
4512
5357
  allManifests.push({ id, manifest });
5358
+ if (collectClientFallbackRef) {
5359
+ collectFromBoundaryNode(router.__defaultErrorBoundary);
5360
+ collectFromBoundaryNode(router.__defaultNotFoundBoundary);
5361
+ collectFromBoundaryNode(router.__notFound);
5362
+ }
4513
5363
  const routeCount = Object.keys(manifest.routeManifest).length;
4514
5364
  const staticRoutes = Object.values(manifest.routeManifest).filter(
4515
5365
  (p) => !p.includes(":") && !p.includes("*")
@@ -4546,21 +5396,17 @@ async function discoverRouters(state, rscEnv) {
4546
5396
  if (manifest.routeTrailingSlash) {
4547
5397
  Object.assign(mergedRouteTrailingSlash, manifest.routeTrailingSlash);
4548
5398
  }
4549
- flattenLeafEntries(
4550
- manifest.prefixTree,
4551
- manifest.routeManifest,
4552
- newMergedPrecomputedEntries
4553
- );
4554
- newPerRouterManifestDataMap.set(id, manifest.routeManifest);
4555
5399
  const routerPrecomputed = [];
4556
5400
  flattenLeafEntries(
4557
5401
  manifest.prefixTree,
4558
5402
  manifest.routeManifest,
4559
5403
  routerPrecomputed
4560
5404
  );
5405
+ newMergedPrecomputedEntries.push(...routerPrecomputed);
5406
+ newPerRouterManifestDataMap.set(id, manifest.routeManifest);
4561
5407
  newPerRouterPrecomputedMap.set(id, routerPrecomputed);
4562
5408
  console.log(
4563
- `[rsc-router] Router "${id}" -> ${routeCount} routes (${staticRoutes} static, ${dynamicRoutes} dynamic)`
5409
+ `[rango] Router "${id}" -> ${routeCount} routes (${staticRoutes} static, ${dynamicRoutes} dynamic)`
4564
5410
  );
4565
5411
  }
4566
5412
  if (registry.size > 1) {
@@ -4569,7 +5415,7 @@ async function discoverRouters(state, rscEnv) {
4569
5415
  );
4570
5416
  if (autoIds.length > 1) {
4571
5417
  console.warn(
4572
- `[rsc-router] WARNING: ${autoIds.length} routers use auto-generated IDs (${autoIds.join(", ")}). In multi-router setups, each createRouter() must have an explicit \`id\` option to ensure per-router manifest data is matched correctly at runtime. Example: createRouter({ id: "site", ... })`
5418
+ `[rango] WARNING: ${autoIds.length} routers use auto-generated IDs (${autoIds.join(", ")}). In multi-router setups, each createRouter() must have an explicit \`id\` option to ensure per-router manifest data is matched correctly at runtime. Example: createRouter({ id: "site", ... })`
4573
5419
  );
4574
5420
  }
4575
5421
  }
@@ -4581,8 +5427,7 @@ async function discoverRouters(state, rscEnv) {
4581
5427
  let newMergedRouteTrie = null;
4582
5428
  const trieStart = debug10 ? performance.now() : 0;
4583
5429
  if (Object.keys(newMergedRouteManifest).length > 0) {
4584
- const buildRouteTrie = buildMod.buildRouteTrie;
4585
- if (buildRouteTrie && mergedRouteAncestry) {
5430
+ if (mergedRouteAncestry) {
4586
5431
  const routeToStaticPrefix = {};
4587
5432
  for (const { manifest } of allManifests) {
4588
5433
  for (const name of Object.keys(manifest.routeManifest)) {
@@ -4614,31 +5459,16 @@ async function discoverRouters(state, rscEnv) {
4614
5459
  newMergedRouteManifest,
4615
5460
  mergedRouteAncestry,
4616
5461
  routeToStaticPrefix,
4617
- Object.keys(mergedRouteTrailingSlash).length > 0 ? mergedRouteTrailingSlash : void 0,
4618
- prerenderRouteNames.size > 0 ? prerenderRouteNames : void 0,
4619
- passthroughRouteNames.size > 0 ? passthroughRouteNames : void 0,
4620
- Object.keys(mergedResponseTypeRoutes).length > 0 ? mergedResponseTypeRoutes : void 0
5462
+ mergedRouteTrailingSlash,
5463
+ prerenderRouteNames,
5464
+ passthroughRouteNames,
5465
+ mergedResponseTypeRoutes
4621
5466
  );
4622
5467
  for (const { id, manifest } of allManifests) {
4623
- if (!manifest._routeAncestry || Object.keys(manifest._routeAncestry).length === 0)
4624
- continue;
4625
- const perRouterStaticPrefix = {};
4626
- for (const name of Object.keys(manifest.routeManifest)) {
4627
- perRouterStaticPrefix[name] = "";
5468
+ const perRouterTrie = buildPerRouterTrie(manifest);
5469
+ if (perRouterTrie) {
5470
+ newPerRouterTrieMap.set(id, perRouterTrie);
4628
5471
  }
4629
- buildRouteToStaticPrefix(manifest.prefixTree, perRouterStaticPrefix);
4630
- const perRouterPrerenderNames = manifest.prerenderRoutes ? new Set(manifest.prerenderRoutes) : void 0;
4631
- const perRouterPassthroughNames = manifest.passthroughRoutes ? new Set(manifest.passthroughRoutes) : void 0;
4632
- const perRouterTrie = buildRouteTrie(
4633
- manifest.routeManifest,
4634
- manifest._routeAncestry,
4635
- perRouterStaticPrefix,
4636
- manifest.routeTrailingSlash && Object.keys(manifest.routeTrailingSlash).length > 0 ? manifest.routeTrailingSlash : void 0,
4637
- perRouterPrerenderNames && perRouterPrerenderNames.size > 0 ? perRouterPrerenderNames : void 0,
4638
- perRouterPassthroughNames && perRouterPassthroughNames.size > 0 ? perRouterPassthroughNames : void 0,
4639
- manifest.responseTypeRoutes && Object.keys(manifest.responseTypeRoutes).length > 0 ? manifest.responseTypeRoutes : void 0
4640
- );
4641
- newPerRouterTrieMap.set(id, perRouterTrie);
4642
5472
  }
4643
5473
  }
4644
5474
  }
@@ -4659,7 +5489,7 @@ async function discoverRouters(state, rscEnv) {
4659
5489
  }
4660
5490
 
4661
5491
  // src/vite/discovery/route-types-writer.ts
4662
- import { dirname as dirname3, basename, join as join2, resolve as resolve6 } from "node:path";
5492
+ import { dirname as dirname3, join as join3, resolve as resolve6 } from "node:path";
4663
5493
  import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, existsSync as existsSync5, unlinkSync as unlinkSync2 } from "node:fs";
4664
5494
  function filterUserNamedRoutes(manifest) {
4665
5495
  const filtered = {};
@@ -4670,39 +5500,20 @@ function filterUserNamedRoutes(manifest) {
4670
5500
  }
4671
5501
  return filtered;
4672
5502
  }
5503
+ function writeGenFileIfChanged(state, outPath, source, opts) {
5504
+ const existing = existsSync5(outPath) ? readFileSync4(outPath, "utf-8") : null;
5505
+ if (existing === source) return;
5506
+ markSelfGenWrite(state, outPath, source);
5507
+ writeFileSync3(outPath, source);
5508
+ if (opts?.log) console.log(`[rango] Generated route types -> ${outPath}`);
5509
+ }
4673
5510
  function writeCombinedRouteTypesWithTracking(state, opts) {
4674
5511
  const routerFiles = state.cachedRouterFiles ?? findRouterFiles(state.projectRoot, state.scanFilter);
4675
5512
  state.cachedRouterFiles = routerFiles;
4676
- const preContent = /* @__PURE__ */ new Map();
4677
- for (const routerFilePath of routerFiles) {
4678
- const routerDir = dirname3(routerFilePath);
4679
- const routerBasename = basename(routerFilePath).replace(
4680
- /\.(tsx?|jsx?)$/,
4681
- ""
4682
- );
4683
- const outPath = join2(routerDir, `${routerBasename}.named-routes.gen.ts`);
4684
- try {
4685
- preContent.set(outPath, readFileSync4(outPath, "utf-8"));
4686
- } catch {
4687
- }
4688
- }
4689
- writeCombinedRouteTypes(state.projectRoot, routerFiles, opts);
4690
- for (const routerFilePath of routerFiles) {
4691
- const routerDir = dirname3(routerFilePath);
4692
- const routerBasename = basename(routerFilePath).replace(
4693
- /\.(tsx?|jsx?)$/,
4694
- ""
4695
- );
4696
- const outPath = join2(routerDir, `${routerBasename}.named-routes.gen.ts`);
4697
- if (!existsSync5(outPath)) continue;
4698
- try {
4699
- const content = readFileSync4(outPath, "utf-8");
4700
- if (content !== preContent.get(outPath)) {
4701
- markSelfGenWrite(state, outPath, content);
4702
- }
4703
- } catch {
4704
- }
4705
- }
5513
+ writeCombinedRouteTypes(state.projectRoot, routerFiles, {
5514
+ ...opts,
5515
+ onWrite: (outPath, content) => markSelfGenWrite(state, outPath, content)
5516
+ });
4706
5517
  }
4707
5518
  function writeRouteTypesFiles(state) {
4708
5519
  if (state.perRouterManifests.length === 0) return;
@@ -4710,11 +5521,11 @@ function writeRouteTypesFiles(state) {
4710
5521
  const entryDir = dirname3(
4711
5522
  resolve6(state.projectRoot, state.resolvedEntryPath)
4712
5523
  );
4713
- const oldCombinedPath = join2(entryDir, "named-routes.gen.ts");
5524
+ const oldCombinedPath = join3(entryDir, "named-routes.gen.ts");
4714
5525
  if (existsSync5(oldCombinedPath)) {
4715
5526
  unlinkSync2(oldCombinedPath);
4716
5527
  console.log(
4717
- `[rsc-router] Removed stale combined route types: ${oldCombinedPath}`
5528
+ `[rango] Removed stale combined route types: ${oldCombinedPath}`
4718
5529
  );
4719
5530
  }
4720
5531
  } catch {
@@ -4728,39 +5539,23 @@ function writeRouteTypesFiles(state) {
4728
5539
  if (!sourceFile) continue;
4729
5540
  if (sourceFile.includes("node_modules")) {
4730
5541
  throw new Error(
4731
- `[rsc-router] Router "${id}" has sourceFile inside node_modules: ${sourceFile}
5542
+ `[rango] Router "${id}" has sourceFile inside node_modules: ${sourceFile}
4732
5543
  This means createRouter() stack trace parsing matched a Vite internal frame.
4733
5544
  Set an explicit \`id\` on createRouter() or check the call site.`
4734
5545
  );
4735
5546
  }
4736
- const routerDir = dirname3(sourceFile);
4737
- const routerBasename = basename(sourceFile).replace(/\.(tsx?|jsx?)$/, "");
4738
- const outPath = join2(routerDir, `${routerBasename}.named-routes.gen.ts`);
5547
+ const outPath = genFileTsPath(sourceFile);
4739
5548
  const userRoutes = filterUserNamedRoutes(routeManifest);
4740
- let effectiveSearchSchemas = routeSearchSchemas;
4741
- if ((!effectiveSearchSchemas || Object.keys(effectiveSearchSchemas).length === 0) && sourceFile) {
4742
- const staticParsed = buildCombinedRouteMapForRouterFile(sourceFile);
4743
- if (Object.keys(staticParsed.searchSchemas).length > 0) {
4744
- const filtered = {};
4745
- for (const name of Object.keys(userRoutes)) {
4746
- const schema = staticParsed.searchSchemas[name];
4747
- if (schema) filtered[name] = schema;
4748
- }
4749
- if (Object.keys(filtered).length > 0) {
4750
- effectiveSearchSchemas = filtered;
4751
- }
4752
- }
4753
- }
5549
+ const effectiveSearchSchemas = resolveSearchSchemas(
5550
+ Object.keys(userRoutes),
5551
+ routeSearchSchemas,
5552
+ sourceFile
5553
+ );
4754
5554
  const source = generateRouteTypesSource(
4755
5555
  userRoutes,
4756
5556
  effectiveSearchSchemas && Object.keys(effectiveSearchSchemas).length > 0 ? effectiveSearchSchemas : void 0
4757
5557
  );
4758
- const existing = existsSync5(outPath) ? readFileSync4(outPath, "utf-8") : null;
4759
- if (existing !== source) {
4760
- markSelfGenWrite(state, outPath, source);
4761
- writeFileSync3(outPath, source);
4762
- console.log(`[rsc-router] Generated route types -> ${outPath}`);
4763
- }
5558
+ writeGenFileIfChanged(state, outPath, source, { log: true });
4764
5559
  }
4765
5560
  }
4766
5561
  function supplementGenFilesWithRuntimeRoutes(state) {
@@ -4798,23 +5593,17 @@ function supplementGenFilesWithRuntimeRoutes(state) {
4798
5593
  }
4799
5594
  }
4800
5595
  }
4801
- const routerDir = dirname3(sourceFile);
4802
- const routerBasename = basename(sourceFile).replace(/\.(tsx?|jsx?)$/, "");
4803
- const outPath = join2(routerDir, `${routerBasename}.named-routes.gen.ts`);
5596
+ const outPath = genFileTsPath(sourceFile);
4804
5597
  const source = generateRouteTypesSource(
4805
5598
  mergedRoutes,
4806
5599
  Object.keys(mergedSearchSchemas).length > 0 ? mergedSearchSchemas : void 0
4807
5600
  );
4808
- const existing = existsSync5(outPath) ? readFileSync4(outPath, "utf-8") : null;
4809
- if (existing !== source) {
4810
- markSelfGenWrite(state, outPath, source);
4811
- writeFileSync3(outPath, source);
4812
- }
5601
+ writeGenFileIfChanged(state, outPath, source);
4813
5602
  }
4814
5603
  }
4815
5604
 
4816
5605
  // src/vite/discovery/virtual-module-codegen.ts
4817
- import { dirname as dirname4, basename as basename2, join as join3 } from "node:path";
5606
+ import { dirname as dirname4, basename, join as join4 } from "node:path";
4818
5607
  function generateRoutesManifestModule(state) {
4819
5608
  const hasManifest = state.mergedRouteManifest && Object.keys(state.mergedRouteManifest).length > 0;
4820
5609
  if (hasManifest) {
@@ -4825,11 +5614,11 @@ function generateRoutesManifestModule(state) {
4825
5614
  for (const entry of state.perRouterManifests) {
4826
5615
  if (entry.sourceFile) {
4827
5616
  const routerDir = dirname4(entry.sourceFile);
4828
- const routerBasename = basename2(entry.sourceFile).replace(
5617
+ const routerBasename = basename(entry.sourceFile).replace(
4829
5618
  /\.(tsx?|jsx?)$/,
4830
5619
  ""
4831
5620
  );
4832
- const genPath = join3(
5621
+ const genPath = join4(
4833
5622
  routerDir,
4834
5623
  `${routerBasename}.named-routes.gen.js`
4835
5624
  ).replaceAll("\\", "/");
@@ -4846,7 +5635,7 @@ function generateRoutesManifestModule(state) {
4846
5635
  }
4847
5636
  }
4848
5637
  const lines = [
4849
- `import { setCachedManifest, setPrecomputedEntries, setRouteTrie, setRouterManifest, registerRouterManifestLoader, clearAllRouterData } from "@rangojs/router/server";`,
5638
+ `import { setCachedManifest, setRouterManifest, registerRouterManifestLoader, clearAllRouterData } from "@rangojs/router/server";`,
4850
5639
  ...genFileImports,
4851
5640
  // Clear stale per-router cached data (manifest, trie, precomputed entries)
4852
5641
  // before re-populating. In Cloudflare dev mode, program reloads re-evaluate
@@ -4882,18 +5671,6 @@ function generateRoutesManifestModule(state) {
4882
5671
  );
4883
5672
  }
4884
5673
  }
4885
- if (state.isBuildMode) {
4886
- if (state.mergedPrecomputedEntries && state.mergedPrecomputedEntries.length > 0) {
4887
- lines.push(
4888
- `setPrecomputedEntries(${jsonParseExpression(state.mergedPrecomputedEntries)});`
4889
- );
4890
- }
4891
- if (state.mergedRouteTrie) {
4892
- lines.push(
4893
- `setRouteTrie(${jsonParseExpression(state.mergedRouteTrie)});`
4894
- );
4895
- }
4896
- }
4897
5674
  for (const routerId of state.perRouterManifestDataMap.keys()) {
4898
5675
  lines.push(
4899
5676
  `registerRouterManifestLoader(${JSON.stringify(routerId)}, () => import(${JSON.stringify(VIRTUAL_ROUTES_MANIFEST_ID + "/" + routerId)}));`
@@ -4922,11 +5699,11 @@ function generatePerRouterModule(state, routerId) {
4922
5699
  const lines = [];
4923
5700
  if (routerEntry?.sourceFile) {
4924
5701
  const routerDir = dirname4(routerEntry.sourceFile);
4925
- const routerBasename = basename2(routerEntry.sourceFile).replace(
5702
+ const routerBasename = basename(routerEntry.sourceFile).replace(
4926
5703
  /\.(tsx?|jsx?)$/,
4927
5704
  ""
4928
5705
  );
4929
- const genPath = join3(
5706
+ const genPath = join4(
4930
5707
  routerDir,
4931
5708
  `${routerBasename}.named-routes.gen.js`
4932
5709
  ).replaceAll("\\", "/");
@@ -4949,7 +5726,7 @@ function generatePerRouterModule(state, routerId) {
4949
5726
  `export const precomputedEntries = ${jsonParseExpression(entries)};`
4950
5727
  );
4951
5728
  }
4952
- return lines.join("\n") || "// empty router manifest";
5729
+ return lines.join("\n") || "";
4953
5730
  }
4954
5731
 
4955
5732
  // src/vite/discovery/bundle-postprocess.ts
@@ -4993,12 +5770,12 @@ function postprocessBundle(state) {
4993
5770
  writeFileSync4(chunkPath, result.code);
4994
5771
  const savedKB = (result.savedBytes / 1024).toFixed(1);
4995
5772
  console.log(
4996
- `[rsc-router] Evicted ${target.label} (${savedKB} KB saved): ${info.fileName}`
5773
+ `[rango] Evicted ${target.label} (${savedKB} KB saved): ${info.fileName}`
4997
5774
  );
4998
5775
  }
4999
5776
  } catch (replaceErr) {
5000
5777
  console.warn(
5001
- `[rsc-router] Failed to evict ${target.label}: ${replaceErr.message}`
5778
+ `[rango] Failed to evict ${target.label}: ${replaceErr.message}`
5002
5779
  );
5003
5780
  }
5004
5781
  }
@@ -5020,7 +5797,7 @@ function postprocessBundle(state) {
5020
5797
  manifestMap[key] = `./assets/${assetFileName}`;
5021
5798
  }
5022
5799
  const manifestCode = [
5023
- `const m=JSON.parse('${JSON.stringify(manifestMap).replace(/'/g, "\\'")}');`,
5800
+ `const m=${jsonParseExpression(manifestMap)};`,
5024
5801
  `export function loadPrerenderAsset(s){return import(s)}`,
5025
5802
  `export default m;`,
5026
5803
  ""
@@ -5036,11 +5813,11 @@ function postprocessBundle(state) {
5036
5813
  writeFileSync4(rscEntryPath, injection + rscCode);
5037
5814
  const totalKB = (totalBytes / 1024).toFixed(1);
5038
5815
  console.log(
5039
- `[rsc-router] Wrote prerender assets (${totalKB} KB total, ${Object.keys(state.prerenderManifestEntries).length} entries)`
5816
+ `[rango] Wrote prerender assets (${totalKB} KB total, ${Object.keys(state.prerenderManifestEntries).length} entries)`
5040
5817
  );
5041
5818
  } catch (err) {
5042
5819
  throw new Error(
5043
- `[rsc-router] Failed to write prerender assets: ${err.message}`
5820
+ `[rango] Failed to write prerender assets: ${err.message}`
5044
5821
  );
5045
5822
  }
5046
5823
  }
@@ -5074,11 +5851,11 @@ function postprocessBundle(state) {
5074
5851
  writeFileSync4(rscEntryPath, injection + rscCode);
5075
5852
  const totalKB = (totalBytes / 1024).toFixed(1);
5076
5853
  console.log(
5077
- `[rsc-router] Wrote static assets (${totalKB} KB total, ${Object.keys(state.staticManifestEntries).length} entries)`
5854
+ `[rango] Wrote static assets (${totalKB} KB total, ${Object.keys(state.staticManifestEntries).length} entries)`
5078
5855
  );
5079
5856
  } catch (err) {
5080
5857
  throw new Error(
5081
- `[rsc-router] Failed to write static assets: ${err.message}`
5858
+ `[rango] Failed to write static assets: ${err.message}`
5082
5859
  );
5083
5860
  }
5084
5861
  }
@@ -5159,6 +5936,57 @@ function createDiscoveryGate(s, debug11) {
5159
5936
  };
5160
5937
  }
5161
5938
 
5939
+ // src/vite/utils/forward-user-plugins.ts
5940
+ function isDenied(name) {
5941
+ return name.startsWith("vite:") || name === "rsc" || name.startsWith("rsc:") || name.startsWith("@rangojs/router") || name.startsWith("@cloudflare/vite-plugin") || name.startsWith("vite-plugin-cloudflare");
5942
+ }
5943
+ function hasResolutionHooks(p) {
5944
+ return Boolean(p.resolveId || p.load);
5945
+ }
5946
+ function stripToResolutionHooks(p) {
5947
+ const stripped = { name: p.name };
5948
+ if (p.enforce) stripped.enforce = p.enforce;
5949
+ if (p.applyToEnvironment)
5950
+ stripped.applyToEnvironment = p.applyToEnvironment;
5951
+ if (p.resolveId) stripped.resolveId = p.resolveId;
5952
+ if (p.load) stripped.load = p.load;
5953
+ return stripped;
5954
+ }
5955
+ function selectForwardableResolvePlugins(plugins) {
5956
+ if (!plugins) return [];
5957
+ const forwarded = [];
5958
+ for (const p of plugins) {
5959
+ const name = p?.name;
5960
+ if (!name || isDenied(name)) continue;
5961
+ if (!hasResolutionHooks(p)) continue;
5962
+ forwarded.push(stripToResolutionHooks(p));
5963
+ }
5964
+ return forwarded;
5965
+ }
5966
+ function pickForwardedRunnerConfig(config) {
5967
+ const r = config.resolve ?? {};
5968
+ const resolve10 = {};
5969
+ if (r.alias !== void 0) resolve10.alias = r.alias;
5970
+ if (r.dedupe !== void 0) resolve10.dedupe = r.dedupe;
5971
+ if (r.conditions !== void 0) resolve10.conditions = r.conditions;
5972
+ if (r.mainFields !== void 0) resolve10.mainFields = r.mainFields;
5973
+ if (r.extensions !== void 0) resolve10.extensions = r.extensions;
5974
+ if (r.preserveSymlinks !== void 0)
5975
+ resolve10.preserveSymlinks = r.preserveSymlinks;
5976
+ if (r.tsconfigPaths !== void 0) resolve10.tsconfigPaths = r.tsconfigPaths;
5977
+ const userOxc = config.oxc;
5978
+ const userJsx = userOxc && typeof userOxc === "object" && typeof userOxc.jsx === "object" && userOxc.jsx !== null ? userOxc.jsx : {};
5979
+ const oxc = userOxc && typeof userOxc === "object" ? {
5980
+ ...userOxc,
5981
+ jsx: { ...userJsx, runtime: "automatic", importSource: "react" }
5982
+ } : { jsx: { runtime: "automatic", importSource: "react" } };
5983
+ return {
5984
+ resolve: resolve10,
5985
+ define: config.define,
5986
+ oxc
5987
+ };
5988
+ }
5989
+
5162
5990
  // src/vite/router-discovery.ts
5163
5991
  var debugDiscovery = createRangoDebugger(NS.discovery);
5164
5992
  var debugRoutes = createRangoDebugger(NS.routes);
@@ -5174,21 +6002,29 @@ function ensureCloudflareProtocolLoaderRegistered() {
5174
6002
  );
5175
6003
  } catch (err) {
5176
6004
  console.warn(
5177
- `[rsc-router] Could not register Node ESM loader hook for cloudflare:* imports (${err?.message ?? err}). Falling back to Vite transform only.`
6005
+ `[rango] Could not register Node ESM loader hook for cloudflare:* imports (${err?.message ?? err}). Falling back to Vite transform only.`
5178
6006
  );
5179
6007
  }
5180
6008
  }
5181
6009
  async function createTempRscServer(state, options = {}) {
5182
6010
  ensureCloudflareProtocolLoaderRegistered();
5183
6011
  const { default: rsc } = await import("@vitejs/plugin-rsc");
6012
+ const runnerConfig = state.userRunnerConfig;
6013
+ const resolveConfig = runnerConfig?.resolve ?? {
6014
+ alias: state.userResolveAlias
6015
+ };
6016
+ const oxcConfig = runnerConfig?.oxc ?? {
6017
+ jsx: { runtime: "automatic", importSource: "react" }
6018
+ };
5184
6019
  return createViteServer({
5185
6020
  root: state.projectRoot,
5186
6021
  configFile: false,
5187
6022
  server: { middlewareMode: true },
5188
6023
  appType: "custom",
5189
6024
  logLevel: "silent",
5190
- resolve: { alias: state.userResolveAlias },
5191
- esbuild: { jsx: "automatic", jsxImportSource: "react" },
6025
+ resolve: resolveConfig,
6026
+ ...runnerConfig?.define ? { define: runnerConfig.define } : {},
6027
+ oxc: oxcConfig,
5192
6028
  ...options.cacheDir && { cacheDir: options.cacheDir },
5193
6029
  plugins: [
5194
6030
  rsc({
@@ -5206,7 +6042,11 @@ async function createTempRscServer(state, options = {}) {
5206
6042
  // Dev prerender must use dev-mode IDs (path-based) to match the workerd
5207
6043
  // runtime. forceBuild produces hashed IDs for production bundle consistency.
5208
6044
  exposeInternalIds(options.forceBuild ? { forceBuild: true } : void 0),
5209
- exposeRouterId()
6045
+ exposeRouterId(),
6046
+ // Forwarded user resolution plugins (e.g. vite-tsconfig-paths). Stripped
6047
+ // to resolveId/load and placed last so framework resolution runs first;
6048
+ // Vite re-sorts by `enforce`, so `enforce: "pre"` resolvers still lead.
6049
+ ...state.userResolvePlugins
5210
6050
  ]
5211
6051
  });
5212
6052
  }
@@ -5215,7 +6055,7 @@ async function resolveBuildEnv(option, factoryCtx) {
5215
6055
  if (option === "auto") {
5216
6056
  if (factoryCtx.preset !== "cloudflare") {
5217
6057
  throw new Error(
5218
- '[rsc-router] buildEnv: "auto" is only supported with preset: "cloudflare". Use a factory function or plain object for other presets.'
6058
+ '[rango] buildEnv: "auto" is only supported with preset: "cloudflare". Use a factory function or plain object for other presets.'
5219
6059
  );
5220
6060
  }
5221
6061
  try {
@@ -5231,7 +6071,7 @@ async function resolveBuildEnv(option, factoryCtx) {
5231
6071
  };
5232
6072
  } catch (err) {
5233
6073
  throw new Error(
5234
- `[rsc-router] buildEnv: "auto" requires wrangler to be installed.
6074
+ `[rango] buildEnv: "auto" requires wrangler to be installed.
5235
6075
  Install it with: pnpm add -D wrangler
5236
6076
  ${err.message}`
5237
6077
  );
@@ -5262,7 +6102,7 @@ async function releaseBuildEnv(s) {
5262
6102
  try {
5263
6103
  await s.buildEnvDispose();
5264
6104
  } catch (err) {
5265
- console.warn(`[rsc-router] buildEnv dispose failed: ${err.message}`);
6105
+ console.warn(`[rango] buildEnv dispose failed: ${err.message}`);
5266
6106
  }
5267
6107
  s.buildEnvDispose = null;
5268
6108
  }
@@ -5275,31 +6115,31 @@ function createRouterDiscoveryPlugin(entryPath, opts) {
5275
6115
  let viteMode = "production";
5276
6116
  return {
5277
6117
  name: "@rangojs/router:discovery",
5278
- config() {
5279
- const config = {
5280
- define: {
5281
- __RANGO_DEBUG__: JSON.stringify(!!process.env.INTERNAL_RANGO_DEBUG)
5282
- }
5283
- };
5284
- return config;
6118
+ // Make INTERNAL_RANGO_DEBUG reach the CLIENT debug logs by just setting the
6119
+ // env var. See injectClientDebugFlag: bakes the resolved flag into the
6120
+ // internal-debug module so FE debug no longer depends on Vite delivering the
6121
+ // `__RANGO_DEBUG__` define to the client (which it does only as an injected
6122
+ // global whose presence varies across consumer setups). Runs in dev and build.
6123
+ transform(_code, id) {
6124
+ return injectClientDebugFlag(id);
5285
6125
  },
5286
6126
  configResolved(config) {
5287
6127
  s.projectRoot = config.root;
6128
+ s.scanFilter = opts?.discovery ? createScanFilter(s.projectRoot, opts.discovery) : void 0;
5288
6129
  s.isBuildMode = config.command === "build";
5289
6130
  viteCommand = config.command;
5290
6131
  viteMode = config.mode;
5291
6132
  s.userResolveAlias = config.resolve.alias;
6133
+ s.userRunnerConfig = pickForwardedRunnerConfig(config);
6134
+ s.userResolvePlugins = selectForwardableResolvePlugins(
6135
+ config.plugins
6136
+ );
5292
6137
  if (!s.resolvedEntryPath && opts?.routerPathRef?.path) {
5293
6138
  s.resolvedEntryPath = opts.routerPathRef.path;
5294
6139
  }
5295
6140
  if (!s.resolvedEntryPath) {
5296
- const rscEnvConfig = config.environments?.["rsc"];
5297
- const entries = rscEnvConfig?.optimizeDeps?.entries;
5298
- if (typeof entries === "string") {
5299
- s.resolvedEntryPath = entries;
5300
- } else if (Array.isArray(entries) && entries.length > 0) {
5301
- s.resolvedEntryPath = entries[0];
5302
- }
6141
+ const entry = resolveRscEntryFromConfig(config);
6142
+ if (entry) s.resolvedEntryPath = entry;
5303
6143
  }
5304
6144
  if (opts?.staticRouteTypesGeneration !== false) {
5305
6145
  s.cachedRouterFiles = findRouterFiles(s.projectRoot, s.scanFilter);
@@ -5426,9 +6266,7 @@ function createRouterDiscoveryPlugin(entryPath, opts) {
5426
6266
  "getOrCreateTempServer: FAILED message=%s",
5427
6267
  err.message
5428
6268
  );
5429
- console.warn(
5430
- `[rsc-router] Failed to create temp runner: ${err.message}`
5431
- );
6269
+ console.warn(`[rango] Failed to create temp runner: ${err.message}`);
5432
6270
  }
5433
6271
  return null;
5434
6272
  }
@@ -5515,7 +6353,7 @@ function createRouterDiscoveryPlugin(entryPath, opts) {
5515
6353
  }
5516
6354
  } catch (err) {
5517
6355
  console.warn(
5518
- `[rsc-router] Cloudflare dev discovery failed: ${err.message}
6356
+ `[rango] Cloudflare dev discovery failed: ${err.message}
5519
6357
  ${err.stack}`
5520
6358
  );
5521
6359
  }
@@ -5559,7 +6397,7 @@ ${err.stack}`
5559
6397
  );
5560
6398
  } catch (err) {
5561
6399
  console.warn(
5562
- `[rsc-router] Router discovery failed: ${err.message}
6400
+ `[rango] Router discovery failed: ${err.message}
5563
6401
  ${err.stack}`
5564
6402
  );
5565
6403
  } finally {
@@ -5592,20 +6430,15 @@ ${err.stack}`
5592
6430
  if (s.mergedRouteTrie && serverMod.setRouteTrie) {
5593
6431
  serverMod.setRouteTrie(s.mergedRouteTrie);
5594
6432
  }
5595
- if (serverMod.setRouterManifest) {
5596
- for (const [routerId, manifest] of s.perRouterManifestDataMap) {
5597
- serverMod.setRouterManifest(routerId, manifest);
5598
- }
5599
- }
5600
- if (serverMod.setRouterTrie) {
5601
- for (const [routerId, trie] of s.perRouterTrieMap) {
5602
- serverMod.setRouterTrie(routerId, trie);
5603
- }
5604
- }
5605
- if (serverMod.setRouterPrecomputedEntries) {
5606
- for (const [routerId, entries] of s.perRouterPrecomputedMap) {
5607
- serverMod.setRouterPrecomputedEntries(routerId, entries);
5608
- }
6433
+ const perRouterSetters = [
6434
+ [s.perRouterManifestDataMap, "setRouterManifest"],
6435
+ [s.perRouterTrieMap, "setRouterTrie"],
6436
+ [s.perRouterPrecomputedMap, "setRouterPrecomputedEntries"]
6437
+ ];
6438
+ for (const [map, fn] of perRouterSetters) {
6439
+ const setter = serverMod[fn];
6440
+ if (typeof setter !== "function") continue;
6441
+ for (const [routerId, value] of map) setter(routerId, value);
5609
6442
  }
5610
6443
  };
5611
6444
  server.middlewares.use("/__rsc_prerender", async (req, res) => {
@@ -5639,7 +6472,7 @@ ${err.stack}`
5639
6472
  registry = serverMod.RouterRegistry ?? null;
5640
6473
  } catch (err) {
5641
6474
  console.warn(
5642
- `[rsc-router] Dev prerender module refresh failed: ${err.message}`
6475
+ `[rango] Dev prerender module refresh failed: ${err.message}`
5643
6476
  );
5644
6477
  res.statusCode = 500;
5645
6478
  res.end(`Prerender handler error: ${err.message}`);
@@ -5684,10 +6517,9 @@ ${err.stack}`
5684
6517
  if (wantIntercept && result.interceptSegments?.length) {
5685
6518
  payload = {
5686
6519
  segments: [...result.segments, ...result.interceptSegments],
5687
- handles: {
5688
- ...result.handles,
5689
- ...result.interceptHandles || {}
5690
- }
6520
+ // Pre-encoded MERGED handle string from the producer (handles are
6521
+ // Flight-encoded so Promise/ReactNode values survive the wire).
6522
+ handles: result.interceptHandles ?? ""
5691
6523
  };
5692
6524
  } else {
5693
6525
  payload = { segments: result.segments, handles: result.handles };
@@ -5696,9 +6528,11 @@ ${err.stack}`
5696
6528
  logResult(200, `match ${result.routeName}`);
5697
6529
  return;
5698
6530
  } catch (err) {
5699
- console.warn(
5700
- `[rsc-router] Dev prerender failed for ${pathname}: ${err.message}`
5701
- );
6531
+ if (err?.name !== "Skip") {
6532
+ console.warn(
6533
+ `[rango] Dev prerender error for ${pathname} (serving live instead): ${err.message}`
6534
+ );
6535
+ }
5702
6536
  }
5703
6537
  }
5704
6538
  res.statusCode = 404;
@@ -5768,9 +6602,25 @@ ${err.stack}`
5768
6602
  () => writeRouteTypesFiles(s)
5769
6603
  );
5770
6604
  }
6605
+ if (s.lastDiscoveryError) {
6606
+ debugDiscovery?.(
6607
+ "hmr: cleared lastDiscoveryError (%s) after successful rediscovery",
6608
+ s.lastDiscoveryError.message
6609
+ );
6610
+ s.lastDiscoveryError = null;
6611
+ }
6612
+ if (rscEnv && !rscEnv.runner) forceCloudflareWorkerReload(rscEnv);
5771
6613
  } catch (err) {
6614
+ s.lastDiscoveryError = {
6615
+ message: err?.message ?? String(err),
6616
+ at: Date.now()
6617
+ };
5772
6618
  console.warn(
5773
- `[rsc-router] Runtime re-discovery failed: ${err.message}`
6619
+ `[rango] Runtime re-discovery failed: ${err.message}`
6620
+ );
6621
+ debugDiscovery?.(
6622
+ "hmr: lastDiscoveryError set (%s) \u2014 manifest preserved at last-good; recovery mode active (any in-scan source change will trigger rediscovery)",
6623
+ err?.message
5774
6624
  );
5775
6625
  } finally {
5776
6626
  debugDiscovery?.(
@@ -5780,6 +6630,25 @@ ${err.stack}`
5780
6630
  }
5781
6631
  });
5782
6632
  };
6633
+ const forceCloudflareWorkerReload = (rscEnv) => {
6634
+ if (!rscEnv?.hot) return;
6635
+ try {
6636
+ const graph = rscEnv.moduleGraph;
6637
+ if (graph?.invalidateAll) {
6638
+ graph.invalidateAll();
6639
+ debugDiscovery?.("hmr: invalidated workerd rsc module graph");
6640
+ }
6641
+ rscEnv.hot.send({ type: "full-reload" });
6642
+ debugDiscovery?.(
6643
+ "hmr: forced workerd rsc env reload (full-reload)"
6644
+ );
6645
+ } catch (err) {
6646
+ debugDiscovery?.(
6647
+ "hmr: workerd reload failed: %s",
6648
+ err?.message ?? err
6649
+ );
6650
+ }
6651
+ };
5783
6652
  const scheduleRouteRegeneration = () => {
5784
6653
  clearTimeout(routeChangeTimer);
5785
6654
  routeChangeTimer = setTimeout(() => {
@@ -5799,9 +6668,7 @@ ${err.stack}`
5799
6668
  }
5800
6669
  }
5801
6670
  } catch (err) {
5802
- console.error(
5803
- `[rsc-router] Route regeneration error: ${err.message}`
5804
- );
6671
+ console.error(`[rango] Route regeneration error: ${err.message}`);
5805
6672
  }
5806
6673
  debugDiscovery?.(
5807
6674
  "watcher: regenerated gen files (%sms)",
@@ -5810,7 +6677,7 @@ ${err.stack}`
5810
6677
  if (s.perRouterManifests.length > 0) {
5811
6678
  refreshRuntimeDiscovery().catch((err) => {
5812
6679
  console.warn(
5813
- `[rsc-router] Runtime re-discovery error: ${err.message}`
6680
+ `[rango] Runtime re-discovery error: ${err.message}`
5814
6681
  );
5815
6682
  resolveDiscoveryGate();
5816
6683
  });
@@ -5819,23 +6686,56 @@ ${err.stack}`
5819
6686
  };
5820
6687
  const handleRouteFileChange = (filePath) => {
5821
6688
  if (maybeHandleGeneratedRouteFileMutation(filePath)) return;
5822
- if (!filePath.endsWith(".ts") && !filePath.endsWith(".tsx") && !filePath.endsWith(".js") && !filePath.endsWith(".jsx"))
6689
+ if (!filePath.endsWith(".ts") && !filePath.endsWith(".tsx") && !filePath.endsWith(".js") && !filePath.endsWith(".jsx")) {
6690
+ if (s.lastDiscoveryError) {
6691
+ debugDiscovery?.(
6692
+ "watcher: skip non-source %s [LASTERR %s]",
6693
+ filePath,
6694
+ s.lastDiscoveryError.message
6695
+ );
6696
+ }
5823
6697
  return;
5824
- if (s.scanFilter && !s.scanFilter(filePath)) return;
6698
+ }
6699
+ if (s.scanFilter && !s.scanFilter(filePath)) {
6700
+ if (s.lastDiscoveryError) {
6701
+ debugDiscovery?.(
6702
+ "watcher: skip scan-filter %s [LASTERR %s]",
6703
+ filePath,
6704
+ s.lastDiscoveryError.message
6705
+ );
6706
+ }
6707
+ return;
6708
+ }
6709
+ const inRecoveryMode = !!s.lastDiscoveryError;
5825
6710
  try {
5826
6711
  const source = readFileSync6(filePath, "utf-8");
5827
6712
  const trimmed = source.trimStart();
5828
- if (trimmed.startsWith('"use client"') || trimmed.startsWith("'use client'"))
5829
- return;
5830
- const hasUrls = source.includes("urls(");
5831
- const hasCreateRouter = /\bcreateRouter\s*[<(]/.test(source);
5832
- if (!hasUrls && !hasCreateRouter) return;
5833
- debugDiscovery?.(
5834
- "watcher: %s matches (urls=%s, router=%s)",
5835
- filePath,
5836
- hasUrls,
5837
- hasCreateRouter
5838
- );
6713
+ const isUseClient = trimmed.startsWith('"use client"') || trimmed.startsWith("'use client'");
6714
+ if (!inRecoveryMode && isUseClient) return;
6715
+ let hasUrls = source.includes("urls(");
6716
+ let hasCreateRouter = /\bcreateRouter\s*[<(]/.test(source);
6717
+ if (hasUrls) hasUrls = firstCodeMatchIndex(source, /urls\(/g) >= 0;
6718
+ if (hasCreateRouter) {
6719
+ hasCreateRouter = firstCodeMatchIndex(source, /\bcreateRouter\s*[<(]/g) >= 0;
6720
+ }
6721
+ if (!inRecoveryMode && !hasUrls && !hasCreateRouter) return;
6722
+ if (inRecoveryMode) {
6723
+ debugDiscovery?.(
6724
+ "watcher: recovery rediscovery for %s (urls=%s, router=%s, useClient=%s) [LASTERR %s]",
6725
+ filePath,
6726
+ hasUrls,
6727
+ hasCreateRouter,
6728
+ isUseClient,
6729
+ s.lastDiscoveryError.message
6730
+ );
6731
+ } else {
6732
+ debugDiscovery?.(
6733
+ "watcher: %s matches (urls=%s, router=%s)",
6734
+ filePath,
6735
+ hasUrls,
6736
+ hasCreateRouter
6737
+ );
6738
+ }
5839
6739
  if (hasCreateRouter) {
5840
6740
  const nestedRouterConflict = findNestedRouterConflict([
5841
6741
  ...s.cachedRouterFiles ?? [],
@@ -5853,7 +6753,15 @@ ${err.stack}`
5853
6753
  gate.noteRouteEvent();
5854
6754
  }
5855
6755
  scheduleRouteRegeneration();
5856
- } catch {
6756
+ } catch (readErr) {
6757
+ if (s.lastDiscoveryError) {
6758
+ debugDiscovery?.(
6759
+ "watcher: read error %s: %s [LASTERR %s]",
6760
+ filePath,
6761
+ readErr?.message,
6762
+ s.lastDiscoveryError.message
6763
+ );
6764
+ }
5857
6765
  }
5858
6766
  };
5859
6767
  server.watcher.on("add", handleRouteFileChange);
@@ -5899,7 +6807,7 @@ ${err.stack}`
5899
6807
  const rscEnv = tempServer.environments?.rsc;
5900
6808
  if (!rscEnv?.runner) {
5901
6809
  console.warn(
5902
- "[rsc-router] RSC environment runner not available during build, skipping manifest generation"
6810
+ "[rango] RSC environment runner not available during build, skipping manifest generation"
5903
6811
  );
5904
6812
  return;
5905
6813
  }
@@ -5931,8 +6839,9 @@ ${err.stack}`
5931
6839
  ${err.stack}` : null
5932
6840
  ].filter(Boolean).join("\n");
5933
6841
  throw new Error(
5934
- `[rsc-router] Build-time router discovery failed:
5935
- ${details}`
6842
+ `[rango] Build-time router discovery failed:
6843
+ ${details}`,
6844
+ { cause: err }
5936
6845
  );
5937
6846
  } finally {
5938
6847
  delete globalThis.__rscRouterDiscoveryActive;
@@ -5960,7 +6869,7 @@ ${details}`
5960
6869
  // `consumeSelfGenWrite` inside `maybeHandleGeneratedRouteFileMutation`),
5961
6870
  // AND vite's own HMR pipeline (which invalidates the gen file's
5962
6871
  // importers and triggers a second workerd full reload — visible to the
5963
- // user as a duplicate "[RSCRouter] HMR: version changed" on the client).
6872
+ // user as a duplicate "[Rango] HMR: version changed" on the client).
5964
6873
  //
5965
6874
  // `peekSelfGenWrite` is the authoritative filter: its map only contains
5966
6875
  // paths that `markSelfGenWrite` has registered, so it natively works
@@ -6120,6 +7029,10 @@ async function rango(options) {
6120
7029
  const resolvedOptions = options ?? { preset: "node" };
6121
7030
  const preset = resolvedOptions.preset ?? "node";
6122
7031
  const showBanner = resolvedOptions.banner ?? true;
7032
+ const clientChunksOption = resolvedOptions.clientChunks ?? true;
7033
+ const useBuiltInClientChunks = clientChunksOption === true;
7034
+ const clientChunkCtx = useBuiltInClientChunks ? { fallbackRefs: /* @__PURE__ */ new Set() } : void 0;
7035
+ const clientChunks = resolveClientChunks(clientChunksOption, clientChunkCtx);
6123
7036
  debugConfig?.("rango(%s) setup start", preset);
6124
7037
  const plugins = [];
6125
7038
  const rangoAliases = { ...getPackageAliases(), ...getVendorAliases() };
@@ -6151,14 +7064,20 @@ async function rango(options) {
6151
7064
  enforce: "pre",
6152
7065
  config() {
6153
7066
  return {
6154
- // Exclude rsc-router modules from optimization to prevent module duplication
6155
- // This ensures the same Context instance is used by both browser entry and RSC proxy modules
6156
7067
  optimizeDeps: {
6157
7068
  exclude: excludeDeps,
6158
- esbuildOptions: sharedEsbuildOptions
7069
+ rolldownOptions: sharedRolldownOptions
6159
7070
  },
6160
7071
  resolve: {
6161
- alias: rangoAliases
7072
+ alias: rangoAliases,
7073
+ // Force a single React/React-DOM copy across all three RSC
7074
+ // environments. RSC requires exactly one react/react-dom instance
7075
+ // per environment runtime; consumer install topologies (pnpm
7076
+ // strict layout, experimental React pins, third-party "use client"
7077
+ // packages) can otherwise resolve duplicate copies, causing
7078
+ // "Invalid hook call" / lost context. Child environments inherit
7079
+ // this root dedupe, and Vite merges it with any consumer dedupe.
7080
+ dedupe: ["react", "react-dom"]
6162
7081
  },
6163
7082
  build: {
6164
7083
  rollupOptions: { onwarn }
@@ -6167,30 +7086,22 @@ async function rango(options) {
6167
7086
  client: {
6168
7087
  build: {
6169
7088
  rollupOptions: {
7089
+ onwarn,
6170
7090
  output: {
6171
7091
  manualChunks: getManualChunks
6172
7092
  }
6173
7093
  }
6174
7094
  },
6175
- // Pre-bundle rsc-html-stream to prevent discovery during first request
6176
- // Exclude rsc-router modules to ensure same Context instance
6177
7095
  optimizeDeps: {
6178
7096
  include: [nested("rsc-html-stream/client")],
6179
7097
  exclude: excludeDeps,
6180
- esbuildOptions: sharedEsbuildOptions
7098
+ rolldownOptions: sharedRolldownOptions
6181
7099
  }
6182
7100
  },
6183
7101
  ssr: {
6184
- // Build SSR inside RSC directory so wrangler can deploy self-contained dist/rsc
6185
7102
  build: {
6186
7103
  outDir: "./dist/rsc/ssr"
6187
7104
  },
6188
- resolve: {
6189
- // Ensure single React instance in SSR child environment
6190
- dedupe: ["react", "react-dom"]
6191
- },
6192
- // Pre-bundle SSR entry and React for proper module linking with childEnvironments
6193
- // All deps must be listed to avoid late discovery triggering ERR_OUTDATED_OPTIMIZED_DEP
6194
7105
  optimizeDeps: {
6195
7106
  entries: [finalEntries.ssr],
6196
7107
  include: [
@@ -6206,14 +7117,11 @@ async function rango(options) {
6206
7117
  )
6207
7118
  ],
6208
7119
  exclude: excludeDeps,
6209
- esbuildOptions: sharedEsbuildOptions
7120
+ rolldownOptions: sharedRolldownOptions
6210
7121
  }
6211
7122
  },
6212
7123
  rsc: {
6213
- // RSC environment needs exclude list and esbuild options
6214
- // Exclude rsc-router modules to prevent createContext in RSC environment
6215
7124
  optimizeDeps: {
6216
- // Pre-bundle all RSC deps to prevent late discovery triggering ERR_OUTDATED_OPTIMIZED_DEP
6217
7125
  include: [
6218
7126
  "react",
6219
7127
  "react/jsx-runtime",
@@ -6223,7 +7131,7 @@ async function rango(options) {
6223
7131
  )
6224
7132
  ],
6225
7133
  exclude: excludeDeps,
6226
- esbuildOptions: sharedEsbuildOptions
7134
+ rolldownOptions: sharedRolldownOptions
6227
7135
  }
6228
7136
  }
6229
7137
  }
@@ -6241,7 +7149,8 @@ async function rango(options) {
6241
7149
  plugins.push(
6242
7150
  rsc({
6243
7151
  entries: finalEntries,
6244
- serverHandler: false
7152
+ serverHandler: false,
7153
+ clientChunks
6245
7154
  })
6246
7155
  );
6247
7156
  plugins.push(clientRefDedup());
@@ -6259,7 +7168,7 @@ async function rango(options) {
6259
7168
  const list = candidates.map(
6260
7169
  (f) => " - " + (f.startsWith(root) ? f.slice(root.length + 1) : f)
6261
7170
  ).join("\n");
6262
- throw new Error(`[rsc-router] Multiple routers found:
7171
+ throw new Error(`[rango] Multiple routers found:
6263
7172
  ${list}`);
6264
7173
  }
6265
7174
  }
@@ -6278,18 +7187,27 @@ ${list}`);
6278
7187
  return {
6279
7188
  optimizeDeps: {
6280
7189
  exclude: excludeDeps,
6281
- esbuildOptions: sharedEsbuildOptions
7190
+ rolldownOptions: sharedRolldownOptions
6282
7191
  },
6283
7192
  build: {
6284
7193
  rollupOptions: { onwarn }
6285
7194
  },
6286
7195
  resolve: {
6287
- alias: rangoAliases
7196
+ alias: rangoAliases,
7197
+ // Force a single React/React-DOM copy across all three RSC
7198
+ // environments. RSC requires exactly one react/react-dom instance
7199
+ // per environment runtime; consumer install topologies (pnpm
7200
+ // strict layout, experimental React pins, third-party "use client"
7201
+ // packages) can otherwise resolve duplicate copies, causing
7202
+ // "Invalid hook call" / lost context. Child environments inherit
7203
+ // this root dedupe, and Vite merges it with any consumer dedupe.
7204
+ dedupe: ["react", "react-dom"]
6288
7205
  },
6289
7206
  environments: {
6290
7207
  client: {
6291
7208
  build: {
6292
7209
  rollupOptions: {
7210
+ onwarn,
6293
7211
  output: {
6294
7212
  manualChunks: getManualChunks
6295
7213
  }
@@ -6304,7 +7222,7 @@ ${list}`);
6304
7222
  nested("rsc-html-stream/client")
6305
7223
  ],
6306
7224
  exclude: excludeDeps,
6307
- esbuildOptions: sharedEsbuildOptions,
7225
+ rolldownOptions: sharedRolldownOptions,
6308
7226
  entries: [VIRTUAL_IDS.browser]
6309
7227
  }
6310
7228
  },
@@ -6323,7 +7241,7 @@ ${list}`);
6323
7241
  )
6324
7242
  ],
6325
7243
  exclude: excludeDeps,
6326
- esbuildOptions: sharedEsbuildOptions
7244
+ rolldownOptions: sharedRolldownOptions
6327
7245
  }
6328
7246
  },
6329
7247
  rsc: {
@@ -6337,7 +7255,13 @@ ${list}`);
6337
7255
  "@vitejs/plugin-rsc/vendor/react-server-dom/server.edge"
6338
7256
  )
6339
7257
  ],
6340
- esbuildOptions: sharedEsbuildOptions
7258
+ // Vite 8 does not propagate the top-level optimizeDeps.exclude
7259
+ // (set in config()) to non-client envs, so the rsc env must set
7260
+ // it explicitly — mirroring the node ssr env and the cloudflare
7261
+ // rsc env. Without it a strict-pnpm npm-installed app can try to
7262
+ // pre-bundle the router's own subpath entries and fail.
7263
+ exclude: excludeDeps,
7264
+ rolldownOptions: sharedRolldownOptions
6341
7265
  }
6342
7266
  }
6343
7267
  }
@@ -6354,7 +7278,7 @@ ${list}`);
6354
7278
  if (rscMinimalCount > 1 && !hasWarnedDuplicate) {
6355
7279
  hasWarnedDuplicate = true;
6356
7280
  console.warn(
6357
- "[rsc-router] Duplicate @vitejs/plugin-rsc detected. Remove rsc() from your vite config \u2014 rango() includes it automatically."
7281
+ "[rango] Duplicate @vitejs/plugin-rsc detected. Remove rsc() from your vite config \u2014 rango() includes it automatically."
6358
7282
  );
6359
7283
  }
6360
7284
  }
@@ -6363,7 +7287,8 @@ ${list}`);
6363
7287
  plugins.push(performanceTracksPlugin());
6364
7288
  plugins.push(
6365
7289
  rsc({
6366
- entries: finalEntries
7290
+ entries: finalEntries,
7291
+ clientChunks
6367
7292
  })
6368
7293
  );
6369
7294
  plugins.push(clientRefDedup());
@@ -6378,8 +7303,7 @@ ${list}`);
6378
7303
  return;
6379
7304
  try {
6380
7305
  const source = readFileSync7(file, "utf-8");
6381
- const trimmed = source.trimStart();
6382
- if (trimmed.startsWith('"use client"') || trimmed.startsWith("'use client'")) {
7306
+ if (hasUseClientDirective(source)) {
6383
7307
  return [];
6384
7308
  }
6385
7309
  } catch {
@@ -6402,7 +7326,10 @@ ${list}`);
6402
7326
  routerPathRef: discoveryRouterRef,
6403
7327
  enableBuildPrerender: prerenderEnabled,
6404
7328
  buildEnv: options?.buildEnv,
6405
- preset
7329
+ preset,
7330
+ prerenderOnError: options?.prerender?.onError,
7331
+ discovery: options?.discovery,
7332
+ clientChunkCtx
6406
7333
  })
6407
7334
  );
6408
7335
  debugConfig?.(
@@ -6417,7 +7344,7 @@ ${list}`);
6417
7344
  // src/vite/plugins/refresh-cmd.ts
6418
7345
  function poke() {
6419
7346
  return {
6420
- name: "vite-plugin-poke",
7347
+ name: "@rangojs/router:poke",
6421
7348
  apply: "serve",
6422
7349
  configureServer(server) {
6423
7350
  const stdin = process.stdin;