astro 4.0.5 → 4.0.7
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/components/Picture.astro +1 -1
- package/components/ViewTransitions.astro +1 -1
- package/dist/@types/astro.d.ts +1 -1
- package/dist/assets/build/generate.js +24 -9
- package/dist/assets/endpoint/config.d.ts +2 -0
- package/dist/assets/endpoint/config.js +12 -0
- package/dist/assets/endpoint/generic.js +3 -1
- package/dist/assets/endpoint/node.js +3 -1
- package/dist/assets/internal.d.ts +2 -6
- package/dist/assets/internal.js +2 -31
- package/dist/assets/services/service.js +2 -1
- package/dist/assets/utils/imageKind.d.ts +3 -0
- package/dist/assets/utils/imageKind.js +10 -0
- package/dist/assets/utils/index.d.ts +2 -0
- package/dist/assets/utils/index.js +17 -0
- package/dist/assets/utils/remotePattern.d.ts +2 -0
- package/dist/assets/utils/remotePattern.js +11 -0
- package/dist/assets/utils/transformToPath.js +1 -1
- package/dist/assets/vite-plugin-assets.js +1 -1
- package/dist/cli/add/index.js +1 -1
- package/dist/core/app/index.js +19 -7
- package/dist/core/build/generate.js +5 -4
- package/dist/core/build/index.js +1 -1
- package/dist/core/build/plugins/plugin-manifest.js +2 -1
- package/dist/core/build/static-build.js +5 -2
- package/dist/core/config/schema.d.ts +360 -360
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/container.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +34 -0
- package/dist/core/errors/errors-data.js +15 -2
- package/dist/core/logger/core.d.ts +8 -7
- package/dist/core/logger/core.js +15 -14
- package/dist/core/logger/node.js +4 -3
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/loadMiddleware.d.ts +1 -1
- package/dist/core/middleware/loadMiddleware.js +6 -4
- package/dist/core/redirects/helpers.js +7 -1
- package/dist/core/routing/manifest/create.js +1 -1
- package/dist/runtime/client/dev-overlay/plugins/audit/a11y.js +14 -8
- package/dist/transitions/router.js +11 -7
- package/dist/vite-plugin-astro-server/request.js +0 -4
- package/dist/vite-plugin-dev-overlay/vite-plugin-dev-overlay.js +1 -1
- package/package.json +4 -4
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -21,7 +21,7 @@ async function dev(inlineConfig) {
|
|
|
21
21
|
base: restart.container.settings.config.base
|
|
22
22
|
})
|
|
23
23
|
);
|
|
24
|
-
const currentVersion = "4.0.
|
|
24
|
+
const currentVersion = "4.0.7";
|
|
25
25
|
if (currentVersion.includes("-")) {
|
|
26
26
|
logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
|
|
27
27
|
}
|
|
@@ -622,6 +622,21 @@ export declare const MarkdownImageNotFound: {
|
|
|
622
622
|
message: (imagePath: string, fullImagePath: string | undefined) => string;
|
|
623
623
|
hint: string;
|
|
624
624
|
};
|
|
625
|
+
/**
|
|
626
|
+
* @docs
|
|
627
|
+
* @see
|
|
628
|
+
* - [Images](https://docs.astro.build/en/guides/images/)
|
|
629
|
+
* @description
|
|
630
|
+
* Astro could not transform one of your images. Often, this is caused by a corrupted or malformed image. Re-exporting the image from your image editor may fix this issue.
|
|
631
|
+
*
|
|
632
|
+
* Depending on the image service you are using, the stack trace may contain more information on the specific error encountered.
|
|
633
|
+
*/
|
|
634
|
+
export declare const CouldNotTransformImage: {
|
|
635
|
+
name: string;
|
|
636
|
+
title: string;
|
|
637
|
+
message: (imagePath: string) => string;
|
|
638
|
+
hint: string;
|
|
639
|
+
};
|
|
625
640
|
/**
|
|
626
641
|
* @docs
|
|
627
642
|
* @description
|
|
@@ -690,6 +705,25 @@ export declare const LocalsNotAnObject: {
|
|
|
690
705
|
message: string;
|
|
691
706
|
hint: string;
|
|
692
707
|
};
|
|
708
|
+
/**
|
|
709
|
+
* @docs
|
|
710
|
+
* @description
|
|
711
|
+
* Thrown in development mode when middleware throws an error while attempting to loading it.
|
|
712
|
+
*
|
|
713
|
+
* For example:
|
|
714
|
+
* ```ts
|
|
715
|
+
* import {defineMiddleware} from "astro:middleware";
|
|
716
|
+
* throw new Error("Error thrown while loading the middleware.")
|
|
717
|
+
* export const onRequest = defineMiddleware(() => {
|
|
718
|
+
* return "string"
|
|
719
|
+
* });
|
|
720
|
+
* ```
|
|
721
|
+
*/
|
|
722
|
+
export declare const MiddlewareCantBeLoaded: {
|
|
723
|
+
name: string;
|
|
724
|
+
title: string;
|
|
725
|
+
message: string;
|
|
726
|
+
};
|
|
693
727
|
/**
|
|
694
728
|
* @docs
|
|
695
729
|
* @see
|
|
@@ -223,6 +223,12 @@ const MarkdownImageNotFound = {
|
|
|
223
223
|
message: (imagePath, fullImagePath) => `Could not find requested image \`${imagePath}\`${fullImagePath ? ` at \`${fullImagePath}\`.` : "."}`,
|
|
224
224
|
hint: "This is often caused by a typo in the image path. Please make sure the file exists, and is spelled correctly."
|
|
225
225
|
};
|
|
226
|
+
const CouldNotTransformImage = {
|
|
227
|
+
name: "CouldNotTransformImage",
|
|
228
|
+
title: "Could not transform image.",
|
|
229
|
+
message: (imagePath) => `Could not transform image \`${imagePath}\`. See the stack trace for more information.`,
|
|
230
|
+
hint: "This is often caused by a corrupted or malformed image. Re-exporting the image from your image editor may fix this issue."
|
|
231
|
+
};
|
|
226
232
|
const ResponseSentError = {
|
|
227
233
|
name: "ResponseSentError",
|
|
228
234
|
title: "Unable to set response.",
|
|
@@ -230,8 +236,8 @@ const ResponseSentError = {
|
|
|
230
236
|
};
|
|
231
237
|
const MiddlewareNoDataOrNextCalled = {
|
|
232
238
|
name: "MiddlewareNoDataOrNextCalled",
|
|
233
|
-
title: "The middleware didn't return a
|
|
234
|
-
message: "
|
|
239
|
+
title: "The middleware didn't return a `Response`.",
|
|
240
|
+
message: "Make sure your middleware returns a `Response` object, either directly or by returning the `Response` from calling the `next` function."
|
|
235
241
|
};
|
|
236
242
|
const MiddlewareNotAResponse = {
|
|
237
243
|
name: "MiddlewareNotAResponse",
|
|
@@ -244,6 +250,11 @@ const LocalsNotAnObject = {
|
|
|
244
250
|
message: "`locals` can only be assigned to an object. Other values like numbers, strings, etc. are not accepted.",
|
|
245
251
|
hint: "If you tried to remove some information from the `locals` object, try to use `delete` or set the property to `undefined`."
|
|
246
252
|
};
|
|
253
|
+
const MiddlewareCantBeLoaded = {
|
|
254
|
+
name: "MiddlewareCantBeLoaded",
|
|
255
|
+
title: "Can't load the middleware.",
|
|
256
|
+
message: "The middleware threw an error while Astro was trying to loading it."
|
|
257
|
+
};
|
|
247
258
|
const LocalImageUsedWrongly = {
|
|
248
259
|
name: "LocalImageUsedWrongly",
|
|
249
260
|
title: "Local images must be imported.",
|
|
@@ -460,6 +471,7 @@ export {
|
|
|
460
471
|
ConfigNotFound,
|
|
461
472
|
ContentCollectionTypeMismatchError,
|
|
462
473
|
ContentSchemaContainsSlugError,
|
|
474
|
+
CouldNotTransformImage,
|
|
463
475
|
DataCollectionEntryParseError,
|
|
464
476
|
DuplicateContentEntrySlugError,
|
|
465
477
|
ExpectedImage,
|
|
@@ -490,6 +502,7 @@ export {
|
|
|
490
502
|
MarkdownFrontmatterParseError,
|
|
491
503
|
MarkdownImageNotFound,
|
|
492
504
|
MdxIntegrationMissingError,
|
|
505
|
+
MiddlewareCantBeLoaded,
|
|
493
506
|
MiddlewareNoDataOrNextCalled,
|
|
494
507
|
MiddlewareNotAResponse,
|
|
495
508
|
MissingImageDimension,
|
|
@@ -17,17 +17,18 @@ export interface LogMessage {
|
|
|
17
17
|
label: string | null;
|
|
18
18
|
level: LoggerLevel;
|
|
19
19
|
message: string;
|
|
20
|
+
newLine: boolean;
|
|
20
21
|
}
|
|
21
22
|
export declare const levels: Record<LoggerLevel, number>;
|
|
22
23
|
/** Full logging API */
|
|
23
|
-
export declare function log(opts: LogOptions, level: LoggerLevel, label: string | null, message: string): void;
|
|
24
|
+
export declare function log(opts: LogOptions, level: LoggerLevel, label: string | null, message: string, newLine?: boolean): void;
|
|
24
25
|
export declare function isLogLevelEnabled(configuredLogLevel: LoggerLevel, level: LoggerLevel): boolean;
|
|
25
26
|
/** Emit a user-facing message. Useful for UI and other console messages. */
|
|
26
|
-
export declare function info(opts: LogOptions, label: string | null, message: string): void;
|
|
27
|
+
export declare function info(opts: LogOptions, label: string | null, message: string, newLine?: boolean): void;
|
|
27
28
|
/** Emit a warning message. Useful for high-priority messages that aren't necessarily errors. */
|
|
28
|
-
export declare function warn(opts: LogOptions, label: string | null, message: string): void;
|
|
29
|
+
export declare function warn(opts: LogOptions, label: string | null, message: string, newLine?: boolean): void;
|
|
29
30
|
/** Emit a error message, Useful when Astro can't recover from some error. */
|
|
30
|
-
export declare function error(opts: LogOptions, label: string | null, message: string): void;
|
|
31
|
+
export declare function error(opts: LogOptions, label: string | null, message: string, newLine?: boolean): void;
|
|
31
32
|
type LogFn = typeof info | typeof warn | typeof error;
|
|
32
33
|
export declare function table(opts: LogOptions, columns: number[]): (logFn: LogFn, ...input: Array<any>) => void;
|
|
33
34
|
export declare function debug(...args: any[]): void;
|
|
@@ -43,9 +44,9 @@ export declare function timerMessage(message: string, startTime?: number): strin
|
|
|
43
44
|
export declare class Logger {
|
|
44
45
|
options: LogOptions;
|
|
45
46
|
constructor(options: LogOptions);
|
|
46
|
-
info(label: LoggerLabel | null, message: string): void;
|
|
47
|
-
warn(label: LoggerLabel | null, message: string): void;
|
|
48
|
-
error(label: LoggerLabel | null, message: string): void;
|
|
47
|
+
info(label: LoggerLabel | null, message: string, newLine?: boolean): void;
|
|
48
|
+
warn(label: LoggerLabel | null, message: string, newLine?: boolean): void;
|
|
49
|
+
error(label: LoggerLabel | null, message: string, newLine?: boolean): void;
|
|
49
50
|
debug(label: LoggerLabel, ...messages: any[]): void;
|
|
50
51
|
level(): LoggerLevel;
|
|
51
52
|
forkIntegrationLogger(label: string): AstroIntegrationLogger;
|
package/dist/core/logger/core.js
CHANGED
|
@@ -13,13 +13,14 @@ const levels = {
|
|
|
13
13
|
error: 50,
|
|
14
14
|
silent: 90
|
|
15
15
|
};
|
|
16
|
-
function log(opts, level, label, message) {
|
|
16
|
+
function log(opts, level, label, message, newLine = true) {
|
|
17
17
|
const logLevel = opts.level;
|
|
18
18
|
const dest = opts.dest;
|
|
19
19
|
const event = {
|
|
20
20
|
label,
|
|
21
21
|
level,
|
|
22
|
-
message
|
|
22
|
+
message,
|
|
23
|
+
newLine
|
|
23
24
|
};
|
|
24
25
|
if (!isLogLevelEnabled(logLevel, level)) {
|
|
25
26
|
return;
|
|
@@ -29,14 +30,14 @@ function log(opts, level, label, message) {
|
|
|
29
30
|
function isLogLevelEnabled(configuredLogLevel, level) {
|
|
30
31
|
return levels[configuredLogLevel] <= levels[level];
|
|
31
32
|
}
|
|
32
|
-
function info(opts, label, message) {
|
|
33
|
-
return log(opts, "info", label, message);
|
|
33
|
+
function info(opts, label, message, newLine = true) {
|
|
34
|
+
return log(opts, "info", label, message, newLine);
|
|
34
35
|
}
|
|
35
|
-
function warn(opts, label, message) {
|
|
36
|
-
return log(opts, "warn", label, message);
|
|
36
|
+
function warn(opts, label, message, newLine = true) {
|
|
37
|
+
return log(opts, "warn", label, message, newLine);
|
|
37
38
|
}
|
|
38
|
-
function error(opts, label, message) {
|
|
39
|
-
return log(opts, "error", label, message);
|
|
39
|
+
function error(opts, label, message, newLine = true) {
|
|
40
|
+
return log(opts, "error", label, message, newLine);
|
|
40
41
|
}
|
|
41
42
|
function table(opts, columns) {
|
|
42
43
|
return function logTable(logFn, ...input) {
|
|
@@ -107,14 +108,14 @@ class Logger {
|
|
|
107
108
|
constructor(options) {
|
|
108
109
|
this.options = options;
|
|
109
110
|
}
|
|
110
|
-
info(label, message) {
|
|
111
|
-
info(this.options, label, message);
|
|
111
|
+
info(label, message, newLine = true) {
|
|
112
|
+
info(this.options, label, message, newLine);
|
|
112
113
|
}
|
|
113
|
-
warn(label, message) {
|
|
114
|
-
warn(this.options, label, message);
|
|
114
|
+
warn(label, message, newLine = true) {
|
|
115
|
+
warn(this.options, label, message, newLine);
|
|
115
116
|
}
|
|
116
|
-
error(label, message) {
|
|
117
|
-
error(this.options, label, message);
|
|
117
|
+
error(label, message, newLine = true) {
|
|
118
|
+
error(this.options, label, message, newLine);
|
|
118
119
|
}
|
|
119
120
|
debug(label, ...messages) {
|
|
120
121
|
debug(label, ...messages);
|
package/dist/core/logger/node.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import debugPackage from "debug";
|
|
2
2
|
import { getEventPrefix, levels } from "./core.js";
|
|
3
3
|
const nodeLogDestination = {
|
|
4
|
-
write(event) {
|
|
4
|
+
write(event, newLine = true) {
|
|
5
5
|
let dest = process.stderr;
|
|
6
6
|
if (levels[event.level] < levels["error"]) {
|
|
7
7
|
dest = process.stdout;
|
|
8
8
|
}
|
|
9
|
+
let trailingLine = event.newLine ? "\n" : "";
|
|
9
10
|
if (event.label === "SKIP_FORMAT") {
|
|
10
|
-
dest.write(event.message +
|
|
11
|
+
dest.write(event.message + trailingLine);
|
|
11
12
|
} else {
|
|
12
|
-
dest.write(getEventPrefix(event) + " " + event.message +
|
|
13
|
+
dest.write(getEventPrefix(event) + " " + event.message + trailingLine);
|
|
13
14
|
}
|
|
14
15
|
return true;
|
|
15
16
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -36,7 +36,7 @@ function serverStart({
|
|
|
36
36
|
host,
|
|
37
37
|
base
|
|
38
38
|
}) {
|
|
39
|
-
const version = "4.0.
|
|
39
|
+
const version = "4.0.7";
|
|
40
40
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
41
41
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
42
42
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -258,7 +258,7 @@ function printHelp({
|
|
|
258
258
|
message.push(
|
|
259
259
|
linebreak(),
|
|
260
260
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
261
|
-
`v${"4.0.
|
|
261
|
+
`v${"4.0.7"}`
|
|
262
262
|
)} ${headline}`
|
|
263
263
|
);
|
|
264
264
|
}
|
|
@@ -4,4 +4,4 @@ import type { ModuleLoader } from '../module-loader/index.js';
|
|
|
4
4
|
*
|
|
5
5
|
* If not middlewares were not set, the function returns an empty array.
|
|
6
6
|
*/
|
|
7
|
-
export declare function loadMiddleware(moduleLoader: ModuleLoader): Promise<Record<string, any
|
|
7
|
+
export declare function loadMiddleware(moduleLoader: ModuleLoader): Promise<Record<string, any>>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { MIDDLEWARE_MODULE_ID } from "./vite-plugin.js";
|
|
2
|
+
import { MiddlewareCantBeLoaded } from "../errors/errors-data.js";
|
|
3
|
+
import { AstroError } from "../errors/index.js";
|
|
2
4
|
async function loadMiddleware(moduleLoader) {
|
|
3
5
|
try {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
return await moduleLoader.import(MIDDLEWARE_MODULE_ID);
|
|
7
|
+
} catch (error) {
|
|
8
|
+
const astroError = new AstroError(MiddlewareCantBeLoaded, void 0, { cause: error });
|
|
9
|
+
throw astroError;
|
|
8
10
|
}
|
|
9
11
|
}
|
|
10
12
|
export {
|
|
@@ -10,7 +10,13 @@ function redirectRouteGenerate(redirectRoute, data) {
|
|
|
10
10
|
if (typeof routeData !== "undefined") {
|
|
11
11
|
return routeData?.generate(data) || routeData?.pathname || "/";
|
|
12
12
|
} else if (typeof route === "string") {
|
|
13
|
-
|
|
13
|
+
let target = route;
|
|
14
|
+
for (const param of Object.keys(data)) {
|
|
15
|
+
const paramValue = data[param];
|
|
16
|
+
target = target.replace(`[${param}]`, paramValue);
|
|
17
|
+
target = target.replace(`[...${param}]`, paramValue);
|
|
18
|
+
}
|
|
19
|
+
return target;
|
|
14
20
|
} else if (typeof route === "undefined") {
|
|
15
21
|
return "/";
|
|
16
22
|
}
|
|
@@ -318,7 +318,7 @@ This route collides with: "${collision.component}".`
|
|
|
318
318
|
if (/^https?:\/\//.test(destination)) {
|
|
319
319
|
logger.warn(
|
|
320
320
|
"redirects",
|
|
321
|
-
`Redirecting to an external URL is not officially supported: ${from} -> ${
|
|
321
|
+
`Redirecting to an external URL is not officially supported: ${from} -> ${destination}`
|
|
322
322
|
);
|
|
323
323
|
}
|
|
324
324
|
}
|
|
@@ -33,6 +33,7 @@ const a11y_required_attributes = {
|
|
|
33
33
|
object: ["title", "aria-label", "aria-labelledby"]
|
|
34
34
|
};
|
|
35
35
|
const interactiveElements = ["button", "details", "embed", "iframe", "label", "select", "textarea"];
|
|
36
|
+
const labellableElements = ["input", "meter", "output", "progress", "select", "textarea"];
|
|
36
37
|
const aria_non_interactive_roles = [
|
|
37
38
|
"alert",
|
|
38
39
|
"alertdialog",
|
|
@@ -204,7 +205,7 @@ const a11y = [
|
|
|
204
205
|
{
|
|
205
206
|
code: "a11y-aria-activedescendant-has-tabindex",
|
|
206
207
|
title: "Elements with attribute `aria-activedescendant` must be tabbable",
|
|
207
|
-
message: "
|
|
208
|
+
message: "Element with the `aria-activedescendant` attribute must either have an inherent `tabindex` or declare `tabindex` as an attribute.",
|
|
208
209
|
selector: "[aria-activedescendant]",
|
|
209
210
|
match(element) {
|
|
210
211
|
if (!element.tabIndex && !element.hasAttribute("tabindex"))
|
|
@@ -268,13 +269,17 @@ const a11y = [
|
|
|
268
269
|
selector: 'a[href]:is([href=""], [href="#"], [href^="javascript:" i])'
|
|
269
270
|
},
|
|
270
271
|
{
|
|
271
|
-
code: "a11y-label
|
|
272
|
-
title: "`label`
|
|
273
|
-
message: "The `label`
|
|
274
|
-
selector: "label
|
|
272
|
+
code: "a11y-invalid-label",
|
|
273
|
+
title: "`label` element should have an associated control and a text content.",
|
|
274
|
+
message: "The `label` element must be associated with a control either by using the `for` attribute or by containing a nested form element. Additionally, the `label` element must have text content.",
|
|
275
|
+
selector: "label",
|
|
275
276
|
match(element) {
|
|
276
|
-
const
|
|
277
|
-
|
|
277
|
+
const hasFor = element.hasAttribute("for");
|
|
278
|
+
const nestedLabellableElement = element.querySelector(`${labellableElements.join(", ")}`);
|
|
279
|
+
if (!hasFor && !nestedLabellableElement)
|
|
280
|
+
return true;
|
|
281
|
+
const innerText = element.innerText.trim();
|
|
282
|
+
if (innerText === "")
|
|
278
283
|
return true;
|
|
279
284
|
}
|
|
280
285
|
},
|
|
@@ -327,7 +332,8 @@ const a11y = [
|
|
|
327
332
|
message: "Headings and anchors must have content to be accessible.",
|
|
328
333
|
selector: a11y_required_content.join(","),
|
|
329
334
|
match(element) {
|
|
330
|
-
|
|
335
|
+
const innerText = element.innerText.trim();
|
|
336
|
+
if (innerText === "")
|
|
331
337
|
return true;
|
|
332
338
|
}
|
|
333
339
|
},
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { TRANSITION_AFTER_SWAP, doPreparation, doSwap } from "./events.js";
|
|
2
|
+
const inBrowser = import.meta.env.SSR === false;
|
|
3
|
+
const pushState = inBrowser && history.pushState.bind(history);
|
|
4
|
+
const replaceState = inBrowser && history.replaceState.bind(history);
|
|
2
5
|
const updateScrollPosition = (positions) => {
|
|
3
6
|
if (history.state) {
|
|
4
7
|
history.scrollRestoration = "manual";
|
|
5
|
-
|
|
8
|
+
replaceState({ ...history.state, ...positions }, "");
|
|
6
9
|
}
|
|
7
10
|
};
|
|
8
|
-
const inBrowser = import.meta.env.SSR === false;
|
|
9
11
|
const supportsViewTransitions = inBrowser && !!document.startViewTransition;
|
|
10
12
|
const transitionEnabledOnThisPage = () => inBrowser && !!document.querySelector('[name="astro-view-transitions-enabled"]');
|
|
11
13
|
const samePage = (thisLocation, otherLocation) => thisLocation.pathname === otherLocation.pathname && thisLocation.search === otherLocation.search;
|
|
@@ -43,7 +45,7 @@ if (inBrowser) {
|
|
|
43
45
|
currentHistoryIndex = history.state.index;
|
|
44
46
|
scrollTo({ left: history.state.scrollX, top: history.state.scrollY });
|
|
45
47
|
} else if (transitionEnabledOnThisPage()) {
|
|
46
|
-
|
|
48
|
+
replaceState({ index: currentHistoryIndex, scrollX, scrollY }, "");
|
|
47
49
|
history.scrollRestoration = "manual";
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -69,7 +71,8 @@ const throttle = (cb, delay) => {
|
|
|
69
71
|
async function fetchHTML(href, init) {
|
|
70
72
|
try {
|
|
71
73
|
const res = await fetch(href, init);
|
|
72
|
-
const
|
|
74
|
+
const contentType = res.headers.get("content-type") ?? "";
|
|
75
|
+
const mediaType = contentType.split(";", 1)[0].trim();
|
|
73
76
|
if (mediaType !== "text/html" && mediaType !== "application/xhtml+xml") {
|
|
74
77
|
return null;
|
|
75
78
|
}
|
|
@@ -117,7 +120,7 @@ const moveToLocation = (to, from, options, historyState) => {
|
|
|
117
120
|
if (to.href !== location.href && !historyState) {
|
|
118
121
|
if (options.history === "replace") {
|
|
119
122
|
const current = history.state;
|
|
120
|
-
|
|
123
|
+
replaceState(
|
|
121
124
|
{
|
|
122
125
|
...options.state,
|
|
123
126
|
index: current.index,
|
|
@@ -128,7 +131,7 @@ const moveToLocation = (to, from, options, historyState) => {
|
|
|
128
131
|
to.href
|
|
129
132
|
);
|
|
130
133
|
} else {
|
|
131
|
-
|
|
134
|
+
pushState(
|
|
132
135
|
{ ...options.state, index: ++currentHistoryIndex, scrollX: 0, scrollY: 0 },
|
|
133
136
|
"",
|
|
134
137
|
to.href
|
|
@@ -315,7 +318,8 @@ async function transition(direction, from, to, options, historyState) {
|
|
|
315
318
|
const init = {};
|
|
316
319
|
if (preparationEvent.formData) {
|
|
317
320
|
init.method = "POST";
|
|
318
|
-
|
|
321
|
+
const form = preparationEvent.sourceElement instanceof HTMLFormElement ? preparationEvent.sourceElement : preparationEvent.sourceElement instanceof HTMLElement && "form" in preparationEvent.sourceElement ? preparationEvent.sourceElement.form : preparationEvent.sourceElement?.closest("form");
|
|
322
|
+
init.body = form?.attributes.getNamedItem("enctype")?.value === "application/x-www-form-urlencoded" ? new URLSearchParams(preparationEvent.formData) : preparationEvent.formData;
|
|
319
323
|
}
|
|
320
324
|
const response = await fetchHTML(href, init);
|
|
321
325
|
if (response === null) {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { collectErrorMetadata } from "../core/errors/dev/index.js";
|
|
2
|
-
import { createSafeError } from "../core/errors/index.js";
|
|
3
|
-
import { formatErrorMessage } from "../core/messages.js";
|
|
4
1
|
import { collapseDuplicateSlashes, removeTrailingForwardSlash } from "../core/path.js";
|
|
5
|
-
import { eventError, telemetry } from "../events/index.js";
|
|
6
2
|
import { isServerLikeOutput } from "../prerender/utils.js";
|
|
7
3
|
import { runWithErrorHandling } from "./controller.js";
|
|
8
4
|
import { handle500Response } from "./response.js";
|
|
@@ -12,7 +12,7 @@ function astroDevOverlay({ settings }) {
|
|
|
12
12
|
if (id === resolvedVirtualModuleId) {
|
|
13
13
|
return `
|
|
14
14
|
export const loadDevOverlayPlugins = async () => {
|
|
15
|
-
return [${settings.devToolbarApps.map((plugin) => `(await import(
|
|
15
|
+
return [${settings.devToolbarApps.map((plugin) => `(await import(${JSON.stringify(plugin)})).default`).join(",")}];
|
|
16
16
|
};
|
|
17
17
|
`;
|
|
18
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.7",
|
|
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",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"vendor"
|
|
100
100
|
],
|
|
101
101
|
"dependencies": {
|
|
102
|
-
"@astrojs/compiler": "^2.3.
|
|
102
|
+
"@astrojs/compiler": "^2.3.4",
|
|
103
103
|
"@babel/core": "^7.23.3",
|
|
104
104
|
"@babel/generator": "^7.23.3",
|
|
105
105
|
"@babel/parser": "^7.23.3",
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
"mime": "^3.0.0",
|
|
138
138
|
"ora": "^7.0.1",
|
|
139
139
|
"p-limit": "^5.0.0",
|
|
140
|
-
"p-queue": "^
|
|
140
|
+
"p-queue": "^8.0.1",
|
|
141
141
|
"path-to-regexp": "^6.2.1",
|
|
142
142
|
"preferred-pm": "^3.1.2",
|
|
143
143
|
"probe-image-size": "^7.2.3",
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
"tsconfck": "^3.0.0",
|
|
153
153
|
"unist-util-visit": "^5.0.0",
|
|
154
154
|
"vfile": "^6.0.1",
|
|
155
|
-
"vite": "^5.0.
|
|
155
|
+
"vite": "^5.0.10",
|
|
156
156
|
"vitefu": "^0.2.5",
|
|
157
157
|
"which-pm": "^2.1.1",
|
|
158
158
|
"yargs-parser": "^21.1.1",
|