@rangojs/router 0.0.0-experimental.124 → 0.0.0-experimental.126

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 (235) hide show
  1. package/README.md +6 -4
  2. package/dist/bin/rango.js +3 -4
  3. package/dist/vite/index.js +315 -68
  4. package/package.json +19 -18
  5. package/skills/breadcrumbs/SKILL.md +60 -0
  6. package/skills/hooks/SKILL.md +2 -2
  7. package/skills/route/SKILL.md +6 -0
  8. package/skills/server-actions/SKILL.md +25 -1
  9. package/skills/testing/SKILL.md +17 -17
  10. package/skills/testing/cache-prerender.md +29 -3
  11. package/skills/testing/flight.md +13 -10
  12. package/skills/testing/render-handler.md +3 -0
  13. package/skills/testing/server-tree.md +1 -1
  14. package/skills/testing/setup.md +1 -1
  15. package/src/__internal.ts +0 -65
  16. package/src/browser/action-coordinator.ts +1 -1
  17. package/src/browser/action-fence.ts +10 -0
  18. package/src/browser/event-controller.ts +1 -83
  19. package/src/browser/navigation-store-handle.ts +3 -4
  20. package/src/browser/navigation-store.ts +0 -39
  21. package/src/browser/navigation-transaction.ts +0 -32
  22. package/src/browser/partial-update.ts +23 -84
  23. package/src/browser/prefetch/cache.ts +6 -45
  24. package/src/browser/prefetch/queue.ts +6 -3
  25. package/src/browser/rango-state.ts +2 -23
  26. package/src/browser/react/Link.tsx +0 -2
  27. package/src/browser/react/NavigationProvider.tsx +2 -1
  28. package/src/browser/react/ScrollRestoration.tsx +10 -6
  29. package/src/browser/react/filter-segment-order.ts +0 -2
  30. package/src/browser/react/index.ts +0 -45
  31. package/src/browser/react/location-state-shared.ts +0 -13
  32. package/src/browser/react/location-state.ts +0 -1
  33. package/src/browser/react/use-action.ts +6 -15
  34. package/src/browser/react/use-handle.ts +0 -5
  35. package/src/browser/react/use-link-status.ts +0 -4
  36. package/src/browser/react/use-navigation.ts +0 -3
  37. package/src/browser/react/use-params.ts +0 -2
  38. package/src/browser/react/use-router.ts +2 -1
  39. package/src/browser/react/use-search-params.ts +0 -5
  40. package/src/browser/react/use-segments.ts +0 -13
  41. package/src/browser/rsc-router.tsx +10 -3
  42. package/src/browser/server-action-bridge.ts +51 -3
  43. package/src/browser/types.ts +23 -5
  44. package/src/browser/validate-redirect-origin.ts +43 -16
  45. package/src/build/index.ts +8 -9
  46. package/src/build/route-trie.ts +46 -11
  47. package/src/build/route-types/param-extraction.ts +6 -3
  48. package/src/build/route-types/router-processing.ts +0 -8
  49. package/src/cache/cache-policy.ts +0 -54
  50. package/src/cache/cache-runtime.ts +48 -24
  51. package/src/cache/cache-scope.ts +0 -27
  52. package/src/cache/cache-tag.ts +0 -37
  53. package/src/cache/cf/cf-cache-store.ts +72 -45
  54. package/src/cache/cf/index.ts +0 -24
  55. package/src/cache/document-cache.ts +10 -36
  56. package/src/cache/handle-snapshot.ts +0 -40
  57. package/src/cache/index.ts +0 -27
  58. package/src/cache/memory-segment-store.ts +0 -52
  59. package/src/cache/profile-registry.ts +6 -30
  60. package/src/cache/read-through-swr.ts +41 -11
  61. package/src/cache/segment-codec.ts +0 -16
  62. package/src/cache/types.ts +0 -98
  63. package/src/client.rsc.tsx +4 -22
  64. package/src/client.tsx +19 -32
  65. package/src/context-var.ts +12 -0
  66. package/src/defer.ts +196 -0
  67. package/src/deps/ssr.ts +0 -1
  68. package/src/handle.ts +2 -12
  69. package/src/handles/MetaTags.tsx +0 -14
  70. package/src/handles/breadcrumbs.ts +16 -5
  71. package/src/handles/meta.ts +0 -39
  72. package/src/host/cookie-handler.ts +0 -36
  73. package/src/host/errors.ts +0 -24
  74. package/src/host/index.ts +6 -0
  75. package/src/host/pattern-matcher.ts +7 -50
  76. package/src/host/router.ts +1 -65
  77. package/src/host/testing.ts +0 -16
  78. package/src/host/types.ts +6 -2
  79. package/src/href-client.ts +0 -4
  80. package/src/index.rsc.ts +27 -2
  81. package/src/index.ts +7 -0
  82. package/src/internal-debug.ts +2 -4
  83. package/src/loader.rsc.ts +4 -15
  84. package/src/loader.ts +3 -9
  85. package/src/network-error-thrower.tsx +1 -6
  86. package/src/outlet-provider.tsx +1 -5
  87. package/src/prerender/param-hash.ts +10 -11
  88. package/src/prerender/store.ts +23 -30
  89. package/src/prerender.ts +34 -0
  90. package/src/redirect-origin.ts +100 -0
  91. package/src/root-error-boundary.tsx +1 -19
  92. package/src/route-content-wrapper.tsx +1 -44
  93. package/src/route-definition/dsl-helpers.ts +7 -19
  94. package/src/route-definition/helpers-types.ts +3 -3
  95. package/src/route-definition/redirect.ts +43 -9
  96. package/src/route-definition/resolve-handler-use.ts +6 -0
  97. package/src/route-map-builder.ts +0 -16
  98. package/src/router/content-negotiation.ts +0 -13
  99. package/src/router/error-handling.ts +12 -16
  100. package/src/router/find-match.ts +4 -31
  101. package/src/router/intercept-resolution.ts +10 -1
  102. package/src/router/lazy-includes.ts +1 -57
  103. package/src/router/loader-resolution.ts +25 -23
  104. package/src/router/logging.ts +0 -6
  105. package/src/router/manifest.ts +1 -25
  106. package/src/router/match-api.ts +0 -20
  107. package/src/router/match-context.ts +0 -22
  108. package/src/router/match-handlers.ts +0 -43
  109. package/src/router/match-middleware/background-revalidation.ts +0 -7
  110. package/src/router/match-middleware/cache-lookup.ts +96 -179
  111. package/src/router/match-middleware/cache-store.ts +0 -31
  112. package/src/router/match-middleware/intercept-resolution.ts +0 -22
  113. package/src/router/match-middleware/segment-resolution.ts +0 -22
  114. package/src/router/match-pipelines.ts +1 -42
  115. package/src/router/match-result.ts +1 -52
  116. package/src/router/metrics.ts +0 -34
  117. package/src/router/middleware-types.ts +0 -116
  118. package/src/router/middleware.ts +77 -60
  119. package/src/router/navigation-snapshot.ts +0 -51
  120. package/src/router/params-util.ts +23 -0
  121. package/src/router/pattern-matching.ts +5 -56
  122. package/src/router/prerender-match.ts +56 -51
  123. package/src/router/request-classification.ts +1 -38
  124. package/src/router/revalidation.ts +14 -62
  125. package/src/router/route-snapshot.ts +0 -1
  126. package/src/router/router-context.ts +0 -27
  127. package/src/router/router-interfaces.ts +10 -0
  128. package/src/router/segment-resolution/fresh.ts +25 -57
  129. package/src/router/segment-resolution/helpers.ts +34 -0
  130. package/src/router/segment-resolution/loader-cache.ts +35 -23
  131. package/src/router/segment-resolution/revalidation.ts +188 -283
  132. package/src/router/segment-resolution/streamed-handler-telemetry.ts +52 -0
  133. package/src/router/segment-resolution.ts +4 -1
  134. package/src/router/segment-wrappers.ts +0 -3
  135. package/src/router/telemetry-otel.ts +0 -20
  136. package/src/router/telemetry.ts +0 -22
  137. package/src/router/timeout.ts +0 -20
  138. package/src/router/trie-matching.ts +66 -45
  139. package/src/router/types.ts +1 -63
  140. package/src/router/url-params.ts +0 -5
  141. package/src/router.ts +8 -11
  142. package/src/rsc/handler-context.ts +1 -0
  143. package/src/rsc/handler.ts +20 -4
  144. package/src/rsc/helpers.ts +71 -3
  145. package/src/rsc/json-route-result.ts +38 -0
  146. package/src/rsc/origin-guard.ts +9 -15
  147. package/src/rsc/progressive-enhancement.ts +10 -1
  148. package/src/rsc/redirect-guard.ts +99 -0
  149. package/src/rsc/response-route-handler.ts +23 -18
  150. package/src/rsc/rsc-rendering.ts +2 -7
  151. package/src/rsc/runtime-warnings.ts +14 -0
  152. package/src/rsc/server-action.ts +34 -29
  153. package/src/rsc/types.ts +6 -3
  154. package/src/search-params.ts +0 -16
  155. package/src/segment-loader-promise.ts +14 -2
  156. package/src/segment-system.tsx +79 -88
  157. package/src/server/handle-store.ts +7 -24
  158. package/src/server/loader-registry.ts +5 -24
  159. package/src/server/request-context.ts +29 -92
  160. package/src/ssr/index.tsx +14 -14
  161. package/src/static-handler.ts +2 -27
  162. package/src/testing/cache-status.ts +44 -48
  163. package/src/testing/collect-handle.ts +1 -24
  164. package/src/testing/dispatch.ts +43 -6
  165. package/src/testing/e2e/index.ts +1 -22
  166. package/src/testing/e2e/matchers.ts +0 -16
  167. package/src/testing/flight-matchers.ts +0 -13
  168. package/src/testing/flight-normalize.ts +3 -30
  169. package/src/testing/flight.ts +46 -48
  170. package/src/testing/generated-routes.ts +1 -41
  171. package/src/testing/index.ts +1 -21
  172. package/src/testing/internal/context.ts +3 -45
  173. package/src/testing/internal/seed-vars.ts +0 -26
  174. package/src/testing/render-handler.ts +31 -61
  175. package/src/testing/render-route.tsx +75 -103
  176. package/src/testing/run-loader.ts +0 -96
  177. package/src/testing/run-middleware.ts +0 -26
  178. package/src/theme/ThemeProvider.tsx +0 -52
  179. package/src/theme/ThemeScript.tsx +0 -6
  180. package/src/theme/constants.ts +0 -12
  181. package/src/theme/index.ts +0 -7
  182. package/src/theme/theme-context.ts +1 -5
  183. package/src/theme/theme-script.ts +0 -14
  184. package/src/theme/use-theme.ts +0 -3
  185. package/src/types/boundaries.ts +0 -35
  186. package/src/types/error-types.ts +25 -89
  187. package/src/types/global-namespace.ts +4 -14
  188. package/src/types/handler-context.ts +28 -9
  189. package/src/types/index.ts +0 -10
  190. package/src/types/request-scope.ts +0 -19
  191. package/src/types/route-config.ts +6 -50
  192. package/src/types/route-entry.ts +0 -6
  193. package/src/types/segments.ts +0 -13
  194. package/src/urls/include-helper.ts +0 -4
  195. package/src/urls/index.ts +0 -6
  196. package/src/urls/path-helper-types.ts +2 -2
  197. package/src/urls/path-helper.ts +0 -54
  198. package/src/urls/urls-function.ts +0 -13
  199. package/src/use-loader.tsx +0 -186
  200. package/src/vite/discovery/bundle-postprocess.ts +2 -1
  201. package/src/vite/discovery/discover-routers.ts +28 -18
  202. package/src/vite/discovery/prerender-collection.ts +2 -4
  203. package/src/vite/discovery/state.ts +5 -0
  204. package/src/vite/discovery/virtual-module-codegen.ts +1 -11
  205. package/src/vite/plugin-types.ts +35 -9
  206. package/src/vite/plugins/cjs-to-esm.ts +0 -11
  207. package/src/vite/plugins/client-ref-dedup.ts +0 -11
  208. package/src/vite/plugins/client-ref-hashing.ts +0 -10
  209. package/src/vite/plugins/cloudflare-protocol-stub.ts +0 -20
  210. package/src/vite/plugins/expose-action-id.ts +2 -73
  211. package/src/vite/plugins/expose-id-utils.ts +0 -55
  212. package/src/vite/plugins/expose-ids/export-analysis.ts +0 -38
  213. package/src/vite/plugins/expose-ids/handler-transform.ts +0 -15
  214. package/src/vite/plugins/expose-ids/loader-transform.ts +0 -15
  215. package/src/vite/plugins/expose-ids/router-transform.ts +0 -13
  216. package/src/vite/plugins/expose-internal-ids.ts +10 -0
  217. package/src/vite/plugins/performance-tracks.ts +0 -3
  218. package/src/vite/plugins/refresh-cmd.ts +1 -1
  219. package/src/vite/plugins/use-cache-transform.ts +21 -46
  220. package/src/vite/plugins/version-injector.ts +0 -20
  221. package/src/vite/plugins/version-plugin.ts +1 -49
  222. package/src/vite/plugins/virtual-entries.ts +0 -15
  223. package/src/vite/rango.ts +2 -108
  224. package/src/vite/router-discovery.ts +9 -1
  225. package/src/vite/utils/ast-handler-extract.ts +0 -16
  226. package/src/vite/utils/bundle-analysis.ts +6 -13
  227. package/src/vite/utils/client-chunks.ts +0 -6
  228. package/src/vite/utils/forward-user-plugins.ts +0 -22
  229. package/src/vite/utils/manifest-utils.ts +0 -4
  230. package/src/vite/utils/package-resolution.ts +1 -73
  231. package/src/vite/utils/prerender-utils.ts +0 -35
  232. package/src/vite/utils/shared-utils.ts +3 -35
  233. package/src/browser/shallow.ts +0 -40
  234. package/src/handles/index.ts +0 -7
  235. package/src/router/middleware-cookies.ts +0 -55
