astro 5.5.3 → 5.5.4
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/content/content-layer.js +3 -3
- package/dist/core/app/index.js +13 -5
- package/dist/core/build/generate.js +6 -1
- package/dist/core/config/vite-load.js +3 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/cookies.d.ts +2 -2
- package/dist/core/cookies/cookies.js +3 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/routing/3xx.d.ts +3 -2
- package/dist/core/routing/3xx.js +10 -5
- package/dist/runtime/server/render/page.js +8 -1
- package/dist/runtime/server/render/server-islands.js +6 -6
- package/dist/vite-plugin-astro-server/response.js +5 -1
- package/dist/vite-plugin-astro-server/route.js +3 -1
- package/package.json +2 -3
|
@@ -153,7 +153,7 @@ ${contentConfig.error.message}`);
|
|
|
153
153
|
logger.info("Content config changed");
|
|
154
154
|
shouldClear = true;
|
|
155
155
|
}
|
|
156
|
-
if (previousAstroVersion && previousAstroVersion !== "5.5.
|
|
156
|
+
if (previousAstroVersion && previousAstroVersion !== "5.5.4") {
|
|
157
157
|
logger.info("Astro version changed");
|
|
158
158
|
shouldClear = true;
|
|
159
159
|
}
|
|
@@ -161,8 +161,8 @@ ${contentConfig.error.message}`);
|
|
|
161
161
|
logger.info("Clearing content store");
|
|
162
162
|
this.#store.clearAll();
|
|
163
163
|
}
|
|
164
|
-
if ("5.5.
|
|
165
|
-
await this.#store.metaStore().set("astro-version", "5.5.
|
|
164
|
+
if ("5.5.4") {
|
|
165
|
+
await this.#store.metaStore().set("astro-version", "5.5.4");
|
|
166
166
|
}
|
|
167
167
|
if (currentConfigDigest) {
|
|
168
168
|
await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
package/dist/core/app/index.js
CHANGED
|
@@ -195,12 +195,20 @@ class App {
|
|
|
195
195
|
const redirect = this.#redirectTrailingSlash(url.pathname);
|
|
196
196
|
if (redirect !== url.pathname) {
|
|
197
197
|
const status = request.method === "GET" ? 301 : 308;
|
|
198
|
-
return new Response(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
198
|
+
return new Response(
|
|
199
|
+
redirectTemplate({
|
|
200
|
+
status,
|
|
201
|
+
relativeLocation: url.pathname,
|
|
202
|
+
absoluteLocation: redirect,
|
|
203
|
+
from: request.url
|
|
204
|
+
}),
|
|
205
|
+
{
|
|
206
|
+
status,
|
|
207
|
+
headers: {
|
|
208
|
+
location: redirect + url.search
|
|
209
|
+
}
|
|
202
210
|
}
|
|
203
|
-
|
|
211
|
+
);
|
|
204
212
|
}
|
|
205
213
|
addCookieHeader = renderOptions?.addCookieHeader;
|
|
206
214
|
clientAddress = renderOptions?.clientAddress ?? Reflect.get(request, clientAddressSymbol);
|
|
@@ -327,7 +327,12 @@ async function generatePath(pathname, pipeline, gopts, route) {
|
|
|
327
327
|
const siteURL = config.site;
|
|
328
328
|
const location = siteURL ? new URL(locationSite, siteURL) : locationSite;
|
|
329
329
|
const fromPath = new URL(request.url).pathname;
|
|
330
|
-
body = redirectTemplate({
|
|
330
|
+
body = redirectTemplate({
|
|
331
|
+
status: response.status,
|
|
332
|
+
absoluteLocation: location,
|
|
333
|
+
relativeLocation: locationSite,
|
|
334
|
+
from: fromPath
|
|
335
|
+
});
|
|
331
336
|
if (config.compressHTML === true) {
|
|
332
337
|
body = body.replaceAll("\n", "");
|
|
333
338
|
}
|
|
@@ -24,6 +24,9 @@ async function loadConfigWithVite({
|
|
|
24
24
|
const config = await import(pathToFileURL(configPath).toString() + "?t=" + Date.now());
|
|
25
25
|
return config.default ?? {};
|
|
26
26
|
} catch (e) {
|
|
27
|
+
if (e && typeof e === "object" && "code" in e && e.code === "ERR_DLOPEN_DISABLED") {
|
|
28
|
+
throw e;
|
|
29
|
+
}
|
|
27
30
|
debug("Failed to load config with Node", e);
|
|
28
31
|
}
|
|
29
32
|
}
|
package/dist/core/constants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type AstroCookieSetOptions = Pick<
|
|
1
|
+
import type { SerializeOptions } from 'cookie';
|
|
2
|
+
export type AstroCookieSetOptions = Pick<SerializeOptions, 'domain' | 'path' | 'expires' | 'maxAge' | 'httpOnly' | 'sameSite' | 'secure' | 'encode'>;
|
|
3
3
|
export interface AstroCookieGetOptions {
|
|
4
4
|
decode?: (value: string) => string;
|
|
5
5
|
}
|
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.5.
|
|
25
|
+
const currentVersion = "5.5.4";
|
|
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.5.
|
|
41
|
+
const version = "5.5.4";
|
|
42
42
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
43
43
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
44
44
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -282,7 +282,7 @@ function printHelp({
|
|
|
282
282
|
message.push(
|
|
283
283
|
linebreak(),
|
|
284
284
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
285
|
-
`v${"5.5.
|
|
285
|
+
`v${"5.5.4"}`
|
|
286
286
|
)} ${headline}`
|
|
287
287
|
);
|
|
288
288
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type RedirectTemplate = {
|
|
2
2
|
from?: string;
|
|
3
|
-
|
|
3
|
+
absoluteLocation: string | URL;
|
|
4
4
|
status: number;
|
|
5
|
+
relativeLocation: string;
|
|
5
6
|
};
|
|
6
|
-
export declare function redirectTemplate({ status,
|
|
7
|
+
export declare function redirectTemplate({ status, absoluteLocation, relativeLocation, from, }: RedirectTemplate): string;
|
package/dist/core/routing/3xx.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
function redirectTemplate({
|
|
1
|
+
function redirectTemplate({
|
|
2
|
+
status,
|
|
3
|
+
absoluteLocation,
|
|
4
|
+
relativeLocation,
|
|
5
|
+
from
|
|
6
|
+
}) {
|
|
2
7
|
const delay = status === 302 ? 2 : 0;
|
|
3
8
|
return `<!doctype html>
|
|
4
|
-
<title>Redirecting to: ${
|
|
5
|
-
<meta http-equiv="refresh" content="${delay};url=${
|
|
9
|
+
<title>Redirecting to: ${relativeLocation}</title>
|
|
10
|
+
<meta http-equiv="refresh" content="${delay};url=${relativeLocation}">
|
|
6
11
|
<meta name="robots" content="noindex">
|
|
7
|
-
<link rel="canonical" href="${
|
|
12
|
+
<link rel="canonical" href="${absoluteLocation}">
|
|
8
13
|
<body>
|
|
9
|
-
<a href="${
|
|
14
|
+
<a href="${relativeLocation}">Redirecting ${from ? `from <code>${from}</code> ` : ""}to <code>${relativeLocation}</code></a>
|
|
10
15
|
</body>`;
|
|
11
16
|
}
|
|
12
17
|
export {
|
|
@@ -51,13 +51,20 @@ async function renderPage(result, componentFactory, props, children, streaming,
|
|
|
51
51
|
headers.set("Content-Length", body.byteLength.toString());
|
|
52
52
|
}
|
|
53
53
|
let status = init.status;
|
|
54
|
+
let statusText = init.statusText;
|
|
54
55
|
if (route?.route === "/404") {
|
|
55
56
|
status = 404;
|
|
57
|
+
if (statusText === "OK") {
|
|
58
|
+
statusText = "Not Found";
|
|
59
|
+
}
|
|
56
60
|
} else if (route?.route === "/500") {
|
|
57
61
|
status = 500;
|
|
62
|
+
if (statusText === "OK") {
|
|
63
|
+
statusText = "Internal Server Error";
|
|
64
|
+
}
|
|
58
65
|
}
|
|
59
66
|
if (status) {
|
|
60
|
-
return new Response(body, { ...init, headers, status });
|
|
67
|
+
return new Response(body, { ...init, headers, status, statusText });
|
|
61
68
|
} else {
|
|
62
69
|
return new Response(body, { ...init, headers });
|
|
63
70
|
}
|
|
@@ -70,7 +70,7 @@ function renderServerIsland(result, _displayName, props, slots) {
|
|
|
70
70
|
`<link rel="preload" as="fetch" href="${serverIslandUrl}" crossorigin="anonymous">`
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
|
-
destination.write(`<script async type="module" data-island-id="${hostId}">
|
|
73
|
+
destination.write(`<script async type="module" data-astro-rerun data-island-id="${hostId}">
|
|
74
74
|
let script = document.querySelector('script[data-island-id="${hostId}"]');
|
|
75
75
|
|
|
76
76
|
${useGETRequest ? (
|
|
@@ -93,11 +93,11 @@ let response = await fetch('${serverIslandUrl}', {
|
|
|
93
93
|
)}
|
|
94
94
|
if (script) {
|
|
95
95
|
if(
|
|
96
|
-
response.status === 200
|
|
97
|
-
&& response.headers.has('content-type')
|
|
96
|
+
response.status === 200
|
|
97
|
+
&& response.headers.has('content-type')
|
|
98
98
|
&& response.headers.get('content-type').split(";")[0].trim() === 'text/html') {
|
|
99
99
|
let html = await response.text();
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
// Swap!
|
|
102
102
|
while(script.previousSibling &&
|
|
103
103
|
script.previousSibling.nodeType !== 8 &&
|
|
@@ -105,11 +105,11 @@ if (script) {
|
|
|
105
105
|
script.previousSibling.remove();
|
|
106
106
|
}
|
|
107
107
|
script.previousSibling?.remove();
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
let frag = document.createRange().createContextualFragment(html);
|
|
110
110
|
script.before(frag);
|
|
111
111
|
}
|
|
112
|
-
script.remove();
|
|
112
|
+
script.remove(); // Prior to v5.4.2, this was the trick to force rerun of scripts. Keeping it to minimize change to the existing behavior.
|
|
113
113
|
}
|
|
114
114
|
</script>`);
|
|
115
115
|
}
|
|
@@ -39,7 +39,11 @@ function writeHtmlResponse(res, statusCode, html) {
|
|
|
39
39
|
res.end();
|
|
40
40
|
}
|
|
41
41
|
function writeRedirectResponse(res, statusCode, location) {
|
|
42
|
-
const html = redirectTemplate({
|
|
42
|
+
const html = redirectTemplate({
|
|
43
|
+
status: statusCode,
|
|
44
|
+
absoluteLocation: location,
|
|
45
|
+
relativeLocation: location
|
|
46
|
+
});
|
|
43
47
|
res.writeHead(statusCode, {
|
|
44
48
|
Location: location,
|
|
45
49
|
"Content-Type": "text/html",
|
|
@@ -211,10 +211,12 @@ async function handleRoute({
|
|
|
211
211
|
}
|
|
212
212
|
if (response.status < 400 && response.status >= 300) {
|
|
213
213
|
if (response.status >= 300 && response.status < 400 && routeIsRedirect(route) && !config.build.redirects && pipeline.settings.buildOutput === "static") {
|
|
214
|
+
const location = response.headers.get("location");
|
|
214
215
|
response = new Response(
|
|
215
216
|
redirectTemplate({
|
|
216
217
|
status: response.status,
|
|
217
|
-
|
|
218
|
+
absoluteLocation: location,
|
|
219
|
+
relativeLocation: location,
|
|
218
220
|
from: pathname
|
|
219
221
|
}),
|
|
220
222
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.4",
|
|
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",
|
|
@@ -106,7 +106,6 @@
|
|
|
106
106
|
"@astrojs/compiler": "^2.11.0",
|
|
107
107
|
"@oslojs/encoding": "^1.1.0",
|
|
108
108
|
"@rollup/pluginutils": "^5.1.4",
|
|
109
|
-
"@types/cookie": "^0.6.0",
|
|
110
109
|
"acorn": "^8.14.1",
|
|
111
110
|
"aria-query": "^5.3.2",
|
|
112
111
|
"axobject-query": "^4.1.0",
|
|
@@ -114,7 +113,7 @@
|
|
|
114
113
|
"ci-info": "^4.2.0",
|
|
115
114
|
"clsx": "^2.1.1",
|
|
116
115
|
"common-ancestor-path": "^1.0.1",
|
|
117
|
-
"cookie": "^0.
|
|
116
|
+
"cookie": "^1.0.2",
|
|
118
117
|
"cssesc": "^3.0.0",
|
|
119
118
|
"debug": "^4.4.0",
|
|
120
119
|
"deterministic-object-hash": "^2.0.2",
|