astro 5.16.5 → 5.16.6
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/dist/assets/endpoint/dev.js +7 -6
- package/dist/assets/services/noop.js +10 -5
- package/dist/assets/services/service.d.ts +1 -1
- package/dist/assets/services/service.js +55 -51
- package/dist/assets/types.d.ts +2 -2
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/types/public/extendables.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { root } from "astro:config/server";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
import os from "node:os";
|
|
4
3
|
import { fileURLToPath } from "node:url";
|
|
5
4
|
import { isParentDirectory } from "@astrojs/internal-helpers/path";
|
|
6
5
|
import { handleImageRequest, loadRemoteImage } from "./shared.js";
|
|
7
|
-
function replaceFileSystemReferences(src) {
|
|
8
|
-
return os.platform().includes("win32") ? src.replace(/^\/@fs\//, "") : src.replace(/^\/@fs/, "");
|
|
9
|
-
}
|
|
10
6
|
async function loadLocalImage(src, url) {
|
|
11
7
|
if (src.startsWith("/@fs/")) {
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
try {
|
|
9
|
+
const res = await fetch(new URL(src, url));
|
|
10
|
+
if (!res.ok) {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
13
|
+
return Buffer.from(await res.arrayBuffer());
|
|
14
|
+
} catch {
|
|
14
15
|
return void 0;
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isESMImportedImage } from "../utils/imageKind.js";
|
|
2
|
+
import { baseService, verifyOptions } from "./service.js";
|
|
2
3
|
const noopService = {
|
|
3
4
|
...baseService,
|
|
4
5
|
propertiesToHash: ["src"],
|
|
5
|
-
async validateOptions(options
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
async validateOptions(options) {
|
|
7
|
+
if (isESMImportedImage(options.src) && options.src.format === "svg") {
|
|
8
|
+
options.format = "svg";
|
|
9
|
+
} else {
|
|
10
|
+
delete options.format;
|
|
11
|
+
}
|
|
12
|
+
verifyOptions(options);
|
|
13
|
+
return options;
|
|
9
14
|
},
|
|
10
15
|
async transform(inputBuffer, transformOptions) {
|
|
11
16
|
return {
|
|
@@ -80,6 +80,7 @@ export type BaseServiceTransform = {
|
|
|
80
80
|
fit?: ImageFit;
|
|
81
81
|
position?: string;
|
|
82
82
|
};
|
|
83
|
+
export declare function verifyOptions(options: ImageTransform): void;
|
|
83
84
|
/**
|
|
84
85
|
* Basic local service using the included `_image` endpoint.
|
|
85
86
|
* This service intentionally does not implement `transform`.
|
|
@@ -95,7 +96,6 @@ export type BaseServiceTransform = {
|
|
|
95
96
|
* ```
|
|
96
97
|
*
|
|
97
98
|
* This service adhere to the included services limitations:
|
|
98
|
-
* - Remote images are passed as is.
|
|
99
99
|
* - Only a limited amount of formats are supported.
|
|
100
100
|
* - For remote images, `width` and `height` are always required.
|
|
101
101
|
*
|
|
@@ -17,61 +17,64 @@ function parseQuality(quality) {
|
|
|
17
17
|
return result;
|
|
18
18
|
}
|
|
19
19
|
const sortNumeric = (a, b) => a - b;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
function verifyOptions(options) {
|
|
21
|
+
if (!options.src || !isRemoteImage(options.src) && !isESMImportedImage(options.src)) {
|
|
22
|
+
throw new AstroError({
|
|
23
|
+
...AstroErrorData.ExpectedImage,
|
|
24
|
+
message: AstroErrorData.ExpectedImage.message(
|
|
25
|
+
JSON.stringify(options.src),
|
|
26
|
+
typeof options.src,
|
|
27
|
+
JSON.stringify(options, (_, v) => v === void 0 ? null : v)
|
|
28
|
+
)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (!isESMImportedImage(options.src)) {
|
|
32
|
+
if (options.src.startsWith("/@fs/") || !isRemotePath(options.src) && !options.src.startsWith("/")) {
|
|
33
|
+
throw new AstroError({
|
|
34
|
+
...AstroErrorData.LocalImageUsedWrongly,
|
|
35
|
+
message: AstroErrorData.LocalImageUsedWrongly.message(options.src)
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
let missingDimension;
|
|
39
|
+
if (!options.width && !options.height) {
|
|
40
|
+
missingDimension = "both";
|
|
41
|
+
} else if (!options.width && options.height) {
|
|
42
|
+
missingDimension = "width";
|
|
43
|
+
} else if (options.width && !options.height) {
|
|
44
|
+
missingDimension = "height";
|
|
45
|
+
}
|
|
46
|
+
if (missingDimension) {
|
|
24
47
|
throw new AstroError({
|
|
25
|
-
...AstroErrorData.
|
|
26
|
-
message: AstroErrorData.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
48
|
+
...AstroErrorData.MissingImageDimension,
|
|
49
|
+
message: AstroErrorData.MissingImageDimension.message(missingDimension, options.src)
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
if (!VALID_SUPPORTED_FORMATS.includes(options.src.format)) {
|
|
54
|
+
throw new AstroError({
|
|
55
|
+
...AstroErrorData.UnsupportedImageFormat,
|
|
56
|
+
message: AstroErrorData.UnsupportedImageFormat.message(
|
|
57
|
+
options.src.format,
|
|
58
|
+
options.src.src,
|
|
59
|
+
VALID_SUPPORTED_FORMATS
|
|
30
60
|
)
|
|
31
61
|
});
|
|
32
62
|
}
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
missingDimension = "height";
|
|
47
|
-
}
|
|
48
|
-
if (missingDimension) {
|
|
49
|
-
throw new AstroError({
|
|
50
|
-
...AstroErrorData.MissingImageDimension,
|
|
51
|
-
message: AstroErrorData.MissingImageDimension.message(missingDimension, options.src)
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
if (!VALID_SUPPORTED_FORMATS.includes(options.src.format)) {
|
|
56
|
-
throw new AstroError({
|
|
57
|
-
...AstroErrorData.UnsupportedImageFormat,
|
|
58
|
-
message: AstroErrorData.UnsupportedImageFormat.message(
|
|
59
|
-
options.src.format,
|
|
60
|
-
options.src.src,
|
|
61
|
-
VALID_SUPPORTED_FORMATS
|
|
62
|
-
)
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
if (options.widths && options.densities) {
|
|
66
|
-
throw new AstroError(AstroErrorData.IncompatibleDescriptorOptions);
|
|
67
|
-
}
|
|
68
|
-
if (options.src.format === "svg") {
|
|
69
|
-
options.format = "svg";
|
|
70
|
-
}
|
|
71
|
-
if (options.src.format === "svg" && options.format !== "svg" || options.src.format !== "svg" && options.format === "svg") {
|
|
72
|
-
throw new AstroError(AstroErrorData.UnsupportedImageConversion);
|
|
73
|
-
}
|
|
63
|
+
if (options.widths && options.densities) {
|
|
64
|
+
throw new AstroError(AstroErrorData.IncompatibleDescriptorOptions);
|
|
65
|
+
}
|
|
66
|
+
if (options.src.format === "svg" && options.format !== "svg" || options.src.format !== "svg" && options.format === "svg") {
|
|
67
|
+
throw new AstroError(AstroErrorData.UnsupportedImageConversion);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const baseService = {
|
|
72
|
+
propertiesToHash: DEFAULT_HASH_PROPS,
|
|
73
|
+
validateOptions(options) {
|
|
74
|
+
if (isESMImportedImage(options.src) && options.src.format === "svg") {
|
|
75
|
+
options.format = "svg";
|
|
74
76
|
}
|
|
77
|
+
verifyOptions(options);
|
|
75
78
|
if (!options.format) {
|
|
76
79
|
options.format = DEFAULT_OUTPUT_FORMAT;
|
|
77
80
|
}
|
|
@@ -234,5 +237,6 @@ function getTargetDimensions(options) {
|
|
|
234
237
|
export {
|
|
235
238
|
baseService,
|
|
236
239
|
isLocalService,
|
|
237
|
-
parseQuality
|
|
240
|
+
parseQuality,
|
|
241
|
+
verifyOptions
|
|
238
242
|
};
|
package/dist/assets/types.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export type ImageTransform = {
|
|
|
72
72
|
fit?: ImageFit | undefined;
|
|
73
73
|
position?: string | undefined;
|
|
74
74
|
[key: string]: any;
|
|
75
|
-
};
|
|
75
|
+
} & Astro.CustomImageProps;
|
|
76
76
|
export interface GetImageResult {
|
|
77
77
|
rawOptions: ImageTransform;
|
|
78
78
|
options: ImageTransform;
|
|
@@ -201,7 +201,7 @@ type ImageSharedProps<T> = T & {
|
|
|
201
201
|
layout?: never;
|
|
202
202
|
fit?: never;
|
|
203
203
|
position?: never;
|
|
204
|
-
});
|
|
204
|
+
}) & Astro.CustomImageProps;
|
|
205
205
|
export type LocalImageProps<T> = ImageSharedProps<T> & {
|
|
206
206
|
/**
|
|
207
207
|
* A reference to a local image imported through an ESM import.
|
|
@@ -164,7 +164,7 @@ ${contentConfig.error.message}`);
|
|
|
164
164
|
logger.info("Content config changed");
|
|
165
165
|
shouldClear = true;
|
|
166
166
|
}
|
|
167
|
-
if (previousAstroVersion && previousAstroVersion !== "5.16.
|
|
167
|
+
if (previousAstroVersion && previousAstroVersion !== "5.16.6") {
|
|
168
168
|
logger.info("Astro version changed");
|
|
169
169
|
shouldClear = true;
|
|
170
170
|
}
|
|
@@ -172,8 +172,8 @@ ${contentConfig.error.message}`);
|
|
|
172
172
|
logger.info("Clearing content store");
|
|
173
173
|
this.#store.clearAll();
|
|
174
174
|
}
|
|
175
|
-
if ("5.16.
|
|
176
|
-
await this.#store.metaStore().set("astro-version", "5.16.
|
|
175
|
+
if ("5.16.6") {
|
|
176
|
+
await this.#store.metaStore().set("astro-version", "5.16.6");
|
|
177
177
|
}
|
|
178
178
|
if (currentConfigDigest) {
|
|
179
179
|
await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
|
|
|
22
22
|
await telemetry.record([]);
|
|
23
23
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
24
24
|
const logger = restart.container.logger;
|
|
25
|
-
const currentVersion = "5.16.
|
|
25
|
+
const currentVersion = "5.16.6";
|
|
26
26
|
const isPrerelease = currentVersion.includes("-");
|
|
27
27
|
if (!isPrerelease) {
|
|
28
28
|
try {
|
package/dist/core/messages.js
CHANGED
|
@@ -38,7 +38,7 @@ function serverStart({
|
|
|
38
38
|
host,
|
|
39
39
|
base
|
|
40
40
|
}) {
|
|
41
|
-
const version = "5.16.
|
|
41
|
+
const version = "5.16.6";
|
|
42
42
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
43
43
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
44
44
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -275,7 +275,7 @@ function printHelp({
|
|
|
275
275
|
message.push(
|
|
276
276
|
linebreak(),
|
|
277
277
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
278
|
-
`v${"5.16.
|
|
278
|
+
`v${"5.16.6"}`
|
|
279
279
|
)} ${headline}`
|
|
280
280
|
);
|
|
281
281
|
}
|