vinext 0.0.26 → 0.0.27

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 (196) hide show
  1. package/README.md +89 -85
  2. package/dist/build/static-export.d.ts.map +1 -1
  3. package/dist/build/static-export.js +3 -8
  4. package/dist/build/static-export.js.map +1 -1
  5. package/dist/check.d.ts.map +1 -1
  6. package/dist/check.js +152 -48
  7. package/dist/check.js.map +1 -1
  8. package/dist/cli.js +10 -11
  9. package/dist/cli.js.map +1 -1
  10. package/dist/cloudflare/kv-cache-handler.d.ts +32 -1
  11. package/dist/cloudflare/kv-cache-handler.d.ts.map +1 -1
  12. package/dist/cloudflare/kv-cache-handler.js +47 -21
  13. package/dist/cloudflare/kv-cache-handler.js.map +1 -1
  14. package/dist/cloudflare/tpr.d.ts.map +1 -1
  15. package/dist/cloudflare/tpr.js +15 -4
  16. package/dist/cloudflare/tpr.js.map +1 -1
  17. package/dist/config/config-matchers.d.ts +27 -0
  18. package/dist/config/config-matchers.d.ts.map +1 -1
  19. package/dist/config/config-matchers.js +306 -60
  20. package/dist/config/config-matchers.js.map +1 -1
  21. package/dist/config/dotenv.d.ts.map +1 -1
  22. package/dist/config/dotenv.js +1 -6
  23. package/dist/config/dotenv.js.map +1 -1
  24. package/dist/config/next-config.d.ts +7 -0
  25. package/dist/config/next-config.d.ts.map +1 -1
  26. package/dist/config/next-config.js +44 -19
  27. package/dist/config/next-config.js.map +1 -1
  28. package/dist/deploy.d.ts.map +1 -1
  29. package/dist/deploy.js +36 -19
  30. package/dist/deploy.js.map +1 -1
  31. package/dist/entries/app-rsc-entry.d.ts.map +1 -1
  32. package/dist/entries/app-rsc-entry.js +89 -38
  33. package/dist/entries/app-rsc-entry.js.map +1 -1
  34. package/dist/entries/pages-client-entry.d.ts.map +1 -1
  35. package/dist/entries/pages-client-entry.js +5 -3
  36. package/dist/entries/pages-client-entry.js.map +1 -1
  37. package/dist/entries/pages-server-entry.d.ts.map +1 -1
  38. package/dist/entries/pages-server-entry.js +32 -10
  39. package/dist/entries/pages-server-entry.js.map +1 -1
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +204 -118
  43. package/dist/index.js.map +1 -1
  44. package/dist/init.d.ts.map +1 -1
  45. package/dist/init.js +6 -5
  46. package/dist/init.js.map +1 -1
  47. package/dist/routing/app-router.d.ts +2 -0
  48. package/dist/routing/app-router.d.ts.map +1 -1
  49. package/dist/routing/app-router.js +10 -18
  50. package/dist/routing/app-router.js.map +1 -1
  51. package/dist/routing/file-matcher.d.ts.map +1 -1
  52. package/dist/routing/file-matcher.js.map +1 -1
  53. package/dist/routing/pages-router.d.ts +2 -0
  54. package/dist/routing/pages-router.d.ts.map +1 -1
  55. package/dist/routing/pages-router.js +8 -5
  56. package/dist/routing/pages-router.js.map +1 -1
  57. package/dist/routing/utils.d.ts.map +1 -1
  58. package/dist/routing/utils.js.map +1 -1
  59. package/dist/server/api-handler.d.ts.map +1 -1
  60. package/dist/server/api-handler.js +7 -2
  61. package/dist/server/api-handler.js.map +1 -1
  62. package/dist/server/app-router-entry.d.ts +3 -2
  63. package/dist/server/app-router-entry.d.ts.map +1 -1
  64. package/dist/server/app-router-entry.js +8 -4
  65. package/dist/server/app-router-entry.js.map +1 -1
  66. package/dist/server/dev-module-runner.d.ts.map +1 -1
  67. package/dist/server/dev-module-runner.js +1 -1
  68. package/dist/server/dev-module-runner.js.map +1 -1
  69. package/dist/server/dev-origin-check.d.ts.map +1 -1
  70. package/dist/server/dev-origin-check.js.map +1 -1
  71. package/dist/server/dev-server.d.ts.map +1 -1
  72. package/dist/server/dev-server.js +30 -18
  73. package/dist/server/dev-server.js.map +1 -1
  74. package/dist/server/image-optimization.d.ts.map +1 -1
  75. package/dist/server/image-optimization.js.map +1 -1
  76. package/dist/server/instrumentation.js +1 -1
  77. package/dist/server/instrumentation.js.map +1 -1
  78. package/dist/server/isr-cache.d.ts +13 -1
  79. package/dist/server/isr-cache.d.ts.map +1 -1
  80. package/dist/server/isr-cache.js +10 -1
  81. package/dist/server/isr-cache.js.map +1 -1
  82. package/dist/server/metadata-routes.d.ts.map +1 -1
  83. package/dist/server/metadata-routes.js +6 -18
  84. package/dist/server/metadata-routes.js.map +1 -1
  85. package/dist/server/middleware-codegen.d.ts.map +1 -1
  86. package/dist/server/middleware-codegen.js +12 -10
  87. package/dist/server/middleware-codegen.js.map +1 -1
  88. package/dist/server/middleware-request-headers.d.ts +9 -0
  89. package/dist/server/middleware-request-headers.d.ts.map +1 -0
  90. package/dist/server/middleware-request-headers.js +77 -0
  91. package/dist/server/middleware-request-headers.js.map +1 -0
  92. package/dist/server/middleware.d.ts.map +1 -1
  93. package/dist/server/middleware.js +38 -19
  94. package/dist/server/middleware.js.map +1 -1
  95. package/dist/server/normalize-path.js.map +1 -1
  96. package/dist/server/prod-server.d.ts +1 -1
  97. package/dist/server/prod-server.d.ts.map +1 -1
  98. package/dist/server/prod-server.js +53 -38
  99. package/dist/server/prod-server.js.map +1 -1
  100. package/dist/server/request-pipeline.d.ts +2 -1
  101. package/dist/server/request-pipeline.d.ts.map +1 -1
  102. package/dist/server/request-pipeline.js +5 -7
  103. package/dist/server/request-pipeline.js.map +1 -1
  104. package/dist/shims/cache-runtime.d.ts.map +1 -1
  105. package/dist/shims/cache-runtime.js +21 -16
  106. package/dist/shims/cache-runtime.js.map +1 -1
  107. package/dist/shims/cache.d.ts.map +1 -1
  108. package/dist/shims/cache.js +18 -17
  109. package/dist/shims/cache.js.map +1 -1
  110. package/dist/shims/constants.d.ts.map +1 -1
  111. package/dist/shims/constants.js +1 -6
  112. package/dist/shims/constants.js.map +1 -1
  113. package/dist/shims/dynamic.d.ts.map +1 -1
  114. package/dist/shims/dynamic.js +1 -1
  115. package/dist/shims/dynamic.js.map +1 -1
  116. package/dist/shims/error-boundary.d.ts.map +1 -1
  117. package/dist/shims/error-boundary.js +2 -3
  118. package/dist/shims/error-boundary.js.map +1 -1
  119. package/dist/shims/error.d.ts.map +1 -1
  120. package/dist/shims/error.js +1 -3
  121. package/dist/shims/error.js.map +1 -1
  122. package/dist/shims/fetch-cache.d.ts.map +1 -1
  123. package/dist/shims/fetch-cache.js +53 -29
  124. package/dist/shims/fetch-cache.js.map +1 -1
  125. package/dist/shims/font-google-base.d.ts.map +1 -1
  126. package/dist/shims/font-google-base.js +16 -4
  127. package/dist/shims/font-google-base.js.map +1 -1
  128. package/dist/shims/font-google.d.ts +1 -1
  129. package/dist/shims/font-google.d.ts.map +1 -1
  130. package/dist/shims/font-google.generated.d.ts.map +1 -1
  131. package/dist/shims/font-google.generated.js +412 -206
  132. package/dist/shims/font-google.generated.js.map +1 -1
  133. package/dist/shims/font-google.js +1 -1
  134. package/dist/shims/font-google.js.map +1 -1
  135. package/dist/shims/font-local.d.ts.map +1 -1
  136. package/dist/shims/font-local.js +13 -3
  137. package/dist/shims/font-local.js.map +1 -1
  138. package/dist/shims/form.d.ts.map +1 -1
  139. package/dist/shims/form.js +2 -2
  140. package/dist/shims/form.js.map +1 -1
  141. package/dist/shims/head.d.ts.map +1 -1
  142. package/dist/shims/head.js +10 -8
  143. package/dist/shims/head.js.map +1 -1
  144. package/dist/shims/headers.d.ts +23 -5
  145. package/dist/shims/headers.d.ts.map +1 -1
  146. package/dist/shims/headers.js +97 -37
  147. package/dist/shims/headers.js.map +1 -1
  148. package/dist/shims/image.d.ts.map +1 -1
  149. package/dist/shims/image.js +35 -8
  150. package/dist/shims/image.js.map +1 -1
  151. package/dist/shims/legacy-image.d.ts.map +1 -1
  152. package/dist/shims/legacy-image.js +1 -1
  153. package/dist/shims/legacy-image.js.map +1 -1
  154. package/dist/shims/link.d.ts.map +1 -1
  155. package/dist/shims/link.js +29 -15
  156. package/dist/shims/link.js.map +1 -1
  157. package/dist/shims/metadata.d.ts +12 -2
  158. package/dist/shims/metadata.d.ts.map +1 -1
  159. package/dist/shims/metadata.js +10 -8
  160. package/dist/shims/metadata.js.map +1 -1
  161. package/dist/shims/navigation-state.d.ts.map +1 -1
  162. package/dist/shims/navigation-state.js +3 -2
  163. package/dist/shims/navigation-state.js.map +1 -1
  164. package/dist/shims/navigation.d.ts.map +1 -1
  165. package/dist/shims/navigation.js +26 -19
  166. package/dist/shims/navigation.js.map +1 -1
  167. package/dist/shims/request-context.d.ts +50 -0
  168. package/dist/shims/request-context.d.ts.map +1 -0
  169. package/dist/shims/request-context.js +59 -0
  170. package/dist/shims/request-context.js.map +1 -0
  171. package/dist/shims/router-state.d.ts.map +1 -1
  172. package/dist/shims/router-state.js +2 -1
  173. package/dist/shims/router-state.js.map +1 -1
  174. package/dist/shims/router.d.ts.map +1 -1
  175. package/dist/shims/router.js +18 -25
  176. package/dist/shims/router.js.map +1 -1
  177. package/dist/shims/script.d.ts.map +1 -1
  178. package/dist/shims/script.js.map +1 -1
  179. package/dist/shims/server.d.ts +13 -0
  180. package/dist/shims/server.d.ts.map +1 -1
  181. package/dist/shims/server.js +100 -34
  182. package/dist/shims/server.js.map +1 -1
  183. package/dist/shims/url-utils.d.ts.map +1 -1
  184. package/dist/shims/url-utils.js +1 -3
  185. package/dist/shims/url-utils.js.map +1 -1
  186. package/dist/utils/base-path.d.ts +17 -0
  187. package/dist/utils/base-path.d.ts.map +1 -0
  188. package/dist/utils/base-path.js +25 -0
  189. package/dist/utils/base-path.js.map +1 -0
  190. package/dist/utils/project.d.ts.map +1 -1
  191. package/dist/utils/project.js +2 -4
  192. package/dist/utils/project.js.map +1 -1
  193. package/dist/utils/query.d.ts.map +1 -1
  194. package/dist/utils/query.js +3 -1
  195. package/dist/utils/query.js.map +1 -1
  196. package/package.json +47 -33
