vinext 1.0.0-beta.0 → 1.0.0-beta.2

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 (305) hide show
  1. package/README.md +21 -2
  2. package/dist/build/assets-ignore.js +1 -1
  3. package/dist/build/clean-output.js +1 -1
  4. package/dist/build/client-build-config.js +7 -4
  5. package/dist/build/css-url-assets.js +3 -3
  6. package/dist/build/google-fonts/fallback-metrics.js +1 -1
  7. package/dist/build/google-fonts/font-metadata.js +1 -1
  8. package/dist/build/inject-pregenerated-paths.js +1 -1
  9. package/dist/build/inline-css.js +2 -5
  10. package/dist/build/module-dependency-cache.d.ts +4 -0
  11. package/dist/build/module-dependency-cache.js +13 -0
  12. package/dist/build/next-client-runtime-manifests.js +1 -1
  13. package/dist/build/pages-client-assets-module.js +1 -1
  14. package/dist/build/precompress.js +7 -7
  15. package/dist/build/prerender-paths.d.ts +2 -2
  16. package/dist/build/prerender-paths.js +10 -15
  17. package/dist/build/prerender-server-pool.js +2 -2
  18. package/dist/build/prerender.js +1 -1
  19. package/dist/build/preview-credentials.d.ts +11 -0
  20. package/dist/build/preview-credentials.js +19 -0
  21. package/dist/build/report.d.ts +8 -4
  22. package/dist/build/report.js +14 -6
  23. package/dist/build/run-prerender.d.ts +2 -11
  24. package/dist/build/run-prerender.js +2 -10
  25. package/dist/build/server-manifest.js +1 -1
  26. package/dist/build/ssr-manifest.d.ts +4 -0
  27. package/dist/build/ssr-manifest.js +10 -6
  28. package/dist/build/standalone.js +37 -37
  29. package/dist/cache/cache-adapters-virtual.d.ts +1 -17
  30. package/dist/cache/cache-adapters-virtual.js +20 -11
  31. package/dist/check.d.ts +0 -16
  32. package/dist/check.js +27 -36
  33. package/dist/cli.js +61 -55
  34. package/dist/client/instrumentation-client-inject.js +1 -1
  35. package/dist/client/pages-router-link-navigation.js +1 -1
  36. package/dist/config/config-matchers.d.ts +13 -37
  37. package/dist/config/config-matchers.js +33 -123
  38. package/dist/config/dotenv.js +1 -1
  39. package/dist/config/next-config.d.ts +7 -3
  40. package/dist/config/next-config.js +84 -15
  41. package/dist/config/prerender.d.ts +2 -2
  42. package/dist/config/prerender.js +7 -15
  43. package/dist/config/request-context.d.ts +14 -0
  44. package/dist/config/request-context.js +26 -0
  45. package/dist/config/server-external-packages.js +1 -1
  46. package/dist/config/tsconfig-paths.js +2 -2
  47. package/dist/{node_modules/.pnpm/am-i-vibing@0.5.0/node_modules → deps/.pnpm/am-i-vibing@0.5.0/deps}/am-i-vibing/dist/detector-1yx2Hoe0.js +2 -2
  48. package/dist/deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js +50 -0
  49. package/dist/entries/app-rsc-entry.js +39 -14
  50. package/dist/entries/app-rsc-manifest.js +21 -4
  51. package/dist/entries/pages-client-entry.js +6 -5
  52. package/dist/entries/pages-server-entry.js +18 -28
  53. package/dist/entries/runtime-entry-module.js +2 -2
  54. package/dist/index.js +314 -230
  55. package/dist/init-cloudflare.js +1 -1
  56. package/dist/init-platform.js +1 -1
  57. package/dist/init.d.ts +6 -4
  58. package/dist/init.js +25 -27
  59. package/dist/plugins/ast-utils.js +1 -1
  60. package/dist/plugins/dynamic-preload-metadata.js +7 -7
  61. package/dist/plugins/extensionless-dynamic-import.js +1 -1
  62. package/dist/plugins/fonts.js +3 -3
  63. package/dist/plugins/ignore-dynamic-requests.js +13 -8
  64. package/dist/plugins/import-meta-url.js +16 -17
  65. package/dist/plugins/middleware-export-validation.js +1 -1
  66. package/dist/plugins/middleware-server-only.js +2 -2
  67. package/dist/plugins/og-asset-ownership.js +7 -6
  68. package/dist/plugins/og-assets.js +5 -6
  69. package/dist/plugins/optimize-imports.js +12 -13
  70. package/dist/plugins/postcss.js +1 -1
  71. package/dist/plugins/remove-console.js +1 -1
  72. package/dist/plugins/require-context.js +1 -1
  73. package/dist/plugins/sass.js +2 -2
  74. package/dist/plugins/server-externals-manifest.js +1 -1
  75. package/dist/plugins/strip-server-exports.js +1 -1
  76. package/dist/plugins/styled-jsx.js +3 -2
  77. package/dist/plugins/typeof-window.js +1 -1
  78. package/dist/routing/app-route-graph.d.ts +16 -15
  79. package/dist/routing/app-route-graph.js +86 -88
  80. package/dist/routing/app-router.d.ts +0 -5
  81. package/dist/routing/app-router.js +12 -11
  82. package/dist/routing/file-matcher.d.ts +13 -28
  83. package/dist/routing/file-matcher.js +31 -44
  84. package/dist/routing/pages-router.js +26 -32
  85. package/dist/routing/route-matching.d.ts +14 -1
  86. package/dist/routing/route-matching.js +13 -1
  87. package/dist/routing/route-pattern.d.ts +2 -1
  88. package/dist/routing/route-pattern.js +7 -4
  89. package/dist/routing/route-trie.d.ts +5 -1
  90. package/dist/routing/route-trie.js +5 -2
  91. package/dist/server/api-handler.js +41 -33
  92. package/dist/server/app-browser-entry.js +18 -11
  93. package/dist/server/app-browser-history-controller.d.ts +1 -1
  94. package/dist/server/app-browser-history-controller.js +3 -3
  95. package/dist/server/app-browser-navigation-controller.js +4 -2
  96. package/dist/server/app-browser-server-action-client.js +1 -1
  97. package/dist/server/app-elements-wire.d.ts +2 -1
  98. package/dist/server/app-fallback-renderer.d.ts +11 -0
  99. package/dist/server/app-fallback-renderer.js +16 -2
  100. package/dist/server/app-middleware.js +2 -1
  101. package/dist/server/app-page-boundary-render.d.ts +26 -2
  102. package/dist/server/app-page-boundary-render.js +190 -55
  103. package/dist/server/app-page-cache-finalizer.d.ts +1 -1
  104. package/dist/server/app-page-cache.d.ts +1 -1
  105. package/dist/server/app-page-dispatch.d.ts +12 -2
  106. package/dist/server/app-page-dispatch.js +37 -51
  107. package/dist/server/app-page-element-builder.d.ts +8 -2
  108. package/dist/server/app-page-element-builder.js +112 -27
  109. package/dist/server/app-page-execution.d.ts +3 -1
  110. package/dist/server/app-page-execution.js +31 -39
  111. package/dist/server/app-page-head.d.ts +54 -2
  112. package/dist/server/app-page-head.js +164 -78
  113. package/dist/server/app-page-http-access-fallback-metadata.d.ts +29 -0
  114. package/dist/server/app-page-http-access-fallback-metadata.js +106 -0
  115. package/dist/server/app-page-render.d.ts +2 -2
  116. package/dist/server/app-page-render.js +1 -1
  117. package/dist/server/app-page-request.d.ts +12 -0
  118. package/dist/server/app-page-request.js +134 -14
  119. package/dist/server/app-page-route-wiring.d.ts +9 -0
  120. package/dist/server/app-page-route-wiring.js +44 -4
  121. package/dist/server/app-post-middleware-context.d.ts +1 -1
  122. package/dist/server/app-post-middleware-context.js +1 -1
  123. package/dist/server/app-route-handler-dispatch.js +31 -17
  124. package/dist/server/app-route-handler-execution.d.ts +6 -1
  125. package/dist/server/app-route-handler-execution.js +41 -15
  126. package/dist/server/app-route-handler-policy.d.ts +2 -0
  127. package/dist/server/app-route-handler-policy.js +3 -3
  128. package/dist/server/app-route-module-loader.d.ts +3 -1
  129. package/dist/server/app-route-module-loader.js +1 -0
  130. package/dist/server/app-route-tree-prefetch.js +1 -1
  131. package/dist/server/app-rsc-cache-busting.d.ts +1 -1
  132. package/dist/server/app-rsc-cache-busting.js +1 -1
  133. package/dist/server/app-rsc-errors.d.ts +1 -1
  134. package/dist/server/app-rsc-errors.js +12 -2
  135. package/dist/server/app-rsc-handler.d.ts +10 -5
  136. package/dist/server/app-rsc-handler.js +51 -23
  137. package/dist/server/app-rsc-redirect-flight.d.ts +66 -0
  138. package/dist/server/app-rsc-redirect-flight.js +71 -0
  139. package/dist/server/app-rsc-request-normalization.d.ts +3 -2
  140. package/dist/server/app-rsc-request-normalization.js +8 -2
  141. package/dist/server/app-rsc-response-finalizer.d.ts +2 -2
  142. package/dist/server/app-rsc-response-finalizer.js +5 -11
  143. package/dist/server/app-rsc-route-matching.d.ts +20 -0
  144. package/dist/server/app-rsc-route-matching.js +87 -11
  145. package/dist/server/app-segment-config.js +15 -5
  146. package/dist/server/app-server-action-execution.d.ts +3 -1
  147. package/dist/server/app-server-action-execution.js +8 -6
  148. package/dist/server/app-ssr-entry.js +4 -1
  149. package/dist/server/app-ssr-stream.d.ts +2 -7
  150. package/dist/server/app-ssr-stream.js +5 -10
  151. package/dist/server/cache-proof.js +1 -1
  152. package/dist/server/config-headers.d.ts +24 -0
  153. package/dist/server/config-headers.js +52 -0
  154. package/dist/server/default-global-error-module.d.ts +3 -1
  155. package/dist/server/default-not-found-module.d.ts +3 -1
  156. package/dist/server/dev-initial-server-error.d.ts +1 -1
  157. package/dist/server/dev-lockfile.js +2 -3
  158. package/dist/server/dev-route-files.js +1 -1
  159. package/dist/server/dev-server.js +281 -173
  160. package/dist/server/dev-stack-sourcemap.js +4 -3
  161. package/dist/server/headers.d.ts +3 -1
  162. package/dist/server/headers.js +3 -1
  163. package/dist/server/image-optimization.js +2 -2
  164. package/dist/server/implicit-tags.js +2 -1
  165. package/dist/server/instrumentation.js +2 -2
  166. package/dist/server/isr-cache.d.ts +1 -1
  167. package/dist/server/isr-cache.js +1 -1
  168. package/dist/server/metadata-routes.js +4 -4
  169. package/dist/server/middleware-matcher-pattern.d.ts +22 -0
  170. package/dist/server/middleware-matcher-pattern.js +219 -0
  171. package/dist/server/middleware-matcher.d.ts +2 -7
  172. package/dist/server/middleware-matcher.js +13 -60
  173. package/dist/server/middleware-path-to-regexp.d.ts +14 -0
  174. package/dist/server/middleware-path-to-regexp.js +228 -0
  175. package/dist/server/middleware-response-headers.js +1 -1
  176. package/dist/server/middleware-runtime.js +5 -4
  177. package/dist/server/middleware.d.ts +2 -1
  178. package/dist/server/middleware.js +3 -2
  179. package/dist/server/navigation-planner.d.ts +2 -0
  180. package/dist/server/navigation-planner.js +8 -2
  181. package/dist/server/next-error-digest.d.ts +9 -24
  182. package/dist/server/next-error-digest.js +23 -15
  183. package/dist/server/operation-token.js +1 -1
  184. package/dist/server/pages-body-parser-config.js +2 -1
  185. package/dist/server/pages-data-route.d.ts +11 -1
  186. package/dist/server/pages-data-route.js +16 -1
  187. package/dist/server/pages-dev-hydration.d.ts +14 -0
  188. package/dist/server/pages-dev-hydration.js +83 -0
  189. package/dist/server/pages-dev-module-url.js +2 -2
  190. package/dist/server/pages-get-initial-props.d.ts +15 -2
  191. package/dist/server/pages-get-initial-props.js +16 -6
  192. package/dist/server/pages-node-compat.d.ts +13 -6
  193. package/dist/server/pages-node-compat.js +44 -45
  194. package/dist/server/pages-page-data.d.ts +4 -2
  195. package/dist/server/pages-page-data.js +20 -10
  196. package/dist/server/pages-page-handler.d.ts +4 -2
  197. package/dist/server/pages-page-handler.js +74 -43
  198. package/dist/server/pages-page-response.d.ts +2 -2
  199. package/dist/server/pages-page-response.js +1 -1
  200. package/dist/server/pages-preview.d.ts +26 -0
  201. package/dist/server/pages-preview.js +165 -0
  202. package/dist/server/pages-readiness.d.ts +5 -4
  203. package/dist/server/pages-readiness.js +4 -2
  204. package/dist/server/pages-request-pipeline.d.ts +1 -0
  205. package/dist/server/pages-request-pipeline.js +25 -11
  206. package/dist/server/pages-router-entry.js +6 -0
  207. package/dist/server/prerender-route-params.js +2 -2
  208. package/dist/server/prod-server.d.ts +1 -4
  209. package/dist/server/prod-server.js +44 -30
  210. package/dist/server/request-pipeline.d.ts +15 -29
  211. package/dist/server/request-pipeline.js +25 -60
  212. package/dist/server/rsc-stream-hints.js +122 -18
  213. package/dist/server/seed-cache.js +1 -1
  214. package/dist/server/socket-error-backstop.js +1 -1
  215. package/dist/server/static-file-cache.js +7 -8
  216. package/dist/server/worker-utils.js +1 -1
  217. package/dist/shims/app.d.ts +1 -1
  218. package/dist/shims/cache-request-state.d.ts +27 -1
  219. package/dist/shims/cache-request-state.js +60 -1
  220. package/dist/shims/cache-runtime.d.ts +12 -1
  221. package/dist/shims/cache-runtime.js +22 -7
  222. package/dist/shims/cache.d.ts +5 -5
  223. package/dist/shims/cache.js +28 -11
  224. package/dist/shims/constants.js +1 -1
  225. package/dist/shims/document.d.ts +42 -83
  226. package/dist/shims/document.js +62 -53
  227. package/dist/shims/dynamic.d.ts +5 -25
  228. package/dist/shims/dynamic.js +29 -8
  229. package/dist/shims/error-boundary.d.ts +4 -4
  230. package/dist/shims/error.d.ts +22 -6
  231. package/dist/shims/error.js +53 -15
  232. package/dist/shims/fetch-cache.js +13 -4
  233. package/dist/shims/font-google-base.d.ts +11 -4
  234. package/dist/shims/font-local.d.ts +10 -3
  235. package/dist/shims/font-utils.js +1 -1
  236. package/dist/shims/form.d.ts +1 -1
  237. package/dist/shims/head.d.ts +13 -2
  238. package/dist/shims/head.js +6 -6
  239. package/dist/shims/headers.d.ts +28 -31
  240. package/dist/shims/headers.js +115 -53
  241. package/dist/shims/image.d.ts +27 -37
  242. package/dist/shims/image.js +21 -14
  243. package/dist/shims/internal/cookie-serialize.d.ts +3 -1
  244. package/dist/shims/internal/cookie-serialize.js +3 -1
  245. package/dist/shims/internal/hybrid-client-route-owner.js +3 -1
  246. package/dist/shims/internal/pages-data-fetch-dedup.js +5 -3
  247. package/dist/shims/internal/utils.d.ts +3 -3
  248. package/dist/shims/layout-segment-context.d.ts +1 -1
  249. package/dist/shims/legacy-image.d.ts +3 -37
  250. package/dist/shims/legacy-image.js +6 -16
  251. package/dist/shims/link.d.ts +16 -21
  252. package/dist/shims/link.js +25 -13
  253. package/dist/shims/navigation-context-state.d.ts +1 -1
  254. package/dist/shims/navigation-errors.d.ts +2 -1
  255. package/dist/shims/navigation-errors.js +9 -13
  256. package/dist/shims/navigation.d.ts +8 -4
  257. package/dist/shims/navigation.js +29 -18
  258. package/dist/shims/next-shims-augmentations.d.ts +1 -0
  259. package/dist/shims/next-shims-public.d.ts +1 -0
  260. package/dist/shims/public-shim-map.json.js +103 -0
  261. package/dist/shims/readonly-url-search-params.d.ts +3 -3
  262. package/dist/shims/readonly-url-search-params.js +3 -3
  263. package/dist/shims/request-state-types.d.ts +1 -1
  264. package/dist/shims/router-state.d.ts +1 -0
  265. package/dist/shims/router.d.ts +57 -22
  266. package/dist/shims/router.js +178 -46
  267. package/dist/shims/script.d.ts +6 -10
  268. package/dist/shims/script.js +7 -4
  269. package/dist/shims/server.d.ts +45 -22
  270. package/dist/shims/server.js +46 -7
  271. package/dist/shims/slot.d.ts +1 -1
  272. package/dist/shims/thenable-params.js +1 -1
  273. package/dist/shims/unified-request-context.d.ts +1 -1
  274. package/dist/shims/unified-request-context.js +2 -0
  275. package/dist/shims/url-safety.d.ts +1 -1
  276. package/dist/shims/url-safety.js +2 -2
  277. package/dist/typegen.d.ts +8 -2
  278. package/dist/typegen.js +84 -25
  279. package/dist/utils/client-build-manifest.js +2 -2
  280. package/dist/utils/client-entry-manifest.js +1 -1
  281. package/dist/utils/client-runtime-metadata.js +1 -1
  282. package/dist/utils/commonjs-loader.js +3 -3
  283. package/dist/utils/domain-locale.d.ts +2 -2
  284. package/dist/utils/external-url.d.ts +5 -0
  285. package/dist/utils/external-url.js +7 -0
  286. package/dist/utils/mdx-scan.js +1 -1
  287. package/dist/utils/path.d.ts +1 -13
  288. package/dist/utils/path.js +1 -15
  289. package/dist/utils/plugin-options.d.ts +4 -0
  290. package/dist/utils/plugin-options.js +8 -0
  291. package/dist/utils/project.d.ts +0 -6
  292. package/dist/utils/project.js +2 -8
  293. package/dist/utils/public-routes.js +2 -2
  294. package/dist/utils/react-version.js +1 -1
  295. package/dist/utils/redirect-digest.d.ts +9 -0
  296. package/dist/utils/redirect-digest.js +25 -0
  297. package/dist/utils/regex-safety.d.ts +8 -0
  298. package/dist/utils/regex-safety.js +737 -0
  299. package/dist/utils/vinext-root.js +1 -1
  300. package/dist/utils/vite-version.d.ts +5 -2
  301. package/dist/utils/vite-version.js +43 -17
  302. package/package.json +16 -4
  303. /package/dist/build/google-fonts/{fallback-metrics-data.js → fallback-metrics-data.json.js} +0 -0
  304. /package/dist/build/google-fonts/{font-data.js → font-data.json.js} +0 -0
  305. /package/dist/{node_modules/.pnpm/process-ancestry@0.1.0/node_modules → deps/.pnpm/process-ancestry@0.1.0/deps}/process-ancestry/dist/index.js +0 -0
