vinext 1.0.0-beta.3 → 1.0.0-beta.5
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 +42 -8
- package/dist/build/prerender-paths.d.ts +2 -2
- package/dist/build/prerender-server-entry.d.ts +1 -1
- package/dist/build/prerender-server-pool.d.ts +4 -2
- package/dist/build/prerender.d.ts +36 -32
- package/dist/build/prerender.js +18 -3
- 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/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-args.d.ts +2 -1
- package/dist/cli-args.js +10 -0
- package/dist/cli-dev-config.d.ts +0 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +14 -8
- 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 +12 -1
- package/dist/client/navigation-runtime.js +6 -2
- 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 +11 -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 +4 -9
- package/dist/config/dotenv.js +30 -22
- package/dist/config/next-config.d.ts +113 -52
- package/dist/config/next-config.js +6 -0
- package/dist/config/prerender.d.ts +0 -1
- package/dist/entries/app-browser-entry.d.ts +0 -1
- package/dist/entries/app-browser-entry.js +7 -3
- package/dist/entries/app-rsc-entry.d.ts +30 -16
- package/dist/entries/app-rsc-entry.js +40 -12
- 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 +7 -2
- package/dist/entries/pages-server-entry.d.ts +1 -2
- package/dist/entries/pages-server-entry.js +25 -6
- package/dist/image/image-adapters-virtual.d.ts +4 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +257 -75
- 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/client-reference-dedup.js +7 -5
- 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/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 +67 -5
- 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/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 +4 -3
- package/dist/server/app-bfcache-identity.d.ts +9 -10
- package/dist/server/app-bfcache-identity.js +27 -102
- 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 +106 -66
- 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 +3 -6
- package/dist/server/app-browser-navigation-controller.js +29 -4
- package/dist/server/app-browser-popstate.d.ts +0 -1
- package/dist/server/app-browser-prefetch-response.d.ts +25 -0
- package/dist/server/app-browser-prefetch-response.js +54 -0
- 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 +11 -5
- package/dist/server/app-browser-state.js +10 -6
- 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-cache-finalizer.d.ts +2 -3
- package/dist/server/app-page-cache-finalizer.js +47 -17
- package/dist/server/app-page-cache-render.d.ts +2 -2
- package/dist/server/app-page-cache-render.js +2 -1
- package/dist/server/app-page-cache.d.ts +1 -3
- package/dist/server/app-page-cache.js +22 -11
- package/dist/server/app-page-dispatch.d.ts +12 -6
- package/dist/server/app-page-dispatch.js +14 -6
- package/dist/server/app-page-element-builder.d.ts +63 -20
- package/dist/server/app-page-element-builder.js +114 -43
- package/dist/server/app-page-execution.d.ts +12 -5
- package/dist/server/app-page-execution.js +1 -1
- 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 +7 -5
- package/dist/server/app-page-render.js +59 -24
- package/dist/server/app-page-request.d.ts +3 -2
- package/dist/server/app-page-request.js +6 -46
- package/dist/server/app-page-response.d.ts +15 -3
- package/dist/server/app-page-response.js +21 -3
- package/dist/server/app-page-route-wiring.d.ts +30 -7
- package/dist/server/app-page-route-wiring.js +163 -63
- 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 +19 -10
- package/dist/server/app-pages-bridge.d.ts +2 -2
- package/dist/server/app-pages-bridge.js +14 -2
- 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 +0 -1
- 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-route-handler-cache.d.ts +2 -2
- package/dist/server/app-route-handler-cache.js +5 -1
- package/dist/server/app-route-handler-dispatch.d.ts +0 -1
- package/dist/server/app-route-handler-execution.d.ts +2 -2
- package/dist/server/app-route-handler-execution.js +5 -1
- package/dist/server/app-route-handler-policy.d.ts +0 -1
- package/dist/server/app-route-handler-response.d.ts +0 -1
- package/dist/server/app-route-handler-runtime.d.ts +0 -1
- package/dist/server/app-route-handler-runtime.js +1 -2
- 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-router-entry.d.ts +0 -1
- package/dist/server/app-router-entry.js +2 -2
- package/dist/server/app-rsc-cache-busting.d.ts +7 -1
- package/dist/server/app-rsc-cache-busting.js +6 -0
- package/dist/server/app-rsc-handler.d.ts +9 -2
- package/dist/server/app-rsc-handler.js +173 -41
- package/dist/server/app-rsc-redirect-flight.d.ts +0 -1
- package/dist/server/app-rsc-render-mode.d.ts +3 -2
- package/dist/server/app-rsc-render-mode.js +4 -1
- package/dist/server/app-rsc-request-normalization.d.ts +19 -10
- package/dist/server/app-rsc-request-normalization.js +65 -4
- package/dist/server/app-rsc-response-finalizer.d.ts +5 -2
- package/dist/server/app-rsc-response-finalizer.js +31 -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-segment-config.d.ts +0 -1
- package/dist/server/app-server-action-execution.d.ts +42 -9
- package/dist/server/app-server-action-execution.js +189 -111
- package/dist/server/app-ssr-entry.d.ts +5 -3
- package/dist/server/app-ssr-entry.js +4 -5
- package/dist/server/app-ssr-router-instance.d.ts +0 -1
- package/dist/server/app-ssr-stream.d.ts +7 -1
- package/dist/server/app-ssr-stream.js +2 -1
- package/dist/server/app-static-generation.d.ts +0 -1
- package/dist/server/app-visited-response-cache.d.ts +7 -2
- package/dist/server/app-visited-response-cache.js +49 -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 +3 -3
- package/dist/server/cache-control.js +3 -2
- 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 +2 -2
- 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 +86 -131
- 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/edge-api-runtime.d.ts +10 -1
- package/dist/server/edge-api-runtime.js +29 -1
- package/dist/server/file-based-metadata.d.ts +0 -1
- package/dist/server/headers.d.ts +17 -2
- package/dist/server/headers.js +17 -1
- 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 +2 -1
- package/dist/server/http-error-responses.js +14 -2
- 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-response.d.ts +0 -1
- package/dist/server/metadata-route-response.js +7 -6
- package/dist/server/metadata-routes.d.ts +34 -16
- 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-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 +2 -1
- package/dist/server/pages-api-route.js +32 -7
- package/dist/server/pages-asset-tags.d.ts +3 -1
- package/dist/server/pages-asset-tags.js +6 -4
- 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 +3 -0
- package/dist/server/pages-dev-stylesheets.d.ts +10 -0
- package/dist/server/pages-dev-stylesheets.js +150 -0
- package/dist/server/pages-document-asset-props.d.ts +26 -0
- package/dist/server/pages-document-asset-props.js +69 -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 +52 -5
- 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 +70 -32
- package/dist/server/pages-page-handler.js +25 -6
- package/dist/server/pages-page-response.d.ts +9 -13
- package/dist/server/pages-page-response.js +25 -26
- 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 +14 -10
- package/dist/server/prerender-manifest.d.ts +7 -0
- package/dist/server/prod-server.d.ts +13 -7
- package/dist/server/prod-server.js +276 -83
- 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 +28 -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 +2 -1
- package/dist/server/seed-cache.js +8 -5
- 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-revalidation-context.js +1 -0
- package/dist/server/worker-utils.d.ts +3 -1
- package/dist/server/worker-utils.js +11 -2
- package/dist/shims/app-router-scroll-state.d.ts +2 -1
- package/dist/shims/app-router-scroll-state.js +7 -2
- 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-handler.d.ts +6 -1
- package/dist/shims/cache-handler.js +4 -2
- package/dist/shims/cache-request-state.d.ts +12 -1
- package/dist/shims/cache-request-state.js +22 -1
- package/dist/shims/cache-runtime.d.ts +9 -5
- package/dist/shims/cache-runtime.js +16 -6
- package/dist/shims/cache.d.ts +2 -3
- package/dist/shims/cache.js +2 -2
- package/dist/shims/cdn-cache.d.ts +0 -1
- 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 +17 -3
- 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 +112 -63
- package/dist/shims/font-google-base.d.ts +0 -1
- package/dist/shims/font-local.d.ts +0 -1
- package/dist/shims/form.d.ts +5 -3
- package/dist/shims/hash-scroll.d.ts +1 -1
- package/dist/shims/hash-scroll.js +2 -1
- package/dist/shims/head-state.d.ts +0 -1
- package/dist/shims/head.d.ts +1 -4
- 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 +31 -0
- package/dist/shims/internal/app-route-prefetch-policy.js +57 -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 +21 -10
- package/dist/shims/internal/pages-data-target.js +1 -1
- 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 -21
- package/dist/shims/link.js +52 -97
- package/dist/shims/metadata.d.ts +11 -25
- package/dist/shims/metadata.js +24 -32
- package/dist/shims/navigation-context-state.d.ts +0 -1
- package/dist/shims/navigation-state.d.ts +1 -0
- package/dist/shims/navigation.d.ts +54 -6
- package/dist/shims/navigation.js +325 -73
- 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 -3
- package/dist/shims/request-state-types.d.ts +1 -0
- package/dist/shims/router.d.ts +44 -23
- package/dist/shims/router.js +8 -7
- 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 +5 -6
- package/dist/shims/slot.d.ts +23 -11
- package/dist/shims/slot.js +103 -19
- package/dist/shims/streamed-icons.d.ts +7 -0
- package/dist/shims/streamed-icons.js +33 -0
- 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/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/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 +7 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/server/http-conditional.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Test an If-None-Match field value against a current entity tag.
|
|
4
|
+
*
|
|
5
|
+
* RFC 9110 requires weak comparison for If-None-Match: a weak and strong
|
|
6
|
+
* validator with the same opaque tag compare equal.
|
|
7
|
+
*/
|
|
8
|
+
declare function matchesIfNoneMatch(ifNoneMatch: string | undefined, etag: string): boolean;
|
|
9
|
+
/** Test an If-Match field using Next.js's weak/strong-equivalent comparison. */
|
|
10
|
+
declare function matchesIfMatch(ifMatch: string | undefined, etag: string | undefined): boolean;
|
|
11
|
+
type StaticConditionalHeaders = {
|
|
12
|
+
cacheControl?: string | string[];
|
|
13
|
+
ifMatch?: string | string[];
|
|
14
|
+
ifUnmodifiedSince?: string | string[];
|
|
15
|
+
ifNoneMatch?: string | string[];
|
|
16
|
+
ifModifiedSince?: string | string[];
|
|
17
|
+
};
|
|
18
|
+
type StaticPreconditionResult = "proceed" | "not-modified" | "precondition-failed";
|
|
19
|
+
/** Evaluate static representation preconditions in RFC 9110 section 13.2.2 order. */
|
|
20
|
+
declare function evaluateStaticPreconditions(headers: StaticConditionalHeaders, method: string | undefined, etag: string | undefined, mtimeMs: number): StaticPreconditionResult;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { StaticPreconditionResult, evaluateStaticPreconditions, matchesIfMatch, matchesIfNoneMatch };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { parseHttpDate } from "./http-date.js";
|
|
2
|
+
//#region src/server/http-conditional.ts
|
|
3
|
+
/**
|
|
4
|
+
* Test an If-None-Match field value against a current entity tag.
|
|
5
|
+
*
|
|
6
|
+
* RFC 9110 requires weak comparison for If-None-Match: a weak and strong
|
|
7
|
+
* validator with the same opaque tag compare equal.
|
|
8
|
+
*/
|
|
9
|
+
function matchesIfNoneMatch(ifNoneMatch, etag) {
|
|
10
|
+
if (!ifNoneMatch) return false;
|
|
11
|
+
const current = parseEntityTag(etag, 0);
|
|
12
|
+
if (!current || current.end !== etag.length) return false;
|
|
13
|
+
const currentOpaqueTag = etag.slice(current.opaqueStart, current.opaqueEnd);
|
|
14
|
+
let index = skipOptionalWhitespace(ifNoneMatch, 0);
|
|
15
|
+
if (ifNoneMatch[index] === "*") return skipOptionalWhitespace(ifNoneMatch, index + 1) === ifNoneMatch.length;
|
|
16
|
+
let matched = false;
|
|
17
|
+
let sawTag = false;
|
|
18
|
+
while (index < ifNoneMatch.length) {
|
|
19
|
+
if (ifNoneMatch[index] === ",") {
|
|
20
|
+
index = skipOptionalWhitespace(ifNoneMatch, index + 1);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const candidate = parseEntityTag(ifNoneMatch, index);
|
|
24
|
+
if (!candidate) return false;
|
|
25
|
+
sawTag = true;
|
|
26
|
+
matched ||= ifNoneMatch.slice(candidate.opaqueStart, candidate.opaqueEnd) === currentOpaqueTag;
|
|
27
|
+
index = skipOptionalWhitespace(ifNoneMatch, candidate.end);
|
|
28
|
+
if (index === ifNoneMatch.length) break;
|
|
29
|
+
if (ifNoneMatch[index] !== ",") return false;
|
|
30
|
+
index = skipOptionalWhitespace(ifNoneMatch, index + 1);
|
|
31
|
+
}
|
|
32
|
+
return sawTag && matched;
|
|
33
|
+
}
|
|
34
|
+
/** Test an If-Match field using Next.js's weak/strong-equivalent comparison. */
|
|
35
|
+
function matchesIfMatch(ifMatch, etag) {
|
|
36
|
+
if (!ifMatch) return false;
|
|
37
|
+
let index = skipOptionalWhitespace(ifMatch, 0);
|
|
38
|
+
if (ifMatch[index] === "*") return skipOptionalWhitespace(ifMatch, index + 1) === ifMatch.length;
|
|
39
|
+
if (!etag) return false;
|
|
40
|
+
const current = parseEntityTag(etag, 0);
|
|
41
|
+
if (!current || current.end !== etag.length) return false;
|
|
42
|
+
const currentOpaqueTag = etag.slice(current.opaqueStart, current.opaqueEnd);
|
|
43
|
+
let matched = false;
|
|
44
|
+
let sawTag = false;
|
|
45
|
+
while (index < ifMatch.length) {
|
|
46
|
+
if (ifMatch[index] === ",") {
|
|
47
|
+
index = skipOptionalWhitespace(ifMatch, index + 1);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const candidate = parseEntityTag(ifMatch, index);
|
|
51
|
+
if (!candidate) return false;
|
|
52
|
+
sawTag = true;
|
|
53
|
+
matched ||= ifMatch.slice(candidate.opaqueStart, candidate.opaqueEnd) === currentOpaqueTag;
|
|
54
|
+
index = skipOptionalWhitespace(ifMatch, candidate.end);
|
|
55
|
+
if (index === ifMatch.length) break;
|
|
56
|
+
if (ifMatch[index] !== ",") return false;
|
|
57
|
+
index = skipOptionalWhitespace(ifMatch, index + 1);
|
|
58
|
+
}
|
|
59
|
+
return sawTag && matched;
|
|
60
|
+
}
|
|
61
|
+
function parseEntityTag(value, start) {
|
|
62
|
+
let index = start;
|
|
63
|
+
const weak = value.startsWith("W/", index);
|
|
64
|
+
if (weak) index += 2;
|
|
65
|
+
if (value[index] !== "\"") return null;
|
|
66
|
+
const opaqueStart = ++index;
|
|
67
|
+
while (index < value.length && value[index] !== "\"") {
|
|
68
|
+
const code = value.charCodeAt(index);
|
|
69
|
+
if (!(code === 33 || code >= 35 && code <= 126 || code >= 128 && code <= 255)) return null;
|
|
70
|
+
index++;
|
|
71
|
+
}
|
|
72
|
+
if (value[index] !== "\"") return null;
|
|
73
|
+
return {
|
|
74
|
+
weak,
|
|
75
|
+
opaqueStart,
|
|
76
|
+
opaqueEnd: index,
|
|
77
|
+
end: index + 1
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function skipOptionalWhitespace(value, start) {
|
|
81
|
+
let index = start;
|
|
82
|
+
while (value[index] === " " || value[index] === " ") index++;
|
|
83
|
+
return index;
|
|
84
|
+
}
|
|
85
|
+
/** Evaluate static representation preconditions in RFC 9110 section 13.2.2 order. */
|
|
86
|
+
function evaluateStaticPreconditions(headers, method, etag, mtimeMs) {
|
|
87
|
+
const ifMatch = joinHeader(headers.ifMatch);
|
|
88
|
+
if (ifMatch !== void 0) {
|
|
89
|
+
if (!matchesIfMatch(ifMatch, etag)) return "precondition-failed";
|
|
90
|
+
} else {
|
|
91
|
+
const ifUnmodifiedSince = joinHeader(headers.ifUnmodifiedSince);
|
|
92
|
+
if (ifUnmodifiedSince) {
|
|
93
|
+
const unmodifiedSinceMs = parseHttpDate(ifUnmodifiedSince);
|
|
94
|
+
if (Number.isFinite(unmodifiedSinceMs) && Number.isFinite(mtimeMs) && Math.floor(mtimeMs / 1e3) > Math.floor(unmodifiedSinceMs / 1e3)) return "precondition-failed";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const ifNoneMatch = joinHeader(headers.ifNoneMatch);
|
|
98
|
+
if (ifNoneMatch !== void 0) {
|
|
99
|
+
if (!(ifNoneMatch.trim() === "*" || etag !== void 0 && matchesIfNoneMatch(ifNoneMatch, etag))) return "proceed";
|
|
100
|
+
if (method !== "GET" && method !== "HEAD") return "precondition-failed";
|
|
101
|
+
const cacheControl = joinHeader(headers.cacheControl);
|
|
102
|
+
return cacheControl && /(?:^|,)\s*no-cache\s*(?:,|$)/i.test(cacheControl) ? "proceed" : "not-modified";
|
|
103
|
+
}
|
|
104
|
+
if (method !== "GET" && method !== "HEAD") return "proceed";
|
|
105
|
+
const cacheControl = joinHeader(headers.cacheControl);
|
|
106
|
+
if (cacheControl && /(?:^|,)\s*no-cache\s*(?:,|$)/i.test(cacheControl)) return "proceed";
|
|
107
|
+
const ifModifiedSince = joinHeader(headers.ifModifiedSince);
|
|
108
|
+
if (!ifModifiedSince) return "proceed";
|
|
109
|
+
const modifiedSinceMs = parseHttpDate(ifModifiedSince);
|
|
110
|
+
if (!Number.isFinite(modifiedSinceMs)) return "proceed";
|
|
111
|
+
return Number.isFinite(mtimeMs) && Math.floor(mtimeMs / 1e3) <= Math.floor(modifiedSinceMs / 1e3) ? "not-modified" : "proceed";
|
|
112
|
+
}
|
|
113
|
+
function joinHeader(value) {
|
|
114
|
+
return Array.isArray(value) ? value.join(", ") : value;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { evaluateStaticPreconditions, matchesIfMatch, matchesIfNoneMatch };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region src/server/http-date.ts
|
|
2
|
+
const IMF_FIXDATE_RE = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT$/;
|
|
3
|
+
const RFC850_DATE_RE = /^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d{2}) (\d{2}):(\d{2}):(\d{2}) GMT$/;
|
|
4
|
+
const ASCTIME_DATE_RE = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?: (\d)|(\d{2})) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/;
|
|
5
|
+
const WEEKDAY_INDEX = {
|
|
6
|
+
Sun: 0,
|
|
7
|
+
Sunday: 0,
|
|
8
|
+
Mon: 1,
|
|
9
|
+
Monday: 1,
|
|
10
|
+
Tue: 2,
|
|
11
|
+
Tuesday: 2,
|
|
12
|
+
Wed: 3,
|
|
13
|
+
Wednesday: 3,
|
|
14
|
+
Thu: 4,
|
|
15
|
+
Thursday: 4,
|
|
16
|
+
Fri: 5,
|
|
17
|
+
Friday: 5,
|
|
18
|
+
Sat: 6,
|
|
19
|
+
Saturday: 6
|
|
20
|
+
};
|
|
21
|
+
const MONTH_INDEX = {
|
|
22
|
+
Jan: 0,
|
|
23
|
+
Feb: 1,
|
|
24
|
+
Mar: 2,
|
|
25
|
+
Apr: 3,
|
|
26
|
+
May: 4,
|
|
27
|
+
Jun: 5,
|
|
28
|
+
Jul: 6,
|
|
29
|
+
Aug: 7,
|
|
30
|
+
Sep: 8,
|
|
31
|
+
Oct: 9,
|
|
32
|
+
Nov: 10,
|
|
33
|
+
Dec: 11
|
|
34
|
+
};
|
|
35
|
+
/** Parse only the three HTTP-date wire formats accepted by RFC 9110. */
|
|
36
|
+
function parseHttpDate(value) {
|
|
37
|
+
const imf = IMF_FIXDATE_RE.exec(value);
|
|
38
|
+
if (imf) return timestampFromHttpDateParts(imf[1], imf[2], imf[3], imf[4], imf[5], imf[6], imf[7]);
|
|
39
|
+
const rfc850 = RFC850_DATE_RE.exec(value);
|
|
40
|
+
if (rfc850) {
|
|
41
|
+
const now = /* @__PURE__ */ new Date();
|
|
42
|
+
let year = now.getUTCFullYear() - now.getUTCFullYear() % 100 + Number(rfc850[4]);
|
|
43
|
+
const candidateTimestamp = timestampForRfc850YearWindow(rfc850[2], rfc850[3], String(year), rfc850[5], rfc850[6], rfc850[7]);
|
|
44
|
+
const fiftyYearsFromNow = new Date(now);
|
|
45
|
+
fiftyYearsFromNow.setUTCFullYear(now.getUTCFullYear() + 50);
|
|
46
|
+
if (candidateTimestamp > fiftyYearsFromNow.getTime()) year -= 100;
|
|
47
|
+
return timestampFromHttpDateParts(rfc850[1], rfc850[2], rfc850[3], String(year), rfc850[5], rfc850[6], rfc850[7]);
|
|
48
|
+
}
|
|
49
|
+
const asctime = ASCTIME_DATE_RE.exec(value);
|
|
50
|
+
if (asctime) return timestampFromHttpDateParts(asctime[1], asctime[3] || asctime[4], asctime[2], asctime[8], asctime[5], asctime[6], asctime[7]);
|
|
51
|
+
return NaN;
|
|
52
|
+
}
|
|
53
|
+
function timestampForRfc850YearWindow(dayValue, monthValue, yearValue, hourValue, minuteValue, secondValue) {
|
|
54
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
55
|
+
date.setUTCFullYear(Number(yearValue), MONTH_INDEX[monthValue], Number(dayValue));
|
|
56
|
+
date.setUTCHours(Number(hourValue), Number(minuteValue), Number(secondValue), 0);
|
|
57
|
+
return date.getTime();
|
|
58
|
+
}
|
|
59
|
+
function timestampFromHttpDateParts(weekday, dayValue, monthValue, yearValue, hourValue, minuteValue, secondValue) {
|
|
60
|
+
const day = Number(dayValue);
|
|
61
|
+
const month = MONTH_INDEX[monthValue];
|
|
62
|
+
const year = Number(yearValue);
|
|
63
|
+
const hour = Number(hourValue);
|
|
64
|
+
const minute = Number(minuteValue);
|
|
65
|
+
const second = Number(secondValue);
|
|
66
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
67
|
+
date.setUTCFullYear(year, month, day);
|
|
68
|
+
date.setUTCHours(hour, minute, second, 0);
|
|
69
|
+
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day || date.getUTCHours() !== hour || date.getUTCMinutes() !== minute || date.getUTCSeconds() !== second || weekday !== void 0 && date.getUTCDay() !== WEEKDAY_INDEX[weekday]) return NaN;
|
|
70
|
+
return date.getTime();
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { parseHttpDate };
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
type ErrorResponseInit = {
|
|
20
20
|
headers?: HeadersInit;
|
|
21
21
|
};
|
|
22
|
+
declare function sanitizeMethodNotAllowedHeaders(headers: Headers, allowedMethods: string): void;
|
|
22
23
|
/**
|
|
23
24
|
* Build a 400 Bad Request plain-text response.
|
|
24
25
|
*
|
|
@@ -88,4 +89,4 @@ declare function payloadTooLargeResponse(): Response;
|
|
|
88
89
|
*/
|
|
89
90
|
declare function internalServerErrorResponse(message?: string, init?: ErrorResponseInit): Response;
|
|
90
91
|
//#endregion
|
|
91
|
-
export { badRequestResponse, forbiddenResponse, internalServerErrorResponse, methodNotAllowedResponse, notFoundResponse, notFoundStaticAssetResponse, payloadTooLargeResponse };
|
|
92
|
+
export { badRequestResponse, forbiddenResponse, internalServerErrorResponse, methodNotAllowedResponse, notFoundResponse, notFoundStaticAssetResponse, payloadTooLargeResponse, sanitizeMethodNotAllowedHeaders };
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
//#region src/server/http-error-responses.ts
|
|
2
|
+
const METHOD_NOT_ALLOWED_BODY_HEADERS = [
|
|
3
|
+
"content-encoding",
|
|
4
|
+
"content-length",
|
|
5
|
+
"content-range",
|
|
6
|
+
"content-type",
|
|
7
|
+
"transfer-encoding"
|
|
8
|
+
];
|
|
9
|
+
function sanitizeMethodNotAllowedHeaders(headers, allowedMethods) {
|
|
10
|
+
for (const name of METHOD_NOT_ALLOWED_BODY_HEADERS) headers.delete(name);
|
|
11
|
+
headers.set("Allow", allowedMethods);
|
|
12
|
+
headers.set("Content-Type", "text/plain; charset=utf-8");
|
|
13
|
+
}
|
|
2
14
|
/**
|
|
3
15
|
* Build a 400 Bad Request plain-text response.
|
|
4
16
|
*
|
|
@@ -74,7 +86,7 @@ function notFoundStaticAssetResponse() {
|
|
|
74
86
|
*/
|
|
75
87
|
function methodNotAllowedResponse(allowedMethods, init) {
|
|
76
88
|
const headers = new Headers(init?.headers);
|
|
77
|
-
headers
|
|
89
|
+
sanitizeMethodNotAllowedHeaders(headers, allowedMethods);
|
|
78
90
|
return new Response("Method Not Allowed", {
|
|
79
91
|
status: 405,
|
|
80
92
|
headers
|
|
@@ -102,4 +114,4 @@ function internalServerErrorResponse(message, init) {
|
|
|
102
114
|
});
|
|
103
115
|
}
|
|
104
116
|
//#endregion
|
|
105
|
-
export { badRequestResponse, forbiddenResponse, internalServerErrorResponse, methodNotAllowedResponse, notFoundResponse, notFoundStaticAssetResponse, payloadTooLargeResponse };
|
|
117
|
+
export { badRequestResponse, forbiddenResponse, internalServerErrorResponse, methodNotAllowedResponse, notFoundResponse, notFoundStaticAssetResponse, payloadTooLargeResponse, sanitizeMethodNotAllowedHeaders };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/server/http-range.d.ts
|
|
2
|
+
type ByteRange = {
|
|
3
|
+
kind: "ignore";
|
|
4
|
+
} | {
|
|
5
|
+
kind: "unsatisfiable";
|
|
6
|
+
} | {
|
|
7
|
+
kind: "range";
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Parse a single bytes range. Unsupported range units, malformed values, and
|
|
13
|
+
* multipart ranges are ignored, which RFC 9110 permits servers to do.
|
|
14
|
+
*/
|
|
15
|
+
declare function parseByteRange(value: string | undefined, size: number): ByteRange;
|
|
16
|
+
/**
|
|
17
|
+
* If-Range requires strong entity-tag comparison. Date validators are matched
|
|
18
|
+
* at HTTP-date (whole-second) precision because filesystem mtimes are finer,
|
|
19
|
+
* and allow a range when the representation has not changed since that date.
|
|
20
|
+
* Vinext's static ETags are currently weak, so its emitted Last-Modified value
|
|
21
|
+
* is the validator that can enable a range response on a later request.
|
|
22
|
+
*/
|
|
23
|
+
declare function ifRangeAllowsRange(value: string | undefined, etag: string, mtimeMs: number): boolean;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ByteRange, ifRangeAllowsRange, parseByteRange };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { parseHttpDate } from "./http-date.js";
|
|
2
|
+
//#region src/server/http-range.ts
|
|
3
|
+
/**
|
|
4
|
+
* Parse a single bytes range. Unsupported range units, malformed values, and
|
|
5
|
+
* multipart ranges are ignored, which RFC 9110 permits servers to do.
|
|
6
|
+
*/
|
|
7
|
+
function parseByteRange(value, size) {
|
|
8
|
+
if (!value || value.slice(0, 6).toLowerCase() !== "bytes=") return { kind: "ignore" };
|
|
9
|
+
const spec = value.slice(6).trim();
|
|
10
|
+
if (spec.includes(",")) return { kind: "ignore" };
|
|
11
|
+
const match = /^(\d*)-(\d*)$/.exec(spec);
|
|
12
|
+
if (!match || !match[1] && !match[2]) return { kind: "ignore" };
|
|
13
|
+
if (!match[1]) {
|
|
14
|
+
const suffixLength = parseDecimalInteger(match[2]);
|
|
15
|
+
if (suffixLength === "overflow") {
|
|
16
|
+
if (size === 0) return { kind: "unsatisfiable" };
|
|
17
|
+
return {
|
|
18
|
+
kind: "range",
|
|
19
|
+
start: 0,
|
|
20
|
+
end: size - 1
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (suffixLength === 0 || size === 0) return { kind: "unsatisfiable" };
|
|
24
|
+
return {
|
|
25
|
+
kind: "range",
|
|
26
|
+
start: Math.max(size - suffixLength, 0),
|
|
27
|
+
end: size - 1
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const start = parseDecimalInteger(match[1]);
|
|
31
|
+
const requestedEnd = match[2] ? parseDecimalInteger(match[2]) : size - 1;
|
|
32
|
+
if (start === "overflow") return { kind: "unsatisfiable" };
|
|
33
|
+
if (requestedEnd === "overflow") {
|
|
34
|
+
if (start >= size) return { kind: "unsatisfiable" };
|
|
35
|
+
return {
|
|
36
|
+
kind: "range",
|
|
37
|
+
start,
|
|
38
|
+
end: size - 1
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (start >= size || requestedEnd < start) return { kind: "unsatisfiable" };
|
|
42
|
+
return {
|
|
43
|
+
kind: "range",
|
|
44
|
+
start,
|
|
45
|
+
end: Math.min(requestedEnd, size - 1)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* If-Range requires strong entity-tag comparison. Date validators are matched
|
|
50
|
+
* at HTTP-date (whole-second) precision because filesystem mtimes are finer,
|
|
51
|
+
* and allow a range when the representation has not changed since that date.
|
|
52
|
+
* Vinext's static ETags are currently weak, so its emitted Last-Modified value
|
|
53
|
+
* is the validator that can enable a range response on a later request.
|
|
54
|
+
*/
|
|
55
|
+
function ifRangeAllowsRange(value, etag, mtimeMs) {
|
|
56
|
+
if (!value) return true;
|
|
57
|
+
const trimmed = value.trim();
|
|
58
|
+
if (trimmed.startsWith("\"") || trimmed.startsWith("W/")) return !trimmed.startsWith("W/") && !etag.startsWith("W/") && trimmed === etag;
|
|
59
|
+
const timestamp = parseHttpDate(trimmed);
|
|
60
|
+
return Number.isFinite(timestamp) && Math.floor(mtimeMs / 1e3) * 1e3 <= timestamp;
|
|
61
|
+
}
|
|
62
|
+
function parseDecimalInteger(value) {
|
|
63
|
+
const parsed = Number(value);
|
|
64
|
+
return Number.isSafeInteger(parsed) ? parsed : "overflow";
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { ifRangeAllowsRange, parseByteRange };
|
|
@@ -44,14 +44,17 @@ declare function isImageOptimizationPath(pathname: string): boolean;
|
|
|
44
44
|
* Controls SVG handling and security headers for the image endpoint.
|
|
45
45
|
*/
|
|
46
46
|
type ImageConfig = {
|
|
47
|
-
/** Allowed device widths. Defaults to Next.js device sizes. */
|
|
47
|
+
/** Allowed device widths. Defaults to Next.js device sizes. */
|
|
48
|
+
deviceSizes?: number[];
|
|
49
|
+
/** Allowed fixed-image widths. Defaults to Next.js image sizes. */
|
|
48
50
|
imageSizes?: number[];
|
|
49
51
|
/**
|
|
50
52
|
* Allowed output qualities. When unset, any quality from 1-100 is permitted
|
|
51
53
|
* (matches Next.js: an unset `images.qualities` is not restricted to a single
|
|
52
54
|
* value). When set, only the listed qualities are accepted.
|
|
53
55
|
*/
|
|
54
|
-
qualities?: number[];
|
|
56
|
+
qualities?: number[];
|
|
57
|
+
/** Allow SVG through the image optimization endpoint. Default: false. */
|
|
55
58
|
dangerouslyAllowSVG?: boolean;
|
|
56
59
|
/**
|
|
57
60
|
* Allow image optimization for hostnames that resolve to private IP addresses.
|
|
@@ -62,8 +65,10 @@ type ImageConfig = {
|
|
|
62
65
|
* there is no active server-side SSRF vector — the flag is consumed client-side
|
|
63
66
|
* via the image shim instead.
|
|
64
67
|
*/
|
|
65
|
-
dangerouslyAllowLocalIP?: boolean;
|
|
66
|
-
|
|
68
|
+
dangerouslyAllowLocalIP?: boolean;
|
|
69
|
+
/** Content-Disposition header value. Default: "inline". */
|
|
70
|
+
contentDispositionType?: "inline" | "attachment";
|
|
71
|
+
/** Content-Security-Policy header value. Default: "script-src 'none'; frame-src 'none'; sandbox;" */
|
|
67
72
|
contentSecurityPolicy?: string;
|
|
68
73
|
};
|
|
69
74
|
/**
|
|
@@ -117,7 +122,9 @@ declare function isSafeImageContentType(contentType: string | null, dangerouslyA
|
|
|
117
122
|
* Workers provide these callbacks to adapt their specific bindings.
|
|
118
123
|
*/
|
|
119
124
|
type ImageHandlers = {
|
|
120
|
-
/** Fetch the source image from storage (e.g., Cloudflare ASSETS binding). */
|
|
125
|
+
/** Fetch the source image from storage (e.g., Cloudflare ASSETS binding). */
|
|
126
|
+
fetchAsset: (path: string, request: Request) => Promise<Response>;
|
|
127
|
+
/** Optional: Transform the image (resize, format, quality). */
|
|
121
128
|
transformImage?: (body: ReadableStream, options: {
|
|
122
129
|
width: number;
|
|
123
130
|
format: string;
|
|
@@ -139,7 +146,8 @@ declare function handleImageOptimization(request: Request, handlers: ImageHandle
|
|
|
139
146
|
* {@link setImageOptimizer}.
|
|
140
147
|
*/
|
|
141
148
|
type ImageOptimizer = {
|
|
142
|
-
/** Transform the source image (resize, format, quality). */
|
|
149
|
+
/** Transform the source image (resize, format, quality). */
|
|
150
|
+
transformImage: (body: ReadableStream, options: {
|
|
143
151
|
width: number;
|
|
144
152
|
format: string;
|
|
145
153
|
quality: number;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ValidFileMatcher } from "../routing/file-matcher.js";
|
|
2
|
-
|
|
3
2
|
//#region src/server/instrumentation.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Minimal duck-typed interface for the module runner passed to
|
|
@@ -31,9 +30,13 @@ declare function findInstrumentationClientFile(root: string, fileMatcher: ValidF
|
|
|
31
30
|
* Provides the error, the request info, and an error context.
|
|
32
31
|
*/
|
|
33
32
|
type OnRequestErrorContext = {
|
|
34
|
-
/** The route path (e.g., '/blog/[slug]') */
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
/** The route path (e.g., '/blog/[slug]') */
|
|
34
|
+
routerKind: "Pages Router" | "App Router";
|
|
35
|
+
/** The matched route pattern */
|
|
36
|
+
routePath: string;
|
|
37
|
+
/** The route type */
|
|
38
|
+
routeType: "render" | "route" | "action" | "middleware";
|
|
39
|
+
/** HTTP status code that will be sent */
|
|
37
40
|
revalidateReason?: "on-demand" | "stale" | undefined;
|
|
38
41
|
};
|
|
39
42
|
type OnRequestErrorHandler = (error: Error, request: {
|
|
@@ -3,8 +3,7 @@ import { RenderObservation } from "./cache-proof.js";
|
|
|
3
3
|
import { AppRscRenderMode } from "./app-rsc-render-mode.js";
|
|
4
4
|
import { PRERENDER_REVALIDATE_HEADER, PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER } from "../utils/protocol-headers.js";
|
|
5
5
|
import { normalizeMountedSlotsHeader } from "./app-mounted-slots-header.js";
|
|
6
|
-
import { CacheHandlerValue, CachedAppPageValue, CachedPagesValue, IncrementalCacheValue } from "../shims/cache-handler.js";
|
|
7
|
-
|
|
6
|
+
import { CacheControlMetadata, CacheHandlerValue, CachedAppPageValue, CachedPagesValue, IncrementalCacheValue } from "../shims/cache-handler.js";
|
|
8
7
|
//#region src/server/isr-cache.d.ts
|
|
9
8
|
declare function getRevalidateSecret(): string;
|
|
10
9
|
declare function isRevalidateSecret(value: string | null | undefined): boolean;
|
|
@@ -17,7 +16,8 @@ declare function isRevalidateSecret(value: string | null | undefined): boolean;
|
|
|
17
16
|
declare function isOnDemandRevalidateRequest(headerValue: string | string[] | null | undefined): boolean;
|
|
18
17
|
type ISRCacheEntry = {
|
|
19
18
|
value: CacheHandlerValue;
|
|
20
|
-
isStale: boolean;
|
|
19
|
+
isStale: boolean;
|
|
20
|
+
/** The entry crossed its hard expire boundary and must not be served. */
|
|
21
21
|
isExpired?: boolean;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
@@ -30,12 +30,34 @@ type ISRCacheEntry = {
|
|
|
30
30
|
*/
|
|
31
31
|
declare function isrGet(key: string): Promise<ISRCacheEntry | null>;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* Assemble cache-control metadata, omitting the dimensions the producing
|
|
34
|
+
* render made no claim about. Shared by every ISR writer so `expire`/`stale`
|
|
35
|
+
* are never invented from `revalidate`.
|
|
34
36
|
*/
|
|
35
|
-
declare function
|
|
37
|
+
declare function isrCacheControl(revalidateSeconds: number | false, claims?: {
|
|
38
|
+
expireSeconds?: number;
|
|
39
|
+
staleSeconds?: number;
|
|
40
|
+
}): CacheControlMetadata;
|
|
41
|
+
/**
|
|
42
|
+
* Write policy for one ISR entry: the cache metadata the producing render
|
|
43
|
+
* resolved, plus the tags that can invalidate it. Routers differ only in which
|
|
44
|
+
* `cacheControl` dimensions they populate — App pages carry the client-router
|
|
45
|
+
* `stale` bound, Pages Router and route handlers do not.
|
|
46
|
+
*/
|
|
47
|
+
type IsrWritePolicy = {
|
|
48
|
+
cacheControl: CacheControlMetadata;
|
|
49
|
+
tags?: string[];
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Store a value in the ISR cache under the given write policy.
|
|
53
|
+
*/
|
|
54
|
+
declare function isrSet(key: string, data: IncrementalCacheValue | null, policy: IsrWritePolicy): Promise<void>;
|
|
55
|
+
type AppPageCacheSetter = (key: string, data: CachedAppPageValue, policy: IsrWritePolicy) => Promise<void>;
|
|
36
56
|
declare function isrSetPrerenderedAppPage(key: string, data: CachedAppPageValue, metadata: {
|
|
37
57
|
expireSeconds?: number;
|
|
38
58
|
revalidateSeconds?: number;
|
|
59
|
+
/** Client reuse bound from the prerender's `cacheLife`. */
|
|
60
|
+
staleSeconds?: number;
|
|
39
61
|
/**
|
|
40
62
|
* Implicit/path tags to attach to the seeded entry. Required so that
|
|
41
63
|
* `revalidatePath()` (and `revalidateTag()`) can invalidate prerender-seeded
|
|
@@ -110,4 +132,4 @@ declare function setRevalidateDuration(key: string, seconds: number): void;
|
|
|
110
132
|
*/
|
|
111
133
|
declare function getRevalidateDuration(key: string): number | undefined;
|
|
112
134
|
//#endregion
|
|
113
|
-
export { ISRCacheEntry, PRERENDER_REVALIDATE_HEADER, PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER, appIsrCacheKey, appIsrHtmlKey, appIsrRouteKey, appIsrRscKey, buildAppPageCacheValue, buildPagesCacheValue, coalesceOnDemandRevalidation, getRevalidateDuration, getRevalidateSecret, isOnDemandRevalidateRequest, isRevalidateSecret, isrCacheKey, isrGet, isrSet, isrSetPrerenderedAppPage, normalizeMountedSlotsHeader, setRevalidateDuration, triggerBackgroundRegeneration };
|
|
135
|
+
export { AppPageCacheSetter, ISRCacheEntry, IsrWritePolicy, PRERENDER_REVALIDATE_HEADER, PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER, appIsrCacheKey, appIsrHtmlKey, appIsrRouteKey, appIsrRscKey, buildAppPageCacheValue, buildPagesCacheValue, coalesceOnDemandRevalidation, getRevalidateDuration, getRevalidateSecret, isOnDemandRevalidateRequest, isRevalidateSecret, isrCacheControl, isrCacheKey, isrGet, isrSet, isrSetPrerenderedAppPage, normalizeMountedSlotsHeader, setRevalidateDuration, triggerBackgroundRegeneration };
|
package/dist/server/isr-cache.js
CHANGED
|
@@ -89,16 +89,25 @@ async function isrGet(key) {
|
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* Assemble cache-control metadata, omitting the dimensions the producing
|
|
93
|
+
* render made no claim about. Shared by every ISR writer so `expire`/`stale`
|
|
94
|
+
* are never invented from `revalidate`.
|
|
93
95
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
cacheControl: expireSeconds === void 0 ? { revalidate: revalidateSeconds } : {
|
|
97
|
-
revalidate: revalidateSeconds,
|
|
98
|
-
expire: expireSeconds
|
|
99
|
-
},
|
|
96
|
+
function isrCacheControl(revalidateSeconds, claims = {}) {
|
|
97
|
+
return {
|
|
100
98
|
revalidate: revalidateSeconds,
|
|
101
|
-
|
|
99
|
+
...claims.expireSeconds === void 0 ? {} : { expire: claims.expireSeconds },
|
|
100
|
+
...claims.staleSeconds === void 0 ? {} : { stale: claims.staleSeconds }
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Store a value in the ISR cache under the given write policy.
|
|
105
|
+
*/
|
|
106
|
+
async function isrSet(key, data, policy) {
|
|
107
|
+
await getCdnCacheAdapter().set(key, data, {
|
|
108
|
+
cacheControl: policy.cacheControl,
|
|
109
|
+
revalidate: policy.cacheControl.revalidate,
|
|
110
|
+
tags: policy.tags ?? []
|
|
102
111
|
});
|
|
103
112
|
}
|
|
104
113
|
async function isrSetPrerenderedAppPage(key, data, metadata) {
|
|
@@ -108,10 +117,7 @@ async function isrSetPrerenderedAppPage(key, data, metadata) {
|
|
|
108
117
|
const ctx = {};
|
|
109
118
|
if (revalidateSeconds !== void 0) {
|
|
110
119
|
ctx.revalidate = revalidateSeconds;
|
|
111
|
-
ctx.cacheControl =
|
|
112
|
-
revalidate: revalidateSeconds,
|
|
113
|
-
expire: metadata.expireSeconds
|
|
114
|
-
};
|
|
120
|
+
ctx.cacheControl = isrCacheControl(revalidateSeconds, metadata);
|
|
115
121
|
}
|
|
116
122
|
if (tags && tags.length > 0) ctx.tags = tags;
|
|
117
123
|
await getCdnCacheAdapter().set(key, data, ctx);
|
|
@@ -273,4 +279,4 @@ function getRevalidateDuration(key) {
|
|
|
273
279
|
return revalidateDurations.get(key);
|
|
274
280
|
}
|
|
275
281
|
//#endregion
|
|
276
|
-
export { PRERENDER_REVALIDATE_HEADER, PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER, appIsrCacheKey, appIsrHtmlKey, appIsrRouteKey, appIsrRscKey, buildAppPageCacheValue, buildPagesCacheValue, coalesceOnDemandRevalidation, getRevalidateDuration, getRevalidateSecret, isOnDemandRevalidateRequest, isRevalidateSecret, isrCacheKey, isrGet, isrSet, isrSetPrerenderedAppPage, normalizeMountedSlotsHeader, setRevalidateDuration, triggerBackgroundRegeneration };
|
|
282
|
+
export { PRERENDER_REVALIDATE_HEADER, PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER, appIsrCacheKey, appIsrHtmlKey, appIsrRouteKey, appIsrRscKey, buildAppPageCacheValue, buildPagesCacheValue, coalesceOnDemandRevalidation, getRevalidateDuration, getRevalidateSecret, isOnDemandRevalidateRequest, isRevalidateSecret, isrCacheControl, isrCacheKey, isrGet, isrSet, isrSetPrerenderedAppPage, normalizeMountedSlotsHeader, setRevalidateDuration, triggerBackgroundRegeneration };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CacheControlMetadata } from "../shims/cache-handler.js";
|
|
2
2
|
import { NEVER_CACHE_CONTROL, NO_STORE_CACHE_CONTROL } from "./cache-control.js";
|
|
3
|
-
|
|
4
3
|
//#region src/server/isr-decision.d.ts
|
|
5
4
|
type IsrDisposition = "HIT" | "STALE" | "MISS";
|
|
6
5
|
type IsrDecision = {
|
|
7
|
-
disposition: IsrDisposition;
|
|
8
|
-
|
|
6
|
+
disposition: IsrDisposition;
|
|
7
|
+
/** True when the caller must schedule a background regeneration. */
|
|
8
|
+
scheduleRegeneration: boolean;
|
|
9
|
+
/** The `Cache-Control` string to stamp on the response. */
|
|
9
10
|
cacheControl: string;
|
|
10
11
|
};
|
|
11
12
|
/**
|
|
@@ -24,7 +25,8 @@ type DecideIsrOptions = {
|
|
|
24
25
|
* query-variant-unproven) must have already passed before passing
|
|
25
26
|
* `"HIT"` or `"STALE"` here.
|
|
26
27
|
*/
|
|
27
|
-
cacheState: "HIT" | "STALE" | "MISS";
|
|
28
|
+
cacheState: "HIT" | "STALE" | "MISS";
|
|
29
|
+
/** Which router is making the decision. */
|
|
28
30
|
kind: IsrPolicyKind;
|
|
29
31
|
/**
|
|
30
32
|
* The route's configured revalidate window in seconds. Used as the fallback
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { markFullyBufferedBody } from "../shims/unified-request-context.js";
|
|
1
2
|
import { notFoundResponse } from "./http-error-responses.js";
|
|
2
3
|
import { isValidMetadataImageId, manifestToJson, matchMetadataRoutePattern, robotsToText, sitemapToXml } from "./metadata-routes.js";
|
|
3
4
|
//#region src/server/metadata-route-response.ts
|
|
@@ -115,10 +116,10 @@ async function handleGeneratedSitemap(route, cleanPathname, functions) {
|
|
|
115
116
|
const result = await functions.defaultExport({ id: makeThenableMetadataRouteId(matchedId) });
|
|
116
117
|
if (result instanceof Response) return withMetadataRouteCacheHeader(result, route);
|
|
117
118
|
if (!isSitemapEntries(result)) throw new TypeError("Metadata sitemap routes must return an array.");
|
|
118
|
-
return new Response(sitemapToXml(result), { headers: {
|
|
119
|
+
return markFullyBufferedBody(new Response(sitemapToXml(result), { headers: {
|
|
119
120
|
"Content-Type": route.contentType,
|
|
120
121
|
"Cache-Control": metadataRouteCacheHeader(route)
|
|
121
|
-
} });
|
|
122
|
+
} }));
|
|
122
123
|
}
|
|
123
124
|
function findGeneratedImageId(imageMetadata, imageId, servedUrl) {
|
|
124
125
|
if (!Array.isArray(imageMetadata)) return null;
|
|
@@ -163,10 +164,10 @@ async function callDynamicMetadataRoute(route, match, makeThenableParams, functi
|
|
|
163
164
|
body = manifestToJson(result);
|
|
164
165
|
} else if (isImageMetadataRoute(route)) throw new TypeError(`Dynamic metadata ${route.type} route ${route.servedUrl} must return a Response.`);
|
|
165
166
|
else body = JSON.stringify(result);
|
|
166
|
-
return new Response(body, { headers: {
|
|
167
|
+
return markFullyBufferedBody(new Response(body, { headers: {
|
|
167
168
|
"Content-Type": route.contentType,
|
|
168
169
|
"Cache-Control": metadataRouteCacheHeader(route)
|
|
169
|
-
} });
|
|
170
|
+
} }));
|
|
170
171
|
}
|
|
171
172
|
function serveStaticMetadataRoute(route) {
|
|
172
173
|
if (typeof route.fileDataBase64 !== "string") throw new Error(`[vinext] Static metadata route ${route.servedUrl} is missing embedded file data.`);
|
|
@@ -174,10 +175,10 @@ function serveStaticMetadataRoute(route) {
|
|
|
174
175
|
const binary = atob(route.fileDataBase64);
|
|
175
176
|
const bytes = new Uint8Array(binary.length);
|
|
176
177
|
for (let index = 0; index < binary.length; index++) bytes[index] = binary.charCodeAt(index);
|
|
177
|
-
return new Response(bytes, { headers: {
|
|
178
|
+
return markFullyBufferedBody(new Response(bytes, { headers: {
|
|
178
179
|
"Content-Type": route.contentType,
|
|
179
180
|
"Cache-Control": metadataRouteCacheHeader(route)
|
|
180
|
-
} });
|
|
181
|
+
} }));
|
|
181
182
|
} catch (error) {
|
|
182
183
|
const reason = error instanceof Error && error.message ? `: ${error.message}` : "";
|
|
183
184
|
throw new Error(`[vinext] Failed to decode embedded metadata route file data for ${route.servedUrl}${reason}`, { cause: error });
|