astro 3.6.4 → 3.6.5
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.
|
@@ -1,21 +1,42 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import { isAbsolute } from "node:path";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
1
4
|
import { isRemotePath, removeQueryString } from "@astrojs/internal-helpers/path";
|
|
2
5
|
import { readFile } from "fs/promises";
|
|
3
6
|
import mime from "mime/lite.js";
|
|
4
|
-
import os from "os";
|
|
5
7
|
import { getConfiguredImageService, isRemoteAllowed } from "../internal.js";
|
|
6
8
|
import { etag } from "../utils/etag.js";
|
|
7
|
-
import { assetsDir, imageConfig } from "astro:assets";
|
|
9
|
+
import { assetsDir, outDir, imageConfig } from "astro:assets";
|
|
8
10
|
function replaceFileSystemReferences(src) {
|
|
9
11
|
return os.platform().includes("win32") ? src.replace(/^\/@fs\//, "") : src.replace(/^\/@fs/, "");
|
|
10
12
|
}
|
|
11
13
|
async function loadLocalImage(src, url) {
|
|
12
|
-
const
|
|
14
|
+
const assetsDirPath = fileURLToPath(assetsDir);
|
|
15
|
+
let fileUrl;
|
|
16
|
+
if (import.meta.env.DEV) {
|
|
17
|
+
fileUrl = pathToFileURL(removeQueryString(replaceFileSystemReferences(src)));
|
|
18
|
+
} else {
|
|
19
|
+
try {
|
|
20
|
+
fileUrl = new URL("." + src, outDir);
|
|
21
|
+
const filePath = fileURLToPath(fileUrl);
|
|
22
|
+
if (!isAbsolute(filePath) || !filePath.startsWith(assetsDirPath)) {
|
|
23
|
+
return void 0;
|
|
24
|
+
}
|
|
25
|
+
} catch (err) {
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
13
29
|
let buffer = void 0;
|
|
14
30
|
try {
|
|
15
|
-
buffer = await readFile(
|
|
31
|
+
buffer = await readFile(fileUrl);
|
|
16
32
|
} catch (e) {
|
|
17
|
-
|
|
18
|
-
|
|
33
|
+
try {
|
|
34
|
+
const sourceUrl = new URL(src, url.origin);
|
|
35
|
+
buffer = await loadRemoteImage(sourceUrl);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
console.error("Could not process image request:", err);
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
19
40
|
}
|
|
20
41
|
return buffer;
|
|
21
42
|
}
|
|
@@ -39,7 +60,11 @@ const GET = async ({ request }) => {
|
|
|
39
60
|
const url = new URL(request.url);
|
|
40
61
|
const transform = await imageService.parseURL(url, imageConfig);
|
|
41
62
|
if (!transform?.src) {
|
|
42
|
-
|
|
63
|
+
const err = new Error(
|
|
64
|
+
"Incorrect transform returned by `parseURL`. Expected a transform with a `src` property."
|
|
65
|
+
);
|
|
66
|
+
console.error("Could not parse image transform from URL:", err);
|
|
67
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
43
68
|
}
|
|
44
69
|
let inputBuffer = void 0;
|
|
45
70
|
if (isRemotePath(transform.src)) {
|
|
@@ -51,7 +76,7 @@ const GET = async ({ request }) => {
|
|
|
51
76
|
inputBuffer = await loadLocalImage(transform.src, url);
|
|
52
77
|
}
|
|
53
78
|
if (!inputBuffer) {
|
|
54
|
-
return new Response("
|
|
79
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
55
80
|
}
|
|
56
81
|
const { data, format } = await imageService.transform(inputBuffer, transform, imageConfig);
|
|
57
82
|
return new Response(data, {
|
|
@@ -64,7 +89,13 @@ const GET = async ({ request }) => {
|
|
|
64
89
|
}
|
|
65
90
|
});
|
|
66
91
|
} catch (err) {
|
|
67
|
-
|
|
92
|
+
console.error("Could not process image request:", err);
|
|
93
|
+
return new Response(
|
|
94
|
+
import.meta.env.DEV ? `Could not process image request: ${err}` : `Internal Server Error`,
|
|
95
|
+
{
|
|
96
|
+
status: 500
|
|
97
|
+
}
|
|
98
|
+
);
|
|
68
99
|
}
|
|
69
100
|
};
|
|
70
101
|
export {
|
|
@@ -54,11 +54,12 @@ function assets({
|
|
|
54
54
|
export { default as Picture } from "astro/components/Picture.astro";
|
|
55
55
|
|
|
56
56
|
export const imageConfig = ${JSON.stringify(settings.config.image)};
|
|
57
|
-
export const
|
|
57
|
+
export const outDir = new URL(${JSON.stringify(
|
|
58
58
|
new URL(
|
|
59
59
|
isServerLikeOutput(settings.config) ? settings.config.build.client : settings.config.outDir
|
|
60
60
|
)
|
|
61
61
|
)});
|
|
62
|
+
export const assetsDir = new URL(${JSON.stringify(settings.config.build.assets)}, outDir);
|
|
62
63
|
export const getImage = async (options) => await getImageInternal(options, imageConfig);
|
|
63
64
|
`;
|
|
64
65
|
}
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -20,7 +20,7 @@ async function dev(inlineConfig) {
|
|
|
20
20
|
base: restart.container.settings.config.base
|
|
21
21
|
})
|
|
22
22
|
);
|
|
23
|
-
const currentVersion = "3.6.
|
|
23
|
+
const currentVersion = "3.6.5";
|
|
24
24
|
if (currentVersion.includes("-")) {
|
|
25
25
|
logger.warn(null, msg.prerelease({ currentVersion }));
|
|
26
26
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -50,7 +50,7 @@ function serverStart({
|
|
|
50
50
|
base,
|
|
51
51
|
isRestart = false
|
|
52
52
|
}) {
|
|
53
|
-
const version = "3.6.
|
|
53
|
+
const version = "3.6.5";
|
|
54
54
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
55
55
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
56
56
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -235,7 +235,7 @@ function printHelp({
|
|
|
235
235
|
message.push(
|
|
236
236
|
linebreak(),
|
|
237
237
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
238
|
-
`v${"3.6.
|
|
238
|
+
`v${"3.6.5"}`
|
|
239
239
|
)} ${headline}`
|
|
240
240
|
);
|
|
241
241
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.5",
|
|
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",
|
|
@@ -166,9 +166,9 @@
|
|
|
166
166
|
"which-pm": "^2.1.1",
|
|
167
167
|
"yargs-parser": "^21.1.1",
|
|
168
168
|
"zod": "^3.22.4",
|
|
169
|
-
"@astrojs/markdown-remark": "3.5.0",
|
|
170
169
|
"@astrojs/internal-helpers": "0.2.1",
|
|
171
|
-
"@astrojs/telemetry": "3.0.4"
|
|
170
|
+
"@astrojs/telemetry": "3.0.4",
|
|
171
|
+
"@astrojs/markdown-remark": "3.5.0"
|
|
172
172
|
},
|
|
173
173
|
"optionalDependencies": {
|
|
174
174
|
"sharp": "^0.32.5"
|