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,107 @@
|
|
|
1
|
+
import { decodeKey } from "../encryption.js";
|
|
2
|
+
import { NOOP_MIDDLEWARE_FN } from "../middleware/noop-middleware.js";
|
|
3
|
+
function deserializeManifest(serializedManifest, routesList) {
|
|
4
|
+
const routes = [];
|
|
5
|
+
if (serializedManifest.routes) {
|
|
6
|
+
for (const serializedRoute of serializedManifest.routes) {
|
|
7
|
+
routes.push({
|
|
8
|
+
...serializedRoute,
|
|
9
|
+
routeData: deserializeRouteData(serializedRoute.routeData)
|
|
10
|
+
});
|
|
11
|
+
const route = serializedRoute;
|
|
12
|
+
route.routeData = deserializeRouteData(serializedRoute.routeData);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (routesList) {
|
|
16
|
+
for (const route of routesList?.routes) {
|
|
17
|
+
routes.push({
|
|
18
|
+
file: "",
|
|
19
|
+
links: [],
|
|
20
|
+
scripts: [],
|
|
21
|
+
styles: [],
|
|
22
|
+
routeData: route
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const assets = new Set(serializedManifest.assets);
|
|
27
|
+
const componentMetadata = new Map(serializedManifest.componentMetadata);
|
|
28
|
+
const inlinedScripts = new Map(serializedManifest.inlinedScripts);
|
|
29
|
+
const clientDirectives = new Map(serializedManifest.clientDirectives);
|
|
30
|
+
const key = decodeKey(serializedManifest.key);
|
|
31
|
+
return {
|
|
32
|
+
// in case user middleware exists, this no-op middleware will be reassigned (see plugin-ssr.ts)
|
|
33
|
+
middleware() {
|
|
34
|
+
return { onRequest: NOOP_MIDDLEWARE_FN };
|
|
35
|
+
},
|
|
36
|
+
...serializedManifest,
|
|
37
|
+
rootDir: new URL(serializedManifest.rootDir),
|
|
38
|
+
srcDir: new URL(serializedManifest.srcDir),
|
|
39
|
+
publicDir: new URL(serializedManifest.publicDir),
|
|
40
|
+
outDir: new URL(serializedManifest.outDir),
|
|
41
|
+
cacheDir: new URL(serializedManifest.cacheDir),
|
|
42
|
+
buildClientDir: new URL(serializedManifest.buildClientDir),
|
|
43
|
+
buildServerDir: new URL(serializedManifest.buildServerDir),
|
|
44
|
+
assets,
|
|
45
|
+
componentMetadata,
|
|
46
|
+
inlinedScripts,
|
|
47
|
+
clientDirectives,
|
|
48
|
+
routes,
|
|
49
|
+
key
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function serializeRouteData(routeData, trailingSlash) {
|
|
53
|
+
return {
|
|
54
|
+
...routeData,
|
|
55
|
+
pattern: routeData.pattern.source,
|
|
56
|
+
redirectRoute: routeData.redirectRoute ? serializeRouteData(routeData.redirectRoute, trailingSlash) : void 0,
|
|
57
|
+
fallbackRoutes: routeData.fallbackRoutes.map((fallbackRoute) => {
|
|
58
|
+
return serializeRouteData(fallbackRoute, trailingSlash);
|
|
59
|
+
}),
|
|
60
|
+
_meta: { trailingSlash }
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function deserializeRouteData(rawRouteData) {
|
|
64
|
+
return {
|
|
65
|
+
route: rawRouteData.route,
|
|
66
|
+
type: rawRouteData.type,
|
|
67
|
+
pattern: new RegExp(rawRouteData.pattern),
|
|
68
|
+
params: rawRouteData.params,
|
|
69
|
+
component: rawRouteData.component,
|
|
70
|
+
pathname: rawRouteData.pathname || void 0,
|
|
71
|
+
segments: rawRouteData.segments,
|
|
72
|
+
prerender: rawRouteData.prerender,
|
|
73
|
+
redirect: rawRouteData.redirect,
|
|
74
|
+
redirectRoute: rawRouteData.redirectRoute ? deserializeRouteData(rawRouteData.redirectRoute) : void 0,
|
|
75
|
+
fallbackRoutes: rawRouteData.fallbackRoutes.map((fallback) => {
|
|
76
|
+
return deserializeRouteData(fallback);
|
|
77
|
+
}),
|
|
78
|
+
isIndex: rawRouteData.isIndex,
|
|
79
|
+
origin: rawRouteData.origin,
|
|
80
|
+
distURL: rawRouteData.distURL
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function serializeRouteInfo(routeInfo, trailingSlash) {
|
|
84
|
+
return {
|
|
85
|
+
styles: routeInfo.styles,
|
|
86
|
+
file: routeInfo.file,
|
|
87
|
+
links: routeInfo.links,
|
|
88
|
+
scripts: routeInfo.scripts,
|
|
89
|
+
routeData: serializeRouteData(routeInfo.routeData, trailingSlash)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function deserializeRouteInfo(rawRouteInfo) {
|
|
93
|
+
return {
|
|
94
|
+
styles: rawRouteInfo.styles,
|
|
95
|
+
file: rawRouteInfo.file,
|
|
96
|
+
links: rawRouteInfo.links,
|
|
97
|
+
scripts: rawRouteInfo.scripts,
|
|
98
|
+
routeData: deserializeRouteData(rawRouteInfo.routeData)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
deserializeManifest,
|
|
103
|
+
deserializeRouteData,
|
|
104
|
+
deserializeRouteInfo,
|
|
105
|
+
serializeRouteData,
|
|
106
|
+
serializeRouteInfo
|
|
107
|
+
};
|
package/dist/core/app/node.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
import type { RemotePattern } from '../../types/public/config.js';
|
|
3
|
-
import type { RouteData } from '../../types/public/internal.js';
|
|
4
3
|
import type { RenderOptions } from './index.js';
|
|
5
4
|
import { App } from './index.js';
|
|
6
5
|
import type { NodeAppHeadersJson, SSRManifest } from './types.js';
|
|
7
|
-
export { apply as applyPolyfills } from '../polyfill.js';
|
|
8
6
|
/**
|
|
9
7
|
* Allow the request body to be explicitly overridden. For example, this
|
|
10
8
|
* is used by the Express JSON middleware.
|
|
@@ -15,13 +13,8 @@ interface NodeRequest extends IncomingMessage {
|
|
|
15
13
|
export declare class NodeApp extends App {
|
|
16
14
|
headersMap: NodeAppHeadersJson | undefined;
|
|
17
15
|
setHeadersMap(headers: NodeAppHeadersJson): void;
|
|
18
|
-
match(req: NodeRequest | Request, allowPrerenderedRoutes?: boolean): RouteData | undefined;
|
|
16
|
+
match(req: NodeRequest | Request, allowPrerenderedRoutes?: boolean): import("../../index.js").RouteData | undefined;
|
|
19
17
|
render(request: NodeRequest | Request, options?: RenderOptions): Promise<Response>;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Instead of passing `RouteData` and locals individually, pass an object with `routeData` and `locals` properties.
|
|
22
|
-
* See https://github.com/withastro/astro/pull/9199 for more information.
|
|
23
|
-
*/
|
|
24
|
-
render(request: NodeRequest | Request, routeData?: RouteData, locals?: object): Promise<Response>;
|
|
25
18
|
/**
|
|
26
19
|
* Converts a NodeJS IncomingMessage into a web standard Request.
|
|
27
20
|
* ```js
|
|
@@ -58,3 +51,4 @@ export declare class NodeApp extends App {
|
|
|
58
51
|
}
|
|
59
52
|
export declare function loadManifest(rootFolder: URL): Promise<SSRManifest>;
|
|
60
53
|
export declare function loadApp(rootFolder: URL): Promise<NodeApp>;
|
|
54
|
+
export {};
|
package/dist/core/app/node.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { Http2ServerResponse } from "node:http2";
|
|
3
3
|
import { clientAddressSymbol, nodeRequestAbortControllerCleanupSymbol } from "../constants.js";
|
|
4
|
-
import { deserializeManifest } from "./
|
|
4
|
+
import { deserializeManifest } from "./manifest.js";
|
|
5
5
|
import { createOutgoingHttpHeaders } from "./createOutgoingHttpHeaders.js";
|
|
6
6
|
import { App } from "./index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { sanitizeHost, validateForwardedHeaders } from "./validate-forwarded-headers.js";
|
|
8
8
|
class NodeApp extends App {
|
|
9
9
|
headersMap = void 0;
|
|
10
10
|
setHeadersMap(headers) {
|
|
@@ -19,13 +19,13 @@ class NodeApp extends App {
|
|
|
19
19
|
}
|
|
20
20
|
return super.match(req, allowPrerenderedRoutes);
|
|
21
21
|
}
|
|
22
|
-
render(
|
|
23
|
-
if (!(
|
|
24
|
-
|
|
22
|
+
render(request, options) {
|
|
23
|
+
if (!(request instanceof Request)) {
|
|
24
|
+
request = NodeApp.createRequest(request, {
|
|
25
25
|
allowedDomains: this.manifest.allowedDomains
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
return super.render(
|
|
28
|
+
return super.render(request, options);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Converts a NodeJS IncomingMessage into a web standard Request.
|
|
@@ -51,14 +51,14 @@ class NodeApp extends App {
|
|
|
51
51
|
};
|
|
52
52
|
const providedProtocol = isEncrypted ? "https" : "http";
|
|
53
53
|
const providedHostname = req.headers.host ?? req.headers[":authority"];
|
|
54
|
-
const validated =
|
|
54
|
+
const validated = validateForwardedHeaders(
|
|
55
55
|
getFirstForwardedValue(req.headers["x-forwarded-proto"]),
|
|
56
56
|
getFirstForwardedValue(req.headers["x-forwarded-host"]),
|
|
57
57
|
getFirstForwardedValue(req.headers["x-forwarded-port"]),
|
|
58
58
|
allowedDomains
|
|
59
59
|
);
|
|
60
60
|
const protocol = validated.protocol ?? providedProtocol;
|
|
61
|
-
const sanitizedProvidedHostname =
|
|
61
|
+
const sanitizedProvidedHostname = sanitizeHost(
|
|
62
62
|
typeof providedHostname === "string" ? providedHostname : void 0
|
|
63
63
|
);
|
|
64
64
|
const hostname = validated.host ?? sanitizedProvidedHostname;
|
|
@@ -258,7 +258,6 @@ async function loadApp(rootFolder) {
|
|
|
258
258
|
}
|
|
259
259
|
export {
|
|
260
260
|
NodeApp,
|
|
261
|
-
apply as applyPolyfills,
|
|
262
261
|
loadApp,
|
|
263
262
|
loadManifest
|
|
264
263
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { ComponentInstance } from '../../types/astro.js';
|
|
2
2
|
import type { RewritePayload } from '../../types/public/common.js';
|
|
3
|
-
import type { RouteData
|
|
4
|
-
import { Pipeline, type TryRewriteResult } from '../base-pipeline.js';
|
|
3
|
+
import type { RouteData } from '../../types/public/internal.js';
|
|
4
|
+
import { type HeadElements, Pipeline, type TryRewriteResult } from '../base-pipeline.js';
|
|
5
5
|
import type { SinglePageBuiltModule } from '../build/types.js';
|
|
6
6
|
export declare class AppPipeline extends Pipeline {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
getName(): string;
|
|
8
|
+
static create({ manifest, streaming }: Pick<AppPipeline, 'manifest' | 'streaming'>): AppPipeline;
|
|
9
|
+
headElements(routeData: RouteData): Promise<HeadElements>;
|
|
9
10
|
componentMetadata(): void;
|
|
10
11
|
getComponentByRoute(routeData: RouteData): Promise<ComponentInstance>;
|
|
11
|
-
tryRewrite(payload: RewritePayload, request: Request): Promise<TryRewriteResult>;
|
|
12
12
|
getModuleForRoute(route: RouteData): Promise<SinglePageBuiltModule>;
|
|
13
|
+
tryRewrite(payload: RewritePayload, request: Request): Promise<TryRewriteResult>;
|
|
13
14
|
}
|
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
import { Pipeline } from "../base-pipeline.js";
|
|
2
|
-
import { RedirectSinglePageBuiltModule } from "../redirects/
|
|
3
|
-
import {
|
|
2
|
+
import { RedirectSinglePageBuiltModule } from "../redirects/index.js";
|
|
3
|
+
import {
|
|
4
|
+
createAssetLink,
|
|
5
|
+
createModuleScriptElement,
|
|
6
|
+
createStylesheetElementSet
|
|
7
|
+
} from "../render/ssr-element.js";
|
|
8
|
+
import { getFallbackRoute, routeIsFallback, routeIsRedirect } from "../routing/helpers.js";
|
|
4
9
|
import { findRouteToRewrite } from "../routing/rewrite.js";
|
|
10
|
+
import { createConsoleLogger } from "./logging.js";
|
|
5
11
|
class AppPipeline extends Pipeline {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
getName() {
|
|
13
|
+
return "AppPipeline";
|
|
14
|
+
}
|
|
15
|
+
static create({ manifest, streaming }) {
|
|
16
|
+
const resolve = async function resolve2(specifier) {
|
|
17
|
+
if (!(specifier in manifest.entryModules)) {
|
|
18
|
+
throw new Error(`Unable to resolve [${specifier}]`);
|
|
19
|
+
}
|
|
20
|
+
const bundlePath = manifest.entryModules[specifier];
|
|
21
|
+
if (bundlePath.startsWith("data:") || bundlePath.length === 0) {
|
|
22
|
+
return bundlePath;
|
|
23
|
+
} else {
|
|
24
|
+
return createAssetLink(bundlePath, manifest.base, manifest.assetsPrefix);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const logger = createConsoleLogger(manifest.logLevel);
|
|
16
28
|
const pipeline = new AppPipeline(
|
|
17
29
|
logger,
|
|
18
30
|
manifest,
|
|
19
|
-
|
|
20
|
-
renderers,
|
|
31
|
+
"production",
|
|
32
|
+
manifest.renderers,
|
|
21
33
|
resolve,
|
|
22
|
-
serverLike,
|
|
23
34
|
streaming,
|
|
24
35
|
void 0,
|
|
25
36
|
void 0,
|
|
@@ -28,16 +39,16 @@ class AppPipeline extends Pipeline {
|
|
|
28
39
|
void 0,
|
|
29
40
|
void 0,
|
|
30
41
|
void 0,
|
|
31
|
-
void 0
|
|
32
|
-
defaultRoutes
|
|
42
|
+
void 0
|
|
33
43
|
);
|
|
34
44
|
return pipeline;
|
|
35
45
|
}
|
|
36
|
-
headElements(routeData) {
|
|
46
|
+
async headElements(routeData) {
|
|
47
|
+
const { assetsPrefix, base } = this.manifest;
|
|
37
48
|
const routeInfo = this.manifest.routes.find((route) => route.routeData === routeData);
|
|
38
49
|
const links = /* @__PURE__ */ new Set();
|
|
39
50
|
const scripts = /* @__PURE__ */ new Set();
|
|
40
|
-
const styles = createStylesheetElementSet(routeInfo?.styles ?? []);
|
|
51
|
+
const styles = createStylesheetElementSet(routeInfo?.styles ?? [], base, assetsPrefix);
|
|
41
52
|
for (const script of routeInfo?.scripts ?? []) {
|
|
42
53
|
if ("stage" in script) {
|
|
43
54
|
if (script.stage === "head-inline") {
|
|
@@ -47,7 +58,7 @@ class AppPipeline extends Pipeline {
|
|
|
47
58
|
});
|
|
48
59
|
}
|
|
49
60
|
} else {
|
|
50
|
-
scripts.add(createModuleScriptElement(script));
|
|
61
|
+
scripts.add(createModuleScriptElement(script, base, assetsPrefix));
|
|
51
62
|
}
|
|
52
63
|
}
|
|
53
64
|
return { links, styles, scripts };
|
|
@@ -58,6 +69,39 @@ class AppPipeline extends Pipeline {
|
|
|
58
69
|
const module = await this.getModuleForRoute(routeData);
|
|
59
70
|
return module.page();
|
|
60
71
|
}
|
|
72
|
+
async getModuleForRoute(route) {
|
|
73
|
+
for (const defaultRoute of this.defaultRoutes) {
|
|
74
|
+
if (route.component === defaultRoute.component) {
|
|
75
|
+
return {
|
|
76
|
+
page: () => Promise.resolve(defaultRoute.instance)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
let routeToProcess = route;
|
|
81
|
+
if (routeIsRedirect(route)) {
|
|
82
|
+
if (route.redirectRoute) {
|
|
83
|
+
routeToProcess = route.redirectRoute;
|
|
84
|
+
} else {
|
|
85
|
+
return RedirectSinglePageBuiltModule;
|
|
86
|
+
}
|
|
87
|
+
} else if (routeIsFallback(route)) {
|
|
88
|
+
routeToProcess = getFallbackRoute(route, this.manifest.routes);
|
|
89
|
+
}
|
|
90
|
+
if (this.manifest.pageMap) {
|
|
91
|
+
const importComponentInstance = this.manifest.pageMap.get(routeToProcess.component);
|
|
92
|
+
if (!importComponentInstance) {
|
|
93
|
+
throw new Error(
|
|
94
|
+
`Unexpectedly unable to find a component instance for route ${route.route}`
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return await importComponentInstance();
|
|
98
|
+
} else if (this.manifest.pageModule) {
|
|
99
|
+
return this.manifest.pageModule;
|
|
100
|
+
}
|
|
101
|
+
throw new Error(
|
|
102
|
+
"Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error, please file an issue."
|
|
103
|
+
);
|
|
104
|
+
}
|
|
61
105
|
async tryRewrite(payload, request) {
|
|
62
106
|
const { newUrl, pathname, routeData } = findRouteToRewrite({
|
|
63
107
|
payload,
|
|
@@ -66,39 +110,11 @@ class AppPipeline extends Pipeline {
|
|
|
66
110
|
trailingSlash: this.manifest.trailingSlash,
|
|
67
111
|
buildFormat: this.manifest.buildFormat,
|
|
68
112
|
base: this.manifest.base,
|
|
69
|
-
outDir: this.serverLike ? this.manifest.buildClientDir : this.manifest.outDir
|
|
113
|
+
outDir: this.manifest?.serverLike ? this.manifest.buildClientDir : this.manifest.outDir
|
|
70
114
|
});
|
|
71
115
|
const componentInstance = await this.getComponentByRoute(routeData);
|
|
72
116
|
return { newUrl, pathname, componentInstance, routeData };
|
|
73
117
|
}
|
|
74
|
-
async getModuleForRoute(route) {
|
|
75
|
-
for (const defaultRoute of this.defaultRoutes) {
|
|
76
|
-
if (route.component === defaultRoute.component) {
|
|
77
|
-
return {
|
|
78
|
-
page: () => Promise.resolve(defaultRoute.instance),
|
|
79
|
-
renderers: []
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (route.type === "redirect") {
|
|
84
|
-
return RedirectSinglePageBuiltModule;
|
|
85
|
-
} else {
|
|
86
|
-
if (this.manifest.pageMap) {
|
|
87
|
-
const importComponentInstance = this.manifest.pageMap.get(route.component);
|
|
88
|
-
if (!importComponentInstance) {
|
|
89
|
-
throw new Error(
|
|
90
|
-
`Unexpectedly unable to find a component instance for route ${route.route}`
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
return await importComponentInstance();
|
|
94
|
-
} else if (this.manifest.pageModule) {
|
|
95
|
-
return this.manifest.pageModule;
|
|
96
|
-
}
|
|
97
|
-
throw new Error(
|
|
98
|
-
"Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error, please file an issue."
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
118
|
}
|
|
103
119
|
export {
|
|
104
120
|
AppPipeline
|
package/dist/core/app/types.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ActionAccept, ActionClient } from '../../actions/runtime/server.js';
|
|
3
|
-
import type { RoutingStrategies } from '../../i18n/utils.js';
|
|
1
|
+
import type { ActionClient } from '../../actions/runtime/types.js';
|
|
4
2
|
import type { ComponentInstance, SerializedRouteData } from '../../types/astro.js';
|
|
5
3
|
import type { AstroMiddlewareInstance } from '../../types/public/common.js';
|
|
6
4
|
import type { AstroConfig, CspAlgorithm, Locales, RemotePattern, ResolvedSessionConfig } from '../../types/public/config.js';
|
|
7
5
|
import type { RouteData, SSRComponentMetadata, SSRLoadedRenderer, SSRResult } from '../../types/public/internal.js';
|
|
8
6
|
import type { SinglePageBuiltModule } from '../build/types.js';
|
|
9
7
|
import type { CspDirective } from '../csp/config.js';
|
|
8
|
+
import type { LoggerLevel } from '../logger/core.js';
|
|
9
|
+
import type { SessionDriver } from '../session.js';
|
|
10
|
+
import type { RoutingStrategies } from './common.js';
|
|
10
11
|
type ComponentPath = string;
|
|
11
12
|
export type StylesheetAsset = {
|
|
12
13
|
type: 'inline';
|
|
@@ -15,28 +16,32 @@ export type StylesheetAsset = {
|
|
|
15
16
|
type: 'external';
|
|
16
17
|
src: string;
|
|
17
18
|
};
|
|
19
|
+
type ScriptAsset = {
|
|
20
|
+
children: string;
|
|
21
|
+
stage: string;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'inline' | 'external';
|
|
24
|
+
value: string;
|
|
25
|
+
};
|
|
18
26
|
export interface RouteInfo {
|
|
19
27
|
routeData: RouteData;
|
|
20
28
|
file: string;
|
|
21
29
|
links: string[];
|
|
22
|
-
scripts:
|
|
23
|
-
children: string;
|
|
24
|
-
stage: string;
|
|
25
|
-
} | {
|
|
26
|
-
type: 'inline' | 'external';
|
|
27
|
-
value: string;
|
|
28
|
-
})[];
|
|
30
|
+
scripts: ScriptAsset[];
|
|
29
31
|
styles: StylesheetAsset[];
|
|
30
32
|
}
|
|
31
33
|
export type SerializedRouteInfo = Omit<RouteInfo, 'routeData'> & {
|
|
32
34
|
routeData: SerializedRouteData;
|
|
33
35
|
};
|
|
34
36
|
type ImportComponentInstance = () => Promise<SinglePageBuiltModule>;
|
|
37
|
+
export type ServerIslandMappings = {
|
|
38
|
+
serverIslandMap?: Map<string, () => Promise<ComponentInstance>>;
|
|
39
|
+
serverIslandNameMap?: Map<string, string>;
|
|
40
|
+
};
|
|
35
41
|
export type AssetsPrefix = string | ({
|
|
36
42
|
fallback: string;
|
|
37
43
|
} & Record<string, string>) | undefined;
|
|
38
44
|
export type SSRManifest = {
|
|
39
|
-
hrefRoot: string;
|
|
40
45
|
adapterName: string;
|
|
41
46
|
routes: RouteInfo[];
|
|
42
47
|
site?: string;
|
|
@@ -53,6 +58,13 @@ export type SSRManifest = {
|
|
|
53
58
|
compressHTML: boolean;
|
|
54
59
|
assetsPrefix?: AssetsPrefix;
|
|
55
60
|
renderers: SSRLoadedRenderer[];
|
|
61
|
+
/**
|
|
62
|
+
* Based on Astro config's `output` option, `true` if "server" or "hybrid".
|
|
63
|
+
*
|
|
64
|
+
* Whether this application is SSR-like. If so, this has some implications, such as
|
|
65
|
+
* the creation of `dist/client` and `dist/server` folders.
|
|
66
|
+
*/
|
|
67
|
+
serverLike: boolean;
|
|
56
68
|
/**
|
|
57
69
|
* Map of directive name (e.g. `load`) to the directive script code
|
|
58
70
|
*/
|
|
@@ -63,26 +75,43 @@ export type SSRManifest = {
|
|
|
63
75
|
componentMetadata: SSRResult['componentMetadata'];
|
|
64
76
|
pageModule?: SinglePageBuiltModule;
|
|
65
77
|
pageMap?: Map<ComponentPath, ImportComponentInstance>;
|
|
66
|
-
|
|
67
|
-
serverIslandNameMap?: Map<string, string>;
|
|
78
|
+
serverIslandMappings?: () => Promise<ServerIslandMappings> | ServerIslandMappings;
|
|
68
79
|
key: Promise<CryptoKey>;
|
|
69
80
|
i18n: SSRManifestI18n | undefined;
|
|
70
81
|
middleware?: () => Promise<AstroMiddlewareInstance> | AstroMiddlewareInstance;
|
|
71
82
|
actions?: () => Promise<SSRActions> | SSRActions;
|
|
83
|
+
sessionDriver?: () => Promise<{
|
|
84
|
+
default: SessionDriver | null;
|
|
85
|
+
}>;
|
|
72
86
|
checkOrigin: boolean;
|
|
73
87
|
allowedDomains?: Partial<RemotePattern>[];
|
|
74
88
|
sessionConfig?: ResolvedSessionConfig<any>;
|
|
75
|
-
cacheDir:
|
|
76
|
-
srcDir:
|
|
77
|
-
outDir:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
cacheDir: URL;
|
|
90
|
+
srcDir: URL;
|
|
91
|
+
outDir: URL;
|
|
92
|
+
rootDir: URL;
|
|
93
|
+
publicDir: URL;
|
|
94
|
+
assetsDir: string;
|
|
95
|
+
buildClientDir: URL;
|
|
96
|
+
buildServerDir: URL;
|
|
81
97
|
csp: SSRManifestCSP | undefined;
|
|
98
|
+
devToolbar: {
|
|
99
|
+
enabled: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Latest version of Astro, will be undefined if:
|
|
102
|
+
* - unable to check
|
|
103
|
+
* - the user has disabled the check
|
|
104
|
+
* - the check has not completed yet
|
|
105
|
+
* - the user is on the latest version already
|
|
106
|
+
*/
|
|
107
|
+
latestAstroVersion: string | undefined;
|
|
108
|
+
debugInfoOutput: string | undefined;
|
|
109
|
+
};
|
|
82
110
|
internalFetchHeaders?: Record<string, string>;
|
|
111
|
+
logLevel: LoggerLevel;
|
|
83
112
|
};
|
|
84
113
|
export type SSRActions = {
|
|
85
|
-
server: Record<string, ActionClient<
|
|
114
|
+
server: Record<string, ActionClient<any, any, any>>;
|
|
86
115
|
};
|
|
87
116
|
export type SSRManifestI18n = {
|
|
88
117
|
fallback: Record<string, string> | undefined;
|
|
@@ -91,6 +120,7 @@ export type SSRManifestI18n = {
|
|
|
91
120
|
locales: Locales;
|
|
92
121
|
defaultLocale: string;
|
|
93
122
|
domainLookupTable: Record<string, string>;
|
|
123
|
+
domains: Record<string, string> | undefined;
|
|
94
124
|
};
|
|
95
125
|
export type SSRManifestCSP = {
|
|
96
126
|
cspDestination: 'adapter' | 'meta' | 'header' | undefined;
|
|
@@ -103,13 +133,19 @@ export type SSRManifestCSP = {
|
|
|
103
133
|
directives: CspDirective[];
|
|
104
134
|
};
|
|
105
135
|
/** Public type exposed through the `astro:build:ssr` integration hook */
|
|
106
|
-
export type SerializedSSRManifest = Omit<SSRManifest, 'middleware' | 'routes' | 'assets' | 'componentMetadata' | 'inlinedScripts' | 'clientDirectives' | 'serverIslandNameMap' | 'key'> & {
|
|
136
|
+
export type SerializedSSRManifest = Omit<SSRManifest, 'middleware' | 'routes' | 'assets' | 'componentMetadata' | 'inlinedScripts' | 'clientDirectives' | 'serverIslandNameMap' | 'key' | 'rootDir' | 'srcDir' | 'cacheDir' | 'outDir' | 'publicDir' | 'buildClientDir' | 'buildServerDir'> & {
|
|
137
|
+
rootDir: string;
|
|
138
|
+
srcDir: string;
|
|
139
|
+
cacheDir: string;
|
|
140
|
+
outDir: string;
|
|
141
|
+
publicDir: string;
|
|
142
|
+
buildClientDir: string;
|
|
143
|
+
buildServerDir: string;
|
|
107
144
|
routes: SerializedRouteInfo[];
|
|
108
145
|
assets: string[];
|
|
109
146
|
componentMetadata: [string, SSRComponentMetadata][];
|
|
110
147
|
inlinedScripts: [string, string][];
|
|
111
148
|
clientDirectives: [string, string][];
|
|
112
|
-
serverIslandNameMap: [string, string][];
|
|
113
149
|
key: string;
|
|
114
150
|
};
|
|
115
151
|
export type NodeAppHeadersJson = {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RemotePattern } from '../../assets/utils/remotePattern.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validate a hostname by rejecting any with path separators.
|
|
4
|
+
* Prevents path injection attacks. Invalid hostnames return undefined.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sanitizeHost(hostname: string | undefined): string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Validate forwarded headers (proto, host, port) against allowedDomains.
|
|
9
|
+
* Returns validated values or undefined for rejected headers.
|
|
10
|
+
* Uses strict defaults: http/https only for proto, rejects port if not in allowedDomains.
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateForwardedHeaders(forwardedProtocol?: string, forwardedHost?: string, forwardedPort?: string, allowedDomains?: Partial<RemotePattern>[]): {
|
|
13
|
+
protocol?: string;
|
|
14
|
+
host?: string;
|
|
15
|
+
port?: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { matchPattern } from "../../assets/utils/remotePattern.js";
|
|
2
|
+
function sanitizeHost(hostname) {
|
|
3
|
+
if (!hostname) return void 0;
|
|
4
|
+
if (/[/\\]/.test(hostname)) return void 0;
|
|
5
|
+
return hostname;
|
|
6
|
+
}
|
|
7
|
+
function validateForwardedHeaders(forwardedProtocol, forwardedHost, forwardedPort, allowedDomains) {
|
|
8
|
+
const result = {};
|
|
9
|
+
if (forwardedProtocol) {
|
|
10
|
+
if (allowedDomains && allowedDomains.length > 0) {
|
|
11
|
+
const hasProtocolPatterns = allowedDomains.some((pattern) => pattern.protocol !== void 0);
|
|
12
|
+
if (hasProtocolPatterns) {
|
|
13
|
+
try {
|
|
14
|
+
const testUrl = new URL(`${forwardedProtocol}://example.com`);
|
|
15
|
+
const isAllowed = allowedDomains.some((pattern) => matchPattern(testUrl, pattern));
|
|
16
|
+
if (isAllowed) {
|
|
17
|
+
result.protocol = forwardedProtocol;
|
|
18
|
+
}
|
|
19
|
+
} catch {
|
|
20
|
+
}
|
|
21
|
+
} else if (/^https?$/.test(forwardedProtocol)) {
|
|
22
|
+
result.protocol = forwardedProtocol;
|
|
23
|
+
}
|
|
24
|
+
} else if (/^https?$/.test(forwardedProtocol)) {
|
|
25
|
+
result.protocol = forwardedProtocol;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (forwardedPort && allowedDomains && allowedDomains.length > 0) {
|
|
29
|
+
const hasPortPatterns = allowedDomains.some((pattern) => pattern.port !== void 0);
|
|
30
|
+
if (hasPortPatterns) {
|
|
31
|
+
const isAllowed = allowedDomains.some((pattern) => pattern.port === forwardedPort);
|
|
32
|
+
if (isAllowed) {
|
|
33
|
+
result.port = forwardedPort;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (forwardedHost && forwardedHost.length > 0 && allowedDomains && allowedDomains.length > 0) {
|
|
38
|
+
const protoForValidation = result.protocol || "https";
|
|
39
|
+
const sanitized = sanitizeHost(forwardedHost);
|
|
40
|
+
if (sanitized) {
|
|
41
|
+
try {
|
|
42
|
+
const hostnameOnly = sanitized.split(":")[0];
|
|
43
|
+
const portFromHost = sanitized.includes(":") ? sanitized.split(":")[1] : void 0;
|
|
44
|
+
const portForValidation = result.port || portFromHost;
|
|
45
|
+
const hostWithPort = portForValidation ? `${hostnameOnly}:${portForValidation}` : hostnameOnly;
|
|
46
|
+
const testUrl = new URL(`${protoForValidation}://${hostWithPort}`);
|
|
47
|
+
const isAllowed = allowedDomains.some((pattern) => matchPattern(testUrl, pattern));
|
|
48
|
+
if (isAllowed) {
|
|
49
|
+
result.host = sanitized;
|
|
50
|
+
}
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
sanitizeHost,
|
|
59
|
+
validateForwardedHeaders
|
|
60
|
+
};
|