@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
|
@@ -145,7 +145,7 @@ export declare class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<T
|
|
|
145
145
|
* the faulty per-colo entry ONLY when that fall-through found no good copy.
|
|
146
146
|
*
|
|
147
147
|
* The conditional evict is the load-bearing detail: when KV DOES serve a copy,
|
|
148
|
-
*
|
|
148
|
+
* readKv has already scheduled a same-key promote (`cache.put`); an eager
|
|
149
149
|
* `cache.delete` here would race that put with no CF Cache API ordering
|
|
150
150
|
* guarantee and could clobber the freshly-restored entry. So in that case we
|
|
151
151
|
* lean on #558's heal-by-overwrite (the non-suppressed fall-through promotes /
|
|
@@ -164,7 +164,10 @@ export declare class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<T
|
|
|
164
164
|
private healCorruptL1;
|
|
165
165
|
/**
|
|
166
166
|
* Re-put a stale L1 entry marked REVALIDATING, so concurrent requests serve it
|
|
167
|
-
* without each triggering a revalidation.
|
|
167
|
+
* without each triggering a revalidation (readL1). A JSON family re-puts its
|
|
168
|
+
* parsed body as a string, without a status text as set() writes it; the
|
|
169
|
+
* document re-puts a clone (`source`) whose original body still streams to
|
|
170
|
+
* the client.
|
|
168
171
|
*
|
|
169
172
|
* The write is NON-BLOCKING (waitUntil) and best-effort by design:
|
|
170
173
|
* - It runs in waitUntil, so it never adds the put latency to the served stale
|
|
@@ -185,20 +188,6 @@ export declare class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<T
|
|
|
185
188
|
* @internal
|
|
186
189
|
*/
|
|
187
190
|
private markRevalidating;
|
|
188
|
-
/**
|
|
189
|
-
* Document-tier counterpart of markRevalidating for getResponse's herd guard.
|
|
190
|
-
* The segment/item tiers JSON-parse the body, so they re-put with a string
|
|
191
|
-
* body; document bodies are streamed verbatim, so we re-put with a CLONED
|
|
192
|
-
* response body (`response.clone()`) supplied by the caller -- the original
|
|
193
|
-
* body still streams to the client while the marker carries the clone. Same
|
|
194
|
-
* REVALIDATING status header, same revalidating-at stamp, same
|
|
195
|
-
* remainingCacheControl re-put math as markRevalidating, so the document tier
|
|
196
|
-
* suppresses concurrent revalidation for the identical MAX_REVALIDATION_INTERVAL
|
|
197
|
-
* window the segment tier does. Best-effort and non-blocking: a failed marker
|
|
198
|
-
* write must not affect the served stale read.
|
|
199
|
-
* @internal
|
|
200
|
-
*/
|
|
201
|
-
private markResponseRevalidating;
|
|
202
191
|
/**
|
|
203
192
|
* Guard the segment tier against a `keyGenerator` that returns a key colliding
|
|
204
193
|
* with a reserved tag-marker namespace: `__tag__/` (the KV marker key) or
|
|
@@ -212,17 +201,29 @@ export declare class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<T
|
|
|
212
201
|
*/
|
|
213
202
|
private isReservedSegmentKey;
|
|
214
203
|
/**
|
|
215
|
-
* Get cached entry data by key.
|
|
216
|
-
*
|
|
217
|
-
|
|
204
|
+
* Get cached entry data by key (readL1). On L1 miss, falls back to KV (L2)
|
|
205
|
+
* if configured; KV hits are promoted to L1 in the background.
|
|
206
|
+
*/
|
|
207
|
+
get(key: string): Promise<CacheGetResult | null | CacheReadError>;
|
|
208
|
+
/**
|
|
209
|
+
* The family's debug sink for one read; the document family is outside the
|
|
210
|
+
* debug surface (op is only get/getItem). Undefined when debug is off, so
|
|
211
|
+
* the hot path allocates no event.
|
|
212
|
+
* @internal
|
|
213
|
+
*/
|
|
214
|
+
private debugSink;
|
|
215
|
+
/**
|
|
216
|
+
* The L1 read of a family, which handles SWR atomically:
|
|
218
217
|
* - If stale and not already revalidating, marks as REVALIDATING and returns shouldRevalidate: true
|
|
219
218
|
* - If already REVALIDATING (and recent), returns shouldRevalidate: false
|
|
220
219
|
* - If fresh, returns shouldRevalidate: false
|
|
221
220
|
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
221
|
+
* Every degraded L1 read falls through to KV (readKv). The family methods
|
|
222
|
+
* return it unwrapped: an async wrapper adds two promises and two microtask
|
|
223
|
+
* ticks to every read.
|
|
224
|
+
* @internal
|
|
224
225
|
*/
|
|
225
|
-
|
|
226
|
+
private readL1;
|
|
226
227
|
/**
|
|
227
228
|
* Store entry data with TTL and optional SWR window.
|
|
228
229
|
* Resolves once the L1 write lands, per the SegmentCacheStore.set contract
|
|
@@ -236,9 +237,9 @@ export declare class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<T
|
|
|
236
237
|
*/
|
|
237
238
|
delete(key: string): Promise<boolean>;
|
|
238
239
|
/**
|
|
239
|
-
* Get a cached Response by key (for document-level caching).
|
|
240
|
-
*
|
|
241
|
-
*
|
|
240
|
+
* Get a cached Response by key (for document-level caching): see readL1.
|
|
241
|
+
* Its body streams to the client unread, outside the debug surface. Falls
|
|
242
|
+
* back to KV (L2) on L1 miss.
|
|
242
243
|
*/
|
|
243
244
|
getResponse(key: string): Promise<{
|
|
244
245
|
response: Response;
|
|
@@ -258,7 +259,7 @@ export declare class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<T
|
|
|
258
259
|
putResponse(key: string, response: Response, ttl: number, swr?: number, tags?: string[]): Promise<void>;
|
|
259
260
|
/**
|
|
260
261
|
* Get a cached function result by key.
|
|
261
|
-
* Follows the same SWR pattern as get() for segment caching.
|
|
262
|
+
* Follows the same SWR pattern as get() for segment caching (readL1).
|
|
262
263
|
* Falls back to KV (L2) on L1 miss.
|
|
263
264
|
*/
|
|
264
265
|
getItem(key: string): Promise<CacheItemResult | null>;
|
|
@@ -351,7 +352,7 @@ export declare class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<T
|
|
|
351
352
|
* caller's `tagHints`: cfTagHints may have evicted the key while the memo
|
|
352
353
|
* still holds it. A shell a tag marker rejects is dropped and read from
|
|
353
354
|
* the store too, which may hold a capture from after the marker (see
|
|
354
|
-
*
|
|
355
|
+
* readL1(), "Tag invalidation"), unless the request's own mask rejected it
|
|
355
356
|
* (declinesKvFallThrough).
|
|
356
357
|
*/
|
|
357
358
|
private readMemoizedShell;
|
|
@@ -538,15 +539,6 @@ export declare class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<T
|
|
|
538
539
|
* @internal
|
|
539
540
|
*/
|
|
540
541
|
private skipUncacheableTagSet;
|
|
541
|
-
/**
|
|
542
|
-
* Merge the internal tag headers onto an existing Headers instance. The
|
|
543
|
-
* from-scratch paths spread tagHeaderEntries() into an object-literal init;
|
|
544
|
-
* the document put/promote paths build a Headers first, so they .set() each
|
|
545
|
-
* entry instead — except `Cache-Tag`, which is APPENDED: a document author
|
|
546
|
-
* may have set their own Cache-Tag, and clobbering it would break their CDN
|
|
547
|
-
* purging. Append produces the comma-merged list CF expects.
|
|
548
|
-
*/
|
|
549
|
-
private setTagHeaders;
|
|
550
542
|
/** Read an entry's tags/taggedAt back from its headers. */
|
|
551
543
|
private readTagInfo;
|
|
552
544
|
/**
|
|
@@ -780,12 +772,27 @@ export declare class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<T
|
|
|
780
772
|
/** invalidateTags' marker writes, tag purge, and hooks. */
|
|
781
773
|
private writeTagInvalidation;
|
|
782
774
|
/**
|
|
783
|
-
* KV
|
|
784
|
-
*
|
|
785
|
-
*
|
|
775
|
+
* The KV (L2) read behind an L1 miss, for every family: a missing,
|
|
776
|
+
* timed-out, corrupt (kvGetOrEvict reports and evicts it), expired or
|
|
777
|
+
* tag-invalidated envelope is a miss, a read failure is the family's read
|
|
778
|
+
* error, and a hit is promoted to L1 in the background.
|
|
779
|
+
*
|
|
780
|
+
* A degraded L1 fall-through (body-timeout / non-200) passes
|
|
781
|
+
* `suppressRevalidate`: KV has no REVALIDATING herd guard, so N concurrent
|
|
782
|
+
* degraded reads would otherwise each spawn a render exactly when the colo
|
|
783
|
+
* is already struggling. The stale data is still served and promoted; only
|
|
784
|
+
* the revalidation is withheld.
|
|
785
|
+
* @internal
|
|
786
|
+
*/
|
|
787
|
+
private readKv;
|
|
788
|
+
/**
|
|
789
|
+
* Promote a KV hit to L1 in the background, under its remaining ttl, with
|
|
790
|
+
* its deadlines (so a promoted entry that later goes stale re-puts with the
|
|
791
|
+
* correct remaining ttl, see set()) and its tags (so it stays
|
|
792
|
+
* tag-invalidatable). The family builds the entry (toL1).
|
|
786
793
|
* @internal
|
|
787
794
|
*/
|
|
788
|
-
private
|
|
795
|
+
private promoteToL1;
|
|
789
796
|
/**
|
|
790
797
|
* Write segment data to KV.
|
|
791
798
|
*
|
|
@@ -794,29 +801,4 @@ export declare class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<T
|
|
|
794
801
|
* @internal
|
|
795
802
|
*/
|
|
796
803
|
private kvSetSegment;
|
|
797
|
-
/**
|
|
798
|
-
* Promote segment data from KV to L1 Cache API.
|
|
799
|
-
* @internal
|
|
800
|
-
*/
|
|
801
|
-
private promoteSegmentToL1;
|
|
802
|
-
/**
|
|
803
|
-
* KV fallback for function cache reads.
|
|
804
|
-
* @internal
|
|
805
|
-
*/
|
|
806
|
-
private kvGetItem;
|
|
807
|
-
/**
|
|
808
|
-
* Promote function cache data from KV to L1.
|
|
809
|
-
* @internal
|
|
810
|
-
*/
|
|
811
|
-
private promoteItemToL1;
|
|
812
|
-
/**
|
|
813
|
-
* KV fallback for document cache reads.
|
|
814
|
-
* @internal
|
|
815
|
-
*/
|
|
816
|
-
private kvGetResponse;
|
|
817
|
-
/**
|
|
818
|
-
* Promote document cache data from KV to L1.
|
|
819
|
-
* @internal
|
|
820
|
-
*/
|
|
821
|
-
private promoteResponseToL1;
|
|
822
804
|
}
|
|
@@ -37,7 +37,7 @@ export declare function kvKeyDigest(value: string): Promise<string>;
|
|
|
37
37
|
* of restarting it -- copying set()'s original full-window max-age would reset
|
|
38
38
|
* CF's retention clock on every re-arm and pin a perpetually-stale entry forever.
|
|
39
39
|
* An entry lacking a valid deadline (legacy/tampered) floors to max-age=1, so it
|
|
40
|
-
* hard-expires in ~1s and self-heals via KV. Mirrors
|
|
40
|
+
* hard-expires in ~1s and self-heals via KV. Mirrors promoteToL1's math.
|
|
41
41
|
* @internal
|
|
42
42
|
*/
|
|
43
43
|
export declare function remainingCacheControl(headers: Headers, now: number): string;
|
|
@@ -31,7 +31,7 @@ export declare function decodeHandleValue<T>(encoded: string): Promise<T | null>
|
|
|
31
31
|
*
|
|
32
32
|
* DSL-loader pushes stay out of the CACHE WRITE: a HIT runs loaders exactly
|
|
33
33
|
* as an uncached render of the same request would (cache-lookup.ts
|
|
34
|
-
*
|
|
34
|
+
* serveStoredSegments), so replaying a recorded copy would duplicate
|
|
35
35
|
* the live push. Handler pushes, including
|
|
36
36
|
* handler-invoked ctx.use(Loader) bodies (skipped with their handler on a
|
|
37
37
|
* HIT), are kept. The store tags loader pushes by array position at push
|
|
@@ -75,19 +75,24 @@ export type OwnedPushDelivery = (loaderId: string) => RecordAuthority;
|
|
|
75
75
|
* owner. Neither claims its loader, so the loader's own cache() HIT still
|
|
76
76
|
* delivers (the pushes holding a promise a restored copy lets through, or its
|
|
77
77
|
* entry's pushes in a placeholder's place).
|
|
78
|
+
*
|
|
79
|
+
* `sent` (a partial request) names the segments the response sends. Any
|
|
80
|
+
* other segment is kept with its handler's values, as on a live walk: only
|
|
81
|
+
* its loaders' copies are restored, which follow their loader as above.
|
|
78
82
|
*/
|
|
79
|
-
export declare function restoreHandles(handles: Record<string, SegmentHandleData>, handleStore: HandleStore, owners?: HandleOwners, owned?: OwnedPushDelivery): void;
|
|
83
|
+
export declare function restoreHandles(handles: Record<string, SegmentHandleData>, handleStore: HandleStore, owners?: HandleOwners, owned?: OwnedPushDelivery, sent?: ReadonlySet<string>): void;
|
|
80
84
|
/**
|
|
81
85
|
* Serve a doc record's handles: set its authority over the loaders' pushes
|
|
82
86
|
* (with or without a handles blob: a pinned loader whose capture pushed
|
|
83
87
|
* nothing has no copy, and its run must still add no settled push), then
|
|
84
88
|
* decode and restoreHandles. `keepIds` limits the restore to the segments a
|
|
85
|
-
* boundary-scoped scope serves. A decode failure
|
|
89
|
+
* boundary-scoped scope serves; `sent` is restoreHandles'. A decode failure
|
|
90
|
+
* skips the restore.
|
|
86
91
|
*/
|
|
87
92
|
export declare function restoreRecordHandles(handleStore: HandleStore, record: {
|
|
88
93
|
handles?: string;
|
|
89
94
|
handleOwners?: HandleOwners;
|
|
90
|
-
}, owned: OwnedPushDelivery | undefined, keepIds?: ReadonlySet<string>): Promise<void>;
|
|
95
|
+
}, owned: OwnedPushDelivery | undefined, keepIds?: ReadonlySet<string>, sent?: ReadonlySet<string>): Promise<void>;
|
|
91
96
|
/**
|
|
92
97
|
* Append recorded handle pushes to the store, in recorded order, via push()
|
|
93
98
|
* so active captures and loader-scope tagging see them like live pushes. For
|
|
@@ -37,6 +37,20 @@ export declare function rscDeserialize<T>(encoded: string | undefined): Promise<
|
|
|
37
37
|
* Returns null only on serialization failure.
|
|
38
38
|
*/
|
|
39
39
|
export declare function serializeResult(value: unknown, onError?: (error: unknown) => void): Promise<string | null>;
|
|
40
|
+
/** The Flight encode of a value and a decoded copy of it (teeResult). */
|
|
41
|
+
export interface TeedResult {
|
|
42
|
+
/** The copy: settles when the root row arrives; later rows stream in. */
|
|
43
|
+
decoded: Promise<unknown>;
|
|
44
|
+
/** The whole encoded text, or null when the stream failed. */
|
|
45
|
+
serialized: Promise<string | null>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Encode `value` once and decode a copy of it as the encode streams, so a
|
|
49
|
+
* "use cache" miss renders the copy as a hit renders a stored entry, and
|
|
50
|
+
* stores the same bytes. Null when the encode could not start.
|
|
51
|
+
*/
|
|
52
|
+
export declare function teeResult(value: unknown, onError?: (error: unknown) => void): TeedResult | null;
|
|
53
|
+
export declare function isUnsupportedValueError(error: unknown): boolean;
|
|
40
54
|
/**
|
|
41
55
|
* RSC-deserialize a cached result string.
|
|
42
56
|
* Counterpart to serializeResult() — always receives a non-empty string.
|
|
@@ -210,7 +210,7 @@ export declare function buildShellLoaderSeed(snapshot: ShellSnapshotRecord[], on
|
|
|
210
210
|
export declare const SHELL_HANDLES_RECORD_KEY = "handles";
|
|
211
211
|
/**
|
|
212
212
|
* The `handles` record of a prerender-served entry, which a HIT tail restores
|
|
213
|
-
* after the prerender store's handles (cache-lookup.ts
|
|
213
|
+
* after the prerender store's handles (cache-lookup.ts decodeStoredEntry), or
|
|
214
214
|
* undefined: an entry with a doc record, or one written before the record
|
|
215
215
|
* existed (v0.21), which serves as it did.
|
|
216
216
|
*/
|
|
@@ -11,9 +11,11 @@ export declare const NOCACHE_SYMBOL: unique symbol;
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function isTainted(value: unknown): boolean;
|
|
13
13
|
/**
|
|
14
|
-
* Symbol stamped on tainted ctx objects PASSED AS
|
|
15
|
-
* function during its execution. ctx.set(),
|
|
16
|
-
* flag and throw if present — those side
|
|
14
|
+
* Symbol stamped on tainted handler and middleware ctx objects PASSED AS
|
|
15
|
+
* ARGUMENTS to a "use cache" function during its execution. ctx.set(),
|
|
16
|
+
* ctx.header(), etc. check this flag and throw if present — those side
|
|
17
|
+
* effects are lost on cache hit. A request context passed as an argument is
|
|
18
|
+
* not stamped (registerCachedFunction in cache-runtime.ts).
|
|
17
19
|
*
|
|
18
20
|
* Argument objects only. Ambient access (cookies()/headers() and ctx methods
|
|
19
21
|
* reached via getRequestContext()) is guarded by the AsyncLocalStorage scope
|
|
@@ -86,10 +86,14 @@ export interface SegmentCacheStore<TEnv = unknown> {
|
|
|
86
86
|
* Return value becomes the final cache key (unless route overrides with `key` option).
|
|
87
87
|
*
|
|
88
88
|
* Resolution priority:
|
|
89
|
-
* 1. Route-level `key` function (
|
|
89
|
+
* 1. Route-level `key` function (replaces the URL part; the request kind stays)
|
|
90
90
|
* 2. Store-level `keyGenerator` (modifies default key)
|
|
91
91
|
* 3. Default key generation (prefix:pathname:params)
|
|
92
92
|
*
|
|
93
|
+
* Keep `defaultKey` in the result: its prefix names the request kind (a
|
|
94
|
+
* document, a navigation or an intercept navigation), whose records hold
|
|
95
|
+
* different segments. A result without it gives every kind one record.
|
|
96
|
+
*
|
|
93
97
|
* Return `defaultKey` unchanged to leave a request unpartitioned. An empty
|
|
94
98
|
* string is not a key: where the result partitions a nested cache() on
|
|
95
99
|
* another store, or a ppr shell, it fails key resolution, so the request
|
|
@@ -250,7 +254,7 @@ export interface SegmentCacheStore<TEnv = unknown> {
|
|
|
250
254
|
/**
|
|
251
255
|
* Declares the shell family present-but-inert: getShell/putShell exist but
|
|
252
256
|
* no-op (a custom store whose backing tier is conditionally unavailable).
|
|
253
|
-
*
|
|
257
|
+
* planShellCapture skips captures whose only write target is inert —
|
|
254
258
|
* the background render would be dead work that still occupies the
|
|
255
259
|
* per-isolate serialized capture queue (a promise-heavy route bakes for
|
|
256
260
|
* seconds per MISS with nothing stored). Absent/false means the family,
|
|
@@ -602,7 +606,7 @@ export type ShellSnapshotFamily = "segment" | "loader" | "handles";
|
|
|
602
606
|
* format (CachedEntryData `handles` + `handleOwners`). A Prerender + ppr
|
|
603
607
|
* route's handler layer comes from the prerender store, whose build-time
|
|
604
608
|
* entry has no loader push, so the entry keeps these for the HIT to restore
|
|
605
|
-
* as a doc record's (issue #1057,
|
|
609
|
+
* as a doc record's (issue #1057, decodeStoredEntry in cache-lookup.ts). An
|
|
606
610
|
* entry written before it (v0.21) has none and serves as it did.
|
|
607
611
|
*/
|
|
608
612
|
export type ShellSnapshotHandlesValue = Pick<CachedEntryData, "handles" | "handleOwners">;
|
|
@@ -326,8 +326,14 @@ export declare class VercelCacheStore<TEnv = unknown> implements SegmentCacheSto
|
|
|
326
326
|
* `taggedAt`. An entry without a stamp counts as older than any mask.
|
|
327
327
|
*/
|
|
328
328
|
private maskedForRequest;
|
|
329
|
-
/**
|
|
330
|
-
|
|
329
|
+
/**
|
|
330
|
+
* The read of a data family (get, getItem, getResponse): a failed read is
|
|
331
|
+
* the family's `readError`; a missing, corrupt, expired or masked entry is a
|
|
332
|
+
* miss, and a corrupt or expired one is evicted. The hit is built before the
|
|
333
|
+
* stale claim, so an entry that does not rebuild is evicted as corrupt with
|
|
334
|
+
* no revalidation lock written for it.
|
|
335
|
+
*/
|
|
336
|
+
private readRecord;
|
|
331
337
|
private toStoreKey;
|
|
332
338
|
private write;
|
|
333
339
|
/**
|
|
@@ -370,8 +376,4 @@ export declare class VercelCacheStore<TEnv = unknown> implements SegmentCacheSto
|
|
|
370
376
|
private clampTagsForWrite;
|
|
371
377
|
private safeDelete;
|
|
372
378
|
private emitDebug;
|
|
373
|
-
private asSegmentEnvelope;
|
|
374
|
-
private asItemEnvelope;
|
|
375
|
-
private asShellEnvelope;
|
|
376
|
-
private asResponseEnvelope;
|
|
377
379
|
}
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The wire markers of prefetches
|
|
3
|
-
* (
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* like segment-fragments.ts: the browser must not import the server modules
|
|
8
|
-
* that use them.
|
|
2
|
+
* The wire markers of prefetches: shared by the browser and the server
|
|
3
|
+
* (router/segment-resolution/prefetch-deferral.ts requestKind,
|
|
4
|
+
* rsc/prefetch-render-error.ts, rsc/rsc-rendering.ts). Dependency free, like
|
|
5
|
+
* segment-fragments.ts: the browser must not import the server modules that
|
|
6
|
+
* use them.
|
|
9
7
|
*/
|
|
10
8
|
/** Request header of a `<Link>` prefetch (browser/prefetch/fetch.ts). */
|
|
11
9
|
export declare const PREFETCH_HEADER = "X-Rango-Prefetch";
|
|
12
|
-
/** Query param of a fill request (browser/navigation-client.ts). */
|
|
13
|
-
export declare const FILL_PARAM = "_rsc_fill";
|
|
14
|
-
/**
|
|
15
|
-
* Query param of a stale request (browser/navigation-client.ts): `revalidate()`
|
|
16
|
-
* sees `stale: true` (router/navigation-snapshot.ts).
|
|
17
|
-
*/
|
|
18
|
-
export declare const STALE_PARAM = "_rsc_stale";
|
|
19
10
|
/**
|
|
20
11
|
* The last row of a prefetch whose render reported an error
|
|
21
12
|
* (rsc/prefetch-render-error.ts): a Flight hint with a code React does not
|
|
@@ -54,6 +54,37 @@ export declare function createDevPrerenderStore(devUrl: string): PrerenderStore;
|
|
|
54
54
|
* Returns null if no prerender data is available.
|
|
55
55
|
*/
|
|
56
56
|
export declare function createPrerenderStore(): PrerenderStore | null;
|
|
57
|
+
/**
|
|
58
|
+
* The segments of a prerendered URL's intercept variant (`/i`): the main
|
|
59
|
+
* variant's without the intercepted route's own (`belongsToRoute`: its
|
|
60
|
+
* handler, layouts and slots), then the intercept's. A render under an
|
|
61
|
+
* intercept skips the route's entry (resolveAllSegments), so the variant
|
|
62
|
+
* holds what a cache() intercept record holds. The producer
|
|
63
|
+
* (matchForPrerender) encodes `interceptHandles` for exactly these segments.
|
|
64
|
+
*/
|
|
65
|
+
export declare function interceptVariantSegments(segments: SerializedSegmentData[], interceptSegments: SerializedSegmentData[]): SerializedSegmentData[];
|
|
66
|
+
/**
|
|
67
|
+
* The intercept variant as served under the intercept the match selected
|
|
68
|
+
* (findInterceptForRoute): its main segments and that intercept's slot,
|
|
69
|
+
* `slotId` in `intercept:<routeName>`. The build bakes every intercept that
|
|
70
|
+
* can target the route, since it cannot evaluate when(). Null when the
|
|
71
|
+
* variant does not hold that slot: the request renders live. The handles
|
|
72
|
+
* string is kept whole; decodeStoredEntry (cache-lookup.ts) replays only the
|
|
73
|
+
* served segments' pushes.
|
|
74
|
+
*/
|
|
75
|
+
export declare function selectInterceptVariant(entry: PrerenderEntry, slotId: string, routeName: string): PrerenderEntry | null;
|
|
76
|
+
/**
|
|
77
|
+
* The manifest entries ([key, PrerenderEntry JSON]) one prerendered URL
|
|
78
|
+
* bakes, keyed as the production store's get() reads them. The intercept
|
|
79
|
+
* variant (`/i`) holds interceptVariantSegments with the handle string the
|
|
80
|
+
* producer encoded for it. Written by the build
|
|
81
|
+
* (vite/discovery/prerender-collection.ts) and serveShellRequest.
|
|
82
|
+
*/
|
|
83
|
+
export declare function prerenderManifestEntries(result: PrerenderEntry & {
|
|
84
|
+
routeName: string;
|
|
85
|
+
interceptSegments?: SerializedSegmentData[];
|
|
86
|
+
interceptHandles?: string;
|
|
87
|
+
}, paramHash: string): Array<[key: string, value: string]>;
|
|
57
88
|
/**
|
|
58
89
|
* Create a static segment store.
|
|
59
90
|
* Production only: backed by globalThis.__STATIC_MANIFEST injected at build time.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* layers import this without pulling the trigger.
|
|
8
8
|
*/
|
|
9
9
|
import type { HandlerCacheConfig } from "../rsc/types.js";
|
|
10
|
-
import type { ShellCaptureDebugEvent } from "../rsc/shell-capture.js";
|
|
10
|
+
import type { ShellCaptureDebugEvent, ShellCaptureState } from "../rsc/shell-capture.js";
|
|
11
11
|
import type { PrerenderWarmCaches } from "./on-demand.js";
|
|
12
12
|
/** What one warm request did: written by the layers, read by the trigger. */
|
|
13
13
|
export interface PrerenderWarmRecord extends PrerenderWarmCaches {
|
|
@@ -33,7 +33,7 @@ export interface PrerenderWarmRecord extends PrerenderWarmCaches {
|
|
|
33
33
|
/** What the helpers read; a derived capture context inherits the record. */
|
|
34
34
|
export interface WarmContext {
|
|
35
35
|
_prerenderWarm?: PrerenderWarmRecord;
|
|
36
|
-
|
|
36
|
+
_shellCaptureState?: Pick<ShellCaptureState, "run">;
|
|
37
37
|
}
|
|
38
38
|
export declare function createWarmRecord(mode: PrerenderWarmRecord["mode"], cacheConfig: HandlerCacheConfig): PrerenderWarmRecord;
|
|
39
39
|
/** The mark is the object: a clone or a rebuilt request carries none. */
|
|
@@ -46,7 +46,7 @@ export declare function readWarmMark(request: Request): PrerenderWarmRecord | un
|
|
|
46
46
|
* "use cache" in-flight dedup lives outside the store, so a wrapper would
|
|
47
47
|
* miss both.
|
|
48
48
|
*
|
|
49
|
-
* False in the warm's own shell capture (`
|
|
49
|
+
* False in the warm's own shell capture (`_shellCaptureState`): it runs after
|
|
50
50
|
* the warm's writes settled and must replay them, or it would render every
|
|
51
51
|
* handler a second time and could bake another generation than the one just
|
|
52
52
|
* written.
|
|
@@ -264,8 +264,8 @@ export declare function isPrerenderPassthrough(value: unknown): value is Prerend
|
|
|
264
264
|
* A build handler signals passthrough by returning `ctx.passthrough()` (the
|
|
265
265
|
* PRERENDER_PASSTHROUGH sentinel), which lands on the segment's `component`.
|
|
266
266
|
* But when the route declares `loading()`, the handler result is deferred
|
|
267
|
-
* upstream (
|
|
268
|
-
* to the sentinel rather than the sentinel itself — a synchronous
|
|
267
|
+
* upstream (resolveEntryHandler), so `component` is a thenable
|
|
268
|
+
* resolving to the sentinel rather than the sentinel itself — a synchronous
|
|
269
269
|
* `isPrerenderPassthrough(component)` on the Promise returns false and the build
|
|
270
270
|
* bakes a corrupt artifact instead of deferring. Resolve thenables first.
|
|
271
271
|
*
|
|
@@ -32,3 +32,8 @@ export declare function publicRouteName(routeKey: string | undefined): string |
|
|
|
32
32
|
* Throws with a clear message when a reserved prefix is detected.
|
|
33
33
|
*/
|
|
34
34
|
export declare function validateUserRouteName(name: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* The route key's last name segment ("item" for "shop.item"). An intercept
|
|
37
|
+
* that targets it is selected when none targets the full key (match-api.ts).
|
|
38
|
+
*/
|
|
39
|
+
export declare function localRouteName(routeKey: string): string;
|
|
@@ -25,7 +25,7 @@ export interface InvokeOnErrorContext<TEnv = any> {
|
|
|
25
25
|
isPartial?: boolean;
|
|
26
26
|
handledByBoundary?: boolean;
|
|
27
27
|
metadata?: Record<string, unknown>;
|
|
28
|
-
/**
|
|
28
|
+
/** performance.now() at request entry; the request context's by default. */
|
|
29
29
|
requestStartTime?: number;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
@@ -35,6 +35,12 @@ export interface InvokeOnErrorContext<TEnv = any> {
|
|
|
35
35
|
* This is a shared utility used by both the router and RSC handler to ensure
|
|
36
36
|
* consistent error callback behavior across the codebase.
|
|
37
37
|
*
|
|
38
|
+
* `background` is set inside runAsBackgroundWork (server/request-context.ts),
|
|
39
|
+
* and `duration` and `env` come from the request context on the ALS
|
|
40
|
+
* (`_handlerStart`, `env`) when the call site leaves them out, so no call
|
|
41
|
+
* site has to know. A Prerender pass's ctx.env throws without buildEnv, so
|
|
42
|
+
* the walk never reads it eagerly.
|
|
43
|
+
*
|
|
38
44
|
* @param onError - The onError callback to invoke (may be undefined)
|
|
39
45
|
* @param error - The error that occurred
|
|
40
46
|
* @param phase - The phase where the error occurred
|
|
@@ -45,10 +51,10 @@ export declare function invokeOnError<TEnv = any>(onError: OnErrorCallback<TEnv>
|
|
|
45
51
|
/**
|
|
46
52
|
* First non-undefined `pick(orphan)` over the routeless entries in
|
|
47
53
|
* `entry.layout` and, recursively, in theirs: depth-first in render order
|
|
48
|
-
* (resolveOrphanLayout in segment-resolution/
|
|
49
|
-
* entry nested in another renders (a layout() after a
|
|
50
|
-
* layout() in a routeless wrapper); a one-level scan
|
|
51
|
-
* intercepts it declares (#926).
|
|
54
|
+
* (resolveOrphanLayout in segment-resolution/revalidation.ts).
|
|
55
|
+
* Since #922 a routeless entry nested in another renders (a layout() after a
|
|
56
|
+
* bare cache() marker, a layout() in a routeless wrapper); a one-level scan
|
|
57
|
+
* missed the boundaries and intercepts it declares (#926).
|
|
52
58
|
*
|
|
53
59
|
* `skip` is the entry an upward walk came from. Only a bare cache() marker is
|
|
54
60
|
* both in its layout's layout[] and in the chain, and its subtree was already
|
|
@@ -190,9 +190,10 @@ export declare function observeSegmentHandler<C, R>(segmentId: string, spanId: s
|
|
|
190
190
|
* loop (request.start/end/error, cache.decision, ...).
|
|
191
191
|
* - segment-resolution/helpers.ts emits via a caller-provided report.telemetry
|
|
192
192
|
* sink rather than the ALS router context.
|
|
193
|
-
* - rsc/
|
|
194
|
-
* (request.origin-rejected), and
|
|
195
|
-
* handler.error) emit via
|
|
193
|
+
* - rsc/request-stages.ts timeoutResponse (request.timeout) and
|
|
194
|
+
* originRejectedResponse (request.origin-rejected), and rsc/handler.ts
|
|
195
|
+
* handleStore.onError (late-handle handler.error) emit via
|
|
196
|
+
* router.telemetry directly — they run outside the
|
|
196
197
|
* RouterContext ALS (only match()/matchPartial() enter it), so a
|
|
197
198
|
* getRouterContext() read there throws and the event would vanish.
|
|
198
199
|
*/
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* functions for soft navigation (modals).
|
|
6
6
|
*/
|
|
7
7
|
import type { EntryData, InterceptEntry, InterceptSelectorContext } from "../server/context";
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type { RevalidationContext } from "./router-context.js";
|
|
8
|
+
import type { ResolvedSegment } from "../types";
|
|
9
|
+
import type { ResolutionPass } from "./segment-resolution/resolution-pass.js";
|
|
11
10
|
/**
|
|
12
11
|
* Check if an intercept's when conditions are satisfied.
|
|
13
12
|
* All when() functions must return true for the intercept to activate.
|
|
@@ -40,6 +39,19 @@ export declare function findInterceptForRoute(targetRouteKey: string, fromEntry:
|
|
|
40
39
|
} | null;
|
|
41
40
|
/** The segment id of `intercept`'s slot on `parentEntry`. */
|
|
42
41
|
export declare function interceptSlotId(parentEntry: EntryData, intercept: InterceptEntry): string;
|
|
42
|
+
/**
|
|
43
|
+
* The intercept a match selected (findInterceptForRoute), as its cache()
|
|
44
|
+
* record names it (CacheScope): the slot id, then `~` and its position among
|
|
45
|
+
* the intercepts its entry declares for the same slot and target route. Two
|
|
46
|
+
* such intercepts share the slot id, and the position tells them apart; one
|
|
47
|
+
* for another slot or route does not renumber it. `~` is unreserved in a
|
|
48
|
+
* URL, so a store that maps the key onto one unencoded keeps the whole key.
|
|
49
|
+
* Undefined when the match selected none.
|
|
50
|
+
*/
|
|
51
|
+
export declare function interceptRecordKey(selected: {
|
|
52
|
+
intercept: InterceptEntry;
|
|
53
|
+
entry: EntryData;
|
|
54
|
+
} | null): string | undefined;
|
|
43
55
|
/**
|
|
44
56
|
* Every segment id an intercept's slot owns, in order: the slot, then one
|
|
45
57
|
* loader segment per loader in declaration order, run or not. A request that
|
|
@@ -47,15 +59,19 @@ export declare function interceptSlotId(parentEntry: EntryData, intercept: Inter
|
|
|
47
59
|
*/
|
|
48
60
|
export declare function interceptSegmentIds(parentEntry: EntryData, intercept: InterceptEntry): string[];
|
|
49
61
|
/**
|
|
50
|
-
* Resolve an intercept entry: its slot segment, then its loader segments.
|
|
62
|
+
* Resolve an intercept entry: its slot segment, then its loader segments. The
|
|
63
|
+
* background re-render resolves with a pass that holds nothing
|
|
64
|
+
* (heldNothingPassInput, resolution-pass.ts): every segment renders fresh, and
|
|
65
|
+
* its loaders are skipped (skipLoaders), each registered for the handler's
|
|
66
|
+
* read.
|
|
51
67
|
*/
|
|
52
|
-
export declare function resolveInterceptEntry<TEnv>(interceptEntry: InterceptEntry, parentEntry: EntryData,
|
|
68
|
+
export declare function resolveInterceptEntry<TEnv>(pass: ResolutionPass<TEnv>, interceptEntry: InterceptEntry, parentEntry: EntryData, belongsToRoute: boolean, options?: {
|
|
53
69
|
/**
|
|
54
70
|
* Set ONLY by the post-response background re-render (stale background
|
|
55
71
|
* revalidation), whose sole purpose is to re-render the segment tree to
|
|
56
|
-
* populate the cache: a handler error
|
|
57
|
-
* error boundary, so a failure is never cached. Never
|
|
58
|
-
* foreground path.
|
|
72
|
+
* populate the cache: a handler error is reported, then rejects instead
|
|
73
|
+
* of rendering the error boundary, so a failure is never cached. Never
|
|
74
|
+
* set on the foreground path.
|
|
59
75
|
*/
|
|
60
76
|
background?: boolean;
|
|
61
77
|
}): Promise<ResolvedSegment[]>;
|
|
@@ -63,4 +79,4 @@ export declare function resolveInterceptEntry<TEnv>(interceptEntry: InterceptEnt
|
|
|
63
79
|
* The loader segments of a cached intercept slot, on a cache hit: the slot
|
|
64
80
|
* keeps its cached component and layout, its loaders are never cached.
|
|
65
81
|
*/
|
|
66
|
-
export declare function resolveInterceptLoadersOnly<TEnv>(interceptEntry: InterceptEntry, parentEntry: EntryData,
|
|
82
|
+
export declare function resolveInterceptLoadersOnly<TEnv>(pass: ResolutionPass<TEnv>, interceptEntry: InterceptEntry, parentEntry: EntryData, belongsToRoute: boolean): Promise<ResolvedSegment[]>;
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
*
|
|
64
64
|
* Handler Context:
|
|
65
65
|
* - handlerContext: Context passed to loaders
|
|
66
|
-
* - loaderPromises: Memoized loader promises
|
|
67
66
|
*
|
|
68
67
|
* Intercepts:
|
|
69
68
|
* - interceptResult: Detected intercept (if soft navigation)
|
|
@@ -114,15 +113,8 @@ import type { EntryData, InterceptSelectorContext, MetricsStore } from "../serve
|
|
|
114
113
|
import type { HandlerContext, ResolvedSegment } from "../types.js";
|
|
115
114
|
import type { RouteMatchResult } from "./pattern-matching.js";
|
|
116
115
|
import type { InterceptResult } from "./router-context.js";
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
*/
|
|
120
|
-
export interface ActionContext {
|
|
121
|
-
actionId?: string;
|
|
122
|
-
actionUrl?: URL;
|
|
123
|
-
actionResult?: any;
|
|
124
|
-
formData?: FormData;
|
|
125
|
-
}
|
|
116
|
+
import type { ResolutionPassInput } from "./segment-resolution/resolution-pass.js";
|
|
117
|
+
import type { ActionContext } from "./types.js";
|
|
126
118
|
/**
|
|
127
119
|
* Match context containing all state for the match pipeline
|
|
128
120
|
*/
|
|
@@ -134,6 +126,8 @@ export interface MatchContext<TEnv = any> {
|
|
|
134
126
|
clientSegmentIds: string[];
|
|
135
127
|
clientSegmentSet: Set<string>;
|
|
136
128
|
stale: boolean;
|
|
129
|
+
/** NavigationSnapshot.heldBoundary: the walk stops above it. */
|
|
130
|
+
heldBoundary?: string;
|
|
137
131
|
prevUrl: URL;
|
|
138
132
|
prevParams: Record<string, string>;
|
|
139
133
|
prevMatch: RouteMatchResult | null;
|
|
@@ -143,7 +137,6 @@ export interface MatchContext<TEnv = any> {
|
|
|
143
137
|
routeKey: string;
|
|
144
138
|
localRouteName: string;
|
|
145
139
|
handlerContext: HandlerContext<any, TEnv>;
|
|
146
|
-
loaderPromises: Map<string, Promise<any>>;
|
|
147
140
|
routeMap: Record<string, string>;
|
|
148
141
|
metricsStore: MetricsStore | undefined;
|
|
149
142
|
Store: any;
|
|
@@ -174,6 +167,8 @@ export interface MatchContext<TEnv = any> {
|
|
|
174
167
|
* stored, so a record can be older than the copy the client holds after it.
|
|
175
168
|
*/
|
|
176
169
|
export declare function rendersLive(ctx: Pick<MatchContext, "isAction" | "stale">): boolean;
|
|
170
|
+
/** This match as the input of a revalidating resolution pass (resolution-pass.ts). */
|
|
171
|
+
export declare function resolutionPassInput<TEnv>(ctx: MatchContext<TEnv>): ResolutionPassInput<TEnv>;
|
|
177
172
|
/**
|
|
178
173
|
* Mutable state that flows through the pipeline
|
|
179
174
|
*/
|