vinext 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/README.md +13 -10
  2. package/dist/build/client-build-config.d.ts +64 -3
  3. package/dist/build/client-build-config.js +131 -4
  4. package/dist/build/client-reference-groups.d.ts +163 -0
  5. package/dist/build/client-reference-groups.js +534 -0
  6. package/dist/build/module-dependency-cache.d.ts +31 -0
  7. package/dist/build/module-dependency-cache.js +51 -1
  8. package/dist/build/next-client-runtime-manifests.d.ts +10 -1
  9. package/dist/build/next-client-runtime-manifests.js +19 -4
  10. package/dist/build/nitro-public-files.d.ts +24 -0
  11. package/dist/build/nitro-public-files.js +60 -0
  12. package/dist/build/output-root-externals.d.ts +21 -0
  13. package/dist/build/output-root-externals.js +40 -0
  14. package/dist/build/pages-client-assets-module.js +1 -1
  15. package/dist/build/prerender-paths.js +6 -3
  16. package/dist/build/prerender.js +1 -1
  17. package/dist/build/server-actions-encryption-key.d.ts +23 -0
  18. package/dist/build/server-actions-encryption-key.js +101 -0
  19. package/dist/build/ssr-manifest.d.ts +3 -0
  20. package/dist/build/ssr-manifest.js +10 -1
  21. package/dist/check.js +5 -6
  22. package/dist/cli-dev-config.js +3 -3
  23. package/dist/cli.js +1 -1
  24. package/dist/client/client-rewrite-params.d.ts +9 -0
  25. package/dist/client/client-rewrite-params.js +20 -0
  26. package/dist/client/dev-error-overlay.js +2 -1
  27. package/dist/client/navigation-runtime.d.ts +25 -2
  28. package/dist/client/navigation-runtime.js +42 -11
  29. package/dist/client/vinext-next-data.d.ts +0 -1
  30. package/dist/config/config-matchers.d.ts +15 -40
  31. package/dist/config/config-matchers.js +195 -262
  32. package/dist/config/config-source.d.ts +34 -0
  33. package/dist/config/config-source.js +141 -0
  34. package/dist/config/header-params.d.ts +29 -0
  35. package/dist/config/header-params.js +106 -0
  36. package/dist/config/next-config.d.ts +7 -5
  37. package/dist/config/next-config.js +120 -7
  38. package/dist/entries/app-browser-entry.d.ts +14 -1
  39. package/dist/entries/app-browser-entry.js +26 -36
  40. package/dist/entries/app-rsc-entry.d.ts +2 -0
  41. package/dist/entries/app-rsc-entry.js +92 -57
  42. package/dist/entries/app-rsc-manifest.d.ts +10 -0
  43. package/dist/entries/app-rsc-manifest.js +20 -1
  44. package/dist/entries/app-ssr-entry.d.ts +4 -1
  45. package/dist/entries/app-ssr-entry.js +9 -2
  46. package/dist/entries/pages-client-entry.d.ts +1 -0
  47. package/dist/entries/pages-client-entry.js +6 -6
  48. package/dist/entries/pages-server-entry.js +17 -14
  49. package/dist/index.d.ts +11 -0
  50. package/dist/index.js +350 -175
  51. package/dist/init.d.ts +1 -1
  52. package/dist/init.js +103 -6
  53. package/dist/plugins/ast-utils.d.ts +53 -2
  54. package/dist/plugins/ast-utils.js +90 -2
  55. package/dist/plugins/cloudflare-dev-module-urls.d.ts +41 -0
  56. package/dist/plugins/cloudflare-dev-module-urls.js +271 -0
  57. package/dist/plugins/commonjs-esm-facade.js +2 -2
  58. package/dist/plugins/css-module-imports.js +13 -20
  59. package/dist/plugins/dynamic-preload-metadata.js +2 -3
  60. package/dist/plugins/extensionless-dynamic-import.js +2 -3
  61. package/dist/plugins/fonts.d.ts +1 -1
  62. package/dist/plugins/fonts.js +3 -3
  63. package/dist/plugins/ignore-dynamic-requests.js +2 -3
  64. package/dist/plugins/import-meta-url.js +3 -4
  65. package/dist/plugins/instrumentation-client.js +3 -2
  66. package/dist/plugins/middleware-export-validation.js +2 -3
  67. package/dist/plugins/og-harfbuzz.js +2 -3
  68. package/dist/plugins/optimize-imports.d.ts +25 -2
  69. package/dist/plugins/optimize-imports.js +109 -24
  70. package/dist/plugins/pages-node-externals.js +2 -3
  71. package/dist/plugins/remove-console.js +2 -18
  72. package/dist/plugins/require-condition-resolution.js +3 -3
  73. package/dist/plugins/require-context.js +2 -3
  74. package/dist/plugins/rsc-client-reference-loaders.d.ts +45 -1
  75. package/dist/plugins/rsc-client-reference-loaders.js +336 -18
  76. package/dist/plugins/strip-server-exports.js +3 -4
  77. package/dist/plugins/styled-jsx.js +2 -3
  78. package/dist/plugins/use-cache-callable.d.ts +26 -2
  79. package/dist/plugins/use-cache-callable.js +101 -36
  80. package/dist/plugins/worker-image-imports.d.ts +1 -0
  81. package/dist/plugins/worker-image-imports.js +31 -34
  82. package/dist/plugins/worker-use-server.js +38 -14
  83. package/dist/routing/app-route-graph.d.ts +1 -1
  84. package/dist/routing/browser-route-manifest.d.ts +43 -0
  85. package/dist/routing/browser-route-manifest.js +195 -0
  86. package/dist/routing/hashed-route-patterns.d.ts +4 -0
  87. package/dist/routing/hashed-route-patterns.js +22 -0
  88. package/dist/routing/optimistic-route-trie.d.ts +27 -0
  89. package/dist/routing/optimistic-route-trie.js +102 -0
  90. package/dist/routing/route-validation.d.ts +6 -1
  91. package/dist/routing/route-validation.js +26 -10
  92. package/dist/server/api-handler.js +1 -1
  93. package/dist/server/app-action-forwarding.d.ts +8 -0
  94. package/dist/server/app-action-forwarding.js +17 -3
  95. package/dist/server/app-browser-entry.js +149 -62
  96. package/dist/server/app-browser-error.d.ts +3 -1
  97. package/dist/server/app-browser-error.js +7 -2
  98. package/dist/server/app-browser-interception-context.d.ts +2 -2
  99. package/dist/server/app-browser-interception-context.js +1 -1
  100. package/dist/server/app-browser-mpa-navigation.d.ts +1 -0
  101. package/dist/server/app-browser-mpa-navigation.js +6 -5
  102. package/dist/server/app-browser-navigation-controller.d.ts +17 -6
  103. package/dist/server/app-browser-navigation-controller.js +88 -26
  104. package/dist/server/app-browser-prefetch-response.js +2 -2
  105. package/dist/server/app-browser-state.d.ts +2 -2
  106. package/dist/server/app-browser-state.js +1 -1
  107. package/dist/server/app-browser-supplemental-refresh.js +1 -1
  108. package/dist/server/app-browser-visible-commit.d.ts +4 -4
  109. package/dist/server/app-client-reference-preloader.d.ts +23 -0
  110. package/dist/server/app-client-reference-preloader.js +30 -7
  111. package/dist/server/app-fallback-renderer.js +2 -1
  112. package/dist/server/app-middleware.d.ts +6 -0
  113. package/dist/server/app-middleware.js +8 -10
  114. package/dist/server/app-optimistic-routing.d.ts +8 -10
  115. package/dist/server/app-optimistic-routing.js +4 -95
  116. package/dist/server/app-page-boundary-render.js +8 -1
  117. package/dist/server/app-page-cache-render.js +1 -0
  118. package/dist/server/app-page-dispatch.js +3 -1
  119. package/dist/server/app-page-render.js +4 -2
  120. package/dist/server/app-page-rsc-render-status.d.ts +1 -0
  121. package/dist/server/app-page-rsc-render-status.js +1 -0
  122. package/dist/server/app-page-search-params-observation.d.ts +1 -4
  123. package/dist/server/app-page-search-params-observation.js +8 -10
  124. package/dist/server/app-page-stream.d.ts +7 -0
  125. package/dist/server/app-page-stream.js +1 -0
  126. package/dist/server/app-pages-bridge.d.ts +2 -1
  127. package/dist/server/app-pages-bridge.js +12 -8
  128. package/dist/server/app-prerender-endpoints.js +1 -1
  129. package/dist/server/app-prerender-static-params.js +3 -2
  130. package/dist/server/app-render-abort-error.d.ts +19 -0
  131. package/dist/server/app-render-abort-error.js +31 -1
  132. package/dist/server/app-render-dependency.js +42 -2
  133. package/dist/server/app-request-stage-independent-entry.js +7 -7
  134. package/dist/server/app-response-stage-entry.js +5 -5
  135. package/dist/server/app-route-handler-dispatch.js +3 -1
  136. package/dist/server/app-route-handler-execution.d.ts +2 -0
  137. package/dist/server/app-route-handler-execution.js +9 -2
  138. package/dist/server/app-route-handler-middleware-context.d.ts +2 -1
  139. package/dist/server/app-route-handler-middleware-context.js +3 -3
  140. package/dist/server/app-route-handler-response.d.ts +2 -1
  141. package/dist/server/app-route-handler-response.js +2 -2
  142. package/dist/server/app-route-handler-runtime.d.ts +2 -0
  143. package/dist/server/app-route-handler-runtime.js +21 -4
  144. package/dist/server/app-route-module-loader.js +7 -6
  145. package/dist/server/app-route-tree.d.ts +20 -0
  146. package/dist/server/app-route-tree.js +18 -0
  147. package/dist/server/app-router-entry.js +7 -7
  148. package/dist/server/app-rsc-cache-busting.d.ts +16 -0
  149. package/dist/server/app-rsc-cache-busting.js +29 -12
  150. package/dist/server/app-rsc-combined-handler.js +8 -1
  151. package/dist/server/app-rsc-errors.d.ts +7 -0
  152. package/dist/server/app-rsc-errors.js +9 -2
  153. package/dist/server/app-rsc-handler.d.ts +4 -1
  154. package/dist/server/app-rsc-handler.js +151 -135
  155. package/dist/server/app-rsc-request-normalization.js +3 -3
  156. package/dist/server/app-rsc-response-finalizer.d.ts +5 -0
  157. package/dist/server/app-rsc-response-finalizer.js +4 -1
  158. package/dist/server/app-rsc-response-stage.js +5 -3
  159. package/dist/server/app-rsc-route-matching.d.ts +1 -0
  160. package/dist/server/app-rsc-route-matching.js +1 -1
  161. package/dist/server/app-server-action-execution.d.ts +23 -6
  162. package/dist/server/app-server-action-execution.js +51 -57
  163. package/dist/server/app-ssr-entry.d.ts +6 -0
  164. package/dist/server/app-ssr-entry.js +21 -11
  165. package/dist/server/app-ssr-stream.d.ts +7 -0
  166. package/dist/server/app-ssr-stream.js +13 -1
  167. package/dist/server/app-visited-response-cache.js +2 -2
  168. package/dist/server/config-headers.js +13 -4
  169. package/dist/server/defer-until-stream-consumed.d.ts +2 -1
  170. package/dist/server/defer-until-stream-consumed.js +3 -1
  171. package/dist/server/dev-server.js +1 -1
  172. package/dist/server/image-optimization.js +1 -0
  173. package/dist/server/isolate-shared-promise.d.ts +10 -0
  174. package/dist/server/isolate-shared-promise.js +33 -0
  175. package/dist/server/isr-cache.js +3 -2
  176. package/dist/server/metadata-route-response.js +2 -2
  177. package/dist/server/middleware-matcher-pattern.d.ts +0 -1
  178. package/dist/server/middleware-matcher-pattern.js +11 -140
  179. package/dist/server/middleware-matcher.js +5 -6
  180. package/dist/server/middleware-response-headers.d.ts +31 -0
  181. package/dist/server/middleware-response-headers.js +57 -1
  182. package/dist/server/middleware-runtime.js +30 -17
  183. package/dist/server/navigation-planner.d.ts +2 -2
  184. package/dist/server/navigation-planner.js +1 -1
  185. package/dist/server/nitro-public-files-plugin.d.ts +38 -0
  186. package/dist/server/nitro-public-files-plugin.js +106 -0
  187. package/dist/server/nitro-public-files.d.ts +21 -0
  188. package/dist/server/nitro-public-files.js +39 -0
  189. package/dist/server/open-redirect.d.ts +11 -4
  190. package/dist/server/open-redirect.js +11 -4
  191. package/dist/server/pages-api-route.js +2 -2
  192. package/dist/server/pages-asset-tags.d.ts +5 -0
  193. package/dist/server/pages-asset-tags.js +9 -2
  194. package/dist/server/pages-client-assets.d.ts +4 -1
  195. package/dist/server/pages-data-route.js +2 -1
  196. package/dist/server/pages-i18n.d.ts +18 -0
  197. package/dist/server/pages-i18n.js +18 -2
  198. package/dist/server/pages-node-compat.d.ts +5 -3
  199. package/dist/server/pages-node-compat.js +35 -16
  200. package/dist/server/pages-page-data.js +1 -1
  201. package/dist/server/pages-page-handler.js +1 -1
  202. package/dist/server/pages-page-response.js +1 -1
  203. package/dist/server/pages-request-pipeline.d.ts +6 -1
  204. package/dist/server/pages-request-pipeline.js +35 -39
  205. package/dist/server/pages-request-stage-entry.js +20 -10
  206. package/dist/server/pages-response-stage-entry.js +1 -1
  207. package/dist/server/pages-revalidate.js +3 -2
  208. package/dist/server/pages-router-entry.js +2 -2
  209. package/dist/server/prod-server.d.ts +2 -2
  210. package/dist/server/prod-server.js +74 -36
  211. package/dist/server/proxy-trust.d.ts +6 -0
  212. package/dist/server/proxy-trust.js +12 -6
  213. package/dist/server/request-pipeline.d.ts +5 -0
  214. package/dist/server/request-pipeline.js +12 -1
  215. package/dist/server/rsc-stream-hints.d.ts +1 -1
  216. package/dist/server/rsc-stream-hints.js +21 -3
  217. package/dist/server/server-reference-loader.js +10 -1
  218. package/dist/server/static-file-cache.js +15 -3
  219. package/dist/server/worker-image-optimization.js +19 -6
  220. package/dist/server/worker-utils.js +1 -1
  221. package/dist/shims/cache-handler.js +3 -2
  222. package/dist/shims/cache-request-state.d.ts +40 -3
  223. package/dist/shims/cache-request-state.js +70 -5
  224. package/dist/shims/cache-runtime.js +47 -19
  225. package/dist/shims/cache.d.ts +2 -2
  226. package/dist/shims/cache.js +17 -8
  227. package/dist/shims/cdn-purge-routes.d.ts +24 -0
  228. package/dist/shims/cdn-purge-routes.js +77 -0
  229. package/dist/shims/dynamic.js +17 -4
  230. package/dist/shims/form.js +8 -3
  231. package/dist/shims/head.js +1 -1
  232. package/dist/shims/headers.js +2 -2
  233. package/dist/shims/image-props.d.ts +93 -0
  234. package/dist/shims/image-props.js +323 -0
  235. package/dist/shims/image.d.ts +4 -18
  236. package/dist/shims/image.js +4 -319
  237. package/dist/shims/internal/headers-state.d.ts +7 -0
  238. package/dist/shims/internal/headers-state.js +14 -2
  239. package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +4 -1
  240. package/dist/shims/internal/hybrid-client-route-owner-direct.js +32 -15
  241. package/dist/shims/internal/hybrid-client-route-owner.js +9 -8
  242. package/dist/shims/link-prefetch.js +5 -4
  243. package/dist/shims/link.js +7 -5
  244. package/dist/shims/navigation.d.ts +1 -1
  245. package/dist/shims/navigation.js +21 -10
  246. package/dist/shims/og.js +35 -10
  247. package/dist/shims/request-context.d.ts +13 -0
  248. package/dist/shims/router.js +28 -52
  249. package/dist/shims/server.d.ts +42 -8
  250. package/dist/shims/server.js +99 -15
  251. package/dist/shims/thenable-params.d.ts +6 -1
  252. package/dist/shims/thenable-params.js +11 -2
  253. package/dist/shims/unified-request-context.d.ts +5 -0
  254. package/dist/shims/unified-request-context.js +2 -0
  255. package/dist/shims/url-utils.d.ts +7 -0
  256. package/dist/shims/url-utils.js +12 -3
  257. package/dist/utils/asset-prefix.d.ts +7 -0
  258. package/dist/utils/asset-prefix.js +10 -1
  259. package/dist/utils/client-build-manifest.js +12 -5
  260. package/dist/utils/client-runtime-metadata.d.ts +1 -0
  261. package/dist/utils/client-runtime-metadata.js +15 -2
  262. package/dist/utils/domain-locale.js +1 -1
  263. package/dist/utils/lazy-chunks.d.ts +4 -0
  264. package/dist/utils/manifest-paths.d.ts +14 -0
  265. package/dist/utils/manifest-paths.js +22 -1
  266. package/dist/utils/path-to-regexp.d.ts +21 -0
  267. package/dist/{server/middleware-path-to-regexp.js → utils/path-to-regexp.js} +14 -11
  268. package/dist/utils/plugin-react-version.d.ts +15 -0
  269. package/dist/utils/plugin-react-version.js +64 -0
  270. package/dist/utils/plugin-rsc-version.d.ts +2 -0
  271. package/dist/utils/plugin-rsc-version.js +28 -2
  272. package/dist/utils/public-routes.d.ts +2 -0
  273. package/dist/utils/public-routes.js +18 -7
  274. package/dist/utils/react-version.d.ts +7 -0
  275. package/dist/utils/react-version.js +39 -16
  276. package/package.json +6 -6
  277. package/dist/build/nitro-route-rules.d.ts +0 -47
  278. package/dist/build/nitro-route-rules.js +0 -79
  279. package/dist/plugins/cache-flight-codec.d.ts +0 -19
  280. package/dist/plugins/cache-flight-codec.js +0 -68
  281. package/dist/server/middleware-path-to-regexp.d.ts +0 -13
  282. package/dist/utils/regex-safety.d.ts +0 -17
  283. package/dist/utils/regex-safety.js +0 -789
