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,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BuildApp } from '../../core/build/app.js';
|
|
2
2
|
import type { Logger } from '../../core/logger/core.js';
|
|
3
3
|
import type { MapValue } from '../../type-utils.js';
|
|
4
4
|
import type { AstroConfig } from '../../types/public/config.js';
|
|
@@ -17,7 +17,7 @@ type AssetEnv = {
|
|
|
17
17
|
imageConfig: AstroConfig['image'];
|
|
18
18
|
assetsFolder: AstroConfig['build']['assets'];
|
|
19
19
|
};
|
|
20
|
-
export declare function prepareAssetsGenerationEnv(
|
|
20
|
+
export declare function prepareAssetsGenerationEnv(app: BuildApp, totalCount: number): Promise<AssetEnv>;
|
|
21
21
|
export declare function generateImagesForPath(originalFilePath: string, transformsAndPath: MapValue<AssetsGlobalStaticImagesList>, env: AssetEnv): Promise<void>;
|
|
22
22
|
export declare function getStaticImageList(): AssetsGlobalStaticImagesList;
|
|
23
23
|
export {};
|
|
@@ -9,10 +9,12 @@ import { isRemotePath, removeLeadingForwardSlash } from "../../core/path.js";
|
|
|
9
9
|
import { getConfiguredImageService } from "../internal.js";
|
|
10
10
|
import { isESMImportedImage } from "../utils/imageKind.js";
|
|
11
11
|
import { loadRemoteImage, revalidateRemoteImage } from "./remote.js";
|
|
12
|
-
async function prepareAssetsGenerationEnv(
|
|
13
|
-
const
|
|
12
|
+
async function prepareAssetsGenerationEnv(app, totalCount) {
|
|
13
|
+
const settings = app.getSettings();
|
|
14
|
+
const logger = app.logger;
|
|
15
|
+
const manifest = app.getManifest();
|
|
14
16
|
let useCache = true;
|
|
15
|
-
const assetsCacheDir = new URL("assets/",
|
|
17
|
+
const assetsCacheDir = new URL("assets/", app.manifest.cacheDir);
|
|
16
18
|
const count = { total: totalCount, current: 1 };
|
|
17
19
|
try {
|
|
18
20
|
await fs.promises.mkdir(assetsCacheDir, { recursive: true });
|
|
@@ -26,11 +28,11 @@ async function prepareAssetsGenerationEnv(pipeline, totalCount) {
|
|
|
26
28
|
const isServerOutput = settings.buildOutput === "server";
|
|
27
29
|
let serverRoot, clientRoot;
|
|
28
30
|
if (isServerOutput) {
|
|
29
|
-
serverRoot =
|
|
30
|
-
clientRoot =
|
|
31
|
+
serverRoot = manifest.buildServerDir;
|
|
32
|
+
clientRoot = manifest.buildClientDir;
|
|
31
33
|
} else {
|
|
32
|
-
serverRoot = getOutDirWithinCwd(
|
|
33
|
-
clientRoot =
|
|
34
|
+
serverRoot = getOutDirWithinCwd(manifest.outDir);
|
|
35
|
+
clientRoot = manifest.outDir;
|
|
34
36
|
}
|
|
35
37
|
return {
|
|
36
38
|
logger,
|
|
@@ -40,8 +42,8 @@ async function prepareAssetsGenerationEnv(pipeline, totalCount) {
|
|
|
40
42
|
assetsCacheDir,
|
|
41
43
|
serverRoot,
|
|
42
44
|
clientRoot,
|
|
43
|
-
imageConfig: config.image,
|
|
44
|
-
assetsFolder:
|
|
45
|
+
imageConfig: settings.config.image,
|
|
46
|
+
assetsFolder: manifest.assetsDir
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
49
|
function getFullImagePath(originalFilePath, env) {
|
|
@@ -48,27 +48,17 @@ async function revalidateRemoteImage(src, revalidationData) {
|
|
|
48
48
|
lastModified: res.headers.get("Last-Modified") ?? (res.ok ? void 0 : revalidationData.lastModified)
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
function webToCachePolicyRequest({ url, method, headers
|
|
52
|
-
let headers = {};
|
|
53
|
-
try {
|
|
54
|
-
headers = Object.fromEntries(_headers.entries());
|
|
55
|
-
} catch {
|
|
56
|
-
}
|
|
51
|
+
function webToCachePolicyRequest({ url, method, headers }) {
|
|
57
52
|
return {
|
|
58
53
|
method,
|
|
59
54
|
url,
|
|
60
|
-
headers
|
|
55
|
+
headers: Object.fromEntries(headers.entries())
|
|
61
56
|
};
|
|
62
57
|
}
|
|
63
|
-
function webToCachePolicyResponse({ status, headers
|
|
64
|
-
let headers = {};
|
|
65
|
-
try {
|
|
66
|
-
headers = Object.fromEntries(_headers.entries());
|
|
67
|
-
} catch {
|
|
68
|
-
}
|
|
58
|
+
function webToCachePolicyResponse({ status, headers }) {
|
|
69
59
|
return {
|
|
70
60
|
status,
|
|
71
|
-
headers
|
|
61
|
+
headers: Object.fromEntries(headers.entries())
|
|
72
62
|
};
|
|
73
63
|
}
|
|
74
64
|
export {
|
|
@@ -28,11 +28,11 @@ function getImageEndpointData(settings, mode, cwd) {
|
|
|
28
28
|
segments,
|
|
29
29
|
params: [],
|
|
30
30
|
component: resolveInjectedRoute(endpointEntrypoint, settings.config.root, cwd).component,
|
|
31
|
-
generate: () => "",
|
|
32
31
|
pathname: settings.config.image.endpoint.route,
|
|
33
32
|
prerender: false,
|
|
34
33
|
fallbackRoutes: [],
|
|
35
|
-
origin: "internal"
|
|
34
|
+
origin: "internal",
|
|
35
|
+
distURL: []
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
export {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { root } from "astro:config/server";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
import os from "node:os";
|
|
4
3
|
import { fileURLToPath } from "node:url";
|
|
5
4
|
import { isParentDirectory } from "@astrojs/internal-helpers/path";
|
|
6
5
|
import { handleImageRequest, loadRemoteImage } from "./shared.js";
|
|
7
|
-
function replaceFileSystemReferences(src) {
|
|
8
|
-
return os.platform().includes("win32") ? src.replace(/^\/@fs\//, "") : src.replace(/^\/@fs/, "");
|
|
9
|
-
}
|
|
10
6
|
async function loadLocalImage(src, url) {
|
|
11
7
|
if (src.startsWith("/@fs/")) {
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
try {
|
|
9
|
+
const res = await fetch(new URL(src, url));
|
|
10
|
+
if (!res.ok) {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
13
|
+
return Buffer.from(await res.arrayBuffer());
|
|
14
|
+
} catch {
|
|
14
15
|
return void 0;
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -1,192 +1,104 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const weightSchema: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
3
|
-
export declare const styleSchema: z.ZodEnum<
|
|
4
|
-
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
export declare const weightSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
3
|
+
export declare const styleSchema: z.ZodEnum<{
|
|
4
|
+
normal: "normal";
|
|
5
|
+
italic: "italic";
|
|
6
|
+
oblique: "oblique";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const displaySchema: z.ZodEnum<{
|
|
9
|
+
optional: "optional";
|
|
10
|
+
auto: "auto";
|
|
11
|
+
block: "block";
|
|
12
|
+
swap: "swap";
|
|
13
|
+
fallback: "fallback";
|
|
14
|
+
}>;
|
|
5
15
|
export declare const localFontFamilySchema: z.ZodObject<{
|
|
6
16
|
provider: z.ZodLiteral<"local">;
|
|
7
|
-
variants: z.
|
|
8
|
-
src: z.
|
|
9
|
-
url: z.ZodUnion<[z.ZodString, z.
|
|
17
|
+
variants: z.ZodTuple<[z.ZodObject<{
|
|
18
|
+
src: z.ZodTuple<[z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>, z.ZodObject<{
|
|
19
|
+
url: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>;
|
|
20
|
+
tech: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strict>]>], z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>, z.ZodObject<{
|
|
22
|
+
url: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>;
|
|
23
|
+
tech: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strict>]>>;
|
|
25
|
+
weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
26
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
27
|
+
normal: "normal";
|
|
28
|
+
italic: "italic";
|
|
29
|
+
oblique: "oblique";
|
|
30
|
+
}>>;
|
|
31
|
+
display: z.ZodOptional<z.ZodEnum<{
|
|
32
|
+
optional: "optional";
|
|
33
|
+
auto: "auto";
|
|
34
|
+
block: "block";
|
|
35
|
+
swap: "swap";
|
|
36
|
+
fallback: "fallback";
|
|
37
|
+
}>>;
|
|
38
|
+
stretch: z.ZodOptional<z.ZodString>;
|
|
39
|
+
featureSettings: z.ZodOptional<z.ZodString>;
|
|
40
|
+
variationSettings: z.ZodOptional<z.ZodString>;
|
|
41
|
+
unicodeRange: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodString>>;
|
|
42
|
+
}, z.core.$strict>], z.ZodObject<{
|
|
43
|
+
src: z.ZodTuple<[z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>, z.ZodObject<{
|
|
44
|
+
url: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>;
|
|
45
|
+
tech: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strict>]>], z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>, z.ZodObject<{
|
|
47
|
+
url: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>;
|
|
10
48
|
tech: z.ZodOptional<z.ZodString>;
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
49
|
+
}, z.core.$strict>]>>;
|
|
50
|
+
weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
51
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
52
|
+
normal: "normal";
|
|
53
|
+
italic: "italic";
|
|
54
|
+
oblique: "oblique";
|
|
55
|
+
}>>;
|
|
56
|
+
display: z.ZodOptional<z.ZodEnum<{
|
|
57
|
+
optional: "optional";
|
|
58
|
+
auto: "auto";
|
|
59
|
+
block: "block";
|
|
60
|
+
swap: "swap";
|
|
61
|
+
fallback: "fallback";
|
|
62
|
+
}>>;
|
|
21
63
|
stretch: z.ZodOptional<z.ZodString>;
|
|
22
64
|
featureSettings: z.ZodOptional<z.ZodString>;
|
|
23
65
|
variationSettings: z.ZodOptional<z.ZodString>;
|
|
24
|
-
unicodeRange: z.ZodOptional<z.
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
url: string | URL;
|
|
28
|
-
tech?: string | undefined;
|
|
29
|
-
}, ...(string | URL | {
|
|
30
|
-
url: string | URL;
|
|
31
|
-
tech?: string | undefined;
|
|
32
|
-
})[]];
|
|
33
|
-
weight?: string | number | undefined;
|
|
34
|
-
style?: "normal" | "italic" | "oblique" | undefined;
|
|
35
|
-
display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
|
|
36
|
-
stretch?: string | undefined;
|
|
37
|
-
featureSettings?: string | undefined;
|
|
38
|
-
variationSettings?: string | undefined;
|
|
39
|
-
unicodeRange?: [string, ...string[]] | undefined;
|
|
40
|
-
}, {
|
|
41
|
-
src: [string | URL | {
|
|
42
|
-
url: string | URL;
|
|
43
|
-
tech?: string | undefined;
|
|
44
|
-
}, ...(string | URL | {
|
|
45
|
-
url: string | URL;
|
|
46
|
-
tech?: string | undefined;
|
|
47
|
-
})[]];
|
|
48
|
-
weight?: string | number | undefined;
|
|
49
|
-
style?: "normal" | "italic" | "oblique" | undefined;
|
|
50
|
-
display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
|
|
51
|
-
stretch?: string | undefined;
|
|
52
|
-
featureSettings?: string | undefined;
|
|
53
|
-
variationSettings?: string | undefined;
|
|
54
|
-
unicodeRange?: [string, ...string[]] | undefined;
|
|
55
|
-
}>, "atleastone">;
|
|
56
|
-
fallbacks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
66
|
+
unicodeRange: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodString>>;
|
|
67
|
+
}, z.core.$strict>>;
|
|
68
|
+
fallbacks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
57
69
|
optimizedFallbacks: z.ZodOptional<z.ZodBoolean>;
|
|
58
70
|
name: z.ZodString;
|
|
59
71
|
cssVariable: z.ZodString;
|
|
60
|
-
},
|
|
61
|
-
provider: "local";
|
|
62
|
-
name: string;
|
|
63
|
-
cssVariable: string;
|
|
64
|
-
variants: [{
|
|
65
|
-
src: [string | URL | {
|
|
66
|
-
url: string | URL;
|
|
67
|
-
tech?: string | undefined;
|
|
68
|
-
}, ...(string | URL | {
|
|
69
|
-
url: string | URL;
|
|
70
|
-
tech?: string | undefined;
|
|
71
|
-
})[]];
|
|
72
|
-
weight?: string | number | undefined;
|
|
73
|
-
style?: "normal" | "italic" | "oblique" | undefined;
|
|
74
|
-
display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
|
|
75
|
-
stretch?: string | undefined;
|
|
76
|
-
featureSettings?: string | undefined;
|
|
77
|
-
variationSettings?: string | undefined;
|
|
78
|
-
unicodeRange?: [string, ...string[]] | undefined;
|
|
79
|
-
}, ...{
|
|
80
|
-
src: [string | URL | {
|
|
81
|
-
url: string | URL;
|
|
82
|
-
tech?: string | undefined;
|
|
83
|
-
}, ...(string | URL | {
|
|
84
|
-
url: string | URL;
|
|
85
|
-
tech?: string | undefined;
|
|
86
|
-
})[]];
|
|
87
|
-
weight?: string | number | undefined;
|
|
88
|
-
style?: "normal" | "italic" | "oblique" | undefined;
|
|
89
|
-
display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
|
|
90
|
-
stretch?: string | undefined;
|
|
91
|
-
featureSettings?: string | undefined;
|
|
92
|
-
variationSettings?: string | undefined;
|
|
93
|
-
unicodeRange?: [string, ...string[]] | undefined;
|
|
94
|
-
}[]];
|
|
95
|
-
fallbacks?: string[] | undefined;
|
|
96
|
-
optimizedFallbacks?: boolean | undefined;
|
|
97
|
-
}, {
|
|
98
|
-
provider: "local";
|
|
99
|
-
name: string;
|
|
100
|
-
cssVariable: string;
|
|
101
|
-
variants: [{
|
|
102
|
-
src: [string | URL | {
|
|
103
|
-
url: string | URL;
|
|
104
|
-
tech?: string | undefined;
|
|
105
|
-
}, ...(string | URL | {
|
|
106
|
-
url: string | URL;
|
|
107
|
-
tech?: string | undefined;
|
|
108
|
-
})[]];
|
|
109
|
-
weight?: string | number | undefined;
|
|
110
|
-
style?: "normal" | "italic" | "oblique" | undefined;
|
|
111
|
-
display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
|
|
112
|
-
stretch?: string | undefined;
|
|
113
|
-
featureSettings?: string | undefined;
|
|
114
|
-
variationSettings?: string | undefined;
|
|
115
|
-
unicodeRange?: [string, ...string[]] | undefined;
|
|
116
|
-
}, ...{
|
|
117
|
-
src: [string | URL | {
|
|
118
|
-
url: string | URL;
|
|
119
|
-
tech?: string | undefined;
|
|
120
|
-
}, ...(string | URL | {
|
|
121
|
-
url: string | URL;
|
|
122
|
-
tech?: string | undefined;
|
|
123
|
-
})[]];
|
|
124
|
-
weight?: string | number | undefined;
|
|
125
|
-
style?: "normal" | "italic" | "oblique" | undefined;
|
|
126
|
-
display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
|
|
127
|
-
stretch?: string | undefined;
|
|
128
|
-
featureSettings?: string | undefined;
|
|
129
|
-
variationSettings?: string | undefined;
|
|
130
|
-
unicodeRange?: [string, ...string[]] | undefined;
|
|
131
|
-
}[]];
|
|
132
|
-
fallbacks?: string[] | undefined;
|
|
133
|
-
optimizedFallbacks?: boolean | undefined;
|
|
134
|
-
}>;
|
|
72
|
+
}, z.core.$strict>;
|
|
135
73
|
export declare const remoteFontFamilySchema: z.ZodObject<{
|
|
136
74
|
provider: z.ZodObject<{
|
|
137
|
-
entrypoint: z.ZodUnion<[z.ZodString, z.
|
|
75
|
+
entrypoint: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>;
|
|
138
76
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
weights: z.ZodOptional<z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>], z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
79
|
+
styles: z.ZodOptional<z.ZodTuple<[z.ZodEnum<{
|
|
80
|
+
normal: "normal";
|
|
81
|
+
italic: "italic";
|
|
82
|
+
oblique: "oblique";
|
|
83
|
+
}>], z.ZodEnum<{
|
|
84
|
+
normal: "normal";
|
|
85
|
+
italic: "italic";
|
|
86
|
+
oblique: "oblique";
|
|
87
|
+
}>>>;
|
|
88
|
+
subsets: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodString>>;
|
|
89
|
+
display: z.ZodOptional<z.ZodEnum<{
|
|
90
|
+
optional: "optional";
|
|
91
|
+
auto: "auto";
|
|
92
|
+
block: "block";
|
|
93
|
+
swap: "swap";
|
|
94
|
+
fallback: "fallback";
|
|
95
|
+
}>>;
|
|
150
96
|
stretch: z.ZodOptional<z.ZodString>;
|
|
151
97
|
featureSettings: z.ZodOptional<z.ZodString>;
|
|
152
98
|
variationSettings: z.ZodOptional<z.ZodString>;
|
|
153
|
-
unicodeRange: z.ZodOptional<z.
|
|
154
|
-
fallbacks: z.ZodOptional<z.ZodArray<z.ZodString
|
|
99
|
+
unicodeRange: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodString>>;
|
|
100
|
+
fallbacks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
155
101
|
optimizedFallbacks: z.ZodOptional<z.ZodBoolean>;
|
|
156
102
|
name: z.ZodString;
|
|
157
103
|
cssVariable: z.ZodString;
|
|
158
|
-
},
|
|
159
|
-
provider: {
|
|
160
|
-
entrypoint: string | URL;
|
|
161
|
-
config?: Record<string, any> | undefined;
|
|
162
|
-
};
|
|
163
|
-
name: string;
|
|
164
|
-
cssVariable: string;
|
|
165
|
-
weights?: [string | number, ...(string | number)[]] | undefined;
|
|
166
|
-
styles?: ["normal" | "italic" | "oblique", ...("normal" | "italic" | "oblique")[]] | undefined;
|
|
167
|
-
subsets?: [string, ...string[]] | undefined;
|
|
168
|
-
fallbacks?: string[] | undefined;
|
|
169
|
-
optimizedFallbacks?: boolean | undefined;
|
|
170
|
-
display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
|
|
171
|
-
stretch?: string | undefined;
|
|
172
|
-
featureSettings?: string | undefined;
|
|
173
|
-
variationSettings?: string | undefined;
|
|
174
|
-
unicodeRange?: [string, ...string[]] | undefined;
|
|
175
|
-
}, {
|
|
176
|
-
provider: {
|
|
177
|
-
entrypoint: string | URL;
|
|
178
|
-
config?: Record<string, any> | undefined;
|
|
179
|
-
};
|
|
180
|
-
name: string;
|
|
181
|
-
cssVariable: string;
|
|
182
|
-
weights?: [string | number, ...(string | number)[]] | undefined;
|
|
183
|
-
styles?: ["normal" | "italic" | "oblique", ...("normal" | "italic" | "oblique")[]] | undefined;
|
|
184
|
-
subsets?: [string, ...string[]] | undefined;
|
|
185
|
-
fallbacks?: string[] | undefined;
|
|
186
|
-
optimizedFallbacks?: boolean | undefined;
|
|
187
|
-
display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
|
|
188
|
-
stretch?: string | undefined;
|
|
189
|
-
featureSettings?: string | undefined;
|
|
190
|
-
variationSettings?: string | undefined;
|
|
191
|
-
unicodeRange?: [string, ...string[]] | undefined;
|
|
192
|
-
}>;
|
|
104
|
+
}, z.core.$strict>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
2
|
import { LOCAL_PROVIDER_NAME } from "./constants.js";
|
|
3
3
|
const weightSchema = z.union([z.string(), z.number()]);
|
|
4
4
|
const styleSchema = z.enum(["normal", "italic", "oblique"]);
|
|
@@ -10,7 +10,7 @@ const familyPropertiesSchema = z.object({
|
|
|
10
10
|
stretch: z.string().optional(),
|
|
11
11
|
featureSettings: z.string().optional(),
|
|
12
12
|
variationSettings: z.string().optional(),
|
|
13
|
-
unicodeRange: z.
|
|
13
|
+
unicodeRange: z.tuple([z.string()], z.string()).optional()
|
|
14
14
|
});
|
|
15
15
|
const fallbacksSchema = z.object({
|
|
16
16
|
fallbacks: z.array(z.string()).optional(),
|
|
@@ -21,22 +21,20 @@ const requiredFamilyAttributesSchema = z.object({
|
|
|
21
21
|
cssVariable: z.string()
|
|
22
22
|
});
|
|
23
23
|
const entrypointSchema = z.union([z.string(), z.instanceof(URL)]);
|
|
24
|
+
const srcSchema = z.union([
|
|
25
|
+
entrypointSchema,
|
|
26
|
+
z.object({ url: entrypointSchema, tech: z.string().optional() }).strict()
|
|
27
|
+
]);
|
|
28
|
+
const variantSchema = z.object({
|
|
29
|
+
...familyPropertiesSchema.shape,
|
|
30
|
+
src: z.tuple([srcSchema], srcSchema)
|
|
31
|
+
// TODO: find a way to support subsets (through fontkit?)
|
|
32
|
+
}).strict();
|
|
24
33
|
const localFontFamilySchema = z.object({
|
|
25
34
|
...requiredFamilyAttributesSchema.shape,
|
|
26
35
|
...fallbacksSchema.shape,
|
|
27
36
|
provider: z.literal(LOCAL_PROVIDER_NAME),
|
|
28
|
-
variants: z.
|
|
29
|
-
z.object({
|
|
30
|
-
...familyPropertiesSchema.shape,
|
|
31
|
-
src: z.array(
|
|
32
|
-
z.union([
|
|
33
|
-
entrypointSchema,
|
|
34
|
-
z.object({ url: entrypointSchema, tech: z.string().optional() }).strict()
|
|
35
|
-
])
|
|
36
|
-
).nonempty()
|
|
37
|
-
// TODO: find a way to support subsets (through fontkit?)
|
|
38
|
-
}).strict()
|
|
39
|
-
).nonempty()
|
|
37
|
+
variants: z.tuple([variantSchema], variantSchema)
|
|
40
38
|
}).strict();
|
|
41
39
|
const remoteFontFamilySchema = z.object({
|
|
42
40
|
...requiredFamilyAttributesSchema.shape,
|
|
@@ -49,9 +47,9 @@ const remoteFontFamilySchema = z.object({
|
|
|
49
47
|
entrypoint: entrypointSchema,
|
|
50
48
|
config: z.record(z.string(), z.any()).optional()
|
|
51
49
|
}).strict(),
|
|
52
|
-
weights: z.
|
|
53
|
-
styles: z.
|
|
54
|
-
subsets: z.
|
|
50
|
+
weights: z.tuple([weightSchema], weightSchema).optional(),
|
|
51
|
+
styles: z.tuple([styleSchema], styleSchema).optional(),
|
|
52
|
+
subsets: z.tuple([z.string()], z.string()).optional()
|
|
55
53
|
}).strict();
|
|
56
54
|
export {
|
|
57
55
|
displaySchema,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RunnableDevEnvironment } from 'vite';
|
|
2
2
|
import type { RemoteFontProviderModResolver } from '../definitions.js';
|
|
3
3
|
export declare class DevServerRemoteFontProviderModResolver implements RemoteFontProviderModResolver {
|
|
4
4
|
#private;
|
|
5
|
-
constructor({
|
|
6
|
-
|
|
5
|
+
constructor({ environment, }: {
|
|
6
|
+
environment: RunnableDevEnvironment;
|
|
7
7
|
});
|
|
8
8
|
resolve(id: string): Promise<any>;
|
|
9
9
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
class DevServerRemoteFontProviderModResolver {
|
|
2
|
-
#
|
|
2
|
+
#environment;
|
|
3
3
|
constructor({
|
|
4
|
-
|
|
4
|
+
environment
|
|
5
5
|
}) {
|
|
6
|
-
this.#
|
|
6
|
+
this.#environment = environment;
|
|
7
7
|
}
|
|
8
8
|
async resolve(id) {
|
|
9
|
-
return
|
|
9
|
+
return this.#environment.runner.import(id);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Font } from '@capsizecss/unpack';
|
|
2
2
|
import type * as unifont from 'unifont';
|
|
3
|
-
import type
|
|
3
|
+
import type * as z from 'zod/v4';
|
|
4
4
|
import type { displaySchema, styleSchema, weightSchema } from './config.js';
|
|
5
5
|
import type { FONT_TYPES, GENERIC_FALLBACK_NAMES, LOCAL_PROVIDER_NAME } from './constants.js';
|
|
6
6
|
import type { CollectedFontForMetrics } from './core/optimize-fallbacks.js';
|
|
@@ -3,6 +3,7 @@ import { readFile } from "node:fs/promises";
|
|
|
3
3
|
import { isAbsolute } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import colors from "piccolore";
|
|
6
|
+
import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../../core/constants.js";
|
|
6
7
|
import { getAlgorithm, shouldTrackCspHashes } from "../../core/csp/common.js";
|
|
7
8
|
import { generateCspDigest } from "../../core/encryption.js";
|
|
8
9
|
import { collectErrorMetadata } from "../../core/errors/dev/utils.js";
|
|
@@ -138,8 +139,8 @@ function fontsPlugin({ settings, sync, logger }) {
|
|
|
138
139
|
fontFileDataMap = res.fontFileDataMap;
|
|
139
140
|
internalConsumableMap = res.internalConsumableMap;
|
|
140
141
|
consumableMap = res.consumableMap;
|
|
141
|
-
if (shouldTrackCspHashes(settings.config.
|
|
142
|
-
const algorithm = getAlgorithm(settings.config.
|
|
142
|
+
if (shouldTrackCspHashes(settings.config.security.csp)) {
|
|
143
|
+
const algorithm = getAlgorithm(settings.config.security.csp);
|
|
143
144
|
for (const { css } of internalConsumableMap.values()) {
|
|
144
145
|
settings.injectedCsp.styleHashes.push(await generateCspDigest(css, algorithm));
|
|
145
146
|
}
|
|
@@ -172,7 +173,9 @@ function fontsPlugin({ settings, sync, logger }) {
|
|
|
172
173
|
await initialize({
|
|
173
174
|
// In dev, we cache fonts data in .astro so it can be easily inspected and cleared
|
|
174
175
|
cacheDir: new URL(CACHE_DIR, settings.dotAstroDir),
|
|
175
|
-
modResolver: new DevServerRemoteFontProviderModResolver({
|
|
176
|
+
modResolver: new DevServerRemoteFontProviderModResolver({
|
|
177
|
+
environment: server.environments[ASTRO_VITE_ENVIRONMENT_NAMES.astro]
|
|
178
|
+
}),
|
|
176
179
|
cssRenderer: new MinifiableCssRenderer({ minify: false }),
|
|
177
180
|
urlResolver: new DevUrlResolver({
|
|
178
181
|
base: baseUrl,
|
|
@@ -45,25 +45,24 @@ const sharpService = {
|
|
|
45
45
|
limitInputPixels: config.service.config.limitInputPixels
|
|
46
46
|
});
|
|
47
47
|
result.rotate();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const fit = fitMap[transform.fit] ?? "inside";
|
|
48
|
+
if (transform.width && transform.height) {
|
|
49
|
+
const fit = transform.fit ? fitMap[transform.fit] ?? "inside" : void 0;
|
|
51
50
|
result.resize({
|
|
52
51
|
width: Math.round(transform.width),
|
|
53
52
|
height: Math.round(transform.height),
|
|
54
53
|
fit,
|
|
55
54
|
position: transform.position,
|
|
56
|
-
withoutEnlargement
|
|
55
|
+
withoutEnlargement: true
|
|
57
56
|
});
|
|
58
57
|
} else if (transform.height && !transform.width) {
|
|
59
58
|
result.resize({
|
|
60
59
|
height: Math.round(transform.height),
|
|
61
|
-
withoutEnlargement
|
|
60
|
+
withoutEnlargement: true
|
|
62
61
|
});
|
|
63
62
|
} else if (transform.width) {
|
|
64
63
|
result.resize({
|
|
65
64
|
width: Math.round(transform.width),
|
|
66
|
-
withoutEnlargement
|
|
65
|
+
withoutEnlargement: true
|
|
67
66
|
});
|
|
68
67
|
}
|
|
69
68
|
if (transform.format) {
|
|
@@ -6,12 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { isESMImportedImage, isRemoteImage, resolveSrc } from './imageKind.js';
|
|
8
8
|
export { imageMetadata } from './metadata.js';
|
|
9
|
-
export {
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated
|
|
12
|
-
*/
|
|
13
|
-
emitESMImage, emitImageMetadata, } from './node/emitAsset.js';
|
|
14
9
|
export { getOrigQueryParams } from './queryParams.js';
|
|
15
10
|
export { isRemoteAllowed, matchHostname, matchPathname, matchPattern, matchPort, matchProtocol, type RemotePattern, } from './remotePattern.js';
|
|
16
11
|
export { inferRemoteSize } from './remoteProbe.js';
|
|
17
|
-
export { hashTransform, propsToFilename } from './transformToPath.js';
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { isESMImportedImage, isRemoteImage, resolveSrc } from "./imageKind.js";
|
|
2
2
|
import { imageMetadata } from "./metadata.js";
|
|
3
|
-
import {
|
|
4
|
-
emitESMImage,
|
|
5
|
-
emitImageMetadata
|
|
6
|
-
} from "./node/emitAsset.js";
|
|
7
3
|
import { getOrigQueryParams } from "./queryParams.js";
|
|
8
4
|
import {
|
|
9
5
|
isRemoteAllowed,
|
|
@@ -14,12 +10,8 @@ import {
|
|
|
14
10
|
matchProtocol
|
|
15
11
|
} from "./remotePattern.js";
|
|
16
12
|
import { inferRemoteSize } from "./remoteProbe.js";
|
|
17
|
-
import { hashTransform, propsToFilename } from "./transformToPath.js";
|
|
18
13
|
export {
|
|
19
|
-
emitESMImage,
|
|
20
|
-
emitImageMetadata,
|
|
21
14
|
getOrigQueryParams,
|
|
22
|
-
hashTransform,
|
|
23
15
|
imageMetadata,
|
|
24
16
|
inferRemoteSize,
|
|
25
17
|
isESMImportedImage,
|
|
@@ -30,6 +22,5 @@ export {
|
|
|
30
22
|
matchPattern,
|
|
31
23
|
matchPort,
|
|
32
24
|
matchProtocol,
|
|
33
|
-
propsToFilename,
|
|
34
25
|
resolveSrc
|
|
35
26
|
};
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as vite from 'vite';
|
|
2
|
+
import type { ImageMetadata, ImageTransform } from '../types.js';
|
|
3
|
+
type FileEmitter = vite.Rollup.EmitFile;
|
|
4
|
+
type ImageMetadataWithContents = ImageMetadata & {
|
|
5
|
+
contents?: Buffer;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Processes an image file and emits its metadata and optionally its contents. This function supports both build and development modes.
|
|
9
|
+
*
|
|
10
|
+
* @param {string | undefined} id - The identifier or path of the image file to process. If undefined, the function returns immediately.
|
|
11
|
+
* @param {FileEmitter | undefined} [fileEmitter] - Function for emitting files during the build process. May throw in certain scenarios.
|
|
12
|
+
* @return {Promise<ImageMetadataWithContents | undefined>} Resolves to metadata with optional image contents or `undefined` if processing fails.
|
|
13
|
+
*/
|
|
14
|
+
export declare function emitImageMetadata(id: string | undefined, fileEmitter?: FileEmitter): Promise<ImageMetadataWithContents | undefined>;
|
|
2
15
|
/**
|
|
3
16
|
* Converts a file path and transformation properties of the transformation image service, into a formatted filename.
|
|
4
17
|
*
|
|
@@ -31,3 +44,4 @@ export declare function propsToFilename(filePath: string, transform: ImageTransf
|
|
|
31
44
|
* @return {string} A hashed string created from the specified properties of the `transform` object and the image service.
|
|
32
45
|
*/
|
|
33
46
|
export declare function hashTransform(transform: ImageTransform, imageService: string, propertiesToHash: string[]): string;
|
|
47
|
+
export {};
|