vinext 1.0.0-beta.4 → 1.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -3
- package/dist/build/client-build-config.d.ts +0 -1
- package/dist/build/css-url-assets.d.ts +0 -1
- package/dist/build/google-fonts/build-url.d.ts +5 -2
- package/dist/build/google-fonts/font-metadata.d.ts +7 -3
- package/dist/build/google-fonts/get-axes.d.ts +0 -1
- package/dist/build/layout-classification.d.ts +7 -4
- package/dist/build/next-client-runtime-manifests.d.ts +0 -1
- package/dist/build/next-client-runtime-manifests.js +2 -19
- package/dist/build/nitro-route-rules.d.ts +0 -1
- package/dist/build/pages-client-assets-module.d.ts +0 -1
- package/dist/build/precompress.d.ts +7 -2
- package/dist/build/precompress.js +41 -7
- package/dist/build/prerender-paths.d.ts +2 -2
- package/dist/build/prerender-paths.js +3 -4
- package/dist/build/prerender-phase.d.ts +15 -0
- package/dist/build/prerender-phase.js +37 -0
- package/dist/build/prerender-server-entry.d.ts +1 -1
- package/dist/build/prerender-server-entry.js +3 -3
- package/dist/build/prerender-server-pool.d.ts +4 -2
- package/dist/build/prerender-server-pool.js +2 -0
- package/dist/build/prerender.d.ts +40 -33
- package/dist/build/prerender.js +99 -18
- package/dist/build/public-dir-conflict.d.ts +14 -0
- package/dist/build/public-dir-conflict.js +25 -0
- package/dist/build/report.d.ts +2 -2
- package/dist/build/route-classification-injector.d.ts +0 -1
- package/dist/build/route-classification-manifest.d.ts +5 -3
- package/dist/build/run-prerender.d.ts +3 -2
- package/dist/build/run-prerender.js +9 -6
- package/dist/build/static-export.d.ts +23 -12
- package/dist/cache/cache-adapters-virtual.d.ts +5 -2
- package/dist/check.js +4 -4
- package/dist/cli-dev-config.d.ts +0 -1
- package/dist/cli.d.ts +1 -1
- package/dist/client/client-rewrite-matcher.d.ts +12 -0
- package/dist/client/client-rewrite-matcher.js +20 -0
- package/dist/client/client-rewrites.d.ts +31 -0
- package/dist/client/client-rewrites.js +41 -0
- package/dist/client/dev-error-overlay.d.ts +0 -1
- package/dist/client/empty-module.d.ts +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +2 -0
- package/dist/client/instrumentation-client-state.d.ts +0 -1
- package/dist/client/navigation-runtime.d.ts +6 -1
- package/dist/client/navigation-runtime.js +5 -1
- package/dist/client/pages-router-link-navigation.d.ts +3 -21
- package/dist/client/react-instance-bootstrap.d.ts +1 -0
- package/dist/client/react-instance-bootstrap.js +7 -0
- package/dist/client/react-instance.d.ts +13 -0
- package/dist/client/react-instance.js +20 -0
- package/dist/client/vinext-next-data.d.ts +13 -6
- package/dist/client/window-next.d.ts +5 -2
- package/dist/config/config-matchers.d.ts +3 -5
- package/dist/config/config-matchers.js +7 -6
- package/dist/config/dotenv.d.ts +1 -5
- package/dist/config/next-config.d.ts +113 -54
- package/dist/config/next-config.js +27 -7
- package/dist/config/prerender.d.ts +0 -1
- package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +808 -0
- package/dist/entries/app-browser-entry.d.ts +0 -1
- package/dist/entries/app-browser-entry.js +8 -3
- package/dist/entries/app-rsc-entry.d.ts +30 -16
- package/dist/entries/app-rsc-entry.js +48 -10
- package/dist/entries/app-rsc-manifest.d.ts +0 -1
- package/dist/entries/app-rsc-manifest.js +1 -0
- package/dist/entries/pages-client-entry.d.ts +0 -1
- package/dist/entries/pages-client-entry.js +15 -5
- package/dist/entries/pages-server-entry.d.ts +1 -2
- package/dist/entries/pages-server-entry.js +21 -5
- package/dist/image/image-adapters-virtual.d.ts +4 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +328 -227
- package/dist/init-cloudflare.d.ts +0 -1
- package/dist/init-platform.d.ts +0 -1
- package/dist/init.d.ts +40 -20
- package/dist/plugins/ast-scope.d.ts +0 -1
- package/dist/plugins/async-hooks-stub.d.ts +0 -1
- package/dist/plugins/client-reference-dedup.d.ts +0 -1
- package/dist/plugins/css-data-url.d.ts +0 -1
- package/dist/plugins/css-module-imports.d.ts +0 -1
- package/dist/plugins/dynamic-preload-metadata.d.ts +0 -1
- package/dist/plugins/extensionless-dynamic-import.d.ts +0 -1
- package/dist/plugins/extensionless-dynamic-import.js +352 -13
- package/dist/plugins/fonts.d.ts +0 -1
- package/dist/plugins/ignore-dynamic-requests.d.ts +0 -1
- package/dist/plugins/ignore-dynamic-requests.js +28 -4
- package/dist/plugins/import-meta-url.d.ts +0 -1
- package/dist/plugins/instrumentation-client.d.ts +0 -1
- package/dist/plugins/middleware-server-only.d.ts +0 -1
- package/dist/plugins/og-asset-ownership.d.ts +0 -1
- package/dist/plugins/og-assets.d.ts +0 -1
- package/dist/plugins/optimize-imports.d.ts +0 -1
- package/dist/plugins/pages-node-externals.d.ts +23 -0
- package/dist/plugins/pages-node-externals.js +206 -0
- package/dist/plugins/remove-console.d.ts +0 -1
- package/dist/plugins/require-context.d.ts +0 -1
- package/dist/plugins/require-context.js +143 -26
- package/dist/plugins/rsc-client-reference-loaders.d.ts +0 -1
- package/dist/plugins/rsc-reference-validation-normalizer.d.ts +0 -1
- package/dist/plugins/sass.d.ts +30 -2
- package/dist/plugins/sass.js +64 -1
- package/dist/plugins/server-externals-manifest.d.ts +0 -1
- package/dist/plugins/strip-server-exports.d.ts +0 -1
- package/dist/plugins/styled-jsx.d.ts +0 -1
- package/dist/plugins/transitive-externals.d.ts +24 -0
- package/dist/plugins/transitive-externals.js +121 -0
- package/dist/plugins/typeof-window.d.ts +11 -1
- package/dist/plugins/typeof-window.js +141 -13
- package/dist/plugins/use-cache-callable.d.ts +12 -0
- package/dist/plugins/use-cache-callable.js +209 -0
- package/dist/plugins/wasm-module-import.d.ts +0 -1
- package/dist/routing/app-route-graph.d.ts +115 -56
- package/dist/routing/app-route-graph.js +2 -1
- package/dist/routing/app-router.d.ts +0 -1
- package/dist/routing/pages-router.d.ts +9 -5
- package/dist/routing/route-matching.d.ts +0 -1
- package/dist/routing/utils.d.ts +1 -23
- package/dist/routing/utils.js +1 -30
- package/dist/server/accept-encoding.d.ts +0 -1
- package/dist/server/api-handler.d.ts +0 -1
- package/dist/server/api-handler.js +1 -1
- package/dist/server/app-bfcache-identity.d.ts +9 -10
- package/dist/server/app-bfcache-identity.js +27 -128
- package/dist/server/app-browser-action-result.d.ts +0 -1
- package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -1
- package/dist/server/app-browser-entry.d.ts +1 -1
- package/dist/server/app-browser-entry.js +46 -30
- package/dist/server/app-browser-history-controller.d.ts +8 -5
- package/dist/server/app-browser-hydration.d.ts +0 -1
- package/dist/server/app-browser-interception-context.d.ts +0 -1
- package/dist/server/app-browser-mpa-navigation.d.ts +0 -1
- package/dist/server/app-browser-navigation-controller.d.ts +2 -5
- package/dist/server/app-browser-popstate.d.ts +0 -1
- package/dist/server/app-browser-prefetch-response.d.ts +17 -1
- package/dist/server/app-browser-prefetch-response.js +23 -1
- package/dist/server/app-browser-server-action-client.d.ts +1 -1
- package/dist/server/app-browser-server-action-client.js +3 -2
- package/dist/server/app-browser-server-action-navigation.d.ts +0 -1
- package/dist/server/app-browser-state.d.ts +4 -3
- package/dist/server/app-browser-state.js +2 -4
- package/dist/server/app-browser-stream.d.ts +0 -1
- package/dist/server/app-browser-visible-commit.d.ts +1 -1
- package/dist/server/app-browser-visible-commit.js +6 -2
- package/dist/server/app-elements-wire.d.ts +16 -13
- package/dist/server/app-elements-wire.js +37 -10
- package/dist/server/app-elements.d.ts +2 -3
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-fallback-renderer.d.ts +8 -4
- package/dist/server/app-fallback-renderer.js +2 -1
- package/dist/server/app-history-state.d.ts +2 -2
- package/dist/server/app-history-state.js +1 -1
- package/dist/server/app-hook-warning-suppression.d.ts +0 -1
- package/dist/server/app-layout-param-observation.d.ts +0 -1
- package/dist/server/app-layout-param-observation.js +1 -1
- package/dist/server/app-middleware.d.ts +5 -1
- package/dist/server/app-middleware.js +96 -31
- package/dist/server/app-optimistic-routing.d.ts +1 -0
- package/dist/server/app-page-boundary-render.d.ts +8 -4
- package/dist/server/app-page-boundary-render.js +4 -7
- package/dist/server/app-page-cache-finalizer.d.ts +3 -3
- package/dist/server/app-page-cache-finalizer.js +45 -19
- package/dist/server/app-page-cache-render.d.ts +3 -2
- package/dist/server/app-page-cache-render.js +5 -2
- package/dist/server/app-page-cache.d.ts +3 -4
- package/dist/server/app-page-cache.js +33 -15
- package/dist/server/app-page-dispatch.d.ts +11 -5
- package/dist/server/app-page-dispatch.js +11 -6
- package/dist/server/app-page-element-builder.d.ts +61 -19
- package/dist/server/app-page-element-builder.js +113 -43
- package/dist/server/app-page-execution.d.ts +12 -5
- package/dist/server/app-page-execution.js +20 -7
- package/dist/server/app-page-head.d.ts +2 -2
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +2 -2
- package/dist/server/app-page-params.d.ts +0 -1
- package/dist/server/app-page-ppr-runtime.d.ts +0 -1
- package/dist/server/app-page-probe.d.ts +4 -3
- package/dist/server/app-page-probe.js +1 -1
- package/dist/server/app-page-render-identity.d.ts +1 -0
- package/dist/server/app-page-render-observation.d.ts +0 -1
- package/dist/server/app-page-render.d.ts +6 -4
- package/dist/server/app-page-render.js +53 -25
- package/dist/server/app-page-request.d.ts +3 -1
- package/dist/server/app-page-request.js +3 -34
- package/dist/server/app-page-response.d.ts +13 -3
- package/dist/server/app-page-response.js +17 -11
- package/dist/server/app-page-route-wiring.d.ts +27 -5
- package/dist/server/app-page-route-wiring.js +110 -58
- package/dist/server/app-page-search-params-observation.d.ts +0 -1
- package/dist/server/app-page-segment-plan.d.ts +56 -0
- package/dist/server/app-page-segment-plan.js +177 -0
- package/dist/server/app-page-segment-state.d.ts +18 -2
- package/dist/server/app-page-segment-state.js +23 -4
- package/dist/server/app-page-stream.d.ts +31 -10
- package/dist/server/app-page-stream.js +10 -3
- package/dist/server/app-pages-bridge.d.ts +0 -1
- package/dist/server/app-pages-bridge.js +12 -1
- package/dist/server/app-post-middleware-context.d.ts +0 -1
- package/dist/server/app-ppr-fallback-shell-render.d.ts +0 -1
- package/dist/server/app-prerender-endpoints.d.ts +1 -1
- package/dist/server/app-prerender-endpoints.js +12 -0
- package/dist/server/app-prerender-static-params.d.ts +0 -1
- package/dist/server/app-render-dependency.d.ts +11 -4
- package/dist/server/app-render-dependency.js +59 -9
- package/dist/server/app-request-context.d.ts +1 -0
- package/dist/server/app-response-header-provenance.d.ts +13 -0
- package/dist/server/app-response-header-provenance.js +26 -0
- package/dist/server/app-route-handler-cache.d.ts +3 -2
- package/dist/server/app-route-handler-cache.js +7 -3
- package/dist/server/app-route-handler-dispatch.d.ts +0 -1
- package/dist/server/app-route-handler-dispatch.js +4 -2
- package/dist/server/app-route-handler-execution.d.ts +2 -2
- package/dist/server/app-route-handler-execution.js +15 -7
- package/dist/server/app-route-handler-policy.d.ts +1 -1
- package/dist/server/app-route-handler-response.d.ts +3 -2
- package/dist/server/app-route-handler-response.js +15 -5
- package/dist/server/app-route-handler-runtime.d.ts +1 -2
- package/dist/server/app-route-handler-runtime.js +218 -85
- package/dist/server/app-route-module-loader.d.ts +32 -6
- package/dist/server/app-route-module-loader.js +73 -3
- package/dist/server/app-route-request-built-ins.d.ts +16 -0
- package/dist/server/app-route-request-built-ins.js +41 -0
- package/dist/server/app-router-entry.d.ts +0 -1
- package/dist/server/app-router-entry.js +4 -4
- package/dist/server/app-rsc-cache-busting.d.ts +2 -1
- package/dist/server/app-rsc-cache-busting.js +24 -16
- package/dist/server/app-rsc-handler.d.ts +9 -2
- package/dist/server/app-rsc-handler.js +176 -47
- package/dist/server/app-rsc-redirect-flight.d.ts +0 -1
- package/dist/server/app-rsc-request-normalization.d.ts +19 -10
- package/dist/server/app-rsc-response-finalizer.d.ts +7 -2
- package/dist/server/app-rsc-response-finalizer.js +34 -18
- package/dist/server/app-rsc-route-matching.d.ts +6 -1
- package/dist/server/app-rsc-route-matching.js +47 -2
- package/dist/server/app-rsc-state-fingerprint.d.ts +14 -0
- package/dist/server/app-rsc-state-fingerprint.js +13 -0
- package/dist/server/app-segment-config.d.ts +0 -1
- package/dist/server/app-server-action-execution.d.ts +41 -8
- package/dist/server/app-server-action-execution.js +191 -113
- package/dist/server/app-ssr-entry.d.ts +11 -3
- package/dist/server/app-ssr-entry.js +19 -8
- package/dist/server/app-ssr-router-instance.d.ts +0 -1
- package/dist/server/app-ssr-stream.d.ts +13 -2
- package/dist/server/app-ssr-stream.js +30 -5
- package/dist/server/app-static-generation.d.ts +0 -1
- package/dist/server/app-visited-response-cache.d.ts +1 -1
- package/dist/server/before-interactive-head.d.ts +0 -1
- package/dist/server/before-interactive-head.js +2 -0
- package/dist/server/bfcache-identity.d.ts +45 -0
- package/dist/server/bfcache-identity.js +52 -0
- package/dist/server/cache-control.d.ts +11 -7
- package/dist/server/cache-control.js +23 -11
- package/dist/server/cache-proof.d.ts +0 -1
- package/dist/server/client-reuse-manifest.d.ts +0 -1
- package/dist/server/config-headers.d.ts +6 -2
- package/dist/server/config-headers.js +19 -3
- package/dist/server/csp.d.ts +0 -1
- package/dist/server/default-global-error-module.d.ts +0 -1
- package/dist/server/default-global-not-found-module.d.ts +0 -1
- package/dist/server/default-not-found-module.d.ts +0 -1
- package/dist/server/dev-lockfile.d.ts +21 -9
- package/dist/server/dev-module-runner.d.ts +0 -1
- package/dist/server/dev-route-files.d.ts +0 -1
- package/dist/server/dev-server.d.ts +4 -8
- package/dist/server/dev-server.js +54 -105
- package/dist/server/dev-stack-sourcemap.d.ts +0 -1
- package/dist/server/document-initial-head.d.ts +12 -2
- package/dist/server/document-initial-head.js +17 -2
- package/dist/server/file-based-metadata.d.ts +0 -1
- package/dist/server/headers.d.ts +21 -2
- package/dist/server/headers.js +23 -2
- package/dist/server/http-conditional.d.ts +22 -0
- package/dist/server/http-conditional.js +117 -0
- package/dist/server/http-date.d.ts +5 -0
- package/dist/server/http-date.js +73 -0
- package/dist/server/http-error-responses.d.ts +3 -2
- package/dist/server/http-error-responses.js +21 -4
- package/dist/server/http-range.d.ts +25 -0
- package/dist/server/http-range.js +67 -0
- package/dist/server/image-optimization.d.ts +14 -6
- package/dist/server/image-optimization.js +0 -1
- package/dist/server/instrumentation.d.ts +7 -4
- package/dist/server/isr-cache.d.ts +28 -6
- package/dist/server/isr-cache.js +19 -13
- package/dist/server/isr-decision.d.ts +6 -4
- package/dist/server/metadata-route-build-data.d.ts +0 -1
- package/dist/server/metadata-route-build-data.js +1 -1
- package/dist/server/metadata-route-cache-policy.d.ts +6 -0
- package/dist/server/metadata-route-cache-policy.js +6 -0
- package/dist/server/metadata-route-response.d.ts +26 -2
- package/dist/server/metadata-route-response.js +225 -11
- package/dist/server/metadata-routes.d.ts +34 -16
- package/dist/server/metadata-routes.js +1 -1
- package/dist/server/middleware-matcher-pattern.d.ts +0 -1
- package/dist/server/middleware-matcher.d.ts +8 -3
- package/dist/server/middleware-matcher.js +23 -18
- package/dist/server/middleware-response-headers.js +4 -2
- package/dist/server/middleware-runtime.d.ts +6 -1
- package/dist/server/middleware-runtime.js +91 -28
- package/dist/server/middleware.d.ts +0 -1
- package/dist/server/navigation-planner.d.ts +1 -1
- package/dist/server/next-error-digest.d.ts +0 -1
- package/dist/server/pages-api-route.d.ts +0 -1
- package/dist/server/pages-api-route.js +30 -5
- package/dist/server/pages-asset-tags.d.ts +2 -1
- package/dist/server/pages-data-route.d.ts +14 -6
- package/dist/server/pages-data-route.js +19 -10
- package/dist/server/pages-dev-hydration.js +14 -4
- package/dist/server/pages-dev-stylesheets.d.ts +10 -0
- package/dist/server/pages-dev-stylesheets.js +150 -0
- package/dist/server/pages-document-initial-props.d.ts +10 -6
- package/dist/server/pages-get-initial-props.d.ts +2 -2
- package/dist/server/pages-i18n.d.ts +1 -7
- package/dist/server/pages-node-compat.d.ts +11 -2
- package/dist/server/pages-node-compat.js +49 -2
- package/dist/server/pages-page-data.d.ts +21 -9
- package/dist/server/pages-page-data.js +109 -30
- package/dist/server/pages-page-handler.d.ts +72 -33
- package/dist/server/pages-page-handler.js +25 -20
- package/dist/server/pages-page-response.d.ts +7 -13
- package/dist/server/pages-page-response.js +16 -23
- package/dist/server/pages-readiness.d.ts +0 -1
- package/dist/server/pages-request-pipeline.d.ts +20 -6
- package/dist/server/pages-request-pipeline.js +40 -20
- package/dist/server/pages-revalidate.d.ts +0 -1
- package/dist/server/pages-revalidate.js +1 -1
- package/dist/server/pages-router-entry.js +13 -9
- package/dist/server/prerender-cache-life-header.d.ts +11 -0
- package/dist/server/prerender-cache-life-header.js +18 -0
- package/dist/server/prerender-manifest.d.ts +11 -2
- package/dist/server/prerender-manifest.js +4 -1
- package/dist/server/prod-server.d.ts +13 -7
- package/dist/server/prod-server.js +280 -92
- package/dist/server/proxy-trust.d.ts +0 -1
- package/dist/server/request-log.d.ts +7 -11
- package/dist/server/request-pipeline.d.ts +13 -4
- package/dist/server/request-pipeline.js +30 -20
- package/dist/server/revalidation-host.d.ts +0 -1
- package/dist/server/revalidation-host.js +1 -1
- package/dist/server/rsc-completion-metadata.d.ts +15 -0
- package/dist/server/rsc-completion-metadata.js +183 -0
- package/dist/server/seed-cache.d.ts +6 -2
- package/dist/server/seed-cache.js +35 -8
- package/dist/server/skip-cache-proof.d.ts +0 -1
- package/dist/server/static-file-cache.d.ts +23 -9
- package/dist/server/static-file-cache.js +47 -23
- package/dist/server/static-layout-client-reuse-proof.d.ts +0 -1
- package/dist/server/worker-revalidation-context.d.ts +0 -1
- package/dist/server/worker-utils.d.ts +3 -1
- package/dist/server/worker-utils.js +12 -3
- package/dist/shims/app-router-scroll.d.ts +2 -8
- package/dist/shims/app.d.ts +1 -5
- package/dist/shims/before-interactive-context.d.ts +5 -3
- package/dist/shims/cache-callable-runtime.d.ts +11 -0
- package/dist/shims/cache-callable-runtime.js +30 -0
- package/dist/shims/cache-handler.d.ts +6 -1
- package/dist/shims/cache-handler.js +4 -2
- package/dist/shims/cache-request-state.d.ts +15 -1
- package/dist/shims/cache-request-state.js +27 -1
- package/dist/shims/cache-runtime.d.ts +15 -6
- package/dist/shims/cache-runtime.js +129 -29
- package/dist/shims/cache.d.ts +2 -3
- package/dist/shims/cache.js +2 -2
- package/dist/shims/cdn-cache.d.ts +18 -7
- package/dist/shims/cdn-cache.js +4 -2
- package/dist/shims/client-locale.d.ts +1 -6
- package/dist/shims/client-only.d.ts +1 -1
- package/dist/shims/compat-router.d.ts +0 -1
- package/dist/shims/constants.d.ts +1 -1
- package/dist/shims/default-global-error.d.ts +1 -4
- package/dist/shims/default-not-found.d.ts +0 -1
- package/dist/shims/document.d.ts +0 -1
- package/dist/shims/document.js +2 -1
- package/dist/shims/dynamic-preload-chunks.d.ts +0 -1
- package/dist/shims/dynamic.d.ts +0 -1
- package/dist/shims/error-boundary-navigation.d.ts +0 -1
- package/dist/shims/error-boundary.d.ts +7 -32
- package/dist/shims/error.d.ts +1 -6
- package/dist/shims/fetch-cache.js +115 -65
- package/dist/shims/font-google-base.d.ts +0 -1
- package/dist/shims/font-local.d.ts +0 -1
- package/dist/shims/font-local.js +3 -3
- package/dist/shims/form.d.ts +5 -3
- package/dist/shims/head-state.d.ts +0 -1
- package/dist/shims/head.d.ts +17 -5
- package/dist/shims/head.js +70 -8
- package/dist/shims/headers.d.ts +2 -2
- package/dist/shims/headers.js +1 -1
- package/dist/shims/i18n-context.d.ts +0 -1
- package/dist/shims/i18n-state.d.ts +0 -1
- package/dist/shims/image.d.ts +0 -1
- package/dist/shims/image.js +1 -2
- package/dist/shims/internal/als-registry.d.ts +31 -2
- package/dist/shims/internal/als-registry.js +50 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +17 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.js +69 -7
- package/dist/shims/internal/app-route-detection.d.ts +0 -1
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +33 -0
- package/dist/shims/internal/app-route-prefetch-policy.js +63 -0
- package/dist/shims/internal/app-router-context.d.ts +0 -1
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +1 -5
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +0 -1
- package/dist/shims/internal/hybrid-client-route-owner.js +6 -8
- package/dist/shims/internal/interpolate-as.d.ts +3 -2
- package/dist/shims/internal/pages-data-target.d.ts +22 -11
- package/dist/shims/internal/pages-data-target.js +19 -6
- package/dist/shims/internal/pages-data-url.d.ts +3 -1
- package/dist/shims/internal/router-context.d.ts +0 -1
- package/dist/shims/internal/work-unit-async-storage.d.ts +4 -3
- package/dist/shims/internal/work-unit-async-storage.js +2 -0
- package/dist/shims/layout-segment-context.d.ts +2 -6
- package/dist/shims/legacy-image.d.ts +0 -1
- package/dist/shims/link.d.ts +29 -23
- package/dist/shims/link.js +59 -150
- package/dist/shims/metadata.d.ts +2 -10
- package/dist/shims/navigation-context-state.d.ts +4 -1
- package/dist/shims/navigation-state.d.ts +1 -0
- package/dist/shims/navigation.d.ts +65 -6
- package/dist/shims/navigation.js +360 -71
- package/dist/shims/navigation.react-server.d.ts +1 -0
- package/dist/shims/og.d.ts +0 -1
- package/dist/shims/request-context.d.ts +8 -4
- package/dist/shims/request-state-types.d.ts +1 -0
- package/dist/shims/root-params.d.ts +3 -1
- package/dist/shims/root-params.js +7 -1
- package/dist/shims/router.d.ts +44 -23
- package/dist/shims/router.js +184 -82
- package/dist/shims/script-nonce-context.d.ts +0 -1
- package/dist/shims/script.d.ts +25 -13
- package/dist/shims/server-only.d.ts +1 -1
- package/dist/shims/server.d.ts +1 -3
- package/dist/shims/server.js +7 -7
- package/dist/shims/slot.d.ts +22 -11
- package/dist/shims/slot.js +99 -19
- package/dist/shims/streamed-icons.d.ts +1 -3
- package/dist/shims/unified-request-context.d.ts +44 -4
- package/dist/shims/unified-request-context.js +56 -2
- package/dist/shims/use-merged-ref.d.ts +0 -1
- package/dist/shims/web-vitals.d.ts +0 -1
- package/dist/typegen.d.ts +1 -2
- package/dist/typegen.js +1 -1
- package/dist/utils/cache-control-metadata.d.ts +13 -1
- package/dist/utils/cache-control-metadata.js +17 -1
- package/dist/utils/client-build-manifest.d.ts +0 -1
- package/dist/utils/domain-locale.d.ts +1 -5
- package/dist/utils/encode-cache-tag.d.ts +1 -1
- package/dist/utils/encode-cache-tag.js +1 -1
- package/dist/utils/html-limited-bots.js +1 -1
- package/dist/utils/middleware-request-headers.d.ts +17 -5
- package/dist/utils/middleware-request-headers.js +32 -23
- package/dist/utils/precompressed-variant.d.ts +9 -0
- package/dist/utils/precompressed-variant.js +15 -0
- package/dist/utils/prerender-output-paths.d.ts +3 -1
- package/dist/utils/prerender-output-paths.js +6 -1
- package/dist/utils/project.d.ts +12 -7
- package/dist/utils/public-file-path.d.ts +5 -0
- package/dist/utils/public-file-path.js +12 -0
- package/dist/utils/public-routes.d.ts +1 -1
- package/dist/utils/public-routes.js +6 -5
- package/package.json +10 -6
package/dist/init-platform.d.ts
CHANGED
package/dist/init.d.ts
CHANGED
|
@@ -1,33 +1,53 @@
|
|
|
1
1
|
import { CloudflareInitOptions, InitPlatform } from "./init-platform.js";
|
|
2
2
|
import { getReactUpgradeDeps } from "./utils/react-version.js";
|
|
3
|
-
|
|
4
3
|
//#region src/init.d.ts
|
|
5
4
|
type InitOptions = {
|
|
6
|
-
/** Project root directory */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
/** Project root directory */
|
|
6
|
+
root: string;
|
|
7
|
+
/** Dev server port (default: 3001), or false to omit the port flag. */
|
|
8
|
+
port?: number | false;
|
|
9
|
+
/** Skip the compatibility check step */
|
|
10
|
+
skipCheck?: boolean;
|
|
11
|
+
/** Force overwrite even if vite.config.ts exists */
|
|
12
|
+
force?: boolean;
|
|
13
|
+
/** Deployment target selected by the user */
|
|
14
|
+
platform?: InitPlatform;
|
|
15
|
+
/** Configure build-time pre-rendering for all discovered static routes */
|
|
16
|
+
prerender?: boolean;
|
|
17
|
+
/** Cloudflare cache and image choices. */
|
|
18
|
+
cloudflare?: CloudflareInitOptions;
|
|
19
|
+
/** Install missing dependencies with the detected package manager (default: true). */
|
|
20
|
+
install?: boolean;
|
|
21
|
+
/** Script naming style (default: namespaced, e.g. dev:vinext). */
|
|
22
|
+
scriptNames?: "namespaced" | "standard";
|
|
23
|
+
/** @internal — override exec for testing (avoids ESM spy issues) */
|
|
15
24
|
_exec?: (cmd: string, opts: {
|
|
16
25
|
cwd: string;
|
|
17
26
|
stdio: string;
|
|
18
|
-
}) => string | void | Promise<string | void>;
|
|
19
|
-
|
|
27
|
+
}) => string | void | Promise<string | void>;
|
|
28
|
+
/** @internal — override pnpm ignored-builds inspection for testing */
|
|
29
|
+
_inspectPnpmIgnoredBuilds?: (root: string) => string;
|
|
30
|
+
/** @internal — stable compatibility date for snapshot tests */
|
|
20
31
|
_today?: string;
|
|
21
32
|
};
|
|
22
33
|
type InitResult = {
|
|
23
|
-
/** Whether dependencies were installed */
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
/** Whether dependencies were installed */
|
|
35
|
+
installedDeps: string[];
|
|
36
|
+
/** Whether "type": "module" was added */
|
|
37
|
+
addedTypeModule: boolean;
|
|
38
|
+
/** CJS config files that were renamed ([old, new] pairs) */
|
|
39
|
+
renamedConfigs: Array<[string, string]>;
|
|
40
|
+
/** Whether scripts were added to package.json */
|
|
41
|
+
addedScripts: string[];
|
|
42
|
+
/** Whether vite.config.ts was generated */
|
|
43
|
+
generatedViteConfig: boolean;
|
|
44
|
+
/** Whether vite.config.ts generation was skipped (already exists) */
|
|
45
|
+
skippedViteConfig: boolean;
|
|
46
|
+
/** Whether .gitignore was updated to include vinext-generated output */
|
|
47
|
+
updatedGitignore: boolean;
|
|
48
|
+
/** Deployment target configured by init */
|
|
49
|
+
platform: InitPlatform;
|
|
50
|
+
/** Platform-specific deployment files generated by init */
|
|
31
51
|
generatedPlatformFiles: string[];
|
|
32
52
|
};
|
|
33
53
|
declare function generateViteConfig(_isAppRouter: boolean, prerender?: boolean): string;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
+
import { escapeRegExp } from "../utils/regex.js";
|
|
3
|
+
import { isUnknownRecord } from "../utils/record.js";
|
|
1
4
|
import { DYNAMIC_IMPORT_PRESCAN, forEachAstChild, hasRange, isAstRecord, nodeArray } from "./ast-utils.js";
|
|
2
5
|
import { createTransformCache } from "./transform-cache.js";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
import fs from "node:fs";
|
|
3
8
|
import { parseAst } from "vite";
|
|
4
9
|
import MagicString from "magic-string";
|
|
5
10
|
//#region src/plugins/extensionless-dynamic-import.ts
|
|
@@ -23,13 +28,24 @@ const TRANSFORMABLE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
23
28
|
".cts"
|
|
24
29
|
]);
|
|
25
30
|
function createExtensionlessDynamicImportPlugin() {
|
|
26
|
-
let
|
|
31
|
+
let transformConfig = {
|
|
32
|
+
aliases: [],
|
|
33
|
+
moduleExtensions: MODULE_EXTENSIONS,
|
|
34
|
+
exportConditions: /* @__PURE__ */ new Set([
|
|
35
|
+
"import",
|
|
36
|
+
"module",
|
|
37
|
+
"node",
|
|
38
|
+
"development",
|
|
39
|
+
"default"
|
|
40
|
+
])
|
|
41
|
+
};
|
|
42
|
+
const environmentConfigs = /* @__PURE__ */ new WeakMap();
|
|
27
43
|
const cached = createTransformCache();
|
|
28
44
|
return {
|
|
29
45
|
name: "vinext:extensionless-dynamic-import",
|
|
30
46
|
enforce: "pre",
|
|
31
47
|
configResolved(config) {
|
|
32
|
-
|
|
48
|
+
transformConfig = createTransformConfig(config);
|
|
33
49
|
},
|
|
34
50
|
transform: {
|
|
35
51
|
filter: {
|
|
@@ -40,12 +56,18 @@ function createExtensionlessDynamicImportPlugin() {
|
|
|
40
56
|
code: DYNAMIC_IMPORT_PRESCAN
|
|
41
57
|
},
|
|
42
58
|
handler(code, id) {
|
|
43
|
-
|
|
59
|
+
const environmentConfig = this.environment?.config;
|
|
60
|
+
let activeConfig = transformConfig;
|
|
61
|
+
if (environmentConfig) {
|
|
62
|
+
activeConfig = environmentConfigs.get(environmentConfig) ?? createTransformConfig(environmentConfig);
|
|
63
|
+
environmentConfigs.set(environmentConfig, activeConfig);
|
|
64
|
+
}
|
|
65
|
+
return cached(id, code, activeConfig, () => transformExtensionlessImports(code, id, activeConfig));
|
|
44
66
|
}
|
|
45
67
|
}
|
|
46
68
|
};
|
|
47
69
|
}
|
|
48
|
-
function transformExtensionlessImports(code, id,
|
|
70
|
+
function transformExtensionlessImports(code, id, config) {
|
|
49
71
|
const lang = langForId(id);
|
|
50
72
|
let ast;
|
|
51
73
|
try {
|
|
@@ -53,12 +75,12 @@ function transformExtensionlessImports(code, id, moduleExtensions) {
|
|
|
53
75
|
} catch {
|
|
54
76
|
return null;
|
|
55
77
|
}
|
|
56
|
-
const imports = collectExtensionlessImports(ast, code,
|
|
78
|
+
const imports = collectExtensionlessImports(ast, code, config, id);
|
|
57
79
|
if (imports.length === 0) return null;
|
|
58
80
|
const output = new MagicString(code);
|
|
59
81
|
for (const dynamicImport of imports) {
|
|
60
82
|
const source = code.slice(dynamicImport.sourceStart, dynamicImport.sourceEnd);
|
|
61
|
-
output.overwrite(dynamicImport.start, dynamicImport.end, buildReplacement(source, dynamicImport.globPattern, dynamicImport.moduleExtensions));
|
|
83
|
+
output.overwrite(dynamicImport.start, dynamicImport.end, dynamicImport.kind === "package" ? buildPackageReplacement(source, dynamicImport.resolution) : buildReplacement(source, dynamicImport.globPattern, dynamicImport.moduleExtensions));
|
|
62
84
|
}
|
|
63
85
|
return {
|
|
64
86
|
code: output.toString(),
|
|
@@ -75,11 +97,11 @@ function langForId(id) {
|
|
|
75
97
|
if (ext === ".tsx") return "tsx";
|
|
76
98
|
return "jsx";
|
|
77
99
|
}
|
|
78
|
-
function collectExtensionlessImports(ast, code,
|
|
100
|
+
function collectExtensionlessImports(ast, code, config, id) {
|
|
79
101
|
const imports = [];
|
|
80
102
|
function visit(value) {
|
|
81
103
|
if (!isAstRecord(value)) return;
|
|
82
|
-
const parsed = parseExtensionlessImport(value, code,
|
|
104
|
+
const parsed = parseExtensionlessImport(value, code, config, id);
|
|
83
105
|
if (parsed) {
|
|
84
106
|
imports.push(parsed);
|
|
85
107
|
return;
|
|
@@ -89,7 +111,7 @@ function collectExtensionlessImports(ast, code, moduleExtensions) {
|
|
|
89
111
|
visit(ast);
|
|
90
112
|
return imports;
|
|
91
113
|
}
|
|
92
|
-
function parseExtensionlessImport(node, code,
|
|
114
|
+
function parseExtensionlessImport(node, code, config, id) {
|
|
93
115
|
if (node.type !== "ImportExpression" || !hasRange(node)) return null;
|
|
94
116
|
if (node.options != null) return null;
|
|
95
117
|
const source = node.source;
|
|
@@ -100,22 +122,308 @@ function parseExtensionlessImport(node, code, moduleExtensions) {
|
|
|
100
122
|
const texts = quasiTexts;
|
|
101
123
|
const first = texts[0];
|
|
102
124
|
if (!isImportPrefix(code.slice(node.start, source.start))) return null;
|
|
103
|
-
if (!(first.startsWith("./") || first.startsWith("../"))) return null;
|
|
104
125
|
if (texts.some((text) => /[*?[\]{}()!?#]/.test(text))) return null;
|
|
126
|
+
if (!(first.startsWith("./") || first.startsWith("../"))) {
|
|
127
|
+
const resolution = resolvePackageImport(first, texts, id, config.exportConditions, config.aliases);
|
|
128
|
+
return resolution ? {
|
|
129
|
+
kind: "package",
|
|
130
|
+
start: node.start,
|
|
131
|
+
end: node.end,
|
|
132
|
+
sourceStart: source.start,
|
|
133
|
+
sourceEnd: source.end,
|
|
134
|
+
resolution
|
|
135
|
+
} : null;
|
|
136
|
+
}
|
|
105
137
|
if (texts.slice(1).some((text) => text.includes("."))) return null;
|
|
106
138
|
const directoryEnd = first.lastIndexOf("/") + 1;
|
|
107
139
|
const directory = first.slice(0, directoryEnd);
|
|
108
140
|
const filenamePrefix = first.slice(directoryEnd);
|
|
109
141
|
if (filenamePrefix.includes(".")) return null;
|
|
110
142
|
return {
|
|
143
|
+
kind: "relative",
|
|
111
144
|
start: node.start,
|
|
112
145
|
end: node.end,
|
|
113
146
|
sourceStart: source.start,
|
|
114
147
|
sourceEnd: source.end,
|
|
115
148
|
globPattern: filenamePrefix.length > 0 ? [`${first}*`, `${first}*/**/*`] : `${directory}**/*`,
|
|
116
|
-
moduleExtensions
|
|
149
|
+
moduleExtensions: config.moduleExtensions
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function resolvePackageImport(first, texts, id, exportConditions, aliases) {
|
|
153
|
+
const packageName = parsePackageName(first);
|
|
154
|
+
if (packageName === null || first === packageName || !first.startsWith(`${packageName}/`)) return null;
|
|
155
|
+
if (aliasesMayMatch(aliases, [first, ...texts.slice(1)].join("*"))) return null;
|
|
156
|
+
const packageInfo = resolvePackageInfo(packageName, id);
|
|
157
|
+
if (packageInfo === null || !isUnknownRecord(packageInfo.packageJson.exports)) return null;
|
|
158
|
+
const requestPattern = `./${[first.slice(packageName.length + 1), ...texts.slice(1)].join("*")}`;
|
|
159
|
+
const matchedExport = findBestPackageExport(packageInfo.packageJson.exports, requestPattern);
|
|
160
|
+
if (matchedExport === null) return null;
|
|
161
|
+
const { keyMatch, exportValue } = matchedExport;
|
|
162
|
+
for (const target of resolveExportTargets(exportValue, exportConditions)) {
|
|
163
|
+
if (!target.startsWith("./")) continue;
|
|
164
|
+
const targetParts = decodePackageTarget(target);
|
|
165
|
+
if (targetParts === null) continue;
|
|
166
|
+
const [targetPrefix, targetSuffix] = targetParts;
|
|
167
|
+
const decodedCapture = decodeRequestCapturePattern(keyMatch.capture);
|
|
168
|
+
if (decodedCapture === null) continue;
|
|
169
|
+
const absoluteGlob = path.resolve(packageInfo.packageRoot, `${targetPrefix.slice(2)}${decodedCapture}${targetSuffix}`);
|
|
170
|
+
const absolutePrefix = path.resolve(packageInfo.packageRoot, targetPrefix.slice(2));
|
|
171
|
+
if (!isWithinPackage(packageInfo.packageRoot, absoluteGlob) || !isWithinPackage(packageInfo.packageRoot, absolutePrefix)) continue;
|
|
172
|
+
const importerDirectory = resolveImporterDirectory(id);
|
|
173
|
+
const globPath = toImporterPath(importerDirectory, absoluteGlob);
|
|
174
|
+
const resolvedPrefixPath = toImporterPath(importerDirectory, absolutePrefix);
|
|
175
|
+
if (globPath === null || resolvedPrefixPath === null) return null;
|
|
176
|
+
const resolvedPrefix = resolvedPrefixPath.replace(/\/+$/, "") + (targetPrefix.endsWith("/") ? "/" : "");
|
|
177
|
+
const globPattern = buildPackageGlobPatterns(resolvedPrefix, decodedCapture, targetSuffix);
|
|
178
|
+
if (globPattern === null) return null;
|
|
179
|
+
return {
|
|
180
|
+
globPattern,
|
|
181
|
+
packageName,
|
|
182
|
+
requestPrefix: `${packageName}/${keyMatch.prefix.slice(2)}`,
|
|
183
|
+
requestSuffix: keyMatch.suffix,
|
|
184
|
+
resolvedPrefix,
|
|
185
|
+
resolvedSuffix: targetSuffix
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
function findBestPackageExport(exports, requestPattern) {
|
|
191
|
+
let best = null;
|
|
192
|
+
for (const [exportKey, exportValue] of Object.entries(exports)) {
|
|
193
|
+
const keyMatch = matchWildcardPattern(exportKey, requestPattern);
|
|
194
|
+
if (keyMatch === null) continue;
|
|
195
|
+
if (best === null || comparePatternKeys(exportKey, best.exportKey) < 0) best = {
|
|
196
|
+
exportKey,
|
|
197
|
+
keyMatch,
|
|
198
|
+
exportValue
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
if (best === null || hasHigherPrecedenceExportIntersection(exports, requestPattern, best.exportKey)) return null;
|
|
202
|
+
return {
|
|
203
|
+
keyMatch: best.keyMatch,
|
|
204
|
+
exportValue: best.exportValue
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function hasHigherPrecedenceExportIntersection(exports, requestPattern, selectedKey) {
|
|
208
|
+
for (const exportKey of Object.keys(exports)) {
|
|
209
|
+
if (exportKey === selectedKey || exportKey === ".") continue;
|
|
210
|
+
if (!exportKey.includes("*")) {
|
|
211
|
+
if (matchesTemplatePattern(requestPattern, exportKey)) return true;
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
if (comparePatternKeys(exportKey, selectedKey) < 0 && wildcardPatternsMayIntersect(requestPattern, exportKey)) return true;
|
|
215
|
+
}
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
function matchesTemplatePattern(templatePattern, value) {
|
|
219
|
+
const source = templatePattern.split("*").map(escapeRegExp).join(".*");
|
|
220
|
+
return new RegExp(`^${source}$`).test(value);
|
|
221
|
+
}
|
|
222
|
+
function wildcardPatternsMayIntersect(left, right) {
|
|
223
|
+
const leftBounds = wildcardPatternBounds(left);
|
|
224
|
+
const rightBounds = wildcardPatternBounds(right);
|
|
225
|
+
return (leftBounds.prefix.startsWith(rightBounds.prefix) || rightBounds.prefix.startsWith(leftBounds.prefix)) && (leftBounds.suffix.endsWith(rightBounds.suffix) || rightBounds.suffix.endsWith(leftBounds.suffix));
|
|
226
|
+
}
|
|
227
|
+
function wildcardPatternBounds(pattern) {
|
|
228
|
+
const firstWildcard = pattern.indexOf("*");
|
|
229
|
+
const lastWildcard = pattern.lastIndexOf("*");
|
|
230
|
+
return {
|
|
231
|
+
prefix: pattern.slice(0, firstWildcard),
|
|
232
|
+
suffix: pattern.slice(lastWildcard + 1)
|
|
117
233
|
};
|
|
118
234
|
}
|
|
235
|
+
function comparePatternKeys(left, right) {
|
|
236
|
+
const leftBaseLength = left.indexOf("*") + 1;
|
|
237
|
+
return right.indexOf("*") + 1 - leftBaseLength || right.length - left.length;
|
|
238
|
+
}
|
|
239
|
+
function parsePackageName(specifierPrefix) {
|
|
240
|
+
const segments = specifierPrefix.split("/");
|
|
241
|
+
if (specifierPrefix.startsWith("@")) return segments.length >= 2 && segments[0] && segments[1] ? `${segments[0]}/${segments[1]}` : null;
|
|
242
|
+
return segments[0] || null;
|
|
243
|
+
}
|
|
244
|
+
function aliasesMayMatch(aliases, requestPattern) {
|
|
245
|
+
const requestPrefix = requestPattern.slice(0, requestPattern.indexOf("*"));
|
|
246
|
+
return aliases.some((alias) => {
|
|
247
|
+
const { find } = alias;
|
|
248
|
+
if (find instanceof RegExp) return !isViteInternalAlias(alias);
|
|
249
|
+
if (matchesTemplatePattern(requestPattern, find)) return true;
|
|
250
|
+
const aliasPrefix = `${find}/`;
|
|
251
|
+
return requestPrefix.startsWith(aliasPrefix) || aliasPrefix.startsWith(requestPrefix);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function isViteInternalAlias(alias) {
|
|
255
|
+
if (!(alias.find instanceof RegExp)) return false;
|
|
256
|
+
const replacement = toSlash(alias.replacement);
|
|
257
|
+
const source = replacement.endsWith("/vite/client/env.mjs") || replacement.endsWith("/vite/dist/client/env.mjs") ? "@vite/env" : replacement.endsWith("/vite/client/client.mjs") || replacement.endsWith("/vite/dist/client/client.mjs") ? "@vite/client" : null;
|
|
258
|
+
if (source === null) return false;
|
|
259
|
+
alias.find.lastIndex = 0;
|
|
260
|
+
const matches = alias.find.test(source);
|
|
261
|
+
alias.find.lastIndex = 0;
|
|
262
|
+
return matches;
|
|
263
|
+
}
|
|
264
|
+
function decodePackageTarget(target) {
|
|
265
|
+
if (target.includes("?") || target.includes("#")) return null;
|
|
266
|
+
const targetParts = splitSingleWildcard(target);
|
|
267
|
+
if (targetParts === null) return null;
|
|
268
|
+
const [rawPrefix, rawSuffix] = targetParts;
|
|
269
|
+
if (/%[\da-f]?$/i.test(rawPrefix) || /^[\da-f]/i.test(rawSuffix)) return null;
|
|
270
|
+
for (const segment of target.slice(2).split("/")) {
|
|
271
|
+
let decodedSegment;
|
|
272
|
+
try {
|
|
273
|
+
decodedSegment = decodeURIComponent(segment);
|
|
274
|
+
} catch {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
if (decodedSegment === "." || decodedSegment === ".." || decodedSegment.toLowerCase() === "node_modules" || decodedSegment.includes("/") || decodedSegment.includes("\\")) return null;
|
|
278
|
+
}
|
|
279
|
+
const wildcard = target.indexOf("*");
|
|
280
|
+
try {
|
|
281
|
+
return [decodeURIComponent(target.slice(0, wildcard)), decodeURIComponent(target.slice(wildcard + 1))];
|
|
282
|
+
} catch {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
function decodeRequestCapturePattern(pattern) {
|
|
287
|
+
const parts = pattern.split("*");
|
|
288
|
+
for (let index = 0; index < parts.length - 1; index++) if (/%[\da-f]?$/i.test(parts[index]) || /^[\da-f]/i.test(parts[index + 1])) return null;
|
|
289
|
+
const decodedParts = [];
|
|
290
|
+
for (const part of parts) {
|
|
291
|
+
const decodedSegments = [];
|
|
292
|
+
for (const segment of part.split("/")) {
|
|
293
|
+
let decodedSegment;
|
|
294
|
+
try {
|
|
295
|
+
decodedSegment = decodeURIComponent(segment);
|
|
296
|
+
} catch {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
if (decodedSegment.includes("/") || decodedSegment.includes("\\")) return null;
|
|
300
|
+
decodedSegments.push(decodedSegment);
|
|
301
|
+
}
|
|
302
|
+
decodedParts.push(decodedSegments.join("/"));
|
|
303
|
+
}
|
|
304
|
+
return decodedParts.join("*");
|
|
305
|
+
}
|
|
306
|
+
function resolvePackageInfo(packageName, id) {
|
|
307
|
+
const cleanId = id.split(/[?#]/, 1)[0];
|
|
308
|
+
const selfPackage = findNearestPackageInfo(path.dirname(cleanId), packageName);
|
|
309
|
+
if (selfPackage !== null) return selfPackage;
|
|
310
|
+
let resolver;
|
|
311
|
+
try {
|
|
312
|
+
resolver = createRequire(cleanId);
|
|
313
|
+
} catch {
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
try {
|
|
317
|
+
const entry = resolver.resolve(packageName);
|
|
318
|
+
const fromEntry = findPackageInfo(path.dirname(entry), packageName);
|
|
319
|
+
if (fromEntry !== null) return fromEntry;
|
|
320
|
+
} catch {}
|
|
321
|
+
for (const lookupPath of resolver.resolve.paths(packageName) ?? []) {
|
|
322
|
+
const candidate = path.join(lookupPath, packageName, "package.json");
|
|
323
|
+
const packageJson = readPackageJson(candidate);
|
|
324
|
+
if (packageJson?.name === packageName) return {
|
|
325
|
+
packageRoot: path.dirname(candidate),
|
|
326
|
+
packageJson
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
function findNearestPackageInfo(startDirectory, packageName) {
|
|
332
|
+
let directory = startDirectory;
|
|
333
|
+
while (true) {
|
|
334
|
+
const filename = path.join(directory, "package.json");
|
|
335
|
+
if (fs.existsSync(filename)) {
|
|
336
|
+
const packageJson = readPackageJson(filename);
|
|
337
|
+
return packageJson?.name === packageName ? {
|
|
338
|
+
packageRoot: directory,
|
|
339
|
+
packageJson
|
|
340
|
+
} : null;
|
|
341
|
+
}
|
|
342
|
+
const parent = path.dirname(directory);
|
|
343
|
+
if (parent === directory) return null;
|
|
344
|
+
directory = parent;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
function findPackageInfo(startDirectory, packageName) {
|
|
348
|
+
let directory = startDirectory;
|
|
349
|
+
while (true) {
|
|
350
|
+
const packageJson = readPackageJson(path.join(directory, "package.json"));
|
|
351
|
+
if (packageJson?.name === packageName) return {
|
|
352
|
+
packageRoot: directory,
|
|
353
|
+
packageJson
|
|
354
|
+
};
|
|
355
|
+
const parent = path.dirname(directory);
|
|
356
|
+
if (parent === directory) return null;
|
|
357
|
+
directory = parent;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function readPackageJson(filename) {
|
|
361
|
+
try {
|
|
362
|
+
return JSON.parse(fs.readFileSync(filename, "utf8"));
|
|
363
|
+
} catch {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function resolveExportTargets(value, conditions) {
|
|
368
|
+
if (typeof value === "string") return [value];
|
|
369
|
+
if (Array.isArray(value)) return value.length === 0 ? [] : resolveExportTargets(value[0], conditions);
|
|
370
|
+
if (!isUnknownRecord(value)) return [];
|
|
371
|
+
for (const [condition, target] of Object.entries(value)) if (condition === "default" || conditions.has(condition)) return resolveExportTargets(target, conditions);
|
|
372
|
+
return [];
|
|
373
|
+
}
|
|
374
|
+
function matchWildcardPattern(pattern, value) {
|
|
375
|
+
const parts = splitSingleWildcard(pattern);
|
|
376
|
+
if (parts === null) return null;
|
|
377
|
+
const [prefix, suffix] = parts;
|
|
378
|
+
if (!value.startsWith(prefix) || !value.endsWith(suffix)) return null;
|
|
379
|
+
return {
|
|
380
|
+
prefix,
|
|
381
|
+
suffix,
|
|
382
|
+
capture: value.slice(prefix.length, suffix.length === 0 ? void 0 : -suffix.length)
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
function splitSingleWildcard(value) {
|
|
386
|
+
const wildcard = value.indexOf("*");
|
|
387
|
+
if (wildcard < 0 || wildcard !== value.lastIndexOf("*")) return null;
|
|
388
|
+
return [value.slice(0, wildcard), value.slice(wildcard + 1)];
|
|
389
|
+
}
|
|
390
|
+
function isWithinPackage(packageRoot, target) {
|
|
391
|
+
const relative = path.relative(packageRoot, target);
|
|
392
|
+
return relative !== ".." && !relative.startsWith("../") && !path.isAbsolute(relative);
|
|
393
|
+
}
|
|
394
|
+
function toImporterPath(importerDirectory, absolutePath) {
|
|
395
|
+
const relative = path.relative(importerDirectory, absolutePath);
|
|
396
|
+
if (path.isAbsolute(relative)) return null;
|
|
397
|
+
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
398
|
+
}
|
|
399
|
+
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
400
|
+
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
401
|
+
function escapeGlobLiteral(value) {
|
|
402
|
+
const pattern = process.platform === "win32" ? WIN32_UNESCAPED_GLOB_SYMBOLS : POSIX_UNESCAPED_GLOB_SYMBOLS;
|
|
403
|
+
return value.replace(pattern, "\\$&");
|
|
404
|
+
}
|
|
405
|
+
function buildPackageGlobPatterns(resolvedPrefix, capturePattern, resolvedSuffix) {
|
|
406
|
+
const parts = capturePattern.split("*");
|
|
407
|
+
const wildcardCount = parts.length - 1;
|
|
408
|
+
if (wildcardCount === 0 || wildcardCount > 4) return null;
|
|
409
|
+
let captures = [escapeGlobLiteral(parts[0])];
|
|
410
|
+
for (let index = 0; index < wildcardCount; index++) {
|
|
411
|
+
const suffix = escapeGlobLiteral(parts[index + 1]);
|
|
412
|
+
captures = captures.flatMap((capture) => [`${capture}*${suffix}`, `${capture}*/**/*${suffix}`]);
|
|
413
|
+
}
|
|
414
|
+
const prefix = escapeGlobLiteral(resolvedPrefix);
|
|
415
|
+
const suffix = escapeGlobLiteral(resolvedSuffix);
|
|
416
|
+
const patterns = [...new Set(captures.map((capture) => `${prefix}${capture}${suffix}`)), `!${prefix}**/node_modules/**`];
|
|
417
|
+
return patterns.length === 1 ? patterns[0] : patterns;
|
|
418
|
+
}
|
|
419
|
+
function resolveImporterDirectory(id) {
|
|
420
|
+
const directory = path.dirname(id.split(/[?#]/, 1)[0]);
|
|
421
|
+
try {
|
|
422
|
+
return toSlash(fs.realpathSync.native(directory));
|
|
423
|
+
} catch {
|
|
424
|
+
return directory;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
119
427
|
function isImportPrefix(value) {
|
|
120
428
|
const prefix = value.match(/^import\s*\(/)?.[0];
|
|
121
429
|
if (!prefix) return false;
|
|
@@ -152,9 +460,40 @@ function templateElementText(value) {
|
|
|
152
460
|
function getModuleExtensions(config) {
|
|
153
461
|
return config.resolve.extensions.filter((extension) => extension !== ".node");
|
|
154
462
|
}
|
|
463
|
+
function getExportConditions(config) {
|
|
464
|
+
const productionCondition = config.isProduction ? "production" : "development";
|
|
465
|
+
const conditions = /* @__PURE__ */ new Set([
|
|
466
|
+
"import",
|
|
467
|
+
"default",
|
|
468
|
+
productionCondition
|
|
469
|
+
]);
|
|
470
|
+
for (const condition of config.resolve.conditions ?? []) conditions.add(condition === "development|production" ? productionCondition : condition);
|
|
471
|
+
return conditions;
|
|
472
|
+
}
|
|
473
|
+
function createTransformConfig(config) {
|
|
474
|
+
return {
|
|
475
|
+
aliases: config.resolve.alias ?? [],
|
|
476
|
+
moduleExtensions: getModuleExtensions(config),
|
|
477
|
+
exportConditions: getExportConditions(config)
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
const JAVASCRIPT_STRING_ESCAPE_MAP = {
|
|
481
|
+
"<": "\\u003C",
|
|
482
|
+
">": "\\u003E",
|
|
483
|
+
"\u2028": "\\u2028",
|
|
484
|
+
"\u2029": "\\u2029"
|
|
485
|
+
};
|
|
486
|
+
function serializeJavaScriptValue(value) {
|
|
487
|
+
return JSON.stringify(value).replace(/[<>\u2028\u2029]/g, (character) => JAVASCRIPT_STRING_ESCAPE_MAP[character]);
|
|
488
|
+
}
|
|
155
489
|
function buildReplacement(source, globPattern, moduleExtensions) {
|
|
156
|
-
const extensions =
|
|
157
|
-
return `((__vinextPath, __vinextModules = import.meta.glob(${
|
|
490
|
+
const extensions = serializeJavaScriptValue(moduleExtensions);
|
|
491
|
+
return `((__vinextPath, __vinextModules = import.meta.glob(${serializeJavaScriptValue(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})`;
|
|
492
|
+
}
|
|
493
|
+
function buildPackageReplacement(source, resolution) {
|
|
494
|
+
const captureEnd = resolution.requestSuffix ? `-${serializeJavaScriptValue(resolution.requestSuffix)}.length` : "undefined";
|
|
495
|
+
const packageSubpathStart = resolution.packageName.length + 1;
|
|
496
|
+
return `((__vinextPath, __vinextModules = import.meta.glob(${serializeJavaScriptValue(resolution.globPattern)}, { exhaustive: true })) => { const __vinextSegments = __vinextPath.slice(${packageSubpathStart}).split("/"); let __vinextDecodedSegments, __vinextCapture; try { __vinextDecodedSegments = __vinextSegments.map((__vinextSegment) => decodeURIComponent(__vinextSegment)); __vinextCapture = __vinextPath.slice(${serializeJavaScriptValue(resolution.requestPrefix)}.length, ${captureEnd}).split("/").map((__vinextSegment) => decodeURIComponent(__vinextSegment)).join("/"); } catch { return Promise.reject(new Error("Cannot find module '" + __vinextPath + "'")); } const __vinextInvalidSubpath = __vinextPath.includes("?") || __vinextPath.includes("#") || __vinextDecodedSegments.some((__vinextSegment) => __vinextSegment === "." || __vinextSegment === ".." || __vinextSegment.toLowerCase() === "node_modules" || __vinextSegment.includes("/") || __vinextSegment.includes("\\\\")); if (__vinextInvalidSubpath) return Promise.reject(new Error("Cannot find module '" + __vinextPath + "'")); const __vinextResolvedPath = (${serializeJavaScriptValue(resolution.resolvedPrefix)} + __vinextCapture + ${serializeJavaScriptValue(resolution.resolvedSuffix)}).replace(/\\/+/g, "/"); const __vinextLoader = __vinextModules[__vinextResolvedPath]; return __vinextLoader ? __vinextLoader() : Promise.reject(new Error("Cannot find module '" + __vinextPath + "'")); })(${source})`;
|
|
158
497
|
}
|
|
159
498
|
//#endregion
|
|
160
499
|
export { createExtensionlessDynamicImportPlugin };
|
package/dist/plugins/fonts.d.ts
CHANGED
|
@@ -43,6 +43,21 @@ function stringValue(node) {
|
|
|
43
43
|
if ((node.type === "Literal" || node.type === "StringLiteral") && typeof node.value === "string") return node.value;
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
|
+
function stringFromCharCodeValue(value, scope) {
|
|
47
|
+
const node = unwrapExpression(value);
|
|
48
|
+
if (node?.type !== "CallExpression") return null;
|
|
49
|
+
const callee = unwrapExpression(node.callee);
|
|
50
|
+
const object = callee?.type === "MemberExpression" ? unwrapExpression(callee.object) : null;
|
|
51
|
+
const property = callee?.type === "MemberExpression" ? unwrapExpression(callee.property) : null;
|
|
52
|
+
if (callee?.type !== "MemberExpression" || callee.computed === true || !isIdentifierNamed(object, "String") || hasAstBinding(scope, "String") || !isIdentifierNamed(property, "fromCharCode")) return null;
|
|
53
|
+
let resolved = "";
|
|
54
|
+
for (const argument of nodeArray(node.arguments)) {
|
|
55
|
+
const argumentNode = unwrapExpression(argument);
|
|
56
|
+
if (argumentNode?.type !== "Literal" || typeof argumentNode.value !== "number" || !Number.isInteger(argumentNode.value) || argumentNode.value < 0 || argumentNode.value > 65535) return null;
|
|
57
|
+
resolved += String.fromCharCode(argumentNode.value);
|
|
58
|
+
}
|
|
59
|
+
return resolved;
|
|
60
|
+
}
|
|
46
61
|
function isUnboundNumericGlobal(node, scope) {
|
|
47
62
|
return node.type === "Identifier" && typeof node.name === "string" && !hasAstBinding(scope, node.name) && (isIdentifierNamed(node, "NaN") || isIdentifierNamed(node, "Infinity"));
|
|
48
63
|
}
|
|
@@ -482,10 +497,19 @@ function transformVeryDynamicRequests(code, id) {
|
|
|
482
497
|
if (node.type === "CallExpression" && hasRange(node)) {
|
|
483
498
|
const callee = unwrapExpression(node.callee);
|
|
484
499
|
const argumentsList = nodeArray(node.arguments);
|
|
485
|
-
if (isIdentifierNamed(callee, "require") && !hasAstBinding(scope, "require") && argumentsList.length === 1 && astNode(argumentsList[0])?.type !== "SpreadElement" && !hasDynamicRequestIgnoreDirective(code, node, argumentsList[0])
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
500
|
+
if (isIdentifierNamed(callee, "require") && !hasAstBinding(scope, "require") && argumentsList.length === 1 && astNode(argumentsList[0])?.type !== "SpreadElement" && !hasDynamicRequestIgnoreDirective(code, node, argumentsList[0])) {
|
|
501
|
+
const resolvedRequest = stringFromCharCodeValue(argumentsList[0], scope);
|
|
502
|
+
const argument = astNode(argumentsList[0]);
|
|
503
|
+
if (resolvedRequest !== null && resolvedRequest.replaceAll("\\", "/") !== "/" && argument && hasRange(argument)) {
|
|
504
|
+
output.overwrite(argument.start, argument.end, JSON.stringify(resolvedRequest));
|
|
505
|
+
changed = true;
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
if (!requestHasStaticPart(argumentsList[0], scope)) {
|
|
509
|
+
output.overwrite(node.start, node.end, dynamicRequireReplacement());
|
|
510
|
+
changed = true;
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
489
513
|
}
|
|
490
514
|
}
|
|
491
515
|
if (node.type === "ImportExpression" && hasRange(node) && !hasDynamicRequestIgnoreDirective(code, node, node.source) && !requestHasStaticPart(node.source, scope)) {
|