vinext 0.1.7 → 0.2.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 (279) hide show
  1. package/README.md +51 -30
  2. package/dist/build/inject-pregenerated-paths.d.ts +4 -0
  3. package/dist/build/inject-pregenerated-paths.js +18 -0
  4. package/dist/build/layout-classification.js +1 -1
  5. package/dist/build/nitro-route-rules.js +1 -1
  6. package/dist/build/pages-client-assets-module.d.ts +11 -0
  7. package/dist/build/pages-client-assets-module.js +27 -0
  8. package/dist/build/prerender.d.ts +2 -1
  9. package/dist/build/prerender.js +13 -6
  10. package/dist/build/report.d.ts +13 -2
  11. package/dist/build/report.js +99 -2
  12. package/dist/build/run-prerender.d.ts +7 -0
  13. package/dist/build/run-prerender.js +10 -1
  14. package/dist/build/standalone.js +2 -0
  15. package/dist/cache/cache-adapters-virtual.js +3 -3
  16. package/dist/check.d.ts +18 -0
  17. package/dist/check.js +77 -19
  18. package/dist/cli-args.d.ts +1 -2
  19. package/dist/cli-args.js +1 -1
  20. package/dist/cli-dev-config.d.ts +12 -0
  21. package/dist/cli-dev-config.js +23 -0
  22. package/dist/cli.js +113 -97
  23. package/dist/{server → client}/dev-error-overlay-store.d.ts +1 -1
  24. package/dist/{server → client}/dev-error-overlay-store.js +1 -1
  25. package/dist/{server → client}/dev-error-overlay.d.ts +1 -1
  26. package/dist/{server → client}/dev-error-overlay.js +2 -2
  27. package/dist/client/navigation-runtime.d.ts +2 -0
  28. package/dist/client/navigation-runtime.js +3 -1
  29. package/dist/client/window-next.d.ts +2 -1
  30. package/dist/cloudflare/index.d.ts +2 -2
  31. package/dist/cloudflare/index.js +2 -2
  32. package/dist/config/config-matchers.js +14 -10
  33. package/dist/config/next-config.d.ts +6 -3
  34. package/dist/config/next-config.js +47 -1
  35. package/dist/config/prerender.d.ts +34 -0
  36. package/dist/config/prerender.js +55 -0
  37. package/dist/config/server-external-packages.d.ts +4 -0
  38. package/dist/config/server-external-packages.js +91 -0
  39. package/dist/entries/app-rsc-entry.d.ts +2 -1
  40. package/dist/entries/app-rsc-entry.js +89 -15
  41. package/dist/entries/app-rsc-manifest.js +10 -0
  42. package/dist/entries/pages-client-entry.d.ts +3 -0
  43. package/dist/entries/pages-client-entry.js +16 -1
  44. package/dist/entries/pages-server-entry.js +6 -2
  45. package/dist/image/image-adapters-virtual.d.ts +59 -0
  46. package/dist/image/image-adapters-virtual.js +59 -0
  47. package/dist/index.d.ts +33 -0
  48. package/dist/index.js +211 -118
  49. package/dist/init-cloudflare.d.ts +43 -0
  50. package/dist/init-cloudflare.js +839 -0
  51. package/dist/init-platform.d.ts +40 -0
  52. package/dist/init-platform.js +195 -0
  53. package/dist/init.d.ts +16 -38
  54. package/dist/init.js +208 -97
  55. package/dist/node_modules/.pnpm/am-i-vibing@0.5.0/node_modules/am-i-vibing/dist/detector-1yx2Hoe0.js +294 -0
  56. package/dist/node_modules/.pnpm/process-ancestry@0.1.0/node_modules/process-ancestry/dist/index.js +94 -0
  57. package/dist/{cloudflare → packages/cloudflare}/src/cache/cdn-adapter.runtime.js +1 -1
  58. package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.d.ts +2 -2
  59. package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.js +1 -1
  60. package/dist/packages/cloudflare/src/deploy-config.js +150 -0
  61. package/dist/packages/cloudflare/src/deploy-help.js +55 -0
  62. package/dist/packages/cloudflare/src/deploy.js +276 -0
  63. package/dist/{cloudflare → packages/cloudflare/src}/tpr.d.ts +4 -41
  64. package/dist/{cloudflare → packages/cloudflare/src}/tpr.js +18 -15
  65. package/dist/plugins/ast-scope.d.ts +16 -0
  66. package/dist/plugins/ast-scope.js +62 -0
  67. package/dist/plugins/ast-utils.d.ts +27 -1
  68. package/dist/plugins/ast-utils.js +32 -1
  69. package/dist/plugins/css-module-imports.d.ts +14 -0
  70. package/dist/plugins/css-module-imports.js +59 -0
  71. package/dist/plugins/extensionless-dynamic-import.js +2 -2
  72. package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
  73. package/dist/plugins/ignore-dynamic-requests.js +530 -0
  74. package/dist/plugins/middleware-server-only.d.ts +8 -6
  75. package/dist/plugins/middleware-server-only.js +8 -7
  76. package/dist/plugins/optimize-imports.js +1 -1
  77. package/dist/plugins/typeof-window.d.ts +1 -1
  78. package/dist/plugins/typeof-window.js +28 -56
  79. package/dist/routing/app-route-graph.d.ts +29 -4
  80. package/dist/routing/app-route-graph.js +182 -40
  81. package/dist/routing/app-router.d.ts +5 -0
  82. package/dist/routing/app-router.js +5 -0
  83. package/dist/routing/file-matcher.d.ts +8 -0
  84. package/dist/routing/file-matcher.js +10 -1
  85. package/dist/routing/pages-router.js +2 -2
  86. package/dist/server/api-handler.js +9 -14
  87. package/dist/server/app-browser-action-result.d.ts +4 -1
  88. package/dist/server/app-browser-action-result.js +8 -1
  89. package/dist/server/app-browser-entry.js +194 -190
  90. package/dist/server/app-browser-history-controller.d.ts +2 -1
  91. package/dist/server/app-browser-history-controller.js +6 -2
  92. package/dist/server/app-browser-interception-context.d.ts +1 -0
  93. package/dist/server/app-browser-interception-context.js +4 -2
  94. package/dist/server/app-browser-navigation-controller.d.ts +2 -0
  95. package/dist/server/app-browser-navigation-controller.js +60 -31
  96. package/dist/server/app-browser-server-action-client.d.ts +32 -0
  97. package/dist/server/app-browser-server-action-client.js +127 -0
  98. package/dist/server/app-browser-state.d.ts +11 -1
  99. package/dist/server/app-browser-state.js +25 -8
  100. package/dist/server/app-browser-visible-commit.d.ts +6 -1
  101. package/dist/server/app-browser-visible-commit.js +43 -25
  102. package/dist/server/app-elements-wire.d.ts +9 -2
  103. package/dist/server/app-elements-wire.js +8 -1
  104. package/dist/server/app-elements.d.ts +2 -2
  105. package/dist/server/app-elements.js +4 -3
  106. package/dist/server/app-fallback-renderer.d.ts +5 -2
  107. package/dist/server/app-fallback-renderer.js +15 -7
  108. package/dist/server/app-hydration-cache-publication.d.ts +11 -0
  109. package/dist/server/app-hydration-cache-publication.js +43 -0
  110. package/dist/server/app-middleware.d.ts +4 -3
  111. package/dist/server/app-middleware.js +8 -3
  112. package/dist/server/app-optimistic-routing.js +11 -4
  113. package/dist/server/app-page-boundary-render.d.ts +3 -0
  114. package/dist/server/app-page-boundary-render.js +14 -3
  115. package/dist/server/app-page-cache-finalizer.d.ts +1 -0
  116. package/dist/server/app-page-cache-finalizer.js +10 -3
  117. package/dist/server/app-page-cache-render.d.ts +1 -0
  118. package/dist/server/app-page-cache-render.js +8 -4
  119. package/dist/server/app-page-cache.d.ts +1 -0
  120. package/dist/server/app-page-cache.js +5 -2
  121. package/dist/server/app-page-dispatch.d.ts +33 -4
  122. package/dist/server/app-page-dispatch.js +63 -90
  123. package/dist/server/app-page-element-builder.d.ts +9 -2
  124. package/dist/server/app-page-element-builder.js +114 -23
  125. package/dist/server/app-page-head.d.ts +16 -1
  126. package/dist/server/app-page-head.js +44 -22
  127. package/dist/server/app-page-params.d.ts +2 -1
  128. package/dist/server/app-page-params.js +8 -1
  129. package/dist/server/app-page-ppr-runtime.d.ts +7 -0
  130. package/dist/server/app-page-ppr-runtime.js +70 -0
  131. package/dist/server/app-page-probe.d.ts +1 -0
  132. package/dist/server/app-page-probe.js +6 -1
  133. package/dist/server/app-page-render-identity.d.ts +1 -0
  134. package/dist/server/app-page-render-identity.js +1 -1
  135. package/dist/server/app-page-render.d.ts +4 -1
  136. package/dist/server/app-page-render.js +26 -3
  137. package/dist/server/app-page-request.d.ts +22 -1
  138. package/dist/server/app-page-request.js +92 -15
  139. package/dist/server/app-page-route-wiring.d.ts +14 -2
  140. package/dist/server/app-page-route-wiring.js +61 -25
  141. package/dist/server/app-page-search-params-observation.d.ts +4 -2
  142. package/dist/server/app-page-search-params-observation.js +11 -7
  143. package/dist/server/app-page-segment-state.d.ts +2 -1
  144. package/dist/server/app-page-segment-state.js +3 -1
  145. package/dist/server/app-page-stream.d.ts +5 -0
  146. package/dist/server/app-page-stream.js +3 -1
  147. package/dist/server/app-ppr-fallback-shell-render.d.ts +4 -3
  148. package/dist/server/app-route-handler-dispatch.js +1 -0
  149. package/dist/server/app-route-handler-execution.js +7 -2
  150. package/dist/server/app-route-handler-response.js +1 -0
  151. package/dist/server/app-route-handler-runtime.js +1 -1
  152. package/dist/server/app-route-module-loader.d.ts +2 -0
  153. package/dist/server/app-route-module-loader.js +1 -0
  154. package/dist/server/app-router-entry.js +16 -8
  155. package/dist/server/app-rsc-errors.js +7 -1
  156. package/dist/server/app-rsc-handler.d.ts +3 -1
  157. package/dist/server/app-rsc-handler.js +67 -39
  158. package/dist/server/app-rsc-request-normalization.d.ts +3 -2
  159. package/dist/server/app-rsc-request-normalization.js +6 -3
  160. package/dist/server/app-rsc-route-matching.d.ts +7 -0
  161. package/dist/server/app-rsc-route-matching.js +36 -3
  162. package/dist/server/app-segment-config.d.ts +12 -0
  163. package/dist/server/app-segment-config.js +91 -5
  164. package/dist/server/app-server-action-execution.d.ts +5 -0
  165. package/dist/server/app-server-action-execution.js +94 -33
  166. package/dist/server/app-ssr-entry.d.ts +3 -0
  167. package/dist/server/app-ssr-entry.js +19 -8
  168. package/dist/server/app-ssr-stream.d.ts +7 -3
  169. package/dist/server/app-ssr-stream.js +10 -6
  170. package/dist/server/app-static-generation.d.ts +1 -0
  171. package/dist/server/app-static-generation.js +1 -0
  172. package/dist/server/app-visited-response-cache.d.ts +6 -0
  173. package/dist/server/app-visited-response-cache.js +3 -1
  174. package/dist/server/client-trace-metadata.js +26 -0
  175. package/dist/server/default-global-not-found-module.d.ts +14 -0
  176. package/dist/server/default-global-not-found-module.js +14 -0
  177. package/dist/server/dev-route-files.js +4 -0
  178. package/dist/server/dev-server.js +19 -18
  179. package/dist/server/dev-stack-sourcemap.d.ts +1 -1
  180. package/dist/server/dev-stack-sourcemap.js +1 -1
  181. package/dist/server/fetch-handler.d.ts +2 -0
  182. package/dist/server/fetch-handler.js +18 -0
  183. package/dist/server/headers.d.ts +5 -15
  184. package/dist/server/headers.js +4 -15
  185. package/dist/server/image-optimization.d.ts +51 -1
  186. package/dist/server/image-optimization.js +52 -2
  187. package/dist/server/implicit-tags.js +1 -1
  188. package/dist/server/isr-cache.d.ts +1 -1
  189. package/dist/server/isr-cache.js +2 -2
  190. package/dist/server/metadata-routes.d.ts +3 -1
  191. package/dist/server/metadata-routes.js +12 -2
  192. package/dist/server/middleware-runtime.js +6 -1
  193. package/dist/server/navigation-planner.d.ts +1 -0
  194. package/dist/server/navigation-planner.js +14 -3
  195. package/dist/server/pages-api-route.js +2 -2
  196. package/dist/server/pages-asset-tags.d.ts +4 -6
  197. package/dist/server/pages-asset-tags.js +12 -12
  198. package/dist/server/pages-client-assets.d.ts +12 -0
  199. package/dist/server/pages-client-assets.js +10 -0
  200. package/dist/server/pages-node-compat.d.ts +8 -1
  201. package/dist/server/pages-node-compat.js +32 -4
  202. package/dist/server/pages-page-data.d.ts +24 -1
  203. package/dist/server/pages-page-data.js +45 -24
  204. package/dist/server/pages-page-handler.d.ts +2 -1
  205. package/dist/server/pages-page-handler.js +19 -12
  206. package/dist/server/pages-page-response.d.ts +7 -0
  207. package/dist/server/pages-page-response.js +4 -1
  208. package/dist/server/pages-request-pipeline.d.ts +2 -0
  209. package/dist/server/pages-request-pipeline.js +25 -1
  210. package/dist/server/pages-router-entry.d.ts +30 -0
  211. package/dist/server/pages-router-entry.js +108 -0
  212. package/dist/server/prerender-manifest.d.ts +3 -1
  213. package/dist/server/prerender-route-params.js +1 -1
  214. package/dist/server/prod-server.d.ts +1 -1
  215. package/dist/server/prod-server.js +48 -26
  216. package/dist/server/request-pipeline.js +1 -0
  217. package/dist/server/seed-cache.js +4 -4
  218. package/dist/server/worker-utils.d.ts +2 -1
  219. package/dist/server/worker-utils.js +7 -1
  220. package/dist/shims/app-router-scroll-state.d.ts +1 -0
  221. package/dist/shims/app-router-scroll-state.js +1 -0
  222. package/dist/shims/app-router-scroll.js +2 -1
  223. package/dist/shims/cache.js +19 -15
  224. package/dist/shims/cdn-cache.js +1 -1
  225. package/dist/shims/dynamic-preload-chunks.js +2 -1
  226. package/dist/shims/error-boundary.d.ts +19 -1
  227. package/dist/shims/error-boundary.js +11 -1
  228. package/dist/shims/form.d.ts +3 -1
  229. package/dist/shims/form.js +37 -43
  230. package/dist/shims/headers.d.ts +9 -1
  231. package/dist/shims/headers.js +31 -6
  232. package/dist/shims/image.js +75 -14
  233. package/dist/shims/internal/app-route-detection.d.ts +2 -17
  234. package/dist/shims/internal/app-route-detection.js +4 -17
  235. package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +23 -0
  236. package/dist/shims/internal/hybrid-client-route-owner-direct.js +51 -0
  237. package/dist/shims/internal/hybrid-client-route-owner.d.ts +2 -15
  238. package/dist/shims/internal/hybrid-client-route-owner.js +9 -60
  239. package/dist/shims/internal/pages-data-fetch-dedup.d.ts +9 -5
  240. package/dist/shims/internal/pages-data-fetch-dedup.js +73 -14
  241. package/dist/shims/internal/pages-data-target.d.ts +10 -9
  242. package/dist/shims/internal/pages-data-target.js +91 -12
  243. package/dist/shims/internal/pages-router-components.d.ts +7 -0
  244. package/dist/shims/internal/pages-router-components.js +13 -0
  245. package/dist/shims/layout-segment-context.d.ts +4 -1
  246. package/dist/shims/layout-segment-context.js +18 -4
  247. package/dist/shims/link.js +70 -37
  248. package/dist/shims/metadata.d.ts +3 -2
  249. package/dist/shims/metadata.js +8 -4
  250. package/dist/shims/navigation.d.ts +5 -1
  251. package/dist/shims/navigation.js +45 -10
  252. package/dist/shims/navigation.react-server.js +1 -1
  253. package/dist/shims/root-params.d.ts +15 -1
  254. package/dist/shims/root-params.js +21 -1
  255. package/dist/shims/router.d.ts +5 -7
  256. package/dist/shims/router.js +374 -94
  257. package/dist/shims/server.js +3 -2
  258. package/dist/shims/slot.js +3 -6
  259. package/dist/typegen.js +6 -5
  260. package/dist/utils/client-runtime-metadata.d.ts +2 -18
  261. package/dist/utils/client-runtime-metadata.js +31 -22
  262. package/dist/utils/dev-stack-sourcemap-endpoint.d.ts +4 -0
  263. package/dist/{server → utils}/dev-stack-sourcemap-endpoint.js +1 -1
  264. package/dist/utils/domain-locale.d.ts +6 -3
  265. package/dist/{server → utils}/middleware-request-headers.d.ts +1 -1
  266. package/dist/{server → utils}/middleware-request-headers.js +2 -2
  267. package/dist/utils/path.d.ts +2 -1
  268. package/dist/utils/path.js +1 -1
  269. package/dist/utils/project.d.ts +52 -2
  270. package/dist/utils/project.js +230 -5
  271. package/dist/utils/protocol-headers.d.ts +17 -0
  272. package/dist/utils/protocol-headers.js +17 -0
  273. package/dist/utils/react-version.d.ts +4 -0
  274. package/dist/utils/react-version.js +44 -0
  275. package/package.json +53 -4
  276. package/dist/deploy.d.ts +0 -190
  277. package/dist/deploy.js +0 -1033
  278. package/dist/server/dev-stack-sourcemap-endpoint.d.ts +0 -4
  279. /package/dist/{cloudflare → packages/cloudflare}/src/utils/cache-control-metadata.js +0 -0
