vinext 0.1.2 → 0.1.4

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 (243) hide show
  1. package/dist/build/client-build-config.d.ts +11 -2
  2. package/dist/build/client-build-config.js +17 -6
  3. package/dist/build/prerender.d.ts +9 -1
  4. package/dist/build/prerender.js +42 -12
  5. package/dist/build/run-prerender.d.ts +10 -2
  6. package/dist/build/run-prerender.js +15 -1
  7. package/dist/client/app-nav-failure-handler.d.ts +8 -0
  8. package/dist/client/app-nav-failure-handler.js +44 -0
  9. package/dist/client/pages-router-link-navigation.d.ts +33 -7
  10. package/dist/client/pages-router-link-navigation.js +32 -2
  11. package/dist/client/vinext-next-data.d.ts +18 -1
  12. package/dist/client/vinext-next-data.js +2 -0
  13. package/dist/client/window-next.d.ts +2 -1
  14. package/dist/client/window-next.js +12 -1
  15. package/dist/cloudflare/src/cache/cdn-adapter.runtime.js +6 -1
  16. package/dist/config/config-matchers.d.ts +11 -1
  17. package/dist/config/config-matchers.js +87 -16
  18. package/dist/config/next-config.d.ts +46 -4
  19. package/dist/config/next-config.js +147 -48
  20. package/dist/config/tsconfig-paths.js +14 -1
  21. package/dist/deploy.d.ts +30 -11
  22. package/dist/deploy.js +200 -112
  23. package/dist/entries/app-browser-entry.d.ts +9 -3
  24. package/dist/entries/app-browser-entry.js +21 -3
  25. package/dist/entries/app-rsc-entry.d.ts +2 -0
  26. package/dist/entries/app-rsc-entry.js +65 -5
  27. package/dist/entries/app-rsc-manifest.js +2 -0
  28. package/dist/entries/app-ssr-entry.js +1 -1
  29. package/dist/entries/pages-client-entry.js +66 -20
  30. package/dist/entries/pages-server-entry.js +47 -31
  31. package/dist/index.js +417 -102
  32. package/dist/plugins/dynamic-preload-metadata.js +2 -4
  33. package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
  34. package/dist/plugins/extensionless-dynamic-import.js +152 -0
  35. package/dist/plugins/fonts.js +5 -4
  36. package/dist/plugins/optimize-imports.d.ts +2 -1
  37. package/dist/plugins/optimize-imports.js +11 -9
  38. package/dist/plugins/postcss.js +7 -7
  39. package/dist/plugins/strip-server-exports.d.ts +9 -7
  40. package/dist/plugins/strip-server-exports.js +493 -46
  41. package/dist/plugins/typeof-window.d.ts +14 -0
  42. package/dist/plugins/typeof-window.js +150 -0
  43. package/dist/routing/app-route-graph.d.ts +2 -1
  44. package/dist/routing/app-route-graph.js +46 -16
  45. package/dist/routing/file-matcher.d.ts +10 -1
  46. package/dist/routing/file-matcher.js +22 -1
  47. package/dist/routing/pages-router.js +3 -3
  48. package/dist/routing/utils.d.ts +35 -6
  49. package/dist/routing/utils.js +59 -7
  50. package/dist/server/api-handler.d.ts +6 -1
  51. package/dist/server/api-handler.js +21 -15
  52. package/dist/server/app-browser-action-result.d.ts +19 -6
  53. package/dist/server/app-browser-action-result.js +20 -11
  54. package/dist/server/app-browser-entry.js +175 -91
  55. package/dist/server/app-browser-error.d.ts +10 -6
  56. package/dist/server/app-browser-error.js +43 -8
  57. package/dist/server/app-browser-hydration.d.ts +2 -0
  58. package/dist/server/app-browser-hydration.js +1 -0
  59. package/dist/server/app-browser-navigation-controller.d.ts +5 -3
  60. package/dist/server/app-browser-navigation-controller.js +23 -2
  61. package/dist/server/app-browser-server-action-navigation.d.ts +6 -0
  62. package/dist/server/app-browser-server-action-navigation.js +9 -0
  63. package/dist/server/app-browser-state.d.ts +1 -1
  64. package/dist/server/app-browser-state.js +19 -11
  65. package/dist/server/app-browser-stream.js +86 -43
  66. package/dist/server/app-browser-visible-commit.d.ts +1 -1
  67. package/dist/server/app-elements-wire.d.ts +6 -1
  68. package/dist/server/app-elements-wire.js +14 -4
  69. package/dist/server/app-elements.d.ts +2 -2
  70. package/dist/server/app-elements.js +2 -2
  71. package/dist/server/app-fallback-renderer.d.ts +1 -0
  72. package/dist/server/app-fallback-renderer.js +3 -1
  73. package/dist/server/app-optimistic-routing.js +2 -2
  74. package/dist/server/app-page-boundary-render.d.ts +1 -0
  75. package/dist/server/app-page-boundary-render.js +27 -14
  76. package/dist/server/app-page-cache-render.d.ts +53 -0
  77. package/dist/server/app-page-cache-render.js +91 -0
  78. package/dist/server/app-page-cache.d.ts +16 -2
  79. package/dist/server/app-page-cache.js +62 -1
  80. package/dist/server/app-page-dispatch.d.ts +26 -0
  81. package/dist/server/app-page-dispatch.js +149 -92
  82. package/dist/server/app-page-element-builder.d.ts +1 -0
  83. package/dist/server/app-page-element-builder.js +5 -2
  84. package/dist/server/app-page-execution.d.ts +6 -1
  85. package/dist/server/app-page-execution.js +21 -1
  86. package/dist/server/app-page-probe.d.ts +1 -0
  87. package/dist/server/app-page-probe.js +4 -0
  88. package/dist/server/app-page-render-observation.d.ts +3 -1
  89. package/dist/server/app-page-render-observation.js +17 -1
  90. package/dist/server/app-page-render.d.ts +12 -1
  91. package/dist/server/app-page-render.js +42 -4
  92. package/dist/server/app-page-request.d.ts +2 -0
  93. package/dist/server/app-page-request.js +2 -1
  94. package/dist/server/app-page-route-wiring.d.ts +3 -1
  95. package/dist/server/app-page-route-wiring.js +14 -5
  96. package/dist/server/app-page-stream.d.ts +15 -3
  97. package/dist/server/app-page-stream.js +11 -5
  98. package/dist/server/app-pages-bridge.d.ts +23 -1
  99. package/dist/server/app-pages-bridge.js +26 -17
  100. package/dist/server/app-ppr-fallback-shell-render.d.ts +17 -0
  101. package/dist/server/app-ppr-fallback-shell-render.js +26 -0
  102. package/dist/server/app-ppr-fallback-shell.d.ts +13 -1
  103. package/dist/server/app-ppr-fallback-shell.js +8 -1
  104. package/dist/server/app-route-handler-dispatch.js +9 -2
  105. package/dist/server/app-route-handler-policy.d.ts +1 -0
  106. package/dist/server/app-router-entry.js +5 -0
  107. package/dist/server/app-rsc-cache-busting.js +2 -0
  108. package/dist/server/app-rsc-handler.d.ts +28 -0
  109. package/dist/server/app-rsc-handler.js +195 -59
  110. package/dist/server/app-rsc-route-matching.d.ts +3 -0
  111. package/dist/server/app-rsc-route-matching.js +8 -2
  112. package/dist/server/app-segment-config.d.ts +9 -1
  113. package/dist/server/app-segment-config.js +12 -3
  114. package/dist/server/app-server-action-execution.d.ts +1 -0
  115. package/dist/server/app-server-action-execution.js +47 -15
  116. package/dist/server/app-ssr-entry.d.ts +2 -0
  117. package/dist/server/app-ssr-entry.js +84 -39
  118. package/dist/server/before-interactive-head.d.ts +17 -0
  119. package/dist/server/before-interactive-head.js +35 -0
  120. package/dist/server/cache-control.js +4 -0
  121. package/dist/server/csp.js +1 -4
  122. package/dist/server/dev-server.d.ts +2 -2
  123. package/dist/server/dev-server.js +321 -83
  124. package/dist/server/hybrid-route-priority.d.ts +22 -0
  125. package/dist/server/hybrid-route-priority.js +33 -0
  126. package/dist/server/image-optimization.d.ts +18 -9
  127. package/dist/server/image-optimization.js +37 -23
  128. package/dist/server/implicit-tags.d.ts +2 -1
  129. package/dist/server/implicit-tags.js +4 -1
  130. package/dist/server/middleware-matcher.js +12 -3
  131. package/dist/server/middleware-runtime.d.ts +3 -4
  132. package/dist/server/middleware-runtime.js +2 -0
  133. package/dist/server/navigation-planner.d.ts +135 -41
  134. package/dist/server/navigation-planner.js +138 -0
  135. package/dist/server/navigation-trace.d.ts +9 -1
  136. package/dist/server/navigation-trace.js +9 -1
  137. package/dist/server/operation-token.d.ts +40 -0
  138. package/dist/server/operation-token.js +85 -0
  139. package/dist/server/pages-api-route.d.ts +6 -0
  140. package/dist/server/pages-api-route.js +13 -2
  141. package/dist/server/pages-asset-tags.d.ts +2 -1
  142. package/dist/server/pages-asset-tags.js +6 -2
  143. package/dist/server/pages-data-route.d.ts +9 -2
  144. package/dist/server/pages-data-route.js +18 -6
  145. package/dist/server/pages-dev-module-url.d.ts +4 -0
  146. package/dist/server/pages-dev-module-url.js +15 -0
  147. package/dist/server/pages-document-initial-props.d.ts +4 -15
  148. package/dist/server/pages-document-initial-props.js +27 -56
  149. package/dist/server/pages-get-initial-props.d.ts +54 -4
  150. package/dist/server/pages-get-initial-props.js +43 -1
  151. package/dist/server/pages-i18n.js +2 -2
  152. package/dist/server/pages-node-compat.js +2 -2
  153. package/dist/server/pages-page-data.d.ts +11 -2
  154. package/dist/server/pages-page-data.js +207 -34
  155. package/dist/server/pages-page-handler.d.ts +4 -2
  156. package/dist/server/pages-page-handler.js +62 -23
  157. package/dist/server/pages-page-response.d.ts +4 -1
  158. package/dist/server/pages-page-response.js +11 -8
  159. package/dist/server/pages-readiness.js +1 -1
  160. package/dist/server/pages-request-pipeline.d.ts +8 -7
  161. package/dist/server/pages-request-pipeline.js +126 -47
  162. package/dist/server/pregenerated-concrete-paths.d.ts +1 -17
  163. package/dist/server/pregenerated-concrete-paths.js +2 -19
  164. package/dist/server/prerender-manifest.d.ts +33 -0
  165. package/dist/server/prerender-manifest.js +54 -0
  166. package/dist/server/prerender-route-params.d.ts +1 -2
  167. package/dist/server/prod-server.d.ts +3 -1
  168. package/dist/server/prod-server.js +50 -13
  169. package/dist/server/request-pipeline.d.ts +3 -15
  170. package/dist/server/request-pipeline.js +58 -47
  171. package/dist/server/rsc-stream-hints.d.ts +5 -1
  172. package/dist/server/rsc-stream-hints.js +6 -1
  173. package/dist/server/seed-cache.js +10 -18
  174. package/dist/server/static-file-cache.js +16 -4
  175. package/dist/shims/app-router-scroll-state.d.ts +3 -1
  176. package/dist/shims/app-router-scroll-state.js +14 -2
  177. package/dist/shims/app-router-scroll.d.ts +3 -0
  178. package/dist/shims/app-router-scroll.js +28 -18
  179. package/dist/shims/before-interactive-context.d.ts +14 -3
  180. package/dist/shims/cache-runtime.js +3 -2
  181. package/dist/shims/cache.d.ts +1 -0
  182. package/dist/shims/cache.js +1 -1
  183. package/dist/shims/cdn-cache.d.ts +5 -5
  184. package/dist/shims/document.d.ts +15 -20
  185. package/dist/shims/document.js +5 -8
  186. package/dist/shims/dynamic-preload-chunks.js +6 -4
  187. package/dist/shims/error-boundary.d.ts +2 -0
  188. package/dist/shims/error-boundary.js +7 -0
  189. package/dist/shims/error.js +3 -2
  190. package/dist/shims/error.react-server.d.ts +9 -0
  191. package/dist/shims/error.react-server.js +6 -0
  192. package/dist/shims/fetch-cache.d.ts +3 -1
  193. package/dist/shims/fetch-cache.js +45 -20
  194. package/dist/shims/hash-scroll.js +6 -1
  195. package/dist/shims/headers.js +29 -4
  196. package/dist/shims/image.js +9 -2
  197. package/dist/shims/internal/als-registry.js +28 -1
  198. package/dist/shims/internal/app-route-detection.js +8 -17
  199. package/dist/shims/internal/hybrid-client-route-owner.d.ts +31 -0
  200. package/dist/shims/internal/hybrid-client-route-owner.js +143 -0
  201. package/dist/shims/internal/navigation-untracked.d.ts +35 -0
  202. package/dist/shims/internal/navigation-untracked.js +55 -0
  203. package/dist/shims/internal/pages-data-fetch-dedup.d.ts +6 -7
  204. package/dist/shims/internal/pages-data-fetch-dedup.js +67 -14
  205. package/dist/shims/internal/pages-data-target.d.ts +7 -2
  206. package/dist/shims/internal/pages-data-target.js +17 -8
  207. package/dist/shims/internal/pages-router-accessor.d.ts +19 -0
  208. package/dist/shims/internal/pages-router-accessor.js +13 -0
  209. package/dist/shims/internal/router-context.d.ts +2 -1
  210. package/dist/shims/internal/router-context.js +3 -1
  211. package/dist/shims/link.js +47 -19
  212. package/dist/shims/metadata.js +4 -4
  213. package/dist/shims/navigation.d.ts +8 -2
  214. package/dist/shims/navigation.js +63 -31
  215. package/dist/shims/ppr-fallback-shell.d.ts +5 -1
  216. package/dist/shims/ppr-fallback-shell.js +28 -7
  217. package/dist/shims/router.d.ts +18 -3
  218. package/dist/shims/router.js +512 -142
  219. package/dist/shims/script.js +8 -4
  220. package/dist/shims/server.d.ts +16 -1
  221. package/dist/shims/server.js +44 -12
  222. package/dist/shims/unified-request-context.js +1 -0
  223. package/dist/utils/built-asset-url.d.ts +4 -0
  224. package/dist/utils/built-asset-url.js +11 -0
  225. package/dist/utils/commonjs-loader.d.ts +16 -0
  226. package/dist/utils/commonjs-loader.js +100 -0
  227. package/dist/utils/deployment-id.d.ts +8 -0
  228. package/dist/utils/deployment-id.js +22 -0
  229. package/dist/utils/has-trailing-comma.d.ts +24 -0
  230. package/dist/utils/has-trailing-comma.js +62 -0
  231. package/dist/utils/html-limited-bots.d.ts +18 -1
  232. package/dist/utils/html-limited-bots.js +23 -1
  233. package/dist/utils/parse-cookie.d.ts +13 -0
  234. package/dist/utils/parse-cookie.js +52 -0
  235. package/dist/utils/path.d.ts +7 -1
  236. package/dist/utils/path.js +9 -1
  237. package/dist/utils/text-stream.d.ts +1 -1
  238. package/dist/utils/text-stream.js +2 -2
  239. package/dist/utils/vite-version.d.ts +12 -1
  240. package/dist/utils/vite-version.js +9 -1
  241. package/package.json +2 -2
  242. package/dist/shims/internal/parse-cookie-header.d.ts +0 -14
  243. package/dist/shims/internal/parse-cookie-header.js +0 -30
