@qzsy/vinext 0.1.7
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.
- package/LICENSE +21 -0
- package/README.md +773 -0
- package/dist/build/assets-ignore.d.ts +32 -0
- package/dist/build/assets-ignore.js +48 -0
- package/dist/build/clean-output.d.ts +13 -0
- package/dist/build/clean-output.js +34 -0
- package/dist/build/client-build-config.d.ts +171 -0
- package/dist/build/client-build-config.js +270 -0
- package/dist/build/css-url-assets.d.ts +29 -0
- package/dist/build/css-url-assets.js +213 -0
- package/dist/build/google-fonts/build-url.d.ts +9 -0
- package/dist/build/google-fonts/build-url.js +28 -0
- package/dist/build/google-fonts/fallback-metrics-data.js +14029 -0
- package/dist/build/google-fonts/fallback-metrics.d.ts +12 -0
- package/dist/build/google-fonts/fallback-metrics.js +44 -0
- package/dist/build/google-fonts/find-font-files-in-css.d.ts +16 -0
- package/dist/build/google-fonts/find-font-files-in-css.js +28 -0
- package/dist/build/google-fonts/font-data.js +24983 -0
- package/dist/build/google-fonts/font-metadata.d.ts +16 -0
- package/dist/build/google-fonts/font-metadata.js +5 -0
- package/dist/build/google-fonts/get-axes.d.ts +6 -0
- package/dist/build/google-fonts/get-axes.js +37 -0
- package/dist/build/google-fonts/sort-variants.d.ts +4 -0
- package/dist/build/google-fonts/sort-variants.js +12 -0
- package/dist/build/google-fonts/validate.d.ts +27 -0
- package/dist/build/google-fonts/validate.js +54 -0
- package/dist/build/inline-css.d.ts +6 -0
- package/dist/build/inline-css.js +48 -0
- package/dist/build/layout-classification-types.d.ts +61 -0
- package/dist/build/layout-classification-types.js +1 -0
- package/dist/build/layout-classification.d.ts +59 -0
- package/dist/build/layout-classification.js +98 -0
- package/dist/build/next-client-runtime-manifests.d.ts +14 -0
- package/dist/build/next-client-runtime-manifests.js +39 -0
- package/dist/build/nitro-route-rules.d.ts +49 -0
- package/dist/build/nitro-route-rules.js +79 -0
- package/dist/build/precompress.d.ts +27 -0
- package/dist/build/precompress.js +110 -0
- package/dist/build/prerender.d.ts +209 -0
- package/dist/build/prerender.js +932 -0
- package/dist/build/report.d.ts +132 -0
- package/dist/build/report.js +504 -0
- package/dist/build/route-classification-injector.d.ts +34 -0
- package/dist/build/route-classification-injector.js +59 -0
- package/dist/build/route-classification-manifest.d.ts +52 -0
- package/dist/build/route-classification-manifest.js +143 -0
- package/dist/build/run-prerender.d.ts +61 -0
- package/dist/build/run-prerender.js +224 -0
- package/dist/build/server-manifest.d.ts +18 -0
- package/dist/build/server-manifest.js +22 -0
- package/dist/build/ssr-manifest.d.ts +18 -0
- package/dist/build/ssr-manifest.js +69 -0
- package/dist/build/standalone.d.ts +31 -0
- package/dist/build/standalone.js +203 -0
- package/dist/build/static-export.d.ts +55 -0
- package/dist/build/static-export.js +60 -0
- package/dist/cache/cache-adapters-virtual.d.ts +50 -0
- package/dist/cache/cache-adapters-virtual.js +45 -0
- package/dist/cache.d.ts +2 -0
- package/dist/cache.js +2 -0
- package/dist/check.d.ts +87 -0
- package/dist/check.js +1037 -0
- package/dist/cli-args.d.ts +33 -0
- package/dist/cli-args.js +124 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +744 -0
- package/dist/client/app-nav-failure-handler.d.ts +8 -0
- package/dist/client/app-nav-failure-handler.js +44 -0
- package/dist/client/empty-module.d.ts +1 -0
- package/dist/client/empty-module.js +1 -0
- package/dist/client/instrumentation-client-inject.d.ts +33 -0
- package/dist/client/instrumentation-client-inject.js +55 -0
- package/dist/client/instrumentation-client-state.d.ts +9 -0
- package/dist/client/instrumentation-client-state.js +17 -0
- package/dist/client/instrumentation-client.d.ts +7 -0
- package/dist/client/instrumentation-client.js +6 -0
- package/dist/client/navigation-runtime.d.ts +70 -0
- package/dist/client/navigation-runtime.js +169 -0
- package/dist/client/pages-router-link-navigation.d.ts +61 -0
- package/dist/client/pages-router-link-navigation.js +42 -0
- package/dist/client/validate-module-path.d.ts +17 -0
- package/dist/client/validate-module-path.js +24 -0
- package/dist/client/vinext-next-data.d.ts +44 -0
- package/dist/client/vinext-next-data.js +50 -0
- package/dist/client/window-next.d.ts +168 -0
- package/dist/client/window-next.js +57 -0
- package/dist/cloudflare/index.d.ts +3 -0
- package/dist/cloudflare/index.js +3 -0
- package/dist/cloudflare/src/cache/cdn-adapter.runtime.js +102 -0
- package/dist/cloudflare/src/cache/kv-data-adapter.runtime.d.ts +126 -0
- package/dist/cloudflare/src/cache/kv-data-adapter.runtime.js +435 -0
- package/dist/cloudflare/src/utils/cache-control-metadata.js +20 -0
- package/dist/cloudflare/tpr.d.ts +82 -0
- package/dist/cloudflare/tpr.js +558 -0
- package/dist/config/config-matchers.d.ts +257 -0
- package/dist/config/config-matchers.js +1046 -0
- package/dist/config/dotenv.d.ts +56 -0
- package/dist/config/dotenv.js +88 -0
- package/dist/config/next-config.d.ts +540 -0
- package/dist/config/next-config.js +1050 -0
- package/dist/config/tsconfig-paths.d.ts +21 -0
- package/dist/config/tsconfig-paths.js +157 -0
- package/dist/deploy.d.ts +190 -0
- package/dist/deploy.js +1033 -0
- package/dist/entries/app-browser-entry.d.ts +29 -0
- package/dist/entries/app-browser-entry.js +83 -0
- package/dist/entries/app-rsc-entry.d.ts +81 -0
- package/dist/entries/app-rsc-entry.js +943 -0
- package/dist/entries/app-rsc-manifest.d.ts +53 -0
- package/dist/entries/app-rsc-manifest.js +294 -0
- package/dist/entries/app-ssr-entry.d.ts +15 -0
- package/dist/entries/app-ssr-entry.js +24 -0
- package/dist/entries/pages-client-entry.d.ts +11 -0
- package/dist/entries/pages-client-entry.js +204 -0
- package/dist/entries/pages-entry-helpers.d.ts +2 -0
- package/dist/entries/pages-entry-helpers.js +2 -0
- package/dist/entries/pages-server-entry.d.ts +11 -0
- package/dist/entries/pages-server-entry.js +398 -0
- package/dist/entries/runtime-entry-module.d.ts +25 -0
- package/dist/entries/runtime-entry-module.js +46 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +2661 -0
- package/dist/init.d.ts +69 -0
- package/dist/init.js +253 -0
- package/dist/plugins/ast-utils.d.ts +20 -0
- package/dist/plugins/ast-utils.js +78 -0
- package/dist/plugins/async-hooks-stub.d.ts +18 -0
- package/dist/plugins/async-hooks-stub.js +40 -0
- package/dist/plugins/client-reference-dedup.d.ts +35 -0
- package/dist/plugins/client-reference-dedup.js +189 -0
- package/dist/plugins/css-data-url.d.ts +6 -0
- package/dist/plugins/css-data-url.js +83 -0
- package/dist/plugins/dynamic-preload-metadata.d.ts +13 -0
- package/dist/plugins/dynamic-preload-metadata.js +413 -0
- package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
- package/dist/plugins/extensionless-dynamic-import.js +155 -0
- package/dist/plugins/fonts.d.ts +95 -0
- package/dist/plugins/fonts.js +711 -0
- package/dist/plugins/import-meta-url.d.ts +16 -0
- package/dist/plugins/import-meta-url.js +353 -0
- package/dist/plugins/instrumentation-client.d.ts +6 -0
- package/dist/plugins/instrumentation-client.js +27 -0
- package/dist/plugins/middleware-export-validation.d.ts +5 -0
- package/dist/plugins/middleware-export-validation.js +36 -0
- package/dist/plugins/middleware-server-only.d.ts +53 -0
- package/dist/plugins/middleware-server-only.js +90 -0
- package/dist/plugins/og-asset-ownership.d.ts +27 -0
- package/dist/plugins/og-asset-ownership.js +285 -0
- package/dist/plugins/og-assets.d.ts +50 -0
- package/dist/plugins/og-assets.js +229 -0
- package/dist/plugins/optimize-imports.d.ts +42 -0
- package/dist/plugins/optimize-imports.js +587 -0
- package/dist/plugins/postcss.d.ts +26 -0
- package/dist/plugins/postcss.js +96 -0
- package/dist/plugins/remove-console.d.ts +21 -0
- package/dist/plugins/remove-console.js +177 -0
- package/dist/plugins/require-context.d.ts +6 -0
- package/dist/plugins/require-context.js +185 -0
- package/dist/plugins/rsc-client-reference-loaders.d.ts +6 -0
- package/dist/plugins/rsc-client-reference-loaders.js +46 -0
- package/dist/plugins/rsc-client-shim-excludes.d.ts +6 -0
- package/dist/plugins/rsc-client-shim-excludes.js +35 -0
- package/dist/plugins/sass.d.ts +62 -0
- package/dist/plugins/sass.js +268 -0
- package/dist/plugins/server-externals-manifest.d.ts +26 -0
- package/dist/plugins/server-externals-manifest.js +81 -0
- package/dist/plugins/strip-server-exports.d.ts +21 -0
- package/dist/plugins/strip-server-exports.js +519 -0
- package/dist/plugins/typeof-window.d.ts +14 -0
- package/dist/plugins/typeof-window.js +150 -0
- package/dist/plugins/wasm-module-import.d.ts +15 -0
- package/dist/plugins/wasm-module-import.js +50 -0
- package/dist/routing/app-route-graph.d.ts +336 -0
- package/dist/routing/app-route-graph.js +1518 -0
- package/dist/routing/app-router.d.ts +30 -0
- package/dist/routing/app-router.js +59 -0
- package/dist/routing/file-matcher.d.ts +60 -0
- package/dist/routing/file-matcher.js +147 -0
- package/dist/routing/pages-router.d.ts +48 -0
- package/dist/routing/pages-router.js +163 -0
- package/dist/routing/route-matching.d.ts +27 -0
- package/dist/routing/route-matching.js +42 -0
- package/dist/routing/route-pattern.d.ts +64 -0
- package/dist/routing/route-pattern.js +165 -0
- package/dist/routing/route-trie.d.ts +67 -0
- package/dist/routing/route-trie.js +143 -0
- package/dist/routing/route-validation.d.ts +10 -0
- package/dist/routing/route-validation.js +101 -0
- package/dist/routing/utils.d.ts +117 -0
- package/dist/routing/utils.js +242 -0
- package/dist/server/accept-encoding.d.ts +29 -0
- package/dist/server/accept-encoding.js +95 -0
- package/dist/server/api-handler.d.ts +17 -0
- package/dist/server/api-handler.js +276 -0
- package/dist/server/app-action-request.d.ts +4 -0
- package/dist/server/app-action-request.js +9 -0
- package/dist/server/app-bfcache-id.d.ts +5 -0
- package/dist/server/app-bfcache-id.js +5 -0
- package/dist/server/app-bfcache-identity.d.ts +36 -0
- package/dist/server/app-bfcache-identity.js +156 -0
- package/dist/server/app-browser-action-result.d.ts +64 -0
- package/dist/server/app-browser-action-result.js +111 -0
- package/dist/server/app-browser-client-reuse-manifest.d.ts +12 -0
- package/dist/server/app-browser-client-reuse-manifest.js +101 -0
- package/dist/server/app-browser-entry.d.ts +1 -0
- package/dist/server/app-browser-entry.js +1087 -0
- package/dist/server/app-browser-error.d.ts +13 -0
- package/dist/server/app-browser-error.js +52 -0
- package/dist/server/app-browser-history-controller.d.ts +104 -0
- package/dist/server/app-browser-history-controller.js +210 -0
- package/dist/server/app-browser-hydration.d.ts +32 -0
- package/dist/server/app-browser-hydration.js +29 -0
- package/dist/server/app-browser-interception-context.d.ts +24 -0
- package/dist/server/app-browser-interception-context.js +43 -0
- package/dist/server/app-browser-mpa-navigation.d.ts +16 -0
- package/dist/server/app-browser-mpa-navigation.js +42 -0
- package/dist/server/app-browser-navigation-controller.d.ts +109 -0
- package/dist/server/app-browser-navigation-controller.js +465 -0
- package/dist/server/app-browser-popstate.d.ts +26 -0
- package/dist/server/app-browser-popstate.js +44 -0
- package/dist/server/app-browser-rsc-redirect.d.ts +38 -0
- package/dist/server/app-browser-rsc-redirect.js +64 -0
- package/dist/server/app-browser-server-action-client.d.ts +32 -0
- package/dist/server/app-browser-server-action-client.js +128 -0
- package/dist/server/app-browser-server-action-navigation.d.ts +6 -0
- package/dist/server/app-browser-server-action-navigation.js +9 -0
- package/dist/server/app-browser-state.d.ts +140 -0
- package/dist/server/app-browser-state.js +315 -0
- package/dist/server/app-browser-stream.d.ts +28 -0
- package/dist/server/app-browser-stream.js +122 -0
- package/dist/server/app-browser-visible-commit.d.ts +78 -0
- package/dist/server/app-browser-visible-commit.js +241 -0
- package/dist/server/app-client-reference-preloader.d.ts +14 -0
- package/dist/server/app-client-reference-preloader.js +44 -0
- package/dist/server/app-elements-wire.d.ts +192 -0
- package/dist/server/app-elements-wire.js +443 -0
- package/dist/server/app-elements.d.ts +9 -0
- package/dist/server/app-elements.js +18 -0
- package/dist/server/app-fallback-renderer.d.ts +89 -0
- package/dist/server/app-fallback-renderer.js +136 -0
- package/dist/server/app-history-state.d.ts +85 -0
- package/dist/server/app-history-state.js +223 -0
- package/dist/server/app-hook-warning-suppression.d.ts +6 -0
- package/dist/server/app-hook-warning-suppression.js +10 -0
- package/dist/server/app-inline-css-client.d.ts +6 -0
- package/dist/server/app-inline-css-client.js +35 -0
- package/dist/server/app-interception-context-header.d.ts +32 -0
- package/dist/server/app-interception-context-header.js +42 -0
- package/dist/server/app-layout-param-observation.d.ts +43 -0
- package/dist/server/app-layout-param-observation.js +168 -0
- package/dist/server/app-middleware.d.ts +46 -0
- package/dist/server/app-middleware.js +168 -0
- package/dist/server/app-mounted-slots-header.d.ts +35 -0
- package/dist/server/app-mounted-slots-header.js +58 -0
- package/dist/server/app-optimistic-routing.d.ts +53 -0
- package/dist/server/app-optimistic-routing.js +227 -0
- package/dist/server/app-page-boundary-render.d.ts +85 -0
- package/dist/server/app-page-boundary-render.js +305 -0
- package/dist/server/app-page-boundary.d.ts +102 -0
- package/dist/server/app-page-boundary.js +120 -0
- package/dist/server/app-page-cache-finalizer.d.ts +62 -0
- package/dist/server/app-page-cache-finalizer.js +122 -0
- package/dist/server/app-page-cache-render.d.ts +53 -0
- package/dist/server/app-page-cache-render.js +91 -0
- package/dist/server/app-page-cache.d.ts +83 -0
- package/dist/server/app-page-cache.js +272 -0
- package/dist/server/app-page-dispatch.d.ts +223 -0
- package/dist/server/app-page-dispatch.js +610 -0
- package/dist/server/app-page-element-builder.d.ts +96 -0
- package/dist/server/app-page-element-builder.js +205 -0
- package/dist/server/app-page-execution.d.ts +138 -0
- package/dist/server/app-page-execution.js +328 -0
- package/dist/server/app-page-head.d.ts +65 -0
- package/dist/server/app-page-head.js +228 -0
- package/dist/server/app-page-method.d.ts +15 -0
- package/dist/server/app-page-method.js +25 -0
- package/dist/server/app-page-params.d.ts +8 -0
- package/dist/server/app-page-params.js +39 -0
- package/dist/server/app-page-ppr-runtime.d.ts +7 -0
- package/dist/server/app-page-ppr-runtime.js +70 -0
- package/dist/server/app-page-probe.d.ts +134 -0
- package/dist/server/app-page-probe.js +276 -0
- package/dist/server/app-page-render-identity.d.ts +21 -0
- package/dist/server/app-page-render-identity.js +40 -0
- package/dist/server/app-page-render-observation.d.ts +36 -0
- package/dist/server/app-page-render-observation.js +82 -0
- package/dist/server/app-page-render.d.ts +111 -0
- package/dist/server/app-page-render.js +602 -0
- package/dist/server/app-page-request.d.ts +137 -0
- package/dist/server/app-page-request.js +216 -0
- package/dist/server/app-page-response.d.ts +68 -0
- package/dist/server/app-page-response.js +120 -0
- package/dist/server/app-page-route-wiring.d.ts +151 -0
- package/dist/server/app-page-route-wiring.js +452 -0
- package/dist/server/app-page-search-params-observation.d.ts +10 -0
- package/dist/server/app-page-search-params-observation.js +20 -0
- package/dist/server/app-page-segment-state.d.ts +9 -0
- package/dist/server/app-page-segment-state.js +80 -0
- package/dist/server/app-page-stream.d.ts +151 -0
- package/dist/server/app-page-stream.js +143 -0
- package/dist/server/app-pages-bridge.d.ts +63 -0
- package/dist/server/app-pages-bridge.js +63 -0
- package/dist/server/app-post-middleware-context.d.ts +15 -0
- package/dist/server/app-post-middleware-context.js +26 -0
- package/dist/server/app-ppr-fallback-shell-render.d.ts +18 -0
- package/dist/server/app-ppr-fallback-shell-render.js +26 -0
- package/dist/server/app-ppr-fallback-shell.d.ts +33 -0
- package/dist/server/app-ppr-fallback-shell.js +89 -0
- package/dist/server/app-prerender-endpoints.d.ts +18 -0
- package/dist/server/app-prerender-endpoints.js +94 -0
- package/dist/server/app-prerender-static-params.d.ts +30 -0
- package/dist/server/app-prerender-static-params.js +81 -0
- package/dist/server/app-render-dependency.d.ts +14 -0
- package/dist/server/app-render-dependency.js +41 -0
- package/dist/server/app-request-context.d.ts +20 -0
- package/dist/server/app-request-context.js +29 -0
- package/dist/server/app-route-handler-cache.d.ts +46 -0
- package/dist/server/app-route-handler-cache.js +78 -0
- package/dist/server/app-route-handler-dispatch.d.ts +49 -0
- package/dist/server/app-route-handler-dispatch.js +163 -0
- package/dist/server/app-route-handler-execution.d.ts +86 -0
- package/dist/server/app-route-handler-execution.js +128 -0
- package/dist/server/app-route-handler-policy.d.ts +55 -0
- package/dist/server/app-route-handler-policy.js +58 -0
- package/dist/server/app-route-handler-response.d.ts +28 -0
- package/dist/server/app-route-handler-response.js +145 -0
- package/dist/server/app-route-handler-runtime.d.ts +39 -0
- package/dist/server/app-route-handler-runtime.js +250 -0
- package/dist/server/app-route-module-loader.d.ts +91 -0
- package/dist/server/app-route-module-loader.js +83 -0
- package/dist/server/app-router-entry.d.ts +13 -0
- package/dist/server/app-router-entry.js +49 -0
- package/dist/server/app-rsc-cache-busting.d.ts +64 -0
- package/dist/server/app-rsc-cache-busting.js +206 -0
- package/dist/server/app-rsc-embedded-chunks.d.ts +8 -0
- package/dist/server/app-rsc-embedded-chunks.js +32 -0
- package/dist/server/app-rsc-error-handler.d.ts +20 -0
- package/dist/server/app-rsc-error-handler.js +28 -0
- package/dist/server/app-rsc-errors.d.ts +40 -0
- package/dist/server/app-rsc-errors.js +60 -0
- package/dist/server/app-rsc-handler.d.ts +201 -0
- package/dist/server/app-rsc-handler.js +538 -0
- package/dist/server/app-rsc-render-mode.d.ts +11 -0
- package/dist/server/app-rsc-render-mode.js +25 -0
- package/dist/server/app-rsc-request-normalization.d.ts +48 -0
- package/dist/server/app-rsc-request-normalization.js +75 -0
- package/dist/server/app-rsc-response-finalizer.d.ts +37 -0
- package/dist/server/app-rsc-response-finalizer.js +54 -0
- package/dist/server/app-rsc-route-matching.d.ts +93 -0
- package/dist/server/app-rsc-route-matching.js +134 -0
- package/dist/server/app-segment-config.d.ts +46 -0
- package/dist/server/app-segment-config.js +113 -0
- package/dist/server/app-server-action-execution.d.ts +219 -0
- package/dist/server/app-server-action-execution.js +767 -0
- package/dist/server/app-ssr-entry.d.ts +52 -0
- package/dist/server/app-ssr-entry.js +295 -0
- package/dist/server/app-ssr-error-meta.d.ts +13 -0
- package/dist/server/app-ssr-error-meta.js +48 -0
- package/dist/server/app-ssr-router-instance.d.ts +6 -0
- package/dist/server/app-ssr-router-instance.js +24 -0
- package/dist/server/app-ssr-stream.d.ts +60 -0
- package/dist/server/app-ssr-stream.js +408 -0
- package/dist/server/app-static-generation.d.ts +15 -0
- package/dist/server/app-static-generation.js +19 -0
- package/dist/server/app-visited-response-cache.d.ts +23 -0
- package/dist/server/app-visited-response-cache.js +19 -0
- package/dist/server/artifact-compatibility.d.ts +54 -0
- package/dist/server/artifact-compatibility.js +91 -0
- package/dist/server/before-interactive-head.d.ts +17 -0
- package/dist/server/before-interactive-head.js +35 -0
- package/dist/server/cache-control.d.ts +37 -0
- package/dist/server/cache-control.js +56 -0
- package/dist/server/cache-headers.d.ts +6 -0
- package/dist/server/cache-headers.js +17 -0
- package/dist/server/cache-proof.d.ts +364 -0
- package/dist/server/cache-proof.js +794 -0
- package/dist/server/client-reuse-manifest.d.ts +104 -0
- package/dist/server/client-reuse-manifest.js +209 -0
- package/dist/server/client-trace-metadata.d.ts +30 -0
- package/dist/server/client-trace-metadata.js +81 -0
- package/dist/server/cookie-utils.d.ts +12 -0
- package/dist/server/cookie-utils.js +18 -0
- package/dist/server/csp.d.ts +10 -0
- package/dist/server/csp.js +41 -0
- package/dist/server/default-global-error-module.d.ts +19 -0
- package/dist/server/default-global-error-module.js +18 -0
- package/dist/server/default-not-found-module.d.ts +19 -0
- package/dist/server/default-not-found-module.js +18 -0
- package/dist/server/defer-until-stream-consumed.d.ts +7 -0
- package/dist/server/defer-until-stream-consumed.js +34 -0
- package/dist/server/dev-error-overlay-store.d.ts +39 -0
- package/dist/server/dev-error-overlay-store.js +86 -0
- package/dist/server/dev-error-overlay.d.ts +51 -0
- package/dist/server/dev-error-overlay.js +1341 -0
- package/dist/server/dev-initial-server-error.d.ts +9 -0
- package/dist/server/dev-initial-server-error.js +26 -0
- package/dist/server/dev-lockfile.d.ts +109 -0
- package/dist/server/dev-lockfile.js +179 -0
- package/dist/server/dev-module-runner.d.ts +30 -0
- package/dist/server/dev-module-runner.js +91 -0
- package/dist/server/dev-origin-check.d.ts +62 -0
- package/dist/server/dev-origin-check.js +156 -0
- package/dist/server/dev-route-files.d.ts +6 -0
- package/dist/server/dev-route-files.js +71 -0
- package/dist/server/dev-server.d.ts +58 -0
- package/dist/server/dev-server.js +1114 -0
- package/dist/server/dev-stack-sourcemap-endpoint.d.ts +4 -0
- package/dist/server/dev-stack-sourcemap-endpoint.js +4 -0
- package/dist/server/dev-stack-sourcemap.d.ts +43 -0
- package/dist/server/dev-stack-sourcemap.js +443 -0
- package/dist/server/document-initial-head.d.ts +6 -0
- package/dist/server/document-initial-head.js +33 -0
- package/dist/server/edge-api-runtime.d.ts +4 -0
- package/dist/server/edge-api-runtime.js +6 -0
- package/dist/server/file-based-metadata.d.ts +29 -0
- package/dist/server/file-based-metadata.js +401 -0
- package/dist/server/headers.d.ts +114 -0
- package/dist/server/headers.js +136 -0
- package/dist/server/html.d.ts +28 -0
- package/dist/server/html.js +41 -0
- package/dist/server/http-error-responses.d.ts +91 -0
- package/dist/server/http-error-responses.js +105 -0
- package/dist/server/hybrid-route-priority.d.ts +22 -0
- package/dist/server/hybrid-route-priority.js +33 -0
- package/dist/server/image-optimization.d.ts +130 -0
- package/dist/server/image-optimization.js +247 -0
- package/dist/server/implicit-tags.d.ts +6 -0
- package/dist/server/implicit-tags.js +44 -0
- package/dist/server/instrumentation-runtime.d.ts +49 -0
- package/dist/server/instrumentation-runtime.js +35 -0
- package/dist/server/instrumentation.d.ts +85 -0
- package/dist/server/instrumentation.js +130 -0
- package/dist/server/isr-cache.d.ts +127 -0
- package/dist/server/isr-cache.js +282 -0
- package/dist/server/isr-decision.d.ts +79 -0
- package/dist/server/isr-decision.js +70 -0
- package/dist/server/metadata-route-build-data.d.ts +24 -0
- package/dist/server/metadata-route-build-data.js +148 -0
- package/dist/server/metadata-route-response.d.ts +16 -0
- package/dist/server/metadata-route-response.js +205 -0
- package/dist/server/metadata-routes.d.ts +139 -0
- package/dist/server/metadata-routes.js +433 -0
- package/dist/server/middleware-matcher.d.ts +14 -0
- package/dist/server/middleware-matcher.js +111 -0
- package/dist/server/middleware-request-headers.d.ts +11 -0
- package/dist/server/middleware-request-headers.js +65 -0
- package/dist/server/middleware-response-headers.d.ts +12 -0
- package/dist/server/middleware-response-headers.js +42 -0
- package/dist/server/middleware-runtime.d.ts +67 -0
- package/dist/server/middleware-runtime.js +240 -0
- package/dist/server/middleware.d.ts +62 -0
- package/dist/server/middleware.js +114 -0
- package/dist/server/navigation-planner.d.ts +308 -0
- package/dist/server/navigation-planner.js +831 -0
- package/dist/server/navigation-trace.d.ts +68 -0
- package/dist/server/navigation-trace.js +71 -0
- package/dist/server/next-error-digest.d.ts +44 -0
- package/dist/server/next-error-digest.js +40 -0
- package/dist/server/normalize-path.d.ts +38 -0
- package/dist/server/normalize-path.js +70 -0
- package/dist/server/open-redirect.d.ts +12 -0
- package/dist/server/open-redirect.js +21 -0
- package/dist/server/operation-token.d.ts +40 -0
- package/dist/server/operation-token.js +85 -0
- package/dist/server/otel-tracer-extension.d.ts +45 -0
- package/dist/server/otel-tracer-extension.js +89 -0
- package/dist/server/pages-api-route.d.ts +83 -0
- package/dist/server/pages-api-route.js +75 -0
- package/dist/server/pages-asset-tags.d.ts +78 -0
- package/dist/server/pages-asset-tags.js +126 -0
- package/dist/server/pages-body-parser-config.d.ts +59 -0
- package/dist/server/pages-body-parser-config.js +77 -0
- package/dist/server/pages-data-route.d.ts +121 -0
- package/dist/server/pages-data-route.js +157 -0
- package/dist/server/pages-default-404.d.ts +30 -0
- package/dist/server/pages-default-404.js +38 -0
- package/dist/server/pages-dev-module-url.d.ts +4 -0
- package/dist/server/pages-dev-module-url.js +15 -0
- package/dist/server/pages-document-initial-props.d.ts +77 -0
- package/dist/server/pages-document-initial-props.js +109 -0
- package/dist/server/pages-get-initial-props.d.ts +67 -0
- package/dist/server/pages-get-initial-props.js +92 -0
- package/dist/server/pages-i18n.d.ts +106 -0
- package/dist/server/pages-i18n.js +183 -0
- package/dist/server/pages-media-type.d.ts +15 -0
- package/dist/server/pages-media-type.js +24 -0
- package/dist/server/pages-node-compat.d.ts +55 -0
- package/dist/server/pages-node-compat.js +235 -0
- package/dist/server/pages-page-data.d.ts +223 -0
- package/dist/server/pages-page-data.js +484 -0
- package/dist/server/pages-page-handler.d.ts +100 -0
- package/dist/server/pages-page-handler.js +403 -0
- package/dist/server/pages-page-method.d.ts +47 -0
- package/dist/server/pages-page-method.js +17 -0
- package/dist/server/pages-page-response.d.ts +138 -0
- package/dist/server/pages-page-response.js +285 -0
- package/dist/server/pages-readiness.d.ts +36 -0
- package/dist/server/pages-readiness.js +21 -0
- package/dist/server/pages-request-pipeline.d.ts +116 -0
- package/dist/server/pages-request-pipeline.js +311 -0
- package/dist/server/pages-revalidate.d.ts +15 -0
- package/dist/server/pages-revalidate.js +19 -0
- package/dist/server/pages-serializable-props.d.ts +24 -0
- package/dist/server/pages-serializable-props.js +67 -0
- package/dist/server/pregenerated-concrete-paths.d.ts +16 -0
- package/dist/server/pregenerated-concrete-paths.js +61 -0
- package/dist/server/prerender-manifest.d.ts +33 -0
- package/dist/server/prerender-manifest.js +54 -0
- package/dist/server/prerender-route-params.d.ts +23 -0
- package/dist/server/prerender-route-params.js +113 -0
- package/dist/server/prerender-work-unit-setup.d.ts +6 -0
- package/dist/server/prerender-work-unit-setup.js +28 -0
- package/dist/server/prod-server.d.ts +148 -0
- package/dist/server/prod-server.js +1136 -0
- package/dist/server/proxy-trust.d.ts +40 -0
- package/dist/server/proxy-trust.js +68 -0
- package/dist/server/request-log.d.ts +39 -0
- package/dist/server/request-log.js +56 -0
- package/dist/server/request-pipeline.d.ts +187 -0
- package/dist/server/request-pipeline.js +447 -0
- package/dist/server/rsc-stream-hints.d.ts +10 -0
- package/dist/server/rsc-stream-hints.js +41 -0
- package/dist/server/seed-cache.d.ts +29 -0
- package/dist/server/seed-cache.js +125 -0
- package/dist/server/server-action-not-found.d.ts +21 -0
- package/dist/server/server-action-not-found.js +62 -0
- package/dist/server/server-globals.d.ts +4 -0
- package/dist/server/server-globals.js +35 -0
- package/dist/server/skip-cache-proof.d.ts +61 -0
- package/dist/server/skip-cache-proof.js +168 -0
- package/dist/server/socket-error-backstop.d.ts +34 -0
- package/dist/server/socket-error-backstop.js +200 -0
- package/dist/server/static-file-cache.d.ts +56 -0
- package/dist/server/static-file-cache.js +231 -0
- package/dist/server/static-layout-client-reuse-proof.d.ts +15 -0
- package/dist/server/static-layout-client-reuse-proof.js +33 -0
- package/dist/server/streaming-metadata.d.ts +4 -0
- package/dist/server/streaming-metadata.js +8 -0
- package/dist/server/worker-utils.d.ts +7 -0
- package/dist/server/worker-utils.js +99 -0
- package/dist/shims/amp.d.ts +19 -0
- package/dist/shims/amp.js +23 -0
- package/dist/shims/app-router-scroll-state.d.ts +15 -0
- package/dist/shims/app-router-scroll-state.js +61 -0
- package/dist/shims/app-router-scroll.d.ts +29 -0
- package/dist/shims/app-router-scroll.js +141 -0
- package/dist/shims/app.d.ts +42 -0
- package/dist/shims/app.js +48 -0
- package/dist/shims/before-interactive-context.d.ts +40 -0
- package/dist/shims/before-interactive-context.js +8 -0
- package/dist/shims/cache-for-request.d.ts +57 -0
- package/dist/shims/cache-for-request.js +72 -0
- package/dist/shims/cache-handler.d.ts +106 -0
- package/dist/shims/cache-handler.js +176 -0
- package/dist/shims/cache-request-state.d.ts +47 -0
- package/dist/shims/cache-request-state.js +126 -0
- package/dist/shims/cache-runtime.d.ts +83 -0
- package/dist/shims/cache-runtime.js +452 -0
- package/dist/shims/cache.d.ts +145 -0
- package/dist/shims/cache.js +401 -0
- package/dist/shims/cdn-cache.d.ts +125 -0
- package/dist/shims/cdn-cache.js +100 -0
- package/dist/shims/client-hook-error.d.ts +13 -0
- package/dist/shims/client-hook-error.js +17 -0
- package/dist/shims/client-locale.d.ts +14 -0
- package/dist/shims/client-locale.js +11 -0
- package/dist/shims/client-only.d.ts +1 -0
- package/dist/shims/client-only.js +1 -0
- package/dist/shims/compat-router.d.ts +16 -0
- package/dist/shims/compat-router.js +25 -0
- package/dist/shims/config.d.ts +28 -0
- package/dist/shims/config.js +21 -0
- package/dist/shims/constants.d.ts +130 -0
- package/dist/shims/constants.js +167 -0
- package/dist/shims/default-global-error.d.ts +31 -0
- package/dist/shims/default-global-error.js +179 -0
- package/dist/shims/default-not-found.d.ts +11 -0
- package/dist/shims/default-not-found.js +59 -0
- package/dist/shims/document.d.ts +92 -0
- package/dist/shims/document.js +76 -0
- package/dist/shims/dynamic-preload-chunks.d.ts +8 -0
- package/dist/shims/dynamic-preload-chunks.js +79 -0
- package/dist/shims/dynamic.d.ts +35 -0
- package/dist/shims/dynamic.js +204 -0
- package/dist/shims/error-boundary-navigation.d.ts +7 -0
- package/dist/shims/error-boundary-navigation.js +44 -0
- package/dist/shims/error-boundary.d.ts +155 -0
- package/dist/shims/error-boundary.js +342 -0
- package/dist/shims/error.d.ts +31 -0
- package/dist/shims/error.js +123 -0
- package/dist/shims/error.react-server.d.ts +9 -0
- package/dist/shims/error.react-server.js +6 -0
- package/dist/shims/fetch-cache.d.ts +136 -0
- package/dist/shims/fetch-cache.js +766 -0
- package/dist/shims/font-google-base.d.ts +83 -0
- package/dist/shims/font-google-base.js +290 -0
- package/dist/shims/font-google.d.ts +2 -0
- package/dist/shims/font-google.js +2 -0
- package/dist/shims/font-local.d.ts +50 -0
- package/dist/shims/font-local.js +195 -0
- package/dist/shims/font-utils.d.ts +56 -0
- package/dist/shims/font-utils.js +107 -0
- package/dist/shims/form.d.ts +19 -0
- package/dist/shims/form.js +236 -0
- package/dist/shims/hash-scroll.d.ts +10 -0
- package/dist/shims/hash-scroll.js +47 -0
- package/dist/shims/head-state.d.ts +16 -0
- package/dist/shims/head-state.js +43 -0
- package/dist/shims/head.d.ts +73 -0
- package/dist/shims/head.js +340 -0
- package/dist/shims/headers.d.ts +253 -0
- package/dist/shims/headers.js +754 -0
- package/dist/shims/i18n-context.d.ts +22 -0
- package/dist/shims/i18n-context.js +42 -0
- package/dist/shims/i18n-state.d.ts +14 -0
- package/dist/shims/i18n-state.js +38 -0
- package/dist/shims/image-config.d.ts +45 -0
- package/dist/shims/image-config.js +85 -0
- package/dist/shims/image.d.ts +55 -0
- package/dist/shims/image.js +582 -0
- package/dist/shims/internal/als-registry.d.ts +14 -0
- package/dist/shims/internal/als-registry.js +80 -0
- package/dist/shims/internal/api-utils.d.ts +14 -0
- package/dist/shims/internal/api-utils.js +1 -0
- package/dist/shims/internal/app-page-props-cache-key.d.ts +5 -0
- package/dist/shims/internal/app-page-props-cache-key.js +16 -0
- package/dist/shims/internal/app-route-detection.d.ts +39 -0
- package/dist/shims/internal/app-route-detection.js +62 -0
- package/dist/shims/internal/app-router-context.d.ts +31 -0
- package/dist/shims/internal/app-router-context.js +28 -0
- package/dist/shims/internal/cookie-serialize.d.ts +45 -0
- package/dist/shims/internal/cookie-serialize.js +49 -0
- package/dist/shims/internal/cookies.d.ts +2 -0
- package/dist/shims/internal/cookies.js +2 -0
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +31 -0
- package/dist/shims/internal/hybrid-client-route-owner.js +143 -0
- package/dist/shims/internal/interpolate-as.d.ts +25 -0
- package/dist/shims/internal/interpolate-as.js +196 -0
- package/dist/shims/internal/link-status-registry.d.ts +43 -0
- package/dist/shims/internal/link-status-registry.js +42 -0
- package/dist/shims/internal/make-hanging-promise.d.ts +15 -0
- package/dist/shims/internal/make-hanging-promise.js +44 -0
- package/dist/shims/internal/navigation-untracked.d.ts +35 -0
- package/dist/shims/internal/navigation-untracked.js +56 -0
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +54 -0
- package/dist/shims/internal/pages-data-fetch-dedup.js +121 -0
- package/dist/shims/internal/pages-data-target.d.ts +62 -0
- package/dist/shims/internal/pages-data-target.js +98 -0
- package/dist/shims/internal/pages-data-url.d.ts +41 -0
- package/dist/shims/internal/pages-data-url.js +71 -0
- package/dist/shims/internal/pages-router-accessor.d.ts +19 -0
- package/dist/shims/internal/pages-router-accessor.js +13 -0
- package/dist/shims/internal/route-pattern-for-warning.d.ts +27 -0
- package/dist/shims/internal/route-pattern-for-warning.js +40 -0
- package/dist/shims/internal/router-context.d.ts +7 -0
- package/dist/shims/internal/router-context.js +13 -0
- package/dist/shims/internal/utils.d.ts +52 -0
- package/dist/shims/internal/utils.js +27 -0
- package/dist/shims/internal/work-unit-async-storage.d.ts +30 -0
- package/dist/shims/internal/work-unit-async-storage.js +17 -0
- package/dist/shims/layout-segment-context.d.ts +24 -0
- package/dist/shims/layout-segment-context.js +39 -0
- package/dist/shims/legacy-image.d.ts +41 -0
- package/dist/shims/legacy-image.js +49 -0
- package/dist/shims/link-prefetch.d.ts +41 -0
- package/dist/shims/link-prefetch.js +43 -0
- package/dist/shims/link.d.ts +102 -0
- package/dist/shims/link.js +687 -0
- package/dist/shims/metadata.d.ts +285 -0
- package/dist/shims/metadata.js +820 -0
- package/dist/shims/navigation-context-state.d.ts +40 -0
- package/dist/shims/navigation-context-state.js +116 -0
- package/dist/shims/navigation-errors.d.ts +55 -0
- package/dist/shims/navigation-errors.js +110 -0
- package/dist/shims/navigation-server.d.ts +3 -0
- package/dist/shims/navigation-server.js +3 -0
- package/dist/shims/navigation-state.d.ts +25 -0
- package/dist/shims/navigation-state.js +66 -0
- package/dist/shims/navigation.d.ts +286 -0
- package/dist/shims/navigation.js +1206 -0
- package/dist/shims/navigation.react-server.d.ts +14 -0
- package/dist/shims/navigation.react-server.js +32 -0
- package/dist/shims/offline.d.ts +4 -0
- package/dist/shims/offline.js +15 -0
- package/dist/shims/og.d.ts +17 -0
- package/dist/shims/og.js +48 -0
- package/dist/shims/pages-router-runtime.d.ts +12 -0
- package/dist/shims/pages-router-runtime.js +24 -0
- package/dist/shims/ppr-fallback-shell.d.ts +33 -0
- package/dist/shims/ppr-fallback-shell.js +170 -0
- package/dist/shims/readonly-url-search-params.d.ts +13 -0
- package/dist/shims/readonly-url-search-params.js +26 -0
- package/dist/shims/request-context.d.ts +58 -0
- package/dist/shims/request-context.js +45 -0
- package/dist/shims/request-state-types.d.ts +12 -0
- package/dist/shims/request-state-types.js +1 -0
- package/dist/shims/root-params.d.ts +12 -0
- package/dist/shims/root-params.js +30 -0
- package/dist/shims/router-state.d.ts +32 -0
- package/dist/shims/router-state.js +39 -0
- package/dist/shims/router.d.ts +192 -0
- package/dist/shims/router.js +1786 -0
- package/dist/shims/script-nonce-context.d.ts +11 -0
- package/dist/shims/script-nonce-context.js +23 -0
- package/dist/shims/script.d.ts +43 -0
- package/dist/shims/script.js +370 -0
- package/dist/shims/server-only.d.ts +1 -0
- package/dist/shims/server-only.js +1 -0
- package/dist/shims/server.d.ts +323 -0
- package/dist/shims/server.js +729 -0
- package/dist/shims/slot.d.ts +45 -0
- package/dist/shims/slot.js +230 -0
- package/dist/shims/thenable-params.d.ts +11 -0
- package/dist/shims/thenable-params.js +176 -0
- package/dist/shims/unified-request-context.d.ts +68 -0
- package/dist/shims/unified-request-context.js +86 -0
- package/dist/shims/unrecognized-action-error.d.ts +34 -0
- package/dist/shims/unrecognized-action-error.js +39 -0
- package/dist/shims/url-safety.d.ts +34 -0
- package/dist/shims/url-safety.js +70 -0
- package/dist/shims/url-utils.d.ts +51 -0
- package/dist/shims/url-utils.js +156 -0
- package/dist/shims/use-merged-ref.d.ts +6 -0
- package/dist/shims/use-merged-ref.js +38 -0
- package/dist/shims/web-vitals.d.ts +8 -0
- package/dist/shims/web-vitals.js +22 -0
- package/dist/typegen.d.ts +9 -0
- package/dist/typegen.js +228 -0
- package/dist/utils/asset-prefix.d.ts +96 -0
- package/dist/utils/asset-prefix.js +122 -0
- package/dist/utils/base-path.d.ts +31 -0
- package/dist/utils/base-path.js +45 -0
- package/dist/utils/built-asset-url.d.ts +4 -0
- package/dist/utils/built-asset-url.js +11 -0
- package/dist/utils/cache-control-metadata.d.ts +4 -0
- package/dist/utils/cache-control-metadata.js +12 -0
- package/dist/utils/client-build-manifest.d.ts +21 -0
- package/dist/utils/client-build-manifest.js +87 -0
- package/dist/utils/client-entry-manifest.d.ts +11 -0
- package/dist/utils/client-entry-manifest.js +29 -0
- package/dist/utils/client-runtime-metadata.d.ts +45 -0
- package/dist/utils/client-runtime-metadata.js +63 -0
- package/dist/utils/commonjs-loader.d.ts +16 -0
- package/dist/utils/commonjs-loader.js +100 -0
- package/dist/utils/compare.d.ts +4 -0
- package/dist/utils/compare.js +8 -0
- package/dist/utils/deployment-id.d.ts +8 -0
- package/dist/utils/deployment-id.js +22 -0
- package/dist/utils/dev-error-recovery-event.d.ts +4 -0
- package/dist/utils/dev-error-recovery-event.js +4 -0
- package/dist/utils/domain-locale.d.ts +26 -0
- package/dist/utils/domain-locale.js +50 -0
- package/dist/utils/encode-cache-tag.d.ts +30 -0
- package/dist/utils/encode-cache-tag.js +36 -0
- package/dist/utils/error-cause.d.ts +4 -0
- package/dist/utils/error-cause.js +95 -0
- package/dist/utils/has-trailing-comma.d.ts +24 -0
- package/dist/utils/has-trailing-comma.js +62 -0
- package/dist/utils/hash.d.ts +24 -0
- package/dist/utils/hash.js +55 -0
- package/dist/utils/html-limited-bots.d.ts +21 -0
- package/dist/utils/html-limited-bots.js +35 -0
- package/dist/utils/lazy-chunks.d.ts +59 -0
- package/dist/utils/lazy-chunks.js +112 -0
- package/dist/utils/manifest-paths.d.ts +30 -0
- package/dist/utils/manifest-paths.js +66 -0
- package/dist/utils/mdx-scan.d.ts +9 -0
- package/dist/utils/mdx-scan.js +34 -0
- package/dist/utils/navigation-signal.d.ts +4 -0
- package/dist/utils/navigation-signal.js +12 -0
- package/dist/utils/number.d.ts +4 -0
- package/dist/utils/number.js +6 -0
- package/dist/utils/parse-cookie.d.ts +13 -0
- package/dist/utils/parse-cookie.js +52 -0
- package/dist/utils/path.d.ts +22 -0
- package/dist/utils/path.js +30 -0
- package/dist/utils/prerender-output-paths.d.ts +14 -0
- package/dist/utils/prerender-output-paths.js +22 -0
- package/dist/utils/project.d.ts +76 -0
- package/dist/utils/project.js +213 -0
- package/dist/utils/promise.d.ts +4 -0
- package/dist/utils/promise.js +6 -0
- package/dist/utils/public-routes.d.ts +4 -0
- package/dist/utils/public-routes.js +48 -0
- package/dist/utils/query.d.ts +49 -0
- package/dist/utils/query.js +122 -0
- package/dist/utils/record.d.ts +4 -0
- package/dist/utils/record.js +6 -0
- package/dist/utils/regex.d.ts +4 -0
- package/dist/utils/regex.js +6 -0
- package/dist/utils/safe-json-file.d.ts +17 -0
- package/dist/utils/safe-json-file.js +23 -0
- package/dist/utils/sorted-array.d.ts +8 -0
- package/dist/utils/sorted-array.js +20 -0
- package/dist/utils/text-stream.d.ts +28 -0
- package/dist/utils/text-stream.js +64 -0
- package/dist/utils/vinext-root.d.ts +23 -0
- package/dist/utils/vinext-root.js +29 -0
- package/dist/utils/virtual-module.d.ts +5 -0
- package/dist/utils/virtual-module.js +0 -0
- package/dist/utils/vite-version.d.ts +21 -0
- package/dist/utils/vite-version.js +42 -0
- package/package.json +145 -0
|
@@ -0,0 +1,766 @@
|
|
|
1
|
+
import { getOrCreateAls } from "./internal/als-registry.js";
|
|
2
|
+
import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation } from "./unified-request-context.js";
|
|
3
|
+
import { getRequestExecutionContext } from "./request-context.js";
|
|
4
|
+
import { getDataCacheHandler } from "./cache-handler.js";
|
|
5
|
+
import { markDynamicUsage } from "./headers.js";
|
|
6
|
+
import { encodeCacheTags } from "../utils/encode-cache-tag.js";
|
|
7
|
+
//#region src/shims/fetch-cache.ts
|
|
8
|
+
/**
|
|
9
|
+
* Extended fetch() with Next.js caching semantics.
|
|
10
|
+
*
|
|
11
|
+
* Patches `globalThis.fetch` during server rendering to support:
|
|
12
|
+
*
|
|
13
|
+
* fetch(url, { next: { revalidate: 60, tags: ['posts'] } })
|
|
14
|
+
* fetch(url, { cache: 'force-cache' })
|
|
15
|
+
* fetch(url, { cache: 'no-store' })
|
|
16
|
+
*
|
|
17
|
+
* Cached responses are stored via the pluggable CacheHandler, so
|
|
18
|
+
* revalidateTag() and revalidatePath() invalidate fetch-level caches.
|
|
19
|
+
*
|
|
20
|
+
* Usage (in server entry):
|
|
21
|
+
* import { withFetchCache, cleanupFetchCache } from './fetch-cache';
|
|
22
|
+
* const cleanup = withFetchCache();
|
|
23
|
+
* try { ... render ... } finally { cleanup(); }
|
|
24
|
+
*
|
|
25
|
+
* Or use the async helper:
|
|
26
|
+
* await runWithFetchCache(async () => { ... render ... });
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Headers excluded from the cache key. These are W3C trace context headers
|
|
30
|
+
* that can break request caching and deduplication.
|
|
31
|
+
* All other headers ARE included in the cache key, matching Next.js behavior.
|
|
32
|
+
*/
|
|
33
|
+
const HEADER_BLOCKLIST = ["traceparent", "tracestate"];
|
|
34
|
+
const CACHE_KEY_PREFIX = "v3";
|
|
35
|
+
const MAX_CACHE_KEY_BODY_BYTES = 1024 * 1024;
|
|
36
|
+
const ONE_YEAR_SECONDS = 31536e3;
|
|
37
|
+
var BodyTooLargeForCacheKeyError = class extends Error {
|
|
38
|
+
constructor() {
|
|
39
|
+
super("Fetch body too large for cache key generation");
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var SkipCacheKeyGenerationError = class extends Error {
|
|
43
|
+
constructor() {
|
|
44
|
+
super("Fetch body could not be serialized for cache key generation");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Collect all headers from the request, excluding the blocklist.
|
|
49
|
+
* Merges headers from both the Request object and the init object,
|
|
50
|
+
* with init taking precedence (matching fetch() spec behavior).
|
|
51
|
+
*/
|
|
52
|
+
function collectHeaders(input, init) {
|
|
53
|
+
const merged = {};
|
|
54
|
+
if (input instanceof Request && input.headers) input.headers.forEach((v, k) => {
|
|
55
|
+
merged[k] = v;
|
|
56
|
+
});
|
|
57
|
+
if (init?.headers) (init.headers instanceof Headers ? init.headers : new Headers(init.headers)).forEach((v, k) => {
|
|
58
|
+
merged[k] = v;
|
|
59
|
+
});
|
|
60
|
+
for (const blocked of HEADER_BLOCKLIST) delete merged[blocked];
|
|
61
|
+
return merged;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Check whether a fetch request carries any per-user auth headers.
|
|
65
|
+
* Used for the safety bypass (skip caching when auth headers are present
|
|
66
|
+
* without an explicit cache opt-in).
|
|
67
|
+
*/
|
|
68
|
+
const AUTH_HEADERS = [
|
|
69
|
+
"authorization",
|
|
70
|
+
"cookie",
|
|
71
|
+
"x-api-key"
|
|
72
|
+
];
|
|
73
|
+
function hasAuthHeaders(input, init) {
|
|
74
|
+
const headers = collectHeaders(input, init);
|
|
75
|
+
return AUTH_HEADERS.some((name) => name in headers);
|
|
76
|
+
}
|
|
77
|
+
async function serializeFormData(formData, pushBodyChunk, getTotalBodyBytes) {
|
|
78
|
+
for (const [key, val] of formData.entries()) {
|
|
79
|
+
if (typeof val === "string") {
|
|
80
|
+
pushBodyChunk(JSON.stringify([key, {
|
|
81
|
+
kind: "string",
|
|
82
|
+
value: val
|
|
83
|
+
}]));
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (val.size > MAX_CACHE_KEY_BODY_BYTES || getTotalBodyBytes() + val.size > MAX_CACHE_KEY_BODY_BYTES) throw new BodyTooLargeForCacheKeyError();
|
|
87
|
+
pushBodyChunk(JSON.stringify([key, {
|
|
88
|
+
kind: "file",
|
|
89
|
+
name: val.name,
|
|
90
|
+
type: val.type,
|
|
91
|
+
value: await val.text()
|
|
92
|
+
}]));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function getParsedFormContentType(contentType) {
|
|
96
|
+
const mediaType = contentType?.split(";")[0]?.trim().toLowerCase();
|
|
97
|
+
if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") return mediaType;
|
|
98
|
+
}
|
|
99
|
+
function stripMultipartBoundary(contentType) {
|
|
100
|
+
const [type, ...params] = contentType.split(";");
|
|
101
|
+
const keptParams = params.map((param) => param.trim()).filter(Boolean).filter((param) => !/^boundary\s*=/i.test(param));
|
|
102
|
+
const normalizedType = type.trim().toLowerCase();
|
|
103
|
+
return keptParams.length > 0 ? `${normalizedType}; ${keptParams.join("; ")}` : normalizedType;
|
|
104
|
+
}
|
|
105
|
+
async function readRequestBodyChunksWithinLimit(request) {
|
|
106
|
+
const contentLengthHeader = request.headers.get("content-length");
|
|
107
|
+
if (contentLengthHeader) {
|
|
108
|
+
const contentLength = Number(contentLengthHeader);
|
|
109
|
+
if (Number.isFinite(contentLength) && contentLength > MAX_CACHE_KEY_BODY_BYTES) throw new BodyTooLargeForCacheKeyError();
|
|
110
|
+
}
|
|
111
|
+
const requestClone = request.clone();
|
|
112
|
+
const contentType = requestClone.headers.get("content-type") ?? void 0;
|
|
113
|
+
const reader = requestClone.body?.getReader();
|
|
114
|
+
if (!reader) return {
|
|
115
|
+
chunks: [],
|
|
116
|
+
contentType
|
|
117
|
+
};
|
|
118
|
+
const chunks = [];
|
|
119
|
+
let totalBodyBytes = 0;
|
|
120
|
+
try {
|
|
121
|
+
while (true) {
|
|
122
|
+
const { done, value } = await reader.read();
|
|
123
|
+
if (done) break;
|
|
124
|
+
totalBodyBytes += value.byteLength;
|
|
125
|
+
if (totalBodyBytes > MAX_CACHE_KEY_BODY_BYTES) throw new BodyTooLargeForCacheKeyError();
|
|
126
|
+
chunks.push(value);
|
|
127
|
+
}
|
|
128
|
+
} catch (err) {
|
|
129
|
+
reader.cancel().catch(() => {});
|
|
130
|
+
throw err;
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
chunks,
|
|
134
|
+
contentType
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Serialize request body into string chunks for cache key inclusion.
|
|
139
|
+
* Handles all body types: string, Uint8Array, ReadableStream, FormData, Blob,
|
|
140
|
+
* and Request object bodies.
|
|
141
|
+
* Returns the serialized body chunks and optionally stashes the original body
|
|
142
|
+
* on init as `_ogBody` so it can still be used after stream consumption.
|
|
143
|
+
*/
|
|
144
|
+
async function serializeBody(input, init) {
|
|
145
|
+
if (!init?.body && !(input instanceof Request && input.body)) return { bodyChunks: [] };
|
|
146
|
+
const bodyChunks = [];
|
|
147
|
+
const encoder = new TextEncoder();
|
|
148
|
+
const decoder = new TextDecoder();
|
|
149
|
+
let totalBodyBytes = 0;
|
|
150
|
+
let canonicalizedContentType;
|
|
151
|
+
const pushBodyChunk = (chunk) => {
|
|
152
|
+
totalBodyBytes += encoder.encode(chunk).byteLength;
|
|
153
|
+
if (totalBodyBytes > MAX_CACHE_KEY_BODY_BYTES) throw new BodyTooLargeForCacheKeyError();
|
|
154
|
+
bodyChunks.push(chunk);
|
|
155
|
+
};
|
|
156
|
+
const getTotalBodyBytes = () => totalBodyBytes;
|
|
157
|
+
if (init?.body instanceof Uint8Array) {
|
|
158
|
+
if (init.body.byteLength > MAX_CACHE_KEY_BODY_BYTES) throw new BodyTooLargeForCacheKeyError();
|
|
159
|
+
pushBodyChunk(decoder.decode(init.body));
|
|
160
|
+
init._ogBody = init.body;
|
|
161
|
+
} else if (init?.body && typeof init.body.getReader === "function") {
|
|
162
|
+
const [bodyForHashing, bodyForFetch] = init.body.tee();
|
|
163
|
+
init._ogBody = bodyForFetch;
|
|
164
|
+
const reader = bodyForHashing.getReader();
|
|
165
|
+
try {
|
|
166
|
+
while (true) {
|
|
167
|
+
const { done, value } = await reader.read();
|
|
168
|
+
if (done) break;
|
|
169
|
+
if (typeof value === "string") pushBodyChunk(value);
|
|
170
|
+
else {
|
|
171
|
+
totalBodyBytes += value.byteLength;
|
|
172
|
+
if (totalBodyBytes > MAX_CACHE_KEY_BODY_BYTES) throw new BodyTooLargeForCacheKeyError();
|
|
173
|
+
bodyChunks.push(decoder.decode(value, { stream: true }));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const finalChunk = decoder.decode();
|
|
177
|
+
if (finalChunk) pushBodyChunk(finalChunk);
|
|
178
|
+
} catch (err) {
|
|
179
|
+
await reader.cancel();
|
|
180
|
+
if (err instanceof BodyTooLargeForCacheKeyError) throw err;
|
|
181
|
+
throw new SkipCacheKeyGenerationError();
|
|
182
|
+
}
|
|
183
|
+
} else if (init?.body instanceof URLSearchParams) {
|
|
184
|
+
init._ogBody = init.body;
|
|
185
|
+
pushBodyChunk(init.body.toString());
|
|
186
|
+
} else if (init?.body && typeof init.body.keys === "function") {
|
|
187
|
+
const formData = init.body;
|
|
188
|
+
init._ogBody = init.body;
|
|
189
|
+
await serializeFormData(formData, pushBodyChunk, getTotalBodyBytes);
|
|
190
|
+
} else if (init?.body && typeof init.body.arrayBuffer === "function") {
|
|
191
|
+
const blob = init.body;
|
|
192
|
+
if (blob.size > MAX_CACHE_KEY_BODY_BYTES) throw new BodyTooLargeForCacheKeyError();
|
|
193
|
+
pushBodyChunk(await blob.text());
|
|
194
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
195
|
+
init._ogBody = new Blob([arrayBuffer], { type: blob.type });
|
|
196
|
+
} else if (typeof init?.body === "string") {
|
|
197
|
+
if (init.body.length > MAX_CACHE_KEY_BODY_BYTES) throw new BodyTooLargeForCacheKeyError();
|
|
198
|
+
pushBodyChunk(init.body);
|
|
199
|
+
init._ogBody = init.body;
|
|
200
|
+
} else if (input instanceof Request && input.body) {
|
|
201
|
+
let chunks;
|
|
202
|
+
let contentType;
|
|
203
|
+
try {
|
|
204
|
+
({chunks, contentType} = await readRequestBodyChunksWithinLimit(input));
|
|
205
|
+
} catch (err) {
|
|
206
|
+
if (err instanceof BodyTooLargeForCacheKeyError) throw err;
|
|
207
|
+
throw new SkipCacheKeyGenerationError();
|
|
208
|
+
}
|
|
209
|
+
const formContentType = getParsedFormContentType(contentType);
|
|
210
|
+
if (formContentType) try {
|
|
211
|
+
await serializeFormData(await new Request(input.url, {
|
|
212
|
+
method: input.method,
|
|
213
|
+
headers: contentType ? { "content-type": contentType } : void 0,
|
|
214
|
+
body: new Blob(chunks)
|
|
215
|
+
}).formData(), pushBodyChunk, getTotalBodyBytes);
|
|
216
|
+
canonicalizedContentType = formContentType === "multipart/form-data" && contentType ? stripMultipartBoundary(contentType) : void 0;
|
|
217
|
+
return {
|
|
218
|
+
bodyChunks,
|
|
219
|
+
canonicalizedContentType
|
|
220
|
+
};
|
|
221
|
+
} catch (err) {
|
|
222
|
+
if (err instanceof BodyTooLargeForCacheKeyError) throw err;
|
|
223
|
+
throw new SkipCacheKeyGenerationError();
|
|
224
|
+
}
|
|
225
|
+
for (const chunk of chunks) pushBodyChunk(decoder.decode(chunk, { stream: true }));
|
|
226
|
+
const finalChunk = decoder.decode();
|
|
227
|
+
if (finalChunk) pushBodyChunk(finalChunk);
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
bodyChunks,
|
|
231
|
+
canonicalizedContentType
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Generate a deterministic cache key from a fetch request.
|
|
236
|
+
*
|
|
237
|
+
* Matches Next.js behavior: the key is a SHA-256 hash of a JSON array
|
|
238
|
+
* containing URL, method, all headers (minus blocklist), all RequestInit
|
|
239
|
+
* options, and the serialized body.
|
|
240
|
+
*/
|
|
241
|
+
async function buildFetchCacheKey(input, init) {
|
|
242
|
+
let url;
|
|
243
|
+
let method = "GET";
|
|
244
|
+
if (typeof input === "string") url = input;
|
|
245
|
+
else if (input instanceof URL) url = input.toString();
|
|
246
|
+
else {
|
|
247
|
+
url = input.url;
|
|
248
|
+
method = input.method || "GET";
|
|
249
|
+
}
|
|
250
|
+
if (init?.method) method = init.method;
|
|
251
|
+
const headers = collectHeaders(input, init);
|
|
252
|
+
const { bodyChunks, canonicalizedContentType } = await serializeBody(input, init);
|
|
253
|
+
if (canonicalizedContentType) headers["content-type"] = canonicalizedContentType;
|
|
254
|
+
const cacheString = JSON.stringify([
|
|
255
|
+
CACHE_KEY_PREFIX,
|
|
256
|
+
url,
|
|
257
|
+
method,
|
|
258
|
+
headers,
|
|
259
|
+
init?.mode,
|
|
260
|
+
init?.redirect,
|
|
261
|
+
init?.credentials,
|
|
262
|
+
init?.referrer,
|
|
263
|
+
init?.referrerPolicy,
|
|
264
|
+
init?.integrity,
|
|
265
|
+
init?.cache,
|
|
266
|
+
bodyChunks
|
|
267
|
+
]);
|
|
268
|
+
const buffer = new TextEncoder().encode(cacheString);
|
|
269
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", buffer);
|
|
270
|
+
return Array.prototype.map.call(new Uint8Array(hashBuffer), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
271
|
+
}
|
|
272
|
+
const _PENDING_KEY = Symbol.for("vinext.fetchCache.pendingRefetches");
|
|
273
|
+
const _gPending = globalThis;
|
|
274
|
+
const pendingRefetches = _gPending[_PENDING_KEY] ??= /* @__PURE__ */ new Map();
|
|
275
|
+
const DEDUP_TIMEOUT_MS = 6e4;
|
|
276
|
+
/** @internal Reset dedup state — exposed for test isolation only. */
|
|
277
|
+
function _resetPendingRefetches() {
|
|
278
|
+
pendingRefetches.clear();
|
|
279
|
+
}
|
|
280
|
+
const _ORIG_FETCH_KEY = Symbol.for("vinext.fetchCache.originalFetch");
|
|
281
|
+
const _gFetch = globalThis;
|
|
282
|
+
const originalFetch = _gFetch[_ORIG_FETCH_KEY] ??= globalThis.fetch;
|
|
283
|
+
const _FALLBACK_KEY = Symbol.for("vinext.fetchCache.fallback");
|
|
284
|
+
const _g = globalThis;
|
|
285
|
+
const _als = getOrCreateAls("vinext.fetchCache.als");
|
|
286
|
+
const _noop = () => {};
|
|
287
|
+
let _responseBodyRegistry;
|
|
288
|
+
if (globalThis.FinalizationRegistry) _responseBodyRegistry = new FinalizationRegistry((weakRef) => {
|
|
289
|
+
const stream = weakRef.deref();
|
|
290
|
+
if (stream && !stream.locked) stream.cancel("Response object has been garbage collected").then(_noop, _noop);
|
|
291
|
+
});
|
|
292
|
+
const _fallbackState = _g[_FALLBACK_KEY] ??= {
|
|
293
|
+
cacheableFetchUrls: /* @__PURE__ */ new Set(),
|
|
294
|
+
currentRequestTags: [],
|
|
295
|
+
currentFetchSoftTags: [],
|
|
296
|
+
currentFetchCacheMode: null,
|
|
297
|
+
currentForceDynamicFetchDefault: false,
|
|
298
|
+
dynamicFetchUrls: /* @__PURE__ */ new Set(),
|
|
299
|
+
isFetchDedupeActive: false,
|
|
300
|
+
currentFetchDedupeEntries: /* @__PURE__ */ new Map()
|
|
301
|
+
};
|
|
302
|
+
function _getState() {
|
|
303
|
+
if (isInsideUnifiedScope()) return getRequestContext();
|
|
304
|
+
return _als.getStore() ?? _fallbackState;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Reset the fallback state for a new request. Used by `withFetchCache()`
|
|
308
|
+
* in single-threaded contexts where ALS.run() isn't used.
|
|
309
|
+
*/
|
|
310
|
+
function _resetFallbackState(isFetchDedupeActive) {
|
|
311
|
+
_fallbackState.cacheableFetchUrls = /* @__PURE__ */ new Set();
|
|
312
|
+
_fallbackState.currentRequestTags = [];
|
|
313
|
+
_fallbackState.currentFetchSoftTags = [];
|
|
314
|
+
_fallbackState.currentFetchCacheMode = null;
|
|
315
|
+
_fallbackState.currentForceDynamicFetchDefault = false;
|
|
316
|
+
_fallbackState.dynamicFetchUrls = /* @__PURE__ */ new Set();
|
|
317
|
+
_fallbackState.isFetchDedupeActive = isFetchDedupeActive;
|
|
318
|
+
_fallbackState.currentFetchDedupeEntries = /* @__PURE__ */ new Map();
|
|
319
|
+
}
|
|
320
|
+
function getFetchObservationUrl(input) {
|
|
321
|
+
return typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
322
|
+
}
|
|
323
|
+
function recordDynamicFetchObservation(input) {
|
|
324
|
+
_getState().dynamicFetchUrls.add(getFetchObservationUrl(input));
|
|
325
|
+
}
|
|
326
|
+
function markUncachedFetchForPageOutput(input) {
|
|
327
|
+
recordDynamicFetchObservation(input);
|
|
328
|
+
markDynamicUsage();
|
|
329
|
+
}
|
|
330
|
+
function recordCacheableFetchObservation(input) {
|
|
331
|
+
_getState().cacheableFetchUrls.add(getFetchObservationUrl(input));
|
|
332
|
+
}
|
|
333
|
+
function peekCacheableFetchObservations() {
|
|
334
|
+
return [..._getState().cacheableFetchUrls].sort();
|
|
335
|
+
}
|
|
336
|
+
function peekDynamicFetchObservations() {
|
|
337
|
+
return [..._getState().dynamicFetchUrls].sort();
|
|
338
|
+
}
|
|
339
|
+
function consumeDynamicFetchObservations() {
|
|
340
|
+
const state = _getState();
|
|
341
|
+
const observed = [...state.dynamicFetchUrls].sort();
|
|
342
|
+
state.dynamicFetchUrls = /* @__PURE__ */ new Set();
|
|
343
|
+
return observed;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Get tags collected during the current render pass.
|
|
347
|
+
* Useful for associating page-level cache entries with all the
|
|
348
|
+
* fetch tags used during rendering.
|
|
349
|
+
*/
|
|
350
|
+
function getCollectedFetchTags() {
|
|
351
|
+
return [..._getState().currentRequestTags];
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Append cache tags to the current request's collected tags.
|
|
355
|
+
*
|
|
356
|
+
* Mirrors Next.js's `propagateCacheLifeAndTagsToRevalidateStore`: tags declared
|
|
357
|
+
* inside a `"use cache"` function (via `cacheTag()`, persisted on the data cache
|
|
358
|
+
* entry) must also bubble up to the surrounding page / route-handler ISR entry
|
|
359
|
+
* so `revalidateTag()` / `revalidatePath()` can evict the rendered output, not
|
|
360
|
+
* just the inner data cache entry. Without this, a cached `"use cache"` result
|
|
361
|
+
* keeps being served from a stale page/route entry after its tag is revalidated
|
|
362
|
+
* (issue #1453). Tags are already encoded by the caller; deduped to match the
|
|
363
|
+
* tagged-fetch path. A no-op for empty input.
|
|
364
|
+
*/
|
|
365
|
+
function addCollectedRequestTags(tags) {
|
|
366
|
+
if (tags.length === 0) return;
|
|
367
|
+
const reqTags = _getState().currentRequestTags;
|
|
368
|
+
for (const tag of tags) if (!reqTags.includes(tag)) reqTags.push(tag);
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Set path-derived implicit tags for fetch cache reads in the current render.
|
|
372
|
+
*
|
|
373
|
+
* These are intentionally not persisted on fetch entries. They mirror Next.js
|
|
374
|
+
* `softTags`: `revalidatePath()` should make a fetch miss while rendering the
|
|
375
|
+
* affected route, without permanently coupling a shared fetch entry to one path.
|
|
376
|
+
*/
|
|
377
|
+
function setCurrentFetchSoftTags(tags) {
|
|
378
|
+
_getState().currentFetchSoftTags = [...tags];
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Read the path-derived soft tags for the current render.
|
|
382
|
+
*
|
|
383
|
+
* Used by the "use cache" runtime to pass soft tags to the cache handler
|
|
384
|
+
* so that `revalidatePath()` invalidates "use cache" entries during the
|
|
385
|
+
* affected route's next request, even when the entry carries no hard tags.
|
|
386
|
+
*/
|
|
387
|
+
function getCurrentFetchSoftTags() {
|
|
388
|
+
return _getState().currentFetchSoftTags;
|
|
389
|
+
}
|
|
390
|
+
function setCurrentFetchCacheMode(mode) {
|
|
391
|
+
_getState().currentFetchCacheMode = mode;
|
|
392
|
+
}
|
|
393
|
+
function setCurrentForceDynamicFetchDefault(enabled) {
|
|
394
|
+
_getState().currentForceDynamicFetchDefault = enabled;
|
|
395
|
+
}
|
|
396
|
+
function isNoStoreFetch(cacheDirective, nextOpts) {
|
|
397
|
+
return cacheDirective === "no-store" || cacheDirective === "no-cache" || nextOpts?.revalidate === 0;
|
|
398
|
+
}
|
|
399
|
+
function isCacheableFetch(cacheDirective, nextOpts) {
|
|
400
|
+
return cacheDirective === "force-cache" || nextOpts?.revalidate === false || typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0;
|
|
401
|
+
}
|
|
402
|
+
function hasExplicitRevalidateValue(nextOpts) {
|
|
403
|
+
return nextOpts?.revalidate !== void 0;
|
|
404
|
+
}
|
|
405
|
+
function isFalsyRevalidate(nextOpts) {
|
|
406
|
+
return !nextOpts?.revalidate;
|
|
407
|
+
}
|
|
408
|
+
function resolveSegmentCacheDirective(cacheDirective, nextOpts, mode, forceDynamicFetchDefault) {
|
|
409
|
+
if (forceDynamicFetchDefault && (!mode || mode === "auto") && (cacheDirective === void 0 || cacheDirective === "default") && isFalsyRevalidate(nextOpts)) return "no-store";
|
|
410
|
+
if (!mode || mode === "auto") return cacheDirective;
|
|
411
|
+
switch (mode) {
|
|
412
|
+
case "force-cache": return "force-cache";
|
|
413
|
+
case "force-no-store": return "no-store";
|
|
414
|
+
case "only-cache":
|
|
415
|
+
if (isNoStoreFetch(cacheDirective, nextOpts)) throw new Error("Route segment config `fetchCache = \"only-cache\"` conflicts with no-store fetch.");
|
|
416
|
+
return cacheDirective ?? "force-cache";
|
|
417
|
+
case "only-no-store":
|
|
418
|
+
if (isCacheableFetch(cacheDirective, nextOpts)) throw new Error("Route segment config `fetchCache = \"only-no-store\"` conflicts with cacheable fetch.");
|
|
419
|
+
return cacheDirective ?? "no-store";
|
|
420
|
+
case "default-cache": return cacheDirective ?? (hasExplicitRevalidateValue(nextOpts) ? void 0 : "force-cache");
|
|
421
|
+
case "default-no-store": return cacheDirective ?? (hasExplicitRevalidateValue(nextOpts) ? void 0 : "no-store");
|
|
422
|
+
}
|
|
423
|
+
return cacheDirective;
|
|
424
|
+
}
|
|
425
|
+
function getFetchCacheDirective(input, init) {
|
|
426
|
+
if (init?.cache !== void 0) return init.cache;
|
|
427
|
+
if (!(input instanceof Request) || input.cache === "default") return;
|
|
428
|
+
return input.cache;
|
|
429
|
+
}
|
|
430
|
+
function buildFetchDedupeKey(request) {
|
|
431
|
+
const filteredHeaders = Array.from(request.headers.entries()).filter(([key]) => !HEADER_BLOCKLIST.includes(key.toLowerCase()));
|
|
432
|
+
return JSON.stringify([
|
|
433
|
+
request.method,
|
|
434
|
+
filteredHeaders,
|
|
435
|
+
request.mode,
|
|
436
|
+
request.redirect,
|
|
437
|
+
request.credentials,
|
|
438
|
+
request.referrer,
|
|
439
|
+
request.referrerPolicy,
|
|
440
|
+
request.integrity
|
|
441
|
+
]);
|
|
442
|
+
}
|
|
443
|
+
function createFetchDedupeCandidate(input, init) {
|
|
444
|
+
if (init?.signal) return null;
|
|
445
|
+
const method = init?.method?.toUpperCase();
|
|
446
|
+
if (method && method !== "GET" && method !== "HEAD") return null;
|
|
447
|
+
if (init?.keepalive) return null;
|
|
448
|
+
const request = typeof input === "string" || input instanceof URL ? new Request(input, init) : input;
|
|
449
|
+
if (request.method !== "GET" && request.method !== "HEAD" || request.keepalive) return null;
|
|
450
|
+
return {
|
|
451
|
+
url: request.url,
|
|
452
|
+
key: buildFetchDedupeKey(request)
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
function buildDedupeClone(body, source) {
|
|
456
|
+
const cloned = new Response(body, {
|
|
457
|
+
status: source.status,
|
|
458
|
+
statusText: source.statusText,
|
|
459
|
+
headers: new Headers(source.headers)
|
|
460
|
+
});
|
|
461
|
+
Object.defineProperty(cloned, "url", {
|
|
462
|
+
value: source.url,
|
|
463
|
+
configurable: true,
|
|
464
|
+
enumerable: true,
|
|
465
|
+
writable: false
|
|
466
|
+
});
|
|
467
|
+
if (_responseBodyRegistry && cloned.body) _responseBodyRegistry.register(cloned, new WeakRef(cloned.body));
|
|
468
|
+
return cloned;
|
|
469
|
+
}
|
|
470
|
+
function cloneDedupeResponse(response) {
|
|
471
|
+
if (!response.body) return [buildDedupeClone(null, response), buildDedupeClone(null, response)];
|
|
472
|
+
const [body1, body2] = response.body.tee();
|
|
473
|
+
return [buildDedupeClone(body1, response), buildDedupeClone(body2, response)];
|
|
474
|
+
}
|
|
475
|
+
function buildCachedFetchResponse(data, input) {
|
|
476
|
+
const response = new Response(data.body, {
|
|
477
|
+
status: data.status ?? 200,
|
|
478
|
+
headers: data.headers
|
|
479
|
+
});
|
|
480
|
+
Object.defineProperty(response, "url", {
|
|
481
|
+
value: data.url ?? getFetchObservationUrl(input),
|
|
482
|
+
configurable: true,
|
|
483
|
+
enumerable: true,
|
|
484
|
+
writable: false
|
|
485
|
+
});
|
|
486
|
+
if (_responseBodyRegistry && response.body) _responseBodyRegistry.register(response, new WeakRef(response.body));
|
|
487
|
+
return response;
|
|
488
|
+
}
|
|
489
|
+
function dedupeFetch(input, init) {
|
|
490
|
+
const state = _getState();
|
|
491
|
+
if (!state.isFetchDedupeActive) return originalFetch(input, init);
|
|
492
|
+
const candidate = createFetchDedupeCandidate(input, init);
|
|
493
|
+
if (!candidate) return originalFetch(input, init);
|
|
494
|
+
const entriesByUrl = state.currentFetchDedupeEntries;
|
|
495
|
+
let entries = entriesByUrl.get(candidate.url);
|
|
496
|
+
if (!entries) {
|
|
497
|
+
entries = [];
|
|
498
|
+
entriesByUrl.set(candidate.url, entries);
|
|
499
|
+
}
|
|
500
|
+
for (const entry of entries) {
|
|
501
|
+
if (entry.key !== candidate.key) continue;
|
|
502
|
+
return entry.promise.then(() => {
|
|
503
|
+
if (!entry.response) throw new Error("[vinext] Missing deduped fetch response");
|
|
504
|
+
const [responseForCaller, responseForFutureCaller] = cloneDedupeResponse(entry.response);
|
|
505
|
+
entry.response = responseForFutureCaller;
|
|
506
|
+
return responseForCaller;
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
const promise = originalFetch(input, init);
|
|
510
|
+
const entry = {
|
|
511
|
+
key: candidate.key,
|
|
512
|
+
promise,
|
|
513
|
+
response: null
|
|
514
|
+
};
|
|
515
|
+
entries.push(entry);
|
|
516
|
+
return promise.then((response) => {
|
|
517
|
+
const [responseForCaller, responseForFutureCaller] = cloneDedupeResponse(response);
|
|
518
|
+
entry.response = responseForFutureCaller;
|
|
519
|
+
return responseForCaller;
|
|
520
|
+
}, (err) => {
|
|
521
|
+
const idx = entries.indexOf(entry);
|
|
522
|
+
if (idx !== -1) entries.splice(idx, 1);
|
|
523
|
+
throw err;
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Create a patched fetch function with Next.js caching semantics.
|
|
528
|
+
*
|
|
529
|
+
* The patched fetch:
|
|
530
|
+
* 1. Checks `cache` and `next` options to determine caching behavior
|
|
531
|
+
* 2. On cache hit, returns the cached response without hitting the network
|
|
532
|
+
* 3. On cache miss, fetches from network, stores in cache, returns response
|
|
533
|
+
* 4. Respects `next.revalidate` for TTL-based revalidation
|
|
534
|
+
* 5. Respects `next.tags` for tag-based invalidation via revalidateTag()
|
|
535
|
+
*/
|
|
536
|
+
function createPatchedFetch() {
|
|
537
|
+
return async function patchedFetch(input, init) {
|
|
538
|
+
const nextOpts = init?.next;
|
|
539
|
+
const cacheDirective = resolveSegmentCacheDirective(getFetchCacheDirective(input, init), nextOpts, _getState().currentFetchCacheMode, _getState().currentForceDynamicFetchDefault);
|
|
540
|
+
if (!nextOpts && !cacheDirective) {
|
|
541
|
+
recordDynamicFetchObservation(input);
|
|
542
|
+
return dedupeFetch(input, init);
|
|
543
|
+
}
|
|
544
|
+
if (cacheDirective === "no-store" || cacheDirective === "no-cache" || nextOpts?.revalidate === 0) {
|
|
545
|
+
const cleanInit = stripNextFromInit(init, cacheDirective);
|
|
546
|
+
markUncachedFetchForPageOutput(input);
|
|
547
|
+
return dedupeFetch(input, cleanInit);
|
|
548
|
+
}
|
|
549
|
+
if (!(cacheDirective === "force-cache" || nextOpts?.revalidate === false || typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0) && hasAuthHeaders(input, init)) {
|
|
550
|
+
const cleanInit = stripNextFromInit(init, cacheDirective);
|
|
551
|
+
recordDynamicFetchObservation(input);
|
|
552
|
+
return dedupeFetch(input, cleanInit);
|
|
553
|
+
}
|
|
554
|
+
let revalidateSeconds;
|
|
555
|
+
if (cacheDirective === "force-cache") revalidateSeconds = nextOpts?.revalidate && typeof nextOpts.revalidate === "number" ? nextOpts.revalidate : ONE_YEAR_SECONDS;
|
|
556
|
+
else if (nextOpts?.revalidate === false) revalidateSeconds = ONE_YEAR_SECONDS;
|
|
557
|
+
else if (typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0) revalidateSeconds = nextOpts.revalidate;
|
|
558
|
+
else if (nextOpts?.tags && nextOpts.tags.length > 0) revalidateSeconds = ONE_YEAR_SECONDS;
|
|
559
|
+
else {
|
|
560
|
+
const cleanInit = stripNextFromInit(init, cacheDirective);
|
|
561
|
+
recordDynamicFetchObservation(input);
|
|
562
|
+
return dedupeFetch(input, cleanInit);
|
|
563
|
+
}
|
|
564
|
+
recordCacheableFetchObservation(input);
|
|
565
|
+
const reqTags = _getState().currentRequestTags;
|
|
566
|
+
const tags = encodeCacheTags(nextOpts?.tags ?? []);
|
|
567
|
+
if (tags.length > 0) {
|
|
568
|
+
for (const tag of tags) if (!reqTags.includes(tag)) reqTags.push(tag);
|
|
569
|
+
}
|
|
570
|
+
const softTags = _getState().currentFetchSoftTags;
|
|
571
|
+
let fetchInit = stripNextFromInit(init, cacheDirective);
|
|
572
|
+
let cacheKey;
|
|
573
|
+
try {
|
|
574
|
+
cacheKey = await buildFetchCacheKey(input, fetchInit);
|
|
575
|
+
fetchInit = stripNextFromInit(fetchInit, cacheDirective);
|
|
576
|
+
} catch (err) {
|
|
577
|
+
if (err instanceof BodyTooLargeForCacheKeyError || err instanceof SkipCacheKeyGenerationError) {
|
|
578
|
+
fetchInit = stripNextFromInit(fetchInit, cacheDirective);
|
|
579
|
+
recordDynamicFetchObservation(input);
|
|
580
|
+
return dedupeFetch(input, fetchInit);
|
|
581
|
+
}
|
|
582
|
+
throw err;
|
|
583
|
+
}
|
|
584
|
+
const handler = getDataCacheHandler();
|
|
585
|
+
try {
|
|
586
|
+
const cached = await handler.get(cacheKey, {
|
|
587
|
+
kind: "FETCH",
|
|
588
|
+
tags,
|
|
589
|
+
softTags
|
|
590
|
+
});
|
|
591
|
+
if (cached?.value && cached.value.kind === "FETCH" && cached.cacheState !== "stale") {
|
|
592
|
+
const cachedData = cached.value.data;
|
|
593
|
+
return buildCachedFetchResponse(cachedData, input);
|
|
594
|
+
}
|
|
595
|
+
if (cached?.value && cached.value.kind === "FETCH" && cached.cacheState === "stale") {
|
|
596
|
+
const staleData = cached.value.data;
|
|
597
|
+
if (!pendingRefetches.has(cacheKey)) {
|
|
598
|
+
const refetchPromise = originalFetch(input, fetchInit).then(async (freshResp) => {
|
|
599
|
+
if (freshResp.status !== 200) return;
|
|
600
|
+
const freshBody = await freshResp.text();
|
|
601
|
+
const freshHeaders = {};
|
|
602
|
+
freshResp.headers.forEach((v, k) => {
|
|
603
|
+
if (k.toLowerCase() === "set-cookie") return;
|
|
604
|
+
freshHeaders[k] = v;
|
|
605
|
+
});
|
|
606
|
+
const freshValue = {
|
|
607
|
+
kind: "FETCH",
|
|
608
|
+
data: {
|
|
609
|
+
headers: freshHeaders,
|
|
610
|
+
body: freshBody,
|
|
611
|
+
url: freshResp.url,
|
|
612
|
+
status: freshResp.status
|
|
613
|
+
},
|
|
614
|
+
tags,
|
|
615
|
+
revalidate: revalidateSeconds
|
|
616
|
+
};
|
|
617
|
+
await handler.set(cacheKey, freshValue, {
|
|
618
|
+
fetchCache: true,
|
|
619
|
+
tags,
|
|
620
|
+
revalidate: revalidateSeconds
|
|
621
|
+
});
|
|
622
|
+
}).catch((err) => {
|
|
623
|
+
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
624
|
+
console.error(`[vinext] fetch cache background revalidation failed for ${url} (key=${cacheKey.slice(0, 12)}...):`, err);
|
|
625
|
+
}).finally(() => {
|
|
626
|
+
if (pendingRefetches.get(cacheKey) === refetchPromise) pendingRefetches.delete(cacheKey);
|
|
627
|
+
clearTimeout(timeoutId);
|
|
628
|
+
});
|
|
629
|
+
pendingRefetches.set(cacheKey, refetchPromise);
|
|
630
|
+
const timeoutId = setTimeout(() => {
|
|
631
|
+
if (pendingRefetches.get(cacheKey) === refetchPromise) pendingRefetches.delete(cacheKey);
|
|
632
|
+
}, DEDUP_TIMEOUT_MS);
|
|
633
|
+
getRequestExecutionContext()?.waitUntil(refetchPromise);
|
|
634
|
+
}
|
|
635
|
+
return buildCachedFetchResponse(staleData, input);
|
|
636
|
+
}
|
|
637
|
+
} catch (cacheErr) {
|
|
638
|
+
console.error("[vinext] fetch cache read error:", cacheErr);
|
|
639
|
+
}
|
|
640
|
+
const response = await dedupeFetch(input, fetchInit);
|
|
641
|
+
if (response.status === 200) {
|
|
642
|
+
const cloned = response.clone();
|
|
643
|
+
const body = await cloned.text();
|
|
644
|
+
const headers = {};
|
|
645
|
+
cloned.headers.forEach((v, k) => {
|
|
646
|
+
if (k.toLowerCase() === "set-cookie") return;
|
|
647
|
+
headers[k] = v;
|
|
648
|
+
});
|
|
649
|
+
const cacheValue = {
|
|
650
|
+
kind: "FETCH",
|
|
651
|
+
data: {
|
|
652
|
+
headers,
|
|
653
|
+
body,
|
|
654
|
+
url: response.url,
|
|
655
|
+
status: cloned.status
|
|
656
|
+
},
|
|
657
|
+
tags,
|
|
658
|
+
revalidate: revalidateSeconds
|
|
659
|
+
};
|
|
660
|
+
handler.set(cacheKey, cacheValue, {
|
|
661
|
+
fetchCache: true,
|
|
662
|
+
tags,
|
|
663
|
+
revalidate: revalidateSeconds
|
|
664
|
+
}).catch((err) => {
|
|
665
|
+
console.error("[vinext] fetch cache write error:", err);
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
return response;
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Strip the `next` property from RequestInit before passing to real fetch.
|
|
673
|
+
* The `next` property is not a standard fetch option and would cause warnings
|
|
674
|
+
* in some environments.
|
|
675
|
+
*/
|
|
676
|
+
function stripNextFromInit(init, cacheOverride) {
|
|
677
|
+
if (!init) return cacheOverride === void 0 ? void 0 : { cache: cacheOverride };
|
|
678
|
+
const { next: _next, _ogBody, ...rest } = init;
|
|
679
|
+
if (cacheOverride !== void 0) rest.cache = cacheOverride;
|
|
680
|
+
if (_ogBody !== void 0) rest.body = _ogBody;
|
|
681
|
+
return Object.keys(rest).length > 0 ? rest : void 0;
|
|
682
|
+
}
|
|
683
|
+
const _PATCH_KEY = Symbol.for("vinext.fetchCache.patchInstalled");
|
|
684
|
+
function _ensurePatchInstalled() {
|
|
685
|
+
if (_g[_PATCH_KEY]) return;
|
|
686
|
+
_g[_PATCH_KEY] = true;
|
|
687
|
+
globalThis.fetch = createPatchedFetch();
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Install the patched fetch and reset per-request tag state.
|
|
691
|
+
* Returns a cleanup function that clears tags.
|
|
692
|
+
*
|
|
693
|
+
* @deprecated Prefer `runWithFetchCache()` which uses `AsyncLocalStorage.run()`
|
|
694
|
+
* for proper per-request isolation in concurrent environments.
|
|
695
|
+
*
|
|
696
|
+
* Usage:
|
|
697
|
+
* const cleanup = withFetchCache();
|
|
698
|
+
* try { await render(); } finally { cleanup(); }
|
|
699
|
+
*/
|
|
700
|
+
function withFetchCache() {
|
|
701
|
+
_ensurePatchInstalled();
|
|
702
|
+
_resetFallbackState(true);
|
|
703
|
+
return () => {
|
|
704
|
+
_resetFallbackState(false);
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Run an async function with patched fetch caching enabled.
|
|
709
|
+
* Uses `AsyncLocalStorage.run()` for proper per-request isolation
|
|
710
|
+
* of collected fetch tags in concurrent server environments.
|
|
711
|
+
*/
|
|
712
|
+
async function runWithFetchCache(fn) {
|
|
713
|
+
_ensurePatchInstalled();
|
|
714
|
+
if (isInsideUnifiedScope()) return await runWithUnifiedStateMutation((uCtx) => {
|
|
715
|
+
uCtx.cacheableFetchUrls = /* @__PURE__ */ new Set();
|
|
716
|
+
uCtx.currentRequestTags = [];
|
|
717
|
+
uCtx.currentFetchSoftTags = [];
|
|
718
|
+
uCtx.dynamicFetchUrls = /* @__PURE__ */ new Set();
|
|
719
|
+
uCtx.isFetchDedupeActive = true;
|
|
720
|
+
uCtx.currentFetchDedupeEntries = /* @__PURE__ */ new Map();
|
|
721
|
+
}, fn);
|
|
722
|
+
return _als.run({
|
|
723
|
+
cacheableFetchUrls: /* @__PURE__ */ new Set(),
|
|
724
|
+
currentRequestTags: [],
|
|
725
|
+
currentFetchSoftTags: [],
|
|
726
|
+
currentFetchCacheMode: null,
|
|
727
|
+
currentForceDynamicFetchDefault: false,
|
|
728
|
+
dynamicFetchUrls: /* @__PURE__ */ new Set(),
|
|
729
|
+
isFetchDedupeActive: true,
|
|
730
|
+
currentFetchDedupeEntries: /* @__PURE__ */ new Map()
|
|
731
|
+
}, fn);
|
|
732
|
+
}
|
|
733
|
+
function runWithFetchDedupe(fn) {
|
|
734
|
+
_ensurePatchInstalled();
|
|
735
|
+
const state = _getState();
|
|
736
|
+
if (state.isFetchDedupeActive) return fn();
|
|
737
|
+
if (isInsideUnifiedScope()) return runWithUnifiedStateMutation((uCtx) => {
|
|
738
|
+
uCtx.isFetchDedupeActive = true;
|
|
739
|
+
uCtx.currentFetchDedupeEntries = /* @__PURE__ */ new Map();
|
|
740
|
+
}, fn);
|
|
741
|
+
return _als.run({
|
|
742
|
+
...state,
|
|
743
|
+
isFetchDedupeActive: true,
|
|
744
|
+
currentFetchDedupeEntries: /* @__PURE__ */ new Map()
|
|
745
|
+
}, fn);
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Install the patched fetch without creating a standalone ALS scope.
|
|
749
|
+
*
|
|
750
|
+
* `runWithFetchCache()` is the standalone helper: it installs the patch and
|
|
751
|
+
* creates an isolated per-request tag store. The unified request context owns
|
|
752
|
+
* that isolation itself via `currentRequestTags`, so callers inside
|
|
753
|
+
* `runWithRequestContext()` only need the process-global fetch monkey-patch.
|
|
754
|
+
*/
|
|
755
|
+
function ensureFetchPatch() {
|
|
756
|
+
_ensurePatchInstalled();
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Get the original (unpatched) fetch function.
|
|
760
|
+
* Useful for internal code that should bypass caching.
|
|
761
|
+
*/
|
|
762
|
+
function getOriginalFetch() {
|
|
763
|
+
return originalFetch;
|
|
764
|
+
}
|
|
765
|
+
//#endregion
|
|
766
|
+
export { _resetPendingRefetches, addCollectedRequestTags, consumeDynamicFetchObservations, ensureFetchPatch, getCollectedFetchTags, getCurrentFetchSoftTags, getOriginalFetch, peekCacheableFetchObservations, peekDynamicFetchObservations, runWithFetchCache, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchSoftTags, setCurrentForceDynamicFetchDefault, withFetchCache };
|