astro 3.0.13 → 3.1.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/README.md +2 -2
- package/astro-jsx.d.ts +28 -1
- package/client.d.ts +9 -7
- package/components/ViewTransitions.astro +15 -15
- package/content-types.template.d.ts +7 -1
- package/dist/@types/astro.d.ts +38 -17
- package/dist/assets/build/generate.d.ts +1 -1
- package/dist/assets/build/remote.d.ts +1 -1
- package/dist/assets/consts.d.ts +2 -2
- package/dist/assets/consts.js +4 -10
- package/dist/assets/internal.d.ts +2 -2
- package/dist/assets/internal.js +3 -2
- package/dist/assets/services/service.d.ts +1 -1
- package/dist/assets/services/service.js +7 -3
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/codecs.d.ts +4 -4
- package/dist/assets/services/vendor/squoosh/image-pool.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/image.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/image_data.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/impl.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/png/squoosh_oxipng_bg.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/png/squoosh_png_bg.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/resize/squoosh_resize_bg.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/rotate/rotate.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/utils/workerPool.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.wasm.d.ts +1 -1
- package/dist/assets/types.d.ts +4 -1
- package/dist/assets/utils/metadata.d.ts +1 -1
- package/dist/assets/utils/metadata.js +6 -2
- package/dist/assets/vite-plugin-assets.d.ts +1 -1
- package/dist/assets/vite-plugin-assets.js +1 -1
- package/dist/cli/add/babel.d.ts +12 -11
- package/dist/config/index.d.ts +1 -1
- package/dist/config/vite-plugin-content-listen.d.ts +2 -2
- package/dist/content/server-listeners.d.ts +1 -1
- package/dist/content/types-generator.d.ts +2 -2
- package/dist/content/utils.d.ts +1 -1
- package/dist/content/vite-plugin-content-assets.d.ts +1 -1
- package/dist/content/vite-plugin-content-imports.d.ts +1 -1
- package/dist/content/vite-plugin-content-virtual-mod.d.ts +1 -1
- package/dist/core/app/common.d.ts +1 -1
- package/dist/core/app/index.d.ts +1 -1
- package/dist/core/app/node.d.ts +3 -3
- package/dist/core/app/ssrPipeline.d.ts +1 -1
- package/dist/core/app/types.d.ts +2 -2
- package/dist/core/build/buildPipeline.d.ts +4 -4
- package/dist/core/build/common.d.ts +1 -1
- package/dist/core/build/css-asset-name.d.ts +1 -1
- package/dist/core/build/generate.d.ts +2 -2
- package/dist/core/build/generate.js +1 -1
- package/dist/core/build/index.d.ts +1 -1
- package/dist/core/build/internal.d.ts +3 -3
- package/dist/core/build/page-data.d.ts +3 -3
- package/dist/core/build/plugin.d.ts +2 -2
- package/dist/core/build/plugins/index.d.ts +1 -1
- package/dist/core/build/plugins/plugin-css.d.ts +3 -3
- package/dist/core/build/plugins/plugin-hoisted-scripts.d.ts +3 -3
- package/dist/core/build/plugins/plugin-internals.d.ts +1 -1
- package/dist/core/build/plugins/plugin-manifest.d.ts +3 -3
- package/dist/core/build/plugins/plugin-manifest.js +2 -2
- package/dist/core/build/plugins/plugin-middleware.d.ts +3 -3
- package/dist/core/build/plugins/plugin-pages.d.ts +3 -3
- package/dist/core/build/plugins/plugin-prerender.d.ts +1 -1
- package/dist/core/build/plugins/plugin-renderers.d.ts +2 -2
- package/dist/core/build/plugins/plugin-ssr.d.ts +2 -2
- package/dist/core/build/plugins/plugin-ssr.js +2 -2
- package/dist/core/build/static-build.d.ts +2 -2
- package/dist/core/build/types.d.ts +5 -4
- package/dist/core/compile/cache.d.ts +1 -1
- package/dist/core/compile/compile.d.ts +1 -1
- package/dist/core/compile/index.d.ts +2 -2
- package/dist/core/config/config.d.ts +2 -2
- package/dist/core/config/index.d.ts +1 -1
- package/dist/core/config/schema.d.ts +29 -15
- package/dist/core/config/schema.js +1 -0
- package/dist/core/config/settings.d.ts +1 -1
- package/dist/core/config/vite-load.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/response.d.ts +1 -1
- package/dist/core/create-vite.d.ts +3 -3
- package/dist/core/create-vite.js +1 -1
- package/dist/core/dev/container.d.ts +4 -4
- package/dist/core/dev/dev.d.ts +3 -3
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/restart.d.ts +3 -3
- package/dist/core/endpoint/index.d.ts +3 -3
- package/dist/core/errors/dev/utils.js +4 -4
- package/dist/core/errors/errors-data.d.ts +12 -3
- package/dist/core/errors/errors-data.js +7 -4
- package/dist/core/errors/index.d.ts +1 -1
- package/dist/core/errors/overlay.js +2 -2
- package/dist/core/logger/node.d.ts +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/callMiddleware.d.ts +2 -2
- package/dist/core/middleware/index.d.ts +2 -2
- package/dist/core/middleware/loadMiddleware.d.ts +2 -2
- package/dist/core/middleware/sequence.d.ts +1 -1
- package/dist/core/module-loader/loader.d.ts +2 -2
- package/dist/core/module-loader/vite.d.ts +1 -1
- package/dist/core/pipeline.d.ts +1 -1
- package/dist/core/preview/index.d.ts +1 -1
- package/dist/core/preview/static-preview-server.d.ts +3 -3
- package/dist/core/redirects/component.d.ts +2 -2
- package/dist/core/redirects/helpers.d.ts +1 -1
- package/dist/core/render/context.d.ts +2 -2
- package/dist/core/render/core.d.ts +1 -1
- package/dist/core/render/environment.d.ts +1 -1
- package/dist/core/render/index.d.ts +2 -2
- package/dist/core/render/paginate.d.ts +1 -1
- package/dist/core/render/params-and-props.d.ts +1 -1
- package/dist/core/render/renderer.d.ts +1 -1
- package/dist/core/render/result.d.ts +1 -1
- package/dist/core/render/route-cache.d.ts +1 -1
- package/dist/core/render/ssr-element.d.ts +2 -2
- package/dist/core/request.d.ts +2 -2
- package/dist/core/routing/manifest/create.d.ts +3 -3
- package/dist/core/routing/manifest/generator.d.ts +1 -1
- package/dist/core/routing/manifest/serialization.d.ts +1 -1
- package/dist/core/routing/match.d.ts +1 -1
- package/dist/core/routing/params.d.ts +1 -1
- package/dist/core/routing/validation.d.ts +2 -2
- package/dist/core/sync/index.d.ts +2 -2
- package/dist/core/util.d.ts +2 -2
- package/dist/events/session.d.ts +1 -1
- package/dist/integrations/astroFeaturesValidation.d.ts +1 -1
- package/dist/integrations/index.d.ts +3 -3
- package/dist/prerender/metadata.d.ts +1 -1
- package/dist/prerender/routing.d.ts +2 -2
- package/dist/prerender/utils.d.ts +1 -1
- package/dist/runtime/client/idle.d.ts +1 -1
- package/dist/runtime/client/load.d.ts +1 -1
- package/dist/runtime/client/media.d.ts +1 -1
- package/dist/runtime/client/only.d.ts +1 -1
- package/dist/runtime/client/visible.d.ts +1 -1
- package/dist/runtime/client/visible.prebuilt.d.ts +1 -1
- package/dist/runtime/client/visible.prebuilt.js +1 -1
- package/dist/runtime/server/astro-component.d.ts +1 -1
- package/dist/runtime/server/astro-global.d.ts +1 -1
- package/dist/runtime/server/astro-island.d.ts +1 -4
- package/dist/runtime/server/endpoint.d.ts +2 -2
- package/dist/runtime/server/hydration.d.ts +1 -1
- package/dist/runtime/server/render/astro/factory.d.ts +3 -3
- package/dist/runtime/server/render/astro/head-and-content.d.ts +1 -1
- package/dist/runtime/server/render/astro/index.d.ts +2 -2
- package/dist/runtime/server/render/astro/instance.d.ts +1 -1
- package/dist/runtime/server/render/astro/render.d.ts +1 -1
- package/dist/runtime/server/render/common.d.ts +1 -1
- package/dist/runtime/server/render/component.d.ts +1 -1
- package/dist/runtime/server/render/dom.d.ts +1 -1
- package/dist/runtime/server/render/head.d.ts +1 -1
- package/dist/runtime/server/render/index.d.ts +2 -2
- package/dist/runtime/server/render/page.d.ts +2 -2
- package/dist/runtime/server/render/tags.d.ts +2 -2
- package/dist/runtime/server/render/util.d.ts +1 -1
- package/dist/runtime/server/scripts.d.ts +1 -1
- package/dist/runtime/server/scripts.js +3 -3
- package/dist/runtime/server/serialize.d.ts +1 -1
- package/dist/runtime/server/transition.d.ts +1 -1
- package/dist/transitions/index.d.ts +1 -1
- package/dist/type-utils.d.ts +4 -0
- package/dist/vite-plugin-astro/hmr.d.ts +1 -1
- package/dist/vite-plugin-astro/index.d.ts +2 -2
- package/dist/vite-plugin-astro/metadata.d.ts +2 -2
- package/dist/vite-plugin-astro/types.d.ts +1 -1
- package/dist/vite-plugin-astro-server/base.d.ts +1 -1
- package/dist/vite-plugin-astro-server/controller.d.ts +2 -2
- package/dist/vite-plugin-astro-server/css.d.ts +1 -1
- package/dist/vite-plugin-astro-server/devPipeline.d.ts +4 -4
- package/dist/vite-plugin-astro-server/index.d.ts +1 -1
- package/dist/vite-plugin-astro-server/metadata.d.ts +2 -2
- package/dist/vite-plugin-astro-server/plugin.d.ts +2 -2
- package/dist/vite-plugin-astro-server/request.d.ts +4 -4
- package/dist/vite-plugin-astro-server/resolve.d.ts +1 -1
- package/dist/vite-plugin-astro-server/response.d.ts +2 -2
- package/dist/vite-plugin-astro-server/route.d.ts +2 -2
- package/dist/vite-plugin-astro-server/scripts.d.ts +2 -2
- package/dist/vite-plugin-astro-server/vite.d.ts +1 -1
- package/dist/vite-plugin-config-alias/index.d.ts +1 -1
- package/dist/vite-plugin-env/index.d.ts +1 -1
- package/dist/vite-plugin-inject-env-ts/index.d.ts +1 -1
- package/dist/vite-plugin-load-fallback/index.d.ts +1 -1
- package/dist/vite-plugin-markdown/index.d.ts +1 -1
- package/dist/vite-plugin-markdown/index.js +20 -20
- package/dist/vite-plugin-mdx/index.d.ts +1 -1
- package/dist/vite-plugin-utils/index.d.ts +1 -1
- package/package.json +4 -2
- package/types.d.ts +6 -1
- package/dist/assets/vendor/image-size/detector.d.ts +0 -3
- package/dist/assets/vendor/image-size/detector.js +0 -28
- package/dist/assets/vendor/image-size/index.d.ts +0 -11
- package/dist/assets/vendor/image-size/index.js +0 -93
- package/dist/assets/vendor/image-size/readUInt.d.ts +0 -4
- package/dist/assets/vendor/image-size/readUInt.js +0 -9
- package/dist/assets/vendor/image-size/types/bmp.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/bmp.js +0 -14
- package/dist/assets/vendor/image-size/types/cur.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/cur.js +0 -16
- package/dist/assets/vendor/image-size/types/dds.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/dds.js +0 -14
- package/dist/assets/vendor/image-size/types/gif.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/gif.js +0 -16
- package/dist/assets/vendor/image-size/types/icns.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/icns.js +0 -87
- package/dist/assets/vendor/image-size/types/ico.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/ico.js +0 -42
- package/dist/assets/vendor/image-size/types/interface.d.ts +0 -14
- package/dist/assets/vendor/image-size/types/interface.js +0 -0
- package/dist/assets/vendor/image-size/types/j2c.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/j2c.js +0 -14
- package/dist/assets/vendor/image-size/types/jp2.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/jp2.js +0 -56
- package/dist/assets/vendor/image-size/types/jpg.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/jpg.js +0 -95
- package/dist/assets/vendor/image-size/types/ktx.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/ktx.js +0 -15
- package/dist/assets/vendor/image-size/types/png.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/png.js +0 -33
- package/dist/assets/vendor/image-size/types/pnm.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/pnm.js +0 -72
- package/dist/assets/vendor/image-size/types/psd.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/psd.js +0 -14
- package/dist/assets/vendor/image-size/types/svg.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/svg.js +0 -91
- package/dist/assets/vendor/image-size/types/tiff.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/tiff.js +0 -81
- package/dist/assets/vendor/image-size/types/webp.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/webp.js +0 -51
- package/dist/assets/vendor/image-size/types.d.ts +0 -19
- package/dist/assets/vendor/image-size/types.js +0 -37
- package/dist/assets/vendor/queue/queue.d.ts +0 -39
- package/dist/assets/vendor/queue/queue.js +0 -187
package/README.md
CHANGED
|
@@ -34,10 +34,10 @@ Having trouble? Get help in the official [Astro Discord](https://astro.build/cha
|
|
|
34
34
|
|
|
35
35
|
**New contributors welcome!** Check out our [Contributors Guide](/CONTRIBUTING.md) for help getting started.
|
|
36
36
|
|
|
37
|
-
Join us on [Discord](https://astro.build/chat) to meet other
|
|
37
|
+
Join us on [Discord](https://astro.build/chat) to meet other contributors. We'll help you get your first contribution in no time!
|
|
38
38
|
|
|
39
39
|
## Sponsors
|
|
40
40
|
|
|
41
|
-
Astro is generously supported by [
|
|
41
|
+
Astro is generously supported by [Vercel](https://vercel.com/), [storyblok](https://storyblok.com/), and several other amazing organizations [listed here.](https://opencollective.com/astrodotbuild)
|
|
42
42
|
|
|
43
43
|
[❤️ Sponsor Astro! ❤️](https://github.com/withastro/.github/blob/main/FUNDING.md)
|
package/astro-jsx.d.ts
CHANGED
|
@@ -471,6 +471,33 @@ declare namespace astroHTML.JSX {
|
|
|
471
471
|
| 'treegrid'
|
|
472
472
|
| 'treeitem';
|
|
473
473
|
|
|
474
|
+
type CssProperty = keyof Omit<
|
|
475
|
+
CSSStyleDeclaration,
|
|
476
|
+
| 'item'
|
|
477
|
+
| 'setProperty'
|
|
478
|
+
| 'removeProperty'
|
|
479
|
+
| 'getPropertyValue'
|
|
480
|
+
| 'getPropertyPriority'
|
|
481
|
+
| 'parentRule'
|
|
482
|
+
| 'length'
|
|
483
|
+
| 'cssFloat'
|
|
484
|
+
| 'cssText'
|
|
485
|
+
| typeof Symbol.iterator
|
|
486
|
+
| number
|
|
487
|
+
>;
|
|
488
|
+
|
|
489
|
+
type KebabCSSDOMProperties = import('./dist/type-utils.js').KebabKeys<DOMCSSProperties>;
|
|
490
|
+
|
|
491
|
+
type DOMCSSProperties = {
|
|
492
|
+
[key in CssProperty]?: string | number | null | undefined;
|
|
493
|
+
};
|
|
494
|
+
type AllCSSProperties = {
|
|
495
|
+
[key: string]: string | number | null | undefined;
|
|
496
|
+
};
|
|
497
|
+
type StyleObject = import('./dist/type-utils.js').Simplify<
|
|
498
|
+
KebabCSSDOMProperties & DOMCSSProperties & AllCSSProperties
|
|
499
|
+
>;
|
|
500
|
+
|
|
474
501
|
interface HTMLAttributes extends AriaAttributes, DOMAttributes, AstroBuiltinAttributes {
|
|
475
502
|
// Standard HTML Attributes
|
|
476
503
|
accesskey?: string | undefined | null;
|
|
@@ -513,7 +540,7 @@ declare namespace astroHTML.JSX {
|
|
|
513
540
|
lang?: string | undefined | null;
|
|
514
541
|
slot?: string | undefined | null;
|
|
515
542
|
spellcheck?: 'true' | 'false' | boolean | undefined | null;
|
|
516
|
-
style?: string |
|
|
543
|
+
style?: string | StyleObject | undefined | null;
|
|
517
544
|
tabindex?: number | string | undefined | null;
|
|
518
545
|
title?: string | undefined | null;
|
|
519
546
|
translate?: 'yes' | 'no' | undefined | null;
|
package/client.d.ts
CHANGED
|
@@ -48,11 +48,9 @@ declare module 'astro:assets' {
|
|
|
48
48
|
* This is functionally equivalent to using the `<Image />` component, as the component calls this function internally.
|
|
49
49
|
*/
|
|
50
50
|
getImage: (
|
|
51
|
-
options:
|
|
52
|
-
| import('./dist/assets/types.js').ImageTransform
|
|
53
|
-
| import('./dist/assets/types.js').UnresolvedImageTransform
|
|
51
|
+
options: import('./dist/assets/types.js').UnresolvedImageTransform
|
|
54
52
|
) => Promise<import('./dist/assets/types.js').GetImageResult>;
|
|
55
|
-
imageConfig: import('./dist/@types/astro').AstroConfig['image'];
|
|
53
|
+
imageConfig: import('./dist/@types/astro.js').AstroConfig['image'];
|
|
56
54
|
getConfiguredImageService: typeof import('./dist/assets/index.js').getConfiguredImageService;
|
|
57
55
|
Image: typeof import('./components/Image.astro').default;
|
|
58
56
|
};
|
|
@@ -108,6 +106,10 @@ declare module '*.svg' {
|
|
|
108
106
|
const metadata: ImageMetadata;
|
|
109
107
|
export default metadata;
|
|
110
108
|
}
|
|
109
|
+
declare module '*.avif' {
|
|
110
|
+
const metadata: ImageMetadata;
|
|
111
|
+
export default metadata;
|
|
112
|
+
}
|
|
111
113
|
|
|
112
114
|
declare module 'astro:transitions' {
|
|
113
115
|
type TransitionModule = typeof import('./dist/transitions/index.js');
|
|
@@ -126,7 +128,7 @@ declare module 'astro:components' {
|
|
|
126
128
|
export * from 'astro/components';
|
|
127
129
|
}
|
|
128
130
|
|
|
129
|
-
type MD = import('./dist/@types/astro').MarkdownInstance<Record<string, any>>;
|
|
131
|
+
type MD = import('./dist/@types/astro.js').MarkdownInstance<Record<string, any>>;
|
|
130
132
|
interface ExportedMarkdownModuleEntities {
|
|
131
133
|
frontmatter: MD['frontmatter'];
|
|
132
134
|
file: MD['file'];
|
|
@@ -231,7 +233,7 @@ declare module '*.mdown' {
|
|
|
231
233
|
}
|
|
232
234
|
|
|
233
235
|
declare module '*.mdx' {
|
|
234
|
-
type MDX = import('./dist/@types/astro').MDXInstance<Record<string, any>>;
|
|
236
|
+
type MDX = import('./dist/@types/astro.js').MDXInstance<Record<string, any>>;
|
|
235
237
|
|
|
236
238
|
export const frontmatter: MDX['frontmatter'];
|
|
237
239
|
export const file: MDX['file'];
|
|
@@ -244,7 +246,7 @@ declare module '*.mdx' {
|
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
declare module 'astro:ssr-manifest' {
|
|
247
|
-
export const manifest: import('./dist/@types/astro').SSRManifest;
|
|
249
|
+
export const manifest: import('./dist/@types/astro.js').SSRManifest;
|
|
248
250
|
}
|
|
249
251
|
|
|
250
252
|
// Everything below are Vite's types (apart from image types, which are in `client.d.ts`)
|
|
@@ -65,19 +65,19 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
async function getHTML(href: string) {
|
|
68
|
-
let res;
|
|
69
68
|
try {
|
|
70
|
-
res = await fetch(href);
|
|
69
|
+
const res = await fetch(href);
|
|
70
|
+
const html = await res.text();
|
|
71
|
+
return {
|
|
72
|
+
ok: res.ok,
|
|
73
|
+
html,
|
|
74
|
+
redirected: res.redirected ? res.url : undefined,
|
|
75
|
+
// drop potential charset (+ other name/value pairs) as parser needs the mediaType
|
|
76
|
+
mediaType: res.headers.get('content-type')?.replace(/;.*$/, ''),
|
|
77
|
+
};
|
|
71
78
|
} catch (err) {
|
|
72
79
|
return { ok: false };
|
|
73
80
|
}
|
|
74
|
-
const html = await res.text();
|
|
75
|
-
return {
|
|
76
|
-
ok: res.ok,
|
|
77
|
-
html,
|
|
78
|
-
redirected: res.redirected ? res.url : undefined,
|
|
79
|
-
contentType: res.headers.get('content-type'),
|
|
80
|
-
};
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
function getFallback(): Fallback {
|
|
@@ -126,13 +126,13 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
126
126
|
|
|
127
127
|
// A noop element used to prevent styles from being removed
|
|
128
128
|
if (import.meta.env.DEV) {
|
|
129
|
-
var noopEl
|
|
129
|
+
var noopEl = document.createElement('div');
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
async function updateDOM(doc: Document, loc: URL, state?: State, fallback?: Fallback) {
|
|
133
133
|
// Check for a head element that should persist, either because it has the data
|
|
134
134
|
// attribute or is a link el.
|
|
135
|
-
const persistedHeadElement = (el:
|
|
135
|
+
const persistedHeadElement = (el: HTMLElement): Element | null => {
|
|
136
136
|
const id = el.getAttribute(PERSIST_ATTR);
|
|
137
137
|
const newEl = id && doc.head.querySelector(`[${PERSIST_ATTR}="${id}"]`);
|
|
138
138
|
if (newEl) {
|
|
@@ -189,7 +189,7 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
189
189
|
|
|
190
190
|
// Swap head
|
|
191
191
|
for (const el of Array.from(document.head.children)) {
|
|
192
|
-
const newEl = persistedHeadElement(el);
|
|
192
|
+
const newEl = persistedHeadElement(el as HTMLElement);
|
|
193
193
|
// If the element exists in the document already, remove it
|
|
194
194
|
// from the new document and leave the current node alone
|
|
195
195
|
if (newEl) {
|
|
@@ -290,16 +290,16 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
290
290
|
async function navigate(dir: Direction, loc: URL, state?: State) {
|
|
291
291
|
let finished: Promise<void>;
|
|
292
292
|
const href = loc.href;
|
|
293
|
-
const { html, ok,
|
|
293
|
+
const { html, ok, mediaType, redirected } = await getHTML(href);
|
|
294
294
|
// if there was a redirection, show the final URL in the browser's address bar
|
|
295
295
|
redirected && (loc = new URL(redirected));
|
|
296
296
|
// If there is a problem fetching the new page, just do an MPA navigation to it.
|
|
297
|
-
if (!ok ||
|
|
297
|
+
if (!ok || !(mediaType === 'text/html' || mediaType === 'application/xhtml+xml')) {
|
|
298
298
|
location.href = href;
|
|
299
299
|
return;
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
const doc = parser.parseFromString(html,
|
|
302
|
+
const doc = parser.parseFromString(html, mediaType);
|
|
303
303
|
if (!doc.querySelector('[name="astro-view-transitions-enabled"]')) {
|
|
304
304
|
location.href = href;
|
|
305
305
|
return;
|
|
@@ -12,7 +12,12 @@ declare module 'astro:content' {
|
|
|
12
12
|
export { z } from 'astro/zod';
|
|
13
13
|
|
|
14
14
|
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
export type CollectionKey = keyof AnyEntryMap;
|
|
17
|
+
export type CollectionEntry<C extends CollectionKey> = Flatten<AnyEntryMap[C]>;
|
|
18
|
+
|
|
19
|
+
export type ContentCollectionKey = keyof ContentEntryMap;
|
|
20
|
+
export type DataCollectionKey = keyof DataEntryMap;
|
|
16
21
|
|
|
17
22
|
// This needs to be in sync with ImageMetadata
|
|
18
23
|
export type ImageFunction = () => import('astro/zod').ZodObject<{
|
|
@@ -28,6 +33,7 @@ declare module 'astro:content' {
|
|
|
28
33
|
import('astro/zod').ZodLiteral<'webp'>,
|
|
29
34
|
import('astro/zod').ZodLiteral<'gif'>,
|
|
30
35
|
import('astro/zod').ZodLiteral<'svg'>,
|
|
36
|
+
import('astro/zod').ZodLiteral<'avif'>,
|
|
31
37
|
]
|
|
32
38
|
>;
|
|
33
39
|
}>;
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
4
4
|
import type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig } from '@astrojs/markdown-remark';
|
|
5
5
|
import type * as babel from '@babel/core';
|
|
6
6
|
import type { OutgoingHttpHeaders } from 'node:http';
|
|
@@ -8,24 +8,24 @@ import type { AddressInfo } from 'node:net';
|
|
|
8
8
|
import type * as rollup from 'rollup';
|
|
9
9
|
import type { TsConfigJson } from 'tsconfig-resolver';
|
|
10
10
|
import type * as vite from 'vite';
|
|
11
|
-
import type { RemotePattern } from '../assets/utils/remotePattern';
|
|
12
|
-
import type { SerializedSSRManifest } from '../core/app/types';
|
|
13
|
-
import type { PageBuildData } from '../core/build/types';
|
|
14
|
-
import type { AstroConfigType } from '../core/config';
|
|
15
|
-
import type { AstroTimer } from '../core/config/timer';
|
|
16
|
-
import type { AstroCookies } from '../core/cookies';
|
|
11
|
+
import type { RemotePattern } from '../assets/utils/remotePattern.js';
|
|
12
|
+
import type { SerializedSSRManifest } from '../core/app/types.js';
|
|
13
|
+
import type { PageBuildData } from '../core/build/types.js';
|
|
14
|
+
import type { AstroConfigType } from '../core/config/index.js';
|
|
15
|
+
import type { AstroTimer } from '../core/config/timer.js';
|
|
16
|
+
import type { AstroCookies } from '../core/cookies/index.js';
|
|
17
17
|
import type { ResponseWithEncoding } from '../core/endpoint/index.js';
|
|
18
|
-
import type { AstroIntegrationLogger, Logger, LoggerLevel } from '../core/logger/core';
|
|
19
|
-
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
|
|
20
|
-
import type { OmitIndexSignature, Simplify } from '../type-utils';
|
|
18
|
+
import type { AstroIntegrationLogger, Logger, LoggerLevel } from '../core/logger/core.js';
|
|
19
|
+
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server/index.js';
|
|
20
|
+
import type { OmitIndexSignature, Simplify } from '../type-utils.js';
|
|
21
21
|
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
|
|
22
22
|
export { type AstroIntegrationLogger };
|
|
23
23
|
export type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, ShikiConfig, } from '@astrojs/markdown-remark';
|
|
24
|
-
export type { ExternalImageService, ImageService, LocalImageService, } from '../assets/services/service';
|
|
25
|
-
export type { GetImageResult, ImageInputFormat, ImageMetadata, ImageOutputFormat, ImageQuality, ImageQualityPreset, ImageTransform, } from '../assets/types';
|
|
26
|
-
export type { RemotePattern } from '../assets/utils/remotePattern';
|
|
27
|
-
export type { SSRManifest } from '../core/app/types';
|
|
28
|
-
export type { AstroCookies } from '../core/cookies';
|
|
24
|
+
export type { ExternalImageService, ImageService, LocalImageService, } from '../assets/services/service.js';
|
|
25
|
+
export type { GetImageResult, ImageInputFormat, ImageMetadata, ImageOutputFormat, ImageQuality, ImageQualityPreset, ImageTransform, UnresolvedImageTransform, } from '../assets/types.js';
|
|
26
|
+
export type { RemotePattern } from '../assets/utils/remotePattern.js';
|
|
27
|
+
export type { SSRManifest } from '../core/app/types.js';
|
|
28
|
+
export type { AstroCookies } from '../core/cookies/index.js';
|
|
29
29
|
export interface AstroBuiltinProps {
|
|
30
30
|
'client:load'?: boolean;
|
|
31
31
|
'client:idle'?: boolean;
|
|
@@ -889,6 +889,27 @@ export interface AstroUserConfig {
|
|
|
889
889
|
* @name Image Options
|
|
890
890
|
*/
|
|
891
891
|
image?: {
|
|
892
|
+
/**
|
|
893
|
+
* @docs
|
|
894
|
+
* @name image.endpoint
|
|
895
|
+
* @type {string}
|
|
896
|
+
* @default `undefined`
|
|
897
|
+
* @version 3.1.0
|
|
898
|
+
* @description
|
|
899
|
+
* Set the endpoint to use for image optimization in dev and SSR. Set to `undefined` to use the default endpoint.
|
|
900
|
+
*
|
|
901
|
+
* The endpoint will always be injected at `/_image`.
|
|
902
|
+
*
|
|
903
|
+
* ```js
|
|
904
|
+
* {
|
|
905
|
+
* image: {
|
|
906
|
+
* // Example: Use a custom image endpoint
|
|
907
|
+
* endpoint: './src/image-endpoint.ts',
|
|
908
|
+
* },
|
|
909
|
+
* }
|
|
910
|
+
* ```
|
|
911
|
+
*/
|
|
912
|
+
endpoint?: string;
|
|
892
913
|
/**
|
|
893
914
|
* @docs
|
|
894
915
|
* @name image.service
|
package/dist/assets/consts.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare const VIRTUAL_MODULE_ID = "astro:assets";
|
|
2
2
|
export declare const VIRTUAL_SERVICE_ID = "virtual:image-service";
|
|
3
|
-
export declare const VALID_INPUT_FORMATS: readonly ["jpeg", "jpg", "png", "tiff", "webp", "gif", "svg"];
|
|
3
|
+
export declare const VALID_INPUT_FORMATS: readonly ["jpeg", "jpg", "png", "tiff", "webp", "gif", "svg", "avif"];
|
|
4
4
|
/**
|
|
5
5
|
* Valid formats that our base services support.
|
|
6
6
|
* Certain formats can be imported (namely SVGs) but will not be processed.
|
|
7
7
|
*/
|
|
8
|
-
export declare const VALID_SUPPORTED_FORMATS: readonly ["jpeg", "jpg", "png", "tiff", "webp", "gif", "svg"];
|
|
8
|
+
export declare const VALID_SUPPORTED_FORMATS: readonly ["jpeg", "jpg", "png", "tiff", "webp", "gif", "svg", "avif"];
|
|
9
9
|
export declare const VALID_OUTPUT_FORMATS: readonly ["avif", "png", "webp", "jpeg", "jpg", "svg"];
|
package/dist/assets/consts.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
const VIRTUAL_MODULE_ID = "astro:assets";
|
|
2
2
|
const VIRTUAL_SERVICE_ID = "virtual:image-service";
|
|
3
3
|
const VALID_INPUT_FORMATS = [
|
|
4
|
-
// TODO: `image-size` does not support the following formats, so users can't import them.
|
|
5
|
-
// However, it would be immensely useful to add, for three reasons:
|
|
6
|
-
// - `heic` and `heif` are common formats, especially among Apple users.
|
|
7
|
-
// - AVIF is a common format on the web that's bound to become more and more common.
|
|
8
|
-
// - It's totally reasonable for an user's provided image service to want to support more image types.
|
|
9
|
-
//'heic',
|
|
10
|
-
//'heif',
|
|
11
|
-
//'avif',
|
|
12
4
|
"jpeg",
|
|
13
5
|
"jpg",
|
|
14
6
|
"png",
|
|
15
7
|
"tiff",
|
|
16
8
|
"webp",
|
|
17
9
|
"gif",
|
|
18
|
-
"svg"
|
|
10
|
+
"svg",
|
|
11
|
+
"avif"
|
|
19
12
|
];
|
|
20
13
|
const VALID_SUPPORTED_FORMATS = [
|
|
21
14
|
"jpeg",
|
|
@@ -24,7 +17,8 @@ const VALID_SUPPORTED_FORMATS = [
|
|
|
24
17
|
"tiff",
|
|
25
18
|
"webp",
|
|
26
19
|
"gif",
|
|
27
|
-
"svg"
|
|
20
|
+
"svg",
|
|
21
|
+
"avif"
|
|
28
22
|
];
|
|
29
23
|
const VALID_OUTPUT_FORMATS = ["avif", "png", "webp", "jpeg", "jpg", "svg"];
|
|
30
24
|
export {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AstroConfig, AstroSettings } from '../@types/astro.js';
|
|
2
2
|
import { type ImageService } from './services/service.js';
|
|
3
|
-
import type { GetImageResult, ImageMetadata,
|
|
3
|
+
import type { GetImageResult, ImageMetadata, UnresolvedImageTransform } from './types.js';
|
|
4
4
|
export declare function injectImageEndpoint(settings: AstroSettings): AstroSettings;
|
|
5
5
|
export declare function isESMImportedImage(src: ImageMetadata | string): src is ImageMetadata;
|
|
6
6
|
export declare function isRemoteImage(src: ImageMetadata | string): src is string;
|
|
7
7
|
export declare function isRemoteAllowed(src: string, { domains, remotePatterns, }: Partial<Pick<AstroConfig['image'], 'domains' | 'remotePatterns'>>): boolean;
|
|
8
8
|
export declare function getConfiguredImageService(): Promise<ImageService>;
|
|
9
|
-
export declare function getImage(options:
|
|
9
|
+
export declare function getImage(options: UnresolvedImageTransform, imageConfig: AstroConfig['image']): Promise<GetImageResult>;
|
package/dist/assets/internal.js
CHANGED
|
@@ -3,9 +3,10 @@ import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
|
3
3
|
import { isLocalService } from "./services/service.js";
|
|
4
4
|
import { matchHostname, matchPattern } from "./utils/remotePattern.js";
|
|
5
5
|
function injectImageEndpoint(settings) {
|
|
6
|
+
const endpointEntrypoint = settings.config.image.endpoint ?? "astro/assets/image-endpoint";
|
|
6
7
|
settings.injectedRoutes.push({
|
|
7
8
|
pattern: "/_image",
|
|
8
|
-
entryPoint:
|
|
9
|
+
entryPoint: endpointEntrypoint,
|
|
9
10
|
prerender: false
|
|
10
11
|
});
|
|
11
12
|
return settings;
|
|
@@ -52,7 +53,7 @@ async function getImage(options, imageConfig) {
|
|
|
52
53
|
const service = await getConfiguredImageService();
|
|
53
54
|
const resolvedOptions = {
|
|
54
55
|
...options,
|
|
55
|
-
src: typeof options.src === "object" && "then" in options.src ? (await options.src).default : options.src
|
|
56
|
+
src: typeof options.src === "object" && "then" in options.src ? (await options.src).default ?? await options.src : options.src
|
|
56
57
|
};
|
|
57
58
|
const validatedOptions = service.validateOptions ? await service.validateOptions(resolvedOptions, imageConfig) : resolvedOptions;
|
|
58
59
|
let imageURL = await service.getURL(validatedOptions, imageConfig);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type { AstroConfig } from '../../@types/astro.js';
|
|
3
3
|
import type { ImageOutputFormat, ImageTransform } from '../types.js';
|
|
4
4
|
export type ImageService = LocalImageService | ExternalImageService;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AstroError, AstroErrorData } from "../../core/errors/index.js";
|
|
2
|
-
import { joinPaths } from "../../core/path.js";
|
|
2
|
+
import { isRemotePath, joinPaths } from "../../core/path.js";
|
|
3
3
|
import { VALID_SUPPORTED_FORMATS } from "../consts.js";
|
|
4
4
|
import { isESMImportedImage, isRemoteAllowed } from "../internal.js";
|
|
5
5
|
function isLocalService(service) {
|
|
@@ -20,11 +20,15 @@ const baseService = {
|
|
|
20
20
|
if (!options.src || typeof options.src !== "string" && typeof options.src !== "object") {
|
|
21
21
|
throw new AstroError({
|
|
22
22
|
...AstroErrorData.ExpectedImage,
|
|
23
|
-
message: AstroErrorData.ExpectedImage.message(
|
|
23
|
+
message: AstroErrorData.ExpectedImage.message(
|
|
24
|
+
JSON.stringify(options.src),
|
|
25
|
+
typeof options.src,
|
|
26
|
+
JSON.stringify(options, (_, v) => v === void 0 ? null : v)
|
|
27
|
+
)
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
30
|
if (!isESMImportedImage(options.src)) {
|
|
27
|
-
if (options.src.startsWith("/@fs/")) {
|
|
31
|
+
if (options.src.startsWith("/@fs/") || !isRemotePath(options.src) && !options.src.startsWith("/")) {
|
|
28
32
|
throw new AstroError({
|
|
29
33
|
...AstroErrorData.LocalImageUsedWrongly,
|
|
30
34
|
message: AstroErrorData.LocalImageUsedWrongly.message(options.src)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
interface DecodeModule extends EmscriptenWasm.Module {
|
|
3
3
|
decode: (data: Uint8Array) => ImageData;
|
|
4
4
|
}
|
|
@@ -12,9 +12,9 @@ export interface ResizeOptions {
|
|
|
12
12
|
export interface RotateOptions {
|
|
13
13
|
numRotations: number;
|
|
14
14
|
}
|
|
15
|
-
import type { MozJPEGModule as MozJPEGEncodeModule } from './mozjpeg/mozjpeg_enc';
|
|
16
|
-
import type { WebPModule as WebPEncodeModule } from './webp/webp_enc';
|
|
17
|
-
import type { AVIFModule as AVIFEncodeModule } from './avif/avif_enc';
|
|
15
|
+
import type { MozJPEGModule as MozJPEGEncodeModule } from './mozjpeg/mozjpeg_enc.js';
|
|
16
|
+
import type { WebPModule as WebPEncodeModule } from './webp/webp_enc.js';
|
|
17
|
+
import type { AVIFModule as AVIFEncodeModule } from './avif/avif_enc.js';
|
|
18
18
|
import ImageData from './image_data.js';
|
|
19
19
|
export declare const preprocessors: {
|
|
20
20
|
readonly resize: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type { ImageOutputFormat } from '../../../types.js';
|
|
3
3
|
import type { Operation } from './image.js';
|
|
4
4
|
export declare function processBuffer(buffer: Buffer, operations: Operation[], encoding: ImageOutputFormat, quality?: number): Promise<Uint8Array>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import ImageData from './image_data.js';
|
|
3
3
|
export declare function decodeBuffer(_buffer: Buffer | Uint8Array): Promise<ImageData>;
|
|
4
4
|
export declare function rotate(image: ImageData, numRotations: number): Promise<ImageData>;
|
package/dist/assets/types.d.ts
CHANGED
|
@@ -25,8 +25,11 @@ export interface ImageMetadata {
|
|
|
25
25
|
format: ImageInputFormat;
|
|
26
26
|
orientation?: number;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* A yet to be resolved image transform. Used by `getImage`
|
|
30
|
+
*/
|
|
28
31
|
export type UnresolvedImageTransform = Omit<ImageTransform, 'src'> & {
|
|
29
|
-
src: Promise<{
|
|
32
|
+
src: ImageMetadata | string | Promise<{
|
|
30
33
|
default: ImageMetadata;
|
|
31
34
|
}>;
|
|
32
35
|
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import probe from "probe-image-size";
|
|
2
2
|
async function imageMetadata(data) {
|
|
3
|
-
const
|
|
3
|
+
const result = probe.sync(data);
|
|
4
|
+
if (result === null) {
|
|
5
|
+
throw new Error("Failed to probe image size.");
|
|
6
|
+
}
|
|
7
|
+
const { width, height, type, orientation } = result;
|
|
4
8
|
const isPortrait = (orientation || 0) >= 5;
|
|
5
9
|
if (!width || !height || !type) {
|
|
6
10
|
return void 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as vite from 'vite';
|
|
2
|
-
import type { AstroPluginOptions } from '../@types/astro';
|
|
2
|
+
import type { AstroPluginOptions } from '../@types/astro.js';
|
|
3
3
|
export default function assets({ settings, mode, }: AstroPluginOptions & {
|
|
4
4
|
mode: string;
|
|
5
5
|
}): vite.Plugin[];
|
|
@@ -10,7 +10,7 @@ import { VALID_INPUT_FORMATS, VIRTUAL_MODULE_ID, VIRTUAL_SERVICE_ID } from "./co
|
|
|
10
10
|
import { emitESMImage } from "./utils/emitAsset.js";
|
|
11
11
|
import { hashTransform, propsToFilename } from "./utils/transformToPath.js";
|
|
12
12
|
const resolvedVirtualModuleId = "\0" + VIRTUAL_MODULE_ID;
|
|
13
|
-
const assetRegex = new RegExp(
|
|
13
|
+
const assetRegex = new RegExp(`\\.(${VALID_INPUT_FORMATS.join("|")})$`, "i");
|
|
14
14
|
function assets({
|
|
15
15
|
settings,
|
|
16
16
|
mode
|