vinext 1.0.0-beta.6 → 1.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -3
- package/dist/build/action-owner-manifest.d.ts +42 -0
- package/dist/build/action-owner-manifest.js +110 -0
- package/dist/build/clean-output.js +1 -4
- package/dist/build/client-build-config.js +10 -11
- package/dist/build/prerender.d.ts +1 -1
- package/dist/build/prerender.js +12 -6
- package/dist/build/report.d.ts +1 -1
- package/dist/build/route-classification-manifest.d.ts +1 -1
- package/dist/build/static-export.d.ts +1 -1
- package/dist/client/app-nav-failure-handler.js +1 -0
- package/dist/client/navigation-runtime.d.ts +5 -3
- package/dist/client/navigation-runtime.js +4 -8
- package/dist/entries/app-browser-entry.d.ts +1 -1
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +111 -8
- package/dist/entries/pages-client-entry.d.ts +1 -1
- package/dist/entries/pages-server-entry.d.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +119 -26
- package/dist/plugins/action-owner-manifest.d.ts +14 -0
- package/dist/plugins/action-owner-manifest.js +84 -0
- package/dist/plugins/ast-utils.d.ts +30 -1
- package/dist/plugins/ast-utils.js +76 -1
- package/dist/plugins/css-module-imports.d.ts +2 -2
- package/dist/plugins/css-module-imports.js +5 -13
- package/dist/plugins/dynamic-preload-metadata.js +13 -34
- package/dist/plugins/environment.d.ts +11 -0
- package/dist/plugins/environment.js +7 -0
- package/dist/plugins/extensionless-dynamic-import.js +11 -35
- package/dist/plugins/fonts.js +8 -12
- package/dist/plugins/ignore-dynamic-requests.d.ts +2 -4
- package/dist/plugins/ignore-dynamic-requests.js +29 -59
- package/dist/plugins/import-meta-url.d.ts +15 -9
- package/dist/plugins/import-meta-url.js +310 -85
- package/dist/plugins/instrumentation-client.js +4 -5
- package/dist/plugins/middleware-export-validation.js +5 -17
- package/dist/plugins/middleware-server-only.js +2 -2
- package/dist/plugins/og-asset-ownership.js +18 -26
- package/dist/plugins/og-assets.js +2 -4
- package/dist/plugins/optimize-imports.js +2 -4
- package/dist/plugins/pages-node-externals.js +13 -40
- package/dist/plugins/remove-console.js +2 -4
- package/dist/plugins/require-condition-resolution.d.ts +16 -0
- package/dist/plugins/require-condition-resolution.js +167 -0
- package/dist/plugins/require-context.js +11 -46
- package/dist/plugins/sass.js +1 -1
- package/dist/plugins/server-externals-manifest.js +1 -23
- package/dist/plugins/strip-server-exports.js +13 -19
- package/dist/plugins/styled-jsx.js +17 -19
- package/dist/plugins/transform-result.d.ts +10 -0
- package/dist/plugins/transform-result.js +10 -0
- package/dist/plugins/transitive-externals.js +7 -21
- package/dist/plugins/typeof-window.d.ts +3 -8
- package/dist/plugins/typeof-window.js +5 -15
- package/dist/plugins/use-cache-callable.js +12 -22
- package/dist/plugins/wasm-module-import.js +1 -1
- package/dist/plugins/worker-image-imports.d.ts +12 -0
- package/dist/plugins/worker-image-imports.js +136 -0
- package/dist/routing/app-route-graph.d.ts +3 -2
- package/dist/routing/app-route-graph.js +1 -1
- package/dist/routing/route-pattern.d.ts +8 -1
- package/dist/routing/route-pattern.js +28 -1
- package/dist/routing/route-validation.js +7 -1
- package/dist/server/accept-encoding.d.ts +1 -2
- package/dist/server/accept-encoding.js +1 -4
- package/dist/server/app-action-forwarding.d.ts +18 -0
- package/dist/server/app-action-forwarding.js +140 -0
- package/dist/server/app-browser-entry.js +231 -50
- package/dist/server/app-browser-error.d.ts +1 -2
- package/dist/server/app-browser-error.js +1 -5
- package/dist/server/app-browser-history-controller.d.ts +16 -1
- package/dist/server/app-browser-history-controller.js +135 -18
- package/dist/server/app-browser-navigation-abort.d.ts +16 -0
- package/dist/server/app-browser-navigation-abort.js +29 -0
- package/dist/server/app-browser-navigation-controller.d.ts +4 -0
- package/dist/server/app-browser-navigation-controller.js +22 -6
- package/dist/server/app-browser-navigation-response.d.ts +11 -0
- package/dist/server/app-browser-navigation-response.js +8 -0
- package/dist/server/app-browser-popstate.d.ts +6 -1
- package/dist/server/app-browser-popstate.js +6 -2
- package/dist/server/app-browser-server-action-client.js +1 -1
- package/dist/server/app-browser-state.d.ts +2 -2
- package/dist/server/app-browser-state.js +3 -3
- package/dist/server/app-browser-stream.d.ts +0 -2
- package/dist/server/app-browser-supplemental-refresh.d.ts +49 -0
- package/dist/server/app-browser-supplemental-refresh.js +190 -0
- package/dist/server/app-browser-visible-commit.js +23 -12
- package/dist/server/app-elements-wire.d.ts +2 -0
- package/dist/server/app-elements-wire.js +7 -0
- package/dist/server/app-history-state.d.ts +22 -1
- package/dist/server/app-history-state.js +93 -9
- package/dist/server/app-optimistic-routing.d.ts +22 -1
- package/dist/server/app-optimistic-routing.js +137 -12
- package/dist/server/app-page-cache-finalizer.d.ts +3 -1
- package/dist/server/app-page-cache-finalizer.js +6 -6
- package/dist/server/app-page-cache.d.ts +2 -1
- package/dist/server/app-page-cache.js +2 -2
- package/dist/server/app-page-dispatch.d.ts +4 -1
- package/dist/server/app-page-dispatch.js +10 -1
- package/dist/server/app-page-element-builder.d.ts +1 -0
- package/dist/server/app-page-element-builder.js +1 -0
- package/dist/server/app-page-ppr-runtime.js +3 -2
- package/dist/server/app-page-render.d.ts +2 -1
- package/dist/server/app-page-render.js +6 -3
- package/dist/server/app-page-request.d.ts +2 -33
- package/dist/server/app-page-request.js +1 -27
- package/dist/server/app-page-route-wiring.d.ts +1 -0
- package/dist/server/app-page-route-wiring.js +4 -0
- package/dist/server/app-page-segment-state.d.ts +2 -2
- package/dist/server/app-page-segment-state.js +14 -8
- package/dist/server/app-ppr-fallback-shell.d.ts +2 -2
- package/dist/server/app-ppr-fallback-shell.js +3 -6
- package/dist/server/app-route-handler-dispatch.js +4 -1
- package/dist/server/app-route-handler-execution.js +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +2 -1
- package/dist/server/app-rsc-cache-busting.js +34 -8
- package/dist/server/app-rsc-handler.d.ts +4 -2
- package/dist/server/app-rsc-handler.js +57 -9
- package/dist/server/app-rsc-request-normalization.d.ts +2 -0
- package/dist/server/app-rsc-request-normalization.js +5 -1
- package/dist/server/app-rsc-route-matching.d.ts +4 -3
- package/dist/server/app-rsc-route-matching.js +14 -42
- package/dist/server/app-server-action-execution.d.ts +3 -0
- package/dist/server/app-server-action-execution.js +77 -2
- package/dist/server/app-ssr-entry.js +6 -6
- package/dist/server/app-ssr-stream.d.ts +1 -1
- package/dist/server/app-ssr-stream.js +2 -2
- package/dist/server/app-visited-response-cache.d.ts +6 -1
- package/dist/server/app-visited-response-cache.js +18 -2
- package/dist/server/dev-route-files.js +2 -5
- package/dist/server/dev-server.d.ts +5 -13
- package/dist/server/dev-server.js +22 -22
- package/dist/server/dev-stack-sourcemap.d.ts +1 -2
- package/dist/server/dev-stack-sourcemap.js +1 -4
- package/dist/server/headers.d.ts +5 -1
- package/dist/server/headers.js +5 -1
- package/dist/server/isr-cache.d.ts +6 -14
- package/dist/server/isr-cache.js +6 -27
- package/dist/server/middleware.d.ts +3 -16
- package/dist/server/middleware.js +2 -19
- package/dist/server/navigation-planner.d.ts +1 -0
- package/dist/server/navigation-planner.js +57 -9
- package/dist/server/navigation-trace.d.ts +1 -0
- package/dist/server/navigation-trace.js +1 -0
- package/dist/server/pages-data-route.d.ts +1 -10
- package/dist/server/pages-data-route.js +1 -12
- package/dist/server/pages-node-compat.d.ts +1 -4
- package/dist/server/pages-node-compat.js +1 -7
- package/dist/server/pages-readiness.js +4 -4
- package/dist/server/prerender-route-params.d.ts +1 -2
- package/dist/server/prerender-route-params.js +1 -4
- package/dist/server/prod-server.js +3 -1
- package/dist/shims/cache-runtime.js +39 -22
- package/dist/shims/cache.d.ts +1 -1
- package/dist/shims/dynamic.d.ts +3 -3
- package/dist/shims/dynamic.js +4 -6
- package/dist/shims/error.js +1 -1
- package/dist/shims/fetch-cache.d.ts +3 -1
- package/dist/shims/fetch-cache.js +23 -4
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +6 -7
- package/dist/shims/internal/app-route-prefetch-policy.js +5 -4
- package/dist/shims/link.js +1 -1
- package/dist/shims/navigation.d.ts +12 -3
- package/dist/shims/navigation.js +46 -11
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/router.js +75 -4
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +1 -0
- package/dist/utils/built-asset-url.d.ts +1 -1
- package/dist/utils/built-asset-url.js +4 -2
- package/dist/utils/package-name.d.ts +11 -0
- package/dist/utils/package-name.js +18 -0
- package/dist/utils/path.d.ts +8 -1
- package/dist/utils/path.js +21 -1
- package/dist/utils/react-compiler-support.d.ts +20 -0
- package/dist/utils/react-compiler-support.js +29 -0
- package/package.json +3 -2
|
@@ -3,8 +3,10 @@ import { stripBasePath } from "../utils/base-path.js";
|
|
|
3
3
|
import { isUnknownRecord } from "../utils/record.js";
|
|
4
4
|
import { AppElementsWire } from "./app-elements-wire.js";
|
|
5
5
|
import "./app-elements.js";
|
|
6
|
-
import { matchRoutePattern } from "../routing/route-pattern.js";
|
|
6
|
+
import { extractRawRoutePatternParams, matchRoutePattern } from "../routing/route-pattern.js";
|
|
7
|
+
import { createNestedBfcacheSlotSegmentId, deriveBfcacheSegmentIdentity, isNestedBfcacheSlotSegmentId } from "./bfcache-identity.js";
|
|
7
8
|
import { stripRscCacheBustingSearchParam, stripRscSuffix } from "./app-rsc-cache-busting.js";
|
|
9
|
+
import { canonicalizeAppPageParams, resolveAppPagePatternStateKey, resolveAppPageSemanticSegmentStateKey } from "./app-page-segment-state.js";
|
|
8
10
|
import { Suspense, createElement, isValidElement } from "react";
|
|
9
11
|
//#region src/server/app-optimistic-routing.ts
|
|
10
12
|
const routeTrieCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -126,12 +128,16 @@ function hrefToRouteParts(href, basePath) {
|
|
|
126
128
|
}
|
|
127
129
|
stripRscCacheBustingSearchParam(url);
|
|
128
130
|
const appPathname = stripBasePath(stripRscSuffix(url.pathname), basePath);
|
|
129
|
-
|
|
131
|
+
const pathname = appPathname === "" ? "/" : appPathname;
|
|
132
|
+
return {
|
|
133
|
+
normalized: splitPathnameForRouteMatch(pathname),
|
|
134
|
+
raw: pathname.split("/").filter(Boolean)
|
|
135
|
+
};
|
|
130
136
|
}
|
|
131
137
|
function matchOptimisticRouteManifestRoute(options) {
|
|
132
138
|
const urlParts = hrefToRouteParts(options.href, options.basePath);
|
|
133
139
|
if (urlParts === null) return null;
|
|
134
|
-
const match = matchNode(getRouteTrie(options.routeManifest), urlParts, 0, []);
|
|
140
|
+
const match = matchNode(getRouteTrie(options.routeManifest), urlParts.normalized, 0, []);
|
|
135
141
|
if (match === null) return null;
|
|
136
142
|
decodeMatchedParams(match.params);
|
|
137
143
|
return match;
|
|
@@ -140,15 +146,85 @@ function mergeParams(target, source) {
|
|
|
140
146
|
for (const [key, value] of Object.entries(source)) target[key] = value;
|
|
141
147
|
}
|
|
142
148
|
function resolveOptimisticNavigationParams(options) {
|
|
143
|
-
const
|
|
149
|
+
const routeParams = extractRawRoutePatternParams(options.match.route.patternParts, options.rawUrlParts);
|
|
150
|
+
canonicalizeAppPageParams(routeParams);
|
|
151
|
+
const navigationParams = { ...routeParams };
|
|
152
|
+
const routeParamNames = new Set(options.match.route.paramNames);
|
|
144
153
|
for (const binding of options.routeManifest.segmentGraph.slotBindings.values()) {
|
|
145
154
|
if (binding.routeId !== options.match.route.id || binding.state !== "active") continue;
|
|
146
155
|
const patternParts = binding.slotPatternParts;
|
|
147
156
|
if (!patternParts) continue;
|
|
157
|
+
if (binding.slotParamNames?.every((name) => routeParamNames.has(name))) continue;
|
|
148
158
|
const matched = matchRoutePattern(options.urlParts, patternParts);
|
|
149
159
|
if (matched) mergeParams(navigationParams, matched);
|
|
150
160
|
}
|
|
151
|
-
return
|
|
161
|
+
return {
|
|
162
|
+
navigationParams,
|
|
163
|
+
routeParams
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function collectRenderedBfcacheSegmentIds(value, candidates, rendered, depth = 0) {
|
|
167
|
+
if (depth > 100) return;
|
|
168
|
+
if (Array.isArray(value)) {
|
|
169
|
+
for (const entry of value) collectRenderedBfcacheSegmentIds(entry, candidates, rendered, depth + 1);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (!isValidElement(value)) return;
|
|
173
|
+
const props = Reflect.get(value, "props");
|
|
174
|
+
if (!isUnknownRecord(props)) return;
|
|
175
|
+
const id = Reflect.get(props, "id");
|
|
176
|
+
if (typeof id === "string" && candidates.has(id)) rendered.add(id);
|
|
177
|
+
for (const prop of Object.values(props)) collectRenderedBfcacheSegmentIds(prop, candidates, rendered, depth + 1);
|
|
178
|
+
}
|
|
179
|
+
function getOmittedBfcacheSegmentIds(elements) {
|
|
180
|
+
const identities = AppElementsWire.readMetadata(elements).bfcacheSegmentIdentities;
|
|
181
|
+
const candidates = new Set(Object.keys(identities).filter((id) => isNestedBfcacheSlotSegmentId(id) && Object.hasOwn(elements, id)));
|
|
182
|
+
if (candidates.size === 0) return [];
|
|
183
|
+
const rendered = /* @__PURE__ */ new Set();
|
|
184
|
+
for (const value of Object.values(elements)) collectRenderedBfcacheSegmentIds(value, candidates, rendered);
|
|
185
|
+
return [...candidates].filter((id) => !rendered.has(id));
|
|
186
|
+
}
|
|
187
|
+
function resolveTargetBfcacheSegmentIdentity(options) {
|
|
188
|
+
const route = options.routeManifest.segmentGraph.routes.get(options.routeId);
|
|
189
|
+
if (!route) return void 0;
|
|
190
|
+
const routeParamNames = new Set(route.paramNames);
|
|
191
|
+
for (const binding of options.routeManifest.segmentGraph.slotBindings.values()) {
|
|
192
|
+
if (binding.routeId !== options.routeId) continue;
|
|
193
|
+
const segmentParams = binding.state === "active" && binding.slotPatternParts !== void 0 && binding.slotPatternParts.length > 0 && !binding.slotParamNames?.every((name) => routeParamNames.has(name)) ? matchRoutePattern(options.targetUrlParts, binding.slotPatternParts) ?? options.targetRouteParams : options.targetRouteParams;
|
|
194
|
+
const ownerLayout = binding.ownerLayoutId ? options.routeManifest.segmentGraph.layouts.get(binding.ownerLayoutId) : void 0;
|
|
195
|
+
const ownerStateKey = ownerLayout ? resolveAppPagePatternStateKey(ownerLayout.patternParts, options.targetRouteParams) : "";
|
|
196
|
+
const boundSegmentKeys = [];
|
|
197
|
+
let level = 0;
|
|
198
|
+
for (const segment of binding.routeSegments ?? []) {
|
|
199
|
+
if (segment.startsWith("@")) continue;
|
|
200
|
+
level += 1;
|
|
201
|
+
boundSegmentKeys.push(resolveAppPageSemanticSegmentStateKey({
|
|
202
|
+
marker: null,
|
|
203
|
+
paramSource: "slot",
|
|
204
|
+
segment
|
|
205
|
+
}, segmentParams));
|
|
206
|
+
if (createNestedBfcacheSlotSegmentId(binding.slotId, level) !== options.segmentId) continue;
|
|
207
|
+
const identityKey = JSON.stringify(boundSegmentKeys);
|
|
208
|
+
return deriveBfcacheSegmentIdentity({
|
|
209
|
+
activeRouteGraphId: null,
|
|
210
|
+
boundSegmentKey: ownerStateKey ? JSON.stringify([ownerStateKey, identityKey]) : identityKey,
|
|
211
|
+
interceptionTargetRouteGraphId: null,
|
|
212
|
+
kind: "slot",
|
|
213
|
+
ownerLayoutGraphId: binding.ownerLayoutId,
|
|
214
|
+
slotGraphId: binding.slotId,
|
|
215
|
+
state: binding.state
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
if (level === 0 && createNestedBfcacheSlotSegmentId(binding.slotId, 1) === options.segmentId) return deriveBfcacheSegmentIdentity({
|
|
219
|
+
activeRouteGraphId: null,
|
|
220
|
+
boundSegmentKey: ownerStateKey ? JSON.stringify([ownerStateKey, ""]) : "",
|
|
221
|
+
interceptionTargetRouteGraphId: null,
|
|
222
|
+
kind: "slot",
|
|
223
|
+
ownerLayoutGraphId: binding.ownerLayoutId,
|
|
224
|
+
slotGraphId: binding.slotId,
|
|
225
|
+
state: binding.state
|
|
226
|
+
});
|
|
227
|
+
}
|
|
152
228
|
}
|
|
153
229
|
function elementHasSuspenseFallback(value, depth = 0) {
|
|
154
230
|
if (depth > 100) return false;
|
|
@@ -194,6 +270,8 @@ function createOptimisticRouteTemplate(options) {
|
|
|
194
270
|
return {
|
|
195
271
|
elements: options.elements,
|
|
196
272
|
mountedSlotsHeader: options.mountedSlotsHeader,
|
|
273
|
+
omittedBfcacheSegmentIds: options.elements["__prefetchLoadingShell"] === "LoadingBoundary" ? getOmittedBfcacheSegmentIds(options.elements) : [],
|
|
274
|
+
omittedLayoutIds: options.elements["__prefetchLoadingShell"] === "LoadingBoundary" ? metadata.layoutIds.filter((layoutId) => !Object.hasOwn(options.elements, layoutId)) : [],
|
|
197
275
|
pageElementIds,
|
|
198
276
|
routeId: match.route.id
|
|
199
277
|
};
|
|
@@ -203,6 +281,49 @@ function createOptimisticRouteElements(template) {
|
|
|
203
281
|
for (const pageElementId of template.pageElementIds) elements[pageElementId] = createElement(OptimisticRouteSegment);
|
|
204
282
|
return elements;
|
|
205
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* A loading-shell prefetch stops at the first loading boundary, so layouts
|
|
286
|
+
* below that boundary are present in the route metadata but absent from the
|
|
287
|
+
* rendered shell. Do not commit that ancestor fallback when one of those
|
|
288
|
+
* omitted layouts is already mounted with the same semantic identity. Next.js
|
|
289
|
+
* keeps the shared segment active in this case, which also means the ancestor
|
|
290
|
+
* loading boundary does not re-trigger.
|
|
291
|
+
*/
|
|
292
|
+
function canCommitOptimisticRouteTemplate(options) {
|
|
293
|
+
if (options.template.omittedLayoutIds.length === 0 && options.template.omittedBfcacheSegmentIds.length === 0) return true;
|
|
294
|
+
const currentLayoutIds = new Set(options.currentLayoutIds);
|
|
295
|
+
const currentIdentities = AppElementsWire.readMetadata(options.currentElements).bfcacheSegmentIdentities;
|
|
296
|
+
for (const layoutId of options.template.omittedLayoutIds) {
|
|
297
|
+
if (!currentLayoutIds.has(layoutId)) continue;
|
|
298
|
+
if (!Object.hasOwn(options.currentElements, layoutId)) continue;
|
|
299
|
+
const layout = options.routeManifest.segmentGraph.layouts.get(layoutId);
|
|
300
|
+
if (layout === void 0) continue;
|
|
301
|
+
const currentIdentity = currentIdentities[layoutId];
|
|
302
|
+
if (currentIdentity !== void 0) {
|
|
303
|
+
if (currentIdentity === deriveBfcacheSegmentIdentity({
|
|
304
|
+
boundSegmentKey: resolveAppPagePatternStateKey(layout.patternParts, options.targetRouteParams),
|
|
305
|
+
graphId: layout.id,
|
|
306
|
+
kind: "layout",
|
|
307
|
+
rootBoundaryId: layout.rootBoundaryId
|
|
308
|
+
})) return false;
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
if (resolveAppPagePatternStateKey(layout.patternParts, options.currentParams) === resolveAppPagePatternStateKey(layout.patternParts, options.targetRouteParams)) return false;
|
|
312
|
+
}
|
|
313
|
+
for (const segmentId of options.template.omittedBfcacheSegmentIds) {
|
|
314
|
+
if (!Object.hasOwn(options.currentElements, segmentId)) continue;
|
|
315
|
+
const currentIdentity = currentIdentities[segmentId];
|
|
316
|
+
const targetIdentity = resolveTargetBfcacheSegmentIdentity({
|
|
317
|
+
routeId: options.template.routeId,
|
|
318
|
+
routeManifest: options.routeManifest,
|
|
319
|
+
segmentId,
|
|
320
|
+
targetRouteParams: options.targetRouteParams,
|
|
321
|
+
targetUrlParts: options.targetUrlParts
|
|
322
|
+
});
|
|
323
|
+
if (currentIdentity !== void 0 && targetIdentity !== void 0 && currentIdentity === targetIdentity) return false;
|
|
324
|
+
}
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
206
327
|
function resolveOptimisticNavigationPayload(options) {
|
|
207
328
|
if (options.interceptionContext !== null) return null;
|
|
208
329
|
const urlParts = hrefToRouteParts(options.href, options.basePath);
|
|
@@ -220,15 +341,19 @@ function resolveOptimisticNavigationPayload(options) {
|
|
|
220
341
|
}));
|
|
221
342
|
if (template === void 0) return null;
|
|
222
343
|
if (template.mountedSlotsHeader !== options.mountedSlotsHeader) return null;
|
|
344
|
+
const { navigationParams, routeParams } = resolveOptimisticNavigationParams({
|
|
345
|
+
match,
|
|
346
|
+
rawUrlParts: urlParts.raw,
|
|
347
|
+
routeManifest: options.routeManifest,
|
|
348
|
+
urlParts: urlParts.normalized
|
|
349
|
+
});
|
|
223
350
|
return {
|
|
224
351
|
elements: createOptimisticRouteElements(template),
|
|
225
|
-
params:
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}),
|
|
230
|
-
template
|
|
352
|
+
params: navigationParams,
|
|
353
|
+
routeParams,
|
|
354
|
+
template,
|
|
355
|
+
urlParts: urlParts.normalized
|
|
231
356
|
};
|
|
232
357
|
}
|
|
233
358
|
//#endregion
|
|
234
|
-
export { createOptimisticRouteElements, createOptimisticRouteTemplate, getOptimisticPrefetchSourceKey, getOptimisticRouteTemplateKey, matchOptimisticRouteManifestRoute, resolveOptimisticNavigationPayload };
|
|
359
|
+
export { canCommitOptimisticRouteTemplate, createOptimisticRouteElements, createOptimisticRouteTemplate, getOptimisticPrefetchSourceKey, getOptimisticRouteTemplateKey, matchOptimisticRouteManifestRoute, resolveOptimisticNavigationPayload };
|
|
@@ -4,7 +4,7 @@ import { AppPageRenderObservationState } from "./app-page-render-observation.js"
|
|
|
4
4
|
import { AppPageCacheSetter } from "./isr-cache.js";
|
|
5
5
|
//#region src/server/app-page-cache-finalizer.d.ts
|
|
6
6
|
type AppPageDebugLogger = (event: string, detail: string) => void;
|
|
7
|
-
type AppPageRscCacheKeyBuilder = (pathname: string, mountedSlotsHeader?: string | null, renderMode?: AppRscRenderMode, interceptionContext?: string | null) => string;
|
|
7
|
+
type AppPageRscCacheKeyBuilder = (pathname: string, mountedSlotsHeader?: string | null, renderMode?: AppRscRenderMode, interceptionContext?: string | null, interceptionId?: string | null) => string;
|
|
8
8
|
type AppPageRequestCacheLife = {
|
|
9
9
|
revalidate?: number;
|
|
10
10
|
expire?: number;
|
|
@@ -29,6 +29,7 @@ type FinalizeAppPageHtmlCacheResponseOptions = {
|
|
|
29
29
|
isrRscKey: AppPageRscCacheKeyBuilder;
|
|
30
30
|
isrSet: AppPageCacheSetter;
|
|
31
31
|
interceptionContext?: string | null;
|
|
32
|
+
interceptionId?: string | null;
|
|
32
33
|
omitPendingDynamicCacheState?: boolean;
|
|
33
34
|
preserveClientResponseHeaders?: boolean;
|
|
34
35
|
expireSeconds?: number;
|
|
@@ -49,6 +50,7 @@ type ScheduleAppPageRscCacheWriteOptions = {
|
|
|
49
50
|
isrRscKey: AppPageRscCacheKeyBuilder;
|
|
50
51
|
isrSet: AppPageCacheSetter;
|
|
51
52
|
interceptionContext?: string | null;
|
|
53
|
+
interceptionId?: string | null;
|
|
52
54
|
mountedSlotsHeader?: string | null;
|
|
53
55
|
omitPendingDynamicCacheState?: boolean;
|
|
54
56
|
renderMode?: AppRscRenderMode;
|
|
@@ -15,7 +15,7 @@ function applyPendingDynamicCdnHeaders(headers, tags, options = {}) {
|
|
|
15
15
|
});
|
|
16
16
|
finalizePendingCacheStateHeaders(headers, options);
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function applyUncacheableRscVariantNoStoreHeaders(headers, options = {}) {
|
|
19
19
|
applyCdnResponseHeaders(headers, { cacheControl: NO_STORE_CACHE_CONTROL });
|
|
20
20
|
finalizePendingCacheStateHeaders(headers, {
|
|
21
21
|
...options,
|
|
@@ -47,7 +47,7 @@ function finalizeAppPageHtmlCacheResponse(response, options) {
|
|
|
47
47
|
if (!response.body) return response;
|
|
48
48
|
const [streamForClient, streamForCache] = response.body.tee();
|
|
49
49
|
const htmlKey = options.isrHtmlKey(options.cleanPathname);
|
|
50
|
-
const rscKey = options.isrRscKey(options.cleanPathname, null, void 0, options.interceptionContext);
|
|
50
|
+
const rscKey = options.isrRscKey(options.cleanPathname, null, void 0, options.interceptionContext, options.interceptionId);
|
|
51
51
|
const clientHeaders = new Headers(response.headers);
|
|
52
52
|
if (options.preserveClientResponseHeaders !== true) applyPendingDynamicCdnHeaders(clientHeaders, options.getPageTags(), { omitCacheState: options.omitPendingDynamicCacheState === true });
|
|
53
53
|
const cachePromise = (async () => {
|
|
@@ -102,10 +102,10 @@ function finalizeAppPageHtmlCacheResponse(response, options) {
|
|
|
102
102
|
}
|
|
103
103
|
function finalizeAppPageRscCacheResponse(response, options) {
|
|
104
104
|
scheduleAppPageRscCacheWrite(options);
|
|
105
|
-
const
|
|
106
|
-
if (options.preserveClientResponseHeaders === true && !
|
|
105
|
+
const isUncacheableVariant = Boolean(options.mountedSlotsHeader);
|
|
106
|
+
if (options.preserveClientResponseHeaders === true && !isUncacheableVariant) return response;
|
|
107
107
|
const clientHeaders = new Headers(response.headers);
|
|
108
|
-
if (
|
|
108
|
+
if (isUncacheableVariant) applyUncacheableRscVariantNoStoreHeaders(clientHeaders, { omitCacheState: options.omitPendingDynamicCacheState === true });
|
|
109
109
|
else applyPendingDynamicCdnHeaders(clientHeaders, options.getPageTags(), { omitCacheState: options.omitPendingDynamicCacheState === true });
|
|
110
110
|
return new Response(response.body, {
|
|
111
111
|
status: response.status,
|
|
@@ -116,7 +116,7 @@ function finalizeAppPageRscCacheResponse(response, options) {
|
|
|
116
116
|
function scheduleAppPageRscCacheWrite(options) {
|
|
117
117
|
const capturedRscDataPromise = options.capturedRscDataPromise;
|
|
118
118
|
if (!capturedRscDataPromise || options.dynamicUsedDuringBuild || options.mountedSlotsHeader) return false;
|
|
119
|
-
const rscKey = options.isrRscKey(options.cleanPathname, null, options.renderMode, options.interceptionContext);
|
|
119
|
+
const rscKey = options.isrRscKey(options.cleanPathname, null, options.renderMode, options.interceptionContext, options.interceptionId);
|
|
120
120
|
const cachePromise = (async () => {
|
|
121
121
|
try {
|
|
122
122
|
const rscData = await capturedRscDataPromise;
|
|
@@ -7,7 +7,7 @@ import { finalizeAppPageHtmlCacheResponse, finalizeAppPageRscCacheResponse, sche
|
|
|
7
7
|
type AppPageDebugLogger = (event: string, detail: string) => void;
|
|
8
8
|
type AppPageCacheGetter = (key: string) => Promise<ISRCacheEntry | null>;
|
|
9
9
|
type AppPageBackgroundRegenerator = (key: string, renderFn: () => Promise<void>) => void;
|
|
10
|
-
type AppPageRscCacheKeyBuilder = (pathname: string, mountedSlotsHeader?: string | null, renderMode?: AppRscRenderMode, interceptionContext?: string | null) => string;
|
|
10
|
+
type AppPageRscCacheKeyBuilder = (pathname: string, mountedSlotsHeader?: string | null, renderMode?: AppRscRenderMode, interceptionContext?: string | null, interceptionId?: string | null) => string;
|
|
11
11
|
type AppPageCacheOutcomeMetric = Readonly<{
|
|
12
12
|
artifact: "html" | "rsc";
|
|
13
13
|
/**
|
|
@@ -50,6 +50,7 @@ type ReadAppPageCacheResponseOptions = {
|
|
|
50
50
|
isrRscKey: AppPageRscCacheKeyBuilder;
|
|
51
51
|
isrSet: AppPageCacheSetter;
|
|
52
52
|
interceptionContext?: string | null;
|
|
53
|
+
interceptionId?: string | null;
|
|
53
54
|
hasRequestSearchParams?: boolean;
|
|
54
55
|
middlewareHeaders?: Headers | null;
|
|
55
56
|
middlewareStatus?: number | null;
|
|
@@ -148,7 +148,7 @@ async function readAppPageCacheResponse(options) {
|
|
|
148
148
|
options.isrDebug?.("MISS (mounted slots RSC variant)", options.cleanPathname);
|
|
149
149
|
return null;
|
|
150
150
|
}
|
|
151
|
-
const isrKey = options.isRscRequest ? options.isrRscKey(options.cleanPathname, null, options.renderMode, options.interceptionContext) : options.isrHtmlKey(options.cleanPathname);
|
|
151
|
+
const isrKey = options.isRscRequest ? options.isrRscKey(options.cleanPathname, null, options.renderMode, options.interceptionContext, options.interceptionId) : options.isrHtmlKey(options.cleanPathname);
|
|
152
152
|
const artifact = options.isRscRequest ? "rsc" : "html";
|
|
153
153
|
try {
|
|
154
154
|
const cached = await options.isrGet(isrKey);
|
|
@@ -222,7 +222,7 @@ async function readAppPageCacheResponse(options) {
|
|
|
222
222
|
renderCacheControl: revalidatedPage.cacheControl,
|
|
223
223
|
routeRevalidateSeconds: options.revalidateSeconds
|
|
224
224
|
});
|
|
225
|
-
const writes = [options.isrSet(options.isRscRequest ? isrKey : options.isrRscKey(options.cleanPathname, null, options.renderMode, options.interceptionContext), buildAppPageCacheValue("", revalidatedPage.rscData, 200, revalidatedPage.rscRenderObservation), {
|
|
225
|
+
const writes = [options.isrSet(options.isRscRequest ? isrKey : options.isrRscKey(options.cleanPathname, null, options.renderMode, options.interceptionContext, options.interceptionId), buildAppPageCacheValue("", revalidatedPage.rscData, 200, revalidatedPage.rscRenderObservation), {
|
|
226
226
|
cacheControl,
|
|
227
227
|
tags: revalidatedPage.tags
|
|
228
228
|
})];
|
|
@@ -32,6 +32,7 @@ type AppPageBackgroundRegenerationErrorContext = {
|
|
|
32
32
|
};
|
|
33
33
|
type AppPageBackgroundRegenerator = (key: string, renderFn: () => Promise<void>, errorContext?: AppPageBackgroundRegenerationErrorContext) => void;
|
|
34
34
|
type AppPageDispatchIntercept<TPage = unknown> = {
|
|
35
|
+
interceptionId?: string | null;
|
|
35
36
|
interceptionGraphId?: string | null;
|
|
36
37
|
interceptLayouts?: readonly unknown[] | null;
|
|
37
38
|
interceptLayoutSegments?: readonly (readonly string[])[] | null;
|
|
@@ -52,6 +53,7 @@ type AppPageDispatchIntercept<TPage = unknown> = {
|
|
|
52
53
|
targetRouteGraphId?: string | null;
|
|
53
54
|
};
|
|
54
55
|
type AppPageDispatchInterceptOptions<TPage = unknown> = {
|
|
56
|
+
interceptionId?: string | null;
|
|
55
57
|
interceptGraphId?: string | null;
|
|
56
58
|
interceptionContext: string | null;
|
|
57
59
|
interceptLayouts?: readonly unknown[] | null;
|
|
@@ -177,7 +179,7 @@ type DispatchAppPageOptions<TRoute extends AppPageDispatchRoute> = {
|
|
|
177
179
|
isrDebug?: AppPageDebugLogger;
|
|
178
180
|
isrGet: AppPageCacheGetter;
|
|
179
181
|
isrHtmlKey: (pathname: string) => string;
|
|
180
|
-
isrRscKey: (pathname: string, mountedSlotsHeader?: string | null, renderMode?: AppRscRenderMode, interceptionContext?: string | null) => string;
|
|
182
|
+
isrRscKey: (pathname: string, mountedSlotsHeader?: string | null, renderMode?: AppRscRenderMode, interceptionContext?: string | null, interceptionId?: string | null) => string;
|
|
181
183
|
isrSet: AppPageCacheSetter;
|
|
182
184
|
loadSsrHandler: () => Promise<AppPageSsrHandler>;
|
|
183
185
|
middlewareContext: AppPageMiddlewareContext;
|
|
@@ -225,6 +227,7 @@ type DispatchAppPageOptions<TRoute extends AppPageDispatchRoute> = {
|
|
|
225
227
|
revalidateSeconds: number | null;
|
|
226
228
|
renderedPathAndSearch?: string | null;
|
|
227
229
|
resolveRouteFetchCacheMode?: (route: TRoute) => FetchCacheMode | null;
|
|
230
|
+
resolveRouteRevalidateSeconds?: (route: TRoute) => number | null;
|
|
228
231
|
resolveRouteDynamicConfig?: (route: TRoute) => string | null | undefined;
|
|
229
232
|
rootForbiddenModule?: AppPageModule | null;
|
|
230
233
|
rootNotFoundModule?: AppPageModule | null;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { closeAfterResponse, createRequestContext, runWithRequestContext } from "../shims/unified-request-context.js";
|
|
2
2
|
import { getRequestExecutionContext } from "../shims/request-context.js";
|
|
3
3
|
import "../utils/protocol-headers.js";
|
|
4
|
+
import { VINEXT_INTERCEPTION_ID_HEADER } from "./headers.js";
|
|
4
5
|
import { AppElementsWire } from "./app-elements-wire.js";
|
|
5
6
|
import { APP_RSC_RENDER_MODE_PREFETCH_DYNAMIC_SHELL } from "./app-rsc-render-mode.js";
|
|
6
7
|
import "./app-elements.js";
|
|
7
8
|
import { consumeDynamicUsage, consumeInvalidDynamicUsageError, getAndClearPendingCookies, getDraftModeCookieHeader, getHeadersContext, isDraftModeRequest, peekDynamicUsage, peekRenderRequestApiUsage, runWithIsolatedDynamicUsage, setHeadersContext } from "../shims/headers.js";
|
|
8
9
|
import { _captureRequestScopedCacheLifeAccessors } from "../shims/cache-request-state.js";
|
|
9
|
-
import { ensureFetchPatch, getCollectedFetchTags, peekDynamicFetchObservations, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchSoftTags, setCurrentForceDynamicFetchDefault, setRefreshStaleFetchesInForeground } from "../shims/fetch-cache.js";
|
|
10
|
+
import { ensureFetchPatch, getCollectedFetchTags, peekDynamicFetchObservations, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchRevalidate, setCurrentFetchSoftTags, setCurrentForceDynamicFetchDefault, setRefreshStaleFetchesInForeground } from "../shims/fetch-cache.js";
|
|
10
11
|
import { VINEXT_RSC_CONTENT_TYPE, VINEXT_RSC_VARY_HEADER, applyRscCompatibilityIdHeader, applyRscDeploymentIdHeader } from "./app-rsc-cache-busting.js";
|
|
11
12
|
import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
|
|
12
13
|
import "./app-page-response.js";
|
|
@@ -135,6 +136,7 @@ async function runAppPageRevalidationContext(options, renderFn) {
|
|
|
135
136
|
routePattern: options.routePattern
|
|
136
137
|
}),
|
|
137
138
|
currentFetchCacheMode: options.currentFetchCacheMode ?? null,
|
|
139
|
+
currentFetchRevalidate: options.currentFetchRevalidate ?? null,
|
|
138
140
|
currentForceDynamicFetchDefault: options.dynamicConfig === "force-dynamic",
|
|
139
141
|
executionContext: getRequestExecutionContext(),
|
|
140
142
|
unstableCacheRevalidation: "foreground"
|
|
@@ -158,6 +160,7 @@ async function runAppPageRevalidationContext(options, renderFn) {
|
|
|
158
160
|
}
|
|
159
161
|
function toInterceptOptions(interceptionContext, intercept) {
|
|
160
162
|
return {
|
|
163
|
+
interceptionId: intercept.interceptionId ?? null,
|
|
161
164
|
interceptGraphId: intercept.interceptionGraphId ?? null,
|
|
162
165
|
interceptionContext,
|
|
163
166
|
interceptLayouts: intercept.interceptLayouts,
|
|
@@ -187,6 +190,7 @@ async function dispatchAppPageInner(options) {
|
|
|
187
190
|
const route = options.route;
|
|
188
191
|
const dynamicConfig = options.dynamicConfig;
|
|
189
192
|
const currentRevalidateSeconds = options.revalidateSeconds;
|
|
193
|
+
const interceptionId = options.isRscRequest ? options.request.headers.get(VINEXT_INTERCEPTION_ID_HEADER) : null;
|
|
190
194
|
const isForceStatic = dynamicConfig === "force-static";
|
|
191
195
|
const isDynamicError = dynamicConfig === "error";
|
|
192
196
|
const isForceDynamic = dynamicConfig === "force-dynamic";
|
|
@@ -204,6 +208,7 @@ async function dispatchAppPageInner(options) {
|
|
|
204
208
|
const hasActiveLoadingBoundary = activeLoadingTreePositions.length > 0;
|
|
205
209
|
setCurrentFetchSoftTags(buildAppPageTags(options.cleanPathname, [], route.routeSegments));
|
|
206
210
|
setCurrentFetchCacheMode(options.fetchCache ?? null);
|
|
211
|
+
setCurrentFetchRevalidate(currentRevalidateSeconds);
|
|
207
212
|
setCurrentForceDynamicFetchDefault(isForceDynamic);
|
|
208
213
|
if (options.hasPageModule && !options.hasPageDefaultExport) {
|
|
209
214
|
options.clearRequestContext();
|
|
@@ -259,6 +264,7 @@ async function dispatchAppPageInner(options) {
|
|
|
259
264
|
isrRscKey: options.isrRscKey,
|
|
260
265
|
isrSet: options.isrSet,
|
|
261
266
|
interceptionContext: options.interceptionContext,
|
|
267
|
+
interceptionId,
|
|
262
268
|
middlewareHeaders: options.middlewareContext.headers,
|
|
263
269
|
middlewareStatus: options.middlewareContext.status,
|
|
264
270
|
mountedSlotsHeader: options.mountedSlotsHeader,
|
|
@@ -293,6 +299,7 @@ async function dispatchAppPageInner(options) {
|
|
|
293
299
|
cleanPathname: options.cleanPathname,
|
|
294
300
|
displayPathname: options.displayPathname,
|
|
295
301
|
currentFetchCacheMode: options.resolveRouteFetchCacheMode?.(revalidationTarget.route) ?? (revalidationTarget.route === route ? options.fetchCache ?? null : null),
|
|
302
|
+
currentFetchRevalidate: options.resolveRouteRevalidateSeconds?.(revalidationTarget.route) ?? (revalidationTarget.route === route ? currentRevalidateSeconds : null),
|
|
296
303
|
draftModeSecret: options.draftModeSecret,
|
|
297
304
|
dynamicConfig: revalidationDynamicConfig,
|
|
298
305
|
params: revalidationTarget.navigationParams,
|
|
@@ -382,6 +389,7 @@ async function dispatchAppPageInner(options) {
|
|
|
382
389
|
}));
|
|
383
390
|
} else setHeadersContext(requestHeadersContext);
|
|
384
391
|
setCurrentFetchCacheMode(options.resolveRouteFetchCacheMode?.(interceptRoute) ?? null);
|
|
392
|
+
setCurrentFetchRevalidate(options.resolveRouteRevalidateSeconds?.(interceptRoute) ?? null);
|
|
385
393
|
setCurrentForceDynamicFetchDefault(sourceDynamicConfig === "force-dynamic");
|
|
386
394
|
return options.buildPageElement(interceptRoute, interceptParams, interceptOpts, interceptSearchParams, interceptLayoutParamAccess, {
|
|
387
395
|
observeMetadataSearchParamsAccess: sourceDynamicConfig !== "force-static",
|
|
@@ -533,6 +541,7 @@ async function dispatchAppPageInner(options) {
|
|
|
533
541
|
isrRscKey: options.isrRscKey,
|
|
534
542
|
isrSet: options.isrSet,
|
|
535
543
|
interceptionContext: options.interceptionContext,
|
|
544
|
+
interceptionId,
|
|
536
545
|
expireSeconds: options.expireSeconds,
|
|
537
546
|
layoutCount: getAppPageLayoutProbeCount(route, activeLoadingTreePositions),
|
|
538
547
|
loadSsrHandler: options.loadSsrHandler,
|
|
@@ -21,6 +21,7 @@ type AppPageBuildRoute<TModule extends AppPageModule = AppPageModule, TErrorModu
|
|
|
21
21
|
};
|
|
22
22
|
type AppPageInterceptOptions<TModule extends AppPageModule = AppPageModule> = {
|
|
23
23
|
interceptGraphId?: string | null;
|
|
24
|
+
interceptionId?: string | null;
|
|
24
25
|
interceptionContext?: string | null;
|
|
25
26
|
interceptLayouts?: readonly (TModule | null | undefined)[] | null;
|
|
26
27
|
interceptLayoutSegments?: readonly (readonly string[])[] | null;
|
|
@@ -270,6 +270,7 @@ async function buildPageElements(options) {
|
|
|
270
270
|
createPageElement,
|
|
271
271
|
globalErrorModule: globalErrorModule ?? DEFAULT_GLOBAL_ERROR_MODULE,
|
|
272
272
|
isRscRequest,
|
|
273
|
+
interceptionId: opts?.interceptionId ?? null,
|
|
273
274
|
layoutParamAccess: options.layoutParamAccess,
|
|
274
275
|
mountedSlotIds,
|
|
275
276
|
makeThenableParams,
|
|
@@ -23,7 +23,7 @@ function classifyPprFallbackShellEligibility(options, currentRevalidateSeconds,
|
|
|
23
23
|
fallbackShells
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
async function probePprFallbackShellCache(options, fallbackShells, currentRevalidateSeconds) {
|
|
26
|
+
async function probePprFallbackShellCache(options, fallbackShells, currentRevalidateSeconds, isForceStatic) {
|
|
27
27
|
const { readAppPageFallbackShellCacheResponse } = await import("./app-page-cache.js");
|
|
28
28
|
const { rewriteAppPprFallbackShellHtmlNavigation } = await import("./app-ppr-fallback-shell.js");
|
|
29
29
|
for (const fallbackShell of fallbackShells) {
|
|
@@ -41,6 +41,7 @@ async function probePprFallbackShellCache(options, fallbackShells, currentRevali
|
|
|
41
41
|
rewriteHtml(html) {
|
|
42
42
|
return rewriteAppPprFallbackShellHtmlNavigation({
|
|
43
43
|
html,
|
|
44
|
+
isForceStatic,
|
|
44
45
|
params: options.params,
|
|
45
46
|
pathname: options.cleanPathname,
|
|
46
47
|
searchParams: options.searchParams
|
|
@@ -59,7 +60,7 @@ const appPagePprRuntime = {
|
|
|
59
60
|
},
|
|
60
61
|
async tryServe(options, currentRevalidateSeconds, isDraftMode, isForceStatic, isForceDynamic) {
|
|
61
62
|
const decision = classifyPprFallbackShellEligibility(options, currentRevalidateSeconds, isDraftMode, isForceStatic, isForceDynamic);
|
|
62
|
-
return decision.kind === "probe-fallback-shells" ? probePprFallbackShellCache(options, decision.fallbackShells, currentRevalidateSeconds) : null;
|
|
63
|
+
return decision.kind === "probe-fallback-shells" ? probePprFallbackShellCache(options, decision.fallbackShells, currentRevalidateSeconds, isForceStatic) : null;
|
|
63
64
|
},
|
|
64
65
|
async warm(options) {
|
|
65
66
|
const { warmPprFallbackShellCaches } = await import("./app-ppr-fallback-shell-render.js");
|
|
@@ -69,9 +69,10 @@ type RenderAppPageLifecycleOptions = {
|
|
|
69
69
|
isRscRequest: boolean;
|
|
70
70
|
isrDebug?: AppPageDebugLogger;
|
|
71
71
|
isrHtmlKey: (pathname: string) => string;
|
|
72
|
-
isrRscKey: (pathname: string, mountedSlotsHeader?: string | null, renderMode?: AppRscRenderMode, interceptionContext?: string | null) => string;
|
|
72
|
+
isrRscKey: (pathname: string, mountedSlotsHeader?: string | null, renderMode?: AppRscRenderMode, interceptionContext?: string | null, interceptionId?: string | null) => string;
|
|
73
73
|
isrSet: AppPageCacheSetter;
|
|
74
74
|
interceptionContext?: string | null;
|
|
75
|
+
interceptionId?: string | null;
|
|
75
76
|
layoutCount: number;
|
|
76
77
|
loadSsrHandler: () => Promise<AppPageSsrHandler>;
|
|
77
78
|
middlewareContext: AppPageMiddlewareContext;
|
|
@@ -12,8 +12,8 @@ import { probeAppPageBeforeRender } from "./app-page-probe.js";
|
|
|
12
12
|
import { DEFAULT_CACHE_VARIANT_BUDGET, buildCacheVariantWithRouteBudget, buildRenderObservation, buildRenderRequestApiObservations, createStaticLayoutArtifactReuseDecision } from "./cache-proof.js";
|
|
13
13
|
import { createAppPageHtmlOutputScope, createAppPageRenderObservation, createAppPageRscOutputScope } from "./app-page-render-observation.js";
|
|
14
14
|
import { finalizeAppPageHtmlCacheResponse, finalizeAppPageRscCacheResponse } from "./app-page-cache-finalizer.js";
|
|
15
|
-
import { createStaticLayoutClientReuseArtifactCompatibility, createStaticLayoutClientReusePayloadHash, createStaticLayoutClientReuseRouteId } from "./static-layout-client-reuse-proof.js";
|
|
16
15
|
import { appendRscCompletionMetadata } from "./rsc-completion-metadata.js";
|
|
16
|
+
import { createStaticLayoutClientReuseArtifactCompatibility, createStaticLayoutClientReusePayloadHash, createStaticLayoutClientReuseRouteId } from "./static-layout-client-reuse-proof.js";
|
|
17
17
|
import { hasDigest } from "./app-rsc-errors.js";
|
|
18
18
|
import { deferUntilStreamConsumed } from "./defer-until-stream-consumed.js";
|
|
19
19
|
import { buildAppPageLinkHeader, createAppPageFontData, createAppPageRscErrorTracker, renderAppPageHtmlStream, renderAppPageHtmlStreamWithRecovery } from "./app-page-stream.js";
|
|
@@ -385,7 +385,8 @@ async function renderAppPageLifecycle(options) {
|
|
|
385
385
|
}));
|
|
386
386
|
}
|
|
387
387
|
const dynamicUsedDuringBuild = consumeRenderDynamicUsage();
|
|
388
|
-
const
|
|
388
|
+
const shouldBypassRscCache = shouldBypassRscCacheForSkipTransport;
|
|
389
|
+
const rscResponsePolicy = shouldBypassRscCache ? { cacheControl: NO_STORE_CACHE_CONTROL } : resolveAppPageRscResponsePolicy({
|
|
389
390
|
dynamicUsedDuringBuild,
|
|
390
391
|
isDraftMode: options.isDraftMode,
|
|
391
392
|
isDynamicError: options.isDynamicError,
|
|
@@ -395,7 +396,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
395
396
|
expireSeconds,
|
|
396
397
|
revalidateSeconds
|
|
397
398
|
});
|
|
398
|
-
if (
|
|
399
|
+
if (shouldBypassRscCache) options.isrDebug?.("RSC cache write skipped (skip transport payload)", options.cleanPathname);
|
|
399
400
|
const shouldEmitDynamicStaleTime = dynamicStaleTimeSeconds !== void 0 && options.isPrerender !== true && !options.isForceStatic && (dynamicUsedDuringBuild || options.isForceDynamic);
|
|
400
401
|
const staleTimePending = options.isPrerender !== true && mayResolveCacheLifeAfterHeaders && !dynamicUsedDuringBuild;
|
|
401
402
|
const rscResponse = buildAppPageRscResponse(rscForResponse, {
|
|
@@ -459,6 +460,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
459
460
|
isrRscKey: options.isrRscKey,
|
|
460
461
|
isrSet: options.isrSet,
|
|
461
462
|
interceptionContext: options.interceptionContext,
|
|
463
|
+
interceptionId: options.interceptionId,
|
|
462
464
|
mountedSlotsHeader: options.mountedSlotsHeader,
|
|
463
465
|
omitPendingDynamicCacheState: options.omitPendingDynamicCacheState,
|
|
464
466
|
renderMode: options.renderMode,
|
|
@@ -669,6 +671,7 @@ async function renderAppPageLifecycle(options) {
|
|
|
669
671
|
isrRscKey: options.isrRscKey,
|
|
670
672
|
isrSet: options.isrSet,
|
|
671
673
|
interceptionContext: options.interceptionContext,
|
|
674
|
+
interceptionId: options.interceptionId,
|
|
672
675
|
omitPendingDynamicCacheState: options.omitPendingDynamicCacheState,
|
|
673
676
|
preserveClientResponseHeaders: !htmlResponsePolicy.shouldWriteToCache,
|
|
674
677
|
expireSeconds,
|
|
@@ -57,6 +57,7 @@ type BuildAppPageElementResult<TElement> = {
|
|
|
57
57
|
response: Response | null;
|
|
58
58
|
};
|
|
59
59
|
type AppPageInterceptMatch<TPage = unknown> = {
|
|
60
|
+
interceptionId?: string | null;
|
|
60
61
|
interceptionGraphId?: string | null;
|
|
61
62
|
interceptLayouts?: readonly unknown[] | null;
|
|
62
63
|
interceptLayoutSegments?: readonly (readonly string[])[] | null;
|
|
@@ -87,21 +88,6 @@ type AppPageInterceptMatch<TPage = unknown> = {
|
|
|
87
88
|
targetPatternParts?: readonly string[];
|
|
88
89
|
targetRouteGraphId?: string | null;
|
|
89
90
|
};
|
|
90
|
-
type ResolveAppPageInterceptMatchOptions<TRoute, TPage, TInterceptOpts> = {
|
|
91
|
-
cleanPathname: string;
|
|
92
|
-
currentRoute: TRoute;
|
|
93
|
-
findIntercept: (pathname: string) => AppPageInterceptMatch<TPage> | null;
|
|
94
|
-
getRouteParamNames: (route: TRoute) => readonly string[];
|
|
95
|
-
getSourceRoute: (sourceRouteIndex: number) => Awaitable<TRoute | undefined>;
|
|
96
|
-
isRscRequest: boolean;
|
|
97
|
-
toInterceptOpts: (intercept: AppPageInterceptMatch<TPage>) => TInterceptOpts;
|
|
98
|
-
};
|
|
99
|
-
type ResolveAppPageInterceptMatchResult<TRoute, TInterceptOpts> = {
|
|
100
|
-
interceptOpts: TInterceptOpts;
|
|
101
|
-
matchedParams: AppPageParams;
|
|
102
|
-
sourceParams: AppPageParams;
|
|
103
|
-
sourceRoute: TRoute;
|
|
104
|
-
};
|
|
105
91
|
type ResolveAppPageInterceptionRerenderTargetOptions<TRoute, TPage, TInterceptOpts> = {
|
|
106
92
|
cleanPathname: string;
|
|
107
93
|
currentParams: AppPageParams;
|
|
@@ -149,26 +135,9 @@ type ResolveAppPageInterceptResult<TInterceptOpts> = {
|
|
|
149
135
|
};
|
|
150
136
|
declare function resolveAppPageGenerateStaticParamsSources(options: ResolveAppPageGenerateStaticParamsSourcesOptions): GenerateStaticParamsSource[];
|
|
151
137
|
declare function validateAppPageDynamicParams(options: ValidateAppPageDynamicParamsOptions): Promise<Response | null>;
|
|
152
|
-
/**
|
|
153
|
-
* Pure: decides whether the incoming request should re-render an intercepted
|
|
154
|
-
* source-route tree, and if so returns the source route, the source-route's
|
|
155
|
-
* param slice, the full matched param set (the URL params the client sees),
|
|
156
|
-
* and an opaque `interceptOpts` bag for the caller's render pipeline.
|
|
157
|
-
*
|
|
158
|
-
* Returns `null` in three decision-fallthrough cases:
|
|
159
|
-
* - non-RSC requests (server rendering the direct page for a full HTML load)
|
|
160
|
-
* - no intercepting route matches the path
|
|
161
|
-
* - the match's source route IS the current route (the same branch today
|
|
162
|
-
* returns `interceptOpts` for the direct render)
|
|
163
|
-
*
|
|
164
|
-
* Shared by both the GET path (resolveAppPageIntercept, which layers on
|
|
165
|
-
* `setNavigationContext` + element build + Response wrap) and the server-action
|
|
166
|
-
* POST path (entries/app-rsc-entry.ts), which runs its own response pipeline.
|
|
167
|
-
*/
|
|
168
|
-
declare function resolveAppPageInterceptMatch<TRoute, TPage, TInterceptOpts>(options: ResolveAppPageInterceptMatchOptions<TRoute, TPage, TInterceptOpts>): Promise<ResolveAppPageInterceptMatchResult<TRoute, TInterceptOpts> | null>;
|
|
169
138
|
declare function resolveAppPageInterceptionRerenderTarget<TRoute, TPage, TInterceptOpts>(options: ResolveAppPageInterceptionRerenderTargetOptions<TRoute, TPage, TInterceptOpts>): Promise<ResolveAppPageInterceptionRerenderTargetResult<TRoute, TInterceptOpts>>;
|
|
170
139
|
declare function resolveAppPageActionRerenderTarget<TRoute, TPage, TInterceptOpts>(options: ResolveAppPageActionRerenderTargetOptions<TRoute, TPage, TInterceptOpts>): Promise<ResolveAppPageActionRerenderTargetResult<TRoute, TInterceptOpts>>;
|
|
171
140
|
declare function resolveAppPageIntercept<TRoute, TPage, TInterceptOpts, TElement>(options: ResolveAppPageInterceptOptions<TRoute, TPage, TInterceptOpts, TElement>): Promise<ResolveAppPageInterceptResult<TInterceptOpts>>;
|
|
172
141
|
declare function buildAppPageElement<TElement>(options: BuildAppPageElementOptions<TElement>): Promise<BuildAppPageElementResult<TElement>>;
|
|
173
142
|
//#endregion
|
|
174
|
-
export { ValidateAppPageDynamicParamsOptions, buildAppPageElement, resolveAppPageActionRerenderTarget, resolveAppPageGenerateStaticParamsSources, resolveAppPageIntercept,
|
|
143
|
+
export { ValidateAppPageDynamicParamsOptions, buildAppPageElement, resolveAppPageActionRerenderTarget, resolveAppPageGenerateStaticParamsSources, resolveAppPageIntercept, resolveAppPageInterceptionRerenderTarget, validateAppPageDynamicParams };
|
|
@@ -235,32 +235,6 @@ async function validateAppPageDynamicParams(options) {
|
|
|
235
235
|
}
|
|
236
236
|
return null;
|
|
237
237
|
}
|
|
238
|
-
/**
|
|
239
|
-
* Pure: decides whether the incoming request should re-render an intercepted
|
|
240
|
-
* source-route tree, and if so returns the source route, the source-route's
|
|
241
|
-
* param slice, the full matched param set (the URL params the client sees),
|
|
242
|
-
* and an opaque `interceptOpts` bag for the caller's render pipeline.
|
|
243
|
-
*
|
|
244
|
-
* Returns `null` in three decision-fallthrough cases:
|
|
245
|
-
* - non-RSC requests (server rendering the direct page for a full HTML load)
|
|
246
|
-
* - no intercepting route matches the path
|
|
247
|
-
* - the match's source route IS the current route (the same branch today
|
|
248
|
-
* returns `interceptOpts` for the direct render)
|
|
249
|
-
*
|
|
250
|
-
* Shared by both the GET path (resolveAppPageIntercept, which layers on
|
|
251
|
-
* `setNavigationContext` + element build + Response wrap) and the server-action
|
|
252
|
-
* POST path (entries/app-rsc-entry.ts), which runs its own response pipeline.
|
|
253
|
-
*/
|
|
254
|
-
async function resolveAppPageInterceptMatch(options) {
|
|
255
|
-
const interceptState = await resolveAppPageInterceptState(options);
|
|
256
|
-
if (interceptState.kind !== "source-route") return null;
|
|
257
|
-
return {
|
|
258
|
-
interceptOpts: options.toInterceptOpts(interceptState.intercept),
|
|
259
|
-
matchedParams: interceptState.intercept.matchedParams,
|
|
260
|
-
sourceParams: pickRouteParams(interceptState.intercept.sourceMatchedParams ?? interceptState.intercept.matchedParams, options.getRouteParamNames(interceptState.sourceRoute)),
|
|
261
|
-
sourceRoute: interceptState.sourceRoute
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
238
|
async function resolveAppPageInterceptState(options) {
|
|
265
239
|
if (!options.isRscRequest) return { kind: "none" };
|
|
266
240
|
const intercept = options.findIntercept(options.cleanPathname);
|
|
@@ -370,4 +344,4 @@ async function buildAppPageElement(options) {
|
|
|
370
344
|
}
|
|
371
345
|
}
|
|
372
346
|
//#endregion
|
|
373
|
-
export { buildAppPageElement, resolveAppPageActionRerenderTarget, resolveAppPageGenerateStaticParamsSources, resolveAppPageIntercept,
|
|
347
|
+
export { buildAppPageElement, resolveAppPageActionRerenderTarget, resolveAppPageGenerateStaticParamsSources, resolveAppPageIntercept, resolveAppPageInterceptionRerenderTarget, validateAppPageDynamicParams };
|
|
@@ -161,6 +161,7 @@ type BuildAppPageRouteElementOptions<TModule extends AppPageModule = AppPageModu
|
|
|
161
161
|
type MakeThenableParams = (params: AppPageParams, observer?: ThenableParamsObserver) => unknown;
|
|
162
162
|
type BuildAppPageElementsOptions<TModule extends AppPageModule = AppPageModule, TErrorModule extends AppPageErrorModule = AppPageErrorModule> = BuildAppPageRouteElementOptions<TModule, TErrorModule> & {
|
|
163
163
|
interception?: AppElementsInterception | null;
|
|
164
|
+
interceptionId?: string | null;
|
|
164
165
|
interceptionContext?: string | null;
|
|
165
166
|
isRscRequest?: boolean;
|
|
166
167
|
mountedSlotIds?: ReadonlySet<string> | null;
|