vinext 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -1
- package/THIRD_PARTY_LICENSES.md +26 -0
- package/dist/build/app-page-static-eligibility.d.ts +15 -0
- package/dist/build/app-page-static-eligibility.js +82 -0
- package/dist/build/lifecycle.js +10 -10
- package/dist/build/pages-client-assets-module.js +6 -1
- package/dist/build/precompress.js +1 -1
- package/dist/build/prerender-paths.js +6 -85
- package/dist/build/prerender.d.ts +8 -1
- package/dist/build/prerender.js +167 -46
- package/dist/build/run-prerender.js +4 -3
- package/dist/build/server-entry.d.ts +2 -0
- package/dist/build/server-entry.js +7 -1
- package/dist/build/server-manifest.d.ts +7 -0
- package/dist/build/server-manifest.js +11 -1
- package/dist/cache/cache-adapters-virtual.d.ts +7 -1
- package/dist/cache/cache-adapters-virtual.js +3 -3
- package/dist/client/browser-globals.d.ts +4 -0
- package/dist/client/browser-globals.js +5 -0
- package/dist/client/navigation-runtime.d.ts +11 -1
- package/dist/client/navigation-runtime.js +3 -3
- package/dist/config/config-matchers.js +3 -1
- package/dist/config/dotenv.js +14 -3
- package/dist/config/next-config.d.ts +7 -0
- package/dist/config/next-config.js +18 -3
- package/dist/entries/app-rsc-entry.d.ts +2 -0
- package/dist/entries/app-rsc-entry.js +67 -45
- package/dist/index.d.ts +4 -1
- package/dist/index.js +200 -100
- package/dist/init-cloudflare.d.ts +1 -1
- package/dist/init-cloudflare.js +6 -6
- package/dist/init-platform.js +1 -1
- package/dist/init.js +4 -2
- package/dist/plugins/cache-flight-codec.d.ts +19 -0
- package/dist/plugins/cache-flight-codec.js +68 -0
- package/dist/plugins/commonjs-esm-facade.d.ts +35 -0
- package/dist/plugins/commonjs-esm-facade.js +80 -0
- package/dist/plugins/commonjs-syntax.d.ts +16 -0
- package/dist/plugins/commonjs-syntax.js +22 -0
- package/dist/plugins/fonts.d.ts +8 -11
- package/dist/plugins/fonts.js +71 -34
- package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
- package/dist/plugins/ignore-dynamic-requests.js +54 -3
- package/dist/plugins/import-meta-url.js +6 -6
- package/dist/plugins/og-asset-ownership.d.ts +2 -0
- package/dist/plugins/og-asset-ownership.js +24 -13
- package/dist/plugins/og-assets.d.ts +18 -0
- package/dist/plugins/og-assets.js +50 -8
- package/dist/plugins/og-harfbuzz.js +38 -27
- package/dist/plugins/optimize-imports.js +2 -1
- package/dist/plugins/require-context.d.ts +1 -0
- package/dist/plugins/require-context.js +28 -1
- package/dist/plugins/scan-build-css.d.ts +12 -0
- package/dist/plugins/scan-build-css.js +39 -0
- package/dist/plugins/strip-server-exports.d.ts +2 -0
- package/dist/plugins/strip-server-exports.js +3 -1
- package/dist/plugins/transform-result.d.ts +18 -0
- package/dist/plugins/transform-result.js +23 -2
- package/dist/plugins/typeof-window.d.ts +10 -0
- package/dist/plugins/typeof-window.js +33 -9
- package/dist/routing/app-route-graph.d.ts +0 -1
- package/dist/routing/app-route-graph.js +2 -4
- package/dist/routing/app-route-ids.d.ts +3 -0
- package/dist/routing/app-route-ids.js +6 -0
- package/dist/routing/file-matcher.d.ts +1 -0
- package/dist/routing/file-matcher.js +1 -1
- package/dist/server/api-handler.js +17 -7
- package/dist/server/app-bfcache-id.d.ts +1 -0
- package/dist/server/app-bfcache-id.js +7 -1
- package/dist/server/app-bfcache-identity.js +1 -2
- package/dist/server/app-browser-entry.js +15 -9
- package/dist/server/app-browser-history-controller.d.ts +2 -0
- package/dist/server/app-browser-history-controller.js +8 -0
- package/dist/server/app-browser-hydration.d.ts +1 -1
- package/dist/server/app-browser-hydration.js +2 -2
- package/dist/server/app-browser-interception-context.js +26 -2
- package/dist/server/app-browser-navigation-controller.d.ts +7 -1
- package/dist/server/app-browser-navigation-controller.js +94 -11
- package/dist/server/app-browser-state.js +1 -1
- package/dist/server/app-browser-stream.d.ts +1 -1
- package/dist/server/app-fallback-renderer.d.ts +2 -0
- package/dist/server/app-fallback-renderer.js +1 -0
- package/dist/server/app-history-state.d.ts +3 -1
- package/dist/server/app-history-state.js +9 -5
- package/dist/server/app-middleware.js +2 -1
- package/dist/server/app-optimistic-routing.js +1 -1
- package/dist/server/app-page-boundary-render.d.ts +5 -0
- package/dist/server/app-page-boundary-render.js +6 -4
- package/dist/server/app-page-cache-finalizer.d.ts +11 -0
- package/dist/server/app-page-cache-finalizer.js +41 -7
- package/dist/server/app-page-cache-render.d.ts +18 -0
- package/dist/server/app-page-cache-render.js +65 -44
- package/dist/server/app-page-cache.d.ts +5 -0
- package/dist/server/app-page-cache.js +27 -7
- package/dist/server/app-page-dispatch.d.ts +9 -1
- package/dist/server/app-page-dispatch.js +47 -30
- package/dist/server/app-page-element-builder.d.ts +7 -0
- package/dist/server/app-page-element-builder.js +27 -42
- package/dist/server/app-page-execution.d.ts +15 -12
- package/dist/server/app-page-execution.js +30 -40
- package/dist/server/app-page-head.d.ts +5 -0
- package/dist/server/app-page-head.js +9 -3
- package/dist/server/app-page-probe.d.ts +0 -109
- package/dist/server/app-page-probe.js +3 -136
- package/dist/server/app-page-render-identity.d.ts +0 -1
- package/dist/server/app-page-render-identity.js +1 -1
- package/dist/server/app-page-render-observation.js +2 -2
- package/dist/server/app-page-render.d.ts +13 -5
- package/dist/server/app-page-render.js +219 -118
- package/dist/server/app-page-request.d.ts +0 -1
- package/dist/server/app-page-request.js +1 -2
- package/dist/server/app-page-response.d.ts +4 -3
- package/dist/server/app-page-response.js +4 -3
- package/dist/server/app-page-route-wiring.d.ts +17 -5
- package/dist/server/app-page-route-wiring.js +55 -33
- package/dist/server/app-page-rsc-render-status.d.ts +48 -0
- package/dist/server/app-page-rsc-render-status.js +54 -0
- package/dist/server/app-page-search-params-observation.js +1 -1
- package/dist/server/app-page-stream.d.ts +15 -8
- package/dist/server/app-page-stream.js +7 -1
- package/dist/server/app-page-tracing.js +2 -1
- package/dist/server/app-pages-bridge.js +3 -2
- package/dist/server/app-render-abort-error.d.ts +3 -0
- package/dist/server/app-render-abort-error.js +8 -0
- package/dist/server/app-request-stage-dispatch.js +1 -1
- package/dist/server/app-request-stage-independent-entry.js +8 -11
- package/dist/server/app-response-header-provenance.d.ts +2 -0
- package/dist/server/app-response-header-provenance.js +10 -4
- package/dist/server/app-route-handler-cache.d.ts +2 -1
- package/dist/server/app-route-handler-cache.js +11 -7
- package/dist/server/app-route-handler-dispatch.js +11 -4
- package/dist/server/app-route-handler-execution.d.ts +9 -1
- package/dist/server/app-route-handler-execution.js +28 -13
- package/dist/server/app-route-handler-policy.js +2 -2
- package/dist/server/app-route-handler-response.d.ts +1 -1
- package/dist/server/app-route-handler-response.js +14 -5
- package/dist/server/app-router-entry.d.ts +2 -1
- package/dist/server/app-router-entry.js +8 -12
- package/dist/server/app-rsc-errors.d.ts +0 -1
- package/dist/server/app-rsc-errors.js +2 -6
- package/dist/server/app-rsc-handler.d.ts +5 -0
- package/dist/server/app-rsc-handler.js +229 -102
- package/dist/server/app-rsc-request-normalization.d.ts +4 -2
- package/dist/server/app-rsc-request-normalization.js +7 -4
- package/dist/server/app-rsc-response-finalizer.js +4 -1
- package/dist/server/app-rsc-response-stage.d.ts +1 -1
- package/dist/server/app-rsc-response-stage.js +6 -4
- package/dist/server/app-rsc-route-matching.d.ts +9 -1
- package/dist/server/app-rsc-route-matching.js +37 -20
- package/dist/server/app-server-action-execution.d.ts +2 -1
- package/dist/server/app-server-action-execution.js +1 -1
- package/dist/server/app-ssr-entry.d.ts +3 -2
- package/dist/server/app-ssr-entry.js +9 -7
- package/dist/server/app-ssr-search-params-gate.js +1 -1
- package/dist/server/app-ssr-stream.d.ts +6 -1
- package/dist/server/app-ssr-stream.js +35 -16
- package/dist/server/app-worker-stages.d.ts +2 -2
- package/dist/server/app-worker-stages.js +3 -3
- package/dist/server/cache-control.js +3 -11
- package/dist/server/cacheability-request.js +56 -52
- package/dist/server/config-headers.js +3 -1
- package/dist/server/dev-server.js +23 -5
- package/dist/server/headers.d.ts +16 -0
- package/dist/server/headers.js +19 -1
- package/dist/server/http-error-responses.js +1 -0
- package/dist/server/image-optimization.d.ts +16 -0
- package/dist/server/image-optimization.js +26 -6
- package/dist/server/isr-cache.d.ts +2 -0
- package/dist/server/isr-cache.js +8 -3
- package/dist/server/metadata-route-response.js +94 -37
- package/dist/server/middleware-matcher-pattern.js +8 -4
- package/dist/server/middleware-response-headers.js +2 -0
- package/dist/server/multi-stage.d.ts +8 -0
- package/dist/server/navigation-planner.js +1 -1
- package/dist/server/node-response-signal.d.ts +16 -0
- package/dist/server/node-response-signal.js +26 -0
- package/dist/server/open-redirect.d.ts +47 -0
- package/dist/server/open-redirect.js +74 -1
- package/dist/server/pages-api-route.js +8 -2
- package/dist/server/pages-asset-tags.d.ts +1 -0
- package/dist/server/pages-asset-tags.js +73 -22
- package/dist/server/pages-client-assets.d.ts +2 -0
- package/dist/server/pages-page-data.d.ts +6 -1
- package/dist/server/pages-page-data.js +71 -65
- package/dist/server/pages-page-handler.js +50 -15
- package/dist/server/pages-page-response.js +3 -1
- package/dist/server/pages-request-pipeline.d.ts +2 -1
- package/dist/server/pages-request-pipeline.js +20 -5
- package/dist/server/pages-request-stage-entry.js +14 -8
- package/dist/server/prerender-manifest.d.ts +6 -0
- package/dist/server/prerender-manifest.js +1 -1
- package/dist/server/prod-server.d.ts +8 -7
- package/dist/server/prod-server.js +152 -78
- package/dist/server/request-pipeline.d.ts +20 -8
- package/dist/server/request-pipeline.js +21 -7
- package/dist/server/response-compression.d.ts +43 -0
- package/dist/server/response-compression.js +111 -0
- package/dist/server/response-stage-cacheability.js +1 -1
- package/dist/server/seed-cache.js +10 -7
- package/dist/server/socket-error-backstop.d.ts +14 -0
- package/dist/server/socket-error-backstop.js +27 -4
- package/dist/server/worker-revalidation-context.d.ts +2 -1
- package/dist/server/worker-revalidation-context.js +1 -0
- package/dist/server/workers-tracing.d.ts +17 -0
- package/dist/server/workers-tracing.js +48 -8
- package/dist/shims/cache-adapter-instantiate.d.ts +50 -0
- package/dist/shims/cache-adapter-instantiate.js +118 -0
- package/dist/shims/cache-callable-runtime.d.ts +2 -40
- package/dist/shims/cache-callable-runtime.js +50 -168
- package/dist/shims/cache-flight-arguments.d.ts +22 -0
- package/dist/shims/cache-flight-arguments.js +56 -0
- package/dist/shims/cache-request-state.d.ts +18 -14
- package/dist/shims/cache-request-state.js +33 -21
- package/dist/shims/cache-runtime.d.ts +6 -19
- package/dist/shims/cache-runtime.js +168 -226
- package/dist/shims/cache.d.ts +3 -2
- package/dist/shims/cache.js +8 -5
- package/dist/shims/cacheability-classification.d.ts +8 -1
- package/dist/shims/cacheability-classification.js +2 -2
- package/dist/shims/cdn-cache.d.ts +10 -1
- package/dist/shims/cdn-cache.js +16 -9
- package/dist/shims/error-boundary-navigation.d.ts +7 -0
- package/dist/shims/error-boundary-navigation.js +19 -1
- package/dist/shims/error-boundary.d.ts +10 -10
- package/dist/shims/error-boundary.js +26 -7
- package/dist/shims/error.d.ts +4 -18
- package/dist/shims/error.js +17 -10
- package/dist/shims/error.react-server.d.ts +4 -6
- package/dist/shims/error.react-server.js +4 -1
- package/dist/shims/fetch-cache.d.ts +6 -0
- package/dist/shims/fetch-cache.js +23 -4
- package/dist/shims/form.js +1 -1
- package/dist/shims/headers.d.ts +19 -69
- package/dist/shims/headers.js +82 -183
- package/dist/shims/internal/app-page-props-cache-key.d.ts +5 -2
- package/dist/shims/internal/app-page-props-cache-key.js +24 -15
- package/dist/shims/internal/cache-context-accessor.d.ts +16 -0
- package/dist/shims/internal/cache-context-accessor.js +15 -0
- package/dist/shims/internal/headers-state.d.ts +73 -0
- package/dist/shims/internal/headers-state.js +157 -0
- package/dist/shims/metadata.js +3 -3
- package/dist/shims/navigation-errors.d.ts +6 -0
- package/dist/shims/navigation-errors.js +11 -1
- package/dist/shims/navigation.d.ts +7 -0
- package/dist/shims/navigation.js +16 -6
- package/dist/shims/request-context.d.ts +9 -0
- package/dist/shims/request-state-types.d.ts +2 -1
- package/dist/shims/root-params.js +1 -1
- package/dist/shims/server.js +52 -2
- package/dist/shims/thenable-params.d.ts +4 -0
- package/dist/shims/thenable-params.js +25 -3
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +1 -0
- package/dist/utils/encode-cache-tag.d.ts +1 -0
- package/dist/utils/encode-cache-tag.js +11 -1
- package/dist/utils/mdx-scan.d.ts +5 -0
- package/dist/utils/mdx-scan.js +8 -1
- package/dist/utils/regex-safety.d.ts +10 -0
- package/dist/utils/regex-safety.js +70 -18
- package/dist/utils/vite-cli-invocation.js +8 -1
- package/package.json +8 -4
- package/dist/server/metadata-route-cache-policy.d.ts +0 -5
- package/dist/server/metadata-route-cache-policy.js +0 -6
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
-
import { booleanLiteralValue, collectBindingNames, forEachAstChild, isIdentifierNamed, stringLiteralValue } from "./ast-utils.js";
|
|
2
|
+
import { DYNAMIC_IMPORT_PRESCAN, booleanLiteralValue, collectBindingNames, forEachAstChild, isIdentifierNamed, stringLiteralValue } from "./ast-utils.js";
|
|
3
3
|
import { magicStringTransformResult } from "./transform-result.js";
|
|
4
4
|
import { stripViteModuleQuery } from "../utils/path.js";
|
|
5
5
|
import { collectDirectScopeBindings, collectLoopScopeBindings, collectSwitchScopeBindings, collectVarScopeBindings, createAstScope, hasAstBinding, isFunctionNode } from "./ast-scope.js";
|
|
6
|
-
import {
|
|
6
|
+
import { parseSync } from "vite";
|
|
7
7
|
import MagicString from "magic-string";
|
|
8
8
|
//#region src/plugins/typeof-window.ts
|
|
9
9
|
const sourceEscapePattern = /\\(?:\r\n|[\n\r\u2028\u2029]|[^\n\r\u2028\u2029])/;
|
|
10
10
|
const consumerEnvironmentConditionFilter = new RegExp(String.raw`\btypeof\s+window\b|${/\\(?:u(?:[\da-fA-F]{4}|\{[\da-fA-F]+\})|x[\da-fA-F]{2})/.source}|\bprocess\b[\s)]*(?:(?:\?\.|\.)\s*(?:browser\b|\/[/*])|(?:\?\.\s*)?\[[\s(]*(?:["']browser["']|["'][^"'\\\n\r]*\\|\/[/*])|\/[/*])`);
|
|
11
|
+
const SCANNED_IMPORT_FOLD_PRESCAN = new RegExp(String.raw`${DYNAMIC_IMPORT_PRESCAN.source}|\bimport\s*\.`);
|
|
12
|
+
const NON_IMPORTING_IMPORT_META_RE = /\s*\.\s*(?:url|env)\b/y;
|
|
11
13
|
function createChildScope(node, parent) {
|
|
12
14
|
if (node.type !== "Program" && node.type !== "BlockStatement" && node.type !== "StaticBlock" && node.type !== "TSModuleBlock" && node.type !== "CatchClause" && node.type !== "ForStatement" && node.type !== "ForInStatement" && node.type !== "ForOfStatement" && node.type !== "ClassDeclaration" && node.type !== "ClassExpression") return null;
|
|
13
15
|
const scope = createAstScope(parent);
|
|
@@ -110,6 +112,27 @@ function evaluateConsumerCondition(node, replacements, scope) {
|
|
|
110
112
|
effects: []
|
|
111
113
|
};
|
|
112
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Cheap pre-parse gate for import-scan builds. Over-inclusive by design; the
|
|
117
|
+
* parser's module record in {@link moduleRecordHasScannedFoldTargets} is exact.
|
|
118
|
+
*/
|
|
119
|
+
function mayFoldChangeScannedImports(code) {
|
|
120
|
+
return SCANNED_IMPORT_FOLD_PRESCAN.test(code);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Whether folding may change a scanned import: any dynamic or phase import, or
|
|
124
|
+
* an `import.meta` expression other than a `.url`/`.env` read. Reads the parser's native module record, so no
|
|
125
|
+
* ESTree is materialized.
|
|
126
|
+
*/
|
|
127
|
+
function moduleRecordHasScannedFoldTargets(code, module, lang) {
|
|
128
|
+
if ((lang === "ts" || lang === "tsx") && DYNAMIC_IMPORT_PRESCAN.test(code)) return true;
|
|
129
|
+
if (module.dynamicImports.length > 0) return true;
|
|
130
|
+
for (const importMeta of module.importMetas) {
|
|
131
|
+
NON_IMPORTING_IMPORT_META_RE.lastIndex = importMeta.end;
|
|
132
|
+
if (!NON_IMPORTING_IMPORT_META_RE.test(code)) return true;
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
113
136
|
function replaceTypeofWindow(code, replacement, id = "file.js") {
|
|
114
137
|
return replaceConsumerEnvironmentConditions(code, { typeofWindow: replacement }, id);
|
|
115
138
|
}
|
|
@@ -119,12 +142,13 @@ function replaceConsumerEnvironmentConditions(code, replacements, id = "file.js"
|
|
|
119
142
|
if (!mayContainTypeofWindow && !mayContainProcessBrowser) return null;
|
|
120
143
|
const extension = path.extname(stripViteModuleQuery(id));
|
|
121
144
|
const lang = extension === ".ts" || extension === ".mts" || extension === ".cts" ? "ts" : extension === ".tsx" ? "tsx" : extension === ".jsx" ? "jsx" : "js";
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
145
|
+
const parsed = parseSync(id, code, {
|
|
146
|
+
lang,
|
|
147
|
+
preserveParens: false
|
|
148
|
+
});
|
|
149
|
+
if (parsed.errors.length > 0) return null;
|
|
150
|
+
if (replacements.onlyIfScannedImportsChange && !moduleRecordHasScannedFoldTargets(code, parsed.module, lang)) return null;
|
|
151
|
+
const ast = parsed.program;
|
|
128
152
|
const output = new MagicString(code);
|
|
129
153
|
let changed = false;
|
|
130
154
|
function overwriteGap(start, end, content) {
|
|
@@ -236,4 +260,4 @@ function replaceConsumerEnvironmentConditions(code, replacements, id = "file.js"
|
|
|
236
260
|
return magicStringTransformResult(output);
|
|
237
261
|
}
|
|
238
262
|
//#endregion
|
|
239
|
-
export { consumerEnvironmentConditionFilter, getTypeofWindowReplacement, replaceConsumerEnvironmentConditions, replaceTypeofWindow };
|
|
263
|
+
export { consumerEnvironmentConditionFilter, getTypeofWindowReplacement, mayFoldChangeScannedImports, replaceConsumerEnvironmentConditions, replaceTypeofWindow };
|
|
@@ -364,7 +364,6 @@ export type RouteManifest = {
|
|
|
364
364
|
graphVersion: GraphVersion;
|
|
365
365
|
segmentGraph: StaticSegmentGraph;
|
|
366
366
|
};
|
|
367
|
-
export declare function createAppRouteGraphInterceptionId(slotId: string, sourcePattern: string, targetPattern: string): string;
|
|
368
367
|
/**
|
|
369
368
|
* Build the App Router route graph by scanning `appDir`.
|
|
370
369
|
*/
|
|
@@ -3,6 +3,7 @@ import { findFileWithExts, scanWithExtensions } from "./file-matcher.js";
|
|
|
3
3
|
import { decodeRouteSegment, isInvisibleSegment, sortRoutes } from "./utils.js";
|
|
4
4
|
import { validateRoutePatterns } from "./route-validation.js";
|
|
5
5
|
import { compareStrings } from "../utils/compare.js";
|
|
6
|
+
import { createAppRouteGraphInterceptionId } from "./app-route-ids.js";
|
|
6
7
|
import fs from "node:fs";
|
|
7
8
|
import { createHash } from "node:crypto";
|
|
8
9
|
//#region src/routing/app-route-graph.ts
|
|
@@ -37,9 +38,6 @@ const SIBLING_INTERCEPT_SLOT_NAME = "__vinext_sibling_intercept";
|
|
|
37
38
|
function createAppRouteGraphSiblingInterceptSlotId(sourcePattern) {
|
|
38
39
|
return createAppRouteGraphSlotId(SIBLING_INTERCEPT_SLOT_NAME, sourcePattern);
|
|
39
40
|
}
|
|
40
|
-
function createAppRouteGraphInterceptionId(slotId, sourcePattern, targetPattern) {
|
|
41
|
-
return `interception:${slotId}:${sourcePattern}->${targetPattern}`;
|
|
42
|
-
}
|
|
43
41
|
function createAppRouteGraphRootBoundaryId(treePath) {
|
|
44
42
|
return `root-boundary:${treePath}`;
|
|
45
43
|
}
|
|
@@ -1753,4 +1751,4 @@ function computeAppRouteStaticSiblings(allRoutes, matchedRoute) {
|
|
|
1753
1751
|
return Array.from(siblings);
|
|
1754
1752
|
}
|
|
1755
1753
|
//#endregion
|
|
1756
|
-
export { buildAppRouteGraph, computeAppRouteStaticSiblings, computeRootParamNames, convertSegmentsToRouteParts,
|
|
1754
|
+
export { buildAppRouteGraph, computeAppRouteStaticSiblings, computeRootParamNames, convertSegmentsToRouteParts, findOwnerRouteForDir, isInvisibleSegment, patternsStructurallyEquivalent };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
//#region src/routing/file-matcher.d.ts
|
|
2
|
+
export declare const DEFAULT_PAGE_EXTENSIONS: readonly ["tsx", "ts", "jsx", "js"];
|
|
2
3
|
export declare function normalizePageExtensions(pageExtensions?: readonly string[] | null): string[];
|
|
3
4
|
export type ValidFileMatcher = {
|
|
4
5
|
extensions: string[];
|
|
@@ -152,4 +152,4 @@ async function* scanWithExtensions(stem, cwd, extensions, exclude) {
|
|
|
152
152
|
})) yield toSlash(file);
|
|
153
153
|
}
|
|
154
154
|
//#endregion
|
|
155
|
-
export { buildViteResolveExtensions, createValidFileMatcher, findFileWithExtensions, findFileWithExts, normalizePageExtensions, normalizeViteResolveExtensions, scanWithExtensions };
|
|
155
|
+
export { DEFAULT_PAGE_EXTENSIONS, buildViteResolveExtensions, createValidFileMatcher, findFileWithExtensions, findFileWithExts, normalizePageExtensions, normalizeViteResolveExtensions, scanWithExtensions };
|
|
@@ -11,6 +11,7 @@ import { resolveRequestHost, resolveRequestProtocol } from "./proxy-trust.js";
|
|
|
11
11
|
import { performOnDemandRevalidate } from "./pages-revalidate.js";
|
|
12
12
|
import { attachPagesPreviewApi, attachPagesRequestCookies } from "./pages-node-compat.js";
|
|
13
13
|
import { finalizeEdgeApiResponse, isEdgeApiRuntime } from "./edge-api-runtime.js";
|
|
14
|
+
import { signalFromNodeResponse } from "./node-response-signal.js";
|
|
14
15
|
import { Buffer } from "node:buffer";
|
|
15
16
|
import { decode } from "node:querystring";
|
|
16
17
|
//#region src/server/api-handler.ts
|
|
@@ -89,7 +90,7 @@ function readEdgeRequestBody(req) {
|
|
|
89
90
|
req.on("error", (error) => controller.error(error));
|
|
90
91
|
} });
|
|
91
92
|
}
|
|
92
|
-
function createEdgeApiRequest(req, url, params, nextConfig) {
|
|
93
|
+
function createEdgeApiRequest(req, res, url, params, nextConfig) {
|
|
93
94
|
const headers = new Headers();
|
|
94
95
|
for (const [name, value] of Object.entries(req.headers)) {
|
|
95
96
|
if (name.startsWith(":")) continue;
|
|
@@ -103,10 +104,12 @@ function createEdgeApiRequest(req, url, params, nextConfig) {
|
|
|
103
104
|
if (basePath && !hasBasePath(requestUrl.pathname, basePath)) requestUrl.pathname = `${basePath}${requestUrl.pathname}`;
|
|
104
105
|
const query = mergeRouteParamsIntoQuery(parseQueryString(url), params);
|
|
105
106
|
requestUrl.search = urlQueryToSearchParams(query).toString();
|
|
106
|
-
const
|
|
107
|
+
const signal = signalFromNodeResponse(res);
|
|
108
|
+
const body = signal.aborted ? void 0 : readEdgeRequestBody(req);
|
|
107
109
|
const init = {
|
|
108
110
|
headers,
|
|
109
|
-
method: req.method
|
|
111
|
+
method: req.method,
|
|
112
|
+
signal
|
|
110
113
|
};
|
|
111
114
|
if (body) {
|
|
112
115
|
init.body = body;
|
|
@@ -138,12 +141,17 @@ function waitForWritableDrain(res) {
|
|
|
138
141
|
res.once("close", onClose);
|
|
139
142
|
});
|
|
140
143
|
}
|
|
141
|
-
async function writeEdgeApiResponseBody(res, body) {
|
|
144
|
+
async function writeEdgeApiResponseBody(res, body, signal) {
|
|
142
145
|
if (!body) {
|
|
143
146
|
res.end();
|
|
144
147
|
return;
|
|
145
148
|
}
|
|
146
149
|
const reader = body.getReader();
|
|
150
|
+
const cancel = () => {
|
|
151
|
+
reader.cancel(signal.reason).catch(() => {});
|
|
152
|
+
};
|
|
153
|
+
if (signal.aborted) cancel();
|
|
154
|
+
else signal.addEventListener("abort", cancel, { once: true });
|
|
147
155
|
try {
|
|
148
156
|
while (true) {
|
|
149
157
|
const result = await reader.read();
|
|
@@ -151,11 +159,13 @@ async function writeEdgeApiResponseBody(res, body) {
|
|
|
151
159
|
if (result.value.byteLength === 0) continue;
|
|
152
160
|
if (!res.write(Buffer.from(result.value))) await waitForWritableDrain(res);
|
|
153
161
|
}
|
|
154
|
-
res.end();
|
|
162
|
+
if (!signal.aborted) res.end();
|
|
155
163
|
} catch (error) {
|
|
164
|
+
if (signal.aborted) return;
|
|
156
165
|
res.destroy(error instanceof Error ? error : new Error(String(error)));
|
|
157
166
|
throw error;
|
|
158
167
|
} finally {
|
|
168
|
+
signal.removeEventListener("abort", cancel);
|
|
159
169
|
reader.releaseLock();
|
|
160
170
|
}
|
|
161
171
|
}
|
|
@@ -224,7 +234,7 @@ async function handleApiRoute(runner, req, res, url, apiRoutes, nextConfig) {
|
|
|
224
234
|
try {
|
|
225
235
|
const apiModule = await importModule(runner, route.filePath);
|
|
226
236
|
if (isEdgeApiRouteModule(apiModule)) {
|
|
227
|
-
const nextRequest = new NextRequest(createEdgeApiRequest(req, url, params, nextConfig), nextConfig ? { nextConfig: {
|
|
237
|
+
const nextRequest = new NextRequest(createEdgeApiRequest(req, res, url, params, nextConfig), nextConfig ? { nextConfig: {
|
|
228
238
|
basePath: nextConfig.basePath,
|
|
229
239
|
i18n: nextConfig.i18n ?? void 0,
|
|
230
240
|
trailingSlash: nextConfig.trailingSlash
|
|
@@ -239,7 +249,7 @@ async function handleApiRoute(runner, req, res, url, apiRoutes, nextConfig) {
|
|
|
239
249
|
if (name !== "set-cookie") res.setHeader(name, value);
|
|
240
250
|
});
|
|
241
251
|
if (setCookieHeaders.length) res.setHeader("set-cookie", setCookieHeaders);
|
|
242
|
-
await writeEdgeApiResponseBody(res, response.body);
|
|
252
|
+
await writeEdgeApiResponseBody(res, response.body, nextRequest.signal);
|
|
243
253
|
return true;
|
|
244
254
|
}
|
|
245
255
|
const handler = apiModule.default;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { AppElementsWire } from "./app-elements-wire.js";
|
|
2
|
+
import "./app-elements.js";
|
|
1
3
|
//#region src/server/app-bfcache-id.ts
|
|
2
4
|
const INITIAL_BFCACHE_ID = "0";
|
|
3
5
|
const PUBLIC_INITIAL_BFCACHE_ID = "_b_0_";
|
|
6
|
+
function isBfcacheSegmentId(id) {
|
|
7
|
+
const parsed = AppElementsWire.parseElementKey(id);
|
|
8
|
+
return parsed?.kind === "layout" || parsed?.kind === "page" || parsed?.kind === "slot" || parsed?.kind === "template";
|
|
9
|
+
}
|
|
4
10
|
//#endregion
|
|
5
|
-
export { INITIAL_BFCACHE_ID, PUBLIC_INITIAL_BFCACHE_ID };
|
|
11
|
+
export { INITIAL_BFCACHE_ID, PUBLIC_INITIAL_BFCACHE_ID, isBfcacheSegmentId };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { AppElementsWire } from "./app-elements-wire.js";
|
|
2
2
|
import "./app-elements.js";
|
|
3
3
|
import { isNestedBfcacheSlotSegmentIdFor } from "./bfcache-identity.js";
|
|
4
|
-
import "./app-bfcache-id.js";
|
|
5
|
-
import { isBfcacheSegmentId } from "./app-history-state.js";
|
|
4
|
+
import { isBfcacheSegmentId } from "./app-bfcache-id.js";
|
|
6
5
|
//#region src/server/app-bfcache-identity.ts
|
|
7
6
|
let nextBfcacheId = 0;
|
|
8
7
|
function rememberBfcacheId(value) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { splitPathnameForRouteMatch } from "../routing/utils.js";
|
|
2
2
|
import { addBasePathToPathname, stripBasePath } from "../utils/base-path.js";
|
|
3
3
|
import { VINEXT_CLIENT_REUSE_MANIFEST_HEADER, VINEXT_PARAMS_HEADER, VINEXT_RENDERED_PATH_AND_SEARCH_HEADER, VINEXT_RSC_REDIRECT_HEADER, VINEXT_RSC_REDIRECT_TYPE_HEADER } from "./headers.js";
|
|
4
|
-
import { AppElementsWire } from "./app-elements-wire.js";
|
|
5
|
-
import { getMountedSlotIdsHeader, resolveVisitedResponseInterceptionContext } from "./app-elements.js";
|
|
6
4
|
import { AppRouterContext } from "../shims/internal/app-router-context.js";
|
|
7
5
|
import { matchRoutePattern } from "../routing/route-pattern.js";
|
|
8
6
|
import { installWindowNext, setWindowNextInternalSourcePage } from "../client/window-next.js";
|
|
9
7
|
import { retryScrollTo, scrollToHashTargetOnNextFrame } from "../shims/hash-scroll.js";
|
|
8
|
+
import { AppElementsWire } from "./app-elements-wire.js";
|
|
9
|
+
import { getMountedSlotIdsHeader, resolveVisitedResponseInterceptionContext } from "./app-elements.js";
|
|
10
10
|
import { getBfcacheIdMapContext, getNavigationContext, setNavigationContext } from "../shims/navigation-context-state.js";
|
|
11
11
|
import { decodeRedirectError, isRedirectError } from "../shims/navigation-errors.js";
|
|
12
12
|
import DefaultGlobalError from "../shims/default-global-error.js";
|
|
@@ -16,14 +16,14 @@ import { beginAppRouterScrollIntent, consumeAppRouterScrollIntent } from "../shi
|
|
|
16
16
|
import { AppRouterScrollCommitProvider } from "../shims/app-router-scroll.js";
|
|
17
17
|
import { BfcacheIdentityMapContext, ElementsContext, Slot, bindAppElementsRenderedSearch, setAppElementsRenderedSearch } from "../shims/slot.js";
|
|
18
18
|
import { VINEXT_RSC_COMPATIBILITY_ID_HEADER, VINEXT_RSC_CONTENT_TYPE, createRscRequestHeaders, createRscRequestUrl, getVinextRscCompatibilityId } from "./app-rsc-cache-busting.js";
|
|
19
|
-
import { getNavigationRuntime, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions } from "../client/navigation-runtime.js";
|
|
20
19
|
import { notifyAppRouterTransitionStart } from "../client/instrumentation-client-state.js";
|
|
21
20
|
import "../client/instrumentation-client.js";
|
|
22
|
-
import {
|
|
21
|
+
import { getNavigationRuntime, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions } from "../client/navigation-runtime.js";
|
|
23
22
|
import { createBfcacheSegmentIdentityMap, createInitialBfcacheIdMap } from "./app-bfcache-identity.js";
|
|
24
23
|
import { createDiscardedServerActionRefreshScheduler, createServerActionInitiationSnapshot, resolveServerActionOperationLane } from "./app-browser-action-result.js";
|
|
25
24
|
import { createClientReuseManifestHeaderFromVisibleAppState } from "./app-browser-client-reuse-manifest.js";
|
|
26
25
|
import { resolveManifestNavigationInterceptionContext, resolveMiddlewareRewriteNavigationInterceptionContext } from "./app-browser-interception-context.js";
|
|
26
|
+
import { isExternalHistoryState, readHistoryStateActiveRoutePaths, readHistoryStatePreviousNextUrl, resolveActiveRoutePaths } from "./app-history-state.js";
|
|
27
27
|
import { AppBrowserMpaNavigationScheduler } from "./app-browser-mpa-navigation.js";
|
|
28
28
|
import { stripRscCompletionMetadataResponse } from "./rsc-completion-metadata.js";
|
|
29
29
|
import { blockDangerousStreamedRscRedirect } from "./app-browser-rsc-redirect.js";
|
|
@@ -362,22 +362,22 @@ function createActionInitiationSnapshot() {
|
|
|
362
362
|
}
|
|
363
363
|
function createNavigationCommitEffect(options) {
|
|
364
364
|
const { activeRoutePaths, bfcacheIds, href, historyUpdateMode, navId, params, previousNextUrl, targetHistoryIndex } = options;
|
|
365
|
-
return () => {
|
|
365
|
+
return ({ keepCurrentUrl, releaseSnapshot }) => {
|
|
366
366
|
if (!browserNavigationController.isCurrentNavigation(navId)) {
|
|
367
|
-
commitClientNavigationState(void 0, { releaseSnapshot
|
|
367
|
+
commitClientNavigationState(void 0, { releaseSnapshot });
|
|
368
368
|
return;
|
|
369
369
|
}
|
|
370
370
|
historyController.commitNavigationHistory({
|
|
371
371
|
activeRoutePaths,
|
|
372
372
|
bfcacheIds,
|
|
373
373
|
href,
|
|
374
|
-
historyUpdateMode,
|
|
374
|
+
historyUpdateMode: keepCurrentUrl ? void 0 : historyUpdateMode,
|
|
375
375
|
previousNextUrl,
|
|
376
376
|
stageClientParams: () => stageClientParams(params),
|
|
377
377
|
targetHistoryIndex
|
|
378
378
|
});
|
|
379
379
|
clearAppNavigationFailureTarget(href);
|
|
380
|
-
commitClientNavigationState(navId);
|
|
380
|
+
commitClientNavigationState(navId, { releaseSnapshot });
|
|
381
381
|
};
|
|
382
382
|
}
|
|
383
383
|
async function renderNavigationPayload(options) {
|
|
@@ -1407,6 +1407,8 @@ function bootstrapHydration(rscStream, devErrorOverlay, initialRscBootstrap) {
|
|
|
1407
1407
|
primary: Promise.resolve(rscPayload),
|
|
1408
1408
|
signal: navigationAbortHandle.signal,
|
|
1409
1409
|
supplemental
|
|
1410
|
+
}).finally(() => {
|
|
1411
|
+
navigationAbortHandle.release();
|
|
1410
1412
|
}).then(requireCompleteSupplementalRefresh);
|
|
1411
1413
|
}
|
|
1412
1414
|
if (IS_STATIC_EXPORT) {
|
|
@@ -1503,7 +1505,11 @@ function bootstrapHydration(rscStream, devErrorOverlay, initialRscBootstrap) {
|
|
|
1503
1505
|
},
|
|
1504
1506
|
preparePrefetchResponse: (response) => decodeAppElementsPromise(createFromFetch(Promise.resolve(response))),
|
|
1505
1507
|
claimCurrentHistoryTreeSnapshot: (historyUpdateMode, previousHistoryState) => historyController.claimCurrentHistoryTreeSnapshot(historyUpdateMode, previousHistoryState),
|
|
1506
|
-
commitAppOwnedHistoryStateWrite: (historyUpdateMode, previousHistoryState) => historyController.commitAppOwnedHistoryStateWrite(historyUpdateMode, previousHistoryState)
|
|
1508
|
+
commitAppOwnedHistoryStateWrite: (historyUpdateMode, previousHistoryState) => historyController.commitAppOwnedHistoryStateWrite(historyUpdateMode, previousHistoryState),
|
|
1509
|
+
discardPendingNavigation: () => {
|
|
1510
|
+
if (browserNavigationController.discardPendingNavigation(historyController.readCurrentTreeSnapshot())) navigationAbortCoordinator.abortActive();
|
|
1511
|
+
},
|
|
1512
|
+
flushCommittingNavigationUrl: () => browserNavigationController.flushCommittingNavigationUrl()
|
|
1507
1513
|
});
|
|
1508
1514
|
const handlePopstate = createPopstateRestoreHandler({
|
|
1509
1515
|
getActiveNavigationId: browserNavigationController.getActiveNavigationId.bind(browserNavigationController),
|
|
@@ -79,6 +79,8 @@ export declare class AppBrowserHistoryController {
|
|
|
79
79
|
beginCacheInvalidationGuard(): () => void;
|
|
80
80
|
invalidateRestorableClientState(): void;
|
|
81
81
|
rememberHistoryStateSnapshot(state: AppRouterState): void;
|
|
82
|
+
/** The router state of the most recently committed render, if any. */
|
|
83
|
+
readCurrentTreeSnapshot(): AppRouterState | null;
|
|
82
84
|
isCurrentExternalHistoryTree(historyState: unknown): boolean;
|
|
83
85
|
/** Records the raw/hash history entry that now claims the live tree. */
|
|
84
86
|
claimCurrentHistoryTreeSnapshot(historyUpdateMode: HistoryUpdateMode, previousHistoryState: unknown): void;
|
|
@@ -96,6 +96,9 @@ var AppBrowserHistoryController = class {
|
|
|
96
96
|
this.#treeSnapshotIdPendingFreshState = historyTreeSnapshotId !== null && this.#treeSnapshots.has(historyTreeSnapshotId) ? historyTreeSnapshotId : null;
|
|
97
97
|
}
|
|
98
98
|
rememberHistoryStateSnapshot(state) {
|
|
99
|
+
const previousState = this.readCurrentTreeSnapshot();
|
|
100
|
+
const previousOperation = previousState?.activeOperation;
|
|
101
|
+
if (previousState && previousOperation?.navigationCommitKind === "detached" && state.activeOperation?.navigationCommitKind === "authoritative" && state.activeOperation.navigationId === previousOperation.navigationId) this.#restorableClientState.replaceHistoryStateSnapshots(previousState, state);
|
|
99
102
|
this.#restorableClientState.rememberHistoryStateSnapshot({
|
|
100
103
|
historyIndex: this.#currentHistoryTraversalIndex,
|
|
101
104
|
state
|
|
@@ -109,6 +112,11 @@ var AppBrowserHistoryController = class {
|
|
|
109
112
|
if (previousTreeSnapshotId !== null && previousTreeSnapshotId !== treeSnapshotId && !this.#treeSnapshotClaimCounts.has(previousTreeSnapshotId)) this.#treeSnapshots.delete(previousTreeSnapshotId);
|
|
110
113
|
if (historyTreeSnapshotId !== treeSnapshotId) this.#replaceHistoryState(createHistoryStateWithTreeSnapshotId(this.#readHistoryState(), treeSnapshotId));
|
|
111
114
|
}
|
|
115
|
+
/** The router state of the most recently committed render, if any. */
|
|
116
|
+
readCurrentTreeSnapshot() {
|
|
117
|
+
if (this.#currentTreeSnapshotId === null) return null;
|
|
118
|
+
return this.#treeSnapshots.get(this.#currentTreeSnapshotId) ?? null;
|
|
119
|
+
}
|
|
112
120
|
isCurrentExternalHistoryTree(historyState) {
|
|
113
121
|
const treeSnapshotId = readHistoryStateTreeSnapshotId(historyState);
|
|
114
122
|
return treeSnapshotId !== null && treeSnapshotId === this.#currentTreeSnapshotId;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RSC_FORM_STATE_GLOBAL } from "../client/browser-globals.js";
|
|
1
2
|
import { ReactFormState, hydrateRoot } from "react-dom/client";
|
|
2
3
|
//#region src/server/app-browser-hydration.d.ts
|
|
3
4
|
type HydrateRootOptions = NonNullable<Parameters<typeof hydrateRoot>[2]>;
|
|
@@ -9,7 +10,6 @@ type HydrateRootCaughtErrorHandler = NonNullable<HydrateRootOptions["onCaughtErr
|
|
|
9
10
|
type HydrateRootUncaughtErrorHandler = NonNullable<HydrateRootOptions["onUncaughtError"]>;
|
|
10
11
|
type HydrateRootRecoverableErrorHandler = NonNullable<HydrateRootOptions["onRecoverableError"]>;
|
|
11
12
|
type StartTransition = (action: () => void) => void;
|
|
12
|
-
export declare const RSC_FORM_STATE_GLOBAL = "__VINEXT_RSC_FORM_STATE__";
|
|
13
13
|
type FormStateGlobal = {
|
|
14
14
|
[RSC_FORM_STATE_GLOBAL]?: ReactFormState;
|
|
15
15
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { RSC_FORM_STATE_GLOBAL } from "../client/browser-globals.js";
|
|
1
2
|
//#region src/server/app-browser-hydration.ts
|
|
2
|
-
const RSC_FORM_STATE_GLOBAL = "__VINEXT_RSC_FORM_STATE__";
|
|
3
3
|
function consumeInitialFormState(global) {
|
|
4
4
|
const formState = global["__VINEXT_RSC_FORM_STATE__"] ?? null;
|
|
5
5
|
delete global[RSC_FORM_STATE_GLOBAL];
|
|
@@ -39,4 +39,4 @@ function resolveFetchedHydrationLocation(renderedPathAndSearch, location) {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
//#endregion
|
|
42
|
-
export {
|
|
42
|
+
export { consumeInitialFormState, createVinextHydrateRootOptions, hydrateRootInTransition, resolveFetchedHydrationLocation };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { splitPathnameForRouteMatch } from "../routing/utils.js";
|
|
1
|
+
import { normalizePathnameForRouteMatch, splitPathnameForRouteMatch } from "../routing/utils.js";
|
|
2
2
|
import { stripBasePath } from "../utils/base-path.js";
|
|
3
|
+
import { normalizePath } from "./normalize-path.js";
|
|
3
4
|
import { matchRoutePattern, matchRoutePatternPrefix, matchRoutePatternWithOptionalDynamicSegments } from "../routing/route-pattern.js";
|
|
4
5
|
//#region src/server/app-browser-interception-context.ts
|
|
5
6
|
/**
|
|
@@ -37,9 +38,32 @@ function resolveMiddlewareRewriteNavigationInterceptionContext(options) {
|
|
|
37
38
|
for (const interception of options.routeManifest.segmentGraph.interceptions.values()) {
|
|
38
39
|
if (!matchRoutePatternWithOptionalDynamicSegments(targetParts, interception.targetPatternParts)) continue;
|
|
39
40
|
if (matchRoutePatternPrefix(sourceParts, interception.sourcePatternParts)) return currentPathname;
|
|
40
|
-
if (currentMatchedPathname !== null && matchedSourceParts !== null && matchRoutePatternPrefix(matchedSourceParts, interception.sourcePatternParts)) return currentMatchedPathname;
|
|
41
|
+
if (currentMatchedPathname !== null && matchedSourceParts !== null && matchRoutePatternPrefix(matchedSourceParts, interception.sourcePatternParts)) return encodeMatchedPathname(currentMatchedPathname);
|
|
41
42
|
}
|
|
42
43
|
return null;
|
|
43
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The matched route pathname is the matched URL decoded once per segment, with
|
|
47
|
+
* path delimiters (and literal `%2F`-style text) re-escaped. The server matches
|
|
48
|
+
* the context on its raw segments, so undo that: keep the escaped delimiters and
|
|
49
|
+
* encode every other `%`, then let the URL parser encode the rest (`café`
|
|
50
|
+
* becomes `caf%C3%A9`). An escaped ASCII character comes back unescaped (`%61`
|
|
51
|
+
* as `a`), like Next.js's `Next-Url`, which it builds from the router tree's
|
|
52
|
+
* canonical params; both spellings match the same params. `%252F` is
|
|
53
|
+
* ambiguous, since both a literal `%2F` and a literal `%252F` produce it. That
|
|
54
|
+
* case, and a result that does not reproduce the same matched pathname because
|
|
55
|
+
* the URL parser changed it (stripping a control character, say), navigate
|
|
56
|
+
* without interception instead of naming a different source.
|
|
57
|
+
*/
|
|
58
|
+
function encodeMatchedPathname(pathname) {
|
|
59
|
+
if (/%25(?:2f|23|3f|5c)/i.test(pathname)) return null;
|
|
60
|
+
let encoded;
|
|
61
|
+
try {
|
|
62
|
+
encoded = new URL(pathname.replace(/%(?!(?:25)?(?:2f|23|3f|5c))/gi, "%25"), "http://n").pathname;
|
|
63
|
+
} catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return normalizePath(normalizePathnameForRouteMatch(encoded)) === pathname ? encoded : null;
|
|
67
|
+
}
|
|
44
68
|
//#endregion
|
|
45
69
|
export { resolveManifestNavigationInterceptionContext, resolveMiddlewareRewriteNavigationInterceptionContext };
|
|
@@ -17,7 +17,10 @@ export type PendingBrowserRouterState = {
|
|
|
17
17
|
};
|
|
18
18
|
export type NavigationPayloadOutcome = "committed" | "no-commit" | "hard-navigate";
|
|
19
19
|
type HardNavigationMode = "assign" | "replace";
|
|
20
|
-
type BrowserNavigationCommitEffect = (
|
|
20
|
+
type BrowserNavigationCommitEffect = (options: {
|
|
21
|
+
keepCurrentUrl: boolean;
|
|
22
|
+
releaseSnapshot: boolean;
|
|
23
|
+
}) => void;
|
|
21
24
|
type BrowserNavigationCommitEffectFactory = (options: {
|
|
22
25
|
activeRoutePaths: readonly string[];
|
|
23
26
|
bfcacheIds: Readonly<Record<string, string>>;
|
|
@@ -78,6 +81,8 @@ type BrowserNavigationController = {
|
|
|
78
81
|
attachBrowserRouterState(setter: Dispatch<AppRouterState | Promise<AppRouterState>>, stateRef: BrowserRouterStateRef): () => void;
|
|
79
82
|
beginPendingBrowserRouterState(): PendingBrowserRouterState;
|
|
80
83
|
finalizeNavigation(navId: number, pending: PendingBrowserRouterState | null | undefined): void;
|
|
84
|
+
discardPendingNavigation(visibleState: AppRouterState | null): boolean;
|
|
85
|
+
flushCommittingNavigationUrl(): void;
|
|
81
86
|
restoreHistorySnapshotVisibleState(options: {
|
|
82
87
|
restoreCopiedExternalHistoryEntry?: boolean;
|
|
83
88
|
beforeCommit?: () => void;
|
|
@@ -100,6 +105,7 @@ type BrowserNavigationController = {
|
|
|
100
105
|
* navigation would otherwise be lost.
|
|
101
106
|
*/
|
|
102
107
|
drainPrePaintEffects(renderId: number): void;
|
|
108
|
+
beginNavigationRenderCommit(renderId: number): void;
|
|
103
109
|
commitNavigationRender(renderId: number): void;
|
|
104
110
|
clearCommittedNavigationFailureTargets(renderId: number): void;
|
|
105
111
|
NavigationCommitSignal(this: void, { renderId, children }: {
|