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
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
+
import { parseModuleRecord } from "../plugins/ast-utils.js";
|
|
3
|
+
import { actionOwnerRouteEntryIds } from "./action-owner-manifest.js";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
//#region src/build/client-reference-groups.ts
|
|
6
|
+
/**
|
|
7
|
+
* Client references whose estimated group cost (see
|
|
8
|
+
* {@link measureClientReferenceGroupCosts}) is larger than this many
|
|
9
|
+
* transformed source bytes keep their own lazy chunk instead of joining a route
|
|
10
|
+
* group. Grouping makes every member load with the group, so a heavy component
|
|
11
|
+
* that a route can reach but rarely renders must not be pulled into that
|
|
12
|
+
* route's startup bundle.
|
|
13
|
+
*/
|
|
14
|
+
const CLIENT_REFERENCE_GROUP_MAX_COST_BYTES = 102400;
|
|
15
|
+
const SEGMENT_FILE_ORDER = [
|
|
16
|
+
"layout",
|
|
17
|
+
"template",
|
|
18
|
+
"error",
|
|
19
|
+
"unauthorized",
|
|
20
|
+
"forbidden",
|
|
21
|
+
"not-found",
|
|
22
|
+
"loading",
|
|
23
|
+
"default",
|
|
24
|
+
"page"
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* Order route files as they render: outer segments first and, within a
|
|
28
|
+
* segment, each file before the ones it wraps. A group evaluates its members in
|
|
29
|
+
* the order the walk reaches them, so this keeps an outer layout's top-level
|
|
30
|
+
* side effects and CSS ahead of its page's, as Next.js evaluates client
|
|
31
|
+
* references in render order.
|
|
32
|
+
*/
|
|
33
|
+
function inRenderOrder(files) {
|
|
34
|
+
const rank = (file) => {
|
|
35
|
+
const index = SEGMENT_FILE_ORDER.indexOf(path.basename(file).split(".")[0]);
|
|
36
|
+
return index === -1 ? SEGMENT_FILE_ORDER.length : index;
|
|
37
|
+
};
|
|
38
|
+
return files.map((file) => ({
|
|
39
|
+
file,
|
|
40
|
+
depth: path.dirname(file).split("/").length,
|
|
41
|
+
rank: rank(file)
|
|
42
|
+
})).sort((a, b) => a.depth - b.depth || a.rank - b.rank).map(({ file }) => file);
|
|
43
|
+
}
|
|
44
|
+
function interceptEntryIds(intercept) {
|
|
45
|
+
return [
|
|
46
|
+
intercept.pagePath,
|
|
47
|
+
...intercept.layoutPaths,
|
|
48
|
+
...intercept.loadingPaths ?? [],
|
|
49
|
+
intercept.notFoundPath,
|
|
50
|
+
intercept.forbiddenPath,
|
|
51
|
+
intercept.unauthorizedPath,
|
|
52
|
+
...intercept.notFoundPaths ?? [],
|
|
53
|
+
...intercept.forbiddenPaths ?? [],
|
|
54
|
+
...intercept.unauthorizedPaths ?? [],
|
|
55
|
+
...intercept.errorPaths ?? []
|
|
56
|
+
].filter((value) => typeof value === "string");
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Map each client reference reachable from App Router route files to a
|
|
60
|
+
* signature naming the owners that reach it. A route owns its page, layouts,
|
|
61
|
+
* templates, boundaries and parallel slots, which render with it. Intercepting
|
|
62
|
+
* routes (which only render on soft navigation), global-error and
|
|
63
|
+
* global-not-found render on their own, so each is owned by its file, named by
|
|
64
|
+
* its path relative to `root`. References with the same signature are needed
|
|
65
|
+
* together, mirroring Next.js' per-route client entries. The map is in the
|
|
66
|
+
* order a depth-first walk in import order first reaches each reference from
|
|
67
|
+
* the route files in render order, which follows ES module evaluation order.
|
|
68
|
+
*
|
|
69
|
+
* References reachable from no route file (for example vinext's internal
|
|
70
|
+
* runtime references) are omitted and keep their own lazy chunk. So are
|
|
71
|
+
* references that route code reaches through a dynamic import (`next/dynamic`,
|
|
72
|
+
* `React.lazy`), directly or through the dynamically imported module's graph.
|
|
73
|
+
*/
|
|
74
|
+
function collectClientReferenceRouteSignatures(options) {
|
|
75
|
+
const canonicalize = options.canonicalizeModuleId ?? ((id) => id);
|
|
76
|
+
const moduleInfoCache = /* @__PURE__ */ new Map();
|
|
77
|
+
const getModuleInfo = (id) => {
|
|
78
|
+
let info = moduleInfoCache.get(id);
|
|
79
|
+
if (info === void 0) {
|
|
80
|
+
info = options.getModuleInfo(id);
|
|
81
|
+
moduleInfoCache.set(id, info);
|
|
82
|
+
}
|
|
83
|
+
return info;
|
|
84
|
+
};
|
|
85
|
+
const lazyReferences = /* @__PURE__ */ new Set();
|
|
86
|
+
const lazyVisited = /* @__PURE__ */ new Set();
|
|
87
|
+
const markLazy = (root) => {
|
|
88
|
+
const stack = [root];
|
|
89
|
+
while (stack.length > 0) {
|
|
90
|
+
const id = stack.pop();
|
|
91
|
+
if (lazyVisited.has(id)) continue;
|
|
92
|
+
lazyVisited.add(id);
|
|
93
|
+
if (options.clientReferenceIds.has(id)) {
|
|
94
|
+
lazyReferences.add(id);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const info = getModuleInfo(id);
|
|
98
|
+
if (info) stack.push(...info.importedIds, ...info.dynamicallyImportedIds);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const referencesByFile = /* @__PURE__ */ new Map();
|
|
102
|
+
const referencesReachedFrom = (file) => {
|
|
103
|
+
let references = referencesByFile.get(file);
|
|
104
|
+
if (references) return references;
|
|
105
|
+
references = /* @__PURE__ */ new Set();
|
|
106
|
+
const visited = /* @__PURE__ */ new Set();
|
|
107
|
+
const stack = [canonicalize(file)];
|
|
108
|
+
while (stack.length > 0) {
|
|
109
|
+
const id = stack.pop();
|
|
110
|
+
if (visited.has(id)) continue;
|
|
111
|
+
visited.add(id);
|
|
112
|
+
if (options.clientReferenceIds.has(id)) {
|
|
113
|
+
references.add(id);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const info = getModuleInfo(id);
|
|
117
|
+
if (!info) continue;
|
|
118
|
+
for (const importedId of info.dynamicallyImportedIds) markLazy(importedId);
|
|
119
|
+
for (let index = info.importedIds.length - 1; index >= 0; index--) stack.push(info.importedIds[index]);
|
|
120
|
+
}
|
|
121
|
+
referencesByFile.set(file, references);
|
|
122
|
+
return references;
|
|
123
|
+
};
|
|
124
|
+
const owners = /* @__PURE__ */ new Map();
|
|
125
|
+
const addOwner = (owner, files) => {
|
|
126
|
+
for (const file of files) for (const reference of referencesReachedFrom(file)) {
|
|
127
|
+
let referenceOwners = owners.get(reference);
|
|
128
|
+
if (!referenceOwners) {
|
|
129
|
+
referenceOwners = /* @__PURE__ */ new Set();
|
|
130
|
+
owners.set(reference, referenceOwners);
|
|
131
|
+
}
|
|
132
|
+
referenceOwners.add(owner);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const fileOwner = (file) => path.relative(options.root, file);
|
|
136
|
+
for (const route of options.routes) {
|
|
137
|
+
addOwner(route.pattern, inRenderOrder(actionOwnerRouteEntryIds({
|
|
138
|
+
...route,
|
|
139
|
+
parallelSlots: route.parallelSlots.map((slot) => ({
|
|
140
|
+
...slot,
|
|
141
|
+
interceptingRoutes: []
|
|
142
|
+
})),
|
|
143
|
+
siblingIntercepts: []
|
|
144
|
+
})));
|
|
145
|
+
const intercepts = [...route.parallelSlots.flatMap((slot) => slot.interceptingRoutes), ...route.siblingIntercepts];
|
|
146
|
+
for (const intercept of intercepts) addOwner(fileOwner(intercept.pagePath), inRenderOrder(interceptEntryIds(intercept)));
|
|
147
|
+
}
|
|
148
|
+
for (const file of options.sharedRoots ?? []) addOwner(fileOwner(file), [file]);
|
|
149
|
+
const signatures = /* @__PURE__ */ new Map();
|
|
150
|
+
for (const [reference, referenceOwners] of owners) {
|
|
151
|
+
if (lazyReferences.has(reference)) continue;
|
|
152
|
+
signatures.set(reference, [...referenceOwners].sort().join("\n"));
|
|
153
|
+
}
|
|
154
|
+
return signatures;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Plan which client references SSR loads before rendering each route. A route
|
|
158
|
+
* preloads every client reference its page, layouts, templates, boundaries and
|
|
159
|
+
* parallel slots reach, statically or through dynamic imports (a
|
|
160
|
+
* `next/dynamic` component renders on the server), plus the `always` set.
|
|
161
|
+
* Intercepting routes only render on soft navigation, which SSR never
|
|
162
|
+
* renders, so they add to no set. `entryIds` are the RSC graph's entries:
|
|
163
|
+
* walking them up to route files finds what renders outside any route.
|
|
164
|
+
*/
|
|
165
|
+
function collectClientReferencePreloadPlan(options) {
|
|
166
|
+
const canonicalize = options.canonicalizeModuleId ?? ((id) => id);
|
|
167
|
+
const moduleInfoCache = /* @__PURE__ */ new Map();
|
|
168
|
+
const getModuleInfo = (id) => {
|
|
169
|
+
let info = moduleInfoCache.get(id);
|
|
170
|
+
if (info === void 0) {
|
|
171
|
+
info = options.getModuleInfo(id);
|
|
172
|
+
moduleInfoCache.set(id, info);
|
|
173
|
+
}
|
|
174
|
+
return info;
|
|
175
|
+
};
|
|
176
|
+
const reached = /* @__PURE__ */ new Set();
|
|
177
|
+
const referencesReachedFrom = (roots, stopAt) => {
|
|
178
|
+
const references = [];
|
|
179
|
+
const visited = /* @__PURE__ */ new Set();
|
|
180
|
+
const stack = roots.map(canonicalize).reverse();
|
|
181
|
+
while (stack.length > 0) {
|
|
182
|
+
const id = stack.pop();
|
|
183
|
+
if (visited.has(id)) continue;
|
|
184
|
+
visited.add(id);
|
|
185
|
+
if (stopAt?.has(id)) continue;
|
|
186
|
+
if (options.clientReferenceIds.has(id)) {
|
|
187
|
+
references.push(id);
|
|
188
|
+
reached.add(id);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const info = getModuleInfo(id);
|
|
192
|
+
if (!info) continue;
|
|
193
|
+
const imports = [...info.importedIds, ...info.dynamicallyImportedIds];
|
|
194
|
+
for (let index = imports.length - 1; index >= 0; index--) stack.push(imports[index]);
|
|
195
|
+
}
|
|
196
|
+
return references;
|
|
197
|
+
};
|
|
198
|
+
const files = [];
|
|
199
|
+
const fileIndices = /* @__PURE__ */ new Map();
|
|
200
|
+
const fileIndex = (file) => {
|
|
201
|
+
const id = canonicalize(file);
|
|
202
|
+
let index = fileIndices.get(id);
|
|
203
|
+
if (index === void 0) {
|
|
204
|
+
index = files.length;
|
|
205
|
+
fileIndices.set(id, index);
|
|
206
|
+
files.push(referencesReachedFrom([id]));
|
|
207
|
+
}
|
|
208
|
+
return index;
|
|
209
|
+
};
|
|
210
|
+
const routes = /* @__PURE__ */ new Map();
|
|
211
|
+
const interceptFiles = [];
|
|
212
|
+
for (const route of options.routes) {
|
|
213
|
+
const indices = inRenderOrder(actionOwnerRouteEntryIds({
|
|
214
|
+
...route,
|
|
215
|
+
parallelSlots: route.parallelSlots.map((slot) => ({
|
|
216
|
+
...slot,
|
|
217
|
+
interceptingRoutes: []
|
|
218
|
+
})),
|
|
219
|
+
siblingIntercepts: []
|
|
220
|
+
})).map(fileIndex);
|
|
221
|
+
routes.set(route.pattern, [.../* @__PURE__ */ new Set([...routes.get(route.pattern) ?? [], ...indices])]);
|
|
222
|
+
for (const intercept of [...route.parallelSlots.flatMap((slot) => slot.interceptingRoutes), ...route.siblingIntercepts]) interceptFiles.push(...interceptEntryIds(intercept));
|
|
223
|
+
}
|
|
224
|
+
const routeless = [...new Set((options.routelessFiles ?? []).map(fileIndex))];
|
|
225
|
+
referencesReachedFrom(interceptFiles);
|
|
226
|
+
const alwaysRoots = options.alwaysRoots ?? [];
|
|
227
|
+
const stopAt = /* @__PURE__ */ new Set([...fileIndices.keys(), ...[...interceptFiles, ...alwaysRoots].map(canonicalize)]);
|
|
228
|
+
const always = /* @__PURE__ */ new Set([...referencesReachedFrom(options.entryIds, stopAt), ...referencesReachedFrom(alwaysRoots)]);
|
|
229
|
+
for (const id of options.clientReferenceIds) if (!reached.has(id)) always.add(id);
|
|
230
|
+
const dynamicallyReached = /* @__PURE__ */ new Set();
|
|
231
|
+
const visited = /* @__PURE__ */ new Set();
|
|
232
|
+
const pending = [...options.entryIds.map(canonicalize), ...stopAt].map((id) => [
|
|
233
|
+
id,
|
|
234
|
+
false,
|
|
235
|
+
true
|
|
236
|
+
]);
|
|
237
|
+
while (pending.length > 0) {
|
|
238
|
+
const [id, dynamic, root] = pending.pop();
|
|
239
|
+
if (!root && stopAt.has(id)) continue;
|
|
240
|
+
const key = dynamic ? `dynamic:${id}` : id;
|
|
241
|
+
if (visited.has(key)) continue;
|
|
242
|
+
visited.add(key);
|
|
243
|
+
if (options.clientReferenceIds.has(id)) {
|
|
244
|
+
if (dynamic) dynamicallyReached.add(id);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const info = getModuleInfo(id);
|
|
248
|
+
if (!info) continue;
|
|
249
|
+
for (const imported of info.importedIds) pending.push([
|
|
250
|
+
imported,
|
|
251
|
+
dynamic,
|
|
252
|
+
false
|
|
253
|
+
]);
|
|
254
|
+
for (const imported of info.dynamicallyImportedIds) pending.push([
|
|
255
|
+
imported,
|
|
256
|
+
true,
|
|
257
|
+
false
|
|
258
|
+
]);
|
|
259
|
+
}
|
|
260
|
+
const staticOnly = [...new Set(files.flat())].filter((id) => !always.has(id) && !dynamicallyReached.has(id));
|
|
261
|
+
return {
|
|
262
|
+
always: [...always],
|
|
263
|
+
files,
|
|
264
|
+
routes,
|
|
265
|
+
routeless,
|
|
266
|
+
staticOnly
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function importedName(kind, name) {
|
|
270
|
+
if (kind === "Name") return name;
|
|
271
|
+
return kind === "Default" ? "default" : "*";
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Read a module's static imports and re-exports for
|
|
275
|
+
* {@link measureClientReferenceGroupCosts}. Returns undefined when the code does
|
|
276
|
+
* not parse or a specifier does not resolve to one of `importedIds`.
|
|
277
|
+
*/
|
|
278
|
+
async function readClientModuleBindings(options) {
|
|
279
|
+
const { code } = options;
|
|
280
|
+
const record = parseModuleRecord(code, "js");
|
|
281
|
+
if (!record) return void 0;
|
|
282
|
+
const specifiers = /* @__PURE__ */ new Set([...record.staticImports.map((statement) => statement.moduleRequest.value), ...record.staticExports.flatMap((statement) => statement.entries.flatMap((entry) => entry.moduleRequest ? [entry.moduleRequest.value] : []))]);
|
|
283
|
+
const importedIds = new Set(options.importedIds);
|
|
284
|
+
const ids = /* @__PURE__ */ new Map();
|
|
285
|
+
for (const [specifier, id] of await Promise.all([...specifiers].map(async (specifier) => [specifier, await options.resolve(specifier)]))) {
|
|
286
|
+
if (id === null || !importedIds.has(id)) return void 0;
|
|
287
|
+
ids.set(specifier, id);
|
|
288
|
+
}
|
|
289
|
+
const isIndirect = (statement) => code.startsWith("import", statement.start);
|
|
290
|
+
const exportList = /export\s*[{*]/y;
|
|
291
|
+
const ranges = [
|
|
292
|
+
...record.staticImports,
|
|
293
|
+
...record.staticExports.filter((statement) => {
|
|
294
|
+
exportList.lastIndex = statement.start;
|
|
295
|
+
return exportList.test(code);
|
|
296
|
+
}),
|
|
297
|
+
...record.staticExports.filter(isIndirect).flatMap((statement) => statement.entries)
|
|
298
|
+
].sort((a, b) => a.start - b.start);
|
|
299
|
+
let body = "";
|
|
300
|
+
let offset = 0;
|
|
301
|
+
for (const range of ranges) {
|
|
302
|
+
if (range.start > offset) body += code.slice(offset, range.start);
|
|
303
|
+
offset = Math.max(offset, range.end);
|
|
304
|
+
}
|
|
305
|
+
body += code.slice(offset);
|
|
306
|
+
const reexports = [];
|
|
307
|
+
const localExports = /* @__PURE__ */ new Map();
|
|
308
|
+
const addLocalExport = (key, exportName) => localExports.set(key, [...localExports.get(key) ?? [], exportName]);
|
|
309
|
+
for (const statement of record.staticExports) for (const entry of statement.entries) {
|
|
310
|
+
const exportName = importedName(entry.exportName.kind, entry.exportName.name);
|
|
311
|
+
const importName = importedName(entry.importName.kind, entry.importName.name);
|
|
312
|
+
if (entry.moduleRequest && isIndirect(statement)) addLocalExport(`\0${entry.importName.start}`, exportName);
|
|
313
|
+
else if (entry.moduleRequest) reexports.push({
|
|
314
|
+
id: ids.get(entry.moduleRequest.value),
|
|
315
|
+
exportName,
|
|
316
|
+
importName
|
|
317
|
+
});
|
|
318
|
+
else if (entry.localName.name !== null) addLocalExport(entry.localName.name, exportName);
|
|
319
|
+
}
|
|
320
|
+
const imports = [];
|
|
321
|
+
for (const statement of record.staticImports) {
|
|
322
|
+
const id = ids.get(statement.moduleRequest.value);
|
|
323
|
+
imports.push({
|
|
324
|
+
id,
|
|
325
|
+
names: /* @__PURE__ */ new Set()
|
|
326
|
+
});
|
|
327
|
+
for (const entry of statement.entries) {
|
|
328
|
+
if (entry.isType) continue;
|
|
329
|
+
const name = importedName(entry.importName.kind, entry.importName.name);
|
|
330
|
+
const local = entry.localName.value;
|
|
331
|
+
const exportNames = [...localExports.get(local) ?? [], ...entry.importName.start !== null && localExports.get(`\0${entry.importName.start}`) || []];
|
|
332
|
+
if (exportNames.length > 0 && !new RegExp(`(?<![\\w$])${local.replaceAll("$", "\\$")}(?![\\w$])`).test(body)) for (const exportName of exportNames) reexports.push({
|
|
333
|
+
id,
|
|
334
|
+
exportName,
|
|
335
|
+
importName: name
|
|
336
|
+
});
|
|
337
|
+
else imports.push({
|
|
338
|
+
id,
|
|
339
|
+
names: name === "*" ? "*" : /* @__PURE__ */ new Set([name])
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const covered = new Set(ids.values());
|
|
344
|
+
for (const id of options.importedIds) if (!covered.has(id)) imports.push({
|
|
345
|
+
id,
|
|
346
|
+
names: "*"
|
|
347
|
+
});
|
|
348
|
+
return {
|
|
349
|
+
bytes: Buffer.byteLength(body, "utf8"),
|
|
350
|
+
imports,
|
|
351
|
+
reexports
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Estimate, in transformed source bytes, how much code each client reference
|
|
356
|
+
* would add to a route group's chunk: the modules only it uses, plus the cost
|
|
357
|
+
* of every client reference it statically imports (grouping a reference pulls
|
|
358
|
+
* those along). Modules shared with other client references are not charged
|
|
359
|
+
* to any one of them, so shared libraries do not block grouping. With
|
|
360
|
+
* {@link readClientModuleBindings}, a side-effect-free module only charges the
|
|
361
|
+
* re-exports that are imported from it, so a reference that imports one icon
|
|
362
|
+
* from a barrel is not charged for the whole library.
|
|
363
|
+
*
|
|
364
|
+
* `references` maps each client reference id to its module id in the client
|
|
365
|
+
* graph. `isSideEffectFree` reports a module's package `sideEffects` flag as
|
|
366
|
+
* the bundler resolved it. Traversal stops at modules for which `isExcluded`
|
|
367
|
+
* returns true (CSS, always-loaded framework chunks, virtual modules that must
|
|
368
|
+
* not be loaded re-entrantly). A reference whose import graph cannot be fully
|
|
369
|
+
* loaded is reported as `null` so callers keep it out of groups.
|
|
370
|
+
*/
|
|
371
|
+
async function measureClientReferenceGroupCosts(options) {
|
|
372
|
+
const loaded = /* @__PURE__ */ new Map();
|
|
373
|
+
const load = (id) => {
|
|
374
|
+
let module = loaded.get(id);
|
|
375
|
+
if (!module) {
|
|
376
|
+
module = options.loadModule(id).catch(() => null);
|
|
377
|
+
loaded.set(id, module);
|
|
378
|
+
}
|
|
379
|
+
return module;
|
|
380
|
+
};
|
|
381
|
+
const referenceByModuleId = /* @__PURE__ */ new Map();
|
|
382
|
+
for (const [referenceId, moduleId] of options.references) referenceByModuleId.set(moduleId, referenceId);
|
|
383
|
+
const reexportIndexes = /* @__PURE__ */ new Map();
|
|
384
|
+
const indexReexports = (id, bindings) => {
|
|
385
|
+
let index = reexportIndexes.get(id);
|
|
386
|
+
if (index) return index;
|
|
387
|
+
index = {
|
|
388
|
+
byName: /* @__PURE__ */ new Map(),
|
|
389
|
+
stars: [],
|
|
390
|
+
sideEffectTargets: /* @__PURE__ */ new Set()
|
|
391
|
+
};
|
|
392
|
+
for (const edge of bindings.reexports) {
|
|
393
|
+
if (edge.exportName === "*") {
|
|
394
|
+
index.stars.push(edge);
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
const edges = index.byName.get(edge.exportName);
|
|
398
|
+
if (edges) edges.push(edge);
|
|
399
|
+
else index.byName.set(edge.exportName, [edge]);
|
|
400
|
+
if (!options.isSideEffectFree(edge.id)) index.sideEffectTargets.add(edge.id);
|
|
401
|
+
}
|
|
402
|
+
reexportIndexes.set(id, index);
|
|
403
|
+
return index;
|
|
404
|
+
};
|
|
405
|
+
const noNames = /* @__PURE__ */ new Set();
|
|
406
|
+
const importedNames = (edge) => edge.importName === "*" ? "*" : /* @__PURE__ */ new Set([edge.importName]);
|
|
407
|
+
const slots = /* @__PURE__ */ new Map();
|
|
408
|
+
const moduleBytes = /* @__PURE__ */ new Map();
|
|
409
|
+
let frontier = [];
|
|
410
|
+
const slot = (id, name) => {
|
|
411
|
+
const key = `${name}\0${id}`;
|
|
412
|
+
let found = slots.get(key);
|
|
413
|
+
if (!found) {
|
|
414
|
+
found = {
|
|
415
|
+
id,
|
|
416
|
+
name,
|
|
417
|
+
children: [],
|
|
418
|
+
references: [],
|
|
419
|
+
failed: false
|
|
420
|
+
};
|
|
421
|
+
slots.set(key, found);
|
|
422
|
+
frontier.push(found);
|
|
423
|
+
}
|
|
424
|
+
return found;
|
|
425
|
+
};
|
|
426
|
+
const link = (from, id, names) => {
|
|
427
|
+
if (options.isExcluded(id)) return;
|
|
428
|
+
const reference = referenceByModuleId.get(id);
|
|
429
|
+
if (reference !== void 0) from.references.push(reference);
|
|
430
|
+
else if (names === "*" || !options.isSideEffectFree(id)) from.children.push(slot(id, "*"));
|
|
431
|
+
else for (const name of names) from.children.push(slot(id, name));
|
|
432
|
+
};
|
|
433
|
+
const rootSlots = /* @__PURE__ */ new Map();
|
|
434
|
+
for (const [referenceId, rootModuleId] of options.references) rootSlots.set(referenceId, slot(rootModuleId, "*"));
|
|
435
|
+
while (frontier.length > 0) {
|
|
436
|
+
const current = frontier;
|
|
437
|
+
frontier = [];
|
|
438
|
+
const modules = await Promise.all(current.map((from) => load(from.id)));
|
|
439
|
+
for (let index = 0; index < modules.length; index++) {
|
|
440
|
+
const module = modules[index];
|
|
441
|
+
const from = current[index];
|
|
442
|
+
if (!module) {
|
|
443
|
+
from.failed = true;
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
const { bindings } = module;
|
|
447
|
+
moduleBytes.set(from.id, bindings?.bytes ?? (module.code ? Buffer.byteLength(module.code, "utf8") : 0));
|
|
448
|
+
if (!bindings) {
|
|
449
|
+
for (const importedId of module.importedIds) link(from, importedId, "*");
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
for (const edge of bindings.imports) link(from, edge.id, edge.names);
|
|
453
|
+
if (from.name === "*") {
|
|
454
|
+
for (const edge of bindings.reexports) link(from, edge.id, importedNames(edge));
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
const reexports = indexReexports(from.id, bindings);
|
|
458
|
+
for (const edge of reexports.byName.get(from.name) ?? []) link(from, edge.id, importedNames(edge));
|
|
459
|
+
const starNames = from.name === "default" ? noNames : /* @__PURE__ */ new Set([from.name]);
|
|
460
|
+
for (const edge of reexports.stars) link(from, edge.id, starNames);
|
|
461
|
+
for (const target of reexports.sideEffectTargets) link(from, target, noNames);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
const parents = /* @__PURE__ */ new Map();
|
|
465
|
+
const leads = /* @__PURE__ */ new Set();
|
|
466
|
+
for (const from of slots.values()) {
|
|
467
|
+
for (const child of from.children) {
|
|
468
|
+
let childParents = parents.get(child);
|
|
469
|
+
if (!childParents) {
|
|
470
|
+
childParents = [];
|
|
471
|
+
parents.set(child, childParents);
|
|
472
|
+
}
|
|
473
|
+
childParents.push(from);
|
|
474
|
+
}
|
|
475
|
+
if (from.references.length > 0 || from.failed) leads.add(from);
|
|
476
|
+
}
|
|
477
|
+
for (const lead of leads) for (const parent of parents.get(lead) ?? []) leads.add(parent);
|
|
478
|
+
const importedReferences = /* @__PURE__ */ new Map();
|
|
479
|
+
const unloadable = /* @__PURE__ */ new Set();
|
|
480
|
+
for (const [referenceId, root] of rootSlots) {
|
|
481
|
+
const imported = /* @__PURE__ */ new Set();
|
|
482
|
+
importedReferences.set(referenceId, imported);
|
|
483
|
+
if (!leads.has(root)) continue;
|
|
484
|
+
const visited = /* @__PURE__ */ new Set([root]);
|
|
485
|
+
const stack = [root];
|
|
486
|
+
while (stack.length > 0) {
|
|
487
|
+
const current = stack.pop();
|
|
488
|
+
if (current.failed) unloadable.add(referenceId);
|
|
489
|
+
for (const reference of current.references) if (reference !== referenceId) imported.add(reference);
|
|
490
|
+
for (const child of current.children) if (leads.has(child) && !visited.has(child)) {
|
|
491
|
+
visited.add(child);
|
|
492
|
+
stack.push(child);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
const slotOwners = /* @__PURE__ */ new Map();
|
|
497
|
+
const marks = [];
|
|
498
|
+
for (const [referenceId, root] of rootSlots) if (!unloadable.has(referenceId)) marks.push([root, referenceId]);
|
|
499
|
+
while (marks.length > 0) {
|
|
500
|
+
const [marked, owner] = marks.pop();
|
|
501
|
+
const current = slotOwners.get(marked);
|
|
502
|
+
const next = current === void 0 || current === owner ? owner : null;
|
|
503
|
+
if (next === current) continue;
|
|
504
|
+
slotOwners.set(marked, next);
|
|
505
|
+
for (const child of marked.children) marks.push([child, next]);
|
|
506
|
+
}
|
|
507
|
+
const moduleOwners = /* @__PURE__ */ new Map();
|
|
508
|
+
for (const [marked, owner] of slotOwners) {
|
|
509
|
+
const current = moduleOwners.get(marked.id);
|
|
510
|
+
moduleOwners.set(marked.id, current === void 0 || current === owner ? owner : null);
|
|
511
|
+
}
|
|
512
|
+
const exclusiveBytes = /* @__PURE__ */ new Map();
|
|
513
|
+
for (const [moduleId, owner] of moduleOwners) {
|
|
514
|
+
if (owner === null) continue;
|
|
515
|
+
exclusiveBytes.set(owner, (exclusiveBytes.get(owner) ?? 0) + (moduleBytes.get(moduleId) ?? 0));
|
|
516
|
+
}
|
|
517
|
+
const costs = /* @__PURE__ */ new Map();
|
|
518
|
+
for (const referenceId of options.references.keys()) {
|
|
519
|
+
let cost = 0;
|
|
520
|
+
const visited = /* @__PURE__ */ new Set();
|
|
521
|
+
const queue = [referenceId];
|
|
522
|
+
for (let index = 0; index < queue.length && cost !== null; index++) {
|
|
523
|
+
const current = queue[index];
|
|
524
|
+
if (visited.has(current)) continue;
|
|
525
|
+
visited.add(current);
|
|
526
|
+
cost = unloadable.has(current) ? null : cost + (exclusiveBytes.get(current) ?? 0);
|
|
527
|
+
for (const importedReference of importedReferences.get(current) ?? []) queue.push(importedReference);
|
|
528
|
+
}
|
|
529
|
+
costs.set(referenceId, cost);
|
|
530
|
+
}
|
|
531
|
+
return costs;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Group client references that share a route signature. References without a
|
|
535
|
+
* signature, references whose cost is unknown or above `maxCostBytes`, and
|
|
536
|
+
* signatures with a single member stay ungrouped. Group keys derive from the
|
|
537
|
+
* members' `referenceKeys`, so a group keeps its chunk name when routes change
|
|
538
|
+
* but its members do not.
|
|
539
|
+
*/
|
|
540
|
+
function planClientReferenceGroups(options) {
|
|
541
|
+
const membersBySignature = /* @__PURE__ */ new Map();
|
|
542
|
+
for (const [referenceId, signature] of options.signatures) {
|
|
543
|
+
if (!options.referenceIds.has(referenceId)) continue;
|
|
544
|
+
const cost = options.costs.get(referenceId);
|
|
545
|
+
if (cost == null || cost > options.maxCostBytes) continue;
|
|
546
|
+
let members = membersBySignature.get(signature);
|
|
547
|
+
if (!members) {
|
|
548
|
+
members = [];
|
|
549
|
+
membersBySignature.set(signature, members);
|
|
550
|
+
}
|
|
551
|
+
members.push(referenceId);
|
|
552
|
+
}
|
|
553
|
+
const groups = [];
|
|
554
|
+
const usedKeys = /* @__PURE__ */ new Set();
|
|
555
|
+
for (const signature of [...membersBySignature.keys()].sort()) {
|
|
556
|
+
const members = membersBySignature.get(signature);
|
|
557
|
+
if (members.length < 2) continue;
|
|
558
|
+
const memberKeys = members.map((referenceId) => options.referenceKeys.get(referenceId));
|
|
559
|
+
const hash = createHash("sha256").update(memberKeys.sort().join("\0")).digest("hex");
|
|
560
|
+
let length = 10;
|
|
561
|
+
while (usedKeys.has(hash.slice(0, length))) length++;
|
|
562
|
+
const key = hash.slice(0, length);
|
|
563
|
+
usedKeys.add(key);
|
|
564
|
+
groups.push({
|
|
565
|
+
key,
|
|
566
|
+
referenceIds: members
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
return groups;
|
|
570
|
+
}
|
|
571
|
+
//#endregion
|
|
572
|
+
export { CLIENT_REFERENCE_GROUP_MAX_COST_BYTES, collectClientReferencePreloadPlan, collectClientReferenceRouteSignatures, measureClientReferenceGroupCosts, planClientReferenceGroups, readClientModuleBindings };
|
|
@@ -26,4 +26,5 @@ export declare function rebaseCssUrlAssetReferences(code: string, sourceDirector
|
|
|
26
26
|
* code only has the leaked marker stripped — no sibling files are emitted.
|
|
27
27
|
*/
|
|
28
28
|
export declare function restoreDedupedCssAssetReferences(bundle: CssUrlAssetBundle, emitRestoredAsset: EmitRestoredCssUrlAsset): void;
|
|
29
|
-
//#endregion
|
|
29
|
+
//#endregion
|
|
30
|
+
export {};
|
|
@@ -8,4 +8,5 @@ type AdjustFontFallback = {
|
|
|
8
8
|
};
|
|
9
9
|
export declare function getFallbackFontOverrideMetrics(fontFamily: string): AdjustFontFallback | undefined;
|
|
10
10
|
export declare function buildFallbackFontFace(family: string, metrics: AdjustFontFallback): string;
|
|
11
|
-
//#endregion
|
|
11
|
+
//#endregion
|
|
12
|
+
export {};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
//#region src/build/google-fonts/find-font-files-in-css.ts
|
|
2
|
+
const formatToExtension = /* @__PURE__ */ new Map([
|
|
3
|
+
["woff", "woff"],
|
|
4
|
+
["woff2", "woff2"],
|
|
5
|
+
["truetype", "ttf"],
|
|
6
|
+
["opentype", "otf"],
|
|
7
|
+
["embedded-opentype", "eot"]
|
|
8
|
+
]);
|
|
2
9
|
/**
|
|
3
10
|
* Find all font files in the CSS response and determine which files should be preloaded.
|
|
4
11
|
* In Google Fonts responses, the @font-face's subset is above it in a comment.
|
|
@@ -16,10 +23,16 @@ function findFontFilesInCss(css, subsetsToPreload) {
|
|
|
16
23
|
if (newSubset) currentSubset = newSubset;
|
|
17
24
|
else {
|
|
18
25
|
const googleFontFileUrl = /src: url\((.+?)\)/.exec(line)?.[1];
|
|
19
|
-
if (googleFontFileUrl && !fontFiles.some((foundFile) => foundFile.googleFontFileUrl === googleFontFileUrl))
|
|
20
|
-
googleFontFileUrl
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
if (googleFontFileUrl && !fontFiles.some((foundFile) => foundFile.googleFontFileUrl === googleFontFileUrl)) {
|
|
27
|
+
const pathname = googleFontFileUrl.split(/[?#]/, 1)[0];
|
|
28
|
+
const format = /format\(['"](.+?)['"]\)/.exec(line)?.[1];
|
|
29
|
+
const ext = /\.(woff|woff2|eot|ttf|otf)$/.exec(pathname)?.[1] ?? formatToExtension.get(format ?? "") ?? "woff2";
|
|
30
|
+
fontFiles.push({
|
|
31
|
+
googleFontFileUrl,
|
|
32
|
+
preloadFontFile: !!subsetsToPreload?.includes(currentSubset),
|
|
33
|
+
ext
|
|
34
|
+
});
|
|
35
|
+
}
|
|
23
36
|
}
|
|
24
37
|
}
|
|
25
38
|
return fontFiles;
|
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
type InlineCssManifest = Record<string, string>;
|
|
3
3
|
export declare function collectInlineCssManifest(clientDir: string, assetPrefix: string): InlineCssManifest;
|
|
4
4
|
export declare function injectInlineCssManifestGlobal(entryPath: string, manifest: InlineCssManifest): boolean;
|
|
5
|
-
//#endregion
|
|
5
|
+
//#endregion
|
|
6
|
+
export {};
|
|
@@ -58,4 +58,5 @@ export declare function isStaticModuleGraphResult(graphResult: ModuleGraphClassi
|
|
|
58
58
|
* Used only by `tests/layout-classification.test.ts`.
|
|
59
59
|
*/
|
|
60
60
|
export declare function classifyAllRouteLayouts(routes: readonly RouteForClassification[], dynamicShimPaths: ReadonlySet<string>, moduleInfo: ModuleInfoProvider): Map<string, LayoutBuildClassification>;
|
|
61
|
-
//#endregion
|
|
61
|
+
//#endregion
|
|
62
|
+
export {};
|