vinext 0.1.8 → 0.2.1

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 (285) hide show
  1. package/README.md +51 -30
  2. package/dist/build/css-url-assets.d.ts +3 -1
  3. package/dist/build/css-url-assets.js +18 -1
  4. package/dist/build/inject-pregenerated-paths.d.ts +7 -0
  5. package/dist/build/inject-pregenerated-paths.js +21 -0
  6. package/dist/build/layout-classification.js +1 -1
  7. package/dist/build/nitro-route-rules.js +1 -1
  8. package/dist/build/pages-client-assets-module.d.ts +11 -0
  9. package/dist/build/pages-client-assets-module.js +27 -0
  10. package/dist/build/prerender-server-entry.d.ts +1 -0
  11. package/dist/build/prerender-server-entry.js +49 -0
  12. package/dist/build/prerender-server-pool.d.ts +44 -0
  13. package/dist/build/prerender-server-pool.js +194 -0
  14. package/dist/build/prerender.d.ts +2 -1
  15. package/dist/build/prerender.js +98 -27
  16. package/dist/build/report.d.ts +13 -2
  17. package/dist/build/report.js +99 -2
  18. package/dist/build/run-prerender.d.ts +7 -0
  19. package/dist/build/run-prerender.js +12 -2
  20. package/dist/build/standalone.js +2 -0
  21. package/dist/cache/cache-adapters-virtual.js +3 -3
  22. package/dist/check.d.ts +4 -6
  23. package/dist/check.js +48 -11
  24. package/dist/cli-args.d.ts +1 -2
  25. package/dist/cli-args.js +1 -1
  26. package/dist/cli-dev-config.d.ts +12 -0
  27. package/dist/cli-dev-config.js +23 -0
  28. package/dist/cli.js +112 -96
  29. package/dist/{server → client}/dev-error-overlay-store.d.ts +1 -1
  30. package/dist/{server → client}/dev-error-overlay-store.js +1 -1
  31. package/dist/{server → client}/dev-error-overlay.d.ts +1 -1
  32. package/dist/{server → client}/dev-error-overlay.js +2 -2
  33. package/dist/client/navigation-runtime.d.ts +2 -0
  34. package/dist/client/navigation-runtime.js +3 -1
  35. package/dist/client/vinext-next-data.d.ts +4 -1
  36. package/dist/client/window-next.d.ts +2 -1
  37. package/dist/cloudflare/index.d.ts +2 -2
  38. package/dist/cloudflare/index.js +2 -2
  39. package/dist/config/config-matchers.js +45 -19
  40. package/dist/config/next-config.d.ts +41 -9
  41. package/dist/config/next-config.js +60 -3
  42. package/dist/config/prerender.d.ts +34 -0
  43. package/dist/config/prerender.js +55 -0
  44. package/dist/entries/app-browser-entry.js +5 -1
  45. package/dist/entries/app-rsc-entry.d.ts +5 -3
  46. package/dist/entries/app-rsc-entry.js +44 -10
  47. package/dist/entries/app-rsc-manifest.js +2 -0
  48. package/dist/entries/pages-client-entry.d.ts +3 -0
  49. package/dist/entries/pages-client-entry.js +28 -3
  50. package/dist/entries/pages-server-entry.js +23 -6
  51. package/dist/image/image-adapters-virtual.d.ts +59 -0
  52. package/dist/image/image-adapters-virtual.js +59 -0
  53. package/dist/index.d.ts +33 -0
  54. package/dist/index.js +482 -120
  55. package/dist/init-cloudflare.d.ts +43 -0
  56. package/dist/init-cloudflare.js +839 -0
  57. package/dist/init-platform.d.ts +40 -0
  58. package/dist/init-platform.js +195 -0
  59. package/dist/init.d.ts +16 -38
  60. package/dist/init.js +209 -99
  61. package/dist/node_modules/.pnpm/am-i-vibing@0.5.0/node_modules/am-i-vibing/dist/detector-1yx2Hoe0.js +294 -0
  62. package/dist/node_modules/.pnpm/process-ancestry@0.1.0/node_modules/process-ancestry/dist/index.js +94 -0
  63. package/dist/{cloudflare → packages/cloudflare}/src/cache/cdn-adapter.runtime.js +1 -1
  64. package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.d.ts +2 -2
  65. package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.js +9 -2
  66. package/dist/packages/cloudflare/src/deploy-config.js +150 -0
  67. package/dist/packages/cloudflare/src/deploy-help.js +55 -0
  68. package/dist/packages/cloudflare/src/deploy.js +272 -0
  69. package/dist/{cloudflare → packages/cloudflare/src}/tpr.d.ts +4 -41
  70. package/dist/{cloudflare → packages/cloudflare/src}/tpr.js +44 -20
  71. package/dist/plugins/ast-scope.d.ts +16 -0
  72. package/dist/plugins/ast-scope.js +62 -0
  73. package/dist/plugins/ast-utils.d.ts +27 -1
  74. package/dist/plugins/ast-utils.js +32 -1
  75. package/dist/plugins/css-module-imports.d.ts +14 -0
  76. package/dist/plugins/css-module-imports.js +59 -0
  77. package/dist/plugins/extensionless-dynamic-import.js +2 -2
  78. package/dist/plugins/fonts.js +1 -1
  79. package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
  80. package/dist/plugins/ignore-dynamic-requests.js +530 -0
  81. package/dist/plugins/og-assets.js +2 -1
  82. package/dist/plugins/optimize-imports.js +1 -1
  83. package/dist/plugins/rsc-reference-validation-normalizer.d.ts +12 -0
  84. package/dist/plugins/rsc-reference-validation-normalizer.js +48 -0
  85. package/dist/plugins/sass.d.ts +17 -1
  86. package/dist/plugins/sass.js +74 -1
  87. package/dist/plugins/styled-jsx.d.ts +16 -0
  88. package/dist/plugins/styled-jsx.js +149 -0
  89. package/dist/plugins/typeof-window.d.ts +1 -1
  90. package/dist/plugins/typeof-window.js +28 -56
  91. package/dist/routing/app-route-graph.d.ts +23 -2
  92. package/dist/routing/app-route-graph.js +138 -38
  93. package/dist/routing/file-matcher.d.ts +11 -1
  94. package/dist/routing/file-matcher.js +18 -3
  95. package/dist/routing/pages-router.js +2 -2
  96. package/dist/server/api-handler.js +9 -14
  97. package/dist/server/app-browser-action-result.d.ts +4 -1
  98. package/dist/server/app-browser-action-result.js +8 -1
  99. package/dist/server/app-browser-entry.js +198 -57
  100. package/dist/server/app-browser-interception-context.d.ts +1 -0
  101. package/dist/server/app-browser-interception-context.js +4 -2
  102. package/dist/server/app-browser-navigation-controller.d.ts +2 -0
  103. package/dist/server/app-browser-navigation-controller.js +60 -31
  104. package/dist/server/app-browser-server-action-client.d.ts +1 -1
  105. package/dist/server/app-browser-server-action-client.js +8 -7
  106. package/dist/server/app-browser-state.d.ts +12 -1
  107. package/dist/server/app-browser-state.js +25 -8
  108. package/dist/server/app-browser-visible-commit.d.ts +6 -1
  109. package/dist/server/app-browser-visible-commit.js +42 -24
  110. package/dist/server/app-elements-wire.d.ts +9 -2
  111. package/dist/server/app-elements-wire.js +8 -1
  112. package/dist/server/app-elements.d.ts +2 -2
  113. package/dist/server/app-elements.js +4 -3
  114. package/dist/server/app-fallback-renderer.d.ts +2 -1
  115. package/dist/server/app-fallback-renderer.js +10 -6
  116. package/dist/server/app-hydration-cache-publication.d.ts +11 -0
  117. package/dist/server/app-hydration-cache-publication.js +43 -0
  118. package/dist/server/app-middleware.d.ts +4 -3
  119. package/dist/server/app-middleware.js +8 -3
  120. package/dist/server/app-optimistic-routing.js +11 -4
  121. package/dist/server/app-page-boundary.js +2 -1
  122. package/dist/server/app-page-cache-finalizer.d.ts +1 -0
  123. package/dist/server/app-page-cache-finalizer.js +5 -4
  124. package/dist/server/app-page-cache-render.d.ts +1 -0
  125. package/dist/server/app-page-cache-render.js +8 -4
  126. package/dist/server/app-page-cache.d.ts +1 -0
  127. package/dist/server/app-page-cache.js +27 -7
  128. package/dist/server/app-page-dispatch.d.ts +1 -0
  129. package/dist/server/app-page-dispatch.js +26 -8
  130. package/dist/server/app-page-element-builder.d.ts +2 -1
  131. package/dist/server/app-page-element-builder.js +59 -4
  132. package/dist/server/app-page-execution.js +2 -1
  133. package/dist/server/app-page-probe.js +5 -0
  134. package/dist/server/app-page-render-identity.d.ts +2 -0
  135. package/dist/server/app-page-render-identity.js +3 -2
  136. package/dist/server/app-page-render.d.ts +2 -0
  137. package/dist/server/app-page-render.js +85 -16
  138. package/dist/server/app-page-request.d.ts +14 -0
  139. package/dist/server/app-page-request.js +69 -4
  140. package/dist/server/app-page-response.d.ts +7 -0
  141. package/dist/server/app-page-response.js +16 -4
  142. package/dist/server/app-page-route-wiring.d.ts +8 -1
  143. package/dist/server/app-page-route-wiring.js +32 -18
  144. package/dist/server/app-page-segment-state.d.ts +2 -1
  145. package/dist/server/app-page-segment-state.js +3 -1
  146. package/dist/server/app-page-stream.d.ts +7 -1
  147. package/dist/server/app-page-stream.js +3 -1
  148. package/dist/server/app-route-handler-execution.js +5 -1
  149. package/dist/server/app-route-handler-response.js +1 -0
  150. package/dist/server/app-route-handler-runtime.js +1 -1
  151. package/dist/server/app-route-tree-prefetch.d.ts +43 -0
  152. package/dist/server/app-route-tree-prefetch.js +187 -0
  153. package/dist/server/app-router-entry.js +9 -2
  154. package/dist/server/app-rsc-cache-busting.d.ts +2 -1
  155. package/dist/server/app-rsc-cache-busting.js +9 -4
  156. package/dist/server/app-rsc-handler.d.ts +7 -0
  157. package/dist/server/app-rsc-handler.js +148 -39
  158. package/dist/server/app-rsc-render-mode.d.ts +3 -2
  159. package/dist/server/app-rsc-render-mode.js +4 -1
  160. package/dist/server/app-rsc-request-normalization.d.ts +6 -6
  161. package/dist/server/app-rsc-request-normalization.js +10 -8
  162. package/dist/server/app-segment-config.d.ts +11 -0
  163. package/dist/server/app-segment-config.js +62 -6
  164. package/dist/server/app-server-action-execution.d.ts +1 -0
  165. package/dist/server/app-server-action-execution.js +61 -30
  166. package/dist/server/app-ssr-entry.d.ts +3 -0
  167. package/dist/server/app-ssr-entry.js +13 -5
  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-visited-response-cache.d.ts +6 -0
  171. package/dist/server/app-visited-response-cache.js +3 -1
  172. package/dist/server/cache-control.d.ts +3 -1
  173. package/dist/server/cache-control.js +13 -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.d.ts +11 -1
  179. package/dist/server/dev-server.js +94 -35
  180. package/dist/server/dev-stack-sourcemap.d.ts +1 -1
  181. package/dist/server/dev-stack-sourcemap.js +1 -1
  182. package/dist/server/fetch-handler.d.ts +2 -0
  183. package/dist/server/fetch-handler.js +18 -0
  184. package/dist/server/headers.d.ts +7 -15
  185. package/dist/server/headers.js +11 -18
  186. package/dist/server/image-optimization.d.ts +51 -1
  187. package/dist/server/image-optimization.js +52 -2
  188. package/dist/server/implicit-tags.js +1 -1
  189. package/dist/server/isr-cache.d.ts +3 -2
  190. package/dist/server/isr-cache.js +9 -5
  191. package/dist/server/metadata-routes.d.ts +3 -1
  192. package/dist/server/metadata-routes.js +12 -2
  193. package/dist/server/middleware-runtime.js +6 -1
  194. package/dist/server/navigation-planner.d.ts +1 -0
  195. package/dist/server/navigation-planner.js +14 -3
  196. package/dist/server/pages-api-route.js +2 -2
  197. package/dist/server/pages-asset-tags.d.ts +4 -6
  198. package/dist/server/pages-asset-tags.js +12 -12
  199. package/dist/server/pages-client-assets.d.ts +12 -0
  200. package/dist/server/pages-client-assets.js +10 -0
  201. package/dist/server/pages-data-route.d.ts +4 -2
  202. package/dist/server/pages-data-route.js +18 -4
  203. package/dist/server/pages-dev-module-url.d.ts +2 -1
  204. package/dist/server/pages-dev-module-url.js +6 -3
  205. package/dist/server/pages-node-compat.d.ts +19 -1
  206. package/dist/server/pages-node-compat.js +81 -4
  207. package/dist/server/pages-page-data.d.ts +33 -1
  208. package/dist/server/pages-page-data.js +62 -33
  209. package/dist/server/pages-page-handler.d.ts +2 -1
  210. package/dist/server/pages-page-handler.js +38 -19
  211. package/dist/server/pages-page-response.d.ts +8 -0
  212. package/dist/server/pages-page-response.js +7 -3
  213. package/dist/server/pages-request-pipeline.d.ts +9 -5
  214. package/dist/server/pages-request-pipeline.js +55 -7
  215. package/dist/server/pages-router-entry.d.ts +30 -0
  216. package/dist/server/pages-router-entry.js +108 -0
  217. package/dist/server/prerender-manifest.d.ts +3 -1
  218. package/dist/server/prerender-route-params.js +1 -1
  219. package/dist/server/prod-server.d.ts +5 -3
  220. package/dist/server/prod-server.js +68 -39
  221. package/dist/server/request-pipeline.js +2 -1
  222. package/dist/server/seed-cache.js +4 -4
  223. package/dist/shims/app-router-scroll-state.d.ts +1 -0
  224. package/dist/shims/app-router-scroll-state.js +1 -0
  225. package/dist/shims/app-router-scroll.js +2 -1
  226. package/dist/shims/cache-handler.js +8 -1
  227. package/dist/shims/cache.js +22 -15
  228. package/dist/shims/cdn-cache.js +1 -1
  229. package/dist/shims/dynamic-preload-chunks.js +2 -1
  230. package/dist/shims/fetch-cache.d.ts +3 -1
  231. package/dist/shims/fetch-cache.js +77 -52
  232. package/dist/shims/form.d.ts +4 -2
  233. package/dist/shims/form.js +37 -43
  234. package/dist/shims/headers.d.ts +7 -1
  235. package/dist/shims/headers.js +17 -3
  236. package/dist/shims/image.js +75 -14
  237. package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +10 -0
  238. package/dist/shims/internal/app-prefetch-fetch-queue.js +61 -0
  239. package/dist/shims/internal/app-route-detection.d.ts +2 -17
  240. package/dist/shims/internal/app-route-detection.js +4 -17
  241. package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +23 -0
  242. package/dist/shims/internal/hybrid-client-route-owner-direct.js +51 -0
  243. package/dist/shims/internal/hybrid-client-route-owner.d.ts +3 -15
  244. package/dist/shims/internal/hybrid-client-route-owner.js +40 -58
  245. package/dist/shims/internal/pages-data-fetch-dedup.d.ts +10 -5
  246. package/dist/shims/internal/pages-data-fetch-dedup.js +84 -14
  247. package/dist/shims/internal/pages-data-target.d.ts +18 -12
  248. package/dist/shims/internal/pages-data-target.js +97 -13
  249. package/dist/shims/internal/pages-router-components.d.ts +7 -0
  250. package/dist/shims/internal/pages-router-components.js +13 -0
  251. package/dist/shims/layout-segment-context.d.ts +4 -1
  252. package/dist/shims/layout-segment-context.js +18 -4
  253. package/dist/shims/link.d.ts +1 -1
  254. package/dist/shims/link.js +224 -58
  255. package/dist/shims/navigation.d.ts +19 -3
  256. package/dist/shims/navigation.js +245 -47
  257. package/dist/shims/request-context.js +18 -0
  258. package/dist/shims/root-params.d.ts +15 -1
  259. package/dist/shims/root-params.js +21 -1
  260. package/dist/shims/router.d.ts +5 -7
  261. package/dist/shims/router.js +387 -102
  262. package/dist/shims/server.js +3 -2
  263. package/dist/shims/slot.js +3 -6
  264. package/dist/shims/unified-request-context.js +1 -0
  265. package/dist/typegen.js +1 -1
  266. package/dist/utils/client-runtime-metadata.d.ts +2 -18
  267. package/dist/utils/client-runtime-metadata.js +31 -22
  268. package/dist/utils/dev-stack-sourcemap-endpoint.d.ts +4 -0
  269. package/dist/{server → utils}/dev-stack-sourcemap-endpoint.js +1 -1
  270. package/dist/utils/domain-locale.d.ts +6 -3
  271. package/dist/{server → utils}/middleware-request-headers.d.ts +1 -1
  272. package/dist/{server → utils}/middleware-request-headers.js +3 -3
  273. package/dist/utils/project.d.ts +48 -2
  274. package/dist/utils/project.js +225 -4
  275. package/dist/utils/protocol-headers.d.ts +23 -0
  276. package/dist/utils/protocol-headers.js +23 -0
  277. package/dist/utils/react-version.d.ts +4 -0
  278. package/dist/utils/react-version.js +44 -0
  279. package/dist/utils/vite-version.d.ts +2 -0
  280. package/dist/utils/vite-version.js +11 -1
  281. package/package.json +47 -2
  282. package/dist/deploy.d.ts +0 -197
  283. package/dist/deploy.js +0 -1040
  284. package/dist/server/dev-stack-sourcemap-endpoint.d.ts +0 -4
  285. /package/dist/{cloudflare → packages/cloudflare}/src/utils/cache-control-metadata.js +0 -0
