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
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
import { prependForwardSlash, removeTrailingForwardSlash } from "@astrojs/internal-helpers/path";
|
|
2
|
+
import { BaseApp } from "../core/app/index.js";
|
|
3
|
+
import { shouldAppendForwardSlash } from "../core/build/util.js";
|
|
4
|
+
import {
|
|
5
|
+
clientLocalsSymbol,
|
|
6
|
+
DEFAULT_404_COMPONENT,
|
|
7
|
+
NOOP_MIDDLEWARE_HEADER,
|
|
8
|
+
REROUTE_DIRECTIVE_HEADER,
|
|
9
|
+
REWRITE_DIRECTIVE_HEADER_KEY
|
|
10
|
+
} from "../core/constants.js";
|
|
11
|
+
import {
|
|
12
|
+
MiddlewareNoDataOrNextCalled,
|
|
13
|
+
MiddlewareNotAResponse,
|
|
14
|
+
NoMatchingStaticPathFound
|
|
15
|
+
} from "../core/errors/errors-data.js";
|
|
16
|
+
import { createSafeError, isAstroError } from "../core/errors/index.js";
|
|
17
|
+
import { req } from "../core/messages.js";
|
|
18
|
+
import { getProps } from "../core/render/index.js";
|
|
19
|
+
import { createRequest } from "../core/request.js";
|
|
20
|
+
import { redirectTemplate } from "../core/routing/3xx.js";
|
|
21
|
+
import { matchAllRoutes, routeIsRedirect } from "../core/routing/index.js";
|
|
22
|
+
import { isRoute404, isRoute500 } from "../core/routing/match.js";
|
|
23
|
+
import { PERSIST_SYMBOL } from "../core/session.js";
|
|
24
|
+
import { getSortedPreloadedMatches } from "../prerender/routing.js";
|
|
25
|
+
import { recordServerError } from "../vite-plugin-astro-server/error.js";
|
|
26
|
+
import { runWithErrorHandling } from "../vite-plugin-astro-server/index.js";
|
|
27
|
+
import {
|
|
28
|
+
handle500Response,
|
|
29
|
+
writeSSRResult,
|
|
30
|
+
writeWebResponse
|
|
31
|
+
} from "../vite-plugin-astro-server/response.js";
|
|
32
|
+
import { AstroServerPipeline } from "./pipeline.js";
|
|
33
|
+
class AstroServerApp extends BaseApp {
|
|
34
|
+
settings;
|
|
35
|
+
logger;
|
|
36
|
+
loader;
|
|
37
|
+
manifestData;
|
|
38
|
+
currentRenderContext = void 0;
|
|
39
|
+
constructor(manifest, streaming = true, logger, manifestData, loader, settings, getDebugInfo) {
|
|
40
|
+
super(manifest, streaming, settings, logger, loader, manifestData, getDebugInfo);
|
|
41
|
+
this.settings = settings;
|
|
42
|
+
this.logger = logger;
|
|
43
|
+
this.loader = loader;
|
|
44
|
+
this.manifestData = manifestData;
|
|
45
|
+
}
|
|
46
|
+
static async create(manifest, routesList, logger, loader, settings, getDebugInfo) {
|
|
47
|
+
return new AstroServerApp(manifest, true, logger, routesList, loader, settings, getDebugInfo);
|
|
48
|
+
}
|
|
49
|
+
createPipeline(_streaming, manifest, settings, logger, loader, manifestData, getDebugInfo) {
|
|
50
|
+
return AstroServerPipeline.create(manifestData, {
|
|
51
|
+
loader,
|
|
52
|
+
logger,
|
|
53
|
+
manifest,
|
|
54
|
+
settings,
|
|
55
|
+
getDebugInfo
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async createRenderContext(payload) {
|
|
59
|
+
this.currentRenderContext = await super.createRenderContext(payload);
|
|
60
|
+
return this.currentRenderContext;
|
|
61
|
+
}
|
|
62
|
+
clearRouteCache() {
|
|
63
|
+
this.pipeline.clearRouteCache();
|
|
64
|
+
}
|
|
65
|
+
async handleRequest({
|
|
66
|
+
controller,
|
|
67
|
+
incomingRequest,
|
|
68
|
+
incomingResponse,
|
|
69
|
+
isHttps
|
|
70
|
+
}) {
|
|
71
|
+
const origin = `${isHttps ? "https" : "http"}://${incomingRequest.headers[":authority"] ?? incomingRequest.headers.host}`;
|
|
72
|
+
const url = new URL(origin + incomingRequest.url);
|
|
73
|
+
let pathname;
|
|
74
|
+
if (this.manifest.trailingSlash === "never" && !incomingRequest.url) {
|
|
75
|
+
pathname = "";
|
|
76
|
+
} else {
|
|
77
|
+
pathname = decodeURI(url.pathname);
|
|
78
|
+
}
|
|
79
|
+
url.pathname = removeTrailingForwardSlash(this.manifest.base) + url.pathname;
|
|
80
|
+
if (url.pathname.endsWith("/") && !shouldAppendForwardSlash(this.manifest.trailingSlash, this.manifest.buildFormat)) {
|
|
81
|
+
url.pathname = url.pathname.slice(0, -1);
|
|
82
|
+
}
|
|
83
|
+
let body = void 0;
|
|
84
|
+
if (!(incomingRequest.method === "GET" || incomingRequest.method === "HEAD")) {
|
|
85
|
+
let bytes = [];
|
|
86
|
+
await new Promise((resolve) => {
|
|
87
|
+
incomingRequest.on("data", (part) => {
|
|
88
|
+
bytes.push(part);
|
|
89
|
+
});
|
|
90
|
+
incomingRequest.on("end", resolve);
|
|
91
|
+
});
|
|
92
|
+
body = Buffer.concat(bytes);
|
|
93
|
+
}
|
|
94
|
+
const self = this;
|
|
95
|
+
await runWithErrorHandling({
|
|
96
|
+
controller,
|
|
97
|
+
pathname,
|
|
98
|
+
async run() {
|
|
99
|
+
const matchedRoute = await matchRoute(
|
|
100
|
+
pathname,
|
|
101
|
+
self.manifestData,
|
|
102
|
+
self.pipeline,
|
|
103
|
+
self.manifest
|
|
104
|
+
);
|
|
105
|
+
const resolvedPathname = matchedRoute?.resolvedPathname ?? pathname;
|
|
106
|
+
return await self.handleRoute({
|
|
107
|
+
matchedRoute,
|
|
108
|
+
url,
|
|
109
|
+
pathname: resolvedPathname,
|
|
110
|
+
body,
|
|
111
|
+
incomingRequest,
|
|
112
|
+
incomingResponse
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
onError(_err) {
|
|
116
|
+
const error = createSafeError(_err);
|
|
117
|
+
if (self.loader) {
|
|
118
|
+
const { errorWithMetadata } = recordServerError(
|
|
119
|
+
self.loader,
|
|
120
|
+
self.manifest,
|
|
121
|
+
self.logger,
|
|
122
|
+
error
|
|
123
|
+
);
|
|
124
|
+
handle500Response(self.loader, incomingResponse, errorWithMetadata);
|
|
125
|
+
}
|
|
126
|
+
return error;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async handleRoute({
|
|
131
|
+
matchedRoute,
|
|
132
|
+
incomingRequest,
|
|
133
|
+
incomingResponse,
|
|
134
|
+
body,
|
|
135
|
+
url,
|
|
136
|
+
pathname
|
|
137
|
+
}) {
|
|
138
|
+
const timeStart = performance.now();
|
|
139
|
+
const { logger } = this.pipeline;
|
|
140
|
+
if (!matchedRoute) {
|
|
141
|
+
throw new Error("No route matched, and default 404 route was not found.");
|
|
142
|
+
}
|
|
143
|
+
let request;
|
|
144
|
+
let renderContext;
|
|
145
|
+
let route = matchedRoute.route;
|
|
146
|
+
const componentInstance = await this.pipeline.getComponentByRoute(route);
|
|
147
|
+
const locals = Reflect.get(incomingRequest, clientLocalsSymbol);
|
|
148
|
+
request = createRequest({
|
|
149
|
+
url,
|
|
150
|
+
headers: incomingRequest.headers,
|
|
151
|
+
method: incomingRequest.method,
|
|
152
|
+
body,
|
|
153
|
+
logger,
|
|
154
|
+
isPrerendered: route.prerender,
|
|
155
|
+
routePattern: route.component
|
|
156
|
+
});
|
|
157
|
+
for (const [name, value] of Object.entries(this.settings.config.server.headers ?? {})) {
|
|
158
|
+
if (value) incomingResponse.setHeader(name, value);
|
|
159
|
+
}
|
|
160
|
+
renderContext = await this.createRenderContext({
|
|
161
|
+
locals,
|
|
162
|
+
pipeline: this.pipeline,
|
|
163
|
+
pathname,
|
|
164
|
+
skipMiddleware: isDefaultPrerendered404(matchedRoute.route),
|
|
165
|
+
request,
|
|
166
|
+
routeData: route,
|
|
167
|
+
clientAddress: incomingRequest.socket.remoteAddress,
|
|
168
|
+
shouldInjectCspMetaTags: false
|
|
169
|
+
});
|
|
170
|
+
let response;
|
|
171
|
+
let statusCode = 200;
|
|
172
|
+
let isReroute = false;
|
|
173
|
+
let isRewrite = false;
|
|
174
|
+
try {
|
|
175
|
+
response = await renderContext.render(componentInstance);
|
|
176
|
+
isReroute = response.headers.has(REROUTE_DIRECTIVE_HEADER);
|
|
177
|
+
isRewrite = response.headers.has(REWRITE_DIRECTIVE_HEADER_KEY);
|
|
178
|
+
const statusCodedMatched = getStatusByMatchedRoute(route);
|
|
179
|
+
statusCode = isRewrite ? (
|
|
180
|
+
// Ignore `matchedRoute` status for rewrites
|
|
181
|
+
response.status
|
|
182
|
+
) : (
|
|
183
|
+
// Our internal noop middleware sets a particular header. If the header isn't present, it means that the user have
|
|
184
|
+
// their own middleware, so we need to return what the user returns.
|
|
185
|
+
!response.headers.has(NOOP_MIDDLEWARE_HEADER) && !isReroute ? response.status : statusCodedMatched ?? response.status
|
|
186
|
+
);
|
|
187
|
+
} catch (err) {
|
|
188
|
+
response = await this.renderError(request, {
|
|
189
|
+
skipMiddleware: false,
|
|
190
|
+
locals,
|
|
191
|
+
status: 500,
|
|
192
|
+
prerenderedErrorPageFetch: fetch,
|
|
193
|
+
clientAddress: incomingRequest.socket.remoteAddress,
|
|
194
|
+
error: err
|
|
195
|
+
});
|
|
196
|
+
statusCode = 500;
|
|
197
|
+
} finally {
|
|
198
|
+
this.currentRenderContext?.session?.[PERSIST_SYMBOL]();
|
|
199
|
+
}
|
|
200
|
+
if (isLoggedRequest(pathname)) {
|
|
201
|
+
const timeEnd = performance.now();
|
|
202
|
+
logger.info(
|
|
203
|
+
null,
|
|
204
|
+
req({
|
|
205
|
+
url: pathname,
|
|
206
|
+
method: incomingRequest.method,
|
|
207
|
+
statusCode,
|
|
208
|
+
isRewrite,
|
|
209
|
+
reqTime: timeEnd - timeStart
|
|
210
|
+
})
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
if (statusCode === 404 && // If the body isn't null, that means the user sets the 404 status
|
|
214
|
+
// but uses the current route to handle the 404
|
|
215
|
+
response.body === null && response.headers.get(REROUTE_DIRECTIVE_HEADER) !== "no") {
|
|
216
|
+
const fourOhFourRoute = await matchRoute(
|
|
217
|
+
"/404",
|
|
218
|
+
this.manifestData,
|
|
219
|
+
this.pipeline,
|
|
220
|
+
this.manifest
|
|
221
|
+
);
|
|
222
|
+
if (fourOhFourRoute) {
|
|
223
|
+
renderContext = await this.createRenderContext({
|
|
224
|
+
locals,
|
|
225
|
+
pipeline: this.pipeline,
|
|
226
|
+
pathname,
|
|
227
|
+
skipMiddleware: isDefaultPrerendered404(fourOhFourRoute.route),
|
|
228
|
+
request,
|
|
229
|
+
routeData: fourOhFourRoute.route,
|
|
230
|
+
clientAddress: incomingRequest.socket.remoteAddress,
|
|
231
|
+
status: 404,
|
|
232
|
+
shouldInjectCspMetaTags: false
|
|
233
|
+
});
|
|
234
|
+
const component = await this.pipeline.preload(
|
|
235
|
+
fourOhFourRoute.route,
|
|
236
|
+
fourOhFourRoute.filePath
|
|
237
|
+
);
|
|
238
|
+
response = await renderContext.render(component);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (isReroute) {
|
|
242
|
+
response.headers.delete(REROUTE_DIRECTIVE_HEADER);
|
|
243
|
+
}
|
|
244
|
+
if (isRewrite) {
|
|
245
|
+
response.headers.delete(REROUTE_DIRECTIVE_HEADER);
|
|
246
|
+
}
|
|
247
|
+
if (route.type === "endpoint") {
|
|
248
|
+
await writeWebResponse(incomingResponse, response);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (isRewrite) {
|
|
252
|
+
await writeSSRResult(request, response, incomingResponse);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (response.status < 400 && response.status >= 300) {
|
|
256
|
+
if (response.status >= 300 && response.status < 400 && routeIsRedirect(route) && !this.settings.config.build.redirects && this.settings.buildOutput === "static") {
|
|
257
|
+
const location = response.headers.get("location");
|
|
258
|
+
response = new Response(
|
|
259
|
+
redirectTemplate({
|
|
260
|
+
status: response.status,
|
|
261
|
+
absoluteLocation: location,
|
|
262
|
+
relativeLocation: location,
|
|
263
|
+
from: pathname
|
|
264
|
+
}),
|
|
265
|
+
{
|
|
266
|
+
status: 200,
|
|
267
|
+
headers: {
|
|
268
|
+
...response.headers,
|
|
269
|
+
"content-type": "text/html"
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
await writeSSRResult(request, response, incomingResponse);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
if (response.status !== statusCode) {
|
|
278
|
+
response = new Response(response.body, {
|
|
279
|
+
status: statusCode,
|
|
280
|
+
headers: response.headers
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
await writeSSRResult(request, response, incomingResponse);
|
|
284
|
+
}
|
|
285
|
+
match(request, _allowPrerenderedRoutes) {
|
|
286
|
+
const url = new URL(request.url);
|
|
287
|
+
if (this.manifest.assets.has(url.pathname)) return void 0;
|
|
288
|
+
let pathname = prependForwardSlash(this.removeBase(url.pathname));
|
|
289
|
+
return this.manifestData.routes.find((route) => {
|
|
290
|
+
return route.pattern.test(pathname) || route.fallbackRoutes.some((fallbackRoute) => fallbackRoute.pattern.test(pathname));
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
async renderError(request, { locals, skipMiddleware = false, error, clientAddress, status }) {
|
|
294
|
+
if (isAstroError(error) && [MiddlewareNoDataOrNextCalled.name, MiddlewareNotAResponse.name].includes(error.name)) {
|
|
295
|
+
throw error;
|
|
296
|
+
}
|
|
297
|
+
const custom500 = getCustom500Route(this.manifestData);
|
|
298
|
+
if (!custom500) {
|
|
299
|
+
throw error;
|
|
300
|
+
}
|
|
301
|
+
try {
|
|
302
|
+
const filePath500 = new URL(`./${custom500.component}`, this.manifest.rootDir);
|
|
303
|
+
const preloaded500Component = await this.pipeline.preload(custom500, filePath500);
|
|
304
|
+
const renderContext = await this.createRenderContext({
|
|
305
|
+
locals,
|
|
306
|
+
pipeline: this.pipeline,
|
|
307
|
+
pathname: this.getPathnameFromRequest(request),
|
|
308
|
+
skipMiddleware,
|
|
309
|
+
request,
|
|
310
|
+
routeData: custom500,
|
|
311
|
+
clientAddress,
|
|
312
|
+
status,
|
|
313
|
+
shouldInjectCspMetaTags: false
|
|
314
|
+
});
|
|
315
|
+
renderContext.props.error = error;
|
|
316
|
+
const response = await renderContext.render(preloaded500Component);
|
|
317
|
+
this.logger.error("router", error.stack || error.message);
|
|
318
|
+
return response;
|
|
319
|
+
} catch (_err) {
|
|
320
|
+
if (skipMiddleware === false) {
|
|
321
|
+
return this.renderError(request, {
|
|
322
|
+
clientAddress: void 0,
|
|
323
|
+
prerenderedErrorPageFetch: fetch,
|
|
324
|
+
status: 500,
|
|
325
|
+
skipMiddleware: true,
|
|
326
|
+
error: _err
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
throw _err;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function getStatusByMatchedRoute(route) {
|
|
334
|
+
if (route.route === "/404") return 404;
|
|
335
|
+
if (route.route === "/500") return 500;
|
|
336
|
+
return void 0;
|
|
337
|
+
}
|
|
338
|
+
function isDefaultPrerendered404(route) {
|
|
339
|
+
return route.route === "/404" && route.prerender && route.component === DEFAULT_404_COMPONENT;
|
|
340
|
+
}
|
|
341
|
+
function isLoggedRequest(url) {
|
|
342
|
+
return url !== "/favicon.ico";
|
|
343
|
+
}
|
|
344
|
+
async function matchRoute(pathname, routesList, pipeline, manifest) {
|
|
345
|
+
const { logger, routeCache } = pipeline;
|
|
346
|
+
const matches = matchAllRoutes(pathname, routesList);
|
|
347
|
+
const preloadedMatches = await getSortedPreloadedMatches({
|
|
348
|
+
pipeline,
|
|
349
|
+
matches,
|
|
350
|
+
manifest
|
|
351
|
+
});
|
|
352
|
+
for await (const { route: maybeRoute, filePath } of preloadedMatches) {
|
|
353
|
+
try {
|
|
354
|
+
await getProps({
|
|
355
|
+
mod: await pipeline.preload(maybeRoute, filePath),
|
|
356
|
+
routeData: maybeRoute,
|
|
357
|
+
routeCache,
|
|
358
|
+
pathname,
|
|
359
|
+
logger,
|
|
360
|
+
serverLike: pipeline.manifest.serverLike,
|
|
361
|
+
base: manifest.base,
|
|
362
|
+
trailingSlash: manifest.trailingSlash
|
|
363
|
+
});
|
|
364
|
+
return {
|
|
365
|
+
route: maybeRoute,
|
|
366
|
+
filePath,
|
|
367
|
+
resolvedPathname: pathname
|
|
368
|
+
};
|
|
369
|
+
} catch (e) {
|
|
370
|
+
if (isAstroError(e) && e.title === NoMatchingStaticPathFound.title) {
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
throw e;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
const altPathname = pathname.replace(/\/index\.html$/, "/").replace(/\.html$/, "");
|
|
377
|
+
if (altPathname !== pathname) {
|
|
378
|
+
return await matchRoute(altPathname, routesList, pipeline, manifest);
|
|
379
|
+
}
|
|
380
|
+
if (matches.length) {
|
|
381
|
+
const possibleRoutes = matches.flatMap((route) => route.component);
|
|
382
|
+
logger.warn(
|
|
383
|
+
"router",
|
|
384
|
+
`${NoMatchingStaticPathFound.message(
|
|
385
|
+
pathname
|
|
386
|
+
)}
|
|
387
|
+
|
|
388
|
+
${NoMatchingStaticPathFound.hint(possibleRoutes)}`
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
const custom404 = getCustom404Route(routesList);
|
|
392
|
+
if (custom404) {
|
|
393
|
+
const filePath = new URL(`./${custom404.component}`, manifest.rootDir);
|
|
394
|
+
return {
|
|
395
|
+
route: custom404,
|
|
396
|
+
filePath,
|
|
397
|
+
resolvedPathname: pathname
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
return void 0;
|
|
401
|
+
}
|
|
402
|
+
function getCustom404Route(manifestData) {
|
|
403
|
+
return manifestData.routes.find((r) => isRoute404(r.route));
|
|
404
|
+
}
|
|
405
|
+
function getCustom500Route(manifestData) {
|
|
406
|
+
return manifestData.routes.find((r) => isRoute500(r.route));
|
|
407
|
+
}
|
|
408
|
+
export {
|
|
409
|
+
AstroServerApp
|
|
410
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type http from 'node:http';
|
|
2
|
+
import { Logger } from '../core/logger/core.js';
|
|
3
|
+
import type { ModuleLoader } from '../core/module-loader/index.js';
|
|
4
|
+
import type { AstroSettings } from '../types/astro.js';
|
|
5
|
+
import type { DevServerController } from '../vite-plugin-astro-server/controller.js';
|
|
6
|
+
export default function createAstroServerApp(controller: DevServerController, settings: AstroSettings, loader: ModuleLoader, logger?: Logger): Promise<{
|
|
7
|
+
handler(incomingRequest: http.IncomingMessage, incomingResponse: http.ServerResponse): void;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { manifest } from "virtual:astro:manifest";
|
|
2
|
+
import { routes } from "virtual:astro:routes";
|
|
3
|
+
import { getPackageManager } from "../cli/info/core/get-package-manager.js";
|
|
4
|
+
import { DevDebugInfoProvider } from "../cli/info/infra/dev-debug-info-provider.js";
|
|
5
|
+
import { ProcessNodeVersionProvider } from "../cli/info/infra/process-node-version-provider.js";
|
|
6
|
+
import { ProcessPackageManagerUserAgentProvider } from "../cli/info/infra/process-package-manager-user-agent-provider.js";
|
|
7
|
+
import { StyledDebugInfoFormatter } from "../cli/info/infra/styled-debug-info-formatter.js";
|
|
8
|
+
import { BuildTimeAstroVersionProvider } from "../cli/infra/build-time-astro-version-provider.js";
|
|
9
|
+
import { PassthroughTextStyler } from "../cli/infra/passthrough-text-styler.js";
|
|
10
|
+
import { ProcessOperatingSystemProvider } from "../cli/infra/process-operating-system-provider.js";
|
|
11
|
+
import { TinyexecCommandExecutor } from "../cli/infra/tinyexec-command-executor.js";
|
|
12
|
+
import { Logger } from "../core/logger/core.js";
|
|
13
|
+
import { nodeLogDestination } from "../core/logger/node.js";
|
|
14
|
+
import { AstroServerApp } from "./app.js";
|
|
15
|
+
async function createAstroServerApp(controller, settings, loader, logger) {
|
|
16
|
+
const actualLogger = logger ?? new Logger({
|
|
17
|
+
dest: nodeLogDestination,
|
|
18
|
+
level: settings.logLevel
|
|
19
|
+
});
|
|
20
|
+
const routesList = { routes: routes.map((r) => r.routeData) };
|
|
21
|
+
const debugInfoProvider = new DevDebugInfoProvider({
|
|
22
|
+
config: settings.config,
|
|
23
|
+
astroVersionProvider: new BuildTimeAstroVersionProvider(),
|
|
24
|
+
operatingSystemProvider: new ProcessOperatingSystemProvider(),
|
|
25
|
+
packageManager: await getPackageManager({
|
|
26
|
+
packageManagerUserAgentProvider: new ProcessPackageManagerUserAgentProvider(),
|
|
27
|
+
commandExecutor: new TinyexecCommandExecutor()
|
|
28
|
+
}),
|
|
29
|
+
nodeVersionProvider: new ProcessNodeVersionProvider()
|
|
30
|
+
});
|
|
31
|
+
const debugInfoFormatter = new StyledDebugInfoFormatter({
|
|
32
|
+
textStyler: new PassthroughTextStyler()
|
|
33
|
+
});
|
|
34
|
+
const debugInfo = debugInfoFormatter.format(await debugInfoProvider.get());
|
|
35
|
+
const app = await AstroServerApp.create(
|
|
36
|
+
manifest,
|
|
37
|
+
routesList,
|
|
38
|
+
actualLogger,
|
|
39
|
+
loader,
|
|
40
|
+
settings,
|
|
41
|
+
async () => debugInfo
|
|
42
|
+
);
|
|
43
|
+
return {
|
|
44
|
+
handler(incomingRequest, incomingResponse) {
|
|
45
|
+
app.handleRequest({
|
|
46
|
+
controller,
|
|
47
|
+
incomingRequest,
|
|
48
|
+
incomingResponse,
|
|
49
|
+
isHttps: loader?.isHttps() ?? false
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
createAstroServerApp as default
|
|
56
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const ASTRO_DEV_APP_ID = "astro:app";
|
|
2
|
+
function vitePluginApp() {
|
|
3
|
+
return {
|
|
4
|
+
name: "astro:app",
|
|
5
|
+
async resolveId(id) {
|
|
6
|
+
if (id === ASTRO_DEV_APP_ID) {
|
|
7
|
+
const url = new URL("./createAstroServerApp.js", import.meta.url);
|
|
8
|
+
return await this.resolve(url.toString());
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
ASTRO_DEV_APP_ID,
|
|
15
|
+
vitePluginApp
|
|
16
|
+
};
|
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type HeadElements, Pipeline, type TryRewriteResult } from '../core/base-pipeline.js';
|
|
2
2
|
import type { Logger } from '../core/logger/core.js';
|
|
3
3
|
import type { ModuleLoader } from '../core/module-loader/index.js';
|
|
4
|
-
import { Pipeline } from '../core/render/index.js';
|
|
5
4
|
import type { AstroSettings, ComponentInstance, RoutesList } from '../types/astro.js';
|
|
6
|
-
import type { RewritePayload } from '../types/public/
|
|
7
|
-
|
|
8
|
-
export declare class DevPipeline extends Pipeline {
|
|
5
|
+
import type { RewritePayload, RouteData, SSRLoadedRenderer, SSRManifest } from '../types/public/index.js';
|
|
6
|
+
export declare class AstroServerPipeline extends Pipeline {
|
|
9
7
|
readonly loader: ModuleLoader;
|
|
10
8
|
readonly logger: Logger;
|
|
11
9
|
readonly manifest: SSRManifest;
|
|
12
10
|
readonly settings: AstroSettings;
|
|
13
11
|
readonly getDebugInfo: () => Promise<string>;
|
|
14
|
-
readonly config: import("../index.js").AstroConfig;
|
|
15
12
|
readonly defaultRoutes: {
|
|
16
13
|
instance: ComponentInstance;
|
|
17
14
|
matchesComponent(filePath: URL): boolean;
|
|
18
15
|
route: string;
|
|
19
16
|
component: string;
|
|
20
17
|
}[];
|
|
18
|
+
getName(): string;
|
|
21
19
|
renderers: SSRLoadedRenderer[];
|
|
22
20
|
routesList: RoutesList | undefined;
|
|
23
21
|
componentInterner: WeakMap<RouteData, ComponentInstance>;
|
|
24
22
|
private constructor();
|
|
25
|
-
static create(manifestData: RoutesList, { loader, logger, manifest, settings, getDebugInfo, }: Pick<
|
|
23
|
+
static create(manifestData: RoutesList, { loader, logger, manifest, settings, getDebugInfo, }: Pick<AstroServerPipeline, 'loader' | 'logger' | 'manifest' | 'settings' | 'getDebugInfo'>): AstroServerPipeline;
|
|
26
24
|
headElements(routeData: RouteData): Promise<HeadElements>;
|
|
27
25
|
componentMetadata(routeData: RouteData): Promise<Map<string, import("../types/public/internal.js").SSRComponentMetadata>>;
|
|
28
26
|
preload(routeData: RouteData, filePath: URL): Promise<ComponentInstance>;
|