astro 5.16.5 → 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.js → bin/astro.mjs} +7 -8
- package/client.d.ts +19 -45
- package/components/ClientRouter.astro +0 -5
- 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 -29
- package/dist/actions/runtime/server.js +162 -82
- package/dist/actions/runtime/types.d.ts +64 -0
- package/dist/actions/runtime/types.js +0 -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 +11 -9
- package/dist/assets/build/remote.js +4 -14
- package/dist/assets/endpoint/config.js +2 -2
- package/dist/assets/endpoint/dev.js +7 -6
- package/dist/assets/fonts/config.d.ts +86 -174
- package/dist/assets/fonts/config.js +15 -17
- package/dist/assets/fonts/infra/dev-remote-font-provider-mod-resolver.d.ts +3 -3
- package/dist/assets/fonts/infra/dev-remote-font-provider-mod-resolver.js +4 -4
- package/dist/assets/fonts/types.d.ts +1 -1
- package/dist/assets/fonts/vite-plugin-fonts.js +6 -3
- package/dist/assets/services/sharp.js +5 -6
- package/dist/assets/utils/index.d.ts +0 -6
- package/dist/assets/utils/index.js +0 -9
- package/dist/assets/utils/{transformToPath.d.ts → node.d.ts} +15 -1
- package/dist/assets/utils/{node/emitAsset.js → node.js} +34 -56
- package/dist/assets/vite-plugin-assets.js +9 -14
- package/dist/cli/index.js +0 -2
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/cli/preferences/index.js +5 -1
- package/dist/config/index.js +11 -16
- package/dist/container/index.d.ts +0 -1
- package/dist/container/index.js +19 -14
- 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/config.js +17 -13
- package/dist/content/content-layer.js +14 -21
- package/dist/content/data-store.d.ts +0 -2
- package/dist/content/loaders/errors.d.ts +3 -3
- package/dist/content/loaders/errors.js +5 -2
- package/dist/content/loaders/glob.d.ts +0 -5
- package/dist/content/loaders/glob.js +3 -30
- package/dist/content/loaders/types.d.ts +11 -4
- package/dist/content/mutable-data-store.js +1 -14
- package/dist/content/runtime-assets.d.ts +4 -4
- package/dist/content/runtime-assets.js +4 -7
- package/dist/content/runtime.d.ts +35 -73
- package/dist/content/runtime.js +63 -231
- package/dist/content/server-listeners.js +25 -88
- package/dist/content/types-generator.d.ts +1 -6
- package/dist/content/types-generator.js +87 -156
- package/dist/content/utils.d.ts +47 -412
- package/dist/content/utils.js +88 -203
- 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 -8
- package/dist/content/vite-plugin-content-virtual-mod.js +13 -131
- 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 -114
- package/dist/core/app/index.js +20 -557
- 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.d.ts +2 -8
- package/dist/core/app/node.js +8 -9
- 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 +95 -204
- package/dist/core/build/graph.js +2 -2
- package/dist/core/build/index.js +11 -19
- package/dist/core/build/internal.d.ts +3 -29
- package/dist/core/build/internal.js +1 -45
- 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 -131
- 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 +180 -154
- 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 -4
- package/dist/core/config/config.js +2 -2
- 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 +330 -1463
- package/dist/core/config/schemas/base.js +40 -56
- package/dist/core/config/schemas/refined.d.ts +2 -2
- package/dist/core/config/schemas/refined.js +8 -1
- package/dist/core/config/schemas/relative.d.ts +607 -1737
- 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 +12 -0
- package/dist/core/constants.js +22 -1
- package/dist/core/create-vite.d.ts +2 -6
- package/dist/core/create-vite.js +36 -47
- 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/dev/container.js +13 -9
- package/dist/core/dev/dev.js +1 -1
- 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/vite.js +2 -19
- package/dist/core/errors/errors-data.d.ts +85 -57
- package/dist/core/errors/errors-data.js +40 -28
- package/dist/core/errors/errors.d.ts +3 -3
- package/dist/core/errors/errors.js +1 -1
- package/dist/core/errors/overlay.js +1 -1
- package/dist/core/errors/zod-error-map.d.ts +2 -2
- package/dist/core/errors/zod-error-map.js +26 -24
- package/dist/core/messages.d.ts +2 -2
- package/dist/core/messages.js +2 -2
- 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 +4 -4
- package/dist/core/middleware/index.js +6 -12
- 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 -5
- package/dist/core/preview/static-preview-server.js +1 -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 -7
- package/dist/core/render/route-cache.d.ts +3 -3
- package/dist/core/render/route-cache.js +7 -7
- package/dist/core/render-context.d.ts +9 -7
- package/dist/core/render-context.js +46 -47
- 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 +9 -13
- 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 +8 -8
- package/dist/core/routing/validation.d.ts +1 -2
- package/dist/core/routing/validation.js +2 -18
- package/dist/core/server-islands/endpoint.d.ts +1 -2
- package/dist/core/server-islands/endpoint.js +5 -4
- 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 +19 -34
- 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/env-loader.d.ts +0 -1
- package/dist/env/env-loader.js +4 -17
- package/dist/env/schema.d.ts +21 -251
- package/dist/env/schema.js +6 -3
- package/dist/env/vite-plugin-env.js +3 -2
- 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/index.js +0 -3
- 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 +2 -3
- package/dist/integrations/hooks.js +9 -33
- 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/prefetch/index.d.ts +0 -10
- package/dist/prefetch/index.js +1 -1
- package/dist/prerender/routing.d.ts +5 -7
- package/dist/prerender/routing.js +6 -17
- package/dist/runtime/server/astro-global.d.ts +2 -2
- package/dist/runtime/server/astro-global.js +86 -24
- package/dist/runtime/server/render/server-islands.js +2 -2
- package/dist/runtime/server/transition.d.ts +1 -0
- package/dist/transitions/events.d.ts +7 -0
- package/dist/transitions/router.js +7 -3
- package/dist/transitions/vite-plugin-transitions.js +1 -4
- package/dist/types/astro.d.ts +10 -8
- package/dist/types/public/common.d.ts +1 -3
- package/dist/types/public/config.d.ts +364 -415
- package/dist/types/public/context.d.ts +21 -52
- package/dist/types/public/index.d.ts +2 -1
- package/dist/types/public/integrations.d.ts +23 -18
- package/dist/types/public/internal.d.ts +3 -18
- 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 -3
- package/dist/virtual-modules/live-config.js +1 -5
- 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 +5 -7
- package/dist/vite-plugin-app/pipeline.js +166 -0
- package/dist/vite-plugin-astro/index.js +11 -13
- 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 +53 -96
- 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-markdown/index.js +0 -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 +14 -15
- package/templates/content/module.mjs +9 -63
- package/templates/content/types.d.ts +32 -78
- 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 -31
- 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/utils/node/emitAsset.d.ts +0 -29
- package/dist/assets/utils/transformToPath.js +0 -32
- package/dist/config/vite-plugin-content-listen.d.ts +0 -17
- package/dist/config/vite-plugin-content-listen.js +0 -26
- package/dist/container/polyfill.d.ts +0 -1
- package/dist/container/polyfill.js +0 -2
- 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/polyfill.d.ts +0 -5
- package/dist/core/polyfill.js +0 -17
- 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-postprocess/index.d.ts +0 -2
- package/dist/vite-plugin-astro-postprocess/index.js +0 -48
- 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 -166
- package/dist/vite-plugin-astro-server/request.d.ts +0 -14
- package/dist/vite-plugin-astro-server/request.js +0 -73
- 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
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { shouldAppendTrailingSlash } from "virtual:astro:actions/options";
|
|
2
|
-
import { internalFetchHeaders } from "virtual:astro:adapter-config/client";
|
|
3
|
-
import {
|
|
4
|
-
ACTION_QUERY_PARAMS,
|
|
5
|
-
ActionError,
|
|
6
|
-
appendForwardSlash,
|
|
7
|
-
astroCalledServerError,
|
|
8
|
-
deserializeActionResult,
|
|
9
|
-
getActionQueryString
|
|
10
|
-
} from "./shared.js";
|
|
11
|
-
export * from "virtual:astro:actions/runtime";
|
|
12
|
-
const apiContextRoutesSymbol = Symbol.for("context.routes");
|
|
13
|
-
const ENCODED_DOT = "%2E";
|
|
14
|
-
function toActionProxy(actionCallback = {}, aggregatedPath = "") {
|
|
15
|
-
return new Proxy(actionCallback, {
|
|
16
|
-
get(target, objKey) {
|
|
17
|
-
if (target.hasOwnProperty(objKey) || typeof objKey === "symbol") {
|
|
18
|
-
return target[objKey];
|
|
19
|
-
}
|
|
20
|
-
const path = aggregatedPath + encodeURIComponent(objKey.toString()).replaceAll(".", ENCODED_DOT);
|
|
21
|
-
function action(param) {
|
|
22
|
-
return handleAction(param, path, this);
|
|
23
|
-
}
|
|
24
|
-
Object.assign(action, {
|
|
25
|
-
queryString: getActionQueryString(path),
|
|
26
|
-
toString: () => action.queryString,
|
|
27
|
-
// redefine prototype methods as the object's own property, not the prototype's
|
|
28
|
-
bind: action.bind,
|
|
29
|
-
valueOf: () => action.valueOf,
|
|
30
|
-
// Progressive enhancement info for React.
|
|
31
|
-
$$FORM_ACTION: function() {
|
|
32
|
-
const searchParams = new URLSearchParams(action.toString());
|
|
33
|
-
return {
|
|
34
|
-
method: "POST",
|
|
35
|
-
// `name` creates a hidden input.
|
|
36
|
-
// It's unused by Astro, but we can't turn this off.
|
|
37
|
-
// At least use a name that won't conflict with a user's formData.
|
|
38
|
-
name: "_astroAction",
|
|
39
|
-
action: "?" + searchParams.toString()
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
// Note: `orThrow` does not have progressive enhancement info.
|
|
43
|
-
// If you want to throw exceptions,
|
|
44
|
-
// you must handle those exceptions with client JS.
|
|
45
|
-
async orThrow(param) {
|
|
46
|
-
const { data, error } = await handleAction(param, path, this);
|
|
47
|
-
if (error) throw error;
|
|
48
|
-
return data;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return toActionProxy(action, path + ".");
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function _getActionPath(toString) {
|
|
56
|
-
let path = `${import.meta.env.BASE_URL.replace(/\/$/, "")}/_actions/${new URLSearchParams(toString()).get(ACTION_QUERY_PARAMS.actionName)}`;
|
|
57
|
-
if (shouldAppendTrailingSlash) {
|
|
58
|
-
path = appendForwardSlash(path);
|
|
59
|
-
}
|
|
60
|
-
return path;
|
|
61
|
-
}
|
|
62
|
-
function getActionPath(action) {
|
|
63
|
-
return _getActionPath(action.toString);
|
|
64
|
-
}
|
|
65
|
-
async function handleAction(param, path, context) {
|
|
66
|
-
if (import.meta.env.SSR && context) {
|
|
67
|
-
const pipeline = Reflect.get(context, apiContextRoutesSymbol);
|
|
68
|
-
if (!pipeline) {
|
|
69
|
-
throw astroCalledServerError();
|
|
70
|
-
}
|
|
71
|
-
const action = await pipeline.getAction(path);
|
|
72
|
-
if (!action) throw new Error(`Action not found: ${path}`);
|
|
73
|
-
return action.bind(context)(param);
|
|
74
|
-
}
|
|
75
|
-
const headers = new Headers();
|
|
76
|
-
headers.set("Accept", "application/json");
|
|
77
|
-
for (const [key, value] of Object.entries(internalFetchHeaders)) {
|
|
78
|
-
headers.set(key, value);
|
|
79
|
-
}
|
|
80
|
-
let body = param;
|
|
81
|
-
if (!(body instanceof FormData)) {
|
|
82
|
-
try {
|
|
83
|
-
body = JSON.stringify(param);
|
|
84
|
-
} catch (e) {
|
|
85
|
-
throw new ActionError({
|
|
86
|
-
code: "BAD_REQUEST",
|
|
87
|
-
message: `Failed to serialize request body to JSON. Full error: ${e.message}`
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
if (body) {
|
|
91
|
-
headers.set("Content-Type", "application/json");
|
|
92
|
-
} else {
|
|
93
|
-
headers.set("Content-Length", "0");
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const rawResult = await fetch(
|
|
97
|
-
_getActionPath(() => getActionQueryString(path)),
|
|
98
|
-
{
|
|
99
|
-
method: "POST",
|
|
100
|
-
body,
|
|
101
|
-
headers
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
|
-
if (rawResult.status === 204) {
|
|
105
|
-
return deserializeActionResult({ type: "empty", status: 204 });
|
|
106
|
-
}
|
|
107
|
-
const bodyText = await rawResult.text();
|
|
108
|
-
if (rawResult.ok) {
|
|
109
|
-
return deserializeActionResult({
|
|
110
|
-
type: "data",
|
|
111
|
-
body: bodyText,
|
|
112
|
-
status: 200,
|
|
113
|
-
contentType: "application/json+devalue"
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
return deserializeActionResult({
|
|
117
|
-
type: "error",
|
|
118
|
-
body: bodyText,
|
|
119
|
-
status: rawResult.status,
|
|
120
|
-
contentType: "application/json"
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
const actions = toActionProxy();
|
|
124
|
-
export {
|
|
125
|
-
actions,
|
|
126
|
-
getActionPath
|
|
127
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type * as vite from 'vite';
|
|
2
|
-
import type { ImageMetadata } from '../../types.js';
|
|
3
|
-
type FileEmitter = vite.Rollup.EmitFile;
|
|
4
|
-
type ImageMetadataWithContents = ImageMetadata & {
|
|
5
|
-
contents?: Buffer;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Processes an image file and emits its metadata and optionally its contents. This function supports both build and development modes.
|
|
9
|
-
*
|
|
10
|
-
* @param {string | undefined} id - The identifier or path of the image file to process. If undefined, the function returns immediately.
|
|
11
|
-
* @param {boolean} _watchMode - **Deprecated**: Indicates if the method is operating in watch mode. This parameter will be removed or updated in the future.
|
|
12
|
-
* @param {boolean} _experimentalSvgEnabled - **Deprecated**: A flag to enable experimental handling of SVG files. Embeds SVG file data if set to true.
|
|
13
|
-
* @param {FileEmitter | undefined} [fileEmitter] - Function for emitting files during the build process. May throw in certain scenarios.
|
|
14
|
-
* @return {Promise<ImageMetadataWithContents | undefined>} Resolves to metadata with optional image contents or `undefined` if processing fails.
|
|
15
|
-
*/
|
|
16
|
-
export declare function emitESMImage(id: string | undefined,
|
|
17
|
-
/** @deprecated */
|
|
18
|
-
_watchMode: boolean,
|
|
19
|
-
/** @deprecated */
|
|
20
|
-
_experimentalSvgEnabled: boolean, fileEmitter?: FileEmitter): Promise<ImageMetadataWithContents | undefined>;
|
|
21
|
-
/**
|
|
22
|
-
* Processes an image file and emits its metadata and optionally its contents. This function supports both build and development modes.
|
|
23
|
-
*
|
|
24
|
-
* @param {string | undefined} id - The identifier or path of the image file to process. If undefined, the function returns immediately.
|
|
25
|
-
* @param {FileEmitter | undefined} [fileEmitter] - Function for emitting files during the build process. May throw in certain scenarios.
|
|
26
|
-
* @return {Promise<ImageMetadataWithContents | undefined>} Resolves to metadata with optional image contents or `undefined` if processing fails.
|
|
27
|
-
*/
|
|
28
|
-
export declare function emitImageMetadata(id: string | undefined, fileEmitter?: FileEmitter): Promise<ImageMetadataWithContents | undefined>;
|
|
29
|
-
export {};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { basename, dirname, extname } from "node:path";
|
|
2
|
-
import { deterministicString } from "deterministic-object-hash";
|
|
3
|
-
import { removeQueryString } from "../../core/path.js";
|
|
4
|
-
import { shorthash } from "../../runtime/server/shorthash.js";
|
|
5
|
-
import { isESMImportedImage } from "./imageKind.js";
|
|
6
|
-
const INVALID_CHAR_REGEX = /[\u0000-\u001F"#$%&*+,:;<=>?[\]^`{|}\u007F]/g;
|
|
7
|
-
function propsToFilename(filePath, transform, hash) {
|
|
8
|
-
let filename = decodeURIComponent(removeQueryString(filePath));
|
|
9
|
-
const ext = extname(filename);
|
|
10
|
-
if (filePath.startsWith("data:")) {
|
|
11
|
-
filename = shorthash(filePath);
|
|
12
|
-
} else {
|
|
13
|
-
filename = basename(filename, ext).replace(INVALID_CHAR_REGEX, "_");
|
|
14
|
-
}
|
|
15
|
-
const prefixDirname = isESMImportedImage(transform.src) ? dirname(filePath) : "";
|
|
16
|
-
let outputExt = transform.format ? `.${transform.format}` : ext;
|
|
17
|
-
return `${prefixDirname}/${filename}_${hash}${outputExt}`;
|
|
18
|
-
}
|
|
19
|
-
function hashTransform(transform, imageService, propertiesToHash) {
|
|
20
|
-
const hashFields = propertiesToHash.reduce(
|
|
21
|
-
(acc, prop) => {
|
|
22
|
-
acc[prop] = transform[prop];
|
|
23
|
-
return acc;
|
|
24
|
-
},
|
|
25
|
-
{ imageService }
|
|
26
|
-
);
|
|
27
|
-
return shorthash(deterministicString(hashFields));
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
hashTransform,
|
|
31
|
-
propsToFilename
|
|
32
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type fsMod from 'node:fs';
|
|
2
|
-
import type { Plugin } from 'vite';
|
|
3
|
-
import type { Logger } from '../core/logger/core.js';
|
|
4
|
-
import type { AstroSettings } from '../types/astro.js';
|
|
5
|
-
/**
|
|
6
|
-
* Listen for Astro content directory changes and generate types.
|
|
7
|
-
*
|
|
8
|
-
* This is a separate plugin for `getViteConfig` as the `attachContentServerListeners` API
|
|
9
|
-
* needs to be called at different times in `astro dev` and `getViteConfig`. For `astro dev`,
|
|
10
|
-
* it needs to be called after the Astro server is started (packages/astro/src/core/dev/dev.ts).
|
|
11
|
-
* For `getViteConfig`, it needs to be called after the Vite server is started.
|
|
12
|
-
*/
|
|
13
|
-
export declare function astroContentListenPlugin({ settings, logger, fs, }: {
|
|
14
|
-
settings: AstroSettings;
|
|
15
|
-
logger: Logger;
|
|
16
|
-
fs: typeof fsMod;
|
|
17
|
-
}): Plugin;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { attachContentServerListeners } from "../content/server-listeners.js";
|
|
2
|
-
function astroContentListenPlugin({
|
|
3
|
-
settings,
|
|
4
|
-
logger,
|
|
5
|
-
fs
|
|
6
|
-
}) {
|
|
7
|
-
let server;
|
|
8
|
-
return {
|
|
9
|
-
name: "astro:content-listen",
|
|
10
|
-
apply: "serve",
|
|
11
|
-
configureServer(_server) {
|
|
12
|
-
server = _server;
|
|
13
|
-
},
|
|
14
|
-
async buildStart() {
|
|
15
|
-
await attachContentServerListeners({
|
|
16
|
-
fs,
|
|
17
|
-
settings,
|
|
18
|
-
logger,
|
|
19
|
-
viteServer: server
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export {
|
|
25
|
-
astroContentListenPlugin
|
|
26
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { GetModuleInfo } from 'rollup';
|
|
2
|
-
import type { AstroSettings } from '../../types/astro.js';
|
|
3
|
-
export declare function shortHashedName(settings: AstroSettings): (id: string, ctx: {
|
|
4
|
-
getModuleInfo: GetModuleInfo;
|
|
5
|
-
}) => string;
|
|
6
|
-
export declare function createNameHash(baseId: string | undefined, hashIds: string[], settings: AstroSettings): string;
|
|
7
|
-
export declare function createSlugger(settings: AstroSettings): (id: string, ctx: {
|
|
8
|
-
getModuleInfo: GetModuleInfo;
|
|
9
|
-
}) => string;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import crypto from "node:crypto";
|
|
2
|
-
import npath from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { viteID } from "../util.js";
|
|
5
|
-
import { normalizePath } from "../viteUtils.js";
|
|
6
|
-
import { getTopLevelPageModuleInfos } from "./graph.js";
|
|
7
|
-
const confusingBaseNames = ["404", "500"];
|
|
8
|
-
function shortHashedName(settings) {
|
|
9
|
-
return function(id, ctx) {
|
|
10
|
-
const parents = getTopLevelPageModuleInfos(id, ctx);
|
|
11
|
-
return createNameHash(
|
|
12
|
-
getFirstParentId(parents),
|
|
13
|
-
parents.map((page) => page.id),
|
|
14
|
-
settings
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function createNameHash(baseId, hashIds, settings) {
|
|
19
|
-
const baseName = baseId ? prettifyBaseName(npath.parse(baseId).name) : "index";
|
|
20
|
-
const hash = crypto.createHash("sha256");
|
|
21
|
-
const root = fileURLToPath(settings.config.root);
|
|
22
|
-
for (const id of hashIds) {
|
|
23
|
-
const relativePath = npath.relative(root, id);
|
|
24
|
-
hash.update(normalizePath(relativePath), "utf-8");
|
|
25
|
-
}
|
|
26
|
-
const h = hash.digest("hex").slice(0, 8);
|
|
27
|
-
const proposedName = baseName + "." + h;
|
|
28
|
-
return proposedName;
|
|
29
|
-
}
|
|
30
|
-
function createSlugger(settings) {
|
|
31
|
-
const pagesDir = viteID(new URL("./pages", settings.config.srcDir));
|
|
32
|
-
const indexPage = viteID(new URL("./pages/index", settings.config.srcDir));
|
|
33
|
-
const map = /* @__PURE__ */ new Map();
|
|
34
|
-
const sep = "-";
|
|
35
|
-
return function(id, ctx) {
|
|
36
|
-
const parents = Array.from(getTopLevelPageModuleInfos(id, ctx));
|
|
37
|
-
const allParentsKey = parents.map((page) => page.id).sort().join("-");
|
|
38
|
-
const firstParentId = getFirstParentId(parents) || indexPage;
|
|
39
|
-
let dir = firstParentId;
|
|
40
|
-
let key = "";
|
|
41
|
-
let i = 0;
|
|
42
|
-
while (i < 2) {
|
|
43
|
-
if (dir === pagesDir) {
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
const name2 = prettifyBaseName(npath.parse(npath.basename(dir)).name);
|
|
47
|
-
key = key.length ? name2 + sep + key : name2;
|
|
48
|
-
dir = npath.dirname(dir);
|
|
49
|
-
i++;
|
|
50
|
-
}
|
|
51
|
-
let name = key;
|
|
52
|
-
if (!map.has(key)) {
|
|
53
|
-
map.set(key, /* @__PURE__ */ new Map([[allParentsKey, 0]]));
|
|
54
|
-
} else {
|
|
55
|
-
const inner = map.get(key);
|
|
56
|
-
if (inner.has(allParentsKey)) {
|
|
57
|
-
const num = inner.get(allParentsKey);
|
|
58
|
-
if (num > 0) {
|
|
59
|
-
name = name + sep + num;
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
const num = inner.size;
|
|
63
|
-
inner.set(allParentsKey, num);
|
|
64
|
-
name = name + sep + num;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return name;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function getFirstParentId(parents) {
|
|
71
|
-
for (const parent of parents) {
|
|
72
|
-
const id = parent.id;
|
|
73
|
-
const baseName = npath.parse(id).name;
|
|
74
|
-
if (!confusingBaseNames.includes(baseName)) {
|
|
75
|
-
return id;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return parents[0]?.id;
|
|
79
|
-
}
|
|
80
|
-
const charsToReplaceRe = /[.[\]]/g;
|
|
81
|
-
const underscoresRe = /_+/g;
|
|
82
|
-
function prettifyBaseName(str) {
|
|
83
|
-
return str.replace(charsToReplaceRe, "_").replace(underscoresRe, "_");
|
|
84
|
-
}
|
|
85
|
-
export {
|
|
86
|
-
createNameHash,
|
|
87
|
-
createSlugger,
|
|
88
|
-
shortHashedName
|
|
89
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { Rollup, Plugin as VitePlugin } from 'vite';
|
|
2
|
-
import type { BuildInternals } from './internal.js';
|
|
3
|
-
import type { StaticBuildOptions, ViteBuildReturn } from './types.js';
|
|
4
|
-
type RollupOutputArray = Extract<ViteBuildReturn, Array<any>>;
|
|
5
|
-
type OutputChunkorAsset = RollupOutputArray[number]['output'][number];
|
|
6
|
-
type OutputChunk = Extract<OutputChunkorAsset, {
|
|
7
|
-
type: 'chunk';
|
|
8
|
-
}>;
|
|
9
|
-
export type BuildTarget = 'server' | 'client';
|
|
10
|
-
type MutateChunk = (chunk: OutputChunk, targets: BuildTarget[], newCode: string) => void;
|
|
11
|
-
interface BuildBeforeHookResult {
|
|
12
|
-
enforce?: 'after-user-plugins';
|
|
13
|
-
vitePlugin: VitePlugin | VitePlugin[] | undefined;
|
|
14
|
-
}
|
|
15
|
-
export type AstroBuildPlugin = {
|
|
16
|
-
targets: BuildTarget[];
|
|
17
|
-
hooks?: {
|
|
18
|
-
'build:before'?: (opts: {
|
|
19
|
-
target: BuildTarget;
|
|
20
|
-
input: Set<string>;
|
|
21
|
-
}) => BuildBeforeHookResult | Promise<BuildBeforeHookResult>;
|
|
22
|
-
'build:post'?: (opts: {
|
|
23
|
-
ssrOutputs: RollupOutputArray;
|
|
24
|
-
clientOutputs: RollupOutputArray;
|
|
25
|
-
mutate: MutateChunk;
|
|
26
|
-
}) => void | Promise<void>;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export declare function createPluginContainer(options: StaticBuildOptions, internals: BuildInternals): {
|
|
30
|
-
options: StaticBuildOptions;
|
|
31
|
-
internals: BuildInternals;
|
|
32
|
-
register(plugin: AstroBuildPlugin): void;
|
|
33
|
-
runBeforeHook(target: BuildTarget, input: Set<string>): Promise<{
|
|
34
|
-
vitePlugins: (VitePlugin<any> | VitePlugin<any>[])[];
|
|
35
|
-
lastVitePlugins: (VitePlugin<any> | VitePlugin<any>[])[];
|
|
36
|
-
}>;
|
|
37
|
-
runPostHook(ssrOutputs: Rollup.RollupOutput[], clientOutputs: Rollup.RollupOutput[]): Promise<Map<string, {
|
|
38
|
-
targets: BuildTarget[];
|
|
39
|
-
code: string;
|
|
40
|
-
}>>;
|
|
41
|
-
};
|
|
42
|
-
export type AstroBuildPluginContainer = ReturnType<typeof createPluginContainer>;
|
|
43
|
-
export {};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
function createPluginContainer(options, internals) {
|
|
2
|
-
const plugins = /* @__PURE__ */ new Map();
|
|
3
|
-
const allPlugins = /* @__PURE__ */ new Set();
|
|
4
|
-
for (const target of ["client", "server"]) {
|
|
5
|
-
plugins.set(target, []);
|
|
6
|
-
}
|
|
7
|
-
return {
|
|
8
|
-
options,
|
|
9
|
-
internals,
|
|
10
|
-
register(plugin) {
|
|
11
|
-
allPlugins.add(plugin);
|
|
12
|
-
for (const target of plugin.targets) {
|
|
13
|
-
const targetPlugins = plugins.get(target) ?? [];
|
|
14
|
-
targetPlugins.push(plugin);
|
|
15
|
-
plugins.set(target, targetPlugins);
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
// Hooks
|
|
19
|
-
async runBeforeHook(target, input) {
|
|
20
|
-
let targetPlugins = plugins.get(target) ?? [];
|
|
21
|
-
let vitePlugins = [];
|
|
22
|
-
let lastVitePlugins = [];
|
|
23
|
-
for (const plugin of targetPlugins) {
|
|
24
|
-
if (plugin.hooks?.["build:before"]) {
|
|
25
|
-
let result = await plugin.hooks["build:before"]({ target, input });
|
|
26
|
-
if (result.vitePlugin) {
|
|
27
|
-
vitePlugins.push(result.vitePlugin);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
vitePlugins,
|
|
33
|
-
lastVitePlugins
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
async runPostHook(ssrOutputs, clientOutputs) {
|
|
37
|
-
const mutations = /* @__PURE__ */ new Map();
|
|
38
|
-
const mutate = (chunk, targets, newCode) => {
|
|
39
|
-
chunk.code = newCode;
|
|
40
|
-
mutations.set(chunk.fileName, {
|
|
41
|
-
targets,
|
|
42
|
-
code: newCode
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
for (const plugin of allPlugins) {
|
|
46
|
-
const postHook = plugin.hooks?.["build:post"];
|
|
47
|
-
if (postHook) {
|
|
48
|
-
await postHook({
|
|
49
|
-
ssrOutputs,
|
|
50
|
-
clientOutputs,
|
|
51
|
-
mutate
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return mutations;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
export {
|
|
60
|
-
createPluginContainer
|
|
61
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { BuildInternals } from '../internal.js';
|
|
2
|
-
import type { AstroBuildPlugin } from '../plugin.js';
|
|
3
|
-
import type { StaticBuildOptions } from '../types.js';
|
|
4
|
-
export declare function pluginActions(opts: StaticBuildOptions, internals: BuildInternals): AstroBuildPlugin;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { vitePluginActionsBuild } from "../../../actions/vite-plugin-actions.js";
|
|
2
|
-
function pluginActions(opts, internals) {
|
|
3
|
-
return {
|
|
4
|
-
targets: ["server"],
|
|
5
|
-
hooks: {
|
|
6
|
-
"build:before": () => {
|
|
7
|
-
return {
|
|
8
|
-
vitePlugin: vitePluginActionsBuild(opts, internals)
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
pluginActions
|
|
16
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { extendManualChunks } from "./util.js";
|
|
2
|
-
function vitePluginChunks() {
|
|
3
|
-
return {
|
|
4
|
-
name: "astro:chunks",
|
|
5
|
-
outputOptions(outputOptions) {
|
|
6
|
-
extendManualChunks(outputOptions, {
|
|
7
|
-
after(id) {
|
|
8
|
-
if (id.includes("astro/dist/runtime/server/")) {
|
|
9
|
-
return "astro/server";
|
|
10
|
-
}
|
|
11
|
-
if (id.includes("astro/dist/runtime")) {
|
|
12
|
-
return "astro";
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function pluginChunks() {
|
|
20
|
-
return {
|
|
21
|
-
targets: ["server"],
|
|
22
|
-
hooks: {
|
|
23
|
-
"build:before": () => {
|
|
24
|
-
return {
|
|
25
|
-
vitePlugin: vitePluginChunks()
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
pluginChunks
|
|
33
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BuildInternals } from '../internal.js';
|
|
2
|
-
import type { AstroBuildPlugin } from '../plugin.js';
|
|
3
|
-
import type { StaticBuildOptions } from '../types.js';
|
|
4
|
-
export declare const ASTRO_PAGE_MODULE_ID = "@astro-page:";
|
|
5
|
-
export declare const ASTRO_PAGE_RESOLVED_MODULE_ID: string;
|
|
6
|
-
export declare function pluginPages(opts: StaticBuildOptions, internals: BuildInternals): AstroBuildPlugin;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { routeIsRedirect } from "../../redirects/index.js";
|
|
2
|
-
import { addRollupInput } from "../add-rollup-input.js";
|
|
3
|
-
import { RENDERERS_MODULE_ID } from "./plugin-renderers.js";
|
|
4
|
-
import { getPagesFromVirtualModulePageName, getVirtualModulePageName } from "./util.js";
|
|
5
|
-
const ASTRO_PAGE_MODULE_ID = "@astro-page:";
|
|
6
|
-
const ASTRO_PAGE_RESOLVED_MODULE_ID = "\0" + ASTRO_PAGE_MODULE_ID;
|
|
7
|
-
function vitePluginPages(opts, internals) {
|
|
8
|
-
return {
|
|
9
|
-
name: "@astro/plugin-build-pages",
|
|
10
|
-
options(options) {
|
|
11
|
-
if (opts.settings.buildOutput === "static") {
|
|
12
|
-
const inputs = /* @__PURE__ */ new Set();
|
|
13
|
-
for (const pageData of Object.values(opts.allPages)) {
|
|
14
|
-
if (routeIsRedirect(pageData.route)) {
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
inputs.add(getVirtualModulePageName(ASTRO_PAGE_MODULE_ID, pageData.component));
|
|
18
|
-
}
|
|
19
|
-
return addRollupInput(options, Array.from(inputs));
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
resolveId(id) {
|
|
23
|
-
if (id.startsWith(ASTRO_PAGE_MODULE_ID)) {
|
|
24
|
-
return "\0" + id;
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
async load(id) {
|
|
28
|
-
if (id.startsWith(ASTRO_PAGE_RESOLVED_MODULE_ID)) {
|
|
29
|
-
const imports = [];
|
|
30
|
-
const exports = [];
|
|
31
|
-
const pageDatas = getPagesFromVirtualModulePageName(
|
|
32
|
-
internals,
|
|
33
|
-
ASTRO_PAGE_RESOLVED_MODULE_ID,
|
|
34
|
-
id
|
|
35
|
-
);
|
|
36
|
-
for (const pageData of pageDatas) {
|
|
37
|
-
const resolvedPage = await this.resolve(pageData.moduleSpecifier);
|
|
38
|
-
if (resolvedPage) {
|
|
39
|
-
imports.push(`import * as _page from ${JSON.stringify(pageData.moduleSpecifier)};`);
|
|
40
|
-
exports.push(`export const page = () => _page`);
|
|
41
|
-
imports.push(`import { renderers } from "${RENDERERS_MODULE_ID}";`);
|
|
42
|
-
exports.push(`export { renderers };`);
|
|
43
|
-
return { code: `${imports.join("\n")}${exports.join("\n")}` };
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function pluginPages(opts, internals) {
|
|
51
|
-
return {
|
|
52
|
-
targets: ["server"],
|
|
53
|
-
hooks: {
|
|
54
|
-
"build:before": () => {
|
|
55
|
-
return {
|
|
56
|
-
vitePlugin: vitePluginPages(opts, internals)
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
export {
|
|
63
|
-
ASTRO_PAGE_MODULE_ID,
|
|
64
|
-
ASTRO_PAGE_RESOLVED_MODULE_ID,
|
|
65
|
-
pluginPages
|
|
66
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { AstroBuildPlugin } from '../plugin.js';
|
|
2
|
-
import type { StaticBuildOptions } from '../types.js';
|
|
3
|
-
export declare const RENDERERS_MODULE_ID = "@astro-renderers";
|
|
4
|
-
export declare const RESOLVED_RENDERERS_MODULE_ID = "\0@astro-renderers";
|
|
5
|
-
export declare function pluginRenderers(opts: StaticBuildOptions): AstroBuildPlugin;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { addRollupInput } from "../add-rollup-input.js";
|
|
2
|
-
const RENDERERS_MODULE_ID = "@astro-renderers";
|
|
3
|
-
const RESOLVED_RENDERERS_MODULE_ID = `\0${RENDERERS_MODULE_ID}`;
|
|
4
|
-
function vitePluginRenderers(opts) {
|
|
5
|
-
return {
|
|
6
|
-
name: "@astro/plugin-renderers",
|
|
7
|
-
options(options) {
|
|
8
|
-
return addRollupInput(options, [RENDERERS_MODULE_ID]);
|
|
9
|
-
},
|
|
10
|
-
resolveId(id) {
|
|
11
|
-
if (id === RENDERERS_MODULE_ID) {
|
|
12
|
-
return RESOLVED_RENDERERS_MODULE_ID;
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
async load(id) {
|
|
16
|
-
if (id === RESOLVED_RENDERERS_MODULE_ID) {
|
|
17
|
-
if (opts.settings.renderers.length > 0) {
|
|
18
|
-
const imports = [];
|
|
19
|
-
const exports = [];
|
|
20
|
-
let i = 0;
|
|
21
|
-
let rendererItems = "";
|
|
22
|
-
for (const renderer of opts.settings.renderers) {
|
|
23
|
-
const variable = `_renderer${i}`;
|
|
24
|
-
imports.push(`import ${variable} from ${JSON.stringify(renderer.serverEntrypoint)};`);
|
|
25
|
-
rendererItems += `Object.assign(${JSON.stringify(renderer)}, { ssr: ${variable} }),`;
|
|
26
|
-
i++;
|
|
27
|
-
}
|
|
28
|
-
exports.push(`export const renderers = [${rendererItems}];`);
|
|
29
|
-
return { code: `${imports.join("\n")}
|
|
30
|
-
${exports.join("\n")}` };
|
|
31
|
-
} else {
|
|
32
|
-
return { code: `export const renderers = [];` };
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function pluginRenderers(opts) {
|
|
39
|
-
return {
|
|
40
|
-
targets: ["server"],
|
|
41
|
-
hooks: {
|
|
42
|
-
"build:before": () => {
|
|
43
|
-
return {
|
|
44
|
-
vitePlugin: vitePluginRenderers(opts)
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
export {
|
|
51
|
-
RENDERERS_MODULE_ID,
|
|
52
|
-
RESOLVED_RENDERERS_MODULE_ID,
|
|
53
|
-
pluginRenderers
|
|
54
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ModuleLoader } from '../module-loader/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* It accepts a module loader and the astro settings, and it attempts to load the middlewares defined in the configuration.
|
|
4
|
-
*
|
|
5
|
-
* If not middlewares were not set, the function returns an empty array.
|
|
6
|
-
*/
|
|
7
|
-
export declare function loadMiddleware(moduleLoader: ModuleLoader): Promise<Record<string, any>>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { MiddlewareCantBeLoaded } from "../errors/errors-data.js";
|
|
2
|
-
import { AstroError } from "../errors/index.js";
|
|
3
|
-
import { MIDDLEWARE_MODULE_ID } from "./vite-plugin.js";
|
|
4
|
-
async function loadMiddleware(moduleLoader) {
|
|
5
|
-
try {
|
|
6
|
-
return await moduleLoader.import(MIDDLEWARE_MODULE_ID);
|
|
7
|
-
} catch (error) {
|
|
8
|
-
const astroError = new AstroError(MiddlewareCantBeLoaded, { cause: error });
|
|
9
|
-
throw astroError;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
loadMiddleware
|
|
14
|
-
};
|