vinext 1.0.0-beta.5 → 1.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/README.md +20 -3
  2. package/dist/build/action-owner-manifest.d.ts +42 -0
  3. package/dist/build/action-owner-manifest.js +110 -0
  4. package/dist/build/clean-output.js +1 -4
  5. package/dist/build/client-build-config.js +10 -11
  6. package/dist/build/prerender-paths.js +3 -4
  7. package/dist/build/prerender-phase.d.ts +15 -0
  8. package/dist/build/prerender-phase.js +37 -0
  9. package/dist/build/prerender-server-entry.js +3 -3
  10. package/dist/build/prerender-server-pool.js +2 -0
  11. package/dist/build/prerender.d.ts +7 -3
  12. package/dist/build/prerender.js +103 -21
  13. package/dist/build/report.d.ts +1 -1
  14. package/dist/build/route-classification-manifest.d.ts +1 -1
  15. package/dist/build/run-prerender.js +9 -6
  16. package/dist/build/static-export.d.ts +1 -1
  17. package/dist/client/app-nav-failure-handler.js +1 -0
  18. package/dist/client/navigation-runtime.d.ts +5 -3
  19. package/dist/client/navigation-runtime.js +4 -8
  20. package/dist/client/vinext-next-data.d.ts +2 -0
  21. package/dist/config/next-config.js +24 -7
  22. package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +808 -0
  23. package/dist/entries/app-browser-entry.d.ts +1 -1
  24. package/dist/entries/app-browser-entry.js +2 -1
  25. package/dist/entries/app-rsc-entry.d.ts +2 -1
  26. package/dist/entries/app-rsc-entry.js +136 -8
  27. package/dist/entries/pages-client-entry.d.ts +1 -1
  28. package/dist/entries/pages-client-entry.js +8 -3
  29. package/dist/entries/pages-server-entry.d.ts +1 -1
  30. package/dist/index.js +190 -181
  31. package/dist/plugins/action-owner-manifest.d.ts +14 -0
  32. package/dist/plugins/action-owner-manifest.js +84 -0
  33. package/dist/plugins/ast-utils.d.ts +30 -1
  34. package/dist/plugins/ast-utils.js +76 -1
  35. package/dist/plugins/css-module-imports.d.ts +2 -2
  36. package/dist/plugins/css-module-imports.js +5 -13
  37. package/dist/plugins/dynamic-preload-metadata.js +13 -34
  38. package/dist/plugins/environment.d.ts +11 -0
  39. package/dist/plugins/environment.js +7 -0
  40. package/dist/plugins/extensionless-dynamic-import.js +11 -35
  41. package/dist/plugins/fonts.js +8 -12
  42. package/dist/plugins/ignore-dynamic-requests.d.ts +2 -4
  43. package/dist/plugins/ignore-dynamic-requests.js +29 -59
  44. package/dist/plugins/import-meta-url.d.ts +15 -9
  45. package/dist/plugins/import-meta-url.js +309 -85
  46. package/dist/plugins/instrumentation-client.js +4 -5
  47. package/dist/plugins/middleware-export-validation.js +5 -17
  48. package/dist/plugins/middleware-server-only.js +2 -2
  49. package/dist/plugins/og-asset-ownership.js +18 -26
  50. package/dist/plugins/og-assets.js +2 -4
  51. package/dist/plugins/optimize-imports.js +2 -4
  52. package/dist/plugins/pages-node-externals.d.ts +23 -0
  53. package/dist/plugins/pages-node-externals.js +179 -0
  54. package/dist/plugins/remove-console.js +2 -4
  55. package/dist/plugins/require-condition-resolution.d.ts +16 -0
  56. package/dist/plugins/require-condition-resolution.js +167 -0
  57. package/dist/plugins/require-context.js +11 -46
  58. package/dist/plugins/sass.js +1 -1
  59. package/dist/plugins/server-externals-manifest.js +1 -23
  60. package/dist/plugins/strip-server-exports.js +13 -19
  61. package/dist/plugins/styled-jsx.js +17 -19
  62. package/dist/plugins/transform-result.d.ts +10 -0
  63. package/dist/plugins/transform-result.js +10 -0
  64. package/dist/plugins/transitive-externals.d.ts +24 -0
  65. package/dist/plugins/transitive-externals.js +107 -0
  66. package/dist/plugins/typeof-window.d.ts +10 -5
  67. package/dist/plugins/typeof-window.js +142 -24
  68. package/dist/plugins/use-cache-callable.d.ts +12 -0
  69. package/dist/plugins/use-cache-callable.js +199 -0
  70. package/dist/plugins/wasm-module-import.js +1 -1
  71. package/dist/plugins/worker-image-imports.d.ts +12 -0
  72. package/dist/plugins/worker-image-imports.js +136 -0
  73. package/dist/routing/app-route-graph.d.ts +3 -2
  74. package/dist/routing/app-route-graph.js +1 -1
  75. package/dist/routing/route-pattern.d.ts +8 -1
  76. package/dist/routing/route-pattern.js +28 -1
  77. package/dist/routing/route-validation.js +7 -1
  78. package/dist/server/accept-encoding.d.ts +1 -2
  79. package/dist/server/accept-encoding.js +1 -4
  80. package/dist/server/api-handler.js +1 -1
  81. package/dist/server/app-action-forwarding.d.ts +18 -0
  82. package/dist/server/app-action-forwarding.js +140 -0
  83. package/dist/server/app-browser-entry.js +236 -51
  84. package/dist/server/app-browser-error.d.ts +1 -2
  85. package/dist/server/app-browser-error.js +1 -5
  86. package/dist/server/app-browser-history-controller.d.ts +16 -1
  87. package/dist/server/app-browser-history-controller.js +135 -18
  88. package/dist/server/app-browser-navigation-abort.d.ts +16 -0
  89. package/dist/server/app-browser-navigation-abort.js +29 -0
  90. package/dist/server/app-browser-navigation-controller.d.ts +4 -0
  91. package/dist/server/app-browser-navigation-controller.js +22 -6
  92. package/dist/server/app-browser-navigation-response.d.ts +11 -0
  93. package/dist/server/app-browser-navigation-response.js +8 -0
  94. package/dist/server/app-browser-popstate.d.ts +6 -1
  95. package/dist/server/app-browser-popstate.js +6 -2
  96. package/dist/server/app-browser-server-action-client.js +1 -1
  97. package/dist/server/app-browser-state.d.ts +2 -2
  98. package/dist/server/app-browser-state.js +3 -3
  99. package/dist/server/app-browser-stream.d.ts +0 -2
  100. package/dist/server/app-browser-supplemental-refresh.d.ts +49 -0
  101. package/dist/server/app-browser-supplemental-refresh.js +190 -0
  102. package/dist/server/app-browser-visible-commit.js +23 -12
  103. package/dist/server/app-elements-wire.d.ts +2 -0
  104. package/dist/server/app-elements-wire.js +7 -0
  105. package/dist/server/app-history-state.d.ts +22 -1
  106. package/dist/server/app-history-state.js +93 -9
  107. package/dist/server/app-optimistic-routing.d.ts +22 -1
  108. package/dist/server/app-optimistic-routing.js +137 -12
  109. package/dist/server/app-page-boundary-render.js +4 -7
  110. package/dist/server/app-page-cache-finalizer.d.ts +4 -1
  111. package/dist/server/app-page-cache-finalizer.js +11 -15
  112. package/dist/server/app-page-cache-render.d.ts +1 -0
  113. package/dist/server/app-page-cache-render.js +3 -1
  114. package/dist/server/app-page-cache.d.ts +4 -2
  115. package/dist/server/app-page-cache.js +13 -6
  116. package/dist/server/app-page-dispatch.d.ts +4 -1
  117. package/dist/server/app-page-dispatch.js +13 -3
  118. package/dist/server/app-page-element-builder.d.ts +1 -0
  119. package/dist/server/app-page-element-builder.js +1 -0
  120. package/dist/server/app-page-execution.js +19 -6
  121. package/dist/server/app-page-ppr-runtime.js +3 -2
  122. package/dist/server/app-page-render.d.ts +2 -1
  123. package/dist/server/app-page-render.js +10 -4
  124. package/dist/server/app-page-request.d.ts +2 -33
  125. package/dist/server/app-page-request.js +1 -27
  126. package/dist/server/app-page-response.js +7 -14
  127. package/dist/server/app-page-route-wiring.d.ts +1 -0
  128. package/dist/server/app-page-route-wiring.js +4 -0
  129. package/dist/server/app-page-segment-state.d.ts +2 -2
  130. package/dist/server/app-page-segment-state.js +14 -8
  131. package/dist/server/app-page-stream.d.ts +12 -0
  132. package/dist/server/app-page-stream.js +10 -3
  133. package/dist/server/app-ppr-fallback-shell.d.ts +2 -2
  134. package/dist/server/app-ppr-fallback-shell.js +3 -6
  135. package/dist/server/app-prerender-endpoints.d.ts +1 -0
  136. package/dist/server/app-prerender-endpoints.js +12 -0
  137. package/dist/server/app-response-header-provenance.d.ts +13 -0
  138. package/dist/server/app-response-header-provenance.js +26 -0
  139. package/dist/server/app-route-handler-cache.d.ts +1 -0
  140. package/dist/server/app-route-handler-cache.js +2 -2
  141. package/dist/server/app-route-handler-dispatch.js +8 -3
  142. package/dist/server/app-route-handler-execution.js +11 -7
  143. package/dist/server/app-route-handler-policy.d.ts +1 -0
  144. package/dist/server/app-route-handler-response.d.ts +3 -1
  145. package/dist/server/app-route-handler-response.js +15 -5
  146. package/dist/server/app-route-handler-runtime.d.ts +1 -1
  147. package/dist/server/app-route-handler-runtime.js +218 -84
  148. package/dist/server/app-route-request-built-ins.d.ts +16 -0
  149. package/dist/server/app-route-request-built-ins.js +41 -0
  150. package/dist/server/app-router-entry.js +2 -2
  151. package/dist/server/app-rsc-cache-busting.d.ts +4 -1
  152. package/dist/server/app-rsc-cache-busting.js +51 -17
  153. package/dist/server/app-rsc-handler.d.ts +6 -2
  154. package/dist/server/app-rsc-handler.js +68 -18
  155. package/dist/server/app-rsc-request-normalization.d.ts +2 -0
  156. package/dist/server/app-rsc-request-normalization.js +5 -1
  157. package/dist/server/app-rsc-response-finalizer.d.ts +2 -0
  158. package/dist/server/app-rsc-response-finalizer.js +4 -1
  159. package/dist/server/app-rsc-route-matching.d.ts +4 -3
  160. package/dist/server/app-rsc-route-matching.js +14 -42
  161. package/dist/server/app-rsc-state-fingerprint.d.ts +14 -0
  162. package/dist/server/app-rsc-state-fingerprint.js +13 -0
  163. package/dist/server/app-server-action-execution.d.ts +3 -0
  164. package/dist/server/app-server-action-execution.js +79 -4
  165. package/dist/server/app-ssr-entry.d.ts +6 -0
  166. package/dist/server/app-ssr-entry.js +21 -9
  167. package/dist/server/app-ssr-stream.d.ts +7 -2
  168. package/dist/server/app-ssr-stream.js +30 -6
  169. package/dist/server/app-visited-response-cache.d.ts +6 -1
  170. package/dist/server/app-visited-response-cache.js +18 -2
  171. package/dist/server/cache-control.d.ts +11 -7
  172. package/dist/server/cache-control.js +23 -12
  173. package/dist/server/config-headers.d.ts +4 -0
  174. package/dist/server/config-headers.js +19 -3
  175. package/dist/server/dev-route-files.js +2 -5
  176. package/dist/server/dev-server.d.ts +5 -13
  177. package/dist/server/dev-server.js +49 -32
  178. package/dist/server/dev-stack-sourcemap.d.ts +1 -2
  179. package/dist/server/dev-stack-sourcemap.js +1 -4
  180. package/dist/server/headers.d.ts +11 -1
  181. package/dist/server/headers.js +13 -2
  182. package/dist/server/http-error-responses.d.ts +1 -1
  183. package/dist/server/http-error-responses.js +7 -2
  184. package/dist/server/isr-cache.d.ts +6 -14
  185. package/dist/server/isr-cache.js +6 -27
  186. package/dist/server/metadata-route-build-data.js +1 -1
  187. package/dist/server/metadata-route-cache-policy.d.ts +6 -0
  188. package/dist/server/metadata-route-cache-policy.js +6 -0
  189. package/dist/server/metadata-route-response.d.ts +26 -1
  190. package/dist/server/metadata-route-response.js +219 -6
  191. package/dist/server/metadata-routes.js +1 -1
  192. package/dist/server/middleware-response-headers.js +4 -2
  193. package/dist/server/middleware.d.ts +3 -16
  194. package/dist/server/middleware.js +2 -19
  195. package/dist/server/navigation-planner.d.ts +1 -0
  196. package/dist/server/navigation-planner.js +57 -9
  197. package/dist/server/navigation-trace.d.ts +1 -0
  198. package/dist/server/navigation-trace.js +1 -0
  199. package/dist/server/pages-data-route.d.ts +1 -10
  200. package/dist/server/pages-data-route.js +1 -12
  201. package/dist/server/pages-dev-hydration.js +11 -4
  202. package/dist/server/pages-node-compat.d.ts +1 -4
  203. package/dist/server/pages-node-compat.js +1 -7
  204. package/dist/server/pages-page-handler.d.ts +3 -1
  205. package/dist/server/pages-page-handler.js +4 -15
  206. package/dist/server/pages-page-response.js +10 -5
  207. package/dist/server/pages-readiness.js +4 -4
  208. package/dist/server/prerender-cache-life-header.d.ts +11 -0
  209. package/dist/server/prerender-cache-life-header.js +18 -0
  210. package/dist/server/prerender-manifest.d.ts +5 -2
  211. package/dist/server/prerender-manifest.js +4 -1
  212. package/dist/server/prerender-route-params.d.ts +1 -2
  213. package/dist/server/prerender-route-params.js +1 -4
  214. package/dist/server/prod-server.js +9 -11
  215. package/dist/server/request-pipeline.js +2 -0
  216. package/dist/server/seed-cache.d.ts +4 -1
  217. package/dist/server/seed-cache.js +28 -4
  218. package/dist/server/worker-utils.js +1 -1
  219. package/dist/shims/cache-callable-runtime.d.ts +11 -0
  220. package/dist/shims/cache-callable-runtime.js +30 -0
  221. package/dist/shims/cache-request-state.d.ts +4 -1
  222. package/dist/shims/cache-request-state.js +6 -1
  223. package/dist/shims/cache-runtime.d.ts +6 -1
  224. package/dist/shims/cache-runtime.js +137 -30
  225. package/dist/shims/cache.d.ts +2 -2
  226. package/dist/shims/cache.js +2 -2
  227. package/dist/shims/cdn-cache.d.ts +18 -6
  228. package/dist/shims/cdn-cache.js +4 -2
  229. package/dist/shims/dynamic.d.ts +3 -3
  230. package/dist/shims/dynamic.js +4 -6
  231. package/dist/shims/error.js +1 -1
  232. package/dist/shims/fetch-cache.d.ts +3 -1
  233. package/dist/shims/fetch-cache.js +27 -7
  234. package/dist/shims/font-local.js +3 -3
  235. package/dist/shims/head.d.ts +16 -1
  236. package/dist/shims/head.js +70 -8
  237. package/dist/shims/internal/app-route-prefetch-policy.d.ts +8 -7
  238. package/dist/shims/internal/app-route-prefetch-policy.js +13 -6
  239. package/dist/shims/internal/pages-data-target.d.ts +1 -1
  240. package/dist/shims/internal/pages-data-target.js +18 -5
  241. package/dist/shims/link.js +50 -55
  242. package/dist/shims/navigation-context-state.d.ts +4 -0
  243. package/dist/shims/navigation.d.ts +39 -3
  244. package/dist/shims/navigation.js +139 -18
  245. package/dist/shims/navigation.react-server.js +1 -1
  246. package/dist/shims/request-state-types.d.ts +1 -1
  247. package/dist/shims/root-params.d.ts +3 -1
  248. package/dist/shims/root-params.js +7 -1
  249. package/dist/shims/router.js +252 -80
  250. package/dist/shims/server.js +2 -1
  251. package/dist/shims/unified-request-context.d.ts +1 -1
  252. package/dist/shims/unified-request-context.js +1 -0
  253. package/dist/utils/built-asset-url.d.ts +1 -1
  254. package/dist/utils/built-asset-url.js +4 -2
  255. package/dist/utils/encode-cache-tag.d.ts +1 -1
  256. package/dist/utils/encode-cache-tag.js +1 -1
  257. package/dist/utils/package-name.d.ts +11 -0
  258. package/dist/utils/package-name.js +18 -0
  259. package/dist/utils/path.d.ts +8 -1
  260. package/dist/utils/path.js +21 -1
  261. package/dist/utils/prerender-output-paths.d.ts +3 -1
  262. package/dist/utils/prerender-output-paths.js +6 -1
  263. package/package.json +5 -4
