astro 4.5.9 → 4.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/astro-jsx.d.ts CHANGED
@@ -526,7 +526,7 @@ declare namespace astroHTML.JSX {
526
526
  | 'search'
527
527
  | 'send'
528
528
  | undefined
529
- | null;
529
+ | null;
530
530
  exportparts?: string | undefined | null;
531
531
  hidden?: boolean | string | undefined | null;
532
532
  id?: string | undefined | null;
@@ -584,6 +584,9 @@ declare namespace astroHTML.JSX {
584
584
  results?: number | string | undefined | null;
585
585
  security?: string | undefined | null;
586
586
  unselectable?: 'on' | 'off' | undefined | null; // Internet Explorer
587
+
588
+ // Allow data- attribute
589
+ [key: `data-${string}`]: any;
587
590
  }
588
591
 
589
592
  type HTMLAttributeReferrerPolicy =
@@ -1344,6 +1347,9 @@ declare namespace astroHTML.JSX {
1344
1347
  yChannelSelector?: string | undefined | null;
1345
1348
  z?: number | string | undefined | null;
1346
1349
  zoomAndPan?: string | undefined | null;
1350
+
1351
+ // Allow data- attribute
1352
+ [key: `data-${string}`]: any;
1347
1353
  }
1348
1354
 
1349
1355
  interface DefinedIntrinsicElements {
@@ -80,7 +80,7 @@ const highlighter = await getCachedHighlighter({
80
80
  ? Object.keys(bundledLanguages).includes(lang)
81
81
  ? lang
82
82
  : 'plaintext'
83
- : lang,
83
+ : (lang as any),
84
84
  ],
85
85
  theme,
86
86
  themes,
@@ -89,7 +89,7 @@ const highlighter = await getCachedHighlighter({
89
89
 
90
90
  const html = highlighter.highlight(code, typeof lang === 'string' ? lang : lang.name, {
91
91
  inline,
92
- attributes: rest,
92
+ attributes: rest as any,
93
93
  });
94
94
  ---
95
95
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import { getImage, type LocalImageProps, type RemoteImageProps } from 'astro:assets';
3
3
  import type { GetImageResult, ImageOutputFormat } from '../dist/@types/astro';
4
- import { isESMImportedImage } from '../dist/assets/utils/imageKind';
4
+ import { isESMImportedImage, resolveSrc } from '../dist/assets/utils/imageKind';
5
5
  import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
6
6
  import type { HTMLAttributes } from '../types';
7
7
 
@@ -27,20 +27,27 @@ if (props.alt === undefined || props.alt === null) {
27
27
  throw new AstroError(AstroErrorData.ImageMissingAlt);
28
28
  }
29
29
 
30
+ const originalSrc = await resolveSrc(props.src);
30
31
  const optimizedImages: GetImageResult[] = await Promise.all(
31
32
  formats.map(
32
33
  async (format) =>
33
- await getImage({ ...props, format: format, widths: props.widths, densities: props.densities })
34
+ await getImage({
35
+ ...props,
36
+ src: originalSrc,
37
+ format: format,
38
+ widths: props.widths,
39
+ densities: props.densities,
40
+ })
34
41
  )
35
42
  );
36
43
 
37
44
  let resultFallbackFormat = fallbackFormat ?? defaultFallbackFormat;
38
45
  if (
39
46
  !fallbackFormat &&
40
- isESMImportedImage(props.src) &&
41
- specialFormatsFallback.includes(props.src.format)
47
+ isESMImportedImage(originalSrc) &&
48
+ originalSrc.format in specialFormatsFallback
42
49
  ) {
43
- resultFallbackFormat = props.src.format;
50
+ resultFallbackFormat = originalSrc.format;
44
51
  }
45
52
 
46
53
  const fallbackImage = await getImage({
@@ -1,7 +1,7 @@
1
1
  import { AstroError, AstroErrorData } from "../core/errors/index.js";
2
2
  import { DEFAULT_HASH_PROPS } from "./consts.js";
3
3
  import { isLocalService } from "./services/service.js";
4
- import { isESMImportedImage, isRemoteImage } from "./utils/imageKind.js";
4
+ import { isESMImportedImage, isRemoteImage, resolveSrc } from "./utils/imageKind.js";
5
5
  import { probe } from "./utils/remoteProbe.js";
6
6
  async function getConfiguredImageService() {
7
7
  if (!globalThis?.astroAsset?.imageService) {
@@ -40,7 +40,7 @@ async function getImage(options, imageConfig) {
40
40
  const service = await getConfiguredImageService();
41
41
  const resolvedOptions = {
42
42
  ...options,
43
- src: typeof options.src === "object" && "then" in options.src ? (await options.src).default ?? await options.src : options.src
43
+ src: await resolveSrc(options.src)
44
44
  };
45
45
  if (options.inferSize && isRemoteImage(resolvedOptions.src)) {
46
46
  try {
@@ -1,3 +1,4 @@
1
- import type { ImageMetadata } from '../types.js';
1
+ import type { ImageMetadata, UnresolvedImageTransform } from '../types.js';
2
2
  export declare function isESMImportedImage(src: ImageMetadata | string): src is ImageMetadata;
3
3
  export declare function isRemoteImage(src: ImageMetadata | string): src is string;
4
+ export declare function resolveSrc(src: UnresolvedImageTransform['src']): Promise<string | ImageMetadata>;
@@ -4,7 +4,11 @@ function isESMImportedImage(src) {
4
4
  function isRemoteImage(src) {
5
5
  return typeof src === "string";
6
6
  }
7
+ async function resolveSrc(src) {
8
+ return typeof src === "object" && "then" in src ? (await src).default ?? await src : src;
9
+ }
7
10
  export {
8
11
  isESMImportedImage,
9
- isRemoteImage
12
+ isRemoteImage,
13
+ resolveSrc
10
14
  };
@@ -57,12 +57,18 @@ function assets({
57
57
  export { default as Picture } from "astro/components/Picture.astro";
58
58
 
59
59
  export const imageConfig = ${JSON.stringify(settings.config.image)};
60
- export const outDir = new URL(${JSON.stringify(
60
+ // This is used by the @astrojs/node integration to locate images.
61
+ // It's unused on other platforms, but on some platforms like Netlify (and presumably also Vercel)
62
+ // new URL("dist/...") is interpreted by the bundler as a signal to include that directory
63
+ // in the Lambda bundle, which would bloat the bundle with images.
64
+ // To prevent this, we mark the URL construction as pure,
65
+ // so that it's tree-shaken away for all platforms that don't need it.
66
+ export const outDir = /* #__PURE__ */ new URL(${JSON.stringify(
61
67
  new URL(
62
68
  isServerLikeOutput(settings.config) ? settings.config.build.client : settings.config.outDir
63
69
  )
64
70
  )});
65
- export const assetsDir = new URL(${JSON.stringify(settings.config.build.assets)}, outDir);
71
+ export const assetsDir = /* #__PURE__ */ new URL(${JSON.stringify(settings.config.build.assets)}, outDir);
66
72
  export const getImage = async (options) => await getImageInternal(options, imageConfig);
67
73
  `;
68
74
  }
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.5.9";
1
+ const ASTRO_VERSION = "4.5.10";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
4
4
  const DEFAULT_404_COMPONENT = "astro-default-404";
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
23
23
  base: restart.container.settings.config.base
24
24
  })
25
25
  );
26
- const currentVersion = "4.5.9";
26
+ const currentVersion = "4.5.10";
27
27
  if (currentVersion.includes("-")) {
28
28
  logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
29
29
  }
@@ -36,7 +36,7 @@ function serverStart({
36
36
  host,
37
37
  base
38
38
  }) {
39
- const version = "4.5.9";
39
+ const version = "4.5.10";
40
40
  const localPrefix = `${dim("\u2503")} Local `;
41
41
  const networkPrefix = `${dim("\u2503")} Network `;
42
42
  const emptyPrefix = " ".repeat(11);
@@ -261,7 +261,7 @@ function printHelp({
261
261
  message.push(
262
262
  linebreak(),
263
263
  ` ${bgGreen(black(` ${commandName} `))} ${green(
264
- `v${"4.5.9"}`
264
+ `v${"4.5.10"}`
265
265
  )} ${headline}`
266
266
  );
267
267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.5.9",
3
+ "version": "4.5.10",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -162,8 +162,8 @@
162
162
  "zod": "^3.22.4",
163
163
  "zod-to-json-schema": "^3.22.4",
164
164
  "@astrojs/internal-helpers": "0.3.0",
165
- "@astrojs/markdown-remark": "4.3.1",
166
- "@astrojs/telemetry": "3.0.4"
165
+ "@astrojs/telemetry": "3.0.4",
166
+ "@astrojs/markdown-remark": "4.3.2"
167
167
  },
168
168
  "optionalDependencies": {
169
169
  "sharp": "^0.32.6"
package/types.d.ts CHANGED
@@ -4,6 +4,7 @@ import type { Simplify } from './dist/type-utils.js';
4
4
 
5
5
  /** Any supported HTML or SVG element name, as defined by the HTML specification */
6
6
  export type HTMLTag = keyof astroHTML.JSX.DefinedIntrinsicElements;
7
+
7
8
  /** The built-in attributes for any known HTML or SVG element name */
8
9
  export type HTMLAttributes<Tag extends HTMLTag> = Omit<
9
10
  astroHTML.JSX.IntrinsicElements[Tag],
@@ -15,9 +16,10 @@ export type HTMLAttributes<Tag extends HTMLTag> = Omit<
15
16
  */
16
17
  export type CSSProperty = keyof astroHTML.JSX.KebabCSSDOMProperties;
17
18
 
18
- type PolymorphicAttributes<P extends { as: HTMLTag }> = Omit<P & HTMLAttributes<P['as']>, 'as'> & {
19
+ type PolymorphicAttributes<P extends { as: HTMLTag }> = Omit<P, 'as'> & {
19
20
  as?: P['as'];
20
- };
21
+ } & HTMLAttributes<P['as']>;
22
+
21
23
  export type Polymorphic<P extends { as: HTMLTag }> = PolymorphicAttributes<
22
24
  Omit<P, 'as'> & { as: NonNullable<P['as']> }
23
25
  >;