vinext 1.0.0-beta.11 → 1.0.0-beta.13

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.
Files changed (170) hide show
  1. package/README.md +39 -12
  2. package/dist/build/action-owner-manifest.js +23 -5
  3. package/dist/build/lifecycle.d.ts +42 -0
  4. package/dist/build/lifecycle.js +246 -0
  5. package/dist/build/nitro-route-rules.js +1 -1
  6. package/dist/build/pages-client-assets-module.d.ts +0 -3
  7. package/dist/build/pages-client-assets-module.js +1 -13
  8. package/dist/build/precompress.js +1 -1
  9. package/dist/build/prerender-paths.d.ts +1 -1
  10. package/dist/build/prerender-paths.js +6 -6
  11. package/dist/build/prerender-server-pool.js +1 -1
  12. package/dist/build/prerender.d.ts +1 -1
  13. package/dist/build/prerender.js +5 -5
  14. package/dist/build/preview-credentials.d.ts +1 -1
  15. package/dist/build/preview-credentials.js +2 -2
  16. package/dist/build/report.js +1 -1
  17. package/dist/build/run-prerender.d.ts +2 -2
  18. package/dist/build/run-prerender.js +5 -5
  19. package/dist/build/standalone.js +2 -2
  20. package/dist/cli-args.d.ts +5 -13
  21. package/dist/cli-args.js +2 -45
  22. package/dist/cli-dev-config.d.ts +6 -2
  23. package/dist/cli-dev-config.js +160 -3
  24. package/dist/cli.js +104 -439
  25. package/dist/config/config-matchers.js +1 -1
  26. package/dist/config/next-config.d.ts +2 -2
  27. package/dist/config/next-config.js +5 -5
  28. package/dist/config/prerender.d.ts +3 -0
  29. package/dist/config/prerender.js +8 -2
  30. package/dist/entries/app-browser-entry.js +1 -1
  31. package/dist/entries/app-rsc-entry.d.ts +2 -0
  32. package/dist/entries/app-rsc-entry.js +25 -5
  33. package/dist/entries/pages-client-entry.d.ts +1 -0
  34. package/dist/entries/pages-client-entry.js +17 -2
  35. package/dist/index.d.ts +6 -8
  36. package/dist/index.js +282 -105
  37. package/dist/init-cloudflare.d.ts +3 -2
  38. package/dist/init-cloudflare.js +117 -5
  39. package/dist/init-platform.d.ts +2 -0
  40. package/dist/init-platform.js +9 -3
  41. package/dist/init.d.ts +7 -5
  42. package/dist/init.js +41 -22
  43. package/dist/plugins/dynamic-preload-metadata.js +1 -1
  44. package/dist/plugins/extensionless-dynamic-import.js +2 -2
  45. package/dist/plugins/fonts.js +1 -1
  46. package/dist/plugins/ignore-dynamic-requests.js +1 -1
  47. package/dist/plugins/import-meta-url.js +1 -1
  48. package/dist/plugins/instrumentation-client.js +1 -1
  49. package/dist/plugins/og-assets.js +32 -13
  50. package/dist/plugins/og-harfbuzz.d.ts +24 -0
  51. package/dist/plugins/og-harfbuzz.js +260 -0
  52. package/dist/plugins/optimize-imports.js +1 -1
  53. package/dist/plugins/require-condition-resolution.js +2 -2
  54. package/dist/plugins/require-context.js +2 -2
  55. package/dist/plugins/typeof-window.js +1 -1
  56. package/dist/plugins/use-cache-callable.d.ts +0 -2
  57. package/dist/plugins/use-cache-callable.js +40 -22
  58. package/dist/plugins/worker-image-imports.js +1 -1
  59. package/dist/routing/app-route-graph.js +1 -1
  60. package/dist/routing/app-router.js +1 -1
  61. package/dist/routing/pages-router.js +1 -1
  62. package/dist/server/app-action-forwarding.js +1 -1
  63. package/dist/server/app-browser-entry.js +1 -0
  64. package/dist/server/app-browser-error.js +1 -1
  65. package/dist/server/app-elements-wire.js +2 -2
  66. package/dist/server/app-middleware.js +1 -1
  67. package/dist/server/app-optimistic-routing.js +1 -1
  68. package/dist/server/app-page-cache-finalizer.d.ts +1 -0
  69. package/dist/server/app-page-cache-finalizer.js +14 -2
  70. package/dist/server/app-page-dispatch.js +1 -1
  71. package/dist/server/app-page-element-builder.js +3 -2
  72. package/dist/server/app-page-probe.js +3 -3
  73. package/dist/server/app-page-render.js +1 -0
  74. package/dist/server/app-page-request.d.ts +2 -0
  75. package/dist/server/app-page-request.js +16 -12
  76. package/dist/server/app-request-stage-dispatch.js +1 -1
  77. package/dist/server/app-request-stage-independent-entry.js +2 -2
  78. package/dist/server/app-route-handler-dispatch.d.ts +1 -0
  79. package/dist/server/app-route-handler-dispatch.js +3 -2
  80. package/dist/server/app-route-handler-execution.d.ts +1 -0
  81. package/dist/server/app-route-handler-execution.js +2 -2
  82. package/dist/server/app-route-handler-runtime.js +1 -1
  83. package/dist/server/app-router-entry.js +2 -2
  84. package/dist/server/app-rsc-handler.d.ts +9 -2
  85. package/dist/server/app-rsc-handler.js +30 -10
  86. package/dist/server/app-rsc-response-stage.js +6 -3
  87. package/dist/server/app-rsc-route-matching.js +1 -1
  88. package/dist/server/app-server-action-execution.js +35 -6
  89. package/dist/server/app-ssr-entry.js +7 -2
  90. package/dist/server/app-ssr-stream.js +25 -6
  91. package/dist/server/app-worker-stages.d.ts +4 -1
  92. package/dist/server/app-worker-stages.js +4 -4
  93. package/dist/server/artifact-compatibility.js +1 -1
  94. package/dist/server/client-reuse-manifest.js +1 -1
  95. package/dist/server/dev-lockfile.d.ts +1 -1
  96. package/dist/server/dev-lockfile.js +4 -1
  97. package/dist/server/dev-server.d.ts +1 -1
  98. package/dist/server/dev-server.js +28 -6
  99. package/dist/server/dev-stack-sourcemap.js +1 -1
  100. package/dist/server/html.d.ts +0 -20
  101. package/dist/server/html.js +16 -1
  102. package/dist/server/instrumentation.d.ts +4 -9
  103. package/dist/server/instrumentation.js +10 -15
  104. package/dist/server/isr-cache.js +3 -3
  105. package/dist/server/metadata-route-response.d.ts +1 -0
  106. package/dist/server/metadata-route-response.js +65 -0
  107. package/dist/server/middleware-runtime.js +3 -3
  108. package/dist/server/pages-asset-tags.d.ts +1 -0
  109. package/dist/server/pages-asset-tags.js +37 -2
  110. package/dist/server/pages-client-assets.d.ts +7 -0
  111. package/dist/server/pages-data-route.js +1 -1
  112. package/dist/server/pages-dev-hydration.d.ts +6 -0
  113. package/dist/server/pages-dev-hydration.js +19 -7
  114. package/dist/server/pages-document-initial-props.d.ts +1 -0
  115. package/dist/server/pages-document-initial-props.js +1 -1
  116. package/dist/server/pages-page-data.js +2 -2
  117. package/dist/server/pages-page-handler.js +5 -2
  118. package/dist/server/pages-page-response.d.ts +1 -0
  119. package/dist/server/pages-page-response.js +3 -2
  120. package/dist/server/pages-request-pipeline.js +3 -3
  121. package/dist/server/pages-request-stage-entry.js +3 -3
  122. package/dist/server/pages-revalidate.js +1 -1
  123. package/dist/server/prerender-route-params.js +1 -1
  124. package/dist/server/prod-server.js +19 -13
  125. package/dist/server/request-pipeline.js +2 -2
  126. package/dist/server/rsc-stream-hints.d.ts +12 -0
  127. package/dist/server/rsc-stream-hints.js +70 -35
  128. package/dist/server/seed-cache.js +3 -4
  129. package/dist/server/socket-error-backstop.js +1 -1
  130. package/dist/shims/cache-callable-runtime.d.ts +38 -0
  131. package/dist/shims/cache-callable-runtime.js +162 -11
  132. package/dist/shims/cache-runtime.d.ts +6 -8
  133. package/dist/shims/cache-runtime.js +89 -24
  134. package/dist/shims/constants.js +1 -1
  135. package/dist/shims/dynamic-preload-chunks.js +6 -2
  136. package/dist/shims/font-local.js +1 -1
  137. package/dist/shims/form.js +1 -1
  138. package/dist/shims/head.js +1 -1
  139. package/dist/shims/headers.js +2 -2
  140. package/dist/shims/image-config.js +2 -0
  141. package/dist/shims/internal/app-page-props-cache-key.d.ts +29 -0
  142. package/dist/shims/internal/app-page-props-cache-key.js +53 -1
  143. package/dist/shims/internal/format-url-object.d.ts +7 -0
  144. package/dist/shims/internal/format-url-object.js +53 -0
  145. package/dist/shims/internal/normalize-router-href.d.ts +15 -0
  146. package/dist/shims/internal/normalize-router-href.js +41 -0
  147. package/dist/shims/internal/pages-data-target.d.ts +4 -1
  148. package/dist/shims/internal/pages-data-target.js +28 -35
  149. package/dist/shims/internal/route-pattern-for-warning.d.ts +2 -2
  150. package/dist/shims/internal/route-pattern-for-warning.js +3 -3
  151. package/dist/shims/link.js +31 -92
  152. package/dist/shims/metadata.js +5 -4
  153. package/dist/shims/navigation.js +2 -2
  154. package/dist/shims/router-state.js +1 -1
  155. package/dist/shims/router.d.ts +8 -7
  156. package/dist/shims/router.js +312 -148
  157. package/dist/shims/script-nonce-context.d.ts +4 -1
  158. package/dist/shims/script-nonce-context.js +15 -6
  159. package/dist/shims/server.js +3 -3
  160. package/dist/utils/built-asset-url.js +1 -1
  161. package/dist/utils/client-runtime-metadata.d.ts +6 -0
  162. package/dist/utils/client-runtime-metadata.js +16 -0
  163. package/dist/utils/lazy-chunks.js +1 -1
  164. package/dist/utils/project.d.ts +1 -11
  165. package/dist/utils/project.js +20 -29
  166. package/dist/utils/react-version.d.ts +3 -1
  167. package/dist/utils/react-version.js +19 -1
  168. package/dist/utils/vite-cli-invocation.d.ts +21 -0
  169. package/dist/utils/vite-cli-invocation.js +144 -0
  170. package/package.json +10 -2
