vinext 1.3.0 → 1.4.0
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 +5 -2
- package/THIRD_PARTY_LICENSES.md +47 -0
- package/dist/_virtual/_rolldown/runtime.js +4 -3
- 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 +13 -3
- package/dist/build/client-build-config.js +46 -9
- 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 +9 -1
- package/dist/build/client-reference-groups.js +40 -2
- 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/module-dependency-cache.d.ts +2 -1
- package/dist/build/next-client-runtime-manifests.d.ts +2 -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-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 +6 -5
- package/dist/build/report.d.ts +2 -15
- package/dist/build/report.js +1 -51
- package/dist/build/run-prerender.d.ts +2 -1
- package/dist/build/server-actions-encryption-key.d.ts +2 -1
- package/dist/build/ssr-manifest.js +25 -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 +5 -1
- package/dist/cli-args.d.ts +2 -1
- package/dist/cli.js +5 -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-rewrites.d.ts +2 -1
- package/dist/client/dev-error-overlay-store.d.ts +2 -1
- package/dist/client/dev-error-overlay.js +1 -1
- package/dist/client/index.js +1 -2
- package/dist/client/instrumentation-client-state.js +5 -5
- package/dist/client/navigation-runtime.d.ts +16 -2
- package/dist/client/navigation-runtime.js +2 -2
- package/dist/client/pages-router-link-navigation.d.ts +2 -1
- package/dist/client/vinext-next-data.d.ts +25 -1
- package/dist/client/window-next.d.ts +2 -1
- package/dist/config/config-matchers.d.ts +12 -1
- package/dist/config/config-matchers.js +111 -16
- package/dist/config/dotenv.d.ts +2 -1
- package/dist/config/next-config.d.ts +32 -1
- package/dist/config/next-config.js +93 -5
- package/dist/config/tsconfig-paths.d.ts +2 -1
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/dbcs-codec.js +327 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/dbcs-data.js +123 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/index.js +29 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/internal.js +134 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-codec.js +50 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-data-generated.js +455 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-data.js +147 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/big5-added.json.js +169 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp936.json.js +2584 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp949.json.js +2220 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp950.json.js +227 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/eucjp.json.js +425 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/gb18030-ranges.json.js +427 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/gbk-added.json.js +229 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/shiftjis.json.js +292 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/utf16.js +106 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/utf7.js +182 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/bom-handling.js +42 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/extend-node.js +147 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/index.js +94 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/streams.js +95 -0
- 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/safer-buffer@2.1.2/deps/safer-buffer/safer.js +45 -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 +20 -5
- package/dist/entries/app-browser-entry.js +79 -6
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +59 -60
- package/dist/entries/app-rsc-manifest.d.ts +2 -1
- package/dist/entries/app-rsc-manifest.js +56 -4
- package/dist/entries/app-ssr-entry.js +1 -0
- 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 +34 -9
- 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.js +184 -103
- package/dist/init-cloudflare.d.ts +1 -3
- package/dist/init-cloudflare.js +10 -48
- package/dist/init-platform.d.ts +2 -0
- package/dist/init-platform.js +4 -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/extensionless-dynamic-import.js +6 -2
- 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/next-intl-catalog.d.ts +12 -0
- package/dist/plugins/next-intl-catalog.js +85 -0
- package/dist/plugins/og-assets.d.ts +2 -1
- package/dist/plugins/og-assets.js +2 -3
- package/dist/plugins/optimize-imports.d.ts +2 -1
- package/dist/plugins/pages-node-externals.d.ts +3 -1
- package/dist/plugins/pages-node-externals.js +1 -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 +8 -0
- package/dist/plugins/rsc-client-reference-loaders.js +170 -68
- 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 +1 -1
- package/dist/plugins/use-cache-callable.js +136 -94
- package/dist/plugins/worker-image-imports.js +1 -1
- package/dist/plugins/worker-use-server.d.ts +2 -1
- package/dist/routing/app-route-graph.d.ts +46 -0
- package/dist/routing/app-route-graph.js +131 -51
- package/dist/routing/browser-route-manifest.d.ts +2 -1
- package/dist/routing/optimistic-route-trie.d.ts +2 -1
- package/dist/routing/route-matching.d.ts +2 -1
- package/dist/routing/route-pattern.d.ts +2 -1
- package/dist/server/accept-encoding.d.ts +2 -1
- package/dist/server/api-handler.js +19 -4
- package/dist/server/app-action-forwarding.d.ts +2 -1
- package/dist/server/app-bfcache-identity.d.ts +2 -1
- package/dist/server/app-bfcache-identity.js +1 -1
- package/dist/server/app-browser-action-result.d.ts +2 -1
- package/dist/server/app-browser-entry.js +106 -66
- package/dist/server/app-browser-error.d.ts +2 -1
- package/dist/server/app-browser-history-controller.d.ts +7 -5
- package/dist/server/app-browser-history-controller.js +93 -15
- package/dist/server/app-browser-hydration.d.ts +2 -1
- package/dist/server/app-browser-interception-context.d.ts +2 -1
- package/dist/server/app-browser-navigation-controller.d.ts +2 -2
- package/dist/server/app-browser-navigation-controller.js +16 -12
- 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-rsc-redirect.js +4 -4
- package/dist/server/app-browser-server-action-client.d.ts +4 -1
- package/dist/server/app-browser-server-action-client.js +4 -3
- package/dist/server/app-browser-state.d.ts +2 -4
- package/dist/server/app-browser-state.js +9 -4
- package/dist/server/app-browser-stream.d.ts +2 -1
- package/dist/server/app-browser-supplemental-refresh.js +16 -1
- package/dist/server/app-browser-visible-commit.d.ts +3 -2
- package/dist/server/app-browser-visible-commit.js +2 -12
- 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 +25 -5
- package/dist/server/app-client-reference-preloader.js +22 -7
- package/dist/server/app-elements-wire.d.ts +8 -39
- package/dist/server/app-elements-wire.js +4 -41
- package/dist/server/app-elements.d.ts +4 -2
- package/dist/server/app-elements.js +4 -2
- package/dist/server/app-fallback-renderer.d.ts +9 -2
- package/dist/server/app-fallback-renderer.js +4 -1
- package/dist/server/app-history-state.d.ts +4 -3
- package/dist/server/app-history-state.js +5 -2
- package/dist/server/app-inline-css-client.d.ts +2 -1
- package/dist/server/app-metadata-tracing.d.ts +2 -1
- package/dist/server/app-mounted-layouts.d.ts +21 -0
- package/dist/server/app-mounted-layouts.js +67 -0
- package/dist/server/app-optimistic-routing.d.ts +37 -2
- package/dist/server/app-optimistic-routing.js +75 -2
- package/dist/server/app-page-boundary-render.d.ts +20 -2
- package/dist/server/app-page-boundary-render.js +224 -40
- package/dist/server/app-page-boundary.d.ts +34 -5
- package/dist/server/app-page-boundary.js +41 -8
- package/dist/server/app-page-cache-finalizer.d.ts +14 -2
- package/dist/server/app-page-cache-finalizer.js +71 -30
- package/dist/server/app-page-cache-render.d.ts +10 -2
- package/dist/server/app-page-cache-render.js +14 -2
- package/dist/server/app-page-cache.d.ts +13 -1
- package/dist/server/app-page-cache.js +33 -11
- package/dist/server/app-page-dispatch.d.ts +39 -11
- package/dist/server/app-page-dispatch.js +236 -177
- package/dist/server/app-page-element-builder.d.ts +19 -3
- package/dist/server/app-page-element-builder.js +193 -71
- package/dist/server/app-page-execution.d.ts +43 -51
- package/dist/server/app-page-execution.js +205 -92
- package/dist/server/app-page-head.d.ts +108 -3
- package/dist/server/app-page-head.js +337 -154
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +49 -2
- package/dist/server/app-page-http-access-fallback-metadata.js +77 -2
- package/dist/server/app-page-layout-gate.d.ts +35 -0
- package/dist/server/app-page-layout-gate.js +50 -0
- package/dist/server/app-page-method.d.ts +2 -1
- package/dist/server/app-page-params.d.ts +0 -1
- package/dist/server/app-page-params.js +1 -14
- package/dist/server/app-page-probe.d.ts +5 -22
- package/dist/server/app-page-probe.js +4 -37
- package/dist/server/app-page-render-identity.d.ts +2 -1
- package/dist/server/app-page-render.d.ts +9 -13
- package/dist/server/app-page-render.js +108 -214
- package/dist/server/app-page-request.d.ts +15 -4
- package/dist/server/app-page-request.js +2 -2
- package/dist/server/app-page-response.js +3 -3
- package/dist/server/app-page-route-wiring.d.ts +65 -8
- package/dist/server/app-page-route-wiring.js +259 -103
- package/dist/server/app-page-rsc-render-status.d.ts +29 -2
- package/dist/server/app-page-rsc-render-status.js +121 -13
- package/dist/server/app-page-search-params-observation.d.ts +7 -2
- package/dist/server/app-page-search-params-observation.js +8 -1
- package/dist/server/app-page-segment-plan.d.ts +2 -1
- package/dist/server/app-page-stream.d.ts +33 -1
- package/dist/server/app-page-stream.js +25 -6
- package/dist/server/app-pages-bridge.d.ts +6 -1
- package/dist/server/app-pages-bridge.js +7 -3
- 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-render-dependency.d.ts +21 -4
- package/dist/server/app-render-dependency.js +100 -33
- package/dist/server/app-request-stage-dispatch.js +1 -1
- package/dist/server/app-request-stage-independent-entry.d.ts +2 -1
- package/dist/server/app-response-stage-entry.d.ts +2 -1
- package/dist/server/app-route-handler-cache.d.ts +2 -1
- package/dist/server/app-route-handler-cache.js +2 -2
- package/dist/server/app-route-handler-dispatch.d.ts +2 -1
- package/dist/server/app-route-handler-dispatch.js +15 -10
- package/dist/server/app-route-handler-execution.d.ts +2 -1
- package/dist/server/app-route-handler-execution.js +8 -3
- package/dist/server/app-route-handler-policy.d.ts +1 -1
- package/dist/server/app-route-handler-policy.js +3 -3
- package/dist/server/app-route-handler-response.d.ts +2 -1
- package/dist/server/app-route-handler-response.js +1 -1
- package/dist/server/app-route-handler-runtime.d.ts +2 -1
- package/dist/server/app-route-handler-runtime.js +17 -4
- package/dist/server/app-route-module-loader.d.ts +18 -1
- package/dist/server/app-route-module-loader.js +8 -0
- package/dist/server/app-route-tree-prefetch.d.ts +2 -1
- package/dist/server/app-rsc-cache-busting.d.ts +2 -2
- package/dist/server/app-rsc-cache-busting.js +4 -4
- package/dist/server/app-rsc-error-handler.d.ts +4 -2
- package/dist/server/app-rsc-error-handler.js +9 -1
- package/dist/server/app-rsc-errors.d.ts +10 -1
- package/dist/server/app-rsc-errors.js +8 -1
- package/dist/server/app-rsc-handler.d.ts +7 -6
- package/dist/server/app-rsc-handler.js +36 -34
- package/dist/server/app-rsc-request-normalization.d.ts +0 -4
- package/dist/server/app-rsc-request-normalization.js +1 -4
- package/dist/server/app-rsc-response-finalizer.d.ts +2 -1
- package/dist/server/app-rsc-response-finalizer.js +2 -2
- package/dist/server/app-rsc-response-stage.js +5 -3
- package/dist/server/app-rsc-route-matching.d.ts +38 -1
- package/dist/server/app-rsc-route-matching.js +24 -0
- 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 +5 -2
- package/dist/server/app-server-action-execution.js +10 -7
- package/dist/server/app-ssr-entry.d.ts +8 -0
- package/dist/server/app-ssr-entry.js +98 -50
- 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 +22 -10
- package/dist/server/app-ssr-stream.js +300 -68
- 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 +38 -2
- package/dist/server/app-visited-response-cache.js +46 -5
- package/dist/server/app-worker-stages.d.ts +27 -4
- package/dist/server/app-worker-stages.js +45 -6
- package/dist/server/artifact-compatibility.d.ts +2 -2
- package/dist/server/artifact-compatibility.js +1 -10
- package/dist/server/bfcache-identity.d.ts +2 -1
- package/dist/server/cache-headers.d.ts +2 -1
- package/dist/server/cache-proof.d.ts +1 -115
- package/dist/server/cache-proof.js +1 -544
- package/dist/server/cacheability-request.d.ts +2 -1
- package/dist/server/cacheability-request.js +13 -8
- package/dist/server/config-headers.d.ts +2 -1
- 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 +14 -6
- 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/headers.d.ts +6 -3
- package/dist/server/headers.js +9 -5
- 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/isr-cache.d.ts +8 -2
- package/dist/server/isr-cache.js +26 -1
- 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 +32 -15
- package/dist/server/metadata-routes.d.ts +2 -1
- package/dist/server/middleware-runtime.d.ts +2 -1
- package/dist/server/multi-stage.d.ts +52 -11
- package/dist/server/multi-stage.js +13 -1
- package/dist/server/navigation-planner.js +1 -1
- 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 +2 -1
- package/dist/server/nitro-public-files.d.ts +2 -1
- 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-api-route.js +28 -19
- package/dist/server/pages-asset-tags.d.ts +2 -1
- package/dist/server/pages-body-parser-config.d.ts +2 -1
- package/dist/server/pages-client-assets.d.ts +4 -0
- 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-media-type.d.ts +21 -1
- package/dist/server/pages-media-type.js +69 -5
- package/dist/server/pages-node-compat.js +52 -27
- 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 +27 -27
- 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 +10 -1
- package/dist/server/pages-request-pipeline.js +6 -7
- package/dist/server/pages-request-stage-entry.d.ts +2 -1
- package/dist/server/pages-request-stage-entry.js +14 -12
- package/dist/server/pages-response-stage-entry.d.ts +2 -1
- package/dist/server/pages-response-stage-entry.js +9 -3
- package/dist/server/pages-route-data-kind.d.ts +2 -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.js +14 -4
- package/dist/server/request-log.d.ts +2 -1
- package/dist/server/request-pipeline.d.ts +6 -0
- package/dist/server/request-pipeline.js +21 -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/shared-cache-identity.d.ts +23 -0
- package/dist/server/shared-cache-identity.js +36 -0
- package/dist/server/static-file-cache.d.ts +2 -1
- package/dist/server/static-file-cache.js +1 -0
- package/dist/server/worker-revalidation-context.d.ts +2 -1
- package/dist/server/worker-stages.d.ts +18 -4
- package/dist/server/worker-stages.js +23 -4
- 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 +31 -11
- package/dist/shims/cache-request-state.d.ts +17 -20
- package/dist/shims/cache-request-state.js +16 -21
- package/dist/shims/cache-runtime.js +27 -11
- package/dist/shims/cache.d.ts +8 -7
- package/dist/shims/cache.js +17 -19
- package/dist/shims/cacheability-classification.d.ts +2 -0
- 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-cache.d.ts +22 -5
- package/dist/shims/cdn-purge-routes.d.ts +2 -1
- package/dist/shims/client-locale.js +2 -1
- package/dist/shims/client-page-root.d.ts +2 -1
- package/dist/shims/client-page-root.js +2 -2
- 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 +9 -6
- package/dist/shims/error-boundary.d.ts +39 -3
- package/dist/shims/error-boundary.js +33 -18
- package/dist/shims/fetch-cache-state.d.ts +5 -1
- package/dist/shims/fetch-cache-state.js +1 -3
- package/dist/shims/fetch-cache.d.ts +2 -1
- package/dist/shims/fetch-cache.js +34 -24
- 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 +3 -3
- package/dist/shims/headers.d.ts +8 -23
- package/dist/shims/headers.js +17 -67
- 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.d.ts +1 -22
- 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 +2 -0
- package/dist/shims/internal/headers-state.js +6 -1
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +2 -1
- package/dist/shims/internal/interpolate-as.d.ts +2 -1
- package/dist/shims/internal/navigation-untracked.js +1 -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 +197 -52
- package/dist/shims/metadata.d.ts +52 -29
- package/dist/shims/metadata.js +142 -42
- package/dist/shims/navigation-errors.d.ts +2 -1
- package/dist/shims/navigation-server.js +1 -1
- package/dist/shims/navigation.d.ts +95 -8
- package/dist/shims/navigation.js +255 -47
- package/dist/shims/navigation.react-server.js +2 -2
- package/dist/shims/pages-router-runtime.d.ts +2 -1
- package/dist/shims/ppr-fallback-shell.d.ts +2 -1
- package/dist/shims/request-state-types.d.ts +2 -2
- package/dist/shims/router.js +14 -3
- package/dist/shims/slot.d.ts +12 -0
- package/dist/shims/slot.js +37 -9
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +5 -6
- package/dist/typegen.d.ts +2 -1
- package/dist/utils/cache-control-metadata.d.ts +5 -0
- package/dist/utils/cache-control-metadata.js +9 -1
- package/dist/utils/client-build-manifest.d.ts +4 -1
- package/dist/utils/client-build-manifest.js +9 -2
- 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 +9 -1
- package/dist/utils/client-runtime-metadata.js +40 -9
- package/dist/utils/compare.d.ts +9 -0
- package/dist/utils/compare.js +15 -1
- package/dist/utils/lazy-chunks.d.ts +14 -0
- package/dist/utils/lazy-chunks.js +27 -1
- package/dist/utils/middleware-request-headers.d.ts +2 -1
- package/dist/utils/project.d.ts +4 -3
- package/dist/utils/project.js +12 -17
- package/dist/utils/query.d.ts +2 -1
- package/dist/utils/regex.d.ts +5 -0
- package/dist/utils/regex.js +11 -1
- package/dist/utils/text-stream.d.ts +10 -5
- package/dist/utils/text-stream.js +6 -6
- package/dist/utils/vite-cli-invocation.d.ts +2 -1
- package/package.json +6 -5
- package/dist/build/layout-classification-types.d.ts +0 -60
- package/dist/build/layout-classification-types.js +0 -1
- package/dist/build/layout-classification.d.ts +0 -61
- package/dist/build/layout-classification.js +0 -98
- package/dist/build/route-classification-injector.d.ts +0 -32
- package/dist/build/route-classification-injector.js +0 -59
- package/dist/build/route-classification-manifest.d.ts +0 -53
- package/dist/build/route-classification-manifest.js +0 -143
- package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +0 -808
- package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -10
- package/dist/server/app-browser-client-reuse-manifest.js +0 -101
- package/dist/server/app-layout-param-observation.d.ts +0 -41
- package/dist/server/app-layout-param-observation.js +0 -168
- package/dist/server/client-reuse-manifest.d.ts +0 -102
- package/dist/server/client-reuse-manifest.js +0 -209
- package/dist/server/default-not-found-module.d.ts +0 -19
- package/dist/server/default-not-found-module.js +0 -18
- package/dist/server/rsc-stream-hints.d.ts +0 -21
- package/dist/server/rsc-stream-hints.js +0 -227
- package/dist/server/skip-cache-proof.d.ts +0 -60
- package/dist/server/skip-cache-proof.js +0 -168
- package/dist/server/static-layout-client-reuse-proof.d.ts +0 -13
- package/dist/server/static-layout-client-reuse-proof.js +0 -33
- package/dist/utils/sorted-array.d.ts +0 -7
- package/dist/utils/sorted-array.js +0 -20
package/dist/shims/slot.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { APP_BFCACHE_SEGMENT_IDENTITIES_KEY, AppElementsWire, UNMATCHED_SLOT } from "../server/app-elements-wire.js";
|
|
3
3
|
import "../server/app-elements.js";
|
|
4
|
-
import {
|
|
4
|
+
import { isNestedBfcacheSlotSegmentId, isNestedBfcacheSlotSegmentIdFor } from "../server/bfcache-identity.js";
|
|
5
5
|
import { notFound } from "./navigation-errors.js";
|
|
6
|
+
import { getBfcacheIdMapContext, getBfcacheSegmentIdContext } from "./navigation-context-state.js";
|
|
6
7
|
import "./navigation-server.js";
|
|
7
|
-
import { isNestedBfcacheSlotSegmentId, isNestedBfcacheSlotSegmentIdFor } from "../server/bfcache-identity.js";
|
|
8
8
|
import * as React$1 from "react";
|
|
9
9
|
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
10
10
|
//#region src/shims/slot.tsx
|
|
@@ -92,11 +92,6 @@ function stageBfcacheSlotEntryForRender(committedSnapshots, committedOrder, acti
|
|
|
92
92
|
snapshots
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
-
function isLayoutFlagsValue(value) {
|
|
96
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
97
|
-
const entries = Object.values(value);
|
|
98
|
-
return entries.length > 0 && entries.every((entry) => entry === "s" || entry === "d");
|
|
99
|
-
}
|
|
100
95
|
function isArtifactCompatibilityEnvelopeValue(value) {
|
|
101
96
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
102
97
|
return "schemaVersion" in value && "appElementsSchemaVersion" in value && "rscPayloadSchemaVersion" in value && "graphVersion" in value && "deploymentVersion" in value && "rootBoundaryId" in value && "renderEpoch" in value;
|
|
@@ -127,7 +122,7 @@ function isCacheEntryReuseProofValue(value) {
|
|
|
127
122
|
return "kind" in value && value.kind === "runtime-cache-entry" && "decision" in value;
|
|
128
123
|
}
|
|
129
124
|
function isTransportMetadataValue(id, value) {
|
|
130
|
-
return
|
|
125
|
+
return isBfcacheSegmentIdentitiesMetadataValue(id, value) || isArtifactCompatibilityEnvelopeValue(value) || isCacheEntryReuseProofValue(value) || isInterceptionMetadataValue(value) || isSkippedLayoutIdsMetadataValue(id, value) || isSlotBindingListValue(value);
|
|
131
126
|
}
|
|
132
127
|
function warnTransportMetadataEntry(id) {
|
|
133
128
|
if (process.env.NODE_ENV === "production") return;
|
|
@@ -210,6 +205,39 @@ function BfcacheSegmentBoundary({ children, id, stateKey }) {
|
|
|
210
205
|
stateKeyMap: identityMap
|
|
211
206
|
});
|
|
212
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Retains a layout's children across navigations that change which segment
|
|
210
|
+
* they render. Each child keeps its own wrappers, so a page and a nested layout
|
|
211
|
+
* give the layout's children different element shapes, and a retention list
|
|
212
|
+
* inside the child would remount with them. Next.js keeps this Activity list in
|
|
213
|
+
* the parent's layout router, above the child's boundaries, so a page left for a
|
|
214
|
+
* sibling with its own layout keeps its state when navigating back.
|
|
215
|
+
*/
|
|
216
|
+
function BfcacheChildrenBoundary({ children, id }) {
|
|
217
|
+
if (!BfcacheIdMapContext || !BfcacheSegmentIdContext || !isCacheComponentsEnabled()) return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
218
|
+
return /* @__PURE__ */ jsx(BfcacheChildrenActivityBoundary, {
|
|
219
|
+
id,
|
|
220
|
+
IdMapContext: BfcacheIdMapContext,
|
|
221
|
+
SegmentContext: BfcacheSegmentIdContext,
|
|
222
|
+
children
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function BfcacheChildrenActivityBoundary({ children, id, IdMapContext, SegmentContext }) {
|
|
226
|
+
const elements = React$1.useContext(ElementsContext);
|
|
227
|
+
const identityMap = React$1.useContext(BfcacheIdentityMapContext);
|
|
228
|
+
const bfcacheIdMap = React$1.useContext(IdMapContext);
|
|
229
|
+
const segmentId = React$1.useContext(SegmentContext);
|
|
230
|
+
const activeStateKey = resolveBfcacheSegmentStateKey(id, identityMap, bfcacheIdMap);
|
|
231
|
+
if (segmentId === null || activeStateKey === void 0) return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
232
|
+
return /* @__PURE__ */ jsx(BfcacheActivitySlotBoundary, {
|
|
233
|
+
activeStateKey,
|
|
234
|
+
content: children,
|
|
235
|
+
elements,
|
|
236
|
+
id: segmentId,
|
|
237
|
+
SegmentContext,
|
|
238
|
+
stateKeyMap: identityMap
|
|
239
|
+
});
|
|
240
|
+
}
|
|
213
241
|
function getNonCacheComponentsSegmentKey(id, activeStateKey) {
|
|
214
242
|
const parsed = AppElementsWire.parseElementKey(id);
|
|
215
243
|
return parsed !== null && parsed.kind !== "route" ? activeStateKey : void 0;
|
|
@@ -340,4 +368,4 @@ function ParallelSlot({ name }) {
|
|
|
340
368
|
return React$1.useContext(ParallelSlotsContext)?.[name] ?? null;
|
|
341
369
|
}
|
|
342
370
|
//#endregion
|
|
343
|
-
export { BfcacheIdentityMapContext, BfcacheSegmentBoundary, Children, ChildrenContext, ElementsContext, ParallelSlot, ParallelSlotsContext, RenderedSearchContext, Slot, UNMATCHED_SLOT, bindAppElementsRenderedSearch, getNonCacheComponentsSegmentKey, mergeElements, resolveBfcacheSegmentStateKey, setAppElementsRenderedSearch, stageBfcacheSlotEntryForRender, updateBfcacheSlotEntryOrder };
|
|
371
|
+
export { BfcacheChildrenBoundary, BfcacheIdentityMapContext, BfcacheSegmentBoundary, Children, ChildrenContext, ElementsContext, ParallelSlot, ParallelSlotsContext, RenderedSearchContext, Slot, UNMATCHED_SLOT, bindAppElementsRenderedSearch, getNonCacheComponentsSegmentKey, mergeElements, resolveBfcacheSegmentStateKey, setAppElementsRenderedSearch, stageBfcacheSlotEntryForRender, updateBfcacheSlotEntryOrder };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ExecutionContextLike } from "./request-context.js";
|
|
2
|
-
import { CacheState } from "./cache-request-state.js";
|
|
3
2
|
import { RootParamsState } from "./root-params.js";
|
|
4
3
|
import { FetchCacheState } from "./fetch-cache-state.js";
|
|
5
4
|
import { VinextHeadersShimState } from "./internal/headers-state.js";
|
|
5
|
+
import { CacheState } from "./cache-request-state.js";
|
|
6
6
|
import { RouterState } from "./router-state.js";
|
|
7
7
|
import { markFullyBufferedBody, preserveFullyBufferedBodyMetadata } from "../server/fully-buffered-response.js";
|
|
8
8
|
import { PrivateCacheState } from "./cache-runtime.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getOrCreateAls } from "./internal/als-registry.js";
|
|
2
2
|
import { isFullyBufferedBody, markFullyBufferedBody, preserveFullyBufferedBodyMetadata } from "../server/fully-buffered-response.js";
|
|
3
|
+
import { deferUntilStreamConsumed } from "../server/defer-until-stream-consumed.js";
|
|
3
4
|
//#region src/shims/unified-request-context.ts
|
|
4
5
|
const _REQUEST_CONTEXT_ALS_KEY = Symbol.for("vinext.requestContext.als");
|
|
5
6
|
const _g = globalThis;
|
|
@@ -17,7 +18,7 @@ function createRequestContext(opts) {
|
|
|
17
18
|
return {
|
|
18
19
|
headersContext: null,
|
|
19
20
|
actionRevalidationKind: 0,
|
|
20
|
-
|
|
21
|
+
isOnDemandRevalidate: false,
|
|
21
22
|
pendingCdnTagInvalidations: [],
|
|
22
23
|
pendingRevalidatedTags: /* @__PURE__ */ new Set(),
|
|
23
24
|
pendingRevalidations: /* @__PURE__ */ new Set(),
|
|
@@ -36,15 +37,14 @@ function createRequestContext(opts) {
|
|
|
36
37
|
serverContext: null,
|
|
37
38
|
serverInsertedHTMLCallbacks: [],
|
|
38
39
|
requestScopedCacheLife: null,
|
|
39
|
-
unstableCacheObservations: /* @__PURE__ */ new Map(),
|
|
40
40
|
unstableCacheRevalidation: "foreground",
|
|
41
41
|
_privateCache: null,
|
|
42
|
-
cacheableFetchUrls: /* @__PURE__ */ new Set(),
|
|
43
42
|
currentRequestTags: [],
|
|
44
43
|
currentFetchSoftTags: [],
|
|
45
44
|
currentFetchCacheMode: null,
|
|
46
45
|
currentFetchRevalidate: null,
|
|
47
46
|
currentForceDynamicFetchDefault: false,
|
|
47
|
+
isDraftMode: false,
|
|
48
48
|
dynamicFetchUrls: /* @__PURE__ */ new Set(),
|
|
49
49
|
refreshStaleFetchesInForeground: false,
|
|
50
50
|
isFetchDedupeActive: false,
|
|
@@ -161,9 +161,8 @@ function closeAfterResponseWithBody(response, ctx) {
|
|
|
161
161
|
return response;
|
|
162
162
|
}
|
|
163
163
|
if (isFullyBufferedBody(response) && !requiresResponseCloseTracking(ctx)) return response;
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
const wrapped = new Response(passthrough.readable, {
|
|
164
|
+
const body = deferUntilStreamConsumed(response.body, () => void closeAfterResponse(ctx));
|
|
165
|
+
const wrapped = new Response(body, {
|
|
167
166
|
status: response.status,
|
|
168
167
|
statusText: response.statusText,
|
|
169
168
|
headers: response.headers
|
package/dist/typegen.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
//#region src/utils/cache-control-metadata.d.ts
|
|
2
2
|
export declare function readCacheControlNumberField(ctx: Record<string, unknown> | undefined, field: string): number | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* When a `"use cache"` entry's generation started (`ctx.timestamp`), which dates
|
|
5
|
+
* the entry like Next.js does. Absent, malformed or future values fall back to `now`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function readCacheTimestamp(ctx: Record<string, unknown> | undefined, now: number): number;
|
|
3
8
|
export declare function readCacheControlRevalidateField(ctx: Record<string, unknown> | undefined): number | false | undefined;
|
|
4
9
|
/**
|
|
5
10
|
* Client-reuse seconds from a resolved `cacheLife`. Shared by every emitter
|
|
@@ -8,6 +8,14 @@ function readCacheControlNumberField(ctx, field) {
|
|
|
8
8
|
const value = readRecordField(ctx, "cacheControl")?.[field] ?? ctx?.[field];
|
|
9
9
|
return typeof value === "number" ? value : void 0;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* When a `"use cache"` entry's generation started (`ctx.timestamp`), which dates
|
|
13
|
+
* the entry like Next.js does. Absent, malformed or future values fall back to `now`.
|
|
14
|
+
*/
|
|
15
|
+
function readCacheTimestamp(ctx, now) {
|
|
16
|
+
const value = ctx?.timestamp;
|
|
17
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 && value <= now ? value : now;
|
|
18
|
+
}
|
|
11
19
|
function readCacheControlRevalidateField(ctx) {
|
|
12
20
|
const value = readRecordField(ctx, "cacheControl")?.revalidate ?? ctx?.revalidate;
|
|
13
21
|
return typeof value === "number" || value === false ? value : void 0;
|
|
@@ -29,4 +37,4 @@ function resolveClientStaleTimeSeconds(cacheLife) {
|
|
|
29
37
|
return isFiniteNonNegative(stale) ? stale : void 0;
|
|
30
38
|
}
|
|
31
39
|
//#endregion
|
|
32
|
-
export { readCacheControlNumberField, readCacheControlRevalidateField, resolveClientStaleTimeSeconds };
|
|
40
|
+
export { readCacheControlNumberField, readCacheControlRevalidateField, readCacheTimestamp, resolveClientStaleTimeSeconds };
|
|
@@ -4,6 +4,8 @@ type ClientBuildManifest = Record<string, BuildManifestChunk>;
|
|
|
4
4
|
export declare function readClientBuildManifest(manifestPath: string): ClientBuildManifest | undefined;
|
|
5
5
|
export declare function findClientEntryFileFromManifest(buildManifest: ClientBuildManifest, assetBase: string): string | undefined;
|
|
6
6
|
export declare function findPagesClientEntryFileFromManifest(buildManifest: ClientBuildManifest, assetBase: string): string | undefined;
|
|
7
|
+
/** Whether a build-manifest entry is the Pages Router client entry. */
|
|
8
|
+
export declare function isPagesClientEntryChunk(key: string, entry: BuildManifestChunk): boolean;
|
|
7
9
|
export declare function findClientEntryFile(options: {
|
|
8
10
|
buildManifest?: ClientBuildManifest;
|
|
9
11
|
clientDir: string;
|
|
@@ -16,4 +18,5 @@ export declare function findPagesClientEntryFile(options: {
|
|
|
16
18
|
assetsSubdir: string;
|
|
17
19
|
assetBase: string;
|
|
18
20
|
}): string | undefined;
|
|
19
|
-
//#endregion
|
|
21
|
+
//#endregion
|
|
22
|
+
export {};
|
|
@@ -42,7 +42,7 @@ function findPagesClientEntryFileFromManifest(buildManifest, assetBase) {
|
|
|
42
42
|
}
|
|
43
43
|
function findEntryFileFromManifest(buildManifest, assetBase, markers, fallbackToFirstEntry) {
|
|
44
44
|
const entries = Object.entries(buildManifest).filter(([, entry]) => entry.isEntry && entry.file);
|
|
45
|
-
const matchers = [
|
|
45
|
+
const matchers = [matchesEntryIdentity, (marker, _key, entry) => entry.file.includes(marker)];
|
|
46
46
|
for (const matches of matchers) for (const marker of markers) {
|
|
47
47
|
const markedEntry = entries.find(([key, entry]) => matches(marker, key, entry));
|
|
48
48
|
if (markedEntry) return manifestFileWithBase(markedEntry[1].file, assetBase);
|
|
@@ -50,6 +50,13 @@ function findEntryFileFromManifest(buildManifest, assetBase, markers, fallbackTo
|
|
|
50
50
|
const chosen = fallbackToFirstEntry ? entries[0]?.[1] : void 0;
|
|
51
51
|
return chosen ? manifestFileWithBase(chosen.file, assetBase) : void 0;
|
|
52
52
|
}
|
|
53
|
+
function matchesEntryIdentity(marker, key, entry) {
|
|
54
|
+
return entry.name === marker || isVirtualEntryId(key, marker) || entry.src !== void 0 && isVirtualEntryId(entry.src, marker);
|
|
55
|
+
}
|
|
56
|
+
/** Whether a build-manifest entry is the Pages Router client entry. */
|
|
57
|
+
function isPagesClientEntryChunk(key, entry) {
|
|
58
|
+
return entry.isEntry === true && PAGES_CLIENT_ENTRY_MARKERS.some((marker) => matchesEntryIdentity(marker, key, entry));
|
|
59
|
+
}
|
|
53
60
|
function isVirtualEntryId(id, marker) {
|
|
54
61
|
const virtualId = `virtual:${marker}`;
|
|
55
62
|
return id === virtualId || id.endsWith(`/${virtualId}`);
|
|
@@ -92,4 +99,4 @@ function readStringArray(value) {
|
|
|
92
99
|
return Array.isArray(value) && value.every((item) => typeof item === "string") ? value : void 0;
|
|
93
100
|
}
|
|
94
101
|
//#endregion
|
|
95
|
-
export { findClientEntryFile, findClientEntryFileFromManifest, findPagesClientEntryFile, findPagesClientEntryFileFromManifest, readClientBuildManifest };
|
|
102
|
+
export { findClientEntryFile, findClientEntryFileFromManifest, findPagesClientEntryFile, findPagesClientEntryFileFromManifest, isPagesClientEntryChunk, readClientBuildManifest };
|
|
@@ -1,10 +1,23 @@
|
|
|
1
|
+
import { ClientReferenceChunks } from "./client-reference-chunks.js";
|
|
1
2
|
//#region src/utils/client-entry-manifest.d.ts
|
|
2
3
|
export declare const VINEXT_CLIENT_ENTRY_MANIFEST = "vinext-client-entry-manifest.json";
|
|
4
|
+
/**
|
|
5
|
+
* Build manifest keys of App Router client reference modules -> the chunk of
|
|
6
|
+
* the module that registers the reference (see build/client-reference-chunks.ts).
|
|
7
|
+
* It names source files, so it sits under `.vite/` with Vite's build manifest,
|
|
8
|
+
* which deploys leave out of the public assets.
|
|
9
|
+
*/
|
|
10
|
+
export declare const VINEXT_CLIENT_REFERENCE_SOURCES = ".vite/vinext-client-reference-sources.json";
|
|
3
11
|
export type ClientEntryManifest = {
|
|
4
12
|
pagesClientEntry?: string;
|
|
5
13
|
appBrowserEntry?: string;
|
|
14
|
+
/** The App Router RouteManifest chunk, which the browser entry imports as it boots. */
|
|
15
|
+
appRouteManifest?: string;
|
|
16
|
+
/** What each App Router client reference loads in the browser. */
|
|
17
|
+
appClientReferenceChunks?: ClientReferenceChunks;
|
|
6
18
|
};
|
|
7
19
|
export declare function readClientEntryManifest(clientDir: string): ClientEntryManifest | undefined;
|
|
20
|
+
export declare function readClientReferenceSources(clientDir: string): Record<string, string> | undefined;
|
|
8
21
|
export declare function findClientEntryFileFromVinextManifest(manifest: ClientEntryManifest | undefined, assetBase: string): string | undefined;
|
|
9
22
|
export declare function findPagesClientEntryFileFromVinextManifest(manifest: ClientEntryManifest | undefined, assetBase: string): string | undefined;
|
|
10
23
|
//#endregion
|
|
@@ -4,6 +4,13 @@ import { manifestFileWithBase } from "./manifest-paths.js";
|
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
//#region src/utils/client-entry-manifest.ts
|
|
6
6
|
const VINEXT_CLIENT_ENTRY_MANIFEST = "vinext-client-entry-manifest.json";
|
|
7
|
+
/**
|
|
8
|
+
* Build manifest keys of App Router client reference modules -> the chunk of
|
|
9
|
+
* the module that registers the reference (see build/client-reference-chunks.ts).
|
|
10
|
+
* It names source files, so it sits under `.vite/` with Vite's build manifest,
|
|
11
|
+
* which deploys leave out of the public assets.
|
|
12
|
+
*/
|
|
13
|
+
const VINEXT_CLIENT_REFERENCE_SOURCES = ".vite/vinext-client-reference-sources.json";
|
|
7
14
|
function readClientEntryManifest(clientDir) {
|
|
8
15
|
const manifestPath = path.join(clientDir, VINEXT_CLIENT_ENTRY_MANIFEST);
|
|
9
16
|
if (!fs.existsSync(manifestPath)) return void 0;
|
|
@@ -13,11 +20,23 @@ function readClientEntryManifest(clientDir) {
|
|
|
13
20
|
const manifest = {};
|
|
14
21
|
if (typeof value.pagesClientEntry === "string") manifest.pagesClientEntry = value.pagesClientEntry;
|
|
15
22
|
if (typeof value.appBrowserEntry === "string") manifest.appBrowserEntry = value.appBrowserEntry;
|
|
23
|
+
if (typeof value.appRouteManifest === "string") manifest.appRouteManifest = value.appRouteManifest;
|
|
24
|
+
if (isUnknownRecord(value.appClientReferenceChunks)) manifest.appClientReferenceChunks = value.appClientReferenceChunks;
|
|
16
25
|
return manifest.pagesClientEntry || manifest.appBrowserEntry ? manifest : void 0;
|
|
17
26
|
} catch {
|
|
18
27
|
return;
|
|
19
28
|
}
|
|
20
29
|
}
|
|
30
|
+
function readClientReferenceSources(clientDir) {
|
|
31
|
+
const sourcesPath = path.join(clientDir, VINEXT_CLIENT_REFERENCE_SOURCES);
|
|
32
|
+
if (!fs.existsSync(sourcesPath)) return void 0;
|
|
33
|
+
try {
|
|
34
|
+
const value = JSON.parse(fs.readFileSync(sourcesPath, "utf-8"));
|
|
35
|
+
return isUnknownRecord(value) ? value : void 0;
|
|
36
|
+
} catch {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
21
40
|
function findClientEntryFileFromVinextManifest(manifest, assetBase) {
|
|
22
41
|
const entry = manifest?.pagesClientEntry ?? manifest?.appBrowserEntry;
|
|
23
42
|
return entry ? manifestFileWithBase(entry, assetBase) : void 0;
|
|
@@ -26,4 +45,4 @@ function findPagesClientEntryFileFromVinextManifest(manifest, assetBase) {
|
|
|
26
45
|
return manifest?.pagesClientEntry ? manifestFileWithBase(manifest.pagesClientEntry, assetBase) : void 0;
|
|
27
46
|
}
|
|
28
47
|
//#endregion
|
|
29
|
-
export { VINEXT_CLIENT_ENTRY_MANIFEST, findClientEntryFileFromVinextManifest, findPagesClientEntryFileFromVinextManifest, readClientEntryManifest };
|
|
48
|
+
export { VINEXT_CLIENT_ENTRY_MANIFEST, VINEXT_CLIENT_REFERENCE_SOURCES, findClientEntryFileFromVinextManifest, findPagesClientEntryFileFromVinextManifest, readClientEntryManifest, readClientReferenceSources };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/utils/client-reference-chunks.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The chunks an App Router client reference loads in the browser, which the
|
|
4
|
+
* RSC render names in the reference's Flight row (see
|
|
5
|
+
* server/app-client-reference-manifest.ts).
|
|
6
|
+
*/
|
|
7
|
+
export type ClientReferenceChunks = {
|
|
8
|
+
/** Reference key -> index into `modules`. */
|
|
9
|
+
references: Record<string, number>;
|
|
10
|
+
/**
|
|
11
|
+
* Each chunk that registers client references (see
|
|
12
|
+
* shims/internal/client-reference-loader.ts), with the JS chunks to
|
|
13
|
+
* modulepreload (it and the chunks it imports that the browser entry
|
|
14
|
+
* doesn't, picked by `build.modulePreload`), and the stylesheets they need.
|
|
15
|
+
*/
|
|
16
|
+
modules: {
|
|
17
|
+
file: string;
|
|
18
|
+
imports: string[];
|
|
19
|
+
css: string[];
|
|
20
|
+
}[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* How the browser loads a chunk a Flight row names. React passes the loader
|
|
24
|
+
* only the chunk id, so the id is the kind followed by the URL.
|
|
25
|
+
*/
|
|
26
|
+
export declare const CLIENT_REFERENCE_CHUNK_KIND: {
|
|
27
|
+
/**
|
|
28
|
+
* The chunk that registers the reference, imported once the stylesheets
|
|
29
|
+
* its id lists after its URL have loaded.
|
|
30
|
+
*/
|
|
31
|
+
readonly module: "m";
|
|
32
|
+
/** A JS chunk to modulepreload: the module chunk, or one it imports. */
|
|
33
|
+
readonly preload: "p";
|
|
34
|
+
};
|
|
35
|
+
/** Separates the URLs in a module chunk's id. A URL can't hold a raw newline. */
|
|
36
|
+
export declare const CLIENT_REFERENCE_CHUNK_URL_SEPARATOR = "\n";
|
|
37
|
+
/**
|
|
38
|
+
* React's webpack Flight binding takes a client reference's chunks as
|
|
39
|
+
* `[chunkId, filename, ...]` pairs. Only the id reaches the browser's chunk
|
|
40
|
+
* loader, so the filenames are left empty. The module chunk's id lists its
|
|
41
|
+
* stylesheets, so the loader can link them before the chunk evaluates, as
|
|
42
|
+
* Vite's preload helper does.
|
|
43
|
+
*/
|
|
44
|
+
export declare function toFlightChunks(module: ClientReferenceChunks["modules"][number]): string[];
|
|
45
|
+
//#endregion
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/utils/client-reference-chunks.ts
|
|
2
|
+
/**
|
|
3
|
+
* How the browser loads a chunk a Flight row names. React passes the loader
|
|
4
|
+
* only the chunk id, so the id is the kind followed by the URL.
|
|
5
|
+
*/
|
|
6
|
+
const CLIENT_REFERENCE_CHUNK_KIND = {
|
|
7
|
+
/**
|
|
8
|
+
* The chunk that registers the reference, imported once the stylesheets
|
|
9
|
+
* its id lists after its URL have loaded.
|
|
10
|
+
*/
|
|
11
|
+
module: "m",
|
|
12
|
+
/** A JS chunk to modulepreload: the module chunk, or one it imports. */
|
|
13
|
+
preload: "p"
|
|
14
|
+
};
|
|
15
|
+
/** Separates the URLs in a module chunk's id. A URL can't hold a raw newline. */
|
|
16
|
+
const CLIENT_REFERENCE_CHUNK_URL_SEPARATOR = "\n";
|
|
17
|
+
/**
|
|
18
|
+
* React's webpack Flight binding takes a client reference's chunks as
|
|
19
|
+
* `[chunkId, filename, ...]` pairs. Only the id reaches the browser's chunk
|
|
20
|
+
* loader, so the filenames are left empty. The module chunk's id lists its
|
|
21
|
+
* stylesheets, so the loader can link them before the chunk evaluates, as
|
|
22
|
+
* Vite's preload helper does.
|
|
23
|
+
*/
|
|
24
|
+
function toFlightChunks(module) {
|
|
25
|
+
const chunks = [CLIENT_REFERENCE_CHUNK_KIND.module + [module.file, ...module.css].join("\n"), ""];
|
|
26
|
+
for (const file of module.imports) chunks.push(CLIENT_REFERENCE_CHUNK_KIND.preload + file, "");
|
|
27
|
+
return chunks;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { CLIENT_REFERENCE_CHUNK_KIND, CLIENT_REFERENCE_CHUNK_URL_SEPARATOR, toFlightChunks };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { ClientReferenceChunks } from "./client-reference-chunks.js";
|
|
1
2
|
//#region src/utils/client-runtime-metadata.d.ts
|
|
2
3
|
type ClientRuntimeMetadata = {
|
|
3
4
|
clientEntryFile?: string;
|
|
4
5
|
appBootstrapPreinitModules?: string[];
|
|
6
|
+
appRouteManifestModule?: string;
|
|
7
|
+
appClientReferenceChunks?: ClientReferenceChunks;
|
|
5
8
|
cssGraph?: Record<string, {
|
|
6
9
|
imports?: string[];
|
|
7
10
|
css?: string[];
|
|
@@ -14,6 +17,10 @@ type ClientRuntimeMetadata = {
|
|
|
14
17
|
* Read the client build manifest and compute runtime metadata used by
|
|
15
18
|
* Cloudflare worker entry injection and Node production server startup.
|
|
16
19
|
*
|
|
20
|
+
* - `appRouteManifestModule` — the App Router RouteManifest chunk, which the
|
|
21
|
+
* browser entry imports as it boots, preloaded during SSR.
|
|
22
|
+
* - `appClientReferenceChunks` — what each App Router client reference loads
|
|
23
|
+
* in the browser, which the RSC render names in its Flight row.
|
|
17
24
|
* - `lazyChunks` — chunks only reachable through dynamic `import()`, excluded
|
|
18
25
|
* from modulepreload hints.
|
|
19
26
|
* - `dynamicPreloads` — per-module JS/CSS files for rendered `next/dynamic()`
|
|
@@ -32,4 +39,5 @@ export declare function computeClientRuntimeMetadata(opts: {
|
|
|
32
39
|
assetPrefix: string;
|
|
33
40
|
includeClientEntry?: boolean | "pages-client-entry";
|
|
34
41
|
}): ClientRuntimeMetadata;
|
|
35
|
-
//#endregion
|
|
42
|
+
//#endregion
|
|
43
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { isAbsoluteAssetPrefix, resolveAssetsDir } from "./asset-prefix.js";
|
|
3
3
|
import { isSharedClientChunkName, manifestFileWithAssetPrefix, manifestFileWithBase } from "./manifest-paths.js";
|
|
4
|
-
import { findClientEntryFileFromVinextManifest, findPagesClientEntryFileFromVinextManifest, readClientEntryManifest } from "./client-entry-manifest.js";
|
|
5
|
-
import { findClientEntryFile, findPagesClientEntryFile, readClientBuildManifest } from "./client-build-manifest.js";
|
|
6
|
-
import { computeDynamicImportPreloads, computeLazyChunks, dynamicImportPreloadsWithBase } from "./lazy-chunks.js";
|
|
4
|
+
import { findClientEntryFileFromVinextManifest, findPagesClientEntryFileFromVinextManifest, readClientEntryManifest, readClientReferenceSources } from "./client-entry-manifest.js";
|
|
5
|
+
import { findClientEntryFile, findPagesClientEntryFile, isPagesClientEntryChunk, readClientBuildManifest } from "./client-build-manifest.js";
|
|
6
|
+
import { addDynamicImportPreloadAliases, computeDynamicImportPreloads, computeLazyChunks, dynamicImportPreloadsWithBase } from "./lazy-chunks.js";
|
|
7
7
|
//#region src/utils/client-runtime-metadata.ts
|
|
8
8
|
/**
|
|
9
9
|
* Shared Pages Router chunk files, keyed on Rolldown chunk names rather than
|
|
@@ -12,7 +12,20 @@ import { computeDynamicImportPreloads, computeLazyChunks, dynamicImportPreloadsW
|
|
|
12
12
|
*/
|
|
13
13
|
function collectSharedChunkFiles(buildManifest, applyBase) {
|
|
14
14
|
const files = /* @__PURE__ */ new Set();
|
|
15
|
-
|
|
15
|
+
const visitedKeys = /* @__PURE__ */ new Set();
|
|
16
|
+
const addStaticImports = (key) => {
|
|
17
|
+
for (const importedKey of buildManifest[key]?.imports ?? []) {
|
|
18
|
+
if (visitedKeys.has(importedKey)) continue;
|
|
19
|
+
visitedKeys.add(importedKey);
|
|
20
|
+
const importedFile = buildManifest[importedKey]?.file;
|
|
21
|
+
if (importedFile?.endsWith(".js")) files.add(applyBase(importedFile));
|
|
22
|
+
addStaticImports(importedKey);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
for (const [key, chunk] of Object.entries(buildManifest)) {
|
|
26
|
+
if (chunk.file.endsWith(".js") && isSharedClientChunkName(chunk.name)) files.add(applyBase(chunk.file));
|
|
27
|
+
if (isPagesClientEntryChunk(key, chunk)) addStaticImports(key);
|
|
28
|
+
}
|
|
16
29
|
return files.size > 0 ? [...files] : void 0;
|
|
17
30
|
}
|
|
18
31
|
function collectCssGraph(buildManifest, applyBase) {
|
|
@@ -56,6 +69,10 @@ function collectAppBootstrapPreinitModules(buildManifest, appBrowserEntry, apply
|
|
|
56
69
|
* Read the client build manifest and compute runtime metadata used by
|
|
57
70
|
* Cloudflare worker entry injection and Node production server startup.
|
|
58
71
|
*
|
|
72
|
+
* - `appRouteManifestModule` — the App Router RouteManifest chunk, which the
|
|
73
|
+
* browser entry imports as it boots, preloaded during SSR.
|
|
74
|
+
* - `appClientReferenceChunks` — what each App Router client reference loads
|
|
75
|
+
* in the browser, which the RSC render names in its Flight row.
|
|
59
76
|
* - `lazyChunks` — chunks only reachable through dynamic `import()`, excluded
|
|
60
77
|
* from modulepreload hints.
|
|
61
78
|
* - `dynamicPreloads` — per-module JS/CSS files for rendered `next/dynamic()`
|
|
@@ -83,18 +100,32 @@ function computeClientRuntimeMetadata(opts) {
|
|
|
83
100
|
const entry = opts.includeClientEntry === "pages-client-entry" ? findPagesClientEntryFileFromVinextManifest(clientEntryManifest, opts.assetBase) ?? findPagesClientEntryFile(entryOptions) : findClientEntryFileFromVinextManifest(clientEntryManifest, opts.assetBase) ?? findClientEntryFile(entryOptions);
|
|
84
101
|
if (entry) metadata.clientEntryFile = entry;
|
|
85
102
|
}
|
|
103
|
+
const appAssetUrl = (file) => {
|
|
104
|
+
const url = manifestFileWithAssetPrefix(file, opts.assetBase, opts.assetPrefix);
|
|
105
|
+
return isAbsoluteAssetPrefix(opts.assetPrefix) ? url : "/" + url;
|
|
106
|
+
};
|
|
107
|
+
const referenceChunks = clientEntryManifest?.appClientReferenceChunks;
|
|
108
|
+
if (referenceChunks) metadata.appClientReferenceChunks = {
|
|
109
|
+
references: referenceChunks.references,
|
|
110
|
+
modules: referenceChunks.modules.map((module) => ({
|
|
111
|
+
file: appAssetUrl(module.file),
|
|
112
|
+
imports: module.imports.map(appAssetUrl),
|
|
113
|
+
css: module.css.map(appAssetUrl)
|
|
114
|
+
}))
|
|
115
|
+
};
|
|
86
116
|
if (!buildManifest) return metadata;
|
|
87
117
|
if (opts.includeClientEntry) {
|
|
88
118
|
metadata.cssGraph = collectCssGraph(buildManifest, (file) => manifestFileWithBase(file, opts.assetBase));
|
|
89
119
|
metadata.sharedChunks = collectSharedChunkFiles(buildManifest, (file) => manifestFileWithBase(file, opts.assetBase));
|
|
90
120
|
}
|
|
91
|
-
metadata.appBootstrapPreinitModules = collectAppBootstrapPreinitModules(buildManifest, clientEntryManifest?.appBrowserEntry,
|
|
92
|
-
|
|
93
|
-
return isAbsoluteAssetPrefix(opts.assetPrefix) ? url : "/" + url;
|
|
94
|
-
});
|
|
121
|
+
metadata.appBootstrapPreinitModules = collectAppBootstrapPreinitModules(buildManifest, clientEntryManifest?.appBrowserEntry, appAssetUrl);
|
|
122
|
+
if (clientEntryManifest?.appRouteManifest) metadata.appRouteManifestModule = appAssetUrl(clientEntryManifest.appRouteManifest);
|
|
95
123
|
const lazyChunks = computeLazyChunks(buildManifest).map((file) => manifestFileWithBase(file, opts.assetBase));
|
|
96
124
|
if (lazyChunks.length > 0) metadata.lazyChunks = lazyChunks;
|
|
97
|
-
const
|
|
125
|
+
const dynamicImportPreloads = computeDynamicImportPreloads(buildManifest);
|
|
126
|
+
const clientReferenceSources = readClientReferenceSources(opts.clientDir);
|
|
127
|
+
if (clientReferenceSources) addDynamicImportPreloadAliases(dynamicImportPreloads, buildManifest, clientReferenceSources);
|
|
128
|
+
const dynamicPreloads = dynamicImportPreloadsWithBase(dynamicImportPreloads, (file) => manifestFileWithAssetPrefix(file, opts.assetBase, opts.assetPrefix));
|
|
98
129
|
if (Object.keys(dynamicPreloads).length > 0) metadata.dynamicPreloads = dynamicPreloads;
|
|
99
130
|
return metadata;
|
|
100
131
|
}
|
package/dist/utils/compare.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
//#region src/utils/compare.d.ts
|
|
2
2
|
export declare const compareStrings: (left: string, right: string) => number;
|
|
3
|
+
/**
|
|
4
|
+
* Turbopack reads a folder's subfolders from a `BTreeMap<RcStr, _>`, whose
|
|
5
|
+
* keys compare as Rust `str`s: by UTF-8 bytes. That is Unicode code point
|
|
6
|
+
* order, which JavaScript's `<` (UTF-16 code units) doesn't match above the
|
|
7
|
+
* Basic Multilingual Plane.
|
|
8
|
+
* https://github.com/vercel/next.js/blob/v16.2.7/crates/next-core/src/app_structure.rs#L188-L192
|
|
9
|
+
* https://github.com/vercel/next.js/blob/v16.2.7/turbopack/crates/turbo-rcstr/src/lib.rs#L350-L354
|
|
10
|
+
*/
|
|
11
|
+
export declare function compareFolderNames(a: string, b: string): number;
|
|
3
12
|
//#endregion
|
package/dist/utils/compare.js
CHANGED
|
@@ -4,5 +4,19 @@ const compareStrings = (left, right) => {
|
|
|
4
4
|
if (left > right) return 1;
|
|
5
5
|
return 0;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Turbopack reads a folder's subfolders from a `BTreeMap<RcStr, _>`, whose
|
|
9
|
+
* keys compare as Rust `str`s: by UTF-8 bytes. That is Unicode code point
|
|
10
|
+
* order, which JavaScript's `<` (UTF-16 code units) doesn't match above the
|
|
11
|
+
* Basic Multilingual Plane.
|
|
12
|
+
* https://github.com/vercel/next.js/blob/v16.2.7/crates/next-core/src/app_structure.rs#L188-L192
|
|
13
|
+
* https://github.com/vercel/next.js/blob/v16.2.7/turbopack/crates/turbo-rcstr/src/lib.rs#L350-L354
|
|
14
|
+
*/
|
|
15
|
+
function compareFolderNames(a, b) {
|
|
16
|
+
const left = Array.from(a, (char) => char.codePointAt(0) ?? 0);
|
|
17
|
+
const right = Array.from(b, (char) => char.codePointAt(0) ?? 0);
|
|
18
|
+
for (let index = 0; index < Math.min(left.length, right.length); index++) if (left[index] !== right[index]) return left[index] - right[index];
|
|
19
|
+
return left.length - right.length;
|
|
20
|
+
}
|
|
7
21
|
//#endregion
|
|
8
|
-
export { compareStrings };
|
|
22
|
+
export { compareFolderNames, compareStrings };
|
|
@@ -26,6 +26,11 @@ export type BuildManifestChunk = {
|
|
|
26
26
|
* static `imports` tree (breadth-first). Any chunk file NOT reached by this
|
|
27
27
|
* walk is only reachable through `dynamicImports` and is therefore "lazy".
|
|
28
28
|
*
|
|
29
|
+
* The Pages Router client entry `import()`s every page and `_app`, but the
|
|
30
|
+
* HTML for a page renders that page and `_app`, so their chunks are roots of
|
|
31
|
+
* the walk too: Next.js emits their scripts in the initial HTML. Their own
|
|
32
|
+
* dynamic imports (next/dynamic, React.lazy) stay lazy.
|
|
33
|
+
*
|
|
29
34
|
* @param buildManifest - Vite's build manifest (manifest.json), which is a
|
|
30
35
|
* Record<string, ManifestChunk> where each chunk has `file`, `imports`,
|
|
31
36
|
* `dynamicImports`, `isEntry`, and `isDynamicEntry` fields.
|
|
@@ -58,5 +63,14 @@ export declare function computeLazyChunks(buildManifest: Record<string, BuildMan
|
|
|
58
63
|
* should be preloaded when that dynamic boundary is rendered.
|
|
59
64
|
*/
|
|
60
65
|
export declare function computeDynamicImportPreloads(buildManifest: Record<string, BuildManifestChunk>): Record<string, string[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Give a module the preloads of a chunk that loads it. The client build
|
|
68
|
+
* imports an App Router client reference through the module that registers it
|
|
69
|
+
* (see build/client-reference-chunks.ts), so the build manifest keys that
|
|
70
|
+
* module's chunk, not the reference's module a next/dynamic boundary names.
|
|
71
|
+
*
|
|
72
|
+
* @param aliases Module manifest key -> the file of the chunk that loads it.
|
|
73
|
+
*/
|
|
74
|
+
export declare function addDynamicImportPreloadAliases(preloads: Record<string, string[]>, buildManifest: Record<string, BuildManifestChunk>, aliases: Record<string, string>): void;
|
|
61
75
|
export declare function dynamicImportPreloadsWithBase(preloads: Record<string, string[]>, applyBase: (file: string) => string): Record<string, string[]>;
|
|
62
76
|
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPagesClientEntryChunk } from "./client-build-manifest.js";
|
|
1
2
|
//#region src/utils/lazy-chunks.ts
|
|
2
3
|
/**
|
|
3
4
|
* Compute the set of chunk filenames that are ONLY reachable through dynamic
|
|
@@ -10,6 +11,11 @@
|
|
|
10
11
|
* static `imports` tree (breadth-first). Any chunk file NOT reached by this
|
|
11
12
|
* walk is only reachable through `dynamicImports` and is therefore "lazy".
|
|
12
13
|
*
|
|
14
|
+
* The Pages Router client entry `import()`s every page and `_app`, but the
|
|
15
|
+
* HTML for a page renders that page and `_app`, so their chunks are roots of
|
|
16
|
+
* the walk too: Next.js emits their scripts in the initial HTML. Their own
|
|
17
|
+
* dynamic imports (next/dynamic, React.lazy) stay lazy.
|
|
18
|
+
*
|
|
13
19
|
* @param buildManifest - Vite's build manifest (manifest.json), which is a
|
|
14
20
|
* Record<string, ManifestChunk> where each chunk has `file`, `imports`,
|
|
15
21
|
* `dynamicImports`, `isEntry`, and `isDynamicEntry` fields.
|
|
@@ -32,6 +38,9 @@ function computeLazyChunks(buildManifest) {
|
|
|
32
38
|
if (chunk.imports) {
|
|
33
39
|
for (const imp of chunk.imports) if (!visited.has(imp)) queue.push(imp);
|
|
34
40
|
}
|
|
41
|
+
if (isPagesClientEntryChunk(key, chunk)) {
|
|
42
|
+
for (const imp of chunk.dynamicImports ?? []) if (!visited.has(imp)) queue.push(imp);
|
|
43
|
+
}
|
|
35
44
|
}
|
|
36
45
|
const lazyChunks = [];
|
|
37
46
|
const allFiles = /* @__PURE__ */ new Set();
|
|
@@ -103,10 +112,27 @@ function computeDynamicImportPreloads(buildManifest) {
|
|
|
103
112
|
}
|
|
104
113
|
return preloads;
|
|
105
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Give a module the preloads of a chunk that loads it. The client build
|
|
117
|
+
* imports an App Router client reference through the module that registers it
|
|
118
|
+
* (see build/client-reference-chunks.ts), so the build manifest keys that
|
|
119
|
+
* module's chunk, not the reference's module a next/dynamic boundary names.
|
|
120
|
+
*
|
|
121
|
+
* @param aliases Module manifest key -> the file of the chunk that loads it.
|
|
122
|
+
*/
|
|
123
|
+
function addDynamicImportPreloadAliases(preloads, buildManifest, aliases) {
|
|
124
|
+
const keysByFile = /* @__PURE__ */ new Map();
|
|
125
|
+
for (const [key, chunk] of Object.entries(buildManifest)) keysByFile.set(chunk.file, normalizeManifestKey(key));
|
|
126
|
+
for (const [moduleKey, file] of Object.entries(aliases)) {
|
|
127
|
+
const key = keysByFile.get(file);
|
|
128
|
+
const files = key === void 0 ? void 0 : preloads[key];
|
|
129
|
+
if (files && !Object.hasOwn(preloads, moduleKey)) preloads[moduleKey] = files;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
106
132
|
function dynamicImportPreloadsWithBase(preloads, applyBase) {
|
|
107
133
|
const withBase = {};
|
|
108
134
|
for (const [key, files] of Object.entries(preloads)) withBase[key] = files.map(applyBase);
|
|
109
135
|
return withBase;
|
|
110
136
|
}
|
|
111
137
|
//#endregion
|
|
112
|
-
export { computeDynamicImportPreloads, computeLazyChunks, dynamicImportPreloadsWithBase };
|
|
138
|
+
export { addDynamicImportPreloadAliases, computeDynamicImportPreloads, computeLazyChunks, dynamicImportPreloadsWithBase };
|
|
@@ -21,4 +21,5 @@ export declare function encodeMiddlewareRequestHeaders(targetHeaders: Headers, r
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function buildRequestHeadersFromMiddlewareResponse(baseHeaders: Headers, middlewareHeaders: MiddlewareHeaderSource): Headers | null;
|
|
23
23
|
export declare function shouldKeepMiddlewareHeader(key: string): boolean;
|
|
24
|
-
//#endregion
|
|
24
|
+
//#endregion
|
|
25
|
+
export {};
|
package/dist/utils/project.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export declare function findViteConfigPath(root: string): string | undefined;
|
|
|
58
58
|
export declare function formatMissingCloudflarePluginError(options: {
|
|
59
59
|
isAppRouter: boolean;
|
|
60
60
|
configFile?: string;
|
|
61
|
+
/** False when configFile is not the root vite.config.* that `vinext init` updates. */
|
|
62
|
+
initUpdatesConfig?: boolean;
|
|
61
63
|
}): string;
|
|
62
64
|
export type ProjectInfo = {
|
|
63
65
|
root: string;
|
|
@@ -78,8 +80,6 @@ export type ProjectInfo = {
|
|
|
78
80
|
hasMDX: boolean;
|
|
79
81
|
/** CodeHike is a dependency */
|
|
80
82
|
hasCodeHike: boolean;
|
|
81
|
-
/** Native Node modules that need stubbing for Workers */
|
|
82
|
-
nativeModulesToStub: string[];
|
|
83
83
|
};
|
|
84
84
|
/** Check whether a wrangler config file exists in the given directory. */
|
|
85
85
|
export declare function hasWranglerConfig(root: string): boolean;
|
|
@@ -111,4 +111,5 @@ export declare function findDir(root: string, ...candidates: string[]): string |
|
|
|
111
111
|
* Check if the project uses App Router (has an app/ directory).
|
|
112
112
|
*/
|
|
113
113
|
export declare function hasAppDir(root: string): boolean;
|
|
114
|
-
//#endregion
|
|
114
|
+
//#endregion
|
|
115
|
+
export {};
|