@@ -1,7 +1,8 @@
1
1
  import { hasBasePath, stripBasePath } from "../utils/base-path.js";
2
2
  import { getRequestExecutionContext } from "./request-context.js";
3
- import { MIDDLEWARE_NEXT_HEADER, MIDDLEWARE_REWRITE_HEADER, MIDDLEWARE_SET_COOKIE_HEADER } from "../server/headers.js";
4
- import { encodeMiddlewareRequestHeaders } from "../server/middleware-request-headers.js";
3
+ import { MIDDLEWARE_SET_COOKIE_HEADER } from "../utils/protocol-headers.js";
4
+ import { MIDDLEWARE_NEXT_HEADER, MIDDLEWARE_REWRITE_HEADER } from "../server/headers.js";
5
+ import { encodeMiddlewareRequestHeaders } from "../utils/middleware-request-headers.js";
5
6
  import { serializeSetCookie, validateCookieName } from "./internal/cookie-serialize.js";
6
7
  import { parseEdgeRequestCookieHeader } from "../utils/parse-cookie.js";
7
8
  import { assertSafeNavigationUrl } from "./url-safety.js";
@@ -166,12 +166,9 @@ function mergeElements(prev, next, options = {}) {
166
166
  const preserveElementIds = typeof options === "boolean" ? [] : options.preserveElementIds ?? [];
167
167
  const preservePreviousSlotIds = typeof options === "boolean" ? [] : options.preservePreviousSlotIds ?? [];
168
168
  const merged = { ...next };
169
- for (const id of preserveElementIds) {
170
- if (Object.hasOwn(merged, id)) continue;
171
- if (Object.hasOwn(prev, id)) {
172
- const value = prev[id];
173
- if (value !== void 0) merged[id] = value;
174
- }
169
+ for (const id of preserveElementIds) if (Object.hasOwn(prev, id)) {
170
+ const value = prev[id];
171
+ if (value !== void 0) merged[id] = value;
175
172
  }
176
173
  const slotKeys = new Set([...Object.keys(prev), ...Object.keys(next)].filter((key) => AppElementsWire.isSlotId(key)));
177
174
  if (clearAbsentSlots) {
package/dist/typegen.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { findDir } from "./utils/project.js";
2
2
  import { decodeRouteSegment, isInvisibleSegment } from "./routing/utils.js";
3
+ import { normalizePathSeparators } from "./utils/path.js";
3
4
  import { patternToNextFormat } from "./routing/route-validation.js";
4
5
  import { compareStrings } from "./utils/compare.js";
5
6
  import "./routing/app-route-graph.js";
@@ -15,17 +16,17 @@ import "./.next/types/routes.d.ts";
15
16
  // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
16
17
  `;
17
18
  async function generateRouteTypes(options) {
18
- const root = path.resolve(options.root);
19
- const appDir = options.appDir ? path.resolve(options.appDir) : findDir(root, "app", path.join("src", "app"));
20
- const outPath = path.join(root, ".next", "types", "routes.d.ts");
19
+ const root = normalizePathSeparators(path.resolve(options.root));
20
+ const appDir = options.appDir ? normalizePathSeparators(path.resolve(options.appDir)) : findDir(root, "app", "src/app");
21
+ const outPath = path.posix.join(root, ".next", "types", "routes.d.ts");
21
22
  const content = appDir ? renderRouteTypes(await collectRouteTypeModel(appDir, options.pageExtensions)) : renderRouteTypes(emptyRouteTypeModel());
22
- await fs.mkdir(path.dirname(outPath), { recursive: true });
23
+ await fs.mkdir(path.posix.dirname(outPath), { recursive: true });
23
24
  await fs.writeFile(outPath, content, "utf-8");
24
25
  await ensureNextEnvFile(root);
25
26
  return outPath;
26
27
  }
27
28
  async function ensureNextEnvFile(root) {
28
- const envPath = path.join(root, "next-env.d.ts");
29
+ const envPath = path.posix.join(root, "next-env.d.ts");
29
30
  try {
30
31
  await fs.writeFile(envPath, NEXT_ENV_FILE_CONTENT, {
31
32
  encoding: "utf-8",
@@ -1,6 +1,7 @@
1
1
  //#region src/utils/client-runtime-metadata.d.ts
2
2
  type ClientRuntimeMetadata = {
3
3
  clientEntryFile?: string;
4
+ appBootstrapPreinitModules?: string[];
4
5
  lazyChunks?: string[];
5
6
  dynamicPreloads?: Record<string, string[]>;
6
7
  };
@@ -24,22 +25,5 @@ declare function computeClientRuntimeMetadata(opts: {
24
25
  assetPrefix: string;
25
26
  includeClientEntry?: boolean | "pages-client-entry";
26
27
  }): ClientRuntimeMetadata;
27
- /**
28
- * Serialize runtime metadata into the `globalThis.__VINEXT_*` assignment script
29
- * that the Cloudflare `closeBundle` hook prepends to the worker entry. Returns
30
- * `""` when there is nothing to inject.
31
- *
32
- * Both the App Router and Pages Router closeBundle paths call this (and the
33
- * deploy tests mirror it), so the injection shape stays in one place. The caller
34
- * decides which fields to pass — e.g. App Router only forwards `clientEntryFile`
35
- * for mixed app+pages builds (where `computeClientRuntimeMetadata` was asked for
36
- * the Pages client entry); pure App Router leaves it undefined.
37
- */
38
- declare function buildRuntimeGlobalsScript(input: {
39
- clientEntryFile?: string | null;
40
- ssrManifest?: Record<string, string[]> | null;
41
- lazyChunks?: string[] | null;
42
- dynamicPreloads?: Record<string, string[]> | null;
43
- }): string;
44
28
  //#endregion
45
- export { buildRuntimeGlobalsScript, computeClientRuntimeMetadata };
29
+ export { computeClientRuntimeMetadata };
@@ -1,10 +1,34 @@
1
- import { resolveAssetsDir } from "./asset-prefix.js";
1
+ import { isAbsoluteAssetPrefix, resolveAssetsDir } from "./asset-prefix.js";
2
2
  import { manifestFileWithAssetPrefix, manifestFileWithBase } from "./manifest-paths.js";
3
3
  import { findClientEntryFile, findPagesClientEntryFile, readClientBuildManifest } from "./client-build-manifest.js";
4
4
  import { findClientEntryFileFromVinextManifest, findPagesClientEntryFileFromVinextManifest, readClientEntryManifest } from "./client-entry-manifest.js";
5
5
  import { computeDynamicImportPreloads, computeLazyChunks, dynamicImportPreloadsWithBase } from "./lazy-chunks.js";
6
6
  import path from "node:path";
7
7
  //#region src/utils/client-runtime-metadata.ts
8
+ function collectAppBootstrapPreinitModules(buildManifest, appBrowserEntry, applyBase) {
9
+ if (!appBrowserEntry) return void 0;
10
+ const entryKey = Object.keys(buildManifest).find((key) => buildManifest[key].file === appBrowserEntry);
11
+ if (!entryKey) return void 0;
12
+ const modules = [];
13
+ const seenFiles = /* @__PURE__ */ new Set();
14
+ const visitedChunks = /* @__PURE__ */ new Set();
15
+ function visit(key) {
16
+ if (visitedChunks.has(key)) return;
17
+ visitedChunks.add(key);
18
+ const chunk = buildManifest[key];
19
+ if (!chunk) return;
20
+ for (const importedKey of chunk.imports ?? []) {
21
+ const importedChunk = buildManifest[importedKey];
22
+ if (importedChunk?.file.endsWith(".js") && !seenFiles.has(importedChunk.file)) {
23
+ seenFiles.add(importedChunk.file);
24
+ modules.push(applyBase(importedChunk.file));
25
+ }
26
+ visit(importedKey);
27
+ }
28
+ }
29
+ visit(entryKey);
30
+ return modules.length > 0 ? modules : void 0;
31
+ }
8
32
  /**
9
33
  * Read the client build manifest and compute runtime metadata used by
10
34
  * Cloudflare worker entry injection and Node production server startup.
@@ -21,9 +45,9 @@ import path from "node:path";
21
45
  */
22
46
  function computeClientRuntimeMetadata(opts) {
23
47
  const buildManifest = readClientBuildManifest(path.join(opts.clientDir, ".vite", "manifest.json"));
48
+ const clientEntryManifest = readClientEntryManifest(opts.clientDir);
24
49
  const metadata = {};
25
50
  if (opts.includeClientEntry) {
26
- const clientEntryManifest = readClientEntryManifest(opts.clientDir);
27
51
  const entryOptions = {
28
52
  buildManifest,
29
53
  clientDir: opts.clientDir,
@@ -34,30 +58,15 @@ function computeClientRuntimeMetadata(opts) {
34
58
  if (entry) metadata.clientEntryFile = entry;
35
59
  }
36
60
  if (!buildManifest) return metadata;
61
+ metadata.appBootstrapPreinitModules = collectAppBootstrapPreinitModules(buildManifest, clientEntryManifest?.appBrowserEntry, (file) => {
62
+ const url = manifestFileWithAssetPrefix(file, opts.assetBase, opts.assetPrefix);
63
+ return isAbsoluteAssetPrefix(opts.assetPrefix) ? url : "/" + url;
64
+ });
37
65
  const lazyChunks = computeLazyChunks(buildManifest).map((file) => manifestFileWithBase(file, opts.assetBase));
38
66
  if (lazyChunks.length > 0) metadata.lazyChunks = lazyChunks;
39
67
  const dynamicPreloads = dynamicImportPreloadsWithBase(computeDynamicImportPreloads(buildManifest), (file) => manifestFileWithAssetPrefix(file, opts.assetBase, opts.assetPrefix));
40
68
  if (Object.keys(dynamicPreloads).length > 0) metadata.dynamicPreloads = dynamicPreloads;
41
69
  return metadata;
42
70
  }
43
- /**
44
- * Serialize runtime metadata into the `globalThis.__VINEXT_*` assignment script
45
- * that the Cloudflare `closeBundle` hook prepends to the worker entry. Returns
46
- * `""` when there is nothing to inject.
47
- *
48
- * Both the App Router and Pages Router closeBundle paths call this (and the
49
- * deploy tests mirror it), so the injection shape stays in one place. The caller
50
- * decides which fields to pass — e.g. App Router only forwards `clientEntryFile`
51
- * for mixed app+pages builds (where `computeClientRuntimeMetadata` was asked for
52
- * the Pages client entry); pure App Router leaves it undefined.
53
- */
54
- function buildRuntimeGlobalsScript(input) {
55
- const globals = [];
56
- if (input.clientEntryFile) globals.push(`globalThis.__VINEXT_CLIENT_ENTRY__ = ${JSON.stringify(input.clientEntryFile)};`);
57
- if (input.ssrManifest && Object.keys(input.ssrManifest).length > 0) globals.push(`globalThis.__VINEXT_SSR_MANIFEST__ = ${JSON.stringify(input.ssrManifest)};`);
58
- if (input.lazyChunks && input.lazyChunks.length > 0) globals.push(`globalThis.__VINEXT_LAZY_CHUNKS__ = ${JSON.stringify(input.lazyChunks)};`);
59
- if (input.dynamicPreloads && Object.keys(input.dynamicPreloads).length > 0) globals.push(`globalThis.__VINEXT_DYNAMIC_PRELOADS__ = ${JSON.stringify(input.dynamicPreloads)};`);
60
- return globals.join("\n");
61
- }
62
71
  //#endregion
63
- export { buildRuntimeGlobalsScript, computeClientRuntimeMetadata };
72
+ export { computeClientRuntimeMetadata };
@@ -0,0 +1,4 @@
1
+ //#region src/utils/dev-stack-sourcemap-endpoint.d.ts
2
+ declare const VINEXT_ORIGINAL_STACK_TRACE_ENDPOINT = "/__vinext_original-stack-trace";
3
+ //#endregion
4
+ export { VINEXT_ORIGINAL_STACK_TRACE_ENDPOINT };
@@ -1,4 +1,4 @@
1
- //#region src/server/dev-stack-sourcemap-endpoint.ts
1
+ //#region src/utils/dev-stack-sourcemap-endpoint.ts
2
2
  const VINEXT_ORIGINAL_STACK_TRACE_ENDPOINT = "/__vinext_original-stack-trace";
3
3
  //#endregion
4
4
  export { VINEXT_ORIGINAL_STACK_TRACE_ENDPOINT };
@@ -1,7 +1,10 @@
1
- import { NextI18nConfig } from "../config/next-config.js";
2
-
3
1
  //#region src/utils/domain-locale.d.ts
4
- type DomainLocale = NonNullable<NextI18nConfig["domains"]>[number];
2
+ type DomainLocale = {
3
+ domain: string;
4
+ defaultLocale: string;
5
+ locales?: string[];
6
+ http?: boolean;
7
+ };
5
8
  declare function normalizeDomainHostname(hostname: string | null | undefined): string | undefined;
6
9
  /**
7
10
  * Match a configured domain either by hostname or locale.
@@ -1,4 +1,4 @@
1
- //#region src/server/middleware-request-headers.d.ts
1
+ //#region src/utils/middleware-request-headers.d.ts
2
2
  type MiddlewareHeaderValue = string | string[];
3
3
  type MiddlewareHeaderSource = Headers | Record<string, MiddlewareHeaderValue>;
4
4
  type BuildRequestHeadersOptions = {
@@ -1,5 +1,5 @@
1
- import { MIDDLEWARE_OVERRIDE_HEADERS, MIDDLEWARE_REQUEST_HEADER_PREFIX } from "./headers.js";
2
- //#region src/server/middleware-request-headers.ts
1
+ import { MIDDLEWARE_OVERRIDE_HEADERS, MIDDLEWARE_REQUEST_HEADER_PREFIX } from "./protocol-headers.js";
2
+ //#region src/utils/middleware-request-headers.ts
3
3
  const CREDENTIAL_REQUEST_HEADERS = ["authorization", "cookie"];
4
4
  function getMiddlewareHeaderValue(source, key) {
5
5
  if (source instanceof Headers) return source.get(key);
@@ -1,4 +1,5 @@
1
1
  //#region src/utils/path.d.ts
2
+ declare const isWindows: boolean;
2
3
  /**
3
4
  * Convert Windows-style backslash path separators to forward slashes.
4
5
  *
@@ -19,4 +20,4 @@ declare function stripViteModuleQuery(id: string): string;
19
20
  * files like `headers.js.ts`. */
20
21
  declare function stripJsExtension(name: string): string;
21
22
  //#endregion
22
- export { normalizePathSeparators, stripJsExtension, stripViteModuleQuery };
23
+ export { isWindows, normalizePathSeparators, stripJsExtension, stripViteModuleQuery };
@@ -27,4 +27,4 @@ function stripJsExtension(name) {
27
27
  return name.endsWith(".js") ? name.slice(0, -3) : name;
28
28
  }
29
29
  //#endregion
30
- export { normalizePathSeparators, stripJsExtension, stripViteModuleQuery };
30
+ export { isWindows, normalizePathSeparators, stripJsExtension, stripViteModuleQuery };
@@ -1,6 +1,7 @@
1
1
  //#region src/utils/project.d.ts
2
2
  /**
3
- * Shared project utilities used by both `vinext init` and `vinext deploy`.
3
+ * Shared project utilities used by `vinext init`, the vinext plugin, and
4
+ * platform packages such as `@vinext/cloudflare`.
4
5
  *
5
6
  * These functions detect and modify project configuration without touching
6
7
  * any Next.js source files, config files, or tsconfig.json.
@@ -62,15 +63,64 @@ declare function findInNodeModules(start: string, subPath: string): string | nul
62
63
  * Check if a vite.config file exists in the project root.
63
64
  */
64
65
  declare function hasViteConfig(root: string): boolean;
66
+ /** Return the config file Vite will load, using Vite's default precedence. */
67
+ declare function findViteConfigPath(root: string): string | undefined;
68
+ declare function formatMissingCloudflarePluginError(options: {
69
+ isAppRouter: boolean;
70
+ configFile?: string;
71
+ }): string;
72
+ type ProjectInfo = {
73
+ root: string;
74
+ isAppRouter: boolean;
75
+ isPagesRouter: boolean;
76
+ hasViteConfig: boolean;
77
+ hasWranglerConfig: boolean;
78
+ hasWorkerEntry: boolean;
79
+ hasCloudflarePlugin: boolean;
80
+ hasRscPlugin: boolean;
81
+ hasWrangler: boolean;
82
+ projectName: string; /** Pages that use `revalidate` (ISR) */
83
+ hasISR: boolean; /** package.json has "type": "module" */
84
+ hasTypeModule: boolean; /** .mdx files detected in app/ or pages/ */
85
+ hasMDX: boolean; /** CodeHike is a dependency */
86
+ hasCodeHike: boolean; /** Native Node modules that need stubbing for Workers */
87
+ nativeModulesToStub: string[];
88
+ };
89
+ /** Check whether a wrangler config file exists in the given directory. */
90
+ declare function hasWranglerConfig(root: string): boolean;
91
+ /**
92
+ * Detect the project structure, routing mode, relevant config files, and
93
+ * deploy-related dependencies. This lives in core because `vinext init`, the
94
+ * Vite plugin, and platform packages all need the same project facts.
95
+ */
96
+ declare function detectProject(root: string): ProjectInfo;
97
+ type MissingDep = {
98
+ name: string;
99
+ version: string;
100
+ };
101
+ /**
102
+ * Check if a package is resolvable from a given root directory using Node's
103
+ * module resolution. Handles hoisting, pnpm symlinks, monorepos, and Yarn PnP.
104
+ */
105
+ declare function isPackageResolvable(root: string, packageName: string): boolean;
106
+ declare function getMissingDeps(info: ProjectInfo, /** Override for testing — defaults to `isPackageResolvable` */
107
+
108
+ _isResolvable?: (root: string, pkg: string) => boolean): MissingDep[];
65
109
  /**
66
110
  * Return the first candidate directory (resolved against `root`) that exists,
67
111
  * or null. Used to locate conventional `app`/`pages` directories that may live
68
112
  * at the root or under `src/`.
113
+ *
114
+ * `root` and `candidates` must be forward-slash, and the returned path is
115
+ * forward-slash too: the candidate is joined with `path.posix.join`, which only
116
+ * stays canonical when its inputs already are.
69
117
  */
70
118
  declare function findDir(root: string, ...candidates: string[]): string | null;
71
119
  /**
72
120
  * Check if the project uses App Router (has an app/ directory).
121
+ *
122
+ * `root` must be forward-slash — it is passed straight to `findDir`.
73
123
  */
74
124
  declare function hasAppDir(root: string): boolean;
75
125
  //#endregion
76
- export { detectPackageManager, detectPackageManagerName, ensureESModule, ensureViteConfigCompatibility, findDir, findInNodeModules, hasAppDir, hasViteConfig, renameCJSConfigs };
126
+ export { ProjectInfo, detectPackageManager, detectPackageManagerName, detectProject, ensureESModule, ensureViteConfigCompatibility, findDir, findInNodeModules, findViteConfigPath, formatMissingCloudflarePluginError, getMissingDeps, hasAppDir, hasViteConfig, hasWranglerConfig, isPackageResolvable, renameCJSConfigs };
@@ -1,8 +1,10 @@
1
+ import { createRequire } from "node:module";
1
2
  import fs from "node:fs";
2
3
  import path from "node:path";
3
4
  //#region src/utils/project.ts
4
5
  /**
5
- * Shared project utilities used by both `vinext init` and `vinext deploy`.
6
+ * Shared project utilities used by `vinext init`, the vinext plugin, and
7
+ * platform packages such as `@vinext/cloudflare`.
6
8
  *
7
9
  * These functions detect and modify project configuration without touching
8
10
  * any Next.js source files, config files, or tsconfig.json.
@@ -187,16 +189,237 @@ function findInNodeModules(start, subPath) {
187
189
  * Check if a vite.config file exists in the project root.
188
190
  */
189
191
  function hasViteConfig(root) {
190
- return fs.existsSync(path.join(root, "vite.config.ts")) || fs.existsSync(path.join(root, "vite.config.js")) || fs.existsSync(path.join(root, "vite.config.mjs"));
192
+ return findViteConfigPath(root) !== void 0;
193
+ }
194
+ /** Return the config file Vite will load, using Vite's default precedence. */
195
+ function findViteConfigPath(root) {
196
+ return [
197
+ "vite.config.js",
198
+ "vite.config.mjs",
199
+ "vite.config.ts",
200
+ "vite.config.cjs",
201
+ "vite.config.mts",
202
+ "vite.config.cts"
203
+ ].map((fileName) => path.join(root, fileName)).find((candidate) => fs.existsSync(candidate));
204
+ }
205
+ function formatMissingCloudflarePluginError(options) {
206
+ const cfArg = options.isAppRouter ? "{\n viteEnvironment: { name: \"rsc\", childEnvironments: [\"ssr\"] },\n }" : "";
207
+ const configRef = options.configFile ? options.configFile : "your Vite config";
208
+ return `[vinext] Missing @cloudflare/vite-plugin in ${configRef}.\n\n Cloudflare Workers builds require the cloudflare() plugin.\n Run \`vinext init --platform=cloudflare\` to update ${configRef}.\n\n Expected plugin shape:\n\n cloudflare(${cfArg})`;
209
+ }
210
+ /** Check whether a wrangler config file exists in the given directory. */
211
+ function hasWranglerConfig(root) {
212
+ return fs.existsSync(path.join(root, "wrangler.jsonc")) || fs.existsSync(path.join(root, "wrangler.json")) || fs.existsSync(path.join(root, "wrangler.toml")) || fs.existsSync(path.join(root, "cloudflare.config.ts"));
213
+ }
214
+ /**
215
+ * Detect the project structure, routing mode, relevant config files, and
216
+ * deploy-related dependencies. This lives in core because `vinext init`, the
217
+ * Vite plugin, and platform packages all need the same project facts.
218
+ */
219
+ function detectProject(root) {
220
+ const hasApp = resolveProjectDir(root, "app") !== null;
221
+ const hasPages = resolveProjectDir(root, "pages") !== null;
222
+ const isAppRouter = hasApp;
223
+ const isPagesRouter = !hasApp && hasPages;
224
+ const hasViteConfigFile = hasViteConfig(root);
225
+ const wranglerConfigExists = hasWranglerConfig(root);
226
+ const hasWorkerEntry = fs.existsSync(path.join(root, "worker", "index.ts")) || fs.existsSync(path.join(root, "worker", "index.js"));
227
+ const hasCloudflarePlugin = findInNodeModules(root, "@cloudflare/vite-plugin") !== null;
228
+ const hasRscPlugin = findInNodeModules(root, "@vitejs/plugin-rsc") !== null;
229
+ const hasWrangler = findInNodeModules(root, ".bin/wrangler") !== null || findInNodeModules(root, ".bin/cf") !== null;
230
+ const pkgPath = path.join(root, "package.json");
231
+ let pkg = null;
232
+ if (fs.existsSync(pkgPath)) try {
233
+ pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
234
+ } catch {}
235
+ let projectName = path.basename(root);
236
+ if (pkg?.name && typeof pkg.name === "string") projectName = pkg.name.replace(/^@[^/]+\//, "").toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
237
+ const hasTypeModule = pkg?.type === "module";
238
+ let hasISR = false;
239
+ let hasMDX = detectMDXFromConfig(root);
240
+ if (isAppRouter) {
241
+ const appDir = resolveProjectDir(root, "app");
242
+ if (appDir) {
243
+ const found = scanTreeForDetection(appDir, {
244
+ isr: true,
245
+ mdx: !hasMDX
246
+ });
247
+ hasISR = found.isr;
248
+ hasMDX = hasMDX || found.mdx;
249
+ }
250
+ }
251
+ if (hasPages) {
252
+ const pagesDir = resolveProjectDir(root, "pages");
253
+ if (pagesDir) {
254
+ const found = scanTreeForDetection(pagesDir, {
255
+ isr: !hasISR,
256
+ mdx: !hasMDX
257
+ });
258
+ hasISR = hasISR || found.isr;
259
+ hasMDX = hasMDX || found.mdx;
260
+ }
261
+ }
262
+ hasISR = hasISR || detectCacheComponents(root);
263
+ const allDeps = {
264
+ ...pkg?.dependencies,
265
+ ...pkg?.devDependencies
266
+ };
267
+ const hasCodeHike = "codehike" in allDeps;
268
+ const nativeModulesToStub = detectNativeModules(allDeps);
269
+ return {
270
+ root,
271
+ isAppRouter,
272
+ isPagesRouter,
273
+ hasViteConfig: hasViteConfigFile,
274
+ hasWranglerConfig: wranglerConfigExists,
275
+ hasWorkerEntry,
276
+ hasCloudflarePlugin,
277
+ hasRscPlugin,
278
+ hasWrangler,
279
+ projectName,
280
+ hasISR,
281
+ hasTypeModule,
282
+ hasMDX,
283
+ hasCodeHike,
284
+ nativeModulesToStub
285
+ };
286
+ }
287
+ const ISR_PATTERN = /export\s+(?:const\s+revalidate\s*=|(?:async\s+)?function\s+getStaticProps\b|const\s+getStaticProps\s*=|\{[^}]*\bgetStaticProps\b[^}]*\})/;
288
+ const ISR_SCANNABLE_EXTENSION = /\.(ts|tsx|js|jsx)$/;
289
+ function resolveProjectDir(root, name) {
290
+ const rootDir = path.join(root, name);
291
+ try {
292
+ if (fs.statSync(rootDir).isDirectory()) return rootDir;
293
+ } catch {}
294
+ const srcDir = path.join(root, "src", name);
295
+ try {
296
+ if (fs.statSync(srcDir).isDirectory()) return srcDir;
297
+ } catch {}
298
+ return null;
299
+ }
300
+ function scanTreeForDetection(dir, want) {
301
+ const found = {
302
+ isr: false,
303
+ mdx: false
304
+ };
305
+ const walk = (current) => {
306
+ let entries;
307
+ try {
308
+ entries = fs.readdirSync(current, { withFileTypes: true });
309
+ } catch {
310
+ return;
311
+ }
312
+ for (const entry of entries) {
313
+ if ((!want.isr || found.isr) && (!want.mdx || found.mdx)) return;
314
+ const fullPath = path.join(current, entry.name);
315
+ if (entry.isDirectory()) {
316
+ if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
317
+ walk(fullPath);
318
+ } else if (entry.isFile()) {
319
+ if (want.mdx && !found.mdx && entry.name.endsWith(".mdx")) found.mdx = true;
320
+ if (want.isr && !found.isr && ISR_SCANNABLE_EXTENSION.test(entry.name)) try {
321
+ if (ISR_PATTERN.test(fs.readFileSync(fullPath, "utf-8"))) found.isr = true;
322
+ } catch {}
323
+ }
324
+ }
325
+ };
326
+ walk(dir);
327
+ return found;
328
+ }
329
+ function detectMDXFromConfig(root) {
330
+ for (const f of [
331
+ "next.config.ts",
332
+ "next.config.mts",
333
+ "next.config.mjs",
334
+ "next.config.js",
335
+ "next.config.cjs"
336
+ ]) {
337
+ const p = path.join(root, f);
338
+ if (fs.existsSync(p)) try {
339
+ const content = fs.readFileSync(p, "utf-8");
340
+ if (/pageExtensions.*mdx/i.test(content) || /@next\/mdx/.test(content)) return true;
341
+ } catch {}
342
+ }
343
+ return false;
344
+ }
345
+ function detectCacheComponents(root) {
346
+ for (const fileName of [
347
+ "next.config.ts",
348
+ "next.config.mts",
349
+ "next.config.mjs",
350
+ "next.config.js",
351
+ "next.config.cjs"
352
+ ]) {
353
+ const configPath = path.join(root, fileName);
354
+ if (!fs.existsSync(configPath)) continue;
355
+ try {
356
+ if (/\bcacheComponents\s*:\s*true\b/.test(fs.readFileSync(configPath, "utf-8"))) return true;
357
+ } catch {}
358
+ }
359
+ return false;
360
+ }
361
+ const NATIVE_MODULES_TO_STUB = [
362
+ "@resvg/resvg-js",
363
+ "satori",
364
+ "lightningcss",
365
+ "@napi-rs/canvas",
366
+ "sharp"
367
+ ];
368
+ function detectNativeModules(allDeps) {
369
+ return NATIVE_MODULES_TO_STUB.filter((mod) => mod in allDeps);
370
+ }
371
+ /**
372
+ * Check if a package is resolvable from a given root directory using Node's
373
+ * module resolution. Handles hoisting, pnpm symlinks, monorepos, and Yarn PnP.
374
+ */
375
+ function isPackageResolvable(root, packageName) {
376
+ try {
377
+ createRequire(path.join(root, "package.json")).resolve(packageName);
378
+ return true;
379
+ } catch {
380
+ return false;
381
+ }
382
+ }
383
+ function getMissingDeps(info, _isResolvable = isPackageResolvable) {
384
+ const missing = [];
385
+ if (!info.hasCloudflarePlugin) missing.push({
386
+ name: "@cloudflare/vite-plugin",
387
+ version: "latest"
388
+ });
389
+ if (!info.hasWrangler) missing.push({
390
+ name: "wrangler",
391
+ version: "latest"
392
+ });
393
+ if (!_isResolvable(info.root, "@vitejs/plugin-react")) missing.push({
394
+ name: "@vitejs/plugin-react",
395
+ version: "latest"
396
+ });
397
+ if (info.isAppRouter && !info.hasRscPlugin) missing.push({
398
+ name: "@vitejs/plugin-rsc",
399
+ version: "latest"
400
+ });
401
+ if (info.isAppRouter && !_isResolvable(info.root, "react-server-dom-webpack")) missing.push({
402
+ name: "react-server-dom-webpack",
403
+ version: "latest"
404
+ });
405
+ if (info.hasMDX && !_isResolvable(info.root, "@mdx-js/rollup")) missing.push({
406
+ name: "@mdx-js/rollup",
407
+ version: "latest"
408
+ });
409
+ return missing;
191
410
  }
192
411
  /**
193
412
  * Return the first candidate directory (resolved against `root`) that exists,
194
413
  * or null. Used to locate conventional `app`/`pages` directories that may live
195
414
  * at the root or under `src/`.
415
+ *
416
+ * `root` and `candidates` must be forward-slash, and the returned path is
417
+ * forward-slash too: the candidate is joined with `path.posix.join`, which only
418
+ * stays canonical when its inputs already are.
196
419
  */
197
420
  function findDir(root, ...candidates) {
198
421
  for (const candidate of candidates) {
199
- const full = path.join(root, candidate);
422
+ const full = path.posix.join(root, candidate);
200
423
  try {
201
424
  if (fs.statSync(full).isDirectory()) return full;
202
425
  } catch {}
@@ -205,9 +428,11 @@ function findDir(root, ...candidates) {
205
428
  }
206
429
  /**
207
430
  * Check if the project uses App Router (has an app/ directory).
431
+ *
432
+ * `root` must be forward-slash — it is passed straight to `findDir`.
208
433
  */
209
434
  function hasAppDir(root) {
210
- return findDir(root, "app", path.join("src", "app")) !== null;
435
+ return findDir(root, "app", "src/app") !== null;
211
436
  }
212
437
  //#endregion
213
- export { detectPackageManager, detectPackageManagerName, ensureESModule, ensureViteConfigCompatibility, findDir, findInNodeModules, hasAppDir, hasViteConfig, renameCJSConfigs };
438
+ export { detectPackageManager, detectPackageManagerName, detectProject, ensureESModule, ensureViteConfigCompatibility, findDir, findInNodeModules, findViteConfigPath, formatMissingCloudflarePluginError, getMissingDeps, hasAppDir, hasViteConfig, hasWranglerConfig, isPackageResolvable, renameCJSConfigs };
@@ -0,0 +1,17 @@
1
+ //#region src/utils/protocol-headers.d.ts
2
+ /** Serialized middleware context (JSON) forwarded from dev server to RSC entry. */
3
+ declare const VINEXT_MW_CTX_HEADER = "x-vinext-mw-ctx";
4
+ /** Build-time prerender authentication secret. */
5
+ declare const VINEXT_PRERENDER_SECRET_HEADER = "x-vinext-prerender-secret";
6
+ /** URL-encoded JSON route params for build-time prerender renders. */
7
+ declare const VINEXT_PRERENDER_ROUTE_PARAMS_HEADER = "x-vinext-prerender-route-params";
8
+ /** Prefix for forwarded request headers (e.g. `x-middleware-request-cookie`). */
9
+ declare const MIDDLEWARE_REQUEST_HEADER_PREFIX = "x-middleware-request-";
10
+ /** Comma-separated list of header names that middleware wants to override. */
11
+ declare const MIDDLEWARE_OVERRIDE_HEADERS = "x-middleware-override-headers";
12
+ /** Carries cookies set by middleware for same-render reads. */
13
+ declare const MIDDLEWARE_SET_COOKIE_HEADER = "x-middleware-set-cookie";
14
+ /** Generic prefix for all middleware internal headers. */
15
+ declare const MIDDLEWARE_HEADER_PREFIX = "x-middleware-";
16
+ //#endregion
17
+ export { MIDDLEWARE_HEADER_PREFIX, MIDDLEWARE_OVERRIDE_HEADERS, MIDDLEWARE_REQUEST_HEADER_PREFIX, MIDDLEWARE_SET_COOKIE_HEADER, VINEXT_MW_CTX_HEADER, VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER };
@@ -0,0 +1,17 @@
1
+ //#region src/utils/protocol-headers.ts
2
+ /** Serialized middleware context (JSON) forwarded from dev server to RSC entry. */
3
+ const VINEXT_MW_CTX_HEADER = "x-vinext-mw-ctx";
4
+ /** Build-time prerender authentication secret. */
5
+ const VINEXT_PRERENDER_SECRET_HEADER = "x-vinext-prerender-secret";
6
+ /** URL-encoded JSON route params for build-time prerender renders. */
7
+ const VINEXT_PRERENDER_ROUTE_PARAMS_HEADER = "x-vinext-prerender-route-params";
8
+ /** Prefix for forwarded request headers (e.g. `x-middleware-request-cookie`). */
9
+ const MIDDLEWARE_REQUEST_HEADER_PREFIX = "x-middleware-request-";
10
+ /** Comma-separated list of header names that middleware wants to override. */
11
+ const MIDDLEWARE_OVERRIDE_HEADERS = "x-middleware-override-headers";
12
+ /** Carries cookies set by middleware for same-render reads. */
13
+ const MIDDLEWARE_SET_COOKIE_HEADER = "x-middleware-set-cookie";
14
+ /** Generic prefix for all middleware internal headers. */
15
+ const MIDDLEWARE_HEADER_PREFIX = "x-middleware-";
16
+ //#endregion
17
+ export { MIDDLEWARE_HEADER_PREFIX, MIDDLEWARE_OVERRIDE_HEADERS, MIDDLEWARE_REQUEST_HEADER_PREFIX, MIDDLEWARE_SET_COOKIE_HEADER, VINEXT_MW_CTX_HEADER, VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER };
@@ -0,0 +1,4 @@
1
+ //#region src/utils/react-version.d.ts
2
+ declare function getReactUpgradeDeps(root: string): string[];
3
+ //#endregion
4
+ export { getReactUpgradeDeps };