@@ -1,4 +1,4 @@
1
- import { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, ActionRevalidationKind, CacheLifeConfig, CacheState, UnstableCacheObservation, UnstableCacheRevalidationMode, _consumeRequestScopedCacheLife, _initRequestScopedCacheState, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, getRegisteredCacheContext, markActionRevalidation, recordUnstableCacheObservation, shouldServeStaleUnstableCacheEntry } from "./cache-request-state.js";
1
+ import { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, ActionRevalidationKind, CacheLifeConfig, CacheState, UnstableCacheObservation, UnstableCacheRevalidationMode, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _queuePendingRevalidation, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, getRegisteredCacheContext, markActionRevalidation, recordUnstableCacheObservation, shouldServeStaleUnstableCacheEntry } from "./cache-request-state.js";
2
2
  import { ExecutionContextLike, getRequestExecutionContext, runWithExecutionContext } from "./request-context.js";
3
3
  import { CacheControlMetadata, CacheHandler, CacheHandlerContext, CacheHandlerValue, CachedAppPageValue, CachedFetchValue, CachedImageValue, CachedPagesValue, CachedRedirectValue, CachedRouteValue, IncrementalCacheValue, MemoryCacheHandler, NoOpCacheHandler, configureMemoryCacheHandler, getCacheHandler, getDataCacheHandler, setCacheHandler, setDataCacheHandler } from "./cache-handler.js";