@@ -161,23 +161,9 @@ function isContentHashedAssetConflict(message: string | undefined): boolean {
161
161
  }
162
162
 
163
163
  /**
164
- * Rollup onwarn handler that suppresses known harmless warnings:
165
- * - "use client" directives: handled by the RSC plugin, not relevant to Rollup
166
- * - sourcemap errors: caused by "use client" directive at line 1:0 confusing sourcemap resolution
167
- * - sourcemap incomplete: plugins that transform without generating sourcemaps (router + RSC plugin)
168
- * - dynamic/static mixed imports: expected for router internals (e.g. request-context, cache-scope).
169
- * Under Rolldown (Vite 8) this surfaces as the INEFFECTIVE_DYNAMIC_IMPORT code emitted directly
170
- * by the bundler, rather than the vite:reporter message handled below (Rollup/Vite 7 shape).
171
- * - empty bundle: @vitejs/plugin-rsc scan build (step 1/5) produces an empty "index" chunk
172
- * because the RSC entry is fully externalized during client-reference analysis
173
- * - file name conflicts on content-hashed assets: @vitejs/plugin-rsc copies the rsc
174
- * environment's imported CSS/assets into the client bundle (its assets-manifest
175
- * generateBundle re-emits each via emitFile with an explicit content-hashed
176
- * fileName). When the client bundle already produced that identical asset,
177
- * rollup raises FILE_NAME_CONFLICT even though the bytes are identical (a
178
- * content hash collision IS a content match). Only these are suppressed; a
179
- * collision on a stable name still surfaces. No upstream fix as of
180
- * @vitejs/plugin-rsc@0.5.27; remove when it skips the redundant emit.
164
+ * Suppress known harmless warnings: "use client" directives, sourcemap errors,
165
+ * mixed imports (expected for router internals), empty bundles, and content-hashed
166
+ * asset collisions from @vitejs/plugin-rsc copying RSC-env assets to the client bundle.
181
167
  */