@@ -1,6 +1,7 @@
1
1
  import { normalizePathSeparators } from "../utils/path.js";
2
2
  import { resolveEntryPath } from "./runtime-entry-module.js";
3
3
  import { isProxyFile } from "../server/middleware.js";
4
+ import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES } from "../server/image-optimization.js";
4
5
  import { buildAppRscManifestCode } from "./app-rsc-manifest.js";
5
6
  import { generateDevOriginCheckCode } from "../server/dev-origin-check.js";
6
7
  import { randomUUID } from "node:crypto";
@@ -16,7 +17,7 @@ import { randomUUID } from "node:crypto";
16
17
  */
17
18
  const DEFAULT_EXPIRE_TIME = 31536e3;
18
19
  const DEFAULT_REACT_MAX_HEADERS_LENGTH = 6e3;
19
- const middlewareRequestHeadersPath = resolveEntryPath("../server/middleware-request-headers.js", import.meta.url);
20
+ const middlewareRequestHeadersPath = resolveEntryPath("../utils/middleware-request-headers.js", import.meta.url);
20
21
  const normalizePathModulePath = resolveEntryPath("../server/normalize-path.js", import.meta.url);
21
22
  const appRouteHandlerDispatchPath = resolveEntryPath("../server/app-route-handler-dispatch.js", import.meta.url);
