@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.
- package/dist/bin/rango.js +27 -2
- package/dist/vite/index.js +147 -30
- package/package.json +1 -1
- package/skills/breadcrumbs/SKILL.md +1 -1
- package/skills/cache-guide/SKILL.md +1 -0
- package/skills/caching/SKILL.md +1 -1
- package/skills/migrate-nextjs/SKILL.md +15 -0
- package/skills/migrate-react-router/SKILL.md +15 -2
- package/skills/ppr/SKILL.md +426 -0
- package/skills/rango/SKILL.md +28 -25
- package/skills/route/SKILL.md +43 -0
- package/src/build/route-trie.ts +35 -7
- package/src/cache/cf/cf-cache-store.ts +155 -0
- package/src/cache/index.ts +6 -0
- package/src/cache/memory-segment-store.ts +57 -1
- package/src/cache/shell-cache.ts +386 -0
- package/src/cache/types.ts +58 -0
- package/src/cache/vercel/vercel-cache-store.ts +159 -5
- package/src/index.rsc.ts +5 -0
- package/src/index.ts +17 -0
- package/src/router/middleware.ts +14 -5
- package/src/router/parse-pattern.ts +115 -0
- package/src/router/pattern-matching.ts +53 -64
- package/src/router/segment-resolution/fresh.ts +12 -1
- package/src/router/segment-resolution/loader-cache.ts +14 -0
- package/src/router/segment-resolution/loader-mask.ts +44 -0
- package/src/router/substitute-pattern-params.ts +54 -35
- package/src/router/trie-matching.ts +19 -11
- package/src/router/url-params.ts +13 -0
- package/src/rsc/full-payload.ts +70 -0
- package/src/rsc/rsc-rendering.ts +105 -51
- package/src/rsc/shell-capture.ts +439 -0
- package/src/rsc/types.ts +26 -0
- package/src/server/cookie-store.ts +45 -0
- package/src/server/live.ts +130 -0
- package/src/server/request-context.ts +49 -0
- package/src/ssr/index.tsx +377 -180
- package/src/ssr/ssr-root.tsx +228 -0
- package/src/testing/render-route.tsx +7 -9
- package/src/types/route-config.ts +19 -7
- package/src/urls/type-extraction.ts +43 -18
- package/src/vite/discovery/discovery-errors.ts +61 -0
- package/src/vite/plugins/virtual-entries.ts +27 -2
- package/src/vite/router-discovery.ts +69 -15
- 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}(\\([^)]*\\))?(?!\\?)`),
|