@qzsy/vinext 0.1.12 → 0.1.81

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 (231) hide show
  1. package/README.md +19 -5
  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/pages-client-assets-module.d.ts +11 -0
  5. package/dist/build/pages-client-assets-module.js +27 -0
  6. package/dist/build/prerender.d.ts +2 -1
  7. package/dist/build/prerender.js +11 -4
  8. package/dist/build/report.d.ts +2 -1
  9. package/dist/build/report.js +2 -1
  10. package/dist/build/run-prerender.d.ts +7 -0
  11. package/dist/build/run-prerender.js +9 -0
  12. package/dist/build/standalone.js +2 -0
  13. package/dist/check.d.ts +18 -0
  14. package/dist/check.js +77 -19
  15. package/dist/cli-dev-config.d.ts +12 -0
  16. package/dist/cli-dev-config.js +23 -0
  17. package/dist/cli.js +64 -28
  18. package/dist/{server → client}/dev-error-overlay-store.d.ts +1 -1
  19. package/dist/{server → client}/dev-error-overlay-store.js +1 -1
  20. package/dist/{server → client}/dev-error-overlay.d.ts +1 -1
  21. package/dist/{server → client}/dev-error-overlay.js +2 -2
  22. package/dist/cloudflare/deploy-config.d.ts +51 -0
  23. package/dist/cloudflare/deploy-config.js +153 -0
  24. package/dist/cloudflare/index.d.ts +1 -1
  25. package/dist/cloudflare/index.js +1 -1
  26. package/dist/cloudflare/project.d.ts +41 -0
  27. package/dist/cloudflare/project.js +243 -0
  28. package/dist/cloudflare/tpr.js +1 -1
  29. package/dist/config/config-matchers.js +14 -10
  30. package/dist/config/next-config.d.ts +6 -3
  31. package/dist/config/next-config.js +47 -1
  32. package/dist/config/server-external-packages.d.ts +4 -0
  33. package/dist/config/server-external-packages.js +91 -0
  34. package/dist/deploy.d.ts +2 -122
  35. package/dist/deploy.js +20 -793
  36. package/dist/entries/app-rsc-entry.d.ts +2 -1
  37. package/dist/entries/app-rsc-entry.js +70 -12
  38. package/dist/entries/app-rsc-manifest.js +8 -0
  39. package/dist/entries/pages-client-entry.d.ts +1 -0
  40. package/dist/entries/pages-client-entry.js +2 -1
  41. package/dist/entries/pages-server-entry.js +6 -2
  42. package/dist/image/image-adapters-virtual.d.ts +59 -0
  43. package/dist/image/image-adapters-virtual.js +50 -0
  44. package/dist/index.d.ts +12 -0
  45. package/dist/index.js +160 -160
  46. package/dist/init-cloudflare.d.ts +43 -0
  47. package/dist/init-cloudflare.js +1000 -0
  48. package/dist/init-platform.d.ts +38 -0
  49. package/dist/init-platform.js +150 -0
  50. package/dist/init.d.ts +14 -37
  51. package/dist/init.js +205 -95
  52. package/dist/node_modules/.pnpm/am-i-vibing@0.5.0/node_modules/am-i-vibing/dist/detector-1yx2Hoe0.js +294 -0
  53. package/dist/node_modules/.pnpm/process-ancestry@0.1.0/node_modules/process-ancestry/dist/index.js +94 -0
  54. package/dist/{cloudflare → packages/cloudflare}/src/cache/cdn-adapter.runtime.js +1 -1
  55. package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.d.ts +2 -2
  56. package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.js +1 -1
  57. package/dist/plugins/ast-scope.d.ts +16 -0
  58. package/dist/plugins/ast-scope.js +62 -0
  59. package/dist/plugins/ast-utils.js +3 -0
  60. package/dist/plugins/css-module-imports.d.ts +14 -0
  61. package/dist/plugins/css-module-imports.js +59 -0
  62. package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
  63. package/dist/plugins/ignore-dynamic-requests.js +530 -0
  64. package/dist/plugins/middleware-server-only.d.ts +8 -6
  65. package/dist/plugins/middleware-server-only.js +8 -7
  66. package/dist/plugins/optimize-imports.js +1 -1
  67. package/dist/plugins/typeof-window.d.ts +1 -1
  68. package/dist/plugins/typeof-window.js +28 -56
  69. package/dist/routing/app-route-graph.d.ts +13 -2
  70. package/dist/routing/app-route-graph.js +116 -32
  71. package/dist/routing/app-router.d.ts +5 -0
  72. package/dist/routing/app-router.js +5 -0
  73. package/dist/routing/file-matcher.d.ts +8 -0
  74. package/dist/routing/file-matcher.js +10 -1
  75. package/dist/routing/pages-router.js +2 -2
  76. package/dist/server/app-browser-action-result.d.ts +2 -1
  77. package/dist/server/app-browser-action-result.js +5 -1
  78. package/dist/server/app-browser-entry.js +17 -12
  79. package/dist/server/app-browser-history-controller.d.ts +2 -1
  80. package/dist/server/app-browser-history-controller.js +6 -2
  81. package/dist/server/app-browser-interception-context.d.ts +1 -0
  82. package/dist/server/app-browser-interception-context.js +4 -2
  83. package/dist/server/app-browser-navigation-controller.js +1 -0
  84. package/dist/server/app-browser-server-action-client.js +2 -3
  85. package/dist/server/app-browser-state.d.ts +1 -0
  86. package/dist/server/app-browser-state.js +3 -2
  87. package/dist/server/app-fallback-renderer.d.ts +3 -2
  88. package/dist/server/app-fallback-renderer.js +12 -7
  89. package/dist/server/app-middleware.d.ts +2 -3
  90. package/dist/server/app-middleware.js +3 -2
  91. package/dist/server/app-optimistic-routing.js +1 -1
  92. package/dist/server/app-page-boundary-render.d.ts +1 -0
  93. package/dist/server/app-page-boundary-render.js +12 -3
  94. package/dist/server/app-page-cache-finalizer.d.ts +1 -0
  95. package/dist/server/app-page-cache-finalizer.js +10 -3
  96. package/dist/server/app-page-cache-render.d.ts +1 -0
  97. package/dist/server/app-page-cache-render.js +8 -4
  98. package/dist/server/app-page-cache.d.ts +1 -0
  99. package/dist/server/app-page-cache.js +4 -1
  100. package/dist/server/app-page-dispatch.d.ts +11 -3
  101. package/dist/server/app-page-dispatch.js +55 -15
  102. package/dist/server/app-page-element-builder.d.ts +5 -1
  103. package/dist/server/app-page-element-builder.js +57 -20
  104. package/dist/server/app-page-head.d.ts +12 -0
  105. package/dist/server/app-page-head.js +42 -19
  106. package/dist/server/app-page-params.d.ts +2 -1
  107. package/dist/server/app-page-params.js +8 -1
  108. package/dist/server/app-page-probe.d.ts +1 -0
  109. package/dist/server/app-page-probe.js +6 -1
  110. package/dist/server/app-page-render-identity.d.ts +1 -0
  111. package/dist/server/app-page-render-identity.js +1 -1
  112. package/dist/server/app-page-render.d.ts +4 -1
  113. package/dist/server/app-page-render.js +8 -3
  114. package/dist/server/app-page-request.d.ts +22 -1
  115. package/dist/server/app-page-request.js +89 -13
  116. package/dist/server/app-page-route-wiring.d.ts +6 -1
  117. package/dist/server/app-page-route-wiring.js +31 -15
  118. package/dist/server/app-page-search-params-observation.d.ts +4 -2
  119. package/dist/server/app-page-search-params-observation.js +11 -7
  120. package/dist/server/app-page-segment-state.js +2 -0
  121. package/dist/server/app-route-handler-dispatch.js +1 -0
  122. package/dist/server/app-route-handler-execution.js +7 -2
  123. package/dist/server/app-route-handler-response.js +1 -0
  124. package/dist/server/app-route-handler-runtime.js +1 -1
  125. package/dist/server/app-route-module-loader.d.ts +2 -0
  126. package/dist/server/app-route-module-loader.js +1 -0
  127. package/dist/server/app-router-entry.d.ts +12 -0
  128. package/dist/server/app-router-entry.js +22 -8
  129. package/dist/server/app-router-image-optimization.d.ts +37 -0
  130. package/dist/server/app-router-image-optimization.js +40 -0
  131. package/dist/server/app-rsc-errors.js +7 -1
  132. package/dist/server/app-rsc-handler.js +27 -14
  133. package/dist/server/app-rsc-route-matching.d.ts +7 -0
  134. package/dist/server/app-rsc-route-matching.js +36 -3
  135. package/dist/server/app-segment-config.d.ts +12 -0
  136. package/dist/server/app-segment-config.js +91 -5
  137. package/dist/server/app-server-action-execution.d.ts +5 -0
  138. package/dist/server/app-server-action-execution.js +106 -33
  139. package/dist/server/app-ssr-entry.js +12 -1
  140. package/dist/server/app-static-generation.d.ts +1 -0
  141. package/dist/server/app-static-generation.js +1 -0
  142. package/dist/server/client-trace-metadata.js +26 -0
  143. package/dist/server/default-global-not-found-module.d.ts +14 -0
  144. package/dist/server/default-global-not-found-module.js +14 -0
  145. package/dist/server/dev-response-headers.d.ts +19 -0
  146. package/dist/server/dev-response-headers.js +78 -0
  147. package/dist/server/dev-server.js +8 -15
  148. package/dist/server/dev-stack-sourcemap.d.ts +1 -1
  149. package/dist/server/dev-stack-sourcemap.js +1 -1
  150. package/dist/server/headers.d.ts +7 -15
  151. package/dist/server/headers.js +6 -15
  152. package/dist/server/image-optimization.d.ts +51 -1
  153. package/dist/server/image-optimization.js +52 -2
  154. package/dist/server/isr-cache.d.ts +1 -1
  155. package/dist/server/isr-cache.js +2 -2
  156. package/dist/server/middleware-runtime.js +6 -1
  157. package/dist/server/navigation-planner.d.ts +1 -0
  158. package/dist/server/navigation-planner.js +14 -3
  159. package/dist/server/pages-asset-tags.d.ts +4 -6
  160. package/dist/server/pages-asset-tags.js +12 -12
  161. package/dist/server/pages-client-assets.d.ts +12 -0
  162. package/dist/server/pages-client-assets.js +10 -0
  163. package/dist/server/pages-page-data.d.ts +23 -1
  164. package/dist/server/pages-page-data.js +43 -24
  165. package/dist/server/pages-page-handler.d.ts +2 -1
  166. package/dist/server/pages-page-handler.js +10 -4
  167. package/dist/server/pages-request-pipeline.d.ts +2 -0
  168. package/dist/server/pages-request-pipeline.js +25 -1
  169. package/dist/server/prerender-manifest.d.ts +3 -1
  170. package/dist/server/prerender-route-params.js +1 -1
  171. package/dist/server/prod-server.d.ts +1 -1
  172. package/dist/server/prod-server.js +47 -25
  173. package/dist/server/request-log.d.ts +5 -14
  174. package/dist/server/request-log.js +7 -1
  175. package/dist/server/request-pipeline.js +1 -0
  176. package/dist/server/seed-cache.js +4 -4
  177. package/dist/server/server-action-logger.d.ts +39 -0
  178. package/dist/server/server-action-logger.js +104 -0
  179. package/dist/server/worker-utils.d.ts +2 -1
  180. package/dist/server/worker-utils.js +7 -1
  181. package/dist/shims/app-router-scroll-state.d.ts +1 -0
  182. package/dist/shims/app-router-scroll-state.js +1 -0
  183. package/dist/shims/app-router-scroll.js +2 -1
  184. package/dist/shims/cache.js +19 -15
  185. package/dist/shims/cdn-cache.js +1 -1
  186. package/dist/shims/dynamic-preload-chunks.js +2 -1
  187. package/dist/shims/error-boundary.d.ts +19 -1
  188. package/dist/shims/error-boundary.js +11 -1
  189. package/dist/shims/form.d.ts +3 -1
  190. package/dist/shims/form.js +37 -43
  191. package/dist/shims/headers.d.ts +9 -1
  192. package/dist/shims/headers.js +31 -6
  193. package/dist/shims/image-optimization-url.d.ts +4 -0
  194. package/dist/shims/image-optimization-url.js +33 -1
  195. package/dist/shims/image.js +46 -13
  196. package/dist/shims/internal/app-route-detection.d.ts +2 -17
  197. package/dist/shims/internal/app-route-detection.js +4 -17
  198. package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +23 -0
  199. package/dist/shims/internal/hybrid-client-route-owner-direct.js +51 -0
  200. package/dist/shims/internal/hybrid-client-route-owner.d.ts +2 -5
  201. package/dist/shims/internal/hybrid-client-route-owner.js +9 -60
  202. package/dist/shims/internal/pages-router-components.d.ts +7 -0
  203. package/dist/shims/internal/pages-router-components.js +13 -0
  204. package/dist/shims/link.js +23 -16
  205. package/dist/shims/metadata.d.ts +3 -2
  206. package/dist/shims/metadata.js +8 -4
  207. package/dist/shims/navigation.js +4 -2
  208. package/dist/shims/root-params.d.ts +15 -1
  209. package/dist/shims/root-params.js +21 -1
  210. package/dist/shims/router.d.ts +2 -5
  211. package/dist/shims/router.js +41 -22
  212. package/dist/shims/server.js +3 -2
  213. package/dist/typegen.js +6 -5
  214. package/dist/utils/client-runtime-metadata.d.ts +2 -18
  215. package/dist/utils/client-runtime-metadata.js +31 -22
  216. package/dist/utils/dev-stack-sourcemap-endpoint.d.ts +4 -0
  217. package/dist/{server → utils}/dev-stack-sourcemap-endpoint.js +1 -1
  218. package/dist/utils/domain-locale.d.ts +6 -3
  219. package/dist/{server → utils}/middleware-request-headers.d.ts +1 -1
  220. package/dist/{server → utils}/middleware-request-headers.js +2 -2
  221. package/dist/utils/path.d.ts +2 -1
  222. package/dist/utils/path.js +1 -1
  223. package/dist/utils/project.d.ts +9 -1
  224. package/dist/utils/project.js +21 -4
  225. package/dist/utils/protocol-headers.d.ts +17 -0
  226. package/dist/utils/protocol-headers.js +17 -0
  227. package/dist/utils/react-version.d.ts +4 -0
  228. package/dist/utils/react-version.js +44 -0
  229. package/package.json +29 -23
  230. package/dist/server/dev-stack-sourcemap-endpoint.d.ts +0 -4
  231. /package/dist/{cloudflare → packages/cloudflare}/src/utils/cache-control-metadata.js +0 -0