@@ -1,7 +1,7 @@
1
1
  import { isBotUserAgent } from "../utils/html-limited-bots.js";
2
2
  import { isExternalUrl } from "../utils/external-url.js";
3
3
  import { stripBasePath } from "../utils/base-path.js";
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";
4
+ import { NEXT_ROUTER_PREFETCH_HEADER, NEXT_ROUTER_SEGMENT_PREFETCH_HEADER, VINEXT_INTERCEPTION_CONTEXT_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_RSC_RENDER_MODE_HEADER } from "../server/app-rsc-vary.js";
5
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_RSC_REDIRECT_HEADER, VINEXT_RSC_REDIRECT_TYPE_HEADER, VINEXT_STALE_TIME_PENDING_HEADER } from "../server/headers.js";
6
6
  import { assertSafeNavigationUrl } from "./url-safety.js";
7
7
  import { APP_RSC_RENDER_MODE_PREFETCH_DYNAMIC_SHELL, APP_RSC_RENDER_MODE_PREFETCH_LOADING_SHELL } from "../server/app-rsc-render-mode.js";
@@ -17,9 +17,9 @@ import { GLOBAL_ACCESSORS_KEY, ServerInsertedHTMLContext, _registerStateAccessor
17
17
  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";
18
18
  import { clearAppNavigationFailureTarget, stageAppNavigationFailureTarget } from "../client/app-nav-failure-handler.js";
19
19
  import { beginAppRouterScrollIntent, clearAppRouterScrollIntent, consumeAppRouterScrollIntent, getPendingAppRouterScrollIntent, isLatestAppRouterScrollIntent } from "./app-router-scroll-state.js";
20
- import { VINEXT_RSC_COMPATIBILITY_ID_HEADER, VINEXT_RSC_CONTENT_TYPE, createRscRequestHeaders, createRscRequestUrl, stripRscCacheBustingSearchParam, stripRscSuffix } from "../server/app-rsc-cache-busting.js";
20
+ import { VINEXT_RSC_COMPATIBILITY_ID_HEADER, VINEXT_RSC_CONTENT_TYPE, createRscRequestHeaders, createRscRequestUrl, formatRscRequestPath, parseRscRequestPath, stripRscCacheBustingSearchParam, stripRscSuffix } from "../server/app-rsc-cache-busting.js";
21
21
  import { notifyAppRouterTransitionStart } from "../client/instrumentation-client-state.js";
22
- import { getNavigationRuntime, hasAppNavigationRuntime } from "../client/navigation-runtime.js";
22
+ import { getNavigationRuntime, hasAppNavigationRuntime, loadNavigationRuntimeRouteManifest } from "../client/navigation-runtime.js";
23
23
  import { UnrecognizedActionError, unstable_isUnrecognizedActionError } from "./unrecognized-action-error.js";
24
24
  import { PUBLIC_INITIAL_BFCACHE_ID } from "../server/app-bfcache-id.js";
25
25
  import { resolveManifestNavigationInterceptionContext } from "../server/app-browser-interception-context.js";
@@ -117,7 +117,7 @@ function getCurrentInterceptionContext() {
117
117
  if (isServer) return null;
118
118
  return stripBasePath(window.location.pathname, __basePath);
119
119
  }
120
- function getPrefetchInterceptionContext(targetHref) {
120
+ function getPrefetchInterceptionContext(targetHref, currentPathname) {
121
121
  if (isServer) return null;
122
122
  let targetUrl;
123
123
  try {
@@ -127,7 +127,7 @@ function getPrefetchInterceptionContext(targetHref) {
127
127
  }
128
128
  return resolveManifestNavigationInterceptionContext({
129
129
  basePath: __basePath,
130
- currentPathname: window.location.pathname,
130
+ currentPathname: currentPathname ?? window.location.pathname,
131
131
  routeManifest: getNavigationRuntime()?.bootstrap.routeManifest ?? null,
132
132
  targetPathname: targetUrl.pathname
133
133
  });
@@ -236,7 +236,7 @@ function resolvePrefetchCacheEntryMountedSlotsHeader(entry) {
236
236
  }
237
237
  function normalizeRscCacheLookupUrl(rscUrl) {
238
238
  try {
239
- const url = new URL(rscUrl, "http://vinext.local");
239
+ const url = parseRscRequestPath(rscUrl);
240
240
  stripRscCacheBustingSearchParam(url);
241
241
  return `${url.pathname}${url.search}`;
242
242
  } catch {
@@ -245,7 +245,7 @@ function normalizeRscCacheLookupUrl(rscUrl) {
245
245
  }
246
246
  function normalizeRscCacheLookupPathname(rscUrl) {
247
247
  try {
248
- const url = new URL(rscUrl, "http://vinext.local");
248
+ const url = parseRscRequestPath(rscUrl);
249
249
  return stripRscSuffix(url.pathname);
250
250
  } catch {
251
251
  return null;
@@ -435,8 +435,7 @@ function toAppPrefetchDestination(href) {
435
435
  }
436
436
  const browserHref = toCanonicalBrowserNavigationHref(localHref, window.location.href, __basePath, __trailingSlash);
437
437
  try {
438
- const url = new URL(browserHref, window.location.href);
439
- return `${url.pathname}${url.search}`;
438
+ return formatRscRequestPath(new URL(browserHref, window.location.href));
440
439
  } catch {
441
440
  return browserHref.split("#", 1)[0];
442
441
  }
@@ -1466,6 +1465,11 @@ async function navigateClientSide(href, mode, scroll, programmaticTransition = f
1466
1465
  const fullHref = toCanonicalBrowserNavigationHref(normalizedHref, window.location.href, __basePath, __trailingSlash);
1467
1466
  notifyAppRouterTransitionStart(fullHref, mode);
1468
1467
  if (mode === "push") saveScrollPosition();
1468
+ const mpaNavigate = getNavigationRuntime()?.functions.navigateExternal;
1469
+ if (mpaNavigate) {
1470
+ await mpaNavigate(fullHref, mode);
1471
+ return;
1472
+ }
1469
1473
  hardNavigateTo(fullHref, mode);
1470
1474
  await new Promise(() => {});
1471
1475
  return;
@@ -1608,7 +1612,8 @@ const _appRouter = {
1608
1612
  if (prefetchHref == null) return;
1609
1613
  const fullHref = toAppPrefetchDestination(prefetchHref);
1610
1614
  if (fullHref === null) return;
1611
- const interceptionContext = getPrefetchInterceptionContext(fullHref);
1615
+ const currentPathname = window.location.pathname;
1616
+ let interceptionContext = getPrefetchInterceptionContext(fullHref, currentPathname);
1612
1617
  const mountedSlotsHeader = getMountedSlotsHeader();
1613
1618
  const headers = createAppPrefetchRequestHeaders({
1614
1619
  fetchPriority: "low",
@@ -1617,6 +1622,12 @@ const _appRouter = {
1617
1622
  });
1618
1623
  const setup = beginPrefetchSetup(fullHref);
1619
1624
  (async () => {
1625
+ const routeManifestLoad = loadNavigationRuntimeRouteManifest();
1626
+ if (routeManifestLoad !== null) {
1627
+ if (!await routeManifestLoad || setup.cancelled) return;
1628
+ interceptionContext = getPrefetchInterceptionContext(fullHref, currentPathname);
1629
+ if (interceptionContext !== null) headers.set(VINEXT_INTERCEPTION_CONTEXT_HEADER, interceptionContext);
1630
+ }
1620
1631
  if (HAS_CLIENT_REWRITES) await preloadHybridClientRouteOwner();
1621
1632
  const hybridOwner = resolveHybridClientRouteOwner(fullHref);
1622
1633
  if (hybridOwner === "pages" || hybridOwner === "document") return;
package/dist/shims/og.js CHANGED
@@ -1,4 +1,6 @@
1
+ import { shareIsolatePromise } from "../server/isolate-shared-promise.js";
1
2
  //#region src/shims/og.tsx
3
+ let vercelOg;
2
4
  const CACHE_HEADERS = {
3
5
  noCache: "no-cache, no-store",
4
6
  revalidate: "public, max-age=0, must-revalidate"
@@ -13,21 +15,43 @@ const CACHE_HEADERS = {
13
15
  var ImageResponse = class extends Response {
14
16
  static displayName = "ImageResponse";
15
17
  constructor(element, options) {
18
+ let startRendering;
19
+ const constructed = new Promise((resolve) => {
20
+ startRendering = resolve;
21
+ });
16
22
  const readable = new ReadableStream({ async start(controller) {
17
- const { ImageResponse: VercelImageResponse } = await import("@vercel/og");
18
- const imageResponse = new VercelImageResponse(element, options);
19
- if (!imageResponse.body) {
20
- controller.close();
21
- return;
23
+ await constructed;
24
+ if (options === null) throw new TypeError("Cannot read properties of null (reading 'headers')");
25
+ let settleInitialization;
26
+ if (!vercelOg) {
27
+ const loading = import("@vercel/og");
28
+ vercelOg = loading;
29
+ loading.catch(() => {
30
+ if (vercelOg === loading) vercelOg = void 0;
31
+ });
32
+ shareIsolatePromise(new Promise((resolve) => {
33
+ settleInitialization = resolve;
34
+ }));
22
35
  }
23
- const reader = imageResponse.body.getReader();
24
- while (true) {
25
- const { done, value } = await reader.read();
26
- if (done) {
36
+ try {
37
+ const { ImageResponse: VercelImageResponse } = await vercelOg;
38
+ const imageResponse = new VercelImageResponse(element, options);
39
+ if (!imageResponse.body) {
27
40
  controller.close();
28
41
  return;
29
42
  }
30
- controller.enqueue(value);
43
+ const reader = imageResponse.body.getReader();
44
+ while (true) {
45
+ const { done, value } = await reader.read();
46
+ settleInitialization?.();
47
+ if (done) {
48
+ controller.close();
49
+ return;
50
+ }
51
+ controller.enqueue(value);
52
+ }
53
+ } finally {
54
+ settleInitialization?.();
31
55
  }
32
56
  } });
33
57
  const headers = new Headers({
@@ -42,6 +66,7 @@ var ImageResponse = class extends Response {
42
66
  status: options?.status,
43
67
  statusText: options?.statusText
44
68
  });
69
+ startRendering();
45
70
  }
46
71
  };
47
72
  //#endregion
@@ -38,6 +38,19 @@ export type ExecutionContextLike = {
38
38
  cache?: unknown;
39
39
  /** Server-owned origin for credential-bearing Pages revalidation loopbacks. */
40
40
  trustedRevalidateOrigin?: string;
41
+ /**
42
+ * Node production server signal that aborts when the client disconnects
43
+ * before the response finishes. Its Request only follows this signal, so the
44
+ * App RSC handler takes it from here (UnifiedRequestContext.requestSignal).
45
+ */
46
+ requestSignal?: AbortSignal;
47
+ /**
48
+ * Server-owned origin middleware runs against. Set by the Node production
49
+ * server, whose request URL comes from the client's Host header. Without it
50
+ * middleware uses the request URL's origin, which Workers can trust because
51
+ * the platform routes by hostname.
52
+ */
53
+ middlewareOrigin?: string;
41
54
  /** Worker-owned in-process dispatcher for authenticated Pages revalidation. */
42
55
  dispatchPagesRevalidate?: (request: Request) => Promise<Response>;
43
56
  /** Marks a request currently executing through the internal revalidation dispatcher. */
@@ -1,9 +1,10 @@
1
1
  import { isUnknownRecord } from "../utils/record.js";
2
+ import { execConfigSource } from "../config/config-source.js";
2
3
  import { parseCookieHeader } from "../utils/parse-cookie.js";
3
4
  import { isExternalUrl } from "../utils/external-url.js";
5
+ import { hasBasePath, removeTrailingSlash, stripBasePath } from "../utils/base-path.js";
4
6
  import { substituteDestinationParams } from "../config/destination-params.js";
5
7
  import { sortRoutes, splitPathSegments } from "../routing/utils.js";
6
- import { hasBasePath, removeTrailingSlash, stripBasePath } from "../utils/base-path.js";
7
8
  import { assertSafeNavigationUrl } from "./url-safety.js";
8
9
  import { addLocalePrefix, getDomainLocaleUrl, getLocalePathPrefix } from "../utils/domain-locale.js";
9
10
  import { AppRouterContext } from "./internal/app-router-context.js";
@@ -28,6 +29,7 @@ import { formatUrlObject, formatUrlObjectWithValidation } from "./internal/forma
28
29
  import { normalizeRouterHref, resolvePagesRouterHref } from "./internal/normalize-router-href.js";
29
30
  import { getCurrentRoutePathnameForWarning } from "./internal/route-pattern-for-warning.js";
30
31
  import { getCurrentBrowserLocale } from "./client-locale.js";
32
+ import { clientRewriteAppendsParams } from "../client/client-rewrite-params.js";
31
33
  import { Component, Fragment, StrictMode, createElement, useContext, useEffect, useLayoutEffect, useMemo, useState } from "react";
32
34
  //#region src/shims/router.ts
33
35
  /**
@@ -935,7 +937,6 @@ function isAppComponent(value) {
935
937
  function resolveSameOriginRedirectedUrl(responseUrl) {
936
938
  const appPath = toSameOriginAppPath(responseUrl, __basePath);
937
939
  if (appPath === null) return null;
938
- if (appPath.startsWith("//")) return normalizePathTrailingSlash(responseUrl, __trailingSlash);
939
940
  return normalizePathTrailingSlash(appPath, __trailingSlash);
940
941
  }
941
942
  function stripLocalePrefixForApiRedirect(appPath) {
@@ -957,19 +958,13 @@ function resolveLocalRedirectUrl(location) {
957
958
  let appPath;
958
959
  if (location.startsWith("/") && !location.startsWith("//")) try {
959
960
  const parsed = new URL(location, "http://vinext.local");
960
- appPath = stripBasePath(parsed.pathname, __basePath) + parsed.search + parsed.hash;
961
+ const pathname = stripBasePath(parsed.pathname, __basePath);
962
+ appPath = pathname.startsWith("//") ? toSameOriginAppPath(new URL(location, window.location.href).href, __basePath) : pathname + parsed.search + parsed.hash;
961
963
  } catch {
962
964
  appPath = location;
963
965
  }
964
966
  else appPath = toSameOriginAppPath(location, __basePath);
965
967
  if (appPath === null) return null;
966
- if (appPath.startsWith("//")) try {
967
- const browserUrl = new URL(location, window.location.href);
968
- if (browserUrl.origin !== getWindowOrigin()) return null;
969
- return normalizePathTrailingSlash(browserUrl.href, __trailingSlash);
970
- } catch {
971
- return null;
972
- }
973
968
  return normalizePathTrailingSlash(stripLocalePrefixForApiRedirect(appPath), __trailingSlash);
974
969
  }
975
970
  function hasClientRewriteRules() {
@@ -982,7 +977,8 @@ function hasClientRedirectRules() {
982
977
  }
983
978
  function hasClientAppRouteManifest() {
984
979
  const routes = window.__VINEXT_LINK_PREFETCH_ROUTES__;
985
- return Array.isArray(routes) && routes.length > 0;
980
+ const routeHandlers = window.__VINEXT_APP_ROUTE_HANDLERS__;
981
+ return Array.isArray(routes) && routes.length > 0 || Array.isArray(routeHandlers) && routeHandlers.length > 0;
986
982
  }
987
983
  function getClientConfigRouteContext(href) {
988
984
  let parsed;
@@ -1036,40 +1032,14 @@ function shouldEvaluateClientConfigRule(ruleBasePath, state) {
1036
1032
  if (!state.basePath) return true;
1037
1033
  return ruleBasePath === false ? !state.hadBasePath : state.hadBasePath;
1038
1034
  }
1039
- function matchSimpleClientConfigPattern(pathname, source) {
1040
- if (source.includes("(") || source.includes("\\") || /:[\w-]+[*+][^/]/.test(source)) return;
1041
- const sourceParts = removeTrailingSlash(source).split("/");
1042
- const pathParts = removeTrailingSlash(pathname).split("/");
1043
- const params = {};
1044
- let pathIndex = 0;
1045
- for (let sourceIndex = 0; sourceIndex < sourceParts.length; sourceIndex++) {
1046
- const sourcePart = sourceParts[sourceIndex];
1047
- const pathPart = pathParts[pathIndex];
1048
- if (sourcePart.startsWith(":")) {
1049
- const catchAll = sourcePart.match(/^:([\w-]+)([*+])$/);
1050
- if (catchAll) {
1051
- const rest = pathParts.slice(pathIndex).join("/");
1052
- if (catchAll[2] === "+" && rest === "") return null;
1053
- params[catchAll[1]] = rest;
1054
- return sourceIndex === sourceParts.length - 1 ? params : void 0;
1055
- }
1056
- if (pathPart === void 0) return null;
1057
- params[sourcePart.slice(1)] = pathPart;
1058
- pathIndex++;
1059
- continue;
1060
- }
1061
- if (pathPart !== sourcePart) return null;
1062
- pathIndex++;
1035
+ function isSerializedRewriteDestination(destination) {
1036
+ if (!destination.startsWith("/") || destination.startsWith("//")) return true;
1037
+ try {
1038
+ const parsed = new URL(destination, "http://n");
1039
+ return parsed.pathname + parsed.search + parsed.hash === destination;
1040
+ } catch {
1041
+ return false;
1063
1042
  }
1064
- return pathIndex === pathParts.length ? params : null;
1065
- }
1066
- function simpleClientConfigSourceCouldMatch(pathname, source) {
1067
- const wildcardIndex = source.search(/[:(\\*+?]/);
1068
- const literalPrefix = wildcardIndex === -1 ? source : source.slice(0, wildcardIndex);
1069
- const normalizedPrefix = removeTrailingSlash(literalPrefix);
1070
- if (!normalizedPrefix || normalizedPrefix === "/") return true;
1071
- const normalizedPathname = removeTrailingSlash(pathname);
1072
- return normalizedPathname === normalizedPrefix || normalizedPathname.startsWith(`${normalizedPrefix}/`);
1073
1043
  }
1074
1044
  function isExternalClientConfigUrl(url) {
1075
1045
  return /^[a-z][a-z0-9+.-]*:/i.test(url) || url.startsWith("//");
@@ -1081,8 +1051,7 @@ function clientConfigRedirectCouldMatch(href) {
1081
1051
  if (!routeContext) return false;
1082
1052
  for (const redirect of redirects) {
1083
1053
  if (!shouldEvaluateClientConfigRule(redirect.basePath, routeContext.basePathState)) continue;
1084
- if (!simpleClientConfigSourceCouldMatch(routeContext.pathname, redirect.source)) continue;
1085
- if (matchSimpleClientConfigPattern(routeContext.pathname, redirect.source) !== null) return true;
1054
+ if (execConfigSource(routeContext.pathname, redirect.source) !== null) return true;
1086
1055
  }
1087
1056
  return false;
1088
1057
  }
@@ -1095,12 +1064,15 @@ function resolveClientConfigRewriteSync(href) {
1095
1064
  const routeContext = getClientConfigRouteContext(currentHref);
1096
1065
  if (!routeContext) return null;
1097
1066
  if (!shouldEvaluateClientConfigRule(rewrite.basePath, routeContext.basePathState)) continue;
1098
- if (!simpleClientConfigSourceCouldMatch(routeContext.pathname, rewrite.source)) continue;
1067
+ const match = execConfigSource(routeContext.pathname, rewrite.source);
1068
+ if (match === null) continue;
1099
1069
  if (rewrite.has || rewrite.requiresServerEvaluation) return void 0;
1100
- const params = matchSimpleClientConfigPattern(routeContext.pathname, rewrite.source);
1101
- if (params === void 0) return void 0;
1102
- if (params === null) continue;
1070
+ if (match.unmatched.length > 0) return void 0;
1071
+ const { params } = match;
1072
+ if (!isSerializedRewriteDestination(rewrite.destination)) return void 0;
1073
+ if (clientRewriteAppendsParams(rewrite.destination, params)) return void 0;
1103
1074
  const rewritten = substituteDestinationParams(rewrite.destination, params, "rewrite");
1075
+ if (!/^(?:https?:\/\/|\/(?![\\/\t\n\r]))/.test(rewritten)) return void 0;
1104
1076
  if (isExternalClientConfigUrl(rewritten)) return { kind: "document" };
1105
1077
  currentHref = mergeRewriteQuery(currentHref, rewritten);
1106
1078
  matched = true;
@@ -1816,6 +1788,10 @@ async function performNavigation(url, as, options, mode, onStateUpdate, redirect
1816
1788
  const absoluteHistoryUrl = sameOriginPath === null ? void 0 : origin && inputHref.startsWith(origin) ? inputHref.slice(origin.length) : sameOriginPath;
1817
1789
  const currentRoute = window.__NEXT_DATA__?.page ?? stripBasePath(window.location.pathname, __basePath);
1818
1790
  const currentAs = stripBasePath(window.location.pathname, __basePath) + window.location.search;
1791
+ const resolveRelativeRoutePath = (href) => href === "" || /^[/?#]/.test(href) || isAbsoluteUrl(href) ? href : resolvePagesRouterHref(href, {
1792
+ pathname: currentRoute,
1793
+ asPath: currentAs
1794
+ }, __basePath);
1819
1795
  const preparedHistoryHref = (isAbsoluteUrl(inputHref) ? toSameOriginAppPath(inputHref, __basePath) : null) ?? absoluteHistoryUrl ?? resolvePagesRouterHref(inputHref, {
1820
1796
  pathname: currentRoute,
1821
1797
  asPath: currentAs
@@ -1825,12 +1801,12 @@ async function performNavigation(url, as, options, mode, onStateUpdate, redirect
1825
1801
  const replaceInheritedLocale = options?.locale !== void 0 && (!as ? urlInheritsCurrentPath || typeof url !== "string" && inheritsVisiblePath(url) : typeof as !== "string" && inheritsVisiblePath(as));
1826
1802
  const credentialedHistoryHref = credentialedSameOriginHref(url);
1827
1803
  const credentialedDisplayHref = credentialedSameOriginHref(as) ?? (!as ? credentialedHistoryHref : void 0);
1828
- as = as ? resolveUrl(as, true) : void 0;
1804
+ as = as ? resolveRelativeRoutePath(resolveUrl(as, true)) : void 0;
1829
1805
  assertSafeNavigationUrl(resolveUrl(url));
1830
1806
  if (as !== void 0) assertSafeNavigationUrl(as);
1831
1807
  const isHydrationQueryUpdate = options?._h === 1;
1832
1808
  const navigationLocale = resolveTransitionLocale(options?.locale);
1833
- const unlocalizedRouteHref = resolveUrl(isQueryOnlyString ? `${stripBasePath(window.location.pathname, __basePath)}${url}` : url);
1809
+ const unlocalizedRouteHref = resolveRelativeRoutePath(resolveUrl(isQueryOnlyString ? `${stripBasePath(window.location.pathname, __basePath)}${url}` : url));
1834
1810
  const localRouteHref = isExternalUrl(unlocalizedRouteHref) ? toSameOriginAppPath(unlocalizedRouteHref, __basePath) : unlocalizedRouteHref;
1835
1811
  const implicitDynamicRoute = !isHydrationQueryUpdate && as === void 0 && localRouteHref !== null ? resolveDynamicRouteHref(localRouteHref) : null;
1836
1812
  const routeForNavigation = implicitDynamicRoute?.as ?? unlocalizedRouteHref;
@@ -28,6 +28,11 @@ export type RequestInit = globalThis.RequestInit & {
28
28
  trailingSlash?: boolean;
29
29
  skipTrailingSlashRedirect?: boolean;
30
30
  };
31
+ /**
32
+ * vinext-internal: the host the request was made to, when the URL carries
33
+ * the server's own origin instead. It picks the i18n domain locale.
34
+ */
35
+ requestHost?: string;
31
36
  signal?: AbortSignal;
32
37
  duplex?: "half";
33
38
  };
@@ -42,13 +47,20 @@ export declare class NextRequest extends Request {
42
47
  get page(): void;
43
48
  get ua(): void;
44
49
  /**
45
- * Client IP address. Prefers Cloudflare's trusted CF-Connecting-IP header
46
- * over the spoofable X-Forwarded-For. Returns undefined if unavailable.
50
+ * Client IP address. Next.js removed `ip` in v15; vinext keeps it as an
51
+ * extension. Returns undefined unless the value comes from a trusted source.
52
+ *
53
+ * On Cloudflare Workers (the request carries `cf` metadata), Cloudflare's
54
+ * edge sets `CF-Connecting-IP`. Elsewhere these headers are client-supplied
55
+ * and are only honored behind a trusted proxy (`VINEXT_TRUST_PROXY` /
56
+ * `VINEXT_TRUSTED_HOSTS`), matching the `X-Forwarded-*` policy.
47
57
  */
48
58
  get ip(): string | undefined;
49
59
  /**
50
- * Geolocation data. Platform-dependent (e.g., Cloudflare, Vercel).
51
- * Returns undefined if not available.
60
+ * Geolocation data. Next.js removed `geo` in v15; vinext keeps it as an
61
+ * extension. Read from Cloudflare's `request.cf` metadata on Workers, or
62
+ * from platform geo headers behind a trusted proxy. Returns undefined
63
+ * otherwise, because any client can send these headers.
52
64
  */
53
65
  get geo(): {
54
66
  city?: string;
@@ -93,6 +105,11 @@ export declare class NextResponse<_Body = unknown> extends Response {
93
105
  }
94
106
  export type NextURLConfig = {
95
107
  basePath?: string;
108
+ /**
109
+ * Request headers. As in Next.js's `getHostname`, a Host header decides the
110
+ * domain locale before the URL's own hostname.
111
+ */
112
+ headers?: Record<string, string | string[] | undefined>;
96
113
  nextConfig?: {
97
114
  i18n?: {
98
115
  locales: string[];
@@ -139,6 +156,12 @@ export declare class NextURL {
139
156
  private _locales;
140
157
  private _domains;
141
158
  private _domainLocale;
159
+ private _headers;
160
+ private _buildId;
161
+ /** First page segment of a raw data pathname, where its locale sits. */
162
+ private _dataPathSegment;
163
+ /** The locale parsed from that segment, if it is one. */
164
+ private _dataPathLocale;
142
165
  constructor(input: string | URL, base?: string | URL, config?: NextURLConfig);
143
166
  /**
144
167
  * With `skipTrailingSlashRedirect`, take the slash from the parsed pathname
@@ -157,9 +180,20 @@ export declare class NextURL {
157
180
  * middleware-base-path's "should execute from absolute paths" case.
158
181
  */
159
182
  private _stripBasePath;
183
+ /**
184
+ * Take the build ID from a raw `/_next/data/<buildId>/….json` pathname, as
185
+ * getNextPathnameInfo does. Middleware only sees one when proxy URL
186
+ * normalization is skipped; the pathname is left as is.
187
+ */
188
+ private _parseBuildId;
160
189
  /** Extract locale from pathname, stripping it from the internal URL. */
161
190
  private _detectPathnameLocale;
162
191
  private _analyzeI18n;
192
+ /**
193
+ * A raw data pathname keeps its locale segment, replaced by the current
194
+ * locale once it has been changed.
195
+ */
196
+ private _formatDataPathLocale;
163
197
  /**
164
198
  * Reconstruct the full pathname with basePath + locale prefix and apply
165
199
  * the configured trailingSlash policy.
@@ -207,10 +241,10 @@ export declare class NextURL {
207
241
  toString(): string;
208
242
  toJSON(): string;
209
243
  /**
210
- * The build ID of the Next.js application.
211
- * Set from `generateBuildId` in next.config.js, or a random UUID if not configured.
212
- * Can be used in middleware to detect deployment skew between client and server.
213
- * Matches the Next.js API: `request.nextUrl.buildId`.
244
+ * Matches the Next.js API: `request.nextUrl.buildId`. Next.js derives it
245
+ * from the URL (only `/_next/data/<buildId>/…` paths carry one) and never
246
+ * from the deployment, so a Client Component reads the same value on the
247
+ * server and in the browser.
214
248
  */
215
249
  get buildId(): string | undefined;
216
250
  }