vinext 1.0.0-beta.4 → 1.0.0-beta.6
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/README.md +44 -3
- package/dist/build/client-build-config.d.ts +0 -1
- package/dist/build/css-url-assets.d.ts +0 -1
- package/dist/build/google-fonts/build-url.d.ts +5 -2
- package/dist/build/google-fonts/font-metadata.d.ts +7 -3
- package/dist/build/google-fonts/get-axes.d.ts +0 -1
- package/dist/build/layout-classification.d.ts +7 -4
- package/dist/build/next-client-runtime-manifests.d.ts +0 -1
- package/dist/build/next-client-runtime-manifests.js +2 -19
- package/dist/build/nitro-route-rules.d.ts +0 -1
- package/dist/build/pages-client-assets-module.d.ts +0 -1
- package/dist/build/precompress.d.ts +7 -2
- package/dist/build/precompress.js +41 -7
- package/dist/build/prerender-paths.d.ts +2 -2
- package/dist/build/prerender-paths.js +3 -4
- package/dist/build/prerender-phase.d.ts +15 -0
- package/dist/build/prerender-phase.js +37 -0
- package/dist/build/prerender-server-entry.d.ts +1 -1
- package/dist/build/prerender-server-entry.js +3 -3
- package/dist/build/prerender-server-pool.d.ts +4 -2
- package/dist/build/prerender-server-pool.js +2 -0
- package/dist/build/prerender.d.ts +40 -33
- package/dist/build/prerender.js +99 -18
- package/dist/build/public-dir-conflict.d.ts +14 -0
- package/dist/build/public-dir-conflict.js +25 -0
- package/dist/build/report.d.ts +2 -2
- package/dist/build/route-classification-injector.d.ts +0 -1
- package/dist/build/route-classification-manifest.d.ts +5 -3
- package/dist/build/run-prerender.d.ts +3 -2
- package/dist/build/run-prerender.js +9 -6
- package/dist/build/static-export.d.ts +23 -12
- package/dist/cache/cache-adapters-virtual.d.ts +5 -2
- package/dist/check.js +4 -4
- package/dist/cli-dev-config.d.ts +0 -1
- package/dist/cli.d.ts +1 -1
- package/dist/client/client-rewrite-matcher.d.ts +12 -0
- package/dist/client/client-rewrite-matcher.js +20 -0
- package/dist/client/client-rewrites.d.ts +31 -0
- package/dist/client/client-rewrites.js +41 -0
- package/dist/client/dev-error-overlay.d.ts +0 -1
- package/dist/client/empty-module.d.ts +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +2 -0
- package/dist/client/instrumentation-client-state.d.ts +0 -1
- package/dist/client/navigation-runtime.d.ts +6 -1
- package/dist/client/navigation-runtime.js +5 -1
- package/dist/client/pages-router-link-navigation.d.ts +3 -21
- package/dist/client/react-instance-bootstrap.d.ts +1 -0
- package/dist/client/react-instance-bootstrap.js +7 -0
- package/dist/client/react-instance.d.ts +13 -0
- package/dist/client/react-instance.js +20 -0
- package/dist/client/vinext-next-data.d.ts +13 -6
- package/dist/client/window-next.d.ts +5 -2
- package/dist/config/config-matchers.d.ts +3 -5
- package/dist/config/config-matchers.js +7 -6
- package/dist/config/dotenv.d.ts +1 -5
- package/dist/config/next-config.d.ts +113 -54
- package/dist/config/next-config.js +27 -7
- package/dist/config/prerender.d.ts +0 -1
- package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +808 -0
- package/dist/entries/app-browser-entry.d.ts +0 -1
- package/dist/entries/app-browser-entry.js +8 -3
- package/dist/entries/app-rsc-entry.d.ts +30 -16
- package/dist/entries/app-rsc-entry.js +48 -10
- package/dist/entries/app-rsc-manifest.d.ts +0 -1
- package/dist/entries/app-rsc-manifest.js +1 -0
- package/dist/entries/pages-client-entry.d.ts +0 -1
- package/dist/entries/pages-client-entry.js +15 -5
- package/dist/entries/pages-server-entry.d.ts +1 -2
- package/dist/entries/pages-server-entry.js +21 -5
- package/dist/image/image-adapters-virtual.d.ts +4 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +328 -227
- package/dist/init-cloudflare.d.ts +0 -1
- package/dist/init-platform.d.ts +0 -1
- package/dist/init.d.ts +40 -20
- package/dist/plugins/ast-scope.d.ts +0 -1
- package/dist/plugins/async-hooks-stub.d.ts +0 -1
- package/dist/plugins/client-reference-dedup.d.ts +0 -1
- package/dist/plugins/css-data-url.d.ts +0 -1
- package/dist/plugins/css-module-imports.d.ts +0 -1
- package/dist/plugins/dynamic-preload-metadata.d.ts +0 -1
- package/dist/plugins/extensionless-dynamic-import.d.ts +0 -1
- package/dist/plugins/extensionless-dynamic-import.js +352 -13
- package/dist/plugins/fonts.d.ts +0 -1
- package/dist/plugins/ignore-dynamic-requests.d.ts +0 -1
- package/dist/plugins/ignore-dynamic-requests.js +28 -4
- package/dist/plugins/import-meta-url.d.ts +0 -1
- package/dist/plugins/instrumentation-client.d.ts +0 -1
- package/dist/plugins/middleware-server-only.d.ts +0 -1
- package/dist/plugins/og-asset-ownership.d.ts +0 -1
- package/dist/plugins/og-assets.d.ts +0 -1
- package/dist/plugins/optimize-imports.d.ts +0 -1
- package/dist/plugins/pages-node-externals.d.ts +23 -0
- package/dist/plugins/pages-node-externals.js +206 -0
- package/dist/plugins/remove-console.d.ts +0 -1
- package/dist/plugins/require-context.d.ts +0 -1
- package/dist/plugins/require-context.js +143 -26
- package/dist/plugins/rsc-client-reference-loaders.d.ts +0 -1
- package/dist/plugins/rsc-reference-validation-normalizer.d.ts +0 -1
- package/dist/plugins/sass.d.ts +30 -2
- package/dist/plugins/sass.js +64 -1
- package/dist/plugins/server-externals-manifest.d.ts +0 -1
- package/dist/plugins/strip-server-exports.d.ts +0 -1
- package/dist/plugins/styled-jsx.d.ts +0 -1
- package/dist/plugins/transitive-externals.d.ts +24 -0
- package/dist/plugins/transitive-externals.js +121 -0
- package/dist/plugins/typeof-window.d.ts +11 -1
- package/dist/plugins/typeof-window.js +141 -13
- package/dist/plugins/use-cache-callable.d.ts +12 -0
- package/dist/plugins/use-cache-callable.js +209 -0
- package/dist/plugins/wasm-module-import.d.ts +0 -1
- package/dist/routing/app-route-graph.d.ts +115 -56
- package/dist/routing/app-route-graph.js +2 -1
- package/dist/routing/app-router.d.ts +0 -1
- package/dist/routing/pages-router.d.ts +9 -5
- package/dist/routing/route-matching.d.ts +0 -1
- package/dist/routing/utils.d.ts +1 -23
- package/dist/routing/utils.js +1 -30
- package/dist/server/accept-encoding.d.ts +0 -1
- package/dist/server/api-handler.d.ts +0 -1
- package/dist/server/api-handler.js +1 -1
- package/dist/server/app-bfcache-identity.d.ts +9 -10
- package/dist/server/app-bfcache-identity.js +27 -128
- package/dist/server/app-browser-action-result.d.ts +0 -1
- package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -1
- package/dist/server/app-browser-entry.d.ts +1 -1
- package/dist/server/app-browser-entry.js +46 -30
- package/dist/server/app-browser-history-controller.d.ts +8 -5
- package/dist/server/app-browser-hydration.d.ts +0 -1
- package/dist/server/app-browser-interception-context.d.ts +0 -1
- package/dist/server/app-browser-mpa-navigation.d.ts +0 -1
- package/dist/server/app-browser-navigation-controller.d.ts +2 -5
- package/dist/server/app-browser-popstate.d.ts +0 -1
- package/dist/server/app-browser-prefetch-response.d.ts +17 -1
- package/dist/server/app-browser-prefetch-response.js +23 -1
- package/dist/server/app-browser-server-action-client.d.ts +1 -1
- package/dist/server/app-browser-server-action-client.js +3 -2
- package/dist/server/app-browser-server-action-navigation.d.ts +0 -1
- package/dist/server/app-browser-state.d.ts +4 -3
- package/dist/server/app-browser-state.js +2 -4
- package/dist/server/app-browser-stream.d.ts +0 -1
- package/dist/server/app-browser-visible-commit.d.ts +1 -1
- package/dist/server/app-browser-visible-commit.js +6 -2
- package/dist/server/app-elements-wire.d.ts +16 -13
- package/dist/server/app-elements-wire.js +37 -10
- package/dist/server/app-elements.d.ts +2 -3
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-fallback-renderer.d.ts +8 -4
- package/dist/server/app-fallback-renderer.js +2 -1
- package/dist/server/app-history-state.d.ts +2 -2
- package/dist/server/app-history-state.js +1 -1
- package/dist/server/app-hook-warning-suppression.d.ts +0 -1
- package/dist/server/app-layout-param-observation.d.ts +0 -1
- package/dist/server/app-layout-param-observation.js +1 -1
- package/dist/server/app-middleware.d.ts +5 -1
- package/dist/server/app-middleware.js +96 -31
- package/dist/server/app-optimistic-routing.d.ts +1 -0
- package/dist/server/app-page-boundary-render.d.ts +8 -4
- package/dist/server/app-page-boundary-render.js +4 -7
- package/dist/server/app-page-cache-finalizer.d.ts +3 -3
- package/dist/server/app-page-cache-finalizer.js +45 -19
- package/dist/server/app-page-cache-render.d.ts +3 -2
- package/dist/server/app-page-cache-render.js +5 -2
- package/dist/server/app-page-cache.d.ts +3 -4
- package/dist/server/app-page-cache.js +33 -15
- package/dist/server/app-page-dispatch.d.ts +11 -5
- package/dist/server/app-page-dispatch.js +11 -6
- package/dist/server/app-page-element-builder.d.ts +61 -19
- package/dist/server/app-page-element-builder.js +113 -43
- package/dist/server/app-page-execution.d.ts +12 -5
- package/dist/server/app-page-execution.js +20 -7
- package/dist/server/app-page-head.d.ts +2 -2
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +2 -2
- package/dist/server/app-page-params.d.ts +0 -1
- package/dist/server/app-page-ppr-runtime.d.ts +0 -1
- package/dist/server/app-page-probe.d.ts +4 -3
- package/dist/server/app-page-probe.js +1 -1
- package/dist/server/app-page-render-identity.d.ts +1 -0
- package/dist/server/app-page-render-observation.d.ts +0 -1
- package/dist/server/app-page-render.d.ts +6 -4
- package/dist/server/app-page-render.js +53 -25
- package/dist/server/app-page-request.d.ts +3 -1
- package/dist/server/app-page-request.js +3 -34
- package/dist/server/app-page-response.d.ts +13 -3
- package/dist/server/app-page-response.js +17 -11
- package/dist/server/app-page-route-wiring.d.ts +27 -5
- package/dist/server/app-page-route-wiring.js +110 -58
- package/dist/server/app-page-search-params-observation.d.ts +0 -1
- package/dist/server/app-page-segment-plan.d.ts +56 -0
- package/dist/server/app-page-segment-plan.js +177 -0
- package/dist/server/app-page-segment-state.d.ts +18 -2
- package/dist/server/app-page-segment-state.js +23 -4
- package/dist/server/app-page-stream.d.ts +31 -10
- package/dist/server/app-page-stream.js +10 -3
- package/dist/server/app-pages-bridge.d.ts +0 -1
- package/dist/server/app-pages-bridge.js +12 -1
- package/dist/server/app-post-middleware-context.d.ts +0 -1
- package/dist/server/app-ppr-fallback-shell-render.d.ts +0 -1
- package/dist/server/app-prerender-endpoints.d.ts +1 -1
- package/dist/server/app-prerender-endpoints.js +12 -0
- package/dist/server/app-prerender-static-params.d.ts +0 -1
- package/dist/server/app-render-dependency.d.ts +11 -4
- package/dist/server/app-render-dependency.js +59 -9
- package/dist/server/app-request-context.d.ts +1 -0
- package/dist/server/app-response-header-provenance.d.ts +13 -0
- package/dist/server/app-response-header-provenance.js +26 -0
- package/dist/server/app-route-handler-cache.d.ts +3 -2
- package/dist/server/app-route-handler-cache.js +7 -3
- package/dist/server/app-route-handler-dispatch.d.ts +0 -1
- package/dist/server/app-route-handler-dispatch.js +4 -2
- package/dist/server/app-route-handler-execution.d.ts +2 -2
- package/dist/server/app-route-handler-execution.js +15 -7
- package/dist/server/app-route-handler-policy.d.ts +1 -1
- package/dist/server/app-route-handler-response.d.ts +3 -2
- package/dist/server/app-route-handler-response.js +15 -5
- package/dist/server/app-route-handler-runtime.d.ts +1 -2
- package/dist/server/app-route-handler-runtime.js +218 -85
- package/dist/server/app-route-module-loader.d.ts +32 -6
- package/dist/server/app-route-module-loader.js +73 -3
- package/dist/server/app-route-request-built-ins.d.ts +16 -0
- package/dist/server/app-route-request-built-ins.js +41 -0
- package/dist/server/app-router-entry.d.ts +0 -1
- package/dist/server/app-router-entry.js +4 -4
- package/dist/server/app-rsc-cache-busting.d.ts +2 -1
- package/dist/server/app-rsc-cache-busting.js +24 -16
- package/dist/server/app-rsc-handler.d.ts +9 -2
- package/dist/server/app-rsc-handler.js +176 -47
- package/dist/server/app-rsc-redirect-flight.d.ts +0 -1
- package/dist/server/app-rsc-request-normalization.d.ts +19 -10
- package/dist/server/app-rsc-response-finalizer.d.ts +7 -2
- package/dist/server/app-rsc-response-finalizer.js +34 -18
- package/dist/server/app-rsc-route-matching.d.ts +6 -1
- package/dist/server/app-rsc-route-matching.js +47 -2
- package/dist/server/app-rsc-state-fingerprint.d.ts +14 -0
- package/dist/server/app-rsc-state-fingerprint.js +13 -0
- package/dist/server/app-segment-config.d.ts +0 -1
- package/dist/server/app-server-action-execution.d.ts +41 -8
- package/dist/server/app-server-action-execution.js +191 -113
- package/dist/server/app-ssr-entry.d.ts +11 -3
- package/dist/server/app-ssr-entry.js +19 -8
- package/dist/server/app-ssr-router-instance.d.ts +0 -1
- package/dist/server/app-ssr-stream.d.ts +13 -2
- package/dist/server/app-ssr-stream.js +30 -5
- package/dist/server/app-static-generation.d.ts +0 -1
- package/dist/server/app-visited-response-cache.d.ts +1 -1
- package/dist/server/before-interactive-head.d.ts +0 -1
- package/dist/server/before-interactive-head.js +2 -0
- package/dist/server/bfcache-identity.d.ts +45 -0
- package/dist/server/bfcache-identity.js +52 -0
- package/dist/server/cache-control.d.ts +11 -7
- package/dist/server/cache-control.js +23 -11
- package/dist/server/cache-proof.d.ts +0 -1
- package/dist/server/client-reuse-manifest.d.ts +0 -1
- package/dist/server/config-headers.d.ts +6 -2
- package/dist/server/config-headers.js +19 -3
- package/dist/server/csp.d.ts +0 -1
- package/dist/server/default-global-error-module.d.ts +0 -1
- package/dist/server/default-global-not-found-module.d.ts +0 -1
- package/dist/server/default-not-found-module.d.ts +0 -1
- package/dist/server/dev-lockfile.d.ts +21 -9
- package/dist/server/dev-module-runner.d.ts +0 -1
- package/dist/server/dev-route-files.d.ts +0 -1
- package/dist/server/dev-server.d.ts +4 -8
- package/dist/server/dev-server.js +54 -105
- package/dist/server/dev-stack-sourcemap.d.ts +0 -1
- package/dist/server/document-initial-head.d.ts +12 -2
- package/dist/server/document-initial-head.js +17 -2
- package/dist/server/file-based-metadata.d.ts +0 -1
- package/dist/server/headers.d.ts +21 -2
- package/dist/server/headers.js +23 -2
- package/dist/server/http-conditional.d.ts +22 -0
- package/dist/server/http-conditional.js +117 -0
- package/dist/server/http-date.d.ts +5 -0
- package/dist/server/http-date.js +73 -0
- package/dist/server/http-error-responses.d.ts +3 -2
- package/dist/server/http-error-responses.js +21 -4
- package/dist/server/http-range.d.ts +25 -0
- package/dist/server/http-range.js +67 -0
- package/dist/server/image-optimization.d.ts +14 -6
- package/dist/server/image-optimization.js +0 -1
- package/dist/server/instrumentation.d.ts +7 -4
- package/dist/server/isr-cache.d.ts +28 -6
- package/dist/server/isr-cache.js +19 -13
- package/dist/server/isr-decision.d.ts +6 -4
- package/dist/server/metadata-route-build-data.d.ts +0 -1
- package/dist/server/metadata-route-build-data.js +1 -1
- package/dist/server/metadata-route-cache-policy.d.ts +6 -0
- package/dist/server/metadata-route-cache-policy.js +6 -0
- package/dist/server/metadata-route-response.d.ts +26 -2
- package/dist/server/metadata-route-response.js +225 -11
- package/dist/server/metadata-routes.d.ts +34 -16
- package/dist/server/metadata-routes.js +1 -1
- package/dist/server/middleware-matcher-pattern.d.ts +0 -1
- package/dist/server/middleware-matcher.d.ts +8 -3
- package/dist/server/middleware-matcher.js +23 -18
- package/dist/server/middleware-response-headers.js +4 -2
- package/dist/server/middleware-runtime.d.ts +6 -1
- package/dist/server/middleware-runtime.js +91 -28
- package/dist/server/middleware.d.ts +0 -1
- package/dist/server/navigation-planner.d.ts +1 -1
- package/dist/server/next-error-digest.d.ts +0 -1
- package/dist/server/pages-api-route.d.ts +0 -1
- package/dist/server/pages-api-route.js +30 -5
- package/dist/server/pages-asset-tags.d.ts +2 -1
- package/dist/server/pages-data-route.d.ts +14 -6
- package/dist/server/pages-data-route.js +19 -10
- package/dist/server/pages-dev-hydration.js +14 -4
- package/dist/server/pages-dev-stylesheets.d.ts +10 -0
- package/dist/server/pages-dev-stylesheets.js +150 -0
- package/dist/server/pages-document-initial-props.d.ts +10 -6
- package/dist/server/pages-get-initial-props.d.ts +2 -2
- package/dist/server/pages-i18n.d.ts +1 -7
- package/dist/server/pages-node-compat.d.ts +11 -2
- package/dist/server/pages-node-compat.js +49 -2
- package/dist/server/pages-page-data.d.ts +21 -9
- package/dist/server/pages-page-data.js +109 -30
- package/dist/server/pages-page-handler.d.ts +72 -33
- package/dist/server/pages-page-handler.js +25 -20
- package/dist/server/pages-page-response.d.ts +7 -13
- package/dist/server/pages-page-response.js +16 -23
- package/dist/server/pages-readiness.d.ts +0 -1
- package/dist/server/pages-request-pipeline.d.ts +20 -6
- package/dist/server/pages-request-pipeline.js +40 -20
- package/dist/server/pages-revalidate.d.ts +0 -1
- package/dist/server/pages-revalidate.js +1 -1
- package/dist/server/pages-router-entry.js +13 -9
- package/dist/server/prerender-cache-life-header.d.ts +11 -0
- package/dist/server/prerender-cache-life-header.js +18 -0
- package/dist/server/prerender-manifest.d.ts +11 -2
- package/dist/server/prerender-manifest.js +4 -1
- package/dist/server/prod-server.d.ts +13 -7
- package/dist/server/prod-server.js +280 -92
- package/dist/server/proxy-trust.d.ts +0 -1
- package/dist/server/request-log.d.ts +7 -11
- package/dist/server/request-pipeline.d.ts +13 -4
- package/dist/server/request-pipeline.js +30 -20
- package/dist/server/revalidation-host.d.ts +0 -1
- package/dist/server/revalidation-host.js +1 -1
- package/dist/server/rsc-completion-metadata.d.ts +15 -0
- package/dist/server/rsc-completion-metadata.js +183 -0
- package/dist/server/seed-cache.d.ts +6 -2
- package/dist/server/seed-cache.js +35 -8
- package/dist/server/skip-cache-proof.d.ts +0 -1
- package/dist/server/static-file-cache.d.ts +23 -9
- package/dist/server/static-file-cache.js +47 -23
- package/dist/server/static-layout-client-reuse-proof.d.ts +0 -1
- package/dist/server/worker-revalidation-context.d.ts +0 -1
- package/dist/server/worker-utils.d.ts +3 -1
- package/dist/server/worker-utils.js +12 -3
- package/dist/shims/app-router-scroll.d.ts +2 -8
- package/dist/shims/app.d.ts +1 -5
- package/dist/shims/before-interactive-context.d.ts +5 -3
- package/dist/shims/cache-callable-runtime.d.ts +11 -0
- package/dist/shims/cache-callable-runtime.js +30 -0
- package/dist/shims/cache-handler.d.ts +6 -1
- package/dist/shims/cache-handler.js +4 -2
- package/dist/shims/cache-request-state.d.ts +15 -1
- package/dist/shims/cache-request-state.js +27 -1
- package/dist/shims/cache-runtime.d.ts +15 -6
- package/dist/shims/cache-runtime.js +129 -29
- package/dist/shims/cache.d.ts +2 -3
- package/dist/shims/cache.js +2 -2
- package/dist/shims/cdn-cache.d.ts +18 -7
- package/dist/shims/cdn-cache.js +4 -2
- package/dist/shims/client-locale.d.ts +1 -6
- package/dist/shims/client-only.d.ts +1 -1
- package/dist/shims/compat-router.d.ts +0 -1
- package/dist/shims/constants.d.ts +1 -1
- package/dist/shims/default-global-error.d.ts +1 -4
- package/dist/shims/default-not-found.d.ts +0 -1
- package/dist/shims/document.d.ts +0 -1
- package/dist/shims/document.js +2 -1
- package/dist/shims/dynamic-preload-chunks.d.ts +0 -1
- package/dist/shims/dynamic.d.ts +0 -1
- package/dist/shims/error-boundary-navigation.d.ts +0 -1
- package/dist/shims/error-boundary.d.ts +7 -32
- package/dist/shims/error.d.ts +1 -6
- package/dist/shims/fetch-cache.js +115 -65
- package/dist/shims/font-google-base.d.ts +0 -1
- package/dist/shims/font-local.d.ts +0 -1
- package/dist/shims/font-local.js +3 -3
- package/dist/shims/form.d.ts +5 -3
- package/dist/shims/head-state.d.ts +0 -1
- package/dist/shims/head.d.ts +17 -5
- package/dist/shims/head.js +70 -8
- package/dist/shims/headers.d.ts +2 -2
- package/dist/shims/headers.js +1 -1
- package/dist/shims/i18n-context.d.ts +0 -1
- package/dist/shims/i18n-state.d.ts +0 -1
- package/dist/shims/image.d.ts +0 -1
- package/dist/shims/image.js +1 -2
- package/dist/shims/internal/als-registry.d.ts +31 -2
- package/dist/shims/internal/als-registry.js +50 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +17 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.js +69 -7
- package/dist/shims/internal/app-route-detection.d.ts +0 -1
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +33 -0
- package/dist/shims/internal/app-route-prefetch-policy.js +63 -0
- package/dist/shims/internal/app-router-context.d.ts +0 -1
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +1 -5
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +0 -1
- package/dist/shims/internal/hybrid-client-route-owner.js +6 -8
- package/dist/shims/internal/interpolate-as.d.ts +3 -2
- package/dist/shims/internal/pages-data-target.d.ts +22 -11
- package/dist/shims/internal/pages-data-target.js +19 -6
- package/dist/shims/internal/pages-data-url.d.ts +3 -1
- package/dist/shims/internal/router-context.d.ts +0 -1
- package/dist/shims/internal/work-unit-async-storage.d.ts +4 -3
- package/dist/shims/internal/work-unit-async-storage.js +2 -0
- package/dist/shims/layout-segment-context.d.ts +2 -6
- package/dist/shims/legacy-image.d.ts +0 -1
- package/dist/shims/link.d.ts +29 -23
- package/dist/shims/link.js +59 -150
- package/dist/shims/metadata.d.ts +2 -10
- package/dist/shims/navigation-context-state.d.ts +4 -1
- package/dist/shims/navigation-state.d.ts +1 -0
- package/dist/shims/navigation.d.ts +65 -6
- package/dist/shims/navigation.js +360 -71
- package/dist/shims/navigation.react-server.d.ts +1 -0
- package/dist/shims/og.d.ts +0 -1
- package/dist/shims/request-context.d.ts +8 -4
- package/dist/shims/request-state-types.d.ts +1 -0
- package/dist/shims/root-params.d.ts +3 -1
- package/dist/shims/root-params.js +7 -1
- package/dist/shims/router.d.ts +44 -23
- package/dist/shims/router.js +184 -82
- package/dist/shims/script-nonce-context.d.ts +0 -1
- package/dist/shims/script.d.ts +25 -13
- package/dist/shims/server-only.d.ts +1 -1
- package/dist/shims/server.d.ts +1 -3
- package/dist/shims/server.js +7 -7
- package/dist/shims/slot.d.ts +22 -11
- package/dist/shims/slot.js +99 -19
- package/dist/shims/streamed-icons.d.ts +1 -3
- package/dist/shims/unified-request-context.d.ts +44 -4
- package/dist/shims/unified-request-context.js +56 -2
- package/dist/shims/use-merged-ref.d.ts +0 -1
- package/dist/shims/web-vitals.d.ts +0 -1
- package/dist/typegen.d.ts +1 -2
- package/dist/typegen.js +1 -1
- package/dist/utils/cache-control-metadata.d.ts +13 -1
- package/dist/utils/cache-control-metadata.js +17 -1
- package/dist/utils/client-build-manifest.d.ts +0 -1
- package/dist/utils/domain-locale.d.ts +1 -5
- package/dist/utils/encode-cache-tag.d.ts +1 -1
- package/dist/utils/encode-cache-tag.js +1 -1
- package/dist/utils/html-limited-bots.js +1 -1
- package/dist/utils/middleware-request-headers.d.ts +17 -5
- package/dist/utils/middleware-request-headers.js +32 -23
- package/dist/utils/precompressed-variant.d.ts +9 -0
- package/dist/utils/precompressed-variant.js +15 -0
- package/dist/utils/prerender-output-paths.d.ts +3 -1
- package/dist/utils/prerender-output-paths.js +6 -1
- package/dist/utils/project.d.ts +12 -7
- package/dist/utils/public-file-path.d.ts +5 -0
- package/dist/utils/public-file-path.js +12 -0
- package/dist/utils/public-routes.d.ts +1 -1
- package/dist/utils/public-routes.js +6 -5
- package/package.json +10 -6
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { ASSET_PREFIX_URL_DIR } from "../utils/asset-prefix.js";
|
|
3
|
+
import { isPrecompressedVariantBeneficial } from "../utils/precompressed-variant.js";
|
|
3
4
|
import fsp from "node:fs/promises";
|
|
4
5
|
//#region src/server/static-file-cache.ts
|
|
5
6
|
/**
|
|
@@ -17,27 +18,43 @@ import fsp from "node:fs/promises";
|
|
|
17
18
|
*/
|
|
18
19
|
/** Content-type lookup for static assets. Shared with prod-server.ts. */
|
|
19
20
|
const CONTENT_TYPES = {
|
|
20
|
-
".
|
|
21
|
-
".
|
|
22
|
-
".
|
|
21
|
+
".avif": "image/avif",
|
|
22
|
+
".bmp": "image/bmp",
|
|
23
|
+
".csv": "text/csv; charset=utf-8",
|
|
24
|
+
".eot": "application/vnd.ms-fontobject",
|
|
25
|
+
".gif": "image/gif",
|
|
26
|
+
".heic": "image/heic",
|
|
27
|
+
".js": "application/javascript; charset=utf-8",
|
|
28
|
+
".mjs": "application/javascript; charset=utf-8",
|
|
29
|
+
".css": "text/css; charset=utf-8",
|
|
23
30
|
".html": "text/html; charset=utf-8",
|
|
24
|
-
".
|
|
25
|
-
".txt": "text/plain; charset=utf-8",
|
|
26
|
-
".png": "image/png",
|
|
27
|
-
".jpg": "image/jpeg",
|
|
31
|
+
".ico": "image/x-icon",
|
|
28
32
|
".jpeg": "image/jpeg",
|
|
29
|
-
".
|
|
33
|
+
".jpg": "image/jpeg",
|
|
34
|
+
".json": "application/json; charset=utf-8",
|
|
35
|
+
".map": "application/json; charset=utf-8",
|
|
36
|
+
".mp3": "audio/mpeg",
|
|
37
|
+
".mp4": "video/mp4",
|
|
38
|
+
".ogg": "audio/ogg",
|
|
39
|
+
".ogv": "video/ogg",
|
|
40
|
+
".pdf": "application/pdf",
|
|
41
|
+
".png": "image/png",
|
|
42
|
+
".rsc": "text/x-component",
|
|
30
43
|
".svg": "image/svg+xml",
|
|
31
|
-
".ico": "image/x-icon",
|
|
32
|
-
".woff": "font/woff",
|
|
33
|
-
".woff2": "font/woff2",
|
|
34
44
|
".ttf": "font/ttf",
|
|
35
|
-
".
|
|
45
|
+
".txt": "text/plain; charset=utf-8",
|
|
46
|
+
".wasm": "application/wasm",
|
|
47
|
+
".webm": "video/webm",
|
|
48
|
+
".webmanifest": "application/manifest+json",
|
|
36
49
|
".webp": "image/webp",
|
|
37
|
-
".
|
|
38
|
-
".
|
|
39
|
-
".
|
|
50
|
+
".woff": "font/woff",
|
|
51
|
+
".woff2": "font/woff2",
|
|
52
|
+
".xml": "application/xml"
|
|
40
53
|
};
|
|
54
|
+
/** Resolve a path's MIME type with case-insensitive extension matching. */
|
|
55
|
+
function contentTypeForPath(filePath) {
|
|
56
|
+
return CONTENT_TYPES[path.extname(filePath).toLowerCase()] ?? "application/octet-stream";
|
|
57
|
+
}
|
|
41
58
|
/**
|
|
42
59
|
* Files below this size are buffered in memory at startup for zero-syscall
|
|
43
60
|
* serving via res.end(buffer). Above this, files stream via createReadStream.
|
|
@@ -45,6 +62,8 @@ const CONTENT_TYPES = {
|
|
|
45
62
|
* to ~50KB with brotli q5).
|
|
46
63
|
*/
|
|
47
64
|
const BUFFER_THRESHOLD = 64 * 1024;
|
|
65
|
+
/** Temp files left by an interrupted atomic precompression write. */
|
|
66
|
+
const PRECOMPRESSION_TEMP_FILE_RE = /\.(?:br|gz|zst)\.\d+\.[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.tmp$/i;
|
|
48
67
|
/**
|
|
49
68
|
* In-memory cache of static file metadata, populated once at server startup.
|
|
50
69
|
*
|
|
@@ -74,15 +93,18 @@ var StaticFileCache = class StaticFileCache {
|
|
|
74
93
|
for (const [relativePath, fileInfo] of allFiles) {
|
|
75
94
|
if (relativePath.endsWith(".br") || relativePath.endsWith(".gz") || relativePath.endsWith(".zst")) continue;
|
|
76
95
|
if (relativePath.startsWith(".vite/") || relativePath === ".vite") continue;
|
|
77
|
-
const ext = path.extname(relativePath);
|
|
78
|
-
const contentType = CONTENT_TYPES[ext] ?? "application/octet-stream";
|
|
79
96
|
const isHashed = relativePath.startsWith(`_next/static/`) || relativePath.includes(`/_next/static/`);
|
|
97
|
+
if (isHashed && PRECOMPRESSION_TEMP_FILE_RE.test(relativePath)) continue;
|
|
98
|
+
const ext = path.extname(relativePath);
|
|
99
|
+
const contentType = contentTypeForPath(relativePath);
|
|
80
100
|
const cacheControl = isHashed ? "public, max-age=31536000, immutable" : "public, max-age=3600";
|
|
81
101
|
const etag = isHashed && etagFromFilenameHash(relativePath, ext) || `W/"${fileInfo.size}-${Math.floor(fileInfo.mtimeMs / 1e3)}"`;
|
|
102
|
+
const lastModified = new Date(fileInfo.mtimeMs).toUTCString();
|
|
82
103
|
const baseHeaders = {
|
|
83
104
|
"Content-Type": contentType,
|
|
84
105
|
"Cache-Control": cacheControl,
|
|
85
|
-
ETag: etag
|
|
106
|
+
ETag: etag,
|
|
107
|
+
"Last-Modified": lastModified
|
|
86
108
|
};
|
|
87
109
|
const original = {
|
|
88
110
|
path: fileInfo.fullPath,
|
|
@@ -94,18 +116,20 @@ var StaticFileCache = class StaticFileCache {
|
|
|
94
116
|
};
|
|
95
117
|
const entry = {
|
|
96
118
|
etag,
|
|
119
|
+
mtimeMs: fileInfo.mtimeMs,
|
|
97
120
|
notModifiedHeaders: {
|
|
98
121
|
ETag: etag,
|
|
99
|
-
"Cache-Control": cacheControl
|
|
122
|
+
"Cache-Control": cacheControl,
|
|
123
|
+
"Last-Modified": lastModified
|
|
100
124
|
},
|
|
101
125
|
original
|
|
102
126
|
};
|
|
103
127
|
const brInfo = allFiles.get(relativePath + ".br");
|
|
104
|
-
if (brInfo) entry.br = buildVariant(brInfo, baseHeaders, "br");
|
|
128
|
+
if (brInfo && isPrecompressedVariantBeneficial(brInfo.size, fileInfo.size, "br")) entry.br = buildVariant(brInfo, baseHeaders, "br");
|
|
105
129
|
const gzInfo = allFiles.get(relativePath + ".gz");
|
|
106
|
-
if (gzInfo) entry.gz = buildVariant(gzInfo, baseHeaders, "gzip");
|
|
130
|
+
if (gzInfo && isPrecompressedVariantBeneficial(gzInfo.size, fileInfo.size, "gzip")) entry.gz = buildVariant(gzInfo, baseHeaders, "gzip");
|
|
107
131
|
const zstInfo = allFiles.get(relativePath + ".zst");
|
|
108
|
-
if (zstInfo) entry.zst = buildVariant(zstInfo, baseHeaders, "zstd");
|
|
132
|
+
if (zstInfo && isPrecompressedVariantBeneficial(zstInfo.size, fileInfo.size, "zstd")) entry.zst = buildVariant(zstInfo, baseHeaders, "zstd");
|
|
109
133
|
if (entry.br || entry.gz || entry.zst) {
|
|
110
134
|
original.headers["Vary"] = "Accept-Encoding";
|
|
111
135
|
entry.notModifiedHeaders["Vary"] = "Accept-Encoding";
|
|
@@ -227,4 +251,4 @@ async function* walkFilesWithStats(dir, base = dir) {
|
|
|
227
251
|
}
|
|
228
252
|
}
|
|
229
253
|
//#endregion
|
|
230
|
-
export { CONTENT_TYPES, StaticFileCache, etagFromFilenameHash };
|
|
254
|
+
export { CONTENT_TYPES, StaticFileCache, contentTypeForPath, etagFromFilenameHash };
|
|
@@ -4,5 +4,7 @@ declare function mergeHeaders(response: Response, extraHeaders: Record<string, s
|
|
|
4
4
|
declare function resolveStaticAssetSignal(signalResponse: Response, options: {
|
|
5
5
|
fetchAsset(path: string): Promise<Response>;
|
|
6
6
|
}): Promise<Response | null>;
|
|
7
|
+
/** Retarget a Worker asset request without dropping its conditional/range fields. */
|
|
8
|
+
declare function createStaticAssetRequest(assetPath: string, sourceRequest: Request): Request;
|
|
7
9
|
//#endregion
|
|
8
|
-
export { finalizeMissingStaticAssetResponse, mergeHeaders, resolveStaticAssetSignal };
|
|
10
|
+
export { createStaticAssetRequest, finalizeMissingStaticAssetResponse, mergeHeaders, resolveStaticAssetSignal };
|
|
@@ -33,7 +33,7 @@ function cancelResponseBody(response) {
|
|
|
33
33
|
function finalizeMissingStaticAssetResponse(response, missingBuildAsset) {
|
|
34
34
|
if (!missingBuildAsset || response.status !== 404) return response;
|
|
35
35
|
cancelResponseBody(response);
|
|
36
|
-
return notFoundStaticAssetResponse();
|
|
36
|
+
return notFoundStaticAssetResponse(response.headers);
|
|
37
37
|
}
|
|
38
38
|
function buildHeaderRecord(response, omitNames = []) {
|
|
39
39
|
const omitted = new Set(omitNames.map((name) => name.toLowerCase()));
|
|
@@ -99,7 +99,16 @@ async function resolveStaticAssetSignal(signalResponse, options) {
|
|
|
99
99
|
]);
|
|
100
100
|
cancelResponseBody(signalResponse);
|
|
101
101
|
const assetResponse = await options.fetchAsset(assetPath);
|
|
102
|
-
return mergeHeaders(assetResponse, extraHeaders, assetResponse.ok && signalResponse.status !== 200 ? signalResponse.status : void 0);
|
|
102
|
+
return mergeHeaders(assetResponse, extraHeaders, assetResponse.ok && assetResponse.status !== 206 && signalResponse.status !== 200 ? signalResponse.status : void 0);
|
|
103
|
+
}
|
|
104
|
+
/** Retarget a Worker asset request without dropping its conditional/range fields. */
|
|
105
|
+
function createStaticAssetRequest(assetPath, sourceRequest) {
|
|
106
|
+
const assetUrl = new URL(assetPath, sourceRequest.url);
|
|
107
|
+
if (sourceRequest.method === "GET" || sourceRequest.method === "HEAD") return new Request(assetUrl, sourceRequest);
|
|
108
|
+
return new Request(assetUrl, {
|
|
109
|
+
method: sourceRequest.method,
|
|
110
|
+
headers: sourceRequest.headers
|
|
111
|
+
});
|
|
103
112
|
}
|
|
104
113
|
//#endregion
|
|
105
|
-
export { finalizeMissingStaticAssetResponse, mergeHeaders, resolveStaticAssetSignal };
|
|
114
|
+
export { createStaticAssetRequest, finalizeMissingStaticAssetResponse, mergeHeaders, resolveStaticAssetSignal };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React$1 from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/shims/app-router-scroll.d.ts
|
|
4
3
|
declare class AppRouterScrollTargetInner extends React$1.Component<{
|
|
5
4
|
children: React$1.ReactNode;
|
|
@@ -13,16 +12,11 @@ declare class AppRouterScrollTargetInner extends React$1.Component<{
|
|
|
13
12
|
componentWillUnmount(): void;
|
|
14
13
|
render(): React$1.ReactNode;
|
|
15
14
|
}
|
|
16
|
-
declare function AppRouterScrollCommitProvider({
|
|
17
|
-
children,
|
|
18
|
-
commitId
|
|
19
|
-
}: {
|
|
15
|
+
declare function AppRouterScrollCommitProvider({ children, commitId }: {
|
|
20
16
|
children?: React$1.ReactNode;
|
|
21
17
|
commitId: number | null;
|
|
22
18
|
}): React$1.JSX.Element;
|
|
23
|
-
declare function AppRouterScrollTarget({
|
|
24
|
-
children
|
|
25
|
-
}: {
|
|
19
|
+
declare function AppRouterScrollTarget({ children }: {
|
|
26
20
|
children: React$1.ReactNode;
|
|
27
21
|
}): React$1.JSX.Element;
|
|
28
22
|
//#endregion
|
package/dist/shims/app.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { ComponentType } from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/shims/app.d.ts
|
|
4
3
|
type AppProps<P = any> = {
|
|
5
4
|
Component: ComponentType<P> & {
|
|
@@ -29,10 +28,7 @@ type AppContext = {
|
|
|
29
28
|
type AppInitialProps<PageProps = any> = {
|
|
30
29
|
pageProps: PageProps;
|
|
31
30
|
};
|
|
32
|
-
declare function appGetInitialProps({
|
|
33
|
-
Component,
|
|
34
|
-
ctx
|
|
35
|
-
}: AppContext): Promise<AppInitialProps>;
|
|
31
|
+
declare function appGetInitialProps({ Component, ctx }: AppContext): Promise<AppInitialProps>;
|
|
36
32
|
declare class App<P = any, CP = any, S = any> extends React.Component<P & AppProps<CP>, S> {
|
|
37
33
|
static origGetInitialProps: typeof appGetInitialProps;
|
|
38
34
|
static getInitialProps: typeof appGetInitialProps;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/shims/before-interactive-context.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* A `<Script strategy="beforeInteractive">` captured during SSR.
|
|
@@ -17,13 +16,16 @@ import React from "react";
|
|
|
17
16
|
* scripts and `innerHTML` set for inline scripts (never both).
|
|
18
17
|
*/
|
|
19
18
|
type BeforeInteractiveInlineScript = {
|
|
20
|
-
/** Optional id attribute. */
|
|
19
|
+
/** Optional id attribute. */
|
|
20
|
+
id?: string;
|
|
21
|
+
/** External script URL. Set for src beforeInteractive scripts. */
|
|
21
22
|
src?: string;
|
|
22
23
|
/**
|
|
23
24
|
* Pre-escaped inline content (already passed through `escapeInlineContent`).
|
|
24
25
|
* Set for inline beforeInteractive scripts; omitted for src scripts.
|
|
25
26
|
*/
|
|
26
|
-
innerHTML?: string;
|
|
27
|
+
innerHTML?: string;
|
|
28
|
+
/** Nonce to emit on the `<script>` tag, when CSP is enabled. */
|
|
27
29
|
nonce?: string;
|
|
28
30
|
/**
|
|
29
31
|
* Additional HTML attributes to emit on the tag. Booleans render as the
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RegisterCachedFunctionOptions } from "./cache-runtime.js";
|
|
2
|
+
//#region src/shims/cache-callable-runtime.d.ts
|
|
3
|
+
declare const CACHE_CAPTURE_TYPE = "use-cache-captures";
|
|
4
|
+
type CacheCaptureEnvelope = {
|
|
5
|
+
type: typeof CACHE_CAPTURE_TYPE;
|
|
6
|
+
encrypted: string | PromiseLike<string>;
|
|
7
|
+
};
|
|
8
|
+
declare function encryptCacheCaptures(captures: unknown[]): CacheCaptureEnvelope;
|
|
9
|
+
declare function registerCachedFunction<TArgs extends unknown[], TResult>(fn: (...args: TArgs) => Promise<TResult>, id: string, variant: string, options: RegisterCachedFunctionOptions): (...args: TArgs) => Promise<TResult>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { encryptCacheCaptures, registerCachedFunction };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { registerCachedFunction as registerCachedFunction$1 } from "./cache-runtime.js";
|
|
2
|
+
import { decryptActionBoundArgs, encryptActionBoundArgs } from "@vitejs/plugin-rsc/utils/encryption-runtime";
|
|
3
|
+
//#region src/shims/cache-callable-runtime.ts
|
|
4
|
+
const CACHE_CAPTURE_TYPE = "use-cache-captures";
|
|
5
|
+
function encryptCacheCaptures(captures) {
|
|
6
|
+
return {
|
|
7
|
+
type: CACHE_CAPTURE_TYPE,
|
|
8
|
+
encrypted: encryptActionBoundArgs(captures)
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
async function decryptCacheCaptures(value) {
|
|
12
|
+
if (!isCacheCaptureEnvelope(value)) return;
|
|
13
|
+
const captures = await decryptActionBoundArgs(Promise.resolve(value.encrypted));
|
|
14
|
+
if (!Array.isArray(captures)) throw new Error("Invalid cache capture payload");
|
|
15
|
+
return captures;
|
|
16
|
+
}
|
|
17
|
+
function isCacheCaptureEnvelope(value) {
|
|
18
|
+
if (typeof value !== "object" || value === null) return false;
|
|
19
|
+
if (!("type" in value) || value.type !== CACHE_CAPTURE_TYPE || !("encrypted" in value)) return false;
|
|
20
|
+
const encrypted = value.encrypted;
|
|
21
|
+
return typeof encrypted === "string" || typeof encrypted === "object" && encrypted !== null && "then" in encrypted && typeof encrypted.then === "function";
|
|
22
|
+
}
|
|
23
|
+
function registerCachedFunction(fn, id, variant, options) {
|
|
24
|
+
return registerCachedFunction$1(fn, id, variant, {
|
|
25
|
+
...options,
|
|
26
|
+
decryptCaptures: decryptCacheCaptures
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { encryptCacheCaptures, registerCachedFunction };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RenderObservation } from "../server/cache-proof.js";
|
|
2
|
-
|
|
3
2
|
//#region src/shims/cache-handler.d.ts
|
|
4
3
|
type CacheHandlerValue = {
|
|
5
4
|
lastModified: number;
|
|
@@ -11,6 +10,12 @@ type CacheHandlerValue = {
|
|
|
11
10
|
type CacheControlMetadata = {
|
|
12
11
|
revalidate: number | false;
|
|
13
12
|
expire?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Client-router reuse bound from the render's resolved `cacheLife`,
|
|
15
|
+
* persisted so warm hits replay the producing render's claim. Independent
|
|
16
|
+
* of `revalidate`/`expire`; absent means no claim was made.
|
|
17
|
+
*/
|
|
18
|
+
stale?: number;
|
|
14
19
|
};
|
|
15
20
|
type IncrementalCacheValue = CachedFetchValue | CachedAppPageValue | CachedPagesValue | CachedRouteValue | CachedRedirectValue | CachedImageValue;
|
|
16
21
|
type CachedFetchValue = {
|
|
@@ -117,15 +117,17 @@ var MemoryCacheHandler = class {
|
|
|
117
117
|
const tags = [...tagSet];
|
|
118
118
|
let effectiveRevalidate = readCacheControlRevalidateField(ctx);
|
|
119
119
|
const effectiveExpire = readCacheControlNumberField(ctx, "expire");
|
|
120
|
+
const effectiveStale = readCacheControlNumberField(ctx, "stale");
|
|
120
121
|
if (data && "revalidate" in data && typeof data.revalidate === "number") effectiveRevalidate = data.revalidate;
|
|
121
122
|
else if (data && "revalidate" in data && data.revalidate === false) effectiveRevalidate ??= false;
|
|
122
123
|
if (effectiveRevalidate === 0) return;
|
|
123
124
|
const now = Date.now();
|
|
124
125
|
const revalidateAt = typeof effectiveRevalidate === "number" && effectiveRevalidate > 0 ? now + effectiveRevalidate * 1e3 : null;
|
|
125
126
|
const expireAt = typeof effectiveExpire === "number" && effectiveExpire > 0 ? now + effectiveExpire * 1e3 : null;
|
|
126
|
-
const cacheControl = typeof effectiveRevalidate === "number" || effectiveRevalidate === false ?
|
|
127
|
+
const cacheControl = typeof effectiveRevalidate === "number" || effectiveRevalidate === false ? {
|
|
127
128
|
revalidate: effectiveRevalidate,
|
|
128
|
-
expire: effectiveExpire
|
|
129
|
+
...effectiveExpire === void 0 ? {} : { expire: effectiveExpire },
|
|
130
|
+
...effectiveStale === void 0 ? {} : { stale: effectiveStale }
|
|
129
131
|
} : void 0;
|
|
130
132
|
if (this.maxMemoryCacheSize === 0) return;
|
|
131
133
|
const entry = {
|
|
@@ -9,12 +9,15 @@ type CacheContextLike = {
|
|
|
9
9
|
tags: string[];
|
|
10
10
|
lifeConfigs: CacheLifeConfig[];
|
|
11
11
|
variant: string;
|
|
12
|
+
readRootParamNames?: Set<string>;
|
|
12
13
|
hasExplicitRevalidate: boolean;
|
|
13
14
|
hasExplicitExpire: boolean;
|
|
14
15
|
dynamicNestedCacheError: Error | undefined;
|
|
15
16
|
};
|
|
16
17
|
declare function _registerCacheContextAccessor(fn: () => CacheContextLike | null): void;
|
|
17
18
|
declare function getRegisteredCacheContext(): CacheContextLike | null;
|
|
19
|
+
/** Record a root-param dependency on the active public `"use cache"` scope. */
|
|
20
|
+
declare function _recordUseCacheRootParamRead(name: string): void;
|
|
18
21
|
type UnstableCacheRevalidationMode = "foreground" | "background";
|
|
19
22
|
type ActionRevalidationKind = 0 | 1 | 2;
|
|
20
23
|
type UnstableCacheObservation = Readonly<{
|
|
@@ -66,8 +69,19 @@ declare function _drainPendingRevalidations(): Promise<void>;
|
|
|
66
69
|
declare function _setRequestScopedCacheLife(config: CacheLifeConfig): void;
|
|
67
70
|
declare function _peekRequestScopedCacheLife(): CacheLifeConfig | null;
|
|
68
71
|
declare function _consumeRequestScopedCacheLife(): CacheLifeConfig | null;
|
|
72
|
+
/**
|
|
73
|
+
* Capture access to the current request's cache-life slot for work that may
|
|
74
|
+
* finish after the AsyncLocalStorage request scope has returned. RSC response
|
|
75
|
+
* bodies are consumed by the server runtime later, so resolving the active
|
|
76
|
+
* store from a stream-finalization callback can otherwise read a detached
|
|
77
|
+
* context and lose cacheLife claims made while rendering the body.
|
|
78
|
+
*/
|
|
79
|
+
declare function _captureRequestScopedCacheLifeAccessors(): {
|
|
80
|
+
consume: () => CacheLifeConfig | null;
|
|
81
|
+
peek: () => CacheLifeConfig | null;
|
|
82
|
+
};
|
|
69
83
|
declare function recordUnstableCacheObservation(observation: UnstableCacheObservation): void;
|
|
70
84
|
declare function _peekUnstableCacheObservations(): UnstableCacheObservation[];
|
|
71
85
|
declare function shouldServeStaleUnstableCacheEntry(): boolean;
|
|
72
86
|
//#endregion
|
|
73
|
-
export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, ActionRevalidationKind, CacheLifeConfig, CacheState, UnstableCacheObservation, UnstableCacheRevalidationMode, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _queuePendingRevalidation, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, getRegisteredCacheContext, markActionRevalidation, recordUnstableCacheObservation, shouldServeStaleUnstableCacheEntry };
|
|
87
|
+
export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, ActionRevalidationKind, CacheLifeConfig, CacheState, UnstableCacheObservation, UnstableCacheRevalidationMode, _captureRequestScopedCacheLifeAccessors, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _queuePendingRevalidation, _recordUseCacheRootParamRead, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, getRegisteredCacheContext, markActionRevalidation, recordUnstableCacheObservation, shouldServeStaleUnstableCacheEntry };
|
|
@@ -45,6 +45,11 @@ function _registerCacheContextAccessor(fn) {
|
|
|
45
45
|
function getRegisteredCacheContext() {
|
|
46
46
|
return getCacheContext?.() ?? null;
|
|
47
47
|
}
|
|
48
|
+
/** Record a root-param dependency on the active public `"use cache"` scope. */
|
|
49
|
+
function _recordUseCacheRootParamRead(name) {
|
|
50
|
+
const context = getRegisteredCacheContext();
|
|
51
|
+
if (context && context.variant !== "private") context.readRootParamNames?.add(name);
|
|
52
|
+
}
|
|
48
53
|
const FALLBACK_KEY = Symbol.for("vinext.cache.fallback");
|
|
49
54
|
const globalState = globalThis;
|
|
50
55
|
const cacheAls = getOrCreateAls("vinext.cache.als");
|
|
@@ -172,6 +177,27 @@ function _consumeRequestScopedCacheLife() {
|
|
|
172
177
|
state.requestScopedCacheLife = null;
|
|
173
178
|
return config;
|
|
174
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Capture access to the current request's cache-life slot for work that may
|
|
182
|
+
* finish after the AsyncLocalStorage request scope has returned. RSC response
|
|
183
|
+
* bodies are consumed by the server runtime later, so resolving the active
|
|
184
|
+
* store from a stream-finalization callback can otherwise read a detached
|
|
185
|
+
* context and lose cacheLife claims made while rendering the body.
|
|
186
|
+
*/
|
|
187
|
+
function _captureRequestScopedCacheLifeAccessors() {
|
|
188
|
+
const state = getCacheState();
|
|
189
|
+
return {
|
|
190
|
+
consume() {
|
|
191
|
+
const config = state.requestScopedCacheLife;
|
|
192
|
+
state.requestScopedCacheLife = null;
|
|
193
|
+
return config;
|
|
194
|
+
},
|
|
195
|
+
peek() {
|
|
196
|
+
const config = state.requestScopedCacheLife;
|
|
197
|
+
return config === null ? null : { ...config };
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
175
201
|
function recordUnstableCacheObservation(observation) {
|
|
176
202
|
getCacheState().unstableCacheObservations.set(observation.keyHash, observation);
|
|
177
203
|
}
|
|
@@ -182,4 +208,4 @@ function shouldServeStaleUnstableCacheEntry() {
|
|
|
182
208
|
return getCacheState().unstableCacheRevalidation === "background";
|
|
183
209
|
}
|
|
184
210
|
//#endregion
|
|
185
|
-
export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _queuePendingRevalidation, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, getRegisteredCacheContext, markActionRevalidation, recordUnstableCacheObservation, shouldServeStaleUnstableCacheEntry };
|
|
211
|
+
export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, _captureRequestScopedCacheLifeAccessors, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _queuePendingRevalidation, _recordUseCacheRootParamRead, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, getRegisteredCacheContext, markActionRevalidation, recordUnstableCacheObservation, shouldServeStaleUnstableCacheEntry };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CacheLifeConfig } from "./cache-request-state.js";
|
|
2
2
|
import { markAppPagePropsForUseCache } from "./internal/app-page-props-cache-key.js";
|
|
3
|
-
|
|
4
3
|
//#region src/shims/cache-runtime.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Used purely as `cause` for the nested-dynamic cache error: its captured stack
|
|
@@ -12,10 +11,17 @@ declare class NestedDynamicUseCacheError extends Error {
|
|
|
12
11
|
constructor();
|
|
13
12
|
}
|
|
14
13
|
type CacheContext = {
|
|
15
|
-
/** Tags collected via cacheTag() during execution */
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
/** Tags collected via cacheTag() during execution */
|
|
15
|
+
tags: string[];
|
|
16
|
+
/** Cache life configs collected via cacheLife() — minimum-wins rule applies */
|
|
17
|
+
lifeConfigs: CacheLifeConfig[];
|
|
18
|
+
/** Cache variant: "default" | "remote" | "private" */
|
|
19
|
+
variant: string;
|
|
20
|
+
/** Root params observed while producing this public cache entry. */
|
|
21
|
+
readRootParamNames?: Set<string>;
|
|
22
|
+
/** Whether cacheLife() was called with an explicit revalidate value */
|
|
23
|
+
hasExplicitRevalidate: boolean;
|
|
24
|
+
/** Whether cacheLife() was called with an explicit expire value */
|
|
19
25
|
hasExplicitExpire: boolean;
|
|
20
26
|
/**
|
|
21
27
|
* The first nested public "use cache" invocation with a dynamic cache life
|
|
@@ -85,6 +91,9 @@ type RegisterCachedFunctionOptions = {
|
|
|
85
91
|
* rather than on the intermediate createElement config object.
|
|
86
92
|
*/
|
|
87
93
|
appPageDefaultExport?: boolean;
|
|
94
|
+
/** Number of declared arguments supplied by the directive transform. */
|
|
95
|
+
argumentCount?: number;
|
|
96
|
+
decryptCaptures?: (value: unknown) => Promise<unknown[] | undefined>;
|
|
88
97
|
};
|
|
89
98
|
/**
|
|
90
99
|
* Register a function as a cached function. This is called by the Vite
|
|
@@ -97,4 +106,4 @@ type RegisterCachedFunctionOptions = {
|
|
|
97
106
|
*/
|
|
98
107
|
declare function registerCachedFunction<TArgs extends unknown[], TResult>(fn: (...args: TArgs) => Promise<TResult>, id: string, variant?: string, options?: RegisterCachedFunctionOptions): (...args: TArgs) => Promise<TResult>;
|
|
99
108
|
//#endregion
|
|
100
|
-
export { CacheContext, NestedDynamicUseCacheError, PrivateCacheState, buildUseCacheKey, cacheContextStorage, clearPrivateCache, getCacheContext, markAppPagePropsForUseCache, registerCachedFunction, replyToCacheKey, runWithPrivateCache };
|
|
109
|
+
export { CacheContext, NestedDynamicUseCacheError, PrivateCacheState, RegisterCachedFunctionOptions, buildUseCacheKey, cacheContextStorage, clearPrivateCache, getCacheContext, markAppPagePropsForUseCache, registerCachedFunction, replyToCacheKey, runWithPrivateCache };
|