astro 6.0.0-alpha.0 → 6.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +18 -21
- package/dist/assets/build/generate.d.ts +2 -2
- package/dist/assets/build/generate.js +12 -10
- 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 +56 -61
- package/dist/assets/services/noop.js +5 -0
- package/dist/assets/utils/index.d.ts +0 -2
- package/dist/assets/utils/index.js +0 -5
- 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/remotePattern.d.ts +1 -3
- package/dist/assets/utils/svg.d.ts +2 -1
- package/dist/assets/utils/svg.js +30 -4
- package/dist/assets/vite-plugin-assets.js +10 -8
- 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/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 +81 -54
- package/dist/content/utils.d.ts +46 -338
- package/dist/content/utils.js +43 -48
- package/dist/content/vite-plugin-content-assets.d.ts +12 -4
- package/dist/content/vite-plugin-content-assets.js +100 -56
- package/dist/content/vite-plugin-content-imports.js +10 -4
- package/dist/content/vite-plugin-content-virtual-mod.js +10 -7
- 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 +5 -13
- package/dist/core/build/plugins/plugin-css.d.ts +2 -2
- package/dist/core/build/plugins/plugin-css.js +86 -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 +29 -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 +60 -132
- 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 +27 -7
- package/dist/core/errors/errors-data.js +17 -4
- 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 +18 -7
- 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 +89 -44
- package/dist/core/session/vite-plugin.d.ts +6 -0
- package/dist/core/session/vite-plugin.js +53 -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/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 +15 -10
- package/dist/env/vite-plugin-import-meta-env.js +3 -2
- 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 +1 -22
- 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 +144 -0
- package/dist/manifest/virtual-module.d.ts +1 -4
- package/dist/manifest/virtual-module.js +77 -80
- package/dist/preferences/index.d.ts +1 -2
- 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/transitions/events.d.ts +7 -0
- package/dist/transitions/router.js +7 -3
- package/dist/transitions/swap-functions.js +4 -0
- package/dist/types/astro.d.ts +8 -6
- package/dist/types/public/config.d.ts +404 -288
- package/dist/types/public/context.d.ts +3 -4
- 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 +3 -2
- 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 +16 -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 +21 -7
- 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 +1 -2
- package/dist/vite-plugin-astro-server/index.js +6 -4
- package/dist/vite-plugin-astro-server/metadata.js +1 -1
- package/dist/vite-plugin-astro-server/plugin.d.ts +4 -7
- package/dist/vite-plugin-astro-server/plugin.js +54 -65
- package/dist/vite-plugin-astro-server/server-state.d.ts +1 -1
- package/dist/vite-plugin-astro-server/util.d.ts +0 -2
- package/dist/vite-plugin-astro-server/util.js +1 -2
- 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-config-alias/index.js +40 -32
- package/dist/vite-plugin-css/index.d.ts +18 -0
- package/dist/vite-plugin-css/index.js +134 -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-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-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 +48 -0
- package/dist/vite-plugin-pages/pages.d.ts +8 -0
- package/dist/vite-plugin-pages/pages.js +57 -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 +40 -0
- package/dist/vite-plugin-routes/index.d.ts +14 -0
- package/dist/vite-plugin-routes/index.js +177 -0
- package/dist/vite-plugin-scripts/index.js +2 -6
- package/dist/vite-plugin-scripts/page-ssr.js +3 -2
- package/dist/zod.d.ts +2 -2
- package/dist/zod.js +2 -2
- package/package.json +34 -31
- 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/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,33 @@
|
|
|
1
|
+
import { pipelineSymbol } from "../../../core/constants.js";
|
|
2
|
+
import { ActionCalledFromServerError } from "../../../core/errors/errors-data.js";
|
|
3
|
+
import { AstroError } from "../../../core/errors/errors.js";
|
|
4
|
+
import { createGetActionPath, createActionsProxy } from "../client.js";
|
|
5
|
+
import { shouldAppendTrailingSlash } from "virtual:astro:actions/options";
|
|
6
|
+
import { ACTION_QUERY_PARAMS } from "../../consts.js";
|
|
7
|
+
import { ActionError, isActionError, isInputError } from "../client.js";
|
|
8
|
+
import { defineAction, getActionContext } from "../server.js";
|
|
9
|
+
const getActionPath = createGetActionPath({
|
|
10
|
+
baseUrl: import.meta.env.BASE_URL,
|
|
11
|
+
shouldAppendTrailingSlash
|
|
12
|
+
});
|
|
13
|
+
const actions = createActionsProxy({
|
|
14
|
+
handleAction: async (param, path, context) => {
|
|
15
|
+
const pipeline = context ? Reflect.get(context, pipelineSymbol) : void 0;
|
|
16
|
+
if (!pipeline) {
|
|
17
|
+
throw new AstroError(ActionCalledFromServerError);
|
|
18
|
+
}
|
|
19
|
+
const action = await pipeline.getAction(path);
|
|
20
|
+
if (!action) throw new Error(`Action not found: ${path}`);
|
|
21
|
+
return action.bind(context)(param);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
export {
|
|
25
|
+
ACTION_QUERY_PARAMS,
|
|
26
|
+
ActionError,
|
|
27
|
+
actions,
|
|
28
|
+
defineAction,
|
|
29
|
+
getActionContext,
|
|
30
|
+
getActionPath,
|
|
31
|
+
isActionError,
|
|
32
|
+
isInputError
|
|
33
|
+
};
|
|
@@ -1,25 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as z from 'zod/v4/core';
|
|
2
2
|
import type { APIContext } from '../../types/public/index.js';
|
|
3
|
-
import { deserializeActionResult
|
|
4
|
-
import {
|
|
5
|
-
export
|
|
6
|
-
export type ActionAccept = 'form' | 'json';
|
|
7
|
-
export type ActionHandler<TInputSchema, TOutput> = TInputSchema extends z.ZodType ? (input: z.infer<TInputSchema>, context: ActionAPIContext) => MaybePromise<TOutput> : (input: any, context: ActionAPIContext) => MaybePromise<TOutput>;
|
|
8
|
-
export type ActionReturnType<T extends ActionHandler<any, any>> = Awaited<ReturnType<T>>;
|
|
9
|
-
export type ActionClient<TOutput, TAccept extends ActionAccept | undefined, TInputSchema extends z.ZodType | undefined> = TInputSchema extends z.ZodType ? ((input: TAccept extends 'form' ? FormData : z.input<TInputSchema>) => Promise<SafeResult<z.input<TInputSchema> extends ErrorInferenceObject ? z.input<TInputSchema> : ErrorInferenceObject, Awaited<TOutput>>>) & {
|
|
10
|
-
queryString: string;
|
|
11
|
-
orThrow: (input: TAccept extends 'form' ? FormData : z.input<TInputSchema>) => Promise<Awaited<TOutput>>;
|
|
12
|
-
} : ((input?: any) => Promise<SafeResult<never, Awaited<TOutput>>>) & {
|
|
13
|
-
orThrow: (input?: any) => Promise<Awaited<TOutput>>;
|
|
14
|
-
};
|
|
15
|
-
export declare function defineAction<TOutput, TAccept extends ActionAccept | undefined = undefined, TInputSchema extends z.ZodType | undefined = TAccept extends 'form' ? z.ZodType<FormData> : undefined>({ accept, input: inputSchema, handler, }: {
|
|
3
|
+
import { deserializeActionResult } from './client.js';
|
|
4
|
+
import type { ActionAccept, ActionClient, ActionHandler, SafeResult, SerializedActionResult } from './types.js';
|
|
5
|
+
export declare function defineAction<TOutput, TAccept extends ActionAccept | undefined = undefined, TInputSchema extends z.$ZodType | undefined = TAccept extends 'form' ? z.$ZodType<FormData> : undefined>({ accept, input: inputSchema, handler, }: {
|
|
16
6
|
input?: TInputSchema;
|
|
17
7
|
accept?: TAccept;
|
|
18
8
|
handler: ActionHandler<TInputSchema, TOutput>;
|
|
19
9
|
}): ActionClient<TOutput, TAccept, TInputSchema> & string;
|
|
20
|
-
|
|
21
|
-
export declare function formDataToObject<T extends z.AnyZodObject>(formData: FormData, schema: T): Record<string, unknown>;
|
|
22
|
-
export type AstroActionContext = {
|
|
10
|
+
interface AstroActionContext {
|
|
23
11
|
/** Information about an incoming action request. */
|
|
24
12
|
action?: {
|
|
25
13
|
/** Whether an action was called using an RPC function or by using an HTML form action. */
|
|
@@ -43,8 +31,13 @@ export type AstroActionContext = {
|
|
|
43
31
|
* Deserialize an action result to access data and error objects.
|
|
44
32
|
*/
|
|
45
33
|
deserializeActionResult: typeof deserializeActionResult;
|
|
46
|
-
}
|
|
34
|
+
}
|
|
47
35
|
/**
|
|
48
36
|
* Access information about Action requests from middleware.
|
|
49
37
|
*/
|
|
50
38
|
export declare function getActionContext(context: APIContext): AstroActionContext;
|
|
39
|
+
export declare const ACTION_API_CONTEXT_SYMBOL: unique symbol;
|
|
40
|
+
/** Transform form data to an object based on a Zod schema. */
|
|
41
|
+
export declare function formDataToObject<T extends z.$ZodObject>(formData: FormData, schema: T): Record<string, unknown>;
|
|
42
|
+
export declare function serializeActionResult(res: SafeResult<any, any>): SerializedActionResult;
|
|
43
|
+
export {};
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stringify as devalueStringify } from "devalue";
|
|
2
|
+
import * as z from "zod/v4/core";
|
|
2
3
|
import { shouldAppendForwardSlash } from "../../core/build/util.js";
|
|
4
|
+
import { pipelineSymbol, REDIRECT_STATUS_CODES } from "../../core/constants.js";
|
|
5
|
+
import {
|
|
6
|
+
ActionCalledFromServerError,
|
|
7
|
+
ActionNotFoundError,
|
|
8
|
+
ActionsReturnedInvalidDataError
|
|
9
|
+
} from "../../core/errors/errors-data.js";
|
|
3
10
|
import { AstroError } from "../../core/errors/errors.js";
|
|
4
|
-
import { ActionCalledFromServerError, ActionNotFoundError } from "../../core/errors/errors-data.js";
|
|
5
11
|
import { removeTrailingForwardSlash } from "../../core/path.js";
|
|
6
|
-
import {
|
|
7
|
-
import { ACTION_RPC_ROUTE_PATTERN } from "../consts.js";
|
|
12
|
+
import { ACTION_QUERY_PARAMS, ACTION_RPC_ROUTE_PATTERN } from "../consts.js";
|
|
8
13
|
import {
|
|
9
|
-
ACTION_QUERY_PARAMS,
|
|
10
14
|
ActionError,
|
|
11
15
|
ActionInputError,
|
|
12
|
-
|
|
13
|
-
deserializeActionResult
|
|
14
|
-
|
|
15
|
-
} from "./shared.js";
|
|
16
|
-
import {
|
|
17
|
-
ACTION_API_CONTEXT_SYMBOL,
|
|
18
|
-
formContentTypes,
|
|
19
|
-
hasContentType,
|
|
20
|
-
isActionAPIContext
|
|
21
|
-
} from "./utils.js";
|
|
22
|
-
export * from "./shared.js";
|
|
16
|
+
actionResultErrorStack,
|
|
17
|
+
deserializeActionResult
|
|
18
|
+
} from "./client.js";
|
|
23
19
|
function defineAction({
|
|
24
20
|
accept,
|
|
25
21
|
input: inputSchema,
|
|
@@ -51,16 +47,19 @@ function getFormServerHandler(handler, inputSchema) {
|
|
|
51
47
|
});
|
|
52
48
|
}
|
|
53
49
|
if (!inputSchema) return await handler(unparsedInput, context);
|
|
54
|
-
const
|
|
55
|
-
const parsed = await inputSchema.safeParseAsync(
|
|
56
|
-
baseSchema instanceof z.ZodObject ? formDataToObject(unparsedInput, baseSchema) : unparsedInput
|
|
57
|
-
);
|
|
50
|
+
const parsed = await parseFormInput(inputSchema, unparsedInput);
|
|
58
51
|
if (!parsed.success) {
|
|
59
52
|
throw new ActionInputError(parsed.error.issues);
|
|
60
53
|
}
|
|
61
54
|
return await handler(parsed.data, context);
|
|
62
55
|
};
|
|
63
56
|
}
|
|
57
|
+
async function parseFormInput(inputSchema, unparsedInput) {
|
|
58
|
+
const baseSchema = unwrapBaseZ4ObjectSchema(inputSchema, unparsedInput);
|
|
59
|
+
const input = baseSchema instanceof z.$ZodObject ? formDataToObject(unparsedInput, baseSchema) : unparsedInput;
|
|
60
|
+
const parsed = await z.safeParseAsync(inputSchema, input);
|
|
61
|
+
return parsed;
|
|
62
|
+
}
|
|
64
63
|
function getJsonServerHandler(handler, inputSchema) {
|
|
65
64
|
return async (unparsedInput, context) => {
|
|
66
65
|
if (unparsedInput instanceof FormData) {
|
|
@@ -70,72 +69,13 @@ function getJsonServerHandler(handler, inputSchema) {
|
|
|
70
69
|
});
|
|
71
70
|
}
|
|
72
71
|
if (!inputSchema) return await handler(unparsedInput, context);
|
|
73
|
-
const parsed = await
|
|
72
|
+
const parsed = await z.safeParseAsync(inputSchema, unparsedInput);
|
|
74
73
|
if (!parsed.success) {
|
|
75
74
|
throw new ActionInputError(parsed.error.issues);
|
|
76
75
|
}
|
|
77
76
|
return await handler(parsed.data, context);
|
|
78
77
|
};
|
|
79
78
|
}
|
|
80
|
-
function formDataToObject(formData, schema) {
|
|
81
|
-
const obj = schema._def.unknownKeys === "passthrough" ? Object.fromEntries(formData.entries()) : {};
|
|
82
|
-
for (const [key, baseValidator] of Object.entries(schema.shape)) {
|
|
83
|
-
let validator = baseValidator;
|
|
84
|
-
while (validator instanceof z.ZodOptional || validator instanceof z.ZodNullable || validator instanceof z.ZodDefault) {
|
|
85
|
-
if (validator instanceof z.ZodDefault && !formData.has(key)) {
|
|
86
|
-
obj[key] = validator._def.defaultValue();
|
|
87
|
-
}
|
|
88
|
-
validator = validator._def.innerType;
|
|
89
|
-
}
|
|
90
|
-
if (!formData.has(key) && key in obj) {
|
|
91
|
-
continue;
|
|
92
|
-
} else if (validator instanceof z.ZodBoolean) {
|
|
93
|
-
const val = formData.get(key);
|
|
94
|
-
obj[key] = val === "true" ? true : val === "false" ? false : formData.has(key);
|
|
95
|
-
} else if (validator instanceof z.ZodArray) {
|
|
96
|
-
obj[key] = handleFormDataGetAll(key, formData, validator);
|
|
97
|
-
} else {
|
|
98
|
-
obj[key] = handleFormDataGet(key, formData, validator, baseValidator);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return obj;
|
|
102
|
-
}
|
|
103
|
-
function handleFormDataGetAll(key, formData, validator) {
|
|
104
|
-
const entries = Array.from(formData.getAll(key));
|
|
105
|
-
const elementValidator = validator._def.type;
|
|
106
|
-
if (elementValidator instanceof z.ZodNumber) {
|
|
107
|
-
return entries.map(Number);
|
|
108
|
-
} else if (elementValidator instanceof z.ZodBoolean) {
|
|
109
|
-
return entries.map(Boolean);
|
|
110
|
-
}
|
|
111
|
-
return entries;
|
|
112
|
-
}
|
|
113
|
-
function handleFormDataGet(key, formData, validator, baseValidator) {
|
|
114
|
-
const value = formData.get(key);
|
|
115
|
-
if (!value) {
|
|
116
|
-
return baseValidator instanceof z.ZodOptional ? void 0 : null;
|
|
117
|
-
}
|
|
118
|
-
return validator instanceof z.ZodNumber ? Number(value) : value;
|
|
119
|
-
}
|
|
120
|
-
function unwrapBaseObjectSchema(schema, unparsedInput) {
|
|
121
|
-
while (schema instanceof z.ZodEffects || schema instanceof z.ZodPipeline) {
|
|
122
|
-
if (schema instanceof z.ZodEffects) {
|
|
123
|
-
schema = schema._def.schema;
|
|
124
|
-
}
|
|
125
|
-
if (schema instanceof z.ZodPipeline) {
|
|
126
|
-
schema = schema._def.in;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (schema instanceof z.ZodDiscriminatedUnion) {
|
|
130
|
-
const typeKey = schema._def.discriminator;
|
|
131
|
-
const typeValue = unparsedInput.get(typeKey);
|
|
132
|
-
if (typeof typeValue !== "string") return schema;
|
|
133
|
-
const objSchema = schema._def.optionsMap.get(typeValue);
|
|
134
|
-
if (!objSchema) return schema;
|
|
135
|
-
return objSchema;
|
|
136
|
-
}
|
|
137
|
-
return schema;
|
|
138
|
-
}
|
|
139
79
|
function getActionContext(context) {
|
|
140
80
|
const callerInfo = getCallerInfo(context);
|
|
141
81
|
const actionResultAlreadySet = Boolean(context.locals._actionPayload);
|
|
@@ -145,7 +85,7 @@ function getActionContext(context) {
|
|
|
145
85
|
calledFrom: callerInfo.from,
|
|
146
86
|
name: callerInfo.name,
|
|
147
87
|
handler: async () => {
|
|
148
|
-
const pipeline = Reflect.get(context,
|
|
88
|
+
const pipeline = Reflect.get(context, pipelineSymbol);
|
|
149
89
|
const callerInfoName = shouldAppendForwardSlash(
|
|
150
90
|
pipeline.manifest.trailingSlash,
|
|
151
91
|
pipeline.manifest.buildFormat
|
|
@@ -218,8 +158,148 @@ async function parseRequestBody(request) {
|
|
|
218
158
|
}
|
|
219
159
|
throw new TypeError("Unsupported content type");
|
|
220
160
|
}
|
|
161
|
+
const ACTION_API_CONTEXT_SYMBOL = Symbol.for("astro.actionAPIContext");
|
|
162
|
+
const formContentTypes = ["application/x-www-form-urlencoded", "multipart/form-data"];
|
|
163
|
+
function hasContentType(contentType, expected) {
|
|
164
|
+
const type = contentType.split(";")[0].toLowerCase();
|
|
165
|
+
return expected.some((t) => type === t);
|
|
166
|
+
}
|
|
167
|
+
function isActionAPIContext(ctx) {
|
|
168
|
+
const symbol = Reflect.get(ctx, ACTION_API_CONTEXT_SYMBOL);
|
|
169
|
+
return symbol === true;
|
|
170
|
+
}
|
|
171
|
+
function formDataToObject(formData, schema) {
|
|
172
|
+
const obj = schema._zod.def.catchall ? Object.fromEntries(formData.entries()) : {};
|
|
173
|
+
for (const [key, baseValidator] of Object.entries(schema._zod.def.shape)) {
|
|
174
|
+
let validator = baseValidator;
|
|
175
|
+
while (validator instanceof z.$ZodOptional || validator instanceof z.$ZodNullable || validator instanceof z.$ZodDefault) {
|
|
176
|
+
if (validator instanceof z.$ZodDefault && !formData.has(key)) {
|
|
177
|
+
obj[key] = validator._zod.def.defaultValue instanceof Function ? validator._zod.def.defaultValue() : validator._zod.def.defaultValue;
|
|
178
|
+
}
|
|
179
|
+
validator = validator._zod.def.innerType;
|
|
180
|
+
}
|
|
181
|
+
if (!formData.has(key) && key in obj) {
|
|
182
|
+
continue;
|
|
183
|
+
} else if (validator instanceof z.$ZodBoolean) {
|
|
184
|
+
const val = formData.get(key);
|
|
185
|
+
obj[key] = val === "true" ? true : val === "false" ? false : formData.has(key);
|
|
186
|
+
} else if (validator instanceof z.$ZodArray) {
|
|
187
|
+
obj[key] = handleFormDataGetAll(key, formData, validator);
|
|
188
|
+
} else {
|
|
189
|
+
obj[key] = handleFormDataGet(key, formData, validator, baseValidator);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return obj;
|
|
193
|
+
}
|
|
194
|
+
function handleFormDataGetAll(key, formData, validator) {
|
|
195
|
+
const entries = Array.from(formData.getAll(key));
|
|
196
|
+
const elementValidator = validator._zod.def.element;
|
|
197
|
+
if (elementValidator instanceof z.$ZodNumber) {
|
|
198
|
+
return entries.map(Number);
|
|
199
|
+
} else if (elementValidator instanceof z.$ZodBoolean) {
|
|
200
|
+
return entries.map(Boolean);
|
|
201
|
+
}
|
|
202
|
+
return entries;
|
|
203
|
+
}
|
|
204
|
+
function handleFormDataGet(key, formData, validator, baseValidator) {
|
|
205
|
+
const value = formData.get(key);
|
|
206
|
+
if (!value) {
|
|
207
|
+
return baseValidator instanceof z.$ZodOptional ? void 0 : null;
|
|
208
|
+
}
|
|
209
|
+
return validator instanceof z.$ZodNumber ? Number(value) : value;
|
|
210
|
+
}
|
|
211
|
+
function unwrapBaseZ4ObjectSchema(schema, unparsedInput) {
|
|
212
|
+
if (schema instanceof z.$ZodPipe) {
|
|
213
|
+
return unwrapBaseZ4ObjectSchema(schema._zod.def.in, unparsedInput);
|
|
214
|
+
}
|
|
215
|
+
if (schema instanceof z.$ZodDiscriminatedUnion) {
|
|
216
|
+
const typeKey = schema._zod.def.discriminator;
|
|
217
|
+
const typeValue = unparsedInput.get(typeKey);
|
|
218
|
+
if (typeof typeValue !== "string") return schema;
|
|
219
|
+
const objSchema = schema._zod.def.options.find(
|
|
220
|
+
(option) => option.def.shape[typeKey].values.has(typeValue)
|
|
221
|
+
);
|
|
222
|
+
if (!objSchema) return schema;
|
|
223
|
+
return objSchema;
|
|
224
|
+
}
|
|
225
|
+
return schema;
|
|
226
|
+
}
|
|
227
|
+
async function callSafely(handler) {
|
|
228
|
+
try {
|
|
229
|
+
const data = await handler();
|
|
230
|
+
return { data, error: void 0 };
|
|
231
|
+
} catch (e) {
|
|
232
|
+
if (e instanceof ActionError) {
|
|
233
|
+
return { data: void 0, error: e };
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
data: void 0,
|
|
237
|
+
error: new ActionError({
|
|
238
|
+
message: e instanceof Error ? e.message : "Unknown error",
|
|
239
|
+
code: "INTERNAL_SERVER_ERROR"
|
|
240
|
+
})
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function serializeActionResult(res) {
|
|
245
|
+
if (res.error) {
|
|
246
|
+
if (import.meta.env?.DEV) {
|
|
247
|
+
actionResultErrorStack.set(res.error.stack);
|
|
248
|
+
}
|
|
249
|
+
let body2;
|
|
250
|
+
if (res.error instanceof ActionInputError) {
|
|
251
|
+
body2 = {
|
|
252
|
+
type: res.error.type,
|
|
253
|
+
issues: res.error.issues,
|
|
254
|
+
fields: res.error.fields
|
|
255
|
+
};
|
|
256
|
+
} else {
|
|
257
|
+
body2 = {
|
|
258
|
+
...res.error,
|
|
259
|
+
message: res.error.message
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
type: "error",
|
|
264
|
+
status: res.error.status,
|
|
265
|
+
contentType: "application/json",
|
|
266
|
+
body: JSON.stringify(body2)
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
if (res.data === void 0) {
|
|
270
|
+
return {
|
|
271
|
+
type: "empty",
|
|
272
|
+
status: 204
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
let body;
|
|
276
|
+
try {
|
|
277
|
+
body = devalueStringify(res.data, {
|
|
278
|
+
// Add support for URL objects
|
|
279
|
+
URL: (value) => value instanceof URL && value.href
|
|
280
|
+
});
|
|
281
|
+
} catch (e) {
|
|
282
|
+
let hint = ActionsReturnedInvalidDataError.hint;
|
|
283
|
+
if (res.data instanceof Response) {
|
|
284
|
+
hint = REDIRECT_STATUS_CODES.includes(res.data.status) ? "If you need to redirect when the action succeeds, trigger a redirect where the action is called. See the Actions guide for server and client redirect examples: https://docs.astro.build/en/guides/actions." : "If you need to return a Response object, try using a server endpoint instead. See https://docs.astro.build/en/guides/endpoints/#server-endpoints-api-routes";
|
|
285
|
+
}
|
|
286
|
+
throw new AstroError({
|
|
287
|
+
...ActionsReturnedInvalidDataError,
|
|
288
|
+
message: ActionsReturnedInvalidDataError.message(String(e)),
|
|
289
|
+
hint
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
type: "data",
|
|
294
|
+
status: 200,
|
|
295
|
+
contentType: "application/json+devalue",
|
|
296
|
+
body
|
|
297
|
+
};
|
|
298
|
+
}
|
|
221
299
|
export {
|
|
300
|
+
ACTION_API_CONTEXT_SYMBOL,
|
|
222
301
|
defineAction,
|
|
223
302
|
formDataToObject,
|
|
224
|
-
getActionContext
|
|
303
|
+
getActionContext,
|
|
304
|
+
serializeActionResult
|
|
225
305
|
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type * as z from 'zod/v4/core';
|
|
2
|
+
import type { APIContext } from '../../types/public/index.js';
|
|
3
|
+
import type { ActionError, codeToStatusMap } from './client.js';
|
|
4
|
+
export type ActionErrorCode = keyof typeof codeToStatusMap;
|
|
5
|
+
export type ActionAccept = 'form' | 'json';
|
|
6
|
+
export type ActionHandler<TInputSchema, TOutput> = TInputSchema extends z.$ZodType ? (input: z.infer<TInputSchema>, context: ActionAPIContext) => MaybePromise<TOutput> : (input: any, context: ActionAPIContext) => MaybePromise<TOutput>;
|
|
7
|
+
export type ActionReturnType<T extends ActionHandler<any, any>> = Awaited<ReturnType<T>>;
|
|
8
|
+
type InferKey = '__internalInfer';
|
|
9
|
+
/**
|
|
10
|
+
* Infers the type of an action's input based on its Zod schema
|
|
11
|
+
*
|
|
12
|
+
* @see https://docs.astro.build/en/reference/modules/astro-actions/#actioninputschema
|
|
13
|
+
*/
|
|
14
|
+
export type ActionInputSchema<T extends ActionClient<any, any, any>> = T extends {
|
|
15
|
+
[key in InferKey]: any;
|
|
16
|
+
} ? T[InferKey] : never;
|
|
17
|
+
export type ActionClient<TOutput, TAccept extends ActionAccept | undefined, TInputSchema extends z.$ZodType | undefined> = TInputSchema extends z.$ZodType ? ((input: TAccept extends 'form' ? FormData : z.input<TInputSchema>) => Promise<SafeResult<z.input<TInputSchema> extends ErrorInferenceObject ? z.input<TInputSchema> : ErrorInferenceObject, Awaited<TOutput>>>) & {
|
|
18
|
+
queryString: string;
|
|
19
|
+
orThrow: (input: TAccept extends 'form' ? FormData : z.input<TInputSchema>) => Promise<Awaited<TOutput>>;
|
|
20
|
+
} & {
|
|
21
|
+
[key in InferKey]: TInputSchema;
|
|
22
|
+
} : ((input?: any) => Promise<SafeResult<never, Awaited<TOutput>>>) & {
|
|
23
|
+
orThrow: (input?: any) => Promise<Awaited<TOutput>>;
|
|
24
|
+
};
|
|
25
|
+
export type SafeResult<TInput extends ErrorInferenceObject, TOutput> = {
|
|
26
|
+
data: TOutput;
|
|
27
|
+
error: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
data: undefined;
|
|
30
|
+
error: ActionError<TInput>;
|
|
31
|
+
};
|
|
32
|
+
export type SerializedActionResult = {
|
|
33
|
+
type: 'data';
|
|
34
|
+
contentType: 'application/json+devalue';
|
|
35
|
+
status: 200;
|
|
36
|
+
body: string;
|
|
37
|
+
} | {
|
|
38
|
+
type: 'error';
|
|
39
|
+
contentType: 'application/json';
|
|
40
|
+
status: number;
|
|
41
|
+
body: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'empty';
|
|
44
|
+
status: 204;
|
|
45
|
+
};
|
|
46
|
+
export interface ActionsLocals {
|
|
47
|
+
_actionPayload: {
|
|
48
|
+
actionResult: SerializedActionResult;
|
|
49
|
+
actionName: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export type ActionAPIContext = Pick<APIContext, 'request' | 'url' | 'isPrerendered' | 'locals' | 'clientAddress' | 'cookies' | 'currentLocale' | 'generator' | 'routePattern' | 'site' | 'params' | 'preferredLocale' | 'preferredLocaleList' | 'originPathname' | 'session' | 'csp'>;
|
|
53
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
54
|
+
/**
|
|
55
|
+
* Used to preserve the input schema type in the error object.
|
|
56
|
+
* This allows for type inference on the `fields` property
|
|
57
|
+
* when type narrowed to an `ActionInputError`.
|
|
58
|
+
*
|
|
59
|
+
* Example: Action has an input schema of `{ name: z.string() }`.
|
|
60
|
+
* When calling the action and checking `isInputError(result.error)`,
|
|
61
|
+
* `result.error.fields` will be typed with the `name` field.
|
|
62
|
+
*/
|
|
63
|
+
export type ErrorInferenceObject = Record<string, any>;
|
|
64
|
+
export {};
|
package/dist/actions/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type fsMod from 'node:fs';
|
|
2
2
|
import type { APIContext } from '../types/public/context.js';
|
|
3
|
-
import {
|
|
4
|
-
export declare function hasActionPayload(locals: APIContext['locals']): locals is
|
|
3
|
+
import type { ActionAPIContext, ActionsLocals } from './runtime/types.js';
|
|
4
|
+
export declare function hasActionPayload(locals: APIContext['locals']): locals is ActionsLocals;
|
|
5
5
|
export declare function createGetActionResult(locals: APIContext['locals']): APIContext['getActionResult'];
|
|
6
6
|
export declare function createCallAction(context: ActionAPIContext): APIContext['callAction'];
|
|
7
7
|
/**
|
package/dist/actions/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as eslexer from "es-module-lexer";
|
|
2
|
-
import { deserializeActionResult, getActionQueryString } from "./runtime/
|
|
3
|
-
import { ACTION_API_CONTEXT_SYMBOL } from "./runtime/
|
|
2
|
+
import { deserializeActionResult, getActionQueryString } from "./runtime/client.js";
|
|
3
|
+
import { ACTION_API_CONTEXT_SYMBOL } from "./runtime/server.js";
|
|
4
4
|
function hasActionPayload(locals) {
|
|
5
5
|
return "_actionPayload" in locals;
|
|
6
6
|
}
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import { addRollupInput } from "../core/build/add-rollup-input.js";
|
|
2
1
|
import { shouldAppendForwardSlash } from "../core/build/util.js";
|
|
3
2
|
import { getServerOutputDirectory } from "../prerender/utils.js";
|
|
4
3
|
import {
|
|
5
|
-
|
|
4
|
+
ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID,
|
|
5
|
+
ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID,
|
|
6
6
|
OPTIONS_VIRTUAL_MODULE_ID,
|
|
7
|
-
RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID,
|
|
8
7
|
RESOLVED_NOOP_ENTRYPOINT_VIRTUAL_MODULE_ID,
|
|
9
8
|
RESOLVED_OPTIONS_VIRTUAL_MODULE_ID,
|
|
10
|
-
RESOLVED_RUNTIME_VIRTUAL_MODULE_ID,
|
|
11
9
|
RESOLVED_VIRTUAL_MODULE_ID,
|
|
12
|
-
RUNTIME_VIRTUAL_MODULE_ID,
|
|
13
10
|
VIRTUAL_MODULE_ID
|
|
14
11
|
} from "./consts.js";
|
|
15
12
|
import { isActionsFilePresent } from "./utils.js";
|
|
13
|
+
import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../core/constants.js";
|
|
16
14
|
function vitePluginActionsBuild(opts, internals) {
|
|
17
15
|
return {
|
|
18
16
|
name: "@astro/plugin-actions-build",
|
|
19
|
-
|
|
20
|
-
return
|
|
17
|
+
applyToEnvironment(environment) {
|
|
18
|
+
return environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr || environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.prerender || environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.astro;
|
|
21
19
|
},
|
|
22
20
|
writeBundle(_, bundle) {
|
|
23
21
|
for (const [chunkName, chunk] of Object.entries(bundle)) {
|
|
24
|
-
if (chunk.type !== "asset" && chunk.facadeModuleId ===
|
|
22
|
+
if (chunk.type !== "asset" && chunk.facadeModuleId === ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID) {
|
|
25
23
|
const outputDirectory = getServerOutputDirectory(opts.settings);
|
|
26
24
|
internals.astroActionsEntryPoint = new URL(chunkName, outputDirectory);
|
|
27
25
|
}
|
|
@@ -41,13 +39,10 @@ function vitePluginActions({
|
|
|
41
39
|
if (id === VIRTUAL_MODULE_ID) {
|
|
42
40
|
return RESOLVED_VIRTUAL_MODULE_ID;
|
|
43
41
|
}
|
|
44
|
-
if (id === RUNTIME_VIRTUAL_MODULE_ID) {
|
|
45
|
-
return RESOLVED_RUNTIME_VIRTUAL_MODULE_ID;
|
|
46
|
-
}
|
|
47
42
|
if (id === OPTIONS_VIRTUAL_MODULE_ID) {
|
|
48
43
|
return RESOLVED_OPTIONS_VIRTUAL_MODULE_ID;
|
|
49
44
|
}
|
|
50
|
-
if (id ===
|
|
45
|
+
if (id === ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID) {
|
|
51
46
|
const resolvedModule = await this.resolve(
|
|
52
47
|
`${decodeURI(new URL("actions", settings.config.srcDir).pathname)}`
|
|
53
48
|
);
|
|
@@ -55,7 +50,7 @@ function vitePluginActions({
|
|
|
55
50
|
return RESOLVED_NOOP_ENTRYPOINT_VIRTUAL_MODULE_ID;
|
|
56
51
|
}
|
|
57
52
|
resolvedActionsId = resolvedModule.id;
|
|
58
|
-
return
|
|
53
|
+
return ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID;
|
|
59
54
|
}
|
|
60
55
|
},
|
|
61
56
|
async configureServer(server) {
|
|
@@ -69,21 +64,23 @@ function vitePluginActions({
|
|
|
69
64
|
server.watcher.on("add", watcherCallback);
|
|
70
65
|
server.watcher.on("change", watcherCallback);
|
|
71
66
|
},
|
|
72
|
-
async load(id
|
|
67
|
+
async load(id) {
|
|
73
68
|
if (id === RESOLVED_VIRTUAL_MODULE_ID) {
|
|
74
|
-
|
|
69
|
+
if (this.environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.client) {
|
|
70
|
+
return {
|
|
71
|
+
code: `export * from 'astro/actions/runtime/entrypoints/client.js';`
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
code: `export * from 'astro/actions/runtime/entrypoints/server.js';`
|
|
76
|
+
};
|
|
75
77
|
}
|
|
76
78
|
if (id === RESOLVED_NOOP_ENTRYPOINT_VIRTUAL_MODULE_ID) {
|
|
77
79
|
return { code: "export const server = {}" };
|
|
78
80
|
}
|
|
79
|
-
if (id ===
|
|
81
|
+
if (id === ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID) {
|
|
80
82
|
return { code: `export { server } from ${JSON.stringify(resolvedActionsId)};` };
|
|
81
83
|
}
|
|
82
|
-
if (id === RESOLVED_RUNTIME_VIRTUAL_MODULE_ID) {
|
|
83
|
-
return {
|
|
84
|
-
code: `export * from 'astro/actions/runtime/${opts?.ssr ? "server" : "client"}.js';`
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
84
|
if (id === RESOLVED_OPTIONS_VIRTUAL_MODULE_ID) {
|
|
88
85
|
return {
|
|
89
86
|
code: `
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BuildApp } from '../../core/build/app.js';
|
|
2
2
|
import type { Logger } from '../../core/logger/core.js';
|
|
3
3
|
import type { MapValue } from '../../type-utils.js';
|
|
4
4
|
import type { AstroConfig } from '../../types/public/config.js';
|
|
@@ -17,7 +17,7 @@ type AssetEnv = {
|
|
|
17
17
|
imageConfig: AstroConfig['image'];
|
|
18
18
|
assetsFolder: AstroConfig['build']['assets'];
|
|
19
19
|
};
|
|
20
|
-
export declare function prepareAssetsGenerationEnv(
|
|
20
|
+
export declare function prepareAssetsGenerationEnv(app: BuildApp, totalCount: number): Promise<AssetEnv>;
|
|
21
21
|
export declare function generateImagesForPath(originalFilePath: string, transformsAndPath: MapValue<AssetsGlobalStaticImagesList>, env: AssetEnv): Promise<void>;
|
|
22
22
|
export declare function getStaticImageList(): AssetsGlobalStaticImagesList;
|
|
23
23
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs, { readFileSync } from "node:fs";
|
|
2
2
|
import { basename } from "node:path/posix";
|
|
3
|
-
import colors from "
|
|
3
|
+
import colors from "piccolore";
|
|
4
4
|
import { getOutDirWithinCwd } from "../../core/build/common.js";
|
|
5
5
|
import { getTimeStat } from "../../core/build/util.js";
|
|
6
6
|
import { AstroError } from "../../core/errors/errors.js";
|
|
@@ -9,10 +9,12 @@ import { isRemotePath, removeLeadingForwardSlash } from "../../core/path.js";
|
|
|
9
9
|
import { getConfiguredImageService } from "../internal.js";
|
|
10
10
|
import { isESMImportedImage } from "../utils/imageKind.js";
|
|
11
11
|
import { loadRemoteImage, revalidateRemoteImage } from "./remote.js";
|
|
12
|
-
async function prepareAssetsGenerationEnv(
|
|
13
|
-
const
|
|
12
|
+
async function prepareAssetsGenerationEnv(app, totalCount) {
|
|
13
|
+
const settings = app.getSettings();
|
|
14
|
+
const logger = app.logger;
|
|
15
|
+
const manifest = app.getManifest();
|
|
14
16
|
let useCache = true;
|
|
15
|
-
const assetsCacheDir = new URL("assets/",
|
|
17
|
+
const assetsCacheDir = new URL("assets/", app.manifest.cacheDir);
|
|
16
18
|
const count = { total: totalCount, current: 1 };
|
|
17
19
|
try {
|
|
18
20
|
await fs.promises.mkdir(assetsCacheDir, { recursive: true });
|
|
@@ -26,11 +28,11 @@ async function prepareAssetsGenerationEnv(pipeline, totalCount) {
|
|
|
26
28
|
const isServerOutput = settings.buildOutput === "server";
|
|
27
29
|
let serverRoot, clientRoot;
|
|
28
30
|
if (isServerOutput) {
|
|
29
|
-
serverRoot =
|
|
30
|
-
clientRoot =
|
|
31
|
+
serverRoot = manifest.buildServerDir;
|
|
32
|
+
clientRoot = manifest.buildClientDir;
|
|
31
33
|
} else {
|
|
32
|
-
serverRoot = getOutDirWithinCwd(
|
|
33
|
-
clientRoot =
|
|
34
|
+
serverRoot = getOutDirWithinCwd(manifest.outDir);
|
|
35
|
+
clientRoot = manifest.outDir;
|
|
34
36
|
}
|
|
35
37
|
return {
|
|
36
38
|
logger,
|
|
@@ -40,8 +42,8 @@ async function prepareAssetsGenerationEnv(pipeline, totalCount) {
|
|
|
40
42
|
assetsCacheDir,
|
|
41
43
|
serverRoot,
|
|
42
44
|
clientRoot,
|
|
43
|
-
imageConfig: config.image,
|
|
44
|
-
assetsFolder:
|
|
45
|
+
imageConfig: settings.config.image,
|
|
46
|
+
assetsFolder: manifest.assetsDir
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
49
|
function getFullImagePath(originalFilePath, env) {
|
|
@@ -28,11 +28,11 @@ function getImageEndpointData(settings, mode, cwd) {
|
|
|
28
28
|
segments,
|
|
29
29
|
params: [],
|
|
30
30
|
component: resolveInjectedRoute(endpointEntrypoint, settings.config.root, cwd).component,
|
|
31
|
-
generate: () => "",
|
|
32
31
|
pathname: settings.config.image.endpoint.route,
|
|
33
32
|
prerender: false,
|
|
34
33
|
fallbackRoutes: [],
|
|
35
|
-
origin: "internal"
|
|
34
|
+
origin: "internal",
|
|
35
|
+
distURL: []
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
export {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { root } from "astro:config/server";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
import os from "node:os";
|
|
4
3
|
import { fileURLToPath } from "node:url";
|
|
5
4
|
import { isParentDirectory } from "@astrojs/internal-helpers/path";
|
|
6
5
|
import { handleImageRequest, loadRemoteImage } from "./shared.js";
|
|
7
|
-
function replaceFileSystemReferences(src) {
|
|
8
|
-
return os.platform().includes("win32") ? src.replace(/^\/@fs\//, "") : src.replace(/^\/@fs/, "");
|
|
9
|
-
}
|
|
10
6
|
async function loadLocalImage(src, url) {
|
|
11
7
|
if (src.startsWith("/@fs/")) {
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
try {
|
|
9
|
+
const res = await fetch(new URL(src, url));
|
|
10
|
+
if (!res.ok) {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
13
|
+
return Buffer.from(await res.arrayBuffer());
|
|
14
|
+
} catch {
|
|
14
15
|
return void 0;
|
|
15
16
|
}
|
|
16
17
|
}
|