astro 4.14.3 → 4.14.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/@types/astro.d.ts +1 -1
- package/dist/actions/runtime/middleware.js +9 -8
- package/dist/content/loaders/file.js +3 -6
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +1 -0
- package/dist/core/messages.js +2 -2
- package/dist/core/render-context.d.ts +1 -1
- package/dist/core/render-context.js +9 -3
- package/package.json +2 -2
package/dist/@types/astro.d.ts
CHANGED
|
@@ -2128,7 +2128,7 @@ export interface AstroUserConfig {
|
|
|
2128
2128
|
* ```
|
|
2129
2129
|
*
|
|
2130
2130
|
* :::note
|
|
2131
|
-
* Loaders will not automatically [exclude files prefaced with an `_`](/en/guides/routing/#excluding-pages). Use a regular expression such as `pattern: '**\/[^_]*.md` in your loader to ignore these files.
|
|
2131
|
+
* Loaders will not automatically [exclude files prefaced with an `_`](/en/guides/routing/#excluding-pages). Use a regular expression such as `pattern: '**\/[^_]*.md'` in your loader to ignore these files.
|
|
2132
2132
|
* :::
|
|
2133
2133
|
*
|
|
2134
2134
|
* #### Querying and rendering with the Content Layer API
|
|
@@ -9,8 +9,16 @@ import {
|
|
|
9
9
|
serializeActionResult
|
|
10
10
|
} from "./virtual/shared.js";
|
|
11
11
|
const onRequest = defineMiddleware(async (context, next) => {
|
|
12
|
+
if (context._isPrerendered) {
|
|
13
|
+
if (context.request.method === "POST") {
|
|
14
|
+
console.warn(
|
|
15
|
+
yellow("[astro:actions]"),
|
|
16
|
+
'POST requests should not be sent to prerendered pages. If you\'re using Actions, disable prerendering with `export const prerender = "false".'
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return next();
|
|
20
|
+
}
|
|
12
21
|
const locals = context.locals;
|
|
13
|
-
const { request } = context;
|
|
14
22
|
if (locals._actionPayload) return next();
|
|
15
23
|
const actionPayload = context.cookies.get(ACTION_QUERY_PARAMS.actionPayload)?.json();
|
|
16
24
|
if (actionPayload) {
|
|
@@ -19,13 +27,6 @@ const onRequest = defineMiddleware(async (context, next) => {
|
|
|
19
27
|
}
|
|
20
28
|
return renderResult({ context, next, ...actionPayload });
|
|
21
29
|
}
|
|
22
|
-
if (import.meta.env.DEV && request.method === "POST" && request.body === null) {
|
|
23
|
-
console.warn(
|
|
24
|
-
yellow("[astro:actions]"),
|
|
25
|
-
'POST requests should not be sent to prerendered pages. If you\'re using Actions, disable prerendering with `export const prerender = "false".'
|
|
26
|
-
);
|
|
27
|
-
return next();
|
|
28
|
-
}
|
|
29
30
|
const actionName = context.url.searchParams.get(ACTION_QUERY_PARAMS.actionName);
|
|
30
31
|
if (context.request.method === "POST" && actionName) {
|
|
31
32
|
return handlePost({ context, next, actionName });
|
|
@@ -15,6 +15,7 @@ function file(fileName) {
|
|
|
15
15
|
logger.debug(error.message);
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
+
const normalizedFilePath = posixRelative(fileURLToPath(settings.config.root), filePath);
|
|
18
19
|
if (Array.isArray(json)) {
|
|
19
20
|
if (json.length === 0) {
|
|
20
21
|
logger.warn(`No items found in ${fileName}`);
|
|
@@ -28,11 +29,7 @@ function file(fileName) {
|
|
|
28
29
|
continue;
|
|
29
30
|
}
|
|
30
31
|
const data = await parseData({ id, data: rawItem, filePath });
|
|
31
|
-
store.set({
|
|
32
|
-
id,
|
|
33
|
-
data,
|
|
34
|
-
filePath: posixRelative(fileURLToPath(settings.config.root), filePath)
|
|
35
|
-
});
|
|
32
|
+
store.set({ id, data, filePath: normalizedFilePath });
|
|
36
33
|
}
|
|
37
34
|
} else if (typeof json === "object") {
|
|
38
35
|
const entries = Object.entries(json);
|
|
@@ -40,7 +37,7 @@ function file(fileName) {
|
|
|
40
37
|
store.clear();
|
|
41
38
|
for (const [id, rawItem] of entries) {
|
|
42
39
|
const data = await parseData({ id, data: rawItem, filePath });
|
|
43
|
-
store.set({ id, data });
|
|
40
|
+
store.set({ id, data, filePath: normalizedFilePath });
|
|
44
41
|
}
|
|
45
42
|
} else {
|
|
46
43
|
logger.error(`Invalid data in ${fileName}. Must be an array or object.`);
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
|
|
|
23
23
|
await telemetry.record([]);
|
|
24
24
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
25
25
|
const logger = restart.container.logger;
|
|
26
|
-
const currentVersion = "4.14.
|
|
26
|
+
const currentVersion = "4.14.4";
|
|
27
27
|
const isPrerelease = currentVersion.includes("-");
|
|
28
28
|
if (!isPrerelease) {
|
|
29
29
|
try {
|
|
@@ -1485,6 +1485,7 @@ export declare const ActionsWithoutServerOutputError: {
|
|
|
1485
1485
|
* - [Actions RFC](https://github.com/withastro/roadmap/blob/actions/proposals/0046-actions.md)
|
|
1486
1486
|
* @description
|
|
1487
1487
|
* Action was called from a form using a GET request, but only POST requests are supported. This often occurs if `method="POST"` is missing on the form.
|
|
1488
|
+
* @deprecated Deprecated since version 4.13.2.
|
|
1488
1489
|
*/
|
|
1489
1490
|
export declare const ActionsUsedWithForGetError: {
|
|
1490
1491
|
name: string;
|
package/dist/core/messages.js
CHANGED
|
@@ -38,7 +38,7 @@ function serverStart({
|
|
|
38
38
|
host,
|
|
39
39
|
base
|
|
40
40
|
}) {
|
|
41
|
-
const version = "4.14.
|
|
41
|
+
const version = "4.14.4";
|
|
42
42
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
43
43
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
44
44
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -270,7 +270,7 @@ function printHelp({
|
|
|
270
270
|
message.push(
|
|
271
271
|
linebreak(),
|
|
272
272
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
273
|
-
`v${"4.14.
|
|
273
|
+
`v${"4.14.4"}`
|
|
274
274
|
)} ${headline}`
|
|
275
275
|
);
|
|
276
276
|
}
|
|
@@ -42,7 +42,7 @@ export declare class RenderContext {
|
|
|
42
42
|
* - fallback
|
|
43
43
|
*/
|
|
44
44
|
render(componentInstance: ComponentInstance | undefined, slots?: Record<string, any>): Promise<Response>;
|
|
45
|
-
createAPIContext(props: APIContext['props']): APIContext;
|
|
45
|
+
createAPIContext(props: APIContext['props'], isPrerendered: boolean): APIContext;
|
|
46
46
|
createActionAPIContext(): ActionAPIContext;
|
|
47
47
|
createResult(mod: ComponentInstance): Promise<SSRResult>;
|
|
48
48
|
/**
|
|
@@ -87,6 +87,7 @@ class RenderContext {
|
|
|
87
87
|
async render(componentInstance, slots = {}) {
|
|
88
88
|
const { cookies, middleware, pipeline } = this;
|
|
89
89
|
const { logger, serverLike, streaming } = pipeline;
|
|
90
|
+
const isPrerendered = !serverLike || this.routeData.prerender;
|
|
90
91
|
const props = Object.keys(this.props).length > 0 ? this.props : await getProps({
|
|
91
92
|
mod: componentInstance,
|
|
92
93
|
routeData: this.routeData,
|
|
@@ -95,7 +96,7 @@ class RenderContext {
|
|
|
95
96
|
logger,
|
|
96
97
|
serverLike
|
|
97
98
|
});
|
|
98
|
-
const apiContext = this.createAPIContext(props);
|
|
99
|
+
const apiContext = this.createAPIContext(props, isPrerendered);
|
|
99
100
|
this.counter++;
|
|
100
101
|
if (this.counter === 4) {
|
|
101
102
|
return new Response("Loop Detected", {
|
|
@@ -166,12 +167,17 @@ class RenderContext {
|
|
|
166
167
|
attachCookiesToResponse(response, cookies);
|
|
167
168
|
return response;
|
|
168
169
|
}
|
|
169
|
-
createAPIContext(props) {
|
|
170
|
+
createAPIContext(props, isPrerendered) {
|
|
170
171
|
const context = this.createActionAPIContext();
|
|
171
172
|
return Object.assign(context, {
|
|
172
173
|
props,
|
|
173
174
|
getActionResult: createGetActionResult(context.locals),
|
|
174
|
-
callAction: createCallAction(context)
|
|
175
|
+
callAction: createCallAction(context),
|
|
176
|
+
// Used internally by Actions middleware.
|
|
177
|
+
// TODO: discuss exposing this information from APIContext.
|
|
178
|
+
// middleware runs on prerendered routes in the dev server,
|
|
179
|
+
// so this is useful information to have.
|
|
180
|
+
_isPrerendered: isPrerendered
|
|
175
181
|
});
|
|
176
182
|
}
|
|
177
183
|
async #executeRewrite(reroutePayload) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.14.
|
|
3
|
+
"version": "4.14.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",
|
|
@@ -172,8 +172,8 @@
|
|
|
172
172
|
"zod": "^3.23.8",
|
|
173
173
|
"zod-to-json-schema": "^3.23.2",
|
|
174
174
|
"zod-to-ts": "^1.2.0",
|
|
175
|
-
"@astrojs/internal-helpers": "0.4.1",
|
|
176
175
|
"@astrojs/markdown-remark": "5.2.0",
|
|
176
|
+
"@astrojs/internal-helpers": "0.4.1",
|
|
177
177
|
"@astrojs/telemetry": "3.1.0"
|
|
178
178
|
},
|
|
179
179
|
"optionalDependencies": {
|