vinext 0.0.50 → 0.0.51

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 (309) hide show
  1. package/dist/build/google-fonts/fallback-metrics-data.js +14031 -0
  2. package/dist/build/google-fonts/fallback-metrics-data.js.map +1 -0
  3. package/dist/build/google-fonts/fallback-metrics.d.ts +13 -0
  4. package/dist/build/google-fonts/fallback-metrics.js +46 -0
  5. package/dist/build/google-fonts/fallback-metrics.js.map +1 -0
  6. package/dist/build/precompress.d.ts +13 -2
  7. package/dist/build/precompress.js +12 -3
  8. package/dist/build/precompress.js.map +1 -1
  9. package/dist/build/prerender.d.ts +1 -1
  10. package/dist/build/prerender.js +44 -14
  11. package/dist/build/prerender.js.map +1 -1
  12. package/dist/build/report.d.ts +5 -4
  13. package/dist/build/report.js +196 -348
  14. package/dist/build/report.js.map +1 -1
  15. package/dist/check.js +1 -0
  16. package/dist/check.js.map +1 -1
  17. package/dist/cli.js +60 -3
  18. package/dist/cli.js.map +1 -1
  19. package/dist/client/window-next.d.ts +3 -1
  20. package/dist/client/window-next.js.map +1 -1
  21. package/dist/config/dotenv.d.ts +11 -1
  22. package/dist/config/dotenv.js.map +1 -1
  23. package/dist/config/next-config.d.ts +87 -3
  24. package/dist/config/next-config.js +222 -6
  25. package/dist/config/next-config.js.map +1 -1
  26. package/dist/config/tsconfig-paths.d.ts +13 -0
  27. package/dist/config/tsconfig-paths.js +117 -0
  28. package/dist/config/tsconfig-paths.js.map +1 -0
  29. package/dist/deploy.js +3 -2
  30. package/dist/deploy.js.map +1 -1
  31. package/dist/entries/app-browser-entry.d.ts +2 -2
  32. package/dist/entries/app-browser-entry.js +26 -1
  33. package/dist/entries/app-browser-entry.js.map +1 -1
  34. package/dist/entries/app-rsc-entry.d.ts +19 -1
  35. package/dist/entries/app-rsc-entry.js +38 -12
  36. package/dist/entries/app-rsc-entry.js.map +1 -1
  37. package/dist/entries/app-rsc-manifest.d.ts +9 -0
  38. package/dist/entries/app-rsc-manifest.js +4 -1
  39. package/dist/entries/app-rsc-manifest.js.map +1 -1
  40. package/dist/entries/pages-client-entry.js +3 -5
  41. package/dist/entries/pages-client-entry.js.map +1 -1
  42. package/dist/entries/pages-server-entry.js +19 -1
  43. package/dist/entries/pages-server-entry.js.map +1 -1
  44. package/dist/index.js +130 -37
  45. package/dist/index.js.map +1 -1
  46. package/dist/plugins/client-reference-dedup.d.ts +15 -2
  47. package/dist/plugins/client-reference-dedup.js +138 -16
  48. package/dist/plugins/client-reference-dedup.js.map +1 -1
  49. package/dist/plugins/fonts.d.ts +2 -2
  50. package/dist/plugins/fonts.js +15 -6
  51. package/dist/plugins/fonts.js.map +1 -1
  52. package/dist/plugins/sass.d.ts +34 -0
  53. package/dist/plugins/sass.js +22 -0
  54. package/dist/plugins/sass.js.map +1 -0
  55. package/dist/routing/app-route-graph.d.ts +31 -2
  56. package/dist/routing/app-route-graph.js +82 -10
  57. package/dist/routing/app-route-graph.js.map +1 -1
  58. package/dist/routing/route-pattern.d.ts +56 -1
  59. package/dist/routing/route-pattern.js +60 -1
  60. package/dist/routing/route-pattern.js.map +1 -1
  61. package/dist/server/app-browser-action-result.d.ts +27 -2
  62. package/dist/server/app-browser-action-result.js +63 -2
  63. package/dist/server/app-browser-action-result.js.map +1 -1
  64. package/dist/server/app-browser-entry.js +262 -108
  65. package/dist/server/app-browser-entry.js.map +1 -1
  66. package/dist/server/app-browser-hydration.d.ts +13 -1
  67. package/dist/server/app-browser-hydration.js +9 -1
  68. package/dist/server/app-browser-hydration.js.map +1 -1
  69. package/dist/server/app-browser-navigation-controller.d.ts +14 -1
  70. package/dist/server/app-browser-navigation-controller.js +28 -9
  71. package/dist/server/app-browser-navigation-controller.js.map +1 -1
  72. package/dist/server/app-browser-popstate.d.ts +16 -0
  73. package/dist/server/app-browser-popstate.js +17 -0
  74. package/dist/server/app-browser-popstate.js.map +1 -0
  75. package/dist/server/app-browser-rsc-redirect.d.ts +28 -0
  76. package/dist/server/app-browser-rsc-redirect.js +37 -0
  77. package/dist/server/app-browser-rsc-redirect.js.map +1 -0
  78. package/dist/server/app-browser-state.d.ts +11 -7
  79. package/dist/server/app-browser-state.js +45 -27
  80. package/dist/server/app-browser-state.js.map +1 -1
  81. package/dist/server/app-browser-stream.d.ts +5 -4
  82. package/dist/server/app-browser-stream.js +5 -6
  83. package/dist/server/app-browser-stream.js.map +1 -1
  84. package/dist/server/app-browser-visible-commit.d.ts +5 -0
  85. package/dist/server/app-browser-visible-commit.js +38 -5
  86. package/dist/server/app-browser-visible-commit.js.map +1 -1
  87. package/dist/server/app-elements-wire.d.ts +38 -6
  88. package/dist/server/app-elements-wire.js +106 -6
  89. package/dist/server/app-elements-wire.js.map +1 -1
  90. package/dist/server/app-elements.d.ts +2 -2
  91. package/dist/server/app-elements.js +2 -2
  92. package/dist/server/app-elements.js.map +1 -1
  93. package/dist/server/app-fallback-renderer.d.ts +10 -1
  94. package/dist/server/app-fallback-renderer.js +37 -1
  95. package/dist/server/app-fallback-renderer.js.map +1 -1
  96. package/dist/server/app-history-state.d.ts +26 -0
  97. package/dist/server/app-history-state.js +53 -0
  98. package/dist/server/app-history-state.js.map +1 -0
  99. package/dist/server/app-page-boundary-render.d.ts +10 -1
  100. package/dist/server/app-page-boundary-render.js +13 -6
  101. package/dist/server/app-page-boundary-render.js.map +1 -1
  102. package/dist/server/app-page-boundary.js +3 -2
  103. package/dist/server/app-page-boundary.js.map +1 -1
  104. package/dist/server/app-page-cache.d.ts +13 -0
  105. package/dist/server/app-page-cache.js +25 -8
  106. package/dist/server/app-page-cache.js.map +1 -1
  107. package/dist/server/app-page-dispatch.d.ts +5 -0
  108. package/dist/server/app-page-dispatch.js +68 -11
  109. package/dist/server/app-page-dispatch.js.map +1 -1
  110. package/dist/server/app-page-element-builder.d.ts +7 -0
  111. package/dist/server/app-page-element-builder.js +32 -4
  112. package/dist/server/app-page-element-builder.js.map +1 -1
  113. package/dist/server/app-page-execution.js +2 -3
  114. package/dist/server/app-page-execution.js.map +1 -1
  115. package/dist/server/app-page-head.d.ts +7 -0
  116. package/dist/server/app-page-head.js +2 -1
  117. package/dist/server/app-page-head.js.map +1 -1
  118. package/dist/server/app-page-probe.d.ts +23 -1
  119. package/dist/server/app-page-probe.js +29 -1
  120. package/dist/server/app-page-probe.js.map +1 -1
  121. package/dist/server/app-page-render-observation.d.ts +35 -0
  122. package/dist/server/app-page-render-observation.js +68 -0
  123. package/dist/server/app-page-render-observation.js.map +1 -0
  124. package/dist/server/app-page-render.d.ts +5 -1
  125. package/dist/server/app-page-render.js +79 -3
  126. package/dist/server/app-page-render.js.map +1 -1
  127. package/dist/server/app-page-request.d.ts +1 -0
  128. package/dist/server/app-page-request.js.map +1 -1
  129. package/dist/server/app-page-response.js +3 -2
  130. package/dist/server/app-page-response.js.map +1 -1
  131. package/dist/server/app-page-route-wiring.d.ts +3 -1
  132. package/dist/server/app-page-route-wiring.js +42 -14
  133. package/dist/server/app-page-route-wiring.js.map +1 -1
  134. package/dist/server/app-page-stream.d.ts +2 -0
  135. package/dist/server/app-page-stream.js +1 -0
  136. package/dist/server/app-page-stream.js.map +1 -1
  137. package/dist/server/app-router-entry.js +1 -13
  138. package/dist/server/app-router-entry.js.map +1 -1
  139. package/dist/server/app-rsc-cache-busting.d.ts +19 -1
  140. package/dist/server/app-rsc-cache-busting.js +36 -1
  141. package/dist/server/app-rsc-cache-busting.js.map +1 -1
  142. package/dist/server/app-rsc-embedded-chunks.d.ts +9 -0
  143. package/dist/server/app-rsc-embedded-chunks.js +34 -0
  144. package/dist/server/app-rsc-embedded-chunks.js.map +1 -0
  145. package/dist/server/app-rsc-errors.d.ts +4 -1
  146. package/dist/server/app-rsc-errors.js +1 -1
  147. package/dist/server/app-rsc-errors.js.map +1 -1
  148. package/dist/server/app-rsc-handler.d.ts +12 -4
  149. package/dist/server/app-rsc-handler.js +6 -1
  150. package/dist/server/app-rsc-handler.js.map +1 -1
  151. package/dist/server/app-rsc-route-matching.d.ts +23 -0
  152. package/dist/server/app-rsc-route-matching.js +45 -23
  153. package/dist/server/app-rsc-route-matching.js.map +1 -1
  154. package/dist/server/app-server-action-execution.d.ts +35 -3
  155. package/dist/server/app-server-action-execution.js +87 -33
  156. package/dist/server/app-server-action-execution.js.map +1 -1
  157. package/dist/server/app-ssr-entry.d.ts +1 -0
  158. package/dist/server/app-ssr-entry.js +37 -13
  159. package/dist/server/app-ssr-entry.js.map +1 -1
  160. package/dist/server/app-ssr-error-meta.d.ts +14 -0
  161. package/dist/server/app-ssr-error-meta.js +50 -0
  162. package/dist/server/app-ssr-error-meta.js.map +1 -0
  163. package/dist/server/app-ssr-stream.d.ts +1 -1
  164. package/dist/server/app-ssr-stream.js +9 -12
  165. package/dist/server/app-ssr-stream.js.map +1 -1
  166. package/dist/server/artifact-compatibility.d.ts +12 -2
  167. package/dist/server/artifact-compatibility.js +12 -8
  168. package/dist/server/artifact-compatibility.js.map +1 -1
  169. package/dist/server/cache-proof.d.ts +124 -5
  170. package/dist/server/cache-proof.js +416 -18
  171. package/dist/server/cache-proof.js.map +1 -1
  172. package/dist/server/dev-lockfile.d.ts +110 -0
  173. package/dist/server/dev-lockfile.js +180 -0
  174. package/dist/server/dev-lockfile.js.map +1 -0
  175. package/dist/server/dev-server.js +15 -5
  176. package/dist/server/dev-server.js.map +1 -1
  177. package/dist/server/file-based-metadata.d.ts +13 -0
  178. package/dist/server/file-based-metadata.js +49 -2
  179. package/dist/server/file-based-metadata.js.map +1 -1
  180. package/dist/server/headers.d.ts +3 -1
  181. package/dist/server/headers.js +5 -2
  182. package/dist/server/headers.js.map +1 -1
  183. package/dist/server/html.js +1 -1
  184. package/dist/server/html.js.map +1 -1
  185. package/dist/server/http-error-responses.d.ts +10 -0
  186. package/dist/server/http-error-responses.js +11 -1
  187. package/dist/server/http-error-responses.js.map +1 -1
  188. package/dist/server/isr-cache.d.ts +2 -1
  189. package/dist/server/isr-cache.js +4 -2
  190. package/dist/server/isr-cache.js.map +1 -1
  191. package/dist/server/metadata-route-response.js +22 -5
  192. package/dist/server/metadata-route-response.js.map +1 -1
  193. package/dist/server/metadata-routes.js +27 -8
  194. package/dist/server/metadata-routes.js.map +1 -1
  195. package/dist/server/middleware-runtime.js +1 -0
  196. package/dist/server/middleware-runtime.js.map +1 -1
  197. package/dist/server/middleware.d.ts +12 -0
  198. package/dist/server/middleware.js +12 -0
  199. package/dist/server/middleware.js.map +1 -1
  200. package/dist/server/navigation-planner.d.ts +19 -5
  201. package/dist/server/navigation-planner.js +278 -17
  202. package/dist/server/navigation-planner.js.map +1 -1
  203. package/dist/server/navigation-trace.d.ts +8 -1
  204. package/dist/server/navigation-trace.js +7 -0
  205. package/dist/server/navigation-trace.js.map +1 -1
  206. package/dist/server/normalize-path.d.ts +2 -1
  207. package/dist/server/normalize-path.js +4 -1
  208. package/dist/server/normalize-path.js.map +1 -1
  209. package/dist/server/pages-api-route.js +1 -0
  210. package/dist/server/pages-api-route.js.map +1 -1
  211. package/dist/server/pages-page-data.d.ts +3 -2
  212. package/dist/server/pages-page-data.js +22 -3
  213. package/dist/server/pages-page-data.js.map +1 -1
  214. package/dist/server/pages-page-response.js +1 -1
  215. package/dist/server/prod-server.d.ts +28 -1
  216. package/dist/server/prod-server.js +62 -9
  217. package/dist/server/prod-server.js.map +1 -1
  218. package/dist/server/server-action-not-found.d.ts +16 -3
  219. package/dist/server/server-action-not-found.js +19 -1
  220. package/dist/server/server-action-not-found.js.map +1 -1
  221. package/dist/server/server-globals.d.ts +5 -0
  222. package/dist/server/server-globals.js +37 -0
  223. package/dist/server/server-globals.js.map +1 -0
  224. package/dist/server/static-file-cache.js +1 -1
  225. package/dist/server/static-file-cache.js.map +1 -1
  226. package/dist/shims/cache-runtime.d.ts +19 -2
  227. package/dist/shims/cache-runtime.js +67 -11
  228. package/dist/shims/cache-runtime.js.map +1 -1
  229. package/dist/shims/cache.d.ts +5 -18
  230. package/dist/shims/cache.js +2 -0
  231. package/dist/shims/cache.js.map +1 -1
  232. package/dist/shims/error-boundary.js +6 -8
  233. package/dist/shims/error-boundary.js.map +1 -1
  234. package/dist/shims/error.d.ts +18 -1
  235. package/dist/shims/error.js +56 -1
  236. package/dist/shims/error.js.map +1 -1
  237. package/dist/shims/fetch-cache.d.ts +4 -1
  238. package/dist/shims/fetch-cache.js +40 -5
  239. package/dist/shims/fetch-cache.js.map +1 -1
  240. package/dist/shims/font-google-base.d.ts +22 -8
  241. package/dist/shims/font-google-base.js +41 -71
  242. package/dist/shims/font-google-base.js.map +1 -1
  243. package/dist/shims/font-local.d.ts +3 -20
  244. package/dist/shims/font-local.js +23 -75
  245. package/dist/shims/font-local.js.map +1 -1
  246. package/dist/shims/font-utils.d.ts +51 -0
  247. package/dist/shims/font-utils.js +97 -0
  248. package/dist/shims/font-utils.js.map +1 -0
  249. package/dist/shims/hash-scroll.d.ts +7 -0
  250. package/dist/shims/hash-scroll.js +30 -0
  251. package/dist/shims/hash-scroll.js.map +1 -0
  252. package/dist/shims/headers.d.ts +8 -11
  253. package/dist/shims/headers.js +22 -2
  254. package/dist/shims/headers.js.map +1 -1
  255. package/dist/shims/image.d.ts +1 -0
  256. package/dist/shims/image.js +144 -78
  257. package/dist/shims/image.js.map +1 -1
  258. package/dist/shims/internal/app-router-context.d.ts +6 -6
  259. package/dist/shims/internal/app-router-context.js +17 -6
  260. package/dist/shims/internal/app-router-context.js.map +1 -1
  261. package/dist/shims/link-prefetch.d.ts +9 -1
  262. package/dist/shims/link-prefetch.js +11 -6
  263. package/dist/shims/link-prefetch.js.map +1 -1
  264. package/dist/shims/link.d.ts +12 -2
  265. package/dist/shims/link.js +78 -32
  266. package/dist/shims/link.js.map +1 -1
  267. package/dist/shims/metadata.d.ts +16 -30
  268. package/dist/shims/metadata.js +87 -28
  269. package/dist/shims/metadata.js.map +1 -1
  270. package/dist/shims/navigation.d.ts +158 -17
  271. package/dist/shims/navigation.js +324 -74
  272. package/dist/shims/navigation.js.map +1 -1
  273. package/dist/shims/navigation.react-server.d.ts +3 -2
  274. package/dist/shims/navigation.react-server.js +5 -2
  275. package/dist/shims/navigation.react-server.js.map +1 -1
  276. package/dist/shims/pages-router-runtime.d.ts +7 -0
  277. package/dist/shims/pages-router-runtime.js +16 -0
  278. package/dist/shims/pages-router-runtime.js.map +1 -0
  279. package/dist/shims/router.d.ts +32 -6
  280. package/dist/shims/router.js +197 -242
  281. package/dist/shims/router.js.map +1 -1
  282. package/dist/shims/script.js +110 -32
  283. package/dist/shims/script.js.map +1 -1
  284. package/dist/shims/server.js +2 -1
  285. package/dist/shims/server.js.map +1 -1
  286. package/dist/shims/slot.d.ts +1 -0
  287. package/dist/shims/slot.js +41 -1
  288. package/dist/shims/slot.js.map +1 -1
  289. package/dist/shims/unified-request-context.js +2 -0
  290. package/dist/shims/unified-request-context.js.map +1 -1
  291. package/dist/shims/unrecognized-action-error.d.ts +35 -0
  292. package/dist/shims/unrecognized-action-error.js +41 -0
  293. package/dist/shims/unrecognized-action-error.js.map +1 -0
  294. package/dist/shims/url-utils.d.ts +21 -1
  295. package/dist/shims/url-utils.js +67 -3
  296. package/dist/shims/url-utils.js.map +1 -1
  297. package/dist/utils/asset-prefix.d.ts +69 -0
  298. package/dist/utils/asset-prefix.js +91 -0
  299. package/dist/utils/asset-prefix.js.map +1 -0
  300. package/dist/utils/base-path.d.ts +7 -1
  301. package/dist/utils/base-path.js +10 -1
  302. package/dist/utils/base-path.js.map +1 -1
  303. package/dist/utils/navigation-signal.d.ts +1 -2
  304. package/dist/utils/navigation-signal.js +1 -1
  305. package/dist/utils/navigation-signal.js.map +1 -1
  306. package/dist/utils/sorted-array.d.ts +9 -0
  307. package/dist/utils/sorted-array.js +22 -0
  308. package/dist/utils/sorted-array.js.map +1 -0
  309. package/package.json +3 -3
