@rangojs/router 0.0.0-experimental.139 → 0.0.0-experimental.140

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 (45) hide show
  1. package/dist/bin/rango.js +27 -2
  2. package/dist/vite/index.js +147 -30
  3. package/package.json +1 -1
  4. package/skills/breadcrumbs/SKILL.md +1 -1
  5. package/skills/cache-guide/SKILL.md +1 -0
  6. package/skills/caching/SKILL.md +1 -1
  7. package/skills/migrate-nextjs/SKILL.md +15 -0
  8. package/skills/migrate-react-router/SKILL.md +15 -2
  9. package/skills/ppr/SKILL.md +426 -0
  10. package/skills/rango/SKILL.md +28 -25
  11. package/skills/route/SKILL.md +43 -0
  12. package/src/build/route-trie.ts +35 -7
  13. package/src/cache/cf/cf-cache-store.ts +155 -0
  14. package/src/cache/index.ts +6 -0
  15. package/src/cache/memory-segment-store.ts +57 -1
  16. package/src/cache/shell-cache.ts +386 -0
  17. package/src/cache/types.ts +58 -0
  18. package/src/cache/vercel/vercel-cache-store.ts +159 -5
  19. package/src/index.rsc.ts +5 -0
  20. package/src/index.ts +17 -0
  21. package/src/router/middleware.ts +14 -5
  22. package/src/router/parse-pattern.ts +115 -0
  23. package/src/router/pattern-matching.ts +53 -64
  24. package/src/router/segment-resolution/fresh.ts +12 -1
  25. package/src/router/segment-resolution/loader-cache.ts +14 -0
  26. package/src/router/segment-resolution/loader-mask.ts +44 -0
  27. package/src/router/substitute-pattern-params.ts +54 -35
  28. package/src/router/trie-matching.ts +19 -11
  29. package/src/router/url-params.ts +13 -0
  30. package/src/rsc/full-payload.ts +70 -0
  31. package/src/rsc/rsc-rendering.ts +105 -51
  32. package/src/rsc/shell-capture.ts +439 -0
  33. package/src/rsc/types.ts +26 -0
  34. package/src/server/cookie-store.ts +45 -0
  35. package/src/server/live.ts +130 -0
  36. package/src/server/request-context.ts +49 -0
  37. package/src/ssr/index.tsx +377 -180
  38. package/src/ssr/ssr-root.tsx +228 -0
  39. package/src/testing/render-route.tsx +7 -9
  40. package/src/types/route-config.ts +19 -7
  41. package/src/urls/type-extraction.ts +43 -18
  42. package/src/vite/discovery/discovery-errors.ts +61 -0
  43. package/src/vite/plugins/virtual-entries.ts +27 -2
  44. package/src/vite/router-discovery.ts +69 -15
  45. package/src/vite/utils/prerender-utils.ts +17 -4
@@ -10,12 +10,10 @@ import {
10
10
  import { resolve } from "node:path";
11
11
 
12
12
  import { escapeRegExp } from "../../regex-escape.js";
13
+ import { encodePathRemainder } from "../../router/url-params.js";
13
14
 
14
15
  export function encodePathParam(value: unknown): string {
15
- return String(value)
16
- .split("/")
17
- .map((segment) => encodeURIComponent(segment))
18
- .join("/");
16
+ return encodePathRemainder(String(value), encodeURIComponent);
19
17
  }
20
18
 
21
19
  export function substituteRouteParams(
@@ -28,6 +26,21 @@ export function substituteRouteParams(
28
26
 
29
27
  for (const [key, value] of Object.entries(params)) {
30
28
  const escaped = escapeRegExp(key);
29
+ // Named catch-all `:key+` / `:key*` (issue #634). Like the runtime reverse,
30
+ // the value is multi-segment: encode each segment and keep the `/` separators
31
+ // (a whole-value encode would turn `a/b` into `a%2Fb`), and consume the
32
+ // trailing modifier so it does not leak into the URL. `*` (zero-or-more)
33
+ // absent collapses via the trailing cleanup below.
34
+ const catchAllRe = new RegExp(`:${escaped}[+*]`);
35
+ if (catchAllRe.test(result)) {
36
+ if (value === "") {
37
+ result = result.replace(catchAllRe, "");
38
+ hadOmittedOptional = true;
39
+ } else {
40
+ result = result.replace(catchAllRe, encodePathRemainder(value, encode));
41
+ }
42
+ continue;
43
+ }
31
44
  if (value === "") {
32
45
  result = result.replace(
33
46
  new RegExp(`:${escaped}(\\([^)]*\\))?(?!\\?)`),