22
23
  const appRouteHandlerResponsePath = resolveEntryPath("../server/app-route-handler-response.js", import.meta.url);
@@ -77,16 +78,25 @@ function generateRscEntry(appDir, routes, middlewarePath, metadataRoutes, global
77
78
  const cacheMaxMemorySize = config?.cacheMaxMemorySize;
78
79
  const inlineCss = config?.inlineCss === true;
79
80
  const cacheComponents = config?.cacheComponents === true;
81
+ const prefetchInlining = config?.prefetchInlining ?? false;
80
82
  const hasServerActions = config?.hasServerActions !== false;
81
83
  const i18nConfig = config?.i18n ?? null;
82
84
  const hasPagesDir = config?.hasPagesDir ?? false;
83
85
  const publicFiles = config?.publicFiles ?? [];
84
86
  const draftModeSecret = config?.draftModeSecret ?? randomUUID();
87
+ const imageAllowedWidths = [...config?.imageConfig?.deviceSizes ?? DEFAULT_DEVICE_SIZES, ...config?.imageConfig?.imageSizes ?? DEFAULT_IMAGE_SIZES];
88
+ const imageConfig = {
89
+ qualities: config?.imageConfig?.qualities,
90
+ dangerouslyAllowSVG: config?.imageConfig?.dangerouslyAllowSVG,
91
+ dangerouslyAllowLocalIP: config?.imageConfig?.dangerouslyAllowLocalIP,
92
+ contentDispositionType: config?.imageConfig?.contentDispositionType,
93
+ contentSecurityPolicy: config?.imageConfig?.contentSecurityPolicy
94
+ };
85
95
  const { imports, routeEntries, metaRouteEntries, generateStaticParamsEntries, rootParamNameEntries, rootNotFoundVar, rootForbiddenVar, rootUnauthorizedVar, rootLayoutVars, globalErrorVar, globalNotFoundImportSpecifier } = buildAppRscManifestCode({
86
96
  routes,
87
97
  metadataRoutes,
88
98
  globalErrorPath,
89
- globalNotFoundPath: config?.globalNotFoundPath ?? null
99
+ globalNotFoundPath: config?.globalNotFound === true ? config.globalNotFoundPath ?? null : null
90
100
  });
91
101
  const loadPrerenderPagesRoutesCode = hasPagesDir ? `
92
102
  async function __loadPrerenderPagesRoutes() {
@@ -123,6 +133,8 @@ ${instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(norm
123
133
  import { ensureInstrumentationRegistered as __ensureInstrumentationRegistered } from ${JSON.stringify(instrumentationRuntimePath)};` : ""}
