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
package/dist/index.js
CHANGED
|
@@ -6,11 +6,14 @@ import { hasBasePath, stripBasePath } from "./utils/base-path.js";
|
|
|
6
6
|
import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./routing/pages-router.js";
|
|
7
7
|
import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
|
|
8
8
|
import { INTERNAL_HEADERS, NEXTJS_DEPLOYMENT_ID_HEADER, VINEXT_INTERNAL_HEADERS, VINEXT_TIMING_HEADER } from "./server/headers.js";
|
|
9
|
+
import { encodeMiddlewareRequestHeaders } from "./utils/middleware-request-headers.js";
|
|
9
10
|
import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
|
|
10
11
|
import { matchesRewriteSource, proxyExternalRequest } from "./config/config-matchers.js";
|
|
11
12
|
import { validateMiddlewareMatcherPatterns } from "./server/middleware-matcher-pattern.js";
|
|
13
|
+
import { methodNotAllowedResponse } from "./server/http-error-responses.js";
|
|
12
14
|
import { isOpenRedirectShaped } from "./server/open-redirect.js";
|
|
13
15
|
import { canonicalizeRequestUrlPathname, filterInternalHeaders, normalizeTrailingSlash } from "./server/request-pipeline.js";
|
|
16
|
+
import { resolvePagesI18nRequest, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
|
|
14
17
|
import { findMiddlewareFile, isProxyFile, runMiddleware } from "./server/middleware.js";
|
|
15
18
|
import { extractMiddlewareMatcherConfig, extractMiddlewareMatcherConfigValue, hasExportedName } from "./build/report.js";
|
|
16
19
|
import { generateServerEntry } from "./entries/pages-server-entry.js";
|
|
@@ -19,8 +22,7 @@ import { appRouteGraph, appRouter, invalidateAppRouteCache, matchAppRoute } from
|
|
|
19
22
|
import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
|
|
20
23
|
import { isUnknownRecord } from "./utils/record.js";
|
|
21
24
|
import { logRequest, now } from "./server/request-log.js";
|
|
22
|
-
import {
|
|
23
|
-
import { encodeUrlParserIgnoredCharacters, isNextDataPathname, normalizeNextDataPagePathname, parseNextDataPathname, urlParserCreatesPagesDataPath } from "./server/pages-data-route.js";
|
|
25
|
+
import { encodeUrlParserIgnoredCharacters, isNextDataPathname, normalizeNextDataPagePathname, parseNextDataPathname, shouldAddTrailingSlashToPagesDataPath, urlParserCreatesPagesDataPath } from "./server/pages-data-route.js";
|
|
24
26
|
import { resolveAssetsDir } from "./utils/asset-prefix.js";
|
|
25
27
|
import { getPagesPreviewModeId } from "./server/pages-preview.js";
|
|
26
28
|
import { createSSRHandler } from "./server/dev-server.js";
|
|
@@ -41,6 +43,7 @@ import { planRouteClassificationInjection } from "./build/route-classification-i
|
|
|
41
43
|
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
|
|
42
44
|
import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
|
|
43
45
|
import { VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
|
|
46
|
+
import { loadDotenv } from "./config/dotenv.js";
|
|
44
47
|
import { mergeServerExternalPackages } from "./config/server-external-packages.js";
|
|
45
48
|
import { precompressAssets } from "./build/precompress.js";
|
|
46
49
|
import { ensureAssetsIgnore } from "./build/assets-ignore.js";
|
|
@@ -51,6 +54,7 @@ import { installDevStackSourcemapMiddleware } from "./server/dev-stack-sourcemap
|
|
|
51
54
|
import { runPagesRequest } from "./server/pages-request-pipeline.js";
|
|
52
55
|
import { pagesRouteHasPriorityOverAppRoute, validateHybridRouteConflicts } from "./server/hybrid-route-priority.js";
|
|
53
56
|
import { VIRTUAL_MODULE_ID_RE } from "./utils/virtual-module.js";
|
|
57
|
+
import { assertNoPublicDirAssetConflict, assertNoPublicNextRequestConflict } from "./build/public-dir-conflict.js";
|
|
54
58
|
import { renderVinextBuiltUrl } from "./utils/built-asset-url.js";
|
|
55
59
|
import { asyncHooksStubPlugin } from "./plugins/async-hooks-stub.js";
|
|
56
60
|
import { clientReferenceDedupPlugin } from "./plugins/client-reference-dedup.js";
|
|
@@ -79,17 +83,18 @@ import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./bui
|
|
|
79
83
|
import { createModuleDependencyCache } from "./build/module-dependency-cache.js";
|
|
80
84
|
import { resolvePostcssStringPlugins } from "./plugins/postcss.js";
|
|
81
85
|
import { markCssUrlAssetReferences, restoreDedupedCssAssetReferences } from "./build/css-url-assets.js";
|
|
82
|
-
import { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter } from "./plugins/sass.js";
|
|
86
|
+
import { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter, createSassTsconfigPathImporters } from "./plugins/sass.js";
|
|
83
87
|
import { createClientAssetFileNames, createClientCodeSplittingConfig, createClientFileNameConfig, createClientManualChunks, createRscFrameworkChunkOutputConfig, getBuildBundlerOptions, getClientTreeshakeConfig, withBuildBundlerOptions } from "./build/client-build-config.js";
|
|
84
88
|
import { hasExportAllCandidate, stripServerExports, validatePageExports } from "./plugins/strip-server-exports.js";
|
|
85
89
|
import { removeConsoleCalls } from "./plugins/remove-console.js";
|
|
86
90
|
import { createImportMetaUrlPlugin } from "./plugins/import-meta-url.js";
|
|
87
|
-
import { createTransformCache } from "./plugins/transform-cache.js";
|
|
88
91
|
import { createRequireContextPlugin } from "./plugins/require-context.js";
|
|
92
|
+
import { createTransformCache } from "./plugins/transform-cache.js";
|
|
89
93
|
import { createExtensionlessDynamicImportPlugin } from "./plugins/extensionless-dynamic-import.js";
|
|
90
94
|
import { createWasmModuleImportPlugin } from "./plugins/wasm-module-import.js";
|
|
91
95
|
import { getTypeofWindowReplacement, replaceTypeofWindow } from "./plugins/typeof-window.js";
|
|
92
96
|
import { hasMdxFiles } from "./utils/mdx-scan.js";
|
|
97
|
+
import { publicFilePathVariants } from "./utils/public-file-path.js";
|
|
93
98
|
import { scanPublicFileRoutes } from "./utils/public-routes.js";
|
|
94
99
|
import { createIgnoreDynamicRequestsPlugin } from "./plugins/ignore-dynamic-requests.js";
|
|
95
100
|
import { assertSupportedViteVersion, getDepOptimizeNodeEnvOptions, serializeViteDefine } from "./utils/vite-version.js";
|
|
@@ -97,7 +102,7 @@ import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGI
|
|
|
97
102
|
import { staticExportApp, staticExportPages } from "./build/static-export.js";
|
|
98
103
|
import { createRequire } from "node:module";
|
|
99
104
|
import fs from "node:fs";
|
|
100
|
-
import { createLogger,
|
|
105
|
+
import { createLogger, parseAst, transformWithOxc } from "vite";
|
|
101
106
|
import { pathToFileURL } from "node:url";
|
|
102
107
|
import { createHash, randomBytes } from "node:crypto";
|
|
103
108
|
import commonjs from "vite-plugin-commonjs";
|
|
@@ -408,23 +413,45 @@ function resolveTsconfigExtends(configPath, specifier) {
|
|
|
408
413
|
} catch {}
|
|
409
414
|
return null;
|
|
410
415
|
}
|
|
416
|
+
function mergeSassTsconfigPathAliases(...groups) {
|
|
417
|
+
const merged = /* @__PURE__ */ new Map();
|
|
418
|
+
for (const group of groups) for (const alias of group) merged.set(alias.find, alias);
|
|
419
|
+
return [...merged.values()];
|
|
420
|
+
}
|
|
421
|
+
function hasZeroOrOneAsterisk(value) {
|
|
422
|
+
const first = value.indexOf("*");
|
|
423
|
+
return first < 0 || first === value.lastIndexOf("*");
|
|
424
|
+
}
|
|
411
425
|
function materializeTsconfigPathAliases(pathsConfig, baseUrl, projectRoot) {
|
|
412
|
-
const
|
|
426
|
+
const vite = {};
|
|
427
|
+
const sass = [];
|
|
413
428
|
for (const [find, rawTargets] of Object.entries(pathsConfig)) {
|
|
414
|
-
const
|
|
415
|
-
if (
|
|
429
|
+
const targets = Array.isArray(rawTargets) ? rawTargets.filter((value) => typeof value === "string") : typeof rawTargets === "string" ? [rawTargets] : [];
|
|
430
|
+
if (targets.length === 0) continue;
|
|
431
|
+
if (find.length > 0 && hasZeroOrOneAsterisk(find)) {
|
|
432
|
+
const findHasStar = find.includes("*");
|
|
433
|
+
const replacements = targets.filter((target) => target.length > 0 && hasZeroOrOneAsterisk(target) && (findHasStar || !target.includes("*"))).map((target) => path.resolve(baseUrl, target));
|
|
434
|
+
if (replacements.length > 0) sass.push({
|
|
435
|
+
find,
|
|
436
|
+
replacements
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
const target = targets[0];
|
|
416
440
|
if (find.includes("*") || target.includes("*")) {
|
|
417
441
|
if (!find.endsWith("/*") || !target.endsWith("/*")) continue;
|
|
418
442
|
if (find.indexOf("*") !== find.length - 1 || target.indexOf("*") !== target.length - 1) continue;
|
|
419
443
|
const aliasKey = find.slice(0, -2);
|
|
420
444
|
const targetDir = target.slice(0, -2);
|
|
421
445
|
if (!aliasKey || !targetDir) continue;
|
|
422
|
-
|
|
446
|
+
vite[aliasKey] = toViteAliasReplacement(path.resolve(baseUrl, targetDir), projectRoot);
|
|
423
447
|
continue;
|
|
424
448
|
}
|
|
425
|
-
|
|
449
|
+
vite[find] = toViteAliasReplacement(path.resolve(baseUrl, target), projectRoot);
|
|
426
450
|
}
|
|
427
|
-
return
|
|
451
|
+
return {
|
|
452
|
+
vite,
|
|
453
|
+
sass
|
|
454
|
+
};
|
|
428
455
|
}
|
|
429
456
|
function toViteAliasReplacement(absolutePath, projectRoot) {
|
|
430
457
|
const normalizedPath = toSlash(absolutePath);
|
|
@@ -457,31 +484,52 @@ function resolveSwcHelpersAlias(root) {
|
|
|
457
484
|
}
|
|
458
485
|
function loadTsconfigPathAliases(configPath, projectRoot, seen = /* @__PURE__ */ new Set()) {
|
|
459
486
|
const normalizedPath = tryRealpathSync(configPath) ?? configPath;
|
|
460
|
-
if (seen.has(normalizedPath)) return {
|
|
487
|
+
if (seen.has(normalizedPath)) return {
|
|
488
|
+
vite: {},
|
|
489
|
+
sass: []
|
|
490
|
+
};
|
|
461
491
|
seen.add(normalizedPath);
|
|
462
492
|
let parsed = null;
|
|
463
493
|
try {
|
|
464
494
|
parsed = parseStaticObjectLiteral(fs.readFileSync(normalizedPath, "utf-8"));
|
|
465
495
|
} catch {
|
|
466
|
-
return {
|
|
496
|
+
return {
|
|
497
|
+
vite: {},
|
|
498
|
+
sass: []
|
|
499
|
+
};
|
|
467
500
|
}
|
|
468
|
-
if (!parsed) return {
|
|
469
|
-
|
|
501
|
+
if (!parsed) return {
|
|
502
|
+
vite: {},
|
|
503
|
+
sass: []
|
|
504
|
+
};
|
|
505
|
+
let aliases = {
|
|
506
|
+
vite: {},
|
|
507
|
+
sass: []
|
|
508
|
+
};
|
|
470
509
|
for (const extendsSpecifier of normalizeTsconfigExtends(parsed.extends)) {
|
|
471
510
|
const extendedPath = resolveTsconfigExtends(normalizedPath, extendsSpecifier);
|
|
472
|
-
if (extendedPath)
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
511
|
+
if (extendedPath) {
|
|
512
|
+
const parent = loadTsconfigPathAliases(extendedPath, projectRoot, seen);
|
|
513
|
+
aliases = {
|
|
514
|
+
vite: {
|
|
515
|
+
...aliases.vite,
|
|
516
|
+
...parent.vite
|
|
517
|
+
},
|
|
518
|
+
sass: mergeSassTsconfigPathAliases(aliases.sass, parent.sass)
|
|
519
|
+
};
|
|
520
|
+
}
|
|
476
521
|
}
|
|
477
522
|
const compilerOptions = isUnknownRecord(parsed.compilerOptions) ? parsed.compilerOptions : null;
|
|
478
523
|
const pathsConfig = compilerOptions && isUnknownRecord(compilerOptions.paths) ? compilerOptions.paths : null;
|
|
479
524
|
if (!pathsConfig) return aliases;
|
|
480
525
|
const baseUrl = compilerOptions && typeof compilerOptions.baseUrl === "string" ? compilerOptions.baseUrl : ".";
|
|
481
|
-
const
|
|
526
|
+
const own = materializeTsconfigPathAliases(pathsConfig, path.resolve(path.dirname(normalizedPath), baseUrl), projectRoot);
|
|
482
527
|
return {
|
|
483
|
-
|
|
484
|
-
|
|
528
|
+
vite: {
|
|
529
|
+
...aliases.vite,
|
|
530
|
+
...own.vite
|
|
531
|
+
},
|
|
532
|
+
sass: mergeSassTsconfigPathAliases(aliases.sass, own.sass)
|
|
485
533
|
};
|
|
486
534
|
}
|
|
487
535
|
/**
|
|
@@ -538,10 +586,17 @@ function resolveTsconfigAliases(projectRoot, configuredPath) {
|
|
|
538
586
|
const configPath = configuredPath ? path.resolve(projectRoot, configuredPath) : void 0;
|
|
539
587
|
const cacheKey = configPath ?? projectRoot;
|
|
540
588
|
if (_tsconfigAliasCache.has(cacheKey)) return _tsconfigAliasCache.get(cacheKey);
|
|
541
|
-
let aliases = {
|
|
589
|
+
let aliases = {
|
|
590
|
+
vite: {},
|
|
591
|
+
sass: []
|
|
592
|
+
};
|
|
542
593
|
for (const candidate of configPath ? [configPath] : TSCONFIG_FILES.map((name) => path.join(projectRoot, name))) {
|
|
543
594
|
if (!fs.existsSync(candidate)) continue;
|
|
544
|
-
|
|
595
|
+
const materialized = loadTsconfigPathAliases(candidate, projectRoot);
|
|
596
|
+
aliases = {
|
|
597
|
+
vite: sortTsconfigAliasesBySpecificity(materialized.vite),
|
|
598
|
+
sass: materialized.sass
|
|
599
|
+
};
|
|
545
600
|
break;
|
|
546
601
|
}
|
|
547
602
|
_tsconfigAliasCache.set(cacheKey, aliases);
|
|
@@ -773,6 +828,8 @@ function vinext(options = {}) {
|
|
|
773
828
|
let pagesOptimizeEntries = [];
|
|
774
829
|
const pagesClientAssetsOutputDirs = /* @__PURE__ */ new Set();
|
|
775
830
|
let pagesClientAssetsModule = null;
|
|
831
|
+
let devPublicFileRoutes = null;
|
|
832
|
+
let publicDirConflictOptions = null;
|
|
776
833
|
let rscCompatibilityId;
|
|
777
834
|
let draftModeSecret = getPagesPreviewModeId();
|
|
778
835
|
let previewBuildCredentials;
|
|
@@ -803,8 +860,9 @@ function vinext(options = {}) {
|
|
|
803
860
|
* Generate the virtual SSR server entry module.
|
|
804
861
|
* This is the entry point for `vite build --ssr`.
|
|
805
862
|
*/
|
|
806
|
-
async function generateServerEntry$1() {
|
|
807
|
-
|
|
863
|
+
async function generateServerEntry$1(configuredPublicDir) {
|
|
864
|
+
const publicFiles = isServeCommand && devPublicFileRoutes ? [...devPublicFileRoutes].sort() : scanPublicFileRoutes(root, configuredPublicDir === "" ? false : configuredPublicDir);
|
|
865
|
+
return generateServerEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath, publicFiles);
|
|
808
866
|
}
|
|
809
867
|
/**
|
|
810
868
|
* Generate the virtual client hydration entry module.
|
|
@@ -984,7 +1042,7 @@ function vinext(options = {}) {
|
|
|
984
1042
|
transform: {
|
|
985
1043
|
filter: { id: /\.m?js(?:\?.*)?$/ },
|
|
986
1044
|
async handler(code, id) {
|
|
987
|
-
const cleanId = id
|
|
1045
|
+
const cleanId = toSlash(stripViteModuleQuery(id));
|
|
988
1046
|
if (isInsideDirectory(__dirname, cleanId)) return;
|
|
989
1047
|
if (cleanId.includes("/node_modules/")) {
|
|
990
1048
|
if (!code.includes("use client") && !code.includes("use server")) return;
|
|
@@ -1030,13 +1088,16 @@ function vinext(options = {}) {
|
|
|
1030
1088
|
root = toSlash(config.root ?? process.cwd());
|
|
1031
1089
|
const userResolve = config.resolve;
|
|
1032
1090
|
let tsconfigPathAliases = {};
|
|
1091
|
+
let sassTsconfigPathAliases = [];
|
|
1033
1092
|
const swcHelpersAlias = resolveSwcHelpersAlias(root);
|
|
1034
1093
|
const mode = env?.mode ?? "development";
|
|
1035
|
-
|
|
1036
|
-
|
|
1094
|
+
if (config.envDir !== false) loadDotenv({
|
|
1095
|
+
root: config.envDir ?? root,
|
|
1096
|
+
mode
|
|
1097
|
+
});
|
|
1037
1098
|
let resolvedNodeEnv;
|
|
1038
|
-
if (
|
|
1039
|
-
else if (
|
|
1099
|
+
if (env?.command === "build" || env?.isPreview === true) resolvedNodeEnv = "production";
|
|
1100
|
+
else if (mode === "test") resolvedNodeEnv = "test";
|
|
1040
1101
|
else resolvedNodeEnv = "development";
|
|
1041
1102
|
if (process.env.NODE_ENV !== resolvedNodeEnv) Reflect.set(process.env, "NODE_ENV", resolvedNodeEnv);
|
|
1042
1103
|
if (env?.command === "build") previewBuildCredentials = getPreviewBuildCredentials() ?? createPreviewBuildCredentials();
|
|
@@ -1078,7 +1139,9 @@ function vinext(options = {}) {
|
|
|
1078
1139
|
};
|
|
1079
1140
|
}
|
|
1080
1141
|
const configuredTsconfigPath = isUnknownRecord(nextConfig.typescript) ? typeof nextConfig.typescript.tsconfigPath === "string" ? nextConfig.typescript.tsconfigPath : void 0 : void 0;
|
|
1081
|
-
|
|
1142
|
+
const resolvedTsconfigAliases = resolveTsconfigAliases(root, configuredTsconfigPath);
|
|
1143
|
+
tsconfigPathAliases = resolvedTsconfigAliases.vite;
|
|
1144
|
+
sassTsconfigPathAliases = resolvedTsconfigAliases.sass;
|
|
1082
1145
|
const shouldAutoEnableNativeTsconfigPaths = userResolve?.tsconfigPaths === void 0 && configuredTsconfigPath === void 0;
|
|
1083
1146
|
if (Object.keys(tsconfigPathAliases).length > 0) config.customLogger = suppressAliasCustomResolverDeprecationWarning(config.customLogger ?? createLogger(config.logLevel, { allowClearScreen: config.clearScreen }));
|
|
1084
1147
|
if (rscCompatibilityId === void 0) {
|
|
@@ -1118,6 +1181,7 @@ function vinext(options = {}) {
|
|
|
1118
1181
|
defines["process.env.__VINEXT_PREFETCH_INLINING"] = JSON.stringify(nextConfig.prefetchInlining ? "true" : "false");
|
|
1119
1182
|
defines["process.env.__NEXT_GESTURE_TRANSITION"] = JSON.stringify(nextConfig.gestureTransition);
|
|
1120
1183
|
defines["process.env.__NEXT_APP_NAV_FAIL_HANDLING"] = JSON.stringify(nextConfig.appNavFailHandling);
|
|
1184
|
+
defines["process.env.__NEXT_TEST_MODE"] = JSON.stringify(process.env.__NEXT_TEST_MODE ?? false);
|
|
1121
1185
|
defines["process.env.__NEXT_SCROLL_RESTORATION"] = JSON.stringify(nextConfig.scrollRestoration ? "true" : "false");
|
|
1122
1186
|
defines["process.env.__VINEXT_TRAILING_SLASH"] = JSON.stringify(nextConfig.trailingSlash ? "true" : "false");
|
|
1123
1187
|
defines["process.env.__VINEXT_IMAGE_REMOTE_PATTERNS"] = JSON.stringify(JSON.stringify(nextConfig.images?.remotePatterns ?? []));
|
|
@@ -1133,16 +1197,7 @@ function vinext(options = {}) {
|
|
|
1133
1197
|
2048,
|
|
1134
1198
|
3840
|
|
1135
1199
|
];
|
|
1136
|
-
const imageSizes = nextConfig.images?.imageSizes ??
|
|
1137
|
-
16,
|
|
1138
|
-
32,
|
|
1139
|
-
48,
|
|
1140
|
-
64,
|
|
1141
|
-
96,
|
|
1142
|
-
128,
|
|
1143
|
-
256,
|
|
1144
|
-
384
|
|
1145
|
-
];
|
|
1200
|
+
const imageSizes = nextConfig.images?.imageSizes ?? DEFAULT_IMAGE_SIZES;
|
|
1146
1201
|
defines["process.env.__VINEXT_IMAGE_DEVICE_SIZES"] = JSON.stringify(JSON.stringify(deviceSizes));
|
|
1147
1202
|
defines["process.env.__VINEXT_IMAGE_SIZES"] = JSON.stringify(JSON.stringify(imageSizes));
|
|
1148
1203
|
defines["process.env.__VINEXT_IMAGE_QUALITIES"] = JSON.stringify(JSON.stringify(nextConfig.images?.qualities ?? null));
|
|
@@ -1192,6 +1247,7 @@ function vinext(options = {}) {
|
|
|
1192
1247
|
"vinext/head-state": path.join(shimsDir, "head-state"),
|
|
1193
1248
|
"vinext/i18n-state": path.join(shimsDir, "i18n-state"),
|
|
1194
1249
|
"vinext/i18n-context": path.join(shimsDir, "i18n-context"),
|
|
1250
|
+
"vinext/client": path.resolve(__dirname, "client", "index"),
|
|
1195
1251
|
"vinext/cache": path.resolve(__dirname, "cache"),
|
|
1196
1252
|
"vinext/instrumentation": path.resolve(__dirname, "server", "instrumentation"),
|
|
1197
1253
|
"vinext/instrumentation-client": path.resolve(__dirname, "client", "instrumentation-client"),
|
|
@@ -1306,8 +1362,11 @@ function vinext(options = {}) {
|
|
|
1306
1362
|
...postcssOverride ? { postcss: postcssOverride } : {},
|
|
1307
1363
|
preprocessorOptions: (() => {
|
|
1308
1364
|
const tildeImporter = createSassTildeImporter(root);
|
|
1365
|
+
const tsconfigPathImporters = createSassTsconfigPathImporters(sassTsconfigPathAliases);
|
|
1309
1366
|
const cssUrlAssetImporter = env.command === "build" ? createSassCssUrlAssetImporter() : null;
|
|
1310
1367
|
const userAdditionalData = sassPreprocessorOptions?.additionalData;
|
|
1368
|
+
const rawUserImporters = sassPreprocessorOptions?.importers;
|
|
1369
|
+
const userImporters = Array.isArray(rawUserImporters) ? rawUserImporters : rawUserImporters == null ? [] : [rawUserImporters];
|
|
1311
1370
|
const baseOpts = {
|
|
1312
1371
|
...sassPreprocessorOptions,
|
|
1313
1372
|
...cssUrlAssetImporter ? { additionalData: async (source, filename) => {
|
|
@@ -1317,7 +1376,8 @@ function vinext(options = {}) {
|
|
|
1317
1376
|
importers: [
|
|
1318
1377
|
tildeImporter,
|
|
1319
1378
|
...cssUrlAssetImporter ? [cssUrlAssetImporter] : [],
|
|
1320
|
-
...
|
|
1379
|
+
...userImporters,
|
|
1380
|
+
...tsconfigPathImporters
|
|
1321
1381
|
]
|
|
1322
1382
|
};
|
|
1323
1383
|
return {
|
|
@@ -1524,6 +1584,14 @@ function vinext(options = {}) {
|
|
|
1524
1584
|
sourcePath: path.relative(root, route.pagePath ?? route.routePath)
|
|
1525
1585
|
})));
|
|
1526
1586
|
}
|
|
1587
|
+
if (config.command === "build") {
|
|
1588
|
+
publicDirConflictOptions = {
|
|
1589
|
+
root: config.root,
|
|
1590
|
+
publicDir: config.publicDir === "" ? null : config.publicDir,
|
|
1591
|
+
assetsDir: config.environments?.client?.build?.assetsDir ?? config.build?.assetsDir ?? resolveAssetsDir(nextConfig.assetPrefix ?? "")
|
|
1592
|
+
};
|
|
1593
|
+
assertNoPublicDirAssetConflict(publicDirConflictOptions);
|
|
1594
|
+
}
|
|
1527
1595
|
if (hasAppDir) {
|
|
1528
1596
|
const ssrEnv = config.environments?.ssr;
|
|
1529
1597
|
if (ssrEnv?.resolve?.external === true && Array.isArray(ssrEnv.resolve.noExternal)) ssrEnv.resolve.noExternal = ssrEnv.resolve.noExternal.filter((entry) => typeof entry !== "string" || !SSR_EXTERNAL_REACT_ENTRIES.includes(entry));
|
|
@@ -1544,6 +1612,13 @@ function vinext(options = {}) {
|
|
|
1544
1612
|
configFile: config.configFile
|
|
1545
1613
|
}));
|
|
1546
1614
|
},
|
|
1615
|
+
renderStart: {
|
|
1616
|
+
order: "pre",
|
|
1617
|
+
handler() {
|
|
1618
|
+
if (this.environment?.name !== "client" || !publicDirConflictOptions) return;
|
|
1619
|
+
assertNoPublicDirAssetConflict(publicDirConflictOptions);
|
|
1620
|
+
}
|
|
1621
|
+
},
|
|
1547
1622
|
resolveId: {
|
|
1548
1623
|
filter: { id: /(?:next\/|vinext\/(?:shims\/|server\/app-rsc-handler)|virtual:vinext-|@vercel\/og(?:\.js)?$)/ },
|
|
1549
1624
|
handler(id, importer) {
|
|
@@ -1589,7 +1664,7 @@ function vinext(options = {}) {
|
|
|
1589
1664
|
filter: { id: /virtual:vinext-/ },
|
|
1590
1665
|
async handler(id) {
|
|
1591
1666
|
if (id === RESOLVED_WORKER_ENTRY) return `export { default } from ${JSON.stringify(hasAppDir ? "vinext/server/app-router-entry" : "vinext/server/pages-router-entry")};`;
|
|
1592
|
-
if (id === RESOLVED_SERVER_ENTRY) return await generateServerEntry$1();
|
|
1667
|
+
if (id === RESOLVED_SERVER_ENTRY) return await generateServerEntry$1(this.environment.config.publicDir === "" ? false : this.environment.config.publicDir);
|
|
1593
1668
|
if (id === RESOLVED_CLIENT_ENTRY) return await generateClientEntry$1();
|
|
1594
1669
|
if (id === RESOLVED_PAGES_CLIENT_ASSETS) {
|
|
1595
1670
|
const metadata = { clientEntry: DEV_PAGES_CLIENT_ENTRY };
|
|
@@ -1642,7 +1717,7 @@ function vinext(options = {}) {
|
|
|
1642
1717
|
contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy
|
|
1643
1718
|
},
|
|
1644
1719
|
hasPagesDir,
|
|
1645
|
-
publicFiles: scanPublicFileRoutes(root),
|
|
1720
|
+
publicFiles: isServeCommand && devPublicFileRoutes ? [...devPublicFileRoutes].sort() : scanPublicFileRoutes(root, this.environment.config.publicDir === "" ? false : this.environment.config.publicDir),
|
|
1646
1721
|
globalNotFoundPath,
|
|
1647
1722
|
draftModeSecret
|
|
1648
1723
|
}, instrumentationPath);
|
|
@@ -1902,6 +1977,19 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1902
1977
|
req.__vinextOriginalEncodedUrl ??= req.url;
|
|
1903
1978
|
next();
|
|
1904
1979
|
});
|
|
1980
|
+
server.middlewares.use((req, _res, next) => {
|
|
1981
|
+
try {
|
|
1982
|
+
assertNoPublicNextRequestConflict({
|
|
1983
|
+
root: server.config.root,
|
|
1984
|
+
publicDir: server.config.publicDir === "" ? null : server.config.publicDir,
|
|
1985
|
+
basePath: nextConfig.basePath ?? "",
|
|
1986
|
+
requestUrl: req.url ?? "/"
|
|
1987
|
+
});
|
|
1988
|
+
next();
|
|
1989
|
+
} catch (error) {
|
|
1990
|
+
next(error);
|
|
1991
|
+
}
|
|
1992
|
+
});
|
|
1905
1993
|
const pageExtensions = fileMatcher.extensionRegex;
|
|
1906
1994
|
let pagesRunner = null;
|
|
1907
1995
|
const getTrustedDevRevalidateOrigin = () => {
|
|
@@ -2050,7 +2138,32 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2050
2138
|
server.httpServer?.on("connection", (socket) => {
|
|
2051
2139
|
socket.on("error", () => {});
|
|
2052
2140
|
});
|
|
2141
|
+
const configuredPublicDir = server.config.publicDir === "" ? false : server.config.publicDir;
|
|
2142
|
+
const devPublicDir = configuredPublicDir === false ? null : path.resolve(toSlash(server.config.root), toSlash(configuredPublicDir));
|
|
2143
|
+
devPublicFileRoutes = new Set(scanPublicFileRoutes(root, configuredPublicDir));
|
|
2144
|
+
const publicRoutesForFile = (filePath) => {
|
|
2145
|
+
if (devPublicDir === null) return null;
|
|
2146
|
+
const cleanPath = toSlash(stripViteModuleQuery(filePath));
|
|
2147
|
+
const relativePath = path.relative(devPublicDir, cleanPath);
|
|
2148
|
+
if (relativePath === "" || relativePath.startsWith("../") || path.isAbsolute(relativePath)) return null;
|
|
2149
|
+
return publicFilePathVariants(`/${relativePath}`);
|
|
2150
|
+
};
|
|
2151
|
+
const updatePublicFileRoute = (filePath, present) => {
|
|
2152
|
+
const routes = publicRoutesForFile(filePath);
|
|
2153
|
+
if (routes === null || devPublicFileRoutes === null) return;
|
|
2154
|
+
let changed = false;
|
|
2155
|
+
for (const route of routes) {
|
|
2156
|
+
if (!(present ? !devPublicFileRoutes.has(route) : devPublicFileRoutes.has(route))) continue;
|
|
2157
|
+
changed = true;
|
|
2158
|
+
if (present) devPublicFileRoutes.add(route);
|
|
2159
|
+
else devPublicFileRoutes.delete(route);
|
|
2160
|
+
}
|
|
2161
|
+
if (!changed) return;
|
|
2162
|
+
if (hasAppDir) invalidateRscEntryModule();
|
|
2163
|
+
if (hasCloudflarePlugin && hasPagesDir && !hasAppDir) invalidatePagesServerEntry();
|
|
2164
|
+
};
|
|
2053
2165
|
server.watcher.on("add", (filePath) => {
|
|
2166
|
+
updatePublicFileRoute(filePath, true);
|
|
2054
2167
|
let routeChanged = false;
|
|
2055
2168
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
2056
2169
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
@@ -2077,6 +2190,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2077
2190
|
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2078
2191
|
});
|
|
2079
2192
|
server.watcher.on("unlink", (filePath) => {
|
|
2193
|
+
updatePublicFileRoute(filePath, false);
|
|
2080
2194
|
let routeChanged = false;
|
|
2081
2195
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
2082
2196
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
@@ -2097,6 +2211,23 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2097
2211
|
revalidateHybridRoutes();
|
|
2098
2212
|
}
|
|
2099
2213
|
});
|
|
2214
|
+
let handlePagesMiddleware = null;
|
|
2215
|
+
const isExistingDevPublicFile = (requestPathname) => devPublicFileRoutes?.has(requestPathname) === true;
|
|
2216
|
+
const isUnsupportedDevPublicRequest = (req, pathnameState = "pre-base") => {
|
|
2217
|
+
if (req.method === "GET" || req.method === "HEAD") return false;
|
|
2218
|
+
let pathname;
|
|
2219
|
+
try {
|
|
2220
|
+
pathname = normalizePathnameForRouteMatchStrict(new URL(req.url ?? "/", "http://vinext.invalid").pathname);
|
|
2221
|
+
} catch {
|
|
2222
|
+
return false;
|
|
2223
|
+
}
|
|
2224
|
+
const basePath = nextConfig?.basePath ?? "";
|
|
2225
|
+
if (pathnameState === "pre-base" && basePath) {
|
|
2226
|
+
if (!hasBasePath(pathname, basePath)) return false;
|
|
2227
|
+
pathname = stripBasePath(pathname, basePath);
|
|
2228
|
+
}
|
|
2229
|
+
return isExistingDevPublicFile(pathname);
|
|
2230
|
+
};
|
|
2100
2231
|
server.middlewares.use((req, res, next) => {
|
|
2101
2232
|
const blockReason = validateDevRequest({
|
|
2102
2233
|
origin: req.headers.origin,
|
|
@@ -2113,12 +2244,27 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2113
2244
|
}
|
|
2114
2245
|
next();
|
|
2115
2246
|
});
|
|
2247
|
+
server.middlewares.use((req, res, next) => {
|
|
2248
|
+
if (!hasPagesDir || !handlePagesMiddleware || !isUnsupportedDevPublicRequest(req)) return next();
|
|
2249
|
+
handlePagesMiddleware(req, res, next);
|
|
2250
|
+
});
|
|
2116
2251
|
installDevStackSourcemapMiddleware(server);
|
|
2117
2252
|
return () => {
|
|
2118
2253
|
const viteFilesystemMiddlewares = server.middlewares.stack.filter(({ handle }) => {
|
|
2119
2254
|
const name = typeof handle === "function" ? handle.name : "";
|
|
2120
2255
|
return name === "viteServePublicMiddleware" || name === "viteServeStaticMiddleware";
|
|
2121
2256
|
}).map(({ handle }) => handle).filter((handle) => typeof handle === "function");
|
|
2257
|
+
if (hasAppDir && !hasPagesDir || hasCloudflarePlugin) {
|
|
2258
|
+
const publicMiddlewareEntry = server.middlewares.stack.find(({ handle }) => typeof handle === "function" && handle.name === "viteServePublicMiddleware");
|
|
2259
|
+
const viteServePublic = publicMiddlewareEntry?.handle;
|
|
2260
|
+
if (publicMiddlewareEntry && viteServePublic) {
|
|
2261
|
+
const vinextServePublicMiddleware = (req, res, next) => {
|
|
2262
|
+
if (isUnsupportedDevPublicRequest(req, "post-base")) return next();
|
|
2263
|
+
return viteServePublic(req, res, next);
|
|
2264
|
+
};
|
|
2265
|
+
publicMiddlewareEntry.handle = vinextServePublicMiddleware;
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2122
2268
|
const serveRewrittenViteFilesystemRoute = async (req, res, requestPathname, stagedHeaders) => {
|
|
2123
2269
|
const originalUrl = req.url;
|
|
2124
2270
|
const originalStatusCode = res.statusCode;
|
|
@@ -2213,7 +2359,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2213
2359
|
});
|
|
2214
2360
|
next();
|
|
2215
2361
|
});
|
|
2216
|
-
|
|
2362
|
+
handlePagesMiddleware = async (req, res, next) => {
|
|
2217
2363
|
try {
|
|
2218
2364
|
let url = req.url ?? "/";
|
|
2219
2365
|
const originalRequestUrl = url;
|
|
@@ -2245,17 +2391,6 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2245
2391
|
const requestHost = revalidationHostname ?? ((Array.isArray(req.headers.host) ? req.headers.host[0] : req.headers.host) || "localhost");
|
|
2246
2392
|
const requestOrigin = `http://${requestHost}`;
|
|
2247
2393
|
const getUrlHostname = (requestUrl) => new URL(requestUrl).hostname;
|
|
2248
|
-
if (isImageOptimizationPath(url.split("?")[0])) {
|
|
2249
|
-
const encodedLocation = resolveDevImageRedirect(new URL(url, requestOrigin), [...nextConfig.images?.deviceSizes ?? DEFAULT_DEVICE_SIZES, ...nextConfig.images?.imageSizes ?? DEFAULT_IMAGE_SIZES], nextConfig.images?.qualities);
|
|
2250
|
-
if (!encodedLocation) {
|
|
2251
|
-
res.writeHead(400);
|
|
2252
|
-
res.end("Invalid image optimization parameters");
|
|
2253
|
-
return;
|
|
2254
|
-
}
|
|
2255
|
-
res.writeHead(302, { Location: encodedLocation });
|
|
2256
|
-
res.end();
|
|
2257
|
-
return;
|
|
2258
|
-
}
|
|
2259
2394
|
const originalEncodedUrl = req.__vinextOriginalEncodedUrl ?? url;
|
|
2260
2395
|
const originalEncodedPathname = originalEncodedUrl.split("?")[0];
|
|
2261
2396
|
if (isOpenRedirectShaped(originalEncodedPathname)) {
|
|
@@ -2334,15 +2469,16 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2334
2469
|
}
|
|
2335
2470
|
if (hasCloudflarePlugin) return next();
|
|
2336
2471
|
let isDataReq = false;
|
|
2472
|
+
let dataNotFoundResponse = null;
|
|
2337
2473
|
if (isNextDataPathname(pathname)) {
|
|
2338
2474
|
const devBuildId = nextConfig?.buildId ?? process.env.__VINEXT_BUILD_ID ?? "development";
|
|
2339
2475
|
const dataMatch = parseNextDataPathname(pathname, devBuildId);
|
|
2340
2476
|
if (dataMatch) {
|
|
2341
2477
|
isDataReq = true;
|
|
2342
2478
|
const qs = url.includes("?") ? url.slice(url.indexOf("?")) : "";
|
|
2343
|
-
const pagePathname = normalizeNextDataPagePathname(dataMatch.pagePathname, capturedMiddlewarePath !== null
|
|
2479
|
+
const pagePathname = normalizeNextDataPagePathname(dataMatch.pagePathname, shouldAddTrailingSlashToPagesDataPath(capturedMiddlewarePath !== null, nextConfig?.trailingSlash === true, nextConfig?.skipProxyUrlNormalize === true));
|
|
2344
2480
|
url = pagePathname + qs;
|
|
2345
|
-
middlewareUrl = url;
|
|
2481
|
+
if (!nextConfig?.skipProxyUrlNormalize) middlewareUrl = url;
|
|
2346
2482
|
routeUrl = url;
|
|
2347
2483
|
pathname = pagePathname;
|
|
2348
2484
|
configMatchPathname = pagePathname;
|
|
@@ -2351,9 +2487,16 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2351
2487
|
const deploymentId = process.env.__VINEXT_DEPLOYMENT_ID || process.env.NEXT_DEPLOYMENT_ID;
|
|
2352
2488
|
const notFoundHeaders = { "Content-Type": "application/json" };
|
|
2353
2489
|
if (deploymentId) notFoundHeaders[NEXTJS_DEPLOYMENT_ID_HEADER] = deploymentId;
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2490
|
+
if (!nextConfig?.skipProxyUrlNormalize) {
|
|
2491
|
+
res.writeHead(404, notFoundHeaders);
|
|
2492
|
+
res.end("{}");
|
|
2493
|
+
return;
|
|
2494
|
+
}
|
|
2495
|
+
isDataReq = true;
|
|
2496
|
+
dataNotFoundResponse = new Response("{}", {
|
|
2497
|
+
status: 404,
|
|
2498
|
+
headers: notFoundHeaders
|
|
2499
|
+
});
|
|
2357
2500
|
}
|
|
2358
2501
|
}
|
|
2359
2502
|
const filePathMatchesRewrite = [
|
|
@@ -2365,15 +2508,16 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2365
2508
|
hadBasePath: true
|
|
2366
2509
|
}));
|
|
2367
2510
|
const isFilePathRequest = pathname.includes(".") && !pathname.endsWith(".html");
|
|
2511
|
+
const isExistingPublicMutation = req.method !== "GET" && req.method !== "HEAD" && isExistingDevPublicFile(pathname);
|
|
2368
2512
|
let filePathMatchesPagesRoute = false;
|
|
2369
2513
|
const requestHostname = getUrlHostname(requestOrigin);
|
|
2370
|
-
if (isFilePathRequest && !filePathMatchesRewrite) {
|
|
2514
|
+
if (isFilePathRequest && !filePathMatchesRewrite && !isDataReq) {
|
|
2371
2515
|
const [pageRoutes, apiRoutes] = await Promise.all([pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher), apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher)]);
|
|
2372
2516
|
const pageRouteUrl = nextConfig?.i18n ? resolvePagesI18nRequest(pathname, nextConfig.i18n, req.headers, requestHostname, bp, nextConfig.trailingSlash ?? false).url : pathname;
|
|
2373
2517
|
const apiRouteUrl = stripI18nLocaleForApiRoute(pathname, nextConfig?.i18n ?? null);
|
|
2374
2518
|
filePathMatchesPagesRoute = matchRoute(pageRouteUrl, pageRoutes) !== null || matchRoute(apiRouteUrl, apiRoutes) !== null;
|
|
2375
2519
|
}
|
|
2376
|
-
if (isFilePathRequest && !filePathMatchesRewrite && !filePathMatchesPagesRoute) return next();
|
|
2520
|
+
if (isFilePathRequest && !isDataReq && !filePathMatchesRewrite && !filePathMatchesPagesRoute && !isExistingPublicMutation) return next();
|
|
2377
2521
|
const rawHeaders = new Headers(Object.fromEntries(Object.entries(req.headers).filter(([k, v]) => v !== void 0 && !k.startsWith(":")).map(([k, v]) => [k, Array.isArray(v) ? v.join(", ") : String(v)])));
|
|
2378
2522
|
const isDataRequest = isDataReq;
|
|
2379
2523
|
const nodeRequestHeaders = filterInternalHeaders(rawHeaders);
|
|
@@ -2412,6 +2556,10 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2412
2556
|
return result;
|
|
2413
2557
|
} : null;
|
|
2414
2558
|
const devPageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
2559
|
+
let devApiRoutesPromise = null;
|
|
2560
|
+
const getDevApiRoutes = () => devApiRoutesPromise ??= apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
2561
|
+
let devAppRoutesPromise = null;
|
|
2562
|
+
const getDevAppRoutes = () => devAppRoutesPromise ??= hasAppDir && appDir ? appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : Promise.resolve([]);
|
|
2415
2563
|
const devPageRouteDataKinds = /* @__PURE__ */ new Map();
|
|
2416
2564
|
const classifyDevPageRoute = (route) => {
|
|
2417
2565
|
const cached = devPageRouteDataKinds.get(route.filePath);
|
|
@@ -2439,9 +2587,15 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2439
2587
|
isDataReq,
|
|
2440
2588
|
isDataRequest,
|
|
2441
2589
|
hasMiddleware: capturedMiddlewarePath !== null,
|
|
2590
|
+
dataNotFoundResponse,
|
|
2442
2591
|
rawSearch: url.includes("?") ? url.slice(url.indexOf("?")) : "",
|
|
2443
2592
|
configMatchPathname,
|
|
2444
2593
|
runMiddleware: devRunMiddlewareAdapter,
|
|
2594
|
+
matchApiRoute: async (apiUrl) => {
|
|
2595
|
+
const pagesMatch = matchRoute(apiUrl, await getDevApiRoutes());
|
|
2596
|
+
if (pagesMatch) return pagesMatch;
|
|
2597
|
+
return matchAppRoute(apiUrl, await getDevAppRoutes());
|
|
2598
|
+
},
|
|
2445
2599
|
matchPageRoute: (resolvedPathname, request) => {
|
|
2446
2600
|
const m = matchRoute(nextConfig?.i18n ? resolvePagesI18nRequest(resolvedPathname, nextConfig.i18n, request.headers, getUrlHostname(request.url), bp, nextConfig.trailingSlash ?? false).url : resolvedPathname, devPageRoutes);
|
|
2447
2601
|
return m ? { route: {
|
|
@@ -2464,8 +2618,17 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2464
2618
|
}
|
|
2465
2619
|
return proxyExternalRequest(new Request(new URL(url, requestOrigin), externalInit), externalUrl);
|
|
2466
2620
|
},
|
|
2467
|
-
serveFilesystemRoute: async (requestPathname, stagedHeaders, phase) => {
|
|
2468
|
-
if (
|
|
2621
|
+
serveFilesystemRoute: async (requestPathname, stagedHeaders, phase, resolvedUrl) => {
|
|
2622
|
+
if (isImageOptimizationPath(requestPathname)) {
|
|
2623
|
+
const encodedLocation = resolveDevImageRedirect(new URL(resolvedUrl, requestOrigin), [...nextConfig.images?.deviceSizes ?? DEFAULT_DEVICE_SIZES, ...nextConfig.images?.imageSizes ?? DEFAULT_IMAGE_SIZES], nextConfig.images?.qualities);
|
|
2624
|
+
return encodedLocation ? new Response(null, {
|
|
2625
|
+
status: 302,
|
|
2626
|
+
headers: { Location: encodedLocation }
|
|
2627
|
+
}) : new Response("Invalid image optimization parameters", { status: 400 });
|
|
2628
|
+
}
|
|
2629
|
+
const isRetrievalMethod = req.method === "GET" || req.method === "HEAD";
|
|
2630
|
+
if (phase === "direct" && isRetrievalMethod || requestPathname === "/" || requestPathname === "/api" || requestPathname.startsWith("/api/")) return false;
|
|
2631
|
+
if (!isRetrievalMethod) return isExistingDevPublicFile(requestPathname) ? methodNotAllowedResponse("GET, HEAD") : false;
|
|
2469
2632
|
return serveRewrittenViteFilesystemRoute(req, res, requestPathname, stagedHeaders);
|
|
2470
2633
|
}
|
|
2471
2634
|
});
|
|
@@ -2475,19 +2638,35 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2475
2638
|
}
|
|
2476
2639
|
if (pipelineResult.type === "next") return next();
|
|
2477
2640
|
if (pipelineResult.type === "handled") return;
|
|
2641
|
+
const forEachStagedHeader = (visit) => {
|
|
2642
|
+
for (const [key, value] of Object.entries(pipelineResult.stagedHeaders)) if (Array.isArray(value)) for (const item of value) visit(key, item);
|
|
2643
|
+
else visit(key, value);
|
|
2644
|
+
};
|
|
2478
2645
|
const flushStagedHeaders = () => {
|
|
2479
|
-
|
|
2480
|
-
else res.appendHeader(key, value);
|
|
2646
|
+
forEachStagedHeader((key, value) => res.appendHeader(key, value));
|
|
2481
2647
|
};
|
|
2482
2648
|
const flushRequestHeaders = () => {
|
|
2483
2649
|
applyRequestHeadersToNodeRequest(pipelineResult.requestHeaders);
|
|
2484
2650
|
};
|
|
2651
|
+
const forwardInternalApiRewriteToApp = (apiUrl) => {
|
|
2652
|
+
const responseHeaders = [];
|
|
2653
|
+
forEachStagedHeader((key, value) => responseHeaders.push([key, value]));
|
|
2654
|
+
const requestHeaders = new Headers();
|
|
2655
|
+
encodeMiddlewareRequestHeaders(requestHeaders, pipelineResult.requestHeaders);
|
|
2656
|
+
flushRequestHeaders();
|
|
2657
|
+
req.headers[VINEXT_MW_CTX_HEADER] = JSON.stringify({
|
|
2658
|
+
h: responseHeaders,
|
|
2659
|
+
q: [...requestHeaders],
|
|
2660
|
+
s: pipelineResult.middlewareStatus ?? null,
|
|
2661
|
+
r: apiUrl
|
|
2662
|
+
});
|
|
2663
|
+
};
|
|
2485
2664
|
if (pipelineResult.type === "api") {
|
|
2486
|
-
const
|
|
2487
|
-
const apiMatch = matchRoute(pipelineResult.apiUrl,
|
|
2665
|
+
const devApiRoutes = await getDevApiRoutes();
|
|
2666
|
+
const apiMatch = matchRoute(pipelineResult.apiUrl, devApiRoutes);
|
|
2488
2667
|
if (apiMatch && hasAppDir && appDir) {
|
|
2489
|
-
const
|
|
2490
|
-
const appMatch = matchAppRoute(pipelineResult.apiUrl,
|
|
2668
|
+
const devAppRoutes = await getDevAppRoutes();
|
|
2669
|
+
const appMatch = matchAppRoute(pipelineResult.apiUrl, devAppRoutes);
|
|
2491
2670
|
if (appMatch && !pagesRouteHasPriorityOverAppRoute(apiMatch.route, appMatch.route)) return next();
|
|
2492
2671
|
}
|
|
2493
2672
|
if (apiMatch) {
|
|
@@ -2495,14 +2674,17 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2495
2674
|
flushRequestHeaders();
|
|
2496
2675
|
if (pipelineResult.middlewareStatus !== void 0) req.__vinextMiddlewareStatus = pipelineResult.middlewareStatus;
|
|
2497
2676
|
}
|
|
2498
|
-
if (await handleApiRoute(getPagesRunner(), req, res, pipelineResult.apiUrl,
|
|
2677
|
+
if (await handleApiRoute(getPagesRunner(), req, res, pipelineResult.apiUrl, devApiRoutes, {
|
|
2499
2678
|
basePath: nextConfig?.basePath,
|
|
2500
2679
|
i18n: nextConfig?.i18n,
|
|
2501
2680
|
trustedRevalidateOrigin: getTrustedDevRevalidateOrigin(),
|
|
2502
2681
|
allowedRevalidateHeaderKeys: nextConfig?.allowedRevalidateHeaderKeys,
|
|
2503
2682
|
trailingSlash: nextConfig?.trailingSlash
|
|
2504
2683
|
})) return;
|
|
2505
|
-
if (hasAppDir)
|
|
2684
|
+
if (hasAppDir) {
|
|
2685
|
+
if (pipelineResult.configRewriteFired) forwardInternalApiRewriteToApp(pipelineResult.apiUrl);
|
|
2686
|
+
return next();
|
|
2687
|
+
}
|
|
2506
2688
|
res.statusCode = 404;
|
|
2507
2689
|
res.end("404 - API route not found");
|
|
2508
2690
|
return;
|
|
@@ -2518,7 +2700,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2518
2700
|
}
|
|
2519
2701
|
if (!cachedSSRHandler || cachedSSRHandler.routes !== routes) cachedSSRHandler = {
|
|
2520
2702
|
routes,
|
|
2521
|
-
handler: createSSRHandler(server, getPagesRunner(), routes, pagesDir, nextConfig?.i18n, fileMatcher, nextConfig?.basePath ?? "", nextConfig?.trailingSlash ?? false, middlewarePath !== null, (nextConfig?.rewrites.beforeFiles.length ?? 0) > 0 || (nextConfig?.rewrites.afterFiles.length ?? 0) > 0 || (nextConfig?.rewrites.fallback.length ?? 0) > 0, nextConfig?.clientTraceMetadata, nextConfig?.htmlLimitedBots, nextConfig?.reactStrictMode === true, nextConfig?.expireTime)
|
|
2703
|
+
handler: createSSRHandler(server, getPagesRunner(), routes, pagesDir, nextConfig?.i18n, fileMatcher, nextConfig?.basePath ?? "", nextConfig?.trailingSlash ?? false, middlewarePath !== null, (nextConfig?.rewrites.beforeFiles.length ?? 0) > 0 || (nextConfig?.rewrites.afterFiles.length ?? 0) > 0 || (nextConfig?.rewrites.fallback.length ?? 0) > 0, nextConfig?.clientTraceMetadata, nextConfig?.htmlLimitedBots, nextConfig?.reactStrictMode === true, nextConfig?.expireTime, nextConfig?.crossOrigin)
|
|
2522
2704
|
};
|
|
2523
2705
|
flushStagedHeaders();
|
|
2524
2706
|
flushRequestHeaders();
|