astro 6.0.1 → 6.0.3
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/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/core/build/generate.js +10 -0
- package/dist/core/constants.d.ts +4 -0
- package/dist/core/constants.js +3 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/server-islands/endpoint.js +2 -2
- package/dist/vite-plugin-astro/compile.js +1 -1
- package/dist/vite-plugin-astro-server/plugin.js +82 -24
- package/dist/vite-plugin-css/index.js +14 -9
- package/dist/vite-plugin-routes/index.js +16 -5
- package/package.json +3 -3
|
@@ -189,7 +189,7 @@ ${contentConfig.error.message}`
|
|
|
189
189
|
logger.info("Content config changed");
|
|
190
190
|
shouldClear = true;
|
|
191
191
|
}
|
|
192
|
-
if (previousAstroVersion && previousAstroVersion !== "6.0.
|
|
192
|
+
if (previousAstroVersion && previousAstroVersion !== "6.0.3") {
|
|
193
193
|
logger.info("Astro version changed");
|
|
194
194
|
shouldClear = true;
|
|
195
195
|
}
|
|
@@ -197,8 +197,8 @@ ${contentConfig.error.message}`
|
|
|
197
197
|
logger.info("Clearing content store");
|
|
198
198
|
this.#store.clearAll();
|
|
199
199
|
}
|
|
200
|
-
if ("6.0.
|
|
201
|
-
this.#store.metaStore().set("astro-version", "6.0.
|
|
200
|
+
if ("6.0.3") {
|
|
201
|
+
this.#store.metaStore().set("astro-version", "6.0.3");
|
|
202
202
|
}
|
|
203
203
|
if (currentConfigDigest) {
|
|
204
204
|
this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -139,6 +139,16 @@ ${colors.bgGreen(colors.black(` ${verb} static routes `))}`);
|
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
+
for (const { route: generatedRoute } of filteredPaths) {
|
|
143
|
+
if (generatedRoute.distURL && generatedRoute.distURL.length > 0) {
|
|
144
|
+
for (const pageData of Object.values(options.allPages)) {
|
|
145
|
+
if (pageData.route.route === generatedRoute.route && pageData.route.component === generatedRoute.component) {
|
|
146
|
+
pageData.route.distURL = generatedRoute.distURL;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
142
152
|
const staticImageList = getStaticImageList();
|
|
143
153
|
if (prerenderer.collectStaticImages) {
|
|
144
154
|
const adapterImages = await prerenderer.collectStaticImages();
|
package/dist/core/constants.d.ts
CHANGED
|
@@ -66,6 +66,10 @@ export declare const originPathnameSymbol: unique symbol;
|
|
|
66
66
|
* Use this symbol to set and retrieve the pipeline.
|
|
67
67
|
*/
|
|
68
68
|
export declare const pipelineSymbol: unique symbol;
|
|
69
|
+
/**
|
|
70
|
+
* Use this symbol to opt into handling prerender routes in Astro core dev middleware.
|
|
71
|
+
*/
|
|
72
|
+
export declare const devPrerenderMiddlewareSymbol: unique symbol;
|
|
69
73
|
/**
|
|
70
74
|
* The symbol used as a field on the request object to store a cleanup callback associated with aborting the request when the underlying socket closes.
|
|
71
75
|
*/
|
package/dist/core/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const ASTRO_VERSION = "6.0.
|
|
1
|
+
const ASTRO_VERSION = "6.0.3";
|
|
2
2
|
const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`;
|
|
3
3
|
const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
|
|
4
4
|
const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
|
|
@@ -12,6 +12,7 @@ const clientAddressSymbol = /* @__PURE__ */ Symbol.for("astro.clientAddress");
|
|
|
12
12
|
const clientLocalsSymbol = /* @__PURE__ */ Symbol.for("astro.locals");
|
|
13
13
|
const originPathnameSymbol = /* @__PURE__ */ Symbol.for("astro.originPathname");
|
|
14
14
|
const pipelineSymbol = /* @__PURE__ */ Symbol.for("astro.pipeline");
|
|
15
|
+
const devPrerenderMiddlewareSymbol = /* @__PURE__ */ Symbol.for("astro.devPrerenderMiddleware");
|
|
15
16
|
const nodeRequestAbortControllerCleanupSymbol = /* @__PURE__ */ Symbol.for(
|
|
16
17
|
"astro.nodeRequestAbortControllerCleanup"
|
|
17
18
|
);
|
|
@@ -57,6 +58,7 @@ export {
|
|
|
57
58
|
SUPPORTED_MARKDOWN_FILE_EXTENSIONS,
|
|
58
59
|
clientAddressSymbol,
|
|
59
60
|
clientLocalsSymbol,
|
|
61
|
+
devPrerenderMiddlewareSymbol,
|
|
60
62
|
nodeRequestAbortControllerCleanupSymbol,
|
|
61
63
|
originPathnameSymbol,
|
|
62
64
|
pipelineSymbol,
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -26,7 +26,7 @@ async function dev(inlineConfig) {
|
|
|
26
26
|
await telemetry.record([]);
|
|
27
27
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
28
28
|
const logger = restart.container.logger;
|
|
29
|
-
const currentVersion = "6.0.
|
|
29
|
+
const currentVersion = "6.0.3";
|
|
30
30
|
const isPrerelease = currentVersion.includes("-");
|
|
31
31
|
if (!isPrerelease) {
|
|
32
32
|
try {
|
|
@@ -59,10 +59,10 @@ async function getRequestData(request, bodySizeLimit = DEFAULT_BODY_SIZE_LIMIT)
|
|
|
59
59
|
const body = await readBodyWithLimit(request, bodySizeLimit);
|
|
60
60
|
const raw = new TextDecoder().decode(body);
|
|
61
61
|
const data = JSON.parse(raw);
|
|
62
|
-
if ("slots"
|
|
62
|
+
if (Object.hasOwn(data, "slots") && typeof data.slots === "object") {
|
|
63
63
|
return badRequest("Plaintext slots are not allowed. Slots must be encrypted.");
|
|
64
64
|
}
|
|
65
|
-
if ("componentExport"
|
|
65
|
+
if (Object.hasOwn(data, "componentExport") && typeof data.componentExport === "string") {
|
|
66
66
|
return badRequest(
|
|
67
67
|
"Plaintext componentExport is not allowed. componentExport must be encrypted."
|
|
68
68
|
);
|
|
@@ -70,7 +70,7 @@ async function enhanceCompileError({
|
|
|
70
70
|
const lineText = err.loc?.lineText;
|
|
71
71
|
const scannedFrontmatter = frontmatterRE.exec(source);
|
|
72
72
|
if (scannedFrontmatter) {
|
|
73
|
-
const frontmatter = scannedFrontmatter[1].replace(/\breturn\b/g, "throw");
|
|
73
|
+
const frontmatter = scannedFrontmatter[1].replace(/\breturn\s*;/g, "throw 0;").replace(/\breturn\b/g, "throw ");
|
|
74
74
|
if (lineText && !frontmatter.includes(lineText)) throw err;
|
|
75
75
|
try {
|
|
76
76
|
await transformWithEsbuild(frontmatter, id, {
|
|
@@ -3,7 +3,7 @@ import { IncomingMessage } from "node:http";
|
|
|
3
3
|
import { isRunnableDevEnvironment } from "vite";
|
|
4
4
|
import { toFallbackType } from "../core/app/common.js";
|
|
5
5
|
import { toRoutingStrategy } from "../core/app/entrypoints/index.js";
|
|
6
|
-
import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../core/constants.js";
|
|
6
|
+
import { ASTRO_VITE_ENVIRONMENT_NAMES, devPrerenderMiddlewareSymbol } from "../core/constants.js";
|
|
7
7
|
import {
|
|
8
8
|
getAlgorithm,
|
|
9
9
|
getDirectives,
|
|
@@ -19,6 +19,7 @@ import { getViteErrorPayload } from "../core/errors/dev/index.js";
|
|
|
19
19
|
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
20
20
|
import { NOOP_MIDDLEWARE_FN } from "../core/middleware/noop-middleware.js";
|
|
21
21
|
import { createViteLoader } from "../core/module-loader/index.js";
|
|
22
|
+
import { matchAllRoutes } from "../core/routing/match.js";
|
|
22
23
|
import { resolveMiddlewareMode } from "../integrations/adapter-utils.js";
|
|
23
24
|
import { SERIALIZED_MANIFEST_ID } from "../manifest/serialized.js";
|
|
24
25
|
import { ASTRO_DEV_SERVER_APP_ID } from "../vite-plugin-app/index.js";
|
|
@@ -40,15 +41,23 @@ function createVitePluginAstroServer({
|
|
|
40
41
|
return environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr;
|
|
41
42
|
},
|
|
42
43
|
async configureServer(viteServer) {
|
|
43
|
-
|
|
44
|
+
const ssrEnvironment = viteServer.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr];
|
|
45
|
+
const prerenderEnvironment = viteServer.environments[ASTRO_VITE_ENVIRONMENT_NAMES.prerender];
|
|
46
|
+
const runnableSsrEnvironment = isRunnableDevEnvironment(ssrEnvironment) ? ssrEnvironment : void 0;
|
|
47
|
+
const runnablePrerenderEnvironment = isRunnableDevEnvironment(prerenderEnvironment) ? prerenderEnvironment : void 0;
|
|
48
|
+
if (!runnableSsrEnvironment && !runnablePrerenderEnvironment) {
|
|
44
49
|
return;
|
|
45
50
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
async function createHandler(environment) {
|
|
52
|
+
const loader = createViteLoader(viteServer, environment);
|
|
53
|
+
const { default: createAstroServerApp } = await environment.runner.import(ASTRO_DEV_SERVER_APP_ID);
|
|
54
|
+
const controller = createController({ loader });
|
|
55
|
+
const { handler } = await createAstroServerApp(controller, settings, loader, logger);
|
|
56
|
+
const { manifest } = await environment.runner.import(SERIALIZED_MANIFEST_ID);
|
|
57
|
+
return { controller, handler, loader, manifest, environment };
|
|
58
|
+
}
|
|
59
|
+
const ssrHandler = runnableSsrEnvironment ? await createHandler(runnableSsrEnvironment) : void 0;
|
|
60
|
+
const prerenderHandler = runnablePrerenderEnvironment ? await createHandler(runnablePrerenderEnvironment) : void 0;
|
|
52
61
|
const localStorage = new AsyncLocalStorage();
|
|
53
62
|
function handleUnhandledRejection(rejection) {
|
|
54
63
|
const error = AstroError.is(rejection) ? rejection : new AstroError({
|
|
@@ -56,20 +65,36 @@ function createVitePluginAstroServer({
|
|
|
56
65
|
message: AstroErrorData.UnhandledRejection.message(rejection?.stack || rejection)
|
|
57
66
|
});
|
|
58
67
|
const store = localStorage.getStore();
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
const handlers = [];
|
|
69
|
+
if (ssrHandler) handlers.push(ssrHandler);
|
|
70
|
+
if (prerenderHandler) handlers.push(prerenderHandler);
|
|
71
|
+
for (const currentHandler of handlers) {
|
|
72
|
+
if (store instanceof IncomingMessage) {
|
|
73
|
+
setRouteError(currentHandler.controller.state, store.url, error);
|
|
74
|
+
}
|
|
75
|
+
const { errorWithMetadata } = recordServerError(
|
|
76
|
+
currentHandler.loader,
|
|
77
|
+
currentHandler.manifest,
|
|
78
|
+
logger,
|
|
79
|
+
error
|
|
80
|
+
);
|
|
81
|
+
setTimeout(
|
|
82
|
+
async () => currentHandler.loader.webSocketSend(await getViteErrorPayload(errorWithMetadata)),
|
|
83
|
+
200
|
|
84
|
+
);
|
|
61
85
|
}
|
|
62
|
-
const { errorWithMetadata } = recordServerError(loader, manifest, logger, error);
|
|
63
|
-
setTimeout(
|
|
64
|
-
async () => loader.webSocketSend(await getViteErrorPayload(errorWithMetadata)),
|
|
65
|
-
200
|
|
66
|
-
);
|
|
67
86
|
}
|
|
68
87
|
process.on("unhandledRejection", handleUnhandledRejection);
|
|
69
88
|
viteServer.httpServer?.on("close", () => {
|
|
70
89
|
process.off("unhandledRejection", handleUnhandledRejection);
|
|
71
90
|
});
|
|
72
91
|
return () => {
|
|
92
|
+
const shouldHandlePrerenderInCore = Boolean(
|
|
93
|
+
viteServer[devPrerenderMiddlewareSymbol]
|
|
94
|
+
);
|
|
95
|
+
if (!ssrHandler && !(prerenderHandler && shouldHandlePrerenderInCore)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
73
98
|
viteServer.middlewares.stack.unshift({
|
|
74
99
|
route: "",
|
|
75
100
|
handle: baseMiddleware(settings, logger)
|
|
@@ -86,16 +111,49 @@ function createVitePluginAstroServer({
|
|
|
86
111
|
route: "",
|
|
87
112
|
handle: secFetchMiddleware(logger, settings.config.security?.allowedDomains)
|
|
88
113
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
114
|
+
if (prerenderHandler && shouldHandlePrerenderInCore) {
|
|
115
|
+
viteServer.middlewares.use(
|
|
116
|
+
async function astroDevPrerenderHandler(request, response, next) {
|
|
117
|
+
if (request.url === void 0 || !request.method) {
|
|
118
|
+
response.writeHead(500, "Incomplete request");
|
|
119
|
+
response.end();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (request.url.startsWith("/@") || request.url.startsWith("/__")) {
|
|
123
|
+
return next();
|
|
124
|
+
}
|
|
125
|
+
if (request.url.includes("/node_modules/")) {
|
|
126
|
+
return next();
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const pathname = decodeURI(new URL(request.url, "http://localhost").pathname);
|
|
130
|
+
const { routes } = await prerenderHandler.environment.runner.import("virtual:astro:routes");
|
|
131
|
+
const routesList = { routes: routes.map((r) => r.routeData) };
|
|
132
|
+
const matches = matchAllRoutes(pathname, routesList);
|
|
133
|
+
if (!matches.some((route) => route.prerender)) {
|
|
134
|
+
return next();
|
|
135
|
+
}
|
|
136
|
+
localStorage.run(request, () => {
|
|
137
|
+
prerenderHandler.handler(request, response);
|
|
138
|
+
});
|
|
139
|
+
} catch (err) {
|
|
140
|
+
next(err);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
if (ssrHandler) {
|
|
146
|
+
viteServer.middlewares.use(async function astroDevHandler(request, response) {
|
|
147
|
+
if (request.url === void 0 || !request.method) {
|
|
148
|
+
response.writeHead(500, "Incomplete request");
|
|
149
|
+
response.end();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
localStorage.run(request, () => {
|
|
153
|
+
ssrHandler.handler(request, response);
|
|
154
|
+
});
|
|
97
155
|
});
|
|
98
|
-
}
|
|
156
|
+
}
|
|
99
157
|
};
|
|
100
158
|
}
|
|
101
159
|
};
|
|
@@ -42,16 +42,19 @@ function* collectCSSWithOrder(id, mod, seen = /* @__PURE__ */ new Set()) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
function astroDevCssPlugin({ routesList, command }) {
|
|
45
|
-
let
|
|
45
|
+
let server;
|
|
46
46
|
const cssContentCache = /* @__PURE__ */ new Map();
|
|
47
|
+
function getCurrentEnvironment(pluginEnv) {
|
|
48
|
+
return pluginEnv ?? server?.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr];
|
|
49
|
+
}
|
|
47
50
|
return [
|
|
48
51
|
{
|
|
49
52
|
name: MODULE_DEV_CSS,
|
|
50
|
-
async configureServer(
|
|
51
|
-
|
|
53
|
+
async configureServer(viteServer) {
|
|
54
|
+
server = viteServer;
|
|
52
55
|
},
|
|
53
56
|
applyToEnvironment(env) {
|
|
54
|
-
return env.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.client;
|
|
57
|
+
return env.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.client || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.prerender;
|
|
55
58
|
},
|
|
56
59
|
resolveId: {
|
|
57
60
|
filter: {
|
|
@@ -81,14 +84,15 @@ function astroDevCssPlugin({ routesList, command }) {
|
|
|
81
84
|
);
|
|
82
85
|
const cssWithOrder = /* @__PURE__ */ new Map();
|
|
83
86
|
const componentPageId = getVirtualModulePageNameForComponent(componentPath);
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
const env = getCurrentEnvironment(this.environment);
|
|
88
|
+
await env?.fetchModule(componentPageId);
|
|
89
|
+
const resolved = await env?.pluginContainer.resolveId(componentPageId);
|
|
86
90
|
if (!resolved?.id) {
|
|
87
91
|
return {
|
|
88
92
|
code: "export const css = new Set()"
|
|
89
93
|
};
|
|
90
94
|
}
|
|
91
|
-
const mod =
|
|
95
|
+
const mod = env?.moduleGraph.getModuleById(resolved.id);
|
|
92
96
|
if (!mod) {
|
|
93
97
|
return {
|
|
94
98
|
code: "export const css = new Set()"
|
|
@@ -123,7 +127,8 @@ function astroDevCssPlugin({ routesList, command }) {
|
|
|
123
127
|
if (command === "build") {
|
|
124
128
|
return;
|
|
125
129
|
}
|
|
126
|
-
const
|
|
130
|
+
const env = getCurrentEnvironment(this.environment);
|
|
131
|
+
const mod = env?.moduleGraph.getModuleById(id);
|
|
127
132
|
if (mod) {
|
|
128
133
|
cssContentCache.set(id, code);
|
|
129
134
|
}
|
|
@@ -133,7 +138,7 @@ function astroDevCssPlugin({ routesList, command }) {
|
|
|
133
138
|
{
|
|
134
139
|
name: MODULE_DEV_CSS_ALL,
|
|
135
140
|
applyToEnvironment(env) {
|
|
136
|
-
return env.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.client || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.
|
|
141
|
+
return env.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.client || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.prerender;
|
|
137
142
|
},
|
|
138
143
|
resolveId: {
|
|
139
144
|
filter: {
|
|
@@ -77,11 +77,22 @@ async function astroPluginRoutes({
|
|
|
77
77
|
routeData: serializeRouteData(r, settings.config.trailingSlash)
|
|
78
78
|
};
|
|
79
79
|
});
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
const environmentsToInvalidate = [];
|
|
81
|
+
for (const name of [
|
|
82
|
+
ASTRO_VITE_ENVIRONMENT_NAMES.ssr,
|
|
83
|
+
ASTRO_VITE_ENVIRONMENT_NAMES.prerender
|
|
84
|
+
]) {
|
|
85
|
+
const environment = server.environments[name];
|
|
86
|
+
if (environment) {
|
|
87
|
+
environmentsToInvalidate.push(environment);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (const environment of environmentsToInvalidate) {
|
|
91
|
+
const virtualMod = environment.moduleGraph.getModuleById(ASTRO_ROUTES_MODULE_ID_RESOLVED);
|
|
92
|
+
if (!virtualMod) continue;
|
|
93
|
+
environment.moduleGraph.invalidateModule(virtualMod);
|
|
94
|
+
environment.hot.send("astro:routes-updated", {});
|
|
95
|
+
}
|
|
85
96
|
}
|
|
86
97
|
}
|
|
87
98
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.3",
|
|
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",
|
|
@@ -153,9 +153,9 @@
|
|
|
153
153
|
"xxhash-wasm": "^1.1.0",
|
|
154
154
|
"yargs-parser": "^22.0.0",
|
|
155
155
|
"zod": "^4.3.6",
|
|
156
|
-
"@astrojs/
|
|
156
|
+
"@astrojs/markdown-remark": "7.0.0",
|
|
157
157
|
"@astrojs/telemetry": "3.3.0",
|
|
158
|
-
"@astrojs/
|
|
158
|
+
"@astrojs/internal-helpers": "0.8.0"
|
|
159
159
|
},
|
|
160
160
|
"optionalDependencies": {
|
|
161
161
|
"sharp": "^0.34.0"
|