124
134
  import { createAppRscHandler } from "vinext/server/app-rsc-handler";
125
135
  import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
136
+ import __pagesClientAssets from "virtual:vinext-pages-client-assets";
137
+ import { setPagesClientAssets as __setPagesClientAssets } from "vinext/server/pages-client-assets";
126
138
  import { decodePathParams as __decodePathParams } from ${JSON.stringify(normalizePathModulePath)};
127
139
  import { buildRequestHeadersFromMiddlewareResponse as __buildRequestHeadersFromMiddlewareResponse } from ${JSON.stringify(middlewareRequestHeadersPath)};
128
140
  ${hasPagesDir ? `import {
@@ -354,6 +366,7 @@ const __fallbackRenderer = __createAppFallbackRenderer({
354
366
  },
355
367
  globalErrorModule: ${globalErrorVar ? globalErrorVar : "null"},
356
368
  loadGlobalNotFoundModule: __loadGlobalNotFoundModule,
369
+ globalNotFoundEnabled: ${config?.globalNotFound === true},
357
370
  metadataRoutes,
358
371
  ssrLoader() {
359
372
  return import.meta.viteRsc.loadModule("ssr", "index");
@@ -415,7 +428,7 @@ const __i18nConfig = ${JSON.stringify(i18nConfig)};
415
428
  const __configRedirects = ${JSON.stringify(redirects)};
416
429
  const __configRewrites = ${JSON.stringify(rewrites)};
417
430
  const __configHeaders = ${JSON.stringify(headers)};
418
- const __imageConfig = ${JSON.stringify(config?.imageConfig)};
431
+ const __runtimeImageConfig = ${JSON.stringify(config?.imageConfig)};
419
432
  const __publicFiles = new Set(${JSON.stringify(publicFiles)});
420
433
  const __allowedOrigins = ${JSON.stringify(allowedOrigins)};
421
434
  const __expireTime = ${JSON.stringify(expireTime)};
@@ -426,6 +439,8 @@ const __reactMaxHeadersLength = ${JSON.stringify(reactMaxHeadersLength)};
426
439
  // mirrors the embedded \`__basePath\` pattern (and Pages Router's
427
440
  // \`vinextConfig\` export). Empty string when unset.
428
441
  export const __assetPrefix = ${JSON.stringify(assetPrefix)};
442
+ export const __imageAllowedWidths = ${JSON.stringify(imageAllowedWidths)};
443
+ export const __imageConfig = ${JSON.stringify(imageConfig)};
429
444
  export const __inlineCss = ${JSON.stringify(inlineCss)};
430
445
  export const __hasPagesDir = ${JSON.stringify(hasPagesDir)};
431
446
  export const getRenderedConcreteUrlPathsForRoute = __getRenderedConcreteUrlPathsForRoute;
@@ -474,10 +489,12 @@ const rootParamNamesMap = {
474
489
  ${rootParamNameEntries.join("\n")}
475
490
  };
476
491
 
492
+ __setPagesClientAssets(__pagesClientAssets);
477
493
  export default createAppRscHandler({
478
494
  basePath: __basePath,
479
495
  buildId: process.env.__VINEXT_BUILD_ID ?? null,
480
496
  ensureRouteLoaded: __ensureRouteLoaded,
497
+ prefetchInlining: ${JSON.stringify(prefetchInlining)},
481
498
  clearRequestContext() {
482
499
  __clearRequestContext();
483
500
  },
@@ -488,7 +505,7 @@ export default createAppRscHandler({
488
505
  },` : ""}
489
506
  configRedirects: __configRedirects,
490
507
  configRewrites: __configRewrites,
491
- imageConfig: __imageConfig,
508
+ imageConfig: __runtimeImageConfig,
492
509
  isDev: process.env.NODE_ENV !== "production",
