vinext 1.0.0-beta.0 → 1.0.0-beta.2
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 +21 -2
- package/dist/build/assets-ignore.js +1 -1
- package/dist/build/clean-output.js +1 -1
- package/dist/build/client-build-config.js +7 -4
- package/dist/build/css-url-assets.js +3 -3
- package/dist/build/google-fonts/fallback-metrics.js +1 -1
- package/dist/build/google-fonts/font-metadata.js +1 -1
- package/dist/build/inject-pregenerated-paths.js +1 -1
- package/dist/build/inline-css.js +2 -5
- package/dist/build/module-dependency-cache.d.ts +4 -0
- package/dist/build/module-dependency-cache.js +13 -0
- package/dist/build/next-client-runtime-manifests.js +1 -1
- package/dist/build/pages-client-assets-module.js +1 -1
- package/dist/build/precompress.js +7 -7
- package/dist/build/prerender-paths.d.ts +2 -2
- package/dist/build/prerender-paths.js +10 -15
- package/dist/build/prerender-server-pool.js +2 -2
- package/dist/build/prerender.js +1 -1
- package/dist/build/preview-credentials.d.ts +11 -0
- package/dist/build/preview-credentials.js +19 -0
- package/dist/build/report.d.ts +8 -4
- package/dist/build/report.js +14 -6
- package/dist/build/run-prerender.d.ts +2 -11
- package/dist/build/run-prerender.js +2 -10
- package/dist/build/server-manifest.js +1 -1
- package/dist/build/ssr-manifest.d.ts +4 -0
- package/dist/build/ssr-manifest.js +10 -6
- package/dist/build/standalone.js +37 -37
- package/dist/cache/cache-adapters-virtual.d.ts +1 -17
- package/dist/cache/cache-adapters-virtual.js +20 -11
- package/dist/check.d.ts +0 -16
- package/dist/check.js +27 -36
- package/dist/cli.js +61 -55
- package/dist/client/instrumentation-client-inject.js +1 -1
- package/dist/client/pages-router-link-navigation.js +1 -1
- package/dist/config/config-matchers.d.ts +13 -37
- package/dist/config/config-matchers.js +33 -123
- package/dist/config/dotenv.js +1 -1
- package/dist/config/next-config.d.ts +7 -3
- package/dist/config/next-config.js +84 -15
- package/dist/config/prerender.d.ts +2 -2
- package/dist/config/prerender.js +7 -15
- package/dist/config/request-context.d.ts +14 -0
- package/dist/config/request-context.js +26 -0
- package/dist/config/server-external-packages.js +1 -1
- package/dist/config/tsconfig-paths.js +2 -2
- package/dist/{node_modules/.pnpm/am-i-vibing@0.5.0/node_modules → deps/.pnpm/am-i-vibing@0.5.0/deps}/am-i-vibing/dist/detector-1yx2Hoe0.js +2 -2
- package/dist/deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js +50 -0
- package/dist/entries/app-rsc-entry.js +39 -14
- package/dist/entries/app-rsc-manifest.js +21 -4
- package/dist/entries/pages-client-entry.js +6 -5
- package/dist/entries/pages-server-entry.js +18 -28
- package/dist/entries/runtime-entry-module.js +2 -2
- package/dist/index.js +314 -230
- package/dist/init-cloudflare.js +1 -1
- package/dist/init-platform.js +1 -1
- package/dist/init.d.ts +6 -4
- package/dist/init.js +25 -27
- package/dist/plugins/ast-utils.js +1 -1
- package/dist/plugins/dynamic-preload-metadata.js +7 -7
- package/dist/plugins/extensionless-dynamic-import.js +1 -1
- package/dist/plugins/fonts.js +3 -3
- package/dist/plugins/ignore-dynamic-requests.js +13 -8
- package/dist/plugins/import-meta-url.js +16 -17
- package/dist/plugins/middleware-export-validation.js +1 -1
- package/dist/plugins/middleware-server-only.js +2 -2
- package/dist/plugins/og-asset-ownership.js +7 -6
- package/dist/plugins/og-assets.js +5 -6
- package/dist/plugins/optimize-imports.js +12 -13
- package/dist/plugins/postcss.js +1 -1
- package/dist/plugins/remove-console.js +1 -1
- package/dist/plugins/require-context.js +1 -1
- package/dist/plugins/sass.js +2 -2
- package/dist/plugins/server-externals-manifest.js +1 -1
- package/dist/plugins/strip-server-exports.js +1 -1
- package/dist/plugins/styled-jsx.js +3 -2
- package/dist/plugins/typeof-window.js +1 -1
- package/dist/routing/app-route-graph.d.ts +16 -15
- package/dist/routing/app-route-graph.js +86 -88
- package/dist/routing/app-router.d.ts +0 -5
- package/dist/routing/app-router.js +12 -11
- package/dist/routing/file-matcher.d.ts +13 -28
- package/dist/routing/file-matcher.js +31 -44
- package/dist/routing/pages-router.js +26 -32
- package/dist/routing/route-matching.d.ts +14 -1
- package/dist/routing/route-matching.js +13 -1
- package/dist/routing/route-pattern.d.ts +2 -1
- package/dist/routing/route-pattern.js +7 -4
- package/dist/routing/route-trie.d.ts +5 -1
- package/dist/routing/route-trie.js +5 -2
- package/dist/server/api-handler.js +41 -33
- package/dist/server/app-browser-entry.js +18 -11
- package/dist/server/app-browser-history-controller.d.ts +1 -1
- package/dist/server/app-browser-history-controller.js +3 -3
- package/dist/server/app-browser-navigation-controller.js +4 -2
- package/dist/server/app-browser-server-action-client.js +1 -1
- package/dist/server/app-elements-wire.d.ts +2 -1
- package/dist/server/app-fallback-renderer.d.ts +11 -0
- package/dist/server/app-fallback-renderer.js +16 -2
- package/dist/server/app-middleware.js +2 -1
- package/dist/server/app-page-boundary-render.d.ts +26 -2
- package/dist/server/app-page-boundary-render.js +190 -55
- package/dist/server/app-page-cache-finalizer.d.ts +1 -1
- package/dist/server/app-page-cache.d.ts +1 -1
- package/dist/server/app-page-dispatch.d.ts +12 -2
- package/dist/server/app-page-dispatch.js +37 -51
- package/dist/server/app-page-element-builder.d.ts +8 -2
- package/dist/server/app-page-element-builder.js +112 -27
- package/dist/server/app-page-execution.d.ts +3 -1
- package/dist/server/app-page-execution.js +31 -39
- package/dist/server/app-page-head.d.ts +54 -2
- package/dist/server/app-page-head.js +164 -78
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +29 -0
- package/dist/server/app-page-http-access-fallback-metadata.js +106 -0
- package/dist/server/app-page-render.d.ts +2 -2
- package/dist/server/app-page-render.js +1 -1
- package/dist/server/app-page-request.d.ts +12 -0
- package/dist/server/app-page-request.js +134 -14
- package/dist/server/app-page-route-wiring.d.ts +9 -0
- package/dist/server/app-page-route-wiring.js +44 -4
- package/dist/server/app-post-middleware-context.d.ts +1 -1
- package/dist/server/app-post-middleware-context.js +1 -1
- package/dist/server/app-route-handler-dispatch.js +31 -17
- package/dist/server/app-route-handler-execution.d.ts +6 -1
- package/dist/server/app-route-handler-execution.js +41 -15
- package/dist/server/app-route-handler-policy.d.ts +2 -0
- package/dist/server/app-route-handler-policy.js +3 -3
- package/dist/server/app-route-module-loader.d.ts +3 -1
- package/dist/server/app-route-module-loader.js +1 -0
- package/dist/server/app-route-tree-prefetch.js +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +1 -1
- package/dist/server/app-rsc-cache-busting.js +1 -1
- package/dist/server/app-rsc-errors.d.ts +1 -1
- package/dist/server/app-rsc-errors.js +12 -2
- package/dist/server/app-rsc-handler.d.ts +10 -5
- package/dist/server/app-rsc-handler.js +51 -23
- package/dist/server/app-rsc-redirect-flight.d.ts +66 -0
- package/dist/server/app-rsc-redirect-flight.js +71 -0
- package/dist/server/app-rsc-request-normalization.d.ts +3 -2
- package/dist/server/app-rsc-request-normalization.js +8 -2
- package/dist/server/app-rsc-response-finalizer.d.ts +2 -2
- package/dist/server/app-rsc-response-finalizer.js +5 -11
- package/dist/server/app-rsc-route-matching.d.ts +20 -0
- package/dist/server/app-rsc-route-matching.js +87 -11
- package/dist/server/app-segment-config.js +15 -5
- package/dist/server/app-server-action-execution.d.ts +3 -1
- package/dist/server/app-server-action-execution.js +8 -6
- package/dist/server/app-ssr-entry.js +4 -1
- package/dist/server/app-ssr-stream.d.ts +2 -7
- package/dist/server/app-ssr-stream.js +5 -10
- package/dist/server/cache-proof.js +1 -1
- package/dist/server/config-headers.d.ts +24 -0
- package/dist/server/config-headers.js +52 -0
- package/dist/server/default-global-error-module.d.ts +3 -1
- package/dist/server/default-not-found-module.d.ts +3 -1
- package/dist/server/dev-initial-server-error.d.ts +1 -1
- package/dist/server/dev-lockfile.js +2 -3
- package/dist/server/dev-route-files.js +1 -1
- package/dist/server/dev-server.js +281 -173
- package/dist/server/dev-stack-sourcemap.js +4 -3
- package/dist/server/headers.d.ts +3 -1
- package/dist/server/headers.js +3 -1
- package/dist/server/image-optimization.js +2 -2
- package/dist/server/implicit-tags.js +2 -1
- package/dist/server/instrumentation.js +2 -2
- package/dist/server/isr-cache.d.ts +1 -1
- package/dist/server/isr-cache.js +1 -1
- package/dist/server/metadata-routes.js +4 -4
- package/dist/server/middleware-matcher-pattern.d.ts +22 -0
- package/dist/server/middleware-matcher-pattern.js +219 -0
- package/dist/server/middleware-matcher.d.ts +2 -7
- package/dist/server/middleware-matcher.js +13 -60
- package/dist/server/middleware-path-to-regexp.d.ts +14 -0
- package/dist/server/middleware-path-to-regexp.js +228 -0
- package/dist/server/middleware-response-headers.js +1 -1
- package/dist/server/middleware-runtime.js +5 -4
- package/dist/server/middleware.d.ts +2 -1
- package/dist/server/middleware.js +3 -2
- package/dist/server/navigation-planner.d.ts +2 -0
- package/dist/server/navigation-planner.js +8 -2
- package/dist/server/next-error-digest.d.ts +9 -24
- package/dist/server/next-error-digest.js +23 -15
- package/dist/server/operation-token.js +1 -1
- package/dist/server/pages-body-parser-config.js +2 -1
- package/dist/server/pages-data-route.d.ts +11 -1
- package/dist/server/pages-data-route.js +16 -1
- package/dist/server/pages-dev-hydration.d.ts +14 -0
- package/dist/server/pages-dev-hydration.js +83 -0
- package/dist/server/pages-dev-module-url.js +2 -2
- package/dist/server/pages-get-initial-props.d.ts +15 -2
- package/dist/server/pages-get-initial-props.js +16 -6
- package/dist/server/pages-node-compat.d.ts +13 -6
- package/dist/server/pages-node-compat.js +44 -45
- package/dist/server/pages-page-data.d.ts +4 -2
- package/dist/server/pages-page-data.js +20 -10
- package/dist/server/pages-page-handler.d.ts +4 -2
- package/dist/server/pages-page-handler.js +74 -43
- package/dist/server/pages-page-response.d.ts +2 -2
- package/dist/server/pages-page-response.js +1 -1
- package/dist/server/pages-preview.d.ts +26 -0
- package/dist/server/pages-preview.js +165 -0
- package/dist/server/pages-readiness.d.ts +5 -4
- package/dist/server/pages-readiness.js +4 -2
- package/dist/server/pages-request-pipeline.d.ts +1 -0
- package/dist/server/pages-request-pipeline.js +25 -11
- package/dist/server/pages-router-entry.js +6 -0
- package/dist/server/prerender-route-params.js +2 -2
- package/dist/server/prod-server.d.ts +1 -4
- package/dist/server/prod-server.js +44 -30
- package/dist/server/request-pipeline.d.ts +15 -29
- package/dist/server/request-pipeline.js +25 -60
- package/dist/server/rsc-stream-hints.js +122 -18
- package/dist/server/seed-cache.js +1 -1
- package/dist/server/socket-error-backstop.js +1 -1
- package/dist/server/static-file-cache.js +7 -8
- package/dist/server/worker-utils.js +1 -1
- package/dist/shims/app.d.ts +1 -1
- package/dist/shims/cache-request-state.d.ts +27 -1
- package/dist/shims/cache-request-state.js +60 -1
- package/dist/shims/cache-runtime.d.ts +12 -1
- package/dist/shims/cache-runtime.js +22 -7
- package/dist/shims/cache.d.ts +5 -5
- package/dist/shims/cache.js +28 -11
- package/dist/shims/constants.js +1 -1
- package/dist/shims/document.d.ts +42 -83
- package/dist/shims/document.js +62 -53
- package/dist/shims/dynamic.d.ts +5 -25
- package/dist/shims/dynamic.js +29 -8
- package/dist/shims/error-boundary.d.ts +4 -4
- package/dist/shims/error.d.ts +22 -6
- package/dist/shims/error.js +53 -15
- package/dist/shims/fetch-cache.js +13 -4
- package/dist/shims/font-google-base.d.ts +11 -4
- package/dist/shims/font-local.d.ts +10 -3
- package/dist/shims/font-utils.js +1 -1
- package/dist/shims/form.d.ts +1 -1
- package/dist/shims/head.d.ts +13 -2
- package/dist/shims/head.js +6 -6
- package/dist/shims/headers.d.ts +28 -31
- package/dist/shims/headers.js +115 -53
- package/dist/shims/image.d.ts +27 -37
- package/dist/shims/image.js +21 -14
- package/dist/shims/internal/cookie-serialize.d.ts +3 -1
- package/dist/shims/internal/cookie-serialize.js +3 -1
- package/dist/shims/internal/hybrid-client-route-owner.js +3 -1
- package/dist/shims/internal/pages-data-fetch-dedup.js +5 -3
- package/dist/shims/internal/utils.d.ts +3 -3
- package/dist/shims/layout-segment-context.d.ts +1 -1
- package/dist/shims/legacy-image.d.ts +3 -37
- package/dist/shims/legacy-image.js +6 -16
- package/dist/shims/link.d.ts +16 -21
- package/dist/shims/link.js +25 -13
- package/dist/shims/navigation-context-state.d.ts +1 -1
- package/dist/shims/navigation-errors.d.ts +2 -1
- package/dist/shims/navigation-errors.js +9 -13
- package/dist/shims/navigation.d.ts +8 -4
- package/dist/shims/navigation.js +29 -18
- package/dist/shims/next-shims-augmentations.d.ts +1 -0
- package/dist/shims/next-shims-public.d.ts +1 -0
- package/dist/shims/public-shim-map.json.js +103 -0
- package/dist/shims/readonly-url-search-params.d.ts +3 -3
- package/dist/shims/readonly-url-search-params.js +3 -3
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/router-state.d.ts +1 -0
- package/dist/shims/router.d.ts +57 -22
- package/dist/shims/router.js +178 -46
- package/dist/shims/script.d.ts +6 -10
- package/dist/shims/script.js +7 -4
- package/dist/shims/server.d.ts +45 -22
- package/dist/shims/server.js +46 -7
- package/dist/shims/slot.d.ts +1 -1
- package/dist/shims/thenable-params.js +1 -1
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/shims/url-safety.d.ts +1 -1
- package/dist/shims/url-safety.js +2 -2
- package/dist/typegen.d.ts +8 -2
- package/dist/typegen.js +84 -25
- package/dist/utils/client-build-manifest.js +2 -2
- package/dist/utils/client-entry-manifest.js +1 -1
- package/dist/utils/client-runtime-metadata.js +1 -1
- package/dist/utils/commonjs-loader.js +3 -3
- package/dist/utils/domain-locale.d.ts +2 -2
- package/dist/utils/external-url.d.ts +5 -0
- package/dist/utils/external-url.js +7 -0
- package/dist/utils/mdx-scan.js +1 -1
- package/dist/utils/path.d.ts +1 -13
- package/dist/utils/path.js +1 -15
- package/dist/utils/plugin-options.d.ts +4 -0
- package/dist/utils/plugin-options.js +8 -0
- package/dist/utils/project.d.ts +0 -6
- package/dist/utils/project.js +2 -8
- package/dist/utils/public-routes.js +2 -2
- package/dist/utils/react-version.js +1 -1
- package/dist/utils/redirect-digest.d.ts +9 -0
- package/dist/utils/redirect-digest.js +25 -0
- package/dist/utils/regex-safety.d.ts +8 -0
- package/dist/utils/regex-safety.js +737 -0
- package/dist/utils/vinext-root.js +1 -1
- package/dist/utils/vite-version.d.ts +5 -2
- package/dist/utils/vite-version.js +43 -17
- package/package.json +16 -4
- /package/dist/build/google-fonts/{fallback-metrics-data.js → fallback-metrics-data.json.js} +0 -0
- /package/dist/build/google-fonts/{font-data.js → font-data.json.js} +0 -0
- /package/dist/{node_modules/.pnpm/process-ancestry@0.1.0/node_modules → deps/.pnpm/process-ancestry@0.1.0/deps}/process-ancestry/dist/index.js +0 -0
package/dist/shims/link.d.ts
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { VinextLinkPrefetchRoute } from "../client/vinext-next-data.js";
|
|
2
|
-
import {
|
|
2
|
+
import { UrlObject } from "node:url";
|
|
3
3
|
import React, { AnchorHTMLAttributes } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/shims/link.d.ts
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
defaultPrevented: boolean;
|
|
10
|
-
};
|
|
11
|
-
type LinkProps = {
|
|
12
|
-
href: string | {
|
|
13
|
-
pathname?: string;
|
|
14
|
-
query?: UrlQuery;
|
|
15
|
-
}; /** URL displayed in the browser (when href is a route pattern like /user/[id]) */
|
|
16
|
-
as?: string; /** Replace the current history entry instead of pushing */
|
|
6
|
+
type LinkProps<_RouteInferType = unknown> = {
|
|
7
|
+
href: string | UrlObject; /** URL displayed in the browser (when href is a route pattern like /user/[id]) */
|
|
8
|
+
as?: string | UrlObject; /** Replace the current history entry instead of pushing */
|
|
17
9
|
replace?: boolean; /** Prefetch the page in the background (App Router default: auto, Pages Router default: true) */
|
|
18
10
|
prefetch?: boolean | "auto" | null;
|
|
19
11
|
/**
|
|
@@ -39,7 +31,10 @@ type LinkProps = {
|
|
|
39
31
|
*/
|
|
40
32
|
shallow?: boolean; /** Locale for i18n (used for locale-prefixed URLs) */
|
|
41
33
|
locale?: string | false; /** Called before navigation happens (Next.js 16). Return value is ignored. */
|
|
42
|
-
onNavigate?: (event:
|
|
34
|
+
onNavigate?: (event: {
|
|
35
|
+
preventDefault(): void;
|
|
36
|
+
}) => void;
|
|
37
|
+
transitionTypes?: string[];
|
|
43
38
|
children?: React.ReactNode;
|
|
44
39
|
} & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href">;
|
|
45
40
|
type LinkPrefetchMode = "disabled" | "auto" | "full" | "full-after-shell";
|
|
@@ -65,11 +60,8 @@ declare function resolveAutoAppRoutePrefetch(href: string): {
|
|
|
65
60
|
shouldPrefetch: boolean;
|
|
66
61
|
};
|
|
67
62
|
declare const Link: React.ForwardRefExoticComponent<{
|
|
68
|
-
href: string |
|
|
69
|
-
|
|
70
|
-
query?: UrlQuery;
|
|
71
|
-
}; /** URL displayed in the browser (when href is a route pattern like /user/[id]) */
|
|
72
|
-
as?: string; /** Replace the current history entry instead of pushing */
|
|
63
|
+
href: string | UrlObject; /** URL displayed in the browser (when href is a route pattern like /user/[id]) */
|
|
64
|
+
as?: string | UrlObject; /** Replace the current history entry instead of pushing */
|
|
73
65
|
replace?: boolean; /** Prefetch the page in the background (App Router default: auto, Pages Router default: true) */
|
|
74
66
|
prefetch?: boolean | "auto" | null;
|
|
75
67
|
/**
|
|
@@ -95,8 +87,11 @@ declare const Link: React.ForwardRefExoticComponent<{
|
|
|
95
87
|
*/
|
|
96
88
|
shallow?: boolean; /** Locale for i18n (used for locale-prefixed URLs) */
|
|
97
89
|
locale?: string | false; /** Called before navigation happens (Next.js 16). Return value is ignored. */
|
|
98
|
-
onNavigate?: (event:
|
|
90
|
+
onNavigate?: (event: {
|
|
91
|
+
preventDefault(): void;
|
|
92
|
+
}) => void;
|
|
93
|
+
transitionTypes?: string[];
|
|
99
94
|
children?: React.ReactNode;
|
|
100
|
-
} & Omit<
|
|
95
|
+
} & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
101
96
|
//#endregion
|
|
102
|
-
export { canAutoPrefetchFullAppRoute, Link as default, resolveAutoAppRoutePrefetch, resolveLinkPrefetchMode, useLinkStatus };
|
|
97
|
+
export { LinkProps, canAutoPrefetchFullAppRoute, Link as default, resolveAutoAppRoutePrefetch, resolveLinkPrefetchMode, useLinkStatus };
|
package/dist/shims/link.js
CHANGED
|
@@ -28,6 +28,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
28
28
|
* page swap via the router's navigation system.
|
|
29
29
|
*/
|
|
30
30
|
const HAS_PAGES_ROUTER = process.env.__VINEXT_HAS_PAGES_ROUTER !== "false";
|
|
31
|
+
const HAS_CLIENT_REWRITES = process.env.__VINEXT_HAS_CLIENT_REWRITES !== "false";
|
|
31
32
|
const LinkStatusContext = createContext({ pending: false });
|
|
32
33
|
/**
|
|
33
34
|
* useLinkStatus returns the pending state of the enclosing <Link>.
|
|
@@ -37,7 +38,12 @@ const LinkStatusContext = createContext({ pending: false });
|
|
|
37
38
|
function useLinkStatus() {
|
|
38
39
|
return useContext(LinkStatusContext);
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
+
let linkPrefetchNavigationEpoch = 0;
|
|
42
|
+
function notifyLinkNavigationStartAndCancelPrefetchSetup() {
|
|
43
|
+
linkPrefetchNavigationEpoch += 1;
|
|
44
|
+
notifyLinkNavigationStart();
|
|
45
|
+
}
|
|
46
|
+
if (typeof window !== "undefined") registerNavigationRuntimeFunctions({ notifyLinkNavigationStart: notifyLinkNavigationStartAndCancelPrefetchSetup });
|
|
41
47
|
/** basePath from next.config.js, injected by the plugin at build time */
|
|
42
48
|
const __basePath = process.env.__NEXT_ROUTER_BASEPATH ?? "";
|
|
43
49
|
/** trailingSlash from next.config.js, injected by the plugin at build time */
|
|
@@ -51,11 +57,12 @@ function resolveHref(href) {
|
|
|
51
57
|
const params = urlQueryToSearchParams(href.query);
|
|
52
58
|
url = appendSearchParamsToUrl(url, params);
|
|
53
59
|
}
|
|
60
|
+
if (href.hash) url += href.hash.startsWith("#") ? href.hash : `#${href.hash}`;
|
|
54
61
|
return url;
|
|
55
62
|
}
|
|
56
63
|
function resolvePagesQueryOnlyHref(href) {
|
|
57
64
|
if (!HAS_PAGES_ROUTER) return href;
|
|
58
|
-
if (!href.startsWith("?") || typeof window === "undefined") return href;
|
|
65
|
+
if (!href.startsWith("?") && !href.startsWith("#") || typeof window === "undefined") return href;
|
|
59
66
|
const pagesRouter = window.next?.appDir === true ? void 0 : window.next?.router;
|
|
60
67
|
return resolvePagesRouterQueryOnlyHref(href, {
|
|
61
68
|
asPath: pagesRouter && "reload" in pagesRouter && "asPath" in pagesRouter && typeof pagesRouter.asPath === "string" ? pagesRouter.asPath : void 0,
|
|
@@ -206,6 +213,7 @@ function resolveFullAppRoutePrefetch() {
|
|
|
206
213
|
*/
|
|
207
214
|
function prefetchUrl(href, mode, priority = "low", pagesRouteHref, locale) {
|
|
208
215
|
if (typeof window === "undefined") return;
|
|
216
|
+
const navigationEpoch = linkPrefetchNavigationEpoch;
|
|
209
217
|
const prefetchHref = getLinkPrefetchHref({
|
|
210
218
|
href,
|
|
211
219
|
basePath: __basePath,
|
|
@@ -224,20 +232,21 @@ function prefetchUrl(href, mode, priority = "low", pagesRouteHref, locale) {
|
|
|
224
232
|
(async () => {
|
|
225
233
|
if (hasAppNavigationRuntime()) {
|
|
226
234
|
if (isBotUserAgent(window.navigator?.userAgent ?? "")) return;
|
|
227
|
-
const [navigation, { AppElementsWire }, rscCacheBusting, { APP_RSC_RENDER_MODE_PREFETCH_DYNAMIC_SHELL, APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL }, headersModule,
|
|
235
|
+
const [navigation, { AppElementsWire }, rscCacheBusting, { APP_RSC_RENDER_MODE_PREFETCH_DYNAMIC_SHELL, APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL }, headersModule, hybridRouteOwner] = await Promise.all([
|
|
228
236
|
import("./navigation.js"),
|
|
229
237
|
import("../server/app-elements.js"),
|
|
230
238
|
import("../server/app-rsc-cache-busting.js"),
|
|
231
239
|
import("../server/app-rsc-render-mode.js"),
|
|
232
240
|
import("../server/headers.js"),
|
|
233
|
-
import("./internal/hybrid-client-route-owner.js")
|
|
241
|
+
HAS_PAGES_ROUTER || HAS_CLIENT_REWRITES ? import("./internal/hybrid-client-route-owner.js") : null
|
|
234
242
|
]);
|
|
243
|
+
if (navigationEpoch !== linkPrefetchNavigationEpoch) return;
|
|
235
244
|
const { getPrefetchInterceptionContext, getPrefetchCache, getPrefetchedUrls, getMountedSlotsHeader, hasSearchAgnosticPrefetchShellForRoute, hasPrefetchCacheEntryForNavigation, peekPrefetchResponseForNavigation, prefetchRscResponse, restoreRscResponse, PREFETCH_CACHE_TTL } = navigation;
|
|
236
245
|
const { createRscRequestHeaders, createRscRequestUrl } = rscCacheBusting;
|
|
237
246
|
const { NEXT_ROUTER_PREFETCH_HEADER, NEXT_ROUTER_SEGMENT_PREFETCH_HEADER, VINEXT_MOUNTED_SLOTS_HEADER } = headersModule;
|
|
238
|
-
const hybridOwner = resolveHybridClientRouteOwner(prefetchHref, __basePath);
|
|
247
|
+
const hybridOwner = HAS_PAGES_ROUTER ? hybridRouteOwner.resolveHybridClientRouteOwner(prefetchHref, __basePath) : null;
|
|
239
248
|
if (hybridOwner === "pages" || hybridOwner === "document") return;
|
|
240
|
-
const rewrittenPrefetchHref = resolveHybridClientRewriteHref(fullHref, __basePath);
|
|
249
|
+
const rewrittenPrefetchHref = HAS_CLIENT_REWRITES ? hybridRouteOwner.resolveHybridClientRewriteHref(fullHref, __basePath) : null;
|
|
241
250
|
const autoPrefetch = mode === "auto" ? resolveAutoAppRoutePrefetch(rewrittenPrefetchHref ?? prefetchHref) : mode === "full-after-shell" ? {
|
|
242
251
|
cacheForNavigation: true,
|
|
243
252
|
prefetchShellFirst: true,
|
|
@@ -369,7 +378,8 @@ function prefetchUrl(href, mode, priority = "low", pagesRouteHref, locale) {
|
|
|
369
378
|
await shellEntry?.pending?.catch(() => {});
|
|
370
379
|
const renderedPathAndSearch = shellEntry?.snapshot?.renderedPathAndSearch;
|
|
371
380
|
if (renderedPathAndSearch) {
|
|
372
|
-
const
|
|
381
|
+
const renderedRscUrl = await createRscRequestUrl(renderedPathAndSearch, headers);
|
|
382
|
+
const cachedRenderedResponse = peekPrefetchResponseForNavigation(renderedRscUrl, interceptionContext, mountedSlotsHeader);
|
|
373
383
|
if (cachedRenderedResponse) return restoreRscResponse(cachedRenderedResponse);
|
|
374
384
|
}
|
|
375
385
|
return scheduleAppPrefetchFetch(() => fetch(rscUrl, {
|
|
@@ -568,18 +578,20 @@ function applyLocaleToHref(href, locale) {
|
|
|
568
578
|
*/
|
|
569
579
|
function resolveConcreteRouteHref(href, as) {
|
|
570
580
|
if (typeof as !== "string") return null;
|
|
571
|
-
return interpolateDynamicRouteHref(typeof href === "string" ? href : resolveHref(href), as, typeof href === "string" ? void 0 : href.query)?.href || null;
|
|
581
|
+
return interpolateDynamicRouteHref(typeof href === "string" ? href : resolveHref(href), as, typeof href === "string" || !href.query || typeof href.query === "string" ? void 0 : href.query)?.href || null;
|
|
572
582
|
}
|
|
573
|
-
const Link = forwardRef(function Link({ href, as, replace = false, prefetch: prefetchProp, scroll = true, shallow = false, children: childrenProp, onClick, onMouseEnter, onTouchStart, onNavigate, unstable_dynamicOnHover = false, legacyBehavior = false, passHref = false, ...rest }, forwardedRef) {
|
|
583
|
+
const Link = forwardRef(function Link({ href, as, replace = false, prefetch: prefetchProp, scroll = true, shallow = false, children: childrenProp, onClick, onMouseEnter, onTouchStart, onNavigate, unstable_dynamicOnHover = false, legacyBehavior = false, passHref = false, transitionTypes: _transitionTypes, ...rest }, forwardedRef) {
|
|
584
|
+
const asHref = as === void 0 ? void 0 : resolveHref(as);
|
|
574
585
|
const { locale, ...restWithoutLocale } = rest;
|
|
575
586
|
let children = childrenProp;
|
|
576
587
|
if (legacyBehavior && (typeof childrenProp === "string" || typeof childrenProp === "number")) children = React.createElement("a", null, childrenProp);
|
|
577
|
-
const
|
|
578
|
-
const
|
|
588
|
+
const unresolvedHref = asHref ?? resolveHref(href);
|
|
589
|
+
const rawResolvedHref = typeof unresolvedHref === "string" && unresolvedHref.startsWith("#") ? resolvePagesQueryOnlyHref(unresolvedHref) : unresolvedHref;
|
|
590
|
+
const routeHrefRaw = (HAS_PAGES_ROUTER ? resolveConcreteRouteHref(href, asHref) : null) ?? (typeof href === "string" ? href : resolveHref(href));
|
|
579
591
|
const resolvedHref = typeof rawResolvedHref === "string" ? warnAndNormalizeRepeatedSlashesInHref(rawResolvedHref) : rawResolvedHref;
|
|
580
592
|
const isDangerous = typeof resolvedHref === "string" && isDangerousScheme(resolvedHref);
|
|
581
593
|
const normalizedHref = normalizePathTrailingSlash(applyLocaleToHref(isDangerous ? "/" : resolvedHref, locale), __trailingSlash);
|
|
582
|
-
const normalizedRouteHref = HAS_PAGES_ROUTER && typeof
|
|
594
|
+
const normalizedRouteHref = HAS_PAGES_ROUTER && typeof asHref === "string" && typeof routeHrefRaw === "string" && asHref !== routeHrefRaw ? normalizePathTrailingSlash(applyLocaleToHref(isDangerous ? "/" : routeHrefRaw, locale), __trailingSlash) : normalizedHref;
|
|
583
595
|
const fullHref = normalizePathTrailingSlash(withBasePath(normalizedHref, __basePath), __trailingSlash);
|
|
584
596
|
const [pending, setPending] = useState(false);
|
|
585
597
|
const mountedRef = useRef(true);
|
|
@@ -701,7 +713,7 @@ const Link = forwardRef(function Link({ href, as, replace = false, prefetch: pre
|
|
|
701
713
|
e.preventDefault();
|
|
702
714
|
const hasAppNavigationRuntime = Boolean(getNavigationRuntime()?.functions.navigate);
|
|
703
715
|
const pagesNavigateHref = HAS_PAGES_ROUTER && resolvedHref.startsWith("?") ? resolvePagesLinkNavigationHref(resolvedHref, locale) : navigateHref;
|
|
704
|
-
const pagesAsForLink = HAS_PAGES_ROUTER && typeof
|
|
716
|
+
const pagesAsForLink = HAS_PAGES_ROUTER && typeof asHref === "string" && typeof routeHrefRaw === "string" && asHref !== routeHrefRaw ? pagesNavigateHref : void 0;
|
|
705
717
|
const pagesHrefForLink = pagesAsForLink === void 0 ? pagesNavigateHref : routeHrefRaw;
|
|
706
718
|
const absoluteFullHref = toBrowserNavigationHref(hasAppNavigationRuntime ? navigateHref : pagesNavigateHref, window.location.href, __basePath);
|
|
707
719
|
if (onNavigate) try {
|
|
@@ -13,7 +13,7 @@ type NavigationContext = {
|
|
|
13
13
|
searchParams: URLSearchParams;
|
|
14
14
|
params: Record<string, string | string[]>;
|
|
15
15
|
};
|
|
16
|
-
declare const ServerInsertedHTMLContext: React$1.Context<((callback: () =>
|
|
16
|
+
declare const ServerInsertedHTMLContext: React$1.Context<((callback: () => React$1.ReactNode) => void) | null> | null;
|
|
17
17
|
declare function getLayoutSegmentContext(): React$1.Context<SegmentMap> | null;
|
|
18
18
|
declare function getBfcacheIdMapContext(): React$1.Context<Readonly<Record<string, string>> | null> | null;
|
|
19
19
|
declare function getBfcacheSegmentIdContext(): React$1.Context<string | null> | null;
|
|
@@ -26,7 +26,8 @@ type RedirectErrorShape = Error & {
|
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* vinext accepts its three-part redirect digest and Next.js's five-part form.
|
|
29
|
-
*
|
|
29
|
+
* This is deliberately only a cheap prefix gate because vinext permits an
|
|
30
|
+
* empty redirect type; parseRedirectDigest is the authoritative validator.
|
|
30
31
|
*/
|
|
31
32
|
declare function isRedirectError(error: unknown): error is RedirectErrorShape;
|
|
32
33
|
declare function decodeRedirectError(digest: string): {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseRedirectDigest } from "../utils/redirect-digest.js";
|
|
1
2
|
//#region src/shims/navigation-errors.ts
|
|
2
3
|
/**
|
|
3
4
|
* Server-safe navigation control-flow errors and predicates.
|
|
@@ -52,24 +53,19 @@ function unauthorized() {
|
|
|
52
53
|
}
|
|
53
54
|
/**
|
|
54
55
|
* vinext accepts its three-part redirect digest and Next.js's five-part form.
|
|
55
|
-
*
|
|
56
|
+
* This is deliberately only a cheap prefix gate because vinext permits an
|
|
57
|
+
* empty redirect type; parseRedirectDigest is the authoritative validator.
|
|
56
58
|
*/
|
|
57
59
|
function isRedirectError(error) {
|
|
58
60
|
return !!error && typeof error === "object" && "digest" in error && typeof error.digest === "string" && error.digest.startsWith("NEXT_REDIRECT;");
|
|
59
61
|
}
|
|
60
62
|
function decodeRedirectError(digest) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
url: decodeURIComponent(encodedTarget),
|
|
68
|
-
type: parts[1] === "push" ? "push" : "replace"
|
|
69
|
-
};
|
|
70
|
-
} catch {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
63
|
+
const redirect = parseRedirectDigest(digest);
|
|
64
|
+
if (!redirect) return null;
|
|
65
|
+
return {
|
|
66
|
+
url: redirect.url,
|
|
67
|
+
type: redirect.type === "push" ? "push" : "replace"
|
|
68
|
+
};
|
|
73
69
|
}
|
|
74
70
|
function isNextRouterError(error) {
|
|
75
71
|
return isRedirectError(error) || isHTTPAccessFallbackError(error);
|
|
@@ -6,8 +6,12 @@ import { GLOBAL_ACCESSORS_KEY, NavigationContext, NavigationStateAccessors, Segm
|
|
|
6
6
|
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";
|
|
7
7
|
import { UnrecognizedActionError, unstable_isUnrecognizedActionError } from "./unrecognized-action-error.js";
|
|
8
8
|
import * as React$1 from "react";
|
|
9
|
+
import { Params } from "@vinext/types/next/upstream/dist/server/request/params";
|
|
9
10
|
|
|
10
11
|
//#region src/shims/navigation.d.ts
|
|
12
|
+
/** Load rewrite-aware hybrid route ownership before navigation becomes interactive. */
|
|
13
|
+
declare function preloadHybridClientRouteOwner(): Promise<void>;
|
|
14
|
+
declare function resolveLoadedHybridClientRewriteHref(href: string, basePath: string): string | null;
|
|
11
15
|
/** basePath from next.config.js, injected by the plugin at build time */
|
|
12
16
|
declare const __basePath: string;
|
|
13
17
|
/** Maximum buffered bytes in the RSC prefetch cache. Mirrors Next.js' 50 MB LRU. */
|
|
@@ -203,7 +207,7 @@ declare function clearPendingPathname(navId: number): void;
|
|
|
203
207
|
* Returns the current pathname.
|
|
204
208
|
* Server: from request context. Client: from window.location.
|
|
205
209
|
*/
|
|
206
|
-
declare function usePathname(): string
|
|
210
|
+
declare function usePathname(): string;
|
|
207
211
|
/**
|
|
208
212
|
* Returns the current search params as a read-only URLSearchParams.
|
|
209
213
|
*/
|
|
@@ -211,7 +215,7 @@ declare function useSearchParams(): ReadonlyURLSearchParams;
|
|
|
211
215
|
/**
|
|
212
216
|
* Returns the dynamic params for the current route.
|
|
213
217
|
*/
|
|
214
|
-
declare function useParams<T extends
|
|
218
|
+
declare function useParams<T extends Params = Params>(): T | null;
|
|
215
219
|
/**
|
|
216
220
|
* Commit pending client navigation state to committed snapshots.
|
|
217
221
|
*
|
|
@@ -252,7 +256,6 @@ declare const appRouterInstance: AppRouterInstance;
|
|
|
252
256
|
* and layers the nearest segment's contextual `bfcacheId` on top.
|
|
253
257
|
*/
|
|
254
258
|
declare function useRouter(): {
|
|
255
|
-
bfcacheId: string;
|
|
256
259
|
back(): void;
|
|
257
260
|
forward(): void;
|
|
258
261
|
refresh(): void;
|
|
@@ -260,6 +263,7 @@ declare function useRouter(): {
|
|
|
260
263
|
replace(href: string, options?: NavigateOptions): void;
|
|
261
264
|
prefetch(href: string, options?: PrefetchOptions$1): void;
|
|
262
265
|
experimental_gesturePush?(href: string, options?: NavigateOptions): void;
|
|
266
|
+
bfcacheId: string;
|
|
263
267
|
};
|
|
264
268
|
/**
|
|
265
269
|
* Returns the active child segment one level below the layout where it's called.
|
|
@@ -299,4 +303,4 @@ declare function useSelectedLayoutSegments(parallelRoutesKey?: string): string[]
|
|
|
299
303
|
*/
|
|
300
304
|
declare function useServerInsertedHTML(callback: () => unknown): void;
|
|
301
305
|
//#endregion
|
|
302
|
-
export { BailoutToCSRError, CachedRscResponse, ClientNavigationRenderSnapshot, DYNAMIC_NAVIGATION_CACHE_TTL, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, type NavigationContext, type NavigationStateAccessors, PREFETCH_CACHE_TTL, PrefetchCacheEntry, PrefetchCacheKind, PrefetchOptions, ReadonlyURLSearchParams, RedirectType, type SegmentMap, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, applyAppRouterScrollFallback, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, deletePrefetchResponseSnapshot, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, hasSearchAgnosticPrefetchShellForRoute, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, peekPrefetchResponseForNavigation, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, seedPrefetchResponseSnapshot, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
|
306
|
+
export { BailoutToCSRError, CachedRscResponse, ClientNavigationRenderSnapshot, DYNAMIC_NAVIGATION_CACHE_TTL, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, type NavigationContext, type NavigationStateAccessors, PREFETCH_CACHE_TTL, PrefetchCacheEntry, PrefetchCacheKind, PrefetchOptions, ReadonlyURLSearchParams, RedirectType, type SegmentMap, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, applyAppRouterScrollFallback, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, deletePrefetchResponseSnapshot, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, hasSearchAgnosticPrefetchShellForRoute, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, peekPrefetchResponseForNavigation, permanentRedirect, prefetchRscResponse, preloadHybridClientRouteOwner, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolveLoadedHybridClientRewriteHref, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, seedPrefetchResponseSnapshot, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
package/dist/shims/navigation.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { stripBasePath } from "../utils/base-path.js";
|
|
2
2
|
import { VINEXT_DYNAMIC_STALE_TIME_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_PARAMS_HEADER, VINEXT_RENDERED_PATH_AND_SEARCH_HEADER } from "../server/headers.js";
|
|
3
3
|
import { assertSafeNavigationUrl } from "./url-safety.js";
|
|
4
|
+
import { isExternalUrl } from "../utils/external-url.js";
|
|
4
5
|
import { AppElementsWire } from "../server/app-elements-wire.js";
|
|
5
6
|
import "../server/app-elements.js";
|
|
6
7
|
import { markPprFallbackShellDynamicBoundary } from "./ppr-fallback-shell.js";
|
|
7
8
|
import { AppRouterContext } from "./internal/app-router-context.js";
|
|
8
|
-
import {
|
|
9
|
+
import { resolveDirectHybridClientRouteOwner } from "./internal/hybrid-client-route-owner-direct.js";
|
|
10
|
+
import { toBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
|
|
9
11
|
import { retryScrollTo, scrollToHashTarget } from "./hash-scroll.js";
|
|
10
12
|
import { GLOBAL_ACCESSORS_KEY, ServerInsertedHTMLContext, _registerStateAccessors, clearClientHydrationContext, clearServerInsertedHTML, flushServerInsertedHTML, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getLayoutSegmentContext, getNavigationContext, registerServerInsertedHTMLCallback, renderServerInsertedHTML, setNavigationContext } from "./navigation-context-state.js";
|
|
11
13
|
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";
|
|
@@ -22,7 +24,6 @@ import { hasPendingAppRouterPageRedirect } from "../server/app-browser-mpa-navig
|
|
|
22
24
|
import { navigationPlanner } from "../server/navigation-planner.js";
|
|
23
25
|
import { ReadonlyURLSearchParams } from "./readonly-url-search-params.js";
|
|
24
26
|
import { getPagesNavigationContext } from "./internal/pages-router-accessor.js";
|
|
25
|
-
import { resolveHybridClientRouteOwner } from "./internal/hybrid-client-route-owner.js";
|
|
26
27
|
import { releaseAppPrefetchFetchSlot, scheduleAppPrefetchFetch } from "./internal/app-prefetch-fetch-queue.js";
|
|
27
28
|
import { UnrecognizedActionError, unstable_isUnrecognizedActionError } from "./unrecognized-action-error.js";
|
|
28
29
|
import * as React$1 from "react";
|
|
@@ -34,6 +35,22 @@ import * as React$1 from "react";
|
|
|
34
35
|
* Server-side: reads from a request context set by the RSC handler.
|
|
35
36
|
* Client-side: reads from browser Location API and provides navigation.
|
|
36
37
|
*/
|
|
38
|
+
const HAS_PAGES_ROUTER = process.env.__VINEXT_HAS_PAGES_ROUTER !== "false";
|
|
39
|
+
let hybridClientRouteOwnerModule = null;
|
|
40
|
+
let hybridClientRouteOwnerModulePromise = null;
|
|
41
|
+
/** Load rewrite-aware hybrid route ownership before navigation becomes interactive. */
|
|
42
|
+
async function preloadHybridClientRouteOwner() {
|
|
43
|
+
if (hybridClientRouteOwnerModule) return;
|
|
44
|
+
hybridClientRouteOwnerModulePromise ??= import("./internal/hybrid-client-route-owner.js");
|
|
45
|
+
hybridClientRouteOwnerModule = await hybridClientRouteOwnerModulePromise;
|
|
46
|
+
}
|
|
47
|
+
function resolveLoadedHybridClientRewriteHref(href, basePath) {
|
|
48
|
+
return hybridClientRouteOwnerModule?.resolveHybridClientRewriteHref(href, basePath) ?? null;
|
|
49
|
+
}
|
|
50
|
+
function resolveHybridClientRouteOwner(href) {
|
|
51
|
+
if (!HAS_PAGES_ROUTER) return null;
|
|
52
|
+
return hybridClientRouteOwnerModule ? hybridClientRouteOwnerModule.resolveHybridClientRouteOwner(href, __basePath) : resolveDirectHybridClientRouteOwner(href, __basePath);
|
|
53
|
+
}
|
|
37
54
|
/**
|
|
38
55
|
* Read the child segments for a parallel route below the current layout.
|
|
39
56
|
* Returns [] if no context is available (RSC environment, outside React tree)
|
|
@@ -331,7 +348,7 @@ function notifyPrefetchInvalidated(entry) {
|
|
|
331
348
|
}
|
|
332
349
|
function deletePrefetchCacheEntry(cache, prefetched, cacheKey, entry, notify) {
|
|
333
350
|
adjustPrefetchCacheByteSize(cache, -getPrefetchCacheEntrySize(entry));
|
|
334
|
-
const cacheKeys = entry.cacheKeys ?? new Set([cacheKey]);
|
|
351
|
+
const cacheKeys = entry.cacheKeys ?? /* @__PURE__ */ new Set([cacheKey]);
|
|
335
352
|
for (const key of cacheKeys) {
|
|
336
353
|
if (cache.get(key) === entry) cache.delete(key);
|
|
337
354
|
prefetched.delete(key);
|
|
@@ -384,7 +401,7 @@ function seedPrefetchResponseSnapshot(rscUrl, snapshot, interceptionContext = nu
|
|
|
384
401
|
const timestamp = Date.now();
|
|
385
402
|
const entry = {
|
|
386
403
|
cacheForNavigation: true,
|
|
387
|
-
cacheKeys: new Set([cacheKey]),
|
|
404
|
+
cacheKeys: /* @__PURE__ */ new Set([cacheKey]),
|
|
388
405
|
expiresAt: resolveCachedRscResponseExpiresAt(timestamp, snapshot, fallbackTtlMs),
|
|
389
406
|
mountedSlotsHeader,
|
|
390
407
|
outcome: "cache-seeded",
|
|
@@ -428,7 +445,7 @@ function storePrefetchResponse(rscUrl, response, interceptionContext = null, opt
|
|
|
428
445
|
const existing = cache.get(cacheKey);
|
|
429
446
|
if (existing) deletePrefetchCacheEntry(cache, prefetched, cacheKey, existing, false);
|
|
430
447
|
const entry = {
|
|
431
|
-
cacheKeys: new Set([cacheKey]),
|
|
448
|
+
cacheKeys: /* @__PURE__ */ new Set([cacheKey]),
|
|
432
449
|
mountedSlotsHeader: null,
|
|
433
450
|
outcome: "pending",
|
|
434
451
|
timestamp: Date.now()
|
|
@@ -531,7 +548,7 @@ function prefetchRscResponse(rscUrl, fetchPromise, interceptionContext = null, m
|
|
|
531
548
|
if (existing) deletePrefetchCacheEntry(cache, prefetched, cacheKey, existing, false);
|
|
532
549
|
const entry = {
|
|
533
550
|
cacheForNavigation: behavior.cacheForNavigation ?? true,
|
|
534
|
-
cacheKeys: new Set([cacheKey]),
|
|
551
|
+
cacheKeys: /* @__PURE__ */ new Set([cacheKey]),
|
|
535
552
|
mountedSlotsHeader,
|
|
536
553
|
optimisticRouteShell: behavior.optimisticRouteShell === true,
|
|
537
554
|
outcome: "pending",
|
|
@@ -577,7 +594,7 @@ function addRenderedPathAndSearchPrefetchAlias(cache, prefetched, primaryCacheKe
|
|
|
577
594
|
if (aliasCacheKey === primaryCacheKey) return;
|
|
578
595
|
const existing = cache.get(aliasCacheKey);
|
|
579
596
|
if (existing && existing !== entry) deletePrefetchCacheEntry(cache, prefetched, aliasCacheKey, existing, false);
|
|
580
|
-
entry.cacheKeys ??= new Set([primaryCacheKey]);
|
|
597
|
+
entry.cacheKeys ??= /* @__PURE__ */ new Set([primaryCacheKey]);
|
|
581
598
|
entry.cacheKeys.add(aliasCacheKey);
|
|
582
599
|
cache.set(aliasCacheKey, entry);
|
|
583
600
|
prefetched.add(aliasCacheKey);
|
|
@@ -941,12 +958,6 @@ function useParams() {
|
|
|
941
958
|
if (renderSnapshot && (getClientNavigationState()?.navigationSnapshotActiveCount ?? 0) > 0) return renderSnapshot.params;
|
|
942
959
|
return params;
|
|
943
960
|
}
|
|
944
|
-
/**
|
|
945
|
-
* Check if a href is an external URL (any URL scheme per RFC 3986, or protocol-relative).
|
|
946
|
-
*/
|
|
947
|
-
function isExternalUrl(href) {
|
|
948
|
-
return isAbsoluteOrProtocolRelativeUrl(href);
|
|
949
|
-
}
|
|
950
961
|
function withSuppressedUrlNotifications(fn) {
|
|
951
962
|
const state = getClientNavigationState();
|
|
952
963
|
if (!state) return fn();
|
|
@@ -1094,7 +1105,7 @@ async function navigateClientSide(href, mode, scroll, programmaticTransition = f
|
|
|
1094
1105
|
}
|
|
1095
1106
|
normalizedHref = localPath;
|
|
1096
1107
|
}
|
|
1097
|
-
const hybridOwner = resolveHybridClientRouteOwner(normalizedHref
|
|
1108
|
+
const hybridOwner = resolveHybridClientRouteOwner(normalizedHref);
|
|
1098
1109
|
if (hybridOwner === "pages" || hybridOwner === "document") {
|
|
1099
1110
|
const fullHref = toBrowserNavigationHref(normalizedHref, window.location.href, __basePath);
|
|
1100
1111
|
notifyAppRouterTransitionStart(fullHref, mode);
|
|
@@ -1238,12 +1249,12 @@ const _appRouter = {
|
|
|
1238
1249
|
}
|
|
1239
1250
|
(async () => {
|
|
1240
1251
|
let prefetchHref = href;
|
|
1241
|
-
if (
|
|
1252
|
+
if (isExternalUrl(href)) {
|
|
1242
1253
|
const localPath = toSameOriginAppPath(href, __basePath);
|
|
1243
1254
|
if (localPath == null) return;
|
|
1244
1255
|
prefetchHref = localPath;
|
|
1245
1256
|
}
|
|
1246
|
-
const hybridOwner = resolveHybridClientRouteOwner(prefetchHref
|
|
1257
|
+
const hybridOwner = resolveHybridClientRouteOwner(prefetchHref);
|
|
1247
1258
|
if (hybridOwner === "pages" || hybridOwner === "document") return;
|
|
1248
1259
|
const fullHref = toBrowserNavigationHref(prefetchHref, window.location.href, __basePath);
|
|
1249
1260
|
const interceptionContext = getPrefetchInterceptionContext(fullHref);
|
|
@@ -1273,7 +1284,7 @@ if (process.env.__NEXT_GESTURE_TRANSITION) _appRouter.experimental_gesturePush =
|
|
|
1273
1284
|
if (isServer) return;
|
|
1274
1285
|
if (!getNavigationRuntime()?.functions.navigate) return;
|
|
1275
1286
|
let appHref = href;
|
|
1276
|
-
if (
|
|
1287
|
+
if (isExternalUrl(href)) {
|
|
1277
1288
|
const localPath = toSameOriginAppPath(href, __basePath);
|
|
1278
1289
|
if (localPath === null) return;
|
|
1279
1290
|
appHref = localPath;
|
|
@@ -1401,4 +1412,4 @@ if (!isServer) {
|
|
|
1401
1412
|
}
|
|
1402
1413
|
}
|
|
1403
1414
|
//#endregion
|
|
1404
|
-
export { BailoutToCSRError, DYNAMIC_NAVIGATION_CACHE_TTL, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, PREFETCH_CACHE_TTL, ReadonlyURLSearchParams, RedirectType, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, applyAppRouterScrollFallback, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, deletePrefetchResponseSnapshot, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, hasSearchAgnosticPrefetchShellForRoute, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, peekPrefetchResponseForNavigation, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, seedPrefetchResponseSnapshot, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
|
1415
|
+
export { BailoutToCSRError, DYNAMIC_NAVIGATION_CACHE_TTL, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, PREFETCH_CACHE_TTL, ReadonlyURLSearchParams, RedirectType, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, applyAppRouterScrollFallback, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, deletePrefetchResponseSnapshot, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, hasSearchAgnosticPrefetchShellForRoute, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, peekPrefetchResponseForNavigation, permanentRedirect, prefetchRscResponse, preloadHybridClientRouteOwner, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolveLoadedHybridClientRewriteHref, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, seedPrefetchResponseSnapshot, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@vinext/types/next/augmentations";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@vinext/types/next";
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//#region src/shims/public-shim-map.json
|
|
2
|
+
var public_shim_map_default = {
|
|
3
|
+
"next/link": {
|
|
4
|
+
"shim": "link",
|
|
5
|
+
"types": "upstream"
|
|
6
|
+
},
|
|
7
|
+
"next/head": {
|
|
8
|
+
"shim": "head",
|
|
9
|
+
"types": "upstream"
|
|
10
|
+
},
|
|
11
|
+
"next/router": {
|
|
12
|
+
"shim": "router",
|
|
13
|
+
"types": "upstream"
|
|
14
|
+
},
|
|
15
|
+
"next/compat/router": {
|
|
16
|
+
"shim": "compat-router",
|
|
17
|
+
"types": "upstream"
|
|
18
|
+
},
|
|
19
|
+
"next/image": {
|
|
20
|
+
"shim": "image",
|
|
21
|
+
"types": "upstream"
|
|
22
|
+
},
|
|
23
|
+
"next/legacy/image": {
|
|
24
|
+
"shim": "legacy-image",
|
|
25
|
+
"types": "upstream"
|
|
26
|
+
},
|
|
27
|
+
"next/dynamic": {
|
|
28
|
+
"shim": "dynamic",
|
|
29
|
+
"types": "upstream"
|
|
30
|
+
},
|
|
31
|
+
"next/app": {
|
|
32
|
+
"shim": "app",
|
|
33
|
+
"types": "upstream"
|
|
34
|
+
},
|
|
35
|
+
"next/document": {
|
|
36
|
+
"shim": "document",
|
|
37
|
+
"types": "upstream"
|
|
38
|
+
},
|
|
39
|
+
"next/config": {
|
|
40
|
+
"shim": "config",
|
|
41
|
+
"types": "vinext"
|
|
42
|
+
},
|
|
43
|
+
"next/script": {
|
|
44
|
+
"shim": "script",
|
|
45
|
+
"types": "upstream"
|
|
46
|
+
},
|
|
47
|
+
"next/server": {
|
|
48
|
+
"shim": "server",
|
|
49
|
+
"types": "upstream"
|
|
50
|
+
},
|
|
51
|
+
"next/navigation": {
|
|
52
|
+
"shim": "navigation",
|
|
53
|
+
"types": "upstream",
|
|
54
|
+
"reactServer": true
|
|
55
|
+
},
|
|
56
|
+
"next/headers": {
|
|
57
|
+
"shim": "headers",
|
|
58
|
+
"types": "upstream"
|
|
59
|
+
},
|
|
60
|
+
"next/font/google": {
|
|
61
|
+
"shim": "font-google",
|
|
62
|
+
"types": "upstream"
|
|
63
|
+
},
|
|
64
|
+
"next/font/local": {
|
|
65
|
+
"shim": "font-local",
|
|
66
|
+
"types": "upstream"
|
|
67
|
+
},
|
|
68
|
+
"next/cache": {
|
|
69
|
+
"shim": "cache",
|
|
70
|
+
"types": "upstream"
|
|
71
|
+
},
|
|
72
|
+
"next/form": {
|
|
73
|
+
"shim": "form",
|
|
74
|
+
"types": "upstream"
|
|
75
|
+
},
|
|
76
|
+
"next/og": {
|
|
77
|
+
"shim": "og",
|
|
78
|
+
"types": "upstream"
|
|
79
|
+
},
|
|
80
|
+
"next/web-vitals": {
|
|
81
|
+
"shim": "web-vitals",
|
|
82
|
+
"types": "vinext"
|
|
83
|
+
},
|
|
84
|
+
"next/amp": {
|
|
85
|
+
"shim": "amp",
|
|
86
|
+
"types": "vinext"
|
|
87
|
+
},
|
|
88
|
+
"next/offline": {
|
|
89
|
+
"shim": "offline",
|
|
90
|
+
"types": "vinext"
|
|
91
|
+
},
|
|
92
|
+
"next/error": {
|
|
93
|
+
"shim": "error",
|
|
94
|
+
"types": "upstream",
|
|
95
|
+
"reactServer": true
|
|
96
|
+
},
|
|
97
|
+
"next/constants": {
|
|
98
|
+
"shim": "constants",
|
|
99
|
+
"types": "upstream"
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
103
|
+
export { public_shim_map_default as default };
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Mutation methods remain present for instanceof/API compatibility but throw.
|
|
5
5
|
*/
|
|
6
6
|
declare class ReadonlyURLSearchParams extends URLSearchParams {
|
|
7
|
-
append(
|
|
8
|
-
delete(
|
|
9
|
-
set(
|
|
7
|
+
append(): never;
|
|
8
|
+
delete(): never;
|
|
9
|
+
set(): never;
|
|
10
10
|
sort(): never;
|
|
11
11
|
}
|
|
12
12
|
//#endregion
|
|
@@ -9,13 +9,13 @@ var ReadonlyURLSearchParamsError = class extends Error {
|
|
|
9
9
|
* Mutation methods remain present for instanceof/API compatibility but throw.
|
|
10
10
|
*/
|
|
11
11
|
var ReadonlyURLSearchParams = class extends URLSearchParams {
|
|
12
|
-
append(
|
|
12
|
+
append() {
|
|
13
13
|
throw new ReadonlyURLSearchParamsError();
|
|
14
14
|
}
|
|
15
|
-
delete(
|
|
15
|
+
delete() {
|
|
16
16
|
throw new ReadonlyURLSearchParamsError();
|
|
17
17
|
}
|
|
18
|
-
set(
|
|
18
|
+
set() {
|
|
19
19
|
throw new ReadonlyURLSearchParamsError();
|
|
20
20
|
}
|
|
21
21
|
sort() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NavigationContext } from "./navigation-context-state.js";
|
|
2
|
-
import { RootParamsState } from "./root-params.js";
|
|
3
2
|
import { CacheLifeConfig, CacheState } from "./cache-request-state.js";
|
|
3
|
+
import { RootParamsState } from "./root-params.js";
|
|
4
4
|
import { ExecutionContextLike } from "./request-context.js";
|
|
5
5
|
import { FetchCacheState } from "./fetch-cache.js";
|
|
6
6
|
import { HeadersAccessPhase, HeadersContext, VinextHeadersShimState } from "./headers.js";
|