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,283 +0,0 @@
|
|
|
1
|
-
import { loadActions } from "../actions/loadActions.js";
|
|
2
|
-
import {
|
|
3
|
-
clientLocalsSymbol,
|
|
4
|
-
DEFAULT_404_COMPONENT,
|
|
5
|
-
NOOP_MIDDLEWARE_HEADER,
|
|
6
|
-
REROUTE_DIRECTIVE_HEADER,
|
|
7
|
-
REWRITE_DIRECTIVE_HEADER_KEY
|
|
8
|
-
} from "../core/constants.js";
|
|
9
|
-
import { AstroErrorData, isAstroError } from "../core/errors/index.js";
|
|
10
|
-
import { req } from "../core/messages.js";
|
|
11
|
-
import { loadMiddleware } from "../core/middleware/loadMiddleware.js";
|
|
12
|
-
import { routeIsRedirect } from "../core/redirects/index.js";
|
|
13
|
-
import { getProps } from "../core/render/index.js";
|
|
14
|
-
import { RenderContext } from "../core/render-context.js";
|
|
15
|
-
import { createRequest } from "../core/request.js";
|
|
16
|
-
import { redirectTemplate } from "../core/routing/3xx.js";
|
|
17
|
-
import { matchAllRoutes } from "../core/routing/index.js";
|
|
18
|
-
import { isRoute404, isRoute500 } from "../core/routing/match.js";
|
|
19
|
-
import { PERSIST_SYMBOL } from "../core/session.js";
|
|
20
|
-
import { getSortedPreloadedMatches } from "../prerender/routing.js";
|
|
21
|
-
import { writeSSRResult, writeWebResponse } from "./response.js";
|
|
22
|
-
function isLoggedRequest(url) {
|
|
23
|
-
return url !== "/favicon.ico";
|
|
24
|
-
}
|
|
25
|
-
function getCustom404Route(manifestData) {
|
|
26
|
-
return manifestData.routes.find((r) => isRoute404(r.route));
|
|
27
|
-
}
|
|
28
|
-
function getCustom500Route(manifestData) {
|
|
29
|
-
return manifestData.routes.find((r) => isRoute500(r.route));
|
|
30
|
-
}
|
|
31
|
-
async function matchRoute(pathname, routesList, pipeline) {
|
|
32
|
-
const { config, logger, routeCache, serverLike, settings } = pipeline;
|
|
33
|
-
const matches = matchAllRoutes(pathname, routesList);
|
|
34
|
-
const preloadedMatches = await getSortedPreloadedMatches({ pipeline, matches, settings });
|
|
35
|
-
for await (const { preloadedComponent, route: maybeRoute, filePath } of preloadedMatches) {
|
|
36
|
-
try {
|
|
37
|
-
await getProps({
|
|
38
|
-
mod: preloadedComponent,
|
|
39
|
-
routeData: maybeRoute,
|
|
40
|
-
routeCache,
|
|
41
|
-
pathname,
|
|
42
|
-
logger,
|
|
43
|
-
serverLike,
|
|
44
|
-
base: config.base
|
|
45
|
-
});
|
|
46
|
-
return {
|
|
47
|
-
route: maybeRoute,
|
|
48
|
-
filePath,
|
|
49
|
-
resolvedPathname: pathname,
|
|
50
|
-
preloadedComponent,
|
|
51
|
-
mod: preloadedComponent
|
|
52
|
-
};
|
|
53
|
-
} catch (e) {
|
|
54
|
-
if (isAstroError(e) && e.title === AstroErrorData.NoMatchingStaticPathFound.title) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
throw e;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const altPathname = pathname.replace(/\/index\.html$/, "/").replace(/\.html$/, "");
|
|
61
|
-
if (altPathname !== pathname) {
|
|
62
|
-
return await matchRoute(altPathname, routesList, pipeline);
|
|
63
|
-
}
|
|
64
|
-
if (matches.length) {
|
|
65
|
-
const possibleRoutes = matches.flatMap((route) => route.component);
|
|
66
|
-
logger.warn(
|
|
67
|
-
"router",
|
|
68
|
-
`${AstroErrorData.NoMatchingStaticPathFound.message(
|
|
69
|
-
pathname
|
|
70
|
-
)}
|
|
71
|
-
|
|
72
|
-
${AstroErrorData.NoMatchingStaticPathFound.hint(possibleRoutes)}`
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
const custom404 = getCustom404Route(routesList);
|
|
76
|
-
if (custom404) {
|
|
77
|
-
const filePath = new URL(`./${custom404.component}`, config.root);
|
|
78
|
-
const preloadedComponent = await pipeline.preload(custom404, filePath);
|
|
79
|
-
return {
|
|
80
|
-
route: custom404,
|
|
81
|
-
filePath,
|
|
82
|
-
resolvedPathname: pathname,
|
|
83
|
-
preloadedComponent,
|
|
84
|
-
mod: preloadedComponent
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
return void 0;
|
|
88
|
-
}
|
|
89
|
-
async function handleRoute({
|
|
90
|
-
matchedRoute,
|
|
91
|
-
url,
|
|
92
|
-
pathname,
|
|
93
|
-
body,
|
|
94
|
-
pipeline,
|
|
95
|
-
routesList,
|
|
96
|
-
incomingRequest,
|
|
97
|
-
incomingResponse
|
|
98
|
-
}) {
|
|
99
|
-
const timeStart = performance.now();
|
|
100
|
-
const { config, loader, logger } = pipeline;
|
|
101
|
-
if (!matchedRoute) {
|
|
102
|
-
throw new Error("No route matched, and default 404 route was not found.");
|
|
103
|
-
}
|
|
104
|
-
let request;
|
|
105
|
-
let renderContext;
|
|
106
|
-
let mod = void 0;
|
|
107
|
-
let route;
|
|
108
|
-
const actions = await loadActions(loader);
|
|
109
|
-
pipeline.setActions(actions);
|
|
110
|
-
const middleware = (await loadMiddleware(loader)).onRequest;
|
|
111
|
-
const locals = Reflect.get(incomingRequest, clientLocalsSymbol);
|
|
112
|
-
const { preloadedComponent } = matchedRoute;
|
|
113
|
-
route = matchedRoute.route;
|
|
114
|
-
request = createRequest({
|
|
115
|
-
url,
|
|
116
|
-
headers: incomingRequest.headers,
|
|
117
|
-
method: incomingRequest.method,
|
|
118
|
-
body,
|
|
119
|
-
logger,
|
|
120
|
-
isPrerendered: route.prerender,
|
|
121
|
-
routePattern: route.component
|
|
122
|
-
});
|
|
123
|
-
for (const [name, value] of Object.entries(config.server.headers ?? {})) {
|
|
124
|
-
if (value) incomingResponse.setHeader(name, value);
|
|
125
|
-
}
|
|
126
|
-
mod = preloadedComponent;
|
|
127
|
-
renderContext = await RenderContext.create({
|
|
128
|
-
locals,
|
|
129
|
-
pipeline,
|
|
130
|
-
pathname,
|
|
131
|
-
middleware: isDefaultPrerendered404(matchedRoute.route) ? void 0 : middleware,
|
|
132
|
-
request,
|
|
133
|
-
routeData: route,
|
|
134
|
-
clientAddress: incomingRequest.socket.remoteAddress,
|
|
135
|
-
actions,
|
|
136
|
-
shouldInjectCspMetaTags: false
|
|
137
|
-
});
|
|
138
|
-
let response;
|
|
139
|
-
let statusCode = 200;
|
|
140
|
-
let isReroute = false;
|
|
141
|
-
let isRewrite = false;
|
|
142
|
-
async function renderError(err, skipMiddleware) {
|
|
143
|
-
const custom500 = getCustom500Route(routesList);
|
|
144
|
-
if (!custom500) {
|
|
145
|
-
throw err;
|
|
146
|
-
}
|
|
147
|
-
try {
|
|
148
|
-
const filePath500 = new URL(`./${custom500.component}`, config.root);
|
|
149
|
-
const preloaded500Component = await pipeline.preload(custom500, filePath500);
|
|
150
|
-
renderContext = await RenderContext.create({
|
|
151
|
-
locals,
|
|
152
|
-
pipeline,
|
|
153
|
-
pathname,
|
|
154
|
-
middleware: skipMiddleware ? void 0 : middleware,
|
|
155
|
-
request,
|
|
156
|
-
routeData: route,
|
|
157
|
-
clientAddress: incomingRequest.socket.remoteAddress,
|
|
158
|
-
actions,
|
|
159
|
-
shouldInjectCspMetaTags: false
|
|
160
|
-
});
|
|
161
|
-
renderContext.props.error = err;
|
|
162
|
-
const _response = await renderContext.render(preloaded500Component);
|
|
163
|
-
logger.error("router", err.stack || err.message);
|
|
164
|
-
statusCode = 500;
|
|
165
|
-
return _response;
|
|
166
|
-
} catch (_err) {
|
|
167
|
-
if (isAstroError(_err) && [
|
|
168
|
-
AstroErrorData.MiddlewareNoDataOrNextCalled.name,
|
|
169
|
-
AstroErrorData.MiddlewareNotAResponse.name
|
|
170
|
-
].includes(_err.name)) {
|
|
171
|
-
throw _err;
|
|
172
|
-
}
|
|
173
|
-
if (skipMiddleware === false) {
|
|
174
|
-
return renderError(_err, true);
|
|
175
|
-
}
|
|
176
|
-
throw _err;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
try {
|
|
180
|
-
response = await renderContext.render(mod);
|
|
181
|
-
isReroute = response.headers.has(REROUTE_DIRECTIVE_HEADER);
|
|
182
|
-
isRewrite = response.headers.has(REWRITE_DIRECTIVE_HEADER_KEY);
|
|
183
|
-
const statusCodedMatched = getStatusByMatchedRoute(matchedRoute);
|
|
184
|
-
statusCode = isRewrite ? (
|
|
185
|
-
// Ignore `matchedRoute` status for rewrites
|
|
186
|
-
response.status
|
|
187
|
-
) : (
|
|
188
|
-
// Our internal noop middleware sets a particular header. If the header isn't present, it means that the user have
|
|
189
|
-
// their own middleware, so we need to return what the user returns.
|
|
190
|
-
!response.headers.has(NOOP_MIDDLEWARE_HEADER) && !isReroute ? response.status : statusCodedMatched ?? response.status
|
|
191
|
-
);
|
|
192
|
-
} catch (err) {
|
|
193
|
-
response = await renderError(err, false);
|
|
194
|
-
} finally {
|
|
195
|
-
renderContext.session?.[PERSIST_SYMBOL]();
|
|
196
|
-
}
|
|
197
|
-
if (isLoggedRequest(pathname)) {
|
|
198
|
-
const timeEnd = performance.now();
|
|
199
|
-
logger.info(
|
|
200
|
-
null,
|
|
201
|
-
req({
|
|
202
|
-
url: pathname,
|
|
203
|
-
method: incomingRequest.method,
|
|
204
|
-
statusCode,
|
|
205
|
-
isRewrite,
|
|
206
|
-
reqTime: timeEnd - timeStart
|
|
207
|
-
})
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
if (statusCode === 404 && // If the body isn't null, that means the user sets the 404 status
|
|
211
|
-
// but uses the current route to handle the 404
|
|
212
|
-
response.body === null && response.headers.get(REROUTE_DIRECTIVE_HEADER) !== "no") {
|
|
213
|
-
const fourOhFourRoute = await matchRoute("/404", routesList, pipeline);
|
|
214
|
-
if (fourOhFourRoute) {
|
|
215
|
-
renderContext = await RenderContext.create({
|
|
216
|
-
locals,
|
|
217
|
-
pipeline,
|
|
218
|
-
pathname,
|
|
219
|
-
middleware: isDefaultPrerendered404(fourOhFourRoute.route) ? void 0 : middleware,
|
|
220
|
-
request,
|
|
221
|
-
routeData: fourOhFourRoute.route,
|
|
222
|
-
clientAddress: incomingRequest.socket.remoteAddress,
|
|
223
|
-
shouldInjectCspMetaTags: false
|
|
224
|
-
});
|
|
225
|
-
response = await renderContext.render(fourOhFourRoute.preloadedComponent);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (isReroute) {
|
|
229
|
-
response.headers.delete(REROUTE_DIRECTIVE_HEADER);
|
|
230
|
-
}
|
|
231
|
-
if (isRewrite) {
|
|
232
|
-
response.headers.delete(REROUTE_DIRECTIVE_HEADER);
|
|
233
|
-
}
|
|
234
|
-
if (route.type === "endpoint") {
|
|
235
|
-
await writeWebResponse(incomingResponse, response);
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
if (isRewrite) {
|
|
239
|
-
await writeSSRResult(request, response, incomingResponse);
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
if (response.status < 400 && response.status >= 300) {
|
|
243
|
-
if (response.status >= 300 && response.status < 400 && routeIsRedirect(route) && !config.build.redirects && pipeline.settings.buildOutput === "static") {
|
|
244
|
-
const location = response.headers.get("location");
|
|
245
|
-
response = new Response(
|
|
246
|
-
redirectTemplate({
|
|
247
|
-
status: response.status,
|
|
248
|
-
absoluteLocation: location,
|
|
249
|
-
relativeLocation: location,
|
|
250
|
-
from: pathname
|
|
251
|
-
}),
|
|
252
|
-
{
|
|
253
|
-
status: 200,
|
|
254
|
-
headers: {
|
|
255
|
-
...response.headers,
|
|
256
|
-
"content-type": "text/html"
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
await writeSSRResult(request, response, incomingResponse);
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
if (response.status !== statusCode) {
|
|
265
|
-
response = new Response(response.body, {
|
|
266
|
-
status: statusCode,
|
|
267
|
-
headers: response.headers
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
await writeSSRResult(request, response, incomingResponse);
|
|
271
|
-
}
|
|
272
|
-
function getStatusByMatchedRoute(matchedRoute) {
|
|
273
|
-
if (matchedRoute?.route.route === "/404") return 404;
|
|
274
|
-
if (matchedRoute?.route.route === "/500") return 500;
|
|
275
|
-
return void 0;
|
|
276
|
-
}
|
|
277
|
-
function isDefaultPrerendered404(route) {
|
|
278
|
-
return route.route === "/404" && route.prerender && route.component === DEFAULT_404_COMPONENT;
|
|
279
|
-
}
|
|
280
|
-
export {
|
|
281
|
-
handleRoute,
|
|
282
|
-
matchRoute
|
|
283
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Plugin as VitePlugin } from 'vite';
|
|
2
|
-
import type { Logger } from '../core/logger/core.js';
|
|
3
|
-
import type { AstroSettings, RoutesList } from '../types/astro.js';
|
|
4
|
-
interface AstroPluginScannerOptions {
|
|
5
|
-
settings: AstroSettings;
|
|
6
|
-
logger: Logger;
|
|
7
|
-
routesList: RoutesList;
|
|
8
|
-
}
|
|
9
|
-
export default function astroScannerPlugin({ settings, logger, routesList, }: AstroPluginScannerOptions): VitePlugin;
|
|
10
|
-
export {};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { extname } from "node:path";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import colors from "piccolore";
|
|
4
|
-
import { warnMissingAdapter } from "../core/dev/adapter-validation.js";
|
|
5
|
-
import { getRoutePrerenderOption } from "../core/routing/manifest/prerender.js";
|
|
6
|
-
import { isEndpoint, isPage } from "../core/util.js";
|
|
7
|
-
import { normalizePath, rootRelativePath } from "../core/viteUtils.js";
|
|
8
|
-
import { createDefaultAstroMetadata } from "../vite-plugin-astro/metadata.js";
|
|
9
|
-
const KNOWN_FILE_EXTENSIONS = [".astro", ".js", ".ts"];
|
|
10
|
-
function astroScannerPlugin({
|
|
11
|
-
settings,
|
|
12
|
-
logger,
|
|
13
|
-
routesList
|
|
14
|
-
}) {
|
|
15
|
-
return {
|
|
16
|
-
name: "astro:scanner",
|
|
17
|
-
enforce: "post",
|
|
18
|
-
async transform(code, id, options) {
|
|
19
|
-
if (!options?.ssr) return;
|
|
20
|
-
const filename = normalizePath(id);
|
|
21
|
-
let fileURL;
|
|
22
|
-
try {
|
|
23
|
-
fileURL = new URL(`file://${filename}`);
|
|
24
|
-
} catch {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const fileIsPage = isPage(fileURL, settings);
|
|
28
|
-
const fileIsEndpoint = isEndpoint(fileURL, settings);
|
|
29
|
-
if (!(fileIsPage || fileIsEndpoint)) return;
|
|
30
|
-
const route = routesList.routes.find((r) => {
|
|
31
|
-
const filePath = new URL(`./${r.component}`, settings.config.root);
|
|
32
|
-
return normalizePath(fileURLToPath(filePath)) === filename;
|
|
33
|
-
});
|
|
34
|
-
if (!route) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (!route.prerender && code.includes("getStaticPaths") && // this should only be valid for `.astro`, `.js` and `.ts` files
|
|
38
|
-
KNOWN_FILE_EXTENSIONS.includes(extname(filename))) {
|
|
39
|
-
logger.warn(
|
|
40
|
-
"router",
|
|
41
|
-
`getStaticPaths() ignored in dynamic page ${colors.bold(
|
|
42
|
-
rootRelativePath(settings.config.root, fileURL, true)
|
|
43
|
-
)}. Add \`export const prerender = true;\` to prerender the page as static HTML during the build process.`
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
const { meta = {} } = this.getModuleInfo(id) ?? {};
|
|
47
|
-
return {
|
|
48
|
-
code,
|
|
49
|
-
map: null,
|
|
50
|
-
meta: {
|
|
51
|
-
...meta,
|
|
52
|
-
astro: {
|
|
53
|
-
...meta.astro ?? createDefaultAstroMetadata(),
|
|
54
|
-
pageOptions: {
|
|
55
|
-
prerender: route.prerender
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
},
|
|
61
|
-
// Handle hot updates to update the prerender option
|
|
62
|
-
async handleHotUpdate(ctx) {
|
|
63
|
-
const filename = normalizePath(ctx.file);
|
|
64
|
-
let fileURL;
|
|
65
|
-
try {
|
|
66
|
-
fileURL = new URL(`file://${filename}`);
|
|
67
|
-
} catch {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const fileIsPage = isPage(fileURL, settings);
|
|
71
|
-
const fileIsEndpoint = isEndpoint(fileURL, settings);
|
|
72
|
-
if (!(fileIsPage || fileIsEndpoint)) return;
|
|
73
|
-
const route = routesList.routes.find((r) => {
|
|
74
|
-
const filePath = new URL(`./${r.component}`, settings.config.root);
|
|
75
|
-
return normalizePath(fileURLToPath(filePath)) === filename;
|
|
76
|
-
});
|
|
77
|
-
if (!route) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
await getRoutePrerenderOption(await ctx.read(), route, settings, logger);
|
|
81
|
-
warnMissingAdapter(logger, settings);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
export {
|
|
86
|
-
astroScannerPlugin as default
|
|
87
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const manifestVirtualModuleId = "astro:ssr-manifest";
|
|
2
|
-
const resolvedManifestVirtualModuleId = "\0" + manifestVirtualModuleId;
|
|
3
|
-
function vitePluginSSRManifest() {
|
|
4
|
-
return {
|
|
5
|
-
name: "@astrojs/vite-plugin-astro-ssr-manifest",
|
|
6
|
-
enforce: "post",
|
|
7
|
-
resolveId(id) {
|
|
8
|
-
if (id === manifestVirtualModuleId) {
|
|
9
|
-
return resolvedManifestVirtualModuleId;
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
load(id) {
|
|
13
|
-
if (id === resolvedManifestVirtualModuleId) {
|
|
14
|
-
return {
|
|
15
|
-
code: `export let manifest = {};
|
|
16
|
-
export function _privateSetManifestDontUseThis(ssrManifest) {
|
|
17
|
-
manifest = ssrManifest;
|
|
18
|
-
}`
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export {
|
|
25
|
-
vitePluginSSRManifest
|
|
26
|
-
};
|