493
510
  draftModeSecret: __draftModeSecret,
494
511
  dispatchMatchedPage({
@@ -512,6 +529,7 @@ export default createAppRscHandler({
512
529
  staticParamsValidationParams,
513
530
  rootParams,
514
531
  request,
532
+ renderedPathAndSearch,
515
533
  route,
516
534
  scriptNonce,
517
535
  searchParams,
@@ -520,18 +538,32 @@ export default createAppRscHandler({
520
538
  const PageComponent = route.page?.default;
521
539
  const __segmentConfig = __resolveAppPageSegmentConfig({
522
540
  layouts: route.layouts,
541
+ layoutTreePositions: route.layoutTreePositions,
523
542
  page: route.page,
543
+ parallelBranches: Object.values(route.slots ?? {}).map((slot) => ({
544
+ layout: slot.layout,
545
+ configLayouts: slot.configLayouts,
546
+ configLayoutTreePositions: slot.configLayoutTreePositions,
547
+ page: slot.page ?? slot.default,
548
+ routeSegments: slot.routeSegments,
549
+ })),
524
550
  parallelPages: Object.values(route.slots ?? {}).map((slot) => slot.page ?? slot.default),
525
- parallelSegments: Object.values(route.slots ?? {}).flatMap((slot) => [
526
- slot.layout,
527
- ...(slot.configLayouts ?? []),
528
- slot.page ?? slot.default,
529
- ]),
551
+ routeSegments: route.routeSegments,
530
552
  });
531
553
  const __generateStaticParams = __resolveAppPageGenerateStaticParamsSources({
532
554
  layouts: route.layouts,
533
555
  layoutTreePositions: route.layoutTreePositions,
534
556
  page: route.page,
557
+ parallelBranches: Object.values(route.slots ?? {}).map((slot) => ({
558
+ layout: slot.layout,
559
+ configLayouts: slot.configLayouts,
560
+ configLayoutTreePositions: slot.configLayoutTreePositions,
561
+ page: slot.page ?? slot.default,
562
+ paramNames: slot.slotParamNames,
563
+ patternParts: slot.slotPatternParts,
564
+ routeSegments: slot.routeSegments,
565
+ })),
566
+ routePatternParts: route.patternParts,
535
567
  routeSegments: route.routeSegments,
536
568
  });
537
569
  const _asyncRouteParams = makeThenableParams(params);
@@ -664,6 +696,7 @@ export default createAppRscHandler({
664
696
  prerenderToReadableStream,
665
697
  request,
666
698
  revalidateSeconds: __segmentConfig.revalidateSeconds,
699
+ renderedPathAndSearch,
667
700
  resolveRouteFetchCacheMode(targetRoute) {
668
701
  return __resolveRouteFetchCacheMode(targetRoute);
669
702
  },
@@ -923,11 +956,12 @@ export default createAppRscHandler({
923
956
  });
924
957
  },` : ""}
925
958
  matchRoute,
926
- ${middlewarePath ? `runMiddleware({ cleanPathname, context, isDataRequest, request }) {
959
+ ${middlewarePath ? `runMiddleware({ cleanPathname, context, hadBasePath, isDataRequest, request }) {
927
960
  return __applyAppMiddleware({
928
961
  basePath: __basePath,
929
962
  cleanPathname,
930
963
  context,
964
+ hadBasePath,
931
965
  filePath: ${JSON.stringify(middlewarePath ? normalizePathSeparators(middlewarePath) : "")},
932
966
  i18nConfig: __i18nConfig,
933
967
  isDataRequest,
@@ -181,6 +181,7 @@ ${interceptEntries.join(",\n")}
181
181
  layouts: ${moduleArray(route.layouts.length)},
182
182
  __loadLayouts: ${layoutLoaders},
183
183
  routeSegments: ${JSON.stringify(route.routeSegments)},
184
+ childrenRouteSegments: ${JSON.stringify(route.childrenRouteSegments ?? null)},
184
185
  templateTreePositions: ${JSON.stringify(route.templateTreePositions)},
185
186
  layoutTreePositions: ${JSON.stringify(route.layoutTreePositions)},
186
187
  templates: ${moduleArray(route.templates.length)},
@@ -193,6 +194,7 @@ ${interceptEntries.join(",\n")}
193
194
  slots: {
194
195
  ${slotEntries.join(",\n")}
195
196
  },
197
+ childrenSlot: ${JSON.stringify(route.childrenSlot ?? null)},
196
198
  siblingIntercepts: [
197
199
  ${siblingInterceptEntries.join(",\n")}
198
200
  ],
@@ -1,11 +1,14 @@
1
1
  import { ResolvedNextConfig } from "../config/next-config.js";
2
2
  import { createValidFileMatcher } from "../routing/file-matcher.js";
3
+ import { StaticMiddlewareMatcher } from "../build/report.js";
3
4
  import { VinextLinkPrefetchRoute } from "../client/vinext-next-data.js";
4
5
 
5
6
  //#region src/entries/pages-client-entry.d.ts
6
7
  declare function generateClientEntry(pagesDir: string, nextConfig: ResolvedNextConfig, fileMatcher: ReturnType<typeof createValidFileMatcher>, options?: {
7
8
  appPrefetchRoutes?: readonly VinextLinkPrefetchRoute[];
8
9
  instrumentationClientPath?: string | null;
10
+ middlewareMatcher?: StaticMiddlewareMatcher | undefined;
11
+ reactPreamble?: boolean;
9
12
  }): Promise<string>;
10
13
  //#endregion
11
14
  export { generateClientEntry };
@@ -3,6 +3,8 @@ import { findFileWithExts } from "../routing/file-matcher.js";
3
3
  import { patternToNextFormat } from "../routing/route-validation.js";
4
4
  import { apiRouter, pagesRouter } from "../routing/pages-router.js";
5
5
  import "./pages-entry-helpers.js";
6
+ import { hasExportedName } from "../build/report.js";
7
+ import { readFile } from "node:fs/promises";
6
8
  //#region src/entries/pages-client-entry.ts
7
9
  /**
8
10
  * Pages Router client hydration entry generator.
@@ -30,6 +32,12 @@ function toPagesLinkPrefetchRoute(route) {
30
32
  patternParts: [...route.patternParts]
31
33
  };
32
34
  }
35
+ async function hasGetStaticPropsExport(filePath) {
36
+ return hasExportedName(await readFile(filePath, "utf8"), "getStaticProps");
37
+ }
38
+ async function hasGetServerSidePropsExport(filePath) {
39
+ return hasExportedName(await readFile(filePath, "utf8"), "getServerSideProps");
40
+ }
33
41
  async function generateClientEntry(pagesDir, nextConfig, fileMatcher, options = {}) {
34
42
  const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
35
43
  const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
@@ -40,6 +48,8 @@ async function generateClientEntry(pagesDir, nextConfig, fileMatcher, options =
40
48
  ...toPagesLinkPrefetchRoute(route),
41
49
  documentOnly: true
42
50
  }))];
51
+ const pagesSsgPatterns = (await Promise.all(pageRoutes.map(async (route) => await hasGetStaticPropsExport(route.filePath) ? patternToNextFormat(route.pattern) : null))).filter((pattern) => pattern !== null);
52
+ const pagesSspPatterns = (await Promise.all(pageRoutes.map(async (route) => await hasGetServerSidePropsExport(route.filePath) ? patternToNextFormat(route.pattern) : null))).filter((pattern) => pattern !== null);
43
53
  const instrumentationClientPath = options.instrumentationClientPath ?? null;
44
54
  const loaderEntries = pageRoutes.map((r) => {
45
55
  const absPath = normalizePathSeparators(r.filePath);
@@ -47,7 +57,10 @@ async function generateClientEntry(pagesDir, nextConfig, fileMatcher, options =
47
57
  return ` ${JSON.stringify(nextFormatPattern)}: () => import(${JSON.stringify(absPath)})`;
48
58
  });
49
59
  const appFileBase = appFilePath ? normalizePathSeparators(appFilePath) : void 0;
50
- return `${instrumentationClientPath ? `import ${JSON.stringify(normalizePathSeparators(instrumentationClientPath))};\n` : ""}
60
+ const userInstrumentationImport = instrumentationClientPath ? `import ${JSON.stringify(normalizePathSeparators(instrumentationClientPath))};\n` : "";
61
+ const reactPreambleImport = options.reactPreamble === false ? "" : "import \"@vitejs/plugin-react/preamble\";\n";
62
+ const reactStrictModeEnabled = nextConfig.reactStrictMode === true;
63
+ return `${userInstrumentationImport}${reactPreambleImport}
51
64
  import "vinext/instrumentation-client";
52
65
  import React from "react";
53
66
  import { hydrateRoot } from "react-dom/client";
@@ -79,6 +92,12 @@ const appLoader = undefined;
79
92
  // can iterate in order and trust the first match.
80
93
  window.__VINEXT_PAGE_LOADERS__ = pageLoaders;
81
94
  window.__VINEXT_PAGE_PATTERNS__ = Object.keys(pageLoaders);
95
+ // reactStrictMode flag — read by wrapWithRouterContext (next/router) so the
96
+ // <React.StrictMode> wrap is applied on initial hydration and every navigation.
97
+ window.__VINEXT_REACT_STRICT_MODE__ = ${JSON.stringify(reactStrictModeEnabled)};
98
+ window.__VINEXT_PAGES_SSG_PATTERNS__ = ${JSON.stringify(pagesSsgPatterns)};
99
+ window.__VINEXT_PAGES_SSP_PATTERNS__ = ${JSON.stringify(pagesSspPatterns)};
100
+ window.__VINEXT_MIDDLEWARE_MATCHER__ = ${JSON.stringify(options.middlewareMatcher)};
82
101
  window.__VINEXT_APP_LOADER__ = appLoader;
83
102
  // Expose the App Router prefetch manifest so Pages Router \`<Link>\`s and
84
103
  // \`Router.prefetch\` can detect when a prefetch target is actually an App
@@ -100,6 +119,7 @@ window.__VINEXT_LINK_PREFETCH_ROUTES__ = ${JSON.stringify(appPrefetchRoutes)};
100
119
  // instead of issuing an RSC request). Set here AND in app-browser-entry.ts
101
120
  // so whichever entry runs first emits the Pages manifest.
102
121
  window.__VINEXT_PAGES_LINK_PREFETCH_ROUTES__ = ${JSON.stringify(pagesPrefetchRoutes)};
122
+ window.__VINEXT_CLIENT_REDIRECTS__ = ${JSON.stringify(nextConfig.redirects)};
103
123
  window.__VINEXT_CLIENT_REWRITES__ = ${JSON.stringify(nextConfig.rewrites)};
104
124
 
105
125
  const nextDataElement = document.getElementById("__NEXT_DATA__");
@@ -172,6 +192,9 @@ async function hydrate() {
172
192
  });
173
193
 
174
194
  // Wrap with RouterContext.Provider so next/router and next/compat/router work during hydration.
195
+ // When reactStrictMode is enabled, wrapWithRouterContext also wraps the tree
196
+ // in <React.StrictMode> (see next/router) — applied here and on every
197
+ // navigation render, matching Next.js.
175
198
  element = wrapWithRouterContext(element, resolveHydrationCommit);
176
199
 
177
200
  const container = document.getElementById("__next");
@@ -190,9 +213,11 @@ async function hydrate() {
190
213
  window.__NEXT_HYDRATED_CB?.();
191
214
 
192
215
  if (nextData.isFallback) {
216
+ const currentUrl = window.location.pathname + window.location.search + window.location.hash;
217
+ const routeUrl = nextData.__vinext?.routeUrl;
193
218
  await Router.replace(
194
- window.location.pathname + window.location.search + window.location.hash,
195
- undefined,
219
+ routeUrl || currentUrl,
220
+ routeUrl ? currentUrl : undefined,
196
221
  { _h: 1, scroll: false },
197
222
  );
198
223
  }
@@ -4,6 +4,8 @@ import { apiRouter, pagesRouter } from "../routing/pages-router.js";
4
4
  import { resolveEntryPath } from "./runtime-entry-module.js";
5
5
  import { isProxyFile } from "../server/middleware.js";
6
6
  import "./pages-entry-helpers.js";
7
+ import { hasExportedName } from "../build/report.js";
8
+ import { readFile } from "node:fs/promises";
7
9
  //#region src/entries/pages-server-entry.ts
8
10
  /**
9
11
  * Pages Router server entry generator.
@@ -24,6 +26,12 @@ const _pagesApiRoutePath = resolveEntryPath("../server/pages-api-route.js", impo
24
26
  const _serverGlobalsPath = resolveEntryPath("../server/server-globals.js", import.meta.url);
25
27
  const _queryUtilsPath = resolveEntryPath("../utils/query.js", import.meta.url);
26
28
  const _pagesPageHandlerPath = resolveEntryPath("../server/pages-page-handler.js", import.meta.url);
29
+ async function getPagesDataKind(filePath) {
30
+ const source = await readFile(filePath, "utf8");
31
+ if (hasExportedName(source, "getStaticProps")) return "static";
32
+ if (hasExportedName(source, "getServerSideProps")) return "server";
33
+ return "none";
34
+ }
27
35
  /**
28
36
  * Generate the virtual SSR server entry module.
29
37
  * This is the entry point for `vite build --ssr`.
@@ -39,10 +47,11 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
39
47
  const absPath = normalizePathSeparators(r.filePath);
40
48
  return `import * as api_${i} from ${JSON.stringify(absPath)};`;
41
49
  });
42
- const pageRouteEntries = pageRoutes.map((r, i) => {
50
+ const pageRouteEntries = await Promise.all(pageRoutes.map(async (r, i) => {
43
51
  const absPath = normalizePathSeparators(r.filePath);
44
- return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: page_${i}, filePath: ${JSON.stringify(absPath)} }`;
45
- });
52
+ const dataKind = await getPagesDataKind(r.filePath);
53
+ return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: page_${i}, filePath: ${JSON.stringify(absPath)}, dataKind: ${JSON.stringify(dataKind)} }`;
54
+ }));
46
55
  const apiRouteEntries = apiRoutes.map((r, i) => ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`);
47
56
  const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
48
57
  const docFilePath = findFileWithExts(pagesDir, "_document", fileMatcher);
@@ -128,6 +137,8 @@ import Router, { setSSRContext, wrapWithRouterContext, getPagesNavigationIsReady
128
137
  import { _runWithCacheState } from "vinext/shims/cache-request-state";
129
138
  import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "vinext/shims/cache-handler";
130
139
  import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
140
+ import __pagesClientAssets from "virtual:vinext-pages-client-assets";
141
+ import { setPagesClientAssets as __setPagesClientAssets } from "vinext/server/pages-client-assets";
131
142
  import { runWithPrivateCache } from "vinext/cache-runtime";
132
143
  import { ensureFetchPatch, runWithFetchCache } from "vinext/fetch-cache";
133
144
  import "vinext/router-state";
@@ -162,9 +173,14 @@ const i18nConfig = ${i18nConfigJson};
162
173
  // to load next.config.js at runtime.
163
174
  export const buildId = ${buildIdJson};
164
175
  export function normalizeDataRequest(request) {
165
- return __normalizePagesDataRequest(request, buildId);
176
+ return __normalizePagesDataRequest(
177
+ request,
178
+ buildId,
179
+ vinextConfig.basePath,
180
+ hasMiddleware && vinextConfig.trailingSlash,
181
+ );
166
182
  }
167
- const __hasMiddleware = ${JSON.stringify(Boolean(middlewarePath))};
183
+ export const hasMiddleware = ${JSON.stringify(Boolean(middlewarePath))};
168
184
 
169
185
  // Full resolved config for production server (embedded at build time)
170
186
  export const vinextConfig = ${vinextConfigJson};
@@ -271,6 +287,7 @@ export function matchApiRoute(url, request) {
271
287
  // All next/*-derived values are passed as closures so the handler module
272
288
  // stays importable in test environments (the root vite.config.ts only
273
289
  // aliases vinext/shims/*, not next/*).
290
+ __setPagesClientAssets(__pagesClientAssets);
274
291
  const _renderPage = __createPagesPageHandler({
275
292
  pageRoutes,
276
293
  errorPageRoute: _errorPageRoute,
@@ -286,7 +303,7 @@ const _renderPage = __createPagesPageHandler({
286
303
  disableOptimizedLoading: vinextConfig.disableOptimizedLoading,
287
304
  },
288
305
  buildId,
289
- hasMiddleware: __hasMiddleware,
306
+ hasMiddleware,
290
307
  appAssetPath: _appAssetPath,
291
308
  hasRewrites:
292
309
  vinextConfig.rewrites.beforeFiles.length > 0 ||
@@ -0,0 +1,59 @@
1
+ //#region src/image/image-adapters-virtual.d.ts
2
+ /**
3
+ * Code generation for the `virtual:vinext-image-adapters` module, resolved by
4
+ * the vinext vite plugin from the user's `images` config ({@link VinextImageConfig}).
5
+ *
6
+ * The generated module exports `registerConfiguredImageOptimizer(env)`, which the
7
+ * server entries call on each request. It self-guards (the optimizer instantiates
8
+ * once per isolate) and is a no-op when nothing is configured. Registration is
9
+ * resilient: a factory that throws (e.g. a Cloudflare Images adapter on the
10
+ * Node.js server, where the `IMAGES` binding can't exist) is logged and skipped
11
+ * rather than failing every request, so the same config can be registered from
12
+ * every runtime/router entry. When no optimizer is registered, image requests
13
+ * fall back to serving the original asset unoptimized.
14
+ *
15
+ * Descriptor `options` are inlined into the generated module and forwarded to the
16
+ * factory at runtime, so a config-time builder like `imagesOptimizer({ binding })`
17
+ * never touches the Workers runtime — instantiation is deferred to the first
18
+ * request.
19
+ *
20
+ * This mirrors the cache-adapter pattern in `cache/cache-adapters-virtual.ts`.
21
+ */
22
+ /**
23
+ * A serializable pointer to an image optimizer adapter module — the shape of the
24
+ * `images.optimizer` slot in the vinext() plugin config. Produced by an adapter
25
+ * builder (e.g. `imagesOptimizer(...)` from `@vinext/cloudflare/images/images-optimizer`)
26
+ * or written by hand. `options` must be JSON-serializable: it is inlined into the
27
+ * generated registration module and forwarded to the adapter factory at runtime.
28
+ */
29
+ type ImageAdapterDescriptor<O extends Record<string, unknown> = Record<string, unknown>> = {
30
+ /**
31
+ * Module specifier (or absolute path, e.g. from `require.resolve(...)`) whose
32
+ * default export is an image optimizer factory.
33
+ */
34
+ adapter: string; /** JSON-serializable options forwarded to the factory at runtime. */
35
+ options?: O;
36
+ };
37
+ /**
38
+ * The `images` option of the vinext() plugin: declaratively register the
39
+ * server-side image optimizer (transform backend) instead of wiring `env.IMAGES`
40
+ * into a custom worker entry.
41
+ *
42
+ * This is complementary to the `images` field in `next.config.js`, which
43
+ * configures the standard Next.js image options (`remotePatterns`, `deviceSizes`,
44
+ * `dangerouslyAllowSVG`, etc.). Those continue to be read from next.config; this
45
+ * option only selects the runtime transform backend, which can't be expressed as
46
+ * serializable next.config data.
47
+ */
48
+ type VinextImageConfig = {
49
+ /** Server-side image optimizer adapter (the `/_next/image` transform backend). */optimizer?: ImageAdapterDescriptor;
50
+ };
51
+ /** Public virtual module id imported by the server entries. */
52
+ declare const VIRTUAL_IMAGE_ADAPTERS = "virtual:vinext-image-adapters";
53
+ /**
54
+ * Generate the source of the `virtual:vinext-image-adapters` module for the
55
+ * given config. Always exports `registerConfiguredImageOptimizer(env)`.
56
+ */
57
+ declare function generateImageAdaptersModule(images?: VinextImageConfig): string;
58
+ //#endregion
59
+ export { VIRTUAL_IMAGE_ADAPTERS, VinextImageConfig, generateImageAdaptersModule };
@@ -0,0 +1,59 @@
1
+ //#region src/image/image-adapters-virtual.ts
2
+ /** Public virtual module id imported by the server entries. */
3
+ const VIRTUAL_IMAGE_ADAPTERS = "virtual:vinext-image-adapters";
4
+ /**
5
+ * Serialize descriptor options into a JS expression for inlining. Plain JSON is
6
+ * a valid JS literal; `undefined` when there are no options. Throws a clear
7
+ * config-time error (not a runtime one) if options are not serializable.
8
+ */
9
+ function inlineOptions(adapter, options) {
10
+ if (options === void 0) return "undefined";
11
+ try {
12
+ return JSON.stringify(options);
13
+ } catch (cause) {
14
+ throw new Error(`[vinext] image adapter "${adapter}" options must be JSON-serializable.`, { cause });
15
+ }
16
+ }
17
+ /**
18
+ * Generate the source of the `virtual:vinext-image-adapters` module for the
19
+ * given config. Always exports `registerConfiguredImageOptimizer(env)`.
20
+ */
21
+ function generateImageAdaptersModule(images) {
22
+ const optimizer = images?.optimizer;
23
+ if (!optimizer?.adapter) return [
24
+ "// vinext: no images.optimizer adapter configured — registration is a no-op.",
25
+ "export function registerConfiguredImageOptimizer() {}",
26
+ ""
27
+ ].join("\n");
28
+ return [
29
+ "// vinext: generated from the `images` option in your vinext() plugin config.",
30
+ `import __vinextImageOptimizerFactory from ${JSON.stringify(optimizer.adapter)};`,
31
+ `import { setImageOptimizer } from "vinext/server/image-optimization";`,
32
+ "",
33
+ "// A factory that throws (e.g. a missing binding on an incompatible runtime)",
34
+ "// is logged and skipped so images fall back to unoptimized passthrough.",
35
+ "function __vinextFormatAdapterError(error) {",
36
+ " if (error instanceof Error && error.message) return error.message;",
37
+ " try {",
38
+ " return String(error);",
39
+ " } catch {",
40
+ " return '<unknown error>';",
41
+ " }",
42
+ "}",
43
+ "",
44
+ "let __vinextImageOptimizerRegistered = false;",
45
+ "",
46
+ "export function registerConfiguredImageOptimizer(env) {",
47
+ " if (__vinextImageOptimizerRegistered) return;",
48
+ " __vinextImageOptimizerRegistered = true;",
49
+ " try {",
50
+ ` setImageOptimizer(__vinextImageOptimizerFactory({ env, options: ${inlineOptions(optimizer.adapter, optimizer.options)} }));`,
51
+ " } catch (error) {",
52
+ " console.warn(\"[vinext] failed to initialize the configured image optimizer; serving images unoptimized.\\n\" + __vinextFormatAdapterError(error));",
53
+ " }",
54
+ "}",
55
+ ""
56
+ ].join("\n");
57
+ }
58
+ //#endregion
59
+ export { VIRTUAL_IMAGE_ADAPTERS, generateImageAdaptersModule };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { NextConfig, NextConfigInput } from "./config/next-config.js";
2
2
  import { AppStaticExportOptions, StaticExportOptions, StaticExportResult, staticExportApp, staticExportPages } from "./build/static-export.js";
3
3
  import { VinextCacheConfig } from "./cache/cache-adapters-virtual.js";
4
+ import { VinextPrerenderConfig } from "./config/prerender.js";
5
+ import { VinextImageConfig } from "./image/image-adapters-virtual.js";
4
6
  import { PluginOption } from "vite";
5
7
  import { Options } from "@vitejs/plugin-react";
6
8
 
@@ -79,6 +81,26 @@ type VinextOptions = {
79
81
  * @default false
80
82
  */
81
83
  precompress?: boolean;
84
+ /**
85
+ * Pre-render routes after `vinext build` without passing
86
+ * `--prerender-all`.
87
+ *
88
+ * Use `true` as shorthand for `{ routes: "*" }`. The object form is
89
+ * available so future releases can support narrower route selections, but
90
+ * currently only `"*"` is supported.
91
+ *
92
+ * The `vinext build --prerender-all` and `vinext deploy --prerender-all`
93
+ * flags still work and take priority when present.
94
+ *
95
+ * @example
96
+ * vinext({ prerender: true })
97
+ *
98
+ * @example
99
+ * vinext({ prerender: { routes: "*" } })
100
+ *
101
+ * @default undefined
102
+ */
103
+ prerender?: VinextPrerenderConfig;
82
104
  /**
83
105
  * Configure cache handlers declaratively, so you don't need a custom worker
84
106
  * entry that calls `setDataCacheHandler()` / `setCdnCacheAdapter()`. Each slot
@@ -97,6 +119,17 @@ type VinextOptions = {
97
119
  * })
98
120
  */
99
121
  cache?: VinextCacheConfig;
122
+ /**
123
+ * Configure the server-side image optimizer declaratively. The adapter factory
124
+ * receives the host `env`, allowing bindings such as Cloudflare Images to be
125
+ * used by both built-in and custom worker entrypoints that forward `env`.
126
+ *
127
+ * @example
128
+ * import { imagesOptimizer } from "@vinext/cloudflare/images/images-optimizer";
129
+ *
130
+ * vinext({ images: { optimizer: imagesOptimizer() } })
131
+ */
132
+ images?: VinextImageConfig;
100
133
  /**
101
134
  * Experimental vinext-only feature flags.
102
135
  */