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
package/astro-jsx.d.ts
CHANGED
|
@@ -672,6 +672,17 @@ declare namespace astroHTML.JSX {
|
|
|
672
672
|
value?: string | string[] | number | undefined | null;
|
|
673
673
|
popovertarget?: string | undefined | null;
|
|
674
674
|
popovertargetaction?: 'hide' | 'show' | 'toggle' | undefined | null;
|
|
675
|
+
command?:
|
|
676
|
+
| 'show-modal'
|
|
677
|
+
| 'close'
|
|
678
|
+
| 'request-close'
|
|
679
|
+
| 'show-popover'
|
|
680
|
+
| 'hide-popover'
|
|
681
|
+
| 'toggle-popover'
|
|
682
|
+
| (string & {})
|
|
683
|
+
| undefined
|
|
684
|
+
| null;
|
|
685
|
+
commandfor?: string | undefined | null;
|
|
675
686
|
}
|
|
676
687
|
|
|
677
688
|
interface CanvasHTMLAttributes extends HTMLAttributes {
|
package/client.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="vite/types/import-meta.d.ts" />
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
/// <reference path="./types/actions.d.ts" />
|
|
4
|
+
/// <reference path="./types/content.d.ts" />
|
|
4
5
|
/// <reference path="./types/env.d.ts" />
|
|
5
6
|
/// <reference path="./types/fonts.d.ts" />
|
|
7
|
+
/// <reference path="./types/transitions.d.ts" />
|
|
6
8
|
|
|
7
9
|
interface ImportMetaEnv {
|
|
8
10
|
// TODO: remove in Astro 7
|
|
@@ -119,46 +121,6 @@ declare module '*.svg' {
|
|
|
119
121
|
export default Component;
|
|
120
122
|
}
|
|
121
123
|
|
|
122
|
-
declare module 'astro:transitions' {
|
|
123
|
-
type TransitionModule = typeof import('./dist/virtual-modules/transitions.js');
|
|
124
|
-
export const slide: TransitionModule['slide'];
|
|
125
|
-
export const fade: TransitionModule['fade'];
|
|
126
|
-
export const createAnimationScope: TransitionModule['createAnimationScope'];
|
|
127
|
-
|
|
128
|
-
type ClientRouterModule = typeof import('./components/ClientRouter.astro');
|
|
129
|
-
export const ClientRouter: ClientRouterModule['default'];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
declare module 'astro:transitions/client' {
|
|
133
|
-
type TransitionRouterModule = typeof import('./dist/virtual-modules/transitions-router.js');
|
|
134
|
-
export const navigate: TransitionRouterModule['navigate'];
|
|
135
|
-
export const supportsViewTransitions: TransitionRouterModule['supportsViewTransitions'];
|
|
136
|
-
export const getFallback: TransitionRouterModule['getFallback'];
|
|
137
|
-
export const transitionEnabledOnThisPage: TransitionRouterModule['transitionEnabledOnThisPage'];
|
|
138
|
-
|
|
139
|
-
export type Fallback = import('./dist/virtual-modules/transitions-types.js').Fallback;
|
|
140
|
-
export type Direction = import('./dist/virtual-modules/transitions-types.ts').Direction;
|
|
141
|
-
// biome-ignore format: bug
|
|
142
|
-
export type NavigationTypeString = import('./dist/virtual-modules/transitions-types.js').NavigationTypeString;
|
|
143
|
-
export type Options = import('./dist/virtual-modules/transitions-types.js').Options;
|
|
144
|
-
|
|
145
|
-
type EventModule = typeof import('./dist/virtual-modules/transitions-events.js');
|
|
146
|
-
export const TRANSITION_BEFORE_PREPARATION: EventModule['TRANSITION_BEFORE_PREPARATION'];
|
|
147
|
-
export const TRANSITION_AFTER_PREPARATION: EventModule['TRANSITION_AFTER_PREPARATION'];
|
|
148
|
-
export const TRANSITION_BEFORE_SWAP: EventModule['TRANSITION_BEFORE_SWAP'];
|
|
149
|
-
export const TRANSITION_AFTER_SWAP: EventModule['TRANSITION_AFTER_SWAP'];
|
|
150
|
-
export const TRANSITION_PAGE_LOAD: EventModule['TRANSITION_PAGE_LOAD'];
|
|
151
|
-
// biome-ignore format: bug
|
|
152
|
-
export type TransitionBeforePreparationEvent = import('./dist/virtual-modules/transitions-events.js').TransitionBeforePreparationEvent;
|
|
153
|
-
// biome-ignore format: bug
|
|
154
|
-
export type TransitionBeforeSwapEvent = import('./dist/virtual-modules/transitions-events.js').TransitionBeforeSwapEvent;
|
|
155
|
-
export const isTransitionBeforePreparationEvent: EventModule['isTransitionBeforePreparationEvent'];
|
|
156
|
-
export const isTransitionBeforeSwapEvent: EventModule['isTransitionBeforeSwapEvent'];
|
|
157
|
-
// biome-ignore format: bug
|
|
158
|
-
type TransitionSwapFunctionModule = typeof import('./dist/virtual-modules/transitions-swap-functions.js');
|
|
159
|
-
export const swapFunctions: TransitionSwapFunctionModule['swapFunctions'];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
124
|
declare module 'astro:prefetch' {
|
|
163
125
|
export { prefetch, PrefetchOptions } from 'astro/virtual-modules/prefetch.js';
|
|
164
126
|
}
|
|
@@ -193,8 +155,22 @@ declare module 'astro:components' {
|
|
|
193
155
|
export * from 'astro/components';
|
|
194
156
|
}
|
|
195
157
|
|
|
158
|
+
// TODO: remove in Astro 7
|
|
159
|
+
/**
|
|
160
|
+
* @deprecated
|
|
161
|
+
* `import { z } from 'astro:schema'` is deprecated and will be removed
|
|
162
|
+
* in Astro 7. Use `import { z } from 'astro/zod'` instead.
|
|
163
|
+
*/
|
|
196
164
|
declare module 'astro:schema' {
|
|
197
165
|
export * from 'astro/zod';
|
|
166
|
+
import zod from 'astro/zod';
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @deprecated
|
|
170
|
+
* `import { z } from 'astro:schema'` is deprecated and will be removed
|
|
171
|
+
* in Astro 7. Use `import { z } from 'astro/zod'` instead.
|
|
172
|
+
*/
|
|
173
|
+
export const z = zod.z;
|
|
198
174
|
}
|
|
199
175
|
|
|
200
176
|
type MD = import('./dist/types/public/content.js').MarkdownInstance<Record<string, any>>;
|
package/components/Code.astro
CHANGED
|
@@ -3,8 +3,8 @@ import type { ThemePresets } from '@astrojs/markdown-remark';
|
|
|
3
3
|
import type { ShikiTransformer, ThemeRegistration, ThemeRegistrationRaw } from 'shiki';
|
|
4
4
|
import { bundledLanguages } from 'shiki/langs';
|
|
5
5
|
import { getCachedHighlighter } from '../dist/core/shiki.js';
|
|
6
|
-
import type { CodeLanguage } from '../dist/types/public';
|
|
7
|
-
import type { HTMLAttributes } from '../types';
|
|
6
|
+
import type { CodeLanguage } from '../dist/types/public/common.js';
|
|
7
|
+
import type { HTMLAttributes } from '../types.js';
|
|
8
8
|
|
|
9
9
|
interface Props extends Omit<HTMLAttributes<'pre'>, 'lang'> {
|
|
10
10
|
/** The code to highlight. Required. */
|
package/components/Image.astro
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getImage, imageConfig, type LocalImageProps, type RemoteImageProps } from 'astro:assets';
|
|
3
|
-
import type { UnresolvedImageTransform } from '../dist/assets/types';
|
|
3
|
+
import type { UnresolvedImageTransform } from '../dist/assets/types.js';
|
|
4
4
|
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
|
|
5
|
-
import type { HTMLAttributes } from '../types';
|
|
5
|
+
import type { HTMLAttributes } from '../types.js';
|
|
6
6
|
|
|
7
7
|
// The TypeScript diagnostic for JSX props uses the last member of the union to suggest props, so it would be better for
|
|
8
8
|
// LocalImageProps to be last. Unfortunately, when we do this the error messages that remote images get are complete nonsense
|
package/components/Picture.astro
CHANGED
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
ImageOutputFormat,
|
|
9
9
|
UnresolvedImageTransform,
|
|
10
10
|
} from '../dist/types/public/index.js';
|
|
11
|
-
import type { HTMLAttributes } from '../types';
|
|
11
|
+
import type { HTMLAttributes } from '../types.js';
|
|
12
12
|
|
|
13
13
|
export type Props = (LocalImageProps | RemoteImageProps) & {
|
|
14
14
|
formats?: ImageOutputFormat[];
|
package/dist/actions/consts.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
export declare const ACTIONS_TYPES_FILE = "actions.d.ts";
|
|
2
2
|
export declare const VIRTUAL_MODULE_ID = "astro:actions";
|
|
3
3
|
export declare const RESOLVED_VIRTUAL_MODULE_ID: string;
|
|
4
|
-
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const RESOLVED_RUNTIME_VIRTUAL_MODULE_ID: string;
|
|
7
|
-
export declare const ENTRYPOINT_VIRTUAL_MODULE_ID = "virtual:astro:actions/entrypoint";
|
|
8
|
-
export declare const RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID: string;
|
|
4
|
+
export declare const ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID = "virtual:astro:actions/entrypoint";
|
|
5
|
+
export declare const ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID: string;
|
|
9
6
|
/** Used to pass data from the config to the main virtual module */
|
|
10
7
|
export declare const OPTIONS_VIRTUAL_MODULE_ID = "virtual:astro:actions/options";
|
|
11
8
|
export declare const RESOLVED_OPTIONS_VIRTUAL_MODULE_ID: string;
|
package/dist/actions/consts.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
const ACTIONS_TYPES_FILE = "actions.d.ts";
|
|
2
2
|
const VIRTUAL_MODULE_ID = "astro:actions";
|
|
3
3
|
const RESOLVED_VIRTUAL_MODULE_ID = "\0" + VIRTUAL_MODULE_ID;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const ENTRYPOINT_VIRTUAL_MODULE_ID = "virtual:astro:actions/entrypoint";
|
|
7
|
-
const RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID = "\0" + ENTRYPOINT_VIRTUAL_MODULE_ID;
|
|
4
|
+
const ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID = "virtual:astro:actions/entrypoint";
|
|
5
|
+
const ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID = "\0" + ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID;
|
|
8
6
|
const OPTIONS_VIRTUAL_MODULE_ID = "virtual:astro:actions/options";
|
|
9
7
|
const RESOLVED_OPTIONS_VIRTUAL_MODULE_ID = "\0" + OPTIONS_VIRTUAL_MODULE_ID;
|
|
10
8
|
const RESOLVED_NOOP_ENTRYPOINT_VIRTUAL_MODULE_ID = "\0virtual:astro:actions/noop-entrypoint";
|
|
@@ -14,16 +12,14 @@ const ACTION_QUERY_PARAMS = {
|
|
|
14
12
|
};
|
|
15
13
|
const ACTION_RPC_ROUTE_PATTERN = "/_actions/[...path]";
|
|
16
14
|
export {
|
|
15
|
+
ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID,
|
|
16
|
+
ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID,
|
|
17
17
|
ACTIONS_TYPES_FILE,
|
|
18
18
|
ACTION_QUERY_PARAMS,
|
|
19
19
|
ACTION_RPC_ROUTE_PATTERN,
|
|
20
|
-
ENTRYPOINT_VIRTUAL_MODULE_ID,
|
|
21
20
|
OPTIONS_VIRTUAL_MODULE_ID,
|
|
22
|
-
RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID,
|
|
23
21
|
RESOLVED_NOOP_ENTRYPOINT_VIRTUAL_MODULE_ID,
|
|
24
22
|
RESOLVED_OPTIONS_VIRTUAL_MODULE_ID,
|
|
25
|
-
RESOLVED_RUNTIME_VIRTUAL_MODULE_ID,
|
|
26
23
|
RESOLVED_VIRTUAL_MODULE_ID,
|
|
27
|
-
RUNTIME_VIRTUAL_MODULE_ID,
|
|
28
24
|
VIRTUAL_MODULE_ID
|
|
29
25
|
};
|
|
@@ -12,7 +12,7 @@ function astroIntegrationActionsRouteHandler({
|
|
|
12
12
|
async "astro:config:setup"() {
|
|
13
13
|
settings.injectedRoutes.push({
|
|
14
14
|
pattern: ACTION_RPC_ROUTE_PATTERN,
|
|
15
|
-
entrypoint: "astro/actions/runtime/route.js",
|
|
15
|
+
entrypoint: "astro/actions/runtime/entrypoints/route.js",
|
|
16
16
|
prerender: false,
|
|
17
17
|
origin: "internal"
|
|
18
18
|
});
|
|
@@ -29,9 +29,7 @@ function astroIntegrationActionsRouteHandler({
|
|
|
29
29
|
settings.injectedTypes.push({
|
|
30
30
|
filename: ACTIONS_TYPES_FILE,
|
|
31
31
|
content: `declare module "astro:actions" {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export const actions: Actions;
|
|
32
|
+
export const actions: typeof import(${stringifiedActionsImport})["server"];
|
|
35
33
|
}`
|
|
36
34
|
});
|
|
37
35
|
}
|
|
@@ -1,3 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type * as z from 'zod/v4/core';
|
|
2
|
+
import type { ActionClient, ActionErrorCode, ErrorInferenceObject, SafeResult, SerializedActionResult } from './types.js';
|
|
3
|
+
import type { APIContext } from '../../types/public/context.js';
|
|
4
|
+
export declare const codeToStatusMap: {
|
|
5
|
+
BAD_REQUEST: number;
|
|
6
|
+
UNAUTHORIZED: number;
|
|
7
|
+
PAYMENT_REQUIRED: number;
|
|
8
|
+
FORBIDDEN: number;
|
|
9
|
+
NOT_FOUND: number;
|
|
10
|
+
METHOD_NOT_ALLOWED: number;
|
|
11
|
+
NOT_ACCEPTABLE: number;
|
|
12
|
+
PROXY_AUTHENTICATION_REQUIRED: number;
|
|
13
|
+
REQUEST_TIMEOUT: number;
|
|
14
|
+
CONFLICT: number;
|
|
15
|
+
GONE: number;
|
|
16
|
+
LENGTH_REQUIRED: number;
|
|
17
|
+
PRECONDITION_FAILED: number;
|
|
18
|
+
CONTENT_TOO_LARGE: number;
|
|
19
|
+
URI_TOO_LONG: number;
|
|
20
|
+
UNSUPPORTED_MEDIA_TYPE: number;
|
|
21
|
+
RANGE_NOT_SATISFIABLE: number;
|
|
22
|
+
EXPECTATION_FAILED: number;
|
|
23
|
+
MISDIRECTED_REQUEST: number;
|
|
24
|
+
UNPROCESSABLE_CONTENT: number;
|
|
25
|
+
LOCKED: number;
|
|
26
|
+
FAILED_DEPENDENCY: number;
|
|
27
|
+
TOO_EARLY: number;
|
|
28
|
+
UPGRADE_REQUIRED: number;
|
|
29
|
+
PRECONDITION_REQUIRED: number;
|
|
30
|
+
TOO_MANY_REQUESTS: number;
|
|
31
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE: number;
|
|
32
|
+
UNAVAILABLE_FOR_LEGAL_REASONS: number;
|
|
33
|
+
INTERNAL_SERVER_ERROR: number;
|
|
34
|
+
NOT_IMPLEMENTED: number;
|
|
35
|
+
BAD_GATEWAY: number;
|
|
36
|
+
SERVICE_UNAVAILABLE: number;
|
|
37
|
+
GATEWAY_TIMEOUT: number;
|
|
38
|
+
HTTP_VERSION_NOT_SUPPORTED: number;
|
|
39
|
+
VARIANT_ALSO_NEGOTIATES: number;
|
|
40
|
+
INSUFFICIENT_STORAGE: number;
|
|
41
|
+
LOOP_DETECTED: number;
|
|
42
|
+
NETWORK_AUTHENTICATION_REQUIRED: number;
|
|
43
|
+
};
|
|
44
|
+
export declare class ActionError<_T extends ErrorInferenceObject = ErrorInferenceObject> extends Error {
|
|
45
|
+
type: string;
|
|
46
|
+
code: ActionErrorCode;
|
|
47
|
+
status: number;
|
|
48
|
+
constructor(params: {
|
|
49
|
+
message?: string;
|
|
50
|
+
code: ActionErrorCode;
|
|
51
|
+
stack?: string;
|
|
52
|
+
});
|
|
53
|
+
static codeToStatus(code: ActionErrorCode): number;
|
|
54
|
+
static statusToCode(status: number): ActionErrorCode;
|
|
55
|
+
static fromJson(body: any): ActionError<ErrorInferenceObject>;
|
|
56
|
+
}
|
|
57
|
+
export declare function isActionError(error?: unknown): error is ActionError;
|
|
58
|
+
export declare function isInputError<T extends ErrorInferenceObject>(error?: ActionError<T>): error is ActionInputError<T>;
|
|
59
|
+
export declare function isInputError(error?: unknown): error is ActionInputError<ErrorInferenceObject>;
|
|
60
|
+
export declare class ActionInputError<T extends ErrorInferenceObject> extends ActionError {
|
|
61
|
+
type: string;
|
|
62
|
+
issues: z.$ZodIssue[];
|
|
63
|
+
fields: {
|
|
64
|
+
[P in keyof T]?: string[] | undefined;
|
|
65
|
+
};
|
|
66
|
+
constructor(issues: z.$ZodIssue[]);
|
|
67
|
+
}
|
|
68
|
+
export declare function deserializeActionResult(res: SerializedActionResult): SafeResult<any, any>;
|
|
69
|
+
export declare const actionResultErrorStack: {
|
|
70
|
+
set(stack: string | undefined): void;
|
|
71
|
+
get(): string | undefined;
|
|
72
|
+
};
|
|
73
|
+
export declare function getActionQueryString(name: string): string;
|
|
74
|
+
export declare function getActionPathFromString({ baseUrl, shouldAppendTrailingSlash, path: input, }: {
|
|
75
|
+
baseUrl: string;
|
|
76
|
+
shouldAppendTrailingSlash: boolean;
|
|
77
|
+
path: string;
|
|
78
|
+
}): string;
|
|
79
|
+
export declare function createGetActionPath(options: Pick<Parameters<typeof getActionPathFromString>[0], 'baseUrl' | 'shouldAppendTrailingSlash'>): (action: ActionClient<any, any, any>) => string;
|
|
80
|
+
export declare function createActionsProxy({ actionCallback, aggregatedPath, handleAction, }: {
|
|
81
|
+
actionCallback?: Record<string | symbol, any>;
|
|
82
|
+
aggregatedPath?: string;
|
|
83
|
+
handleAction: (param: any, path: string, context: APIContext | undefined) => Promise<SafeResult<any, any>>;
|
|
84
|
+
}): Record<string | symbol, any>;
|
|
@@ -1,11 +1,242 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { parse as devalueParse } from "devalue";
|
|
2
|
+
import { ACTION_QUERY_PARAMS } from "../consts.js";
|
|
3
|
+
import { appendForwardSlash } from "../../core/path.js";
|
|
4
|
+
const codeToStatusMap = {
|
|
5
|
+
// Implemented from IANA HTTP Status Code Registry
|
|
6
|
+
// https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
|
|
7
|
+
BAD_REQUEST: 400,
|
|
8
|
+
UNAUTHORIZED: 401,
|
|
9
|
+
PAYMENT_REQUIRED: 402,
|
|
10
|
+
FORBIDDEN: 403,
|
|
11
|
+
NOT_FOUND: 404,
|
|
12
|
+
METHOD_NOT_ALLOWED: 405,
|
|
13
|
+
NOT_ACCEPTABLE: 406,
|
|
14
|
+
PROXY_AUTHENTICATION_REQUIRED: 407,
|
|
15
|
+
REQUEST_TIMEOUT: 408,
|
|
16
|
+
CONFLICT: 409,
|
|
17
|
+
GONE: 410,
|
|
18
|
+
LENGTH_REQUIRED: 411,
|
|
19
|
+
PRECONDITION_FAILED: 412,
|
|
20
|
+
CONTENT_TOO_LARGE: 413,
|
|
21
|
+
URI_TOO_LONG: 414,
|
|
22
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
23
|
+
RANGE_NOT_SATISFIABLE: 416,
|
|
24
|
+
EXPECTATION_FAILED: 417,
|
|
25
|
+
MISDIRECTED_REQUEST: 421,
|
|
26
|
+
UNPROCESSABLE_CONTENT: 422,
|
|
27
|
+
LOCKED: 423,
|
|
28
|
+
FAILED_DEPENDENCY: 424,
|
|
29
|
+
TOO_EARLY: 425,
|
|
30
|
+
UPGRADE_REQUIRED: 426,
|
|
31
|
+
PRECONDITION_REQUIRED: 428,
|
|
32
|
+
TOO_MANY_REQUESTS: 429,
|
|
33
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
|
|
34
|
+
UNAVAILABLE_FOR_LEGAL_REASONS: 451,
|
|
35
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
36
|
+
NOT_IMPLEMENTED: 501,
|
|
37
|
+
BAD_GATEWAY: 502,
|
|
38
|
+
SERVICE_UNAVAILABLE: 503,
|
|
39
|
+
GATEWAY_TIMEOUT: 504,
|
|
40
|
+
HTTP_VERSION_NOT_SUPPORTED: 505,
|
|
41
|
+
VARIANT_ALSO_NEGOTIATES: 506,
|
|
42
|
+
INSUFFICIENT_STORAGE: 507,
|
|
43
|
+
LOOP_DETECTED: 508,
|
|
44
|
+
NETWORK_AUTHENTICATION_REQUIRED: 511
|
|
45
|
+
};
|
|
46
|
+
const statusToCodeMap = Object.entries(codeToStatusMap).reduce(
|
|
47
|
+
// reverse the key-value pairs
|
|
48
|
+
(acc, [key, value]) => ({ ...acc, [value]: key }),
|
|
49
|
+
{}
|
|
50
|
+
);
|
|
51
|
+
class ActionError extends Error {
|
|
52
|
+
type = "AstroActionError";
|
|
53
|
+
code = "INTERNAL_SERVER_ERROR";
|
|
54
|
+
status = 500;
|
|
55
|
+
constructor(params) {
|
|
56
|
+
super(params.message);
|
|
57
|
+
this.code = params.code;
|
|
58
|
+
this.status = ActionError.codeToStatus(params.code);
|
|
59
|
+
if (params.stack) {
|
|
60
|
+
this.stack = params.stack;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
static codeToStatus(code) {
|
|
64
|
+
return codeToStatusMap[code];
|
|
65
|
+
}
|
|
66
|
+
static statusToCode(status) {
|
|
67
|
+
return statusToCodeMap[status] ?? "INTERNAL_SERVER_ERROR";
|
|
68
|
+
}
|
|
69
|
+
static fromJson(body) {
|
|
70
|
+
if (isInputError(body)) {
|
|
71
|
+
return new ActionInputError(body.issues);
|
|
72
|
+
}
|
|
73
|
+
if (isActionError(body)) {
|
|
74
|
+
return new ActionError(body);
|
|
75
|
+
}
|
|
76
|
+
return new ActionError({
|
|
77
|
+
code: "INTERNAL_SERVER_ERROR"
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function isActionError(error) {
|
|
82
|
+
return typeof error === "object" && error != null && "type" in error && error.type === "AstroActionError";
|
|
83
|
+
}
|
|
84
|
+
function isInputError(error) {
|
|
85
|
+
return typeof error === "object" && error != null && "type" in error && error.type === "AstroActionInputError" && "issues" in error && Array.isArray(error.issues);
|
|
86
|
+
}
|
|
87
|
+
class ActionInputError extends ActionError {
|
|
88
|
+
type = "AstroActionInputError";
|
|
89
|
+
// We don't expose all ZodError properties.
|
|
90
|
+
// Not all properties will serialize from server to client,
|
|
91
|
+
// and we don't want to import the full ZodError object into the client.
|
|
92
|
+
issues;
|
|
93
|
+
fields;
|
|
94
|
+
constructor(issues) {
|
|
95
|
+
super({
|
|
96
|
+
message: `Failed to validate: ${JSON.stringify(issues, null, 2)}`,
|
|
97
|
+
code: "BAD_REQUEST"
|
|
98
|
+
});
|
|
99
|
+
this.issues = issues;
|
|
100
|
+
this.fields = {};
|
|
101
|
+
for (const issue of issues) {
|
|
102
|
+
if (issue.path.length > 0) {
|
|
103
|
+
const key = issue.path[0].toString();
|
|
104
|
+
this.fields[key] ??= [];
|
|
105
|
+
this.fields[key]?.push(issue.message);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function deserializeActionResult(res) {
|
|
111
|
+
if (res.type === "error") {
|
|
112
|
+
let json;
|
|
113
|
+
try {
|
|
114
|
+
json = JSON.parse(res.body);
|
|
115
|
+
} catch {
|
|
116
|
+
return {
|
|
117
|
+
data: void 0,
|
|
118
|
+
error: new ActionError({
|
|
119
|
+
message: res.body,
|
|
120
|
+
code: "INTERNAL_SERVER_ERROR"
|
|
121
|
+
})
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (import.meta.env?.PROD) {
|
|
125
|
+
return { error: ActionError.fromJson(json), data: void 0 };
|
|
126
|
+
} else {
|
|
127
|
+
const error = ActionError.fromJson(json);
|
|
128
|
+
error.stack = actionResultErrorStack.get();
|
|
129
|
+
return {
|
|
130
|
+
error,
|
|
131
|
+
data: void 0
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (res.type === "empty") {
|
|
136
|
+
return { data: void 0, error: void 0 };
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
data: devalueParse(res.body, {
|
|
140
|
+
URL: (href) => new URL(href)
|
|
141
|
+
}),
|
|
142
|
+
error: void 0
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const actionResultErrorStack = /* @__PURE__ */ function actionResultErrorStackFn() {
|
|
146
|
+
let errorStack;
|
|
147
|
+
return {
|
|
148
|
+
set(stack) {
|
|
149
|
+
errorStack = stack;
|
|
150
|
+
},
|
|
151
|
+
get() {
|
|
152
|
+
return errorStack;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}();
|
|
156
|
+
function getActionQueryString(name) {
|
|
157
|
+
const searchParams = new URLSearchParams({ [ACTION_QUERY_PARAMS.actionName]: name });
|
|
158
|
+
return `?${searchParams.toString()}`;
|
|
159
|
+
}
|
|
160
|
+
function getActionPathFromString({
|
|
161
|
+
baseUrl,
|
|
162
|
+
shouldAppendTrailingSlash,
|
|
163
|
+
path: input
|
|
164
|
+
}) {
|
|
165
|
+
let path = `${baseUrl.replace(/\/$/, "")}/_actions/${new URLSearchParams(input).get(ACTION_QUERY_PARAMS.actionName)}`;
|
|
166
|
+
if (shouldAppendTrailingSlash) {
|
|
167
|
+
path = appendForwardSlash(path);
|
|
168
|
+
}
|
|
169
|
+
return path;
|
|
170
|
+
}
|
|
171
|
+
function createGetActionPath(options) {
|
|
172
|
+
return function getActionPath(action) {
|
|
173
|
+
return getActionPathFromString({
|
|
174
|
+
baseUrl: options.baseUrl,
|
|
175
|
+
shouldAppendTrailingSlash: options.shouldAppendTrailingSlash,
|
|
176
|
+
path: action.toString()
|
|
177
|
+
});
|
|
178
|
+
};
|
|
4
179
|
}
|
|
5
|
-
|
|
6
|
-
|
|
180
|
+
const ENCODED_DOT = "%2E";
|
|
181
|
+
function createActionsProxy({
|
|
182
|
+
actionCallback = {},
|
|
183
|
+
aggregatedPath = "",
|
|
184
|
+
handleAction
|
|
185
|
+
}) {
|
|
186
|
+
return new Proxy(actionCallback, {
|
|
187
|
+
get(target, objKey) {
|
|
188
|
+
if (target.hasOwnProperty(objKey) || typeof objKey === "symbol") {
|
|
189
|
+
return target[objKey];
|
|
190
|
+
}
|
|
191
|
+
const path = aggregatedPath + encodeURIComponent(objKey.toString()).replaceAll(".", ENCODED_DOT);
|
|
192
|
+
function action(param) {
|
|
193
|
+
return handleAction(param, path, this);
|
|
194
|
+
}
|
|
195
|
+
Object.assign(action, {
|
|
196
|
+
queryString: getActionQueryString(path),
|
|
197
|
+
toString: () => action.queryString,
|
|
198
|
+
// redefine prototype methods as the object's own property, not the prototype's
|
|
199
|
+
bind: action.bind,
|
|
200
|
+
valueOf: () => action.valueOf,
|
|
201
|
+
// Progressive enhancement info for React.
|
|
202
|
+
$$FORM_ACTION: function() {
|
|
203
|
+
const searchParams = new URLSearchParams(action.toString());
|
|
204
|
+
return {
|
|
205
|
+
method: "POST",
|
|
206
|
+
// `name` creates a hidden input.
|
|
207
|
+
// It's unused by Astro, but we can't turn this off.
|
|
208
|
+
// At least use a name that won't conflict with a user's formData.
|
|
209
|
+
name: "_astroAction",
|
|
210
|
+
action: "?" + searchParams.toString()
|
|
211
|
+
};
|
|
212
|
+
},
|
|
213
|
+
// Note: `orThrow` does not have progressive enhancement info.
|
|
214
|
+
// If you want to throw exceptions,
|
|
215
|
+
// you must handle those exceptions with client JS.
|
|
216
|
+
async orThrow(param) {
|
|
217
|
+
const { data, error } = await handleAction(param, path, this);
|
|
218
|
+
if (error) throw error;
|
|
219
|
+
return data;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
return createActionsProxy({
|
|
223
|
+
actionCallback: action,
|
|
224
|
+
aggregatedPath: path + ".",
|
|
225
|
+
handleAction
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
});
|
|
7
229
|
}
|
|
8
230
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
231
|
+
ActionError,
|
|
232
|
+
ActionInputError,
|
|
233
|
+
actionResultErrorStack,
|
|
234
|
+
codeToStatusMap,
|
|
235
|
+
createActionsProxy,
|
|
236
|
+
createGetActionPath,
|
|
237
|
+
deserializeActionResult,
|
|
238
|
+
getActionPathFromString,
|
|
239
|
+
getActionQueryString,
|
|
240
|
+
isActionError,
|
|
241
|
+
isInputError
|
|
11
242
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ACTION_QUERY_PARAMS } from '../../consts.js';
|
|
2
|
+
export { ActionError, isActionError, isInputError, } from '../client.js';
|
|
3
|
+
export type { ActionAPIContext, ActionClient, ActionErrorCode, ActionInputSchema, ActionReturnType, SafeResult, } from '../types.js';
|
|
4
|
+
export declare function defineAction(): void;
|
|
5
|
+
export declare function getActionContext(): void;
|
|
6
|
+
export declare const getActionPath: (action: import("../types.js").ActionClient<any, any, any>) => string;
|
|
7
|
+
export declare const actions: Record<string | symbol, any>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { shouldAppendTrailingSlash } from "virtual:astro:actions/options";
|
|
2
|
+
import { internalFetchHeaders } from "virtual:astro:adapter-config/client";
|
|
3
|
+
import {
|
|
4
|
+
ActionError,
|
|
5
|
+
createActionsProxy,
|
|
6
|
+
createGetActionPath,
|
|
7
|
+
deserializeActionResult,
|
|
8
|
+
getActionPathFromString,
|
|
9
|
+
getActionQueryString
|
|
10
|
+
} from "../client.js";
|
|
11
|
+
import { ACTION_QUERY_PARAMS } from "../../consts.js";
|
|
12
|
+
import {
|
|
13
|
+
ActionError as ActionError2,
|
|
14
|
+
isActionError,
|
|
15
|
+
isInputError
|
|
16
|
+
} from "../client.js";
|
|
17
|
+
function defineAction() {
|
|
18
|
+
throw new Error("[astro:actions] `defineAction()` unexpectedly used on the client.");
|
|
19
|
+
}
|
|
20
|
+
function getActionContext() {
|
|
21
|
+
throw new Error("[astro:actions] `getActionContext()` unexpectedly used on the client.");
|
|
22
|
+
}
|
|
23
|
+
const getActionPath = createGetActionPath({
|
|
24
|
+
baseUrl: import.meta.env.BASE_URL,
|
|
25
|
+
shouldAppendTrailingSlash
|
|
26
|
+
});
|
|
27
|
+
const actions = createActionsProxy({
|
|
28
|
+
handleAction: async (param, path) => {
|
|
29
|
+
const headers = new Headers();
|
|
30
|
+
headers.set("Accept", "application/json");
|
|
31
|
+
for (const [key, value] of Object.entries(internalFetchHeaders)) {
|
|
32
|
+
headers.set(key, value);
|
|
33
|
+
}
|
|
34
|
+
let body = param;
|
|
35
|
+
if (!(body instanceof FormData)) {
|
|
36
|
+
try {
|
|
37
|
+
body = JSON.stringify(param);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
throw new ActionError({
|
|
40
|
+
code: "BAD_REQUEST",
|
|
41
|
+
message: `Failed to serialize request body to JSON. Full error: ${e.message}`
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (body) {
|
|
45
|
+
headers.set("Content-Type", "application/json");
|
|
46
|
+
} else {
|
|
47
|
+
headers.set("Content-Length", "0");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const rawResult = await fetch(
|
|
51
|
+
getActionPathFromString({
|
|
52
|
+
baseUrl: import.meta.env.BASE_URL,
|
|
53
|
+
shouldAppendTrailingSlash,
|
|
54
|
+
path: getActionQueryString(path)
|
|
55
|
+
}),
|
|
56
|
+
{
|
|
57
|
+
method: "POST",
|
|
58
|
+
body,
|
|
59
|
+
headers
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
if (rawResult.status === 204) {
|
|
63
|
+
return deserializeActionResult({ type: "empty", status: 204 });
|
|
64
|
+
}
|
|
65
|
+
const bodyText = await rawResult.text();
|
|
66
|
+
if (rawResult.ok) {
|
|
67
|
+
return deserializeActionResult({
|
|
68
|
+
type: "data",
|
|
69
|
+
body: bodyText,
|
|
70
|
+
status: 200,
|
|
71
|
+
contentType: "application/json+devalue"
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return deserializeActionResult({
|
|
75
|
+
type: "error",
|
|
76
|
+
body: bodyText,
|
|
77
|
+
status: rawResult.status,
|
|
78
|
+
contentType: "application/json"
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
export {
|
|
83
|
+
ACTION_QUERY_PARAMS,
|
|
84
|
+
ActionError2 as ActionError,
|
|
85
|
+
actions,
|
|
86
|
+
defineAction,
|
|
87
|
+
getActionContext,
|
|
88
|
+
getActionPath,
|
|
89
|
+
isActionError,
|
|
90
|
+
isInputError
|
|
91
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ACTION_QUERY_PARAMS } from '../../consts.js';
|
|
2
|
+
export { ActionError, isActionError, isInputError } from '../client.js';
|
|
3
|
+
export { defineAction, getActionContext } from '../server.js';
|
|
4
|
+
export type { ActionAPIContext, ActionClient, ActionErrorCode, ActionInputSchema, ActionReturnType, SafeResult, } from '../types.js';
|
|
5
|
+
export declare const getActionPath: (action: import("../types.js").ActionClient<any, any, any>) => string;
|
|
6
|
+
export declare const actions: Record<string | symbol, any>;
|