astro 6.0.0-beta.9 → 6.0.0
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/README.md +1 -1
- package/bin/astro.mjs +1 -1
- package/client.d.ts +7 -2
- package/components/ClientRouter.astro +3 -3
- package/components/Code.astro +11 -1
- package/components/Image.astro +5 -3
- package/components/Picture.astro +3 -1
- package/components/ResponsiveImage.astro +0 -2
- package/components/ResponsivePicture.astro +0 -1
- package/dist/actions/runtime/client.js +4 -6
- package/dist/actions/runtime/server.js +51 -8
- package/dist/actions/runtime/types.d.ts +1 -1
- package/dist/assets/build/generate.d.ts +2 -2
- package/dist/assets/build/generate.js +9 -11
- package/dist/assets/build/remote.js +8 -2
- package/dist/assets/consts.d.ts +2 -0
- package/dist/assets/consts.js +4 -0
- package/dist/assets/endpoint/config.js +8 -28
- package/dist/assets/endpoint/dev.js +2 -15
- package/dist/assets/endpoint/generic.js +5 -1
- package/dist/assets/endpoint/shared.js +4 -1
- package/dist/assets/fonts/infra/capsize-font-metrics-resolver.js +1 -1
- package/dist/assets/fonts/infra/levenshtein-string-matcher.js +1 -1
- package/dist/assets/fonts/providers/index.d.ts +19 -15
- package/dist/assets/fonts/providers/index.js +23 -1
- package/dist/assets/fonts/providers/local.d.ts +1 -1
- package/dist/assets/fonts/vite-plugin-fonts.js +1 -1
- package/dist/assets/index.d.ts +2 -1
- package/dist/assets/index.js +4 -2
- package/dist/assets/internal.d.ts +1 -0
- package/dist/assets/internal.js +18 -10
- package/dist/assets/runtime.js +1 -1
- package/dist/assets/services/service.d.ts +8 -1
- package/dist/assets/services/service.js +16 -12
- package/dist/assets/services/sharp.js +1 -0
- package/dist/assets/types.d.ts +17 -19
- package/dist/assets/types.js +1 -1
- package/dist/assets/utils/assets.d.ts +23 -0
- package/dist/assets/utils/assets.js +24 -0
- package/dist/assets/utils/deterministic-string.d.ts +10 -0
- package/dist/assets/utils/deterministic-string.js +104 -0
- package/dist/assets/utils/generateImageStylesCSS.d.ts +1 -0
- package/dist/assets/utils/generateImageStylesCSS.js +38 -0
- package/dist/assets/utils/hash.d.ts +9 -0
- package/dist/assets/utils/hash.js +54 -0
- package/dist/assets/utils/imageKind.d.ts +2 -2
- package/dist/assets/utils/index.d.ts +1 -0
- package/dist/assets/utils/index.js +2 -0
- package/dist/assets/utils/node.d.ts +2 -34
- package/dist/assets/utils/node.js +3 -28
- package/dist/assets/utils/proxy.js +1 -1
- package/dist/assets/utils/queryParams.js +2 -2
- package/dist/assets/utils/remoteProbe.d.ts +5 -1
- package/dist/assets/utils/remoteProbe.js +34 -2
- package/dist/assets/utils/resolveImports.d.ts +2 -2
- package/dist/assets/utils/svg.js +11 -1
- package/dist/assets/vite-plugin-assets.js +124 -36
- package/dist/cli/add/index.js +52 -67
- package/dist/cli/build/index.js +1 -1
- package/dist/cli/definitions.d.ts +1 -0
- package/dist/cli/dev/index.js +1 -1
- package/dist/cli/flags.d.ts +1 -1
- package/dist/cli/flags.js +2 -3
- package/dist/cli/index.js +6 -8
- package/dist/cli/info/infra/{prompts-prompt.d.ts → clack-prompt.d.ts} +1 -1
- package/dist/cli/info/infra/{prompts-prompt.js → clack-prompt.js} +7 -8
- package/dist/cli/info/infra/tinyclip-clipboard.d.ts +10 -0
- package/dist/cli/info/infra/tinyclip-clipboard.js +32 -0
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/cli/infra/passthrough-text-styler.d.ts +1 -0
- package/dist/cli/infra/passthrough-text-styler.js +3 -0
- package/dist/cli/install-package.js +16 -21
- package/dist/cli/preferences/index.js +1 -1
- package/dist/cli/preview/index.js +1 -1
- package/dist/cli/sync/index.js +1 -1
- package/dist/cli/telemetry/index.js +1 -1
- package/dist/cli/throw-and-exit.js +1 -1
- package/dist/config/entrypoint.d.ts +7 -0
- package/dist/config/entrypoint.js +8 -0
- package/dist/config/index.js +5 -3
- package/dist/container/index.d.ts +1 -1
- package/dist/container/index.js +11 -4
- package/dist/content/content-layer.d.ts +5 -9
- package/dist/content/content-layer.js +22 -30
- package/dist/content/data-store.d.ts +1 -1
- package/dist/content/instance.d.ts +17 -0
- package/dist/content/instance.js +20 -0
- package/dist/content/loaders/glob.js +1 -1
- package/dist/content/mutable-data-store.js +27 -4
- package/dist/content/runtime-assets.js +2 -1
- package/dist/content/runtime.js +7 -1
- package/dist/content/utils.js +2 -2
- package/dist/content/vite-plugin-content-assets.js +8 -4
- package/dist/content/vite-plugin-content-imports.js +2 -1
- package/dist/content/vite-plugin-content-virtual-mod.js +3 -1
- package/dist/core/app/app.d.ts +2 -1
- package/dist/core/app/app.js +3 -0
- package/dist/core/app/base.d.ts +44 -8
- package/dist/core/app/base.js +166 -58
- package/dist/core/app/dev/app.d.ts +3 -5
- package/dist/core/app/dev/app.js +30 -15
- package/dist/core/app/dev/pipeline.js +9 -0
- package/dist/core/app/entrypoints/index.d.ts +7 -0
- package/dist/core/app/{index.js → entrypoints/index.js} +8 -6
- package/dist/core/app/entrypoints/manifest.d.ts +1 -0
- package/dist/core/app/entrypoints/manifest.js +14 -0
- package/dist/core/app/entrypoints/node.d.ts +1 -0
- package/dist/core/app/entrypoints/node.js +8 -0
- package/dist/core/app/entrypoints/virtual/dev.d.ts +2 -0
- package/dist/core/app/entrypoints/virtual/dev.js +31 -0
- package/dist/core/app/entrypoints/virtual/index.d.ts +2 -0
- package/dist/core/app/entrypoints/virtual/index.js +5 -0
- package/dist/core/app/entrypoints/virtual/prod.d.ts +2 -0
- package/dist/core/app/entrypoints/virtual/prod.js +8 -0
- package/dist/core/app/manifest.d.ts +3 -0
- package/dist/core/app/manifest.js +8 -0
- package/dist/core/app/node.d.ts +50 -7
- package/dist/core/app/node.js +159 -138
- package/dist/core/app/pipeline.js +3 -1
- package/dist/core/app/types.d.ts +31 -0
- package/dist/core/app/{validate-forwarded-headers.d.ts → validate-headers.d.ts} +4 -3
- package/dist/core/app/{validate-forwarded-headers.js → validate-headers.js} +36 -16
- package/dist/core/base-pipeline.d.ts +18 -1
- package/dist/core/base-pipeline.js +40 -3
- package/dist/core/build/app.d.ts +5 -1
- package/dist/core/build/app.js +8 -1
- package/dist/core/build/common.d.ts +1 -1
- package/dist/core/build/common.js +2 -1
- package/dist/core/build/default-prerenderer.d.ts +22 -0
- package/dist/core/build/default-prerenderer.js +37 -0
- package/dist/core/build/generate.js +187 -256
- package/dist/core/build/index.js +9 -6
- package/dist/core/build/internal.d.ts +26 -0
- package/dist/core/build/internal.js +16 -1
- package/dist/core/build/pipeline.js +10 -1
- package/dist/core/build/plugins/index.js +3 -1
- package/dist/core/build/plugins/plugin-component-entry.d.ts +1 -1
- package/dist/core/build/plugins/plugin-internals.js +11 -7
- package/dist/core/build/plugins/plugin-manifest.js +23 -2
- package/dist/core/build/plugins/plugin-ssr.d.ts +6 -0
- package/dist/core/build/plugins/plugin-ssr.js +2 -1
- package/dist/core/build/static-build.d.ts +1 -3
- package/dist/core/build/static-build.js +101 -82
- package/dist/core/build/vite-plugin-ssr-assets.d.ts +9 -0
- package/dist/core/build/vite-plugin-ssr-assets.js +94 -0
- package/dist/core/cache/config.d.ts +29 -0
- package/dist/core/cache/config.js +20 -0
- package/dist/core/cache/memory-provider.d.ts +56 -0
- package/dist/core/cache/memory-provider.js +305 -0
- package/dist/core/cache/runtime/cache.d.ts +42 -0
- package/dist/core/cache/runtime/cache.js +99 -0
- package/dist/core/cache/runtime/noop.d.ts +26 -0
- package/dist/core/cache/runtime/noop.js +49 -0
- package/dist/core/cache/runtime/route-matching.d.ts +20 -0
- package/dist/core/cache/runtime/route-matching.js +28 -0
- package/dist/core/cache/runtime/utils.d.ts +8 -0
- package/dist/core/cache/runtime/utils.js +34 -0
- package/dist/core/cache/types.d.ts +64 -0
- package/dist/core/cache/types.js +0 -0
- package/dist/core/cache/utils.d.ts +16 -0
- package/dist/core/cache/utils.js +47 -0
- package/dist/core/cache/vite-plugin.d.ts +6 -0
- package/dist/core/cache/vite-plugin.js +56 -0
- package/dist/core/compile/compile-rs.d.ts +25 -0
- package/dist/core/compile/compile-rs.js +111 -0
- package/dist/core/compile/style.d.ts +10 -2
- package/dist/core/compile/style.js +3 -1
- package/dist/core/config/config.js +1 -1
- package/dist/core/config/merge.js +3 -2
- package/dist/core/config/schemas/base.d.ts +28 -0
- package/dist/core/config/schemas/base.js +21 -4
- package/dist/core/config/schemas/refined.js +1 -1
- package/dist/core/config/schemas/relative.d.ts +66 -4
- package/dist/core/config/settings.js +1 -0
- package/dist/core/constants.js +7 -7
- package/dist/core/cookies/cookies.js +2 -2
- package/dist/core/cookies/response.js +1 -1
- package/dist/core/create-vite.js +14 -4
- package/dist/core/dev/adapter-validation.js +10 -0
- package/dist/core/dev/container.js +7 -5
- package/dist/core/dev/dev.js +12 -5
- package/dist/core/dev/restart.d.ts +1 -0
- package/dist/core/dev/restart.js +23 -19
- package/dist/core/errors/dev/utils.d.ts +0 -1
- package/dist/core/errors/dev/utils.js +0 -11
- package/dist/core/errors/errors-data.d.ts +124 -10
- package/dist/core/errors/errors-data.js +65 -13
- package/dist/core/errors/userError.d.ts +1 -0
- package/dist/core/errors/userError.js +3 -1
- package/dist/core/logger/core.d.ts +1 -1
- package/dist/core/logger/node.d.ts +3 -0
- package/dist/core/logger/node.js +12 -3
- package/dist/core/logger/vite.js +1 -1
- package/dist/core/messages/node.d.ts +3 -0
- package/dist/core/messages/node.js +14 -0
- package/dist/core/{messages.d.ts → messages/runtime.d.ts} +16 -5
- package/dist/core/{messages.js → messages/runtime.js} +43 -26
- package/dist/core/middleware/callMiddleware.d.ts +1 -1
- package/dist/core/middleware/index.d.ts +8 -1
- package/dist/core/middleware/index.js +7 -10
- package/dist/core/preview/index.js +4 -2
- package/dist/core/preview/static-preview-server.js +6 -2
- package/dist/core/preview/vite-plugin-astro-preview.js +2 -2
- package/dist/core/redirects/render.js +6 -3
- package/dist/core/render/paginate.js +2 -2
- package/dist/core/render/slots.js +1 -1
- package/dist/core/render-context.d.ts +2 -0
- package/dist/core/render-context.js +57 -11
- package/dist/core/request-body.d.ts +17 -0
- package/dist/core/request-body.js +43 -0
- package/dist/core/routing/3xx.d.ts +3 -0
- package/dist/core/routing/astro-designed-error-pages.d.ts +1 -4
- package/dist/core/routing/astro-designed-error-pages.js +1 -33
- package/dist/core/routing/create-manifest.d.ts +32 -0
- package/dist/core/routing/{manifest/create.js → create-manifest.js} +169 -32
- package/dist/core/routing/default.js +1 -1
- package/dist/core/routing/{manifest/generator.d.ts → generator.d.ts} +2 -2
- package/dist/core/routing/{manifest/generator.js → generator.js} +2 -1
- package/dist/core/routing/helpers.d.ts +9 -0
- package/dist/core/routing/helpers.js +1 -1
- package/dist/core/routing/internal/astro-designed-error-pages.d.ts +4 -0
- package/dist/core/routing/internal/astro-designed-error-pages.js +35 -0
- package/dist/core/routing/internal/route-errors.d.ts +2 -0
- package/dist/core/routing/internal/route-errors.js +12 -0
- package/dist/core/routing/internal/validation.d.ts +2 -0
- package/dist/core/routing/internal/validation.js +16 -0
- package/dist/core/routing/match.d.ts +3 -21
- package/dist/core/routing/match.js +3 -24
- package/dist/core/routing/params.js +2 -2
- package/dist/core/routing/parse-route.d.ts +22 -0
- package/dist/core/routing/parse-route.js +65 -0
- package/dist/core/routing/{manifest/parts.d.ts → parts.d.ts} +1 -1
- package/dist/core/routing/{manifest/pattern.d.ts → pattern.d.ts} +2 -2
- package/dist/core/routing/prerender.d.ts +4 -0
- package/dist/core/routing/{manifest/prerender.js → prerender.js} +2 -2
- package/dist/core/routing/rewrite.js +2 -2
- package/dist/core/routing/router.d.ts +50 -0
- package/dist/core/routing/router.js +101 -0
- package/dist/core/routing/validation.d.ts +0 -2
- package/dist/core/routing/validation.js +0 -13
- package/dist/core/server-islands/endpoint.d.ts +6 -1
- package/dist/core/server-islands/endpoint.js +14 -6
- package/dist/core/session/config.js +1 -2
- package/dist/core/session/runtime.js +21 -2
- package/dist/core/sync/index.js +5 -4
- package/dist/core/util-runtime.d.ts +11 -0
- package/dist/core/util-runtime.js +20 -0
- package/dist/core/util.d.ts +0 -7
- package/dist/core/util.js +0 -18
- package/dist/env/env-loader.js +25 -3
- package/dist/env/validators.d.ts +10 -0
- package/dist/env/validators.js +23 -1
- package/dist/events/session.js +1 -1
- package/dist/i18n/fallback.d.ts +46 -0
- package/dist/i18n/fallback.js +58 -0
- package/dist/i18n/index.d.ts +2 -2
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/middleware.js +66 -108
- package/dist/i18n/router.d.ts +86 -0
- package/dist/i18n/router.js +142 -0
- package/dist/integrations/adapter-utils.d.ts +19 -0
- package/dist/integrations/adapter-utils.js +12 -0
- package/dist/integrations/features-validation.js +1 -1
- package/dist/integrations/hooks.d.ts +2 -2
- package/dist/integrations/hooks.js +12 -7
- package/dist/jsx-runtime/index.js +1 -1
- package/dist/manifest/serialized.js +23 -2
- package/dist/manifest/virtual-module.js +21 -2
- package/dist/prerender/routing.js +1 -1
- package/dist/prerender/utils.js +5 -1
- package/dist/runtime/client/dev-toolbar/apps/audit/rules/a11y.js +3 -3
- package/dist/runtime/client/dev-toolbar/apps/audit/rules/perf.js +3 -3
- package/dist/runtime/client/dev-toolbar/apps/audit/ui/audit-list-window.js +1 -1
- package/dist/runtime/client/dev-toolbar/apps/utils/icons.js +1 -1
- package/dist/runtime/client/visible.d.ts +1 -1
- package/dist/runtime/prerender/static-paths.d.ts +25 -0
- package/dist/runtime/prerender/static-paths.js +77 -0
- package/dist/runtime/server/astro-global.js +3 -0
- package/dist/runtime/server/astro-island.js +1 -1
- package/dist/runtime/server/astro-island.prebuilt-dev.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt-dev.js +1 -1
- package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/runtime/server/escape.js +2 -2
- package/dist/runtime/server/html-string-cache.d.ts +48 -0
- package/dist/runtime/server/html-string-cache.js +119 -0
- package/dist/runtime/server/jsx.js +3 -3
- package/dist/runtime/server/render/any.js +31 -23
- package/dist/runtime/server/render/astro/head-and-content.js +1 -1
- package/dist/runtime/server/render/astro/instance.js +1 -1
- package/dist/runtime/server/render/astro/render-template.js +43 -24
- package/dist/runtime/server/render/astro/render.d.ts +4 -0
- package/dist/runtime/server/render/common.js +2 -2
- package/dist/runtime/server/render/component.js +9 -2
- package/dist/runtime/server/render/head.js +25 -8
- package/dist/runtime/server/render/instruction.js +1 -1
- package/dist/runtime/server/render/page.js +41 -10
- package/dist/runtime/server/render/queue/builder.d.ts +14 -0
- package/dist/runtime/server/render/queue/builder.js +182 -0
- package/dist/runtime/server/render/queue/jsx-builder.d.ts +33 -0
- package/dist/runtime/server/render/queue/jsx-builder.js +146 -0
- package/dist/runtime/server/render/queue/pool.d.ts +123 -0
- package/dist/runtime/server/render/queue/pool.js +203 -0
- package/dist/runtime/server/render/queue/renderer.d.ts +12 -0
- package/dist/runtime/server/render/queue/renderer.js +103 -0
- package/dist/runtime/server/render/queue/types.d.ts +81 -0
- package/dist/runtime/server/render/queue/types.js +0 -0
- package/dist/runtime/server/render/server-islands.js +10 -1
- package/dist/runtime/server/render/slot.js +1 -1
- package/dist/runtime/server/render/util.js +5 -14
- package/dist/runtime/server/serialize.js +2 -2
- package/dist/runtime/server/transition.js +1 -1
- package/dist/transitions/cssesc.d.ts +8 -0
- package/dist/transitions/cssesc.js +69 -0
- package/dist/transitions/swap-functions.js +34 -7
- package/dist/transitions/vite-plugin-transitions.js +0 -7
- package/dist/types/astro.d.ts +3 -2
- package/dist/types/public/config.d.ts +220 -54
- package/dist/types/public/context.d.ts +13 -3
- package/dist/types/public/index.d.ts +2 -1
- package/dist/types/public/integrations.d.ts +138 -32
- package/dist/types/public/internal.d.ts +16 -1
- package/dist/types/public/manifest.d.ts +3 -1
- package/dist/virtual-modules/i18n.js +1 -1
- package/dist/vite-plugin-adapter-config/index.js +20 -0
- package/dist/vite-plugin-app/app.d.ts +9 -4
- package/dist/vite-plugin-app/app.js +36 -13
- package/dist/vite-plugin-app/createAstroServerApp.js +4 -0
- package/dist/vite-plugin-app/index.d.ts +2 -2
- package/dist/vite-plugin-app/index.js +42 -11
- package/dist/vite-plugin-app/pipeline.js +10 -1
- package/dist/vite-plugin-astro/compile-rs.d.ts +12 -0
- package/dist/vite-plugin-astro/compile-rs.js +39 -0
- package/dist/vite-plugin-astro/compile.d.ts +2 -2
- package/dist/vite-plugin-astro/index.js +15 -7
- package/dist/vite-plugin-astro-server/base.js +2 -1
- package/dist/vite-plugin-astro-server/error.js +1 -1
- package/dist/vite-plugin-astro-server/plugin.js +24 -4
- package/dist/vite-plugin-astro-server/response.js +3 -3
- package/dist/vite-plugin-astro-server/sec-fetch.d.ts +21 -0
- package/dist/vite-plugin-astro-server/sec-fetch.js +40 -0
- package/dist/vite-plugin-css/index.js +3 -0
- package/dist/vite-plugin-environment/index.js +1 -3
- package/dist/vite-plugin-pages/page.js +1 -1
- package/dist/vite-plugin-pages/pages.js +1 -1
- package/dist/vite-plugin-renderers/index.d.ts +4 -2
- package/dist/vite-plugin-renderers/index.js +9 -0
- package/dist/vite-plugin-routes/index.d.ts +7 -0
- package/dist/vite-plugin-routes/index.js +25 -6
- package/dist/vite-plugin-static-paths/index.d.ts +9 -0
- package/dist/vite-plugin-static-paths/index.js +35 -0
- package/package.json +28 -29
- package/types/content.d.ts +0 -1
- package/components/image.css +0 -11
- package/dist/assets/utils/imageAttributes.d.ts +0 -2
- package/dist/assets/utils/imageAttributes.js +0 -14
- package/dist/cli/info/infra/cli-clipboard.d.ts +0 -13
- package/dist/cli/info/infra/cli-clipboard.js +0 -78
- package/dist/core/app/entrypoint.d.ts +0 -2
- package/dist/core/app/entrypoint.js +0 -32
- package/dist/core/app/index.d.ts +0 -7
- package/dist/core/config/logging.d.ts +0 -3
- package/dist/core/config/logging.js +0 -12
- package/dist/core/routing/index.d.ts +0 -2
- package/dist/core/routing/index.js +0 -6
- package/dist/core/routing/manifest/create.d.ts +0 -25
- package/dist/core/routing/manifest/prerender.d.ts +0 -4
- package/dist/core/routing/request.d.ts +0 -9
- package/dist/core/routing/request.js +0 -9
- /package/dist/core/routing/{manifest/parts.js → parts.js} +0 -0
- /package/dist/core/routing/{manifest/pattern.js → pattern.js} +0 -0
- /package/dist/core/routing/{manifest/segment.d.ts → segment.d.ts} +0 -0
- /package/dist/core/routing/{manifest/segment.js → segment.js} +0 -0
package/README.md
CHANGED
package/bin/astro.mjs
CHANGED
|
@@ -19,7 +19,7 @@ const skipSemverCheckIfAbove = IS_STACKBLITZ ? 21 : 23;
|
|
|
19
19
|
async function main() {
|
|
20
20
|
const version = process.versions.node;
|
|
21
21
|
// Fast-path for higher Node.js versions
|
|
22
|
-
if ((parseInt(version) || 0) <= skipSemverCheckIfAbove) {
|
|
22
|
+
if ((Number.parseInt(version) || 0) <= skipSemverCheckIfAbove) {
|
|
23
23
|
const semver = await import('semver');
|
|
24
24
|
try {
|
|
25
25
|
if (!semver.satisfies(version, engines)) {
|
package/client.d.ts
CHANGED
|
@@ -84,6 +84,11 @@ declare module 'astro:assets' {
|
|
|
84
84
|
}: AstroAssets;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
declare module 'virtual:astro:image-styles.css' {
|
|
88
|
+
const styles: string;
|
|
89
|
+
export default styles;
|
|
90
|
+
}
|
|
91
|
+
|
|
87
92
|
type ImageMetadata = import('./dist/assets/types.js').ImageMetadata;
|
|
88
93
|
|
|
89
94
|
declare module '*.gif' {
|
|
@@ -282,8 +287,8 @@ declare module '*.mdx' {
|
|
|
282
287
|
export default load;
|
|
283
288
|
}
|
|
284
289
|
|
|
285
|
-
declare module 'astro:
|
|
286
|
-
export const
|
|
290
|
+
declare module 'astro:static-paths' {
|
|
291
|
+
export const StaticPaths: typeof import('./dist/runtime/prerender/static-paths.js').StaticPaths;
|
|
287
292
|
}
|
|
288
293
|
|
|
289
294
|
// Everything below are Vite's types (apart from image types, which are in `client.d.ts`)
|
|
@@ -115,14 +115,14 @@ const { fallback = 'animate' } = Astro.props;
|
|
|
115
115
|
const form = el as HTMLFormElement;
|
|
116
116
|
const formData = new FormData(form, submitter);
|
|
117
117
|
// form.action and form.method can point to an <input name="action"> or <input name="method">
|
|
118
|
-
// in which case should
|
|
118
|
+
// in which case should fall back to the form attribute
|
|
119
119
|
const formAction =
|
|
120
120
|
typeof form.action === 'string' ? form.action : form.getAttribute('action');
|
|
121
121
|
const formMethod =
|
|
122
122
|
typeof form.method === 'string' ? form.method : form.getAttribute('method');
|
|
123
|
-
// Use the form action, if defined
|
|
123
|
+
// Use the form action, if defined; otherwise, fall back to current path.
|
|
124
124
|
let action = submitter?.getAttribute('formaction') ?? formAction ?? location.pathname;
|
|
125
|
-
// Use the form method, if defined
|
|
125
|
+
// Use the form method, if defined; otherwise, fall back to "get"
|
|
126
126
|
const method = submitter?.getAttribute('formmethod') ?? formMethod ?? 'get';
|
|
127
127
|
|
|
128
128
|
// the "dialog" method is a special keyword used within <dialog> elements
|
package/components/Code.astro
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { type ThemePresets
|
|
2
|
+
import { createShikiHighlighter, type ThemePresets } from '@astrojs/markdown-remark/shiki';
|
|
3
3
|
import type { ShikiTransformer, ThemeRegistration, ThemeRegistrationRaw } from 'shiki';
|
|
4
4
|
import { bundledLanguages } from 'shiki/langs';
|
|
5
5
|
import type { CodeLanguage } from '../dist/types/public/common.js';
|
|
@@ -16,6 +16,14 @@ interface Props extends Omit<HTMLAttributes<'pre'>, 'lang'> {
|
|
|
16
16
|
* @default "plaintext"
|
|
17
17
|
*/
|
|
18
18
|
lang?: CodeLanguage;
|
|
19
|
+
/**
|
|
20
|
+
* Additional languages to load.
|
|
21
|
+
* Useful if `code` embeds languages not included by the given `lang`
|
|
22
|
+
* For example, TSX in Vue
|
|
23
|
+
*
|
|
24
|
+
* @default []
|
|
25
|
+
*/
|
|
26
|
+
embeddedLangs?: CodeLanguage[];
|
|
19
27
|
/**
|
|
20
28
|
* A metastring to pass to the highlighter.
|
|
21
29
|
* Allows passing information to transformers: https://shiki.style/guide/transformers#meta
|
|
@@ -72,6 +80,7 @@ interface Props extends Omit<HTMLAttributes<'pre'>, 'lang'> {
|
|
|
72
80
|
const {
|
|
73
81
|
code,
|
|
74
82
|
lang = 'plaintext',
|
|
83
|
+
embeddedLangs = [],
|
|
75
84
|
meta,
|
|
76
85
|
theme = 'github-dark',
|
|
77
86
|
themes = {},
|
|
@@ -101,6 +110,7 @@ const highlighter = await createShikiHighlighter({
|
|
|
101
110
|
? lang
|
|
102
111
|
: 'plaintext'
|
|
103
112
|
: (lang as any),
|
|
113
|
+
...embeddedLangs,
|
|
104
114
|
],
|
|
105
115
|
theme,
|
|
106
116
|
themes,
|
package/components/Image.astro
CHANGED
|
@@ -17,20 +17,22 @@ if (props.alt === undefined || props.alt === null) {
|
|
|
17
17
|
|
|
18
18
|
// As a convenience, allow width and height to be string with a number in them, to match HTML's native `img`.
|
|
19
19
|
if (typeof props.width === 'string') {
|
|
20
|
-
props.width = parseInt(props.width);
|
|
20
|
+
props.width = Number.parseInt(props.width);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
if (typeof props.height === 'string') {
|
|
24
|
-
props.height = parseInt(props.height);
|
|
24
|
+
props.height = Number.parseInt(props.height);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const layout = props.layout ?? imageConfig.layout ?? 'none';
|
|
28
28
|
|
|
29
29
|
if (layout !== 'none') {
|
|
30
|
-
// Apply defaults from imageConfig if not provided
|
|
31
30
|
props.layout ??= imageConfig.layout;
|
|
32
31
|
props.fit ??= imageConfig.objectFit ?? 'cover';
|
|
33
32
|
props.position ??= imageConfig.objectPosition ?? 'center';
|
|
33
|
+
} else if (imageConfig.objectFit || imageConfig.objectPosition) {
|
|
34
|
+
props.fit ??= imageConfig.objectFit;
|
|
35
|
+
props.position ??= imageConfig.objectPosition;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
const image = await getImage(props as UnresolvedImageTransform);
|
package/components/Picture.astro
CHANGED
|
@@ -46,10 +46,12 @@ const layout = props.layout ?? imageConfig.layout ?? 'none';
|
|
|
46
46
|
const useResponsive = layout !== 'none';
|
|
47
47
|
|
|
48
48
|
if (useResponsive) {
|
|
49
|
-
// Apply defaults from imageConfig if not provided
|
|
50
49
|
props.layout ??= imageConfig.layout;
|
|
51
50
|
props.fit ??= imageConfig.objectFit ?? 'cover';
|
|
52
51
|
props.position ??= imageConfig.objectPosition ?? 'center';
|
|
52
|
+
} else if (imageConfig.objectFit || imageConfig.objectPosition) {
|
|
53
|
+
props.fit ??= imageConfig.objectFit;
|
|
54
|
+
props.position ??= imageConfig.objectPosition;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
for (const key in props) {
|
|
@@ -5,8 +5,6 @@ import Image from './Image.astro';
|
|
|
5
5
|
type Props = LocalImageProps | RemoteImageProps;
|
|
6
6
|
|
|
7
7
|
const { class: className, ...props } = Astro.props;
|
|
8
|
-
|
|
9
|
-
import './image.css';
|
|
10
8
|
---
|
|
11
9
|
|
|
12
10
|
{/* Applying class outside of the spread prevents it from applying unnecessary astro-* classes */}
|
|
@@ -4,7 +4,6 @@ import { default as Picture, type Props as PictureProps } from './Picture.astro'
|
|
|
4
4
|
type Props = PictureProps;
|
|
5
5
|
|
|
6
6
|
const { class: className, ...props } = Astro.props;
|
|
7
|
-
import './image.css';
|
|
8
7
|
---
|
|
9
8
|
|
|
10
9
|
{/* Applying class outside of the spread prevents it from applying unnecessary astro-* classes */}
|
|
@@ -43,10 +43,8 @@ const codeToStatusMap = {
|
|
|
43
43
|
LOOP_DETECTED: 508,
|
|
44
44
|
NETWORK_AUTHENTICATION_REQUIRED: 511
|
|
45
45
|
};
|
|
46
|
-
const statusToCodeMap = Object.
|
|
47
|
-
|
|
48
|
-
(acc, [key, value]) => ({ ...acc, [value]: key }),
|
|
49
|
-
{}
|
|
46
|
+
const statusToCodeMap = Object.fromEntries(
|
|
47
|
+
Object.entries(codeToStatusMap).map(([key, value]) => [value, key])
|
|
50
48
|
);
|
|
51
49
|
class ActionError extends Error {
|
|
52
50
|
type = "AstroActionError";
|
|
@@ -142,7 +140,7 @@ function deserializeActionResult(res) {
|
|
|
142
140
|
error: void 0
|
|
143
141
|
};
|
|
144
142
|
}
|
|
145
|
-
const actionResultErrorStack = /* @__PURE__ */ function actionResultErrorStackFn() {
|
|
143
|
+
const actionResultErrorStack = /* @__PURE__ */ (function actionResultErrorStackFn() {
|
|
146
144
|
let errorStack;
|
|
147
145
|
return {
|
|
148
146
|
set(stack) {
|
|
@@ -152,7 +150,7 @@ const actionResultErrorStack = /* @__PURE__ */ function actionResultErrorStackFn
|
|
|
152
150
|
return errorStack;
|
|
153
151
|
}
|
|
154
152
|
};
|
|
155
|
-
}();
|
|
153
|
+
})();
|
|
156
154
|
function getActionQueryString(name) {
|
|
157
155
|
const searchParams = new URLSearchParams({ [ACTION_QUERY_PARAMS.actionName]: name });
|
|
158
156
|
return `?${searchParams.toString()}`;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from "../../core/errors/errors-data.js";
|
|
10
10
|
import { AstroError } from "../../core/errors/errors.js";
|
|
11
11
|
import { removeTrailingForwardSlash } from "../../core/path.js";
|
|
12
|
+
import { BodySizeLimitError, readBodyWithLimit } from "../../core/request-body.js";
|
|
12
13
|
import { ACTION_QUERY_PARAMS, ACTION_RPC_ROUTE_PATTERN } from "../consts.js";
|
|
13
14
|
import {
|
|
14
15
|
ActionError,
|
|
@@ -99,10 +100,14 @@ function getActionContext(context) {
|
|
|
99
100
|
}
|
|
100
101
|
throw error;
|
|
101
102
|
}
|
|
103
|
+
const bodySizeLimit = pipeline.manifest.actionBodySizeLimit;
|
|
102
104
|
let input;
|
|
103
105
|
try {
|
|
104
|
-
input = await parseRequestBody(context.request);
|
|
106
|
+
input = await parseRequestBody(context.request, bodySizeLimit);
|
|
105
107
|
} catch (e) {
|
|
108
|
+
if (e instanceof ActionError) {
|
|
109
|
+
return { data: void 0, error: e };
|
|
110
|
+
}
|
|
106
111
|
if (e instanceof TypeError) {
|
|
107
112
|
return { data: void 0, error: new ActionError({ code: "UNSUPPORTED_MEDIA_TYPE" }) };
|
|
108
113
|
}
|
|
@@ -146,19 +151,52 @@ function getCallerInfo(ctx) {
|
|
|
146
151
|
}
|
|
147
152
|
return void 0;
|
|
148
153
|
}
|
|
149
|
-
async function parseRequestBody(request) {
|
|
154
|
+
async function parseRequestBody(request, bodySizeLimit) {
|
|
150
155
|
const contentType = request.headers.get("content-type");
|
|
151
|
-
const
|
|
156
|
+
const contentLengthHeader = request.headers.get("content-length");
|
|
157
|
+
const contentLength = contentLengthHeader ? Number.parseInt(contentLengthHeader, 10) : void 0;
|
|
158
|
+
const hasContentLength = typeof contentLength === "number" && Number.isFinite(contentLength);
|
|
152
159
|
if (!contentType) return void 0;
|
|
153
|
-
if (
|
|
154
|
-
|
|
160
|
+
if (hasContentLength && contentLength > bodySizeLimit) {
|
|
161
|
+
throw new ActionError({
|
|
162
|
+
code: "CONTENT_TOO_LARGE",
|
|
163
|
+
message: `Request body exceeds ${bodySizeLimit} bytes`
|
|
164
|
+
});
|
|
155
165
|
}
|
|
156
|
-
|
|
157
|
-
|
|
166
|
+
try {
|
|
167
|
+
if (hasContentType(contentType, formContentTypes)) {
|
|
168
|
+
if (!hasContentLength) {
|
|
169
|
+
const body = await readBodyWithLimit(request.clone(), bodySizeLimit);
|
|
170
|
+
const formRequest = new Request(request.url, {
|
|
171
|
+
method: request.method,
|
|
172
|
+
headers: request.headers,
|
|
173
|
+
body: toArrayBuffer(body)
|
|
174
|
+
});
|
|
175
|
+
return await formRequest.formData();
|
|
176
|
+
}
|
|
177
|
+
return await request.clone().formData();
|
|
178
|
+
}
|
|
179
|
+
if (hasContentType(contentType, ["application/json"])) {
|
|
180
|
+
if (contentLength === 0) return void 0;
|
|
181
|
+
if (!hasContentLength) {
|
|
182
|
+
const body = await readBodyWithLimit(request.clone(), bodySizeLimit);
|
|
183
|
+
if (body.byteLength === 0) return void 0;
|
|
184
|
+
return JSON.parse(new TextDecoder().decode(body));
|
|
185
|
+
}
|
|
186
|
+
return await request.clone().json();
|
|
187
|
+
}
|
|
188
|
+
} catch (e) {
|
|
189
|
+
if (e instanceof BodySizeLimitError) {
|
|
190
|
+
throw new ActionError({
|
|
191
|
+
code: "CONTENT_TOO_LARGE",
|
|
192
|
+
message: `Request body exceeds ${bodySizeLimit} bytes`
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
throw e;
|
|
158
196
|
}
|
|
159
197
|
throw new TypeError("Unsupported content type");
|
|
160
198
|
}
|
|
161
|
-
const ACTION_API_CONTEXT_SYMBOL = Symbol.for("astro.actionAPIContext");
|
|
199
|
+
const ACTION_API_CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("astro.actionAPIContext");
|
|
162
200
|
const formContentTypes = ["application/x-www-form-urlencoded", "multipart/form-data"];
|
|
163
201
|
function hasContentType(contentType, expected) {
|
|
164
202
|
const type = contentType.split(";")[0].toLowerCase();
|
|
@@ -296,6 +334,11 @@ function serializeActionResult(res) {
|
|
|
296
334
|
body
|
|
297
335
|
};
|
|
298
336
|
}
|
|
337
|
+
function toArrayBuffer(buffer) {
|
|
338
|
+
const copy = new Uint8Array(buffer.byteLength);
|
|
339
|
+
copy.set(buffer);
|
|
340
|
+
return copy.buffer;
|
|
341
|
+
}
|
|
299
342
|
export {
|
|
300
343
|
ACTION_API_CONTEXT_SYMBOL,
|
|
301
344
|
defineAction,
|
|
@@ -49,7 +49,7 @@ export interface ActionsLocals {
|
|
|
49
49
|
actionName: string;
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
export type ActionAPIContext = Pick<APIContext, 'request' | 'url' | 'isPrerendered' | 'locals' | 'clientAddress' | 'cookies' | 'currentLocale' | 'generator' | 'routePattern' | 'site' | 'params' | 'preferredLocale' | 'preferredLocaleList' | 'originPathname' | 'session' | 'csp'>;
|
|
52
|
+
export type ActionAPIContext = Pick<APIContext, 'request' | 'url' | 'isPrerendered' | 'locals' | 'clientAddress' | 'cookies' | 'currentLocale' | 'generator' | 'routePattern' | 'site' | 'params' | 'preferredLocale' | 'preferredLocaleList' | 'originPathname' | 'session' | 'cache' | 'csp'>;
|
|
53
53
|
export type MaybePromise<T> = T | Promise<T>;
|
|
54
54
|
/**
|
|
55
55
|
* Used to preserve the input schema type in the error object.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StaticBuildOptions } from '../../core/build/types.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(options: StaticBuildOptions, 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,12 +9,10 @@ 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 settings =
|
|
14
|
-
const logger = app.logger;
|
|
15
|
-
const manifest = app.getManifest();
|
|
12
|
+
async function prepareAssetsGenerationEnv(options, totalCount) {
|
|
13
|
+
const { settings, logger } = options;
|
|
16
14
|
let useCache = true;
|
|
17
|
-
const assetsCacheDir = new URL("assets/",
|
|
15
|
+
const assetsCacheDir = new URL("assets/", settings.config.cacheDir);
|
|
18
16
|
const count = { total: totalCount, current: 1 };
|
|
19
17
|
try {
|
|
20
18
|
await fs.promises.mkdir(assetsCacheDir, { recursive: true });
|
|
@@ -28,11 +26,11 @@ async function prepareAssetsGenerationEnv(app, totalCount) {
|
|
|
28
26
|
const isServerOutput = settings.buildOutput === "server";
|
|
29
27
|
let serverRoot, clientRoot;
|
|
30
28
|
if (isServerOutput) {
|
|
31
|
-
serverRoot = new URL(".prerender/",
|
|
32
|
-
clientRoot =
|
|
29
|
+
serverRoot = new URL(".prerender/", settings.config.build.server);
|
|
30
|
+
clientRoot = settings.config.build.client;
|
|
33
31
|
} else {
|
|
34
|
-
serverRoot = getOutDirWithinCwd(
|
|
35
|
-
clientRoot =
|
|
32
|
+
serverRoot = getOutDirWithinCwd(settings.config.outDir);
|
|
33
|
+
clientRoot = settings.config.outDir;
|
|
36
34
|
}
|
|
37
35
|
return {
|
|
38
36
|
logger,
|
|
@@ -43,7 +41,7 @@ async function prepareAssetsGenerationEnv(app, totalCount) {
|
|
|
43
41
|
serverRoot,
|
|
44
42
|
clientRoot,
|
|
45
43
|
imageConfig: settings.config.image,
|
|
46
|
-
assetsFolder:
|
|
44
|
+
assetsFolder: settings.config.build.assets
|
|
47
45
|
};
|
|
48
46
|
}
|
|
49
47
|
function getFullImagePath(originalFilePath, env) {
|
|
@@ -54,7 +52,7 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env) {
|
|
|
54
52
|
for (const [_, transform] of transformsAndPath.transforms) {
|
|
55
53
|
await generateImage(transform.finalPath, transform.transform);
|
|
56
54
|
}
|
|
57
|
-
if (
|
|
55
|
+
if (transformsAndPath.originalSrcPath && !globalThis.astroAsset.referencedImages?.has(transformsAndPath.originalSrcPath)) {
|
|
58
56
|
try {
|
|
59
57
|
if (transformsAndPath.originalSrcPath) {
|
|
60
58
|
env.logger.debug(
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import CachePolicy from "http-cache-semantics";
|
|
2
2
|
async function loadRemoteImage(src) {
|
|
3
3
|
const req = new Request(src);
|
|
4
|
-
const res = await fetch(req);
|
|
4
|
+
const res = await fetch(req, { redirect: "manual" });
|
|
5
|
+
if (res.status >= 300 && res.status < 400) {
|
|
6
|
+
throw new Error(`Failed to load remote image ${src}. The request was redirected.`);
|
|
7
|
+
}
|
|
5
8
|
if (!res.ok) {
|
|
6
9
|
throw new Error(
|
|
7
10
|
`Failed to load remote image ${src}. The request did not return a 200 OK response. (received ${res.status}))`
|
|
@@ -22,7 +25,10 @@ async function revalidateRemoteImage(src, revalidationData) {
|
|
|
22
25
|
...revalidationData.lastModified && { "If-Modified-Since": revalidationData.lastModified }
|
|
23
26
|
};
|
|
24
27
|
const req = new Request(src, { headers, cache: "no-cache" });
|
|
25
|
-
const res = await fetch(req);
|
|
28
|
+
const res = await fetch(req, { redirect: "manual" });
|
|
29
|
+
if (res.status >= 300 && res.status < 400) {
|
|
30
|
+
throw new Error(`Failed to revalidate cached remote image ${src}. The request was redirected.`);
|
|
31
|
+
}
|
|
26
32
|
if (!res.ok && res.status !== 304) {
|
|
27
33
|
throw new Error(
|
|
28
34
|
`Failed to revalidate cached remote image ${src}. The request did not return a 200 OK / 304 NOT MODIFIED response. (received ${res.status} ${res.statusText})`
|
package/dist/assets/consts.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const VIRTUAL_MODULE_ID = "astro:assets";
|
|
2
2
|
export declare const RESOLVED_VIRTUAL_MODULE_ID: string;
|
|
3
3
|
export declare const VIRTUAL_SERVICE_ID = "virtual:image-service";
|
|
4
|
+
export declare const VIRTUAL_IMAGE_STYLES_ID = "virtual:astro:image-styles.css";
|
|
5
|
+
export declare const RESOLVED_VIRTUAL_IMAGE_STYLES_ID: string;
|
|
4
6
|
export declare const VALID_INPUT_FORMATS: readonly ["jpeg", "jpg", "png", "tiff", "webp", "gif", "svg", "avif"];
|
|
5
7
|
/**
|
|
6
8
|
* Valid formats that our base services support.
|
package/dist/assets/consts.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const VIRTUAL_MODULE_ID = "astro:assets";
|
|
2
2
|
const RESOLVED_VIRTUAL_MODULE_ID = "\0" + VIRTUAL_MODULE_ID;
|
|
3
3
|
const VIRTUAL_SERVICE_ID = "virtual:image-service";
|
|
4
|
+
const VIRTUAL_IMAGE_STYLES_ID = "virtual:astro:image-styles.css";
|
|
5
|
+
const RESOLVED_VIRTUAL_IMAGE_STYLES_ID = "\0" + VIRTUAL_IMAGE_STYLES_ID;
|
|
4
6
|
const VALID_INPUT_FORMATS = [
|
|
5
7
|
"jpeg",
|
|
6
8
|
"jpg",
|
|
@@ -36,10 +38,12 @@ const DEFAULT_HASH_PROPS = [
|
|
|
36
38
|
export {
|
|
37
39
|
DEFAULT_HASH_PROPS,
|
|
38
40
|
DEFAULT_OUTPUT_FORMAT,
|
|
41
|
+
RESOLVED_VIRTUAL_IMAGE_STYLES_ID,
|
|
39
42
|
RESOLVED_VIRTUAL_MODULE_ID,
|
|
40
43
|
VALID_INPUT_FORMATS,
|
|
41
44
|
VALID_OUTPUT_FORMATS,
|
|
42
45
|
VALID_SUPPORTED_FORMATS,
|
|
46
|
+
VIRTUAL_IMAGE_STYLES_ID,
|
|
43
47
|
VIRTUAL_MODULE_ID,
|
|
44
48
|
VIRTUAL_SERVICE_ID
|
|
45
49
|
};
|
|
@@ -1,39 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
removeTrailingForwardSlash
|
|
4
|
-
} from "@astrojs/internal-helpers/path";
|
|
5
|
-
import { resolveInjectedRoute } from "../../core/routing/manifest/create.js";
|
|
6
|
-
import { getPattern } from "../../core/routing/manifest/pattern.js";
|
|
1
|
+
import { resolveInjectedRoute } from "../../core/routing/create-manifest.js";
|
|
2
|
+
import { parseRoute } from "../../core/routing/parse-route.js";
|
|
7
3
|
function injectImageEndpoint(settings, manifest, mode, cwd) {
|
|
8
4
|
manifest.routes.unshift(getImageEndpointData(settings, mode, cwd));
|
|
9
5
|
}
|
|
10
6
|
function getImageEndpointData(settings, mode, cwd) {
|
|
11
7
|
const endpointEntrypoint = settings.config.image.endpoint.entrypoint === void 0 ? mode === "dev" ? "astro/assets/endpoint/dev" : "astro/assets/endpoint/generic" : settings.config.image.endpoint.entrypoint;
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
content: removeTrailingForwardSlash(
|
|
16
|
-
removeLeadingForwardSlash(settings.config.image.endpoint.route)
|
|
17
|
-
),
|
|
18
|
-
dynamic: false,
|
|
19
|
-
spread: false
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
];
|
|
23
|
-
return {
|
|
8
|
+
const component = resolveInjectedRoute(endpointEntrypoint, settings.config.root, cwd).component;
|
|
9
|
+
return parseRoute(settings.config.image.endpoint.route, settings, {
|
|
10
|
+
component,
|
|
24
11
|
type: "endpoint",
|
|
12
|
+
origin: "internal",
|
|
25
13
|
isIndex: false,
|
|
26
|
-
route: settings.config.image.endpoint.route,
|
|
27
|
-
pattern: getPattern(segments, settings.config.base, settings.config.trailingSlash),
|
|
28
|
-
segments,
|
|
29
|
-
params: [],
|
|
30
|
-
component: resolveInjectedRoute(endpointEntrypoint, settings.config.root, cwd).component,
|
|
31
|
-
pathname: settings.config.image.endpoint.route,
|
|
32
14
|
prerender: false,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
distURL: []
|
|
36
|
-
};
|
|
15
|
+
params: []
|
|
16
|
+
});
|
|
37
17
|
}
|
|
38
18
|
export {
|
|
39
19
|
injectImageEndpoint
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { safeModulePaths, viteFSConfig } from "astro:assets";
|
|
1
|
+
import { fsDenyGlob, safeModulePaths, viteFSConfig } from "astro:assets";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import os from "node:os";
|
|
4
|
-
import picomatch from "picomatch";
|
|
5
4
|
import { isFileLoadingAllowed } from "vite";
|
|
6
5
|
import { handleImageRequest, loadRemoteImage } from "./shared.js";
|
|
7
6
|
function replaceFileSystemReferences(src) {
|
|
@@ -15,19 +14,7 @@ async function loadLocalImage(src, url) {
|
|
|
15
14
|
}
|
|
16
15
|
if (fsPath && isFileLoadingAllowed(
|
|
17
16
|
{
|
|
18
|
-
fsDenyGlob
|
|
19
|
-
// matchBase: true does not work as it's documented
|
|
20
|
-
// https://github.com/micromatch/picomatch/issues/89
|
|
21
|
-
// convert patterns without `/` on our side for now
|
|
22
|
-
viteFSConfig.deny.map(
|
|
23
|
-
(pattern) => pattern.includes("/") ? pattern : `**/${pattern}`
|
|
24
|
-
),
|
|
25
|
-
{
|
|
26
|
-
matchBase: false,
|
|
27
|
-
nocase: true,
|
|
28
|
-
dot: true
|
|
29
|
-
}
|
|
30
|
-
),
|
|
17
|
+
fsDenyGlob,
|
|
31
18
|
server: { fs: viteFSConfig },
|
|
32
19
|
safeModulePaths
|
|
33
20
|
},
|
|
@@ -8,8 +8,12 @@ async function loadRemoteImage(src, headers) {
|
|
|
8
8
|
try {
|
|
9
9
|
const res = await fetch(src, {
|
|
10
10
|
// Forward all headers from the original request
|
|
11
|
-
headers
|
|
11
|
+
headers,
|
|
12
|
+
redirect: "manual"
|
|
12
13
|
});
|
|
14
|
+
if (res.status >= 300 && res.status < 400) {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
13
17
|
if (!res.ok) {
|
|
14
18
|
return void 0;
|
|
15
19
|
}
|
|
@@ -6,7 +6,10 @@ import { getConfiguredImageService } from "../internal.js";
|
|
|
6
6
|
import { etag } from "../utils/etag.js";
|
|
7
7
|
async function loadRemoteImage(src) {
|
|
8
8
|
try {
|
|
9
|
-
const res = await fetch(src);
|
|
9
|
+
const res = await fetch(src, { redirect: "manual" });
|
|
10
|
+
if (res.status >= 300 && res.status < 400) {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
10
13
|
if (!res.ok) {
|
|
11
14
|
return void 0;
|
|
12
15
|
}
|
|
@@ -125,7 +125,7 @@ class LevenshteinStringMatcher {
|
|
|
125
125
|
return this.#myers_x(a, b);
|
|
126
126
|
}
|
|
127
127
|
#closest(str, arr) {
|
|
128
|
-
let min_distance =
|
|
128
|
+
let min_distance = Number.POSITIVE_INFINITY;
|
|
129
129
|
let min_index = 0;
|
|
130
130
|
for (let i = 0; i < arr.length; i++) {
|
|
131
131
|
const dist = this.#distance(str, arr[i]);
|
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import { type AdobeProviderOptions, type GoogleFamilyOptions, type GoogleiconsFamilyOptions } from 'unifont';
|
|
1
|
+
import { type AdobeProviderOptions, type GoogleFamilyOptions, type GoogleiconsFamilyOptions, type NpmProviderOptions, type NpmFamilyOptions } from 'unifont';
|
|
2
2
|
import type { FontProvider } from '../types.js';
|
|
3
3
|
import { type LocalFamilyOptions } from './local.js';
|
|
4
|
-
/** [Adobe](https://
|
|
4
|
+
/** [Adobe](https://docs.astro.build/en/reference/font-provider-reference/#adobe) */
|
|
5
5
|
declare function adobe(config: AdobeProviderOptions): FontProvider;
|
|
6
|
-
/** [Bunny](https://
|
|
6
|
+
/** [Bunny](https://docs.astro.build/en/reference/font-provider-reference/#bunny) */
|
|
7
7
|
declare function bunny(): FontProvider;
|
|
8
|
-
/** [Fontshare](https://
|
|
8
|
+
/** [Fontshare](https://docs.astro.build/en/reference/font-provider-reference/#fontshare) */
|
|
9
9
|
declare function fontshare(): FontProvider;
|
|
10
|
-
/** [Fontsource](https://
|
|
10
|
+
/** [Fontsource](https://docs.astro.build/en/reference/font-provider-reference/#fontsource) */
|
|
11
11
|
declare function fontsource(): FontProvider;
|
|
12
|
-
/** [Google](https://
|
|
12
|
+
/** [Google](https://docs.astro.build/en/reference/font-provider-reference/#google) */
|
|
13
13
|
declare function google(): FontProvider<GoogleFamilyOptions | undefined>;
|
|
14
|
-
/** [Google Icons](https://
|
|
14
|
+
/** [Google Icons](https://docs.astro.build/en/reference/font-provider-reference/#google-icons) */
|
|
15
15
|
declare function googleicons(): FontProvider<GoogleiconsFamilyOptions | undefined>;
|
|
16
|
-
/**
|
|
16
|
+
/** [Local](https://docs.astro.build/en/reference/font-provider-reference/#local) */
|
|
17
17
|
declare function local(): FontProvider<LocalFamilyOptions>;
|
|
18
|
+
/** [NPM](https://docs.astro.build/en/reference/font-provider-reference/#npm) */
|
|
19
|
+
declare function npm(options?: Omit<NpmProviderOptions, 'root' | 'readFile'>): FontProvider<NpmFamilyOptions | undefined>;
|
|
18
20
|
/**
|
|
19
21
|
* Astro exports a few built-in providers:
|
|
20
|
-
* - [Adobe](https://
|
|
21
|
-
* - [Bunny](https://
|
|
22
|
-
* - [Fontshare](https://
|
|
23
|
-
* - [Fontsource](https://
|
|
24
|
-
* - [Google](https://
|
|
25
|
-
* - [Google Icons](https://
|
|
26
|
-
* - Local
|
|
22
|
+
* - [Adobe](https://docs.astro.build/en/reference/font-provider-reference/#adobe)
|
|
23
|
+
* - [Bunny](https://docs.astro.build/en/reference/font-provider-reference/#bunny)
|
|
24
|
+
* - [Fontshare](https://docs.astro.build/en/reference/font-provider-reference/#fontshare)
|
|
25
|
+
* - [Fontsource](https://docs.astro.build/en/reference/font-provider-reference/#fontsource)
|
|
26
|
+
* - [Google](https://docs.astro.build/en/reference/font-provider-reference/#google)
|
|
27
|
+
* - [Google Icons](https://docs.astro.build/en/reference/font-provider-reference/#google-icons)
|
|
28
|
+
* - [Local](https://docs.astro.build/en/reference/font-provider-reference/#local)
|
|
29
|
+
* - [NPM](TODO:)
|
|
27
30
|
*/
|
|
28
31
|
export declare const fontProviders: {
|
|
29
32
|
adobe: typeof adobe;
|
|
@@ -33,5 +36,6 @@ export declare const fontProviders: {
|
|
|
33
36
|
google: typeof google;
|
|
34
37
|
googleicons: typeof googleicons;
|
|
35
38
|
local: typeof local;
|
|
39
|
+
npm: typeof npm;
|
|
36
40
|
};
|
|
37
41
|
export {};
|
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
} from "unifont";
|
|
4
4
|
import { FontaceFontFileReader } from "../infra/fontace-font-file-reader.js";
|
|
5
5
|
import { LocalFontProvider } from "./local.js";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { readFile } from "node:fs/promises";
|
|
6
8
|
function adobe(config) {
|
|
7
9
|
const provider = providers.adobe(config);
|
|
8
10
|
let initializedProvider;
|
|
@@ -105,6 +107,25 @@ function local() {
|
|
|
105
107
|
fontFileReader: new FontaceFontFileReader()
|
|
106
108
|
});
|
|
107
109
|
}
|
|
110
|
+
function npm(options) {
|
|
111
|
+
let initializedProvider;
|
|
112
|
+
return {
|
|
113
|
+
name: providers.npm()._name,
|
|
114
|
+
async init(context) {
|
|
115
|
+
initializedProvider = await providers.npm({
|
|
116
|
+
...options,
|
|
117
|
+
root: fileURLToPath(context.root),
|
|
118
|
+
readFile: (path) => readFile(path, "utf-8").catch(() => null)
|
|
119
|
+
})(context);
|
|
120
|
+
},
|
|
121
|
+
async resolveFont({ familyName, ...rest }) {
|
|
122
|
+
return await initializedProvider?.resolveFont(familyName, rest);
|
|
123
|
+
},
|
|
124
|
+
async listFonts() {
|
|
125
|
+
return await initializedProvider?.listFonts?.();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
108
129
|
const fontProviders = {
|
|
109
130
|
adobe,
|
|
110
131
|
bunny,
|
|
@@ -112,7 +133,8 @@ const fontProviders = {
|
|
|
112
133
|
fontsource,
|
|
113
134
|
google,
|
|
114
135
|
googleicons,
|
|
115
|
-
local
|
|
136
|
+
local,
|
|
137
|
+
npm
|
|
116
138
|
};
|
|
117
139
|
export {
|
|
118
140
|
fontProviders
|