@rangojs/router 0.27.0 → 0.29.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/dist/bin/rango.js +1 -1
- package/dist/types/__internal.d.ts +7 -1
- package/dist/types/browser/action-fence.d.ts +2 -1
- package/dist/types/browser/event-controller.d.ts +8 -2
- package/dist/types/browser/history-state.d.ts +3 -9
- package/dist/types/browser/navigation-store.d.ts +8 -6
- package/dist/types/browser/partial-update.d.ts +11 -0
- package/dist/types/browser/react/filter-segment-order.d.ts +2 -2
- package/dist/types/browser/react/use-action.d.ts +7 -2
- package/dist/types/browser/react/use-handle.d.ts +19 -16
- package/dist/types/browser/react/use-link-status.d.ts +5 -2
- package/dist/types/browser/segment-reconciler.d.ts +32 -4
- package/dist/types/browser/types.d.ts +24 -5
- package/dist/types/browser/wire-protocol.d.ts +26 -0
- package/dist/types/cache/cache-key-utils.d.ts +11 -5
- package/dist/types/cache/cache-scope.d.ts +34 -22
- package/dist/types/cache/cf/cf-cache-constants.d.ts +2 -2
- package/dist/types/cache/cf/cf-cache-store.d.ts +47 -65
- package/dist/types/cache/cf/cf-kv-utils.d.ts +1 -1
- package/dist/types/cache/handle-snapshot.d.ts +9 -4
- package/dist/types/cache/segment-codec.d.ts +14 -0
- package/dist/types/cache/shell-snapshot.d.ts +1 -1
- package/dist/types/cache/taint.d.ts +5 -3
- package/dist/types/cache/types.d.ts +7 -3
- package/dist/types/cache/vercel/vercel-cache-store.d.ts +8 -6
- package/dist/types/prefetch-markers.d.ts +5 -14
- package/dist/types/prerender/store.d.ts +31 -0
- package/dist/types/prerender/warm-request.d.ts +3 -3
- package/dist/types/prerender.d.ts +2 -2
- package/dist/types/route-name.d.ts +5 -0
- package/dist/types/router/error-handling.d.ts +11 -5
- package/dist/types/router/instrument.d.ts +4 -3
- package/dist/types/router/intercept-resolution.d.ts +25 -9
- package/dist/types/router/match-context.d.ts +6 -11
- package/dist/types/router/match-handlers.d.ts +2 -6
- package/dist/types/router/match-middleware/background-revalidation.d.ts +13 -22
- package/dist/types/router/match-middleware/cache-lookup.d.ts +34 -86
- package/dist/types/router/match-middleware/segment-resolution.d.ts +8 -6
- package/dist/types/router/navigation-snapshot.d.ts +7 -0
- package/dist/types/router/prerender-match.d.ts +21 -6
- package/dist/types/router/preview-match.d.ts +2 -7
- package/dist/types/router/request-classification.d.ts +5 -0
- package/dist/types/router/router-context.d.ts +7 -46
- package/dist/types/router/router-interfaces.d.ts +8 -14
- package/dist/types/router/segment-resolution/helpers.d.ts +19 -3
- package/dist/types/router/segment-resolution/loader-cache.d.ts +3 -3
- package/dist/types/router/segment-resolution/loader-mask.d.ts +4 -4
- package/dist/types/router/segment-resolution/prefetch-deferral.d.ts +20 -18
- package/dist/types/router/segment-resolution/resolution-pass.d.ts +95 -0
- package/dist/types/router/segment-resolution/revalidation.d.ts +82 -31
- package/dist/types/router/segment-resolution/streamed-handler-boundary.d.ts +2 -0
- package/dist/types/router/segment-resolution.d.ts +1 -2
- package/dist/types/router/segment-wrappers.d.ts +11 -48
- package/dist/types/router/telemetry.d.ts +2 -0
- package/dist/types/router/types.d.ts +11 -1
- package/dist/types/rsc/full-payload.d.ts +2 -2
- package/dist/types/rsc/handler-context.d.ts +6 -6
- package/dist/types/rsc/json-route-result.d.ts +5 -9
- package/dist/types/rsc/request-stages.d.ts +203 -0
- package/dist/types/rsc/response-cache-serve.d.ts +7 -12
- package/dist/types/rsc/response-route-handler.d.ts +2 -2
- package/dist/types/rsc/routine-plan.d.ts +1 -1
- package/dist/types/rsc/server-action.d.ts +2 -2
- package/dist/types/rsc/shell-capture-constants.d.ts +1 -1
- package/dist/types/rsc/shell-capture.d.ts +132 -15
- package/dist/types/rsc/shell-serve.d.ts +37 -12
- package/dist/types/server/context.d.ts +9 -8
- package/dist/types/server/handle-store.d.ts +16 -0
- package/dist/types/server/render-pass.d.ts +72 -0
- package/dist/types/server/request-context.d.ts +53 -104
- package/dist/types/server/rewrite-trail.d.ts +2 -2
- package/dist/types/testing/dispatch.d.ts +35 -18
- package/dist/types/testing/render-route.d.ts +43 -8
- package/dist/types/testing/serve-shell-request.d.ts +8 -1
- package/dist/types/types/cache-types.d.ts +6 -3
- package/dist/types/types/error-types.d.ts +30 -3
- package/dist/types/types/handler-context.d.ts +9 -1
- package/dist/types/types/segments.d.ts +1 -1
- package/dist/types/vite/discovery/build-discovery-phase.d.ts +40 -0
- package/dist/types/vite/discovery/build-env.d.ts +22 -0
- package/dist/types/vite/discovery/bundle-scan-phase.d.ts +12 -0
- package/dist/types/vite/discovery/dev-prerender-cache.d.ts +3 -2
- package/dist/types/vite/discovery/dev-server-phase.d.ts +26 -0
- package/dist/types/vite/discovery/discovery-errors.d.ts +1 -1
- package/dist/types/vite/discovery/state.d.ts +12 -0
- package/dist/types/vite/plugins/version-plugin.d.ts +1 -1
- package/dist/types/vite/plugins/virtual-entries.d.ts +1 -1
- package/dist/types/vite/router-discovery.d.ts +8 -47
- package/dist/types/vite/temp-rsc-server.d.ts +39 -0
- package/dist/types/vite/utils/prerender-utils.d.ts +9 -0
- package/dist/types/wire-params.d.ts +39 -0
- package/dist/vite/index.js +3822 -3727
- package/package.json +1 -1
- package/skills/cache-guide/SKILL.md +8 -5
- package/skills/caching/SKILL.md +37 -18
- package/skills/client-urls/SKILL.md +4 -2
- package/skills/document-cache/SKILL.md +13 -1
- package/skills/handler-use/SKILL.md +1 -1
- package/skills/hooks/SKILL.md +1 -1
- package/skills/hooks/data.md +8 -1
- package/skills/hooks/handle-and-actions.md +33 -2
- package/skills/hooks/navigation.md +121 -15
- package/skills/hooks/state.md +6 -4
- package/skills/hooks/urls.md +16 -5
- package/skills/intercept/SKILL.md +23 -7
- package/skills/middleware/SKILL.md +18 -0
- package/skills/observability/SKILL.md +30 -0
- package/skills/ppr/SKILL.md +18 -3
- package/skills/prerender/SKILL.md +39 -15
- package/skills/rango/SKILL.md +5 -1
- package/skills/server-actions/SKILL.md +15 -1
- package/skills/testing/client-components.md +25 -18
- package/skills/testing/response-routes.md +6 -4
- package/skills/testing/serve-shell-request.md +7 -7
- package/skills/use-cache/SKILL.md +46 -8
- package/skills/view-transitions/SKILL.md +1 -1
- package/src/__internal.ts +7 -1
- package/src/browser/action-fence.ts +2 -1
- package/src/browser/connection-warmup.ts +3 -1
- package/src/browser/event-controller.ts +37 -13
- package/src/browser/history-state.ts +6 -12
- package/src/browser/navigation-bridge.ts +59 -26
- package/src/browser/navigation-client.ts +20 -25
- package/src/browser/navigation-store.ts +25 -27
- package/src/browser/navigation-transaction.ts +4 -1
- package/src/browser/network-error-handler.ts +4 -0
- package/src/browser/partial-update.ts +33 -6
- package/src/browser/prefetch/cache.ts +2 -1
- package/src/browser/prefetch/fetch.ts +8 -16
- package/src/browser/prefetch/queue.ts +4 -4
- package/src/browser/react/NavigationProvider.tsx +2 -1
- package/src/browser/react/filter-segment-order.ts +2 -2
- package/src/browser/react/use-action.ts +24 -48
- package/src/browser/react/use-handle.ts +22 -18
- package/src/browser/react/use-link-status.ts +48 -60
- package/src/browser/react/use-navigation.ts +92 -41
- package/src/browser/rsc-router.tsx +1 -0
- package/src/browser/segment-reconciler.ts +109 -53
- package/src/browser/server-action-bridge.ts +81 -61
- package/src/browser/types.ts +25 -5
- package/src/browser/wire-protocol.ts +43 -0
- package/src/cache/cache-key-utils.ts +11 -5
- package/src/cache/cache-runtime.ts +132 -75
- package/src/cache/cache-scope.ts +110 -64
- package/src/cache/cf/cf-cache-constants.ts +2 -2
- package/src/cache/cf/cf-cache-store.ts +486 -874
- package/src/cache/cf/cf-kv-utils.ts +1 -1
- package/src/cache/document-cache.ts +64 -46
- package/src/cache/handle-snapshot.ts +19 -7
- package/src/cache/read-through-swr.ts +20 -18
- package/src/cache/segment-codec.ts +55 -0
- package/src/cache/shell-snapshot.ts +2 -2
- package/src/cache/tag-invalidation.ts +6 -2
- package/src/cache/taint.ts +5 -3
- package/src/cache/types.ts +7 -3
- package/src/cache/vercel/vercel-cache-store.ts +243 -310
- package/src/handles/pushed-by.ts +1 -1
- package/src/prefetch-markers.ts +5 -16
- package/src/prerender/store.ts +76 -0
- package/src/prerender/warm-request.ts +8 -4
- package/src/prerender.ts +2 -2
- package/src/route-name.ts +8 -0
- package/src/router/error-handling.ts +22 -10
- package/src/router/instrument.ts +4 -3
- package/src/router/intercept-resolution.ts +82 -75
- package/src/router/loader-resolution.ts +5 -4
- package/src/router/match-api.ts +5 -5
- package/src/router/match-context.ts +23 -12
- package/src/router/match-handlers.ts +8 -20
- package/src/router/match-middleware/background-revalidation.ts +46 -57
- package/src/router/match-middleware/cache-lookup.ts +677 -726
- package/src/router/match-middleware/cache-store.ts +4 -8
- package/src/router/match-middleware/intercept-resolution.ts +3 -23
- package/src/router/match-middleware/segment-resolution.ts +34 -61
- package/src/router/middleware.ts +69 -11
- package/src/router/navigation-snapshot.ts +14 -4
- package/src/router/prerender-match.ts +100 -44
- package/src/router/preview-match.ts +6 -41
- package/src/router/request-classification.ts +13 -7
- package/src/router/route-snapshot.ts +2 -5
- package/src/router/router-context.ts +10 -95
- package/src/router/router-interfaces.ts +8 -14
- package/src/router/segment-resolution/helpers.ts +49 -13
- package/src/router/segment-resolution/loader-cache.ts +15 -9
- package/src/router/segment-resolution/loader-mask.ts +5 -5
- package/src/router/segment-resolution/prefetch-deferral.ts +30 -27
- package/src/router/segment-resolution/resolution-pass.ts +139 -0
- package/src/router/segment-resolution/revalidation.ts +939 -789
- package/src/router/segment-resolution/streamed-handler-boundary.ts +3 -0
- package/src/router/segment-resolution.ts +4 -13
- package/src/router/segment-wrappers.ts +51 -269
- package/src/router/telemetry.ts +5 -0
- package/src/router/types.ts +11 -1
- package/src/router.ts +19 -17
- package/src/rsc/full-payload.ts +6 -5
- package/src/rsc/handler-context.ts +8 -14
- package/src/rsc/handler.ts +126 -507
- package/src/rsc/json-route-result.ts +5 -9
- package/src/rsc/loader-fetch.ts +6 -5
- package/src/rsc/progressive-enhancement.ts +5 -0
- package/src/rsc/request-stages.ts +759 -0
- package/src/rsc/response-cache-serve.ts +10 -14
- package/src/rsc/response-route-handler.ts +13 -5
- package/src/rsc/rewrite-passes.ts +2 -1
- package/src/rsc/routine-plan.ts +1 -1
- package/src/rsc/rsc-rendering.ts +164 -349
- package/src/rsc/server-action.ts +87 -113
- package/src/rsc/shell-capture-constants.ts +1 -1
- package/src/rsc/shell-capture.ts +275 -227
- package/src/rsc/shell-serve.ts +121 -18
- package/src/rsc/ssr-setup.ts +5 -4
- package/src/segment-system.tsx +3 -3
- package/src/server/context.ts +22 -25
- package/src/server/handle-store.ts +55 -0
- package/src/server/render-pass.ts +291 -0
- package/src/server/request-context.ts +75 -115
- package/src/server/rewrite-trail.ts +6 -4
- package/src/ssr/index.tsx +1 -1
- package/src/testing/dispatch.ts +226 -710
- package/src/testing/e2e/page-helpers.ts +2 -2
- package/src/testing/render-route.tsx +199 -13
- package/src/testing/serve-shell-request.ts +36 -40
- package/src/types/cache-types.ts +6 -3
- package/src/types/error-types.ts +30 -3
- package/src/types/handler-context.ts +12 -1
- package/src/types/segments.ts +1 -1
- package/src/vite/discovery/build-discovery-phase.ts +204 -0
- package/src/vite/discovery/build-env.ts +148 -0
- package/src/vite/discovery/bundle-scan-phase.ts +128 -0
- package/src/vite/discovery/dev-prerender-cache.ts +8 -3
- package/src/vite/discovery/dev-server-phase.ts +1776 -0
- package/src/vite/discovery/discover-routers.ts +1 -1
- package/src/vite/discovery/discovery-errors.ts +1 -1
- package/src/vite/discovery/prerender-collection.ts +24 -39
- package/src/vite/discovery/state.ts +15 -0
- package/src/vite/plugins/version-plugin.ts +1 -1
- package/src/vite/plugins/virtual-entries.ts +1 -1
- package/src/vite/router-discovery.ts +29 -2428
- package/src/vite/temp-rsc-server.ts +223 -0
- package/src/vite/utils/prerender-utils.ts +47 -0
- package/src/wire-params.ts +40 -0
- package/dist/types/router/segment-resolution/fresh.d.ts +0 -72
- package/src/router/segment-resolution/fresh.ts +0 -945
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { ErrorBoundaryHandler, ErrorInfo, ErrorPhase, MatchResult } from "../types";
|
|
3
3
|
import { type EntryData, type InterceptEntry, type InterceptSelectorContext } from "../server/context.js";
|
|
4
|
-
import type { MatchApiDeps } from "./types.js";
|
|
4
|
+
import type { ActionContext, MatchApiDeps } from "./types.js";
|
|
5
5
|
import type { RouterContext } from "./router-context.js";
|
|
6
|
-
import { type ActionContext } from "./match-context.js";
|
|
7
6
|
import type { MiddlewareFn } from "./middleware.js";
|
|
8
7
|
import { type TelemetrySink } from "./telemetry.js";
|
|
9
8
|
export interface MatchHandlerDeps<TEnv = any> {
|
|
@@ -33,11 +32,8 @@ export interface MatchHandlers<TEnv = any> {
|
|
|
33
32
|
handler: MiddlewareFn;
|
|
34
33
|
params: Record<string, string>;
|
|
35
34
|
}>;
|
|
36
|
-
responseType?: string;
|
|
37
|
-
handler?: Function;
|
|
38
35
|
params?: Record<string, string>;
|
|
39
|
-
|
|
40
|
-
manifestEntry?: EntryData;
|
|
36
|
+
routeKey?: string;
|
|
41
37
|
} | null>;
|
|
42
38
|
}
|
|
43
39
|
/**
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* |
|
|
37
37
|
* v
|
|
38
38
|
* +---------------------------+
|
|
39
|
-
* |
|
|
39
|
+
* | FRESH segment pass | Fresh resolution (no revalidation)
|
|
40
40
|
* | + resolveIntercepts() | Ensures complete components
|
|
41
41
|
* +---------------------------+
|
|
42
42
|
* |
|
|
@@ -94,10 +94,12 @@
|
|
|
94
94
|
* FRESH RESOLUTION (NO REVALIDATION)
|
|
95
95
|
* ===================================
|
|
96
96
|
*
|
|
97
|
-
* Both full and partial requests
|
|
97
|
+
* Both full and partial requests resolve with a FRESH pass (without
|
|
98
98
|
* revalidation logic) to ensure all segments have complete components.
|
|
99
99
|
* Using revalidation-aware resolution would produce null components
|
|
100
|
-
* for skipped segments, which would corrupt the cache entry.
|
|
100
|
+
* for skipped segments, which would corrupt the cache entry. Under an
|
|
101
|
+
* intercept the walk still skips the intercepted route's entry, as the MISS
|
|
102
|
+
* does: an intercept: record never holds the route's page.
|
|
101
103
|
*/
|
|
102
104
|
import type { ResolvedSegment } from "../../types.js";
|
|
103
105
|
import type { MatchContext, MatchPipelineState } from "../match-context.js";
|
|
@@ -118,25 +120,14 @@ import { type RequestContext } from "../../server/request-context.js";
|
|
|
118
120
|
* MAX_REVALIDATION_INTERVAL, as after a refresh that throws.
|
|
119
121
|
*
|
|
120
122
|
* Runs on a DERIVED request context that owns the per-render state the
|
|
121
|
-
* foreground reads while it is still producing the page
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* - _metricsStore: undefined, and the DSL store below has `metrics` unset
|
|
130
|
-
* (track() reads that one), so nothing lands on the foreground's perf
|
|
131
|
-
* timeline. ctx.Store.run closes over ctx.Store, so the derived store
|
|
132
|
-
* needs its own run.
|
|
133
|
-
* - response writes (headers, cookies, status, onResponse callbacks) go to
|
|
134
|
-
* a throwaway context (whose status gates the write, above) and are
|
|
135
|
-
* dropped: a layout above the cache() boundary is outside the header
|
|
136
|
-
* guard and an error boundary sets a status, so they would otherwise
|
|
137
|
-
* reach the live response.
|
|
138
|
-
* runWithRequestContext also re-establishes the request ALS, which a waitUntil
|
|
139
|
-
* task on workerd loses; the DSL store is a different ALS (build context).
|
|
123
|
+
* foreground reads while it is still producing the page:
|
|
124
|
+
* RENDER_PASS_FIELDS["background-revalidation"] (server/render-pass.ts) lists
|
|
125
|
+
* each field and why. The DSL store below has `metrics` unset too (track()
|
|
126
|
+
* reads that one), so nothing lands on the foreground's perf timeline;
|
|
127
|
+
* ctx.Store.run closes over ctx.Store, so the derived store needs its own run.
|
|
128
|
+
* runAsBackgroundWork also re-establishes the request ALS, which a waitUntil
|
|
129
|
+
* task on workerd loses, and marks the pass's onError reports `background`;
|
|
130
|
+
* the DSL store is a different ALS (build context).
|
|
140
131
|
*/
|
|
141
132
|
export declare function rerenderAndCacheRoute<TEnv>(ctx: MatchContext<TEnv>, requestCtx: RequestContext<TEnv>, cacheScope: CacheScope, routerCtx: RouterContext<TEnv>): Promise<number>;
|
|
142
133
|
/**
|
|
@@ -1,95 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cache Lookup Middleware
|
|
3
3
|
*
|
|
4
|
-
* First middleware in the pipeline.
|
|
4
|
+
* First middleware in the pipeline. Before segment resolution runs, it serves
|
|
5
|
+
* a stored match from the first source that answers:
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* +---------------------+
|
|
13
|
-
* | Is action request? |──yes──> yield* source (pass through)
|
|
14
|
-
* +---------------------+
|
|
15
|
-
* | no
|
|
16
|
-
* v
|
|
17
|
-
* +---------------------+
|
|
18
|
-
* | Cache enabled? |──no───> yield* source (pass through)
|
|
19
|
-
* +---------------------+
|
|
20
|
-
* | yes
|
|
21
|
-
* v
|
|
22
|
-
* +---------------------+
|
|
23
|
-
* | Lookup cache |
|
|
24
|
-
* | (pathname, params) |
|
|
25
|
-
* +---------------------+
|
|
26
|
-
* |
|
|
27
|
-
* +-----+-----+
|
|
28
|
-
* | |
|
|
29
|
-
* miss hit
|
|
30
|
-
* | |
|
|
31
|
-
* v v
|
|
32
|
-
* yield* Set state.cacheHit = true
|
|
33
|
-
* source Set state.shouldRevalidate
|
|
34
|
-
* | |
|
|
35
|
-
* | v
|
|
36
|
-
* | +---------------------------+
|
|
37
|
-
* | | For each cached segment: |
|
|
38
|
-
* | | - Apply revalidation |
|
|
39
|
-
* | | - Set component = null |
|
|
40
|
-
* | | if client has it |
|
|
41
|
-
* | +---------------------------+
|
|
42
|
-
* | |
|
|
43
|
-
* | v
|
|
44
|
-
* | +---------------------------+
|
|
45
|
-
* | | Resolve fresh loaders | <-- Loaders are NEVER cached
|
|
46
|
-
* | | (always fresh data) |
|
|
47
|
-
* | +---------------------------+
|
|
48
|
-
* | |
|
|
49
|
-
* | v
|
|
50
|
-
* | yield cached segments
|
|
51
|
-
* | yield fresh loader segments
|
|
52
|
-
* | |
|
|
53
|
-
* +-----------+
|
|
54
|
-
* |
|
|
55
|
-
* v
|
|
56
|
-
* next middleware
|
|
7
|
+
* 1. Prerender: the writable on-demand overlay, then the bundled build
|
|
8
|
+
* manifest. A live render (an action or a stale partial) reads them too
|
|
9
|
+
* when the route has no live handler (not a Passthrough).
|
|
10
|
+
* 2. The dev Static store (`__PRERENDER_DEV_URL`, isStaticPrerender entries).
|
|
11
|
+
* 3. The route's cache() record (the segment cache). An action or a stale
|
|
12
|
+
* partial renders live (rendersLive) and reads no record.
|
|
57
13
|
*
|
|
14
|
+
* Every source serves through serveStoredSegments: pre-rendering is caching
|
|
15
|
+
* at build time, so a prerender entry is a cache hit through the same segment
|
|
16
|
+
* path. When no source answers, the request passes through to
|
|
17
|
+
* segment-resolution.
|
|
58
18
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
19
|
+
* A STORED HIT
|
|
20
|
+
* ============
|
|
61
21
|
*
|
|
62
|
-
* Cache HIT:
|
|
63
22
|
* - state.cacheHit = true signals downstream middleware to skip
|
|
64
|
-
* -
|
|
65
|
-
* - Loaders are always re-resolved
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* Cache MISS:
|
|
69
|
-
* - Passes through to segment-resolution middleware
|
|
70
|
-
* - No segments yielded from this middleware
|
|
71
|
-
*
|
|
72
|
-
* Loaders:
|
|
73
|
-
* - NEVER cached in the segment cache
|
|
74
|
-
* - Always resolved fresh on every request
|
|
75
|
-
* - Ensures data freshness even with cached UI components
|
|
76
|
-
* - Segment cache staleness does NOT propagate to loader revalidation;
|
|
23
|
+
* - A segment the client already holds and keeps has its component nullified
|
|
24
|
+
* - Loaders are always re-resolved fresh: never cached or pre-rendered.
|
|
25
|
+
* Segment cache staleness does NOT propagate to loader revalidation;
|
|
77
26
|
* loaders use their own revalidation rules (actionId, user-defined)
|
|
27
|
+
* - A cache() record sets state.shouldRevalidate, which triggers background
|
|
28
|
+
* SWR when the record was stale
|
|
78
29
|
*
|
|
30
|
+
* REVALIDATION RULES (cache() record)
|
|
31
|
+
* ===================================
|
|
79
32
|
*
|
|
80
|
-
*
|
|
81
|
-
* ==================
|
|
82
|
-
*
|
|
83
|
-
* Each cached segment is evaluated against its revalidation rules:
|
|
33
|
+
* Each record segment the client holds is evaluated against its rules:
|
|
84
34
|
*
|
|
85
|
-
* 1. No rules defined ->
|
|
35
|
+
* 1. No rules defined -> re-render the route's own segments when the search
|
|
36
|
+
* or the route params changed; otherwise skip (nullify component)
|
|
86
37
|
* 2. Rules return false -> skip re-render (nullify component)
|
|
87
38
|
* 3. Rules return true -> re-render (keep component)
|
|
88
39
|
*
|
|
89
|
-
* Revalidation context includes
|
|
90
|
-
*
|
|
91
|
-
* - Request object
|
|
92
|
-
* - Action context (if POST)
|
|
40
|
+
* Revalidation context includes the previous/next URL and params, the request
|
|
41
|
+
* and the action context (if POST).
|
|
93
42
|
*/
|
|
94
43
|
import type { ResolvedSegment } from "../../types.js";
|
|
95
44
|
import { type EntryData } from "../../server/context.js";
|
|
@@ -112,7 +61,7 @@ export declare function setPrerenderStoreForTests(store: PrerenderStore | null |
|
|
|
112
61
|
* misses the store and renders live, and replay — including its heal
|
|
113
62
|
* capture — must stay available for it (withCacheStore records the doc
|
|
114
63
|
* record on that path; state.cacheSource is not "prerender"). The store
|
|
115
|
-
* memoizes per routeKey/paramHash, so this probe and
|
|
64
|
+
* memoizes per routeKey/paramHash, so this probe and readPrerenderSource's
|
|
116
65
|
* subsequent get() share one underlying load.
|
|
117
66
|
*/
|
|
118
67
|
export declare function prerenderEntryExists(routeKey: string | undefined, params: Record<string, string>, pathname: string, entries: EntryData[]): Promise<boolean>;
|
|
@@ -127,14 +76,13 @@ export type GeneratorMiddleware<T> = (source: AsyncGenerator<T>) => AsyncGenerat
|
|
|
127
76
|
/**
|
|
128
77
|
* Creates cache lookup middleware
|
|
129
78
|
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* -
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
79
|
+
* The middleware is serveStoredSegments. It serves a stored match when one
|
|
80
|
+
* answers, in this order: the prerender overlay and build store (Prerender
|
|
81
|
+
* and on-demand routes), the dev Static store, then the route's cache()
|
|
82
|
+
* record. It yields the stored segments and the loaders resolved fresh and
|
|
83
|
+
* sets state.cacheHit (and state.shouldRevalidate for a cache() record, for
|
|
84
|
+
* background SWR).
|
|
136
85
|
*
|
|
137
|
-
* If
|
|
138
|
-
* - Passes through to next middleware
|
|
86
|
+
* If nothing answers, passes through to the next middleware.
|
|
139
87
|
*/
|
|
140
88
|
export declare function withCacheLookup<TEnv>(ctx: MatchContext<TEnv>, state: MatchPipelineState): GeneratorMiddleware<ResolvedSegment>;
|
|
@@ -29,15 +29,16 @@
|
|
|
29
29
|
* yes no
|
|
30
30
|
* | |
|
|
31
31
|
* v v
|
|
32
|
-
*
|
|
33
|
-
* Segments Segments
|
|
34
|
-
* | |
|
|
32
|
+
* FRESH pass partial pass
|
|
35
33
|
* | | (compares with prev state)
|
|
36
34
|
* | | (handles null components)
|
|
37
35
|
* | |
|
|
38
36
|
* +-----------+
|
|
39
37
|
* |
|
|
40
38
|
* v
|
|
39
|
+
* resolveAllSegments()
|
|
40
|
+
* |
|
|
41
|
+
* v
|
|
41
42
|
* +---------------------------+
|
|
42
43
|
* | Update state: |
|
|
43
44
|
* | - state.segments |
|
|
@@ -54,13 +55,14 @@
|
|
|
54
55
|
* RESOLUTION MODES
|
|
55
56
|
* ================
|
|
56
57
|
*
|
|
58
|
+
* Both use resolveAllSegments().
|
|
59
|
+
*
|
|
57
60
|
* Full Match (document request):
|
|
58
|
-
* -
|
|
59
|
-
*
|
|
61
|
+
* - A FRESH pass (freshPassInput): no revalidation logic (nothing to
|
|
62
|
+
* compare against)
|
|
60
63
|
* - Simple resolution of all route entries
|
|
61
64
|
*
|
|
62
65
|
* Partial Match (navigation):
|
|
63
|
-
* - Uses resolveAllSegmentsWithRevalidation()
|
|
64
66
|
* - Compares current vs previous params/URL
|
|
65
67
|
* - Sets component = null for segments client already has
|
|
66
68
|
* - Respects custom revalidation rules
|
|
@@ -11,6 +11,13 @@ export interface NavigationSnapshot {
|
|
|
11
11
|
clientSegmentSet: Set<string>;
|
|
12
12
|
filteredSegmentIds: string[];
|
|
13
13
|
stale: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The id of an action's error boundary on screen that a stale request holds
|
|
16
|
+
* (`_rsc_boundary`, the action follow-up): read only beside `stale`, so it
|
|
17
|
+
* has every stale guarantee (a live render, no route-cache or document-cache
|
|
18
|
+
* read or store, no PPR replay).
|
|
19
|
+
*/
|
|
20
|
+
heldBoundary?: string;
|
|
14
21
|
isSameRouteNavigation: boolean;
|
|
15
22
|
effectiveFromUrl: URL;
|
|
16
23
|
effectiveFromMatch: RouteMatchResult | null;
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import type { RouterContext } from "./router-context.js";
|
|
2
|
-
import type { ResolveSegmentOptions } from "./segment-resolution.js";
|
|
3
|
-
import type { EntryData } from "../server/context";
|
|
4
2
|
import type { PartialPrerenderProps } from "../urls/pattern-types.js";
|
|
5
|
-
import type { HandlerContext, ResolvedSegment } from "../types";
|
|
6
3
|
import type { SerializedSegmentData } from "../cache/types.js";
|
|
7
4
|
import type { RouteMatchResult } from "./pattern-matching.js";
|
|
8
5
|
import type { RouterVersions } from "../router-versions.js";
|
|
9
6
|
import type { OnDemandRouteConfig } from "../prerender/on-demand.js";
|
|
7
|
+
/**
|
|
8
|
+
* An intercept a navigation can select over the route that the build does
|
|
9
|
+
* not bake: its HIT misses (selectInterceptVariant) and it renders live,
|
|
10
|
+
* with the request instead of BuildContext.
|
|
11
|
+
* - `same-slot`: another intercept on its layout fills the same slot.
|
|
12
|
+
* - `handler-response` / `layout-response`: its handler or layout returned a
|
|
13
|
+
* Response for this URL.
|
|
14
|
+
* - `local-name`: it targets the route's localRouteName, which the build
|
|
15
|
+
* never bakes.
|
|
16
|
+
*/
|
|
17
|
+
export interface LiveIntercept {
|
|
18
|
+
slot: string;
|
|
19
|
+
reason: "same-slot" | "handler-response" | "layout-response" | "local-name";
|
|
20
|
+
}
|
|
10
21
|
export interface PrerenderMatchDeps<TEnv = any> {
|
|
11
22
|
/** Owning router id; scopes bake-time root-scope/search-schema lookups the
|
|
12
23
|
* same way reqCtx._routerId does at runtime (issue #762). */
|
|
@@ -21,7 +32,7 @@ export interface PrerenderMatchDeps<TEnv = any> {
|
|
|
21
32
|
findMatch: (pathname: string) => RouteMatchResult<TEnv> | null | Promise<RouteMatchResult<TEnv> | null>;
|
|
22
33
|
buildRouterContext: () => RouterContext<TEnv>;
|
|
23
34
|
mergedRouteMap: Record<string, string>;
|
|
24
|
-
resolveAllSegments:
|
|
35
|
+
resolveAllSegments: RouterContext<TEnv>["resolveAllSegments"];
|
|
25
36
|
}
|
|
26
37
|
/**
|
|
27
38
|
* Build-time pre-render match. Resolves segments with a BuildContext
|
|
@@ -46,9 +57,13 @@ onDemand?: boolean): Promise<{
|
|
|
46
57
|
routeName: string;
|
|
47
58
|
params: Record<string, string>;
|
|
48
59
|
interceptSegments?: SerializedSegmentData[];
|
|
49
|
-
/** RSC-encoded
|
|
50
|
-
*
|
|
60
|
+
/** RSC-encoded handle map for the intercept artifact: the intercept's
|
|
61
|
+
* pushes and those of the main segments the intercepted route does not
|
|
62
|
+
* own; the sinks store it as-is. */
|
|
51
63
|
interceptHandles?: string;
|
|
64
|
+
/** The intercepts the intercept variant does not hold, for the build's
|
|
65
|
+
* warning (warnLiveIntercepts). */
|
|
66
|
+
liveIntercepts?: LiveIntercept[];
|
|
52
67
|
passthrough?: true;
|
|
53
68
|
/** On-demand only: the render hit `notFound()` and nothing else failed. */
|
|
54
69
|
notFound?: true;
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import type { EntryData } from "../server/context";
|
|
2
1
|
import type { RouteMatchResult } from "./pattern-matching.js";
|
|
3
2
|
import type { MiddlewareFn } from "./middleware.js";
|
|
4
3
|
export interface PreviewMatchDeps<TEnv = any> {
|
|
5
4
|
findMatch: (pathname: string) => RouteMatchResult<TEnv> | null | Promise<RouteMatchResult<TEnv> | null>;
|
|
6
5
|
}
|
|
7
6
|
/**
|
|
8
|
-
* Preview match - returns route middleware without
|
|
9
|
-
*
|
|
7
|
+
* Preview match - returns the route, its params and route middleware without
|
|
8
|
+
* segment resolution (a content-negotiated variant's, when one wins).
|
|
10
9
|
*/
|
|
11
10
|
export declare function previewMatch<TEnv = any>(request: Request, _context: TEnv, deps: PreviewMatchDeps<TEnv>): Promise<{
|
|
12
11
|
routeMiddleware?: Array<{
|
|
13
12
|
handler: MiddlewareFn;
|
|
14
13
|
params: Record<string, string>;
|
|
15
14
|
}>;
|
|
16
|
-
responseType?: string;
|
|
17
|
-
handler?: Function;
|
|
18
15
|
params?: Record<string, string>;
|
|
19
|
-
negotiated?: boolean;
|
|
20
|
-
manifestEntry?: EntryData;
|
|
21
16
|
routeKey?: string;
|
|
22
17
|
} | null>;
|
|
@@ -61,6 +61,11 @@ interface FullRenderPlan<TEnv = any> {
|
|
|
61
61
|
mode: "full-render";
|
|
62
62
|
route: RouteSnapshot<TEnv>;
|
|
63
63
|
negotiated: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* No route matched: the render path renders the 404 (match() re-throws
|
|
66
|
+
* RouteNotFoundError). Set by rsc/request-stages.ts classify.
|
|
67
|
+
*/
|
|
68
|
+
unmatched?: true;
|
|
64
69
|
}
|
|
65
70
|
interface PartialRenderPlan<TEnv = any> {
|
|
66
71
|
mode: "partial-render";
|
|
@@ -3,26 +3,9 @@ import type { EntryData, InterceptEntry, InterceptSelectorContext, MetricsStore
|
|
|
3
3
|
import type { HandlerContext, ResolvedSegment, ShouldRevalidateFn } from "../types.js";
|
|
4
4
|
import type { RouteMatchResult } from "./pattern-matching.js";
|
|
5
5
|
import type { TelemetrySink } from "./telemetry.js";
|
|
6
|
-
import type { ResolveSegmentOptions } from "./segment-resolution.js";
|
|
7
6
|
import type { EvaluateRevalidationOptions } from "./revalidation.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
export interface RevalidationContext {
|
|
12
|
-
clientSegmentIds: ReadonlySet<string>;
|
|
13
|
-
prevParams: Record<string, string>;
|
|
14
|
-
request: Request;
|
|
15
|
-
prevUrl: URL;
|
|
16
|
-
nextUrl: URL;
|
|
17
|
-
routeKey: string;
|
|
18
|
-
actionContext?: {
|
|
19
|
-
actionId?: string;
|
|
20
|
-
actionUrl?: URL;
|
|
21
|
-
actionResult?: any;
|
|
22
|
-
formData?: FormData;
|
|
23
|
-
};
|
|
24
|
-
stale?: boolean;
|
|
25
|
-
}
|
|
7
|
+
import type { ResolutionPassInput } from "./segment-resolution/resolution-pass.js";
|
|
8
|
+
import type { RevalidatingWalkOptions } from "./segment-resolution/revalidation.js";
|
|
26
9
|
/**
|
|
27
10
|
* Result from intercept lookup
|
|
28
11
|
*/
|
|
@@ -51,43 +34,21 @@ export interface RouterContext<TEnv = any> {
|
|
|
51
34
|
getMetricsStore: () => MetricsStore | undefined;
|
|
52
35
|
createCacheScope: (cacheConfig: any, parent: CacheScope | null) => CacheScope | null;
|
|
53
36
|
findInterceptForRoute: (routeKey: string, parentEntry: EntryData | null, selectorContext: InterceptSelectorContext, isAction: boolean) => InterceptResult | null;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
chain?: readonly EntryData[]) => Promise<{
|
|
37
|
+
/** The segment walker; a full match passes freshPassInput (FRESH). */
|
|
38
|
+
resolveAllSegments: (pass: ResolutionPassInput<TEnv>, entries: EntryData[], walk: RevalidatingWalkOptions) => Promise<{
|
|
57
39
|
segments: ResolvedSegment[];
|
|
58
40
|
matchedIds: string[];
|
|
59
41
|
}>;
|
|
60
|
-
|
|
61
|
-
__type: "id";
|
|
62
|
-
id: string;
|
|
63
|
-
}>;
|
|
64
|
-
resolveInterceptEntry: (intercept: InterceptEntry, entry: EntryData, params: Record<string, string>, handlerContext: HandlerContext<any, TEnv>, belongsToRoute: boolean, revalidationContext?: RevalidationContext, options?: {
|
|
42
|
+
resolveInterceptEntry: (pass: ResolutionPassInput<TEnv>, intercept: InterceptEntry, entry: EntryData, belongsToRoute: boolean, options?: {
|
|
65
43
|
background?: boolean;
|
|
66
44
|
}) => Promise<ResolvedSegment[]>;
|
|
67
|
-
collectWithMarkers?: <T>(gen: AsyncGenerator<T | {
|
|
68
|
-
__type: "id";
|
|
69
|
-
id: string;
|
|
70
|
-
}>) => Promise<{
|
|
71
|
-
items: T[];
|
|
72
|
-
matchedIds: string[];
|
|
73
|
-
}>;
|
|
74
45
|
evaluateRevalidation: (params: EvaluateRevalidationOptions<TEnv>) => Promise<boolean>;
|
|
75
46
|
getRequestContext: () => {
|
|
76
47
|
waitUntil: (fn: () => Promise<void>) => void;
|
|
77
48
|
_handleStore?: any;
|
|
78
49
|
} | undefined;
|
|
79
|
-
resolveAllSegments: (entries: EntryData[], routeKey: string, params: Record<string, string>, handlerContext: HandlerContext<any, TEnv>, loaderPromises: Map<string, Promise<any>>, options?: ResolveSegmentOptions) => Promise<ResolvedSegment[]>;
|
|
80
|
-
resolveAllSegmentsGenerator?: (entries: EntryData[], routeKey: string, params: Record<string, string>, handlerContext: HandlerContext<any, TEnv>, loaderPromises: Map<string, Promise<any>>) => AsyncGenerator<ResolvedSegment | {
|
|
81
|
-
__type: "id";
|
|
82
|
-
id: string;
|
|
83
|
-
}>;
|
|
84
|
-
collectSegmentsFromGenerator?: <T>(gen: AsyncGenerator<T | {
|
|
85
|
-
__type: "id";
|
|
86
|
-
id: string;
|
|
87
|
-
}>) => Promise<T[]>;
|
|
88
50
|
createHandleStore: () => any;
|
|
89
|
-
resolveLoadersOnly?: (entries: EntryData[],
|
|
90
|
-
resolveLoadersOnlyWithRevalidation?: (entries: EntryData[], handlerContext: HandlerContext<any, TEnv>, clientSegmentSet: Set<string>, prevParams: Record<string, string>, request: Request, prevUrl: URL, nextUrl: URL, routeKey: string, actionContext?: any, stale?: boolean) => Promise<{
|
|
51
|
+
resolveLoadersOnly?: (pass: ResolutionPassInput<TEnv>, entries: EntryData[], walk?: Pick<RevalidatingWalkOptions, "interceptResult">) => Promise<{
|
|
91
52
|
segments: ResolvedSegment[];
|
|
92
53
|
matchedIds: string[];
|
|
93
54
|
}>;
|
|
@@ -96,7 +57,7 @@ export interface RouterContext<TEnv = any> {
|
|
|
96
57
|
}>;
|
|
97
58
|
telemetry?: TelemetrySink;
|
|
98
59
|
requestId?: string;
|
|
99
|
-
resolveInterceptLoadersOnly?: (intercept: InterceptEntry, entry: EntryData,
|
|
60
|
+
resolveInterceptLoadersOnly?: (pass: ResolutionPassInput<TEnv>, intercept: InterceptEntry, entry: EntryData, belongsToRoute: boolean) => Promise<ResolvedSegment[]>;
|
|
100
61
|
}
|
|
101
62
|
/**
|
|
102
63
|
* Get router dependencies from AsyncLocalStorage context
|
|
@@ -4,7 +4,6 @@ import type { ReverseFunction } from "../reverse.js";
|
|
|
4
4
|
import type { UrlPatterns } from "../urls.js";
|
|
5
5
|
import type { ClientUrlPatterns } from "../client-urls/types.js";
|
|
6
6
|
import type { UrlBuilder, EnvCompatible } from "../urls/pattern-types.js";
|
|
7
|
-
import type { EntryData } from "../server/context";
|
|
8
7
|
import type { ErrorInfo, MatchResult } from "../types";
|
|
9
8
|
import type { NonceProvider } from "../rsc/types.js";
|
|
10
9
|
import type { ShellCaptureDebug } from "../rsc/shell-capture.js";
|
|
@@ -12,6 +11,7 @@ import type { ExecutionContext } from "../server/request-context.js";
|
|
|
12
11
|
import type { SerializedSegmentData } from "../cache/types.js";
|
|
13
12
|
import type { MiddlewareEntry, MiddlewareFn } from "./middleware.js";
|
|
14
13
|
import type { RouteMatchResult } from "./pattern-matching.js";
|
|
14
|
+
import type { LiveIntercept } from "./prerender-match.js";
|
|
15
15
|
import type { ExtractParams } from "../types/route-config.js";
|
|
16
16
|
import { RSC_ROUTER_BRAND } from "./router-registry.js";
|
|
17
17
|
import type { RangoOptions, RootLayoutProps } from "./router-options.js";
|
|
@@ -19,6 +19,7 @@ import type { DefaultVars } from "../types/global-namespace.js";
|
|
|
19
19
|
import type { ResolvedTimeouts, OnTimeoutCallback } from "./timeout.js";
|
|
20
20
|
import type { ResolvedTracing } from "./tracing.js";
|
|
21
21
|
import type { TelemetrySink } from "./telemetry.js";
|
|
22
|
+
import type { ActionContext } from "./types.js";
|
|
22
23
|
/**
|
|
23
24
|
* Options passed to router.fetch(), router.match(), and other request entrypoints.
|
|
24
25
|
* All entrypoints use this same shape for consistency.
|
|
@@ -425,8 +426,10 @@ export interface RangoInternal<TEnv = any, TRoutes extends Record<string, unknow
|
|
|
425
426
|
routeName: string;
|
|
426
427
|
params: Record<string, string>;
|
|
427
428
|
interceptSegments?: SerializedSegmentData[];
|
|
428
|
-
/** RSC-encoded
|
|
429
|
+
/** RSC-encoded handle map for the intercept artifact (see matchForPrerender). */
|
|
429
430
|
interceptHandles?: string;
|
|
431
|
+
/** The intercepts the intercept artifact does not hold (see matchForPrerender). */
|
|
432
|
+
liveIntercepts?: LiveIntercept[];
|
|
430
433
|
passthrough?: true;
|
|
431
434
|
} | null>;
|
|
432
435
|
/**
|
|
@@ -438,27 +441,18 @@ export interface RangoInternal<TEnv = any, TRoutes extends Record<string, unknow
|
|
|
438
441
|
handles: string;
|
|
439
442
|
} | null>;
|
|
440
443
|
/**
|
|
441
|
-
* Preview match - returns route
|
|
442
|
-
*
|
|
444
|
+
* Preview match - returns the route, its params and route middleware
|
|
445
|
+
* without segment resolution.
|
|
443
446
|
*/
|
|
444
447
|
previewMatch(request: Request, input?: RouterRequestInput<TEnv>): Promise<{
|
|
445
448
|
routeMiddleware?: Array<{
|
|
446
449
|
handler: import("./middleware.js").MiddlewareFn;
|
|
447
450
|
params: Record<string, string>;
|
|
448
451
|
}>;
|
|
449
|
-
responseType?: string;
|
|
450
|
-
handler?: Function;
|
|
451
452
|
params?: Record<string, string>;
|
|
452
|
-
negotiated?: boolean;
|
|
453
|
-
manifestEntry?: EntryData;
|
|
454
453
|
routeKey?: string;
|
|
455
454
|
} | null>;
|
|
456
|
-
matchPartial(request: Request, input?: RouterRequestInput<TEnv>, actionContext?:
|
|
457
|
-
actionId?: string;
|
|
458
|
-
actionUrl?: URL;
|
|
459
|
-
actionResult?: any;
|
|
460
|
-
formData?: FormData;
|
|
461
|
-
}): Promise<MatchResult | null>;
|
|
455
|
+
matchPartial(request: Request, input?: RouterRequestInput<TEnv>, actionContext?: ActionContext): Promise<MatchResult | null>;
|
|
462
456
|
/**
|
|
463
457
|
* Match an error to the nearest error boundary and return error segments
|
|
464
458
|
*
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { ReactNode } from "react";
|
|
11
11
|
import type { EntryData } from "../../server/context";
|
|
12
|
-
import type { ResolvedSegment, HandlerContext } from "../../types";
|
|
12
|
+
import type { ResolvedSegment, ErrorInfo, HandlerContext } from "../../types";
|
|
13
13
|
import type { SegmentResolutionDeps } from "../types.js";
|
|
14
14
|
import type { TelemetrySink } from "../telemetry.js";
|
|
15
15
|
/** The errorContext shape wrapLoaderPromise expects as its 5th argument. */
|
|
@@ -70,16 +70,32 @@ export interface ErrorReportContext {
|
|
|
70
70
|
routeKey?: string;
|
|
71
71
|
env?: any;
|
|
72
72
|
isPartial?: boolean;
|
|
73
|
-
requestStartTime?: number;
|
|
74
73
|
telemetry?: TelemetrySink;
|
|
75
74
|
}
|
|
75
|
+
type Thrower = {
|
|
76
|
+
id: string;
|
|
77
|
+
type: ErrorInfo["segmentType"];
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Note that `id` threw `error`, for an error its owning entry's boundary
|
|
81
|
+
* catches (a parallel slot's sync throw, an orphan layout's): onError names
|
|
82
|
+
* the segment that threw, as a streamed slot's rejection does. Kept on the
|
|
83
|
+
* request context, never the module: a reused error object (a constant, a
|
|
84
|
+
* memoized rejection) can be thrown by another request, or by a Prerender
|
|
85
|
+
* pass that rethrows before catchSegmentError reads it. Returns `error`, to
|
|
86
|
+
* rethrow.
|
|
87
|
+
*/
|
|
88
|
+
export declare function noteThrower(error: unknown, id: string, type: ErrorInfo["segmentType"]): unknown;
|
|
76
89
|
/**
|
|
77
90
|
* Handle a caught error during segment resolution by creating an
|
|
78
91
|
* error or not-found segment with the nearest boundary.
|
|
79
92
|
*
|
|
80
93
|
* Called by resolveWithErrorBoundary to produce error/notFound segments.
|
|
94
|
+
* `entry` is where the boundary is looked up; `thrower` names the segment
|
|
95
|
+
* that threw when it is not `entry` (an intercept's slot, under its declaring
|
|
96
|
+
* entry), for the report, the server print and the client's ErrorInfo.
|
|
81
97
|
*/
|
|
82
|
-
export declare function catchSegmentError<TEnv>(error: unknown, entry: EntryData, params: Record<string, string>, deps: SegmentResolutionDeps<TEnv>, report?: ErrorReportContext, pathname?: string): ResolvedSegment;
|
|
98
|
+
export declare function catchSegmentError<TEnv>(error: unknown, entry: EntryData, params: Record<string, string>, deps: SegmentResolutionDeps<TEnv>, report?: ErrorReportContext, pathname?: string, thrower?: Thrower): ResolvedSegment;
|
|
83
99
|
/**
|
|
84
100
|
* Generic error boundary wrapper for segment resolution.
|
|
85
101
|
* Catches non-Response errors and produces an error/notFound segment
|
|
@@ -94,8 +94,8 @@ export declare function loaderPins(entries: readonly EntryData[], reqCtx: Reques
|
|
|
94
94
|
* PPR loader lane rule — the canonical source statement; other sites point
|
|
95
95
|
* here (consumer docs: skills/ppr/SKILL.md "The loader lane rule";
|
|
96
96
|
* docs/design/loader-container-bake.md). This is the single funnel every
|
|
97
|
-
* loader segment path routes through (
|
|
98
|
-
*
|
|
97
|
+
* loader segment path routes through (resolveOwnerLoaders: the full match's
|
|
98
|
+
* FRESH pass, cache-hit and revalidation resolveLoadersOnly, and
|
|
99
99
|
* intercept loaders in intercept-resolution.ts, which pass no bake key and
|
|
100
100
|
* never run under a shell capture), so the lane is decided here, per LOADER,
|
|
101
101
|
* never by the entry's loading():
|
|
@@ -109,7 +109,7 @@ export declare function loaderPins(entries: readonly EntryData[], reqCtx: Reques
|
|
|
109
109
|
* plain objects, arrays and JSX props are masked (mask-nested.ts) and stay
|
|
110
110
|
* live holes at the consumer's own Suspense — per-request material must be
|
|
111
111
|
* promise-shaped (the #692 cross-session scar). The masked container
|
|
112
|
-
* registers on `
|
|
112
|
+
* registers on `_shellCaptureState.loaderRecords`: it holds the capture gate
|
|
113
113
|
* (bounded by `ppr.captureTimeout`) and pins into the snapshot's loader
|
|
114
114
|
* family, and on a HIT the recorded container is overlaid onto the fresh
|
|
115
115
|
* run (below) so the payload matches the frozen prelude outside the holes.
|
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
* consuming Suspense subtree postpones as a hole, and the serve pass runs them
|
|
8
8
|
* fresh into it.
|
|
9
9
|
*
|
|
10
|
-
* Capture mode is signalled by `requestCtx.
|
|
10
|
+
* Capture mode is signalled by `requestCtx._shellCaptureState.run`, set ONLY on
|
|
11
11
|
* the derived request context of the background capture task (shell-capture.ts);
|
|
12
|
-
* the foreground render never
|
|
12
|
+
* the foreground render never has it. This module is the single home for the
|
|
13
13
|
* mask so every loader execution site gates the same way (loader-cache.ts
|
|
14
|
-
* `resolveLoaderData`,
|
|
14
|
+
* `resolveLoaderData`, revalidation.ts `resolveOwnerLoaders`).
|
|
15
15
|
*/
|
|
16
16
|
import { type RequestContext } from "../../server/request-context.js";
|
|
17
17
|
/**
|
|
18
18
|
* True when the current render is the active PPR shell capture and route loaders
|
|
19
|
-
* must be masked rather than executed. Reads `
|
|
19
|
+
* must be masked rather than executed. Reads `_shellCaptureState` off the ALS
|
|
20
20
|
* request context (the capture task re-establishes its derived context via
|
|
21
21
|
* runWithRequestContext), so it is accurate at the loader resolution sites, which
|
|
22
22
|
* run synchronously inside the pipeline's context frame.
|