@rangojs/router 0.0.0-experimental.121 → 0.0.0-experimental.124
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 +7 -2
- package/dist/vite/index.js +47 -6
- package/package.json +61 -21
- package/skills/cache-guide/SKILL.md +8 -6
- package/skills/caching/SKILL.md +148 -1
- package/skills/hooks/SKILL.md +38 -27
- package/skills/host-router/SKILL.md +16 -2
- package/skills/intercept/SKILL.md +4 -2
- package/skills/layout/SKILL.md +11 -6
- package/skills/loader/SKILL.md +6 -2
- package/skills/middleware/SKILL.md +4 -2
- package/skills/migrate-nextjs/SKILL.md +38 -16
- package/skills/parallel/SKILL.md +9 -4
- package/skills/rango/SKILL.md +27 -15
- package/skills/route/SKILL.md +4 -2
- package/skills/testing/SKILL.md +129 -0
- package/skills/testing/bindings.md +89 -0
- package/skills/testing/cache-prerender.md +98 -0
- package/skills/testing/client-components.md +122 -0
- package/skills/testing/e2e-parity.md +125 -0
- package/skills/testing/flight.md +89 -0
- package/skills/testing/handles.md +129 -0
- package/skills/testing/loader.md +128 -0
- package/skills/testing/middleware.md +99 -0
- package/skills/testing/render-handler.md +118 -0
- package/skills/testing/response-routes.md +95 -0
- package/skills/testing/reverse-and-types.md +84 -0
- package/skills/testing/server-actions.md +107 -0
- package/skills/testing/server-tree.md +128 -0
- package/skills/testing/setup.md +120 -0
- package/skills/use-cache/SKILL.md +9 -7
- package/src/browser/action-fence.ts +37 -0
- package/src/browser/cookie-name.ts +140 -0
- package/src/browser/invalidate-client-cache.ts +52 -0
- package/src/browser/navigation-bridge.ts +14 -1
- package/src/browser/navigation-client.ts +14 -1
- package/src/browser/navigation-store-handle.ts +39 -0
- package/src/browser/navigation-store.ts +26 -12
- package/src/browser/prefetch/fetch.ts +7 -0
- package/src/browser/rango-state.ts +176 -97
- package/src/browser/react/index.ts +0 -6
- package/src/browser/rsc-router.tsx +12 -4
- package/src/browser/server-action-bridge.ts +77 -15
- package/src/browser/types.ts +7 -1
- package/src/cache/cache-error.ts +104 -0
- package/src/cache/cache-policy.ts +95 -1
- package/src/cache/cache-runtime.ts +79 -13
- package/src/cache/cache-scope.ts +55 -4
- package/src/cache/cache-tag.ts +135 -0
- package/src/cache/cf/cf-cache-store.ts +2080 -224
- package/src/cache/cf/index.ts +15 -1
- package/src/cache/document-cache.ts +74 -7
- package/src/cache/index.ts +17 -0
- package/src/cache/memory-segment-store.ts +164 -14
- package/src/cache/tag-invalidation.ts +230 -0
- package/src/cache/types.ts +27 -0
- package/src/client.rsc.tsx +1 -1
- package/src/client.tsx +0 -6
- package/src/component-utils.ts +19 -0
- package/src/handle.ts +29 -9
- package/src/host/testing.ts +43 -14
- package/src/index.rsc.ts +29 -1
- package/src/index.ts +43 -1
- package/src/loader.rsc.ts +24 -3
- package/src/loader.ts +16 -2
- package/src/prerender.ts +24 -3
- package/src/router/basename.ts +14 -0
- package/src/router/match-handlers.ts +62 -20
- package/src/router/prerender-match.ts +6 -0
- package/src/router/router-interfaces.ts +7 -0
- package/src/router/router-options.ts +30 -0
- package/src/router/segment-resolution/loader-cache.ts +8 -17
- package/src/router/state-cookie-name.ts +33 -0
- package/src/router/telemetry.ts +99 -0
- package/src/router.ts +36 -7
- package/src/rsc/handler.ts +13 -1
- package/src/rsc/helpers.ts +19 -0
- package/src/rsc/progressive-enhancement.ts +2 -0
- package/src/rsc/response-route-handler.ts +8 -1
- package/src/rsc/rsc-rendering.ts +2 -0
- package/src/rsc/types.ts +2 -0
- package/src/runtime-env.ts +18 -0
- package/src/server/cookie-store.ts +52 -1
- package/src/server/request-context.ts +105 -2
- package/src/static-handler.ts +25 -3
- package/src/testing/cache-status.ts +166 -0
- package/src/testing/collect-handle.ts +63 -0
- package/src/testing/dispatch.ts +581 -0
- package/src/testing/dom.entry.ts +22 -0
- package/src/testing/e2e/fixture.ts +188 -0
- package/src/testing/e2e/index.ts +149 -0
- package/src/testing/e2e/matchers.ts +51 -0
- package/src/testing/e2e/page-helpers.ts +272 -0
- package/src/testing/e2e/parity.ts +387 -0
- package/src/testing/e2e/server.ts +195 -0
- package/src/testing/flight-matchers.ts +110 -0
- package/src/testing/flight-normalize.ts +38 -0
- package/src/testing/flight-runtime.d.ts +57 -0
- package/src/testing/flight-tree.ts +682 -0
- package/src/testing/flight.entry.ts +52 -0
- package/src/testing/flight.ts +234 -0
- package/src/testing/generated-routes.ts +223 -0
- package/src/testing/index.ts +119 -0
- package/src/testing/internal/context.ts +390 -0
- package/src/testing/internal/flight-client-globals.ts +30 -0
- package/src/testing/internal/seed-vars.ts +80 -0
- package/src/testing/render-handler.ts +360 -0
- package/src/testing/render-route.tsx +594 -0
- package/src/testing/run-loader.ts +474 -0
- package/src/testing/run-middleware.ts +231 -0
- package/src/testing/vitest-stubs/cloudflare-email.ts +9 -0
- package/src/testing/vitest-stubs/cloudflare-workers.ts +21 -0
- package/src/testing/vitest-stubs/plugin-rsc.ts +16 -0
- package/src/testing/vitest-stubs/version.ts +5 -0
- package/src/testing/vitest.ts +305 -0
- package/src/types/cache-types.ts +13 -4
- package/src/types/error-types.ts +5 -1
- package/src/types/global-namespace.ts +11 -1
- package/src/types/handler-context.ts +16 -5
- package/src/browser/react/use-client-cache.ts +0 -58
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* normalizeFlight — scrub volatile bits from a Flight wire string so snapshots
|
|
3
|
+
* are stable across runs/machines.
|
|
4
|
+
*
|
|
5
|
+
* This is two regex replacements and NOTHING else. It is split out of flight.ts
|
|
6
|
+
* on purpose: flight.ts top-level imports the vendored react-server-dom
|
|
7
|
+
* serializer, which throws when imported outside the `react-server` export
|
|
8
|
+
* condition. The flight-matchers module (and a consumer's shared `setupFiles`
|
|
9
|
+
* that does `expect.extend(flightMatchers)`) must be importable under the PLAIN
|
|
10
|
+
* node condition, so the normalizer it needs cannot live next to that import.
|
|
11
|
+
* flight.ts re-exports normalizeFlight from here, so the public surface of the
|
|
12
|
+
* `@rangojs/router/testing/flight` entry is unchanged.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// Volatile leading reference row: `:N<timestamp>` (dev debug-info anchor).
|
|
16
|
+
const REFERENCE_ROW_RE = /^:N[\d.]+\n/;
|
|
17
|
+
// Absolute file:// paths embedded in dev STACK rows. The serializer emits stack
|
|
18
|
+
// frames as `["Component","file:///abs/path.tsx",<line>,<col>,...]`, so the
|
|
19
|
+
// path is a quoted JSON string immediately followed by `",<line>,<col>`. The
|
|
20
|
+
// lookahead scopes the scrub to exactly that frame shape, leaving a legitimate
|
|
21
|
+
// `file://` href in RENDERED content (e.g. `{"href":"file:///x"}`) untouched.
|
|
22
|
+
const FILE_URL_RE = /file:\/\/[^"\\]+(?=",\d+,\d+)/g;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Scrub volatile bits from a Flight string so snapshots are stable across runs
|
|
26
|
+
* and machines:
|
|
27
|
+
* - the leading `:N<timestamp>` reference row (dev only),
|
|
28
|
+
* - absolute `file://...` paths inside dev stack rows.
|
|
29
|
+
*
|
|
30
|
+
* Under NODE_ENV=production these rows are already absent; normalize is a
|
|
31
|
+
* no-op safety net there. In dev mode it removes the machine/clock-specific
|
|
32
|
+
* noise while leaving the rendered tree intact.
|
|
33
|
+
*/
|
|
34
|
+
export function normalizeFlight(flight: string): string {
|
|
35
|
+
return flight
|
|
36
|
+
.replace(REFERENCE_ROW_RE, "")
|
|
37
|
+
.replace(FILE_URL_RE, "file://<path>");
|
|
38
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient declaration for the vendored react-server-dom serializer shipped
|
|
3
|
+
* inside @vitejs/plugin-rsc. The package ships no .d.ts for this private
|
|
4
|
+
* subpath, so we declare the minimal surface renderToFlightString uses.
|
|
5
|
+
*
|
|
6
|
+
* Only loadable under the `react-server` export condition (see flight.ts).
|
|
7
|
+
*/
|
|
8
|
+
declare module "@vitejs/plugin-rsc/vendor/react-server-dom/server.edge" {
|
|
9
|
+
/**
|
|
10
|
+
* Serialize a server-component payload to a Flight wire stream.
|
|
11
|
+
*
|
|
12
|
+
* @param payload The value to serialize (Rango wraps a payload object).
|
|
13
|
+
* @param clientManifest Client-reference manifest; `{}` for server-only trees.
|
|
14
|
+
* @param options Render options; `onError` is invoked per render error.
|
|
15
|
+
*/
|
|
16
|
+
export function renderToReadableStream(
|
|
17
|
+
payload: unknown,
|
|
18
|
+
clientManifest: unknown,
|
|
19
|
+
options?: { onError?: (error: unknown) => string | void },
|
|
20
|
+
): ReadableStream<Uint8Array>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Tag a value as a client reference. Mutates `impl` in place (defining
|
|
24
|
+
* `$$typeof`/`$$id`/`$$async`) and returns it, so a server tree that imports
|
|
25
|
+
* the same module binding renders it as a client boundary (an `I` row) rather
|
|
26
|
+
* than inlining it. `$$id` becomes `${id}#${exportName}`.
|
|
27
|
+
*/
|
|
28
|
+
export function registerClientReference<T>(
|
|
29
|
+
impl: T,
|
|
30
|
+
id: string,
|
|
31
|
+
exportName: string,
|
|
32
|
+
): T;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Vendored react-server-dom CLIENT deserializer wrappers shipped inside
|
|
37
|
+
* @vitejs/plugin-rsc. Used by renderServerTree to turn a Flight wire string
|
|
38
|
+
* back into an inspectable React element tree. These run in the same
|
|
39
|
+
* `react-server`-condition worker as the serializer (deserialize-only never
|
|
40
|
+
* renders, so the client React/react-dom imports they pull are inert).
|
|
41
|
+
*/
|
|
42
|
+
declare module "@vitejs/plugin-rsc/react/browser" {
|
|
43
|
+
export function createFromReadableStream<T = unknown>(
|
|
44
|
+
stream: ReadableStream<Uint8Array>,
|
|
45
|
+
options?: { temporaryReferences?: unknown },
|
|
46
|
+
): Promise<T>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare module "@vitejs/plugin-rsc/core/browser" {
|
|
50
|
+
/**
|
|
51
|
+
* Install the module loader the client deserializer resolves client
|
|
52
|
+
* references through. Init-once per worker (first call wins).
|
|
53
|
+
*/
|
|
54
|
+
export function setRequireModule(options: {
|
|
55
|
+
load: (id: string) => unknown;
|
|
56
|
+
}): void;
|
|
57
|
+
}
|