@@ -1,15 +1,16 @@
1
1
  "use client";
2
+ import { isBotUserAgent } from "../utils/html-limited-bots.js";
2
3
  import { isDangerousScheme, reportBlockedDangerousNavigation } from "./url-safety.js";
3
4
  import { addLocalePrefix, getDomainLocaleUrl } from "../utils/domain-locale.js";
4
5
  import { RouterContext } from "./internal/router-context.js";
5
6
  import { getPagesMiddlewareDataHref, prefetchPagesData, resolvePagesDataNavigationTarget } from "./internal/pages-data-target.js";
6
7
  import { markAppRouteDetectedOnPrefetch } from "./internal/app-route-detection.js";
7
8
  import { isAbsoluteOrProtocolRelativeUrl, normalizePathTrailingSlash, toCanonicalBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
8
- import { appendSearchParamsToUrl, urlQueryToSearchParams } from "../utils/query.js";
9
9
  import { interpolateDynamicRouteHref, resolveDynamicRouteHref } from "./internal/interpolate-as.js";
10
- import { getCurrentBrowserLocale } from "./client-locale.js";
10
+ import { formatUrlObject, formatUrlObjectWithValidation } from "./internal/format-url-object.js";
11
+ import { normalizeRouterHref, resolvePagesRouterHref } from "./internal/normalize-router-href.js";
11
12
  import { getCurrentRoutePathnameForWarning } from "./internal/route-pattern-for-warning.js";
12
- import { isBotUserAgent } from "../utils/html-limited-bots.js";
13
+ import { getCurrentBrowserLocale } from "./client-locale.js";
13
14
  import { getNavigationRuntime, hasAppNavigationRuntime, registerNavigationRuntimeFunctions } from "../client/navigation-runtime.js";
14
15
  import { navigatePagesRouterLinkWithFallback, resolvePagesRouterQueryOnlyHref } from "../client/pages-router-link-navigation.js";
15
16
  import { scheduleAppPrefetchFetch } from "./internal/app-prefetch-fetch-queue.js";
@@ -65,15 +66,15 @@ const __basePath = process.env.__NEXT_ROUTER_BASEPATH ?? "";
65
66
  /** trailingSlash from next.config.js, injected by the plugin at build time */
66
67
  const __trailingSlash = process.env.__VINEXT_TRAILING_SLASH === "true";
67
68
  const __prefetchInlining = process.env.__VINEXT_PREFETCH_INLINING === "true";
68
- function resolveHref(href) {
69
+ function resolveHref(href, validate = false) {
69
70
  if (typeof href === "string") return href;
70
- let url = href.pathname ?? "";
71
- if (href.query) {
72
- const params = urlQueryToSearchParams(href.query);
73
- url = appendSearchParamsToUrl(url, params);
74
- }
75
- if (href.hash) url += href.hash.startsWith("#") ? href.hash : `#${href.hash}`;
76
- return url;
71
+ return validate ? formatUrlObjectWithValidation(href) : formatUrlObject(href);
72
+ }
73
+ function resolvePagesLinkValue(value, pagesRouter, routePathnameForWarning) {
74
+ const formatted = resolveHref(value, pagesRouter !== null);
75
+ if (pagesRouter === null) return formatted;
76
+ if (typeof pagesRouter.pathname === "string" && typeof pagesRouter.asPath === "string" && !formatted.startsWith("?") && !formatted.startsWith("#")) return resolvePagesRouterHref(formatted, pagesRouter, __basePath);
77
+ return normalizeRouterHref(formatted, routePathnameForWarning);
77
78
  }
78
79
  function resolvePagesQueryOnlyHref(href) {
79
80
  if (!HAS_PAGES_ROUTER) return href;
@@ -95,52 +96,6 @@ function applyPagesNavigationFallback(href, replace) {
95
96
  else window.history.pushState({}, "", href);
96
97
  window.dispatchEvent(new PopStateEvent("popstate"));
97
98
  }
98
- /**
99
- * Collapse repeated forward-slashes (and convert backslashes to forward-slashes)
100
- * in the path portion of a URL, preserving any query string.
101
- *
102
- * Ported from Next.js: packages/next/src/shared/lib/utils/normalize-repeated-slashes.ts
103
- * https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/utils/normalize-repeated-slashes.ts
104
- */
105
- function normalizeRepeatedSlashes(url) {
106
- const urlParts = url.split("?");
107
- const urlNoQueryString = urlParts.shift() ?? "";
108
- const queryString = urlParts.join("?");
109
- return urlNoQueryString.replace(/\\/g, "/").replace(/\/\/+/g, "/") + (queryString ? `?${queryString}` : "");
110
- }
111
- /**
112
- * Emit Next.js's "Invalid href" `console.error` when `href` contains repeated
113
- * forward slashes or backslashes in its path portion, and return the
114
- * normalized URL (with `\\` converted to `/` and runs of `/` collapsed). If
115
- * the href is already well-formed, the original string is returned unchanged.
116
- *
117
- * Ported from Next.js: packages/next/src/client/resolve-href.ts
118
- * https://github.com/vercel/next.js/blob/canary/packages/next/src/client/resolve-href.ts
119
- *
120
- * Matches the message asserted by:
121
- * test/e2e/repeated-forward-slashes-error/repeated-forward-slashes-error.test.ts
122
- *
123
- * Note: Next.js fires this warning unconditionally on every call to
124
- * `resolveHref`. We mirror that behaviour (no dedup) for exact parity.
125
- *
126
- * Note: Next.js uses `router.pathname` (the route pattern, e.g.
127
- * `/posts/[id]`) for the "in page" segment of the message. The Next.js
128
- * compat test asserts this exact text (`in page: '/my/path/[name]'`), so we
129
- * source it from the current render's route pattern via
130
- * `getCurrentRoutePathnameForWarning()`: the Pages Router SSR context's route
131
- * pattern on the server, `window.location.pathname` on the client, falling
132
- * back to `"/"`.
133
- */
134
- function warnAndNormalizeRepeatedSlashesInHref(urlAsString) {
135
- if (urlAsString.startsWith("//")) return urlAsString;
136
- const urlProtoMatch = urlAsString.match(/^[a-z][a-z0-9+.-]*:\/\//i);
137
- const urlAsStringNoProto = urlProtoMatch ? urlAsString.slice(urlProtoMatch[0].length) : urlAsString;
138
- if (!(urlAsStringNoProto.split("?", 1)[0] || "").match(/(\/\/|\\)/)) return urlAsString;
139
- const pathname = getCurrentRoutePathnameForWarning();
140
- console.error(`Invalid href '${urlAsString}' passed to next/router in page: '${pathname}'. Repeated forward-slashes (//) or backslashes \\ are not valid in the href.`);
141
- const normalizedNoProto = normalizeRepeatedSlashes(urlAsStringNoProto);
142
- return (urlProtoMatch ? urlProtoMatch[0] : "") + normalizedNoProto;
143
- }
144
99
  function resolveLinkPrefetchMode(prefetchProp, isDangerous) {
145
100
  if (isDangerous || prefetchProp === false) return "disabled";
146
101
  if (prefetchProp === true) return "full";
@@ -335,7 +290,7 @@ function prefetchUrl(href, mode, priority = "low", pagesRouteHref, locale) {
335
290
  } else if (HAS_PAGES_ROUTER && window.__NEXT_DATA__) {
336
291
  const dataTarget = resolvePagesDataNavigationTarget(fullRouteHref, __basePath, { locale });
337
292
  if (dataTarget) {
338
- const middlewareDataHref = fullRouteHref === fullHref ? dataTarget.middlewareDataHref : getPagesMiddlewareDataHref(fullHref, __basePath, { locale }) ?? void 0;
293
+ const middlewareDataHref = fullRouteHref === fullHref ? dataTarget.middlewareDataHref : getPagesMiddlewareDataHref(fullHref, __basePath, { locale }, fullRouteHref) ?? void 0;
339
294
  prefetchPagesData({
340
295
  ...dataTarget,
341
296
  middlewareDataHref
@@ -497,50 +452,34 @@ function applyLocaleToHref(href, locale) {
497
452
  }
498
453
  return addLocalePrefix(href, resolvedLocale, defaultLocale);
499
454
  }
500
- /**
501
- * For the `<Link href="/blog/[slug]" as="/blog/test-post">` case, project the
502
- * bracket-pattern href + the resolved `as` back into a concrete route URL the
503
- * Pages Router can fetch (`/blog/test-post`). Returns null when:
504
- * - `href` has no bracket params (already concrete; the existing forwarding
505
- * path works as-is)
506
- * - interpolation fails because a required param could not be resolved
507
- * (caller falls back to `as`, matching pre-PR behavior)
508
- *
509
- * The query for interpolation is the href's own query — `as` is the matcher
510
- * input rather than the source of param values. For string hrefs the search
511
- * portion is parsed into the query record; for object hrefs we take
512
- * `href.query` directly.
513
- */
455
+ /** Resolve a dynamic route pattern to the concrete URL used for prefetching. */
514
456
  function resolveConcreteRouteHref(href, as) {
515
457
  if (typeof as !== "string") return null;
516
- const hrefStr = typeof href === "string" ? href : resolveHref(href);
517
- return interpolateDynamicRouteHref(hrefStr, as, typeof href === "string" || !href.query || typeof href.query === "string" ? void 0 : href.query)?.href || null;
458
+ return interpolateDynamicRouteHref(href, as)?.href || null;
518
459
  }
519
460
  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) {
520
461
  const pagesRouter = useContext(RouterContext);
521
- const asHref = as === void 0 ? void 0 : resolveHref(as);
522
- const hrefStr = resolveHref(href);
462
+ const routePathnameForWarning = getCurrentRoutePathnameForWarning();
463
+ const hrefStr = resolvePagesLinkValue(href, pagesRouter, routePathnameForWarning);
464
+ const asHref = as === void 0 ? void 0 : resolvePagesLinkValue(as, pagesRouter, routePathnameForWarning);
523
465
  const { locale, ...restWithoutLocale } = rest;
524
466
  let children = childrenProp;
525
467
  if (legacyBehavior && (typeof childrenProp === "string" || typeof childrenProp === "number")) children = React.createElement("a", null, childrenProp);
526
468
  const hrefForImplicitInterpolation = isAbsoluteOrProtocolRelativeUrl(hrefStr) ? hrefStr.startsWith("//") ? null : toSameOriginAppPath(hrefStr, __basePath) : hrefStr;
527
469
  const implicitDynamicRouteHref = HAS_PAGES_ROUTER && pagesRouter !== null && asHref === void 0 && hrefForImplicitInterpolation !== null ? resolveDynamicRouteHref(hrefForImplicitInterpolation) : null;
528
- const dynamicRouteHref = implicitDynamicRouteHref ? {
529
- ...implicitDynamicRouteHref,
530
- href: hrefStr
531
- } : null;
532
- const pagesAsHref = asHref ?? dynamicRouteHref?.as;
470
+ const pagesAsHref = asHref ?? implicitDynamicRouteHref?.as;
533
471
  const unresolvedHref = pagesAsHref ?? hrefStr;
534
- const rawResolvedHref = typeof unresolvedHref === "string" && unresolvedHref.startsWith("#") && !getNavigationRuntime()?.functions.navigate ? resolvePagesQueryOnlyHref(unresolvedHref) : unresolvedHref;
535
- const concreteRouteHref = HAS_PAGES_ROUTER ? resolveConcreteRouteHref(dynamicRouteHref ? hrefForImplicitInterpolation ?? href : href, pagesAsHref) : null;
536
- const routeHrefRaw = dynamicRouteHref?.href ?? concreteRouteHref ?? hrefStr;
472
+ const resolvedHref = unresolvedHref.startsWith("#") && !getNavigationRuntime()?.functions.navigate ? resolvePagesQueryOnlyHref(unresolvedHref) : unresolvedHref;
473
+ const concreteRouteHref = HAS_PAGES_ROUTER ? resolveConcreteRouteHref(hrefForImplicitInterpolation ?? hrefStr, pagesAsHref) : null;
474
+ const routeHrefRaw = hrefStr;
537
475
  const prefetchRouteHrefRaw = concreteRouteHref ?? routeHrefRaw;
538
- const hasPagesHrefAsPair = HAS_PAGES_ROUTER && typeof pagesAsHref === "string" && typeof routeHrefRaw === "string" && pagesAsHref !== routeHrefRaw;
539
- const resolvedHref = typeof rawResolvedHref === "string" ? warnAndNormalizeRepeatedSlashesInHref(rawResolvedHref) : rawResolvedHref;
540
- const isDangerous = typeof resolvedHref === "string" && isDangerousScheme(resolvedHref);
476
+ const hasPagesHrefAsPair = HAS_PAGES_ROUTER && pagesAsHref !== void 0 && pagesAsHref !== routeHrefRaw;
477
+ const isDangerous = isDangerousScheme(resolvedHref);
478
+ const isRouteDangerous = isDangerousScheme(prefetchRouteHrefRaw);
479
+ const isPrefetchDangerous = isDangerous || pagesRouter !== null && isRouteDangerous;
541
480
  const localizedHref = applyLocaleToHref(isDangerous ? "/" : resolvedHref, locale);
542
481
  const normalizedHref = normalizePathTrailingSlash(localizedHref, __trailingSlash);
543
- const normalizedRouteHref = hasPagesHrefAsPair ? normalizePathTrailingSlash(applyLocaleToHref(isDangerous ? "/" : prefetchRouteHrefRaw, locale), __trailingSlash) : normalizedHref;
482
+ const normalizedRouteHref = hasPagesHrefAsPair ? normalizePathTrailingSlash(applyLocaleToHref(isRouteDangerous ? "/" : prefetchRouteHrefRaw, locale), __trailingSlash) : normalizedHref;
544
483
  const fullHref = normalizePathTrailingSlash(withBasePath(normalizedHref, __basePath), __trailingSlash);
545
484
  const [pending, setPending] = useState(false);
546
485
  const mountedRef = useRef(true);
@@ -562,11 +501,11 @@ const Link = forwardRef(function Link({ href, as, replace = false, prefetch: pre
562
501
  const prefetchRouterMode = getLinkPrefetchRouterMode();
563
502
  const isShallowPagesLink = prefetchRouterMode === "pages" && shallow;
564
503
  const effectivePrefetchProp = isShallowPagesLink ? false : prefetchProp;
565
- const prefetchMode = resolveLinkPrefetchMode(effectivePrefetchProp, isDangerous);
504
+ const prefetchMode = resolveLinkPrefetchMode(effectivePrefetchProp, isPrefetchDangerous);
566
505
  const shouldViewportPrefetch = canLinkPrefetch({
567
506
  nodeEnv: process.env.NODE_ENV,
568
507
  prefetch: effectivePrefetchProp,
569
- isDangerous
508
+ isDangerous: isPrefetchDangerous
570
509
  });
571
510
  const setRefs = useCallback((node) => {
572
511
  internalRef.current = node;
@@ -620,7 +559,7 @@ const Link = forwardRef(function Link({ href, as, replace = false, prefetch: pre
620
559
  if (isShallowPagesLink || !canLinkIntentPrefetch({
621
560
  nodeEnv: process.env.NODE_ENV,
622
561
  prefetch: effectivePrefetchProp,
623
- isDangerous,
562
+ isDangerous: isPrefetchDangerous,
624
563
  routerMode: prefetchRouterMode
625
564
  })) return;
626
565
  const intentMode = unstable_dynamicOnHover ? "full-after-shell" : prefetchMode;
@@ -632,7 +571,7 @@ const Link = forwardRef(function Link({ href, as, replace = false, prefetch: pre
632
571
  prefetchUrl(normalizedHref, intentMode, "high", normalizedRouteHref === normalizedHref ? void 0 : normalizedRouteHref, locale);
633
572
  }, [
634
573
  effectivePrefetchProp,
635
- isDangerous,
574
+ isPrefetchDangerous,
636
575
  isShallowPagesLink,
637
576
  prefetchMode,
638
577
  prefetchRouterMode,
@@ -1,5 +1,6 @@
1
1
  import { isAbsoluteOrProtocolRelativeUrl } from "./url-utils.js";
2
2
  import { makeThenableParams } from "./thenable-params.js";
3
+ import { withUseCachePageMarker } from "./internal/app-page-props-cache-key.js";
3
4
  import React from "react";
4
5
  import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
5
6
  //#region src/shims/metadata.tsx
@@ -18,10 +19,10 @@ const USE_CACHE_ACCEPTS_SECOND_ARGUMENT_SYMBOL = Symbol.for("vinext.useCacheAcce
18
19
  async function resolveModuleViewport(mod, params = {}, searchParams, parent = Promise.resolve(mergeViewport([])), searchParamsObserver) {
19
20
  if (typeof mod.generateViewport === "function") {
20
21
  const asyncParams = makeThenableParams(params);
21
- const props = searchParams === void 0 ? { params: asyncParams } : {
22
+ const props = searchParams === void 0 ? { params: asyncParams } : withUseCachePageMarker(mod.generateViewport, {
22
23
  params: asyncParams,
23
24
  searchParams: makeThenableParams(searchParams, searchParamsObserver)
24
- };
25
+ });
25
26
  return await mod.generateViewport(props, parent);
26
27
  }
27
28
  if (mod.viewport && typeof mod.viewport === "object") return mod.viewport;
@@ -267,10 +268,10 @@ async function resolveModuleMetadata(mod, params = {}, searchParams, parent = Pr
267
268
  if (typeof mod.generateMetadata === "function") {
268
269
  const generateMetadata = mod.generateMetadata;
269
270
  const asyncParams = makeThenableParams(params);
270
- const props = searchParams === void 0 ? { params: asyncParams } : {
271
+ const props = searchParams === void 0 ? { params: asyncParams } : withUseCachePageMarker(generateMetadata, {
271
272
  params: asyncParams,
272
273
  searchParams: makeThenableParams(searchParams, searchParamsObserver)
273
- };
274
+ });
274
275
  const isUseCacheFunction = Reflect.get(generateMetadata, USE_CACHE_FUNCTION_SYMBOL) === true;
275
276
  const acceptsSecondArgument = Reflect.get(generateMetadata, USE_CACHE_ACCEPTS_SECOND_ARGUMENT_SYMBOL);
276
277
  return await (!isUseCacheFunction || (typeof acceptsSecondArgument === "boolean" ? acceptsSecondArgument : generateMetadata.length >= 2) ? generateMetadata(props, parent) : generateMetadata(props));
@@ -1,8 +1,9 @@
1
+ import { isBotUserAgent } from "../utils/html-limited-bots.js";
2
+ import { isExternalUrl } from "../utils/external-url.js";
1
3
  import { stripBasePath } from "../utils/base-path.js";
2
4
  import { NEXT_ROUTER_PREFETCH_HEADER, NEXT_ROUTER_SEGMENT_PREFETCH_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_RSC_RENDER_MODE_HEADER } from "../server/app-rsc-vary.js";
3
5
  import { NEXT_ROUTER_STALE_TIME_HEADER, VINEXT_DYNAMIC_STALE_TIME_HEADER, VINEXT_PARAMS_HEADER, VINEXT_RENDERED_PATH_AND_SEARCH_HEADER, VINEXT_RSC_COMPLETION_METADATA_HEADER, VINEXT_STALE_TIME_PENDING_HEADER } from "../server/headers.js";
4
6
  import { assertSafeNavigationUrl } from "./url-safety.js";
5
- import { isExternalUrl } from "../utils/external-url.js";
6
7
  import { APP_RSC_RENDER_MODE_PREFETCH_DYNAMIC_SHELL, APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL } from "../server/app-rsc-render-mode.js";
7
8
  import { AppElementsWire } from "../server/app-elements-wire.js";
8
9
  import "../server/app-elements.js";
@@ -11,7 +12,6 @@ import { AppRouterContext } from "./internal/app-router-context.js";
11
12
  import { resolveDirectHybridClientRouteOwner } from "./internal/hybrid-client-route-owner-direct.js";
12
13
  import { isHashOnlyBrowserUrlChange, toCanonicalBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
13
14
  import { retryScrollTo, scrollToHashTarget, scrollToHashTargetOnNextFrame } from "./hash-scroll.js";
14
- import { isBotUserAgent } from "../utils/html-limited-bots.js";
15
15
  import { GLOBAL_ACCESSORS_KEY, ServerInsertedHTMLContext, _registerStateAccessors, clearClientHydrationContext, clearServerInsertedHTML, flushServerInsertedHTML, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getLayoutSegmentContext, getNavigationContext, registerServerInsertedHTMLCallback, renderServerInsertedHTML, setNavigationContext } from "./navigation-context-state.js";
16
16
  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";
17
17
  import { clearAppNavigationFailureTarget, stageAppNavigationFailureTarget } from "../client/app-nav-failure-handler.js";
@@ -1,7 +1,7 @@
1
1
  import { getOrCreateAls } from "./internal/als-registry.js";
2
2
  import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation } from "./unified-request-context.js";
3
- import { _registerRouterStateAccessors } from "./router.js";
4
3
  import { registerRoutePatternForWarningAccessor } from "./internal/route-pattern-for-warning.js";
4
+ import { _registerRouterStateAccessors } from "./router.js";
5
5
  //#region src/shims/router-state.ts
6
6
  /**
7
7
  * Server-only Pages Router state backed by AsyncLocalStorage.
@@ -11,6 +11,8 @@ type BeforePopStateCallback = (state: {
11
11
  as: string;
12
12
  options: TransitionOptions;
13
13
  }) => boolean;
14
+ type UrlObject$1 = UrlObject;
15
+ type Url = string | UrlObject$1;
14
16
  export type NextRouter = {
15
17
  /** Current pathname */
16
18
  pathname: string;
@@ -39,9 +41,9 @@ export type NextRouter = {
39
41
  /** Whether this is a fallback page */
40
42
  isFallback: boolean;
41
43
  /** Navigate to a new URL */
42
- push(url: string | UrlObject$1, as?: string, options?: TransitionOptions): Promise<boolean>;
44
+ push(url: Url, as?: Url, options?: TransitionOptions): Promise<boolean>;
43
45
  /** Replace current URL */
44
- replace(url: string | UrlObject$1, as?: string, options?: TransitionOptions): Promise<boolean>;
46
+ replace(url: Url, as?: Url, options?: TransitionOptions): Promise<boolean>;
45
47
  /** Go back */
46
48
  back(): void;
47
49
  /** Go forward */
@@ -55,7 +57,6 @@ export type NextRouter = {
55
57
  /** Listen for route changes */
56
58
  events: RouterEvents;
57
59
  };
58
- type UrlObject$1 = UrlObject;
59
60
  type TransitionOptions = {
60
61
  _h?: 1;
61
62
  shallow?: boolean;
@@ -200,8 +201,8 @@ declare const RouterMethods: {
200
201
  /** See `_components` comment above for the dual role this map plays. */
201
202
  components: PagesRouterComponentsMap;
202
203
  sdc: Record<string, Promise<Response>>;
203
- push: (url: string | UrlObject$1, as?: string, options?: TransitionOptions) => Promise<boolean>;
204
- replace: (url: string | UrlObject$1, as?: string, options?: TransitionOptions) => Promise<boolean>;
204
+ push: (url: Url, as?: Url, options?: TransitionOptions) => Promise<boolean>;
205
+ replace: (url: Url, as?: Url, options?: TransitionOptions) => Promise<boolean>;
205
206
  back: () => void;
206
207
  forward: () => void;
207
208
  reload: () => void;
@@ -234,8 +235,8 @@ export declare class Router {
234
235
  get events(): RouterEvents;
235
236
  get components(): PagesRouterComponentsMap;
236
237
  get sdc(): Record<string, Promise<Response>>;
237
- push(url: string | UrlObject$1, as?: string, options?: TransitionOptions): Promise<boolean>;
238
- replace(url: string | UrlObject$1, as?: string, options?: TransitionOptions): Promise<boolean>;
238
+ push(url: Url, as?: Url, options?: TransitionOptions): Promise<boolean>;
239
+ replace(url: Url, as?: Url, options?: TransitionOptions): Promise<boolean>;
239
240
  reload(): void;
240
241
  back(): void;
241
242
  forward(): void;