182
168
  export function onwarn(
183
169
  warning: Vite.Rollup.RollupLog,
@@ -197,10 +183,6 @@ export function onwarn(
197
183
  ) {
198
184
  return;
199
185
  }
200
- // @vitejs/plugin-rsc@0.5.14: rsc:virtual:vite-rsc/assets-manifest renderChunk
201
- // returns { code } without map, causing Rollup to warn about incorrect sourcemaps.
202
- // This is harmless (simple string replacement). Remove this suppression if a
203
- // future version of @vitejs/plugin-rsc fixes the missing sourcemap.
204
186
  if (warning.message?.includes("Sourcemap is likely to be incorrect")) {
205
187
  return;
206
188
  }
@@ -215,10 +197,6 @@ export function onwarn(
215
197
  defaultHandler(warning);
216
198
  }
217
199
 
218
- /**
219
- * Manual chunks configuration for client build.
220
- * Splits React and router packages into separate chunks for better caching.
221
- */
222
200
  export function getManualChunks(id: string): string | undefined {
223
201
  const normalized = Vite.normalizePath(id);
224
202
 
@@ -230,16 +208,6 @@ export function getManualChunks(id: string): string | undefined {
230
208
  ) {
231
209
  return "react";
232
210
  }
233
- // Use dynamic package name from package.json
234
- // Check both npm install path and workspace symlink resolved path.
235
- //
236
- // The workspace patterns are anchored to the package's own `src`/`dist` so
237
- // they match the router runtime but NOT consumer apps that merely live under a
238
- // `packages/rangojs-router/` ancestor (the in-repo e2e apps at
239
- // `packages/rangojs-router/e2e/<app>/src/...`). Without the anchor those apps'
240
- // own client components were force-merged into the shared "router" chunk,
241
- // which both misrepresented real-consumer bundles and blocked `clientChunks`
242
- // splitting from relocating them.
243
211
  const packageName = getPublishedPackageName();
244
212
  if (
245
213
  normalized.includes(`node_modules/${packageName}/`) ||
@@ -1,40 +0,0 @@
1
- /**
2
- * Shallow comparison utility for selector optimization
3
- *
4
- * Used by useNavigation hook to prevent unnecessary re-renders
5
- * when the selected value hasn't changed.
6
- *
7
- * @param a - First value
8
- * @param b - Second value
9
- * @returns true if values are shallowly equal
10
- */
11
- export function shallow<T>(a: T, b: T): boolean {
12
- // Same reference or primitive equality
13
- if (Object.is(a, b)) return true;
14
-
15
- // Different types or non-objects
16
- if (typeof a !== "object" || typeof b !== "object") return false;
17
-
18
- // Null checks
19
- if (a === null || b === null) return false;
20
-
21
- // Compare object keys
22
- const keysA = Object.keys(a);
23
- const keysB = Object.keys(b);
24
-
25
- if (keysA.length !== keysB.length) return false;
26
-
27
- // Check each key's value with Object.is
28
- for (const key of keysA) {
29
- if (
30
- !Object.is(
31
- (a as Record<string, unknown>)[key],
32
- (b as Record<string, unknown>)[key],
33
- )
34
- ) {
35
- return false;
36
- }
37
- }
38
-
39
- return true;
40
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Built-in handles for rsc-router.
3
- */
4
-
5
- export { Meta } from "./meta.ts";
6
- export { MetaTags } from "./MetaTags.tsx";
7
- export { Breadcrumbs, type BreadcrumbItem } from "./breadcrumbs.ts";
@@ -1,55 +0,0 @@
1
- /**
2
- * Cookie Utilities
3
- *
4
- * Parsing and serialization for HTTP cookies used by middleware context.
5
- */
6
-
7
- import type { CookieOptions } from "./middleware-types.js";
8
-
9
- /**
10
- * Parse cookies from Cookie header
11
- */
12
- export function parseCookies(
13
- cookieHeader: string | null,
14
- ): Record<string, string> {
15
- if (!cookieHeader) return {};
16
-
17
- const cookies: Record<string, string> = {};
18
- const pairs = cookieHeader.split(";");
19
-
20
- for (const pair of pairs) {
21
- const [name, ...rest] = pair.trim().split("=");
22
- if (name) {
23
- const raw = rest.join("=");
24
- try {
25
- cookies[name] = decodeURIComponent(raw);
26
- } catch {
27
- // Malformed percent-encoded value (e.g. %zz) - fall back to raw value
28
- cookies[name] = raw;
29
- }
30
- }
31
- }
32
-
33
- return cookies;
34
- }
35
-
36
- /**
37
- * Serialize a cookie for Set-Cookie header
38
- */
39
- export function serializeCookie(
40
- name: string,
41
- value: string,
42
- options: CookieOptions = {},
43
- ): string {
44
- let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
45
-
46
- if (options.domain) cookie += `; Domain=${options.domain}`;
47
- if (options.path) cookie += `; Path=${options.path}`;
48
- if (options.maxAge !== undefined) cookie += `; Max-Age=${options.maxAge}`;
49
- if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
50
- if (options.httpOnly) cookie += "; HttpOnly";
51
- if (options.secure) cookie += "; Secure";
52
- if (options.sameSite) cookie += `; SameSite=${options.sameSite}`;
53
-
54
- return cookie;
55
- }