@@ -1,22 +1,23 @@
1
1
  import { splitPathSegments } from "../routing/utils.js";
2
2
  import { removeTrailingSlash, stripBasePath } from "../utils/base-path.js";
3
3
  import { assertSafeNavigationUrl } from "./url-safety.js";
4
- import { fillRoutePatternSegments, matchRoutePattern, routePatternParts } from "../routing/route-pattern.js";
5
4
  import { isUnknownRecord } from "../utils/record.js";
6
5
  import { AppRouterContext } from "./internal/app-router-context.js";
7
6
  import { RouterContext } from "./internal/router-context.js";
8
7
  import { applyVinextLocaleGlobals, extractVinextNextDataJson, parseVinextNextDataJson } from "../client/vinext-next-data.js";
9
8
  import { isValidModulePath } from "../client/validate-module-path.js";
10
9
  import { addLocalePrefix, getDomainLocaleUrl, getLocalePathPrefix } from "../utils/domain-locale.js";
10
+ import { fillRoutePatternSegments, matchRoutePattern, routePatternParts } from "../routing/route-pattern.js";
11
11
  import { buildPagesDataHref } from "./internal/pages-data-url.js";
12
12
  import { NEXT_DEPLOYMENT_ID_HEADER, getDeploymentId } from "../utils/deployment-id.js";
