astro 6.0.0-alpha.0 → 6.0.0-alpha.2
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/astro-jsx.d.ts +11 -0
- package/client.d.ts +17 -41
- package/components/Code.astro +2 -2
- package/components/Image.astro +2 -2
- package/components/Picture.astro +1 -1
- package/dist/actions/consts.d.ts +2 -5
- package/dist/actions/consts.js +4 -8
- package/dist/actions/integration.js +2 -4
- package/dist/actions/runtime/client.d.ts +84 -3
- package/dist/actions/runtime/client.js +238 -7
- package/dist/actions/runtime/entrypoints/client.d.ts +7 -0
- package/dist/actions/runtime/entrypoints/client.js +91 -0
- package/dist/actions/runtime/entrypoints/route.d.ts +2 -0
- package/dist/actions/runtime/{route.js → entrypoints/route.js} +1 -1
- package/dist/actions/runtime/entrypoints/server.d.ts +6 -0
- package/dist/actions/runtime/entrypoints/server.js +33 -0
- package/dist/actions/runtime/server.d.ts +11 -18
- package/dist/actions/runtime/server.js +162 -82
- package/dist/actions/runtime/types.d.ts +64 -0
- package/dist/actions/utils.d.ts +2 -2
- package/dist/actions/utils.js +2 -2
- package/dist/actions/vite-plugin-actions.js +58 -47
- package/dist/assets/build/generate.d.ts +2 -2
- package/dist/assets/build/generate.js +12 -10
- package/dist/assets/consts.d.ts +1 -0
- package/dist/assets/consts.js +2 -0
- package/dist/assets/endpoint/config.js +2 -2
- package/dist/assets/endpoint/dev.js +7 -6
- package/dist/assets/fonts/config.d.ts +91 -350
- package/dist/assets/fonts/config.js +35 -136
- package/dist/assets/fonts/constants.js +1 -1
- package/dist/assets/fonts/core/dedupe-font-faces.d.ts +2 -0
- package/dist/assets/fonts/core/dedupe-font-faces.js +30 -0
- package/dist/assets/fonts/definitions.d.ts +9 -22
- package/dist/assets/fonts/infra/build-remote-font-provider-mod-resolver.d.ts +4 -0
- package/dist/assets/fonts/infra/build-remote-font-provider-mod-resolver.js +8 -0
- package/dist/assets/fonts/infra/build-url-proxy-hash-resolver.d.ts +15 -0
- package/dist/assets/fonts/infra/build-url-proxy-hash-resolver.js +20 -0
- package/dist/assets/fonts/infra/build-url-resolver.d.ts +12 -0
- package/dist/assets/fonts/infra/build-url-resolver.js +40 -0
- package/dist/assets/fonts/infra/cached-font-fetcher.d.ts +11 -0
- package/dist/assets/fonts/infra/cached-font-fetcher.js +42 -0
- package/dist/assets/fonts/infra/capsize-font-metrics-resolver.d.ts +18 -0
- package/dist/assets/fonts/infra/capsize-font-metrics-resolver.js +71 -0
- package/dist/assets/fonts/infra/data-collector.d.ts +10 -0
- package/dist/assets/fonts/infra/data-collector.js +35 -0
- package/dist/assets/fonts/infra/dev-remote-font-provider-mod-resolver.d.ts +9 -0
- package/dist/assets/fonts/infra/dev-remote-font-provider-mod-resolver.js +14 -0
- package/dist/assets/fonts/infra/dev-url-proxy-hash-resolver.d.ts +15 -0
- package/dist/assets/fonts/infra/dev-url-proxy-hash-resolver.js +37 -0
- package/dist/assets/fonts/infra/dev-url-resolver.d.ts +10 -0
- package/dist/assets/fonts/infra/dev-url-resolver.js +29 -0
- package/dist/assets/fonts/infra/font-type-extractor.d.ts +5 -0
- package/dist/assets/fonts/infra/font-type-extractor.js +21 -0
- package/dist/assets/fonts/infra/fontace-font-file-reader.d.ts +11 -0
- package/dist/assets/fonts/infra/fontace-font-file-reader.js +25 -0
- package/dist/assets/fonts/infra/levenshtein-string-matcher.d.ts +5 -0
- package/dist/assets/fonts/infra/levenshtein-string-matcher.js +145 -0
- package/dist/assets/fonts/infra/local-url-proxy-content-resolver.d.ts +4 -0
- package/dist/assets/fonts/infra/local-url-proxy-content-resolver.js +14 -0
- package/dist/assets/fonts/{implementations/css-renderer.d.ts → infra/minifiable-css-renderer.d.ts} +8 -3
- package/dist/assets/fonts/{implementations/css-renderer.js → infra/minifiable-css-renderer.js} +12 -10
- package/dist/assets/fonts/infra/remote-font-provider-resolver.d.ts +10 -0
- package/dist/assets/fonts/infra/remote-font-provider-resolver.js +49 -0
- package/dist/assets/fonts/infra/remote-url-proxy-content-resolver.d.ts +4 -0
- package/dist/assets/fonts/infra/remote-url-proxy-content-resolver.js +9 -0
- package/dist/assets/fonts/infra/require-local-provider-url-resolver.d.ts +9 -0
- package/dist/assets/fonts/infra/require-local-provider-url-resolver.js +22 -0
- package/dist/assets/fonts/infra/system-fallbacks-provider.d.ts +6 -0
- package/dist/assets/fonts/{implementations → infra}/system-fallbacks-provider.js +8 -11
- package/dist/assets/fonts/infra/unstorage-fs-storage.d.ts +11 -0
- package/dist/assets/fonts/infra/unstorage-fs-storage.js +26 -0
- package/dist/assets/fonts/infra/url-proxy.d.ts +16 -0
- package/dist/assets/fonts/infra/url-proxy.js +50 -0
- package/dist/assets/fonts/infra/xxhash-hasher.d.ts +7 -0
- package/dist/assets/fonts/infra/xxhash-hasher.js +18 -0
- package/dist/assets/fonts/orchestrate.d.ts +1 -2
- package/dist/assets/fonts/orchestrate.js +50 -17
- package/dist/assets/fonts/providers/index.d.ts +6 -24
- package/dist/assets/fonts/types.d.ts +138 -8
- package/dist/assets/fonts/utils.d.ts +1 -2
- package/dist/assets/fonts/vite-plugin-fonts.js +66 -65
- package/dist/assets/services/noop.js +11 -1
- package/dist/assets/services/service.d.ts +1 -1
- package/dist/assets/services/service.js +55 -51
- package/dist/assets/types.d.ts +2 -2
- package/dist/assets/utils/index.d.ts +1 -3
- package/dist/assets/utils/index.js +4 -9
- package/dist/assets/utils/{transformToPath.d.ts → node.d.ts} +15 -1
- package/dist/assets/utils/{node/emitAsset.js → node.js} +34 -6
- package/dist/assets/utils/svg.d.ts +2 -1
- package/dist/assets/utils/svg.js +30 -4
- package/dist/assets/vite-plugin-assets.js +36 -19
- package/dist/cli/add/index.js +21 -13
- package/dist/cli/create-key/infra/crypto-key-generator.d.ts +3 -1
- package/dist/cli/create-key/infra/crypto-key-generator.js +7 -9
- package/dist/cli/definitions.d.ts +19 -2
- package/dist/cli/dev/index.js +1 -1
- package/dist/cli/docs/core/open-docs.d.ts +5 -3
- package/dist/cli/docs/core/open-docs.js +2 -9
- package/dist/cli/docs/definitions.d.ts +3 -11
- package/dist/cli/docs/domain/cloud-ide.d.ts +1 -0
- package/dist/cli/docs/domain/cloud-ide.js +0 -0
- package/dist/cli/docs/infra/process-cloud-ide-provider.d.ts +5 -0
- package/dist/cli/docs/infra/process-cloud-ide-provider.js +6 -0
- package/dist/cli/flags.d.ts +1 -0
- package/dist/cli/index.js +78 -21
- package/dist/cli/info/core/get-package-manager.d.ts +8 -0
- package/dist/cli/info/core/get-package-manager.js +37 -0
- package/dist/cli/info/core/info.d.ts +21 -0
- package/dist/cli/info/core/info.js +21 -0
- package/dist/cli/info/definitions.d.ts +30 -0
- package/dist/cli/info/definitions.js +0 -0
- package/dist/cli/info/domain/debug-info.d.ts +1 -0
- package/dist/cli/info/domain/debug-info.js +0 -0
- package/dist/cli/info/infra/bun-package-manager.d.ts +5 -0
- package/dist/cli/info/infra/bun-package-manager.js +9 -0
- package/dist/cli/info/infra/cli-astro-config-resolver.d.ts +10 -0
- package/dist/cli/info/infra/cli-astro-config-resolver.js +36 -0
- package/dist/cli/info/infra/cli-clipboard.d.ts +13 -0
- package/dist/cli/info/infra/cli-clipboard.js +78 -0
- package/dist/cli/info/infra/cli-debug-info-provider.d.ts +15 -0
- package/dist/cli/info/infra/cli-debug-info-provider.js +57 -0
- package/dist/cli/info/infra/dev-debug-info-provider.d.ts +18 -0
- package/dist/cli/info/infra/dev-debug-info-provider.js +36 -0
- package/dist/cli/info/infra/noop-package-manager.d.ts +5 -0
- package/dist/cli/info/infra/noop-package-manager.js +9 -0
- package/dist/cli/info/infra/npm-package-manager.d.ts +10 -0
- package/dist/cli/info/infra/npm-package-manager.js +32 -0
- package/dist/cli/info/infra/pnpm-package-manager.d.ts +10 -0
- package/dist/cli/info/infra/pnpm-package-manager.js +33 -0
- package/dist/cli/info/infra/process-node-version-provider.d.ts +4 -0
- package/dist/cli/info/infra/process-node-version-provider.js +6 -0
- package/dist/cli/info/infra/process-package-manager-user-agent-provider.d.ts +4 -0
- package/dist/cli/info/infra/process-package-manager-user-agent-provider.js +7 -0
- package/dist/cli/info/infra/prompts-prompt.d.ts +11 -0
- package/dist/cli/info/infra/prompts-prompt.js +25 -0
- package/dist/cli/info/infra/styled-debug-info-formatter.d.ts +10 -0
- package/dist/cli/info/infra/styled-debug-info-formatter.js +29 -0
- package/dist/cli/info/infra/yarn-package-manager.d.ts +10 -0
- package/dist/cli/info/infra/yarn-package-manager.js +34 -0
- package/dist/cli/infra/build-time-astro-version-provider.d.ts +3 -1
- package/dist/cli/infra/build-time-astro-version-provider.js +4 -8
- package/dist/cli/infra/cli-command-runner.d.ts +7 -4
- package/dist/cli/infra/cli-command-runner.js +14 -10
- package/dist/cli/infra/logger-help-display.d.ts +11 -7
- package/dist/cli/infra/logger-help-display.js +62 -50
- package/dist/cli/infra/passthrough-text-styler.d.ts +9 -0
- package/dist/cli/infra/passthrough-text-styler.js +23 -0
- package/dist/cli/infra/piccolore-text-styler.d.ts +2 -0
- package/dist/cli/infra/piccolore-text-styler.js +5 -0
- package/dist/cli/infra/process-operating-system-provider.d.ts +6 -0
- package/dist/cli/infra/process-operating-system-provider.js +12 -0
- package/dist/cli/infra/tinyexec-command-executor.d.ts +6 -0
- package/dist/cli/infra/tinyexec-command-executor.js +34 -0
- package/dist/cli/install-package.js +1 -1
- package/dist/cli/preferences/index.js +6 -2
- package/dist/cli/preview/index.js +1 -1
- package/dist/cli/utils/format-version.js +1 -1
- package/dist/config/index.js +9 -5
- package/dist/container/index.js +19 -13
- package/dist/container/pipeline.d.ts +2 -1
- package/dist/container/pipeline.js +4 -11
- package/dist/container/vite-plugin-container.js +7 -4
- package/dist/content/config.d.ts +34 -40
- package/dist/content/content-layer.js +13 -18
- package/dist/content/loaders/errors.d.ts +3 -3
- package/dist/content/loaders/errors.js +5 -2
- package/dist/content/loaders/glob.js +6 -1
- package/dist/content/loaders/types.d.ts +11 -4
- package/dist/content/runtime-assets.d.ts +4 -4
- package/dist/content/runtime-assets.js +2 -2
- package/dist/content/runtime.d.ts +21 -20
- package/dist/content/runtime.js +14 -16
- package/dist/content/types-generator.js +90 -54
- package/dist/content/utils.d.ts +46 -338
- package/dist/content/utils.js +52 -50
- package/dist/content/vite-plugin-content-assets.d.ts +12 -4
- package/dist/content/vite-plugin-content-assets.js +152 -102
- package/dist/content/vite-plugin-content-imports.js +58 -40
- package/dist/content/vite-plugin-content-virtual-mod.js +95 -77
- package/dist/core/app/app.d.ts +5 -0
- package/dist/core/app/app.js +13 -0
- package/dist/core/app/base.d.ts +132 -0
- package/dist/core/app/base.js +448 -0
- package/dist/core/app/common.d.ts +6 -2
- package/dist/core/app/common.js +60 -33
- package/dist/core/app/dev/app.d.ts +15 -0
- package/dist/core/app/dev/app.js +86 -0
- package/dist/core/app/dev/pipeline.d.ts +13 -0
- package/dist/core/app/dev/pipeline.js +123 -0
- package/dist/core/app/entrypoint.d.ts +2 -0
- package/dist/core/app/entrypoint.js +15 -0
- package/dist/core/app/index.d.ts +7 -99
- package/dist/core/app/index.js +20 -486
- package/dist/core/app/logging.d.ts +3 -0
- package/dist/core/app/logging.js +11 -0
- package/dist/core/app/manifest.d.ts +9 -0
- package/dist/core/app/manifest.js +107 -0
- package/dist/core/app/middlewares.js +1 -1
- package/dist/core/app/node.js +14 -13
- package/dist/core/app/pipeline.d.ts +6 -5
- package/dist/core/app/pipeline.js +65 -49
- package/dist/core/app/types.d.ts +58 -22
- package/dist/core/app/validate-forwarded-headers.d.ts +16 -0
- package/dist/core/app/validate-forwarded-headers.js +60 -0
- package/dist/core/base-pipeline.d.ts +22 -14
- package/dist/core/base-pipeline.js +54 -6
- package/dist/core/build/app.d.ts +13 -0
- package/dist/core/build/app.js +38 -0
- package/dist/core/build/common.d.ts +1 -1
- package/dist/core/build/common.js +2 -2
- package/dist/core/build/generate.d.ts +1 -1
- package/dist/core/build/generate.js +96 -204
- package/dist/core/build/graph.js +2 -2
- package/dist/core/build/index.js +11 -16
- package/dist/core/build/internal.d.ts +2 -27
- package/dist/core/build/internal.js +1 -44
- package/dist/core/build/page-data.js +1 -1
- package/dist/core/build/pipeline.d.ts +15 -26
- package/dist/core/build/pipeline.js +106 -170
- package/dist/core/build/plugins/index.d.ts +4 -2
- package/dist/core/build/plugins/index.js +17 -23
- package/dist/core/build/plugins/plugin-analyzer.d.ts +2 -2
- package/dist/core/build/plugins/plugin-analyzer.js +5 -13
- package/dist/core/build/plugins/plugin-component-entry.d.ts +7 -2
- package/dist/core/build/plugins/plugin-component-entry.js +15 -17
- package/dist/core/build/plugins/plugin-css.d.ts +2 -2
- package/dist/core/build/plugins/plugin-css.js +90 -41
- package/dist/core/build/plugins/plugin-internals.d.ts +2 -2
- package/dist/core/build/plugins/plugin-internals.js +24 -18
- package/dist/core/build/plugins/plugin-manifest.d.ts +33 -5
- package/dist/core/build/plugins/plugin-manifest.js +89 -129
- package/dist/core/build/plugins/plugin-middleware.d.ts +2 -2
- package/dist/core/build/plugins/plugin-middleware.js +5 -7
- package/dist/core/build/plugins/plugin-noop.d.ts +3 -0
- package/dist/core/build/plugins/plugin-noop.js +35 -0
- package/dist/core/build/plugins/plugin-prerender.d.ts +2 -2
- package/dist/core/build/plugins/plugin-prerender.js +7 -64
- package/dist/core/build/plugins/plugin-scripts.d.ts +5 -2
- package/dist/core/build/plugins/plugin-scripts.js +5 -13
- package/dist/core/build/plugins/plugin-ssr.d.ts +2 -2
- package/dist/core/build/plugins/plugin-ssr.js +85 -139
- package/dist/core/build/plugins/util.d.ts +1 -25
- package/dist/core/build/plugins/util.js +0 -47
- package/dist/core/build/runtime.d.ts +26 -0
- package/dist/core/build/runtime.js +45 -0
- package/dist/core/build/static-build.d.ts +2 -2
- package/dist/core/build/static-build.js +181 -155
- package/dist/core/build/types.d.ts +1 -2
- package/dist/core/build/util.d.ts +0 -1
- package/dist/core/build/util.js +0 -7
- package/dist/core/compile/compile.d.ts +2 -3
- package/dist/core/compile/compile.js +2 -2
- package/dist/core/config/config.js +3 -3
- package/dist/core/config/index.d.ts +0 -1
- package/dist/core/config/index.js +0 -2
- package/dist/core/config/schemas/base.d.ts +336 -1434
- package/dist/core/config/schemas/base.js +42 -41
- package/dist/core/config/schemas/refined.d.ts +2 -2
- package/dist/core/config/schemas/refined.js +1 -1
- package/dist/core/config/schemas/relative.d.ts +672 -1761
- package/dist/core/config/schemas/relative.js +4 -4
- package/dist/core/config/settings.d.ts +3 -3
- package/dist/core/config/settings.js +5 -6
- package/dist/core/config/validate.js +13 -2
- package/dist/core/config/vite-load.js +12 -3
- package/dist/core/constants.d.ts +11 -0
- package/dist/core/constants.js +20 -1
- package/dist/core/create-vite.d.ts +2 -6
- package/dist/core/create-vite.js +35 -43
- package/dist/core/csp/common.d.ts +1 -1
- package/dist/core/csp/common.js +1 -1
- package/dist/core/csp/config.d.ts +8 -4
- package/dist/core/csp/config.js +1 -1
- package/dist/core/csp/runtime.d.ts +11 -0
- package/dist/core/csp/runtime.js +35 -0
- package/dist/core/dev/container.js +13 -7
- package/dist/core/dev/dev.js +2 -2
- package/dist/core/dev/restart.js +15 -6
- package/dist/core/errors/dev/runtime.d.ts +6 -0
- package/dist/core/errors/dev/runtime.js +27 -0
- package/dist/core/errors/dev/utils.js +1 -1
- package/dist/core/errors/dev/vite.js +1 -1
- package/dist/core/errors/errors-data.d.ts +32 -16
- package/dist/core/errors/errors-data.js +23 -10
- package/dist/core/errors/errors.d.ts +3 -3
- package/dist/core/errors/errors.js +8 -8
- package/dist/core/errors/zod-error-map.d.ts +2 -2
- package/dist/core/errors/zod-error-map.js +26 -24
- package/dist/core/logger/core.js +1 -1
- package/dist/core/messages.d.ts +2 -2
- package/dist/core/messages.js +3 -3
- package/dist/core/middleware/callMiddleware.js +1 -1
- package/dist/core/middleware/defineMiddleware.d.ts +2 -0
- package/dist/core/middleware/defineMiddleware.js +6 -0
- package/dist/core/middleware/index.d.ts +3 -3
- package/dist/core/middleware/index.js +1 -3
- package/dist/core/middleware/sequence.js +4 -4
- package/dist/core/middleware/vite-plugin.d.ts +1 -1
- package/dist/core/middleware/vite-plugin.js +41 -24
- package/dist/core/module-loader/index.d.ts +2 -2
- package/dist/core/module-loader/index.js +1 -1
- package/dist/core/module-loader/{loader.d.ts → runner.d.ts} +6 -17
- package/dist/core/module-loader/{loader.js → runner.js} +3 -0
- package/dist/core/module-loader/vite.d.ts +3 -2
- package/dist/core/module-loader/vite.js +17 -13
- package/dist/core/preview/index.js +20 -3
- package/dist/core/preview/static-preview-server.js +11 -0
- package/dist/core/redirects/component.js +1 -2
- package/dist/core/redirects/index.d.ts +0 -1
- package/dist/core/redirects/index.js +1 -3
- package/dist/core/redirects/render.js +5 -2
- package/dist/core/render/paginate.d.ts +1 -1
- package/dist/core/render/paginate.js +8 -6
- package/dist/core/render/params-and-props.d.ts +2 -0
- package/dist/core/render/params-and-props.js +19 -6
- package/dist/core/render/route-cache.d.ts +3 -2
- package/dist/core/render/route-cache.js +6 -5
- package/dist/core/render-context.d.ts +6 -4
- package/dist/core/render-context.js +66 -25
- package/dist/core/routing/astro-designed-error-pages.js +2 -2
- package/dist/core/routing/default.js +1 -1
- package/dist/core/routing/helpers.d.ts +22 -0
- package/dist/core/routing/helpers.js +25 -0
- package/dist/core/routing/index.d.ts +1 -1
- package/dist/core/routing/index.js +2 -2
- package/dist/core/routing/manifest/create.d.ts +6 -1
- package/dist/core/routing/manifest/create.js +11 -14
- package/dist/core/routing/manifest/generator.d.ts +3 -1
- package/dist/core/routing/params.d.ts +2 -1
- package/dist/core/routing/params.js +3 -2
- package/dist/core/server-islands/endpoint.js +40 -19
- package/dist/core/server-islands/vite-plugin-server-islands.d.ts +1 -1
- package/dist/core/server-islands/vite-plugin-server-islands.js +106 -46
- package/dist/core/session/vite-plugin.d.ts +6 -0
- package/dist/core/session/vite-plugin.js +59 -0
- package/dist/core/session.d.ts +4 -2
- package/dist/core/session.js +8 -48
- package/dist/core/sync/index.d.ts +2 -5
- package/dist/core/sync/index.js +34 -22
- package/dist/core/util/pathname.d.ts +10 -0
- package/dist/core/util/pathname.js +17 -0
- package/dist/core/util.d.ts +2 -2
- package/dist/core/util.js +3 -3
- package/dist/core/viteUtils.d.ts +1 -0
- package/dist/core/viteUtils.js +2 -0
- package/dist/entrypoints/legacy.d.ts +2 -0
- package/dist/entrypoints/legacy.js +12 -0
- package/dist/entrypoints/prerender.d.ts +4 -0
- package/dist/entrypoints/prerender.js +7 -0
- package/dist/env/schema.d.ts +21 -251
- package/dist/env/schema.js +6 -3
- package/dist/env/vite-plugin-env.js +61 -42
- package/dist/env/vite-plugin-import-meta-env.js +45 -37
- package/dist/environments.d.ts +3 -0
- package/dist/environments.js +11 -0
- package/dist/events/error.d.ts +2 -2
- package/dist/i18n/index.d.ts +2 -2
- package/dist/i18n/utils.d.ts +1 -6
- package/dist/i18n/utils.js +1 -63
- package/dist/i18n/vite-plugin-i18n.d.ts +0 -5
- package/dist/i18n/vite-plugin-i18n.js +8 -26
- package/dist/integrations/hooks.d.ts +1 -1
- package/dist/integrations/hooks.js +10 -7
- package/dist/manifest/serialized.d.ts +9 -0
- package/dist/manifest/serialized.js +150 -0
- package/dist/manifest/virtual-module.d.ts +1 -4
- package/dist/manifest/virtual-module.js +100 -91
- package/dist/preferences/index.d.ts +1 -2
- package/dist/prefetch/vite-plugin-prefetch.js +20 -9
- package/dist/prerender/routing.d.ts +5 -7
- package/dist/prerender/routing.js +6 -17
- package/dist/runtime/client/dev-toolbar/ui-library/badge.d.ts +2 -2
- package/dist/runtime/client/dev-toolbar/ui-library/button.d.ts +2 -2
- package/dist/runtime/client/dev-toolbar/ui-library/card.d.ts +2 -2
- package/dist/runtime/client/dev-toolbar/ui-library/highlight.d.ts +2 -2
- package/dist/runtime/client/dev-toolbar/ui-library/radio-checkbox.d.ts +2 -2
- package/dist/runtime/client/dev-toolbar/ui-library/select.d.ts +2 -2
- package/dist/runtime/client/dev-toolbar/ui-library/toggle.d.ts +2 -2
- package/dist/runtime/server/endpoint.js +1 -1
- package/dist/runtime/server/render/server-islands.js +5 -4
- package/dist/runtime/server/transition.d.ts +1 -0
- package/dist/template/4xx.js +3 -1
- package/dist/toolbar/vite-plugin-dev-toolbar.js +13 -7
- package/dist/transitions/events.d.ts +7 -0
- package/dist/transitions/router.js +7 -3
- package/dist/transitions/swap-functions.js +4 -0
- package/dist/transitions/vite-plugin-transitions.js +35 -22
- package/dist/types/astro.d.ts +8 -6
- package/dist/types/public/config.d.ts +438 -289
- package/dist/types/public/context.d.ts +3 -4
- package/dist/types/public/extendables.d.ts +2 -0
- package/dist/types/public/index.d.ts +2 -1
- package/dist/types/public/integrations.d.ts +23 -1
- package/dist/types/public/internal.d.ts +1 -16
- package/dist/types/public/preview.d.ts +6 -0
- package/dist/virtual-modules/i18n.d.ts +10 -2
- package/dist/virtual-modules/i18n.js +16 -7
- package/dist/virtual-modules/live-config.d.ts +1 -1
- package/dist/virtual-modules/live-config.js +1 -1
- package/dist/virtual-modules/middleware.d.ts +2 -1
- package/dist/virtual-modules/middleware.js +2 -1
- package/dist/vite-plugin-adapter-config/index.js +12 -5
- package/dist/vite-plugin-app/app.d.ts +47 -0
- package/dist/vite-plugin-app/app.js +410 -0
- package/dist/vite-plugin-app/createAstroServerApp.d.ts +8 -0
- package/dist/vite-plugin-app/createAstroServerApp.js +56 -0
- package/dist/vite-plugin-app/index.d.ts +3 -0
- package/dist/vite-plugin-app/index.js +19 -0
- package/dist/{vite-plugin-astro-server → vite-plugin-app}/pipeline.d.ts +6 -7
- package/dist/vite-plugin-app/pipeline.js +166 -0
- package/dist/vite-plugin-astro/index.js +215 -170
- package/dist/vite-plugin-astro-server/base.js +1 -1
- package/dist/vite-plugin-astro-server/controller.d.ts +1 -1
- package/dist/vite-plugin-astro-server/error.d.ts +3 -4
- package/dist/vite-plugin-astro-server/error.js +2 -5
- package/dist/vite-plugin-astro-server/index.d.ts +0 -1
- package/dist/vite-plugin-astro-server/index.js +0 -2
- package/dist/vite-plugin-astro-server/metadata.js +1 -1
- package/dist/vite-plugin-astro-server/plugin.d.ts +3 -7
- package/dist/vite-plugin-astro-server/plugin.js +40 -108
- package/dist/vite-plugin-astro-server/server-state.d.ts +1 -1
- package/dist/vite-plugin-astro-server/util.d.ts +2 -2
- package/dist/vite-plugin-astro-server/util.js +2 -1
- package/dist/vite-plugin-astro-server/vite.d.ts +2 -2
- package/dist/vite-plugin-astro-server/vite.js +7 -7
- package/dist/vite-plugin-chromedevtools/index.d.ts +7 -0
- package/dist/vite-plugin-chromedevtools/index.js +47 -0
- package/dist/vite-plugin-config-alias/index.js +59 -44
- package/dist/vite-plugin-css/index.d.ts +18 -0
- package/dist/vite-plugin-css/index.js +155 -0
- package/dist/vite-plugin-css/util.d.ts +5 -0
- package/dist/vite-plugin-css/util.js +8 -0
- package/dist/vite-plugin-environment/index.d.ts +15 -0
- package/dist/vite-plugin-environment/index.js +77 -0
- package/dist/vite-plugin-fileurl/index.js +6 -3
- package/dist/vite-plugin-head/index.d.ts +1 -2
- package/dist/vite-plugin-head/index.js +42 -58
- package/dist/vite-plugin-hmr-reload/index.js +2 -1
- package/dist/vite-plugin-html/index.d.ts +7 -4
- package/dist/vite-plugin-html/index.js +5 -3
- package/dist/vite-plugin-load-fallback/index.js +12 -5
- package/dist/vite-plugin-markdown/index.js +27 -8
- package/dist/vite-plugin-overlay/index.d.ts +2 -0
- package/dist/vite-plugin-overlay/index.js +21 -0
- package/dist/vite-plugin-pages/const.d.ts +2 -0
- package/dist/vite-plugin-pages/const.js +6 -0
- package/dist/vite-plugin-pages/index.d.ts +2 -0
- package/dist/vite-plugin-pages/index.js +7 -0
- package/dist/vite-plugin-pages/page.d.ts +7 -0
- package/dist/vite-plugin-pages/page.js +54 -0
- package/dist/vite-plugin-pages/pages.d.ts +8 -0
- package/dist/vite-plugin-pages/pages.js +63 -0
- package/dist/vite-plugin-pages/util.d.ts +8 -0
- package/dist/vite-plugin-pages/util.js +15 -0
- package/dist/vite-plugin-renderers/index.d.ts +9 -0
- package/dist/vite-plugin-renderers/index.js +45 -0
- package/dist/vite-plugin-routes/index.d.ts +14 -0
- package/dist/vite-plugin-routes/index.js +181 -0
- package/dist/vite-plugin-scripts/index.js +27 -25
- package/dist/vite-plugin-scripts/page-ssr.js +3 -2
- package/dist/vite-plugin-utils/index.d.ts +1 -0
- package/dist/vite-plugin-utils/index.js +2 -1
- package/dist/zod.d.ts +2 -2
- package/dist/zod.js +2 -2
- package/package.json +35 -32
- package/templates/content/module.mjs +1 -0
- package/templates/content/types.d.ts +24 -11
- package/types/actions.d.ts +1 -5
- package/types/content.d.ts +9 -11
- package/types/transitions.d.ts +25 -0
- package/dist/actions/loadActions.d.ts +0 -8
- package/dist/actions/loadActions.js +0 -13
- package/dist/actions/runtime/route.d.ts +0 -2
- package/dist/actions/runtime/shared.d.ts +0 -60
- package/dist/actions/runtime/shared.js +0 -296
- package/dist/actions/runtime/utils.d.ts +0 -25
- package/dist/actions/runtime/utils.js +0 -16
- package/dist/actions/runtime/virtual.d.ts +0 -4
- package/dist/actions/runtime/virtual.js +0 -127
- package/dist/assets/fonts/implementations/data-collector.d.ts +0 -3
- package/dist/assets/fonts/implementations/data-collector.js +0 -21
- package/dist/assets/fonts/implementations/error-handler.d.ts +0 -2
- package/dist/assets/fonts/implementations/error-handler.js +0 -41
- package/dist/assets/fonts/implementations/font-fetcher.d.ts +0 -8
- package/dist/assets/fonts/implementations/font-fetcher.js +0 -34
- package/dist/assets/fonts/implementations/font-file-reader.d.ts +0 -4
- package/dist/assets/fonts/implementations/font-file-reader.js +0 -26
- package/dist/assets/fonts/implementations/font-metrics-resolver.d.ts +0 -5
- package/dist/assets/fonts/implementations/font-metrics-resolver.js +0 -66
- package/dist/assets/fonts/implementations/font-type-extractor.d.ts +0 -4
- package/dist/assets/fonts/implementations/font-type-extractor.js +0 -22
- package/dist/assets/fonts/implementations/hasher.d.ts +0 -2
- package/dist/assets/fonts/implementations/hasher.js +0 -14
- package/dist/assets/fonts/implementations/levenshtein-string-matcher.d.ts +0 -2
- package/dist/assets/fonts/implementations/levenshtein-string-matcher.js +0 -147
- package/dist/assets/fonts/implementations/local-provider-url-resolver.d.ts +0 -5
- package/dist/assets/fonts/implementations/local-provider-url-resolver.js +0 -17
- package/dist/assets/fonts/implementations/remote-font-provider-mod-resolver.d.ts +0 -6
- package/dist/assets/fonts/implementations/remote-font-provider-mod-resolver.js +0 -20
- package/dist/assets/fonts/implementations/remote-font-provider-resolver.d.ts +0 -6
- package/dist/assets/fonts/implementations/remote-font-provider-resolver.js +0 -47
- package/dist/assets/fonts/implementations/storage.d.ts +0 -4
- package/dist/assets/fonts/implementations/storage.js +0 -14
- package/dist/assets/fonts/implementations/system-fallbacks-provider.d.ts +0 -11
- package/dist/assets/fonts/implementations/url-proxy-content-resolver.d.ts +0 -5
- package/dist/assets/fonts/implementations/url-proxy-content-resolver.js +0 -28
- package/dist/assets/fonts/implementations/url-proxy-hash-resolver.d.ts +0 -8
- package/dist/assets/fonts/implementations/url-proxy-hash-resolver.js +0 -39
- package/dist/assets/fonts/implementations/url-proxy.d.ts +0 -7
- package/dist/assets/fonts/implementations/url-proxy.js +0 -31
- package/dist/assets/fonts/implementations/url-resolver.d.ts +0 -11
- package/dist/assets/fonts/implementations/url-resolver.js +0 -55
- package/dist/assets/utils/node/emitAsset.d.ts +0 -15
- package/dist/assets/utils/remotePattern.d.ts +0 -3
- package/dist/assets/utils/remotePattern.js +0 -16
- package/dist/assets/utils/transformToPath.js +0 -32
- package/dist/cli/docs/domains/platform.d.ts +0 -1
- package/dist/cli/docs/infra/process-platform-provider.d.ts +0 -2
- package/dist/cli/docs/infra/process-platform-provider.js +0 -11
- package/dist/cli/docs/infra/tinyexec-command-executor.d.ts +0 -2
- package/dist/cli/docs/infra/tinyexec-command-executor.js +0 -30
- package/dist/cli/info/index.d.ts +0 -12
- package/dist/cli/info/index.js +0 -267
- package/dist/cli/infra/picocolors-text-styler.d.ts +0 -2
- package/dist/cli/infra/picocolors-text-styler.js +0 -7
- package/dist/core/build/css-asset-name.d.ts +0 -9
- package/dist/core/build/css-asset-name.js +0 -89
- package/dist/core/build/plugin.d.ts +0 -43
- package/dist/core/build/plugin.js +0 -61
- package/dist/core/build/plugins/plugin-actions.d.ts +0 -4
- package/dist/core/build/plugins/plugin-actions.js +0 -16
- package/dist/core/build/plugins/plugin-chunks.d.ts +0 -2
- package/dist/core/build/plugins/plugin-chunks.js +0 -33
- package/dist/core/build/plugins/plugin-pages.d.ts +0 -6
- package/dist/core/build/plugins/plugin-pages.js +0 -66
- package/dist/core/build/plugins/plugin-renderers.d.ts +0 -5
- package/dist/core/build/plugins/plugin-renderers.js +0 -54
- package/dist/core/middleware/loadMiddleware.d.ts +0 -7
- package/dist/core/middleware/loadMiddleware.js +0 -14
- package/dist/core/redirects/helpers.d.ts +0 -7
- package/dist/core/redirects/helpers.js +0 -10
- package/dist/core/routing/manifest/serialization.d.ts +0 -5
- package/dist/core/routing/manifest/serialization.js +0 -37
- package/dist/prerender/metadata.d.ts +0 -8
- package/dist/prerender/metadata.js +0 -18
- package/dist/vite-plugin-astro-server/css.d.ts +0 -13
- package/dist/vite-plugin-astro-server/css.js +0 -48
- package/dist/vite-plugin-astro-server/pipeline.js +0 -161
- package/dist/vite-plugin-astro-server/request.d.ts +0 -14
- package/dist/vite-plugin-astro-server/request.js +0 -66
- package/dist/vite-plugin-astro-server/route.d.ts +0 -25
- package/dist/vite-plugin-astro-server/route.js +0 -283
- package/dist/vite-plugin-scanner/index.d.ts +0 -10
- package/dist/vite-plugin-scanner/index.js +0 -87
- package/dist/vite-plugin-ssr-manifest/index.d.ts +0 -2
- package/dist/vite-plugin-ssr-manifest/index.js +0 -26
- /package/dist/{cli/docs/domains/platform.js → actions/runtime/types.js} +0 -0
- /package/dist/assets/fonts/{logic → core}/extract-unifont-providers.d.ts +0 -0
- /package/dist/assets/fonts/{logic → core}/extract-unifont-providers.js +0 -0
- /package/dist/assets/fonts/{logic → core}/normalize-remote-font-faces.d.ts +0 -0
- /package/dist/assets/fonts/{logic → core}/normalize-remote-font-faces.js +0 -0
- /package/dist/assets/fonts/{logic → core}/optimize-fallbacks.d.ts +0 -0
- /package/dist/assets/fonts/{logic → core}/optimize-fallbacks.js +0 -0
- /package/dist/assets/fonts/{logic → core}/resolve-families.d.ts +0 -0
- /package/dist/assets/fonts/{logic → core}/resolve-families.js +0 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { Pipeline } from "../core/base-pipeline.js";
|
|
3
|
+
import { ASTRO_VERSION } from "../core/constants.js";
|
|
4
|
+
import { enhanceViteSSRError } from "../core/errors/dev/index.js";
|
|
5
|
+
import { AggregateError, CSSError, MarkdownError } from "../core/errors/index.js";
|
|
6
|
+
import { RedirectComponentInstance } from "../core/redirects/index.js";
|
|
7
|
+
import { loadRenderer } from "../core/render/index.js";
|
|
8
|
+
import { createDefaultRoutes } from "../core/routing/default.js";
|
|
9
|
+
import { routeIsRedirect } from "../core/routing/index.js";
|
|
10
|
+
import { findRouteToRewrite } from "../core/routing/rewrite.js";
|
|
11
|
+
import { isPage } from "../core/util.js";
|
|
12
|
+
import { resolveIdToUrl } from "../core/viteUtils.js";
|
|
13
|
+
import { getComponentMetadata } from "../vite-plugin-astro-server/metadata.js";
|
|
14
|
+
import { createResolve } from "../vite-plugin-astro-server/resolve.js";
|
|
15
|
+
import { PAGE_SCRIPT_ID } from "../vite-plugin-scripts/index.js";
|
|
16
|
+
import { getDevCSSModuleName } from "../vite-plugin-css/util.js";
|
|
17
|
+
class AstroServerPipeline extends Pipeline {
|
|
18
|
+
constructor(loader, logger, manifest, settings, getDebugInfo, defaultRoutes = createDefaultRoutes(manifest)) {
|
|
19
|
+
const resolve = createResolve(loader, manifest.rootDir);
|
|
20
|
+
const streaming = true;
|
|
21
|
+
super(logger, manifest, "development", [], resolve, streaming);
|
|
22
|
+
this.loader = loader;
|
|
23
|
+
this.logger = logger;
|
|
24
|
+
this.manifest = manifest;
|
|
25
|
+
this.settings = settings;
|
|
26
|
+
this.getDebugInfo = getDebugInfo;
|
|
27
|
+
this.defaultRoutes = defaultRoutes;
|
|
28
|
+
}
|
|
29
|
+
getName() {
|
|
30
|
+
return "AstroServerPipeline";
|
|
31
|
+
}
|
|
32
|
+
// renderers are loaded on every request,
|
|
33
|
+
// so it needs to be mutable here unlike in other environments
|
|
34
|
+
renderers = new Array();
|
|
35
|
+
routesList;
|
|
36
|
+
componentInterner = /* @__PURE__ */ new WeakMap();
|
|
37
|
+
static create(manifestData, {
|
|
38
|
+
loader,
|
|
39
|
+
logger,
|
|
40
|
+
manifest,
|
|
41
|
+
settings,
|
|
42
|
+
getDebugInfo
|
|
43
|
+
}) {
|
|
44
|
+
const pipeline = new AstroServerPipeline(loader, logger, manifest, settings, getDebugInfo);
|
|
45
|
+
pipeline.routesList = manifestData;
|
|
46
|
+
return pipeline;
|
|
47
|
+
}
|
|
48
|
+
async headElements(routeData) {
|
|
49
|
+
const { manifest, loader, runtimeMode, settings } = this;
|
|
50
|
+
const filePath = new URL(`${routeData.component}`, manifest.rootDir);
|
|
51
|
+
const scripts = /* @__PURE__ */ new Set();
|
|
52
|
+
if (settings) {
|
|
53
|
+
if (isPage(filePath, settings) && runtimeMode === "development") {
|
|
54
|
+
scripts.add({
|
|
55
|
+
props: { type: "module", src: "/@vite/client" },
|
|
56
|
+
children: ""
|
|
57
|
+
});
|
|
58
|
+
if (settings.config.devToolbar.enabled && await settings.preferences.get("devToolbar.enabled")) {
|
|
59
|
+
const src = await resolveIdToUrl(
|
|
60
|
+
loader,
|
|
61
|
+
"astro/runtime/client/dev-toolbar/entrypoint.js"
|
|
62
|
+
);
|
|
63
|
+
scripts.add({ props: { type: "module", src }, children: "" });
|
|
64
|
+
const additionalMetadata = {
|
|
65
|
+
root: fileURLToPath(settings.config.root),
|
|
66
|
+
version: ASTRO_VERSION,
|
|
67
|
+
latestAstroVersion: settings.latestAstroVersion,
|
|
68
|
+
// TODO: Currently the debug info is always fetched, which slows things down.
|
|
69
|
+
// We should look into not loading it if the dev toolbar is disabled. And when
|
|
70
|
+
// enabled, it would nice to request the debug info through import.meta.hot
|
|
71
|
+
// when the button is click to defer execution as much as possible
|
|
72
|
+
debugInfo: await this.getDebugInfo()
|
|
73
|
+
};
|
|
74
|
+
const children = `window.__astro_dev_toolbar__ = ${JSON.stringify(additionalMetadata)}`;
|
|
75
|
+
scripts.add({ props: {}, children });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const script of settings.scripts) {
|
|
79
|
+
if (script.stage === "head-inline") {
|
|
80
|
+
scripts.add({
|
|
81
|
+
props: {},
|
|
82
|
+
children: script.content
|
|
83
|
+
});
|
|
84
|
+
} else if (script.stage === "page" && isPage(filePath, settings)) {
|
|
85
|
+
scripts.add({
|
|
86
|
+
props: { type: "module", src: `/@id/${PAGE_SCRIPT_ID}` },
|
|
87
|
+
children: ""
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const { css } = await loader.import(getDevCSSModuleName(routeData.component));
|
|
93
|
+
const links = /* @__PURE__ */ new Set();
|
|
94
|
+
const styles = /* @__PURE__ */ new Set();
|
|
95
|
+
for (const { id, url: src, content } of css) {
|
|
96
|
+
scripts.add({ props: { type: "module", src }, children: "" });
|
|
97
|
+
styles.add({ props: { "data-vite-dev-id": id }, children: content });
|
|
98
|
+
}
|
|
99
|
+
return { scripts, styles, links };
|
|
100
|
+
}
|
|
101
|
+
componentMetadata(routeData) {
|
|
102
|
+
const filePath = new URL(`${routeData.component}`, this.manifest.rootDir);
|
|
103
|
+
return getComponentMetadata(filePath, this.loader);
|
|
104
|
+
}
|
|
105
|
+
async preload(routeData, filePath) {
|
|
106
|
+
if (routeIsRedirect(routeData)) {
|
|
107
|
+
return RedirectComponentInstance;
|
|
108
|
+
}
|
|
109
|
+
const { loader } = this;
|
|
110
|
+
for (const route of this.defaultRoutes) {
|
|
111
|
+
if (route.matchesComponent(filePath)) {
|
|
112
|
+
return route.instance;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (this.settings) {
|
|
116
|
+
const renderers__ = this.settings.renderers.map((r) => loadRenderer(r, loader));
|
|
117
|
+
const renderers_ = await Promise.all(renderers__);
|
|
118
|
+
this.renderers = renderers_.filter((r) => Boolean(r));
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const componentInstance = await loader.import(filePath.toString());
|
|
122
|
+
this.componentInterner.set(routeData, componentInstance);
|
|
123
|
+
return componentInstance;
|
|
124
|
+
} catch (error) {
|
|
125
|
+
if (MarkdownError.is(error) || CSSError.is(error) || AggregateError.is(error)) {
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
throw enhanceViteSSRError({ error, filePath, loader });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
clearRouteCache() {
|
|
132
|
+
this.routeCache.clearAll();
|
|
133
|
+
this.componentInterner = /* @__PURE__ */ new WeakMap();
|
|
134
|
+
}
|
|
135
|
+
async getComponentByRoute(routeData) {
|
|
136
|
+
const component = this.componentInterner.get(routeData);
|
|
137
|
+
if (component) {
|
|
138
|
+
return component;
|
|
139
|
+
} else {
|
|
140
|
+
const filePath = new URL(`${routeData.component}`, this.manifest.rootDir);
|
|
141
|
+
return await this.preload(routeData, filePath);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async tryRewrite(payload, request) {
|
|
145
|
+
if (!this.routesList) {
|
|
146
|
+
throw new Error("Missing manifest data. This is an internal error, please file an issue.");
|
|
147
|
+
}
|
|
148
|
+
const { routeData, pathname, newUrl } = findRouteToRewrite({
|
|
149
|
+
payload,
|
|
150
|
+
request,
|
|
151
|
+
routes: this.routesList?.routes,
|
|
152
|
+
trailingSlash: this.manifest.trailingSlash,
|
|
153
|
+
buildFormat: this.manifest.buildFormat,
|
|
154
|
+
base: this.manifest.base,
|
|
155
|
+
outDir: this.manifest.outDir
|
|
156
|
+
});
|
|
157
|
+
const componentInstance = await this.getComponentByRoute(routeData);
|
|
158
|
+
return { newUrl, pathname, componentInstance, routeData };
|
|
159
|
+
}
|
|
160
|
+
setManifestData(manifestData) {
|
|
161
|
+
this.routesList = manifestData;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
export {
|
|
165
|
+
AstroServerPipeline
|
|
166
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { defaultClientConditions, defaultServerConditions, normalizePath } from "vite";
|
|
2
|
-
import {
|
|
2
|
+
import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../core/constants.js";
|
|
3
|
+
import { isAstroServerEnvironment } from "../environments.js";
|
|
4
|
+
import { normalizeFilename, specialQueriesRE } from "../vite-plugin-utils/index.js";
|
|
3
5
|
import { compileAstro } from "./compile.js";
|
|
4
6
|
import { handleHotUpdate } from "./hmr.js";
|
|
5
7
|
import { parseAstroRequest } from "./query.js";
|
|
@@ -14,205 +16,248 @@ function astro({ settings, logger }) {
|
|
|
14
16
|
const srcRootWeb = config.srcDir.pathname.slice(config.root.pathname.length - 1);
|
|
15
17
|
const isBrowserPath = (path) => path.startsWith(srcRootWeb) && srcRootWeb !== "/";
|
|
16
18
|
const notAstroComponent = (component) => !component.resolvedPath.endsWith(".astro");
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
name: "astro:build:css-hmr",
|
|
22
|
+
enforce: "pre",
|
|
23
|
+
applyToEnvironment(environment) {
|
|
24
|
+
return environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.client;
|
|
25
|
+
},
|
|
26
|
+
transform: {
|
|
27
|
+
filter: {
|
|
28
|
+
id: {
|
|
29
|
+
include: [/(?:\?|&)astro(?:&|=|$)/],
|
|
30
|
+
// ignore astro file sub-requests, e.g. Foo.astro?astro&type=script&index=0&lang.ts
|
|
31
|
+
exclude: [specialQueriesRE]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
async handler(_source, id) {
|
|
35
|
+
const parsedId = parseAstroRequest(id);
|
|
36
|
+
const astroFilename = normalizePath(normalizeFilename(parsedId.filename, config.root));
|
|
37
|
+
const compileMetadata = astroFileToCompileMetadata.get(astroFilename);
|
|
38
|
+
if (compileMetadata && parsedId.query.type === "style" && parsedId.query.index != null) {
|
|
39
|
+
const result = compileMetadata.css[parsedId.query.index];
|
|
40
|
+
result.dependencies?.forEach((dep) => this.addWatchFile(dep));
|
|
41
|
+
}
|
|
28
42
|
}
|
|
29
43
|
}
|
|
30
|
-
viteConfig.resolve.conditions.push("astro");
|
|
31
44
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
{
|
|
46
|
+
name: "astro:build",
|
|
47
|
+
enforce: "pre",
|
|
48
|
+
// run transforms before other plugins can
|
|
49
|
+
async configEnvironment(name, viteConfig, opts) {
|
|
50
|
+
viteConfig.resolve ??= {};
|
|
51
|
+
if (viteConfig.resolve.conditions == null) {
|
|
52
|
+
if (viteConfig.consumer === "client" || name === "client" || opts.isSsrTargetWebworker) {
|
|
53
|
+
viteConfig.resolve.conditions = [...defaultClientConditions];
|
|
54
|
+
} else {
|
|
55
|
+
viteConfig.resolve.conditions = [...defaultServerConditions];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
viteConfig.resolve.conditions.push("astro");
|
|
59
|
+
},
|
|
60
|
+
async configResolved(viteConfig) {
|
|
61
|
+
const toolbarEnabled = await settings.preferences.get("devToolbar.enabled");
|
|
62
|
+
compile = (code, filename) => {
|
|
63
|
+
return compileAstro({
|
|
64
|
+
compileProps: {
|
|
65
|
+
astroConfig: config,
|
|
66
|
+
viteConfig,
|
|
67
|
+
toolbarEnabled,
|
|
68
|
+
filename,
|
|
69
|
+
source: code
|
|
70
|
+
},
|
|
71
|
+
astroFileToCompileMetadata,
|
|
72
|
+
logger
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
configureServer(_server) {
|
|
77
|
+
server = _server;
|
|
78
|
+
server.watcher.on("unlink", (filename) => {
|
|
79
|
+
astroFileToCompileMetadata.delete(filename);
|
|
44
80
|
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
buildStart() {
|
|
54
|
-
astroFileToCompileMetadata = /* @__PURE__ */ new Map();
|
|
55
|
-
if (astroFileToCompileMetadataWeakMap.has(config)) {
|
|
56
|
-
astroFileToCompileMetadata = astroFileToCompileMetadataWeakMap.get(config);
|
|
57
|
-
} else {
|
|
58
|
-
astroFileToCompileMetadataWeakMap.set(config, astroFileToCompileMetadata);
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
async load(id, opts) {
|
|
62
|
-
const parsedId = parseAstroRequest(id);
|
|
63
|
-
const query = parsedId.query;
|
|
64
|
-
if (!query.astro) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
const filename = normalizePath(normalizeFilename(parsedId.filename, config.root));
|
|
68
|
-
let compileMetadata = astroFileToCompileMetadata.get(filename);
|
|
69
|
-
if (!compileMetadata) {
|
|
70
|
-
if (server) {
|
|
71
|
-
const code = await loadId(server.pluginContainer, filename);
|
|
72
|
-
if (code != null) await compile(code, filename);
|
|
81
|
+
},
|
|
82
|
+
buildStart() {
|
|
83
|
+
astroFileToCompileMetadata = /* @__PURE__ */ new Map();
|
|
84
|
+
if (astroFileToCompileMetadataWeakMap.has(config)) {
|
|
85
|
+
astroFileToCompileMetadata = astroFileToCompileMetadataWeakMap.get(config);
|
|
86
|
+
} else {
|
|
87
|
+
astroFileToCompileMetadataWeakMap.set(config, astroFileToCompileMetadata);
|
|
73
88
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
},
|
|
90
|
+
load: {
|
|
91
|
+
filter: {
|
|
92
|
+
id: /(?:\?|&)astro(?:&|=|$)/
|
|
93
|
+
},
|
|
94
|
+
async handler(id) {
|
|
95
|
+
const parsedId = parseAstroRequest(id);
|
|
96
|
+
const query = parsedId.query;
|
|
97
|
+
const filename = normalizePath(normalizeFilename(parsedId.filename, config.root));
|
|
98
|
+
let compileMetadata = astroFileToCompileMetadata.get(filename);
|
|
99
|
+
if (!compileMetadata) {
|
|
100
|
+
if (server) {
|
|
101
|
+
const code = await loadId(server.pluginContainer, filename);
|
|
102
|
+
if (code != null) await compile(code, filename);
|
|
103
|
+
}
|
|
104
|
+
compileMetadata = astroFileToCompileMetadata.get(filename);
|
|
85
105
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
106
|
+
if (!compileMetadata) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`No cached compile metadata found for "${id}". The main Astro module "${filename}" should have compiled and filled the metadata first, before its virtual modules can be requested.`
|
|
109
|
+
);
|
|
89
110
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
// if the Astro component's default export is not used
|
|
95
|
-
meta: result.isGlobal ? void 0 : {
|
|
96
|
-
vite: {
|
|
97
|
-
cssScopeTo: [filename, "default"]
|
|
111
|
+
switch (query.type) {
|
|
112
|
+
case "style": {
|
|
113
|
+
if (typeof query.index === "undefined") {
|
|
114
|
+
throw new Error(`Requests for Astro CSS must include an index.`);
|
|
98
115
|
}
|
|
116
|
+
const result = compileMetadata.css[query.index];
|
|
117
|
+
if (!result) {
|
|
118
|
+
throw new Error(`No Astro CSS at index ${query.index}`);
|
|
119
|
+
}
|
|
120
|
+
result.dependencies?.forEach((dep) => this.addWatchFile(dep));
|
|
121
|
+
return {
|
|
122
|
+
code: result.code,
|
|
123
|
+
// `vite.cssScopeTo` is a Vite feature that allows this CSS to be treeshaken
|
|
124
|
+
// if the Astro component's default export is not used
|
|
125
|
+
meta: result.isGlobal ? void 0 : {
|
|
126
|
+
vite: {
|
|
127
|
+
cssScopeTo: [filename, "default"]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
99
131
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
throw new Error(
|
|
120
|
-
`
|
|
132
|
+
case "script": {
|
|
133
|
+
if (typeof query.index === "undefined") {
|
|
134
|
+
throw new Error(`Requests for scripts must include an index`);
|
|
135
|
+
}
|
|
136
|
+
if (isAstroServerEnvironment(this.environment)) {
|
|
137
|
+
return {
|
|
138
|
+
code: `/* client script, empty in SSR: ${id} */`
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const script = compileMetadata.scripts[query.index];
|
|
142
|
+
if (!script) {
|
|
143
|
+
throw new Error(`No script at index ${query.index}`);
|
|
144
|
+
}
|
|
145
|
+
if (script.type === "external") {
|
|
146
|
+
const src = script.src;
|
|
147
|
+
if (src.startsWith("/") && !isBrowserPath(src)) {
|
|
148
|
+
const publicDir = config.publicDir.pathname.replace(/\/$/, "").split("/").pop() + "/";
|
|
149
|
+
throw new Error(
|
|
150
|
+
`
|
|
121
151
|
|
|
122
152
|
<script src="${src}"> references an asset in the "${publicDir}" directory. Please add the "is:inline" directive to keep this asset from being bundled.
|
|
123
153
|
|
|
124
154
|
File: ${id}`
|
|
125
|
-
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const result = {
|
|
159
|
+
code: "",
|
|
160
|
+
meta: {
|
|
161
|
+
vite: {
|
|
162
|
+
lang: "ts"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
switch (script.type) {
|
|
167
|
+
case "inline": {
|
|
168
|
+
const { code, map } = script;
|
|
169
|
+
result.code = appendSourceMap(code, map);
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
case "external": {
|
|
173
|
+
const { src } = script;
|
|
174
|
+
result.code = `import "${src}"`;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return result;
|
|
126
179
|
}
|
|
180
|
+
case "custom":
|
|
181
|
+
case "template":
|
|
182
|
+
case void 0:
|
|
183
|
+
default:
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
transform: {
|
|
189
|
+
filter: {
|
|
190
|
+
id: {
|
|
191
|
+
include: [/\.astro$/, /\.astro\?/],
|
|
192
|
+
// ignore astro file sub-requests, e.g. Foo.astro?astro&type=script&index=0&lang.ts
|
|
193
|
+
exclude: [specialQueriesRE, /(?:\?|&)astro(?:&|=|$)/]
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
async handler(source, id) {
|
|
197
|
+
const parsedId = parseAstroRequest(id);
|
|
198
|
+
if (!parsedId.filename.endsWith(".astro")) {
|
|
199
|
+
return;
|
|
127
200
|
}
|
|
128
|
-
const
|
|
129
|
-
|
|
201
|
+
const filename = normalizePath(parsedId.filename);
|
|
202
|
+
if (this.environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.client) {
|
|
203
|
+
return {
|
|
204
|
+
code: `export default import.meta.env.DEV
|
|
205
|
+
? () => {
|
|
206
|
+
throw new Error(
|
|
207
|
+
'Astro components cannot be used in the browser.\\nTried to render "${filename}".'
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
: {};`,
|
|
211
|
+
meta: { vite: { lang: "ts" } }
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
const transformResult = await compile(source, filename);
|
|
215
|
+
const astroMetadata = {
|
|
216
|
+
// Remove Astro components that have been mistakenly given client directives
|
|
217
|
+
// We'll warn the user about this later, but for now we'll prevent them from breaking the build
|
|
218
|
+
clientOnlyComponents: transformResult.clientOnlyComponents.filter(notAstroComponent),
|
|
219
|
+
hydratedComponents: transformResult.hydratedComponents.filter(notAstroComponent),
|
|
220
|
+
serverComponents: transformResult.serverComponents,
|
|
221
|
+
scripts: transformResult.scripts,
|
|
222
|
+
containsHead: transformResult.containsHead,
|
|
223
|
+
propagation: transformResult.propagation ? "self" : "none",
|
|
224
|
+
pageOptions: {}
|
|
225
|
+
};
|
|
226
|
+
return {
|
|
227
|
+
code: transformResult.code,
|
|
228
|
+
map: transformResult.map,
|
|
130
229
|
meta: {
|
|
230
|
+
astro: astroMetadata,
|
|
131
231
|
vite: {
|
|
232
|
+
// Setting this vite metadata to `ts` causes Vite to resolve .js
|
|
233
|
+
// extensions to .ts files.
|
|
132
234
|
lang: "ts"
|
|
133
235
|
}
|
|
134
236
|
}
|
|
135
237
|
};
|
|
136
|
-
switch (script.type) {
|
|
137
|
-
case "inline": {
|
|
138
|
-
const { code, map } = script;
|
|
139
|
-
result.code = appendSourceMap(code, map);
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
case "external": {
|
|
143
|
-
const { src } = script;
|
|
144
|
-
result.code = `import "${src}"`;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return result;
|
|
149
238
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
default:
|
|
154
|
-
return null;
|
|
239
|
+
},
|
|
240
|
+
async handleHotUpdate(ctx) {
|
|
241
|
+
return handleHotUpdate(ctx, { logger, astroFileToCompileMetadata });
|
|
155
242
|
}
|
|
156
243
|
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
result.dependencies?.forEach((dep) => this.addWatchFile(dep));
|
|
167
|
-
}
|
|
244
|
+
{
|
|
245
|
+
name: "astro:build:normal",
|
|
246
|
+
// If Vite resolver can't resolve the Astro request, it's likely a virtual Astro file, fallback here instead
|
|
247
|
+
resolveId: {
|
|
248
|
+
filter: {
|
|
249
|
+
id: /(?:\?|&)astro(?:&|=|$)/
|
|
250
|
+
},
|
|
251
|
+
handler(id) {
|
|
252
|
+
return id;
|
|
168
253
|
}
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
const filename = normalizePath(parsedId.filename);
|
|
172
|
-
const transformResult = await compile(source, filename);
|
|
173
|
-
const astroMetadata = {
|
|
174
|
-
// Remove Astro components that have been mistakenly given client directives
|
|
175
|
-
// We'll warn the user about this later, but for now we'll prevent them from breaking the build
|
|
176
|
-
clientOnlyComponents: transformResult.clientOnlyComponents.filter(notAstroComponent),
|
|
177
|
-
hydratedComponents: transformResult.hydratedComponents.filter(notAstroComponent),
|
|
178
|
-
serverComponents: transformResult.serverComponents,
|
|
179
|
-
scripts: transformResult.scripts,
|
|
180
|
-
containsHead: transformResult.containsHead,
|
|
181
|
-
propagation: transformResult.propagation ? "self" : "none",
|
|
182
|
-
pageOptions: {}
|
|
183
|
-
};
|
|
184
|
-
return {
|
|
185
|
-
code: transformResult.code,
|
|
186
|
-
map: transformResult.map,
|
|
187
|
-
meta: {
|
|
188
|
-
astro: astroMetadata,
|
|
189
|
-
vite: {
|
|
190
|
-
// Setting this vite metadata to `ts` causes Vite to resolve .js
|
|
191
|
-
// extensions to .ts files.
|
|
192
|
-
lang: "ts"
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
},
|
|
197
|
-
async handleHotUpdate(ctx) {
|
|
198
|
-
return handleHotUpdate(ctx, { logger, astroFileToCompileMetadata });
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
const normalPlugin = {
|
|
202
|
-
name: "astro:build:normal",
|
|
203
|
-
resolveId(id) {
|
|
204
|
-
const parsedId = parseAstroRequest(id);
|
|
205
|
-
if (parsedId.query.astro) {
|
|
206
|
-
return id;
|
|
207
254
|
}
|
|
208
255
|
}
|
|
209
|
-
|
|
210
|
-
return [prePlugin, normalPlugin];
|
|
256
|
+
];
|
|
211
257
|
}
|
|
212
258
|
function appendSourceMap(content, map) {
|
|
213
259
|
if (!map) return content;
|
|
214
|
-
return `${content}
|
|
215
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,${Buffer.from(
|
|
260
|
+
return `${content}${"\n//#"} sourceMappingURL=data:application/json;charset=utf-8;base64,${Buffer.from(
|
|
216
261
|
map
|
|
217
262
|
).toString("base64")}`;
|
|
218
263
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { appendForwardSlash } from "@astrojs/internal-helpers/path";
|
|
4
|
-
import colors from "
|
|
4
|
+
import colors from "piccolore";
|
|
5
5
|
import { notFoundTemplate, subpathNotUsedTemplate } from "../template/4xx.js";
|
|
6
6
|
import { writeHtmlResponse } from "./response.js";
|
|
7
7
|
function baseMiddleware(settings, logger) {
|
|
@@ -16,7 +16,7 @@ interface RunWithErrorHandlingParams {
|
|
|
16
16
|
controller: DevServerController;
|
|
17
17
|
pathname: string;
|
|
18
18
|
run: () => Promise<any>;
|
|
19
|
-
onError: (error: unknown) => Error;
|
|
19
|
+
onError: (error: unknown) => Error | undefined;
|
|
20
20
|
}
|
|
21
21
|
export declare function runWithErrorHandling({ controller: { state }, pathname, run, onError, }: RunWithErrorHandlingParams): Promise<void>;
|
|
22
22
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import type { SSRManifest } from '../core/app/types.js';
|
|
2
|
+
import type { Logger } from '../core/logger/core.js';
|
|
1
3
|
import type { ModuleLoader } from '../core/module-loader/index.js';
|
|
2
|
-
|
|
3
|
-
import type { DevPipeline } from './pipeline.js';
|
|
4
|
-
export declare function recordServerError(loader: ModuleLoader, config: AstroConfig, { logger }: DevPipeline, _err: unknown): {
|
|
5
|
-
error: Error;
|
|
4
|
+
export declare function recordServerError(loader: ModuleLoader, manifest: SSRManifest, logger: Logger, err: Error): {
|
|
6
5
|
errorWithMetadata: import("../core/errors/errors.js").ErrorWithMetadata;
|
|
7
6
|
};
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { collectErrorMetadata } from "../core/errors/dev/index.js";
|
|
2
|
-
import { createSafeError } from "../core/errors/index.js";
|
|
3
2
|
import { formatErrorMessage } from "../core/messages.js";
|
|
4
|
-
function recordServerError(loader,
|
|
5
|
-
const err = createSafeError(_err);
|
|
3
|
+
function recordServerError(loader, manifest, logger, err) {
|
|
6
4
|
try {
|
|
7
5
|
loader.fixStacktrace(err);
|
|
8
6
|
} catch {
|
|
9
7
|
}
|
|
10
|
-
const errorWithMetadata = collectErrorMetadata(err,
|
|
8
|
+
const errorWithMetadata = collectErrorMetadata(err, manifest.rootDir);
|
|
11
9
|
logger.error(null, formatErrorMessage(errorWithMetadata, logger.level() === "debug"));
|
|
12
10
|
return {
|
|
13
|
-
error: err,
|
|
14
11
|
errorWithMetadata
|
|
15
12
|
};
|
|
16
13
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { createController, runWithErrorHandling } from "./controller.js";
|
|
2
2
|
import { default as default2 } from "./plugin.js";
|
|
3
|
-
import { handleRequest } from "./request.js";
|
|
4
3
|
export {
|
|
5
4
|
createController,
|
|
6
|
-
handleRequest,
|
|
7
5
|
runWithErrorHandling,
|
|
8
6
|
default2 as vitePluginAstroServer
|
|
9
7
|
};
|