@@ -53,6 +53,7 @@ type CachedPagesValue = {
53
53
  kind: "PAGES";
54
54
  html: string;
55
55
  pageData: object;
56
+ generatedFromDataRequest?: boolean;
56
57
  headers: Record<string, string | string[]> | undefined;
57
58
  status: number | undefined;
58
59
  };
@@ -1,10 +1,10 @@
1
1
  import { getOrCreateAls } from "./internal/als-registry.js";
2
2
  import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation } from "./unified-request-context.js";
3
3
  import { getRequestExecutionContext, runWithExecutionContext } from "./request-context.js";
4
+ import { makeHangingPromise } from "./internal/make-hanging-promise.js";
4
5
  import { getHeadersAccessPhase, markDynamicUsage } from "./headers.js";
5
6
  import { fnv1a64 } from "../utils/hash.js";
6
7
  import { workUnitAsyncStorage } from "./internal/work-unit-async-storage.js";
7
- import { makeHangingPromise } from "./internal/make-hanging-promise.js";
8
8
  import { readCacheControlNumberField } from "../utils/cache-control-metadata.js";
9
9
  import { encodeCacheTag, encodeCacheTags } from "../utils/encode-cache-tag.js";
10
10
  import { getCdnCacheAdapter } from "./cdn-cache.js";