4
4
 
@@ -18,7 +18,7 @@ import { CacheControlMetadata, CacheHandler, CacheHandlerContext, CacheHandlerVa
18
18
  */
19
19
  declare function revalidateTag(tag: string, profile?: string | {
20
20
  expire?: number;
21
- }): Promise<void>;
21
+ }): undefined;
22
22
  /**
23
23
  * Revalidate cached data associated with a specific path.
24
24
  *
@@ -34,7 +34,7 @@ declare function revalidateTag(tag: string, profile?: string | {
34
34
  * The `type` parameter is App Router only — Pages Router does not generate
35
35
  * layout/page hierarchy tags, so only no-type invalidation applies there.
36
36
  */
37
- declare function revalidatePath(path: string, type?: "page" | "layout"): Promise<void>;
37
+ declare function revalidatePath(path: string, type?: "page" | "layout"): undefined;
38
38
  /**
39
39
  * No-op shim for API compatibility.
40
40
  *
@@ -57,7 +57,7 @@ declare function refresh(): void;
57
57
  *
58
58
  * @see https://nextjs.org/docs/app/api-reference/functions/updateTag
59
59
  */
60
- declare function updateTag(tag: string): Promise<void>;
60
+ declare function updateTag(tag: string): undefined;
61
61
  /**
62
62
  * Opt out of static rendering and indicate a particular component should not be cached.
63
63
  *
@@ -142,4 +142,4 @@ type UnstableCacheOptions = {
142
142
  */
