@qzsy/vinext 0.1.11 → 0.1.80
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 +19 -5
- package/dist/build/inject-pregenerated-paths.d.ts +4 -0
- package/dist/build/inject-pregenerated-paths.js +18 -0
- package/dist/build/pages-client-assets-module.d.ts +11 -0
- package/dist/build/pages-client-assets-module.js +27 -0
- package/dist/build/prerender.d.ts +2 -1
- package/dist/build/prerender.js +11 -4
- package/dist/build/report.d.ts +2 -1
- package/dist/build/report.js +2 -1
- package/dist/build/run-prerender.d.ts +7 -0
- package/dist/build/run-prerender.js +9 -0
- package/dist/build/standalone.js +2 -0
- package/dist/check.d.ts +18 -0
- package/dist/check.js +77 -19
- package/dist/cli-dev-config.d.ts +12 -0
- package/dist/cli-dev-config.js +23 -0
- package/dist/cli.js +64 -28
- package/dist/{server → client}/dev-error-overlay-store.d.ts +1 -1
- package/dist/{server → client}/dev-error-overlay-store.js +1 -1
- package/dist/{server → client}/dev-error-overlay.d.ts +1 -1
- package/dist/{server → client}/dev-error-overlay.js +2 -2
- package/dist/cloudflare/deploy-config.d.ts +51 -0
- package/dist/cloudflare/deploy-config.js +153 -0
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.js +1 -1
- package/dist/cloudflare/project.d.ts +41 -0
- package/dist/cloudflare/project.js +243 -0
- package/dist/cloudflare/tpr.js +1 -1
- package/dist/config/config-matchers.js +14 -10
- package/dist/config/next-config.d.ts +6 -3
- package/dist/config/next-config.js +47 -1
- package/dist/config/server-external-packages.d.ts +4 -0
- package/dist/config/server-external-packages.js +91 -0
- package/dist/deploy.d.ts +2 -122
- package/dist/deploy.js +20 -793
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +70 -12
- package/dist/entries/app-rsc-manifest.js +8 -0
- package/dist/entries/pages-client-entry.d.ts +1 -0
- package/dist/entries/pages-client-entry.js +2 -1
- package/dist/entries/pages-server-entry.js +6 -2
- package/dist/image/image-adapters-virtual.d.ts +59 -0
- package/dist/image/image-adapters-virtual.js +50 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +158 -109
- package/dist/init-cloudflare.d.ts +43 -0
- package/dist/init-cloudflare.js +1000 -0
- package/dist/init-platform.d.ts +38 -0
- package/dist/init-platform.js +150 -0
- package/dist/init.d.ts +14 -37
- package/dist/init.js +205 -95
- package/dist/node_modules/.pnpm/am-i-vibing@0.5.0/node_modules/am-i-vibing/dist/detector-1yx2Hoe0.js +294 -0
- package/dist/node_modules/.pnpm/process-ancestry@0.1.0/node_modules/process-ancestry/dist/index.js +94 -0
- package/dist/{cloudflare → packages/cloudflare}/src/cache/cdn-adapter.runtime.js +1 -1
- package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.d.ts +2 -2
- package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.js +1 -1
- package/dist/plugins/ast-scope.d.ts +16 -0
- package/dist/plugins/ast-scope.js +62 -0
- package/dist/plugins/ast-utils.js +3 -0
- package/dist/plugins/css-module-imports.d.ts +14 -0
- package/dist/plugins/css-module-imports.js +59 -0
- package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
- package/dist/plugins/ignore-dynamic-requests.js +530 -0
- package/dist/plugins/middleware-server-only.d.ts +8 -6
- package/dist/plugins/middleware-server-only.js +8 -7
- package/dist/plugins/optimize-imports.js +1 -1
- package/dist/plugins/typeof-window.d.ts +1 -1
- package/dist/plugins/typeof-window.js +28 -56
- package/dist/routing/app-route-graph.d.ts +13 -2
- package/dist/routing/app-route-graph.js +116 -32
- package/dist/routing/app-router.d.ts +5 -0
- package/dist/routing/app-router.js +5 -0
- package/dist/routing/file-matcher.d.ts +8 -0
- package/dist/routing/file-matcher.js +10 -1
- package/dist/routing/pages-router.js +2 -2
- package/dist/server/app-browser-action-result.d.ts +2 -1
- package/dist/server/app-browser-action-result.js +5 -1
- package/dist/server/app-browser-entry.js +17 -12
- package/dist/server/app-browser-history-controller.d.ts +2 -1
- package/dist/server/app-browser-history-controller.js +6 -2
- package/dist/server/app-browser-interception-context.d.ts +1 -0
- package/dist/server/app-browser-interception-context.js +4 -2
- package/dist/server/app-browser-navigation-controller.js +1 -0
- package/dist/server/app-browser-server-action-client.js +2 -3
- package/dist/server/app-browser-state.d.ts +1 -0
- package/dist/server/app-browser-state.js +3 -2
- package/dist/server/app-fallback-renderer.d.ts +3 -2
- package/dist/server/app-fallback-renderer.js +12 -7
- package/dist/server/app-middleware.d.ts +2 -3
- package/dist/server/app-middleware.js +3 -2
- package/dist/server/app-optimistic-routing.js +1 -1
- package/dist/server/app-page-boundary-render.d.ts +1 -0
- package/dist/server/app-page-boundary-render.js +12 -3
- package/dist/server/app-page-cache-finalizer.d.ts +1 -0
- package/dist/server/app-page-cache-finalizer.js +10 -3
- package/dist/server/app-page-cache-render.d.ts +1 -0
- package/dist/server/app-page-cache-render.js +8 -4
- package/dist/server/app-page-cache.d.ts +1 -0
- package/dist/server/app-page-cache.js +4 -1
- package/dist/server/app-page-dispatch.d.ts +11 -3
- package/dist/server/app-page-dispatch.js +55 -15
- package/dist/server/app-page-element-builder.d.ts +5 -1
- package/dist/server/app-page-element-builder.js +57 -20
- package/dist/server/app-page-head.d.ts +12 -0
- package/dist/server/app-page-head.js +42 -19
- package/dist/server/app-page-params.d.ts +2 -1
- package/dist/server/app-page-params.js +8 -1
- package/dist/server/app-page-probe.d.ts +1 -0
- package/dist/server/app-page-probe.js +6 -1
- package/dist/server/app-page-render-identity.d.ts +1 -0
- package/dist/server/app-page-render-identity.js +1 -1
- package/dist/server/app-page-render.d.ts +4 -1
- package/dist/server/app-page-render.js +8 -3
- package/dist/server/app-page-request.d.ts +22 -1
- package/dist/server/app-page-request.js +89 -13
- package/dist/server/app-page-route-wiring.d.ts +6 -1
- package/dist/server/app-page-route-wiring.js +31 -15
- package/dist/server/app-page-search-params-observation.d.ts +4 -2
- package/dist/server/app-page-search-params-observation.js +11 -7
- package/dist/server/app-page-segment-state.js +2 -0
- package/dist/server/app-route-handler-dispatch.js +1 -0
- package/dist/server/app-route-handler-execution.js +7 -2
- package/dist/server/app-route-handler-response.js +1 -0
- package/dist/server/app-route-handler-runtime.js +1 -1
- package/dist/server/app-route-module-loader.d.ts +2 -0
- package/dist/server/app-route-module-loader.js +1 -0
- package/dist/server/app-router-entry.d.ts +12 -0
- package/dist/server/app-router-entry.js +22 -8
- package/dist/server/app-router-image-optimization.d.ts +37 -0
- package/dist/server/app-router-image-optimization.js +40 -0
- package/dist/server/app-rsc-errors.js +7 -1
- package/dist/server/app-rsc-handler.js +27 -14
- package/dist/server/app-rsc-route-matching.d.ts +7 -0
- package/dist/server/app-rsc-route-matching.js +36 -3
- package/dist/server/app-segment-config.d.ts +12 -0
- package/dist/server/app-segment-config.js +91 -5
- package/dist/server/app-server-action-execution.d.ts +5 -0
- package/dist/server/app-server-action-execution.js +94 -33
- package/dist/server/app-ssr-entry.js +12 -1
- package/dist/server/app-static-generation.d.ts +1 -0
- package/dist/server/app-static-generation.js +1 -0
- package/dist/server/client-trace-metadata.js +26 -0
- package/dist/server/default-global-not-found-module.d.ts +14 -0
- package/dist/server/default-global-not-found-module.js +14 -0
- package/dist/server/dev-server.js +8 -15
- package/dist/server/dev-stack-sourcemap.d.ts +1 -1
- package/dist/server/dev-stack-sourcemap.js +1 -1
- package/dist/server/headers.d.ts +5 -15
- package/dist/server/headers.js +4 -15
- package/dist/server/image-optimization.d.ts +51 -1
- package/dist/server/image-optimization.js +52 -2
- package/dist/server/isr-cache.d.ts +1 -1
- package/dist/server/isr-cache.js +2 -2
- package/dist/server/middleware-runtime.js +6 -1
- package/dist/server/navigation-planner.d.ts +1 -0
- package/dist/server/navigation-planner.js +14 -3
- package/dist/server/pages-asset-tags.d.ts +4 -6
- package/dist/server/pages-asset-tags.js +12 -12
- package/dist/server/pages-client-assets.d.ts +12 -0
- package/dist/server/pages-client-assets.js +10 -0
- package/dist/server/pages-page-data.d.ts +23 -1
- package/dist/server/pages-page-data.js +43 -24
- package/dist/server/pages-page-handler.d.ts +2 -1
- package/dist/server/pages-page-handler.js +10 -4
- package/dist/server/pages-request-pipeline.d.ts +2 -0
- package/dist/server/pages-request-pipeline.js +25 -1
- package/dist/server/prerender-manifest.d.ts +3 -1
- package/dist/server/prerender-route-params.js +1 -1
- package/dist/server/prod-server.d.ts +1 -1
- package/dist/server/prod-server.js +47 -25
- package/dist/server/request-pipeline.js +1 -0
- package/dist/server/seed-cache.js +4 -4
- package/dist/server/worker-utils.d.ts +2 -1
- package/dist/server/worker-utils.js +7 -1
- package/dist/shims/app-router-scroll-state.d.ts +1 -0
- package/dist/shims/app-router-scroll-state.js +1 -0
- package/dist/shims/app-router-scroll.js +2 -1
- package/dist/shims/cache.js +19 -15
- package/dist/shims/cdn-cache.js +1 -1
- package/dist/shims/dynamic-preload-chunks.js +2 -1
- package/dist/shims/error-boundary.d.ts +19 -1
- package/dist/shims/error-boundary.js +11 -1
- package/dist/shims/form.d.ts +3 -1
- package/dist/shims/form.js +37 -43
- package/dist/shims/headers.d.ts +9 -1
- package/dist/shims/headers.js +31 -6
- package/dist/shims/image-optimization-url.d.ts +4 -0
- package/dist/shims/image-optimization-url.js +33 -1
- package/dist/shims/image.js +46 -13
- package/dist/shims/internal/app-route-detection.d.ts +2 -17
- package/dist/shims/internal/app-route-detection.js +4 -17
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +23 -0
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +51 -0
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +2 -5
- package/dist/shims/internal/hybrid-client-route-owner.js +9 -60
- package/dist/shims/internal/pages-router-components.d.ts +7 -0
- package/dist/shims/internal/pages-router-components.js +13 -0
- package/dist/shims/link.js +23 -16
- package/dist/shims/metadata.d.ts +3 -2
- package/dist/shims/metadata.js +8 -4
- package/dist/shims/navigation.js +4 -2
- package/dist/shims/root-params.d.ts +15 -1
- package/dist/shims/root-params.js +21 -1
- package/dist/shims/router.d.ts +2 -5
- package/dist/shims/router.js +41 -22
- package/dist/shims/server.js +3 -2
- package/dist/typegen.js +6 -5
- package/dist/utils/client-runtime-metadata.d.ts +2 -18
- package/dist/utils/client-runtime-metadata.js +31 -22
- package/dist/utils/dev-stack-sourcemap-endpoint.d.ts +4 -0
- package/dist/{server → utils}/dev-stack-sourcemap-endpoint.js +1 -1
- package/dist/utils/domain-locale.d.ts +6 -3
- package/dist/{server → utils}/middleware-request-headers.d.ts +1 -1
- package/dist/{server → utils}/middleware-request-headers.js +2 -2
- package/dist/utils/path.d.ts +2 -1
- package/dist/utils/path.js +1 -1
- package/dist/utils/project.d.ts +9 -1
- package/dist/utils/project.js +21 -4
- package/dist/utils/protocol-headers.d.ts +17 -0
- package/dist/utils/protocol-headers.js +17 -0
- package/dist/utils/react-version.d.ts +4 -0
- package/dist/utils/react-version.js +44 -0
- package/package.json +28 -24
- package/dist/server/dev-stack-sourcemap-endpoint.d.ts +0 -4
- /package/dist/{cloudflare → packages/cloudflare}/src/utils/cache-control-metadata.js +0 -0
package/dist/shims/link.js
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { stripBasePath } from "../utils/base-path.js";
|
|
3
3
|
import { createRouteTrieCache, matchRouteWithTrie } from "../routing/route-matching.js";
|
|
4
|
-
import { VINEXT_MOUNTED_SLOTS_HEADER } from "../server/headers.js";
|
|
5
4
|
import { isDangerousScheme, reportBlockedDangerousNavigation } from "./url-safety.js";
|
|
6
|
-
import { AppElementsWire } from "../server/app-elements-wire.js";
|
|
7
|
-
import { APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL } from "../server/app-rsc-render-mode.js";
|
|
8
|
-
import "../server/app-elements.js";
|
|
9
5
|
import { addLocalePrefix, getDomainLocaleUrl } from "../utils/domain-locale.js";
|
|
10
6
|
import { prefetchPagesData, resolvePagesDataNavigationTarget } from "./internal/pages-data-target.js";
|
|
11
|
-
import { appendSearchParamsToUrl, urlQueryToSearchParams } from "../utils/query.js";
|
|
12
|
-
import { resolveHybridClientRouteOwner } from "./internal/hybrid-client-route-owner.js";
|
|
13
7
|
import { markAppRouteDetectedOnPrefetch } from "./internal/app-route-detection.js";
|
|
14
8
|
import { isAbsoluteOrProtocolRelativeUrl, normalizePathTrailingSlash, toBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
|
|
9
|
+
import { appendSearchParamsToUrl, urlQueryToSearchParams } from "../utils/query.js";
|
|
15
10
|
import { interpolateDynamicRouteHref } from "./internal/interpolate-as.js";
|
|
16
11
|
import { getCurrentBrowserLocale } from "./client-locale.js";
|
|
17
12
|
import { getCurrentRoutePathnameForWarning } from "./internal/route-pattern-for-warning.js";
|
|
18
|
-
import {
|
|
13
|
+
import { isBotUserAgent } from "../utils/html-limited-bots.js";
|
|
19
14
|
import { getNavigationRuntime, hasAppNavigationRuntime, registerNavigationRuntimeFunctions } from "../client/navigation-runtime.js";
|
|
20
15
|
import { navigatePagesRouterLinkWithFallback, resolvePagesRouterQueryOnlyHref } from "../client/pages-router-link-navigation.js";
|
|
21
|
-
import { getMountedSlotsHeader, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, navigateClientSide, prefetchRscResponse } from "./navigation.js";
|
|
22
16
|
import { getI18nContext } from "./i18n-context.js";
|
|
23
17
|
import { canLinkIntentPrefetch, canLinkPrefetch, getLinkPrefetchHref } from "./link-prefetch.js";
|
|
24
18
|
import { clearLinkForCurrentNavigation, notifyLinkNavigationStart, setLinkForCurrentNavigation } from "./internal/link-status-registry.js";
|
|
@@ -211,6 +205,17 @@ function prefetchUrl(href, mode, priority = "low") {
|
|
|
211
205
|
} : window.requestIdleCallback ?? ((fn) => setTimeout(fn, 100)))(() => {
|
|
212
206
|
(async () => {
|
|
213
207
|
if (hasAppNavigationRuntime()) {
|
|
208
|
+
if (isBotUserAgent(window.navigator?.userAgent ?? "")) return;
|
|
209
|
+
const [navigation, { AppElementsWire }, rscCacheBusting, { APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL }, { VINEXT_MOUNTED_SLOTS_HEADER }, { resolveHybridClientRouteOwner }] = await Promise.all([
|
|
210
|
+
import("./navigation.js"),
|
|
211
|
+
import("../server/app-elements.js"),
|
|
212
|
+
import("../server/app-rsc-cache-busting.js"),
|
|
213
|
+
import("../server/app-rsc-render-mode.js"),
|
|
214
|
+
import("../server/headers.js"),
|
|
215
|
+
import("./internal/hybrid-client-route-owner.js")
|
|
216
|
+
]);
|
|
217
|
+
const { getPrefetchInterceptionContext, getPrefetchCache, getPrefetchedUrls, getMountedSlotsHeader, hasPrefetchCacheEntryForNavigation, prefetchRscResponse } = navigation;
|
|
218
|
+
const { createRscRequestHeaders, createRscRequestUrl } = rscCacheBusting;
|
|
214
219
|
const hybridOwner = resolveHybridClientRouteOwner(prefetchHref, __basePath);
|
|
215
220
|
if (hybridOwner === "pages" || hybridOwner === "document") return;
|
|
216
221
|
const autoPrefetch = mode === "auto" ? resolveAutoAppRoutePrefetch(prefetchHref) : {
|
|
@@ -272,7 +277,7 @@ function prefetchUrl(href, mode, priority = "low") {
|
|
|
272
277
|
const dataTarget = resolvePagesDataNavigationTarget(fullHref, __basePath);
|
|
273
278
|
if (dataTarget) prefetchPagesData(dataTarget);
|
|
274
279
|
else {
|
|
275
|
-
markAppRouteDetectedOnPrefetch(fullHref, __basePath);
|
|
280
|
+
await markAppRouteDetectedOnPrefetch(fullHref, __basePath);
|
|
276
281
|
const link = document.createElement("link");
|
|
277
282
|
link.rel = "prefetch";
|
|
278
283
|
link.href = fullHref;
|
|
@@ -285,8 +290,10 @@ function prefetchUrl(href, mode, priority = "low") {
|
|
|
285
290
|
});
|
|
286
291
|
});
|
|
287
292
|
}
|
|
288
|
-
function promotePrefetchEntriesForNavigation(href) {
|
|
293
|
+
async function promotePrefetchEntriesForNavigation(href) {
|
|
289
294
|
if (typeof window === "undefined") return;
|
|
295
|
+
if (!hasAppNavigationRuntime()) return;
|
|
296
|
+
const [{ getPrefetchCache }, { stripRscCacheBustingSearchParam, stripRscSuffix }] = await Promise.all([import("./navigation.js"), import("../server/app-rsc-cache-busting.js")]);
|
|
290
297
|
let target;
|
|
291
298
|
try {
|
|
292
299
|
target = new URL(toBrowserNavigationHref(href, window.location.href, __basePath), window.location.href);
|
|
@@ -553,12 +560,14 @@ const Link = forwardRef(function Link({ href, as, replace = false, prefetch: pre
|
|
|
553
560
|
onNavigate(navEvent);
|
|
554
561
|
if (navEvent.defaultPrevented) return;
|
|
555
562
|
} catch {}
|
|
556
|
-
|
|
563
|
+
const hybridOwner = HAS_PAGES_ROUTER && hasAppNavigationRuntime ? (await import("./internal/hybrid-client-route-owner.js")).resolveHybridClientRouteOwner(navigateHref, __basePath) : null;
|
|
564
|
+
if (HAS_PAGES_ROUTER && hasAppNavigationRuntime && ["pages", "document"].includes(hybridOwner ?? "")) {
|
|
557
565
|
if (replace) window.location.replace(absoluteFullHref);
|
|
558
566
|
else window.location.assign(absoluteFullHref);
|
|
559
567
|
return;
|
|
560
568
|
}
|
|
561
569
|
if (hasAppNavigationRuntime) {
|
|
570
|
+
const { navigateClientSide } = await import("./navigation.js");
|
|
562
571
|
const setter = setPendingRef.current;
|
|
563
572
|
if (setter) setLinkForCurrentNavigation(setter);
|
|
564
573
|
setPending(true);
|
|
@@ -573,7 +582,7 @@ const Link = forwardRef(function Link({ href, as, replace = false, prefetch: pre
|
|
|
573
582
|
const Router = window.next?.appDir === true ? void 0 : window.next?.router;
|
|
574
583
|
await navigatePagesRouterLinkWithFallback({
|
|
575
584
|
router: Router && "reload" in Router ? Router : void 0,
|
|
576
|
-
loadRouter: async () => (await import("next
|
|
585
|
+
loadRouter: async () => (await import("D:\\projects\\vinext\\node_modules\\.pnpm\\next@16.2.7_@opentelemetry+_a27effa3fabbfbd07255229e73bfb661\\node_modules\\next\\router.js")).default,
|
|
577
586
|
navigation: {
|
|
578
587
|
href: pagesHrefForLink,
|
|
579
588
|
as: pagesAsForLink,
|
|
@@ -651,7 +660,7 @@ const Link = forwardRef(function Link({ href, as, replace = false, prefetch: pre
|
|
|
651
660
|
onClick: (event) => {
|
|
652
661
|
if (childOnClick) childOnClick(event);
|
|
653
662
|
if (event.defaultPrevented) return;
|
|
654
|
-
handleClick(event, { skipLinkOnClick: true });
|
|
663
|
+
return handleClick(event, { skipLinkOnClick: true });
|
|
655
664
|
},
|
|
656
665
|
onMouseEnter: (event) => {
|
|
657
666
|
if (childOnMouseEnter) childOnMouseEnter(event);
|
|
@@ -673,9 +682,7 @@ const Link = forwardRef(function Link({ href, as, replace = false, prefetch: pre
|
|
|
673
682
|
children: /* @__PURE__ */ jsx("a", {
|
|
674
683
|
ref: setRefs,
|
|
675
684
|
href: fullHref,
|
|
676
|
-
onClick:
|
|
677
|
-
handleClick(event);
|
|
678
|
-
},
|
|
685
|
+
onClick: handleClick,
|
|
679
686
|
onMouseEnter: handleMouseEnter,
|
|
680
687
|
onTouchStart: handleTouchStart,
|
|
681
688
|
...anchorProps,
|
package/dist/shims/metadata.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ThenableParamsObserver } from "./thenable-params.js";
|
|
1
2
|
import React from "react";
|
|
2
3
|
|
|
3
4
|
//#region src/shims/metadata.d.ts
|
|
@@ -18,7 +19,7 @@ type Viewport = {
|
|
|
18
19
|
* Resolve viewport config from a module. Handles both static `viewport` export
|
|
19
20
|
* and async `generateViewport()` function.
|
|
20
21
|
*/
|
|
21
|
-
declare function resolveModuleViewport(mod: Record<string, unknown>, params: Record<string, string | string[]
|
|
22
|
+
declare function resolveModuleViewport(mod: Record<string, unknown>, params: Record<string, string | string[]>, searchParams?: Record<string, string | string[]>, searchParamsObserver?: ThenableParamsObserver): Promise<Viewport | null>;
|
|
22
23
|
/**
|
|
23
24
|
* Merge viewport configs from multiple sources (layouts + page).
|
|
24
25
|
* Later entries override earlier ones.
|
|
@@ -267,7 +268,7 @@ declare function mergeMetadataEntries(entries: readonly MetadataMergeEntry[]): M
|
|
|
267
268
|
* resolution approach. If not provided, defaults to a promise that resolves
|
|
268
269
|
* to an empty object (so `await parent` never throws).
|
|
269
270
|
*/
|
|
270
|
-
declare function resolveModuleMetadata(mod: Record<string, unknown>, params?: Record<string, string | string[]>, searchParams?: Record<string, string | string[]>, parent?: Promise<Metadata
|
|
271
|
+
declare function resolveModuleMetadata(mod: Record<string, unknown>, params?: Record<string, string | string[]>, searchParams?: Record<string, string | string[]>, parent?: Promise<Metadata>, searchParamsObserver?: ThenableParamsObserver): Promise<Metadata | null>;
|
|
271
272
|
type MetadataHeadProps = {
|
|
272
273
|
metadata: Metadata;
|
|
273
274
|
pathname?: string;
|
package/dist/shims/metadata.js
CHANGED
|
@@ -13,10 +13,14 @@ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
|
13
13
|
* Resolve viewport config from a module. Handles both static `viewport` export
|
|
14
14
|
* and async `generateViewport()` function.
|
|
15
15
|
*/
|
|
16
|
-
async function resolveModuleViewport(mod, params) {
|
|
16
|
+
async function resolveModuleViewport(mod, params, searchParams, searchParamsObserver) {
|
|
17
17
|
if (typeof mod.generateViewport === "function") {
|
|
18
18
|
const asyncParams = makeThenableParams(params);
|
|
19
|
-
|
|
19
|
+
const props = searchParams === void 0 ? { params: asyncParams } : {
|
|
20
|
+
params: asyncParams,
|
|
21
|
+
searchParams: makeThenableParams(searchParams, searchParamsObserver)
|
|
22
|
+
};
|
|
23
|
+
return await mod.generateViewport(props);
|
|
20
24
|
}
|
|
21
25
|
if (mod.viewport && typeof mod.viewport === "object") return mod.viewport;
|
|
22
26
|
return null;
|
|
@@ -213,12 +217,12 @@ function mergeMetadataEntries(entries) {
|
|
|
213
217
|
* resolution approach. If not provided, defaults to a promise that resolves
|
|
214
218
|
* to an empty object (so `await parent` never throws).
|
|
215
219
|
*/
|
|
216
|
-
async function resolveModuleMetadata(mod, params = {}, searchParams, parent = Promise.resolve({})) {
|
|
220
|
+
async function resolveModuleMetadata(mod, params = {}, searchParams, parent = Promise.resolve({}), searchParamsObserver) {
|
|
217
221
|
if (typeof mod.generateMetadata === "function") {
|
|
218
222
|
const asyncParams = makeThenableParams(params);
|
|
219
223
|
const props = searchParams === void 0 ? { params: asyncParams } : {
|
|
220
224
|
params: asyncParams,
|
|
221
|
-
searchParams: makeThenableParams(searchParams)
|
|
225
|
+
searchParams: makeThenableParams(searchParams, searchParamsObserver)
|
|
222
226
|
};
|
|
223
227
|
return await (mod.generateMetadata.length >= 2 ? mod.generateMetadata(props, parent) : mod.generateMetadata(props));
|
|
224
228
|
}
|
package/dist/shims/navigation.js
CHANGED
|
@@ -5,11 +5,11 @@ import { AppElementsWire } from "../server/app-elements-wire.js";
|
|
|
5
5
|
import "../server/app-elements.js";
|
|
6
6
|
import { markPprFallbackShellDynamicBoundary } from "./ppr-fallback-shell.js";
|
|
7
7
|
import { AppRouterContext } from "./internal/app-router-context.js";
|
|
8
|
-
import { resolveHybridClientRouteOwner } from "./internal/hybrid-client-route-owner.js";
|
|
9
8
|
import { isAbsoluteOrProtocolRelativeUrl, toBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
|
|
10
9
|
import { retryScrollTo, scrollToHashTarget } from "./hash-scroll.js";
|
|
11
10
|
import { GLOBAL_ACCESSORS_KEY, ServerInsertedHTMLContext, _registerStateAccessors, clearClientHydrationContext, clearServerInsertedHTML, flushServerInsertedHTML, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getLayoutSegmentContext, getNavigationContext, registerServerInsertedHTMLCallback, renderServerInsertedHTML, setNavigationContext } from "./navigation-context-state.js";
|
|
12
11
|
import { BailoutToCSRError, DynamicServerError, HTTP_ERROR_FALLBACK_ERROR_CODE, RedirectType, decodeRedirectError, forbidden, getAccessFallbackHTTPStatus, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, notFound, permanentRedirect, redirect, unauthorized, unstable_rethrow } from "./navigation-errors.js";
|
|
12
|
+
import { isBotUserAgent } from "../utils/html-limited-bots.js";
|
|
13
13
|
import { clearAppNavigationFailureTarget, stageAppNavigationFailureTarget } from "../client/app-nav-failure-handler.js";
|
|
14
14
|
import { beginAppRouterScrollIntent, clearAppRouterScrollIntent, consumeAppRouterScrollIntent, getPendingAppRouterScrollIntent } from "./app-router-scroll-state.js";
|
|
15
15
|
import { VINEXT_RSC_COMPATIBILITY_ID_HEADER, createRscRequestHeaders, createRscRequestUrl, stripRscCacheBustingSearchParam } from "../server/app-rsc-cache-busting.js";
|
|
@@ -22,6 +22,7 @@ import { hasPendingAppRouterPageRedirect } from "../server/app-browser-mpa-navig
|
|
|
22
22
|
import { navigationPlanner } from "../server/navigation-planner.js";
|
|
23
23
|
import { ReadonlyURLSearchParams } from "./readonly-url-search-params.js";
|
|
24
24
|
import { getPagesNavigationContext } from "./internal/pages-router-accessor.js";
|
|
25
|
+
import { resolveHybridClientRouteOwner } from "./internal/hybrid-client-route-owner.js";
|
|
25
26
|
import { UnrecognizedActionError, unstable_isUnrecognizedActionError } from "./unrecognized-action-error.js";
|
|
26
27
|
import * as React$1 from "react";
|
|
27
28
|
//#region src/shims/navigation.ts
|
|
@@ -41,7 +42,7 @@ function useChildSegments(parallelRoutesKey = "children") {
|
|
|
41
42
|
const ctx = getLayoutSegmentContext();
|
|
42
43
|
if (!ctx) return [];
|
|
43
44
|
try {
|
|
44
|
-
return React$1.useContext(ctx)[parallelRoutesKey] ?? [];
|
|
45
|
+
return (React$1.useContext(ctx)[parallelRoutesKey] ?? []).filter((segment) => !segment.startsWith("__PAGE__"));
|
|
45
46
|
} catch {
|
|
46
47
|
return [];
|
|
47
48
|
}
|
|
@@ -1033,6 +1034,7 @@ const _appRouter = {
|
|
|
1033
1034
|
prefetch(href, options) {
|
|
1034
1035
|
assertSafeNavigationUrl(href);
|
|
1035
1036
|
if (isServer) return;
|
|
1037
|
+
if (isBotUserAgent(window.navigator?.userAgent ?? "")) return;
|
|
1036
1038
|
try {
|
|
1037
1039
|
new URL(withBasePath(href, __basePath), window.location.href);
|
|
1038
1040
|
} catch {
|
|
@@ -3,10 +3,24 @@ type RootParams = Record<string, string | string[] | undefined>;
|
|
|
3
3
|
type RootParamsState = {
|
|
4
4
|
rootParams: RootParams | null;
|
|
5
5
|
};
|
|
6
|
+
type RootParamsUsage = {
|
|
7
|
+
kind: "route";
|
|
8
|
+
} | {
|
|
9
|
+
kind: "server-action";
|
|
10
|
+
} | {
|
|
11
|
+
kind: "route-handler";
|
|
12
|
+
routePattern: string;
|
|
13
|
+
};
|
|
14
|
+
type RootParamsUsageController = {
|
|
15
|
+
transitionToRender(): void;
|
|
16
|
+
};
|
|
6
17
|
declare function pickRootParams(params: RootParams, rootParamNames: readonly string[] | null | undefined): RootParams;
|
|
7
18
|
declare function setRootParams(params: RootParams | null): void;
|
|
8
19
|
declare function getRootParam(name: string): Promise<string | string[] | undefined>;
|
|
20
|
+
declare function runWithRootParamsUsage<T>(usage: RootParamsUsage, fn: () => Promise<T>, controller?: RootParamsUsageController): Promise<T>;
|
|
21
|
+
declare function runWithRootParamsUsage<T>(usage: RootParamsUsage, fn: () => T | Promise<T>, controller?: RootParamsUsageController): T | Promise<T>;
|
|
22
|
+
declare function createRootParamsUsageController(): RootParamsUsageController;
|
|
9
23
|
declare function runWithRootParamsScope<T>(params: RootParams, fn: () => Promise<T>): Promise<T>;
|
|
10
24
|
declare function runWithRootParamsScope<T>(params: RootParams, fn: () => T | Promise<T>): T | Promise<T>;
|
|
11
25
|
//#endregion
|
|
12
|
-
export { RootParams, RootParamsState, getRootParam, pickRootParams, runWithRootParamsScope, setRootParams };
|
|
26
|
+
export { RootParams, RootParamsState, RootParamsUsage, RootParamsUsageController, createRootParamsUsageController, getRootParam, pickRootParams, runWithRootParamsScope, runWithRootParamsUsage, setRootParams };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { getOrCreateAls } from "./internal/als-registry.js";
|
|
2
2
|
import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation } from "./unified-request-context.js";
|
|
3
3
|
//#region src/shims/root-params.ts
|
|
4
|
+
function createRootParamsUsageError(message) {
|
|
5
|
+
return new Error(message);
|
|
6
|
+
}
|
|
4
7
|
const _FALLBACK_KEY = Symbol.for("vinext.rootParams.fallback");
|
|
5
8
|
const _g = globalThis;
|
|
6
9
|
const _als = getOrCreateAls("vinext.rootParams.als");
|
|
10
|
+
const _usageAls = getOrCreateAls("vinext.rootParams.usage.als");
|
|
7
11
|
const _fallbackState = _g[_FALLBACK_KEY] ??= { rootParams: null };
|
|
8
12
|
function getState() {
|
|
9
13
|
if (isInsideUnifiedScope()) return getRequestContext();
|
|
@@ -18,8 +22,24 @@ function setRootParams(params) {
|
|
|
18
22
|
getState().rootParams = params;
|
|
19
23
|
}
|
|
20
24
|
function getRootParam(name) {
|
|
25
|
+
const usage = _usageAls.getStore();
|
|
26
|
+
if (usage?.kind === "server-action" && usage.phase === "active") throw createRootParamsUsageError(`\`import('next/root-params').${name}()\` was used inside a Server Action. This is not supported. Functions from 'next/root-params' can only be called in the context of a route.`);
|
|
27
|
+
if (usage?.kind === "route-handler" && usage.phase === "active") throw createRootParamsUsageError(`Route ${usage.routePattern} used \`import('next/root-params').${name}()\` inside a Route Handler. Support for this API in Route Handlers is planned for a future version of Next.js.`);
|
|
21
28
|
return Promise.resolve(getState().rootParams?.[name]);
|
|
22
29
|
}
|
|
30
|
+
function runWithRootParamsUsage(usage, fn, controller) {
|
|
31
|
+
const state = {
|
|
32
|
+
...usage,
|
|
33
|
+
phase: "active"
|
|
34
|
+
};
|
|
35
|
+
if (controller) controller.transitionToRender = () => {
|
|
36
|
+
if (usage.kind === "server-action") state.phase = "render";
|
|
37
|
+
};
|
|
38
|
+
return _usageAls.run(state, fn);
|
|
39
|
+
}
|
|
40
|
+
function createRootParamsUsageController() {
|
|
41
|
+
return { transitionToRender() {} };
|
|
42
|
+
}
|
|
23
43
|
function runWithRootParamsScope(params, fn) {
|
|
24
44
|
if (isInsideUnifiedScope()) return runWithUnifiedStateMutation((ctx) => {
|
|
25
45
|
ctx.rootParams = params;
|
|
@@ -27,4 +47,4 @@ function runWithRootParamsScope(params, fn) {
|
|
|
27
47
|
else return _als.run({ rootParams: params }, fn);
|
|
28
48
|
}
|
|
29
49
|
//#endregion
|
|
30
|
-
export { getRootParam, pickRootParams, runWithRootParamsScope, setRootParams };
|
|
50
|
+
export { createRootParamsUsageController, getRootParam, pickRootParams, runWithRootParamsScope, runWithRootParamsUsage, setRootParams };
|
package/dist/shims/router.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VinextNextData } from "../client/vinext-next-data.js";
|
|
2
|
+
import { PagesRouterComponentsMap } from "./internal/pages-router-components.js";
|
|
2
3
|
import { UrlQuery } from "../utils/query.js";
|
|
3
4
|
import { ComponentType, ReactElement } from "react";
|
|
4
5
|
|
|
@@ -174,11 +175,7 @@ type ExcludeRouterProps<P> = Pick<P, Exclude<keyof P, keyof WithRouterProps>>;
|
|
|
174
175
|
*/
|
|
175
176
|
declare function withRouter<P extends WithRouterProps>(ComposedComponent: ComponentType<P>): ComponentType<ExcludeRouterProps<P>>;
|
|
176
177
|
declare const RouterMethods: {
|
|
177
|
-
/** See `_components` comment above for the dual role this map plays. */components:
|
|
178
|
-
[x: string]: {
|
|
179
|
-
__appRouter: true;
|
|
180
|
-
} | Record<string, unknown>;
|
|
181
|
-
};
|
|
178
|
+
/** See `_components` comment above for the dual role this map plays. */components: PagesRouterComponentsMap;
|
|
182
179
|
push: (url: string | UrlObject, as?: string, options?: TransitionOptions) => Promise<boolean>;
|
|
183
180
|
replace: (url: string | UrlObject, as?: string, options?: TransitionOptions) => Promise<boolean>;
|
|
184
181
|
back: () => void;
|
package/dist/shims/router.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { splitPathSegments } from "../routing/utils.js";
|
|
2
2
|
import { removeTrailingSlash, stripBasePath } from "../utils/base-path.js";
|
|
3
3
|
import { assertSafeNavigationUrl } from "./url-safety.js";
|
|
4
|
-
import { fillRoutePatternSegments, matchRoutePattern, routePatternParts } from "../routing/route-pattern.js";
|
|
5
4
|
import { isUnknownRecord } from "../utils/record.js";
|
|
6
5
|
import { AppRouterContext } from "./internal/app-router-context.js";
|
|
7
6
|
import { RouterContext } from "./internal/router-context.js";
|
|
8
7
|
import { applyVinextLocaleGlobals, extractVinextNextDataJson, parseVinextNextDataJson } from "../client/vinext-next-data.js";
|
|
9
8
|
import { isValidModulePath } from "../client/validate-module-path.js";
|
|
10
9
|
import { addLocalePrefix, getDomainLocaleUrl, getLocalePathPrefix } from "../utils/domain-locale.js";
|
|
10
|
+
import { fillRoutePatternSegments, matchRoutePattern, routePatternParts } from "../routing/route-pattern.js";
|
|
11
11
|
import { buildPagesDataHref } from "./internal/pages-data-url.js";
|
|
12
12
|
import { NEXT_DEPLOYMENT_ID_HEADER, getDeploymentId } from "../utils/deployment-id.js";
|
|
13
13
|
import { dedupedPagesDataFetch } from "./internal/pages-data-fetch-dedup.js";
|
|
14
14
|
import { prefetchPagesData, resolvePagesDataNavigationTarget } from "./internal/pages-data-target.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
15
|
+
import { getPagesRouterComponentsMap } from "./internal/pages-router-components.js";
|
|
16
|
+
import { markAppRouteDetectedOnPrefetch } from "./internal/app-route-detection.js";
|
|
17
|
+
import { resolveDirectHybridClientRouteOwner } from "./internal/hybrid-client-route-owner-direct.js";
|
|
18
18
|
import { installWindowNext } from "../client/window-next.js";
|
|
19
19
|
import { getWindowOrigin, isAbsoluteOrProtocolRelativeUrl, isHashOnlyBrowserUrlChange, normalizePathTrailingSlash, toBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
|
|
20
|
+
import { addQueryParam, appendSearchParamsToUrl, mergeRouteParamsIntoQuery, parseQueryString, urlQueryToSearchParams } from "../utils/query.js";
|
|
20
21
|
import { scrollToHashTarget } from "./hash-scroll.js";
|
|
21
22
|
import { installPagesRouterRuntime, setPagesRouterPopStateHandler, setStampInitialHistoryState } from "./pages-router-runtime.js";
|
|
22
23
|
import { interpolateDynamicRouteHref } from "./internal/interpolate-as.js";
|
|
@@ -186,6 +187,7 @@ function createPagesRouterRuntimeState() {
|
|
|
186
187
|
activeAbortController: null,
|
|
187
188
|
cancelPendingRenderCommit: null,
|
|
188
189
|
lastPathnameAndSearch: typeof window !== "undefined" ? window.location.pathname + window.location.search : "",
|
|
190
|
+
lastHash: typeof window !== "undefined" ? window.location.hash : "",
|
|
189
191
|
isFirstPopStateEvent: true,
|
|
190
192
|
routerDidNavigate: false,
|
|
191
193
|
deprecatedEventBridgeInstalled: false,
|
|
@@ -941,6 +943,7 @@ async function navigateClientData(url, initialTarget, controller, navId, assertS
|
|
|
941
943
|
if (!redirectedUrl) scheduleHardNavigationAndThrow(softRedirect, "Navigation redirected externally");
|
|
942
944
|
window.history.replaceState(window.history.state ?? {}, "", redirectedUrl);
|
|
943
945
|
routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
946
|
+
routerRuntimeState.lastHash = window.location.hash;
|
|
944
947
|
await navigateClientHtml(redirectedUrl, redirectedUrl, controller, navId, assertStillCurrent);
|
|
945
948
|
return;
|
|
946
949
|
}
|
|
@@ -1099,6 +1102,7 @@ async function navigateClientHtml(url, fetchUrl, controller, navId, assertStillC
|
|
|
1099
1102
|
if (pendingRedirectHistoryUrl) {
|
|
1100
1103
|
window.history.replaceState(window.history.state ?? {}, "", pendingRedirectHistoryUrl);
|
|
1101
1104
|
routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
1105
|
+
routerRuntimeState.lastHash = window.location.hash;
|
|
1102
1106
|
}
|
|
1103
1107
|
window.__NEXT_DATA__ = nextData;
|
|
1104
1108
|
applyVinextLocaleGlobals(window, nextData);
|
|
@@ -1138,8 +1142,8 @@ async function navigateClient(url, fetchUrl = url, options = {}, routeUrl = url)
|
|
|
1138
1142
|
let htmlFetchUrl = fetchUrl;
|
|
1139
1143
|
let dataTarget = resolvePagesDataNavigationTarget(routeUrl, __basePath);
|
|
1140
1144
|
let middlewareDataResponse;
|
|
1141
|
-
|
|
1142
|
-
|
|
1145
|
+
let middlewareEffect = null;
|
|
1146
|
+
if (hasVinextMiddleware(window.__NEXT_DATA__)) {
|
|
1143
1147
|
try {
|
|
1144
1148
|
middlewareEffect = await resolveMiddlewareDataEffect(browserUrl, controller.signal);
|
|
1145
1149
|
} catch (err) {
|
|
@@ -1147,18 +1151,19 @@ async function navigateClient(url, fetchUrl = url, options = {}, routeUrl = url)
|
|
|
1147
1151
|
throw err;
|
|
1148
1152
|
}
|
|
1149
1153
|
assertStillCurrent();
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1154
|
+
}
|
|
1155
|
+
const redirectLocation = middlewareEffect?.redirectLocation ?? null;
|
|
1156
|
+
if (redirectLocation) {
|
|
1157
|
+
const redirectedUrl = resolveLocalRedirectUrl(redirectLocation);
|
|
1158
|
+
if (!redirectedUrl) scheduleHardNavigationAndThrow(redirectLocation, "Navigation redirected externally");
|
|
1159
|
+
window.history.replaceState(window.history.state ?? {}, "", redirectedUrl);
|
|
1160
|
+
routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
1161
|
+
routerRuntimeState.lastHash = window.location.hash;
|
|
1162
|
+
browserUrl = redirectedUrl;
|
|
1163
|
+
htmlFetchUrl = redirectedUrl;
|
|
1164
|
+
} else if (middlewareEffect) {
|
|
1165
|
+
if (middlewareEffect.rewriteTarget || routeUrl === url) middlewareDataResponse = middlewareEffect.response;
|
|
1166
|
+
if (!dataTarget && middlewareEffect.rewriteTarget) dataTarget = resolvePagesDataNavigationTarget(middlewareEffect.rewriteTarget, __basePath);
|
|
1162
1167
|
}
|
|
1163
1168
|
if (dataTarget) await navigateClientData(browserUrl, dataTarget, controller, navId, assertStillCurrent, options, middlewareDataResponse);
|
|
1164
1169
|
else await navigateClientHtml(browserUrl, htmlFetchUrl, controller, navId, assertStillCurrent, options);
|
|
@@ -1263,6 +1268,7 @@ function updateHistory(mode, fullUrl, navState) {
|
|
|
1263
1268
|
else window.history.replaceState(state, "", fullUrl);
|
|
1264
1269
|
routerRuntimeState.currentHistoryKey = key;
|
|
1265
1270
|
routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
1271
|
+
routerRuntimeState.lastHash = window.location.hash;
|
|
1266
1272
|
routerRuntimeState.routerDidNavigate = true;
|
|
1267
1273
|
}
|
|
1268
1274
|
function createHistoryKey() {
|
|
@@ -1386,7 +1392,14 @@ async function performNavigation(url, as, options, mode, onStateUpdate) {
|
|
|
1386
1392
|
const appPath = getLocalPathname(resolved);
|
|
1387
1393
|
const appPathNorm = appPath !== null ? removeTrailingSlash(appPath) : null;
|
|
1388
1394
|
const appPathEntry = appPathNorm !== null ? getPagesRouterComponentsMap()[appPathNorm] : void 0;
|
|
1389
|
-
if (appPathEntry !== void 0 && "__appRouter" in appPathEntry && appPathEntry.__appRouter
|
|
1395
|
+
if (appPathEntry !== void 0 && "__appRouter" in appPathEntry && appPathEntry.__appRouter) {
|
|
1396
|
+
if (mode === "push") window.location.assign(full);
|
|
1397
|
+
else window.location.replace(full);
|
|
1398
|
+
return new Promise(() => {});
|
|
1399
|
+
}
|
|
1400
|
+
const rewrites = window.__VINEXT_CLIENT_REWRITES__;
|
|
1401
|
+
const hybridOwner = rewrites && (rewrites.beforeFiles.length > 0 || rewrites.afterFiles.length > 0 || rewrites.fallback.length > 0) ? (await import("./internal/hybrid-client-route-owner.js")).resolveHybridClientRouteOwner(resolved, __basePath) : resolveDirectHybridClientRouteOwner(resolved, __basePath);
|
|
1402
|
+
if (["app", "document"].includes(hybridOwner ?? "")) {
|
|
1390
1403
|
if (mode === "push") window.location.assign(full);
|
|
1391
1404
|
else window.location.replace(full);
|
|
1392
1405
|
return new Promise(() => {});
|
|
@@ -1434,7 +1447,7 @@ async function prefetchUrl(url) {
|
|
|
1434
1447
|
prefetchPagesData(dataTarget);
|
|
1435
1448
|
return;
|
|
1436
1449
|
}
|
|
1437
|
-
markAppRouteDetectedOnPrefetch(url, __basePath);
|
|
1450
|
+
await markAppRouteDetectedOnPrefetch(url, __basePath);
|
|
1438
1451
|
const link = document.createElement("link");
|
|
1439
1452
|
link.rel = "prefetch";
|
|
1440
1453
|
link.href = url;
|
|
@@ -1519,6 +1532,10 @@ function getRouterStateKey(state) {
|
|
|
1519
1532
|
if (!isNextRouterState(state)) return void 0;
|
|
1520
1533
|
return typeof state.key === "string" ? state.key : void 0;
|
|
1521
1534
|
}
|
|
1535
|
+
function getTrackedPagesRouterAsPath() {
|
|
1536
|
+
const trackedUrl = new URL(routerRuntimeState.lastPathnameAndSearch, window.location.href);
|
|
1537
|
+
return removeNavigationLocalePrefix(stripBasePath(trackedUrl.pathname, __basePath) + trackedUrl.search);
|
|
1538
|
+
}
|
|
1522
1539
|
function handlePagesRouterPopState(e) {
|
|
1523
1540
|
const browserUrl = window.location.pathname + window.location.search;
|
|
1524
1541
|
const appUrl = stripBasePath(window.location.pathname, __basePath) + window.location.search;
|
|
@@ -1528,9 +1545,10 @@ function handlePagesRouterPopState(e) {
|
|
|
1528
1545
|
if (state !== null && state !== void 0 && !isNextRouterState(state)) return;
|
|
1529
1546
|
if (wasFirst && !routerRuntimeState.routerDidNavigate && isNextRouterState(state)) {
|
|
1530
1547
|
const currentLocale = window.__VINEXT_LOCALE__;
|
|
1531
|
-
if (state.options?.locale === currentLocale && typeof state.as === "string" &&
|
|
1548
|
+
if (state.options?.locale === currentLocale && typeof state.as === "string" && state.as === getTrackedPagesRouterAsPath()) return;
|
|
1532
1549
|
}
|
|
1533
|
-
const
|
|
1550
|
+
const currentHash = window.location.hash;
|
|
1551
|
+
const isHashOnly = browserUrl === routerRuntimeState.lastPathnameAndSearch && (currentHash !== routerRuntimeState.lastHash || currentHash !== "");
|
|
1534
1552
|
const targetKey = getRouterStateKey(state);
|
|
1535
1553
|
let forcedScroll;
|
|
1536
1554
|
if (manualScrollRestoration) {
|
|
@@ -1555,6 +1573,7 @@ function handlePagesRouterPopState(e) {
|
|
|
1555
1573
|
}
|
|
1556
1574
|
if (targetKey !== void 0) routerRuntimeState.currentHistoryKey = targetKey;
|
|
1557
1575
|
routerRuntimeState.lastPathnameAndSearch = browserUrl;
|
|
1576
|
+
routerRuntimeState.lastHash = currentHash;
|
|
1558
1577
|
if (isHashOnly) {
|
|
1559
1578
|
const hashUrl = appUrl + window.location.hash;
|
|
1560
1579
|
routerEvents.emit("hashChangeStart", hashUrl, { shallow: false });
|
package/dist/shims/server.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { hasBasePath, stripBasePath } from "../utils/base-path.js";
|
|
2
2
|
import { getRequestExecutionContext } from "./request-context.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { MIDDLEWARE_SET_COOKIE_HEADER } from "../utils/protocol-headers.js";
|
|
4
|
+
import { MIDDLEWARE_NEXT_HEADER, MIDDLEWARE_REWRITE_HEADER } from "../server/headers.js";
|
|
5
|
+
import { encodeMiddlewareRequestHeaders } from "../utils/middleware-request-headers.js";
|
|
5
6
|
import { serializeSetCookie, validateCookieName } from "./internal/cookie-serialize.js";
|
|
6
7
|
import { parseEdgeRequestCookieHeader } from "../utils/parse-cookie.js";
|
|
7
8
|
import { assertSafeNavigationUrl } from "./url-safety.js";
|
package/dist/typegen.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { findDir } from "./utils/project.js";
|
|
2
2
|
import { decodeRouteSegment, isInvisibleSegment } from "./routing/utils.js";
|
|
3
|
+
import { normalizePathSeparators } from "./utils/path.js";
|
|
3
4
|
import { patternToNextFormat } from "./routing/route-validation.js";
|
|
4
5
|
import { compareStrings } from "./utils/compare.js";
|
|
5
6
|
import "./routing/app-route-graph.js";
|
|
@@ -15,17 +16,17 @@ import "./.next/types/routes.d.ts";
|
|
|
15
16
|
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
|
16
17
|
`;
|
|
17
18
|
async function generateRouteTypes(options) {
|
|
18
|
-
const root = path.resolve(options.root);
|
|
19
|
-
const appDir = options.appDir ? path.resolve(options.appDir) : findDir(root, "app",
|
|
20
|
-
const outPath = path.join(root, ".next", "types", "routes.d.ts");
|
|
19
|
+
const root = normalizePathSeparators(path.resolve(options.root));
|
|
20
|
+
const appDir = options.appDir ? normalizePathSeparators(path.resolve(options.appDir)) : findDir(root, "app", "src/app");
|
|
21
|
+
const outPath = path.posix.join(root, ".next", "types", "routes.d.ts");
|
|
21
22
|
const content = appDir ? renderRouteTypes(await collectRouteTypeModel(appDir, options.pageExtensions)) : renderRouteTypes(emptyRouteTypeModel());
|
|
22
|
-
await fs.mkdir(path.dirname(outPath), { recursive: true });
|
|
23
|
+
await fs.mkdir(path.posix.dirname(outPath), { recursive: true });
|
|
23
24
|
await fs.writeFile(outPath, content, "utf-8");
|
|
24
25
|
await ensureNextEnvFile(root);
|
|
25
26
|
return outPath;
|
|
26
27
|
}
|
|
27
28
|
async function ensureNextEnvFile(root) {
|
|
28
|
-
const envPath = path.join(root, "next-env.d.ts");
|
|
29
|
+
const envPath = path.posix.join(root, "next-env.d.ts");
|
|
29
30
|
try {
|
|
30
31
|
await fs.writeFile(envPath, NEXT_ENV_FILE_CONTENT, {
|
|
31
32
|
encoding: "utf-8",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//#region src/utils/client-runtime-metadata.d.ts
|
|
2
2
|
type ClientRuntimeMetadata = {
|
|
3
3
|
clientEntryFile?: string;
|
|
4
|
+
appBootstrapPreinitModules?: string[];
|
|
4
5
|
lazyChunks?: string[];
|
|
5
6
|
dynamicPreloads?: Record<string, string[]>;
|
|
6
7
|
};
|
|
@@ -24,22 +25,5 @@ declare function computeClientRuntimeMetadata(opts: {
|
|
|
24
25
|
assetPrefix: string;
|
|
25
26
|
includeClientEntry?: boolean | "pages-client-entry";
|
|
26
27
|
}): ClientRuntimeMetadata;
|
|
27
|
-
/**
|
|
28
|
-
* Serialize runtime metadata into the `globalThis.__VINEXT_*` assignment script
|
|
29
|
-
* that the Cloudflare `closeBundle` hook prepends to the worker entry. Returns
|
|
30
|
-
* `""` when there is nothing to inject.
|
|
31
|
-
*
|
|
32
|
-
* Both the App Router and Pages Router closeBundle paths call this (and the
|
|
33
|
-
* deploy tests mirror it), so the injection shape stays in one place. The caller
|
|
34
|
-
* decides which fields to pass — e.g. App Router only forwards `clientEntryFile`
|
|
35
|
-
* for mixed app+pages builds (where `computeClientRuntimeMetadata` was asked for
|
|
36
|
-
* the Pages client entry); pure App Router leaves it undefined.
|
|
37
|
-
*/
|
|
38
|
-
declare function buildRuntimeGlobalsScript(input: {
|
|
39
|
-
clientEntryFile?: string | null;
|
|
40
|
-
ssrManifest?: Record<string, string[]> | null;
|
|
41
|
-
lazyChunks?: string[] | null;
|
|
42
|
-
dynamicPreloads?: Record<string, string[]> | null;
|
|
43
|
-
}): string;
|
|
44
28
|
//#endregion
|
|
45
|
-
export {
|
|
29
|
+
export { computeClientRuntimeMetadata };
|
|
@@ -1,10 +1,34 @@
|
|
|
1
|
-
import { resolveAssetsDir } from "./asset-prefix.js";
|
|
1
|
+
import { isAbsoluteAssetPrefix, resolveAssetsDir } from "./asset-prefix.js";
|
|
2
2
|
import { manifestFileWithAssetPrefix, manifestFileWithBase } from "./manifest-paths.js";
|
|
3
3
|
import { findClientEntryFile, findPagesClientEntryFile, readClientBuildManifest } from "./client-build-manifest.js";
|
|
4
4
|
import { findClientEntryFileFromVinextManifest, findPagesClientEntryFileFromVinextManifest, readClientEntryManifest } from "./client-entry-manifest.js";
|
|
5
5
|
import { computeDynamicImportPreloads, computeLazyChunks, dynamicImportPreloadsWithBase } from "./lazy-chunks.js";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
//#region src/utils/client-runtime-metadata.ts
|
|
8
|
+
function collectAppBootstrapPreinitModules(buildManifest, appBrowserEntry, applyBase) {
|
|
9
|
+
if (!appBrowserEntry) return void 0;
|
|
10
|
+
const entryKey = Object.keys(buildManifest).find((key) => buildManifest[key].file === appBrowserEntry);
|
|
11
|
+
if (!entryKey) return void 0;
|
|
12
|
+
const modules = [];
|
|
13
|
+
const seenFiles = /* @__PURE__ */ new Set();
|
|
14
|
+
const visitedChunks = /* @__PURE__ */ new Set();
|
|
15
|
+
function visit(key) {
|
|
16
|
+
if (visitedChunks.has(key)) return;
|
|
17
|
+
visitedChunks.add(key);
|
|
18
|
+
const chunk = buildManifest[key];
|
|
19
|
+
if (!chunk) return;
|
|
20
|
+
for (const importedKey of chunk.imports ?? []) {
|
|
21
|
+
const importedChunk = buildManifest[importedKey];
|
|
22
|
+
if (importedChunk?.file.endsWith(".js") && !seenFiles.has(importedChunk.file)) {
|
|
23
|
+
seenFiles.add(importedChunk.file);
|
|
24
|
+
modules.push(applyBase(importedChunk.file));
|
|
25
|
+
}
|
|
26
|
+
visit(importedKey);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
visit(entryKey);
|
|
30
|
+
return modules.length > 0 ? modules : void 0;
|
|
31
|
+
}
|
|
8
32
|
/**
|
|
9
33
|
* Read the client build manifest and compute runtime metadata used by
|
|
10
34
|
* Cloudflare worker entry injection and Node production server startup.
|
|
@@ -21,9 +45,9 @@ import path from "node:path";
|
|
|
21
45
|
*/
|
|
22
46
|
function computeClientRuntimeMetadata(opts) {
|
|
23
47
|
const buildManifest = readClientBuildManifest(path.join(opts.clientDir, ".vite", "manifest.json"));
|
|
48
|
+
const clientEntryManifest = readClientEntryManifest(opts.clientDir);
|
|
24
49
|
const metadata = {};
|
|
25
50
|
if (opts.includeClientEntry) {
|
|
26
|
-
const clientEntryManifest = readClientEntryManifest(opts.clientDir);
|
|
27
51
|
const entryOptions = {
|
|
28
52
|
buildManifest,
|
|
29
53
|
clientDir: opts.clientDir,
|
|
@@ -34,30 +58,15 @@ function computeClientRuntimeMetadata(opts) {
|
|
|
34
58
|
if (entry) metadata.clientEntryFile = entry;
|
|
35
59
|
}
|
|
36
60
|
if (!buildManifest) return metadata;
|
|
61
|
+
metadata.appBootstrapPreinitModules = collectAppBootstrapPreinitModules(buildManifest, clientEntryManifest?.appBrowserEntry, (file) => {
|
|
62
|
+
const url = manifestFileWithAssetPrefix(file, opts.assetBase, opts.assetPrefix);
|
|
63
|
+
return isAbsoluteAssetPrefix(opts.assetPrefix) ? url : "/" + url;
|
|
64
|
+
});
|
|
37
65
|
const lazyChunks = computeLazyChunks(buildManifest).map((file) => manifestFileWithBase(file, opts.assetBase));
|
|
38
66
|
if (lazyChunks.length > 0) metadata.lazyChunks = lazyChunks;
|
|
39
67
|
const dynamicPreloads = dynamicImportPreloadsWithBase(computeDynamicImportPreloads(buildManifest), (file) => manifestFileWithAssetPrefix(file, opts.assetBase, opts.assetPrefix));
|
|
40
68
|
if (Object.keys(dynamicPreloads).length > 0) metadata.dynamicPreloads = dynamicPreloads;
|
|
41
69
|
return metadata;
|
|
42
70
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Serialize runtime metadata into the `globalThis.__VINEXT_*` assignment script
|
|
45
|
-
* that the Cloudflare `closeBundle` hook prepends to the worker entry. Returns
|
|
46
|
-
* `""` when there is nothing to inject.
|
|
47
|
-
*
|
|
48
|
-
* Both the App Router and Pages Router closeBundle paths call this (and the
|
|
49
|
-
* deploy tests mirror it), so the injection shape stays in one place. The caller
|
|
50
|
-
* decides which fields to pass — e.g. App Router only forwards `clientEntryFile`
|
|
51
|
-
* for mixed app+pages builds (where `computeClientRuntimeMetadata` was asked for
|
|
52
|
-
* the Pages client entry); pure App Router leaves it undefined.
|
|
53
|
-
*/
|
|
54
|
-
function buildRuntimeGlobalsScript(input) {
|
|
55
|
-
const globals = [];
|
|
56
|
-
if (input.clientEntryFile) globals.push(`globalThis.__VINEXT_CLIENT_ENTRY__ = ${JSON.stringify(input.clientEntryFile)};`);
|
|
57
|
-
if (input.ssrManifest && Object.keys(input.ssrManifest).length > 0) globals.push(`globalThis.__VINEXT_SSR_MANIFEST__ = ${JSON.stringify(input.ssrManifest)};`);
|
|
58
|
-
if (input.lazyChunks && input.lazyChunks.length > 0) globals.push(`globalThis.__VINEXT_LAZY_CHUNKS__ = ${JSON.stringify(input.lazyChunks)};`);
|
|
59
|
-
if (input.dynamicPreloads && Object.keys(input.dynamicPreloads).length > 0) globals.push(`globalThis.__VINEXT_DYNAMIC_PRELOADS__ = ${JSON.stringify(input.dynamicPreloads)};`);
|
|
60
|
-
return globals.join("\n");
|
|
61
|
-
}
|
|
62
71
|
//#endregion
|
|
63
|
-
export {
|
|
72
|
+
export { computeClientRuntimeMetadata };
|