@@ -1,6 +1,7 @@
1
1
  import { fnv1a64 } from "../utils/hash.js";
2
+ import { findSortedStringPosition } from "../utils/sorted-array.js";
2
3
  //#region src/server/cache-proof.ts
3
- const CACHE_PROOF_MODEL_SCHEMA_VERSION = 0;
4
+ const CACHE_PROOF_MODEL_SCHEMA_VERSION = 1;
4
5
  const DEFAULT_CACHE_VARIANT_BUDGET = {
5
6
  maxDimensionCount: 8,
6
7
  maxDimensionNameLength: 64,
@@ -9,6 +10,14 @@ const DEFAULT_CACHE_VARIANT_BUDGET = {
9
10
  maxValuesPerDimension: 8,
10
11
  maxVariantsPerRoute: 64
11
12
  };
13
+ const ALL_RENDER_REQUEST_API_KINDS = [
14
+ "connection",
15
+ "cookies",
16
+ "draftMode",
17
+ "headers",
18
+ "params",
19
+ "searchParams"
20
+ ];
12
21
  const PUBLIC_UNSAFE_DIMENSION_SOURCES = new Set([
13
22
  "auth",
14
23
  "cookie",
@@ -197,14 +206,6 @@ function buildCacheVariant(input) {
197
206
  kind: "breakerFallback",
198
207
  fallback: budgetFallback
199
208
  };
200
- if (input.existingVariantCount >= input.budget.maxVariantsPerRoute) return {
201
- kind: "breakerFallback",
202
- fallback: buildBreakerFallback("CP_ROUTE_VARIANT_CEILING_EXCEEDED", {
203
- existingVariantCount: input.existingVariantCount,
204
- maxVariantsPerRoute: input.budget.maxVariantsPerRoute,
205
- routeId: input.output.routeId
206
- }, "privateUncacheable", "route")
207
- };
208
209
  const dimensionInputs = mergeDimensionInputs(input.dimensions);
209
210
  if (dimensionInputs.length > input.budget.maxDimensionCount) return {
210
211
  kind: "breakerFallback",
@@ -225,7 +226,7 @@ function buildCacheVariant(input) {
225
226
  }
226
227
  dimensions.sort(compareDimensions);
227
228
  const encoded = [
228
- `schema:0`,
229
+ `schema:1`,
229
230
  encodeOutputScope(input.output),
230
231
  ...dimensions.map((dimension) => dimension.encoded)
231
232
  ].join("|");
@@ -241,8 +242,8 @@ function buildCacheVariant(input) {
241
242
  return {
242
243
  kind: "variant",
243
244
  variant: {
244
- schemaVersion: 0,
245
- cacheKey: `cp0:${fnv1a64(encoded)}`,
245
+ schemaVersion: 1,
246
+ cacheKey: `cp1:${fnv1a64(encoded)}`,
246
247
  output: input.output,
247
248
  dimensions,
248
249
  encodedLength: encoded.length,
@@ -250,6 +251,80 @@ function buildCacheVariant(input) {
250
251
  }
251
252
  };
252
253
  }
254
+ function normalizeRouteBudget(input) {
255
+ return {
256
+ routeId: input.routeId,
257
+ variantCacheKeys: sortedUnique(input.variantCacheKeys)
258
+ };
259
+ }
260
+ function buildRouteVariantCeilingFallback(variant, existingVariantCount) {
261
+ return buildBreakerFallback("CP_ROUTE_VARIANT_CEILING_EXCEEDED", {
262
+ existingVariantCount,
263
+ maxVariantsPerRoute: variant.budget.maxVariantsPerRoute,
264
+ routeId: variant.output.routeId
265
+ }, "privateUncacheable", "route");
266
+ }
267
+ function enforceCacheVariantRouteBudget(input) {
268
+ if (input.routeBudget && input.routeBudget.routeId !== input.variant.output.routeId) return {
269
+ kind: "breakerFallback",
270
+ routeBudget: normalizeRouteBudget(input.routeBudget),
271
+ fallback: buildBreakerFallback("CP_ROUTE_VARIANT_BUDGET_ROUTE_MISMATCH", {
272
+ budgetRouteId: input.routeBudget.routeId,
273
+ routeId: input.variant.output.routeId
274
+ }, "privateUncacheable", "route")
275
+ };
276
+ const routeBudget = normalizeRouteBudget(input.routeBudget ?? {
277
+ routeId: input.variant.output.routeId,
278
+ variantCacheKeys: []
279
+ });
280
+ const existingVariantCount = routeBudget.variantCacheKeys.length;
281
+ const variantKeyPosition = findSortedStringPosition(routeBudget.variantCacheKeys, input.variant.cacheKey);
282
+ if (existingVariantCount > input.variant.budget.maxVariantsPerRoute) return {
283
+ kind: "breakerFallback",
284
+ routeBudget,
285
+ fallback: buildRouteVariantCeilingFallback(input.variant, existingVariantCount)
286
+ };
287
+ if (variantKeyPosition.found) return {
288
+ kind: "variant",
289
+ variant: input.variant,
290
+ routeBudget,
291
+ didConsumeRouteVariantBudget: false
292
+ };
293
+ if (existingVariantCount >= input.variant.budget.maxVariantsPerRoute) return {
294
+ kind: "breakerFallback",
295
+ routeBudget,
296
+ fallback: buildRouteVariantCeilingFallback(input.variant, existingVariantCount)
297
+ };
298
+ return {
299
+ kind: "variant",
300
+ variant: input.variant,
301
+ routeBudget: {
302
+ routeId: routeBudget.routeId,
303
+ variantCacheKeys: [
304
+ ...routeBudget.variantCacheKeys.slice(0, variantKeyPosition.index),
305
+ input.variant.cacheKey,
306
+ ...routeBudget.variantCacheKeys.slice(variantKeyPosition.index)
307
+ ]
308
+ },
309
+ didConsumeRouteVariantBudget: true
310
+ };
311
+ }
312
+ function buildCacheVariantWithRouteBudget(input) {
313
+ const variantResult = buildCacheVariant({
314
+ budget: input.budget,
315
+ dimensions: input.dimensions,
316
+ output: input.output
317
+ });
318
+ if (variantResult.kind === "breakerFallback") return {
319
+ kind: "breakerFallback",
320
+ routeBudget: input.routeBudget ? normalizeRouteBudget(input.routeBudget) : null,
321
+ fallback: variantResult.fallback
322
+ };
323
+ return enforceCacheVariantRouteBudget({
324
+ routeBudget: input.routeBudget,
325
+ variant: variantResult.variant
326
+ });
327
+ }
253
328
  function boundaryOutcomesMatch(expected, candidate) {
254
329
  switch (expected.kind) {
255
330
  case "error": return candidate.kind === "error" && (expected.digest ?? "") === (candidate.digest ?? "");
@@ -307,36 +382,359 @@ function normalizeRequestApiObservations(observations) {
307
382
  status
308
383
  }));
309
384
  }
385
+ function cacheProofDowngradeTargetRank(target) {
386
+ switch (target) {
387
+ case "public": return 0;
388
+ case "publicVariant": return 1;
389
+ case "private": return 2;
390
+ case "privateUncacheable": return 3;
391
+ case "freshRender": return 4;
392
+ default: return assertNever(target);
393
+ }
394
+ }
395
+ function maxCacheProofDowngradeTarget(current, candidate) {
396
+ return cacheProofDowngradeTargetRank(candidate) > cacheProofDowngradeTargetRank(current) ? candidate : current;
397
+ }
398
+ function createDowngradeFallback(target, reasons) {
399
+ switch (target) {
400
+ case "public":
401
+ case "publicVariant":
402
+ case "private": return null;
403
+ case "privateUncacheable": return buildBreakerFallback("CP_PRIVATE_DYNAMIC_DOWNGRADE", {
404
+ reasonCodes: reasons.map((reason) => reason.code),
405
+ target
406
+ }, "privateUncacheable");
407
+ case "freshRender": return buildBreakerFallback("CP_PRIVATE_DYNAMIC_DOWNGRADE", {
408
+ reasonCodes: reasons.map((reason) => reason.code),
409
+ target
410
+ });
411
+ default: return assertNever(target);
412
+ }
413
+ }
414
+ function classifyObservedRequestApiDowngrade(kind) {
415
+ switch (kind) {
416
+ case "connection": return {
417
+ code: "CP_DOWNGRADE_DYNAMIC_REQUEST_API",
418
+ requestApi: "connection",
419
+ target: "freshRender"
420
+ };
421
+ case "cookies": return {
422
+ code: "CP_DOWNGRADE_PRIVATE_REQUEST_API",
423
+ requestApi: "cookies",
424
+ target: "private"
425
+ };
426
+ case "draftMode": return {
427
+ code: "CP_DOWNGRADE_DRAFT_MODE",
428
+ requestApi: "draftMode",
429
+ target: "privateUncacheable"
430
+ };
431
+ case "headers": return {
432
+ code: "CP_DOWNGRADE_PRIVATE_REQUEST_API",
433
+ requestApi: "headers",
434
+ target: "private"
435
+ };
436
+ case "params": return {
437
+ code: "CP_DOWNGRADE_PUBLIC_REQUEST_API",
438
+ requestApi: "params",
439
+ target: "publicVariant"
440
+ };
441
+ case "searchParams": return {
442
+ code: "CP_DOWNGRADE_PUBLIC_REQUEST_API",
443
+ requestApi: "searchParams",
444
+ target: "publicVariant"
445
+ };
446
+ default: return assertNever(kind);
447
+ }
448
+ }
449
+ function classifyCacheVariantDimensionDowngrade(input) {
450
+ switch (input.source) {
451
+ case "auth": return {
452
+ code: "CP_DOWNGRADE_PRIVATE_DIMENSION",
453
+ inputClass: "auth",
454
+ source: "auth",
455
+ target: "private"
456
+ };
457
+ case "cookie": return {
458
+ code: "CP_DOWNGRADE_PRIVATE_DIMENSION",
459
+ inputClass: "private",
460
+ source: "cookie",
461
+ target: "private"
462
+ };
463
+ case "draft-mode": return {
464
+ code: "CP_DOWNGRADE_PRIVATE_DIMENSION",
465
+ inputClass: "draft",
466
+ source: "draft-mode",
467
+ target: "privateUncacheable"
468
+ };
469
+ case "header": return {
470
+ code: "CP_DOWNGRADE_PRIVATE_DIMENSION",
471
+ inputClass: "private",
472
+ source: "header",
473
+ target: "private"
474
+ };
475
+ case "session": return {
476
+ code: "CP_DOWNGRADE_PRIVATE_DIMENSION",
477
+ inputClass: "session",
478
+ source: "session",
479
+ target: "private"
480
+ };
481
+ case "custom":
482
+ case "interception":
483
+ case "mounted-slots":
484
+ case "params":
485
+ case "route":
486
+ case "search": return null;
487
+ default: return assertNever(input.source);
488
+ }
489
+ }
490
+ function classifyRenderObservationDowngrade(input) {
491
+ const reasons = [];
492
+ let target = "public";
493
+ switch (input.cacheability) {
494
+ case "public": break;
495
+ case "private": {
496
+ const reason = {
497
+ code: "CP_DOWNGRADE_CACHEABILITY_PRIVATE",
498
+ target: "private"
499
+ };
500
+ reasons.push(reason);
501
+ target = maxCacheProofDowngradeTarget(target, reason.target);
502
+ break;
503
+ }
504
+ case "uncacheable": {
505
+ const reason = {
506
+ code: "CP_DOWNGRADE_CACHEABILITY_UNCACHEABLE",
507
+ target: "privateUncacheable"
508
+ };
509
+ reasons.push(reason);
510
+ target = maxCacheProofDowngradeTarget(target, reason.target);
511
+ break;
512
+ }
513
+ case "unknown": {
514
+ const reason = {
515
+ code: "CP_DOWNGRADE_CACHEABILITY_UNKNOWN",
516
+ target: "freshRender"
517
+ };
518
+ reasons.push(reason);
519
+ target = maxCacheProofDowngradeTarget(target, reason.target);
520
+ break;
521
+ }
522
+ default: assertNever(input.cacheability);
523
+ }
524
+ if (input.completeness !== "complete") {
525
+ const reason = {
526
+ code: "CP_DOWNGRADE_INCOMPLETE_OBSERVATION",
527
+ completeness: input.completeness,
528
+ target: "freshRender"
529
+ };
530
+ reasons.push(reason);
531
+ target = maxCacheProofDowngradeTarget(target, reason.target);
532
+ }
533
+ if (input.dynamicFetches.length > 0) {
534
+ const reason = {
535
+ code: "CP_DOWNGRADE_DYNAMIC_FETCH",
536
+ dynamicFetchCount: input.dynamicFetches.length,
537
+ target: "freshRender"
538
+ };
539
+ reasons.push(reason);
540
+ target = maxCacheProofDowngradeTarget(target, reason.target);
541
+ }
542
+ const requestApis = normalizeRequestApiObservations(input.requestApis);
543
+ for (const requestApi of requestApis) {
544
+ if (requestApi.status === "notObserved") continue;
545
+ const reason = requestApi.status === "unknown" ? {
546
+ code: "CP_DOWNGRADE_UNKNOWN_REQUEST_API",
547
+ requestApi: requestApi.kind,
548
+ target: "freshRender"
549
+ } : classifyObservedRequestApiDowngrade(requestApi.kind);
550
+ reasons.push(reason);
551
+ target = maxCacheProofDowngradeTarget(target, reason.target);
552
+ }
553
+ return {
554
+ target,
555
+ reasons,
556
+ fallback: createDowngradeFallback(target, reasons),
557
+ isPublicCacheCandidate: target === "public" || target === "publicVariant"
558
+ };
559
+ }
560
+ function buildRenderRequestApiObservations(input) {
561
+ const observedKinds = new Set(input.observed);
562
+ const absentStatus = input.completeness === "complete" ? "notObserved" : "unknown";
563
+ return ALL_RENDER_REQUEST_API_KINDS.map((kind) => ({
564
+ kind,
565
+ status: observedKinds.has(kind) ? "observed" : absentStatus
566
+ }));
567
+ }
310
568
  function buildRenderObservation(input) {
569
+ const requestApis = normalizeRequestApiObservations(input.requestApis);
570
+ const dynamicFetches = sortedUniqueRedacted(input.dynamicFetches);
311
571
  return {
312
- schemaVersion: 0,
572
+ schemaVersion: 1,
313
573
  output: input.output,
314
574
  completeness: input.completeness,
315
575
  boundaryOutcome: input.boundaryOutcome,
316
- requestApis: normalizeRequestApiObservations(input.requestApis),
317
- dynamicFetches: sortedUniqueRedacted(input.dynamicFetches),
576
+ requestApis,
577
+ dynamicFetches,
318
578
  cacheTags: sortedUnique(input.cacheTags),
319
579
  pathTags: sortedUnique(input.pathTags),
320
- cacheability: input.cacheability
580
+ cacheability: input.cacheability,
581
+ downgrade: classifyRenderObservationDowngrade({
582
+ cacheability: input.cacheability,
583
+ completeness: input.completeness,
584
+ dynamicFetches,
585
+ requestApis
586
+ })
321
587
  };
322
588
  }
323
589
  function hasCompleteNegativeRequestApiProof(observation, requiredApis) {
324
590
  if (observation.completeness !== "complete") return false;
325
591
  const statuses = /* @__PURE__ */ new Map();
326
- for (const requestApi of observation.requestApis) statuses.set(requestApi.kind, requestApi.status);
592
+ for (const requestApi of normalizeRequestApiObservations(observation.requestApis)) statuses.set(requestApi.kind, requestApi.status);
327
593
  for (const api of requiredApis) if (statuses.get(api) !== "notObserved") return false;
328
594
  return true;
329
595
  }
596
+ function isStaticLayoutOutputScope(output) {
597
+ return output.kind === "layout";
598
+ }
599
+ function rejectStaticLayoutReuseProof(code, fields, mode = "renderFresh") {
600
+ return {
601
+ kind: "rejected",
602
+ fallback: buildBreakerFallback(code, fields, mode)
603
+ };
604
+ }
605
+ function getRequestApiStatus(observations, kind) {
606
+ let status = null;
607
+ for (const requestApi of observations) {
608
+ if (requestApi.kind !== kind) continue;
609
+ if (status === null || requestApiStatusRank(requestApi.status) > requestApiStatusRank(status)) status = requestApi.status;
610
+ }
611
+ return status ?? "missing";
612
+ }
613
+ function createStaticLayoutDowngradeFallback(downgrade) {
614
+ const mode = downgrade.target === "privateUncacheable" ? "privateUncacheable" : "renderFresh";
615
+ return buildBreakerFallback("CP_STATIC_LAYOUT_PRIVATE_DYNAMIC_DOWNGRADE", {
616
+ reasonCodes: downgrade.reasons.map((reason) => reason.code),
617
+ target: downgrade.target
618
+ }, mode);
619
+ }
620
+ function createPrivateVariantDimensionFallback(dimension) {
621
+ const downgrade = classifyCacheVariantDimensionDowngrade({ source: dimension.source });
622
+ if (!downgrade && dimension.privacy !== "private") return null;
623
+ const target = downgrade?.target ?? "private";
624
+ const mode = target === "privateUncacheable" ? "privateUncacheable" : "renderFresh";
625
+ return buildBreakerFallback("CP_STATIC_LAYOUT_PRIVATE_VARIANT_DIMENSION", {
626
+ dimension: dimension.name,
627
+ privacy: dimension.privacy,
628
+ reasonCode: downgrade?.code ?? null,
629
+ source: dimension.source,
630
+ target
631
+ }, mode);
632
+ }
633
+ function outputFieldMismatch(candidate, observation) {
634
+ if (candidate.layoutId !== observation.layoutId) return "layoutId";
635
+ if (candidate.rootBoundaryId !== observation.rootBoundaryId) return "rootBoundaryId";
636
+ if (candidate.routeId !== observation.routeId) return "routeId";
637
+ return null;
638
+ }
639
+ function buildStaticLayoutReuseProof(input) {
640
+ if (!isStaticLayoutOutputScope(input.currentOutput)) return rejectStaticLayoutReuseProof("CP_STATIC_LAYOUT_CURRENT_OUTPUT_KIND", { currentOutputKind: input.currentOutput.kind });
641
+ if (!isStaticLayoutOutputScope(input.candidateVariant.output)) return rejectStaticLayoutReuseProof("CP_STATIC_LAYOUT_CANDIDATE_OUTPUT_KIND", { candidateOutputKind: input.candidateVariant.output.kind });
642
+ if (!isStaticLayoutOutputScope(input.candidateObservation.output)) return rejectStaticLayoutReuseProof("CP_STATIC_LAYOUT_OBSERVATION_OUTPUT_KIND", { observationOutputKind: input.candidateObservation.output.kind });
643
+ const currentOutput = input.currentOutput;
644
+ const candidateOutput = input.candidateVariant.output;
645
+ const observationOutput = input.candidateObservation.output;
646
+ const requestApis = normalizeRequestApiObservations(input.candidateObservation.requestApis);
647
+ const candidateObservation = {
648
+ ...input.candidateObservation,
649
+ requestApis,
650
+ downgrade: classifyRenderObservationDowngrade({
651
+ cacheability: input.candidateObservation.cacheability,
652
+ completeness: input.candidateObservation.completeness,
653
+ dynamicFetches: input.candidateObservation.dynamicFetches,
654
+ requestApis
655
+ })
656
+ };
657
+ const observedOutputMismatch = outputFieldMismatch(candidateOutput, observationOutput);
658
+ if (observedOutputMismatch) return rejectStaticLayoutReuseProof("CP_STATIC_LAYOUT_OBSERVATION_OUTPUT_MISMATCH", {
659
+ candidateLayoutId: candidateOutput.layoutId,
660
+ candidateRootBoundaryId: candidateOutput.rootBoundaryId,
661
+ candidateRouteId: candidateOutput.routeId,
662
+ field: observedOutputMismatch,
663
+ observationLayoutId: observationOutput.layoutId,
664
+ observationRootBoundaryId: observationOutput.rootBoundaryId,
665
+ observationRouteId: observationOutput.routeId
666
+ });
667
+ if (currentOutput.layoutId !== candidateOutput.layoutId) return rejectStaticLayoutReuseProof("CP_STATIC_LAYOUT_ID_MISMATCH", {
668
+ candidateLayoutId: candidateOutput.layoutId,
669
+ currentLayoutId: currentOutput.layoutId
670
+ });
671
+ if (currentOutput.rootBoundaryId === null || candidateOutput.rootBoundaryId === null) return rejectStaticLayoutReuseProof("CP_STATIC_LAYOUT_ROOT_BOUNDARY_UNKNOWN", {
672
+ candidateRootBoundaryId: candidateOutput.rootBoundaryId,
673
+ currentRootBoundaryId: currentOutput.rootBoundaryId
674
+ });
675
+ if (currentOutput.rootBoundaryId !== candidateOutput.rootBoundaryId) return rejectStaticLayoutReuseProof("CP_STATIC_LAYOUT_ROOT_BOUNDARY_MISMATCH", {
676
+ candidateRootBoundaryId: candidateOutput.rootBoundaryId,
677
+ currentRootBoundaryId: currentOutput.rootBoundaryId
678
+ });
679
+ const boundaryCompatibility = buildBoundaryOutcomeCompatibility({
680
+ candidate: candidateObservation.boundaryOutcome,
681
+ expected: { kind: "success" }
682
+ });
683
+ if (boundaryCompatibility.kind === "incompatible") return {
684
+ kind: "rejected",
685
+ fallback: boundaryCompatibility.fallback
686
+ };
687
+ for (const dimension of input.candidateVariant.dimensions) {
688
+ const fallback = createPrivateVariantDimensionFallback(dimension);
689
+ if (fallback) return {
690
+ kind: "rejected",
691
+ fallback
692
+ };
693
+ }
694
+ if (!candidateObservation.downgrade.isPublicCacheCandidate) return {
695
+ kind: "rejected",
696
+ fallback: createStaticLayoutDowngradeFallback(candidateObservation.downgrade)
697
+ };
698
+ const requiredNegativeRequestApis = ALL_RENDER_REQUEST_API_KINDS;
699
+ for (const api of requiredNegativeRequestApis) {
700
+ const status = getRequestApiStatus(candidateObservation.requestApis, api);
701
+ if (status === "notObserved") continue;
702
+ return rejectStaticLayoutReuseProof(status === "missing" ? "CP_STATIC_LAYOUT_REQUEST_API_UNKNOWN" : "CP_STATIC_LAYOUT_REQUEST_API_OBSERVED", {
703
+ requestApi: api,
704
+ status
705
+ });
706
+ }
707
+ return {
708
+ kind: "proof",
709
+ proof: {
710
+ authorizesRuntimeReuse: false,
711
+ candidateOutput,
712
+ code: "CP_STATIC_LAYOUT_REUSE_PROVEN",
713
+ currentOutput,
714
+ fields: {
715
+ candidateRouteId: candidateOutput.routeId,
716
+ currentRouteId: currentOutput.routeId,
717
+ layoutId: currentOutput.layoutId,
718
+ rootBoundaryId: currentOutput.rootBoundaryId
719
+ },
720
+ observation: candidateObservation,
721
+ requiredNegativeRequestApis: [...requiredNegativeRequestApis],
722
+ reuseClass: "static-layout",
723
+ variant: input.candidateVariant
724
+ }
725
+ };
726
+ }
330
727
  function createDisabledCacheProofDecision(input) {
331
728
  return {
332
729
  kind: "disabled",
333
730
  canReuse: false,
334
731
  variant: input.variant,
335
732
  observation: input.observation,
733
+ ...input.staticLayoutProof ? { staticLayoutProof: input.staticLayoutProof } : {},
336
734
  fallback: buildBreakerFallback("CP_MODEL_DISABLED")
337
735
  };
338
736
  }
339
737
  //#endregion
340
- export { CACHE_PROOF_MODEL_SCHEMA_VERSION, DEFAULT_CACHE_VARIANT_BUDGET, buildBoundaryOutcomeCompatibility, buildCacheVariant, buildRenderObservation, createAppRouteCacheProofGraphScope, createDisabledCacheProofDecision, hasCompleteNegativeRequestApiProof };
738
+ export { ALL_RENDER_REQUEST_API_KINDS, CACHE_PROOF_MODEL_SCHEMA_VERSION, DEFAULT_CACHE_VARIANT_BUDGET, buildBoundaryOutcomeCompatibility, buildCacheVariant, buildCacheVariantWithRouteBudget, buildRenderObservation, buildRenderRequestApiObservations, buildStaticLayoutReuseProof, classifyCacheVariantDimensionDowngrade, classifyRenderObservationDowngrade, createAppRouteCacheProofGraphScope, createDisabledCacheProofDecision, enforceCacheVariantRouteBudget, hasCompleteNegativeRequestApiProof };
341
739
 
342
740
  //# sourceMappingURL=cache-proof.js.map