13
13
  import { dedupedPagesDataFetch } from "./internal/pages-data-fetch-dedup.js";
14
14
  import { prefetchPagesData, resolvePagesDataNavigationTarget } from "./internal/pages-data-target.js";
15
- import { addQueryParam, appendSearchParamsToUrl, mergeRouteParamsIntoQuery, parseQueryString, urlQueryToSearchParams } from "../utils/query.js";
16
- import { resolveHybridClientRouteOwner } from "./internal/hybrid-client-route-owner.js";
17
- import { getPagesRouterComponentsMap, markAppRouteDetectedOnPrefetch } from "./internal/app-route-detection.js";
15
+ import { getPagesRouterComponentsMap } from "./internal/pages-router-components.js";
16
+ import { markAppRouteDetectedOnPrefetch } from "./internal/app-route-detection.js";
17
+ import { resolveDirectHybridClientRouteOwner } from "./internal/hybrid-client-route-owner-direct.js";
18
18
  import { installWindowNext } from "../client/window-next.js";
19
19
  import { getWindowOrigin, isAbsoluteOrProtocolRelativeUrl, isHashOnlyBrowserUrlChange, normalizePathTrailingSlash, toBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
20
+ import { addQueryParam, appendSearchParamsToUrl, mergeRouteParamsIntoQuery, parseQueryString, urlQueryToSearchParams } from "../utils/query.js";
20
21
  import { scrollToHashTarget } from "./hash-scroll.js";
21
22
  import { installPagesRouterRuntime, setPagesRouterPopStateHandler, setStampInitialHistoryState } from "./pages-router-runtime.js";
22
23
  import { interpolateDynamicRouteHref } from "./internal/interpolate-as.js";
@@ -186,6 +187,7 @@ function createPagesRouterRuntimeState() {
186
187
  activeAbortController: null,
187
188
  cancelPendingRenderCommit: null,
188
189
  lastPathnameAndSearch: typeof window !== "undefined" ? window.location.pathname + window.location.search : "",
190
+ lastHash: typeof window !== "undefined" ? window.location.hash : "",
189
191
  isFirstPopStateEvent: true,
190
192
  routerDidNavigate: false,
191
193
  deprecatedEventBridgeInstalled: false,
@@ -941,6 +943,7 @@ async function navigateClientData(url, initialTarget, controller, navId, assertS
941
943
  if (!redirectedUrl) scheduleHardNavigationAndThrow(softRedirect, "Navigation redirected externally");
942
944
  window.history.replaceState(window.history.state ?? {}, "", redirectedUrl);
943
945
  routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
946
+ routerRuntimeState.lastHash = window.location.hash;
944
947
  await navigateClientHtml(redirectedUrl, redirectedUrl, controller, navId, assertStillCurrent);
945
948
  return;
946
949
  }
@@ -1099,6 +1102,7 @@ async function navigateClientHtml(url, fetchUrl, controller, navId, assertStillC
1099
1102
  if (pendingRedirectHistoryUrl) {
1100
1103
  window.history.replaceState(window.history.state ?? {}, "", pendingRedirectHistoryUrl);
1101
1104
  routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
1105
+ routerRuntimeState.lastHash = window.location.hash;
1102
1106
  }
1103
1107
  window.__NEXT_DATA__ = nextData;
1104
1108
  applyVinextLocaleGlobals(window, nextData);
@@ -1138,8 +1142,8 @@ async function navigateClient(url, fetchUrl = url, options = {}, routeUrl = url)
1138
1142
  let htmlFetchUrl = fetchUrl;
1139
1143
  let dataTarget = resolvePagesDataNavigationTarget(routeUrl, __basePath);
1140
1144
  let middlewareDataResponse;
1141
- if (!dataTarget) {
1142
- let middlewareEffect;
1145
+ let middlewareEffect = null;
1146
+ if (hasVinextMiddleware(window.__NEXT_DATA__)) {
1143
1147
  try {
1144
1148
  middlewareEffect = await resolveMiddlewareDataEffect(browserUrl, controller.signal);
1145
1149
  } catch (err) {
@@ -1147,18 +1151,19 @@ async function navigateClient(url, fetchUrl = url, options = {}, routeUrl = url)
1147
1151
  throw err;
1148
1152
  }
1149
1153
  assertStillCurrent();
1150
- const redirectLocation = middlewareEffect?.redirectLocation ?? null;
1151
- if (redirectLocation) {
1152
- const redirectedUrl = resolveLocalRedirectUrl(redirectLocation);
1153
- if (!redirectedUrl) scheduleHardNavigationAndThrow(redirectLocation, "Navigation redirected externally");
1154
- window.history.replaceState(window.history.state ?? {}, "", redirectedUrl);
1155
- routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
1156
- browserUrl = redirectedUrl;
1157
- htmlFetchUrl = redirectedUrl;
1158
- } else if (middlewareEffect?.rewriteTarget) {
1159
- dataTarget = resolvePagesDataNavigationTarget(middlewareEffect.rewriteTarget, __basePath);
1160
- if (dataTarget) middlewareDataResponse = middlewareEffect.response;
1161
- }
1154
+ }
1155
+ const redirectLocation = middlewareEffect?.redirectLocation ?? null;
1156
+ if (redirectLocation) {
1157
+ const redirectedUrl = resolveLocalRedirectUrl(redirectLocation);
1158
+ if (!redirectedUrl) scheduleHardNavigationAndThrow(redirectLocation, "Navigation redirected externally");
1159
+ window.history.replaceState(window.history.state ?? {}, "", redirectedUrl);
1160
+ routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
1161
+ routerRuntimeState.lastHash = window.location.hash;
1162
+ browserUrl = redirectedUrl;
1163
+ htmlFetchUrl = redirectedUrl;
1164
+ } else if (middlewareEffect) {
1165
+ if (middlewareEffect.rewriteTarget || routeUrl === url) middlewareDataResponse = middlewareEffect.response;
1166
+ if (!dataTarget && middlewareEffect.rewriteTarget) dataTarget = resolvePagesDataNavigationTarget(middlewareEffect.rewriteTarget, __basePath);
1162
1167
  }
1163
1168
  if (dataTarget) await navigateClientData(browserUrl, dataTarget, controller, navId, assertStillCurrent, options, middlewareDataResponse);
1164
1169
  else await navigateClientHtml(browserUrl, htmlFetchUrl, controller, navId, assertStillCurrent, options);
@@ -1263,6 +1268,7 @@ function updateHistory(mode, fullUrl, navState) {
1263
1268
  else window.history.replaceState(state, "", fullUrl);
1264
1269
  routerRuntimeState.currentHistoryKey = key;
1265
1270
  routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
1271
+ routerRuntimeState.lastHash = window.location.hash;
1266
1272
  routerRuntimeState.routerDidNavigate = true;
1267
1273
  }
1268
1274
  function createHistoryKey() {
@@ -1386,7 +1392,14 @@ async function performNavigation(url, as, options, mode, onStateUpdate) {
1386
1392
  const appPath = getLocalPathname(resolved);
1387
1393
  const appPathNorm = appPath !== null ? removeTrailingSlash(appPath) : null;
1388
1394
  const appPathEntry = appPathNorm !== null ? getPagesRouterComponentsMap()[appPathNorm] : void 0;
1389
- if (appPathEntry !== void 0 && "__appRouter" in appPathEntry && appPathEntry.__appRouter || ["app", "document"].includes(resolveHybridClientRouteOwner(resolved, __basePath) ?? "")) {
1395
+ if (appPathEntry !== void 0 && "__appRouter" in appPathEntry && appPathEntry.__appRouter) {
1396
+ if (mode === "push") window.location.assign(full);
1397
+ else window.location.replace(full);
1398
+ return new Promise(() => {});
1399
+ }
1400
+ const rewrites = window.__VINEXT_CLIENT_REWRITES__;
1401
+ const hybridOwner = rewrites && (rewrites.beforeFiles.length > 0 || rewrites.afterFiles.length > 0 || rewrites.fallback.length > 0) ? (await import("./internal/hybrid-client-route-owner.js")).resolveHybridClientRouteOwner(resolved, __basePath) : resolveDirectHybridClientRouteOwner(resolved, __basePath);
1402
+ if (["app", "document"].includes(hybridOwner ?? "")) {
1390
1403
  if (mode === "push") window.location.assign(full);
1391
1404
  else window.location.replace(full);
1392
1405
  return new Promise(() => {});
@@ -1434,7 +1447,7 @@ async function prefetchUrl(url) {
1434
1447
  prefetchPagesData(dataTarget);
1435
1448
  return;
1436
1449
  }
1437
- markAppRouteDetectedOnPrefetch(url, __basePath);
1450
+ await markAppRouteDetectedOnPrefetch(url, __basePath);
1438
1451
  const link = document.createElement("link");
1439
1452
  link.rel = "prefetch";
1440
1453
  link.href = url;
@@ -1519,6 +1532,10 @@ function getRouterStateKey(state) {
1519
1532
  if (!isNextRouterState(state)) return void 0;
1520
1533
  return typeof state.key === "string" ? state.key : void 0;
1521
1534
  }
1535
+ function getTrackedPagesRouterAsPath() {
1536
+ const trackedUrl = new URL(routerRuntimeState.lastPathnameAndSearch, window.location.href);
1537
+ return removeNavigationLocalePrefix(stripBasePath(trackedUrl.pathname, __basePath) + trackedUrl.search);
1538
+ }
1522
1539
  function handlePagesRouterPopState(e) {
1523
1540
  const browserUrl = window.location.pathname + window.location.search;
1524
1541
  const appUrl = stripBasePath(window.location.pathname, __basePath) + window.location.search;
@@ -1528,9 +1545,10 @@ function handlePagesRouterPopState(e) {
1528
1545
  if (state !== null && state !== void 0 && !isNextRouterState(state)) return;
1529
1546
  if (wasFirst && !routerRuntimeState.routerDidNavigate && isNextRouterState(state)) {
1530
1547
  const currentLocale = window.__VINEXT_LOCALE__;
1531
- if (state.options?.locale === currentLocale && typeof state.as === "string" && withBasePath(state.as, __basePath) === routerRuntimeState.lastPathnameAndSearch) return;
1548
+ if (state.options?.locale === currentLocale && typeof state.as === "string" && state.as === getTrackedPagesRouterAsPath()) return;
1532
1549
  }
1533
- const isHashOnly = browserUrl === routerRuntimeState.lastPathnameAndSearch;
1550
+ const currentHash = window.location.hash;
1551
+ const isHashOnly = browserUrl === routerRuntimeState.lastPathnameAndSearch && (currentHash !== routerRuntimeState.lastHash || currentHash !== "");
1534
1552
  const targetKey = getRouterStateKey(state);
1535
1553
  let forcedScroll;
1536
1554
  if (manualScrollRestoration) {
@@ -1555,6 +1573,7 @@ function handlePagesRouterPopState(e) {
1555
1573
  }
1556
1574
  if (targetKey !== void 0) routerRuntimeState.currentHistoryKey = targetKey;
1557
1575
  routerRuntimeState.lastPathnameAndSearch = browserUrl;
1576
+ routerRuntimeState.lastHash = currentHash;
1558
1577
  if (isHashOnly) {
1559
1578
  const hashUrl = appUrl + window.location.hash;
1560
1579
  routerEvents.emit("hashChangeStart", hashUrl, { shallow: false });
@@ -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";
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 };
@@ -62,15 +62,23 @@ declare function findInNodeModules(start: string, subPath: string): string | nul
62
62
  * Check if a vite.config file exists in the project root.
63
63
  */
64
64
  declare function hasViteConfig(root: string): boolean;
65
+ /** Return the config file Vite will load, using Vite's default precedence. */
66
+ declare function findViteConfigPath(root: string): string | undefined;
65
67
  /**
66
68
  * Return the first candidate directory (resolved against `root`) that exists,
67
69
  * or null. Used to locate conventional `app`/`pages` directories that may live
68
70
  * at the root or under `src/`.
71
+ *
72
+ * `root` and `candidates` must be forward-slash, and the returned path is
73
+ * forward-slash too: the candidate is joined with `path.posix.join`, which only
74
+ * stays canonical when its inputs already are.
69
75
  */
70
76
  declare function findDir(root: string, ...candidates: string[]): string | null;
71
77
  /**
72
78
  * Check if the project uses App Router (has an app/ directory).
79
+ *
80
+ * `root` must be forward-slash — it is passed straight to `findDir`.
73
81
  */
74
82
  declare function hasAppDir(root: string): boolean;
75
83
  //#endregion
76
- export { detectPackageManager, detectPackageManagerName, ensureESModule, ensureViteConfigCompatibility, findDir, findInNodeModules, hasAppDir, hasViteConfig, renameCJSConfigs };
84
+ export { detectPackageManager, detectPackageManagerName, ensureESModule, ensureViteConfigCompatibility, findDir, findInNodeModules, findViteConfigPath, hasAppDir, hasViteConfig, renameCJSConfigs };
@@ -187,16 +187,31 @@ function findInNodeModules(start, subPath) {
187
187
  * Check if a vite.config file exists in the project root.
188
188
  */
189
189
  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"));
190
+ return findViteConfigPath(root) !== void 0;
191
+ }
192
+ /** Return the config file Vite will load, using Vite's default precedence. */
193
+ function findViteConfigPath(root) {
194
+ return [
195
+ "vite.config.js",
196
+ "vite.config.mjs",
197
+ "vite.config.ts",
198
+ "vite.config.cjs",
199
+ "vite.config.mts",
200
+ "vite.config.cts"
201
+ ].map((fileName) => path.join(root, fileName)).find((candidate) => fs.existsSync(candidate));
191
202
  }
192
203
  /**
193
204
  * Return the first candidate directory (resolved against `root`) that exists,
194
205
  * or null. Used to locate conventional `app`/`pages` directories that may live
195
206
  * at the root or under `src/`.
207
+ *
208
+ * `root` and `candidates` must be forward-slash, and the returned path is
209
+ * forward-slash too: the candidate is joined with `path.posix.join`, which only
210
+ * stays canonical when its inputs already are.
196
211
  */
197
212
  function findDir(root, ...candidates) {
198
213
  for (const candidate of candidates) {
199
- const full = path.join(root, candidate);
214
+ const full = path.posix.join(root, candidate);
200
215
  try {
201
216
  if (fs.statSync(full).isDirectory()) return full;
202
217
  } catch {}
@@ -205,9 +220,11 @@ function findDir(root, ...candidates) {
205
220
  }
206
221
  /**
207
222
  * Check if the project uses App Router (has an app/ directory).
223
+ *
224
+ * `root` must be forward-slash — it is passed straight to `findDir`.
208
225
  */
209
226
  function hasAppDir(root) {
210
- return findDir(root, "app", path.join("src", "app")) !== null;
227
+ return findDir(root, "app", "src/app") !== null;
211
228
  }
212
229
  //#endregion
213
- export { detectPackageManager, detectPackageManagerName, ensureESModule, ensureViteConfigCompatibility, findDir, findInNodeModules, hasAppDir, hasViteConfig, renameCJSConfigs };
230
+ export { detectPackageManager, detectPackageManagerName, ensureESModule, ensureViteConfigCompatibility, findDir, findInNodeModules, findViteConfigPath, hasAppDir, hasViteConfig, 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 };
@@ -0,0 +1,44 @@
1
+ import { createRequire } from "node:module";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ //#region src/utils/react-version.ts
5
+ function getDependencyUpgradeDeps(root, recommendations) {
6
+ const req = createRequire(path.join(root, "package.json"));
7
+ for (const [dependency, recommendation] of Object.entries(recommendations)) try {
8
+ const version = findPackageVersion(req.resolve(dependency), dependency);
9
+ if (version && isVersionBelow(version, recommendation.minimumVersion)) return recommendation.upgrades;
10
+ } catch {
11
+ continue;
12
+ }
13
+ return [];
14
+ }
15
+ function getReactUpgradeDeps(root) {
16
+ return getDependencyUpgradeDeps(root, { react: {
17
+ minimumVersion: [
18
+ 19,
19
+ 2,
20
+ 6
21
+ ],
22
+ upgrades: ["react@latest", "react-dom@latest"]
23
+ } });
24
+ }
25
+ function isVersionBelow(version, minimum) {
26
+ const current = version.split(".").map((part) => parseInt(part, 10));
27
+ for (let index = 0; index < minimum.length; index++) if ((current[index] ?? 0) !== minimum[index]) return (current[index] ?? 0) < minimum[index];
28
+ return false;
29
+ }
30
+ /** Walk up from a resolved module entry to find its package version. */
31
+ function findPackageVersion(resolvedEntry, packageName) {
32
+ let dir = path.dirname(resolvedEntry);
33
+ while (dir !== path.dirname(dir)) {
34
+ const candidate = path.join(dir, "package.json");
35
+ try {
36
+ const pkg = JSON.parse(fs.readFileSync(candidate, "utf-8"));
37
+ if (pkg.name === packageName) return pkg.version ?? null;
38
+ } catch {}
39
+ dir = path.dirname(dir);
40
+ }
41
+ return null;
42
+ }
43
+ //#endregion
44
+ export { getReactUpgradeDeps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qzsy/vinext",
3
- "version": "0.1.12",
3
+ "version": "0.1.81",
4
4
  "description": "Run Next.js apps on Vite. Drop-in replacement for the next CLI.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -53,6 +53,10 @@
53
53
  "types": "./dist/server/pages-request-pipeline.d.ts",
54
54
  "import": "./dist/server/pages-request-pipeline.js"
55
55
  },
56
+ "./server/pages-client-assets": {
57
+ "types": "./dist/server/pages-client-assets.d.ts",
58
+ "import": "./dist/server/pages-client-assets.js"
59
+ },
56
60
  "./server/app-router-entry": {
57
61
  "types": "./dist/server/app-router-entry.d.ts",
58
62
  "import": "./dist/server/app-router-entry.js"
@@ -89,26 +93,32 @@
89
93
  "publishConfig": {
90
94
  "access": "public"
91
95
  },
96
+ "scripts": {
97
+ "build": "vp pack",
98
+ "prepack": "node --input-type=module -e \"import { copyFileSync } from 'node:fs'; copyFileSync('../../README.md','README.md');\" && vp run build",
99
+ "dev": "vp pack --watch"
100
+ },
92
101
  "dependencies": {
93
- "@unpic/react": "^1.0.2",
94
- "@vercel/og": "^0.8.6",
95
- "image-size": "2.0.2",
96
- "ipaddr.js": "^2.1.0",
97
- "magic-string": "^0.30.21",
98
- "vite-plugin-commonjs": "^0.10.4",
99
- "web-vitals": "^4.2.4"
102
+ "@unpic/react": "catalog:",
103
+ "@vercel/og": "catalog:",
104
+ "image-size": "catalog:",
105
+ "ipaddr.js": "catalog:",
106
+ "magic-string": "catalog:",
107
+ "vite-plugin-commonjs": "catalog:",
108
+ "web-vitals": "catalog:"
100
109
  },
101
110
  "devDependencies": {
102
- "@types/node": "^25.9.2",
103
- "@types/react": "^19.2.16",
104
- "@types/react-dom": "^19.2.3",
105
- "@vitejs/plugin-react": "^6.0.1",
106
- "@vitejs/plugin-rsc": "^0.5.27",
107
- "react-server-dom-webpack": "^19.2.7",
108
- "vite": "npm:@voidzero-dev/vite-plus-core@0.2.1",
109
- "vite-plus": "0.2.1",
110
- "vite-tsconfig-paths": "^6.1.1",
111
- "@vinext/cloudflare": "0.1.2"
111
+ "@types/node": "catalog:",
112
+ "@types/react": "catalog:",
113
+ "@types/react-dom": "catalog:",
114
+ "@vinext/cloudflare": "workspace:*",
115
+ "@vitejs/plugin-react": "catalog:",
116
+ "@vitejs/plugin-rsc": "catalog:",
117
+ "am-i-vibing": "catalog:",
118
+ "react-server-dom-webpack": "catalog:",
119
+ "vite": "catalog:",
120
+ "vite-plus": "catalog:",
121
+ "vite-tsconfig-paths": "catalog:"
112
122
  },
113
123
  "peerDependencies": {
114
124
  "@mdx-js/rollup": "^3.0.0",
@@ -136,9 +146,5 @@
136
146
  },
137
147
  "engines": {
138
148
  "node": ">=22"
139
- },
140
- "scripts": {
141
- "build": "vp pack",
142
- "dev": "vp pack --watch"
143
149
  }
144
- }
150
+ }
@@ -1,4 +0,0 @@
1
- //#region src/server/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 };