astro 4.0.4 → 4.0.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.
- package/astro-jsx.d.ts +8 -2
- package/astro.js +1 -1
- package/dist/assets/internal.js +10 -0
- package/dist/core/build/static-build.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +2 -0
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +6 -0
- package/dist/core/errors/errors-data.js +10 -0
- package/dist/core/messages.js +2 -2
- package/dist/integrations/astroFeaturesValidation.js +7 -7
- package/dist/vite-plugin-astro-server/error.d.ts +7 -0
- package/dist/vite-plugin-astro-server/error.js +24 -0
- package/dist/vite-plugin-astro-server/plugin.js +33 -7
- package/dist/vite-plugin-astro-server/request.js +3 -12
- package/dist/vite-plugin-fileurl/index.d.ts +2 -0
- package/dist/vite-plugin-fileurl/index.js +14 -0
- package/package.json +1 -1
package/astro-jsx.d.ts
CHANGED
|
@@ -517,7 +517,8 @@ declare namespace astroHTML.JSX {
|
|
|
517
517
|
| 'search'
|
|
518
518
|
| 'send'
|
|
519
519
|
| undefined
|
|
520
|
-
|
|
520
|
+
| null;
|
|
521
|
+
exportparts?: string | undefined | null;
|
|
521
522
|
hidden?: boolean | string | undefined | null;
|
|
522
523
|
id?: string | undefined | null;
|
|
523
524
|
inert?: boolean | string | undefined | null;
|
|
@@ -533,18 +534,23 @@ declare namespace astroHTML.JSX {
|
|
|
533
534
|
| undefined
|
|
534
535
|
| null;
|
|
535
536
|
is?: string | undefined | null;
|
|
537
|
+
|
|
538
|
+
// Microdata API
|
|
536
539
|
itemid?: string | undefined | null;
|
|
537
540
|
itemprop?: string | undefined | null;
|
|
538
541
|
itemref?: string | undefined | null;
|
|
539
542
|
itemscope?: boolean | string | undefined | null;
|
|
540
543
|
itemtype?: string | undefined | null;
|
|
544
|
+
|
|
541
545
|
lang?: string | undefined | null;
|
|
546
|
+
part?: string | undefined | null;
|
|
547
|
+
popover?: boolean | string | undefined | null;
|
|
542
548
|
slot?: string | undefined | null;
|
|
543
549
|
spellcheck?: 'true' | 'false' | boolean | undefined | null;
|
|
544
550
|
style?: string | StyleObject | undefined | null;
|
|
545
551
|
tabindex?: number | string | undefined | null;
|
|
546
552
|
title?: string | undefined | null;
|
|
547
|
-
translate?: 'yes' | 'no' | undefined | null;
|
|
553
|
+
translate?: 'yes' | 'no' | '' | undefined | null;
|
|
548
554
|
|
|
549
555
|
// <command>, <menuitem>
|
|
550
556
|
radiogroup?: string | undefined | null;
|
package/astro.js
CHANGED
|
@@ -67,7 +67,7 @@ Please upgrade Node.js to a supported version: "${engines}"\n`);
|
|
|
67
67
|
console.log(
|
|
68
68
|
`${ci.name} CI Environment Detected!\nAdditional steps may be needed to set your Node.js version:`
|
|
69
69
|
);
|
|
70
|
-
console.log(`Documentation: https://docs.astro.build/guides/deploy
|
|
70
|
+
console.log(`Documentation: https://docs.astro.build/en/guides/deploy/`);
|
|
71
71
|
if (CI_INSTRUCTIONS[platform]) {
|
|
72
72
|
console.log(`${ci.name} Documentation: ${CI_INSTRUCTIONS[platform]}`);
|
|
73
73
|
}
|
package/dist/assets/internal.js
CHANGED
|
@@ -51,6 +51,16 @@ async function getImage(options, imageConfig) {
|
|
|
51
51
|
message: AstroErrorData.ExpectedImageOptions.message(JSON.stringify(options))
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
+
if (typeof options.src === "undefined") {
|
|
55
|
+
throw new AstroError({
|
|
56
|
+
...AstroErrorData.ExpectedImage,
|
|
57
|
+
message: AstroErrorData.ExpectedImage.message(
|
|
58
|
+
options.src,
|
|
59
|
+
"undefined",
|
|
60
|
+
JSON.stringify(options)
|
|
61
|
+
)
|
|
62
|
+
});
|
|
63
|
+
}
|
|
54
64
|
const service = await getConfiguredImageService();
|
|
55
65
|
const resolvedOptions = {
|
|
56
66
|
...options,
|
|
@@ -269,7 +269,7 @@ async function runPostBuildHooks(container, ssrOutputs, clientOutputs) {
|
|
|
269
269
|
const config = container.options.settings.config;
|
|
270
270
|
const build = container.options.settings.config.build;
|
|
271
271
|
for (const [fileName, mutation] of mutations) {
|
|
272
|
-
const root = isServerLikeOutput(config) ? mutation.targets.includes("server") ? build.server : build.client : config.outDir;
|
|
272
|
+
const root = isServerLikeOutput(config) ? mutation.targets.includes("server") ? build.server : build.client : getOutDirWithinCwd(config.outDir);
|
|
273
273
|
const fullPath = path.join(fileURLToPath(root), fileName);
|
|
274
274
|
const fileURL = pathToFileURL(fullPath);
|
|
275
275
|
await fs.promises.mkdir(new URL("./", fileURL), { recursive: true });
|
package/dist/core/constants.js
CHANGED
package/dist/core/create-vite.js
CHANGED
|
@@ -31,6 +31,7 @@ import { vitePluginSSRManifest } from "../vite-plugin-ssr-manifest/index.js";
|
|
|
31
31
|
import { createViteLogger } from "./logger/vite.js";
|
|
32
32
|
import { vitePluginMiddleware } from "./middleware/vite-plugin.js";
|
|
33
33
|
import { joinPaths } from "./path.js";
|
|
34
|
+
import vitePluginFileURL from "../vite-plugin-fileurl/index.js";
|
|
34
35
|
const ALWAYS_NOEXTERNAL = [
|
|
35
36
|
// This is only because Vite's native ESM doesn't resolve "exports" correctly.
|
|
36
37
|
"astro",
|
|
@@ -113,6 +114,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
|
|
113
114
|
astroPrefetch({ settings }),
|
|
114
115
|
astroTransitions({ settings }),
|
|
115
116
|
astroDevOverlay({ settings, logger }),
|
|
117
|
+
vitePluginFileURL({}),
|
|
116
118
|
!!settings.config.i18n && astroInternationalization({ settings })
|
|
117
119
|
],
|
|
118
120
|
publicDir: fileURLToPath(settings.config.publicDir),
|
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.5";
|
|
25
25
|
if (currentVersion.includes("-")) {
|
|
26
26
|
logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
|
|
27
27
|
}
|
|
@@ -440,6 +440,15 @@ const CantRenderPage = {
|
|
|
440
440
|
hint: "If you expect to find a route here, this may be an Astro bug. Please file an issue/restart the dev server"
|
|
441
441
|
};
|
|
442
442
|
const UnknownError = { name: "UnknownError", title: "Unknown Error." };
|
|
443
|
+
const UnhandledRejection = {
|
|
444
|
+
name: "UnhandledRejection",
|
|
445
|
+
title: "Unhandled rejection",
|
|
446
|
+
message: (stack) => {
|
|
447
|
+
return `Astro detected an unhandled rejection. Here's the stack trace:
|
|
448
|
+
${stack}`;
|
|
449
|
+
},
|
|
450
|
+
hint: "Make sure your promises all have an `await` or a `.catch()` handler."
|
|
451
|
+
};
|
|
443
452
|
export {
|
|
444
453
|
AstroGlobNoMatch,
|
|
445
454
|
AstroGlobUsedOutside,
|
|
@@ -503,6 +512,7 @@ export {
|
|
|
503
512
|
ResponseSentError,
|
|
504
513
|
StaticClientAddressNotAvailable,
|
|
505
514
|
StaticRedirectNotAvailable,
|
|
515
|
+
UnhandledRejection,
|
|
506
516
|
UnknownCLIError,
|
|
507
517
|
UnknownCSSError,
|
|
508
518
|
UnknownCompilerError,
|
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.5";
|
|
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.5"}`
|
|
262
262
|
)} ${headline}`
|
|
263
263
|
);
|
|
264
264
|
}
|
|
@@ -43,9 +43,9 @@ function validateSupportKind(supportKind, adapterName, logger, featureName, hasC
|
|
|
43
43
|
if (supportKind === STABLE) {
|
|
44
44
|
return true;
|
|
45
45
|
} else if (supportKind === DEPRECATED) {
|
|
46
|
-
featureIsDeprecated(adapterName, logger);
|
|
46
|
+
featureIsDeprecated(adapterName, logger, featureName);
|
|
47
47
|
} else if (supportKind === EXPERIMENTAL) {
|
|
48
|
-
featureIsExperimental(adapterName, logger);
|
|
48
|
+
featureIsExperimental(adapterName, logger, featureName);
|
|
49
49
|
}
|
|
50
50
|
if (hasCorrectConfig() && supportKind === UNSUPPORTED) {
|
|
51
51
|
featureIsUnsupported(adapterName, logger, featureName);
|
|
@@ -55,18 +55,18 @@ function validateSupportKind(supportKind, adapterName, logger, featureName, hasC
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
function featureIsUnsupported(adapterName, logger, featureName) {
|
|
58
|
-
logger.error("config", `The feature ${featureName} is not supported (used by ${adapterName}).`);
|
|
58
|
+
logger.error("config", `The feature "${featureName}" is not supported (used by ${adapterName}).`);
|
|
59
59
|
}
|
|
60
|
-
function featureIsExperimental(adapterName, logger) {
|
|
60
|
+
function featureIsExperimental(adapterName, logger, featureName) {
|
|
61
61
|
logger.warn(
|
|
62
62
|
"config",
|
|
63
|
-
`The feature is experimental and subject to change (used by ${adapterName}).`
|
|
63
|
+
`The feature "${featureName}" is experimental and subject to change (used by ${adapterName}).`
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
|
-
function featureIsDeprecated(adapterName, logger) {
|
|
66
|
+
function featureIsDeprecated(adapterName, logger, featureName) {
|
|
67
67
|
logger.warn(
|
|
68
68
|
"config",
|
|
69
|
-
`The feature is deprecated and will be removed in the future (used by ${adapterName}).`
|
|
69
|
+
`The feature "${featureName}" is deprecated and will be removed in the future (used by ${adapterName}).`
|
|
70
70
|
);
|
|
71
71
|
}
|
|
72
72
|
const SHARP_SERVICE = "astro/assets/services/sharp";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ModuleLoader } from '../core/module-loader/index.js';
|
|
2
|
+
import type { AstroConfig } from '../@types/astro.js';
|
|
3
|
+
import type DevPipeline from './devPipeline.js';
|
|
4
|
+
export declare function recordServerError(loader: ModuleLoader, config: AstroConfig, pipeline: DevPipeline, _err: unknown): {
|
|
5
|
+
error: Error;
|
|
6
|
+
errorWithMetadata: import("../core/errors/errors.js").ErrorWithMetadata;
|
|
7
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
import { eventError, telemetry } from "../events/index.js";
|
|
5
|
+
function recordServerError(loader, config, pipeline, _err) {
|
|
6
|
+
const err = createSafeError(_err);
|
|
7
|
+
try {
|
|
8
|
+
loader.fixStacktrace(err);
|
|
9
|
+
} catch {
|
|
10
|
+
}
|
|
11
|
+
const errorWithMetadata = collectErrorMetadata(err, config.root);
|
|
12
|
+
telemetry.record(eventError({ cmd: "dev", err: errorWithMetadata, isFatal: false }));
|
|
13
|
+
pipeline.logger.error(
|
|
14
|
+
null,
|
|
15
|
+
formatErrorMessage(errorWithMetadata, pipeline.logger.level() === "debug")
|
|
16
|
+
);
|
|
17
|
+
return {
|
|
18
|
+
error: err,
|
|
19
|
+
errorWithMetadata
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
recordServerError
|
|
24
|
+
};
|
|
@@ -5,6 +5,12 @@ import { baseMiddleware } from "./base.js";
|
|
|
5
5
|
import { createController } from "./controller.js";
|
|
6
6
|
import DevPipeline from "./devPipeline.js";
|
|
7
7
|
import { handleRequest } from "./request.js";
|
|
8
|
+
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
9
|
+
import { getViteErrorPayload } from "../core/errors/dev/index.js";
|
|
10
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
|
+
import { IncomingMessage } from "node:http";
|
|
12
|
+
import { setRouteError } from "./server-state.js";
|
|
13
|
+
import { recordServerError } from "./error.js";
|
|
8
14
|
function createVitePluginAstroServer({
|
|
9
15
|
settings,
|
|
10
16
|
logger,
|
|
@@ -18,6 +24,7 @@ function createVitePluginAstroServer({
|
|
|
18
24
|
const pipeline = new DevPipeline({ logger, manifest, settings, loader });
|
|
19
25
|
let manifestData = createRouteManifest({ settings, fsMod }, logger);
|
|
20
26
|
const controller = createController({ loader });
|
|
27
|
+
const localStorage = new AsyncLocalStorage();
|
|
21
28
|
function rebuildManifest(needsManifestRebuild) {
|
|
22
29
|
pipeline.clearRouteCache();
|
|
23
30
|
if (needsManifestRebuild) {
|
|
@@ -27,6 +34,23 @@ function createVitePluginAstroServer({
|
|
|
27
34
|
viteServer.watcher.on("add", rebuildManifest.bind(null, true));
|
|
28
35
|
viteServer.watcher.on("unlink", rebuildManifest.bind(null, true));
|
|
29
36
|
viteServer.watcher.on("change", rebuildManifest.bind(null, false));
|
|
37
|
+
function handleUnhandledRejection(rejection) {
|
|
38
|
+
const error = new AstroError({
|
|
39
|
+
...AstroErrorData.UnhandledRejection,
|
|
40
|
+
message: AstroErrorData.UnhandledRejection.message(rejection?.stack || rejection)
|
|
41
|
+
});
|
|
42
|
+
const store = localStorage.getStore();
|
|
43
|
+
if (store instanceof IncomingMessage) {
|
|
44
|
+
const request = store;
|
|
45
|
+
setRouteError(controller.state, request.url, error);
|
|
46
|
+
}
|
|
47
|
+
const { errorWithMetadata } = recordServerError(loader, settings.config, pipeline, error);
|
|
48
|
+
setTimeout(
|
|
49
|
+
async () => loader.webSocketSend(await getViteErrorPayload(errorWithMetadata)),
|
|
50
|
+
200
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
process.on("unhandledRejection", handleUnhandledRejection);
|
|
30
54
|
return () => {
|
|
31
55
|
viteServer.middlewares.stack.unshift({
|
|
32
56
|
route: "",
|
|
@@ -38,13 +62,15 @@ function createVitePluginAstroServer({
|
|
|
38
62
|
response.end();
|
|
39
63
|
return;
|
|
40
64
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
65
|
+
localStorage.run(request, () => {
|
|
66
|
+
handleRequest({
|
|
67
|
+
pipeline,
|
|
68
|
+
manifestData,
|
|
69
|
+
controller,
|
|
70
|
+
incomingRequest: request,
|
|
71
|
+
incomingResponse: response,
|
|
72
|
+
manifest
|
|
73
|
+
});
|
|
48
74
|
});
|
|
49
75
|
});
|
|
50
76
|
};
|
|
@@ -7,6 +7,7 @@ import { isServerLikeOutput } from "../prerender/utils.js";
|
|
|
7
7
|
import { runWithErrorHandling } from "./controller.js";
|
|
8
8
|
import { handle500Response } from "./response.js";
|
|
9
9
|
import { handleRoute, matchRoute } from "./route.js";
|
|
10
|
+
import { recordServerError } from "./error.js";
|
|
10
11
|
async function handleRequest({
|
|
11
12
|
pipeline,
|
|
12
13
|
manifestData,
|
|
@@ -64,19 +65,9 @@ async function handleRequest({
|
|
|
64
65
|
});
|
|
65
66
|
},
|
|
66
67
|
onError(_err) {
|
|
67
|
-
const
|
|
68
|
-
try {
|
|
69
|
-
moduleLoader.fixStacktrace(err);
|
|
70
|
-
} catch {
|
|
71
|
-
}
|
|
72
|
-
const errorWithMetadata = collectErrorMetadata(err, config.root);
|
|
73
|
-
telemetry.record(eventError({ cmd: "dev", err: errorWithMetadata, isFatal: false }));
|
|
74
|
-
pipeline.logger.error(
|
|
75
|
-
null,
|
|
76
|
-
formatErrorMessage(errorWithMetadata, pipeline.logger.level() === "debug")
|
|
77
|
-
);
|
|
68
|
+
const { error, errorWithMetadata } = recordServerError(moduleLoader, config, pipeline, _err);
|
|
78
69
|
handle500Response(moduleLoader, incomingResponse, errorWithMetadata);
|
|
79
|
-
return
|
|
70
|
+
return error;
|
|
80
71
|
}
|
|
81
72
|
});
|
|
82
73
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function vitePluginFileURL({}) {
|
|
2
|
+
return {
|
|
3
|
+
name: "astro:vite-plugin-file-url",
|
|
4
|
+
resolveId(source, importer) {
|
|
5
|
+
if (source.startsWith("file://")) {
|
|
6
|
+
const rest = source.slice(7);
|
|
7
|
+
return this.resolve(rest, importer);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
vitePluginFileURL as default
|
|
14
|
+
};
|