@rangojs/router 0.24.4 → 0.26.0
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/README.md +1 -0
- package/dist/bin/rango.js +363 -39
- package/dist/testing/vitest.js +37 -4
- package/dist/types/browser/event-controller.d.ts +24 -5
- package/dist/types/browser/intercept-utils.d.ts +5 -2
- package/dist/types/browser/merge-segment-loaders.d.ts +0 -23
- package/dist/types/browser/navigation-transaction.d.ts +5 -5
- package/dist/types/browser/partial-update.d.ts +21 -13
- package/dist/types/browser/prefetch/cache.d.ts +8 -0
- package/dist/types/browser/rango-marker.d.ts +7 -0
- package/dist/types/browser/react/filter-segment-order.d.ts +10 -0
- package/dist/types/browser/react/use-handle.d.ts +20 -0
- package/dist/types/browser/react/use-href.d.ts +6 -0
- package/dist/types/browser/react/use-router.d.ts +6 -1
- package/dist/types/browser/response-adapter.d.ts +5 -3
- package/dist/types/browser/scroll-restoration.d.ts +9 -3
- package/dist/types/browser/segment-reconciler.d.ts +10 -13
- package/dist/types/browser/types.d.ts +38 -8
- package/dist/types/build/route-types/per-module-writer.d.ts +12 -0
- package/dist/types/cache/cf/cf-cache-store.d.ts +0 -2
- package/dist/types/cache/cf/cf-cache-types.d.ts +0 -16
- package/dist/types/cache/cf/cf-shell-frame.d.ts +2 -0
- package/dist/types/cache/handle-snapshot.d.ts +2 -2
- package/dist/types/cache/types.d.ts +16 -6
- package/dist/types/cache/vercel/vercel-cache-store.d.ts +1 -15
- package/dist/types/client-urls/client-urls.d.ts +6 -2
- package/dist/types/client-urls/revalidate-registry.d.ts +1 -1
- package/dist/types/client-urls/server-projection.d.ts +9 -5
- package/dist/types/client-urls/types.d.ts +29 -16
- package/dist/types/client.d.ts +2 -2
- package/dist/types/client.rsc.d.ts +2 -2
- package/dist/types/decode-loader-results.d.ts +28 -7
- package/dist/types/handles/deferred-resolution.d.ts +3 -2
- package/dist/types/handles/meta.d.ts +5 -0
- package/dist/types/href-client.d.ts +3 -1
- package/dist/types/index.rsc.d.ts +1 -1
- package/dist/types/loader-redirect.d.ts +2 -3
- package/dist/types/outlet-context.d.ts +7 -6
- package/dist/types/prefetch-markers.d.ts +14 -5
- package/dist/types/prerender/build-shell-capture.d.ts +1 -2
- package/dist/types/prerender/writable-store.d.ts +2 -3
- package/dist/types/route-content-wrapper.d.ts +17 -14
- package/dist/types/route-definition/helpers-types.d.ts +7 -2
- package/dist/types/route-definition/resolve-handler-use.d.ts +6 -1
- package/dist/types/route-definition/rewrite.d.ts +48 -5
- package/dist/types/route-types.d.ts +2 -2
- package/dist/types/router/handler-context.d.ts +14 -2
- package/dist/types/router/intercept-resolution.d.ts +19 -46
- package/dist/types/router/lazy-includes.d.ts +7 -0
- package/dist/types/router/match-middleware/intercept-resolution.d.ts +2 -2
- package/dist/types/router/middleware.d.ts +0 -16
- package/dist/types/router/navigation-snapshot.d.ts +2 -0
- package/dist/types/router/prefetch-cache-ttl.d.ts +8 -11
- package/dist/types/router/revalidation.d.ts +8 -1
- package/dist/types/router/router-context.d.ts +4 -16
- package/dist/types/router/router-interfaces.d.ts +0 -11
- package/dist/types/router/router-options.d.ts +4 -27
- package/dist/types/router/segment-resolution/mask-nested.d.ts +5 -3
- package/dist/types/router/segment-resolution/prefetch-deferral.d.ts +31 -8
- package/dist/types/router/segment-resolution/revalidation.d.ts +38 -4
- package/dist/types/router/segment-resolution.d.ts +1 -1
- package/dist/types/router/segment-wrappers.d.ts +3 -5
- package/dist/types/router/substitute-pattern-params.d.ts +3 -2
- package/dist/types/router/tracing.d.ts +2 -2
- package/dist/types/router-versions.d.ts +8 -6
- package/dist/types/rsc/full-payload.d.ts +14 -2
- package/dist/types/rsc/helpers.d.ts +8 -0
- package/dist/types/rsc/manifest-init.d.ts +20 -0
- package/dist/types/rsc/prefetch-render-error.d.ts +22 -0
- package/dist/types/rsc/progressive-enhancement.d.ts +20 -0
- package/dist/types/rsc/rewrite-passes.d.ts +12 -2
- package/dist/types/rsc/server-action.d.ts +6 -0
- package/dist/types/rsc/shell-capture-constants.d.ts +14 -4
- package/dist/types/rsc/shell-capture.d.ts +23 -2
- package/dist/types/rsc/types.d.ts +5 -8
- package/dist/types/segment-system.d.ts +15 -0
- package/dist/types/server/build-version-table.d.ts +10 -13
- package/dist/types/server/context.d.ts +90 -6
- package/dist/types/server/handle-store.d.ts +17 -6
- package/dist/types/server/request-context.d.ts +45 -7
- package/dist/types/server/request-headers.d.ts +12 -0
- package/dist/types/server/rewrite-trail.d.ts +8 -1
- package/dist/types/testing/build-versions.d.ts +0 -3
- package/dist/types/testing/e2e/index.d.ts +1 -1
- package/dist/types/testing/flight.entry.d.ts +1 -1
- package/dist/types/testing/index.d.ts +1 -1
- package/dist/types/testing/internal/client-urls-projection.d.ts +4 -3
- package/dist/types/testing/internal/seed-vars.d.ts +4 -4
- package/dist/types/testing/render-route.d.ts +21 -11
- package/dist/types/testing/run-loader.d.ts +7 -0
- package/dist/types/testing/run-middleware.d.ts +7 -0
- package/dist/types/testing/run-revalidate.d.ts +5 -4
- package/dist/types/testing/serve-shell-request.d.ts +42 -5
- package/dist/types/testing/shell-status.d.ts +17 -0
- package/dist/types/testing/vitest-stubs/version.d.ts +1 -0
- package/dist/types/testing/vitest.d.ts +10 -1
- package/dist/types/thenable-status.d.ts +0 -6
- package/dist/types/types/handler-context.d.ts +12 -1
- package/dist/types/types/loader-types.d.ts +10 -4
- package/dist/types/types/route-entry.d.ts +2 -1
- package/dist/types/urls/path-helper-types.d.ts +4 -2
- package/dist/types/vite/discovery/client-urls-projection.d.ts +55 -5
- package/dist/types/vite/discovery/state.d.ts +20 -0
- package/dist/types/vite/plugins/client-urls-revalidate-hoist.d.ts +28 -16
- package/dist/types/vite/plugins/hoist/source.d.ts +8 -7
- package/dist/types/vite/plugins/virtual-entries.d.ts +6 -0
- package/dist/types/vite/utils/prerender-utils.d.ts +7 -0
- package/dist/vite/index.js +6819 -6555
- package/package.json +1 -1
- package/skills/app-structure/SKILL.md +255 -0
- package/skills/app-structure/content-site.md +333 -0
- package/skills/app-structure/e-commerce.md +435 -0
- package/skills/app-structure/large-app.md +885 -0
- package/skills/app-structure/multi-app.md +280 -0
- package/skills/breadcrumbs/SKILL.md +6 -1
- package/skills/cache-guide/SKILL.md +4 -8
- package/skills/caching/SKILL.md +6 -6
- package/skills/catalog.json +12 -0
- package/skills/client-urls/SKILL.md +185 -32
- package/skills/comparison/references/framework-comparison.md +1 -1
- package/skills/composability/SKILL.md +10 -8
- package/skills/handler-use/SKILL.md +48 -9
- package/skills/hooks/handle-and-actions.md +104 -0
- package/skills/hooks/navigation.md +24 -10
- package/skills/hooks/urls.md +1 -1
- package/skills/host-router/SKILL.md +1 -1
- package/skills/i18n/SKILL.md +2 -1
- package/skills/intercept/SKILL.md +60 -29
- package/skills/layout/SKILL.md +6 -3
- package/skills/links/SKILL.md +151 -17
- package/skills/loader/SKILL.md +42 -19
- package/skills/middleware/SKILL.md +111 -15
- package/skills/observability/SKILL.md +11 -0
- package/skills/parallel/SKILL.md +5 -5
- package/skills/ppr/SKILL.md +103 -52
- package/skills/prerender/SKILL.md +4 -5
- package/skills/rango/SKILL.md +3 -0
- package/skills/response-routes/SKILL.md +4 -1
- package/skills/router-setup/SKILL.md +0 -2
- package/skills/scripts/SKILL.md +12 -1
- package/skills/server-actions/SKILL.md +60 -20
- package/skills/testing/SKILL.md +1 -0
- package/skills/testing/client-components.md +13 -10
- package/skills/testing/loader.md +25 -24
- package/skills/testing/middleware.md +11 -11
- package/skills/testing/render-handler.md +17 -17
- package/skills/testing/response-routes.md +4 -1
- package/skills/testing/serve-shell-request.md +86 -22
- package/skills/testing/server-actions.md +16 -16
- package/skills/ux-architecture/SKILL.md +980 -0
- package/skills/vercel/SKILL.md +1 -1
- package/skills/view-transitions/SKILL.md +43 -10
- package/src/__augment-tests__/augmented.check.ts +28 -0
- package/src/browser/event-controller.ts +44 -18
- package/src/browser/intercept-utils.ts +3 -2
- package/src/browser/merge-segment-loaders.ts +0 -85
- package/src/browser/navigation-bridge.ts +112 -84
- package/src/browser/navigation-client.ts +20 -15
- package/src/browser/navigation-store.ts +4 -2
- package/src/browser/navigation-transaction.ts +9 -8
- package/src/browser/partial-update.ts +90 -32
- package/src/browser/prefetch/cache.ts +8 -0
- package/src/browser/prefetch/fetch.ts +13 -3
- package/src/browser/rango-marker.ts +13 -0
- package/src/browser/react/NavigationProvider.tsx +25 -7
- package/src/browser/react/filter-segment-order.ts +13 -0
- package/src/browser/react/use-action.ts +9 -15
- package/src/browser/react/use-handle.ts +63 -71
- package/src/browser/react/use-href.tsx +24 -5
- package/src/browser/react/use-link-status.ts +1 -1
- package/src/browser/react/use-navigation.ts +30 -40
- package/src/browser/react/use-router.ts +37 -6
- package/src/browser/react/use-segments.ts +8 -12
- package/src/browser/response-adapter.ts +11 -5
- package/src/browser/rsc-router.tsx +3 -1
- package/src/browser/scroll-restoration.ts +34 -20
- package/src/browser/segment-reconciler.ts +11 -29
- package/src/browser/server-action-bridge.ts +52 -16
- package/src/browser/types.ts +40 -8
- package/src/build/generate-manifest.ts +12 -1
- package/src/build/route-types/codegen.ts +6 -2
- package/src/build/route-types/per-module-writer.ts +94 -61
- package/src/cache/cache-runtime.ts +9 -0
- package/src/cache/cache-scope.ts +2 -1
- package/src/cache/cf/cf-cache-store.ts +6 -7
- package/src/cache/cf/cf-cache-types.ts +0 -17
- package/src/cache/cf/cf-shell-frame.ts +3 -0
- package/src/cache/handle-snapshot.ts +2 -2
- package/src/cache/types.ts +16 -6
- package/src/cache/vercel/vercel-cache-store.ts +8 -19
- package/src/client-urls/client-urls.ts +202 -153
- package/src/client-urls/revalidate-registry.ts +12 -3
- package/src/client-urls/server-projection.ts +137 -66
- package/src/client-urls/types.ts +30 -15
- package/src/client.rsc.tsx +11 -1
- package/src/client.tsx +9 -1
- package/src/decode-loader-results.ts +64 -31
- package/src/handles/deferred-resolution.ts +3 -2
- package/src/handles/meta.ts +5 -0
- package/src/href-client.ts +3 -1
- package/src/index.rsc.ts +1 -0
- package/src/index.ts +12 -4
- package/src/loader-redirect.tsx +2 -3
- package/src/outlet-context.ts +7 -6
- package/src/prefetch-markers.ts +15 -5
- package/src/prerender/build-shell-capture.ts +1 -2
- package/src/prerender/writable-store.ts +2 -3
- package/src/reverse.ts +3 -3
- package/src/route-content-wrapper.tsx +19 -17
- package/src/route-definition/dsl-helpers.ts +41 -21
- package/src/route-definition/helpers-types.ts +7 -2
- package/src/route-definition/resolve-handler-use.ts +23 -10
- package/src/route-definition/rewrite.ts +86 -19
- package/src/route-types.ts +1 -2
- package/src/router/find-match.ts +37 -1
- package/src/router/handler-context.ts +85 -40
- package/src/router/intercept-resolution.ts +161 -307
- package/src/router/lazy-includes.ts +43 -27
- package/src/router/loader-resolution.ts +21 -1
- package/src/router/manifest.ts +15 -10
- package/src/router/match-api.ts +11 -1
- package/src/router/match-middleware/background-revalidation.ts +2 -4
- package/src/router/match-middleware/cache-lookup.ts +16 -20
- package/src/router/match-middleware/intercept-resolution.ts +41 -60
- package/src/router/match-result.ts +31 -2
- package/src/router/middleware.ts +6 -147
- package/src/router/navigation-snapshot.ts +38 -2
- package/src/router/prefetch-cache-ttl.ts +10 -18
- package/src/router/prerender-match.ts +2 -1
- package/src/router/revalidation.ts +24 -3
- package/src/router/router-context.ts +5 -18
- package/src/router/router-interfaces.ts +0 -13
- package/src/router/router-options.ts +4 -28
- package/src/router/segment-resolution/fresh.ts +6 -2
- package/src/router/segment-resolution/helpers.ts +7 -1
- package/src/router/segment-resolution/loader-cache.ts +4 -3
- package/src/router/segment-resolution/mask-nested.ts +5 -3
- package/src/router/segment-resolution/prefetch-deferral.ts +62 -12
- package/src/router/segment-resolution/revalidation.ts +75 -35
- package/src/router/segment-resolution.ts +0 -1
- package/src/router/segment-wrappers.ts +8 -13
- package/src/router/substitute-pattern-params.ts +3 -2
- package/src/router/tracing.ts +2 -2
- package/src/router-versions.ts +7 -7
- package/src/router.ts +5 -17
- package/src/rsc/full-payload.ts +26 -4
- package/src/rsc/handler.ts +86 -48
- package/src/rsc/helpers.ts +13 -0
- package/src/rsc/manifest-init.ts +56 -3
- package/src/rsc/prefetch-render-error.ts +38 -0
- package/src/rsc/progressive-enhancement.ts +161 -211
- package/src/rsc/rewrite-passes.ts +56 -9
- package/src/rsc/rsc-rendering.ts +79 -23
- package/src/rsc/server-action.ts +25 -2
- package/src/rsc/shell-capture-constants.ts +26 -3
- package/src/rsc/shell-capture.ts +137 -51
- package/src/rsc/types.ts +5 -9
- package/src/segment-system.tsx +125 -119
- package/src/server/build-version-table.ts +12 -24
- package/src/server/context.ts +160 -7
- package/src/server/handle-store.ts +80 -12
- package/src/server/request-context.ts +46 -6
- package/src/server/request-headers.ts +32 -0
- package/src/server/rewrite-trail.ts +55 -9
- package/src/ssr/ssr-root.tsx +6 -10
- package/src/testing/build-versions.ts +0 -3
- package/src/testing/dispatch.ts +5 -8
- package/src/testing/e2e/index.ts +1 -0
- package/src/testing/flight.entry.ts +1 -0
- package/src/testing/index.ts +1 -0
- package/src/testing/internal/client-urls-projection.ts +31 -11
- package/src/testing/internal/seed-vars.ts +4 -4
- package/src/testing/render-route.tsx +83 -40
- package/src/testing/run-loader.ts +26 -2
- package/src/testing/run-middleware.ts +10 -0
- package/src/testing/run-revalidate.ts +13 -6
- package/src/testing/serve-shell-request.ts +79 -9
- package/src/testing/shell-status.ts +40 -0
- package/src/testing/vitest-stubs/version.ts +1 -0
- package/src/testing/vitest.ts +74 -7
- package/src/thenable-status.ts +0 -11
- package/src/types/handler-context.ts +12 -1
- package/src/types/loader-types.ts +10 -4
- package/src/types/route-entry.ts +2 -1
- package/src/urls/include-helper.ts +38 -11
- package/src/urls/path-helper-types.ts +4 -2
- package/src/vite/discovery/client-urls-projection.ts +205 -16
- package/src/vite/discovery/discover-routers.ts +2 -2
- package/src/vite/discovery/prerender-collection.ts +2 -6
- package/src/vite/discovery/shell-prerender-phase.ts +1 -5
- package/src/vite/discovery/state.ts +26 -0
- package/src/vite/plugins/client-urls-revalidate-hoist.ts +190 -77
- package/src/vite/plugins/expose-internal-ids.ts +46 -40
- package/src/vite/plugins/hoist/source.ts +8 -7
- package/src/vite/plugins/transition-when-hoist.ts +1 -0
- package/src/vite/plugins/version-plugin.ts +7 -0
- package/src/vite/plugins/version.d.ts +7 -0
- package/src/vite/plugins/virtual-entries.ts +20 -0
- package/src/vite/rango.ts +4 -1
- package/src/vite/router-discovery.ts +39 -7
- package/src/vite/utils/prerender-utils.ts +17 -0
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import type { EntryData, InterceptEntry, InterceptSelectorContext } from "../server/context";
|
|
8
8
|
import type { HandlerContext, ResolvedSegment } from "../types";
|
|
9
9
|
import type { SegmentResolutionDeps } from "./types.js";
|
|
10
|
+
import type { RevalidationContext } from "./router-context.js";
|
|
10
11
|
/**
|
|
11
12
|
* Check if an intercept's when conditions are satisfied.
|
|
12
13
|
* All when() functions must return true for the intercept to activate.
|
|
@@ -37,57 +38,29 @@ export declare function findInterceptForRoute(targetRouteKey: string, fromEntry:
|
|
|
37
38
|
intercept: InterceptEntry;
|
|
38
39
|
entry: EntryData;
|
|
39
40
|
} | null;
|
|
41
|
+
/** The segment id of `intercept`'s slot on `parentEntry`. */
|
|
42
|
+
export declare function interceptSlotId(parentEntry: EntryData, intercept: InterceptEntry): string;
|
|
40
43
|
/**
|
|
41
|
-
*
|
|
44
|
+
* Every segment id an intercept's slot owns, in order: the slot, then one
|
|
45
|
+
* loader segment per loader in declaration order, run or not. A request that
|
|
46
|
+
* resolves the intercept lists them in `matched` (match-result.ts).
|
|
42
47
|
*/
|
|
43
|
-
export declare function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
nextUrl: URL;
|
|
49
|
-
routeKey: string;
|
|
50
|
-
actionContext?: {
|
|
51
|
-
actionId?: string;
|
|
52
|
-
actionUrl?: URL;
|
|
53
|
-
actionResult?: any;
|
|
54
|
-
formData?: FormData;
|
|
55
|
-
};
|
|
56
|
-
stale?: boolean;
|
|
57
|
-
}, options?: {
|
|
48
|
+
export declare function interceptSegmentIds(parentEntry: EntryData, intercept: InterceptEntry): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Resolve an intercept entry: its slot segment, then its loader segments.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveInterceptEntry<TEnv>(interceptEntry: InterceptEntry, parentEntry: EntryData, params: Record<string, string>, context: HandlerContext<any, TEnv>, belongsToRoute: boolean, deps: SegmentResolutionDeps<TEnv>, revalidationContext?: RevalidationContext, options?: {
|
|
58
53
|
/**
|
|
59
|
-
*
|
|
60
|
-
* background re-render paths (proactive caching, stale background
|
|
54
|
+
* Set ONLY by the post-response background re-render (stale background
|
|
61
55
|
* revalidation), whose sole purpose is to re-render the segment tree to
|
|
62
|
-
* populate the cache
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* which the background render reuses. Re-running middleware here would fire
|
|
66
|
-
* its side effects a SECOND time, and a middleware that short-circuits with
|
|
67
|
-
* a Response would `throw` and silently abort the cache write. Never set on
|
|
68
|
-
* the foreground path.
|
|
56
|
+
* populate the cache: a handler error rejects instead of rendering the
|
|
57
|
+
* error boundary, so a failure is never cached. Never set on the
|
|
58
|
+
* foreground path.
|
|
69
59
|
*/
|
|
70
|
-
|
|
60
|
+
background?: boolean;
|
|
71
61
|
}): Promise<ResolvedSegment[]>;
|
|
72
62
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
63
|
+
* The loader segments of a cached intercept slot, on a cache hit: the slot
|
|
64
|
+
* keeps its cached component and layout, its loaders are never cached.
|
|
75
65
|
*/
|
|
76
|
-
export declare function resolveInterceptLoadersOnly<TEnv>(interceptEntry: InterceptEntry, parentEntry: EntryData,
|
|
77
|
-
clientSegmentIds: Set<string>;
|
|
78
|
-
prevParams: Record<string, string>;
|
|
79
|
-
request: Request;
|
|
80
|
-
prevUrl: URL;
|
|
81
|
-
nextUrl: URL;
|
|
82
|
-
routeKey: string;
|
|
83
|
-
actionContext?: {
|
|
84
|
-
actionId?: string;
|
|
85
|
-
actionUrl?: URL;
|
|
86
|
-
actionResult?: any;
|
|
87
|
-
formData?: FormData;
|
|
88
|
-
};
|
|
89
|
-
stale?: boolean;
|
|
90
|
-
}): Promise<{
|
|
91
|
-
loaderDataPromise: Promise<any[]> | any[];
|
|
92
|
-
loaderIds: string[];
|
|
93
|
-
} | null>;
|
|
66
|
+
export declare function resolveInterceptLoadersOnly<TEnv>(interceptEntry: InterceptEntry, parentEntry: EntryData, context: HandlerContext<any, TEnv>, belongsToRoute: boolean, deps: SegmentResolutionDeps<TEnv>, revalidationContext: RevalidationContext): Promise<ResolvedSegment[]>;
|
|
@@ -24,3 +24,10 @@ export declare function findLazyIncludes<TEnv = any>(items: AllUseItems[]): Arra
|
|
|
24
24
|
* Also detects nested lazy includes and registers them as new entries
|
|
25
25
|
*/
|
|
26
26
|
export declare function evaluateLazyEntry<TEnv = any>(entry: RouteEntry<TEnv>, deps: LazyEvalDeps<TEnv>): void | Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve an async include entry's provider once and cache the patterns on
|
|
29
|
+
* `entry.lazyPatterns`. Concurrent callers (match-time expansion and
|
|
30
|
+
* render-time loadManifest) share one in-flight import; it clears when it
|
|
31
|
+
* settles, so a rejected import is retried by the next request.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveEntryPatterns<TEnv = any>(entry: RouteEntry<TEnv>): Promise<UrlPatterns<TEnv>>;
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* v
|
|
30
30
|
* +----------------------+ +----------------------------+
|
|
31
31
|
* | Fresh intercept? |yes>| resolveInterceptEntry() |
|
|
32
|
-
* | (!cacheHit or | | -
|
|
32
|
+
* | (!cacheHit or | | - loaders, UI |
|
|
33
33
|
* | no intercept segs) | +----------------------------+
|
|
34
34
|
* +----------------------+ |
|
|
35
35
|
* | no v
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
*
|
|
60
60
|
* 1. Fresh intercept (no cache):
|
|
61
61
|
* - Full resolution of intercept entry
|
|
62
|
-
* - Resolves
|
|
62
|
+
* - Resolves loaders and component
|
|
63
63
|
* - Yields all intercept segments
|
|
64
64
|
*
|
|
65
65
|
* 2. Cache hit with intercept:
|
|
@@ -80,22 +80,6 @@ export declare function executeMiddleware<TEnv>(middlewares: Array<{
|
|
|
80
80
|
entry: MiddlewareEntry<TEnv>;
|
|
81
81
|
params: Record<string, string>;
|
|
82
82
|
}>, request: Request, env: TEnv, variables: Record<string, any>, finalHandler: () => Promise<Response>, reverse?: (name: string, params?: Record<string, string>, search?: Record<string, unknown>) => string): Promise<Response>;
|
|
83
|
-
/**
|
|
84
|
-
* Execute middleware for intercepts (simplified execution)
|
|
85
|
-
*
|
|
86
|
-
* Intercepts use a shared stubResponse from the request context. This function:
|
|
87
|
-
* - Runs middleware in sequence with a simple next() chain
|
|
88
|
-
* - Returns Response if any middleware short-circuits (returns OR throws a Response, or redirects, BEFORE next())
|
|
89
|
-
* - Returns null if all middleware calls next() - headers set after next() remain on stubResponse
|
|
90
|
-
*
|
|
91
|
-
* @param middlewares - Array of middleware functions
|
|
92
|
-
* @param request - Original request
|
|
93
|
-
* @param env - Environment bindings
|
|
94
|
-
* @param params - Route params
|
|
95
|
-
* @param variables - Shared variables object
|
|
96
|
-
* @param stubResponse - Response from request context for collecting headers/cookies
|
|
97
|
-
*/
|
|
98
|
-
export declare function executeInterceptMiddleware<TEnv>(middlewares: MiddlewareFn<TEnv>[], request: Request, env: TEnv, params: Record<string, string>, variables: Record<string, any>, stubResponse: Response, reverse?: (name: string, params?: Record<string, string>, search?: Record<string, unknown>) => string): Promise<Response | null>;
|
|
99
83
|
/**
|
|
100
84
|
* Execute middleware chain for loaders (simpler signature)
|
|
101
85
|
*
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { RouteMatchResult } from "./pattern-matching.js";
|
|
2
2
|
export interface NavigationSnapshot {
|
|
3
3
|
prevUrl: URL;
|
|
4
|
+
/** The visitor's URL of the page left, when `prevUrl` is its rewrite target. */
|
|
5
|
+
prevVisitorUrl: URL | null;
|
|
4
6
|
prevParams: Record<string, string>;
|
|
5
7
|
prevMatch: RouteMatchResult | null;
|
|
6
8
|
interceptContextUrl: URL;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resolve the prefetch cache TTL once, at router init, into the
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Cache-Control
|
|
2
|
+
* Resolve the prefetch cache TTL once, at router init, into the values the
|
|
3
|
+
* rest of the router consumes: seconds, and milliseconds for the client-side
|
|
4
|
+
* in-memory prefetch cache (shipped in payload metadata). Prefetch responses
|
|
5
|
+
* carry no Cache-Control: the browser HTTP cache would keep a prefetch whose
|
|
6
|
+
* render failed after its 200 went out (#1170).
|
|
6
7
|
*
|
|
7
8
|
* `false` disables prefetch caching (seconds 0). A non-finite input
|
|
8
9
|
* (NaN/Infinity, e.g. from an env-derived number that failed to parse) is
|
|
9
|
-
* treated as the default rather than
|
|
10
|
-
*
|
|
11
|
-
* which would silently disable caching on EVERY prefetch response. Negative
|
|
12
|
-
* finite values clamp to 0 (disabled).
|
|
10
|
+
* treated as the default rather than disabling the cache. Negative finite
|
|
11
|
+
* values clamp to 0 (disabled).
|
|
13
12
|
*
|
|
14
13
|
* Policy note: this is the prefetch-TTL policy specifically. Other finite-number
|
|
15
14
|
* guards in the codebase deliberately differ — defer.ts treats Infinity as an
|
|
@@ -17,11 +16,9 @@
|
|
|
17
16
|
* at config time. They are NOT the same guard, so don't unify them.
|
|
18
17
|
*/
|
|
19
18
|
export interface ResolvedPrefetchCacheTTL {
|
|
20
|
-
/** TTL in seconds
|
|
19
|
+
/** TTL in seconds. */
|
|
21
20
|
seconds: number;
|
|
22
21
|
/** TTL in milliseconds for the client-side in-memory prefetch cache. */
|
|
23
22
|
ms: number;
|
|
24
|
-
/** Cache-Control header value, or false when caching is disabled. */
|
|
25
|
-
cacheControl: string | false;
|
|
26
23
|
}
|
|
27
24
|
export declare function resolvePrefetchCacheTTL(rawTTL: number | false | undefined): ResolvedPrefetchCacheTTL;
|
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Evaluates whether segments should revalidate based on params, actions, and custom functions.
|
|
5
5
|
*/
|
|
6
|
-
import type { ResolvedSegment, HandlerContext } from "../types";
|
|
6
|
+
import type { ResolvedSegment, HandlerContext, ShouldRevalidateFn } from "../types";
|
|
7
7
|
import type { ActionContext } from "./types";
|
|
8
8
|
import type { RevalidationTraceEntry } from "./logging.js";
|
|
9
|
+
/**
|
|
10
|
+
* The predicate `revalidate(true)` / `revalidate(false)` stands for: the
|
|
11
|
+
* constant hard decision of `revalidate(() => true)` / `() => false`.
|
|
12
|
+
* Booleans are converted where they enter (the urls() helper, clientUrls()
|
|
13
|
+
* materialization, runRevalidate), so evaluation only ever sees functions.
|
|
14
|
+
*/
|
|
15
|
+
export declare function toShouldRevalidateFn(fn: ShouldRevalidateFn<any, any> | boolean): ShouldRevalidateFn<any, any>;
|
|
9
16
|
/**
|
|
10
17
|
* Options for revalidation evaluation
|
|
11
18
|
*/
|
|
@@ -8,7 +8,7 @@ import type { ResolveSegmentOptions } from "./segment-resolution.js";
|
|
|
8
8
|
* Revalidation context passed to segment resolution
|
|
9
9
|
*/
|
|
10
10
|
export interface RevalidationContext {
|
|
11
|
-
clientSegmentIds:
|
|
11
|
+
clientSegmentIds: ReadonlySet<string>;
|
|
12
12
|
prevParams: Record<string, string>;
|
|
13
13
|
request: Request;
|
|
14
14
|
prevUrl: URL;
|
|
@@ -20,7 +20,7 @@ export interface RevalidationContext {
|
|
|
20
20
|
actionResult?: any;
|
|
21
21
|
formData?: FormData;
|
|
22
22
|
};
|
|
23
|
-
stale
|
|
23
|
+
stale?: boolean;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Result from intercept lookup
|
|
@@ -61,7 +61,7 @@ export interface RouterContext<TEnv = any> {
|
|
|
61
61
|
id: string;
|
|
62
62
|
}>;
|
|
63
63
|
resolveInterceptEntry: (intercept: InterceptEntry, entry: EntryData, params: Record<string, string>, handlerContext: HandlerContext<any, TEnv>, belongsToRoute: boolean, revalidationContext?: RevalidationContext, options?: {
|
|
64
|
-
|
|
64
|
+
background?: boolean;
|
|
65
65
|
}) => Promise<ResolvedSegment[]>;
|
|
66
66
|
collectWithMarkers?: <T>(gen: AsyncGenerator<T | {
|
|
67
67
|
__type: "id";
|
|
@@ -111,19 +111,7 @@ export interface RouterContext<TEnv = any> {
|
|
|
111
111
|
}>;
|
|
112
112
|
telemetry?: TelemetrySink;
|
|
113
113
|
requestId?: string;
|
|
114
|
-
resolveInterceptLoadersOnly?: (intercept: InterceptEntry, entry: EntryData,
|
|
115
|
-
clientSegmentIds: Set<string>;
|
|
116
|
-
prevParams: Record<string, string>;
|
|
117
|
-
request: Request;
|
|
118
|
-
prevUrl: URL;
|
|
119
|
-
nextUrl: URL;
|
|
120
|
-
routeKey: string;
|
|
121
|
-
actionContext?: any;
|
|
122
|
-
stale?: boolean;
|
|
123
|
-
}) => Promise<{
|
|
124
|
-
loaderDataPromise: Promise<any[]> | any[];
|
|
125
|
-
loaderIds: string[];
|
|
126
|
-
} | null>;
|
|
114
|
+
resolveInterceptLoadersOnly?: (intercept: InterceptEntry, entry: EntryData, handlerContext: HandlerContext<any, TEnv>, belongsToRoute: boolean, revalidationContext: RevalidationContext) => Promise<ResolvedSegment[]>;
|
|
127
115
|
}
|
|
128
116
|
/**
|
|
129
117
|
* Get router dependencies from AsyncLocalStorage context
|
|
@@ -296,12 +296,6 @@ export interface RangoInternal<TEnv = any, TRoutes extends Record<string, unknow
|
|
|
296
296
|
* Always includes at least the "default" profile.
|
|
297
297
|
*/
|
|
298
298
|
readonly cacheProfiles: Record<string, import("../cache/profile-registry.js").CacheProfile>;
|
|
299
|
-
/**
|
|
300
|
-
* Cache-Control header value for prefetch responses.
|
|
301
|
-
* False means no caching of prefetch responses.
|
|
302
|
-
* Derived from prefetchCacheTTL.
|
|
303
|
-
*/
|
|
304
|
-
readonly prefetchCacheControl: string | false;
|
|
305
299
|
/**
|
|
306
300
|
* TTL in milliseconds for the client-side in-memory prefetch cache.
|
|
307
301
|
* 0 means caching is disabled.
|
|
@@ -384,11 +378,6 @@ export interface RangoInternal<TEnv = any, TRoutes extends Record<string, unknow
|
|
|
384
378
|
* Nonce provider for CSP
|
|
385
379
|
*/
|
|
386
380
|
readonly nonce?: NonceProvider<TEnv>;
|
|
387
|
-
/**
|
|
388
|
-
* The consumer-set version (createRouter({ version })), used for both of the
|
|
389
|
-
* router's versions. Undefined when the router uses its build versions.
|
|
390
|
-
*/
|
|
391
|
-
readonly version?: string;
|
|
392
381
|
/**
|
|
393
382
|
* URL patterns reference for build-time manifest generation
|
|
394
383
|
*/
|
|
@@ -490,35 +490,12 @@ export interface RangoOptions<TEnv = any> {
|
|
|
490
490
|
*/
|
|
491
491
|
nonce?: NonceProvider<TEnv>;
|
|
492
492
|
/**
|
|
493
|
-
*
|
|
494
|
-
* router's versions: it keys the router's cached data (segments, `"use
|
|
495
|
-
* cache"` values, loader data) and its stored HTML (PPR shells,
|
|
496
|
-
* document-cache responses), is sent in payload metadata, and is what the
|
|
497
|
-
* browser's `_rsc_v` is compared with (a mismatch reloads the tab).
|
|
498
|
-
*
|
|
499
|
-
* Leave it unset for the default: rango computes two versions per router at
|
|
500
|
-
* build time, a data version from the router's server code and a document
|
|
501
|
-
* version that also covers the client assets. The same code builds to the
|
|
502
|
-
* same versions, so a deploy that does not change this router keeps its
|
|
503
|
-
* cache. In dev both are a stamp bumped on every RSC module edit.
|
|
504
|
-
*
|
|
505
|
-
* Set it to clear this router's cache on demand (change the value), or to
|
|
506
|
-
* tie the cache to your own release id (a per-deploy value clears the cache
|
|
507
|
-
* on every deploy).
|
|
508
|
-
*
|
|
509
|
-
* @default the router's build versions
|
|
510
|
-
*/
|
|
511
|
-
version?: string;
|
|
512
|
-
/**
|
|
513
|
-
* TTL (in seconds) for the in-memory prefetch cache and the
|
|
514
|
-
* Cache-Control header on prefetch responses.
|
|
493
|
+
* TTL (in seconds) for the client-side in-memory prefetch cache.
|
|
515
494
|
*
|
|
516
495
|
* Controls how long prefetch responses are kept in the client-side
|
|
517
|
-
* in-memory cache
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
* intercept targets gets no prefetch `Cache-Control`: whether its
|
|
521
|
-
* response is the modal or the full page depends on the source page.
|
|
496
|
+
* in-memory cache. Prefetch responses carry no `Cache-Control`, so the
|
|
497
|
+
* browser's HTTP cache does not keep them: a prefetch whose render failed
|
|
498
|
+
* after its 200 went out would otherwise answer later requests.
|
|
522
499
|
*
|
|
523
500
|
* The cache is automatically invalidated on server actions regardless
|
|
524
501
|
* of TTL, so this is primarily a staleness safety net.
|
|
@@ -59,9 +59,11 @@ export declare function settleNestedThenables(value: unknown): Promise<void>;
|
|
|
59
59
|
/**
|
|
60
60
|
* True when `value` is a thenable or holds one where the capture's loader
|
|
61
61
|
* push funnel masks it (maskNestedContainerThenables): through plain data
|
|
62
|
-
* objects, arrays and React element props.
|
|
63
|
-
* record and reaches a HIT only from a run of its
|
|
64
|
-
* keeps it; a push without one is the record's
|
|
62
|
+
* objects, arrays and React element props. A settled push that holds one
|
|
63
|
+
* stays out of a shell's record and reaches a HIT only from a run of its
|
|
64
|
+
* loader there, so a HIT keeps it; a push without one is the record's
|
|
65
|
+
* (HandleStore.pushRestored). A top-level thenable is judged by the value it
|
|
66
|
+
* settles to, on both sides (#1182).
|
|
65
67
|
*/
|
|
66
68
|
export declare function holdsThenable(value: unknown): boolean;
|
|
67
69
|
/**
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* force a same-route render from an intercept source (match-api.ts), and a
|
|
25
25
|
* unit deferred on that ground would be dropped from the response as held.
|
|
26
26
|
*/
|
|
27
|
-
import { type EntryData, type LoaderEntry } from "../../server/context.js";
|
|
27
|
+
import { type EntryData, type InterceptEntry, type LoaderEntry } from "../../server/context.js";
|
|
28
28
|
import type { HandlerContext } from "../../types.js";
|
|
29
29
|
import type { CacheScope } from "../../cache/cache-scope.js";
|
|
30
30
|
/**
|
|
@@ -148,33 +148,42 @@ export interface DeferredLoader {
|
|
|
148
148
|
* in the tree declares `prefetch: false`.
|
|
149
149
|
*/
|
|
150
150
|
export declare function resolveDeferralScope(entries: readonly EntryData[]): DeferralScope;
|
|
151
|
+
/**
|
|
152
|
+
* The deferral scope of a request that resolves `intercept`: its own flagged
|
|
153
|
+
* loaders, nothing of the target chain. The chain's layouts below the
|
|
154
|
+
* declaring entry render in that request and its `matched` leaves them out
|
|
155
|
+
* (match-result.ts), so a hole there would stand for a segment outside the
|
|
156
|
+
* page. A flagged loading() inside intercept() defers nothing: the slot is
|
|
157
|
+
* never a unit. Memoized on the entry (replaced with its manifest on HMR).
|
|
158
|
+
*/
|
|
159
|
+
export declare function resolveInterceptDeferralScope(intercept: InterceptEntry): DeferralScope;
|
|
151
160
|
/**
|
|
152
161
|
* Which half of the feature a partial request is, if either (`fill` and
|
|
153
162
|
* `prefetch` are requestKind's answer). Both halves are GETs: a request of
|
|
154
163
|
* another method that carries either marker is a normal request. A prefetch
|
|
155
164
|
* defers only on a plain GET navigation: an action re-renders what it
|
|
156
|
-
* changed,
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* runs the full match): each one states its own reason.
|
|
165
|
+
* changed, and a shell capture is never a prefetch whatever the request that
|
|
166
|
+
* scheduled it sent. The conditions overlap today (an action is a POST, a
|
|
167
|
+
* capture runs the full match): each one states its own reason.
|
|
160
168
|
*/
|
|
161
169
|
export declare function partialDeferralMode(request: {
|
|
162
170
|
fill: boolean;
|
|
163
171
|
prefetch: boolean;
|
|
164
172
|
method: string;
|
|
165
173
|
isAction: boolean;
|
|
166
|
-
isIntercept: boolean;
|
|
167
174
|
isShellCapture: boolean;
|
|
168
175
|
}): PrefetchDeferral["mode"];
|
|
176
|
+
export declare const NOTHING_HELD: ReadonlySet<string>;
|
|
169
177
|
/**
|
|
170
178
|
* The plan for one match, or undefined when the tree declares no flag and the
|
|
171
179
|
* request is not a fill (the common case: nothing to carry). `held` is the
|
|
172
|
-
* client's segment ids as the request listed them.
|
|
180
|
+
* client's segment ids as the request listed them. `scope` is the chain's
|
|
181
|
+
* unless the request resolves an intercept (resolveInterceptDeferralScope).
|
|
173
182
|
*/
|
|
174
183
|
export declare function planPrefetchDeferral(entries: readonly EntryData[], mode: PrefetchDeferral["mode"], matched: {
|
|
175
184
|
pr?: boolean;
|
|
176
185
|
od?: boolean;
|
|
177
|
-
}, cacheScope: CacheScope | null | undefined, held?: ReadonlySet<string
|
|
186
|
+
}, cacheScope: CacheScope | null | undefined, held?: ReadonlySet<string>, scope?: DeferralScope): PrefetchDeferral | undefined;
|
|
178
187
|
export declare function getPrefetchDeferral(ctx: HandlerContext<any, any> | undefined): PrefetchDeferral | undefined;
|
|
179
188
|
/** The request is a fill: a held segment is skipped without consulting anything. */
|
|
180
189
|
export declare function isFillRequest(ctx: HandlerContext<any, any>): boolean;
|
|
@@ -186,6 +195,20 @@ export declare function isFillRequest(ctx: HandlerContext<any, any>): boolean;
|
|
|
186
195
|
* deciding site resolves with.
|
|
187
196
|
*/
|
|
188
197
|
export declare function fillSends(ctx: HandlerContext<any, any>, segmentId: string, held: ReadonlySet<string>): boolean | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* A fill that resolves an intercept sends only what the client lacks of the
|
|
200
|
+
* intercept: a target-chain entry (by id) or stored segment it does not hold
|
|
201
|
+
* lies outside the intercept's `matched` (match-result.ts), so the fill skips
|
|
202
|
+
* it. The intercept's own segments are never skipped.
|
|
203
|
+
*/
|
|
204
|
+
export declare function interceptFillSkips(match: {
|
|
205
|
+
handlerContext: HandlerContext<any, any>;
|
|
206
|
+
isIntercept: boolean;
|
|
207
|
+
clientSegmentSet: ReadonlySet<string>;
|
|
208
|
+
}, segment: string | {
|
|
209
|
+
id: string;
|
|
210
|
+
namespace?: string;
|
|
211
|
+
}): boolean;
|
|
189
212
|
/** PrefetchDeferral.record, or all of it open when the match has no plan. */
|
|
190
213
|
export declare function recordUse(ctx: HandlerContext<any, any> | undefined): RecordUse;
|
|
191
214
|
/**
|
|
@@ -5,14 +5,48 @@
|
|
|
5
5
|
* Mirrors the fresh path but adds revalidation awareness: only re-resolves
|
|
6
6
|
* segments whose revalidate() predicate returns true.
|
|
7
7
|
*/
|
|
8
|
-
import { type EntryData } from "../../server/context";
|
|
8
|
+
import { type EntryData, type LoaderEntry } from "../../server/context";
|
|
9
9
|
import type { HandlerContext, ResolvedSegment, ShouldRevalidateFn } from "../../types";
|
|
10
10
|
import type { SegmentResolutionDeps, SegmentRevalidationResult, ActionContext } from "../types.js";
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* A deferred loader something started in this request (a handler that awaits
|
|
13
|
+
* it with ctx.use(), or another loader) ran in the prefetch whatever its flag
|
|
14
|
+
* says: deliver that run instead of having the fill run it a second time. A
|
|
15
|
+
* reader starts it through its registration (prefetch-deferral.ts
|
|
16
|
+
* startDeferredLoader), so the delivery's resolveLoaderData finds the same
|
|
17
|
+
* run or cache() binding. Called once resolution has awaited every handler it
|
|
18
|
+
* awaits; a streamed handler that reads the loader later is not seen, and
|
|
19
|
+
* that loader runs again in the fill.
|
|
14
20
|
*/
|
|
15
|
-
export declare function
|
|
21
|
+
export declare function deliverStartedLoaders<TEnv>(ctx: HandlerContext<any, TEnv>, segments: ResolvedSegment[]): void;
|
|
22
|
+
/**
|
|
23
|
+
* Whose loaders a resolveOwnerLoaders call resolves: a route entry's (or the
|
|
24
|
+
* entry its loaders are inherited into), or an intercept's, whose loaders are
|
|
25
|
+
* loader segments of its slot (`${parent}.${slot}D${i}.${$$id}`).
|
|
26
|
+
*/
|
|
27
|
+
export interface LoaderOwner {
|
|
28
|
+
readonly loaders: readonly LoaderEntry[];
|
|
29
|
+
/** The segments' namespace: the entry id, or `intercept:${routeName}`. */
|
|
30
|
+
readonly namespace: string;
|
|
31
|
+
/** The segment id the loader ids extend and the handle pushes file under. */
|
|
32
|
+
readonly segmentPrefix: string;
|
|
33
|
+
/** Where a loader error renders (wrapLoaderPromise). */
|
|
34
|
+
readonly boundary: EntryData;
|
|
35
|
+
/**
|
|
36
|
+
* resolveLoaderData's PPR bake/seed key for every loader (loader-cache.ts).
|
|
37
|
+
* False for an intercept: never a document.
|
|
38
|
+
*/
|
|
39
|
+
readonly bakeLane: boolean;
|
|
40
|
+
readonly traceSource: "loader" | "intercept-loader";
|
|
41
|
+
}
|
|
42
|
+
/** A route entry as a LoaderOwner, under `shortCodeOverride` when inherited. */
|
|
43
|
+
export declare function ownerOf(entry: EntryData, shortCodeOverride?: string): LoaderOwner;
|
|
44
|
+
/**
|
|
45
|
+
* The partial lane's one loader funnel: each loader is a segment, run when
|
|
46
|
+
* the client lacks it, asked its revalidate() when held, kept outright in a
|
|
47
|
+
* fill (fillSends), deferred in a prefetch that defers it (defersLoader).
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveOwnerLoaders<TEnv>(owner: LoaderOwner, ctx: HandlerContext<any, TEnv>, belongsToRoute: boolean, clientSegmentIds: ReadonlySet<string>, prevParams: Record<string, string>, request: Request, prevUrl: URL, nextUrl: URL, routeKey: string, deps: SegmentResolutionDeps<TEnv>, actionContext?: ActionContext, stale?: boolean): Promise<{
|
|
16
50
|
segments: ResolvedSegment[];
|
|
17
51
|
matchedIds: string[];
|
|
18
52
|
}>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { handleHandlerResult, warnOnStreamedResponse, buildLoaderErrorContext, } from "./segment-resolution/helpers.js";
|
|
2
2
|
export { resolveLoaders, type ResolveSegmentOptions, resolveSegment, resolveOrphanLayout, resolveParallelEntry, resolveAllSegments, resolveLoadersOnly, } from "./segment-resolution/fresh.js";
|
|
3
|
-
export {
|
|
3
|
+
export { resolveLoadersOnlyWithRevalidation, buildEntryRevalidateMap, resolveParallelSegmentsWithRevalidation, resolveEntryHandlerWithRevalidation, resolveSegmentWithRevalidation, resolveOrphanLayoutWithRevalidation, resolveAllSegmentsWithRevalidation, } from "./segment-resolution/revalidation.js";
|
|
@@ -2,6 +2,7 @@ import type { EntryData, InterceptEntry } from "../server/context";
|
|
|
2
2
|
import type { HandlerContext, ResolvedSegment, ShouldRevalidateFn } from "../types";
|
|
3
3
|
import type { SegmentResolutionDeps } from "./types.js";
|
|
4
4
|
import type { ResolveSegmentOptions } from "./segment-resolution.js";
|
|
5
|
+
import type { RevalidationContext } from "./router-context.js";
|
|
5
6
|
import type { InterceptSelectorContext } from "../server/context";
|
|
6
7
|
export interface SegmentWrappers<TEnv = any> {
|
|
7
8
|
resolveAllSegments: (entries: EntryData[], routeKey: string, params: Record<string, string>, context: HandlerContext<any, TEnv>, loaderPromises: Map<string, Promise<any>>, options?: ResolveSegmentOptions) => Promise<ResolvedSegment[]>;
|
|
@@ -36,12 +37,9 @@ export interface SegmentWrappers<TEnv = any> {
|
|
|
36
37
|
entry: EntryData;
|
|
37
38
|
} | null;
|
|
38
39
|
resolveInterceptEntry: (interceptEntry: InterceptEntry, parentEntry: EntryData, params: Record<string, string>, context: HandlerContext<any, TEnv>, belongsToRoute?: boolean, revalidationContext?: any, options?: {
|
|
39
|
-
|
|
40
|
+
background?: boolean;
|
|
40
41
|
}) => Promise<ResolvedSegment[]>;
|
|
41
|
-
resolveInterceptLoadersOnly: (interceptEntry: InterceptEntry, parentEntry: EntryData,
|
|
42
|
-
loaderDataPromise: Promise<any[]> | any[];
|
|
43
|
-
loaderIds: string[];
|
|
44
|
-
} | null>;
|
|
42
|
+
resolveInterceptLoadersOnly: (interceptEntry: InterceptEntry, parentEntry: EntryData, context: HandlerContext<any, TEnv>, belongsToRoute: boolean, revalidationContext: RevalidationContext) => Promise<ResolvedSegment[]>;
|
|
45
43
|
}
|
|
46
44
|
/**
|
|
47
45
|
* Create thin wrapper functions that bind segmentDeps to extracted
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
* omit when absent.
|
|
18
18
|
*
|
|
19
19
|
* Shared by `ctx.reverse()` (server), `createReverse()` (typed runtime
|
|
20
|
-
* helper),
|
|
21
|
-
*
|
|
20
|
+
* helper), `useReverse()` (client hook), and the include() mount fill of
|
|
21
|
+
* `useHref()` and relative `useRouter().push`. The behavior must stay
|
|
22
|
+
* identical across all of them.
|
|
22
23
|
*/
|
|
23
24
|
export declare function substitutePatternParams(pattern: string, params: Record<string, string | undefined>, routeName: string): string;
|
|
24
25
|
/**
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
* registry; do not call traceSpan directly from new code.
|
|
25
25
|
*
|
|
26
26
|
* Phase coverage (all via observePhase): rango.request (span-only; handler:total
|
|
27
|
-
* metered directly), rango.middleware (span-only
|
|
28
|
-
*
|
|
27
|
+
* metered directly), rango.middleware (span-only; pre/post metered directly),
|
|
28
|
+
* rango.action (action:<id>; server-action
|
|
29
29
|
* execution, JS + no-JS/PE), rango.loader (loader:<id>; single metering site at
|
|
30
30
|
* useLoader, plus the fetchable path), rango.handler (span-only, one per segment
|
|
31
31
|
* route/layout handler execution; the handler:<id> perf metric is owned by the
|
|
@@ -27,13 +27,15 @@ export interface RouterVersions {
|
|
|
27
27
|
export type RouterVersionsTable = Readonly<Record<string, readonly [data: string, document: string]>>;
|
|
28
28
|
/** Table key of the whole-build versions. Not a legal `$$id` (8 hex chars). */
|
|
29
29
|
export declare const DEFAULT_ROUTER_VERSIONS_KEY = "*";
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* One value for both versions: the dev stamp, the version a build-time shell
|
|
32
|
+
* capture is asked for, or a test's seed.
|
|
33
|
+
*/
|
|
31
34
|
export declare function uniformVersions(version: string): RouterVersions;
|
|
32
35
|
/**
|
|
33
|
-
* The versions a router serves with under `table`:
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* tests) or it has neither entry. One function for the request handler and
|
|
36
|
+
* The versions a router serves with under `table`: the router's own entry,
|
|
37
|
+
* else the whole-build pair, for a router the table does not list.
|
|
38
|
+
* `undefined` when there is no table (dev, tests) or it has neither entry. One function for the request handler and
|
|
37
39
|
* the build's shell capture, which must stamp what the handler will check.
|
|
38
40
|
*/
|
|
39
|
-
export declare function resolveVersionsFrom(table: RouterVersionsTable | undefined, routerId: string | undefined
|
|
41
|
+
export declare function resolveVersionsFrom(table: RouterVersionsTable | undefined, routerId: string | undefined): RouterVersions | undefined;
|
|
@@ -28,10 +28,22 @@ export declare function buildFullPayload(m: MatchResult, ctx: HandlerContext<any
|
|
|
28
28
|
* bar) agree on `usePathname()` and `useSearchParams()`. A render other
|
|
29
29
|
* visitors may be served shows `url`, the target, as a direct visit does: a
|
|
30
30
|
* shell capture, and a render the document cache stores (its key is the
|
|
31
|
-
* target)
|
|
31
|
+
* target), except a visitor-keyed shell capture, whose key covers the
|
|
32
|
+
* visitor's URL. Any other render that shows the visitor's URL marks
|
|
32
33
|
* `_payloadVisitorLocation`, and the document cache does not store it.
|
|
33
34
|
*/
|
|
34
|
-
export declare function renderedLocation(reqCtx: Pick<RequestContext<any>, "_variables" | "_shellCaptureRun" | "_documentCacheRender" | "_payloadVisitorLocation" | "res"> | undefined, url: URL): URL;
|
|
35
|
+
export declare function renderedLocation(reqCtx: Pick<RequestContext<any>, "_variables" | "_shellCaptureRun" | "_shellCaptureForVisitor" | "_documentCacheRender" | "_payloadVisitorLocation" | "res"> | undefined, url: URL): URL;
|
|
36
|
+
/**
|
|
37
|
+
* A payload's `pathname` (renderedLocation) and, when middleware rewrote the
|
|
38
|
+
* request, `rewriteTarget`: the path and search the route rendered (the
|
|
39
|
+
* trail's last URL). The browser keeps it per history entry and sends it
|
|
40
|
+
* back as `_rsc_rt`, so the next request from the page diffs against the
|
|
41
|
+
* route that rendered it (navigation-snapshot.ts resolveNavigation, #1144).
|
|
42
|
+
*/
|
|
43
|
+
export declare function payloadLocation(reqCtx: Parameters<typeof renderedLocation>[0], url: URL): {
|
|
44
|
+
pathname: string;
|
|
45
|
+
rewriteTarget?: string;
|
|
46
|
+
};
|
|
35
47
|
/**
|
|
36
48
|
* The theme a document payload carries as `metadata.initialTheme` (the
|
|
37
49
|
* ThemeProvider's first state), read with no identity guard: it is the
|
|
@@ -117,6 +117,14 @@ export declare function buildRouteMiddlewareEntries<TEnv>(routeMiddleware: Array
|
|
|
117
117
|
entry: MiddlewareEntry<TEnv>;
|
|
118
118
|
params: Record<string, string>;
|
|
119
119
|
}>;
|
|
120
|
+
/**
|
|
121
|
+
* The request route middleware sees around the render after a server action
|
|
122
|
+
* or a no-JS form post: the page's GET (URL, headers without body framing or
|
|
123
|
+
* content-type, signal, workerd `cf`; no body). Route middleware never wraps the action,
|
|
124
|
+
* only that render, so it decides as for a GET of the page: a rewrite it
|
|
125
|
+
* skips for mutations still moves the render to its target (#1145).
|
|
126
|
+
*/
|
|
127
|
+
export declare function actionRenderRequest(request: Request): Request;
|
|
120
128
|
/**
|
|
121
129
|
* Merge stub headers from the request context onto an existing Response in
|
|
122
130
|
* place, then drain onResponse callbacks. Used when a Response cannot flow
|
|
@@ -4,6 +4,26 @@
|
|
|
4
4
|
* Builds a fresh route trie from every registered URL-pattern mount for
|
|
5
5
|
* dev/HMR scenarios where the manifest exists but the trie needs rebuilding.
|
|
6
6
|
*/
|
|
7
|
+
/** True when the trie installed for `router.id` was built from this router. */
|
|
8
|
+
export declare function isRouterTrieBuiltFrom(router: {
|
|
9
|
+
id?: string;
|
|
10
|
+
}): boolean;
|
|
11
|
+
/** The router fields ensureRouterTrie reads. */
|
|
12
|
+
export interface TrieSource {
|
|
13
|
+
id?: string;
|
|
14
|
+
urlpatterns?: unknown;
|
|
15
|
+
routeMap: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Install the trie `router` matches through, as a request finds it: the build
|
|
19
|
+
* manifest's trie when one is registered for its id, otherwise one built from
|
|
20
|
+
* its routes the way the dev handler builds it (rsc/handler.ts). Ids can repeat
|
|
21
|
+
* across router objects (tests), and another object's trie names other routes,
|
|
22
|
+
* so a trie this object did not build is rebuilt. Seeds the per-router manifest
|
|
23
|
+
* from `router.routeMap` when neither source set one, for reverse(). testing's
|
|
24
|
+
* dispatch matches through it, never the regex fallback alone (#1104, #1107).
|
|
25
|
+
*/
|
|
26
|
+
export declare function ensureRouterTrie(router: TrieSource): Promise<void>;
|
|
7
27
|
/**
|
|
8
28
|
* Build a fresh route trie from the router's URL-pattern mounts and store it in
|
|
9
29
|
* the per-router cache. Also sets the per-router manifest and merges into the
|