@qzsy/vinext 0.1.7
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/LICENSE +21 -0
- package/README.md +773 -0
- package/dist/build/assets-ignore.d.ts +32 -0
- package/dist/build/assets-ignore.js +48 -0
- package/dist/build/clean-output.d.ts +13 -0
- package/dist/build/clean-output.js +34 -0
- package/dist/build/client-build-config.d.ts +171 -0
- package/dist/build/client-build-config.js +270 -0
- package/dist/build/css-url-assets.d.ts +29 -0
- package/dist/build/css-url-assets.js +213 -0
- package/dist/build/google-fonts/build-url.d.ts +9 -0
- package/dist/build/google-fonts/build-url.js +28 -0
- package/dist/build/google-fonts/fallback-metrics-data.js +14029 -0
- package/dist/build/google-fonts/fallback-metrics.d.ts +12 -0
- package/dist/build/google-fonts/fallback-metrics.js +44 -0
- package/dist/build/google-fonts/find-font-files-in-css.d.ts +16 -0
- package/dist/build/google-fonts/find-font-files-in-css.js +28 -0
- package/dist/build/google-fonts/font-data.js +24983 -0
- package/dist/build/google-fonts/font-metadata.d.ts +16 -0
- package/dist/build/google-fonts/font-metadata.js +5 -0
- package/dist/build/google-fonts/get-axes.d.ts +6 -0
- package/dist/build/google-fonts/get-axes.js +37 -0
- package/dist/build/google-fonts/sort-variants.d.ts +4 -0
- package/dist/build/google-fonts/sort-variants.js +12 -0
- package/dist/build/google-fonts/validate.d.ts +27 -0
- package/dist/build/google-fonts/validate.js +54 -0
- package/dist/build/inline-css.d.ts +6 -0
- package/dist/build/inline-css.js +48 -0
- package/dist/build/layout-classification-types.d.ts +61 -0
- package/dist/build/layout-classification-types.js +1 -0
- package/dist/build/layout-classification.d.ts +59 -0
- package/dist/build/layout-classification.js +98 -0
- package/dist/build/next-client-runtime-manifests.d.ts +14 -0
- package/dist/build/next-client-runtime-manifests.js +39 -0
- package/dist/build/nitro-route-rules.d.ts +49 -0
- package/dist/build/nitro-route-rules.js +79 -0
- package/dist/build/precompress.d.ts +27 -0
- package/dist/build/precompress.js +110 -0
- package/dist/build/prerender.d.ts +209 -0
- package/dist/build/prerender.js +932 -0
- package/dist/build/report.d.ts +132 -0
- package/dist/build/report.js +504 -0
- package/dist/build/route-classification-injector.d.ts +34 -0
- package/dist/build/route-classification-injector.js +59 -0
- package/dist/build/route-classification-manifest.d.ts +52 -0
- package/dist/build/route-classification-manifest.js +143 -0
- package/dist/build/run-prerender.d.ts +61 -0
- package/dist/build/run-prerender.js +224 -0
- package/dist/build/server-manifest.d.ts +18 -0
- package/dist/build/server-manifest.js +22 -0
- package/dist/build/ssr-manifest.d.ts +18 -0
- package/dist/build/ssr-manifest.js +69 -0
- package/dist/build/standalone.d.ts +31 -0
- package/dist/build/standalone.js +203 -0
- package/dist/build/static-export.d.ts +55 -0
- package/dist/build/static-export.js +60 -0
- package/dist/cache/cache-adapters-virtual.d.ts +50 -0
- package/dist/cache/cache-adapters-virtual.js +45 -0
- package/dist/cache.d.ts +2 -0
- package/dist/cache.js +2 -0
- package/dist/check.d.ts +87 -0
- package/dist/check.js +1037 -0
- package/dist/cli-args.d.ts +33 -0
- package/dist/cli-args.js +124 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +744 -0
- package/dist/client/app-nav-failure-handler.d.ts +8 -0
- package/dist/client/app-nav-failure-handler.js +44 -0
- package/dist/client/empty-module.d.ts +1 -0
- package/dist/client/empty-module.js +1 -0
- package/dist/client/instrumentation-client-inject.d.ts +33 -0
- package/dist/client/instrumentation-client-inject.js +55 -0
- package/dist/client/instrumentation-client-state.d.ts +9 -0
- package/dist/client/instrumentation-client-state.js +17 -0
- package/dist/client/instrumentation-client.d.ts +7 -0
- package/dist/client/instrumentation-client.js +6 -0
- package/dist/client/navigation-runtime.d.ts +70 -0
- package/dist/client/navigation-runtime.js +169 -0
- package/dist/client/pages-router-link-navigation.d.ts +61 -0
- package/dist/client/pages-router-link-navigation.js +42 -0
- package/dist/client/validate-module-path.d.ts +17 -0
- package/dist/client/validate-module-path.js +24 -0
- package/dist/client/vinext-next-data.d.ts +44 -0
- package/dist/client/vinext-next-data.js +50 -0
- package/dist/client/window-next.d.ts +168 -0
- package/dist/client/window-next.js +57 -0
- package/dist/cloudflare/index.d.ts +3 -0
- package/dist/cloudflare/index.js +3 -0
- package/dist/cloudflare/src/cache/cdn-adapter.runtime.js +102 -0
- package/dist/cloudflare/src/cache/kv-data-adapter.runtime.d.ts +126 -0
- package/dist/cloudflare/src/cache/kv-data-adapter.runtime.js +435 -0
- package/dist/cloudflare/src/utils/cache-control-metadata.js +20 -0
- package/dist/cloudflare/tpr.d.ts +82 -0
- package/dist/cloudflare/tpr.js +558 -0
- package/dist/config/config-matchers.d.ts +257 -0
- package/dist/config/config-matchers.js +1046 -0
- package/dist/config/dotenv.d.ts +56 -0
- package/dist/config/dotenv.js +88 -0
- package/dist/config/next-config.d.ts +540 -0
- package/dist/config/next-config.js +1050 -0
- package/dist/config/tsconfig-paths.d.ts +21 -0
- package/dist/config/tsconfig-paths.js +157 -0
- package/dist/deploy.d.ts +190 -0
- package/dist/deploy.js +1033 -0
- package/dist/entries/app-browser-entry.d.ts +29 -0
- package/dist/entries/app-browser-entry.js +83 -0
- package/dist/entries/app-rsc-entry.d.ts +81 -0
- package/dist/entries/app-rsc-entry.js +943 -0
- package/dist/entries/app-rsc-manifest.d.ts +53 -0
- package/dist/entries/app-rsc-manifest.js +294 -0
- package/dist/entries/app-ssr-entry.d.ts +15 -0
- package/dist/entries/app-ssr-entry.js +24 -0
- package/dist/entries/pages-client-entry.d.ts +11 -0
- package/dist/entries/pages-client-entry.js +204 -0
- package/dist/entries/pages-entry-helpers.d.ts +2 -0
- package/dist/entries/pages-entry-helpers.js +2 -0
- package/dist/entries/pages-server-entry.d.ts +11 -0
- package/dist/entries/pages-server-entry.js +398 -0
- package/dist/entries/runtime-entry-module.d.ts +25 -0
- package/dist/entries/runtime-entry-module.js +46 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +2661 -0
- package/dist/init.d.ts +69 -0
- package/dist/init.js +253 -0
- package/dist/plugins/ast-utils.d.ts +20 -0
- package/dist/plugins/ast-utils.js +78 -0
- package/dist/plugins/async-hooks-stub.d.ts +18 -0
- package/dist/plugins/async-hooks-stub.js +40 -0
- package/dist/plugins/client-reference-dedup.d.ts +35 -0
- package/dist/plugins/client-reference-dedup.js +189 -0
- package/dist/plugins/css-data-url.d.ts +6 -0
- package/dist/plugins/css-data-url.js +83 -0
- package/dist/plugins/dynamic-preload-metadata.d.ts +13 -0
- package/dist/plugins/dynamic-preload-metadata.js +413 -0
- package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
- package/dist/plugins/extensionless-dynamic-import.js +155 -0
- package/dist/plugins/fonts.d.ts +95 -0
- package/dist/plugins/fonts.js +711 -0
- package/dist/plugins/import-meta-url.d.ts +16 -0
- package/dist/plugins/import-meta-url.js +353 -0
- package/dist/plugins/instrumentation-client.d.ts +6 -0
- package/dist/plugins/instrumentation-client.js +27 -0
- package/dist/plugins/middleware-export-validation.d.ts +5 -0
- package/dist/plugins/middleware-export-validation.js +36 -0
- package/dist/plugins/middleware-server-only.d.ts +53 -0
- package/dist/plugins/middleware-server-only.js +90 -0
- package/dist/plugins/og-asset-ownership.d.ts +27 -0
- package/dist/plugins/og-asset-ownership.js +285 -0
- package/dist/plugins/og-assets.d.ts +50 -0
- package/dist/plugins/og-assets.js +229 -0
- package/dist/plugins/optimize-imports.d.ts +42 -0
- package/dist/plugins/optimize-imports.js +587 -0
- package/dist/plugins/postcss.d.ts +26 -0
- package/dist/plugins/postcss.js +96 -0
- package/dist/plugins/remove-console.d.ts +21 -0
- package/dist/plugins/remove-console.js +177 -0
- package/dist/plugins/require-context.d.ts +6 -0
- package/dist/plugins/require-context.js +185 -0
- package/dist/plugins/rsc-client-reference-loaders.d.ts +6 -0
- package/dist/plugins/rsc-client-reference-loaders.js +46 -0
- package/dist/plugins/rsc-client-shim-excludes.d.ts +6 -0
- package/dist/plugins/rsc-client-shim-excludes.js +35 -0
- package/dist/plugins/sass.d.ts +62 -0
- package/dist/plugins/sass.js +268 -0
- package/dist/plugins/server-externals-manifest.d.ts +26 -0
- package/dist/plugins/server-externals-manifest.js +81 -0
- package/dist/plugins/strip-server-exports.d.ts +21 -0
- package/dist/plugins/strip-server-exports.js +519 -0
- package/dist/plugins/typeof-window.d.ts +14 -0
- package/dist/plugins/typeof-window.js +150 -0
- package/dist/plugins/wasm-module-import.d.ts +15 -0
- package/dist/plugins/wasm-module-import.js +50 -0
- package/dist/routing/app-route-graph.d.ts +336 -0
- package/dist/routing/app-route-graph.js +1518 -0
- package/dist/routing/app-router.d.ts +30 -0
- package/dist/routing/app-router.js +59 -0
- package/dist/routing/file-matcher.d.ts +60 -0
- package/dist/routing/file-matcher.js +147 -0
- package/dist/routing/pages-router.d.ts +48 -0
- package/dist/routing/pages-router.js +163 -0
- package/dist/routing/route-matching.d.ts +27 -0
- package/dist/routing/route-matching.js +42 -0
- package/dist/routing/route-pattern.d.ts +64 -0
- package/dist/routing/route-pattern.js +165 -0
- package/dist/routing/route-trie.d.ts +67 -0
- package/dist/routing/route-trie.js +143 -0
- package/dist/routing/route-validation.d.ts +10 -0
- package/dist/routing/route-validation.js +101 -0
- package/dist/routing/utils.d.ts +117 -0
- package/dist/routing/utils.js +242 -0
- package/dist/server/accept-encoding.d.ts +29 -0
- package/dist/server/accept-encoding.js +95 -0
- package/dist/server/api-handler.d.ts +17 -0
- package/dist/server/api-handler.js +276 -0
- package/dist/server/app-action-request.d.ts +4 -0
- package/dist/server/app-action-request.js +9 -0
- package/dist/server/app-bfcache-id.d.ts +5 -0
- package/dist/server/app-bfcache-id.js +5 -0
- package/dist/server/app-bfcache-identity.d.ts +36 -0
- package/dist/server/app-bfcache-identity.js +156 -0
- package/dist/server/app-browser-action-result.d.ts +64 -0
- package/dist/server/app-browser-action-result.js +111 -0
- package/dist/server/app-browser-client-reuse-manifest.d.ts +12 -0
- package/dist/server/app-browser-client-reuse-manifest.js +101 -0
- package/dist/server/app-browser-entry.d.ts +1 -0
- package/dist/server/app-browser-entry.js +1087 -0
- package/dist/server/app-browser-error.d.ts +13 -0
- package/dist/server/app-browser-error.js +52 -0
- package/dist/server/app-browser-history-controller.d.ts +104 -0
- package/dist/server/app-browser-history-controller.js +210 -0
- package/dist/server/app-browser-hydration.d.ts +32 -0
- package/dist/server/app-browser-hydration.js +29 -0
- package/dist/server/app-browser-interception-context.d.ts +24 -0
- package/dist/server/app-browser-interception-context.js +43 -0
- package/dist/server/app-browser-mpa-navigation.d.ts +16 -0
- package/dist/server/app-browser-mpa-navigation.js +42 -0
- package/dist/server/app-browser-navigation-controller.d.ts +109 -0
- package/dist/server/app-browser-navigation-controller.js +465 -0
- package/dist/server/app-browser-popstate.d.ts +26 -0
- package/dist/server/app-browser-popstate.js +44 -0
- package/dist/server/app-browser-rsc-redirect.d.ts +38 -0
- package/dist/server/app-browser-rsc-redirect.js +64 -0
- package/dist/server/app-browser-server-action-client.d.ts +32 -0
- package/dist/server/app-browser-server-action-client.js +128 -0
- package/dist/server/app-browser-server-action-navigation.d.ts +6 -0
- package/dist/server/app-browser-server-action-navigation.js +9 -0
- package/dist/server/app-browser-state.d.ts +140 -0
- package/dist/server/app-browser-state.js +315 -0
- package/dist/server/app-browser-stream.d.ts +28 -0
- package/dist/server/app-browser-stream.js +122 -0
- package/dist/server/app-browser-visible-commit.d.ts +78 -0
- package/dist/server/app-browser-visible-commit.js +241 -0
- package/dist/server/app-client-reference-preloader.d.ts +14 -0
- package/dist/server/app-client-reference-preloader.js +44 -0
- package/dist/server/app-elements-wire.d.ts +192 -0
- package/dist/server/app-elements-wire.js +443 -0
- package/dist/server/app-elements.d.ts +9 -0
- package/dist/server/app-elements.js +18 -0
- package/dist/server/app-fallback-renderer.d.ts +89 -0
- package/dist/server/app-fallback-renderer.js +136 -0
- package/dist/server/app-history-state.d.ts +85 -0
- package/dist/server/app-history-state.js +223 -0
- package/dist/server/app-hook-warning-suppression.d.ts +6 -0
- package/dist/server/app-hook-warning-suppression.js +10 -0
- package/dist/server/app-inline-css-client.d.ts +6 -0
- package/dist/server/app-inline-css-client.js +35 -0
- package/dist/server/app-interception-context-header.d.ts +32 -0
- package/dist/server/app-interception-context-header.js +42 -0
- package/dist/server/app-layout-param-observation.d.ts +43 -0
- package/dist/server/app-layout-param-observation.js +168 -0
- package/dist/server/app-middleware.d.ts +46 -0
- package/dist/server/app-middleware.js +168 -0
- package/dist/server/app-mounted-slots-header.d.ts +35 -0
- package/dist/server/app-mounted-slots-header.js +58 -0
- package/dist/server/app-optimistic-routing.d.ts +53 -0
- package/dist/server/app-optimistic-routing.js +227 -0
- package/dist/server/app-page-boundary-render.d.ts +85 -0
- package/dist/server/app-page-boundary-render.js +305 -0
- package/dist/server/app-page-boundary.d.ts +102 -0
- package/dist/server/app-page-boundary.js +120 -0
- package/dist/server/app-page-cache-finalizer.d.ts +62 -0
- package/dist/server/app-page-cache-finalizer.js +122 -0
- package/dist/server/app-page-cache-render.d.ts +53 -0
- package/dist/server/app-page-cache-render.js +91 -0
- package/dist/server/app-page-cache.d.ts +83 -0
- package/dist/server/app-page-cache.js +272 -0
- package/dist/server/app-page-dispatch.d.ts +223 -0
- package/dist/server/app-page-dispatch.js +610 -0
- package/dist/server/app-page-element-builder.d.ts +96 -0
- package/dist/server/app-page-element-builder.js +205 -0
- package/dist/server/app-page-execution.d.ts +138 -0
- package/dist/server/app-page-execution.js +328 -0
- package/dist/server/app-page-head.d.ts +65 -0
- package/dist/server/app-page-head.js +228 -0
- package/dist/server/app-page-method.d.ts +15 -0
- package/dist/server/app-page-method.js +25 -0
- package/dist/server/app-page-params.d.ts +8 -0
- package/dist/server/app-page-params.js +39 -0
- package/dist/server/app-page-ppr-runtime.d.ts +7 -0
- package/dist/server/app-page-ppr-runtime.js +70 -0
- package/dist/server/app-page-probe.d.ts +134 -0
- package/dist/server/app-page-probe.js +276 -0
- package/dist/server/app-page-render-identity.d.ts +21 -0
- package/dist/server/app-page-render-identity.js +40 -0
- package/dist/server/app-page-render-observation.d.ts +36 -0
- package/dist/server/app-page-render-observation.js +82 -0
- package/dist/server/app-page-render.d.ts +111 -0
- package/dist/server/app-page-render.js +602 -0
- package/dist/server/app-page-request.d.ts +137 -0
- package/dist/server/app-page-request.js +216 -0
- package/dist/server/app-page-response.d.ts +68 -0
- package/dist/server/app-page-response.js +120 -0
- package/dist/server/app-page-route-wiring.d.ts +151 -0
- package/dist/server/app-page-route-wiring.js +452 -0
- package/dist/server/app-page-search-params-observation.d.ts +10 -0
- package/dist/server/app-page-search-params-observation.js +20 -0
- package/dist/server/app-page-segment-state.d.ts +9 -0
- package/dist/server/app-page-segment-state.js +80 -0
- package/dist/server/app-page-stream.d.ts +151 -0
- package/dist/server/app-page-stream.js +143 -0
- package/dist/server/app-pages-bridge.d.ts +63 -0
- package/dist/server/app-pages-bridge.js +63 -0
- package/dist/server/app-post-middleware-context.d.ts +15 -0
- package/dist/server/app-post-middleware-context.js +26 -0
- package/dist/server/app-ppr-fallback-shell-render.d.ts +18 -0
- package/dist/server/app-ppr-fallback-shell-render.js +26 -0
- package/dist/server/app-ppr-fallback-shell.d.ts +33 -0
- package/dist/server/app-ppr-fallback-shell.js +89 -0
- package/dist/server/app-prerender-endpoints.d.ts +18 -0
- package/dist/server/app-prerender-endpoints.js +94 -0
- package/dist/server/app-prerender-static-params.d.ts +30 -0
- package/dist/server/app-prerender-static-params.js +81 -0
- package/dist/server/app-render-dependency.d.ts +14 -0
- package/dist/server/app-render-dependency.js +41 -0
- package/dist/server/app-request-context.d.ts +20 -0
- package/dist/server/app-request-context.js +29 -0
- package/dist/server/app-route-handler-cache.d.ts +46 -0
- package/dist/server/app-route-handler-cache.js +78 -0
- package/dist/server/app-route-handler-dispatch.d.ts +49 -0
- package/dist/server/app-route-handler-dispatch.js +163 -0
- package/dist/server/app-route-handler-execution.d.ts +86 -0
- package/dist/server/app-route-handler-execution.js +128 -0
- package/dist/server/app-route-handler-policy.d.ts +55 -0
- package/dist/server/app-route-handler-policy.js +58 -0
- package/dist/server/app-route-handler-response.d.ts +28 -0
- package/dist/server/app-route-handler-response.js +145 -0
- package/dist/server/app-route-handler-runtime.d.ts +39 -0
- package/dist/server/app-route-handler-runtime.js +250 -0
- package/dist/server/app-route-module-loader.d.ts +91 -0
- package/dist/server/app-route-module-loader.js +83 -0
- package/dist/server/app-router-entry.d.ts +13 -0
- package/dist/server/app-router-entry.js +49 -0
- package/dist/server/app-rsc-cache-busting.d.ts +64 -0
- package/dist/server/app-rsc-cache-busting.js +206 -0
- package/dist/server/app-rsc-embedded-chunks.d.ts +8 -0
- package/dist/server/app-rsc-embedded-chunks.js +32 -0
- package/dist/server/app-rsc-error-handler.d.ts +20 -0
- package/dist/server/app-rsc-error-handler.js +28 -0
- package/dist/server/app-rsc-errors.d.ts +40 -0
- package/dist/server/app-rsc-errors.js +60 -0
- package/dist/server/app-rsc-handler.d.ts +201 -0
- package/dist/server/app-rsc-handler.js +538 -0
- package/dist/server/app-rsc-render-mode.d.ts +11 -0
- package/dist/server/app-rsc-render-mode.js +25 -0
- package/dist/server/app-rsc-request-normalization.d.ts +48 -0
- package/dist/server/app-rsc-request-normalization.js +75 -0
- package/dist/server/app-rsc-response-finalizer.d.ts +37 -0
- package/dist/server/app-rsc-response-finalizer.js +54 -0
- package/dist/server/app-rsc-route-matching.d.ts +93 -0
- package/dist/server/app-rsc-route-matching.js +134 -0
- package/dist/server/app-segment-config.d.ts +46 -0
- package/dist/server/app-segment-config.js +113 -0
- package/dist/server/app-server-action-execution.d.ts +219 -0
- package/dist/server/app-server-action-execution.js +767 -0
- package/dist/server/app-ssr-entry.d.ts +52 -0
- package/dist/server/app-ssr-entry.js +295 -0
- package/dist/server/app-ssr-error-meta.d.ts +13 -0
- package/dist/server/app-ssr-error-meta.js +48 -0
- package/dist/server/app-ssr-router-instance.d.ts +6 -0
- package/dist/server/app-ssr-router-instance.js +24 -0
- package/dist/server/app-ssr-stream.d.ts +60 -0
- package/dist/server/app-ssr-stream.js +408 -0
- package/dist/server/app-static-generation.d.ts +15 -0
- package/dist/server/app-static-generation.js +19 -0
- package/dist/server/app-visited-response-cache.d.ts +23 -0
- package/dist/server/app-visited-response-cache.js +19 -0
- package/dist/server/artifact-compatibility.d.ts +54 -0
- package/dist/server/artifact-compatibility.js +91 -0
- package/dist/server/before-interactive-head.d.ts +17 -0
- package/dist/server/before-interactive-head.js +35 -0
- package/dist/server/cache-control.d.ts +37 -0
- package/dist/server/cache-control.js +56 -0
- package/dist/server/cache-headers.d.ts +6 -0
- package/dist/server/cache-headers.js +17 -0
- package/dist/server/cache-proof.d.ts +364 -0
- package/dist/server/cache-proof.js +794 -0
- package/dist/server/client-reuse-manifest.d.ts +104 -0
- package/dist/server/client-reuse-manifest.js +209 -0
- package/dist/server/client-trace-metadata.d.ts +30 -0
- package/dist/server/client-trace-metadata.js +81 -0
- package/dist/server/cookie-utils.d.ts +12 -0
- package/dist/server/cookie-utils.js +18 -0
- package/dist/server/csp.d.ts +10 -0
- package/dist/server/csp.js +41 -0
- package/dist/server/default-global-error-module.d.ts +19 -0
- package/dist/server/default-global-error-module.js +18 -0
- package/dist/server/default-not-found-module.d.ts +19 -0
- package/dist/server/default-not-found-module.js +18 -0
- package/dist/server/defer-until-stream-consumed.d.ts +7 -0
- package/dist/server/defer-until-stream-consumed.js +34 -0
- package/dist/server/dev-error-overlay-store.d.ts +39 -0
- package/dist/server/dev-error-overlay-store.js +86 -0
- package/dist/server/dev-error-overlay.d.ts +51 -0
- package/dist/server/dev-error-overlay.js +1341 -0
- package/dist/server/dev-initial-server-error.d.ts +9 -0
- package/dist/server/dev-initial-server-error.js +26 -0
- package/dist/server/dev-lockfile.d.ts +109 -0
- package/dist/server/dev-lockfile.js +179 -0
- package/dist/server/dev-module-runner.d.ts +30 -0
- package/dist/server/dev-module-runner.js +91 -0
- package/dist/server/dev-origin-check.d.ts +62 -0
- package/dist/server/dev-origin-check.js +156 -0
- package/dist/server/dev-route-files.d.ts +6 -0
- package/dist/server/dev-route-files.js +71 -0
- package/dist/server/dev-server.d.ts +58 -0
- package/dist/server/dev-server.js +1114 -0
- package/dist/server/dev-stack-sourcemap-endpoint.d.ts +4 -0
- package/dist/server/dev-stack-sourcemap-endpoint.js +4 -0
- package/dist/server/dev-stack-sourcemap.d.ts +43 -0
- package/dist/server/dev-stack-sourcemap.js +443 -0
- package/dist/server/document-initial-head.d.ts +6 -0
- package/dist/server/document-initial-head.js +33 -0
- package/dist/server/edge-api-runtime.d.ts +4 -0
- package/dist/server/edge-api-runtime.js +6 -0
- package/dist/server/file-based-metadata.d.ts +29 -0
- package/dist/server/file-based-metadata.js +401 -0
- package/dist/server/headers.d.ts +114 -0
- package/dist/server/headers.js +136 -0
- package/dist/server/html.d.ts +28 -0
- package/dist/server/html.js +41 -0
- package/dist/server/http-error-responses.d.ts +91 -0
- package/dist/server/http-error-responses.js +105 -0
- package/dist/server/hybrid-route-priority.d.ts +22 -0
- package/dist/server/hybrid-route-priority.js +33 -0
- package/dist/server/image-optimization.d.ts +130 -0
- package/dist/server/image-optimization.js +247 -0
- package/dist/server/implicit-tags.d.ts +6 -0
- package/dist/server/implicit-tags.js +44 -0
- package/dist/server/instrumentation-runtime.d.ts +49 -0
- package/dist/server/instrumentation-runtime.js +35 -0
- package/dist/server/instrumentation.d.ts +85 -0
- package/dist/server/instrumentation.js +130 -0
- package/dist/server/isr-cache.d.ts +127 -0
- package/dist/server/isr-cache.js +282 -0
- package/dist/server/isr-decision.d.ts +79 -0
- package/dist/server/isr-decision.js +70 -0
- package/dist/server/metadata-route-build-data.d.ts +24 -0
- package/dist/server/metadata-route-build-data.js +148 -0
- package/dist/server/metadata-route-response.d.ts +16 -0
- package/dist/server/metadata-route-response.js +205 -0
- package/dist/server/metadata-routes.d.ts +139 -0
- package/dist/server/metadata-routes.js +433 -0
- package/dist/server/middleware-matcher.d.ts +14 -0
- package/dist/server/middleware-matcher.js +111 -0
- package/dist/server/middleware-request-headers.d.ts +11 -0
- package/dist/server/middleware-request-headers.js +65 -0
- package/dist/server/middleware-response-headers.d.ts +12 -0
- package/dist/server/middleware-response-headers.js +42 -0
- package/dist/server/middleware-runtime.d.ts +67 -0
- package/dist/server/middleware-runtime.js +240 -0
- package/dist/server/middleware.d.ts +62 -0
- package/dist/server/middleware.js +114 -0
- package/dist/server/navigation-planner.d.ts +308 -0
- package/dist/server/navigation-planner.js +831 -0
- package/dist/server/navigation-trace.d.ts +68 -0
- package/dist/server/navigation-trace.js +71 -0
- package/dist/server/next-error-digest.d.ts +44 -0
- package/dist/server/next-error-digest.js +40 -0
- package/dist/server/normalize-path.d.ts +38 -0
- package/dist/server/normalize-path.js +70 -0
- package/dist/server/open-redirect.d.ts +12 -0
- package/dist/server/open-redirect.js +21 -0
- package/dist/server/operation-token.d.ts +40 -0
- package/dist/server/operation-token.js +85 -0
- package/dist/server/otel-tracer-extension.d.ts +45 -0
- package/dist/server/otel-tracer-extension.js +89 -0
- package/dist/server/pages-api-route.d.ts +83 -0
- package/dist/server/pages-api-route.js +75 -0
- package/dist/server/pages-asset-tags.d.ts +78 -0
- package/dist/server/pages-asset-tags.js +126 -0
- package/dist/server/pages-body-parser-config.d.ts +59 -0
- package/dist/server/pages-body-parser-config.js +77 -0
- package/dist/server/pages-data-route.d.ts +121 -0
- package/dist/server/pages-data-route.js +157 -0
- package/dist/server/pages-default-404.d.ts +30 -0
- package/dist/server/pages-default-404.js +38 -0
- package/dist/server/pages-dev-module-url.d.ts +4 -0
- package/dist/server/pages-dev-module-url.js +15 -0
- package/dist/server/pages-document-initial-props.d.ts +77 -0
- package/dist/server/pages-document-initial-props.js +109 -0
- package/dist/server/pages-get-initial-props.d.ts +67 -0
- package/dist/server/pages-get-initial-props.js +92 -0
- package/dist/server/pages-i18n.d.ts +106 -0
- package/dist/server/pages-i18n.js +183 -0
- package/dist/server/pages-media-type.d.ts +15 -0
- package/dist/server/pages-media-type.js +24 -0
- package/dist/server/pages-node-compat.d.ts +55 -0
- package/dist/server/pages-node-compat.js +235 -0
- package/dist/server/pages-page-data.d.ts +223 -0
- package/dist/server/pages-page-data.js +484 -0
- package/dist/server/pages-page-handler.d.ts +100 -0
- package/dist/server/pages-page-handler.js +403 -0
- package/dist/server/pages-page-method.d.ts +47 -0
- package/dist/server/pages-page-method.js +17 -0
- package/dist/server/pages-page-response.d.ts +138 -0
- package/dist/server/pages-page-response.js +285 -0
- package/dist/server/pages-readiness.d.ts +36 -0
- package/dist/server/pages-readiness.js +21 -0
- package/dist/server/pages-request-pipeline.d.ts +116 -0
- package/dist/server/pages-request-pipeline.js +311 -0
- package/dist/server/pages-revalidate.d.ts +15 -0
- package/dist/server/pages-revalidate.js +19 -0
- package/dist/server/pages-serializable-props.d.ts +24 -0
- package/dist/server/pages-serializable-props.js +67 -0
- package/dist/server/pregenerated-concrete-paths.d.ts +16 -0
- package/dist/server/pregenerated-concrete-paths.js +61 -0
- package/dist/server/prerender-manifest.d.ts +33 -0
- package/dist/server/prerender-manifest.js +54 -0
- package/dist/server/prerender-route-params.d.ts +23 -0
- package/dist/server/prerender-route-params.js +113 -0
- package/dist/server/prerender-work-unit-setup.d.ts +6 -0
- package/dist/server/prerender-work-unit-setup.js +28 -0
- package/dist/server/prod-server.d.ts +148 -0
- package/dist/server/prod-server.js +1136 -0
- package/dist/server/proxy-trust.d.ts +40 -0
- package/dist/server/proxy-trust.js +68 -0
- package/dist/server/request-log.d.ts +39 -0
- package/dist/server/request-log.js +56 -0
- package/dist/server/request-pipeline.d.ts +187 -0
- package/dist/server/request-pipeline.js +447 -0
- package/dist/server/rsc-stream-hints.d.ts +10 -0
- package/dist/server/rsc-stream-hints.js +41 -0
- package/dist/server/seed-cache.d.ts +29 -0
- package/dist/server/seed-cache.js +125 -0
- package/dist/server/server-action-not-found.d.ts +21 -0
- package/dist/server/server-action-not-found.js +62 -0
- package/dist/server/server-globals.d.ts +4 -0
- package/dist/server/server-globals.js +35 -0
- package/dist/server/skip-cache-proof.d.ts +61 -0
- package/dist/server/skip-cache-proof.js +168 -0
- package/dist/server/socket-error-backstop.d.ts +34 -0
- package/dist/server/socket-error-backstop.js +200 -0
- package/dist/server/static-file-cache.d.ts +56 -0
- package/dist/server/static-file-cache.js +231 -0
- package/dist/server/static-layout-client-reuse-proof.d.ts +15 -0
- package/dist/server/static-layout-client-reuse-proof.js +33 -0
- package/dist/server/streaming-metadata.d.ts +4 -0
- package/dist/server/streaming-metadata.js +8 -0
- package/dist/server/worker-utils.d.ts +7 -0
- package/dist/server/worker-utils.js +99 -0
- package/dist/shims/amp.d.ts +19 -0
- package/dist/shims/amp.js +23 -0
- package/dist/shims/app-router-scroll-state.d.ts +15 -0
- package/dist/shims/app-router-scroll-state.js +61 -0
- package/dist/shims/app-router-scroll.d.ts +29 -0
- package/dist/shims/app-router-scroll.js +141 -0
- package/dist/shims/app.d.ts +42 -0
- package/dist/shims/app.js +48 -0
- package/dist/shims/before-interactive-context.d.ts +40 -0
- package/dist/shims/before-interactive-context.js +8 -0
- package/dist/shims/cache-for-request.d.ts +57 -0
- package/dist/shims/cache-for-request.js +72 -0
- package/dist/shims/cache-handler.d.ts +106 -0
- package/dist/shims/cache-handler.js +176 -0
- package/dist/shims/cache-request-state.d.ts +47 -0
- package/dist/shims/cache-request-state.js +126 -0
- package/dist/shims/cache-runtime.d.ts +83 -0
- package/dist/shims/cache-runtime.js +452 -0
- package/dist/shims/cache.d.ts +145 -0
- package/dist/shims/cache.js +401 -0
- package/dist/shims/cdn-cache.d.ts +125 -0
- package/dist/shims/cdn-cache.js +100 -0
- package/dist/shims/client-hook-error.d.ts +13 -0
- package/dist/shims/client-hook-error.js +17 -0
- package/dist/shims/client-locale.d.ts +14 -0
- package/dist/shims/client-locale.js +11 -0
- package/dist/shims/client-only.d.ts +1 -0
- package/dist/shims/client-only.js +1 -0
- package/dist/shims/compat-router.d.ts +16 -0
- package/dist/shims/compat-router.js +25 -0
- package/dist/shims/config.d.ts +28 -0
- package/dist/shims/config.js +21 -0
- package/dist/shims/constants.d.ts +130 -0
- package/dist/shims/constants.js +167 -0
- package/dist/shims/default-global-error.d.ts +31 -0
- package/dist/shims/default-global-error.js +179 -0
- package/dist/shims/default-not-found.d.ts +11 -0
- package/dist/shims/default-not-found.js +59 -0
- package/dist/shims/document.d.ts +92 -0
- package/dist/shims/document.js +76 -0
- package/dist/shims/dynamic-preload-chunks.d.ts +8 -0
- package/dist/shims/dynamic-preload-chunks.js +79 -0
- package/dist/shims/dynamic.d.ts +35 -0
- package/dist/shims/dynamic.js +204 -0
- package/dist/shims/error-boundary-navigation.d.ts +7 -0
- package/dist/shims/error-boundary-navigation.js +44 -0
- package/dist/shims/error-boundary.d.ts +155 -0
- package/dist/shims/error-boundary.js +342 -0
- package/dist/shims/error.d.ts +31 -0
- package/dist/shims/error.js +123 -0
- package/dist/shims/error.react-server.d.ts +9 -0
- package/dist/shims/error.react-server.js +6 -0
- package/dist/shims/fetch-cache.d.ts +136 -0
- package/dist/shims/fetch-cache.js +766 -0
- package/dist/shims/font-google-base.d.ts +83 -0
- package/dist/shims/font-google-base.js +290 -0
- package/dist/shims/font-google.d.ts +2 -0
- package/dist/shims/font-google.js +2 -0
- package/dist/shims/font-local.d.ts +50 -0
- package/dist/shims/font-local.js +195 -0
- package/dist/shims/font-utils.d.ts +56 -0
- package/dist/shims/font-utils.js +107 -0
- package/dist/shims/form.d.ts +19 -0
- package/dist/shims/form.js +236 -0
- package/dist/shims/hash-scroll.d.ts +10 -0
- package/dist/shims/hash-scroll.js +47 -0
- package/dist/shims/head-state.d.ts +16 -0
- package/dist/shims/head-state.js +43 -0
- package/dist/shims/head.d.ts +73 -0
- package/dist/shims/head.js +340 -0
- package/dist/shims/headers.d.ts +253 -0
- package/dist/shims/headers.js +754 -0
- package/dist/shims/i18n-context.d.ts +22 -0
- package/dist/shims/i18n-context.js +42 -0
- package/dist/shims/i18n-state.d.ts +14 -0
- package/dist/shims/i18n-state.js +38 -0
- package/dist/shims/image-config.d.ts +45 -0
- package/dist/shims/image-config.js +85 -0
- package/dist/shims/image.d.ts +55 -0
- package/dist/shims/image.js +582 -0
- package/dist/shims/internal/als-registry.d.ts +14 -0
- package/dist/shims/internal/als-registry.js +80 -0
- package/dist/shims/internal/api-utils.d.ts +14 -0
- package/dist/shims/internal/api-utils.js +1 -0
- package/dist/shims/internal/app-page-props-cache-key.d.ts +5 -0
- package/dist/shims/internal/app-page-props-cache-key.js +16 -0
- package/dist/shims/internal/app-route-detection.d.ts +39 -0
- package/dist/shims/internal/app-route-detection.js +62 -0
- package/dist/shims/internal/app-router-context.d.ts +31 -0
- package/dist/shims/internal/app-router-context.js +28 -0
- package/dist/shims/internal/cookie-serialize.d.ts +45 -0
- package/dist/shims/internal/cookie-serialize.js +49 -0
- package/dist/shims/internal/cookies.d.ts +2 -0
- package/dist/shims/internal/cookies.js +2 -0
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +31 -0
- package/dist/shims/internal/hybrid-client-route-owner.js +143 -0
- package/dist/shims/internal/interpolate-as.d.ts +25 -0
- package/dist/shims/internal/interpolate-as.js +196 -0
- package/dist/shims/internal/link-status-registry.d.ts +43 -0
- package/dist/shims/internal/link-status-registry.js +42 -0
- package/dist/shims/internal/make-hanging-promise.d.ts +15 -0
- package/dist/shims/internal/make-hanging-promise.js +44 -0
- package/dist/shims/internal/navigation-untracked.d.ts +35 -0
- package/dist/shims/internal/navigation-untracked.js +56 -0
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +54 -0
- package/dist/shims/internal/pages-data-fetch-dedup.js +121 -0
- package/dist/shims/internal/pages-data-target.d.ts +62 -0
- package/dist/shims/internal/pages-data-target.js +98 -0
- package/dist/shims/internal/pages-data-url.d.ts +41 -0
- package/dist/shims/internal/pages-data-url.js +71 -0
- package/dist/shims/internal/pages-router-accessor.d.ts +19 -0
- package/dist/shims/internal/pages-router-accessor.js +13 -0
- package/dist/shims/internal/route-pattern-for-warning.d.ts +27 -0
- package/dist/shims/internal/route-pattern-for-warning.js +40 -0
- package/dist/shims/internal/router-context.d.ts +7 -0
- package/dist/shims/internal/router-context.js +13 -0
- package/dist/shims/internal/utils.d.ts +52 -0
- package/dist/shims/internal/utils.js +27 -0
- package/dist/shims/internal/work-unit-async-storage.d.ts +30 -0
- package/dist/shims/internal/work-unit-async-storage.js +17 -0
- package/dist/shims/layout-segment-context.d.ts +24 -0
- package/dist/shims/layout-segment-context.js +39 -0
- package/dist/shims/legacy-image.d.ts +41 -0
- package/dist/shims/legacy-image.js +49 -0
- package/dist/shims/link-prefetch.d.ts +41 -0
- package/dist/shims/link-prefetch.js +43 -0
- package/dist/shims/link.d.ts +102 -0
- package/dist/shims/link.js +687 -0
- package/dist/shims/metadata.d.ts +285 -0
- package/dist/shims/metadata.js +820 -0
- package/dist/shims/navigation-context-state.d.ts +40 -0
- package/dist/shims/navigation-context-state.js +116 -0
- package/dist/shims/navigation-errors.d.ts +55 -0
- package/dist/shims/navigation-errors.js +110 -0
- package/dist/shims/navigation-server.d.ts +3 -0
- package/dist/shims/navigation-server.js +3 -0
- package/dist/shims/navigation-state.d.ts +25 -0
- package/dist/shims/navigation-state.js +66 -0
- package/dist/shims/navigation.d.ts +286 -0
- package/dist/shims/navigation.js +1206 -0
- package/dist/shims/navigation.react-server.d.ts +14 -0
- package/dist/shims/navigation.react-server.js +32 -0
- package/dist/shims/offline.d.ts +4 -0
- package/dist/shims/offline.js +15 -0
- package/dist/shims/og.d.ts +17 -0
- package/dist/shims/og.js +48 -0
- package/dist/shims/pages-router-runtime.d.ts +12 -0
- package/dist/shims/pages-router-runtime.js +24 -0
- package/dist/shims/ppr-fallback-shell.d.ts +33 -0
- package/dist/shims/ppr-fallback-shell.js +170 -0
- package/dist/shims/readonly-url-search-params.d.ts +13 -0
- package/dist/shims/readonly-url-search-params.js +26 -0
- package/dist/shims/request-context.d.ts +58 -0
- package/dist/shims/request-context.js +45 -0
- package/dist/shims/request-state-types.d.ts +12 -0
- package/dist/shims/request-state-types.js +1 -0
- package/dist/shims/root-params.d.ts +12 -0
- package/dist/shims/root-params.js +30 -0
- package/dist/shims/router-state.d.ts +32 -0
- package/dist/shims/router-state.js +39 -0
- package/dist/shims/router.d.ts +192 -0
- package/dist/shims/router.js +1786 -0
- package/dist/shims/script-nonce-context.d.ts +11 -0
- package/dist/shims/script-nonce-context.js +23 -0
- package/dist/shims/script.d.ts +43 -0
- package/dist/shims/script.js +370 -0
- package/dist/shims/server-only.d.ts +1 -0
- package/dist/shims/server-only.js +1 -0
- package/dist/shims/server.d.ts +323 -0
- package/dist/shims/server.js +729 -0
- package/dist/shims/slot.d.ts +45 -0
- package/dist/shims/slot.js +230 -0
- package/dist/shims/thenable-params.d.ts +11 -0
- package/dist/shims/thenable-params.js +176 -0
- package/dist/shims/unified-request-context.d.ts +68 -0
- package/dist/shims/unified-request-context.js +86 -0
- package/dist/shims/unrecognized-action-error.d.ts +34 -0
- package/dist/shims/unrecognized-action-error.js +39 -0
- package/dist/shims/url-safety.d.ts +34 -0
- package/dist/shims/url-safety.js +70 -0
- package/dist/shims/url-utils.d.ts +51 -0
- package/dist/shims/url-utils.js +156 -0
- package/dist/shims/use-merged-ref.d.ts +6 -0
- package/dist/shims/use-merged-ref.js +38 -0
- package/dist/shims/web-vitals.d.ts +8 -0
- package/dist/shims/web-vitals.js +22 -0
- package/dist/typegen.d.ts +9 -0
- package/dist/typegen.js +228 -0
- package/dist/utils/asset-prefix.d.ts +96 -0
- package/dist/utils/asset-prefix.js +122 -0
- package/dist/utils/base-path.d.ts +31 -0
- package/dist/utils/base-path.js +45 -0
- package/dist/utils/built-asset-url.d.ts +4 -0
- package/dist/utils/built-asset-url.js +11 -0
- package/dist/utils/cache-control-metadata.d.ts +4 -0
- package/dist/utils/cache-control-metadata.js +12 -0
- package/dist/utils/client-build-manifest.d.ts +21 -0
- package/dist/utils/client-build-manifest.js +87 -0
- package/dist/utils/client-entry-manifest.d.ts +11 -0
- package/dist/utils/client-entry-manifest.js +29 -0
- package/dist/utils/client-runtime-metadata.d.ts +45 -0
- package/dist/utils/client-runtime-metadata.js +63 -0
- package/dist/utils/commonjs-loader.d.ts +16 -0
- package/dist/utils/commonjs-loader.js +100 -0
- package/dist/utils/compare.d.ts +4 -0
- package/dist/utils/compare.js +8 -0
- package/dist/utils/deployment-id.d.ts +8 -0
- package/dist/utils/deployment-id.js +22 -0
- package/dist/utils/dev-error-recovery-event.d.ts +4 -0
- package/dist/utils/dev-error-recovery-event.js +4 -0
- package/dist/utils/domain-locale.d.ts +26 -0
- package/dist/utils/domain-locale.js +50 -0
- package/dist/utils/encode-cache-tag.d.ts +30 -0
- package/dist/utils/encode-cache-tag.js +36 -0
- package/dist/utils/error-cause.d.ts +4 -0
- package/dist/utils/error-cause.js +95 -0
- package/dist/utils/has-trailing-comma.d.ts +24 -0
- package/dist/utils/has-trailing-comma.js +62 -0
- package/dist/utils/hash.d.ts +24 -0
- package/dist/utils/hash.js +55 -0
- package/dist/utils/html-limited-bots.d.ts +21 -0
- package/dist/utils/html-limited-bots.js +35 -0
- package/dist/utils/lazy-chunks.d.ts +59 -0
- package/dist/utils/lazy-chunks.js +112 -0
- package/dist/utils/manifest-paths.d.ts +30 -0
- package/dist/utils/manifest-paths.js +66 -0
- package/dist/utils/mdx-scan.d.ts +9 -0
- package/dist/utils/mdx-scan.js +34 -0
- package/dist/utils/navigation-signal.d.ts +4 -0
- package/dist/utils/navigation-signal.js +12 -0
- package/dist/utils/number.d.ts +4 -0
- package/dist/utils/number.js +6 -0
- package/dist/utils/parse-cookie.d.ts +13 -0
- package/dist/utils/parse-cookie.js +52 -0
- package/dist/utils/path.d.ts +22 -0
- package/dist/utils/path.js +30 -0
- package/dist/utils/prerender-output-paths.d.ts +14 -0
- package/dist/utils/prerender-output-paths.js +22 -0
- package/dist/utils/project.d.ts +76 -0
- package/dist/utils/project.js +213 -0
- package/dist/utils/promise.d.ts +4 -0
- package/dist/utils/promise.js +6 -0
- package/dist/utils/public-routes.d.ts +4 -0
- package/dist/utils/public-routes.js +48 -0
- package/dist/utils/query.d.ts +49 -0
- package/dist/utils/query.js +122 -0
- package/dist/utils/record.d.ts +4 -0
- package/dist/utils/record.js +6 -0
- package/dist/utils/regex.d.ts +4 -0
- package/dist/utils/regex.js +6 -0
- package/dist/utils/safe-json-file.d.ts +17 -0
- package/dist/utils/safe-json-file.js +23 -0
- package/dist/utils/sorted-array.d.ts +8 -0
- package/dist/utils/sorted-array.js +20 -0
- package/dist/utils/text-stream.d.ts +28 -0
- package/dist/utils/text-stream.js +64 -0
- package/dist/utils/vinext-root.d.ts +23 -0
- package/dist/utils/vinext-root.js +29 -0
- package/dist/utils/virtual-module.d.ts +5 -0
- package/dist/utils/virtual-module.js +0 -0
- package/dist/utils/vite-version.d.ts +21 -0
- package/dist/utils/vite-version.js +42 -0
- package/package.json +145 -0
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { isUnknownRecord } from "../utils/record.js";
|
|
2
|
+
import { hasTrailingComma } from "../utils/has-trailing-comma.js";
|
|
3
|
+
import { relativeWithinRoot, tryRealpathSync } from "../build/ssr-manifest.js";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { parseAst } from "vite";
|
|
6
|
+
import MagicString from "magic-string";
|
|
7
|
+
//#region src/plugins/dynamic-preload-metadata.ts
|
|
8
|
+
function getString(node, key) {
|
|
9
|
+
const value = node[key];
|
|
10
|
+
return typeof value === "string" ? value : null;
|
|
11
|
+
}
|
|
12
|
+
function getNumber(node, key) {
|
|
13
|
+
const value = node[key];
|
|
14
|
+
return typeof value === "number" ? value : null;
|
|
15
|
+
}
|
|
16
|
+
function getArray(node, key) {
|
|
17
|
+
const value = node[key];
|
|
18
|
+
return Array.isArray(value) ? value : [];
|
|
19
|
+
}
|
|
20
|
+
function getBoolean(node, key) {
|
|
21
|
+
return node[key] === true;
|
|
22
|
+
}
|
|
23
|
+
function nodeName(node) {
|
|
24
|
+
if (!isUnknownRecord(node)) return null;
|
|
25
|
+
const name = node.name;
|
|
26
|
+
if (typeof name === "string") return name;
|
|
27
|
+
const value = node.value;
|
|
28
|
+
return typeof value === "string" ? value : null;
|
|
29
|
+
}
|
|
30
|
+
function nodeStringValue(node) {
|
|
31
|
+
if (!isUnknownRecord(node)) return null;
|
|
32
|
+
const value = node.value;
|
|
33
|
+
return typeof value === "string" ? value : null;
|
|
34
|
+
}
|
|
35
|
+
function walkAst(value, visitor) {
|
|
36
|
+
if (!isUnknownRecord(value)) return;
|
|
37
|
+
visitor(value);
|
|
38
|
+
for (const [key, child] of Object.entries(value)) {
|
|
39
|
+
if (key === "parent") continue;
|
|
40
|
+
if (Array.isArray(child)) for (const item of child) walkAst(item, visitor);
|
|
41
|
+
else if (isUnknownRecord(child)) walkAst(child, visitor);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function importSource(node) {
|
|
45
|
+
const source = node.source;
|
|
46
|
+
if (!isUnknownRecord(source)) return null;
|
|
47
|
+
return nodeStringValue(source);
|
|
48
|
+
}
|
|
49
|
+
function isNextDynamicSource(source) {
|
|
50
|
+
return source === "next/dynamic" || source === "next/dynamic.js";
|
|
51
|
+
}
|
|
52
|
+
function collectDynamicImportLocals(ast) {
|
|
53
|
+
const locals = /* @__PURE__ */ new Set();
|
|
54
|
+
if (!isUnknownRecord(ast)) return locals;
|
|
55
|
+
for (const node of getArray(ast, "body")) {
|
|
56
|
+
if (!isUnknownRecord(node)) continue;
|
|
57
|
+
if (getString(node, "type") !== "ImportDeclaration") continue;
|
|
58
|
+
if (!isNextDynamicSource(importSource(node))) continue;
|
|
59
|
+
for (const specifier of getArray(node, "specifiers")) {
|
|
60
|
+
if (!isUnknownRecord(specifier)) continue;
|
|
61
|
+
if (getString(specifier, "type") !== "ImportDefaultSpecifier") continue;
|
|
62
|
+
const local = nodeName(specifier.local);
|
|
63
|
+
if (local) locals.add(local);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return locals;
|
|
67
|
+
}
|
|
68
|
+
function isIdentifierNameInSet(node, names) {
|
|
69
|
+
if (!isUnknownRecord(node)) return false;
|
|
70
|
+
return getString(node, "type") === "Identifier" && names.has(getString(node, "name") ?? "");
|
|
71
|
+
}
|
|
72
|
+
function isDynamicCall(node, dynamicLocals) {
|
|
73
|
+
if (getString(node, "type") !== "CallExpression") return false;
|
|
74
|
+
return isIdentifierNameInSet(node.callee, dynamicLocals);
|
|
75
|
+
}
|
|
76
|
+
function addBindingName(pattern, names) {
|
|
77
|
+
if (!isUnknownRecord(pattern)) return;
|
|
78
|
+
const type = getString(pattern, "type");
|
|
79
|
+
if (type === null) return;
|
|
80
|
+
switch (type) {
|
|
81
|
+
case "Identifier": {
|
|
82
|
+
const name = getString(pattern, "name");
|
|
83
|
+
if (name) names.add(name);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
case "AssignmentPattern":
|
|
87
|
+
addBindingName(pattern.left, names);
|
|
88
|
+
return;
|
|
89
|
+
case "RestElement":
|
|
90
|
+
addBindingName(pattern.argument, names);
|
|
91
|
+
return;
|
|
92
|
+
case "ArrayPattern":
|
|
93
|
+
for (const element of getArray(pattern, "elements")) addBindingName(element, names);
|
|
94
|
+
return;
|
|
95
|
+
case "ObjectPattern":
|
|
96
|
+
for (const property of getArray(pattern, "properties")) {
|
|
97
|
+
if (!isUnknownRecord(property)) continue;
|
|
98
|
+
if (getString(property, "type") === "RestElement") {
|
|
99
|
+
addBindingName(property.argument, names);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
addBindingName(property.value, names);
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
default: return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function addVariableDeclarationBindingNames(node, names) {
|
|
109
|
+
if (!isUnknownRecord(node) || getString(node, "type") !== "VariableDeclaration") return;
|
|
110
|
+
for (const declaration of getArray(node, "declarations")) if (isUnknownRecord(declaration)) addBindingName(declaration.id, names);
|
|
111
|
+
}
|
|
112
|
+
function collectBlockScopedBindingNames(body) {
|
|
113
|
+
const names = /* @__PURE__ */ new Set();
|
|
114
|
+
for (const statement of body) {
|
|
115
|
+
if (!isUnknownRecord(statement)) continue;
|
|
116
|
+
const type = getString(statement, "type");
|
|
117
|
+
if (type === "VariableDeclaration") {
|
|
118
|
+
if (getString(statement, "kind") !== "var") addVariableDeclarationBindingNames(statement, names);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (type === "FunctionDeclaration" || type === "ClassDeclaration") {
|
|
122
|
+
const name = nodeName(statement.id);
|
|
123
|
+
if (name) names.add(name);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return names;
|
|
127
|
+
}
|
|
128
|
+
function collectSwitchScopedBindingNames(node) {
|
|
129
|
+
const names = /* @__PURE__ */ new Set();
|
|
130
|
+
for (const switchCase of getArray(node, "cases")) {
|
|
131
|
+
if (!isUnknownRecord(switchCase)) continue;
|
|
132
|
+
for (const statement of getArray(switchCase, "consequent")) for (const name of collectBlockScopedBindingNames([statement])) names.add(name);
|
|
133
|
+
}
|
|
134
|
+
return names;
|
|
135
|
+
}
|
|
136
|
+
function collectVarBindingNames(value, names) {
|
|
137
|
+
if (!isUnknownRecord(value)) return;
|
|
138
|
+
const type = getString(value, "type");
|
|
139
|
+
if (type === "FunctionDeclaration" || type === "FunctionExpression" || type === "ArrowFunctionExpression") return;
|
|
140
|
+
if (type === "VariableDeclaration" && getString(value, "kind") === "var") addVariableDeclarationBindingNames(value, names);
|
|
141
|
+
for (const [key, child] of Object.entries(value)) {
|
|
142
|
+
if (key === "parent") continue;
|
|
143
|
+
if (Array.isArray(child)) for (const item of child) collectVarBindingNames(item, names);
|
|
144
|
+
else if (isUnknownRecord(child)) collectVarBindingNames(child, names);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function collectFunctionScopeBindingNames(node) {
|
|
148
|
+
const names = /* @__PURE__ */ new Set();
|
|
149
|
+
if (getString(node, "type") === "FunctionExpression") {
|
|
150
|
+
const name = nodeName(node.id);
|
|
151
|
+
if (name) names.add(name);
|
|
152
|
+
}
|
|
153
|
+
for (const param of getArray(node, "params")) addBindingName(param, names);
|
|
154
|
+
collectVarBindingNames(node.body, names);
|
|
155
|
+
return names;
|
|
156
|
+
}
|
|
157
|
+
function collectForBindingNames(node) {
|
|
158
|
+
const names = /* @__PURE__ */ new Set();
|
|
159
|
+
addVariableDeclarationBindingNames(node.init, names);
|
|
160
|
+
addVariableDeclarationBindingNames(node.left, names);
|
|
161
|
+
return names;
|
|
162
|
+
}
|
|
163
|
+
function withoutBindings(activeNames, localNames) {
|
|
164
|
+
if (activeNames.size === 0 || localNames.size === 0) return activeNames;
|
|
165
|
+
let scoped = null;
|
|
166
|
+
for (const name of localNames) {
|
|
167
|
+
if (!activeNames.has(name)) continue;
|
|
168
|
+
scoped ??= new Set(activeNames);
|
|
169
|
+
scoped.delete(name);
|
|
170
|
+
}
|
|
171
|
+
return scoped ?? activeNames;
|
|
172
|
+
}
|
|
173
|
+
function visitChildren(node, dynamicLocals, visitor) {
|
|
174
|
+
for (const [key, child] of Object.entries(node)) {
|
|
175
|
+
if (key === "parent") continue;
|
|
176
|
+
if (Array.isArray(child)) for (const item of child) visitDynamicCalls(item, dynamicLocals, visitor);
|
|
177
|
+
else if (isUnknownRecord(child)) visitDynamicCalls(child, dynamicLocals, visitor);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function visitDynamicCalls(value, dynamicLocals, visitor) {
|
|
181
|
+
if (!isUnknownRecord(value) || dynamicLocals.size === 0) return;
|
|
182
|
+
const type = getString(value, "type");
|
|
183
|
+
if (type === "Program") {
|
|
184
|
+
const scoped = withoutBindings(dynamicLocals, collectBlockScopedBindingNames(getArray(value, "body")));
|
|
185
|
+
for (const statement of getArray(value, "body")) visitDynamicCalls(statement, scoped, visitor);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (type === "BlockStatement") {
|
|
189
|
+
const scoped = withoutBindings(dynamicLocals, collectBlockScopedBindingNames(getArray(value, "body")));
|
|
190
|
+
for (const statement of getArray(value, "body")) visitDynamicCalls(statement, scoped, visitor);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (type === "SwitchStatement") {
|
|
194
|
+
visitDynamicCalls(value.discriminant, dynamicLocals, visitor);
|
|
195
|
+
const scoped = withoutBindings(dynamicLocals, collectSwitchScopedBindingNames(value));
|
|
196
|
+
for (const switchCase of getArray(value, "cases")) visitDynamicCalls(switchCase, scoped, visitor);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (type === "FunctionDeclaration" || type === "FunctionExpression" || type === "ArrowFunctionExpression") {
|
|
200
|
+
visitChildren(value, withoutBindings(dynamicLocals, collectFunctionScopeBindingNames(value)), visitor);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (type === "ClassDeclaration" || type === "ClassExpression") {
|
|
204
|
+
const names = /* @__PURE__ */ new Set();
|
|
205
|
+
const name = nodeName(value.id);
|
|
206
|
+
if (name) names.add(name);
|
|
207
|
+
visitChildren(value, withoutBindings(dynamicLocals, names), visitor);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (type === "ForStatement" || type === "ForInStatement" || type === "ForOfStatement") {
|
|
211
|
+
visitChildren(value, withoutBindings(dynamicLocals, collectForBindingNames(value)), visitor);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (type === "CatchClause") {
|
|
215
|
+
const names = /* @__PURE__ */ new Set();
|
|
216
|
+
addBindingName(value.param, names);
|
|
217
|
+
visitChildren(value, withoutBindings(dynamicLocals, names), visitor);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (isDynamicCall(value, dynamicLocals)) visitor(value);
|
|
221
|
+
visitChildren(value, dynamicLocals, visitor);
|
|
222
|
+
}
|
|
223
|
+
function collectImportSpecifiers(node) {
|
|
224
|
+
const specifiers = [];
|
|
225
|
+
const seen = /* @__PURE__ */ new Set();
|
|
226
|
+
walkAst(node, (item) => {
|
|
227
|
+
if (getString(item, "type") === "ImportExpression") {
|
|
228
|
+
const specifier = nodeStringValue(item.source);
|
|
229
|
+
if (specifier && !seen.has(specifier)) {
|
|
230
|
+
seen.add(specifier);
|
|
231
|
+
specifiers.push(specifier);
|
|
232
|
+
}
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (getString(item, "type") !== "CallExpression") return;
|
|
236
|
+
const callee = item.callee;
|
|
237
|
+
if (!isUnknownRecord(callee) || getString(callee, "type") !== "Import") return;
|
|
238
|
+
const firstArg = getArray(item, "arguments")[0];
|
|
239
|
+
const specifier = nodeStringValue(firstArg);
|
|
240
|
+
if (specifier && !seen.has(specifier)) {
|
|
241
|
+
seen.add(specifier);
|
|
242
|
+
specifiers.push(specifier);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
return specifiers;
|
|
246
|
+
}
|
|
247
|
+
function propertyKeyName(property) {
|
|
248
|
+
if (!isUnknownRecord(property)) return null;
|
|
249
|
+
if (getBoolean(property, "computed")) return null;
|
|
250
|
+
return nodeName(property.key);
|
|
251
|
+
}
|
|
252
|
+
function objectProperties(node) {
|
|
253
|
+
if (!isUnknownRecord(node) || getString(node, "type") !== "ObjectExpression") return [];
|
|
254
|
+
return getArray(node, "properties").filter(isUnknownRecord);
|
|
255
|
+
}
|
|
256
|
+
function hasObjectProperty(node, name) {
|
|
257
|
+
return objectProperties(node).some((property) => propertyKeyName(property) === name);
|
|
258
|
+
}
|
|
259
|
+
function findObjectProperty(node, name) {
|
|
260
|
+
return objectProperties(node).find((property) => propertyKeyName(property) === name) ?? null;
|
|
261
|
+
}
|
|
262
|
+
function dynamicLoaderNode(firstArg) {
|
|
263
|
+
if (!isUnknownRecord(firstArg) || getString(firstArg, "type") !== "ObjectExpression") return firstArg;
|
|
264
|
+
return (findObjectProperty(firstArg, "loader") ?? findObjectProperty(firstArg, "modules"))?.value;
|
|
265
|
+
}
|
|
266
|
+
function findLastEndedProperty(node) {
|
|
267
|
+
const properties = objectProperties(node);
|
|
268
|
+
for (let index = properties.length - 1; index >= 0; index -= 1) if (getNumber(properties[index], "end") !== null) return properties[index];
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
function appendObjectProperty(output, objectNode, property) {
|
|
272
|
+
const start = getNumber(objectNode, "start");
|
|
273
|
+
const end = getNumber(objectNode, "end");
|
|
274
|
+
if (start === null || end === null) return false;
|
|
275
|
+
const lastProperty = findLastEndedProperty(objectNode);
|
|
276
|
+
if (!lastProperty) {
|
|
277
|
+
output.appendLeft(start + 1, property);
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
const propertyEnd = getNumber(lastProperty, "end");
|
|
281
|
+
if (propertyEnd === null) return false;
|
|
282
|
+
output.appendLeft(propertyEnd, `, ${property}`);
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
function insertSecondOptionsArgument(output, code, callNode, firstArg, optionsLiteral) {
|
|
286
|
+
const callEnd = getNumber(callNode, "end");
|
|
287
|
+
const firstArgEnd = getNumber(firstArg, "end");
|
|
288
|
+
if (callEnd === null || firstArgEnd === null) return false;
|
|
289
|
+
const closeParen = callEnd - 1;
|
|
290
|
+
const separator = hasTrailingComma(code.slice(firstArgEnd, closeParen)) ? " " : ", ";
|
|
291
|
+
output.appendLeft(closeParen, `${separator}${optionsLiteral}`);
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
function cleanResolvedId(id) {
|
|
295
|
+
let start = 0;
|
|
296
|
+
while (start < id.length && id.charCodeAt(start) === 0) start += 1;
|
|
297
|
+
return id.slice(start).replace(/^\/@fs\//, "/").split("?")[0].replace(/\\/g, "/");
|
|
298
|
+
}
|
|
299
|
+
const rootRealpathCache = /* @__PURE__ */ new Map();
|
|
300
|
+
function cachedRootRealpath(root) {
|
|
301
|
+
if (!rootRealpathCache.has(root)) rootRealpathCache.set(root, tryRealpathSync(root));
|
|
302
|
+
return rootRealpathCache.get(root) ?? null;
|
|
303
|
+
}
|
|
304
|
+
/** `code` offset -> human `:line:column` (1-based), for build error messages. */
|
|
305
|
+
function formatNodeLocation(code, node) {
|
|
306
|
+
const start = getNumber(node, "start");
|
|
307
|
+
if (start === null) return "";
|
|
308
|
+
const before = code.slice(0, start);
|
|
309
|
+
return `:${before.split("\n").length}:${start - before.lastIndexOf("\n")}`;
|
|
310
|
+
}
|
|
311
|
+
function toManifestModuleId(root, resolvedId) {
|
|
312
|
+
const cleaned = cleanResolvedId(resolvedId);
|
|
313
|
+
if (!path.isAbsolute(cleaned)) return cleaned.replace(/^\/+/, "");
|
|
314
|
+
const rootCandidates = new Set([root]);
|
|
315
|
+
const realRoot = cachedRootRealpath(root);
|
|
316
|
+
if (realRoot) rootCandidates.add(realRoot);
|
|
317
|
+
const moduleCandidates = new Set([cleaned]);
|
|
318
|
+
const realCleaned = tryRealpathSync(cleaned);
|
|
319
|
+
if (realCleaned) moduleCandidates.add(realCleaned.replace(/\\/g, "/"));
|
|
320
|
+
for (const rootCandidate of rootCandidates) for (const moduleCandidate of moduleCandidates) {
|
|
321
|
+
const relative = relativeWithinRoot(rootCandidate, moduleCandidate);
|
|
322
|
+
if (relative) return relative;
|
|
323
|
+
}
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
async function resolveManifestModuleIds(specifiers, importer, root, resolveDynamicImport) {
|
|
327
|
+
const resolvedIds = [];
|
|
328
|
+
const seen = /* @__PURE__ */ new Set();
|
|
329
|
+
for (const specifier of specifiers) {
|
|
330
|
+
const resolved = await resolveDynamicImport(specifier, importer);
|
|
331
|
+
const moduleId = resolved ? toManifestModuleId(root, resolved) : null;
|
|
332
|
+
if (!moduleId || seen.has(moduleId)) continue;
|
|
333
|
+
seen.add(moduleId);
|
|
334
|
+
resolvedIds.push(moduleId);
|
|
335
|
+
}
|
|
336
|
+
return resolvedIds;
|
|
337
|
+
}
|
|
338
|
+
function shouldSkipCall(firstArg, secondArg) {
|
|
339
|
+
if (hasObjectProperty(firstArg, "loadableGenerated")) return true;
|
|
340
|
+
return hasObjectProperty(secondArg, "loadableGenerated");
|
|
341
|
+
}
|
|
342
|
+
function applyLoadableGenerated(output, code, callNode, moduleIds) {
|
|
343
|
+
const args = getArray(callNode, "arguments");
|
|
344
|
+
const firstArg = args[0];
|
|
345
|
+
const secondArg = args[1];
|
|
346
|
+
if (!isUnknownRecord(firstArg)) return false;
|
|
347
|
+
if (shouldSkipCall(firstArg, secondArg)) return false;
|
|
348
|
+
const property = `loadableGenerated: { modules: ${JSON.stringify(moduleIds)} }`;
|
|
349
|
+
if (getString(firstArg, "type") === "ObjectExpression") return appendObjectProperty(output, firstArg, property);
|
|
350
|
+
if (secondArg === void 0) return insertSecondOptionsArgument(output, code, callNode, firstArg, `{ ${property} }`);
|
|
351
|
+
if (isUnknownRecord(secondArg) && getString(secondArg, "type") === "ObjectExpression") return appendObjectProperty(output, secondArg, property);
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
async function transformNextDynamicPreloadMetadata(code, id, root, resolveDynamicImport) {
|
|
355
|
+
if (!code.includes("next/dynamic")) return null;
|
|
356
|
+
let ast;
|
|
357
|
+
try {
|
|
358
|
+
ast = parseAst(code);
|
|
359
|
+
} catch (error) {
|
|
360
|
+
if (typeof process !== "undefined" && process.env?.DEBUG?.includes("vinext")) console.debug(`[vinext] dynamic-preload-metadata: failed to parse ${id}:`, error);
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
const dynamicLocals = collectDynamicImportLocals(ast);
|
|
364
|
+
if (dynamicLocals.size === 0) return null;
|
|
365
|
+
const output = new MagicString(code);
|
|
366
|
+
let changed = false;
|
|
367
|
+
const pending = [];
|
|
368
|
+
visitDynamicCalls(ast, dynamicLocals, (node) => {
|
|
369
|
+
const args = getArray(node, "arguments");
|
|
370
|
+
if (args.length > 2) throw new Error(`next/dynamic only accepts 2 arguments (${id}${formatNodeLocation(code, node)})`);
|
|
371
|
+
const specifiers = collectImportSpecifiers(dynamicLoaderNode(args[0]));
|
|
372
|
+
if (specifiers.length === 0) return;
|
|
373
|
+
pending.push(resolveManifestModuleIds(specifiers, id, root, resolveDynamicImport).then((moduleIds) => {
|
|
374
|
+
if (moduleIds.length === 0) return;
|
|
375
|
+
if (applyLoadableGenerated(output, code, node, moduleIds)) changed = true;
|
|
376
|
+
}));
|
|
377
|
+
});
|
|
378
|
+
await Promise.all(pending);
|
|
379
|
+
if (!changed) return null;
|
|
380
|
+
return {
|
|
381
|
+
code: output.toString(),
|
|
382
|
+
map: output.generateMap({ hires: "boundary" })
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
function createDynamicPreloadMetadataPlugin() {
|
|
386
|
+
let root = process.cwd();
|
|
387
|
+
return {
|
|
388
|
+
name: "vinext:dynamic-preload-metadata",
|
|
389
|
+
configResolved(config) {
|
|
390
|
+
root = config.root;
|
|
391
|
+
},
|
|
392
|
+
transform: {
|
|
393
|
+
filter: {
|
|
394
|
+
id: {
|
|
395
|
+
include: /\.(tsx?|jsx?|mjs)$/,
|
|
396
|
+
exclude: /node_modules/
|
|
397
|
+
},
|
|
398
|
+
code: "next/dynamic"
|
|
399
|
+
},
|
|
400
|
+
async handler(code, id) {
|
|
401
|
+
if (id.includes("node_modules") || id.startsWith("\0")) return null;
|
|
402
|
+
if (!/\.(tsx?|jsx?|mjs)$/.test(id)) return null;
|
|
403
|
+
const result = await transformNextDynamicPreloadMetadata(code, id, root, async (specifier, importer) => {
|
|
404
|
+
return (await this.resolve(specifier, importer, { skipSelf: true }))?.id ?? null;
|
|
405
|
+
});
|
|
406
|
+
if (!result) return null;
|
|
407
|
+
return result;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
//#endregion
|
|
413
|
+
export { createDynamicPreloadMetadataPlugin, transformNextDynamicPreloadMetadata };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { forEachAstChild, hasRange, isAstRecord, nodeArray } from "./ast-utils.js";
|
|
2
|
+
import { parseAst } from "vite";
|
|
3
|
+
import MagicString from "magic-string";
|
|
4
|
+
//#region src/plugins/extensionless-dynamic-import.ts
|
|
5
|
+
const MODULE_EXTENSIONS = [
|
|
6
|
+
".mjs",
|
|
7
|
+
".js",
|
|
8
|
+
".mts",
|
|
9
|
+
".ts",
|
|
10
|
+
".jsx",
|
|
11
|
+
".tsx",
|
|
12
|
+
".json"
|
|
13
|
+
];
|
|
14
|
+
const TRANSFORMABLE_EXTENSIONS = new Set([
|
|
15
|
+
".mjs",
|
|
16
|
+
".js",
|
|
17
|
+
".mts",
|
|
18
|
+
".ts",
|
|
19
|
+
".jsx",
|
|
20
|
+
".tsx",
|
|
21
|
+
".cjs",
|
|
22
|
+
".cts"
|
|
23
|
+
]);
|
|
24
|
+
function createExtensionlessDynamicImportPlugin() {
|
|
25
|
+
let moduleExtensions = MODULE_EXTENSIONS;
|
|
26
|
+
return {
|
|
27
|
+
name: "vinext:extensionless-dynamic-import",
|
|
28
|
+
enforce: "pre",
|
|
29
|
+
configResolved(config) {
|
|
30
|
+
moduleExtensions = getModuleExtensions(config);
|
|
31
|
+
},
|
|
32
|
+
transform: {
|
|
33
|
+
filter: {
|
|
34
|
+
id: {
|
|
35
|
+
include: /\.(?:[cm]?[jt]s|[jt]sx)(?:\?.*)?$/i,
|
|
36
|
+
exclude: /[\\/]node_modules[\\/]/
|
|
37
|
+
},
|
|
38
|
+
code: /\bimport\s*\(/
|
|
39
|
+
},
|
|
40
|
+
handler(code, id) {
|
|
41
|
+
const lang = langForId(id);
|
|
42
|
+
let ast;
|
|
43
|
+
try {
|
|
44
|
+
ast = parseAst(code, { lang });
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const imports = collectExtensionlessImports(ast, code, moduleExtensions);
|
|
49
|
+
if (imports.length === 0) return null;
|
|
50
|
+
const output = new MagicString(code);
|
|
51
|
+
for (const dynamicImport of imports) {
|
|
52
|
+
const source = code.slice(dynamicImport.sourceStart, dynamicImport.sourceEnd);
|
|
53
|
+
output.overwrite(dynamicImport.start, dynamicImport.end, buildReplacement(source, dynamicImport.globPattern, dynamicImport.moduleExtensions));
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
code: output.toString(),
|
|
57
|
+
map: output.generateMap({ hires: "boundary" })
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function langForId(id) {
|
|
64
|
+
const clean = id.split("?", 1)[0];
|
|
65
|
+
const dot = clean.lastIndexOf(".");
|
|
66
|
+
if (dot < 0) return null;
|
|
67
|
+
const ext = clean.slice(dot).toLowerCase();
|
|
68
|
+
if (!TRANSFORMABLE_EXTENSIONS.has(ext)) return null;
|
|
69
|
+
if (ext === ".ts" || ext === ".mts" || ext === ".cts") return "ts";
|
|
70
|
+
if (ext === ".tsx") return "tsx";
|
|
71
|
+
return "jsx";
|
|
72
|
+
}
|
|
73
|
+
function collectExtensionlessImports(ast, code, moduleExtensions) {
|
|
74
|
+
const imports = [];
|
|
75
|
+
function visit(value) {
|
|
76
|
+
if (!isAstRecord(value)) return;
|
|
77
|
+
const parsed = parseExtensionlessImport(value, code, moduleExtensions);
|
|
78
|
+
if (parsed) {
|
|
79
|
+
imports.push(parsed);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
forEachAstChild(value, visit);
|
|
83
|
+
}
|
|
84
|
+
visit(ast);
|
|
85
|
+
return imports;
|
|
86
|
+
}
|
|
87
|
+
function parseExtensionlessImport(node, code, moduleExtensions) {
|
|
88
|
+
if (node.type !== "ImportExpression" || !hasRange(node)) return null;
|
|
89
|
+
if (node.options != null) return null;
|
|
90
|
+
const source = node.source;
|
|
91
|
+
if (!isAstRecord(source) || source.type !== "TemplateLiteral" || !hasRange(source)) return null;
|
|
92
|
+
if (nodeArray(source.expressions).length === 0) return null;
|
|
93
|
+
const quasiTexts = nodeArray(source.quasis).map(templateElementText);
|
|
94
|
+
if (quasiTexts.some((text) => text == null)) return null;
|
|
95
|
+
const texts = quasiTexts;
|
|
96
|
+
const first = texts[0];
|
|
97
|
+
if (!isImportPrefix(code.slice(node.start, source.start))) return null;
|
|
98
|
+
if (!(first.startsWith("./") || first.startsWith("../"))) return null;
|
|
99
|
+
if (texts.some((text) => /[*?[\]{}()!?#]/.test(text))) return null;
|
|
100
|
+
if (texts.slice(1).some((text) => text.includes("."))) return null;
|
|
101
|
+
const directoryEnd = first.lastIndexOf("/") + 1;
|
|
102
|
+
const directory = first.slice(0, directoryEnd);
|
|
103
|
+
const filenamePrefix = first.slice(directoryEnd);
|
|
104
|
+
if (filenamePrefix.includes(".")) return null;
|
|
105
|
+
return {
|
|
106
|
+
start: node.start,
|
|
107
|
+
end: node.end,
|
|
108
|
+
sourceStart: source.start,
|
|
109
|
+
sourceEnd: source.end,
|
|
110
|
+
globPattern: filenamePrefix.length > 0 ? [`${first}*`, `${first}*/**/*`] : `${directory}**/*`,
|
|
111
|
+
moduleExtensions
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function isImportPrefix(value) {
|
|
115
|
+
const prefix = value.match(/^import\s*\(/)?.[0];
|
|
116
|
+
if (!prefix) return false;
|
|
117
|
+
let index = prefix.length;
|
|
118
|
+
while (index < value.length) {
|
|
119
|
+
const char = value[index];
|
|
120
|
+
if (/\s/.test(char)) {
|
|
121
|
+
index += 1;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (value.startsWith("/*", index)) {
|
|
125
|
+
const commentEnd = value.indexOf("*/", index + 2);
|
|
126
|
+
if (commentEnd < 0) return false;
|
|
127
|
+
index = commentEnd + 2;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (value.startsWith("//", index)) {
|
|
131
|
+
const lineEnd = value.indexOf("\n", index + 2);
|
|
132
|
+
if (lineEnd < 0) return true;
|
|
133
|
+
index = lineEnd + 1;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
function templateElementText(value) {
|
|
141
|
+
if (!isAstRecord(value) || value.type !== "TemplateElement") return null;
|
|
142
|
+
const templateValue = value.value;
|
|
143
|
+
if (typeof templateValue !== "object" || templateValue === null) return null;
|
|
144
|
+
const cooked = Reflect.get(templateValue, "cooked");
|
|
145
|
+
return typeof cooked === "string" ? cooked : null;
|
|
146
|
+
}
|
|
147
|
+
function getModuleExtensions(config) {
|
|
148
|
+
return config.resolve.extensions.filter((extension) => extension !== ".node");
|
|
149
|
+
}
|
|
150
|
+
function buildReplacement(source, globPattern, moduleExtensions) {
|
|
151
|
+
const extensions = JSON.stringify(moduleExtensions);
|
|
152
|
+
return `((__vinextPath, __vinextModules = import.meta.glob(${JSON.stringify(globPattern)}), __vinextExtensions = ${extensions}) => { const __vinextLoader = __vinextModules[__vinextPath] ?? __vinextExtensions.map((__vinextExtension) => __vinextModules[__vinextPath + __vinextExtension]).find(Boolean) ?? __vinextExtensions.map((__vinextExtension) => __vinextModules[__vinextPath + "/index" + __vinextExtension]).find(Boolean); return __vinextLoader ? __vinextLoader() : Promise.reject(new Error("Cannot find module '" + __vinextPath + "'")); })(${source})`;
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
export { createExtensionlessDynamicImportPlugin };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/fonts.d.ts
|
|
4
|
+
declare const VIRTUAL_GOOGLE_FONTS = "virtual:vinext-google-fonts";
|
|
5
|
+
declare const RESOLVED_VIRTUAL_GOOGLE_FONTS: string;
|
|
6
|
+
/**
|
|
7
|
+
* Rewrite absolute filesystem paths in cached Google Fonts CSS so the
|
|
8
|
+
* `@font-face { src: url(...) }` references point at the served URL the
|
|
9
|
+
* plugin's `writeBundle` hook copies the font files to.
|
|
10
|
+
*
|
|
11
|
+
* This is called once per transform, before the CSS string is embedded in
|
|
12
|
+
* the bundle as `_vinext.font.selfHostedCSS`. Every downstream consumer reads
|
|
13
|
+
* from the same rewritten CSS: the injected `<style data-vinext-fonts>` block, the
|
|
14
|
+
* HTML body's `<link rel="preload">` tags (via `collectFontPreloadsFromCSS`
|
|
15
|
+
* in `shims/font-google-base.ts`), and the HTTP `Link:` response header
|
|
16
|
+
* (via `buildAppPageFontLinkHeader` in `server/app-page-execution.ts`).
|
|
17
|
+
*
|
|
18
|
+
* Without this rewrite, all three emit the dev-machine filesystem path
|
|
19
|
+
* (e.g. `/home/user/project/.vinext/fonts/geist-<hash>/geist-<hash>.woff2`)
|
|
20
|
+
* and any production request fetches `<origin>/home/user/...` → 404.
|
|
21
|
+
*
|
|
22
|
+
* `assetsDir` must match whatever Vite has resolved for
|
|
23
|
+
* `build.assetsDir` on the client environment — otherwise the embedded
|
|
24
|
+
* CSS URLs and the files emitted by the `writeBundle` hook would diverge
|
|
25
|
+
* and a user who customizes `build.assetsDir` (e.g. to `"static"`) would
|
|
26
|
+
* see 404s on every preload. The call site in `injectSelfHostedCss`
|
|
27
|
+
* passes the resolved value through from plugin state. The default is
|
|
28
|
+
* kept only so the exported helper can be driven directly from unit
|
|
29
|
+
* tests without synthesizing a full plugin context.
|
|
30
|
+
*
|
|
31
|
+
* Uses split/join rather than regex because `cacheDir` is an absolute
|
|
32
|
+
* filesystem path that may contain regex metacharacters on unusual
|
|
33
|
+
* filesystems.
|
|
34
|
+
*/
|
|
35
|
+
declare function _rewriteCachedFontCssToServedUrls(css: string, cacheDir: string, assetsDir?: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Safely parse a static JS object literal string into a plain object.
|
|
38
|
+
* Uses Vite's parseAst (Rollup/acorn) so no code is ever evaluated.
|
|
39
|
+
* Returns null if the expression contains anything dynamic (function calls,
|
|
40
|
+
* template literals, identifiers, computed properties, etc.).
|
|
41
|
+
*
|
|
42
|
+
* Supports: string literals, numeric literals, boolean literals,
|
|
43
|
+
* arrays of the above, and nested object literals.
|
|
44
|
+
*/
|
|
45
|
+
declare function parseStaticObjectLiteral(objectStr: string): Record<string, unknown> | null;
|
|
46
|
+
declare function generateGoogleFontsVirtualModule(id: string, fontGoogleShimPath: string): string | null;
|
|
47
|
+
/**
|
|
48
|
+
* Create the `vinext:google-fonts` Vite plugin.
|
|
49
|
+
*
|
|
50
|
+
* @param fontGoogleShimPath - Absolute path to the font-google shim module
|
|
51
|
+
* (either `.ts` in source or `.js` in built packages). Resolved by the caller
|
|
52
|
+
* so the plugin file has no dependency on `__dirname`.
|
|
53
|
+
* @param shimsDir - Absolute path to the shims directory. Used to skip shim
|
|
54
|
+
* files from transform (they contain `next/font/google` references that must
|
|
55
|
+
* not be rewritten).
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* Scan `code` forward from `searchStart` for a `{...}` object literal that
|
|
59
|
+
* may contain arbitrarily nested braces. Returns `[objStart, objEnd]` where
|
|
60
|
+
* `code[objStart] === '{'` and `code[objEnd - 1] === '}'`, or `null` if no
|
|
61
|
+
* balanced object is found.
|
|
62
|
+
*
|
|
63
|
+
* String literals (single-quoted, double-quoted, and backtick template
|
|
64
|
+
* literals including `${...}` interpolations) are fully skipped so that brace
|
|
65
|
+
* characters inside string values do not affect the depth count.
|
|
66
|
+
*/
|
|
67
|
+
declare function _findBalancedObject(code: string, searchStart: number): [number, number] | null;
|
|
68
|
+
/**
|
|
69
|
+
* Given the index just past the closing `}` of an options object, skip
|
|
70
|
+
* optional whitespace and return the index after the closing `)`.
|
|
71
|
+
* Returns `null` if the next non-whitespace character is not `)`.
|
|
72
|
+
*/
|
|
73
|
+
declare function _findCallEnd(code: string, objEnd: number): number | null;
|
|
74
|
+
declare function createGoogleFontsPlugin(fontGoogleShimPath: string, shimsDir: string): Plugin;
|
|
75
|
+
/**
|
|
76
|
+
* Create the `vinext:local-fonts` Vite plugin.
|
|
77
|
+
*
|
|
78
|
+
* Rewrites relative font file paths in `next/font/local` calls into Vite
|
|
79
|
+
* asset import references so that both dev (/@fs/...) and prod
|
|
80
|
+
* (/assets/font-xxx.woff2) URLs resolve correctly.
|
|
81
|
+
*
|
|
82
|
+
* @param shimsDir - Absolute path to the shims directory (with trailing
|
|
83
|
+
* separator). Used to skip vinext's own shim files from transform — they
|
|
84
|
+
* contain example `next/font/local` paths in comments that must not be
|
|
85
|
+
* rewritten. A precise prefix check is required (rather than a loose
|
|
86
|
+
* substring match) because, now that `node_modules` is no longer excluded,
|
|
87
|
+
* the guard runs against arbitrary third-party package paths — some of
|
|
88
|
+
* which may legitimately contain the substring `font-local` (e.g. a
|
|
89
|
+
* package named `font-local-loader`) and must still be transformed. This
|
|
90
|
+
* mirrors `createGoogleFontsPlugin`, which takes `shimsDir` for the same
|
|
91
|
+
* reason.
|
|
92
|
+
*/
|
|
93
|
+
declare function createLocalFontsPlugin(shimsDir: string): Plugin;
|
|
94
|
+
//#endregion
|
|
95
|
+
export { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, _findBalancedObject, _findCallEnd, _rewriteCachedFontCssToServedUrls, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral };
|