astro 3.0.12 → 3.1.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 +2 -2
- package/astro-jsx.d.ts +28 -1
- package/client.d.ts +8 -4
- package/components/ViewTransitions.astro +77 -24
- package/content-types.template.d.ts +6 -1
- package/dist/@types/astro.d.ts +43 -22
- 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.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/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/utils.js +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 +3 -0
- 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/render/ssr-element.js +1 -3
- 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/hmr.js +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/tags.js +1 -1
- package/dist/runtime/server/render/util.d.ts +1 -1
- package/dist/runtime/server/scripts.d.ts +1 -1
- 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/route.js +0 -1
- 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
|
@@ -52,7 +52,7 @@ declare module 'astro:assets' {
|
|
|
52
52
|
| import('./dist/assets/types.js').ImageTransform
|
|
53
53
|
| import('./dist/assets/types.js').UnresolvedImageTransform
|
|
54
54
|
) => Promise<import('./dist/assets/types.js').GetImageResult>;
|
|
55
|
-
imageConfig: import('./dist/@types/astro').AstroConfig['image'];
|
|
55
|
+
imageConfig: import('./dist/@types/astro.js').AstroConfig['image'];
|
|
56
56
|
getConfiguredImageService: typeof import('./dist/assets/index.js').getConfiguredImageService;
|
|
57
57
|
Image: typeof import('./components/Image.astro').default;
|
|
58
58
|
};
|
|
@@ -108,6 +108,10 @@ declare module '*.svg' {
|
|
|
108
108
|
const metadata: ImageMetadata;
|
|
109
109
|
export default metadata;
|
|
110
110
|
}
|
|
111
|
+
declare module '*.avif' {
|
|
112
|
+
const metadata: ImageMetadata;
|
|
113
|
+
export default metadata;
|
|
114
|
+
}
|
|
111
115
|
|
|
112
116
|
declare module 'astro:transitions' {
|
|
113
117
|
type TransitionModule = typeof import('./dist/transitions/index.js');
|
|
@@ -126,7 +130,7 @@ declare module 'astro:components' {
|
|
|
126
130
|
export * from 'astro/components';
|
|
127
131
|
}
|
|
128
132
|
|
|
129
|
-
type MD = import('./dist/@types/astro').MarkdownInstance<Record<string, any>>;
|
|
133
|
+
type MD = import('./dist/@types/astro.js').MarkdownInstance<Record<string, any>>;
|
|
130
134
|
interface ExportedMarkdownModuleEntities {
|
|
131
135
|
frontmatter: MD['frontmatter'];
|
|
132
136
|
file: MD['file'];
|
|
@@ -231,7 +235,7 @@ declare module '*.mdown' {
|
|
|
231
235
|
}
|
|
232
236
|
|
|
233
237
|
declare module '*.mdx' {
|
|
234
|
-
type MDX = import('./dist/@types/astro').MDXInstance<Record<string, any>>;
|
|
238
|
+
type MDX = import('./dist/@types/astro.js').MDXInstance<Record<string, any>>;
|
|
235
239
|
|
|
236
240
|
export const frontmatter: MDX['frontmatter'];
|
|
237
241
|
export const file: MDX['file'];
|
|
@@ -244,7 +248,7 @@ declare module '*.mdx' {
|
|
|
244
248
|
}
|
|
245
249
|
|
|
246
250
|
declare module 'astro:ssr-manifest' {
|
|
247
|
-
export const manifest: import('./dist/@types/astro').SSRManifest;
|
|
251
|
+
export const manifest: import('./dist/@types/astro.js').SSRManifest;
|
|
248
252
|
}
|
|
249
253
|
|
|
250
254
|
// Everything below are Vite's types (apart from image types, which are in `client.d.ts`)
|
|
@@ -15,6 +15,7 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
15
15
|
type Direction = 'forward' | 'back';
|
|
16
16
|
type State = {
|
|
17
17
|
index: number;
|
|
18
|
+
scrollX: number;
|
|
18
19
|
scrollY: number;
|
|
19
20
|
};
|
|
20
21
|
type Events = 'astro:page-load' | 'astro:after-swap';
|
|
@@ -37,9 +38,9 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
37
38
|
// we reloaded a page with history state
|
|
38
39
|
// (e.g. history navigation from non-transition page or browser reload)
|
|
39
40
|
currentHistoryIndex = history.state.index;
|
|
40
|
-
scrollTo({ left:
|
|
41
|
+
scrollTo({ left: history.state.scrollX, top: history.state.scrollY });
|
|
41
42
|
} else if (transitionEnabledOnThisPage()) {
|
|
42
|
-
history.replaceState({ index: currentHistoryIndex, scrollY }, '');
|
|
43
|
+
history.replaceState({ index: currentHistoryIndex, scrollX, scrollY }, '');
|
|
43
44
|
}
|
|
44
45
|
const throttle = (cb: (...args: any[]) => any, delay: number) => {
|
|
45
46
|
let wait = false;
|
|
@@ -64,9 +65,19 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
async function getHTML(href: string) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
try {
|
|
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
|
+
};
|
|
78
|
+
} catch (err) {
|
|
79
|
+
return { ok: false };
|
|
80
|
+
}
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
function getFallback(): Fallback {
|
|
@@ -113,10 +124,15 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
113
124
|
|
|
114
125
|
const parser = new DOMParser();
|
|
115
126
|
|
|
127
|
+
// A noop element used to prevent styles from being removed
|
|
128
|
+
if (import.meta.env.DEV) {
|
|
129
|
+
var noopEl = document.createElement('div');
|
|
130
|
+
}
|
|
131
|
+
|
|
116
132
|
async function updateDOM(doc: Document, loc: URL, state?: State, fallback?: Fallback) {
|
|
117
133
|
// Check for a head element that should persist, either because it has the data
|
|
118
134
|
// attribute or is a link el.
|
|
119
|
-
const persistedHeadElement = (el:
|
|
135
|
+
const persistedHeadElement = (el: HTMLElement): Element | null => {
|
|
120
136
|
const id = el.getAttribute(PERSIST_ATTR);
|
|
121
137
|
const newEl = id && doc.head.querySelector(`[${PERSIST_ATTR}="${id}"]`);
|
|
122
138
|
if (newEl) {
|
|
@@ -139,6 +155,18 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
139
155
|
}
|
|
140
156
|
}
|
|
141
157
|
}
|
|
158
|
+
// Only run this in dev. This will get stripped from production builds and is not needed.
|
|
159
|
+
if (import.meta.env.DEV) {
|
|
160
|
+
if (el.tagName === 'STYLE' && el.dataset.viteDevId) {
|
|
161
|
+
const devId = el.dataset.viteDevId;
|
|
162
|
+
// If this same style tag exists, remove it from the new page
|
|
163
|
+
return (
|
|
164
|
+
doc.querySelector(`style[data-astro-dev-id="${devId}"]`) ||
|
|
165
|
+
// Otherwise, keep it anyways. This is client:only styles.
|
|
166
|
+
noopEl
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
142
170
|
return null;
|
|
143
171
|
};
|
|
144
172
|
|
|
@@ -161,7 +189,7 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
161
189
|
|
|
162
190
|
// Swap head
|
|
163
191
|
for (const el of Array.from(document.head.children)) {
|
|
164
|
-
const newEl = persistedHeadElement(el);
|
|
192
|
+
const newEl = persistedHeadElement(el as HTMLElement);
|
|
165
193
|
// If the element exists in the document already, remove it
|
|
166
194
|
// from the new document and leave the current node alone
|
|
167
195
|
if (newEl) {
|
|
@@ -191,17 +219,29 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
191
219
|
// Chromium based browsers (Chrome, Edge, Opera, ...)
|
|
192
220
|
scrollTo({ left: 0, top: 0, behavior: 'instant' });
|
|
193
221
|
|
|
222
|
+
let initialScrollX = 0;
|
|
194
223
|
let initialScrollY = 0;
|
|
195
224
|
if (!state && loc.hash) {
|
|
196
225
|
const id = decodeURIComponent(loc.hash.slice(1));
|
|
197
226
|
const elem = document.getElementById(id);
|
|
198
227
|
// prefer scrollIntoView() over scrollTo() because it takes scroll-padding into account
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
228
|
+
if (elem) {
|
|
229
|
+
elem.scrollIntoView();
|
|
230
|
+
initialScrollX = Math.max(
|
|
231
|
+
0,
|
|
232
|
+
elem.offsetLeft + elem.offsetWidth - document.documentElement.clientWidth
|
|
233
|
+
);
|
|
234
|
+
initialScrollY = elem.offsetTop;
|
|
235
|
+
}
|
|
236
|
+
} else if (state) {
|
|
237
|
+
scrollTo(state.scrollX, state.scrollY); // usings default scrollBehavior
|
|
202
238
|
}
|
|
203
239
|
!state &&
|
|
204
|
-
history.pushState(
|
|
240
|
+
history.pushState(
|
|
241
|
+
{ index: ++currentHistoryIndex, scrollX: initialScrollX, scrollY: initialScrollY },
|
|
242
|
+
'',
|
|
243
|
+
loc.href
|
|
244
|
+
);
|
|
205
245
|
triggerEvent('astro:after-swap');
|
|
206
246
|
};
|
|
207
247
|
|
|
@@ -250,18 +290,24 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
250
290
|
async function navigate(dir: Direction, loc: URL, state?: State) {
|
|
251
291
|
let finished: Promise<void>;
|
|
252
292
|
const href = loc.href;
|
|
253
|
-
const { html, ok } = await getHTML(href);
|
|
293
|
+
const { html, ok, mediaType, redirected } = await getHTML(href);
|
|
294
|
+
// if there was a redirection, show the final URL in the browser's address bar
|
|
295
|
+
redirected && (loc = new URL(redirected));
|
|
254
296
|
// If there is a problem fetching the new page, just do an MPA navigation to it.
|
|
255
|
-
if (!ok) {
|
|
297
|
+
if (!ok || !(mediaType === 'text/html' || mediaType === 'application/xhtml+xml')) {
|
|
256
298
|
location.href = href;
|
|
257
299
|
return;
|
|
258
300
|
}
|
|
259
|
-
|
|
301
|
+
|
|
302
|
+
const doc = parser.parseFromString(html, mediaType);
|
|
260
303
|
if (!doc.querySelector('[name="astro-view-transitions-enabled"]')) {
|
|
261
304
|
location.href = href;
|
|
262
305
|
return;
|
|
263
306
|
}
|
|
264
307
|
|
|
308
|
+
// Now we are sure that we will push state, and it is time to create a state if it is still missing.
|
|
309
|
+
!state && history.replaceState({ index: currentHistoryIndex, scrollX, scrollY }, '');
|
|
310
|
+
|
|
265
311
|
document.documentElement.dataset.astroTransition = dir;
|
|
266
312
|
if (supportsViewTransitions) {
|
|
267
313
|
finished = document.startViewTransition(() => updateDOM(doc, loc, state)).finished;
|
|
@@ -335,28 +381,31 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
335
381
|
// But we want to handle it like any other same page navigation
|
|
336
382
|
// So we scroll to the top of the page but do not start page transitions
|
|
337
383
|
ev.preventDefault();
|
|
338
|
-
|
|
339
|
-
scrollTo({ left: 0, top: 0, behavior: 'instant' });
|
|
384
|
+
// push state on the first navigation but not if we were here already
|
|
340
385
|
if (location.hash) {
|
|
341
|
-
|
|
342
|
-
|
|
386
|
+
history.replaceState(
|
|
387
|
+
{ index: currentHistoryIndex, scrollX, scrollY: -(scrollY + 1) },
|
|
388
|
+
''
|
|
389
|
+
);
|
|
390
|
+
const newState: State = { index: ++currentHistoryIndex, scrollX: 0, scrollY: 0 };
|
|
343
391
|
history.pushState(newState, '', link.href);
|
|
344
392
|
}
|
|
393
|
+
scrollTo({ left: 0, top: 0, behavior: 'instant' });
|
|
345
394
|
return;
|
|
346
395
|
}
|
|
347
396
|
}
|
|
348
397
|
|
|
349
398
|
// these are the cases we will handle: same origin, different page
|
|
350
399
|
ev.preventDefault();
|
|
351
|
-
persistState({ index: currentHistoryIndex, scrollY });
|
|
352
400
|
navigate('forward', new URL(link.href));
|
|
353
401
|
});
|
|
354
402
|
|
|
355
403
|
addEventListener('popstate', (ev) => {
|
|
356
404
|
if (!transitionEnabledOnThisPage() && ev.state) {
|
|
357
|
-
// The current page doesn't
|
|
358
|
-
//
|
|
359
|
-
//
|
|
405
|
+
// The current page doesn't have View Transitions enabled
|
|
406
|
+
// but the page we navigate to does (because it set the state).
|
|
407
|
+
// Do a full page refresh to reload the client-side router from the new page.
|
|
408
|
+
// Scroll restauration will then happen during the reload when the router's code is re-executed
|
|
360
409
|
history.scrollRestoration && (history.scrollRestoration = 'manual');
|
|
361
410
|
location.reload();
|
|
362
411
|
return;
|
|
@@ -383,7 +432,11 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
383
432
|
const nextIndex = state.index;
|
|
384
433
|
const direction: Direction = nextIndex > currentHistoryIndex ? 'forward' : 'back';
|
|
385
434
|
currentHistoryIndex = nextIndex;
|
|
386
|
-
|
|
435
|
+
if (state.scrollY < 0) {
|
|
436
|
+
scrollTo(state.scrollX, -(state.scrollY + 1));
|
|
437
|
+
} else {
|
|
438
|
+
navigate(direction, new URL(location.href), state);
|
|
439
|
+
}
|
|
387
440
|
});
|
|
388
441
|
|
|
389
442
|
['mouseenter', 'touchstart', 'focus'].forEach((evName) => {
|
|
@@ -408,7 +461,7 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
408
461
|
// There's not a good way to record scroll position before a back button.
|
|
409
462
|
// So the way we do it is by listening to scrollend if supported, and if not continuously record the scroll position.
|
|
410
463
|
const updateState = () => {
|
|
411
|
-
persistState({ ...history.state, scrollY });
|
|
464
|
+
persistState({ ...history.state, scrollX, scrollY });
|
|
412
465
|
};
|
|
413
466
|
|
|
414
467
|
if ('onscrollend' in window) addEventListener('scrollend', updateState);
|
|
@@ -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<{
|
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, } 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;
|
|
@@ -543,12 +543,12 @@ export interface AstroUserConfig {
|
|
|
543
543
|
* @description
|
|
544
544
|
*
|
|
545
545
|
* Specify the strategy used for scoping styles within Astro components. Choose from:
|
|
546
|
-
* - `'where'` - Use `:where` selectors, causing no
|
|
547
|
-
* - `'class'` - Use class-based selectors, causing a +1
|
|
548
|
-
* - `'attribute'` - Use `data-` attributes, causing
|
|
546
|
+
* - `'where'` - Use `:where` selectors, causing no specificity increase.
|
|
547
|
+
* - `'class'` - Use class-based selectors, causing a +1 specificity increase.
|
|
548
|
+
* - `'attribute'` - Use `data-` attributes, causing a +1 specificity increase.
|
|
549
549
|
*
|
|
550
550
|
* Using `'class'` is helpful when you want to ensure that element selectors within an Astro component override global style defaults (e.g. from a global stylesheet).
|
|
551
|
-
* Using `'where'` gives you more control over
|
|
551
|
+
* Using `'where'` gives you more control over specificity, but requires that you use higher-specificity selectors, layers, and other tools to control which selectors are applied.
|
|
552
552
|
* Using `'attribute'` is useful when you are manipulating the `class` attribute of elements and need to avoid conflicts between your own styling logic and Astro's application of styles.
|
|
553
553
|
*/
|
|
554
554
|
scopedStyleStrategy?: 'where' | 'class' | 'attribute';
|
|
@@ -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
|
|
@@ -911,7 +932,7 @@ export interface AstroUserConfig {
|
|
|
911
932
|
* }
|
|
912
933
|
* ```
|
|
913
934
|
*/
|
|
914
|
-
service
|
|
935
|
+
service?: ImageServiceConfig;
|
|
915
936
|
/**
|
|
916
937
|
* @docs
|
|
917
938
|
* @name image.domains
|
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 {
|
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>;
|