vinext 1.2.0 → 1.3.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 +13 -10
- package/dist/build/client-build-config.d.ts +64 -3
- package/dist/build/client-build-config.js +131 -4
- package/dist/build/client-reference-groups.d.ts +163 -0
- package/dist/build/client-reference-groups.js +534 -0
- package/dist/build/module-dependency-cache.d.ts +31 -0
- package/dist/build/module-dependency-cache.js +51 -1
- package/dist/build/next-client-runtime-manifests.d.ts +10 -1
- package/dist/build/next-client-runtime-manifests.js +19 -4
- package/dist/build/nitro-public-files.d.ts +24 -0
- package/dist/build/nitro-public-files.js +60 -0
- package/dist/build/output-root-externals.d.ts +21 -0
- package/dist/build/output-root-externals.js +40 -0
- package/dist/build/pages-client-assets-module.js +1 -1
- package/dist/build/prerender-paths.js +6 -3
- package/dist/build/prerender.js +1 -1
- package/dist/build/server-actions-encryption-key.d.ts +23 -0
- package/dist/build/server-actions-encryption-key.js +101 -0
- package/dist/build/ssr-manifest.d.ts +3 -0
- package/dist/build/ssr-manifest.js +10 -1
- package/dist/check.js +5 -6
- package/dist/cli-dev-config.js +3 -3
- package/dist/cli.js +1 -1
- package/dist/client/client-rewrite-params.d.ts +9 -0
- package/dist/client/client-rewrite-params.js +20 -0
- package/dist/client/dev-error-overlay.js +2 -1
- package/dist/client/navigation-runtime.d.ts +25 -2
- package/dist/client/navigation-runtime.js +42 -11
- package/dist/client/vinext-next-data.d.ts +0 -1
- package/dist/config/config-matchers.d.ts +15 -40
- package/dist/config/config-matchers.js +195 -262
- package/dist/config/config-source.d.ts +34 -0
- package/dist/config/config-source.js +141 -0
- package/dist/config/header-params.d.ts +29 -0
- package/dist/config/header-params.js +106 -0
- package/dist/config/next-config.d.ts +7 -5
- package/dist/config/next-config.js +120 -7
- package/dist/entries/app-browser-entry.d.ts +14 -1
- package/dist/entries/app-browser-entry.js +26 -36
- package/dist/entries/app-rsc-entry.d.ts +2 -0
- package/dist/entries/app-rsc-entry.js +92 -57
- package/dist/entries/app-rsc-manifest.d.ts +10 -0
- package/dist/entries/app-rsc-manifest.js +20 -1
- package/dist/entries/app-ssr-entry.d.ts +4 -1
- package/dist/entries/app-ssr-entry.js +9 -2
- package/dist/entries/pages-client-entry.d.ts +1 -0
- package/dist/entries/pages-client-entry.js +6 -6
- package/dist/entries/pages-server-entry.js +17 -14
- package/dist/index.d.ts +11 -0
- package/dist/index.js +350 -175
- package/dist/init.d.ts +1 -1
- package/dist/init.js +103 -6
- package/dist/plugins/ast-utils.d.ts +53 -2
- package/dist/plugins/ast-utils.js +90 -2
- package/dist/plugins/cloudflare-dev-module-urls.d.ts +41 -0
- package/dist/plugins/cloudflare-dev-module-urls.js +271 -0
- package/dist/plugins/commonjs-esm-facade.js +2 -2
- package/dist/plugins/css-module-imports.js +13 -20
- package/dist/plugins/dynamic-preload-metadata.js +2 -3
- package/dist/plugins/extensionless-dynamic-import.js +2 -3
- package/dist/plugins/fonts.d.ts +1 -1
- package/dist/plugins/fonts.js +3 -3
- package/dist/plugins/ignore-dynamic-requests.js +2 -3
- package/dist/plugins/import-meta-url.js +3 -4
- package/dist/plugins/instrumentation-client.js +3 -2
- package/dist/plugins/middleware-export-validation.js +2 -3
- package/dist/plugins/og-harfbuzz.js +2 -3
- package/dist/plugins/optimize-imports.d.ts +25 -2
- package/dist/plugins/optimize-imports.js +109 -24
- package/dist/plugins/pages-node-externals.js +2 -3
- package/dist/plugins/remove-console.js +2 -18
- package/dist/plugins/require-condition-resolution.js +3 -3
- package/dist/plugins/require-context.js +2 -3
- package/dist/plugins/rsc-client-reference-loaders.d.ts +45 -1
- package/dist/plugins/rsc-client-reference-loaders.js +336 -18
- package/dist/plugins/strip-server-exports.js +3 -4
- package/dist/plugins/styled-jsx.js +2 -3
- package/dist/plugins/use-cache-callable.d.ts +26 -2
- package/dist/plugins/use-cache-callable.js +101 -36
- package/dist/plugins/worker-image-imports.d.ts +1 -0
- package/dist/plugins/worker-image-imports.js +31 -34
- package/dist/plugins/worker-use-server.js +38 -14
- package/dist/routing/app-route-graph.d.ts +1 -1
- package/dist/routing/browser-route-manifest.d.ts +43 -0
- package/dist/routing/browser-route-manifest.js +195 -0
- package/dist/routing/hashed-route-patterns.d.ts +4 -0
- package/dist/routing/hashed-route-patterns.js +22 -0
- package/dist/routing/optimistic-route-trie.d.ts +27 -0
- package/dist/routing/optimistic-route-trie.js +102 -0
- package/dist/routing/route-validation.d.ts +6 -1
- package/dist/routing/route-validation.js +26 -10
- package/dist/server/api-handler.js +1 -1
- package/dist/server/app-action-forwarding.d.ts +8 -0
- package/dist/server/app-action-forwarding.js +17 -3
- package/dist/server/app-browser-entry.js +149 -62
- package/dist/server/app-browser-error.d.ts +3 -1
- package/dist/server/app-browser-error.js +7 -2
- package/dist/server/app-browser-interception-context.d.ts +2 -2
- package/dist/server/app-browser-interception-context.js +1 -1
- package/dist/server/app-browser-mpa-navigation.d.ts +1 -0
- package/dist/server/app-browser-mpa-navigation.js +6 -5
- package/dist/server/app-browser-navigation-controller.d.ts +17 -6
- package/dist/server/app-browser-navigation-controller.js +88 -26
- package/dist/server/app-browser-prefetch-response.js +2 -2
- package/dist/server/app-browser-state.d.ts +2 -2
- package/dist/server/app-browser-state.js +1 -1
- package/dist/server/app-browser-supplemental-refresh.js +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +4 -4
- package/dist/server/app-client-reference-preloader.d.ts +23 -0
- package/dist/server/app-client-reference-preloader.js +30 -7
- package/dist/server/app-fallback-renderer.js +2 -1
- package/dist/server/app-middleware.d.ts +6 -0
- package/dist/server/app-middleware.js +8 -10
- package/dist/server/app-optimistic-routing.d.ts +8 -10
- package/dist/server/app-optimistic-routing.js +4 -95
- package/dist/server/app-page-boundary-render.js +8 -1
- package/dist/server/app-page-cache-render.js +1 -0
- package/dist/server/app-page-dispatch.js +3 -1
- package/dist/server/app-page-render.js +4 -2
- package/dist/server/app-page-rsc-render-status.d.ts +1 -0
- package/dist/server/app-page-rsc-render-status.js +1 -0
- package/dist/server/app-page-search-params-observation.d.ts +1 -4
- package/dist/server/app-page-search-params-observation.js +8 -10
- package/dist/server/app-page-stream.d.ts +7 -0
- package/dist/server/app-page-stream.js +1 -0
- package/dist/server/app-pages-bridge.d.ts +2 -1
- package/dist/server/app-pages-bridge.js +12 -8
- package/dist/server/app-prerender-endpoints.js +1 -1
- package/dist/server/app-prerender-static-params.js +3 -2
- package/dist/server/app-render-abort-error.d.ts +19 -0
- package/dist/server/app-render-abort-error.js +31 -1
- package/dist/server/app-render-dependency.js +42 -2
- package/dist/server/app-request-stage-independent-entry.js +7 -7
- package/dist/server/app-response-stage-entry.js +5 -5
- package/dist/server/app-route-handler-dispatch.js +3 -1
- package/dist/server/app-route-handler-execution.d.ts +2 -0
- package/dist/server/app-route-handler-execution.js +9 -2
- package/dist/server/app-route-handler-middleware-context.d.ts +2 -1
- package/dist/server/app-route-handler-middleware-context.js +3 -3
- package/dist/server/app-route-handler-response.d.ts +2 -1
- package/dist/server/app-route-handler-response.js +2 -2
- package/dist/server/app-route-handler-runtime.d.ts +2 -0
- package/dist/server/app-route-handler-runtime.js +21 -4
- package/dist/server/app-route-module-loader.js +7 -6
- package/dist/server/app-route-tree.d.ts +20 -0
- package/dist/server/app-route-tree.js +18 -0
- package/dist/server/app-router-entry.js +7 -7
- package/dist/server/app-rsc-cache-busting.d.ts +16 -0
- package/dist/server/app-rsc-cache-busting.js +29 -12
- package/dist/server/app-rsc-combined-handler.js +8 -1
- package/dist/server/app-rsc-errors.d.ts +7 -0
- package/dist/server/app-rsc-errors.js +9 -2
- package/dist/server/app-rsc-handler.d.ts +4 -1
- package/dist/server/app-rsc-handler.js +151 -135
- package/dist/server/app-rsc-request-normalization.js +3 -3
- package/dist/server/app-rsc-response-finalizer.d.ts +5 -0
- package/dist/server/app-rsc-response-finalizer.js +4 -1
- package/dist/server/app-rsc-response-stage.js +5 -3
- package/dist/server/app-rsc-route-matching.d.ts +1 -0
- package/dist/server/app-rsc-route-matching.js +1 -1
- package/dist/server/app-server-action-execution.d.ts +23 -6
- package/dist/server/app-server-action-execution.js +51 -57
- package/dist/server/app-ssr-entry.d.ts +6 -0
- package/dist/server/app-ssr-entry.js +21 -11
- package/dist/server/app-ssr-stream.d.ts +7 -0
- package/dist/server/app-ssr-stream.js +13 -1
- package/dist/server/app-visited-response-cache.js +2 -2
- package/dist/server/config-headers.js +13 -4
- package/dist/server/defer-until-stream-consumed.d.ts +2 -1
- package/dist/server/defer-until-stream-consumed.js +3 -1
- package/dist/server/dev-server.js +1 -1
- package/dist/server/image-optimization.js +1 -0
- package/dist/server/isolate-shared-promise.d.ts +10 -0
- package/dist/server/isolate-shared-promise.js +33 -0
- package/dist/server/isr-cache.js +3 -2
- package/dist/server/metadata-route-response.js +2 -2
- package/dist/server/middleware-matcher-pattern.d.ts +0 -1
- package/dist/server/middleware-matcher-pattern.js +11 -140
- package/dist/server/middleware-matcher.js +5 -6
- package/dist/server/middleware-response-headers.d.ts +31 -0
- package/dist/server/middleware-response-headers.js +57 -1
- package/dist/server/middleware-runtime.js +30 -17
- package/dist/server/navigation-planner.d.ts +2 -2
- package/dist/server/navigation-planner.js +1 -1
- package/dist/server/nitro-public-files-plugin.d.ts +38 -0
- package/dist/server/nitro-public-files-plugin.js +106 -0
- package/dist/server/nitro-public-files.d.ts +21 -0
- package/dist/server/nitro-public-files.js +39 -0
- package/dist/server/open-redirect.d.ts +11 -4
- package/dist/server/open-redirect.js +11 -4
- package/dist/server/pages-api-route.js +2 -2
- package/dist/server/pages-asset-tags.d.ts +5 -0
- package/dist/server/pages-asset-tags.js +9 -2
- package/dist/server/pages-client-assets.d.ts +4 -1
- package/dist/server/pages-data-route.js +2 -1
- package/dist/server/pages-i18n.d.ts +18 -0
- package/dist/server/pages-i18n.js +18 -2
- package/dist/server/pages-node-compat.d.ts +5 -3
- package/dist/server/pages-node-compat.js +35 -16
- package/dist/server/pages-page-data.js +1 -1
- package/dist/server/pages-page-handler.js +1 -1
- package/dist/server/pages-page-response.js +1 -1
- package/dist/server/pages-request-pipeline.d.ts +6 -1
- package/dist/server/pages-request-pipeline.js +35 -39
- package/dist/server/pages-request-stage-entry.js +20 -10
- package/dist/server/pages-response-stage-entry.js +1 -1
- package/dist/server/pages-revalidate.js +3 -2
- package/dist/server/pages-router-entry.js +2 -2
- package/dist/server/prod-server.d.ts +2 -2
- package/dist/server/prod-server.js +74 -36
- package/dist/server/proxy-trust.d.ts +6 -0
- package/dist/server/proxy-trust.js +12 -6
- package/dist/server/request-pipeline.d.ts +5 -0
- package/dist/server/request-pipeline.js +12 -1
- package/dist/server/rsc-stream-hints.d.ts +1 -1
- package/dist/server/rsc-stream-hints.js +21 -3
- package/dist/server/server-reference-loader.js +10 -1
- package/dist/server/static-file-cache.js +15 -3
- package/dist/server/worker-image-optimization.js +19 -6
- package/dist/server/worker-utils.js +1 -1
- package/dist/shims/cache-handler.js +3 -2
- package/dist/shims/cache-request-state.d.ts +40 -3
- package/dist/shims/cache-request-state.js +70 -5
- package/dist/shims/cache-runtime.js +47 -19
- package/dist/shims/cache.d.ts +2 -2
- package/dist/shims/cache.js +17 -8
- package/dist/shims/cdn-purge-routes.d.ts +24 -0
- package/dist/shims/cdn-purge-routes.js +77 -0
- package/dist/shims/dynamic.js +17 -4
- package/dist/shims/form.js +8 -3
- package/dist/shims/head.js +1 -1
- package/dist/shims/headers.js +2 -2
- package/dist/shims/image-props.d.ts +93 -0
- package/dist/shims/image-props.js +323 -0
- package/dist/shims/image.d.ts +4 -18
- package/dist/shims/image.js +4 -319
- package/dist/shims/internal/headers-state.d.ts +7 -0
- package/dist/shims/internal/headers-state.js +14 -2
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +4 -1
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +32 -15
- package/dist/shims/internal/hybrid-client-route-owner.js +9 -8
- package/dist/shims/link-prefetch.js +5 -4
- package/dist/shims/link.js +7 -5
- package/dist/shims/navigation.d.ts +1 -1
- package/dist/shims/navigation.js +21 -10
- package/dist/shims/og.js +35 -10
- package/dist/shims/request-context.d.ts +13 -0
- package/dist/shims/router.js +28 -52
- package/dist/shims/server.d.ts +42 -8
- package/dist/shims/server.js +99 -15
- package/dist/shims/thenable-params.d.ts +6 -1
- package/dist/shims/thenable-params.js +11 -2
- package/dist/shims/unified-request-context.d.ts +5 -0
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/shims/url-utils.d.ts +7 -0
- package/dist/shims/url-utils.js +12 -3
- package/dist/utils/asset-prefix.d.ts +7 -0
- package/dist/utils/asset-prefix.js +10 -1
- package/dist/utils/client-build-manifest.js +12 -5
- package/dist/utils/client-runtime-metadata.d.ts +1 -0
- package/dist/utils/client-runtime-metadata.js +15 -2
- package/dist/utils/domain-locale.js +1 -1
- package/dist/utils/lazy-chunks.d.ts +4 -0
- package/dist/utils/manifest-paths.d.ts +14 -0
- package/dist/utils/manifest-paths.js +22 -1
- package/dist/utils/path-to-regexp.d.ts +21 -0
- package/dist/{server/middleware-path-to-regexp.js → utils/path-to-regexp.js} +14 -11
- package/dist/utils/plugin-react-version.d.ts +15 -0
- package/dist/utils/plugin-react-version.js +64 -0
- package/dist/utils/plugin-rsc-version.d.ts +2 -0
- package/dist/utils/plugin-rsc-version.js +28 -2
- package/dist/utils/public-routes.d.ts +2 -0
- package/dist/utils/public-routes.js +18 -7
- package/dist/utils/react-version.d.ts +7 -0
- package/dist/utils/react-version.js +39 -16
- package/package.json +6 -6
- package/dist/build/nitro-route-rules.d.ts +0 -47
- package/dist/build/nitro-route-rules.js +0 -79
- package/dist/plugins/cache-flight-codec.d.ts +0 -19
- package/dist/plugins/cache-flight-codec.js +0 -68
- package/dist/server/middleware-path-to-regexp.d.ts +0 -13
- package/dist/utils/regex-safety.d.ts +0 -17
- package/dist/utils/regex-safety.js +0 -789
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import { isUnknownRecord } from "../utils/record.js";
|
|
2
|
+
import { decodeBrowserRouteManifest } from "../routing/browser-route-manifest.js";
|
|
2
3
|
import { NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION } from "./browser-globals.js";
|
|
3
4
|
//#region src/client/navigation-runtime.ts
|
|
4
5
|
const NAVIGATION_RUNTIME_KEY = Symbol.for(NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION);
|
|
5
6
|
const ROUTE_MANIFEST_SEGMENT_GRAPH_MAP_KEYS = [
|
|
6
|
-
"boundaries",
|
|
7
|
-
"defaults",
|
|
8
7
|
"interceptions",
|
|
9
8
|
"interceptionsBySlotId",
|
|
10
9
|
"layouts",
|
|
11
|
-
"pages",
|
|
12
10
|
"rootBoundaries",
|
|
13
|
-
"routeHandlers",
|
|
14
11
|
"routes",
|
|
15
|
-
"slotBindings"
|
|
16
|
-
"slots",
|
|
17
|
-
"templates"
|
|
12
|
+
"slotBindings"
|
|
18
13
|
];
|
|
19
14
|
function createNavigationRuntime() {
|
|
20
15
|
return {
|
|
@@ -31,7 +26,7 @@ function readRuntimeWindow() {
|
|
|
31
26
|
}
|
|
32
27
|
function isNavigationRuntimeFunctions(value) {
|
|
33
28
|
if (!isUnknownRecord(value)) return false;
|
|
34
|
-
return isOptionalRuntimeFunction(Reflect.get(value, "clearNavigationCaches")) && isOptionalRuntimeFunction(Reflect.get(value, "commitHashNavigation")) && isOptionalRuntimeFunction(Reflect.get(value, "navigateExternal")) && isOptionalRuntimeFunction(Reflect.get(value, "navigate")) && isOptionalRuntimeFunction(Reflect.get(value, "getPrefetchRouterState")) && isOptionalRuntimeFunction(Reflect.get(value, "notifyLinkNavigationStart")) && isOptionalRuntimeFunction(Reflect.get(value, "pingVisibleLinks")) && isOptionalRuntimeFunction(Reflect.get(value, "preparePrefetchResponse")) && isOptionalRuntimeFunction(Reflect.get(value, "claimCurrentHistoryTreeSnapshot")) && isOptionalRuntimeFunction(Reflect.get(value, "commitAppOwnedHistoryStateWrite")) && isOptionalRuntimeFunction(Reflect.get(value, "discardPendingNavigation")) && isOptionalRuntimeFunction(Reflect.get(value, "flushCommittingNavigationUrl"));
|
|
29
|
+
return isOptionalRuntimeFunction(Reflect.get(value, "clearNavigationCaches")) && isOptionalRuntimeFunction(Reflect.get(value, "commitHashNavigation")) && isOptionalRuntimeFunction(Reflect.get(value, "navigateExternal")) && isOptionalRuntimeFunction(Reflect.get(value, "navigate")) && isOptionalRuntimeFunction(Reflect.get(value, "getPrefetchRouterState")) && isOptionalRuntimeFunction(Reflect.get(value, "notifyLinkNavigationStart")) && isOptionalRuntimeFunction(Reflect.get(value, "pingVisibleLinks")) && isOptionalRuntimeFunction(Reflect.get(value, "preparePrefetchResponse")) && isOptionalRuntimeFunction(Reflect.get(value, "claimCurrentHistoryTreeSnapshot")) && isOptionalRuntimeFunction(Reflect.get(value, "commitAppOwnedHistoryStateWrite")) && isOptionalRuntimeFunction(Reflect.get(value, "discardPendingNavigation")) && isOptionalRuntimeFunction(Reflect.get(value, "flushCommittingNavigationUrl")) && isOptionalRuntimeFunction(Reflect.get(value, "loadRouteManifest"));
|
|
35
30
|
}
|
|
36
31
|
function isNavigationRuntimeRscChunk(value) {
|
|
37
32
|
if (typeof value === "string") return true;
|
|
@@ -49,6 +44,7 @@ function isNavigationRuntimeParams(value) {
|
|
|
49
44
|
}
|
|
50
45
|
function isNavigationRuntimeRscBootstrap(value) {
|
|
51
46
|
if (!isUnknownRecord(value)) return false;
|
|
47
|
+
const compatibilityId = Reflect.get(value, "compatibilityId");
|
|
52
48
|
const done = Reflect.get(value, "done");
|
|
53
49
|
const dynamicStaleTimeSeconds = Reflect.get(value, "dynamicStaleTimeSeconds");
|
|
54
50
|
const initialCacheKind = Reflect.get(value, "initialCacheKind");
|
|
@@ -58,7 +54,7 @@ function isNavigationRuntimeRscBootstrap(value) {
|
|
|
58
54
|
const renderedSearch = Reflect.get(value, "renderedSearch");
|
|
59
55
|
const rsc = Reflect.get(value, "rsc");
|
|
60
56
|
const staleTimeSeconds = Reflect.get(value, "staleTimeSeconds");
|
|
61
|
-
return (done === void 0 || typeof done === "boolean") && isOptionalStaleTimeSeconds(dynamicStaleTimeSeconds) && (initialCacheKind === void 0 || initialCacheKind === "dynamic" || initialCacheKind === "static") && (searchParamsFromBrowser === void 0 || typeof searchParamsFromBrowser === "boolean") && (nav === void 0 || isNavigationRuntimeSnapshot(nav)) && (params === void 0 || isNavigationRuntimeParams(params)) && (renderedSearch === void 0 || typeof renderedSearch === "string") && Array.isArray(rsc) && rsc.every(isNavigationRuntimeRscChunk) && isOptionalStaleTimeSeconds(staleTimeSeconds);
|
|
57
|
+
return (compatibilityId === void 0 || typeof compatibilityId === "string") && (done === void 0 || typeof done === "boolean") && isOptionalStaleTimeSeconds(dynamicStaleTimeSeconds) && (initialCacheKind === void 0 || initialCacheKind === "dynamic" || initialCacheKind === "static") && (searchParamsFromBrowser === void 0 || typeof searchParamsFromBrowser === "boolean") && (nav === void 0 || isNavigationRuntimeSnapshot(nav)) && (params === void 0 || isNavigationRuntimeParams(params)) && (renderedSearch === void 0 || typeof renderedSearch === "string") && Array.isArray(rsc) && rsc.every(isNavigationRuntimeRscChunk) && isOptionalStaleTimeSeconds(staleTimeSeconds);
|
|
62
58
|
}
|
|
63
59
|
function isOptionalStaleTimeSeconds(value) {
|
|
64
60
|
return value === void 0 || typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
@@ -71,7 +67,7 @@ function isNullableString(value) {
|
|
|
71
67
|
}
|
|
72
68
|
function isNavigationRuntimeInterception(value) {
|
|
73
69
|
if (!isUnknownRecord(value)) return false;
|
|
74
|
-
return typeof value.id === "string" &&
|
|
70
|
+
return typeof value.id === "string" && isReadonlyStringArray(value.sourcePatternParts) && isReadonlyStringArray(value.targetPatternParts) && typeof value.slotId === "string" && isNullableString(value.ownerLayoutId) && isNullableString(value.targetRouteId);
|
|
75
71
|
}
|
|
76
72
|
function isNavigationRuntimeInterceptionArray(value) {
|
|
77
73
|
return Array.isArray(value) && value.every(isNavigationRuntimeInterception);
|
|
@@ -150,6 +146,41 @@ function ensureNavigationRuntimeRscBootstrapForRuntime(runtime) {
|
|
|
150
146
|
}
|
|
151
147
|
return rscBootstrap;
|
|
152
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* The browser entry does not inline the RouteManifest: the manifest grows with
|
|
151
|
+
* every route of the app, so it lives in its own chunk that loads alongside
|
|
152
|
+
* hydration. The navigation planner needs it to classify commits (root layout
|
|
153
|
+
* changes, intercepted payloads, preserved slots), so navigations, commits and
|
|
154
|
+
* prefetches that read it wait for this load first.
|
|
155
|
+
*/
|
|
156
|
+
function createNavigationRuntimeRouteManifestLoader(importManifest) {
|
|
157
|
+
let loaded = false;
|
|
158
|
+
let reportedFailure = false;
|
|
159
|
+
let pending = null;
|
|
160
|
+
return () => {
|
|
161
|
+
if (loaded) return null;
|
|
162
|
+
pending ??= importManifest().then(({ default: wire }) => {
|
|
163
|
+
registerNavigationRuntimeBootstrap({ routeManifest: wire === null ? null : decodeBrowserRouteManifest(wire) });
|
|
164
|
+
loaded = true;
|
|
165
|
+
return true;
|
|
166
|
+
}).catch((error) => {
|
|
167
|
+
pending = null;
|
|
168
|
+
if (!reportedFailure) {
|
|
169
|
+
reportedFailure = true;
|
|
170
|
+
console.error("[vinext] Failed to load the App Router route manifest:", error);
|
|
171
|
+
}
|
|
172
|
+
return false;
|
|
173
|
+
});
|
|
174
|
+
return pending;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Starts or joins the RouteManifest load. Resolves whether it loaded, and
|
|
179
|
+
* returns null once it has (or when no App Router runtime registered a loader).
|
|
180
|
+
*/
|
|
181
|
+
function loadNavigationRuntimeRouteManifest() {
|
|
182
|
+
return getNavigationRuntime()?.functions.loadRouteManifest?.() ?? null;
|
|
183
|
+
}
|
|
153
184
|
function hasAppNavigationRuntime() {
|
|
154
185
|
return typeof getNavigationRuntime()?.functions.navigate === "function";
|
|
155
186
|
}
|
|
@@ -169,4 +200,4 @@ function hasAppNavigationRuntimeBootstrap() {
|
|
|
169
200
|
return getNavigationRuntime() !== null;
|
|
170
201
|
}
|
|
171
202
|
//#endregion
|
|
172
|
-
export { NAVIGATION_RUNTIME_KEY, ensureNavigationRuntimeRscBootstrap, getNavigationRuntime, hasAppNavigationRuntime, hasAppNavigationRuntimeBootstrap, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions };
|
|
203
|
+
export { NAVIGATION_RUNTIME_KEY, createNavigationRuntimeRouteManifestLoader, ensureNavigationRuntimeRscBootstrap, getNavigationRuntime, hasAppNavigationRuntime, hasAppNavigationRuntimeBootstrap, loadNavigationRuntimeRouteManifest, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions };
|
|
@@ -2,34 +2,8 @@ import { HasCondition, NextHeader, NextI18nConfig, NextRedirect, NextRewrite } f
|
|
|
2
2
|
import { RequestContext, normalizeHost, parseCookies, requestContextFromRequest } from "./request-context.js";
|
|
3
3
|
import { RedirectDestinationQueryPart } from "./destination-params.js";
|
|
4
4
|
import { isExternalUrl } from "../utils/external-url.js";
|
|
5
|
+
import { configSourceError, matchConfigPattern } from "./config-source.js";
|
|
5
6
|
//#region src/config/config-matchers.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Detect regex patterns vulnerable to catastrophic backtracking (ReDoS).
|
|
8
|
-
*
|
|
9
|
-
* Uses the same deterministic structural analysis as middleware matcher
|
|
10
|
-
* validation. Nested bounded repetition is accepted only when its repeated
|
|
11
|
-
* language has fixed width and unambiguous branches; a fixed outer count can
|
|
12
|
-
* otherwise still cause polynomially catastrophic backtracking on long near
|
|
13
|
-
* misses.
|
|
14
|
-
*
|
|
15
|
-
* Returns true if the pattern appears safe, false if it's potentially dangerous.
|
|
16
|
-
*/
|
|
17
|
-
export declare function isSafeRegex(pattern: string, flags?: string): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Compile a regex pattern safely. Returns the compiled RegExp or null if the
|
|
20
|
-
* pattern is invalid or vulnerable to ReDoS.
|
|
21
|
-
*
|
|
22
|
-
* Logs a warning when a pattern is rejected so developers can fix their config.
|
|
23
|
-
*/
|
|
24
|
-
export declare function safeRegExp(pattern: string, flags?: string): RegExp | null;
|
|
25
|
-
/**
|
|
26
|
-
* Convert a Next.js header/rewrite/redirect source pattern into a regex string.
|
|
27
|
-
*
|
|
28
|
-
* Regex groups in the source (e.g. `(\d+)`) are extracted first, the remaining
|
|
29
|
-
* text is escaped/converted in a **single pass** (avoiding chained `.replace()`
|
|
30
|
-
* which CodeQL flags as incomplete sanitization), then groups are restored.
|
|
31
|
-
*/
|
|
32
|
-
export declare function escapeHeaderSource(source: string): string;
|
|
33
7
|
/**
|
|
34
8
|
* basePath gating state passed alongside the pathname to every matcher.
|
|
35
9
|
*
|
|
@@ -75,7 +49,6 @@ export declare function applyMiddlewareRequestHeaders(middlewareHeaders: Record<
|
|
|
75
49
|
postMwReqCtx: RequestContext;
|
|
76
50
|
};
|
|
77
51
|
export declare function checkHasConditions(has: HasCondition[] | undefined, missing: HasCondition[] | undefined, ctx: RequestContext): boolean;
|
|
78
|
-
export declare function matchConfigPattern(pathname: string, pattern: string): Record<string, string> | null;
|
|
79
52
|
/**
|
|
80
53
|
* A matched config redirect. `destinationQuery` holds the destination query's
|
|
81
54
|
* parts, split before params were substituted, for merging the request query.
|
|
@@ -220,17 +193,19 @@ export declare function matchHeaders(pathname: string, headers: NextHeader[], ct
|
|
|
220
193
|
* starts with `/:nextInternalLocale(en|sv|nl)` so that locale-prefixed
|
|
221
194
|
* URLs match. For redirects only, a second variant prefixed with
|
|
222
195
|
* `/${defaultLocale}` is also emitted, matching Next.js exactly.
|
|
223
|
-
* -
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
196
|
+
* - Headers get only that variant, exactly like Next.js. Every header
|
|
197
|
+
* matcher caller splices the (domain-aware) default locale into
|
|
198
|
+
* unprefixed request paths first (`normalizeDefaultLocalePathname`,
|
|
199
|
+
* mirroring `resolve-routes.ts`), so `/about` is matched as `/en/about`.
|
|
200
|
+
* `/_next/*` paths are left unprefixed and therefore only match
|
|
201
|
+
* `locale: false` rules, as in Next.js.
|
|
202
|
+
* - **Vinext divergence (redirects/rewrites only)**: we ALSO retain the
|
|
203
|
+
* original (unprefixed) source, appended LAST so the locale-aware
|
|
204
|
+
* variants win when both forms could match. Their callers normalise
|
|
205
|
+
* default-locale paths too, so this is a legacy fallback. Headers never
|
|
206
|
+
* get it: it would apply rules Next.js skips (`/((?!api).*)` would match
|
|
207
|
+
* `/fr/api/x` as `fr/api/x`), and default-locale requests would match
|
|
208
|
+
* both variants, appending additive headers such as `Set-Cookie` twice.
|
|
234
209
|
*
|
|
235
210
|
* Destinations that are local (start with `/`) are similarly rewritten with
|
|
236
211
|
* `/:nextInternalLocale` for the locale-capture variant so the locale
|
|
@@ -243,4 +218,4 @@ export declare function applyLocaleToRoutes<T extends NextRedirect | NextRewrite
|
|
|
243
218
|
trailingSlash?: boolean;
|
|
244
219
|
}): T[];
|
|
245
220
|
//#endregion
|
|
246
|
-
export { type RequestContext, isExternalUrl, normalizeHost, parseCookies, requestContextFromRequest };
|
|
221
|
+
export { type RequestContext, configSourceError, isExternalUrl, matchConfigPattern, normalizeHost, parseCookies, requestContextFromRequest };
|