@rangojs/router 0.0.0-experimental.122 → 0.0.0-experimental.125
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 +10 -6
- package/dist/testing/vitest.js +82 -0
- package/dist/vite/index.js +55 -48
- package/package.json +61 -21
- package/skills/caching/SKILL.md +2 -1
- package/skills/hooks/SKILL.md +40 -29
- 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 +3 -1
- package/skills/parallel/SKILL.md +9 -4
- package/skills/rango/SKILL.md +12 -0
- package/skills/route/SKILL.md +10 -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/src/__internal.ts +0 -65
- package/src/browser/action-coordinator.ts +1 -1
- package/src/browser/action-fence.ts +47 -0
- package/src/browser/cookie-name.ts +140 -0
- package/src/browser/event-controller.ts +1 -83
- 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 +38 -0
- package/src/browser/navigation-store.ts +26 -51
- package/src/browser/navigation-transaction.ts +0 -32
- package/src/browser/partial-update.ts +1 -83
- package/src/browser/prefetch/cache.ts +6 -45
- package/src/browser/prefetch/fetch.ts +7 -0
- package/src/browser/prefetch/queue.ts +6 -3
- package/src/browser/rango-state.ts +157 -99
- package/src/browser/react/Link.tsx +0 -2
- package/src/browser/react/NavigationProvider.tsx +2 -1
- package/src/browser/react/ScrollRestoration.tsx +10 -6
- package/src/browser/react/filter-segment-order.ts +0 -2
- package/src/browser/react/index.ts +0 -51
- package/src/browser/react/location-state-shared.ts +0 -13
- package/src/browser/react/location-state.ts +0 -1
- package/src/browser/react/use-action.ts +6 -15
- package/src/browser/react/use-handle.ts +0 -5
- package/src/browser/react/use-link-status.ts +0 -4
- package/src/browser/react/use-navigation.ts +0 -3
- package/src/browser/react/use-params.ts +0 -2
- package/src/browser/react/use-search-params.ts +0 -5
- package/src/browser/react/use-segments.ts +0 -13
- package/src/browser/rsc-router.tsx +12 -4
- package/src/browser/server-action-bridge.ts +77 -15
- package/src/browser/types.ts +7 -2
- package/src/browser/validate-redirect-origin.ts +4 -5
- package/src/build/route-trie.ts +3 -0
- package/src/build/route-types/param-extraction.ts +6 -3
- package/src/build/route-types/router-processing.ts +0 -8
- package/src/cache/cache-policy.ts +0 -54
- package/src/cache/cache-runtime.ts +27 -24
- package/src/cache/cache-scope.ts +0 -27
- package/src/cache/cache-tag.ts +0 -37
- package/src/cache/cf/cf-cache-store.ts +94 -46
- package/src/cache/cf/index.ts +0 -24
- package/src/cache/document-cache.ts +11 -36
- package/src/cache/handle-snapshot.ts +0 -40
- package/src/cache/index.ts +0 -27
- package/src/cache/memory-segment-store.ts +2 -48
- package/src/cache/profile-registry.ts +7 -3
- package/src/cache/read-through-swr.ts +41 -11
- package/src/cache/segment-codec.ts +0 -16
- package/src/cache/types.ts +0 -98
- package/src/client.rsc.tsx +1 -22
- package/src/client.tsx +14 -38
- package/src/component-utils.ts +19 -0
- package/src/deps/ssr.ts +0 -1
- package/src/handle.ts +28 -18
- package/src/handles/MetaTags.tsx +0 -14
- package/src/handles/meta.ts +0 -39
- package/src/host/cookie-handler.ts +0 -36
- package/src/host/errors.ts +0 -24
- package/src/host/index.ts +6 -0
- package/src/host/pattern-matcher.ts +7 -50
- package/src/host/router.ts +1 -65
- package/src/host/testing.ts +40 -27
- package/src/host/types.ts +6 -2
- package/src/href-client.ts +0 -4
- package/src/index.rsc.ts +42 -3
- package/src/index.ts +31 -1
- package/src/internal-debug.ts +2 -4
- package/src/loader.rsc.ts +19 -9
- package/src/loader.ts +12 -4
- package/src/network-error-thrower.tsx +1 -6
- package/src/outlet-provider.tsx +1 -5
- package/src/prerender/param-hash.ts +10 -11
- package/src/prerender/store.ts +23 -30
- package/src/prerender.ts +58 -3
- package/src/root-error-boundary.tsx +1 -19
- package/src/route-content-wrapper.tsx +1 -44
- package/src/route-definition/dsl-helpers.ts +7 -19
- package/src/route-definition/helpers-types.ts +3 -3
- package/src/route-definition/redirect.ts +11 -1
- package/src/route-map-builder.ts +0 -16
- package/src/router/basename.ts +14 -0
- package/src/router/content-negotiation.ts +0 -13
- package/src/router/error-handling.ts +12 -16
- package/src/router/find-match.ts +4 -30
- package/src/router/intercept-resolution.ts +10 -1
- package/src/router/lazy-includes.ts +1 -57
- package/src/router/loader-resolution.ts +3 -2
- package/src/router/logging.ts +0 -6
- package/src/router/manifest.ts +1 -25
- package/src/router/match-api.ts +0 -20
- package/src/router/match-context.ts +0 -22
- package/src/router/match-handlers.ts +57 -58
- package/src/router/match-middleware/background-revalidation.ts +0 -7
- package/src/router/match-middleware/cache-lookup.ts +1 -54
- package/src/router/match-middleware/cache-store.ts +0 -31
- package/src/router/match-middleware/intercept-resolution.ts +0 -22
- package/src/router/match-middleware/segment-resolution.ts +0 -21
- package/src/router/match-pipelines.ts +1 -42
- package/src/router/match-result.ts +1 -52
- package/src/router/metrics.ts +0 -34
- package/src/router/middleware-cookies.ts +0 -13
- package/src/router/middleware-types.ts +0 -115
- package/src/router/middleware.ts +7 -30
- package/src/router/navigation-snapshot.ts +0 -51
- package/src/router/params-util.ts +23 -0
- package/src/router/pattern-matching.ts +1 -33
- package/src/router/prerender-match.ts +33 -45
- package/src/router/request-classification.ts +1 -38
- package/src/router/revalidation.ts +5 -58
- package/src/router/router-context.ts +0 -26
- package/src/router/router-interfaces.ts +7 -0
- package/src/router/router-options.ts +30 -0
- package/src/router/segment-resolution/fresh.ts +25 -57
- package/src/router/segment-resolution/helpers.ts +34 -0
- package/src/router/segment-resolution/loader-cache.ts +10 -13
- package/src/router/segment-resolution/revalidation.ts +5 -42
- package/src/router/segment-resolution/streamed-handler-telemetry.ts +52 -0
- package/src/router/segment-resolution.ts +4 -1
- package/src/router/state-cookie-name.ts +33 -0
- package/src/router/telemetry-otel.ts +0 -20
- package/src/router/telemetry.ts +96 -19
- package/src/router/timeout.ts +0 -20
- package/src/router/trie-matching.ts +63 -40
- package/src/router/types.ts +1 -63
- package/src/router/url-params.ts +0 -5
- package/src/router.ts +40 -9
- package/src/rsc/handler.ts +14 -2
- package/src/rsc/helpers.ts +34 -0
- package/src/rsc/origin-guard.ts +0 -12
- package/src/rsc/progressive-enhancement.ts +4 -1
- package/src/rsc/rsc-rendering.ts +4 -7
- package/src/rsc/runtime-warnings.ts +14 -0
- package/src/rsc/server-action.ts +30 -28
- package/src/rsc/types.ts +2 -1
- package/src/runtime-env.ts +18 -0
- package/src/search-params.ts +0 -16
- package/src/segment-loader-promise.ts +14 -2
- package/src/segment-system.tsx +79 -88
- package/src/server/cookie-store.ts +52 -1
- package/src/server/handle-store.ts +7 -24
- package/src/server/loader-registry.ts +5 -24
- package/src/server/request-context.ts +74 -77
- package/src/ssr/index.tsx +14 -14
- package/src/static-handler.ts +10 -13
- package/src/testing/cache-status.ts +119 -0
- package/src/testing/collect-handle.ts +40 -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 +127 -0
- package/src/testing/e2e/matchers.ts +35 -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 +97 -0
- package/src/testing/flight-normalize.ts +11 -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 +186 -0
- package/src/testing/generated-routes.ts +183 -0
- package/src/testing/index.ts +98 -0
- package/src/testing/internal/context.ts +348 -0
- package/src/testing/internal/flight-client-globals.ts +30 -0
- package/src/testing/internal/seed-vars.ts +54 -0
- package/src/testing/render-handler.ts +311 -0
- package/src/testing/render-route.tsx +504 -0
- package/src/testing/run-loader.ts +378 -0
- package/src/testing/run-middleware.ts +205 -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/theme/ThemeProvider.tsx +0 -52
- package/src/theme/ThemeScript.tsx +0 -6
- package/src/theme/constants.ts +0 -12
- package/src/theme/index.ts +0 -7
- package/src/theme/theme-context.ts +1 -5
- package/src/theme/theme-script.ts +0 -14
- package/src/theme/use-theme.ts +0 -3
- package/src/types/boundaries.ts +0 -35
- package/src/types/error-types.ts +25 -89
- package/src/types/global-namespace.ts +15 -15
- package/src/types/handler-context.ts +16 -13
- package/src/types/index.ts +0 -10
- package/src/types/request-scope.ts +0 -19
- package/src/types/route-config.ts +6 -50
- package/src/types/route-entry.ts +0 -6
- package/src/types/segments.ts +0 -13
- package/src/urls/include-helper.ts +0 -4
- package/src/urls/index.ts +0 -6
- package/src/urls/path-helper-types.ts +2 -2
- package/src/urls/path-helper.ts +0 -54
- package/src/urls/urls-function.ts +0 -13
- package/src/use-loader.tsx +0 -186
- package/src/vite/discovery/bundle-postprocess.ts +2 -1
- package/src/vite/discovery/discover-routers.ts +6 -7
- package/src/vite/discovery/virtual-module-codegen.ts +1 -11
- package/src/vite/plugin-types.ts +3 -1
- package/src/vite/plugins/cjs-to-esm.ts +0 -11
- package/src/vite/plugins/client-ref-dedup.ts +0 -11
- package/src/vite/plugins/client-ref-hashing.ts +0 -10
- package/src/vite/plugins/cloudflare-protocol-stub.ts +0 -20
- package/src/vite/plugins/expose-action-id.ts +2 -73
- package/src/vite/plugins/expose-id-utils.ts +0 -55
- package/src/vite/plugins/expose-ids/export-analysis.ts +0 -38
- package/src/vite/plugins/expose-ids/handler-transform.ts +0 -15
- package/src/vite/plugins/expose-ids/loader-transform.ts +0 -15
- package/src/vite/plugins/expose-ids/router-transform.ts +0 -13
- package/src/vite/plugins/expose-internal-ids.ts +10 -0
- package/src/vite/plugins/performance-tracks.ts +0 -3
- package/src/vite/plugins/use-cache-transform.ts +0 -36
- package/src/vite/plugins/version-injector.ts +0 -20
- package/src/vite/plugins/version-plugin.ts +1 -49
- package/src/vite/plugins/virtual-entries.ts +0 -15
- package/src/vite/rango.ts +1 -108
- package/src/vite/router-discovery.ts +2 -1
- package/src/vite/utils/ast-handler-extract.ts +0 -16
- package/src/vite/utils/bundle-analysis.ts +6 -13
- package/src/vite/utils/client-chunks.ts +0 -6
- package/src/vite/utils/forward-user-plugins.ts +0 -22
- package/src/vite/utils/manifest-utils.ts +0 -4
- package/src/vite/utils/package-resolution.ts +1 -73
- package/src/vite/utils/prerender-utils.ts +0 -35
- package/src/vite/utils/shared-utils.ts +3 -35
- package/src/browser/react/use-client-cache.ts +0 -58
- package/src/browser/shallow.ts +0 -40
|
@@ -161,23 +161,9 @@ function isContentHashedAssetConflict(message: string | undefined): boolean {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
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,58 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useContext, useCallback } from "react";
|
|
4
|
-
import { NavigationStoreContext } from "./context.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Return type for useClientCache hook
|
|
8
|
-
*/
|
|
9
|
-
export interface ClientCacheControls {
|
|
10
|
-
/**
|
|
11
|
-
* Clear the client-side navigation cache.
|
|
12
|
-
* Call this after data changes that happen outside of server actions
|
|
13
|
-
* (e.g., REST API calls, WebSocket updates, etc.)
|
|
14
|
-
*
|
|
15
|
-
* This will also broadcast to other tabs to clear their caches.
|
|
16
|
-
*/
|
|
17
|
-
clear: () => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Hook to access client-side cache controls
|
|
22
|
-
*
|
|
23
|
-
* Use this when you need to manually invalidate the navigation cache
|
|
24
|
-
* after data changes that happen outside of server actions.
|
|
25
|
-
*
|
|
26
|
-
* Server actions automatically clear the cache, so you only need this for:
|
|
27
|
-
* - REST API mutations
|
|
28
|
-
* - WebSocket-driven updates
|
|
29
|
-
* - Other non-RSC data changes
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```tsx
|
|
33
|
-
* function DataEditor() {
|
|
34
|
-
* const { clear } = useClientCache();
|
|
35
|
-
*
|
|
36
|
-
* async function handleSave() {
|
|
37
|
-
* await fetch('/api/data', { method: 'POST', body: JSON.stringify(data) });
|
|
38
|
-
* // Clear cache so back/forward navigation shows fresh data
|
|
39
|
-
* clear();
|
|
40
|
-
* }
|
|
41
|
-
*
|
|
42
|
-
* return <button onClick={handleSave}>Save</button>;
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
export function useClientCache(): ClientCacheControls {
|
|
47
|
-
const ctx = useContext(NavigationStoreContext);
|
|
48
|
-
|
|
49
|
-
if (!ctx) {
|
|
50
|
-
throw new Error("useClientCache must be used within NavigationProvider");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const clear = useCallback(() => {
|
|
54
|
-
ctx.store.clearHistoryCache();
|
|
55
|
-
}, [ctx]);
|
|
56
|
-
|
|
57
|
-
return { clear };
|
|
58
|
-
}
|
package/src/browser/shallow.ts
DELETED
|
@@ -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
|
-
}
|