@@ -1,8 +1,8 @@
1
1
  import { CacheHandlerValue, IncrementalCacheValue } from "./cache.js";
2
2
 
3
3
  //#region src/shims/cdn-cache.d.ts
4
- /** A map of response header name -> value the adapter wants applied. */
5
- type CdnResponseHeaders = Record<string, string>;
4
+ /** A map of response header name -> value the adapter wants applied or removed. */
5
+ type CdnResponseHeaders = Record<string, string | null>;
6
6
  type CdnCacheableHeaderInput = {
7
7
  /**
8
8
  * The cacheable `Cache-Control` value the framework computed for shared
@@ -50,9 +50,9 @@ type CdnCacheAdapter = {
50
50
  */
51
51
  set(key: string, data: IncrementalCacheValue | null, ctx?: Record<string, unknown>): Promise<void>;
52
52
  /**
53
- * Build the response cache headers for a given cacheable policy. Returns a map
54
- * so an adapter can emit more than one header (e.g. `Cache-Control` +
55
- * `CDN-Cache-Control`).
53
+ * Build the response cache headers for a given policy. Returns a map so an
54
+ * adapter can emit more than one header (e.g. `Cache-Control` +
55
+ * `CDN-Cache-Control`) and remove stale adapter-owned headers with `null`.
56
56
  */
57
57
  buildResponseHeaders(input: CdnCacheableHeaderInput): CdnResponseHeaders;
58
58
  /**
@@ -34,25 +34,23 @@ declare function Main(): React.JSX.Element;
34
34
  */
35
35
  declare function NextScript(): React.JSX.Element;
36
36
  /**
37
- * Loose stand-ins for Next.js's `DocumentContext` / `DocumentInitialProps`.
38
- * The shim doesn't currently invoke `getInitialProps` on user `_document.tsx`
39
- * files (separate gap), but the signatures here match Next.js's so subclasses
40
- * that delegate via `await Document.getInitialProps(ctx)` typecheck against
41
- * the same shape they'd see under real Next.js.
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.
42
41
  *
43
42
  * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/utils.ts
44
43
  */
45
44
  type DocumentContext = {
46
- renderPage?: (options?: {
45
+ renderPage: (options?: {
47
46
  enhanceApp?: (App: React.ComponentType<{
48
47
  children?: React.ReactNode;
49
- }>) => unknown;
50
- enhanceComponent?: (Comp: React.ComponentType<unknown>) => unknown;
51
- }) => {
52
- html: string;
53
- head?: ReadonlyArray<React.ReactElement>;
54
- };
55
- defaultGetInitialProps?: (ctx: DocumentContext, options?: {
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?: {
56
54
  nonce?: string;
57
55
  }) => Promise<DocumentInitialProps>;
58
56
  pathname?: string;
@@ -83,14 +81,11 @@ declare class Document<P = {}> extends React.Component<P & {
83
81
  children?: React.ReactNode;
84
82
  }> {
85
83
  /**
86
- * `getInitialProps` is invoked by the SSR pipeline. The default implementation
87
- * is a stub: vinext does not yet plumb the Pages Router `renderPage` /
88
- * `defaultGetInitialProps` chain into the SSR entry, so subclasses that
89
- * delegate via `await Document.getInitialProps(ctx)` receive an empty shell
90
- * (`html: ""`). This matches the runtime contract user code expects without
91
- * pretending the chain is wired up.
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.
92
87
  */
93
- static getInitialProps(_ctx: DocumentContext): Promise<DocumentInitialProps>;
88
+ static getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps>;
94
89
  render(): React.ReactNode;
95
90
  }
96
91
  //#endregion
@@ -61,15 +61,12 @@ function NextScript() {
61
61
  */
62
62
  var Document = class extends React.Component {
63
63
  /**
64
- * `getInitialProps` is invoked by the SSR pipeline. The default implementation
65
- * is a stub: vinext does not yet plumb the Pages Router `renderPage` /
66
- * `defaultGetInitialProps` chain into the SSR entry, so subclasses that
67
- * delegate via `await Document.getInitialProps(ctx)` receive an empty shell
68
- * (`html: ""`). This matches the runtime contract user code expects without
69
- * pretending the chain is wired up.
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.
70
67
  */
71
- static async getInitialProps(_ctx) {
72
- return { html: "" };
68
+ static getInitialProps(ctx) {
69
+ return ctx.defaultGetInitialProps(ctx);
73
70
  }
74
71
  render() {
75
72
  return /* @__PURE__ */ jsxs(Html, { children: [/* @__PURE__ */ jsx(Head, {}), /* @__PURE__ */ jsxs("body", { children: [/* @__PURE__ */ jsx(Main, {}), /* @__PURE__ */ jsx(NextScript, {})] })] });
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { appendAssetDeploymentIdQuery } from "../utils/deployment-id.js";
2
3
  import { useScriptNonce } from "./script-nonce-context.js";
3
4
  import React from "react";
4
5
  import * as ReactDOM from "react-dom";
@@ -51,8 +52,9 @@ function DynamicPreloadChunks(props) {
51
52
  if (files.length === 0) return null;
52
53
  const stylesheets = [];
53
54
  for (const file of files) {
54
- const href = dynamicPreloadHref(file);
55
- if (href.endsWith(".css")) {
55
+ const assetHref = dynamicPreloadHref(file);
56
+ if (assetHref.endsWith(".css")) {
57
+ const href = appendAssetDeploymentIdQuery(assetHref);
56
58
  stylesheets.push(React.createElement("link", {
57
59
  key: href,
58
60
  rel: "stylesheet",
@@ -62,13 +64,13 @@ function DynamicPreloadChunks(props) {
62
64
  }));
63
65
  continue;
64
66
  }
65
- if (href.endsWith(".js") && typeof ReactDOM.preload === "function") {
67
+ if (assetHref.endsWith(".js") && typeof ReactDOM.preload === "function") {
66
68
  const preloadOptions = {
67
69
  as: "script",
68
70
  fetchPriority: "low",
69
71
  nonce
70
72
  };
71
- ReactDOM.preload(href, preloadOptions);
73
+ ReactDOM.preload(assetHref, preloadOptions);
72
74
  }
73
75
  }
74
76
  return stylesheets.length > 0 ? React.createElement(React.Fragment, null, ...stylesheets) : null;
@@ -17,6 +17,7 @@ type RedirectBoundaryState = {
17
17
  redirectType: "push" | "replace" | null;
18
18
  };
19
19
  type ErrorBoundaryInnerProps = {
20
+ isImplicitRootErrorBoundary?: boolean;
20
21
  pathname: string | null;
21
22
  } & ErrorBoundaryProps;
22
23
  type ErrorBoundaryState = {
@@ -131,6 +132,7 @@ declare function UnauthorizedBoundary({
131
132
  resetKey
132
133
  }: UnauthorizedBoundaryProps): React.JSX.Element;
133
134
  type DevRecoveryBoundaryProps = {
135
+ isImplicitRootErrorBoundary?: boolean;
134
136
  resetKey: number;
135
137
  onCatch?: (resetKey: number) => void;
136
138
  children?: React.ReactNode;
@@ -1,5 +1,7 @@
1
1
  "use client";
2
+ import { handleAppNavigationFailure } from "../client/app-nav-failure-handler.js";
2
3
  import { decodeRedirectError, isRedirectError, usePathname, useRouter } from "./navigation.js";
4
+ import DefaultGlobalError from "./default-global-error.js";
3
5
  import { VINEXT_DEV_ERROR_RECOVERY_EVENT } from "../utils/dev-error-recovery-event.js";
4
6
  import { isNavigationSignalError } from "../utils/navigation-signal.js";
5
7
  import React from "react";
@@ -98,6 +100,10 @@ var ErrorBoundaryInner = class extends React.Component {
98
100
  }
99
101
  static getDerivedStateFromProps(props, state) {
100
102
  const nextResetState = readBoundaryResetState(props);
103
+ if (state.error && handleAppNavigationFailure(state.error.thrownValue)) return {
104
+ error: null,
105
+ ...nextResetState
106
+ };
101
107
  if (state.error && shouldResetBoundary(nextResetState, state)) return {
102
108
  error: null,
103
109
  ...nextResetState
@@ -150,6 +156,7 @@ function GlobalErrorBoundary({ fallback, children }) {
150
156
  return /* @__PURE__ */ jsx(ErrorBoundaryInner, {
151
157
  pathname: usePathname(),
152
158
  fallback,
159
+ isImplicitRootErrorBoundary: fallback === DefaultGlobalError,
153
160
  children
154
161
  });
155
162
  }
@@ -1,6 +1,7 @@
1
1
  import { AppRouterContext } from "./internal/app-router-context.js";
2
2
  import { RouterContext } from "./internal/router-context.js";
3
- import { isNextRouterError, usePathname } from "./navigation.js";
3
+ import { isNextRouterError } from "./navigation.js";
4
+ import { useUntrackedPathname } from "./internal/navigation-untracked.js";
4
5
  import React from "react";
5
6
  //#region src/shims/error.tsx
6
7
  /**
@@ -104,7 +105,7 @@ function unstable_catchError(fallback) {
104
105
  Fallback.displayName = fallback.name || "CatchErrorFallback";
105
106
  function CatchErrorBoundary(allProps) {
106
107
  const { children, ...rest } = allProps;
107
- const pathname = usePathname();
108
+ const pathname = useUntrackedPathname();
108
109
  const isPagesRouter = React.useContext(RouterContext) !== null;
109
110
  const forwardedProps = rest;
110
111
  return React.createElement(_CatchError, {
@@ -0,0 +1,9 @@
1
+ //#region src/shims/error.react-server.d.ts
2
+ type ErrorInfo = {
3
+ error: unknown;
4
+ reset: () => void;
5
+ unstable_retry: () => void;
6
+ };
7
+ declare function unstable_catchError(): never;
8
+ //#endregion
9
+ export { ErrorInfo, unstable_catchError };
@@ -0,0 +1,6 @@
1
+ //#region src/shims/error.react-server.ts
2
+ function unstable_catchError() {
3
+ throw new Error("`unstable_catchError` can only be used in Client Components.");
4
+ }
5
+ //#endregion
6
+ export { unstable_catchError };
@@ -40,6 +40,7 @@ type FetchCacheState = {
40
40
  currentRequestTags: string[];
41
41
  currentFetchSoftTags: string[];
42
42
  currentFetchCacheMode: FetchCacheMode | null;
43
+ currentForceDynamicFetchDefault: boolean;
43
44
  dynamicFetchUrls: Set<string>;
44
45
  isFetchDedupeActive: boolean;
45
46
  currentFetchDedupeEntries: Map<string, FetchDedupeEntry[]>;
@@ -84,6 +85,7 @@ declare function setCurrentFetchSoftTags(tags: string[]): void;
84
85
  */
85
86
  declare function getCurrentFetchSoftTags(): string[];
86
87
  declare function setCurrentFetchCacheMode(mode: FetchCacheMode | null): void;
88
+ declare function setCurrentForceDynamicFetchDefault(enabled: boolean): void;
87
89
  /**
88
90
  * Install the patched fetch and reset per-request tag state.
89
91
  * Returns a cleanup function that clears tags.
@@ -131,4 +133,4 @@ declare function ensureFetchPatch(): void;
131
133
  */
132
134
  declare function getOriginalFetch(): typeof globalThis.fetch;
133
135
  //#endregion
134
- export { FetchCacheMode, FetchCacheState, _resetPendingRefetches, addCollectedRequestTags, consumeDynamicFetchObservations, ensureFetchPatch, getCollectedFetchTags, getCurrentFetchSoftTags, getOriginalFetch, peekCacheableFetchObservations, peekDynamicFetchObservations, runWithFetchCache, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchSoftTags, withFetchCache };
136
+ export { FetchCacheMode, FetchCacheState, _resetPendingRefetches, addCollectedRequestTags, consumeDynamicFetchObservations, ensureFetchPatch, getCollectedFetchTags, getCurrentFetchSoftTags, getOriginalFetch, peekCacheableFetchObservations, peekDynamicFetchObservations, runWithFetchCache, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchSoftTags, setCurrentForceDynamicFetchDefault, withFetchCache };
@@ -1,6 +1,7 @@
1
1
  import { getOrCreateAls } from "./internal/als-registry.js";
2
2
  import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation } from "./unified-request-context.js";
3
3
  import { getRequestExecutionContext } from "./request-context.js";
4
+ import { markDynamicUsage } from "./headers.js";
4
5
  import { encodeCacheTags } from "../utils/encode-cache-tag.js";
5
6
  import { getDataCacheHandler } from "./cache.js";
6
7
  //#region src/shims/fetch-cache.ts
@@ -32,6 +33,7 @@ import { getDataCacheHandler } from "./cache.js";
32
33
  const HEADER_BLOCKLIST = ["traceparent", "tracestate"];
33
34
  const CACHE_KEY_PREFIX = "v3";
34
35
  const MAX_CACHE_KEY_BODY_BYTES = 1024 * 1024;
36
+ const ONE_YEAR_SECONDS = 31536e3;
35
37
  var BodyTooLargeForCacheKeyError = class extends Error {
36
38
  constructor() {
37
39
  super("Fetch body too large for cache key generation");
@@ -292,6 +294,7 @@ const _fallbackState = _g[_FALLBACK_KEY] ??= {
292
294
  currentRequestTags: [],
293
295
  currentFetchSoftTags: [],
294
296
  currentFetchCacheMode: null,
297
+ currentForceDynamicFetchDefault: false,
295
298
  dynamicFetchUrls: /* @__PURE__ */ new Set(),
296
299
  isFetchDedupeActive: false,
297
300
  currentFetchDedupeEntries: /* @__PURE__ */ new Map()
@@ -309,6 +312,7 @@ function _resetFallbackState(isFetchDedupeActive) {
309
312
  _fallbackState.currentRequestTags = [];
310
313
  _fallbackState.currentFetchSoftTags = [];
311
314
  _fallbackState.currentFetchCacheMode = null;
315
+ _fallbackState.currentForceDynamicFetchDefault = false;
312
316
  _fallbackState.dynamicFetchUrls = /* @__PURE__ */ new Set();
313
317
  _fallbackState.isFetchDedupeActive = isFetchDedupeActive;
314
318
  _fallbackState.currentFetchDedupeEntries = /* @__PURE__ */ new Map();
@@ -319,6 +323,10 @@ function getFetchObservationUrl(input) {
319
323
  function recordDynamicFetchObservation(input) {
320
324
  _getState().dynamicFetchUrls.add(getFetchObservationUrl(input));
321
325
  }
326
+ function markUncachedFetchForPageOutput(input) {
327
+ recordDynamicFetchObservation(input);
328
+ markDynamicUsage();
329
+ }
322
330
  function recordCacheableFetchObservation(input) {
323
331
  _getState().cacheableFetchUrls.add(getFetchObservationUrl(input));
324
332
  }
@@ -382,16 +390,23 @@ function getCurrentFetchSoftTags() {
382
390
  function setCurrentFetchCacheMode(mode) {
383
391
  _getState().currentFetchCacheMode = mode;
384
392
  }
393
+ function setCurrentForceDynamicFetchDefault(enabled) {
394
+ _getState().currentForceDynamicFetchDefault = enabled;
395
+ }
385
396
  function isNoStoreFetch(cacheDirective, nextOpts) {
386
- return cacheDirective === "no-store" || cacheDirective === "no-cache" || nextOpts?.revalidate === false || nextOpts?.revalidate === 0;
397
+ return cacheDirective === "no-store" || cacheDirective === "no-cache" || nextOpts?.revalidate === 0;
387
398
  }
388
399
  function isCacheableFetch(cacheDirective, nextOpts) {
389
- return cacheDirective === "force-cache" || typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0;
400
+ return cacheDirective === "force-cache" || nextOpts?.revalidate === false || typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0;
390
401
  }
391
402
  function hasExplicitRevalidateValue(nextOpts) {
392
403
  return nextOpts?.revalidate !== void 0;
393
404
  }
394
- function resolveSegmentCacheDirective(cacheDirective, nextOpts, mode) {
405
+ function isFalsyRevalidate(nextOpts) {
406
+ return !nextOpts?.revalidate;
407
+ }
408
+ function resolveSegmentCacheDirective(cacheDirective, nextOpts, mode, forceDynamicFetchDefault) {
409
+ if (forceDynamicFetchDefault && (!mode || mode === "auto") && (cacheDirective === void 0 || cacheDirective === "default") && isFalsyRevalidate(nextOpts)) return "no-store";
395
410
  if (!mode || mode === "auto") return cacheDirective;
396
411
  switch (mode) {
397
412
  case "force-cache": return "force-cache";
@@ -457,6 +472,20 @@ function cloneDedupeResponse(response) {
457
472
  const [body1, body2] = response.body.tee();
458
473
  return [buildDedupeClone(body1, response), buildDedupeClone(body2, response)];
459
474
  }
475
+ function buildCachedFetchResponse(data, input) {
476
+ const response = new Response(data.body, {
477
+ status: data.status ?? 200,
478
+ headers: data.headers
479
+ });
480
+ Object.defineProperty(response, "url", {
481
+ value: data.url ?? getFetchObservationUrl(input),
482
+ configurable: true,
483
+ enumerable: true,
484
+ writable: false
485
+ });
486
+ if (_responseBodyRegistry && response.body) _responseBodyRegistry.register(response, new WeakRef(response.body));
487
+ return response;
488
+ }
460
489
  function dedupeFetch(input, init) {
461
490
  const state = _getState();
462
491
  if (!state.isFetchDedupeActive) return originalFetch(input, init);
@@ -507,25 +536,26 @@ function dedupeFetch(input, init) {
507
536
  function createPatchedFetch() {
508
537
  return async function patchedFetch(input, init) {
509
538
  const nextOpts = init?.next;
510
- const cacheDirective = resolveSegmentCacheDirective(getFetchCacheDirective(input, init), nextOpts, _getState().currentFetchCacheMode);
539
+ const cacheDirective = resolveSegmentCacheDirective(getFetchCacheDirective(input, init), nextOpts, _getState().currentFetchCacheMode, _getState().currentForceDynamicFetchDefault);
511
540
  if (!nextOpts && !cacheDirective) {
512
541
  recordDynamicFetchObservation(input);
513
542
  return dedupeFetch(input, init);
514
543
  }
515
- if (cacheDirective === "no-store" || cacheDirective === "no-cache" || nextOpts?.revalidate === false || nextOpts?.revalidate === 0) {
544
+ if (cacheDirective === "no-store" || cacheDirective === "no-cache" || nextOpts?.revalidate === 0) {
516
545
  const cleanInit = stripNextFromInit(init, cacheDirective);
517
- recordDynamicFetchObservation(input);
546
+ markUncachedFetchForPageOutput(input);
518
547
  return dedupeFetch(input, cleanInit);
519
548
  }
520
- if (!(cacheDirective === "force-cache" || typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0) && hasAuthHeaders(input, init)) {
549
+ if (!(cacheDirective === "force-cache" || nextOpts?.revalidate === false || typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0) && hasAuthHeaders(input, init)) {
521
550
  const cleanInit = stripNextFromInit(init, cacheDirective);
522
551
  recordDynamicFetchObservation(input);
523
552
  return dedupeFetch(input, cleanInit);
524
553
  }
525
554
  let revalidateSeconds;
526
- if (cacheDirective === "force-cache") revalidateSeconds = nextOpts?.revalidate && typeof nextOpts.revalidate === "number" ? nextOpts.revalidate : 31536e3;
555
+ if (cacheDirective === "force-cache") revalidateSeconds = nextOpts?.revalidate && typeof nextOpts.revalidate === "number" ? nextOpts.revalidate : ONE_YEAR_SECONDS;
556
+ else if (nextOpts?.revalidate === false) revalidateSeconds = ONE_YEAR_SECONDS;
527
557
  else if (typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0) revalidateSeconds = nextOpts.revalidate;
528
- else if (nextOpts?.tags && nextOpts.tags.length > 0) revalidateSeconds = 31536e3;
558
+ else if (nextOpts?.tags && nextOpts.tags.length > 0) revalidateSeconds = ONE_YEAR_SECONDS;
529
559
  else {
530
560
  const cleanInit = stripNextFromInit(init, cacheDirective);
531
561
  recordDynamicFetchObservation(input);
@@ -560,10 +590,7 @@ function createPatchedFetch() {
560
590
  });
561
591
  if (cached?.value && cached.value.kind === "FETCH" && cached.cacheState !== "stale") {
562
592
  const cachedData = cached.value.data;
563
- return new Response(cachedData.body, {
564
- status: cachedData.status ?? 200,
565
- headers: cachedData.headers
566
- });
593
+ return buildCachedFetchResponse(cachedData, input);
567
594
  }
568
595
  if (cached?.value && cached.value.kind === "FETCH" && cached.cacheState === "stale") {
569
596
  const staleData = cached.value.data;
@@ -581,7 +608,7 @@ function createPatchedFetch() {
581
608
  data: {
582
609
  headers: freshHeaders,
583
610
  body: freshBody,
584
- url: typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url,
611
+ url: freshResp.url,
585
612
  status: freshResp.status
586
613
  },
587
614
  tags,
@@ -605,10 +632,7 @@ function createPatchedFetch() {
605
632
  }, DEDUP_TIMEOUT_MS);
606
633
  getRequestExecutionContext()?.waitUntil(refetchPromise);
607
634
  }
608
- return new Response(staleData.body, {
609
- status: staleData.status ?? 200,
610
- headers: staleData.headers
611
- });
635
+ return buildCachedFetchResponse(staleData, input);
612
636
  }
613
637
  } catch (cacheErr) {
614
638
  console.error("[vinext] fetch cache read error:", cacheErr);
@@ -627,7 +651,7 @@ function createPatchedFetch() {
627
651
  data: {
628
652
  headers,
629
653
  body,
630
- url: typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url,
654
+ url: response.url,
631
655
  status: cloned.status
632
656
  },
633
657
  tags,
@@ -700,6 +724,7 @@ async function runWithFetchCache(fn) {
700
724
  currentRequestTags: [],
701
725
  currentFetchSoftTags: [],
702
726
  currentFetchCacheMode: null,
727
+ currentForceDynamicFetchDefault: false,
703
728
  dynamicFetchUrls: /* @__PURE__ */ new Set(),
704
729
  isFetchDedupeActive: true,
705
730
  currentFetchDedupeEntries: /* @__PURE__ */ new Map()
@@ -738,4 +763,4 @@ function getOriginalFetch() {
738
763
  return originalFetch;
739
764
  }
740
765
  //#endregion
741
- export { _resetPendingRefetches, addCollectedRequestTags, consumeDynamicFetchObservations, ensureFetchPatch, getCollectedFetchTags, getCurrentFetchSoftTags, getOriginalFetch, peekCacheableFetchObservations, peekDynamicFetchObservations, runWithFetchCache, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchSoftTags, withFetchCache };
766
+ export { _resetPendingRefetches, addCollectedRequestTags, consumeDynamicFetchObservations, ensureFetchPatch, getCollectedFetchTags, getCurrentFetchSoftTags, getOriginalFetch, peekCacheableFetchObservations, peekDynamicFetchObservations, runWithFetchCache, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchSoftTags, setCurrentForceDynamicFetchDefault, withFetchCache };
@@ -17,7 +17,12 @@ function scrollToHashTarget(hash) {
17
17
  idElement.scrollIntoView({ behavior: "auto" });
18
18
  return;
19
19
  }
20
- document.getElementsByName(fragment)[0]?.scrollIntoView({ behavior: "auto" });
20
+ const namedElement = document.getElementsByName(fragment)[0];
21
+ if (namedElement) {
22
+ namedElement.scrollIntoView({ behavior: "auto" });
23
+ return;
24
+ }
25
+ window.scrollTo(0, 0);
21
26
  }
22
27
  function scrollToHashTargetOnNextFrame(hash) {
23
28
  requestAnimationFrame(() => {
@@ -3,7 +3,8 @@ import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation }
3
3
  import { MIDDLEWARE_SET_COOKIE_HEADER } from "../server/headers.js";
4
4
  import { buildRequestHeadersFromMiddlewareResponse } from "../server/middleware-request-headers.js";
5
5
  import { serializeSetCookie, validateCookieAttributeValue, validateCookieName } from "./internal/cookie-serialize.js";
6
- import { parseCookieHeader } from "./internal/parse-cookie-header.js";
6
+ import { parseEdgeRequestCookieHeader } from "../utils/parse-cookie.js";
7
+ import { createPprFallbackShellSuspensePromise } from "./ppr-fallback-shell.js";
7
8
  //#region src/shims/headers.ts
8
9
  /**
9
10
  * next/headers shim
@@ -81,7 +82,7 @@ function setCookieNameValue(setCookie) {
81
82
  function rebuildCookiesFromHeader(ctx, cookieHeader) {
82
83
  ctx.cookies.clear();
83
84
  if (cookieHeader === null) return;
84
- const nextCookies = parseCookieHeader(cookieHeader);
85
+ const nextCookies = parseEdgeRequestCookieHeader(cookieHeader);
85
86
  for (const [name, value] of nextCookies) ctx.cookies.set(name, value);
86
87
  }
87
88
  function mergeMiddlewareSetCookies(ctx, rawHeader) {
@@ -414,6 +415,26 @@ function _decorateRejectedRequestApiPromise(error) {
414
415
  throw normalizedError;
415
416
  } }));
416
417
  }
418
+ function _decorateSuspendingRequestApiPromise(promise) {
419
+ return new Proxy(promise, {
420
+ get(promiseTarget, prop) {
421
+ if (prop === "then" || prop === "catch" || prop === "finally") {
422
+ const value = Reflect.get(promiseTarget, prop, promiseTarget);
423
+ return typeof value === "function" ? value.bind(promiseTarget) : value;
424
+ }
425
+ throw promise;
426
+ },
427
+ getOwnPropertyDescriptor() {
428
+ throw promise;
429
+ },
430
+ has() {
431
+ throw promise;
432
+ },
433
+ ownKeys() {
434
+ throw promise;
435
+ }
436
+ });
437
+ }
417
438
  function _sealHeaders(headers) {
418
439
  return new Proxy(headers, { get(target, prop) {
419
440
  if (typeof prop === "string" && _HEADERS_MUTATING_METHODS.has(prop)) throw new ReadonlyHeadersError();
@@ -485,7 +506,7 @@ function headersContextFromRequest(request, options) {
485
506
  let _cookies = null;
486
507
  function getCookies() {
487
508
  if (_cookies) return _cookies;
488
- _cookies = parseCookieHeader(headersProxy.get("cookie") || "");
509
+ _cookies = parseEdgeRequestCookieHeader(headersProxy.get("cookie") || "");
489
510
  return _cookies;
490
511
  }
491
512
  return {
@@ -512,6 +533,8 @@ function headers() {
512
533
  if (!state.headersContext) return _decorateRejectedRequestApiPromise(/* @__PURE__ */ new Error("headers() can only be called from a Server Component, Route Handler, or Server Action. Make sure you're not calling it from a Client Component."));
513
534
  if (state.headersContext.accessError) return _decorateRejectedRequestApiPromise(state.headersContext.accessError);
514
535
  markDynamicUsage();
536
+ const fallbackShellPromise = createPprFallbackShellSuspensePromise("`headers()`");
537
+ if (fallbackShellPromise) return _decorateSuspendingRequestApiPromise(fallbackShellPromise);
515
538
  return _getOrCreateDecoratedRequestApiPromise(_decoratedHeadersPromises, _getReadonlyHeaders(state.headersContext));
516
539
  }
517
540
  /**
@@ -529,6 +552,8 @@ function cookies() {
529
552
  if (!state.headersContext) return _decorateRejectedRequestApiPromise(/* @__PURE__ */ new Error("cookies() can only be called from a Server Component, Route Handler, or Server Action."));
530
553
  if (state.headersContext.accessError) return _decorateRejectedRequestApiPromise(state.headersContext.accessError);
531
554
  markDynamicUsage();
555
+ const fallbackShellPromise = createPprFallbackShellSuspensePromise("`cookies()`");
556
+ if (fallbackShellPromise) return _decorateSuspendingRequestApiPromise(fallbackShellPromise);
532
557
  return _getOrCreateDecoratedRequestApiPromise(_decoratedCookiesPromises, _areCookiesMutableInCurrentPhase() ? _getMutableCookies(state.headersContext) : _getReadonlyCookies(state.headersContext));
533
558
  }
534
559
  /** Accumulated Set-Cookie headers from cookies().set() / .delete() calls */
@@ -572,7 +597,7 @@ function ensureContextDraftModeSecret(ctx) {
572
597
  function isDraftModeRequest(request, draftModeSecret) {
573
598
  const cookieHeader = request.headers.get("cookie");
574
599
  if (!cookieHeader) return false;
575
- return parseCookieHeader(cookieHeader).get(DRAFT_MODE_COOKIE) === validateDraftModeSecret(draftModeSecret);
600
+ return parseEdgeRequestCookieHeader(cookieHeader).get(DRAFT_MODE_COOKIE) === validateDraftModeSecret(draftModeSecret);
576
601
  }
577
602
  function draftModeCookieAttributes() {
578
603
  if (typeof process !== "undefined" && process.env?.NODE_ENV === "development") return "Path=/; HttpOnly; SameSite=Lax";
@@ -175,6 +175,13 @@ function sanitizeBlurDataURL(url) {
175
175
  function isRemoteUrl(src) {
176
176
  return src.startsWith("http://") || src.startsWith("https://") || src.startsWith("//");
177
177
  }
178
+ function isSvgUrl(src) {
179
+ try {
180
+ return new URL(src, "http://vinext.local").pathname.toLowerCase().endsWith(".svg");
181
+ } catch {
182
+ return false;
183
+ }
184
+ }
178
185
  function getFillStyle(style, backgroundStyle) {
179
186
  return {
180
187
  position: "absolute",
@@ -414,7 +421,7 @@ const Image = forwardRef(function Image({ src: srcProp, alt, width, height, fill
414
421
  }
415
422
  }
416
423
  const imgQuality = quality ?? 75;
417
- const isSvg = src.endsWith(".svg");
424
+ const isSvg = isSvgUrl(src);
418
425
  const skipOptimization = _unoptimized === true || isSvg && !__dangerouslyAllowSVG;
419
426
  const srcSet = imgWidth && !fill && !skipOptimization ? generateSrcSet(src, imgWidth, imgQuality) : imgWidth && !fill ? RESPONSIVE_WIDTHS.filter((w) => w <= imgWidth * 2).map((w) => `${src} ${w}w`).join(", ") || `${src} ${imgWidth}w` : void 0;
420
427
  const optimizedSrc = skipOptimization ? src : imgWidth ? imageOptimizationUrl(src, imgWidth, imgQuality) : imageOptimizationUrl(src, RESPONSIVE_WIDTHS[0], imgQuality);
@@ -483,7 +490,7 @@ function getImageProps(props) {
483
490
  width: imgWidth ?? 0,
484
491
  quality: imgQuality
485
492
  }) : src;
486
- const isSvg = resolvedSrc.endsWith(".svg");
493
+ const isSvg = isSvgUrl(resolvedSrc);
487
494
  const skipOpt = _unoptimized === true || isSvg && !__dangerouslyAllowSVG || blockedInProd || !!loader || isRemoteUrl(resolvedSrc);
488
495
  const optimizedSrc = skipOpt ? resolvedSrc : imgWidth ? imageOptimizationUrl(resolvedSrc, imgWidth, imgQuality) : imageOptimizationUrl(resolvedSrc, RESPONSIVE_WIDTHS[0], imgQuality);
489
496
  const srcSet = imgWidth && !fill && !isRemoteUrl(resolvedSrc) && !loader && !skipOpt ? generateSrcSet(resolvedSrc, imgWidth, imgQuality) : void 0;
@@ -38,6 +38,33 @@ import { AsyncLocalStorage } from "node:async_hooks";
38
38
  */
39
39
  const _g = globalThis;
40
40
  /**
41
+ * No-op AsyncLocalStorage used when the runtime does not provide a usable
42
+ * `AsyncLocalStorage` constructor.
43
+ *
44
+ * In browser/client bundles `node:async_hooks` can resolve to a stub without a
45
+ * usable constructor (e.g. Vite's `__vite-browser-external`). Constructing such
46
+ * a value with `new` throws `TypeError: AsyncLocalStorage is not a constructor`
47
+ * at module-eval time, crashing every client-reachable shim that calls
48
+ * `getOrCreateAls` on import (request-context, headers, cache, …).
49
+ *
50
+ * Mirrors Next.js' `FakeAsyncLocalStorage` (and this repo's
51
+ * `async-hooks-stub.ts` client virtual module): `getStore()` returns
52
+ * `undefined` so shims fall back to their non-ALS code path, and the mutating
53
+ * methods are best-effort no-ops that still invoke the callback.
54
+ * See: https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/async-local-storage.ts
55
+ */
56
+ var NoopAsyncLocalStorage = class {
57
+ getStore() {}
58
+ run(_store, fn, ...args) {
59
+ return fn(...args);
60
+ }
61
+ exit(fn, ...args) {
62
+ return fn(...args);
63
+ }
64
+ enterWith(_store) {}
65
+ disable() {}
66
+ };
67
+ /**
41
68
  * Get (or lazily create) the AsyncLocalStorage registered on `globalThis`
42
69
  * under `Symbol.for(key)`. Multiple callers — including callers in different
43
70
  * module instances — that pass the same `key` receive the same ALS instance.
@@ -47,7 +74,7 @@ const _g = globalThis;
47
74
  */
48
75
  function getOrCreateAls(key) {
49
76
  const sym = Symbol.for(key);
50
- return _g[sym] ??= new AsyncLocalStorage();
77
+ return _g[sym] ??= typeof AsyncLocalStorage === "function" ? new AsyncLocalStorage() : new NoopAsyncLocalStorage();
51
78
  }
52
79
  //#endregion
53
80
  export { getOrCreateAls };