143
143
  declare function unstable_cache<T extends (...args: any[]) => Promise<any>>(fn: T, keyParts?: string[], options?: UnstableCacheOptions): T;
144
144
  //#endregion
145
- export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, ActionRevalidationKind, CacheControlMetadata, CacheHandler, CacheHandlerContext, CacheHandlerValue, CacheLifeConfig, CacheState, CachedAppPageValue, CachedFetchValue, CachedImageValue, CachedPagesValue, CachedRedirectValue, CachedRouteValue, type ExecutionContextLike, IncrementalCacheValue, MemoryCacheHandler, NoOpCacheHandler, UnstableCacheObservation, UnstableCacheRevalidationMode, _consumeRequestScopedCacheLife, _initRequestScopedCacheState, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLife, cacheLifeProfiles, cacheTag, configureMemoryCacheHandler, getAndClearActionRevalidationKind, getCacheHandler, getDataCacheHandler, getRegisteredCacheContext, getRequestExecutionContext, io, isInsideUnstableCacheScope, markActionRevalidation, unstable_noStore as noStore, unstable_noStore, recordUnstableCacheObservation, refresh, revalidatePath, revalidateTag, runWithExecutionContext, setCacheHandler, setDataCacheHandler, shouldServeStaleUnstableCacheEntry, unstable_cache, unstable_cacheLife, unstable_cacheTag, unstable_io, updateTag };
145
+ export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, ActionRevalidationKind, CacheControlMetadata, CacheHandler, CacheHandlerContext, CacheHandlerValue, CacheLifeConfig, CacheState, CachedAppPageValue, CachedFetchValue, CachedImageValue, CachedPagesValue, CachedRedirectValue, CachedRouteValue, type ExecutionContextLike, IncrementalCacheValue, MemoryCacheHandler, NoOpCacheHandler, UnstableCacheObservation, UnstableCacheRevalidationMode, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _queuePendingRevalidation, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLife, cacheLifeProfiles, cacheTag, configureMemoryCacheHandler, getAndClearActionRevalidationKind, getCacheHandler, getDataCacheHandler, getRegisteredCacheContext, getRequestExecutionContext, io, isInsideUnstableCacheScope, markActionRevalidation, unstable_noStore as noStore, unstable_noStore, recordUnstableCacheObservation, refresh, revalidatePath, revalidateTag, runWithExecutionContext, setCacheHandler, setDataCacheHandler, shouldServeStaleUnstableCacheEntry, unstable_cache, unstable_cacheLife, unstable_cacheTag, unstable_io, updateTag };
@@ -6,9 +6,9 @@ import { getCdnCacheAdapter } from "./cdn-cache.js";
6
6
  import { fnv1a64 } from "../utils/hash.js";
7
7
  import { makeHangingPromise } from "./internal/make-hanging-promise.js";
8
8
  import { getHeadersAccessPhase, isDraftModeEnabled, markDynamicUsage } from "./headers.js";
9
- import { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, _consumeRequestScopedCacheLife, _initRequestScopedCacheState, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, getRegisteredCacheContext, markActionRevalidation, recordUnstableCacheObservation, shouldServeStaleUnstableCacheEntry } from "./cache-request-state.js";
9
+ import { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _queuePendingRevalidation, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, getRegisteredCacheContext, markActionRevalidation, recordUnstableCacheObservation, shouldServeStaleUnstableCacheEntry } from "./cache-request-state.js";
10
10
  import { encodeCacheTag, encodeCacheTags } from "../utils/encode-cache-tag.js";
11
- import { addCollectedRequestTags } from "./fetch-cache.js";
11
+ import { addCollectedRequestTags, getCurrentFetchSoftTags } from "./fetch-cache.js";
12
12
  import { workUnitAsyncStorage } from "./internal/work-unit-async-storage.js";
13
13
  //#region src/shims/cache.ts
14
14
  /**
@@ -32,6 +32,14 @@ import { workUnitAsyncStorage } from "./internal/work-unit-async-storage.js";
32
32
  * target used by the generated cache-adapter module.
33
33
  */
34
34
  const _g = globalThis;
35
+ function scheduleRevalidation(promise) {
36
+ const executionContext = getRequestExecutionContext();
37
+ const queued = _queuePendingRevalidation(promise);
38
+ if (executionContext) executionContext.waitUntil(promise);
39
+ else if (!queued) promise.catch((error) => {
40
+ console.error("[vinext] cache revalidation failed:", error);
41
+ });
42
+ }
35
43
  /**
36
44
  * Revalidate cached data associated with a specific cache tag.
37
45
  *
@@ -45,14 +53,16 @@ const _g = globalThis;
45
53
  * @param tag - Cache tag to revalidate
46
54
  * @param profile - cacheLife profile name (e.g. 'max', 'hours') or inline { expire: number }
47
55
  */