@@ -1 +1 @@
1
- {"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../../src/shims/error-boundary.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC;QAAE,KAAK,EAAE,KAAK,CA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MD,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AA2DD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,qBAAqB,2CAO7E"}
@@ -33,7 +33,7 @@ export class ErrorBoundary extends React.Component {
33
33
  render() {
34
34
  if (this.state.error) {
35
35
  const FallbackComponent = this.props.fallback;
36
- return (_jsx(FallbackComponent, { error: this.state.error, reset: this.reset }));
36
+ return _jsx(FallbackComponent, { error: this.state.error, reset: this.reset });
37
37
  }
38
38
  return this.props.children;
39
39
  }
@@ -62,8 +62,7 @@ class NotFoundBoundaryInner extends React.Component {
62
62
  static getDerivedStateFromError(error) {
63
63
  if (error && typeof error === "object" && "digest" in error) {
64
64
  const digest = String(error.digest);
65
- if (digest === "NEXT_NOT_FOUND" ||
66
- digest.startsWith("NEXT_HTTP_ERROR_FALLBACK;404")) {
65
+ if (digest === "NEXT_NOT_FOUND" || digest.startsWith("NEXT_HTTP_ERROR_FALLBACK;404")) {
67
66
  return { notFound: true };
68
67
  }
69
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"error-boundary.js","sourceRoot":"","sources":["../../src/shims/error-boundary.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,+FAA+F;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAW9C;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK,CAAC,SAGxC;IACC,YAAY,KAAyB;QACnC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAY;QAC1C,yEAAyE;QACzE,gEAAgE;QAChE,uDAAuD;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C,gBAAgB,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YAChE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/D,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;IACxE,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAY;QAC1C,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;YAC5D,MAAM,MAAM,GAAG,MAAM,CAAE,KAAa,CAAC,MAAM,CAAC,CAAC;YAC7C,IACE,MAAM,KAAK,gBAAgB;gBAC3B,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC,EACjD,CAAC;gBACD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YAC5B,CAAC;QACH,CAAC;QACD,+EAA+E;QAC/E,MAAM,KAAK,CAAC;IACd,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC7B,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAyB;IAC5E,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,OAAO,CACL,KAAC,qBAAqB,IAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,YAC1D,QAAQ,GACa,CACzB,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport React from \"react\";\n// eslint-disable-next-line @typescript-eslint/no-require-imports -- next/navigation is shimmed\nimport { usePathname } from \"next/navigation\";\n\ninterface ErrorBoundaryProps {\n fallback: React.ComponentType<{ error: Error; reset: () => void }>;\n children: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error: Error | null;\n}\n\n/**\n * Generic ErrorBoundary used to wrap route segments with error.tsx.\n * This must be a client component since error boundaries use\n * componentDidCatch / getDerivedStateFromError.\n */\nexport class ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = { error: null };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n // notFound(), forbidden(), unauthorized(), and redirect() must propagate\n // past error boundaries. Re-throw them so they bubble up to the\n // framework's HTTP access fallback / redirect handler.\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String((error as any).digest);\n if (\n digest === \"NEXT_NOT_FOUND\" || // legacy compat\n digest.startsWith(\"NEXT_HTTP_ERROR_FALLBACK;\") ||\n digest.startsWith(\"NEXT_REDIRECT;\")\n ) {\n throw error;\n }\n }\n return { error };\n }\n\n reset = () => {\n this.setState({ error: null });\n };\n\n render() {\n if (this.state.error) {\n const FallbackComponent = this.props.fallback;\n return (\n <FallbackComponent error={this.state.error} reset={this.reset} />\n );\n }\n return this.props.children;\n }\n}\n\n// ---------------------------------------------------------------------------\n// NotFoundBoundary — catches notFound() on the client and renders not-found.tsx\n// ---------------------------------------------------------------------------\n\ninterface NotFoundBoundaryProps {\n fallback: React.ReactNode;\n children: React.ReactNode;\n}\n\ninterface NotFoundBoundaryInnerProps extends NotFoundBoundaryProps {\n pathname: string;\n}\n\ninterface NotFoundBoundaryState {\n notFound: boolean;\n previousPathname: string;\n}\n\n/**\n * Inner class component that catches notFound() errors and renders the\n * not-found.tsx fallback. Resets when the pathname changes (client navigation)\n * so a previous notFound() doesn't permanently stick.\n *\n * The ErrorBoundary above re-throws notFound errors so they propagate up to this\n * boundary. This must be placed above the ErrorBoundary in the component tree.\n */\nclass NotFoundBoundaryInner extends React.Component<\n NotFoundBoundaryInnerProps,\n NotFoundBoundaryState\n> {\n constructor(props: NotFoundBoundaryInnerProps) {\n super(props);\n this.state = { notFound: false, previousPathname: props.pathname };\n }\n\n static getDerivedStateFromProps(\n props: NotFoundBoundaryInnerProps,\n state: NotFoundBoundaryState,\n ): NotFoundBoundaryState | null {\n // Reset the boundary when the route changes so a previous notFound()\n // doesn't permanently stick after client-side navigation.\n if (props.pathname !== state.previousPathname && state.notFound) {\n return { notFound: false, previousPathname: props.pathname };\n }\n return { notFound: state.notFound, previousPathname: props.pathname };\n }\n\n static getDerivedStateFromError(error: Error): Partial<NotFoundBoundaryState> {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String((error as any).digest);\n if (\n digest === \"NEXT_NOT_FOUND\" ||\n digest.startsWith(\"NEXT_HTTP_ERROR_FALLBACK;404\")\n ) {\n return { notFound: true };\n }\n }\n // Not a notFound error — re-throw so it reaches an ErrorBoundary or propagates\n throw error;\n }\n\n render() {\n if (this.state.notFound) {\n return this.props.fallback;\n }\n return this.props.children;\n }\n}\n\n/**\n * Wrapper that reads the current pathname and passes it to the inner class\n * component. This enables automatic reset on client-side navigation.\n */\nexport function NotFoundBoundary({ fallback, children }: NotFoundBoundaryProps) {\n const pathname = usePathname();\n return (\n <NotFoundBoundaryInner pathname={pathname} fallback={fallback}>\n {children}\n </NotFoundBoundaryInner>\n );\n}\n"]}
1
+ {"version":3,"file":"error-boundary.js","sourceRoot":"","sources":["../../src/shims/error-boundary.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,+FAA+F;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAW9C;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK,CAAC,SAAiD;IACxF,YAAY,KAAyB;QACnC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC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react\";\n// eslint-disable-next-line @typescript-eslint/no-require-imports -- next/navigation is shimmed\nimport { usePathname } from \"next/navigation\";\n\ninterface ErrorBoundaryProps {\n fallback: React.ComponentType<{ error: Error; reset: () => void }>;\n children: React.ReactNode;\n}\n\ninterface ErrorBoundaryState {\n error: Error | null;\n}\n\n/**\n * Generic ErrorBoundary used to wrap route segments with error.tsx.\n * This must be a client component since error boundaries use\n * componentDidCatch / getDerivedStateFromError.\n */\nexport class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n this.state = { error: null };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n // notFound(), forbidden(), unauthorized(), and redirect() must propagate\n // past error boundaries. Re-throw them so they bubble up to the\n // framework's HTTP access fallback / redirect handler.\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String((error as any).digest);\n if (\n digest === \"NEXT_NOT_FOUND\" || // legacy compat\n digest.startsWith(\"NEXT_HTTP_ERROR_FALLBACK;\") ||\n digest.startsWith(\"NEXT_REDIRECT;\")\n ) {\n throw error;\n }\n }\n return { error };\n }\n\n reset = () => {\n this.setState({ error: null });\n };\n\n render() {\n if (this.state.error) {\n const FallbackComponent = this.props.fallback;\n return <FallbackComponent error={this.state.error} reset={this.reset} />;\n }\n return this.props.children;\n }\n}\n\n// ---------------------------------------------------------------------------\n// NotFoundBoundary — catches notFound() on the client and renders not-found.tsx\n// ---------------------------------------------------------------------------\n\ninterface NotFoundBoundaryProps {\n fallback: React.ReactNode;\n children: React.ReactNode;\n}\n\ninterface NotFoundBoundaryInnerProps extends NotFoundBoundaryProps {\n pathname: string;\n}\n\ninterface NotFoundBoundaryState {\n notFound: boolean;\n previousPathname: string;\n}\n\n/**\n * Inner class component that catches notFound() errors and renders the\n * not-found.tsx fallback. Resets when the pathname changes (client navigation)\n * so a previous notFound() doesn't permanently stick.\n *\n * The ErrorBoundary above re-throws notFound errors so they propagate up to this\n * boundary. This must be placed above the ErrorBoundary in the component tree.\n */\nclass NotFoundBoundaryInner extends React.Component<\n NotFoundBoundaryInnerProps,\n NotFoundBoundaryState\n> {\n constructor(props: NotFoundBoundaryInnerProps) {\n super(props);\n this.state = { notFound: false, previousPathname: props.pathname };\n }\n\n static getDerivedStateFromProps(\n props: NotFoundBoundaryInnerProps,\n state: NotFoundBoundaryState,\n ): NotFoundBoundaryState | null {\n // Reset the boundary when the route changes so a previous notFound()\n // doesn't permanently stick after client-side navigation.\n if (props.pathname !== state.previousPathname && state.notFound) {\n return { notFound: false, previousPathname: props.pathname };\n }\n return { notFound: state.notFound, previousPathname: props.pathname };\n }\n\n static getDerivedStateFromError(error: Error): Partial<NotFoundBoundaryState> {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String((error as any).digest);\n if (digest === \"NEXT_NOT_FOUND\" || digest.startsWith(\"NEXT_HTTP_ERROR_FALLBACK;404\")) {\n return { notFound: true };\n }\n }\n // Not a notFound error — re-throw so it reaches an ErrorBoundary or propagates\n throw error;\n }\n\n render() {\n if (this.state.notFound) {\n return this.props.fallback;\n }\n return this.props.children;\n }\n}\n\n/**\n * Wrapper that reads the current pathname and passes it to the inner class\n * component. This enables automatic reset on client-side navigation.\n */\nexport function NotFoundBoundary({ fallback, children }: NotFoundBoundaryProps) {\n const pathname = usePathname();\n return (\n <NotFoundBoundaryInner pathname={pathname} fallback={fallback}>\n {children}\n </NotFoundBoundaryInner>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/shims/error.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,UAAU,UAAU;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,iBAAS,cAAc,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,UAAU,GAAG,KAAK,CAAC,YAAY,CA2D7E;AAED,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/shims/error.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,UAAU,UAAU;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,iBAAS,cAAc,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,UAAU,GAAG,KAAK,CAAC,YAAY,CAyD7E;AAED,eAAe,cAAc,CAAC"}
@@ -7,9 +7,7 @@
7
7
  */
8
8
  import React from "react";
9
9
  function ErrorComponent({ statusCode, title }) {
10
- const defaultTitle = statusCode === 404
11
- ? "This page could not be found"
12
- : "Internal Server Error";
10
+ const defaultTitle = statusCode === 404 ? "This page could not be found" : "Internal Server Error";
13
11
  const displayTitle = title ?? defaultTitle;
14
12
  return React.createElement("div", {
15
13
  style: {
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/shims/error.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,SAAS,cAAc,CAAC,EAAE,UAAU,EAAE,KAAK,EAAc;IACvD,MAAM,YAAY,GAChB,UAAU,KAAK,GAAG;QAChB,CAAC,CAAC,8BAA8B;QAChC,CAAC,CAAC,uBAAuB,CAAC;IAE9B,MAAM,YAAY,GAAG,KAAK,IAAI,YAAY,CAAC;IAE3C,OAAO,KAAK,CAAC,aAAa,CACxB,KAAK,EACL;QACE,KAAK,EAAE;YACL,UAAU,EACR,4FAA4F;YAC9F,MAAM,EAAE,OAAO;YACf,SAAS,EAAE,QAAiB;YAC5B,OAAO,EAAE,MAAM;YACf,aAAa,EAAE,QAAiB;YAChC,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;SACzB;KACF,EACD,KAAK,CAAC,aAAa,CACjB,KAAK,EACL,IAAI,EACJ,KAAK,CAAC,aAAa,CACjB,IAAI,EACJ;QACE,KAAK,EAAE;YACL,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE,YAAY;YACpB,OAAO,EAAE,YAAY;YACrB,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,GAAG;YACf,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,MAAM;YAClB,WAAW,EAAE,6BAA6B;SAC3C;KACF,EACD,UAAU,CACX,EACD,KAAK,CAAC,aAAa,CACjB,KAAK,EACL,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EACtC,KAAK,CAAC,aAAa,CACjB,IAAI,EACJ;QACE,KAAK,EAAE;YACL,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,GAAG;YACf,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,CAAC;SACV;KACF,EACD,YAAY,GAAG,GAAG,CACnB,CACF,CACF,CACF,CAAC;AACJ,CAAC;AAED,eAAe,cAAc,CAAC","sourcesContent":["/**\n * next/error shim\n *\n * Provides the default Next.js error page component.\n * Used by apps that import `import Error from 'next/error'` for\n * custom error handling in getServerSideProps or API routes.\n */\nimport React from \"react\";\n\ninterface ErrorProps {\n statusCode: number;\n title?: string;\n withDarkMode?: boolean;\n}\n\nfunction ErrorComponent({ statusCode, title }: ErrorProps): React.ReactElement {\n const defaultTitle =\n statusCode === 404\n ? \"This page could not be found\"\n : \"Internal Server Error\";\n\n const displayTitle = title ?? defaultTitle;\n\n return React.createElement(\n \"div\",\n {\n style: {\n fontFamily:\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n height: \"100vh\",\n textAlign: \"center\" as const,\n display: \"flex\",\n flexDirection: \"column\" as const,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n },\n React.createElement(\n \"div\",\n null,\n React.createElement(\n \"h1\",\n {\n style: {\n display: \"inline-block\",\n margin: \"0 20px 0 0\",\n padding: \"0 23px 0 0\",\n fontSize: 24,\n fontWeight: 500,\n verticalAlign: \"top\",\n lineHeight: \"49px\",\n borderRight: \"1px solid rgba(0, 0, 0, .3)\",\n },\n },\n statusCode,\n ),\n React.createElement(\n \"div\",\n { style: { display: \"inline-block\" } },\n React.createElement(\n \"h2\",\n {\n style: {\n fontSize: 14,\n fontWeight: 400,\n lineHeight: \"49px\",\n margin: 0,\n },\n },\n displayTitle + \".\",\n ),\n ),\n ),\n );\n}\n\nexport default ErrorComponent;\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/shims/error.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,SAAS,cAAc,CAAC,EAAE,UAAU,EAAE,KAAK,EAAc;IACvD,MAAM,YAAY,GAChB,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,uBAAuB,CAAC;IAEhF,MAAM,YAAY,GAAG,KAAK,IAAI,YAAY,CAAC;IAE3C,OAAO,KAAK,CAAC,aAAa,CACxB,KAAK,EACL;QACE,KAAK,EAAE;YACL,UAAU,EACR,4FAA4F;YAC9F,MAAM,EAAE,OAAO;YACf,SAAS,EAAE,QAAiB;YAC5B,OAAO,EAAE,MAAM;YACf,aAAa,EAAE,QAAiB;YAChC,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;SACzB;KACF,EACD,KAAK,CAAC,aAAa,CACjB,KAAK,EACL,IAAI,EACJ,KAAK,CAAC,aAAa,CACjB,IAAI,EACJ;QACE,KAAK,EAAE;YACL,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE,YAAY;YACpB,OAAO,EAAE,YAAY;YACrB,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,GAAG;YACf,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,MAAM;YAClB,WAAW,EAAE,6BAA6B;SAC3C;KACF,EACD,UAAU,CACX,EACD,KAAK,CAAC,aAAa,CACjB,KAAK,EACL,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EACtC,KAAK,CAAC,aAAa,CACjB,IAAI,EACJ;QACE,KAAK,EAAE;YACL,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,GAAG;YACf,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,CAAC;SACV;KACF,EACD,YAAY,GAAG,GAAG,CACnB,CACF,CACF,CACF,CAAC;AACJ,CAAC;AAED,eAAe,cAAc,CAAC","sourcesContent":["/**\n * next/error shim\n *\n * Provides the default Next.js error page component.\n * Used by apps that import `import Error from 'next/error'` for\n * custom error handling in getServerSideProps or API routes.\n */\nimport React from \"react\";\n\ninterface ErrorProps {\n statusCode: number;\n title?: string;\n withDarkMode?: boolean;\n}\n\nfunction ErrorComponent({ statusCode, title }: ErrorProps): React.ReactElement {\n const defaultTitle =\n statusCode === 404 ? \"This page could not be found\" : \"Internal Server Error\";\n\n const displayTitle = title ?? defaultTitle;\n\n return React.createElement(\n \"div\",\n {\n style: {\n fontFamily:\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n height: \"100vh\",\n textAlign: \"center\" as const,\n display: \"flex\",\n flexDirection: \"column\" as const,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n },\n React.createElement(\n \"div\",\n null,\n React.createElement(\n \"h1\",\n {\n style: {\n display: \"inline-block\",\n margin: \"0 20px 0 0\",\n padding: \"0 23px 0 0\",\n fontSize: 24,\n fontWeight: 500,\n verticalAlign: \"top\",\n lineHeight: \"49px\",\n borderRight: \"1px solid rgba(0, 0, 0, .3)\",\n },\n },\n statusCode,\n ),\n React.createElement(\n \"div\",\n { style: { display: \"inline-block\" } },\n React.createElement(\n \"h2\",\n {\n style: {\n fontSize: 14,\n fontWeight: 400,\n lineHeight: \"49px\",\n margin: 0,\n },\n },\n displayTitle + \".\",\n ),\n ),\n ),\n );\n}\n\nexport default ErrorComponent;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-cache.d.ts","sourceRoot":"","sources":["../../src/shims/fetch-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AA0WH,UAAU,gBAAgB;IACxB,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,WAAW;QACnB,IAAI,CAAC,EAAE,gBAAgB,CAAC;KACzB;CACF;AA0CD;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,EAAE,CAEhD;AAoOD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,IAAI,MAAM,IAAI,CAO3C;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAG3E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,UAAU,CAAC,KAAK,CAE1D"}
1
+ {"version":3,"file":"fetch-cache.d.ts","sourceRoot":"","sources":["../../src/shims/fetch-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAyXH,UAAU,gBAAgB;IACxB,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,WAAW;QACnB,IAAI,CAAC,EAAE,gBAAgB,CAAC;KACzB;CACF;AA4CD;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,EAAE,CAEhD;AA2PD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,IAAI,MAAM,IAAI,CAO3C;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAG3E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,UAAU,CAAC,KAAK,CAE1D"}
@@ -18,7 +18,7 @@
18
18
  * Or use the async helper:
19
19
  * await runWithFetchCache(async () => { ... render ... });
20
20
  */
21
- import { getCacheHandler, } from "./cache.js";
21
+ import { getCacheHandler } from "./cache.js";
22
22
  import { AsyncLocalStorage } from "node:async_hooks";
23
23
  // ---------------------------------------------------------------------------
24
24
  // Cache key generation
@@ -51,14 +51,16 @@ function collectHeaders(input, init) {
51
51
  const merged = {};
52
52
  // Start with headers from Request object (if any)
53
53
  if (input instanceof Request && input.headers) {
54
- input.headers.forEach((v, k) => { merged[k] = v; });
54
+ input.headers.forEach((v, k) => {
55
+ merged[k] = v;
56
+ });
55
57
  }
56
58
  // Override with headers from init (init takes precedence per fetch spec)
57
59
  if (init?.headers) {
58
- const headers = init.headers instanceof Headers
59
- ? init.headers
60
- : new Headers(init.headers);
61
- headers.forEach((v, k) => { merged[k] = v; });
60
+ const headers = init.headers instanceof Headers ? init.headers : new Headers(init.headers);
61
+ headers.forEach((v, k) => {
62
+ merged[k] = v;
63
+ });
62
64
  }
63
65
  // Remove blocklisted headers
64
66
  for (const blocked of HEADER_BLOCKLIST) {
@@ -82,15 +84,19 @@ async function serializeFormData(formData, pushBodyChunk, getTotalBodyBytes) {
82
84
  pushBodyChunk(JSON.stringify([key, { kind: "string", value: val }]));
83
85
  continue;
84
86
  }
85
- if (val.size > MAX_CACHE_KEY_BODY_BYTES || getTotalBodyBytes() + val.size > MAX_CACHE_KEY_BODY_BYTES) {
87
+ if (val.size > MAX_CACHE_KEY_BODY_BYTES ||
88
+ getTotalBodyBytes() + val.size > MAX_CACHE_KEY_BODY_BYTES) {
86
89
  throw new BodyTooLargeForCacheKeyError();
87
90
  }
88
- pushBodyChunk(JSON.stringify([key, {
91
+ pushBodyChunk(JSON.stringify([
92
+ key,
93
+ {
89
94
  kind: "file",
90
95
  name: val.name,
91
96
  type: val.type,
92
97
  value: await val.text(),
93
- }]));
98
+ },
99
+ ]));
94
100
  }
95
101
  }
96
102
  function getParsedFormContentType(contentType) {
@@ -107,9 +113,7 @@ function stripMultipartBoundary(contentType) {
107
113
  .filter(Boolean)
108
114
  .filter((param) => !/^boundary\s*=/i.test(param));
109
115
  const normalizedType = type.trim().toLowerCase();
110
- return keptParams.length > 0
111
- ? `${normalizedType}; ${keptParams.join("; ")}`
112
- : normalizedType;
116
+ return keptParams.length > 0 ? `${normalizedType}; ${keptParams.join("; ")}` : normalizedType;
113
117
  }
114
118
  async function readRequestBodyChunksWithinLimit(request) {
115
119
  const contentLengthHeader = request.headers.get("content-length");
@@ -265,9 +269,10 @@ async function serializeBody(input, init) {
265
269
  });
266
270
  const formData = await boundedRequest.formData();
267
271
  await serializeFormData(formData, pushBodyChunk, getTotalBodyBytes);
268
- canonicalizedContentType = formContentType === "multipart/form-data" && contentType
269
- ? stripMultipartBoundary(contentType)
270
- : undefined;
272
+ canonicalizedContentType =
273
+ formContentType === "multipart/form-data" && contentType
274
+ ? stripMultipartBoundary(contentType)
275
+ : undefined;
271
276
  return { bodyChunks, canonicalizedContentType };
272
277
  }
273
278
  catch (err) {
@@ -343,11 +348,13 @@ async function buildFetchCacheKey(input, init) {
343
348
  // multi-environment module instances via Symbol.for().
344
349
  const _ORIG_FETCH_KEY = Symbol.for("vinext.fetchCache.originalFetch");
345
350
  const _gFetch = globalThis;
346
- const originalFetch = (_gFetch[_ORIG_FETCH_KEY] ??= globalThis.fetch);
351
+ const originalFetch = (_gFetch[_ORIG_FETCH_KEY] ??=
352
+ globalThis.fetch);
347
353
  const _ALS_KEY = Symbol.for("vinext.fetchCache.als");
348
354
  const _FALLBACK_KEY = Symbol.for("vinext.fetchCache.fallback");
349
355
  const _g = globalThis;
350
- const _als = (_g[_ALS_KEY] ??= new AsyncLocalStorage());
356
+ const _als = (_g[_ALS_KEY] ??=
357
+ new AsyncLocalStorage());
351
358
  const _fallbackState = (_g[_FALLBACK_KEY] ??= {
352
359
  currentRequestTags: [],
353
360
  });
@@ -395,7 +402,10 @@ function createPatchedFetch() {
395
402
  return originalFetch(input, init);
396
403
  }
397
404
  // Explicit no-store or no-cache — bypass cache entirely
398
- if (cacheDirective === "no-store" || cacheDirective === "no-cache" || nextOpts?.revalidate === false || nextOpts?.revalidate === 0) {
405
+ if (cacheDirective === "no-store" ||
406
+ cacheDirective === "no-cache" ||
407
+ nextOpts?.revalidate === false ||
408
+ nextOpts?.revalidate === 0) {
399
409
  // Strip the `next` property before passing to real fetch
400
410
  const cleanInit = stripNextFromInit(init);
401
411
  return originalFetch(input, cleanInit);
@@ -415,9 +425,10 @@ function createPatchedFetch() {
415
425
  let revalidateSeconds;
416
426
  if (cacheDirective === "force-cache") {
417
427
  // force-cache means cache indefinitely (we use a very large number)
418
- revalidateSeconds = nextOpts?.revalidate && typeof nextOpts.revalidate === "number"
419
- ? nextOpts.revalidate
420
- : 31536000; // 1 year
428
+ revalidateSeconds =
429
+ nextOpts?.revalidate && typeof nextOpts.revalidate === "number"
430
+ ? nextOpts.revalidate
431
+ : 31536000; // 1 year
421
432
  }
422
433
  else if (typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0) {
423
434
  revalidateSeconds = nextOpts.revalidate;
@@ -441,7 +452,8 @@ function createPatchedFetch() {
441
452
  cacheKey = await buildFetchCacheKey(input, init);
442
453
  }
443
454
  catch (err) {
444
- if (err instanceof BodyTooLargeForCacheKeyError || err instanceof SkipCacheKeyGenerationError) {
455
+ if (err instanceof BodyTooLargeForCacheKeyError ||
456
+ err instanceof SkipCacheKeyGenerationError) {
445
457
  const cleanInit = stripNextFromInit(init);
446
458
  return originalFetch(input, cleanInit);
447
459
  }
@@ -475,16 +487,23 @@ function createPatchedFetch() {
475
487
  const staleData = cached.value.data;
476
488
  // Background refetch
477
489
  const cleanInit = stripNextFromInit(init);
478
- originalFetch(input, cleanInit).then(async (freshResp) => {
490
+ originalFetch(input, cleanInit)
491
+ .then(async (freshResp) => {
479
492
  const freshBody = await freshResp.text();
480
493
  const freshHeaders = {};
481
- freshResp.headers.forEach((v, k) => { freshHeaders[k] = v; });
494
+ freshResp.headers.forEach((v, k) => {
495
+ freshHeaders[k] = v;
496
+ });
482
497
  const freshValue = {
483
498
  kind: "FETCH",
484
499
  data: {
485
500
  headers: freshHeaders,
486
501
  body: freshBody,
487
- url: typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url,
502
+ url: typeof input === "string"
503
+ ? input
504
+ : input instanceof URL
505
+ ? input.toString()
506
+ : input.url,
488
507
  status: freshResp.status,
489
508
  },
490
509
  tags,
@@ -495,7 +514,8 @@ function createPatchedFetch() {
495
514
  tags,
496
515
  revalidate: revalidateSeconds,
497
516
  });
498
- }).catch((err) => {
517
+ })
518
+ .catch((err) => {
499
519
  console.error("[vinext] fetch cache background revalidation failed:", err);
500
520
  });
501
521
  // Return stale data immediately
@@ -518,7 +538,9 @@ function createPatchedFetch() {
518
538
  const cloned = response.clone();
519
539
  const body = await cloned.text();
520
540
  const headers = {};
521
- cloned.headers.forEach((v, k) => { headers[k] = v; });
541
+ cloned.headers.forEach((v, k) => {
542
+ headers[k] = v;
543
+ });
522
544
  const cacheValue = {
523
545
  kind: "FETCH",
524
546
  data: {
@@ -531,11 +553,13 @@ function createPatchedFetch() {
531
553
  revalidate: revalidateSeconds,
532
554
  };
533
555
  // Store in cache (fire-and-forget)
534
- handler.set(cacheKey, cacheValue, {
556
+ handler
557
+ .set(cacheKey, cacheValue, {
535
558
  fetchCache: true,
536
559
  tags,
537
560
  revalidate: revalidateSeconds,
538
- }).catch((err) => {
561
+ })
562
+ .catch((err) => {
539
563
  console.error("[vinext] fetch cache write error:", err);
540
564
  });
541
565
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-cache.js","s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IAC3B,EAAE,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IACtB,UAAU,CAAC,KAAK,GAAG,kBAAkB,EAAE,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc;IAC5B,qBAAqB,EAAE,CAAC;IACxB,mBAAmB,EAAE,CAAC;IAEtB,OAAO,GAAG,EAAE;QACV,mBAAmB,EAAE,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAI,EAAoB;IAC7D,qBAAqB,EAAE,CAAC;IACxB,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,kBAAkB,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["/**\n * Extended fetch() with Next.js caching semantics.\n *\n * Patches `globalThis.fetch` during server rendering to support:\n *\n * fetch(url, { next: { revalidate: 60, tags: ['posts'] } })\n * fetch(url, { cache: 'force-cache' })\n * fetch(url, { cache: 'no-store' })\n *\n * Cached responses are stored via the pluggable CacheHandler, so\n * revalidateTag() and revalidatePath() invalidate fetch-level caches.\n *\n * Usage (in server entry):\n * import { withFetchCache, cleanupFetchCache } from './fetch-cache';\n * const cleanup = withFetchCache();\n * try { ... render ... } finally { cleanup(); }\n *\n * Or use the async helper:\n * await runWithFetchCache(async () => { ... render ... });\n */\n\nimport {\n getCacheHandler,\n type CachedFetchValue,\n} from \"./cache.js\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n\n// ---------------------------------------------------------------------------\n// Cache key generation\n// ---------------------------------------------------------------------------\n\n/**\n * Headers excluded from the cache key. These are W3C trace context headers\n * that can break request caching and deduplication.\n * All other headers ARE included in the cache key, matching Next.js behavior.\n */\nconst HEADER_BLOCKLIST = [\"traceparent\", \"tracestate\"];\n\n// Cache key version — bump when changing the key format to bust stale entries\nconst CACHE_KEY_PREFIX = \"v3\";\nconst MAX_CACHE_KEY_BODY_BYTES = 1024 * 1024; // 1 MiB\n\nclass BodyTooLargeForCacheKeyError extends Error {\n constructor() {\n super(\"Fetch body too large for cache key generation\");\n }\n}\n\nclass SkipCacheKeyGenerationError extends Error {\n constructor() {\n super(\"Fetch body could not be serialized for cache key generation\");\n }\n}\n\n/**\n * Collect all headers from the request, excluding the blocklist.\n * Merges headers from both the Request object and the init object,\n * with init taking precedence (matching fetch() spec behavior).\n */\nfunction collectHeaders(input: string | URL | Request, init?: RequestInit): Record<string, string> {\n const merged: Record<string, string> = {};\n\n // Start with headers from Request object (if any)\n if (input instanceof Request && input.headers) {\n input.headers.forEach((v, k) => { merged[k] = v; });\n }\n\n // Override with headers from init (init takes precedence per fetch spec)\n if (init?.headers) {\n const headers = init.headers instanceof Headers\n ? init.headers\n : new Headers(init.headers as HeadersInit);\n headers.forEach((v, k) => { merged[k] = v; });\n }\n\n // Remove blocklisted headers\n for (const blocked of HEADER_BLOCKLIST) {\n delete merged[blocked];\n }\n\n return merged;\n}\n\n/**\n * Check whether a fetch request carries any per-user auth headers.\n * Used for the safety bypass (skip caching when auth headers are present\n * without an explicit cache opt-in).\n */\nconst AUTH_HEADERS = [\"authorization\", \"cookie\", \"x-api-key\"];\n\nfunction hasAuthHeaders(input: string | URL | Request, init?: RequestInit): boolean {\n const headers = collectHeaders(input, init);\n return AUTH_HEADERS.some((name) => name in headers);\n}\n\nasync function serializeFormData(\n formData: FormData,\n pushBodyChunk: (chunk: string) => void,\n getTotalBodyBytes: () => number,\n): Promise<void> {\n for (const [key, val] of formData.entries()) {\n if (typeof val === \"string\") {\n pushBodyChunk(JSON.stringify([key, { kind: \"string\", value: val }]));\n continue;\n }\n if (val.size > MAX_CACHE_KEY_BODY_BYTES || getTotalBodyBytes() + val.size > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n pushBodyChunk(JSON.stringify([key, {\n kind: \"file\",\n name: val.name,\n type: val.type,\n value: await val.text(),\n }]));\n }\n}\n\ntype ParsedFormContentType = \"multipart/form-data\" | \"application/x-www-form-urlencoded\";\n\nfunction getParsedFormContentType(contentType: string | undefined): ParsedFormContentType | undefined {\n const mediaType = contentType?.split(\";\")[0]?.trim().toLowerCase();\n if (mediaType === \"multipart/form-data\" || mediaType === \"application/x-www-form-urlencoded\") {\n return mediaType;\n }\n return undefined;\n}\n\nfunction stripMultipartBoundary(contentType: string): string {\n const [type, ...params] = contentType.split(\";\");\n const keptParams = params\n .map((param) => param.trim())\n .filter(Boolean)\n .filter((param) => !/^boundary\\s*=/i.test(param));\n const normalizedType = type.trim().toLowerCase();\n return keptParams.length > 0\n ? `${normalizedType}; ${keptParams.join(\"; \")}`\n : normalizedType;\n}\n\ninterface SerializedBodyResult {\n bodyChunks: string[];\n canonicalizedContentType?: string;\n}\n\nasync function readRequestBodyChunksWithinLimit(request: Request): Promise<{\n chunks: Uint8Array[];\n contentType: string | undefined;\n}> {\n const contentLengthHeader = request.headers.get(\"content-length\");\n if (contentLengthHeader) {\n const contentLength = Number(contentLengthHeader);\n if (Number.isFinite(contentLength) && contentLength > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n }\n\n const requestClone = request.clone();\n const contentType = requestClone.headers.get(\"content-type\") ?? undefined;\n const reader = requestClone.body?.getReader();\n if (!reader) {\n return { chunks: [], contentType };\n }\n\n const chunks: Uint8Array[] = [];\n let totalBodyBytes = 0;\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n totalBodyBytes += value.byteLength;\n if (totalBodyBytes > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n\n chunks.push(value);\n }\n } catch (err) {\n void reader.cancel().catch(() => {});\n throw err;\n }\n\n return { chunks, contentType };\n}\n\n/**\n * Serialize request body into string chunks for cache key inclusion.\n * Handles all body types: string, Uint8Array, ReadableStream, FormData, Blob,\n * and Request object bodies.\n * Returns the serialized body chunks and optionally stashes the original body\n * on init as `_ogBody` so it can still be used after stream consumption.\n */\nasync function serializeBody(input: string | URL | Request, init?: RequestInit): Promise<SerializedBodyResult> {\n if (!init?.body && !(input instanceof Request && input.body)) {\n return { bodyChunks: [] };\n }\n\n const bodyChunks: string[] = [];\n const encoder = new TextEncoder();\n const decoder = new TextDecoder();\n let totalBodyBytes = 0;\n let canonicalizedContentType: string | undefined;\n\n const pushBodyChunk = (chunk: string): void => {\n totalBodyBytes += encoder.encode(chunk).byteLength;\n if (totalBodyBytes > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n bodyChunks.push(chunk);\n };\n const getTotalBodyBytes = (): number => totalBodyBytes;\n\n if (init?.body instanceof Uint8Array) {\n if (init.body.byteLength > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n pushBodyChunk(decoder.decode(init.body));\n (init as any)._ogBody = init.body;\n } else if (init?.body && typeof (init.body as any).getReader === \"function\") {\n // ReadableStream\n const readableBody = init.body as ReadableStream<Uint8Array | string>;\n const [bodyForHashing, bodyForFetch] = readableBody.tee();\n (init as any)._ogBody = bodyForFetch;\n const reader = bodyForHashing.getReader();\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n if (typeof value === \"string\") {\n pushBodyChunk(value);\n } else {\n // Check raw byte size before the expensive decode to prevent\n // OOM from a single oversized chunk.\n totalBodyBytes += value.byteLength;\n if (totalBodyBytes > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n bodyChunks.push(decoder.decode(value, { stream: true }));\n }\n }\n const finalChunk = decoder.decode();\n if (finalChunk) {\n pushBodyChunk(finalChunk);\n }\n } catch (err) {\n await reader.cancel();\n if (err instanceof BodyTooLargeForCacheKeyError) {\n throw err;\n }\n throw new SkipCacheKeyGenerationError();\n }\n } else if (init?.body instanceof URLSearchParams) {\n // URLSearchParams — .toString() gives a stable serialization\n (init as any)._ogBody = init.body;\n pushBodyChunk(init.body.toString());\n } else if (init?.body && typeof (init.body as any).keys === \"function\") {\n // FormData\n const formData = init.body as FormData;\n (init as any)._ogBody = init.body;\n await serializeFormData(formData, pushBodyChunk, getTotalBodyBytes);\n } else if (init?.body && typeof (init.body as any).arrayBuffer === \"function\") {\n // Blob\n const blob = init.body as Blob;\n if (blob.size > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n pushBodyChunk(await blob.text());\n const arrayBuffer = await blob.arrayBuffer();\n (init as any)._ogBody = new Blob([arrayBuffer], { type: blob.type });\n } else if (typeof init?.body === \"string\") {\n // String length is always <= UTF-8 byte length, so this is a\n // cheap lower-bound check that avoids encoder.encode() for huge strings.\n if (init.body.length > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n pushBodyChunk(init.body);\n (init as any)._ogBody = init.body;\n } else if (input instanceof Request && input.body) {\n let chunks: Uint8Array[];\n let contentType: string | undefined;\n try {\n ({ chunks, contentType } = await readRequestBodyChunksWithinLimit(input));\n } catch (err) {\n if (err instanceof BodyTooLargeForCacheKeyError) {\n throw err;\n }\n throw new SkipCacheKeyGenerationError();\n }\n const formContentType = getParsedFormContentType(contentType);\n\n if (formContentType) {\n try {\n const boundedRequest = new Request(input.url, {\n method: input.method,\n headers: contentType ? { \"content-type\": contentType } : undefined,\n body: new Blob(chunks as unknown as BlobPart[]),\n });\n const formData = await boundedRequest.formData();\n await serializeFormData(formData, pushBodyChunk, getTotalBodyBytes);\n canonicalizedContentType = formContentType === \"multipart/form-data\" && contentType\n ? stripMultipartBoundary(contentType)\n : undefined;\n return { bodyChunks, canonicalizedContentType };\n } catch (err) {\n if (err instanceof BodyTooLargeForCacheKeyError) {\n throw err;\n }\n throw new SkipCacheKeyGenerationError();\n }\n }\n\n for (const chunk of chunks) {\n pushBodyChunk(decoder.decode(chunk, { stream: true }));\n }\n const finalChunk = decoder.decode();\n if (finalChunk) {\n pushBodyChunk(finalChunk);\n }\n }\n\n return { bodyChunks, canonicalizedContentType };\n}\n\n/**\n * Generate a deterministic cache key from a fetch request.\n *\n * Matches Next.js behavior: the key is a SHA-256 hash of a JSON array\n * containing URL, method, all headers (minus blocklist), all RequestInit\n * options, and the serialized body.\n */\nasync function buildFetchCacheKey(input: string | URL | Request, init?: RequestInit & { next?: NextFetchOptions }): Promise<string> {\n let url: string;\n let method = \"GET\";\n\n if (typeof input === \"string\") {\n url = input;\n } else if (input instanceof URL) {\n url = input.toString();\n } else {\n // Request object\n url = input.url;\n method = input.method || \"GET\";\n }\n\n if (init?.method) method = init.method;\n\n const headers = collectHeaders(input, init);\n const { bodyChunks, canonicalizedContentType } = await serializeBody(input, init);\n if (canonicalizedContentType) {\n headers[\"content-type\"] = canonicalizedContentType;\n }\n\n const cacheString = JSON.stringify([\n CACHE_KEY_PREFIX,\n url,\n method,\n headers,\n init?.mode,\n init?.redirect,\n init?.credentials,\n init?.referrer,\n init?.referrerPolicy,\n init?.integrity,\n init?.cache,\n bodyChunks,\n ]);\n\n const encoder = new TextEncoder();\n const buffer = encoder.encode(cacheString);\n const hashBuffer = await crypto.subtle.digest(\"SHA-256\", buffer);\n return Array.prototype.map\n .call(new Uint8Array(hashBuffer), (b: number) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ninterface NextFetchOptions {\n revalidate?: number | false;\n tags?: string[];\n}\n\n// Extend the standard RequestInit to include `next`\ndeclare global {\n interface RequestInit {\n next?: NextFetchOptions;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Patching\n// ---------------------------------------------------------------------------\n\n// Capture the real (unpatched) fetch once, shared across Vite's\n// multi-environment module instances via Symbol.for().\nconst _ORIG_FETCH_KEY = Symbol.for(\"vinext.fetchCache.originalFetch\");\nconst _gFetch = globalThis as unknown as Record<PropertyKey, unknown>;\nconst originalFetch: typeof globalThis.fetch = (_gFetch[_ORIG_FETCH_KEY] ??= globalThis.fetch) as typeof globalThis.fetch;\n\n// ---------------------------------------------------------------------------\n// AsyncLocalStorage for request-scoped fetch cache state.\n// Uses Symbol.for() on globalThis so the storage is shared across Vite's\n// multi-environment module instances.\n// ---------------------------------------------------------------------------\ninterface FetchCacheState {\n currentRequestTags: string[];\n}\n\nconst _ALS_KEY = Symbol.for(\"vinext.fetchCache.als\");\nconst _FALLBACK_KEY = Symbol.for(\"vinext.fetchCache.fallback\");\nconst _g = globalThis as unknown as Record<PropertyKey, unknown>;\nconst _als = (_g[_ALS_KEY] ??= new AsyncLocalStorage<FetchCacheState>()) as AsyncLocalStorage<FetchCacheState>;\n\nconst _fallbackState = (_g[_FALLBACK_KEY] ??= {\n currentRequestTags: [],\n} satisfies FetchCacheState) as FetchCacheState;\n\nfunction _getState(): FetchCacheState {\n return _als.getStore() ?? _fallbackState;\n}\n\n/**\n * Reset the fallback state for a new request. Used by `withFetchCache()`\n * in single-threaded contexts where ALS.run() isn't used.\n */\nfunction _resetFallbackState(): void {\n _fallbackState.currentRequestTags = [];\n}\n\n/**\n * Get tags collected during the current render pass.\n * Useful for associating page-level cache entries with all the\n * fetch tags used during rendering.\n */\nexport function getCollectedFetchTags(): string[] {\n return [..._getState().currentRequestTags];\n}\n\n/**\n * Create a patched fetch function with Next.js caching semantics.\n *\n * The patched fetch:\n * 1. Checks `cache` and `next` options to determine caching behavior\n * 2. On cache hit, returns the cached response without hitting the network\n * 3. On cache miss, fetches from network, stores in cache, returns response\n * 4. Respects `next.revalidate` for TTL-based revalidation\n * 5. Respects `next.tags` for tag-based invalidation via revalidateTag()\n */\nfunction createPatchedFetch(): typeof globalThis.fetch {\n return async function patchedFetch(\n input: string | URL | Request,\n init?: RequestInit,\n ): Promise<Response> {\n const nextOpts = init?.next as NextFetchOptions | undefined;\n const cacheDirective = init?.cache;\n\n // Determine caching behavior:\n // - cache: 'no-store' → skip cache entirely\n // - cache: 'force-cache' → cache indefinitely (revalidate = Infinity)\n // - next.revalidate: false → same as 'no-store'\n // - next.revalidate: 0 → same as 'no-store'\n // - next.revalidate: N → cache for N seconds\n // - No cache/next options → default behavior (no caching, pass-through)\n\n // If no caching options at all, just pass through to original fetch\n if (!nextOpts && !cacheDirective) {\n return originalFetch(input, init);\n }\n\n // Explicit no-store or no-cache — bypass cache entirely\n if (cacheDirective === \"no-store\" || cacheDirective === \"no-cache\" || nextOpts?.revalidate === false || nextOpts?.revalidate === 0) {\n // Strip the `next` property before passing to real fetch\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n\n // Safety: when per-user auth headers are present and the developer hasn't\n // explicitly opted into caching with `cache: 'force-cache'` or an explicit\n // `next.revalidate`, skip caching to prevent accidental cross-user data\n // leakage. Developers who understand the implications can still force\n // caching by using `cache: 'force-cache'` or `next: { revalidate: N }`.\n const hasExplicitCacheOpt =\n cacheDirective === \"force-cache\" ||\n (typeof nextOpts?.revalidate === \"number\" && nextOpts.revalidate > 0);\n if (!hasExplicitCacheOpt && hasAuthHeaders(input, init)) {\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n\n // Determine revalidation period\n let revalidateSeconds: number;\n if (cacheDirective === \"force-cache\") {\n // force-cache means cache indefinitely (we use a very large number)\n revalidateSeconds = nextOpts?.revalidate && typeof nextOpts.revalidate === \"number\"\n ? nextOpts.revalidate\n : 31536000; // 1 year\n } else if (typeof nextOpts?.revalidate === \"number\" && nextOpts.revalidate > 0) {\n revalidateSeconds = nextOpts.revalidate;\n } else {\n // Has `next` options but no explicit revalidate — Next.js defaults to\n // caching when `next` is present (force-cache behavior).\n // If only tags are specified, cache indefinitely.\n if (nextOpts?.tags && nextOpts.tags.length > 0) {\n revalidateSeconds = 31536000;\n } else {\n // next: {} with no revalidate or tags — pass through\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n }\n\n const tags = nextOpts?.tags ?? [];\n let cacheKey: string;\n try {\n cacheKey = await buildFetchCacheKey(input, init);\n } catch (err) {\n if (err instanceof BodyTooLargeForCacheKeyError || err instanceof SkipCacheKeyGenerationError) {\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n throw err;\n }\n const handler = getCacheHandler();\n\n // Collect tags for this render pass\n const reqTags = _getState().currentRequestTags;\n if (tags.length > 0) {\n for (const tag of tags) {\n if (!reqTags.includes(tag)) {\n reqTags.push(tag);\n }\n }\n }\n\n // Try cache first\n try {\n const cached = await handler.get(cacheKey, { kind: \"FETCH\", tags });\n if (cached?.value && cached.value.kind === \"FETCH\" && cached.cacheState !== \"stale\") {\n const cachedData = cached.value.data;\n // Reconstruct a Response from the cached data\n return new Response(cachedData.body, {\n status: cachedData.status ?? 200,\n headers: cachedData.headers,\n });\n }\n\n // Stale entry — we could do stale-while-revalidate here, but for fetch()\n // the simpler approach is to just re-fetch (the page-level ISR handles SWR).\n // However, if we have a stale entry, return it and trigger background refetch.\n if (cached?.value && cached.value.kind === \"FETCH\" && cached.cacheState === \"stale\") {\n const staleData = cached.value.data;\n\n // Background refetch\n const cleanInit = stripNextFromInit(init);\n originalFetch(input, cleanInit).then(async (freshResp) => {\n const freshBody = await freshResp.text();\n const freshHeaders: Record<string, string> = {};\n freshResp.headers.forEach((v, k) => { freshHeaders[k] = v; });\n\n const freshValue: CachedFetchValue = {\n kind: \"FETCH\",\n data: {\n headers: freshHeaders,\n body: freshBody,\n url: typeof input === \"string\" ? input : input instanceof URL ? input.toString() : input.url,\n status: freshResp.status,\n },\n tags,\n revalidate: revalidateSeconds,\n };\n await handler.set(cacheKey, freshValue, {\n fetchCache: true,\n tags,\n revalidate: revalidateSeconds,\n });\n }).catch((err) => {\n console.error(\"[vinext] fetch cache background revalidation failed:\", err);\n });\n\n // Return stale data immediately\n return new Response(staleData.body, {\n status: staleData.status ?? 200,\n headers: staleData.headers,\n });\n }\n } catch (cacheErr) {\n // Cache read failed — fall through to network\n console.error(\"[vinext] fetch cache read error:\", cacheErr);\n }\n\n // Cache miss — fetch from network\n const cleanInit = stripNextFromInit(init);\n const response = await originalFetch(input, cleanInit);\n\n // Only cache successful responses (2xx)\n if (response.ok) {\n // Clone before reading body\n const cloned = response.clone();\n const body = await cloned.text();\n const headers: Record<string, string> = {};\n cloned.headers.forEach((v, k) => { headers[k] = v; });\n\n const cacheValue: CachedFetchValue = {\n kind: \"FETCH\",\n data: {\n headers,\n body,\n url: typeof input === \"string\" ? input : input instanceof URL ? input.toString() : input.url,\n status: cloned.status,\n },\n tags,\n revalidate: revalidateSeconds,\n };\n\n // Store in cache (fire-and-forget)\n handler.set(cacheKey, cacheValue, {\n fetchCache: true,\n tags,\n revalidate: revalidateSeconds,\n }).catch((err) => {\n console.error(\"[vinext] fetch cache write error:\", err);\n });\n }\n\n return response;\n } as typeof globalThis.fetch;\n}\n\n/**\n * Strip the `next` property from RequestInit before passing to real fetch.\n * The `next` property is not a standard fetch option and would cause warnings\n * in some environments.\n */\nfunction stripNextFromInit(init?: RequestInit): RequestInit | undefined {\n if (!init) return init;\n const castInit = init as RequestInit & { next?: unknown; _ogBody?: BodyInit };\n const { next: _next, _ogBody, ...rest } = castInit;\n // Restore the original body if it was stashed by serializeBody (e.g. after\n // consuming a ReadableStream for cache key generation).\n if (_ogBody !== undefined) {\n rest.body = _ogBody;\n }\n return Object.keys(rest).length > 0 ? rest : undefined;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n// ---------------------------------------------------------------------------\n// Fetch patching — install once, not per-request.\n// The patched fetch uses _getState() internally, which reads from ALS\n// (concurrent) or _fallbackState (single-threaded), so per-request\n// isolation is handled at the state level, not by swapping globalThis.fetch.\n// ---------------------------------------------------------------------------\n\nconst _PATCH_KEY = Symbol.for(\"vinext.fetchCache.patchInstalled\");\n\nfunction _ensurePatchInstalled(): void {\n if (_g[_PATCH_KEY]) return;\n _g[_PATCH_KEY] = true;\n globalThis.fetch = createPatchedFetch();\n}\n\n/**\n * Install the patched fetch and reset per-request tag state.\n * Returns a cleanup function that clears tags.\n *\n * @deprecated Prefer `runWithFetchCache()` which uses `AsyncLocalStorage.run()`\n * for proper per-request isolation in concurrent environments.\n *\n * Usage:\n * const cleanup = withFetchCache();\n * try { await render(); } finally { cleanup(); }\n */\nexport function withFetchCache(): () => void {\n _ensurePatchInstalled();\n _resetFallbackState();\n\n return () => {\n _resetFallbackState();\n };\n}\n\n/**\n * Run an async function with patched fetch caching enabled.\n * Uses `AsyncLocalStorage.run()` for proper per-request isolation\n * of collected fetch tags in concurrent server environments.\n */\nexport async function runWithFetchCache<T>(fn: () => Promise<T>): Promise<T> {\n _ensurePatchInstalled();\n return _als.run({ currentRequestTags: [] }, fn);\n}\n\n/**\n * Get the original (unpatched) fetch function.\n * Useful for internal code that should bypass caching.\n */\nexport function getOriginalFetch(): typeof globalThis.fetch {\n return originalFetch;\n}\n"]}
1
+ {"version":3,"file":"fetch-cache.js","sourceRoot":"","sources":["../../src/shims/fetch-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,eAAe,EAAyB,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;AAEvD,8EAA8E;AAC9E,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,wBAAwB,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ;AAEtD,MAAM,4BAA6B,SAAQ,KAAK;IAC9C;QACE,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACzD,CAAC;CACF;AAED,MAAM,2BAA4B,SAAQ,KAAK;IAC7C;QACE,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACvE,CAAC;CACF;AAED;;;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ch` during server rendering to support:\n *\n * fetch(url, { next: { revalidate: 60, tags: ['posts'] } })\n * fetch(url, { cache: 'force-cache' })\n * fetch(url, { cache: 'no-store' })\n *\n * Cached responses are stored via the pluggable CacheHandler, so\n * revalidateTag() and revalidatePath() invalidate fetch-level caches.\n *\n * Usage (in server entry):\n * import { withFetchCache, cleanupFetchCache } from './fetch-cache';\n * const cleanup = withFetchCache();\n * try { ... render ... } finally { cleanup(); }\n *\n * Or use the async helper:\n * await runWithFetchCache(async () => { ... render ... });\n */\n\nimport { getCacheHandler, type CachedFetchValue } from \"./cache.js\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n\n// ---------------------------------------------------------------------------\n// Cache key generation\n// ---------------------------------------------------------------------------\n\n/**\n * Headers excluded from the cache key. These are W3C trace context headers\n * that can break request caching and deduplication.\n * All other headers ARE included in the cache key, matching Next.js behavior.\n */\nconst HEADER_BLOCKLIST = [\"traceparent\", \"tracestate\"];\n\n// Cache key version — bump when changing the key format to bust stale entries\nconst CACHE_KEY_PREFIX = \"v3\";\nconst MAX_CACHE_KEY_BODY_BYTES = 1024 * 1024; // 1 MiB\n\nclass BodyTooLargeForCacheKeyError extends Error {\n constructor() {\n super(\"Fetch body too large for cache key generation\");\n }\n}\n\nclass SkipCacheKeyGenerationError extends Error {\n constructor() {\n super(\"Fetch body could not be serialized for cache key generation\");\n }\n}\n\n/**\n * Collect all headers from the request, excluding the blocklist.\n * Merges headers from both the Request object and the init object,\n * with init taking precedence (matching fetch() spec behavior).\n */\nfunction collectHeaders(input: string | URL | Request, init?: RequestInit): Record<string, string> {\n const merged: Record<string, string> = {};\n\n // Start with headers from Request object (if any)\n if (input instanceof Request && input.headers) {\n input.headers.forEach((v, k) => {\n merged[k] = v;\n });\n }\n\n // Override with headers from init (init takes precedence per fetch spec)\n if (init?.headers) {\n const headers =\n init.headers instanceof Headers ? init.headers : new Headers(init.headers as HeadersInit);\n headers.forEach((v, k) => {\n merged[k] = v;\n });\n }\n\n // Remove blocklisted headers\n for (const blocked of HEADER_BLOCKLIST) {\n delete merged[blocked];\n }\n\n return merged;\n}\n\n/**\n * Check whether a fetch request carries any per-user auth headers.\n * Used for the safety bypass (skip caching when auth headers are present\n * without an explicit cache opt-in).\n */\nconst AUTH_HEADERS = [\"authorization\", \"cookie\", \"x-api-key\"];\n\nfunction hasAuthHeaders(input: string | URL | Request, init?: RequestInit): boolean {\n const headers = collectHeaders(input, init);\n return AUTH_HEADERS.some((name) => name in headers);\n}\n\nasync function serializeFormData(\n formData: FormData,\n pushBodyChunk: (chunk: string) => void,\n getTotalBodyBytes: () => number,\n): Promise<void> {\n for (const [key, val] of formData.entries()) {\n if (typeof val === \"string\") {\n pushBodyChunk(JSON.stringify([key, { kind: \"string\", value: val }]));\n continue;\n }\n if (\n val.size > MAX_CACHE_KEY_BODY_BYTES ||\n getTotalBodyBytes() + val.size > MAX_CACHE_KEY_BODY_BYTES\n ) {\n throw new BodyTooLargeForCacheKeyError();\n }\n pushBodyChunk(\n JSON.stringify([\n key,\n {\n kind: \"file\",\n name: val.name,\n type: val.type,\n value: await val.text(),\n },\n ]),\n );\n }\n}\n\ntype ParsedFormContentType = \"multipart/form-data\" | \"application/x-www-form-urlencoded\";\n\nfunction getParsedFormContentType(\n contentType: string | undefined,\n): ParsedFormContentType | undefined {\n const mediaType = contentType?.split(\";\")[0]?.trim().toLowerCase();\n if (mediaType === \"multipart/form-data\" || mediaType === \"application/x-www-form-urlencoded\") {\n return mediaType;\n }\n return undefined;\n}\n\nfunction stripMultipartBoundary(contentType: string): string {\n const [type, ...params] = contentType.split(\";\");\n const keptParams = params\n .map((param) => param.trim())\n .filter(Boolean)\n .filter((param) => !/^boundary\\s*=/i.test(param));\n const normalizedType = type.trim().toLowerCase();\n return keptParams.length > 0 ? `${normalizedType}; ${keptParams.join(\"; \")}` : normalizedType;\n}\n\ninterface SerializedBodyResult {\n bodyChunks: string[];\n canonicalizedContentType?: string;\n}\n\nasync function readRequestBodyChunksWithinLimit(request: Request): Promise<{\n chunks: Uint8Array[];\n contentType: string | undefined;\n}> {\n const contentLengthHeader = request.headers.get(\"content-length\");\n if (contentLengthHeader) {\n const contentLength = Number(contentLengthHeader);\n if (Number.isFinite(contentLength) && contentLength > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n }\n\n const requestClone = request.clone();\n const contentType = requestClone.headers.get(\"content-type\") ?? undefined;\n const reader = requestClone.body?.getReader();\n if (!reader) {\n return { chunks: [], contentType };\n }\n\n const chunks: Uint8Array[] = [];\n let totalBodyBytes = 0;\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n totalBodyBytes += value.byteLength;\n if (totalBodyBytes > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n\n chunks.push(value);\n }\n } catch (err) {\n void reader.cancel().catch(() => {});\n throw err;\n }\n\n return { chunks, contentType };\n}\n\n/**\n * Serialize request body into string chunks for cache key inclusion.\n * Handles all body types: string, Uint8Array, ReadableStream, FormData, Blob,\n * and Request object bodies.\n * Returns the serialized body chunks and optionally stashes the original body\n * on init as `_ogBody` so it can still be used after stream consumption.\n */\nasync function serializeBody(\n input: string | URL | Request,\n init?: RequestInit,\n): Promise<SerializedBodyResult> {\n if (!init?.body && !(input instanceof Request && input.body)) {\n return { bodyChunks: [] };\n }\n\n const bodyChunks: string[] = [];\n const encoder = new TextEncoder();\n const decoder = new TextDecoder();\n let totalBodyBytes = 0;\n let canonicalizedContentType: string | undefined;\n\n const pushBodyChunk = (chunk: string): void => {\n totalBodyBytes += encoder.encode(chunk).byteLength;\n if (totalBodyBytes > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n bodyChunks.push(chunk);\n };\n const getTotalBodyBytes = (): number => totalBodyBytes;\n\n if (init?.body instanceof Uint8Array) {\n if (init.body.byteLength > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n pushBodyChunk(decoder.decode(init.body));\n (init as any)._ogBody = init.body;\n } else if (init?.body && typeof (init.body as any).getReader === \"function\") {\n // ReadableStream\n const readableBody = init.body as ReadableStream<Uint8Array | string>;\n const [bodyForHashing, bodyForFetch] = readableBody.tee();\n (init as any)._ogBody = bodyForFetch;\n const reader = bodyForHashing.getReader();\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n if (typeof value === \"string\") {\n pushBodyChunk(value);\n } else {\n // Check raw byte size before the expensive decode to prevent\n // OOM from a single oversized chunk.\n totalBodyBytes += value.byteLength;\n if (totalBodyBytes > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n bodyChunks.push(decoder.decode(value, { stream: true }));\n }\n }\n const finalChunk = decoder.decode();\n if (finalChunk) {\n pushBodyChunk(finalChunk);\n }\n } catch (err) {\n await reader.cancel();\n if (err instanceof BodyTooLargeForCacheKeyError) {\n throw err;\n }\n throw new SkipCacheKeyGenerationError();\n }\n } else if (init?.body instanceof URLSearchParams) {\n // URLSearchParams — .toString() gives a stable serialization\n (init as any)._ogBody = init.body;\n pushBodyChunk(init.body.toString());\n } else if (init?.body && typeof (init.body as any).keys === \"function\") {\n // FormData\n const formData = init.body as FormData;\n (init as any)._ogBody = init.body;\n await serializeFormData(formData, pushBodyChunk, getTotalBodyBytes);\n } else if (init?.body && typeof (init.body as any).arrayBuffer === \"function\") {\n // Blob\n const blob = init.body as Blob;\n if (blob.size > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n pushBodyChunk(await blob.text());\n const arrayBuffer = await blob.arrayBuffer();\n (init as any)._ogBody = new Blob([arrayBuffer], { type: blob.type });\n } else if (typeof init?.body === \"string\") {\n // String length is always <= UTF-8 byte length, so this is a\n // cheap lower-bound check that avoids encoder.encode() for huge strings.\n if (init.body.length > MAX_CACHE_KEY_BODY_BYTES) {\n throw new BodyTooLargeForCacheKeyError();\n }\n pushBodyChunk(init.body);\n (init as any)._ogBody = init.body;\n } else if (input instanceof Request && input.body) {\n let chunks: Uint8Array[];\n let contentType: string | undefined;\n try {\n ({ chunks, contentType } = await readRequestBodyChunksWithinLimit(input));\n } catch (err) {\n if (err instanceof BodyTooLargeForCacheKeyError) {\n throw err;\n }\n throw new SkipCacheKeyGenerationError();\n }\n const formContentType = getParsedFormContentType(contentType);\n\n if (formContentType) {\n try {\n const boundedRequest = new Request(input.url, {\n method: input.method,\n headers: contentType ? { \"content-type\": contentType } : undefined,\n body: new Blob(chunks as unknown as BlobPart[]),\n });\n const formData = await boundedRequest.formData();\n await serializeFormData(formData, pushBodyChunk, getTotalBodyBytes);\n canonicalizedContentType =\n formContentType === \"multipart/form-data\" && contentType\n ? stripMultipartBoundary(contentType)\n : undefined;\n return { bodyChunks, canonicalizedContentType };\n } catch (err) {\n if (err instanceof BodyTooLargeForCacheKeyError) {\n throw err;\n }\n throw new SkipCacheKeyGenerationError();\n }\n }\n\n for (const chunk of chunks) {\n pushBodyChunk(decoder.decode(chunk, { stream: true }));\n }\n const finalChunk = decoder.decode();\n if (finalChunk) {\n pushBodyChunk(finalChunk);\n }\n }\n\n return { bodyChunks, canonicalizedContentType };\n}\n\n/**\n * Generate a deterministic cache key from a fetch request.\n *\n * Matches Next.js behavior: the key is a SHA-256 hash of a JSON array\n * containing URL, method, all headers (minus blocklist), all RequestInit\n * options, and the serialized body.\n */\nasync function buildFetchCacheKey(\n input: string | URL | Request,\n init?: RequestInit & { next?: NextFetchOptions },\n): Promise<string> {\n let url: string;\n let method = \"GET\";\n\n if (typeof input === \"string\") {\n url = input;\n } else if (input instanceof URL) {\n url = input.toString();\n } else {\n // Request object\n url = input.url;\n method = input.method || \"GET\";\n }\n\n if (init?.method) method = init.method;\n\n const headers = collectHeaders(input, init);\n const { bodyChunks, canonicalizedContentType } = await serializeBody(input, init);\n if (canonicalizedContentType) {\n headers[\"content-type\"] = canonicalizedContentType;\n }\n\n const cacheString = JSON.stringify([\n CACHE_KEY_PREFIX,\n url,\n method,\n headers,\n init?.mode,\n init?.redirect,\n init?.credentials,\n init?.referrer,\n init?.referrerPolicy,\n init?.integrity,\n init?.cache,\n bodyChunks,\n ]);\n\n const encoder = new TextEncoder();\n const buffer = encoder.encode(cacheString);\n const hashBuffer = await crypto.subtle.digest(\"SHA-256\", buffer);\n return Array.prototype.map\n .call(new Uint8Array(hashBuffer), (b: number) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ninterface NextFetchOptions {\n revalidate?: number | false;\n tags?: string[];\n}\n\n// Extend the standard RequestInit to include `next`\ndeclare global {\n interface RequestInit {\n next?: NextFetchOptions;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Patching\n// ---------------------------------------------------------------------------\n\n// Capture the real (unpatched) fetch once, shared across Vite's\n// multi-environment module instances via Symbol.for().\nconst _ORIG_FETCH_KEY = Symbol.for(\"vinext.fetchCache.originalFetch\");\nconst _gFetch = globalThis as unknown as Record<PropertyKey, unknown>;\nconst originalFetch: typeof globalThis.fetch = (_gFetch[_ORIG_FETCH_KEY] ??=\n globalThis.fetch) as typeof globalThis.fetch;\n\n// ---------------------------------------------------------------------------\n// AsyncLocalStorage for request-scoped fetch cache state.\n// Uses Symbol.for() on globalThis so the storage is shared across Vite's\n// multi-environment module instances.\n// ---------------------------------------------------------------------------\ninterface FetchCacheState {\n currentRequestTags: string[];\n}\n\nconst _ALS_KEY = Symbol.for(\"vinext.fetchCache.als\");\nconst _FALLBACK_KEY = Symbol.for(\"vinext.fetchCache.fallback\");\nconst _g = globalThis as unknown as Record<PropertyKey, unknown>;\nconst _als = (_g[_ALS_KEY] ??=\n new AsyncLocalStorage<FetchCacheState>()) as AsyncLocalStorage<FetchCacheState>;\n\nconst _fallbackState = (_g[_FALLBACK_KEY] ??= {\n currentRequestTags: [],\n} satisfies FetchCacheState) as FetchCacheState;\n\nfunction _getState(): FetchCacheState {\n return _als.getStore() ?? _fallbackState;\n}\n\n/**\n * Reset the fallback state for a new request. Used by `withFetchCache()`\n * in single-threaded contexts where ALS.run() isn't used.\n */\nfunction _resetFallbackState(): void {\n _fallbackState.currentRequestTags = [];\n}\n\n/**\n * Get tags collected during the current render pass.\n * Useful for associating page-level cache entries with all the\n * fetch tags used during rendering.\n */\nexport function getCollectedFetchTags(): string[] {\n return [..._getState().currentRequestTags];\n}\n\n/**\n * Create a patched fetch function with Next.js caching semantics.\n *\n * The patched fetch:\n * 1. Checks `cache` and `next` options to determine caching behavior\n * 2. On cache hit, returns the cached response without hitting the network\n * 3. On cache miss, fetches from network, stores in cache, returns response\n * 4. Respects `next.revalidate` for TTL-based revalidation\n * 5. Respects `next.tags` for tag-based invalidation via revalidateTag()\n */\nfunction createPatchedFetch(): typeof globalThis.fetch {\n return async function patchedFetch(\n input: string | URL | Request,\n init?: RequestInit,\n ): Promise<Response> {\n const nextOpts = init?.next as NextFetchOptions | undefined;\n const cacheDirective = init?.cache;\n\n // Determine caching behavior:\n // - cache: 'no-store' → skip cache entirely\n // - cache: 'force-cache' → cache indefinitely (revalidate = Infinity)\n // - next.revalidate: false → same as 'no-store'\n // - next.revalidate: 0 → same as 'no-store'\n // - next.revalidate: N → cache for N seconds\n // - No cache/next options → default behavior (no caching, pass-through)\n\n // If no caching options at all, just pass through to original fetch\n if (!nextOpts && !cacheDirective) {\n return originalFetch(input, init);\n }\n\n // Explicit no-store or no-cache — bypass cache entirely\n if (\n cacheDirective === \"no-store\" ||\n cacheDirective === \"no-cache\" ||\n nextOpts?.revalidate === false ||\n nextOpts?.revalidate === 0\n ) {\n // Strip the `next` property before passing to real fetch\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n\n // Safety: when per-user auth headers are present and the developer hasn't\n // explicitly opted into caching with `cache: 'force-cache'` or an explicit\n // `next.revalidate`, skip caching to prevent accidental cross-user data\n // leakage. Developers who understand the implications can still force\n // caching by using `cache: 'force-cache'` or `next: { revalidate: N }`.\n const hasExplicitCacheOpt =\n cacheDirective === \"force-cache\" ||\n (typeof nextOpts?.revalidate === \"number\" && nextOpts.revalidate > 0);\n if (!hasExplicitCacheOpt && hasAuthHeaders(input, init)) {\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n\n // Determine revalidation period\n let revalidateSeconds: number;\n if (cacheDirective === \"force-cache\") {\n // force-cache means cache indefinitely (we use a very large number)\n revalidateSeconds =\n nextOpts?.revalidate && typeof nextOpts.revalidate === \"number\"\n ? nextOpts.revalidate\n : 31536000; // 1 year\n } else if (typeof nextOpts?.revalidate === \"number\" && nextOpts.revalidate > 0) {\n revalidateSeconds = nextOpts.revalidate;\n } else {\n // Has `next` options but no explicit revalidate — Next.js defaults to\n // caching when `next` is present (force-cache behavior).\n // If only tags are specified, cache indefinitely.\n if (nextOpts?.tags && nextOpts.tags.length > 0) {\n revalidateSeconds = 31536000;\n } else {\n // next: {} with no revalidate or tags — pass through\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n }\n\n const tags = nextOpts?.tags ?? [];\n let cacheKey: string;\n try {\n cacheKey = await buildFetchCacheKey(input, init);\n } catch (err) {\n if (\n err instanceof BodyTooLargeForCacheKeyError ||\n err instanceof SkipCacheKeyGenerationError\n ) {\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n throw err;\n }\n const handler = getCacheHandler();\n\n // Collect tags for this render pass\n const reqTags = _getState().currentRequestTags;\n if (tags.length > 0) {\n for (const tag of tags) {\n if (!reqTags.includes(tag)) {\n reqTags.push(tag);\n }\n }\n }\n\n // Try cache first\n try {\n const cached = await handler.get(cacheKey, { kind: \"FETCH\", tags });\n if (cached?.value && cached.value.kind === \"FETCH\" && cached.cacheState !== \"stale\") {\n const cachedData = cached.value.data;\n // Reconstruct a Response from the cached data\n return new Response(cachedData.body, {\n status: cachedData.status ?? 200,\n headers: cachedData.headers,\n });\n }\n\n // Stale entry — we could do stale-while-revalidate here, but for fetch()\n // the simpler approach is to just re-fetch (the page-level ISR handles SWR).\n // However, if we have a stale entry, return it and trigger background refetch.\n if (cached?.value && cached.value.kind === \"FETCH\" && cached.cacheState === \"stale\") {\n const staleData = cached.value.data;\n\n // Background refetch\n const cleanInit = stripNextFromInit(init);\n originalFetch(input, cleanInit)\n .then(async (freshResp) => {\n const freshBody = await freshResp.text();\n const freshHeaders: Record<string, string> = {};\n freshResp.headers.forEach((v, k) => {\n freshHeaders[k] = v;\n });\n\n const freshValue: CachedFetchValue = {\n kind: \"FETCH\",\n data: {\n headers: freshHeaders,\n body: freshBody,\n url:\n typeof input === \"string\"\n ? input\n : input instanceof URL\n ? input.toString()\n : input.url,\n status: freshResp.status,\n },\n tags,\n revalidate: revalidateSeconds,\n };\n await handler.set(cacheKey, freshValue, {\n fetchCache: true,\n tags,\n revalidate: revalidateSeconds,\n });\n })\n .catch((err) => {\n console.error(\"[vinext] fetch cache background revalidation failed:\", err);\n });\n\n // Return stale data immediately\n return new Response(staleData.body, {\n status: staleData.status ?? 200,\n headers: staleData.headers,\n });\n }\n } catch (cacheErr) {\n // Cache read failed — fall through to network\n console.error(\"[vinext] fetch cache read error:\", cacheErr);\n }\n\n // Cache miss — fetch from network\n const cleanInit = stripNextFromInit(init);\n const response = await originalFetch(input, cleanInit);\n\n // Only cache successful responses (2xx)\n if (response.ok) {\n // Clone before reading body\n const cloned = response.clone();\n const body = await cloned.text();\n const headers: Record<string, string> = {};\n cloned.headers.forEach((v, k) => {\n headers[k] = v;\n });\n\n const cacheValue: CachedFetchValue = {\n kind: \"FETCH\",\n data: {\n headers,\n body,\n url:\n typeof input === \"string\" ? input : input instanceof URL ? input.toString() : input.url,\n status: cloned.status,\n },\n tags,\n revalidate: revalidateSeconds,\n };\n\n // Store in cache (fire-and-forget)\n handler\n .set(cacheKey, cacheValue, {\n fetchCache: true,\n tags,\n revalidate: revalidateSeconds,\n })\n .catch((err) => {\n console.error(\"[vinext] fetch cache write error:\", err);\n });\n }\n\n return response;\n } as typeof globalThis.fetch;\n}\n\n/**\n * Strip the `next` property from RequestInit before passing to real fetch.\n * The `next` property is not a standard fetch option and would cause warnings\n * in some environments.\n */\nfunction stripNextFromInit(init?: RequestInit): RequestInit | undefined {\n if (!init) return init;\n const castInit = init as RequestInit & { next?: unknown; _ogBody?: BodyInit };\n const { next: _next, _ogBody, ...rest } = castInit;\n // Restore the original body if it was stashed by serializeBody (e.g. after\n // consuming a ReadableStream for cache key generation).\n if (_ogBody !== undefined) {\n rest.body = _ogBody;\n }\n return Object.keys(rest).length > 0 ? rest : undefined;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n// ---------------------------------------------------------------------------\n// Fetch patching — install once, not per-request.\n// The patched fetch uses _getState() internally, which reads from ALS\n// (concurrent) or _fallbackState (single-threaded), so per-request\n// isolation is handled at the state level, not by swapping globalThis.fetch.\n// ---------------------------------------------------------------------------\n\nconst _PATCH_KEY = Symbol.for(\"vinext.fetchCache.patchInstalled\");\n\nfunction _ensurePatchInstalled(): void {\n if (_g[_PATCH_KEY]) return;\n _g[_PATCH_KEY] = true;\n globalThis.fetch = createPatchedFetch();\n}\n\n/**\n * Install the patched fetch and reset per-request tag state.\n * Returns a cleanup function that clears tags.\n *\n * @deprecated Prefer `runWithFetchCache()` which uses `AsyncLocalStorage.run()`\n * for proper per-request isolation in concurrent environments.\n *\n * Usage:\n * const cleanup = withFetchCache();\n * try { await render(); } finally { cleanup(); }\n */\nexport function withFetchCache(): () => void {\n _ensurePatchInstalled();\n _resetFallbackState();\n\n return () => {\n _resetFallbackState();\n };\n}\n\n/**\n * Run an async function with patched fetch caching enabled.\n * Uses `AsyncLocalStorage.run()` for proper per-request isolation\n * of collected fetch tags in concurrent server environments.\n */\nexport async function runWithFetchCache<T>(fn: () => Promise<T>): Promise<T> {\n _ensurePatchInstalled();\n return _als.run({ currentRequestTags: [] }, fn);\n}\n\n/**\n * Get the original (unpatched) fetch function.\n * Useful for internal code that should bypass caching.\n */\nexport function getOriginalFetch(): typeof globalThis.fetch {\n return originalFetch;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"font-google-base.d.ts","sourceRoot":"","sources":["../../src/shims/font-google-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAwDH,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAUD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,MAAM,CA8ChF;AAyGD;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C;AAKD;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAE1C;AAMD;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAE1E;AA0ED,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG;IAAE,cAAc,CAAC,EAAE,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AAA;CAAE,CAAC,CAE1E;AA0ED,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,UAAU,CAAC;AAE7F,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CA+C3D;AAKD,QAAA,MAAM,WAAW,4BAA6C,WAAW,KAAK,UAAU,CAStF,CAAC;AAEH,eAAe,WAAW,CAAC"}
@@ -53,9 +53,19 @@ function sanitizeCSSVarName(name) {
53
53
  function sanitizeFallback(name) {
54
54
  // CSS generic font families — safe to use unquoted
55
55
  const generics = new Set([
56
- "serif", "sans-serif", "monospace", "cursive", "fantasy",
57
- "system-ui", "ui-serif", "ui-sans-serif", "ui-monospace", "ui-rounded",
58
- "emoji", "math", "fangsong",
56
+ "serif",
57
+ "sans-serif",
58
+ "monospace",
59
+ "cursive",
60
+ "fantasy",
61
+ "system-ui",
62
+ "ui-serif",
63
+ "ui-sans-serif",
64
+ "ui-monospace",
65
+ "ui-rounded",
66
+ "emoji",
67
+ "math",
68
+ "fangsong",
59
69
  ]);
60
70
  const trimmed = name.trim();
61
71
  if (generics.has(trimmed))
@@ -314,7 +324,9 @@ export function createFontLoader(family) {
314
324
  // Validate CSS variable name — reject anything that could inject CSS.
315
325
  // Fall back to auto-generated name if invalid.
316
326
  const defaultVarName = toVarName(family);
317
- const cssVarName = options.variable ? (sanitizeCSSVarName(options.variable) ?? defaultVarName) : defaultVarName;
327
+ const cssVarName = options.variable
328
+ ? (sanitizeCSSVarName(options.variable) ?? defaultVarName)
329
+ : defaultVarName;
318
330
  // In Next.js, `variable` returns a CLASS NAME that sets the CSS variable.
319
331
  // Users apply this class to set the CSS variable on that element.
320
332
  const variableClassName = `__variable_${family.toLowerCase().replace(/\s+/g, "_")}_${id}`;