@@ -3,9 +3,11 @@ import { findDir } from "../utils/project.js";
3
3
  import { apiRouter, pagesRouter } from "../routing/pages-router.js";
4
4
  import { appRouter } from "../routing/app-router.js";
5
5
  import { scanMetadataFiles } from "../server/metadata-routes.js";
6
+ import { PHASE_PRODUCTION_BUILD } from "../shims/constants.js";
6
7
  import { loadNextConfig, resolveNextConfig } from "../config/next-config.js";
7
8
  import { readPrerenderSecret } from "./server-manifest.js";
8
9
  import { rememberCurrentServerEntryImportMtime, startProdServer } from "../server/prod-server.js";
10
+ import { enterPrerenderPhase } from "./prerender-phase.js";
9
11
  import { prerenderApp, prerenderPages, writePrerenderIndex } from "./prerender.js";
10
12
  import { injectPregeneratedConcretePaths } from "./inject-pregenerated-paths.js";
11
13
  import fs from "node:fs";
@@ -104,12 +106,10 @@ async function runPrerender(options) {
104
106
  const appDir = findDir(root, "app", "src/app");
105
107
  const pagesDir = findDir(root, "pages", "src/pages");
106
108
  if (!appDir && !pagesDir) return null;
107
- const previousPrerenderFlag = process.env.VINEXT_PRERENDER;
108
- process.env.VINEXT_PRERENDER = "1";
109
109
  const manifestDir = path.join(root, "dist", "server");
110
110
  const rscBundlePath = options.rscBundlePath ?? path.join(root, "dist", "server", "index.js");
111
111
  const serverDir = path.dirname(rscBundlePath);
112
- const config = options.nextConfig ? { ...options.nextConfig } : { ...await resolveNextConfig(await loadNextConfig(root), root) };
112
+ const config = options.nextConfig ? { ...options.nextConfig } : { ...await resolveNextConfig(await loadNextConfig(root, PHASE_PRODUCTION_BUILD), root) };
113
113
  const builtBuildId = readBuiltBuildId(serverDir);
114
114
  if (builtBuildId) config.buildId = builtBuildId;
115
115
  const mode = config.output === "export" ? "export" : "default";
@@ -121,6 +121,7 @@ async function runPrerender(options) {
121
121
  const outDir = mode === "export" ? path.join(root, "dist", "client") : path.join(root, "dist", "server", "prerendered-routes");
122
122
  let sharedProdServer = null;
123
123
  let sharedPrerenderSecret;
124
+ const restorePrerenderPhase = enterPrerenderPhase();
124
125
  try {
125
126
  if (appDir && pagesDir) {
126
127
  sharedProdServer = await startProdServer({
@@ -187,9 +188,11 @@ async function runPrerender(options) {
187
188
  if (result.outputFiles) allOutputFiles.push(...result.outputFiles);
188
189
  }
189
190
  } finally {
190
- if (sharedProdServer) await new Promise((resolve) => sharedProdServer.server.close(() => resolve()));
191
- if (previousPrerenderFlag === void 0) delete process.env.VINEXT_PRERENDER;
192
- else process.env.VINEXT_PRERENDER = previousPrerenderFlag;
191
+ try {
192
+ if (sharedProdServer) await new Promise((resolve) => sharedProdServer.server.close(() => resolve()));
193
+ } finally {
194
+ restorePrerenderPhase();
195
+ }
193
196
  }
194
197
  if (allRoutes.length === 0) {
195
198
  progress.finish(0, 0, 0);
@@ -1,6 +1,6 @@
1
+ import { AppRoute } from "../routing/app-route-graph.js";
1
2
  import { ResolvedNextConfig } from "../config/next-config.js";
2
3
  import { Route } from "../routing/pages-router.js";
3
- import { AppRoute } from "../routing/app-route-graph.js";
4
4
  //#region src/build/static-export.d.ts
5
5
  type StaticExportOptions = {
6
6
  /**
@@ -22,6 +22,7 @@ function clearAppNavigationFailureTarget(target) {
22
22
  }
23
23
  function handleAppNavigationFailure(error) {
24
24
  if (!process.env.__NEXT_APP_NAV_FAIL_HANDLING || typeof window === "undefined") return false;
25
+ if (error !== null && typeof error === "object" && "handled" in error && error.handled === true) return false;
25
26
  const pendingUrl = getPendingUrl();
26
27
  if (pendingUrl === null || pendingUrl.href === window.location.href) return false;
27
28
  console.error("Error occurred during navigation, falling back to hard navigation", error);
@@ -10,6 +10,7 @@ type NavigationRuntimeRscBootstrap = {
10
10
  done?: boolean;
11
11
  dynamicStaleTimeSeconds?: number;
12
12
  initialCacheKind?: "dynamic" | "static";
13
+ searchParamsFromBrowser?: boolean;
13
14
  nav?: NavigationRuntimeSnapshot;
14
15
  params?: Record<string, string | string[]>;
15
16
  rsc: NavigationRuntimeRscChunk[];
@@ -32,7 +33,7 @@ type NavigationRuntimeTraversalIntent = {
32
33
  historyState: unknown;
33
34
  targetHistoryIndex: number | null;
34
35
  };
35
- type NavigationRuntimeNavigate = (href: string, redirectDepth?: number, navigationKind?: NavigationRuntimeKind, historyUpdateMode?: NavigationRuntimeHistoryUpdateMode, previousNextUrlOverride?: string | null, programmaticTransition?: boolean, traversalIntent?: NavigationRuntimeTraversalIntent, scrollIntent?: AppRouterScrollIntent | null, visibleCommitMode?: NavigationRuntimeVisibleCommitMode) => Promise<void>;
36
+ type NavigationRuntimeNavigate = (href: string, redirectDepth?: number, navigationKind?: NavigationRuntimeKind, historyUpdateMode?: NavigationRuntimeHistoryUpdateMode, previousNextUrlOverride?: string | null, programmaticTransition?: boolean, traversalIntent?: NavigationRuntimeTraversalIntent, scrollIntent?: AppRouterScrollIntent | null, visibleCommitMode?: NavigationRuntimeVisibleCommitMode, bypassNavigationCache?: boolean) => Promise<void>;
36
37
  type NavigationRuntimeFunctions = {
37
38
  clearNavigationCaches?: () => void;
38
39
  commitHashNavigation?: (href: string, historyUpdateMode: NavigationRuntimeHistoryUpdateMode, scroll: boolean) => void;
@@ -49,6 +50,8 @@ type NavigationRuntimeFunctions = {
49
50
  notifyLinkNavigationStart?: () => void;
50
51
  pingVisibleLinks?: () => void;
51
52
  preparePrefetchResponse?: (response: Response) => Promise<unknown>;
53
+ claimCurrentHistoryTreeSnapshot?: (historyUpdateMode: NavigationRuntimeHistoryUpdateMode, previousHistoryState: unknown) => void;
54
+ commitAppOwnedHistoryStateWrite?: (historyUpdateMode: NavigationRuntimeHistoryUpdateMode, previousHistoryState: unknown) => void;
52
55
  };
53
56
  type NavigationRuntimeBootstrap = {
54
57
  routeManifest: RouteManifest | null;
@@ -64,7 +67,6 @@ declare function getNavigationRuntime(): NavigationRuntime | null;
64
67
  declare function registerNavigationRuntimeBootstrap(bootstrap: Partial<NavigationRuntimeBootstrap>): NavigationRuntime;
65
68
  declare function registerNavigationRuntimeFunctions(functions: Partial<NavigationRuntimeFunctions>): NavigationRuntime;
66
69
  declare function ensureNavigationRuntimeRscBootstrap(): NavigationRuntimeRscBootstrap;
67
- declare function subscribeNavigationRuntimeRscChunk(chunk: NavigationRuntimeRscChunk): NavigationRuntime;
68
70
  declare function hasAppNavigationRuntime(): boolean;
69
71
  /**
70
72
  * True when the App Router has installed its runtime bootstrap on `window`,
@@ -80,4 +82,4 @@ declare function hasAppNavigationRuntime(): boolean;
80
82
  */
81
83
  declare function hasAppNavigationRuntimeBootstrap(): boolean;
82
84
  //#endregion
83
- export { NAVIGATION_RUNTIME_KEY, NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION, NavigationRuntime, NavigationRuntimeBootstrap, NavigationRuntimeFunctions, NavigationRuntimeNavigate, NavigationRuntimeRscBootstrap, NavigationRuntimeRscChunk, NavigationRuntimeSnapshot, NavigationRuntimeVisibleCommitMode, ensureNavigationRuntimeRscBootstrap, getNavigationRuntime, hasAppNavigationRuntime, hasAppNavigationRuntimeBootstrap, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions, subscribeNavigationRuntimeRscChunk };
85
+ export { NAVIGATION_RUNTIME_KEY, NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION, NavigationRuntime, NavigationRuntimeBootstrap, NavigationRuntimeFunctions, NavigationRuntimeNavigate, NavigationRuntimeRscBootstrap, NavigationRuntimeRscChunk, NavigationRuntimeVisibleCommitMode, ensureNavigationRuntimeRscBootstrap, getNavigationRuntime, hasAppNavigationRuntime, hasAppNavigationRuntimeBootstrap, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions };
@@ -31,7 +31,7 @@ function readRuntimeWindow() {
31
31
  }
32
32
  function isNavigationRuntimeFunctions(value) {
33
33
  if (!isUnknownRecord(value)) return false;
34
- return isOptionalRuntimeFunction(Reflect.get(value, "clearNavigationCaches")) && isOptionalRuntimeFunction(Reflect.get(value, "commitHashNavigation")) && isOptionalRuntimeFunction(Reflect.get(value, "navigateExternal")) && isOptionalRuntimeFunction(Reflect.get(value, "navigate")) && isOptionalRuntimeFunction(Reflect.get(value, "getPrefetchRouterState")) && isOptionalRuntimeFunction(Reflect.get(value, "notifyLinkNavigationStart")) && isOptionalRuntimeFunction(Reflect.get(value, "pingVisibleLinks")) && isOptionalRuntimeFunction(Reflect.get(value, "preparePrefetchResponse"));
34
+ return isOptionalRuntimeFunction(Reflect.get(value, "clearNavigationCaches")) && isOptionalRuntimeFunction(Reflect.get(value, "commitHashNavigation")) && isOptionalRuntimeFunction(Reflect.get(value, "navigateExternal")) && isOptionalRuntimeFunction(Reflect.get(value, "navigate")) && isOptionalRuntimeFunction(Reflect.get(value, "getPrefetchRouterState")) && isOptionalRuntimeFunction(Reflect.get(value, "notifyLinkNavigationStart")) && isOptionalRuntimeFunction(Reflect.get(value, "pingVisibleLinks")) && isOptionalRuntimeFunction(Reflect.get(value, "preparePrefetchResponse")) && isOptionalRuntimeFunction(Reflect.get(value, "claimCurrentHistoryTreeSnapshot")) && isOptionalRuntimeFunction(Reflect.get(value, "commitAppOwnedHistoryStateWrite"));
35
35
  }
36
36
  function isNavigationRuntimeRscChunk(value) {
37
37
  if (typeof value === "string") return true;
@@ -52,11 +52,12 @@ function isNavigationRuntimeRscBootstrap(value) {
52
52
  const done = Reflect.get(value, "done");
53
53
  const dynamicStaleTimeSeconds = Reflect.get(value, "dynamicStaleTimeSeconds");
54
54
  const initialCacheKind = Reflect.get(value, "initialCacheKind");
55
+ const searchParamsFromBrowser = Reflect.get(value, "searchParamsFromBrowser");
55
56
  const nav = Reflect.get(value, "nav");
56
57
  const params = Reflect.get(value, "params");
57
58
  const rsc = Reflect.get(value, "rsc");
58
59
  const staleTimeSeconds = Reflect.get(value, "staleTimeSeconds");
59
- return (done === void 0 || typeof done === "boolean") && isOptionalStaleTimeSeconds(dynamicStaleTimeSeconds) && (initialCacheKind === void 0 || initialCacheKind === "dynamic" || initialCacheKind === "static") && (nav === void 0 || isNavigationRuntimeSnapshot(nav)) && (params === void 0 || isNavigationRuntimeParams(params)) && Array.isArray(rsc) && rsc.every(isNavigationRuntimeRscChunk) && isOptionalStaleTimeSeconds(staleTimeSeconds);
60
+ return (done === void 0 || typeof done === "boolean") && isOptionalStaleTimeSeconds(dynamicStaleTimeSeconds) && (initialCacheKind === void 0 || initialCacheKind === "dynamic" || initialCacheKind === "static") && (searchParamsFromBrowser === void 0 || typeof searchParamsFromBrowser === "boolean") && (nav === void 0 || isNavigationRuntimeSnapshot(nav)) && (params === void 0 || isNavigationRuntimeParams(params)) && Array.isArray(rsc) && rsc.every(isNavigationRuntimeRscChunk) && isOptionalStaleTimeSeconds(staleTimeSeconds);
60
61
  }
61
62
  function isOptionalStaleTimeSeconds(value) {
62
63
  return value === void 0 || typeof value === "number" && Number.isFinite(value) && value >= 0;
@@ -148,11 +149,6 @@ function ensureNavigationRuntimeRscBootstrapForRuntime(runtime) {
148
149
  }
149
150
  return rscBootstrap;
150
151
  }
151
- function subscribeNavigationRuntimeRscChunk(chunk) {
152
- const runtime = ensureNavigationRuntime();
153
- ensureNavigationRuntimeRscBootstrapForRuntime(runtime).rsc.push(chunk);
154
- return runtime;
155
- }
156
152
  function hasAppNavigationRuntime() {
157
153
  return typeof getNavigationRuntime()?.functions.navigate === "function";
158
154
  }
@@ -172,4 +168,4 @@ function hasAppNavigationRuntimeBootstrap() {
172
168
  return getNavigationRuntime() !== null;
173
169
  }
174
170
  //#endregion
175
- export { NAVIGATION_RUNTIME_KEY, NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION, ensureNavigationRuntimeRscBootstrap, getNavigationRuntime, hasAppNavigationRuntime, hasAppNavigationRuntimeBootstrap, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions, subscribeNavigationRuntimeRscChunk };
171
+ export { NAVIGATION_RUNTIME_KEY, NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION, ensureNavigationRuntimeRscBootstrap, getNavigationRuntime, hasAppNavigationRuntime, hasAppNavigationRuntimeBootstrap, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions };
@@ -6,6 +6,8 @@ type VinextLinkPrefetchRoute = {
6
6
  isDynamic: boolean;
7
7
  patternParts: string[];
8
8
  requiresDynamicNavigationRequest?: boolean;
9
+ /** The route has dynamic params above its root layout. */
10
+ hasRootParams?: true;
9
11
  };
10
12
  /**
11
13
  * Pages Router route pattern exposed to the client so the App Router's
@@ -332,7 +332,11 @@ async function loadNextConfig(root, phase = DEFAULT_PHASE) {
332
332
  const normalizedConfigPath = safeRealpath(path.resolve(configPath));
333
333
  try {
334
334
  const { runnerImport } = await import("vite");
335
- const { module: mod } = await runnerImport(configPath, {
335
+ const virtualConfigId = "virtual:vinext-resolved-next-config";
336
+ const resolvedVirtualConfigId = `\0${virtualConfigId}`;
337
+ const configPathLiteral = JSON.stringify(configPath);
338
+ const phaseLiteral = JSON.stringify(phase);
339
+ const { module: mod } = await runnerImport(virtualConfigId, {
336
340
  root,
337
341
  logLevel: "error",
338
342
  clearScreen: false,
@@ -351,13 +355,26 @@ async function loadNextConfig(root, phase = DEFAULT_PHASE) {
351
355
  ".json"
352
356
  ]
353
357
  },
354
- plugins: [...isTypeScriptConfig ? [cjsGlobalsInjectorPlugin(configPath)] : [], commonjs({ filter: (id) => {
355
- const idPath = id.startsWith("file://") ? fileURLToPath(id) : id.split("?")[0];
356
- if (safeRealpath(path.resolve(idPath)) === normalizedConfigPath) return false;
357
- return id.includes("node_modules") ? true : void 0;
358
- } })]
358
+ plugins: [
359
+ {
360
+ name: "vinext:resolve-next-config-value",
361
+ resolveId(id) {
362
+ if (id === virtualConfigId) return resolvedVirtualConfigId;
363
+ },
364
+ load(id) {
365
+ if (id !== resolvedVirtualConfigId) return;
366
+ return `import * as configModule from ${configPathLiteral};\nconst cjsModule = configModule[${JSON.stringify(VINEXT_CJS_EXPORTS_KEY)}];\nconst cjsInitial = configModule[${JSON.stringify(VINEXT_CJS_INITIAL_KEY)}];\nconst cjsExports = cjsModule && cjsModule.exports;\nconst cjsValue = cjsExports != null && (cjsExports !== cjsInitial || (typeof cjsExports === "object" && Object.keys(cjsExports).length > 0)) ? cjsExports : undefined;\nconst value = cjsValue ?? configModule.default ?? configModule;\nexport default typeof value === "function" ? await value(${phaseLiteral}, { defaultConfig: {} }) : value;\n`;
367
+ }
368
+ },
369
+ ...isTypeScriptConfig ? [cjsGlobalsInjectorPlugin(configPath)] : [],
370
+ commonjs({ filter: (id) => {
371
+ const idPath = id.startsWith("file://") ? fileURLToPath(id) : id.split("?")[0];
372
+ if (safeRealpath(path.resolve(idPath)) === normalizedConfigPath) return false;
373
+ return id.includes("node_modules") ? true : void 0;
374
+ } })
375
+ ]
359
376
  });
360
- return await unwrapConfig(mod, phase);
377
+ return mod.default;
361
378
  } catch (e) {
362
379
  if (isCjsError(e) && (filename.endsWith(".js") || filename.endsWith(".cjs"))) try {
363
380
  return await loadConfigViaRequire(configPath, root, phase);