vinext 1.0.0-beta.5 → 1.0.0-beta.7
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 +20 -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-paths.js +3 -4
- package/dist/build/prerender-phase.d.ts +15 -0
- package/dist/build/prerender-phase.js +37 -0
- package/dist/build/prerender-server-entry.js +3 -3
- package/dist/build/prerender-server-pool.js +2 -0
- package/dist/build/prerender.d.ts +7 -3
- package/dist/build/prerender.js +103 -21
- package/dist/build/report.d.ts +1 -1
- package/dist/build/route-classification-manifest.d.ts +1 -1
- package/dist/build/run-prerender.js +9 -6
- 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/client/vinext-next-data.d.ts +2 -0
- package/dist/config/next-config.js +24 -7
- package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +808 -0
- package/dist/entries/app-browser-entry.d.ts +1 -1
- package/dist/entries/app-browser-entry.js +2 -1
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +136 -8
- package/dist/entries/pages-client-entry.d.ts +1 -1
- package/dist/entries/pages-client-entry.js +8 -3
- package/dist/entries/pages-server-entry.d.ts +1 -1
- package/dist/index.js +190 -181
- 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 +309 -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.d.ts +23 -0
- package/dist/plugins/pages-node-externals.js +179 -0
- 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.d.ts +24 -0
- package/dist/plugins/transitive-externals.js +107 -0
- package/dist/plugins/typeof-window.d.ts +10 -5
- package/dist/plugins/typeof-window.js +142 -24
- package/dist/plugins/use-cache-callable.d.ts +12 -0
- package/dist/plugins/use-cache-callable.js +199 -0
- 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/api-handler.js +1 -1
- 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 +236 -51
- 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-boundary-render.js +4 -7
- package/dist/server/app-page-cache-finalizer.d.ts +4 -1
- package/dist/server/app-page-cache-finalizer.js +11 -15
- package/dist/server/app-page-cache-render.d.ts +1 -0
- package/dist/server/app-page-cache-render.js +3 -1
- package/dist/server/app-page-cache.d.ts +4 -2
- package/dist/server/app-page-cache.js +13 -6
- package/dist/server/app-page-dispatch.d.ts +4 -1
- package/dist/server/app-page-dispatch.js +13 -3
- 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-execution.js +19 -6
- 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 +10 -4
- package/dist/server/app-page-request.d.ts +2 -33
- package/dist/server/app-page-request.js +1 -27
- package/dist/server/app-page-response.js +7 -14
- 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-page-stream.d.ts +12 -0
- package/dist/server/app-page-stream.js +10 -3
- 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-prerender-endpoints.d.ts +1 -0
- package/dist/server/app-prerender-endpoints.js +12 -0
- package/dist/server/app-response-header-provenance.d.ts +13 -0
- package/dist/server/app-response-header-provenance.js +26 -0
- package/dist/server/app-route-handler-cache.d.ts +1 -0
- package/dist/server/app-route-handler-cache.js +2 -2
- package/dist/server/app-route-handler-dispatch.js +8 -3
- package/dist/server/app-route-handler-execution.js +11 -7
- package/dist/server/app-route-handler-policy.d.ts +1 -0
- package/dist/server/app-route-handler-response.d.ts +3 -1
- package/dist/server/app-route-handler-response.js +15 -5
- package/dist/server/app-route-handler-runtime.d.ts +1 -1
- package/dist/server/app-route-handler-runtime.js +218 -84
- package/dist/server/app-route-request-built-ins.d.ts +16 -0
- package/dist/server/app-route-request-built-ins.js +41 -0
- package/dist/server/app-router-entry.js +2 -2
- package/dist/server/app-rsc-cache-busting.d.ts +4 -1
- package/dist/server/app-rsc-cache-busting.js +51 -17
- package/dist/server/app-rsc-handler.d.ts +6 -2
- package/dist/server/app-rsc-handler.js +68 -18
- 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-response-finalizer.d.ts +2 -0
- package/dist/server/app-rsc-response-finalizer.js +4 -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-rsc-state-fingerprint.d.ts +14 -0
- package/dist/server/app-rsc-state-fingerprint.js +13 -0
- package/dist/server/app-server-action-execution.d.ts +3 -0
- package/dist/server/app-server-action-execution.js +79 -4
- package/dist/server/app-ssr-entry.d.ts +6 -0
- package/dist/server/app-ssr-entry.js +21 -9
- package/dist/server/app-ssr-stream.d.ts +7 -2
- package/dist/server/app-ssr-stream.js +30 -6
- package/dist/server/app-visited-response-cache.d.ts +6 -1
- package/dist/server/app-visited-response-cache.js +18 -2
- package/dist/server/cache-control.d.ts +11 -7
- package/dist/server/cache-control.js +23 -12
- package/dist/server/config-headers.d.ts +4 -0
- package/dist/server/config-headers.js +19 -3
- package/dist/server/dev-route-files.js +2 -5
- package/dist/server/dev-server.d.ts +5 -13
- package/dist/server/dev-server.js +49 -32
- 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 +11 -1
- package/dist/server/headers.js +13 -2
- package/dist/server/http-error-responses.d.ts +1 -1
- package/dist/server/http-error-responses.js +7 -2
- package/dist/server/isr-cache.d.ts +6 -14
- package/dist/server/isr-cache.js +6 -27
- package/dist/server/metadata-route-build-data.js +1 -1
- package/dist/server/metadata-route-cache-policy.d.ts +6 -0
- package/dist/server/metadata-route-cache-policy.js +6 -0
- package/dist/server/metadata-route-response.d.ts +26 -1
- package/dist/server/metadata-route-response.js +219 -6
- package/dist/server/metadata-routes.js +1 -1
- package/dist/server/middleware-response-headers.js +4 -2
- 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-dev-hydration.js +11 -4
- package/dist/server/pages-node-compat.d.ts +1 -4
- package/dist/server/pages-node-compat.js +1 -7
- package/dist/server/pages-page-handler.d.ts +3 -1
- package/dist/server/pages-page-handler.js +4 -15
- package/dist/server/pages-page-response.js +10 -5
- package/dist/server/pages-readiness.js +4 -4
- package/dist/server/prerender-cache-life-header.d.ts +11 -0
- package/dist/server/prerender-cache-life-header.js +18 -0
- package/dist/server/prerender-manifest.d.ts +5 -2
- package/dist/server/prerender-manifest.js +4 -1
- 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 +9 -11
- package/dist/server/request-pipeline.js +2 -0
- package/dist/server/seed-cache.d.ts +4 -1
- package/dist/server/seed-cache.js +28 -4
- package/dist/server/worker-utils.js +1 -1
- package/dist/shims/cache-callable-runtime.d.ts +11 -0
- package/dist/shims/cache-callable-runtime.js +30 -0
- package/dist/shims/cache-request-state.d.ts +4 -1
- package/dist/shims/cache-request-state.js +6 -1
- package/dist/shims/cache-runtime.d.ts +6 -1
- package/dist/shims/cache-runtime.js +137 -30
- package/dist/shims/cache.d.ts +2 -2
- package/dist/shims/cache.js +2 -2
- package/dist/shims/cdn-cache.d.ts +18 -6
- package/dist/shims/cdn-cache.js +4 -2
- 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 +27 -7
- package/dist/shims/font-local.js +3 -3
- package/dist/shims/head.d.ts +16 -1
- package/dist/shims/head.js +70 -8
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +8 -7
- package/dist/shims/internal/app-route-prefetch-policy.js +13 -6
- package/dist/shims/internal/pages-data-target.d.ts +1 -1
- package/dist/shims/internal/pages-data-target.js +18 -5
- package/dist/shims/link.js +50 -55
- package/dist/shims/navigation-context-state.d.ts +4 -0
- package/dist/shims/navigation.d.ts +39 -3
- package/dist/shims/navigation.js +139 -18
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/root-params.d.ts +3 -1
- package/dist/shims/root-params.js +7 -1
- package/dist/shims/router.js +252 -80
- package/dist/shims/server.js +2 -1
- 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/encode-cache-tag.d.ts +1 -1
- package/dist/utils/encode-cache-tag.js +1 -1
- 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/prerender-output-paths.d.ts +3 -1
- package/dist/utils/prerender-output-paths.js +6 -1
- package/package.json +5 -4
|
@@ -3,9 +3,11 @@ import { findDir } from "../utils/project.js";
|
|
|
3
3
|
import { apiRouter, pagesRouter } from "../routing/pages-router.js";
|
|
4
4
|
import { appRouter } from "../routing/app-router.js";
|
|
5
5
|
import { scanMetadataFiles } from "../server/metadata-routes.js";
|
|
6
|
+
import { PHASE_PRODUCTION_BUILD } from "../shims/constants.js";
|
|
6
7
|
import { loadNextConfig, resolveNextConfig } from "../config/next-config.js";
|
|
7
8
|
import { readPrerenderSecret } from "./server-manifest.js";
|
|
8
9
|
import { rememberCurrentServerEntryImportMtime, startProdServer } from "../server/prod-server.js";
|
|
10
|
+
import { enterPrerenderPhase } from "./prerender-phase.js";
|
|
9
11
|
import { prerenderApp, prerenderPages, writePrerenderIndex } from "./prerender.js";
|
|
10
12
|
import { injectPregeneratedConcretePaths } from "./inject-pregenerated-paths.js";
|
|
11
13
|
import fs from "node:fs";
|
|
@@ -104,12 +106,10 @@ async function runPrerender(options) {
|
|
|
104
106
|
const appDir = findDir(root, "app", "src/app");
|
|
105
107
|
const pagesDir = findDir(root, "pages", "src/pages");
|
|
106
108
|
if (!appDir && !pagesDir) return null;
|
|
107
|
-
const previousPrerenderFlag = process.env.VINEXT_PRERENDER;
|
|
108
|
-
process.env.VINEXT_PRERENDER = "1";
|
|
109
109
|
const manifestDir = path.join(root, "dist", "server");
|
|
110
110
|
const rscBundlePath = options.rscBundlePath ?? path.join(root, "dist", "server", "index.js");
|
|
111
111
|
const serverDir = path.dirname(rscBundlePath);
|
|
112
|
-
const config = options.nextConfig ? { ...options.nextConfig } : { ...await resolveNextConfig(await loadNextConfig(root), root) };
|
|
112
|
+
const config = options.nextConfig ? { ...options.nextConfig } : { ...await resolveNextConfig(await loadNextConfig(root, PHASE_PRODUCTION_BUILD), root) };
|
|
113
113
|
const builtBuildId = readBuiltBuildId(serverDir);
|
|
114
114
|
if (builtBuildId) config.buildId = builtBuildId;
|
|
115
115
|
const mode = config.output === "export" ? "export" : "default";
|
|
@@ -121,6 +121,7 @@ async function runPrerender(options) {
|
|
|
121
121
|
const outDir = mode === "export" ? path.join(root, "dist", "client") : path.join(root, "dist", "server", "prerendered-routes");
|
|
122
122
|
let sharedProdServer = null;
|
|
123
123
|
let sharedPrerenderSecret;
|
|
124
|
+
const restorePrerenderPhase = enterPrerenderPhase();
|
|
124
125
|
try {
|
|
125
126
|
if (appDir && pagesDir) {
|
|
126
127
|
sharedProdServer = await startProdServer({
|
|
@@ -187,9 +188,11 @@ async function runPrerender(options) {
|
|
|
187
188
|
if (result.outputFiles) allOutputFiles.push(...result.outputFiles);
|
|
188
189
|
}
|
|
189
190
|
} finally {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
try {
|
|
192
|
+
if (sharedProdServer) await new Promise((resolve) => sharedProdServer.server.close(() => resolve()));
|
|
193
|
+
} finally {
|
|
194
|
+
restorePrerenderPhase();
|
|
195
|
+
}
|
|
193
196
|
}
|
|
194
197
|
if (allRoutes.length === 0) {
|
|
195
198
|
progress.finish(0, 0, 0);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AppRoute } from "../routing/app-route-graph.js";
|
|
1
2
|
import { ResolvedNextConfig } from "../config/next-config.js";
|
|
2
3
|
import { Route } from "../routing/pages-router.js";
|
|
3
|
-
import { AppRoute } from "../routing/app-route-graph.js";
|
|
4
4
|
//#region src/build/static-export.d.ts
|
|
5
5
|
type StaticExportOptions = {
|
|
6
6
|
/**
|
|
@@ -22,6 +22,7 @@ function clearAppNavigationFailureTarget(target) {
|
|
|
22
22
|
}
|
|
23
23
|
function handleAppNavigationFailure(error) {
|
|
24
24
|
if (!process.env.__NEXT_APP_NAV_FAIL_HANDLING || typeof window === "undefined") return false;
|
|
25
|
+
if (error !== null && typeof error === "object" && "handled" in error && error.handled === true) return false;
|
|
25
26
|
const pendingUrl = getPendingUrl();
|
|
26
27
|
if (pendingUrl === null || pendingUrl.href === window.location.href) return false;
|
|
27
28
|
console.error("Error occurred during navigation, falling back to hard navigation", error);
|
|
@@ -10,6 +10,7 @@ type NavigationRuntimeRscBootstrap = {
|
|
|
10
10
|
done?: boolean;
|
|
11
11
|
dynamicStaleTimeSeconds?: number;
|
|
12
12
|
initialCacheKind?: "dynamic" | "static";
|
|
13
|
+
searchParamsFromBrowser?: boolean;
|
|
13
14
|
nav?: NavigationRuntimeSnapshot;
|
|
14
15
|
params?: Record<string, string | string[]>;
|
|
15
16
|
rsc: NavigationRuntimeRscChunk[];
|
|
@@ -32,7 +33,7 @@ type NavigationRuntimeTraversalIntent = {
|
|
|
32
33
|
historyState: unknown;
|
|
33
34
|
targetHistoryIndex: number | null;
|
|
34
35
|
};
|
|
35
|
-
type NavigationRuntimeNavigate = (href: string, redirectDepth?: number, navigationKind?: NavigationRuntimeKind, historyUpdateMode?: NavigationRuntimeHistoryUpdateMode, previousNextUrlOverride?: string | null, programmaticTransition?: boolean, traversalIntent?: NavigationRuntimeTraversalIntent, scrollIntent?: AppRouterScrollIntent | null, visibleCommitMode?: NavigationRuntimeVisibleCommitMode) => Promise<void>;
|
|
36
|
+
type NavigationRuntimeNavigate = (href: string, redirectDepth?: number, navigationKind?: NavigationRuntimeKind, historyUpdateMode?: NavigationRuntimeHistoryUpdateMode, previousNextUrlOverride?: string | null, programmaticTransition?: boolean, traversalIntent?: NavigationRuntimeTraversalIntent, scrollIntent?: AppRouterScrollIntent | null, visibleCommitMode?: NavigationRuntimeVisibleCommitMode, bypassNavigationCache?: boolean) => Promise<void>;
|
|
36
37
|
type NavigationRuntimeFunctions = {
|
|
37
38
|
clearNavigationCaches?: () => void;
|
|
38
39
|
commitHashNavigation?: (href: string, historyUpdateMode: NavigationRuntimeHistoryUpdateMode, scroll: boolean) => void;
|
|
@@ -49,6 +50,8 @@ type NavigationRuntimeFunctions = {
|
|
|
49
50
|
notifyLinkNavigationStart?: () => void;
|
|
50
51
|
pingVisibleLinks?: () => void;
|
|
51
52
|
preparePrefetchResponse?: (response: Response) => Promise<unknown>;
|
|
53
|
+
claimCurrentHistoryTreeSnapshot?: (historyUpdateMode: NavigationRuntimeHistoryUpdateMode, previousHistoryState: unknown) => void;
|
|
54
|
+
commitAppOwnedHistoryStateWrite?: (historyUpdateMode: NavigationRuntimeHistoryUpdateMode, previousHistoryState: unknown) => void;
|
|
52
55
|
};
|
|
53
56
|
type NavigationRuntimeBootstrap = {
|
|
54
57
|
routeManifest: RouteManifest | null;
|
|
@@ -64,7 +67,6 @@ declare function getNavigationRuntime(): NavigationRuntime | null;
|
|
|
64
67
|
declare function registerNavigationRuntimeBootstrap(bootstrap: Partial<NavigationRuntimeBootstrap>): NavigationRuntime;
|
|
65
68
|
declare function registerNavigationRuntimeFunctions(functions: Partial<NavigationRuntimeFunctions>): NavigationRuntime;
|
|
66
69
|
declare function ensureNavigationRuntimeRscBootstrap(): NavigationRuntimeRscBootstrap;
|
|
67
|
-
declare function subscribeNavigationRuntimeRscChunk(chunk: NavigationRuntimeRscChunk): NavigationRuntime;
|
|
68
70
|
declare function hasAppNavigationRuntime(): boolean;
|
|
69
71
|
/**
|
|
70
72
|
* True when the App Router has installed its runtime bootstrap on `window`,
|
|
@@ -80,4 +82,4 @@ declare function hasAppNavigationRuntime(): boolean;
|
|
|
80
82
|
*/
|
|
81
83
|
declare function hasAppNavigationRuntimeBootstrap(): boolean;
|
|
82
84
|
//#endregion
|
|
83
|
-
export { NAVIGATION_RUNTIME_KEY, NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION, NavigationRuntime, NavigationRuntimeBootstrap, NavigationRuntimeFunctions, NavigationRuntimeNavigate, NavigationRuntimeRscBootstrap, NavigationRuntimeRscChunk,
|
|
85
|
+
export { NAVIGATION_RUNTIME_KEY, NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION, NavigationRuntime, NavigationRuntimeBootstrap, NavigationRuntimeFunctions, NavigationRuntimeNavigate, NavigationRuntimeRscBootstrap, NavigationRuntimeRscChunk, NavigationRuntimeVisibleCommitMode, ensureNavigationRuntimeRscBootstrap, getNavigationRuntime, hasAppNavigationRuntime, hasAppNavigationRuntimeBootstrap, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions };
|
|
@@ -31,7 +31,7 @@ function readRuntimeWindow() {
|
|
|
31
31
|
}
|
|
32
32
|
function isNavigationRuntimeFunctions(value) {
|
|
33
33
|
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"));
|
|
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"));
|
|
35
35
|
}
|
|
36
36
|
function isNavigationRuntimeRscChunk(value) {
|
|
37
37
|
if (typeof value === "string") return true;
|
|
@@ -52,11 +52,12 @@ function isNavigationRuntimeRscBootstrap(value) {
|
|
|
52
52
|
const done = Reflect.get(value, "done");
|
|
53
53
|
const dynamicStaleTimeSeconds = Reflect.get(value, "dynamicStaleTimeSeconds");
|
|
54
54
|
const initialCacheKind = Reflect.get(value, "initialCacheKind");
|
|
55
|
+
const searchParamsFromBrowser = Reflect.get(value, "searchParamsFromBrowser");
|
|
55
56
|
const nav = Reflect.get(value, "nav");
|
|
56
57
|
const params = Reflect.get(value, "params");
|
|
57
58
|
const rsc = Reflect.get(value, "rsc");
|
|
58
59
|
const staleTimeSeconds = Reflect.get(value, "staleTimeSeconds");
|
|
59
|
-
return (done === void 0 || typeof done === "boolean") && isOptionalStaleTimeSeconds(dynamicStaleTimeSeconds) && (initialCacheKind === void 0 || initialCacheKind === "dynamic" || initialCacheKind === "static") && (nav === void 0 || isNavigationRuntimeSnapshot(nav)) && (params === void 0 || isNavigationRuntimeParams(params)) && Array.isArray(rsc) && rsc.every(isNavigationRuntimeRscChunk) && isOptionalStaleTimeSeconds(staleTimeSeconds);
|
|
60
|
+
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)) && Array.isArray(rsc) && rsc.every(isNavigationRuntimeRscChunk) && isOptionalStaleTimeSeconds(staleTimeSeconds);
|
|
60
61
|
}
|
|
61
62
|
function isOptionalStaleTimeSeconds(value) {
|
|
62
63
|
return value === void 0 || typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
@@ -148,11 +149,6 @@ function ensureNavigationRuntimeRscBootstrapForRuntime(runtime) {
|
|
|
148
149
|
}
|
|
149
150
|
return rscBootstrap;
|
|
150
151
|
}
|
|
151
|
-
function subscribeNavigationRuntimeRscChunk(chunk) {
|
|
152
|
-
const runtime = ensureNavigationRuntime();
|
|
153
|
-
ensureNavigationRuntimeRscBootstrapForRuntime(runtime).rsc.push(chunk);
|
|
154
|
-
return runtime;
|
|
155
|
-
}
|
|
156
152
|
function hasAppNavigationRuntime() {
|
|
157
153
|
return typeof getNavigationRuntime()?.functions.navigate === "function";
|
|
158
154
|
}
|
|
@@ -172,4 +168,4 @@ function hasAppNavigationRuntimeBootstrap() {
|
|
|
172
168
|
return getNavigationRuntime() !== null;
|
|
173
169
|
}
|
|
174
170
|
//#endregion
|
|
175
|
-
export { NAVIGATION_RUNTIME_KEY, NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION, ensureNavigationRuntimeRscBootstrap, getNavigationRuntime, hasAppNavigationRuntime, hasAppNavigationRuntimeBootstrap, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions
|
|
171
|
+
export { NAVIGATION_RUNTIME_KEY, NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION, ensureNavigationRuntimeRscBootstrap, getNavigationRuntime, hasAppNavigationRuntime, hasAppNavigationRuntimeBootstrap, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions };
|
|
@@ -6,6 +6,8 @@ type VinextLinkPrefetchRoute = {
|
|
|
6
6
|
isDynamic: boolean;
|
|
7
7
|
patternParts: string[];
|
|
8
8
|
requiresDynamicNavigationRequest?: boolean;
|
|
9
|
+
/** The route has dynamic params above its root layout. */
|
|
10
|
+
hasRootParams?: true;
|
|
9
11
|
};
|
|
10
12
|
/**
|
|
11
13
|
* Pages Router route pattern exposed to the client so the App Router's
|
|
@@ -332,7 +332,11 @@ async function loadNextConfig(root, phase = DEFAULT_PHASE) {
|
|
|
332
332
|
const normalizedConfigPath = safeRealpath(path.resolve(configPath));
|
|
333
333
|
try {
|
|
334
334
|
const { runnerImport } = await import("vite");
|
|
335
|
-
const
|
|
335
|
+
const virtualConfigId = "virtual:vinext-resolved-next-config";
|
|
336
|
+
const resolvedVirtualConfigId = `\0${virtualConfigId}`;
|
|
337
|
+
const configPathLiteral = JSON.stringify(configPath);
|
|
338
|
+
const phaseLiteral = JSON.stringify(phase);
|
|
339
|
+
const { module: mod } = await runnerImport(virtualConfigId, {
|
|
336
340
|
root,
|
|
337
341
|
logLevel: "error",
|
|
338
342
|
clearScreen: false,
|
|
@@ -351,13 +355,26 @@ async function loadNextConfig(root, phase = DEFAULT_PHASE) {
|
|
|
351
355
|
".json"
|
|
352
356
|
]
|
|
353
357
|
},
|
|
354
|
-
plugins: [
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
358
|
+
plugins: [
|
|
359
|
+
{
|
|
360
|
+
name: "vinext:resolve-next-config-value",
|
|
361
|
+
resolveId(id) {
|
|
362
|
+
if (id === virtualConfigId) return resolvedVirtualConfigId;
|
|
363
|
+
},
|
|
364
|
+
load(id) {
|
|
365
|
+
if (id !== resolvedVirtualConfigId) return;
|
|
366
|
+
return `import * as configModule from ${configPathLiteral};\nconst cjsModule = configModule[${JSON.stringify(VINEXT_CJS_EXPORTS_KEY)}];\nconst cjsInitial = configModule[${JSON.stringify(VINEXT_CJS_INITIAL_KEY)}];\nconst cjsExports = cjsModule && cjsModule.exports;\nconst cjsValue = cjsExports != null && (cjsExports !== cjsInitial || (typeof cjsExports === "object" && Object.keys(cjsExports).length > 0)) ? cjsExports : undefined;\nconst value = cjsValue ?? configModule.default ?? configModule;\nexport default typeof value === "function" ? await value(${phaseLiteral}, { defaultConfig: {} }) : value;\n`;
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
...isTypeScriptConfig ? [cjsGlobalsInjectorPlugin(configPath)] : [],
|
|
370
|
+
commonjs({ filter: (id) => {
|
|
371
|
+
const idPath = id.startsWith("file://") ? fileURLToPath(id) : id.split("?")[0];
|
|
372
|
+
if (safeRealpath(path.resolve(idPath)) === normalizedConfigPath) return false;
|
|
373
|
+
return id.includes("node_modules") ? true : void 0;
|
|
374
|
+
} })
|
|
375
|
+
]
|
|
359
376
|
});
|
|
360
|
-
return
|
|
377
|
+
return mod.default;
|
|
361
378
|
} catch (e) {
|
|
362
379
|
if (isCjsError(e) && (filename.endsWith(".js") || filename.endsWith(".cjs"))) try {
|
|
363
380
|
return await loadConfigViaRequire(configPath, root, phase);
|