vinext 1.2.1 → 1.3.1
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 +12 -9
- package/dist/_virtual/_rolldown/runtime.js +1 -1
- package/dist/build/action-owner-manifest.d.ts +3 -2
- package/dist/build/action-owner-manifest.js +18 -2
- package/dist/build/app-page-static-eligibility.d.ts +17 -1
- package/dist/build/app-page-static-eligibility.js +80 -13
- package/dist/build/clean-output.d.ts +2 -1
- package/dist/build/client-build-config.d.ts +77 -6
- package/dist/build/client-build-config.js +176 -12
- package/dist/build/client-reference-async.d.ts +48 -0
- package/dist/build/client-reference-async.js +123 -0
- package/dist/build/client-reference-chunks.d.ts +32 -0
- package/dist/build/client-reference-chunks.js +111 -0
- package/dist/build/client-reference-groups.d.ts +171 -0
- package/dist/build/client-reference-groups.js +572 -0
- package/dist/build/css-url-assets.d.ts +2 -1
- package/dist/build/google-fonts/fallback-metrics.d.ts +2 -1
- package/dist/build/google-fonts/find-font-files-in-css.d.ts +1 -0
- package/dist/build/google-fonts/find-font-files-in-css.js +17 -4
- package/dist/build/google-fonts/font-metadata.d.ts +2 -1
- package/dist/build/google-fonts/validate.d.ts +2 -1
- package/dist/build/inline-css.d.ts +2 -1
- package/dist/build/layout-classification.d.ts +2 -1
- package/dist/build/module-dependency-cache.d.ts +33 -1
- package/dist/build/module-dependency-cache.js +51 -1
- package/dist/build/next-client-runtime-manifests.d.ts +12 -2
- package/dist/build/next-client-runtime-manifests.js +19 -4
- package/dist/build/nitro-public-files.d.ts +24 -0
- package/dist/build/nitro-public-files.js +60 -0
- package/dist/build/pages-client-assets-module.js +1 -1
- package/dist/build/precompress.d.ts +2 -1
- package/dist/build/precompress.js +1 -1
- package/dist/build/prerender-paths.d.ts +2 -1
- package/dist/build/prerender-paths.js +5 -2
- package/dist/build/prerender-phase.d.ts +2 -1
- package/dist/build/prerender-server-pool.js +1 -1
- package/dist/build/prerender.d.ts +3 -2
- package/dist/build/prerender.js +5 -4
- package/dist/build/report.d.ts +2 -1
- package/dist/build/route-classification-injector.d.ts +2 -1
- package/dist/build/route-classification-manifest.d.ts +2 -1
- package/dist/build/run-prerender.d.ts +2 -1
- package/dist/build/server-actions-encryption-key.d.ts +24 -0
- package/dist/build/server-actions-encryption-key.js +101 -0
- package/dist/build/ssr-manifest.d.ts +3 -0
- package/dist/build/ssr-manifest.js +34 -2
- package/dist/build/standalone.d.ts +2 -1
- package/dist/cache/cache-adapters-virtual.d.ts +2 -1
- package/dist/cache.js +1 -2
- package/dist/check.d.ts +2 -1
- package/dist/check.js +4 -0
- package/dist/cli-args.d.ts +2 -1
- package/dist/cli.js +2 -0
- package/dist/client/client-redirect-matcher.js +2 -1
- package/dist/client/client-redirects.d.ts +4 -3
- package/dist/client/client-redirects.js +2 -1
- package/dist/client/client-rewrite-params.d.ts +9 -0
- package/dist/client/client-rewrite-params.js +20 -0
- package/dist/client/client-rewrites.d.ts +2 -1
- package/dist/client/dev-error-overlay-store.d.ts +2 -1
- package/dist/client/dev-error-overlay.js +2 -1
- package/dist/client/index.js +1 -2
- package/dist/client/instrumentation-client-state.js +5 -5
- package/dist/client/navigation-runtime.d.ts +28 -3
- package/dist/client/navigation-runtime.js +42 -11
- package/dist/client/pages-router-link-navigation.d.ts +2 -1
- package/dist/client/vinext-next-data.d.ts +25 -2
- package/dist/client/window-next.d.ts +2 -1
- package/dist/config/config-matchers.d.ts +27 -41
- package/dist/config/config-matchers.js +293 -270
- package/dist/config/config-source.d.ts +34 -0
- package/dist/config/config-source.js +141 -0
- package/dist/config/dotenv.d.ts +2 -1
- package/dist/config/header-params.d.ts +29 -0
- package/dist/config/header-params.js +106 -0
- package/dist/config/next-config.d.ts +20 -6
- package/dist/config/next-config.js +149 -11
- package/dist/config/tsconfig-paths.d.ts +2 -1
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/detector.js +23 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/index.js +2 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/lookup.js +25 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/bmp.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/cur.js +15 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/dds.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/gif.js +12 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/heif.js +55 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/icns.js +76 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ico.js +39 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/index.js +46 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/j2c.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jp2.js +21 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jpg.js +71 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl-stream.js +42 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl.js +46 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ktx.js +19 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/png.js +28 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/pnm.js +54 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/psd.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/svg.js +79 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tga.js +15 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tiff.js +96 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/utils.js +53 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/webp.js +45 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/utils/bit-reader.js +38 -0
- package/dist/deps/.pnpm/ua-parser-js@1.0.35/deps/ua-parser-js/src/ua-parser.js +2 -2
- package/dist/entries/app-browser-entry.d.ts +34 -6
- package/dist/entries/app-browser-entry.js +103 -40
- package/dist/entries/app-rsc-entry.d.ts +4 -1
- package/dist/entries/app-rsc-entry.js +131 -66
- package/dist/entries/app-rsc-manifest.d.ts +12 -1
- package/dist/entries/app-rsc-manifest.js +73 -1
- package/dist/entries/app-ssr-entry.d.ts +4 -1
- package/dist/entries/app-ssr-entry.js +9 -2
- package/dist/entries/pages-client-entry.d.ts +1 -0
- package/dist/entries/pages-client-entry.js +6 -6
- package/dist/entries/pages-entry-helpers.js +1 -2
- package/dist/entries/pages-server-entry.d.ts +2 -1
- package/dist/entries/pages-server-entry.js +18 -15
- package/dist/entries/runtime-entry-module.d.ts +1 -0
- package/dist/entries/runtime-entry-module.js +4 -1
- package/dist/image/image-adapters-virtual.d.ts +2 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +340 -116
- package/dist/init.js +17 -0
- package/dist/plugins/client-compile-hints.d.ts +30 -0
- package/dist/plugins/client-compile-hints.js +88 -0
- package/dist/plugins/client-reference-dedup.d.ts +2 -1
- package/dist/plugins/cloudflare-dev-module-urls.d.ts +2 -1
- package/dist/plugins/dynamic-preload-metadata.d.ts +3 -1
- package/dist/plugins/dynamic-preload-metadata.js +1 -1
- package/dist/plugins/environment.d.ts +2 -1
- package/dist/plugins/fonts.js +9 -12
- package/dist/plugins/ignore-dynamic-requests.d.ts +2 -1
- package/dist/plugins/import-meta-url.d.ts +2 -1
- package/dist/plugins/og-assets.d.ts +2 -1
- package/dist/plugins/og-assets.js +2 -3
- package/dist/plugins/optimize-imports.d.ts +27 -3
- package/dist/plugins/optimize-imports.js +106 -20
- package/dist/plugins/pages-node-externals.d.ts +2 -1
- package/dist/plugins/remove-console.d.ts +2 -1
- package/dist/plugins/require-condition-resolution.d.ts +2 -1
- package/dist/plugins/rsc-client-reference-loaders.d.ts +53 -1
- package/dist/plugins/rsc-client-reference-loaders.js +447 -27
- package/dist/plugins/rsc-client-shim-excludes.js +2 -0
- package/dist/plugins/sass.d.ts +2 -1
- package/dist/plugins/strip-server-exports.d.ts +2 -1
- package/dist/plugins/styled-jsx.d.ts +2 -1
- package/dist/plugins/transform-result.d.ts +2 -1
- package/dist/plugins/typeof-window.d.ts +2 -1
- package/dist/plugins/use-cache-callable.d.ts +5 -0
- package/dist/plugins/use-cache-callable.js +30 -8
- package/dist/plugins/worker-image-imports.d.ts +1 -0
- package/dist/plugins/worker-image-imports.js +2 -2
- package/dist/plugins/worker-use-server.d.ts +2 -1
- package/dist/routing/app-route-graph.d.ts +41 -1
- package/dist/routing/app-route-graph.js +122 -50
- package/dist/routing/browser-route-manifest.d.ts +44 -0
- package/dist/routing/browser-route-manifest.js +195 -0
- package/dist/routing/hashed-route-patterns.d.ts +4 -0
- package/dist/routing/hashed-route-patterns.js +22 -0
- package/dist/routing/optimistic-route-trie.d.ts +28 -0
- package/dist/routing/optimistic-route-trie.js +102 -0
- package/dist/routing/route-matching.d.ts +2 -1
- package/dist/routing/route-pattern.d.ts +2 -1
- package/dist/routing/route-validation.d.ts +6 -1
- package/dist/routing/route-validation.js +26 -10
- package/dist/server/accept-encoding.d.ts +2 -1
- package/dist/server/app-action-forwarding.d.ts +10 -1
- package/dist/server/app-action-forwarding.js +15 -1
- package/dist/server/app-bfcache-identity.d.ts +2 -1
- package/dist/server/app-browser-action-result.d.ts +2 -1
- package/dist/server/app-browser-client-reuse-manifest.d.ts +2 -1
- package/dist/server/app-browser-entry.js +175 -64
- package/dist/server/app-browser-error.d.ts +5 -2
- package/dist/server/app-browser-error.js +7 -2
- package/dist/server/app-browser-history-controller.d.ts +2 -1
- package/dist/server/app-browser-hydration.d.ts +2 -1
- package/dist/server/app-browser-interception-context.d.ts +4 -3
- package/dist/server/app-browser-mpa-navigation.d.ts +1 -0
- package/dist/server/app-browser-mpa-navigation.js +6 -5
- package/dist/server/app-browser-navigation-controller.d.ts +17 -6
- package/dist/server/app-browser-navigation-controller.js +103 -36
- package/dist/server/app-browser-popstate.d.ts +2 -1
- package/dist/server/app-browser-rsc-redirect.d.ts +2 -1
- package/dist/server/app-browser-server-action-client.d.ts +2 -1
- package/dist/server/app-browser-state.d.ts +2 -2
- package/dist/server/app-browser-state.js +1 -1
- package/dist/server/app-browser-stream.d.ts +2 -1
- package/dist/server/app-browser-visible-commit.d.ts +6 -5
- package/dist/server/app-client-reference-manifest.d.ts +31 -0
- package/dist/server/app-client-reference-manifest.js +46 -0
- package/dist/server/app-client-reference-preloader.d.ts +45 -2
- package/dist/server/app-client-reference-preloader.js +48 -10
- package/dist/server/app-elements-wire.d.ts +2 -1
- package/dist/server/app-elements.d.ts +2 -0
- package/dist/server/app-elements.js +3 -1
- package/dist/server/app-fallback-renderer.d.ts +9 -2
- package/dist/server/app-fallback-renderer.js +6 -2
- package/dist/server/app-history-state.d.ts +2 -1
- package/dist/server/app-inline-css-client.d.ts +2 -1
- package/dist/server/app-layout-param-observation.d.ts +2 -1
- package/dist/server/app-metadata-tracing.d.ts +2 -1
- package/dist/server/app-middleware.d.ts +6 -0
- package/dist/server/app-middleware.js +8 -10
- package/dist/server/app-optimistic-routing.d.ts +26 -11
- package/dist/server/app-optimistic-routing.js +38 -96
- package/dist/server/app-page-boundary-render.d.ts +20 -2
- package/dist/server/app-page-boundary-render.js +229 -39
- package/dist/server/app-page-boundary.d.ts +34 -5
- package/dist/server/app-page-boundary.js +40 -7
- package/dist/server/app-page-cache-finalizer.d.ts +2 -1
- package/dist/server/app-page-cache-finalizer.js +1 -1
- package/dist/server/app-page-cache-render.d.ts +10 -2
- package/dist/server/app-page-cache-render.js +15 -2
- package/dist/server/app-page-cache.js +2 -2
- package/dist/server/app-page-dispatch.d.ts +34 -1
- package/dist/server/app-page-dispatch.js +165 -34
- package/dist/server/app-page-element-builder.d.ts +17 -1
- package/dist/server/app-page-element-builder.js +187 -66
- package/dist/server/app-page-execution.d.ts +28 -1
- package/dist/server/app-page-execution.js +114 -5
- package/dist/server/app-page-head.d.ts +95 -3
- package/dist/server/app-page-head.js +307 -152
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +48 -2
- package/dist/server/app-page-http-access-fallback-metadata.js +76 -1
- package/dist/server/app-page-method.d.ts +2 -1
- package/dist/server/app-page-probe.d.ts +2 -1
- package/dist/server/app-page-render-identity.d.ts +2 -1
- package/dist/server/app-page-render.d.ts +7 -1
- package/dist/server/app-page-render.js +38 -11
- package/dist/server/app-page-request.d.ts +14 -1
- package/dist/server/app-page-request.js +1 -1
- package/dist/server/app-page-route-wiring.d.ts +52 -2
- package/dist/server/app-page-route-wiring.js +197 -47
- package/dist/server/app-page-rsc-render-status.d.ts +3 -1
- package/dist/server/app-page-rsc-render-status.js +1 -0
- package/dist/server/app-page-search-params-observation.d.ts +8 -6
- package/dist/server/app-page-search-params-observation.js +16 -11
- package/dist/server/app-page-segment-plan.d.ts +2 -1
- package/dist/server/app-page-stream.d.ts +38 -1
- package/dist/server/app-page-stream.js +24 -4
- package/dist/server/app-pages-bridge.d.ts +4 -2
- package/dist/server/app-pages-bridge.js +11 -7
- package/dist/server/app-ppr-fallback-shell-render.d.ts +2 -1
- package/dist/server/app-ppr-fallback-shell.d.ts +2 -1
- package/dist/server/app-prerender-endpoints.d.ts +2 -1
- package/dist/server/app-prerender-static-params.d.ts +2 -1
- package/dist/server/app-prerender-static-params.js +3 -2
- package/dist/server/app-render-dependency.d.ts +11 -1
- package/dist/server/app-render-dependency.js +65 -6
- package/dist/server/app-request-stage-independent-entry.d.ts +2 -1
- package/dist/server/app-request-stage-independent-entry.js +2 -2
- package/dist/server/app-response-stage-entry.d.ts +2 -1
- package/dist/server/app-response-stage-entry.js +3 -3
- package/dist/server/app-route-handler-cache.d.ts +2 -1
- package/dist/server/app-route-handler-dispatch.d.ts +2 -1
- package/dist/server/app-route-handler-dispatch.js +4 -2
- package/dist/server/app-route-handler-execution.d.ts +4 -1
- package/dist/server/app-route-handler-execution.js +9 -2
- package/dist/server/app-route-handler-middleware-context.d.ts +2 -1
- package/dist/server/app-route-handler-middleware-context.js +3 -3
- package/dist/server/app-route-handler-response.d.ts +4 -2
- package/dist/server/app-route-handler-response.js +2 -2
- package/dist/server/app-route-handler-runtime.d.ts +4 -1
- package/dist/server/app-route-handler-runtime.js +20 -3
- package/dist/server/app-route-module-loader.d.ts +18 -1
- package/dist/server/app-route-module-loader.js +15 -6
- package/dist/server/app-route-tree-prefetch.d.ts +2 -1
- package/dist/server/app-route-tree.d.ts +20 -0
- package/dist/server/app-route-tree.js +18 -0
- package/dist/server/app-router-entry.js +2 -2
- package/dist/server/app-rsc-combined-handler.js +8 -1
- package/dist/server/app-rsc-error-handler.d.ts +2 -1
- package/dist/server/app-rsc-errors.d.ts +9 -1
- package/dist/server/app-rsc-errors.js +9 -2
- package/dist/server/app-rsc-handler.d.ts +6 -2
- package/dist/server/app-rsc-handler.js +152 -140
- package/dist/server/app-rsc-response-finalizer.d.ts +7 -1
- package/dist/server/app-rsc-response-finalizer.js +4 -1
- package/dist/server/app-rsc-response-stage.js +3 -1
- package/dist/server/app-rsc-route-matching.d.ts +39 -1
- package/dist/server/app-rsc-route-matching.js +25 -1
- package/dist/server/app-segment-config.d.ts +2 -1
- package/dist/server/app-segment-config.js +1 -14
- package/dist/server/app-server-action-execution.d.ts +25 -7
- package/dist/server/app-server-action-execution.js +53 -59
- package/dist/server/app-ssr-entry.d.ts +12 -0
- package/dist/server/app-ssr-entry.js +104 -48
- package/dist/server/app-ssr-error-meta.d.ts +2 -1
- package/dist/server/app-ssr-search-params-gate.d.ts +2 -1
- package/dist/server/app-ssr-stream.d.ts +29 -10
- package/dist/server/app-ssr-stream.js +311 -67
- package/dist/server/app-static-generation.d.ts +2 -1
- package/dist/server/app-streamed-client-references.d.ts +39 -0
- package/dist/server/app-streamed-client-references.js +156 -0
- package/dist/server/app-visited-response-cache.d.ts +2 -1
- package/dist/server/app-worker-stages.d.ts +2 -1
- package/dist/server/artifact-compatibility.d.ts +2 -1
- package/dist/server/bfcache-identity.d.ts +2 -1
- package/dist/server/cache-headers.d.ts +2 -1
- package/dist/server/cacheability-request.d.ts +2 -1
- package/dist/server/client-reuse-manifest.d.ts +2 -1
- package/dist/server/config-headers.d.ts +2 -1
- package/dist/server/config-headers.js +12 -3
- package/dist/server/csp.d.ts +2 -1
- package/dist/server/default-global-not-found-module.d.ts +2 -1
- package/dist/server/default-http-access-fallback-modules.d.ts +33 -0
- package/dist/server/default-http-access-fallback-modules.js +31 -0
- package/dist/server/defer-until-stream-consumed.d.ts +34 -0
- package/dist/server/defer-until-stream-consumed.js +154 -21
- package/dist/server/dev-lockfile.d.ts +32 -2
- package/dist/server/dev-lockfile.js +46 -2
- package/dist/server/dev-module-runner.d.ts +2 -1
- package/dist/server/dev-server.js +10 -3
- package/dist/server/fetch-handler.js +1 -2
- package/dist/server/file-based-metadata.d.ts +2 -1
- package/dist/server/framework-tracer.d.ts +2 -1
- package/dist/server/html.d.ts +1 -0
- package/dist/server/html.js +19 -1
- package/dist/server/http-conditional.d.ts +2 -1
- package/dist/server/http-error-responses.d.ts +2 -1
- package/dist/server/implicit-tags.d.ts +2 -1
- package/dist/server/isolate-shared-promise.d.ts +10 -0
- package/dist/server/isolate-shared-promise.js +33 -0
- package/dist/server/isr-cache.js +3 -2
- package/dist/server/metadata-route-build-data.d.ts +2 -1
- package/dist/server/metadata-route-build-data.js +1 -1
- package/dist/server/metadata-route-response.d.ts +2 -1
- package/dist/server/metadata-route-response.js +1 -1
- package/dist/server/metadata-routes.d.ts +2 -1
- package/dist/server/middleware-matcher-pattern.d.ts +0 -1
- package/dist/server/middleware-matcher-pattern.js +11 -140
- package/dist/server/middleware-matcher.js +5 -6
- package/dist/server/middleware-response-headers.d.ts +31 -0
- package/dist/server/middleware-response-headers.js +57 -1
- package/dist/server/middleware-runtime.d.ts +2 -1
- package/dist/server/middleware-runtime.js +26 -13
- package/dist/server/navigation-planner.d.ts +2 -2
- package/dist/server/navigation-trace.d.ts +2 -1
- package/dist/server/next-error-digest.d.ts +2 -1
- package/dist/server/nitro-public-files-plugin.d.ts +39 -0
- package/dist/server/nitro-public-files-plugin.js +106 -0
- package/dist/server/nitro-public-files.d.ts +22 -0
- package/dist/server/nitro-public-files.js +39 -0
- package/dist/server/opentelemetry-api.d.ts +2 -1
- package/dist/server/operation-token.d.ts +2 -1
- package/dist/server/pages-api-route.d.ts +2 -1
- package/dist/server/pages-asset-tags.d.ts +7 -1
- package/dist/server/pages-asset-tags.js +9 -2
- package/dist/server/pages-body-parser-config.d.ts +2 -1
- package/dist/server/pages-client-assets.d.ts +8 -1
- package/dist/server/pages-data-route.d.ts +2 -1
- package/dist/server/pages-document-asset-props.d.ts +2 -1
- package/dist/server/pages-document-initial-props.d.ts +2 -1
- package/dist/server/pages-execution-tracing.d.ts +2 -1
- package/dist/server/pages-execution-tracing.js +1 -1
- package/dist/server/pages-get-initial-props.d.ts +2 -1
- package/dist/server/pages-i18n.d.ts +18 -0
- package/dist/server/pages-i18n.js +18 -2
- package/dist/server/pages-node-compat.d.ts +5 -3
- package/dist/server/pages-node-compat.js +35 -16
- package/dist/server/pages-page-data.d.ts +7 -1
- package/dist/server/pages-page-data.js +35 -12
- package/dist/server/pages-page-handler.d.ts +3 -2
- package/dist/server/pages-page-handler.js +16 -7
- package/dist/server/pages-page-method.d.ts +2 -1
- package/dist/server/pages-page-response.d.ts +2 -1
- package/dist/server/pages-preview.d.ts +2 -1
- package/dist/server/pages-readiness.d.ts +2 -1
- package/dist/server/pages-request-pipeline.d.ts +8 -2
- package/dist/server/pages-request-pipeline.js +35 -40
- package/dist/server/pages-request-stage-entry.d.ts +2 -1
- package/dist/server/pages-request-stage-entry.js +16 -6
- package/dist/server/pages-response-stage-entry.d.ts +2 -1
- package/dist/server/pages-response-stage-entry.js +1 -1
- package/dist/server/pages-revalidate.js +1 -0
- package/dist/server/pages-route-data-kind.d.ts +2 -1
- package/dist/server/pages-router-entry.js +1 -1
- package/dist/server/prerender-cache-life-header.d.ts +2 -1
- package/dist/server/prerender-route-params.d.ts +2 -1
- package/dist/server/prod-server.d.ts +2 -2
- package/dist/server/prod-server.js +80 -36
- package/dist/server/proxy-trust.d.ts +6 -0
- package/dist/server/proxy-trust.js +12 -6
- package/dist/server/request-log.d.ts +2 -1
- package/dist/server/request-pipeline.d.ts +5 -0
- package/dist/server/request-pipeline.js +12 -1
- package/dist/server/request-tracing.d.ts +2 -1
- package/dist/server/request-tracing.js +1 -1
- package/dist/server/response-start-tracing.js +7 -29
- package/dist/server/rsc-render-stream.d.ts +4 -0
- package/dist/server/rsc-render-stream.js +25 -0
- package/dist/server/seed-cache.d.ts +2 -1
- package/dist/server/seed-cache.js +1 -1
- package/dist/server/server-reference-loader.js +10 -1
- package/dist/server/static-file-cache.d.ts +2 -1
- package/dist/server/static-file-cache.js +16 -3
- package/dist/server/static-layout-client-reuse-proof.d.ts +2 -1
- package/dist/server/worker-revalidation-context.d.ts +2 -1
- package/dist/server/worker-stages.d.ts +2 -1
- package/dist/server/worker-utils.js +1 -1
- package/dist/shims/app.d.ts +2 -1
- package/dist/shims/cache-callable-runtime.d.ts +2 -1
- package/dist/shims/cache-handler.d.ts +8 -3
- package/dist/shims/cache-handler.js +32 -11
- package/dist/shims/cache-request-state.d.ts +40 -3
- package/dist/shims/cache-request-state.js +70 -5
- package/dist/shims/cache-runtime.js +47 -19
- package/dist/shims/cache.d.ts +2 -2
- package/dist/shims/cache.js +17 -8
- package/dist/shims/caught-not-found-boundaries.d.ts +15 -0
- package/dist/shims/caught-not-found-boundaries.js +48 -0
- package/dist/shims/cdn-purge-routes.d.ts +25 -0
- package/dist/shims/cdn-purge-routes.js +77 -0
- package/dist/shims/client-locale.js +2 -1
- package/dist/shims/client-page-root.d.ts +2 -1
- package/dist/shims/config.d.ts +2 -1
- package/dist/shims/default-forbidden.d.ts +4 -0
- package/dist/shims/default-forbidden.js +18 -0
- package/dist/shims/default-not-found.d.ts +0 -5
- package/dist/shims/default-not-found.js +5 -41
- package/dist/shims/default-unauthorized.d.ts +4 -0
- package/dist/shims/default-unauthorized.js +18 -0
- package/dist/shims/dynamic.js +17 -4
- package/dist/shims/error-boundary.d.ts +39 -3
- package/dist/shims/error-boundary.js +31 -16
- package/dist/shims/font-google.js +1 -2
- package/dist/shims/font-utils.d.ts +3 -2
- package/dist/shims/font-utils.js +5 -3
- package/dist/shims/form.js +9 -4
- package/dist/shims/http-access-error-fallback.d.ts +7 -0
- package/dist/shims/http-access-error-fallback.js +47 -0
- package/dist/shims/image-props.d.ts +93 -0
- package/dist/shims/image-props.js +323 -0
- package/dist/shims/image.d.ts +4 -39
- package/dist/shims/image.js +4 -319
- package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +22 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.js +71 -18
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +14 -3
- package/dist/shims/internal/app-route-prefetch-policy.js +29 -4
- package/dist/shims/internal/cache-context-accessor.d.ts +2 -1
- package/dist/shims/internal/client-reference-loader.d.ts +7 -0
- package/dist/shims/internal/client-reference-loader.js +91 -0
- package/dist/shims/internal/cookie-serialize.d.ts +2 -1
- package/dist/shims/internal/cookies.js +1 -2
- package/dist/shims/internal/headers-state.d.ts +9 -0
- package/dist/shims/internal/headers-state.js +19 -2
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +6 -2
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +31 -14
- package/dist/shims/internal/hybrid-client-route-owner.js +8 -8
- package/dist/shims/internal/interpolate-as.d.ts +2 -1
- package/dist/shims/internal/pages-data-target.d.ts +2 -1
- package/dist/shims/internal/pages-data-url.d.ts +2 -1
- package/dist/shims/internal/thenable-well-known-properties.d.ts +2 -1
- package/dist/shims/link.js +198 -53
- package/dist/shims/metadata.d.ts +32 -11
- package/dist/shims/metadata.js +88 -26
- package/dist/shims/navigation-errors.d.ts +2 -1
- package/dist/shims/navigation.d.ts +23 -3
- package/dist/shims/navigation.js +91 -25
- package/dist/shims/og.js +35 -10
- package/dist/shims/pages-router-runtime.d.ts +2 -1
- package/dist/shims/ppr-fallback-shell.d.ts +2 -1
- package/dist/shims/request-context.d.ts +13 -0
- package/dist/shims/router.js +33 -43
- package/dist/shims/server.d.ts +31 -4
- package/dist/shims/server.js +58 -10
- package/dist/shims/thenable-params.d.ts +6 -1
- package/dist/shims/thenable-params.js +11 -2
- package/dist/shims/unified-request-context.d.ts +5 -0
- package/dist/shims/unified-request-context.js +5 -3
- package/dist/typegen.d.ts +2 -1
- package/dist/utils/asset-prefix.d.ts +7 -0
- package/dist/utils/asset-prefix.js +10 -1
- package/dist/utils/client-build-manifest.d.ts +4 -1
- package/dist/utils/client-build-manifest.js +20 -6
- package/dist/utils/client-entry-manifest.d.ts +13 -0
- package/dist/utils/client-entry-manifest.js +20 -1
- package/dist/utils/client-reference-chunks.d.ts +45 -0
- package/dist/utils/client-reference-chunks.js +30 -0
- package/dist/utils/client-runtime-metadata.d.ts +10 -1
- package/dist/utils/client-runtime-metadata.js +53 -9
- package/dist/utils/compare.d.ts +9 -0
- package/dist/utils/compare.js +15 -1
- package/dist/utils/lazy-chunks.d.ts +18 -0
- package/dist/utils/lazy-chunks.js +27 -1
- package/dist/utils/manifest-paths.d.ts +14 -0
- package/dist/utils/manifest-paths.js +22 -1
- package/dist/utils/middleware-request-headers.d.ts +2 -1
- package/dist/utils/path-to-regexp.d.ts +21 -0
- package/dist/{server/middleware-path-to-regexp.js → utils/path-to-regexp.js} +14 -11
- package/dist/utils/plugin-react-version.d.ts +15 -0
- package/dist/utils/plugin-react-version.js +64 -0
- package/dist/utils/project.d.ts +2 -1
- package/dist/utils/project.js +9 -1
- package/dist/utils/public-routes.d.ts +2 -0
- package/dist/utils/public-routes.js +18 -7
- package/dist/utils/query.d.ts +2 -1
- package/dist/utils/sorted-array.d.ts +2 -1
- package/dist/utils/vite-cli-invocation.d.ts +2 -1
- package/package.json +5 -5
- package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +0 -808
- package/dist/server/default-not-found-module.d.ts +0 -19
- package/dist/server/default-not-found-module.js +0 -18
- package/dist/server/middleware-path-to-regexp.d.ts +0 -13
- package/dist/server/rsc-stream-hints.d.ts +0 -21
- package/dist/server/rsc-stream-hints.js +0 -227
- package/dist/utils/regex-safety.d.ts +0 -17
- package/dist/utils/regex-safety.js +0 -789
|
@@ -42,5 +42,61 @@ function mergeMiddlewareResponseHeaders(target, middlewareHeaders) {
|
|
|
42
42
|
target.set(key, value);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
const RESPONSE_APPENDED_HEADER_NAMES = [
|
|
46
|
+
"set-cookie",
|
|
47
|
+
"www-authenticate",
|
|
48
|
+
"proxy-authenticate"
|
|
49
|
+
];
|
|
50
|
+
const RESPONSE_APPENDED_COOKIE_HEADER_NAMES = ["set-cookie"];
|
|
51
|
+
/**
|
|
52
|
+
* Merge middleware response headers onto an already-built response's headers.
|
|
53
|
+
*
|
|
54
|
+
* Next.js writes middleware response headers before the handler runs and then
|
|
55
|
+
* appends the handler response's Set-Cookie, WWW-Authenticate and
|
|
56
|
+
* Proxy-Authenticate values, so middleware values come first and the
|
|
57
|
+
* response's own are kept. A handler's cookie for the same name (a logout
|
|
58
|
+
* deletion or session rotation) is then the one the browser applies last.
|
|
59
|
+
*/
|
|
60
|
+
function mergeMiddlewareResponseHeadersOntoResponse(target, middlewareHeaders, options = {}) {
|
|
61
|
+
if (!middlewareHeaders) return;
|
|
62
|
+
const responseValues = [];
|
|
63
|
+
const appendedNames = options.appendResponseChallenges === false ? RESPONSE_APPENDED_COOKIE_HEADER_NAMES : RESPONSE_APPENDED_HEADER_NAMES;
|
|
64
|
+
for (const name of appendedNames) {
|
|
65
|
+
if (!middlewareHeaders.has(name)) continue;
|
|
66
|
+
const value = target.get(name);
|
|
67
|
+
responseValues.push([name, name === "set-cookie" ? target.getSetCookie() : value === null ? [] : [value]]);
|
|
68
|
+
target.delete(name);
|
|
69
|
+
}
|
|
70
|
+
mergeMiddlewareResponseHeaders(target, middlewareHeaders);
|
|
71
|
+
for (const [name, values] of responseValues) {
|
|
72
|
+
if (!middlewareHeaders.get(name)) target.delete(name);
|
|
73
|
+
for (const value of values) target.append(name, value);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Build the response for an external rewrite from the headers routing staged
|
|
78
|
+
* before proxying.
|
|
79
|
+
*
|
|
80
|
+
* Next.js writes the staged config and middleware headers to its outgoing
|
|
81
|
+
* response and then proxies, and the proxy sets each upstream header over
|
|
82
|
+
* them. Its Set-Cookie patch keeps middleware's cookies ahead of the
|
|
83
|
+
* upstream's, so an upstream cookie replaces a staged config cookie while
|
|
84
|
+
* middleware's are kept. Without an upstream Set-Cookie the staged cookies
|
|
85
|
+
* stay as they are.
|
|
86
|
+
*/
|
|
87
|
+
function withExternalRewriteResponseHeaders(upstream, staged, middlewareCookies) {
|
|
88
|
+
staged.delete("content-length");
|
|
89
|
+
for (const name of new Set(upstream.headers.keys())) if (name !== "set-cookie") staged.set(name, upstream.headers.get(name) ?? "");
|
|
90
|
+
const upstreamCookies = upstream.headers.getSetCookie();
|
|
91
|
+
if (upstreamCookies.length > 0) {
|
|
92
|
+
staged.delete("set-cookie");
|
|
93
|
+
for (const cookie of /* @__PURE__ */ new Set([...middlewareCookies, ...upstreamCookies])) staged.append("set-cookie", cookie);
|
|
94
|
+
}
|
|
95
|
+
return new Response(upstream.body, {
|
|
96
|
+
status: upstream.status,
|
|
97
|
+
statusText: upstream.statusText,
|
|
98
|
+
headers: staged
|
|
99
|
+
});
|
|
100
|
+
}
|
|
45
101
|
//#endregion
|
|
46
|
-
export { mergeMiddlewareResponseHeaders, mergeVaryHeader };
|
|
102
|
+
export { mergeMiddlewareResponseHeaders, mergeMiddlewareResponseHeadersOntoResponse, mergeVaryHeader, withExternalRewriteResponseHeaders };
|
|
@@ -87,4 +87,5 @@ export declare function resolveMiddlewareModuleHandler(mod: MiddlewareModule, op
|
|
|
87
87
|
}): MiddlewareHandler;
|
|
88
88
|
export declare function executeMiddleware(options: ExecuteMiddlewareOptions): Promise<MiddlewareResult>;
|
|
89
89
|
export declare function runGeneratedMiddleware(options: RunGeneratedMiddlewareOptions): Promise<MiddlewareResult>;
|
|
90
|
-
//#endregion
|
|
90
|
+
//#endregion
|
|
91
|
+
export {};
|
|
@@ -6,7 +6,7 @@ import { addBasePathToPathname, hasBasePath, removeTrailingSlash, stripBasePath
|
|
|
6
6
|
import { MIDDLEWARE_REWRITE_HEADER } from "./headers.js";
|
|
7
7
|
import { badRequestResponse, internalServerErrorResponse } from "./http-error-responses.js";
|
|
8
8
|
import { isOpenRedirectShaped } from "./open-redirect.js";
|
|
9
|
-
import { processMiddlewareHeaders } from "./request-pipeline.js";
|
|
9
|
+
import { dropEmptyMiddlewareSetCookie, processMiddlewareHeaders } from "./request-pipeline.js";
|
|
10
10
|
import { normalizePathnameForRouteMatchStrict } from "../routing/utils.js";
|
|
11
11
|
import { getRequestExecutionContext, runWithExecutionContext } from "../shims/request-context.js";
|
|
12
12
|
import "./server-globals.js";
|
|
@@ -118,6 +118,7 @@ function dataRedirectResponse(target, originalResponse) {
|
|
|
118
118
|
function collectMiddlewareHeaders(response) {
|
|
119
119
|
const responseHeaders = new Headers();
|
|
120
120
|
for (const [key, value] of response.headers) if (!key.startsWith("x-middleware-") || shouldKeepMiddlewareHeader(key)) responseHeaders.append(key, value);
|
|
121
|
+
dropEmptyMiddlewareSetCookie(responseHeaders);
|
|
121
122
|
return responseHeaders;
|
|
122
123
|
}
|
|
123
124
|
function drainFetchEvent(fetchEvent) {
|
|
@@ -135,12 +136,19 @@ function resolveMiddlewarePathname(request) {
|
|
|
135
136
|
return badRequestResponse();
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
/** The same path and query on another origin. */
|
|
140
|
+
function withOrigin(url, origin) {
|
|
141
|
+
const result = new URL(origin);
|
|
142
|
+
if (result.origin === url.origin) return url;
|
|
143
|
+
result.pathname = url.pathname;
|
|
144
|
+
result.search = url.search;
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
function createNextRequest(request, url, i18nConfig, basePath, trailingSlash, hadBasePath, requestBodyAlreadyIsolated = false, skipTrailingSlashRedirect = false) {
|
|
140
148
|
let mwRequest = !requestBodyAlreadyIsolated && request.body && !request.bodyUsed ? request.clone() : request;
|
|
141
149
|
const requestPathname = url.pathname;
|
|
142
150
|
const mwPathname = basePath && hadBasePath && !hasBasePath(requestPathname, basePath) ? addBasePathToPathname(requestPathname, basePath) : requestPathname;
|
|
143
|
-
if (mwPathname !== url.pathname) {
|
|
151
|
+
if (mwPathname !== url.pathname || url.href !== request.url) {
|
|
144
152
|
const mwUrl = new URL(url);
|
|
145
153
|
mwUrl.pathname = mwPathname;
|
|
146
154
|
mwRequest = new Request(mwUrl, mwRequest);
|
|
@@ -151,7 +159,12 @@ function createNextRequest(request, i18nConfig, basePath, trailingSlash, hadBase
|
|
|
151
159
|
trailingSlash: trailingSlash ?? void 0,
|
|
152
160
|
skipTrailingSlashRedirect
|
|
153
161
|
} : void 0;
|
|
154
|
-
const
|
|
162
|
+
const requestUrl = new URL(request.url);
|
|
163
|
+
const requestHost = requestUrl.origin === url.origin ? void 0 : requestUrl.host;
|
|
164
|
+
const nextRequest = mwRequest instanceof NextRequest && (!mwRequest.body || mwRequest.bodyUsed) ? mwRequest : new NextRequest(mwRequest, nextConfig ? {
|
|
165
|
+
nextConfig,
|
|
166
|
+
requestHost
|
|
167
|
+
} : void 0);
|
|
155
168
|
if (mwRequest !== request && mwRequest.body && !mwRequest.bodyUsed && !mwRequest.body.locked) mwRequest.body.cancel().catch(() => {});
|
|
156
169
|
return nextRequest;
|
|
157
170
|
}
|
|
@@ -219,7 +232,8 @@ async function executeMiddlewareModule(options) {
|
|
|
219
232
|
const decodedMatches = !encodedMatches && decodedMatchPathname !== null && decodedMatchPathname !== encodedMatchPathname && matchesMiddleware(decodedMatchPathname, matcher, options.request, options.i18nConfig, localeContext);
|
|
220
233
|
if (!encodedMatches && !decodedMatches) return { continue: true };
|
|
221
234
|
options.onMatch?.();
|
|
222
|
-
const
|
|
235
|
+
const middlewareUrl = withOrigin(requestUrl, getRequestExecutionContext()?.middlewareOrigin ?? requestUrl.origin);
|
|
236
|
+
const nextRequest = createNextRequest(options.request, middlewareUrl, options.i18nConfig, options.basePath, options.trailingSlash, hadBasePath, options.requestBodyAlreadyIsolated, options.skipTrailingSlashRedirect);
|
|
223
237
|
if (options.isDataRequest) Object.defineProperty(nextRequest, "__isData", {
|
|
224
238
|
enumerable: false,
|
|
225
239
|
value: true
|
|
@@ -260,11 +274,11 @@ async function executeMiddlewareModule(options) {
|
|
|
260
274
|
if (response.status >= 300 && response.status < 400) {
|
|
261
275
|
const location = response.headers.get("Location") ?? response.headers.get("location");
|
|
262
276
|
if (location) {
|
|
263
|
-
const relativeLocation = relativizeLocation(location,
|
|
277
|
+
const relativeLocation = relativizeLocation(location, middlewareUrl.href);
|
|
264
278
|
let normalizedLocation = relativeLocation;
|
|
265
279
|
if (options.trailingSlash !== void 0 && !options.skipTrailingSlashRedirect) try {
|
|
266
|
-
const loc = new URL(relativeLocation,
|
|
267
|
-
if (loc.origin ===
|
|
280
|
+
const loc = new URL(relativeLocation, middlewareUrl);
|
|
281
|
+
if (loc.origin === middlewareUrl.origin) {
|
|
268
282
|
const p = loc.pathname;
|
|
269
283
|
let normalized = null;
|
|
270
284
|
if (p !== "" && p !== "/") {
|
|
@@ -273,7 +287,7 @@ async function executeMiddlewareModule(options) {
|
|
|
273
287
|
}
|
|
274
288
|
if (normalized !== null) {
|
|
275
289
|
loc.pathname = normalized;
|
|
276
|
-
normalizedLocation = relativizeLocation(loc.toString(),
|
|
290
|
+
normalizedLocation = relativizeLocation(loc.toString(), middlewareUrl.href);
|
|
277
291
|
}
|
|
278
292
|
}
|
|
279
293
|
} catch {}
|
|
@@ -311,9 +325,8 @@ async function executeMiddlewareModule(options) {
|
|
|
311
325
|
let rewritePath;
|
|
312
326
|
let rewriteHadBasePath;
|
|
313
327
|
try {
|
|
314
|
-
const rewriteParsed = new URL(rewriteUrl,
|
|
315
|
-
|
|
316
|
-
if (rewriteParsed.origin === requestOrigin) {
|
|
328
|
+
const rewriteParsed = new URL(rewriteUrl, middlewareUrl);
|
|
329
|
+
if (rewriteParsed.origin === middlewareUrl.origin) {
|
|
317
330
|
rewriteHadBasePath = !options.basePath || hasBasePath(rewriteParsed.pathname, options.basePath);
|
|
318
331
|
rewritePath = (options.basePath ? stripBasePath(rewriteParsed.pathname, options.basePath) : rewriteParsed.pathname) + rewriteParsed.search;
|
|
319
332
|
} else rewritePath = rewriteParsed.href;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BrowserRouteManifest } from "../routing/browser-route-manifest.js";
|
|
2
2
|
import { CacheEntryReuseDecision, CacheEntryReuseProof } from "./cache-proof.js";
|
|
3
3
|
import { AppElementsSlotBinding } from "./app-elements-wire.js";
|
|
4
4
|
import "./app-elements.js";
|
|
@@ -230,7 +230,7 @@ type NavigationPrefetchProbeDecision = {
|
|
|
230
230
|
reason: "cacheBypassed" | "refresh" | "visitedResponseAvailable";
|
|
231
231
|
};
|
|
232
232
|
export type NavigationPlannerInput = {
|
|
233
|
-
routeManifest:
|
|
233
|
+
routeManifest: BrowserRouteManifest | null;
|
|
234
234
|
state: NavigationPlannerState;
|
|
235
235
|
event: NavigationEvent;
|
|
236
236
|
};
|
|
@@ -65,4 +65,5 @@ export declare function createNavigationLifecycleTraceFields(options: {
|
|
|
65
65
|
}): NavigationTraceFields;
|
|
66
66
|
export declare function createNavigationTrace(code: NavigationTraceCode, fields?: NavigationTraceFields): NavigationTrace;
|
|
67
67
|
export declare function prependNavigationTraceEntry(trace: NavigationTrace, code: NavigationTraceCode, fields?: NavigationTraceFields): NavigationTrace;
|
|
68
|
-
//#endregion
|
|
68
|
+
//#endregion
|
|
69
|
+
export {};
|
|
@@ -24,4 +24,5 @@ export declare function parseNextRedirectDigest(digest: string): NextRedirectDig
|
|
|
24
24
|
* for the fallback form. Returns null otherwise.
|
|
25
25
|
*/
|
|
26
26
|
export declare function parseNextHttpErrorDigest(digest: string): NextHttpErrorDigest | null;
|
|
27
|
-
//#endregion
|
|
27
|
+
//#endregion
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/server/nitro-public-files-plugin.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Nitro runtime plugin that lets vinext serve the files in `public/`.
|
|
4
|
+
*
|
|
5
|
+
* Nitro's static handler answers a request for a public file before any app
|
|
6
|
+
* handler runs, so middleware would never see it. The plugin sends those
|
|
7
|
+
* requests to vinext instead. vinext's router then decides which public file
|
|
8
|
+
* a request resolves to, for example the destination of a rewrite, but only
|
|
9
|
+
* the static handler can read the file from the server output. The plugin
|
|
10
|
+
* publishes an asset fetcher that sends a request back through the Nitro app,
|
|
11
|
+
* where the static handler answers it.
|
|
12
|
+
*
|
|
13
|
+
* This module runs in Nitro's server bundle, separate from vinext's request
|
|
14
|
+
* handlers, so it imports nothing and shares state through `globalThis`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const NITRO_ASSETS_KEY = "vinext.nitro.assets";
|
|
17
|
+
type NitroApp = {
|
|
18
|
+
fetch: (request: Request) => Response | Promise<Response>;
|
|
19
|
+
captureError?: (error: unknown, context: {
|
|
20
|
+
tags?: string[];
|
|
21
|
+
}) => void;
|
|
22
|
+
};
|
|
23
|
+
export type NitroAssets = {
|
|
24
|
+
fetch(request: Request): Promise<Response>;
|
|
25
|
+
/** Whether a request is an asset fetch that Nitro's static handler did not answer. */
|
|
26
|
+
isAssetRequest(request: Request): boolean;
|
|
27
|
+
};
|
|
28
|
+
type NitroPublicFilesPluginOptions = {
|
|
29
|
+
/**
|
|
30
|
+
* The static files Nitro serves for the files in `public/`, including
|
|
31
|
+
* their compressed copies, keyed as Nitro's static handler keys them.
|
|
32
|
+
*/
|
|
33
|
+
publicAssets: string[];
|
|
34
|
+
/** Sends a request to vinext's request handler. */
|
|
35
|
+
fetchApp(request: Request): Promise<Response>;
|
|
36
|
+
};
|
|
37
|
+
export declare function createNitroPublicFilesPlugin(options: NitroPublicFilesPluginOptions): (nitroApp: NitroApp) => void;
|
|
38
|
+
//#endregion
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
//#region src/server/nitro-public-files-plugin.ts
|
|
2
|
+
/**
|
|
3
|
+
* Nitro runtime plugin that lets vinext serve the files in `public/`.
|
|
4
|
+
*
|
|
5
|
+
* Nitro's static handler answers a request for a public file before any app
|
|
6
|
+
* handler runs, so middleware would never see it. The plugin sends those
|
|
7
|
+
* requests to vinext instead. vinext's router then decides which public file
|
|
8
|
+
* a request resolves to, for example the destination of a rewrite, but only
|
|
9
|
+
* the static handler can read the file from the server output. The plugin
|
|
10
|
+
* publishes an asset fetcher that sends a request back through the Nitro app,
|
|
11
|
+
* where the static handler answers it.
|
|
12
|
+
*
|
|
13
|
+
* This module runs in Nitro's server bundle, separate from vinext's request
|
|
14
|
+
* handlers, so it imports nothing and shares state through `globalThis`.
|
|
15
|
+
*/
|
|
16
|
+
const NITRO_ASSETS_KEY = "vinext.nitro.assets";
|
|
17
|
+
const ASSET_REQUEST_HEADER = "x-vinext-nitro-asset";
|
|
18
|
+
const STATIC_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
|
|
19
|
+
const ENCODING_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
20
|
+
["br", ".br"],
|
|
21
|
+
["gzip", ".gz"],
|
|
22
|
+
["zstd", ".zst"]
|
|
23
|
+
]);
|
|
24
|
+
/**
|
|
25
|
+
* The pathnames h3 can give Nitro's static handler for a request URL. srvx
|
|
26
|
+
* usually hands h3 the URL's path up to the query as it is, so a literal `#`
|
|
27
|
+
* stays in it, but parses the URL fully when the path needs normalizing.
|
|
28
|
+
*/
|
|
29
|
+
function getRequestPathnames(url) {
|
|
30
|
+
const parsed = new URL(url).pathname;
|
|
31
|
+
const start = url.indexOf("/", url.indexOf("://") + 3);
|
|
32
|
+
if (start === -1) return [parsed];
|
|
33
|
+
const query = url.indexOf("?", start);
|
|
34
|
+
const raw = url.slice(start, query === -1 ? void 0 : query);
|
|
35
|
+
return raw === parsed ? [parsed] : [parsed, raw];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The pathname h3 2.0.1-rc.22, which the pinned Nitro uses, gives Nitro's
|
|
39
|
+
* static handler. When it creates the request event, it decodes a pathname
|
|
40
|
+
* that contains `%` except for `%25`, and the URL parser then resolves the
|
|
41
|
+
* result again, for example `\` and `..` segments. Returns `undefined` when
|
|
42
|
+
* h3 fails the request instead. Newer h3 releases leave decoding to Nitro, so
|
|
43
|
+
* the plugin also looks up the pathname without this step.
|
|
44
|
+
*/
|
|
45
|
+
function toH3Pathname(pathname) {
|
|
46
|
+
if (!pathname.includes("%")) return pathname;
|
|
47
|
+
try {
|
|
48
|
+
const url = new URL("http://localhost");
|
|
49
|
+
url.pathname = decodeURI(pathname.replace(/%25/g, "%2525"));
|
|
50
|
+
return url.pathname;
|
|
51
|
+
} catch {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Whether Nitro's static handler would answer a request for a pathname with
|
|
57
|
+
* a public file, following its lookup in `runtime/internal/static.mjs`. It
|
|
58
|
+
* looks h3's pathname up without one trailing slash and decoded except for
|
|
59
|
+
* `%2F`, and then as a directory with an `index.html`, each first with the
|
|
60
|
+
* extension of a compressed copy for every encoding the request accepts.
|
|
61
|
+
*/
|
|
62
|
+
function isPublicFilePathname(pathname, extensions, publicAssets) {
|
|
63
|
+
let id = pathname.length > 1 && pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
64
|
+
try {
|
|
65
|
+
id = decodeURIComponent(id.replace(/%2f/gi, "%252F"));
|
|
66
|
+
} catch {}
|
|
67
|
+
const index = id.endsWith("/") ? `${id}index.html` : `${id}/index.html`;
|
|
68
|
+
return extensions.some((extension) => publicAssets.has(id + extension) || publicAssets.has(index + extension));
|
|
69
|
+
}
|
|
70
|
+
function isPublicFileRequest(request, publicAssets) {
|
|
71
|
+
if (!STATIC_METHODS.has(request.method)) return false;
|
|
72
|
+
const extensions = [""];
|
|
73
|
+
for (const encoding of request.headers.get("accept-encoding")?.split(",") ?? []) {
|
|
74
|
+
const [name, ...params] = encoding.split(";");
|
|
75
|
+
const quality = params.map((param) => param.trim().split("=")).find(([key]) => key.toLowerCase() === "q")?.[1];
|
|
76
|
+
if ((quality === void 0 ? 1 : Number.parseFloat(quality)) <= 0) continue;
|
|
77
|
+
const extension = ENCODING_EXTENSIONS.get(name.trim().toLowerCase());
|
|
78
|
+
if (extension) extensions.push(extension);
|
|
79
|
+
}
|
|
80
|
+
return getRequestPathnames(request.url).some((pathname) => [pathname, toH3Pathname(pathname)].some((candidate) => candidate !== void 0 && isPublicFilePathname(candidate, extensions, publicAssets)));
|
|
81
|
+
}
|
|
82
|
+
function createNitroPublicFilesPlugin(options) {
|
|
83
|
+
const publicAssets = new Set(options.publicAssets);
|
|
84
|
+
return (nitroApp) => {
|
|
85
|
+
const appFetch = nitroApp.fetch;
|
|
86
|
+
const token = crypto.randomUUID();
|
|
87
|
+
Reflect.set(globalThis, Symbol.for(NITRO_ASSETS_KEY), {
|
|
88
|
+
async fetch(request) {
|
|
89
|
+
const headers = new Headers(request.headers);
|
|
90
|
+
headers.set(ASSET_REQUEST_HEADER, token);
|
|
91
|
+
return appFetch(new Request(request, { headers }));
|
|
92
|
+
},
|
|
93
|
+
isAssetRequest: (request) => request.headers.get(ASSET_REQUEST_HEADER) === token
|
|
94
|
+
});
|
|
95
|
+
if (publicAssets.size > 0) nitroApp.fetch = (request) => {
|
|
96
|
+
if (!isPublicFileRequest(request, publicAssets)) return appFetch(request);
|
|
97
|
+
return Promise.resolve().then(() => options.fetchApp(request)).catch((error) => {
|
|
98
|
+
console.error("[vinext]", error);
|
|
99
|
+
nitroApp.captureError?.(error, { tags: ["vinext"] });
|
|
100
|
+
return new Response(null, { status: 500 });
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { NITRO_ASSETS_KEY, createNitroPublicFilesPlugin };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { VinextAssetFetcher } from "./multi-stage.js";
|
|
2
|
+
//#region src/server/nitro-public-files.d.ts
|
|
3
|
+
type NitroFetchEntry = {
|
|
4
|
+
fetch(request: Request): Promise<Response>;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Wrap the App Router SSR service that Nitro dispatches requests to, so a
|
|
8
|
+
* public file the router resolves is served by Nitro's static handler.
|
|
9
|
+
*/
|
|
10
|
+
export declare function withNitroPublicFiles(entry: NitroFetchEntry): NitroFetchEntry;
|
|
11
|
+
type PagesWorkerEntry<Env, Context extends object> = {
|
|
12
|
+
fetch(request: Request, env: Env, ctx: Context & {
|
|
13
|
+
assets?: VinextAssetFetcher;
|
|
14
|
+
}): unknown;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Give the Pages Router worker that Nitro dispatches requests to an asset
|
|
18
|
+
* fetcher that reads files through Nitro's static handler.
|
|
19
|
+
*/
|
|
20
|
+
export declare function withNitroPagesPublicFiles<Env, Context extends object>(worker: PagesWorkerEntry<Env, Context>): PagesWorkerEntry<Env, Context>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createStaticAssetRequest, resolveStaticAssetSignal } from "./worker-utils.js";
|
|
2
|
+
import { NITRO_ASSETS_KEY } from "./nitro-public-files-plugin.js";
|
|
3
|
+
//#region src/server/nitro-public-files.ts
|
|
4
|
+
function getNitroAssets() {
|
|
5
|
+
const assets = Reflect.get(globalThis, Symbol.for(NITRO_ASSETS_KEY));
|
|
6
|
+
if (!assets) throw new Error("[vinext] The Nitro public files plugin did not run.");
|
|
7
|
+
return assets;
|
|
8
|
+
}
|
|
9
|
+
function notFound() {
|
|
10
|
+
return new Response(null, { status: 404 });
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Wrap the App Router SSR service that Nitro dispatches requests to, so a
|
|
14
|
+
* public file the router resolves is served by Nitro's static handler.
|
|
15
|
+
*/
|
|
16
|
+
function withNitroPublicFiles(entry) {
|
|
17
|
+
return { async fetch(request) {
|
|
18
|
+
const assets = getNitroAssets();
|
|
19
|
+
if (assets.isAssetRequest(request)) return notFound();
|
|
20
|
+
const response = await entry.fetch(request);
|
|
21
|
+
return await resolveStaticAssetSignal(response, { fetchAsset: (path, requestHeaders) => assets.fetch(createStaticAssetRequest(path, request, requestHeaders)) }) ?? response;
|
|
22
|
+
} };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Give the Pages Router worker that Nitro dispatches requests to an asset
|
|
26
|
+
* fetcher that reads files through Nitro's static handler.
|
|
27
|
+
*/
|
|
28
|
+
function withNitroPagesPublicFiles(worker) {
|
|
29
|
+
return { fetch(request, env, ctx) {
|
|
30
|
+
const assets = getNitroAssets();
|
|
31
|
+
if (assets.isAssetRequest(request)) return notFound();
|
|
32
|
+
return worker.fetch(request, env, {
|
|
33
|
+
...ctx,
|
|
34
|
+
assets
|
|
35
|
+
});
|
|
36
|
+
} };
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { withNitroPagesPublicFiles, withNitroPublicFiles };
|
|
@@ -56,4 +56,5 @@ export type OpenTelemetryApi = {
|
|
|
56
56
|
export declare function getOpenTelemetryRootContext(): OpenTelemetryContext;
|
|
57
57
|
/** Resolve the API registered by the application, if any. */
|
|
58
58
|
export declare function getOpenTelemetryApi(): OpenTelemetryApi | undefined;
|
|
59
|
-
//#endregion
|
|
59
|
+
//#endregion
|
|
60
|
+
export {};
|
|
@@ -36,4 +36,5 @@ export type OperationTokenVerificationPolicy = {
|
|
|
36
36
|
export declare function verifyOperationToken(token: OperationToken, authority: OperationTokenAuthority, policy: OperationTokenVerificationPolicy): OperationTokenVerdict;
|
|
37
37
|
export declare function verifyOperationTokenForCommit(token: OperationToken, authority: Pick<OperationTokenAuthority, "activeNavigationId" | "visibleCommitVersion">): OperationTokenVerdict;
|
|
38
38
|
export declare function verifyOperationTokenForCacheReuse(token: OperationToken, authority: Pick<OperationTokenAuthority, "graphVersion" | "installedCacheVariantFingerprint">): OperationTokenVerdict;
|
|
39
|
-
//#endregion
|
|
39
|
+
//#endregion
|
|
40
|
+
export {};
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
* unit-testable and lives in a normal typed module rather than a codegen
|
|
10
10
|
* template string.
|
|
11
11
|
*/
|
|
12
|
+
/**
|
|
13
|
+
* Fallback for when no build-time `sharedChunks` list is registered. Prefers
|
|
14
|
+
* the chunk-name based list the build writes into the SSR manifest; the file
|
|
15
|
+
* name scan only matches `[name]-[hash]` names, not hash-only ones.
|
|
16
|
+
*/
|
|
12
17
|
export declare function getSharedChunkFiles(manifest: Record<string, string[]>): string[];
|
|
13
18
|
/**
|
|
14
19
|
* Resolve the effective SSR manifest: prefer the caller-supplied object and
|
|
@@ -76,4 +81,5 @@ type CollectAssetTagsOptions = {
|
|
|
76
81
|
* Extracted from `entries/pages-server-entry.ts`.
|
|
77
82
|
*/
|
|
78
83
|
export declare function collectAssetTags(options: CollectAssetTagsOptions): string;
|
|
79
|
-
//#endregion
|
|
84
|
+
//#endregion
|
|
85
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { appendDeploymentIdQuery } from "../utils/deployment-id.js";
|
|
2
2
|
import { createNonceAttribute } from "./html.js";
|
|
3
|
-
import { assetServingUrlFromBaseAnchored } from "../utils/manifest-paths.js";
|
|
3
|
+
import { SSR_MANIFEST_SHARED_CHUNKS_KEY, assetServingUrlFromBaseAnchored } from "../utils/manifest-paths.js";
|
|
4
4
|
import { getPagesClientAssets } from "./pages-client-assets.js";
|
|
5
5
|
//#region src/server/pages-asset-tags.ts
|
|
6
6
|
/**
|
|
@@ -55,7 +55,14 @@ function findModuleKey(manifest, moduleId) {
|
|
|
55
55
|
}
|
|
56
56
|
return matchedKey;
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Fallback for when no build-time `sharedChunks` list is registered. Prefers
|
|
60
|
+
* the chunk-name based list the build writes into the SSR manifest; the file
|
|
61
|
+
* name scan only matches `[name]-[hash]` names, not hash-only ones.
|
|
62
|
+
*/
|
|
58
63
|
function getSharedChunkFiles(manifest) {
|
|
64
|
+
const recorded = manifest[SSR_MANIFEST_SHARED_CHUNKS_KEY];
|
|
65
|
+
if (recorded) return recorded;
|
|
59
66
|
const cached = sharedChunkFiles.get(manifest);
|
|
60
67
|
if (cached) return cached;
|
|
61
68
|
const files = /* @__PURE__ */ new Set();
|
|
@@ -186,7 +193,7 @@ function collectAssetTags(options) {
|
|
|
186
193
|
const files = getManifestFilesForModule(m, id);
|
|
187
194
|
if (files) for (let fi = 0; fi < files.length; fi++) allFiles.push(files[fi]);
|
|
188
195
|
}
|
|
189
|
-
const sharedFiles =
|
|
196
|
+
const sharedFiles = runtimeAssets.sharedChunks ?? getSharedChunkFiles(m);
|
|
190
197
|
for (const file of sharedFiles) allFiles.push(file);
|
|
191
198
|
} else for (const akey in m) {
|
|
192
199
|
const avals = m[akey];
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import { ClientReferenceChunks } from "../utils/client-reference-chunks.js";
|
|
1
2
|
//#region src/server/pages-client-assets.d.ts
|
|
2
3
|
export type AssetCrossOrigin = "" | "anonymous" | "use-credentials";
|
|
3
4
|
export type PagesClientAssets = {
|
|
4
5
|
clientEntry?: string;
|
|
5
6
|
appBootstrapPreinitModules?: string[];
|
|
7
|
+
appRouteManifestModule?: string;
|
|
8
|
+
/** What each App Router client reference loads in the browser, by URL. */
|
|
9
|
+
appClientReferenceChunks?: ClientReferenceChunks;
|
|
6
10
|
ssrManifest?: Record<string, string[]>;
|
|
7
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Shared Pages chunk files (framework, vinext runtime, client entry) keyed on
|
|
13
|
+
* chunk names from this client build, in the SSR-manifest key-space.
|
|
14
|
+
*/
|
|
8
15
|
sharedChunks?: string[];
|
|
9
16
|
cssGraph?: Record<string, {
|
|
10
17
|
imports?: string[];
|
|
@@ -138,4 +138,5 @@ type NormalizePagesDataRequestResult = {
|
|
|
138
138
|
* `runMiddleware` share a single implementation.
|
|
139
139
|
*/
|
|
140
140
|
export declare function normalizePagesDataRequest(request: Request, buildId: string | null, basePath?: string, trailingSlash?: boolean): NormalizePagesDataRequestResult;
|
|
141
|
-
//#endregion
|
|
141
|
+
//#endregion
|
|
142
|
+
export {};
|
|
@@ -26,4 +26,5 @@ export declare function extractDocumentAssetProps(html: string, token: string):
|
|
|
26
26
|
export declare function markDocumentAssetPropsProtectedTags(html: string, markerAttribute: string): string;
|
|
27
27
|
export declare function stripDocumentAssetPropsProtectionMarkers(html: string, markerAttribute: string): string;
|
|
28
28
|
export declare function applyDocumentAssetProps(html: string, props: DocumentAssetProps, options?: ApplyDocumentAssetPropsOptions): string;
|
|
29
|
-
//#endregion
|
|
29
|
+
//#endregion
|
|
30
|
+
export {};
|
|
@@ -78,4 +78,5 @@ type RunDocumentRenderPageResult = {
|
|
|
78
78
|
* @see .nextjs-ref/packages/next/src/server/render.tsx (search `renderPage`)
|
|
79
79
|
*/
|
|
80
80
|
export declare function runDocumentRenderPage(input: DocumentRenderPageInput): Promise<RunDocumentRenderPageResult>;
|
|
81
|
-
//#endregion
|
|
81
|
+
//#endregion
|
|
82
|
+
export {};
|
|
@@ -37,4 +37,5 @@ export declare function createFindPageComponentsSpanDescriptor(routePattern: str
|
|
|
37
37
|
readonly type: "NextNodeServer.findPageComponents";
|
|
38
38
|
};
|
|
39
39
|
export declare function traceFindPageComponents<T>(routePattern: string, callback: () => T): T;
|
|
40
|
-
//#endregion
|
|
40
|
+
//#endregion
|
|
41
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { deferUntilStreamConsumed } from "./defer-until-stream-consumed.js";
|
|
1
2
|
import { patternToNextFormat } from "../routing/route-validation.js";
|
|
2
3
|
import { frameworkTracer } from "./tracer.js";
|
|
3
|
-
import { deferUntilStreamConsumed } from "./defer-until-stream-consumed.js";
|
|
4
4
|
//#region src/server/pages-execution-tracing.ts
|
|
5
5
|
function createPagesDataSpanDescriptor(method, routePattern) {
|
|
6
6
|
const route = patternToNextFormat(routePattern);
|
|
@@ -63,12 +63,30 @@ export declare function detectPathnameLocale(pathname: string, locales: readonly
|
|
|
63
63
|
* `:locale`. After normalisation the request looks like `/en/to-sv` and
|
|
64
64
|
* the rule matches with `:locale=en`.
|
|
65
65
|
*
|
|
66
|
+
* `restoreRootTrailingSlash` makes the root `/en/` rather than `/en`; header
|
|
67
|
+
* callers compute it with `shouldRestoreLocaleRootTrailingSlash`. Redirect
|
|
68
|
+
* and rewrite callers do not pass it yet.
|
|
69
|
+
*
|
|
66
70
|
* Ported from Next.js: packages/next/src/server/lib/router-utils/resolve-routes.ts
|
|
67
71
|
* https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/router-utils/resolve-routes.ts
|
|
68
72
|
*/
|
|
69
73
|
export declare function normalizeDefaultLocalePathname(pathname: string, i18n: NextI18nConfig | null | undefined, options?: {
|
|
70
74
|
hostname?: string | null;
|
|
75
|
+
restoreRootTrailingSlash?: boolean;
|
|
71
76
|
}): string;
|
|
77
|
+
/**
|
|
78
|
+
* Whether Next.js re-adds the root's trailing slash after splicing in the
|
|
79
|
+
* default locale: the raw request pathname (basePath included, so `/docs`
|
|
80
|
+
* stays `/docs/en` while `/docs/` becomes `/docs/en/`) ends with `/`, and
|
|
81
|
+
* `trailingSlash` is on without `skipProxyUrlNormalize`.
|
|
82
|
+
*
|
|
83
|
+
* Ported from Next.js: packages/next/src/server/lib/router-utils/resolve-routes.ts
|
|
84
|
+
* (`hadTrailingSlash` + `maybeAddTrailingSlash`).
|
|
85
|
+
*/
|
|
86
|
+
export declare function shouldRestoreLocaleRootTrailingSlash(rawPathname: string, config: {
|
|
87
|
+
trailingSlash?: boolean;
|
|
88
|
+
skipProxyUrlNormalize?: boolean;
|
|
89
|
+
}): boolean;
|
|
72
90
|
/**
|
|
73
91
|
* Extract locale prefix from a URL path.
|
|
74
92
|
* e.g. /fr/about -> { locale: "fr", url: "/about", hadPrefix: true }
|
|
@@ -51,6 +51,10 @@ function detectPathnameLocale(pathname, locales) {
|
|
|
51
51
|
* `:locale`. After normalisation the request looks like `/en/to-sv` and
|
|
52
52
|
* the rule matches with `:locale=en`.
|
|
53
53
|
*
|
|
54
|
+
* `restoreRootTrailingSlash` makes the root `/en/` rather than `/en`; header
|
|
55
|
+
* callers compute it with `shouldRestoreLocaleRootTrailingSlash`. Redirect
|
|
56
|
+
* and rewrite callers do not pass it yet.
|
|
57
|
+
*
|
|
54
58
|
* Ported from Next.js: packages/next/src/server/lib/router-utils/resolve-routes.ts
|
|
55
59
|
* https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/router-utils/resolve-routes.ts
|
|
56
60
|
*/
|
|
@@ -59,10 +63,22 @@ function normalizeDefaultLocalePathname(pathname, i18n, options = {}) {
|
|
|
59
63
|
if (pathname.startsWith("/_next/") || pathname.startsWith("/__vinext/")) return pathname;
|
|
60
64
|
if (detectPathnameLocale(pathname, i18n.locales)) return pathname;
|
|
61
65
|
const defaultLocale = detectDomainLocale(i18n.domains, options.hostname ?? void 0)?.defaultLocale ?? i18n.defaultLocale;
|
|
62
|
-
if (pathname === "/") return `/${defaultLocale}`;
|
|
66
|
+
if (pathname === "/") return options.restoreRootTrailingSlash ? `/${defaultLocale}/` : `/${defaultLocale}`;
|
|
63
67
|
return `/${defaultLocale}${pathname}`;
|
|
64
68
|
}
|
|
65
69
|
/**
|
|
70
|
+
* Whether Next.js re-adds the root's trailing slash after splicing in the
|
|
71
|
+
* default locale: the raw request pathname (basePath included, so `/docs`
|
|
72
|
+
* stays `/docs/en` while `/docs/` becomes `/docs/en/`) ends with `/`, and
|
|
73
|
+
* `trailingSlash` is on without `skipProxyUrlNormalize`.
|
|
74
|
+
*
|
|
75
|
+
* Ported from Next.js: packages/next/src/server/lib/router-utils/resolve-routes.ts
|
|
76
|
+
* (`hadTrailingSlash` + `maybeAddTrailingSlash`).
|
|
77
|
+
*/
|
|
78
|
+
function shouldRestoreLocaleRootTrailingSlash(rawPathname, config) {
|
|
79
|
+
return Boolean(config.trailingSlash && !config.skipProxyUrlNormalize && rawPathname.endsWith("/"));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
66
82
|
* Extract locale prefix from a URL path.
|
|
67
83
|
* e.g. /fr/about -> { locale: "fr", url: "/about", hadPrefix: true }
|
|
68
84
|
* /about -> { locale: defaultLocale, url: "/about", hadPrefix: false }
|
|
@@ -243,4 +259,4 @@ function resolvePagesI18nRequest(url, i18nConfig, headers, hostname, basePath =
|
|
|
243
259
|
};
|
|
244
260
|
}
|
|
245
261
|
//#endregion
|
|
246
|
-
export { detectDomainLocale, detectLocaleFromAcceptLanguage, detectPathnameLocale, extractLocaleFromUrl, getLocaleRedirect, normalizeDefaultLocalePathname, parseCookieLocaleFromHeader, resolvePagesI18nRequest, stripI18nLocaleForApiRoute };
|
|
262
|
+
export { detectDomainLocale, detectLocaleFromAcceptLanguage, detectPathnameLocale, extractLocaleFromUrl, getLocaleRedirect, normalizeDefaultLocalePathname, parseCookieLocaleFromHeader, resolvePagesI18nRequest, shouldRestoreLocaleRootTrailingSlash, stripI18nLocaleForApiRoute };
|