48
- async function revalidateTag(tag, profile) {
56
+ function revalidateTag(tag, profile) {
49
57
  let durations;
50
58
  if (typeof profile === "string") {
51
59
  const resolved = cacheLifeProfiles[profile];
52
60
  if (resolved) durations = { expire: resolved.expire };
53
61
  } else if (profile && typeof profile === "object") durations = profile;
54
62
  if (!profile || !durations || durations.expire === 0) markActionRevalidation(1);
55
- await _invalidateEncodedTag(encodeCacheTag(tag), durations);
63
+ const encodedTag = encodeCacheTag(tag);
64
+ _markPendingRevalidatedTag(encodedTag);
65
+ return scheduleRevalidation(_invalidateEncodedTag(encodedTag, durations));
56
66
  }
57
67
  /**
58
68
  * Invalidate one already-encoded tag across both cache layers.
@@ -82,10 +92,12 @@ async function _invalidateEncodedTag(encoded, durations) {
82
92
  * The `type` parameter is App Router only — Pages Router does not generate
83
93
  * layout/page hierarchy tags, so only no-type invalidation applies there.
84
94
  */
85
- async function revalidatePath(path, type) {
95
+ function revalidatePath(path, type) {
86
96
  markActionRevalidation(1);
87
97
  const stem = path.endsWith("/") ? path.slice(0, -1) : path;
88
- await _invalidateEncodedTag(encodeCacheTag(type ? `_N_T_${stem}/${type}` : `_N_T_${stem || "/"}`));
98
+ const encodedTag = encodeCacheTag(type ? `_N_T_${stem}/${type}` : `_N_T_${stem || "/"}`);
99
+ _markPendingRevalidatedTag(encodedTag);
100
+ return scheduleRevalidation(_invalidateEncodedTag(encodedTag));
89
101
  }
90
102
  /**
91
103
  * No-op shim for API compatibility.
@@ -114,7 +126,9 @@ function refresh() {
114
126
  function updateTag(tag) {
115
127
  if (getHeadersAccessPhase() !== "action") throw new Error("updateTag can only be called from within a Server Action. To invalidate cache tags in Route Handlers or other contexts, use revalidateTag instead. See more info here: https://nextjs.org/docs/app/api-reference/functions/updateTag");
116
128
  markActionRevalidation(1);
117
- return _invalidateEncodedTag(encodeCacheTag(tag));
129
+ const encodedTag = encodeCacheTag(tag);
130
+ _markPendingRevalidatedTag(encodedTag);
131
+ return scheduleRevalidation(_invalidateEncodedTag(encodedTag));
118
132
  }
119
133
  /**
120
134
  * Opt out of static rendering and indicate a particular component should not be cached.
@@ -374,7 +388,8 @@ function unstable_cache(fn, keyParts, options) {
374
388
  const tags = encodeCacheTags(options?.tags ?? []);
375
389
  const revalidateSeconds = options?.revalidate;
376
390
  const cachedFn = async (...args) => {
377
- const cacheKey = `unstable_cache:${baseKey}:${JSON.stringify(args)}`;
391
+ const argsKey = JSON.stringify(args);
392
+ const cacheKey = `unstable_cache:${baseKey}:${argsKey}`;
378
393
  addCollectedRequestTags(tags);
379
394
  recordUnstableCacheObservation({
380
395
  kind: "unstable_cache",
@@ -385,9 +400,11 @@ function unstable_cache(fn, keyParts, options) {
385
400
  });
386
401
  const isDraftMode = isDraftModeEnabled();
387
402
  if (!isDraftMode) {
388
- const existing = await getDataCacheHandler().get(cacheKey, {
403
+ const softTags = getCurrentFetchSoftTags();
404
+ const existing = _hasPendingRevalidatedTag([...tags, ...softTags]) ? null : await getDataCacheHandler().get(cacheKey, {
389
405
  kind: "FETCH",
390
- tags
406
+ tags,
407
+ softTags
391
408
  });
392
409
  if (existing?.value && existing.value.kind === "FETCH") {
393
410
  const cached = tryDeserializeUnstableCacheResult(existing.value.data.body);
@@ -405,4 +422,4 @@ function unstable_cache(fn, keyParts, options) {
405
422
  return cachedFn;
406
423
  }
407
424
  //#endregion
408
- export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, MemoryCacheHandler, NoOpCacheHandler, _consumeRequestScopedCacheLife, _initRequestScopedCacheState, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLife, cacheLifeProfiles, cacheTag, configureMemoryCacheHandler, getAndClearActionRevalidationKind, getCacheHandler, getDataCacheHandler, getRegisteredCacheContext, getRequestExecutionContext, io, isInsideUnstableCacheScope, markActionRevalidation, unstable_noStore as noStore, unstable_noStore, recordUnstableCacheObservation, refresh, revalidatePath, revalidateTag, runWithExecutionContext, setCacheHandler, setDataCacheHandler, shouldServeStaleUnstableCacheEntry, unstable_cache, unstable_cacheLife, unstable_cacheTag, unstable_io, updateTag };
425
+ export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, MemoryCacheHandler, NoOpCacheHandler, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _queuePendingRevalidation, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLife, cacheLifeProfiles, cacheTag, configureMemoryCacheHandler, getAndClearActionRevalidationKind, getCacheHandler, getDataCacheHandler, getRegisteredCacheContext, getRequestExecutionContext, io, isInsideUnstableCacheScope, markActionRevalidation, unstable_noStore as noStore, unstable_noStore, recordUnstableCacheObservation, refresh, revalidatePath, revalidateTag, runWithExecutionContext, setCacheHandler, setDataCacheHandler, shouldServeStaleUnstableCacheEntry, unstable_cache, unstable_cacheLife, unstable_cacheTag, unstable_io, updateTag };
@@ -158,7 +158,7 @@ const EDGE_UNSUPPORTED_NODE_APIS = [
158
158
  "TransformStreamDefaultController",
159
159
  "WritableStreamDefaultController"
160
160
  ];
161
- const SYSTEM_ENTRYPOINTS = new Set([
161
+ const SYSTEM_ENTRYPOINTS = /* @__PURE__ */ new Set([
162
162
  CLIENT_STATIC_FILES_RUNTIME_MAIN,
163
163
  CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH,
164
164
  CLIENT_STATIC_FILES_RUNTIME_MAIN_APP
@@ -1,92 +1,51 @@
1
1
  import React from "react";
2
+ import { DocumentContext, DocumentInitialProps, DocumentProps } from "@vinext/types/next/upstream/dist/shared/lib/utils";
3
+ import { HtmlProps } from "@vinext/types/next/upstream/dist/shared/lib/html-context.shared-runtime";
2
4
 
3
5
  //#region src/shims/document.d.ts
4
- declare function Html({
5
- children,
6
- lang,
7
- ...props
8
- }: React.HTMLAttributes<HTMLHtmlElement> & {
6
+ type OriginProps = {
7
+ nonce?: string;
8
+ crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
9
9
  children?: React.ReactNode;
10
- }): React.JSX.Element;
11
- /**
12
- * Document Head - renders <head> with children.
13
- * The dev server injects meta tags, styles, etc.
14
- *
15
- * Note: charset and viewport are intentionally NOT hardcoded here. Those
16
- * defaults are seeded by `next/head`'s `defaultHead()` and emitted alongside
17
- * user `<Head>` tags via `getSSRHeadHTML()`, matching Next.js's canonical
18
- * ordering (`<meta charset>` first, then `<meta viewport>`, then user tags,
19
- * all with `data-next-head=""`). See `test/e2e/next-head/index.test.ts`.
20
- */
21
- declare function Head({
22
- children
23
- }: {
24
- children?: React.ReactNode;
25
- }): React.JSX.Element;
26
- /**
27
- * Main - renders the page content container.
28
- */
29
- declare function Main(): React.JSX.Element;
30
- /**
31
- * NextScript - renders a placeholder that the dev-server replaces with
32
- * actual hydration scripts (__NEXT_DATA__ + entry module).
33
- * Uses dangerouslySetInnerHTML so the HTML comment survives renderToString.
34
- */
35
- declare function NextScript(): React.JSX.Element;
36
- /**
37
- * Stand-ins for Next.js's `DocumentContext` / `DocumentInitialProps`.
38
- * The signatures match Next.js so custom `_document.tsx` subclasses can use
39
- * `ctx.renderPage()` enhancers and delegate through
40
- * `await Document.getInitialProps(ctx)` with the expected public types.
41
- *
42
- * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/utils.ts
43
- */
44
- type DocumentContext = {
45
- renderPage: (options?: {
46
- enhanceApp?: (App: React.ComponentType<{
47
- children?: React.ReactNode;
48
- }>) => React.ComponentType<{
49
- children?: React.ReactNode;
50
- }>;
51
- enhanceComponent?: (Comp: React.ComponentType<unknown>) => React.ComponentType<unknown>;
52
- } | ((Comp: React.ComponentType<unknown>) => React.ComponentType<unknown>)) => DocumentInitialProps | Promise<DocumentInitialProps>;
53
- defaultGetInitialProps: (ctx: DocumentContext, options?: {
54
- nonce?: string;
55
- }) => Promise<DocumentInitialProps>;
56
- pathname?: string;
57
- query?: Record<string, string | string[] | undefined>;
58
- asPath?: string;
59
- err?: any;
60
10
  };
61
- type DocumentInitialProps = {
62
- html: string;
63
- head?: ReadonlyArray<React.ReactElement>;
64
- styles?: React.ReactElement[] | Iterable<React.ReactNode> | React.ReactElement;
11
+ type DocumentFiles = {
12
+ sharedFiles: readonly string[];
13
+ pageFiles: readonly string[];
14
+ allFiles: readonly string[];
65
15
  };
66
- /**
67
- * Default Document component — also the base class user `_document.tsx` files
68
- * `extend`. Must be a class (not a function) to match Next.js's `next/document`
69
- * default export so `class MyDocument extends Document` produces a constructible
70
- * class that React can instantiate during SSR. Returning a function here breaks
71
- * any user `_document.tsx` that uses the class-based form because `extends`
72
- * against a non-constructor produces a class that can only be called without
73
- * `new`, which React refuses to do.
74
- *
75
- * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/pages/_document.tsx
76
- * Ported behavior: Next.js's default `Document` is a `class Document extends
77
- * React.Component`. Custom documents extend it and override `getInitialProps`
78
- * and `render`. Generic default matches Next.js (`P = {}`).
79
- */
80
- declare class Document<P = {}> extends React.Component<P & {
81
- children?: React.ReactNode;
82
- }> {
83
- /**
84
- * `getInitialProps` is invoked by the SSR pipeline. The runtime-provided
85
- * `ctx.defaultGetInitialProps()` owns the page render and style collection,
86
- * matching Next.js's canonical CSS-in-JS integration path.
87
- */
16
+ type HeadProps = OriginProps & React.ComponentPropsWithoutRef<"head">;
17
+ declare function Html(props: React.DetailedHTMLProps<React.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>): React.ReactElement;
18
+ interface Head {
19
+ context: HtmlProps;
20
+ }
21
+ declare class Head extends React.Component<HeadProps> {
22
+ static contextType: React.Context<HtmlProps | undefined>;
23
+ getCssLinks(_files: DocumentFiles): React.ReactElement[] | null;
24
+ getPreloadDynamicChunks(): Array<React.ReactElement | null>;
25
+ getPreloadMainLinks(_files: DocumentFiles): React.ReactElement[] | null;
26
+ getBeforeInteractiveInlineScripts(): React.ReactElement[];
27
+ getDynamicChunks(_files: DocumentFiles): Array<React.ReactElement | null>;
28
+ getPreNextScripts(): React.ReactElement;
29
+ getScripts(_files: DocumentFiles): React.ReactElement[];
30
+ getPolyfillScripts(): React.ReactElement[];
31
+ render(): React.ReactElement;
32
+ }
33
+ declare function Main(): React.ReactElement;
34
+ interface NextScript {
35
+ context: HtmlProps;
36
+ }
37
+ declare class NextScript extends React.Component<OriginProps> {
38
+ static contextType: React.Context<HtmlProps | undefined>;
39
+ getDynamicChunks(_files: DocumentFiles): Array<React.ReactElement | null>;
40
+ getPreNextScripts(): React.ReactElement;
41
+ getScripts(_files: DocumentFiles): React.ReactElement[];
42
+ getPolyfillScripts(): React.ReactElement[];
43
+ static getInlineScriptSource(context: Readonly<HtmlProps>): string;
44
+ render(): React.ReactElement;
45
+ }
46
+ declare class Document<P = {}> extends React.Component<DocumentProps & P> {
88
47
  static getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps>;
89
- render(): React.ReactNode;
48
+ render(): React.ReactElement;
90
49
  }
91
50
  //#endregion
92
- export { DocumentContext, DocumentInitialProps, Head, Html, Main, NextScript, Document as default };
51
+ export { type DocumentContext, type DocumentInitialProps, type DocumentProps, Head, Html, Main, NextScript, OriginProps, Document as default };
@@ -1,70 +1,79 @@
1
1
  import React from "react";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
3
3
  //#region src/shims/document.tsx
4
4
  /**
5
5
  * next/document shim
6
6
  *
7
- * Provides Html, Head, Main, NextScript components for custom _document.tsx.
8
- * During SSR these render placeholder markers that the dev server replaces
9
- * with actual content.
7
+ * Provides Html, Head, Main, NextScript, and the class-based Document API for
8
+ * custom Pages Router documents. Vinext's renderer replaces the Main and
9
+ * NextScript placeholders with the rendered page and hydration scripts.
10
10
  */
11
- function Html({ children, lang, ...props }) {
12
- return /* @__PURE__ */ jsx("html", {
13
- lang,
14
- ...props,
15
- children
16
- });
17
- }
18
- /**
19
- * Document Head - renders <head> with children.
20
- * The dev server injects meta tags, styles, etc.
21
- *
22
- * Note: charset and viewport are intentionally NOT hardcoded here. Those
23
- * defaults are seeded by `next/head`'s `defaultHead()` and emitted alongside
24
- * user `<Head>` tags via `getSSRHeadHTML()`, matching Next.js's canonical
25
- * ordering (`<meta charset>` first, then `<meta viewport>`, then user tags,
26
- * all with `data-next-head=""`). See `test/e2e/next-head/index.test.ts`.
27
- */
28
- function Head({ children }) {
29
- return /* @__PURE__ */ jsx("head", { children });
11
+ const HtmlContext = React.createContext(void 0);
12
+ function Html(props) {
13
+ return /* @__PURE__ */ jsx("html", { ...props });
30
14
  }
31
- /**
32
- * Main - renders the page content container.
33
- */
15
+ var Head = class extends React.Component {
16
+ static contextType = HtmlContext;
17
+ getCssLinks(_files) {
18
+ return null;
19
+ }
20
+ getPreloadDynamicChunks() {
21
+ return [];
22
+ }
23
+ getPreloadMainLinks(_files) {
24
+ return null;
25
+ }
26
+ getBeforeInteractiveInlineScripts() {
27
+ return [];
28
+ }
29
+ getDynamicChunks(_files) {
30
+ return [];
31
+ }
32
+ getPreNextScripts() {
33
+ return /* @__PURE__ */ jsx(Fragment$1, {});
34
+ }
35
+ getScripts(_files) {
36
+ return [];
37
+ }
38
+ getPolyfillScripts() {
39
+ return [];
40
+ }
41
+ render() {
42
+ const { children, ...props } = this.props;
43
+ return /* @__PURE__ */ jsx("head", {
44
+ ...props,
45
+ children
46
+ });
47
+ }
48
+ };
34
49
  function Main() {
35
50
  return /* @__PURE__ */ jsx("div", {
36
51
  id: "__next",
37
52
  dangerouslySetInnerHTML: { __html: "__NEXT_MAIN__" }
38
53
  });
39
54
  }
40
- /**
41
- * NextScript - renders a placeholder that the dev-server replaces with
42
- * actual hydration scripts (__NEXT_DATA__ + entry module).
43
- * Uses dangerouslySetInnerHTML so the HTML comment survives renderToString.
44
- */
45
- function NextScript() {
46
- return /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: "<!-- __NEXT_SCRIPTS__ -->" } });
47
- }
48
- /**
49
- * Default Document component — also the base class user `_document.tsx` files
50
- * `extend`. Must be a class (not a function) to match Next.js's `next/document`
51
- * default export so `class MyDocument extends Document` produces a constructible
52
- * class that React can instantiate during SSR. Returning a function here breaks
53
- * any user `_document.tsx` that uses the class-based form because `extends`
54
- * against a non-constructor produces a class that can only be called without
55
- * `new`, which React refuses to do.
56
- *
57
- * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/pages/_document.tsx
58
- * Ported behavior: Next.js's default `Document` is a `class Document extends
59
- * React.Component`. Custom documents extend it and override `getInitialProps`
60
- * and `render`. Generic default matches Next.js (`P = {}`).
61
- */
55
+ var NextScript = class extends React.Component {
56
+ static contextType = HtmlContext;
57
+ getDynamicChunks(_files) {
58
+ return [];
59
+ }
60
+ getPreNextScripts() {
61
+ return /* @__PURE__ */ jsx(Fragment$1, {});
62
+ }
63
+ getScripts(_files) {
64
+ return [];
65
+ }
66
+ getPolyfillScripts() {
67
+ return [];
68
+ }
69
+ static getInlineScriptSource(context) {
70
+ return JSON.stringify(context.__NEXT_DATA__);
71
+ }
72
+ render() {
73
+ return /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: "<!-- __NEXT_SCRIPTS__ -->" } });
74
+ }
75
+ };
62
76
  var Document = class extends React.Component {
63
- /**
64
- * `getInitialProps` is invoked by the SSR pipeline. The runtime-provided
65
- * `ctx.defaultGetInitialProps()` owns the page render and style collection,
66
- * matching Next.js's canonical CSS-in-JS integration path.
67
- */
68
77
  static getInitialProps(ctx) {
69
78
  return ctx.defaultGetInitialProps(ctx);
70
79
  }
@@ -1,28 +1,7 @@
1
- import { ComponentType } from "react";
1
+ import React, { ComponentType } from "react";
2
+ import { DynamicOptions, DynamicOptionsLoadingProps, LoadableComponent, LoadableFn, LoadableGeneratedOptions, LoadableOptions, Loader, LoaderComponent, LoaderMap } from "@vinext/types/next/upstream/dynamic";
2
3
 
3
4
  //#region src/shims/dynamic.d.ts
4
- type DynamicLoadingProps = {
5
- error?: Error | null;
6
- isLoading?: boolean;
7
- pastDelay?: boolean;
8
- retry?: () => void;
9
- timedOut?: boolean;
10
- };
11
- type ComponentModule<P> = {
12
- default: ComponentType<P>;
13
- };
14
- type LoaderComponent<P> = Promise<ComponentModule<P> | ComponentType<P>>;
15
- type LoaderFn<P> = () => LoaderComponent<P>;
16
- type DynamicOptions<P> = {
17
- loading?: ComponentType<DynamicLoadingProps>;
18
- loader?: Loader<P>;
19
- loadableGenerated?: {
20
- modules?: readonly string[];
21
- };
22
- modules?: readonly string[];
23
- ssr?: boolean;
24
- };
25
- type Loader<P> = LoaderFn<P> | LoaderComponent<P>;
26
5
  type DynamicInput<P> = DynamicOptions<P> | Loader<P>;
27
6
  /**
28
7
  * Wait for all pending dynamic() preloads to resolve, then clear the queue.
@@ -30,6 +9,7 @@ type DynamicInput<P> = DynamicOptions<P> | Loader<P>;
30
9
  * No-op for the App Router path which uses React.lazy + Suspense.
31
10
  */
32
11
  declare function flushPreloads(): Promise<void[]>;
33
- declare function dynamic<P extends object = object>(dynamicInput: DynamicInput<P>, options?: DynamicOptions<P>): ComponentType<P>;
12
+ declare function dynamic<P = {}>(dynamicInput: DynamicInput<P>, options?: DynamicOptions<P>): ComponentType<P>;
13
+ declare function noSSR<P = {}>(LoadableInitializer: LoadableFn<P>, loadableOptions: DynamicOptions<P>): React.ComponentType<P>;
34
14
  //#endregion
35
- export { dynamic as default, flushPreloads };
15
+ export { type DynamicOptions, type DynamicOptionsLoadingProps, type LoadableComponent, type LoadableFn, type LoadableGeneratedOptions, type LoadableOptions, type Loader, type LoaderComponent, type LoaderMap, dynamic as default, flushPreloads, noSSR };
@@ -68,6 +68,9 @@ function useRetryableLazyComponent(loader, initialLazyComponent) {
68
68
  retryKey
69
69
  };
70
70
  }
71
+ function createElementWithProps(Component, props) {
72
+ return React.createElement(Component, props);
73
+ }
71
74
  /**
72
75
  * Lightweight error boundary that renders the loading component with the error
73
76
  * when a dynamic() loader rejects. Without this, loader failures would propagate
@@ -122,9 +125,14 @@ function flushPreloads() {
122
125
  return Promise.all(pending);
123
126
  }
124
127
  function dynamic(dynamicInput, options) {
125
- const { loader: dynamicLoader, loadableGenerated, loading: LoadingComponent, modules, ssr = true } = normalizeDynamicOptions(dynamicInput, options);
128
+ const normalizedOptions = normalizeDynamicOptions(dynamicInput, options);
129
+ const { loader: dynamicLoader, loadableGenerated, loading: LoadingComponent, ssr = true } = normalizedOptions;
130
+ if (dynamicLoader && typeof dynamicLoader === "object" && !(dynamicLoader instanceof Promise)) throw new Error("next/dynamic loader maps are not supported by vinext");
126
131
  const loader = dynamicLoader ? normalizeLoader(dynamicLoader) : () => Promise.resolve(() => null);
127
- const preloadModuleIds = loadableGenerated?.modules ?? modules;
132
+ const generatedModules = loadableGenerated?.modules;
133
+ const optionModules = normalizedOptions.modules;
134
+ const configuredModules = generatedModules ?? optionModules;
135
+ const preloadModuleIds = typeof configuredModules === "function" ? Object.keys(configuredModules()) : configuredModules;
128
136
  if (!ssr) {
129
137
  if (isServer) {
130
138
  const SSRFalse = (_props) => LoadingComponent ? React.createElement(LoadingComponent, createDynamicLoadingProps()) : null;
@@ -138,7 +146,7 @@ function dynamic(dynamicInput, options) {
138
146
  React.useEffect(() => setMounted(true), []);
139
147
  if (!mounted) return LoadingComponent ? React.createElement(LoadingComponent, createDynamicLoadingProps({ retry })) : null;
140
148
  const fallback = LoadingComponent ? React.createElement(LoadingComponent, createDynamicLoadingProps({ retry })) : null;
141
- const lazyElement = React.createElement(LazyComponent, props);
149
+ const lazyElement = createElementWithProps(LazyComponent, props);
142
150
  let content = lazyElement;
143
151
  if (LoadingComponent) {
144
152
  const ErrorBoundary = getDynamicErrorBoundary();
@@ -157,8 +165,7 @@ function dynamic(dynamicInput, options) {
157
165
  if (typeof React.lazy !== "function") {
158
166
  const AsyncServerDynamic = async (props) => {
159
167
  const mod = await loader();
160
- const Component = "default" in mod ? mod.default : mod;
161
- return React.createElement(Component, props);
168
+ return createElementWithProps("default" in mod ? mod.default : mod, props);
162
169
  };
163
170
  AsyncServerDynamic.displayName = "DynamicAsyncServer";
164
171
  return AsyncServerDynamic;
@@ -166,7 +173,7 @@ function dynamic(dynamicInput, options) {
166
173
  const LazyServer = createLazyComponent(loader);
167
174
  const ServerDynamic = (props) => {
168
175
  const fallback = LoadingComponent ? React.createElement(LoadingComponent, createDynamicLoadingProps()) : null;
169
- const lazyElement = React.createElement(LazyServer, props);
176
+ const lazyElement = createElementWithProps(LazyServer, props);
170
177
  let content = lazyElement;
171
178
  if (LoadingComponent) {
172
179
  const ErrorBoundary = getDynamicErrorBoundary();
@@ -185,7 +192,7 @@ function dynamic(dynamicInput, options) {
185
192
  const ClientDynamic = (props) => {
186
193
  const { LazyComponent, retry, retryKey } = useRetryableLazyComponent(loader, InitialLazyComponent);
187
194
  const fallback = LoadingComponent ? React.createElement(LoadingComponent, createDynamicLoadingProps({ retry })) : null;
188
- const lazyElement = React.createElement(LazyComponent, props);
195
+ const lazyElement = createElementWithProps(LazyComponent, props);
189
196
  let content = lazyElement;
190
197
  if (LoadingComponent) {
191
198
  const ErrorBoundary = getDynamicErrorBoundary();
@@ -200,5 +207,19 @@ function dynamic(dynamicInput, options) {
200
207
  ClientDynamic.displayName = "DynamicClient";
201
208
  return ClientDynamic;
202
209
  }
210
+ function noSSR(LoadableInitializer, loadableOptions) {
211
+ delete loadableOptions.webpack;
212
+ delete loadableOptions.modules;
213
+ if (!isServer) return LoadableInitializer(loadableOptions);
214
+ const Loading = loadableOptions.loading;
215
+ const NoSSR = () => React.createElement(Loading, {
216
+ error: null,
217
+ isLoading: true,
218
+ pastDelay: false,
219
+ timedOut: false
220
+ });
221
+ NoSSR.displayName = "NoSSR";
222
+ return NoSSR;
223
+ }
203
224
  //#endregion
204
- export { dynamic as default, flushPreloads };
225
+ export { dynamic as default, flushPreloads, noSSR };
@@ -50,7 +50,7 @@ declare class RedirectErrorBoundary extends React.Component<{
50
50
  children?: React.ReactNode;
51
51
  });
52
52
  static getDerivedStateFromError(error: unknown): RedirectBoundaryState;
53
- render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
53
+ render(): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | null | undefined;
54
54
  }
55
55
  declare function RedirectBoundary({
56
56
  children
@@ -70,7 +70,7 @@ declare class ErrorBoundaryInner extends React.Component<ErrorBoundaryInnerProps
70
70
  componentDidMount(): void;
71
71
  componentWillUnmount(): void;
72
72
  reset: () => void;
73
- render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
73
+ render(): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | null | undefined;
74
74
  }
75
75
  declare function ErrorBoundary({
76
76
  fallback,
@@ -118,7 +118,7 @@ declare class ForbiddenBoundaryInner extends React.Component<ForbiddenBoundaryIn
118
118
  constructor(props: ForbiddenBoundaryInnerProps);
119
119
  static getDerivedStateFromProps(props: ForbiddenBoundaryInnerProps, state: ForbiddenBoundaryState): ForbiddenBoundaryState | null;
120
120
  static getDerivedStateFromError(error: unknown): Partial<ForbiddenBoundaryState>;
121
- render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
121
+ render(): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | null | undefined;
122
122
  }
123
123
  declare function ForbiddenBoundary({
124
124
  fallback,
@@ -142,7 +142,7 @@ declare class UnauthorizedBoundaryInner extends React.Component<UnauthorizedBoun
142
142
  constructor(props: UnauthorizedBoundaryInnerProps);
143
143
  static getDerivedStateFromProps(props: UnauthorizedBoundaryInnerProps, state: UnauthorizedBoundaryState): UnauthorizedBoundaryState | null;
144
144
  static getDerivedStateFromError(error: unknown): Partial<UnauthorizedBoundaryState>;
145
- render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
145
+ render(): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | null | undefined;
146
146
  }
147
147
  declare function UnauthorizedBoundary({
148
148
  fallback,
@@ -1,17 +1,33 @@
1
1
  import React from "react";
2
+ import { IncomingMessage, ServerResponse } from "node:http";
2
3
 
3
4
  //#region src/shims/error.d.ts
4
5
  type ErrorProps = {
5
6
  statusCode: number;
7
+ hostname?: string;
6
8
  title?: string;
7
9
  withDarkMode?: boolean;
8
10
  };
9
- declare function ErrorComponent({
10
- statusCode,
11
- title
12
- }: ErrorProps): React.ReactElement;
11
+ type ErrorPageContext = {
12
+ err?: (Error & {
13
+ statusCode?: number;
14
+ }) | null;
15
+ req?: IncomingMessage;
16
+ res?: ServerResponse;
17
+ };
18
+ declare function getErrorInitialProps({
19
+ err,
20
+ req,
21
+ res
22
+ }: ErrorPageContext): ErrorProps;
23
+ declare class ErrorComponent<P = {}> extends React.Component<P & ErrorProps> {
24
+ static displayName: string;
25
+ static getInitialProps: typeof getErrorInitialProps;
26
+ static origGetInitialProps: typeof getErrorInitialProps;
27
+ render(): React.ReactElement;
28
+ }
13
29
  type ErrorInfo = {
14
- error: unknown;
30
+ error: Error;
15
31
  reset: () => void;
16
32
  unstable_retry: () => void;
17
33
  };
@@ -28,4 +44,4 @@ declare function unstable_catchError<P extends _UserProps>(fallback: (props: P,
28
44
  children?: React.ReactNode;
29
45
  }>;
30
46
  //#endregion
31
- export { ErrorInfo, ErrorComponent as default, unstable_catchError };
47
+ export { ErrorInfo, ErrorProps, ErrorComponent as default, unstable_catchError };