astro 4.8.7 → 4.9.1
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 +43 -96
- package/dist/actions/runtime/middleware.d.ts +1 -0
- package/dist/actions/runtime/middleware.js +27 -25
- package/dist/actions/runtime/route.js +1 -2
- package/dist/actions/runtime/utils.d.ts +6 -1
- package/dist/actions/runtime/utils.js +2 -1
- package/dist/actions/runtime/virtual/server.d.ts +4 -2
- package/dist/actions/runtime/virtual/server.js +9 -11
- package/dist/actions/utils.d.ts +2 -0
- package/dist/actions/utils.js +2 -1
- package/dist/container/index.d.ts +162 -0
- package/dist/container/index.js +234 -0
- package/dist/container/pipeline.d.ts +11 -0
- package/dist/container/pipeline.js +96 -0
- package/dist/core/app/node.js +4 -1
- package/dist/core/build/generate.js +3 -3
- package/dist/core/build/plugins/plugin-manifest.js +2 -2
- package/dist/core/config/schema.d.ts +92 -120
- package/dist/core/config/schema.js +18 -23
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/render-context.d.ts +1 -1
- package/dist/core/render-context.js +6 -3
- package/dist/core/routing/manifest/create.d.ts +4 -1
- package/dist/core/routing/manifest/create.js +10 -8
- package/dist/integrations/features-validation.js +1 -1
- package/dist/vite-plugin-astro-server/plugin.d.ts +0 -1
- package/dist/vite-plugin-astro-server/plugin.js +1 -1
- package/package.json +5 -1
- package/templates/actions.mjs +37 -12
|
@@ -113,7 +113,7 @@ function createDevelopmentManifest(settings) {
|
|
|
113
113
|
componentMetadata: /* @__PURE__ */ new Map(),
|
|
114
114
|
inlinedScripts: /* @__PURE__ */ new Map(),
|
|
115
115
|
i18n: i18nManifest,
|
|
116
|
-
checkOrigin: settings.config.
|
|
116
|
+
checkOrigin: settings.config.security?.checkOrigin ?? false,
|
|
117
117
|
rewritingEnabled: settings.config.experimental.rewriting,
|
|
118
118
|
middleware(_, next) {
|
|
119
119
|
return next();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.1",
|
|
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",
|
|
@@ -48,6 +48,10 @@
|
|
|
48
48
|
"types": "./config.d.ts",
|
|
49
49
|
"default": "./config.mjs"
|
|
50
50
|
},
|
|
51
|
+
"./container": {
|
|
52
|
+
"types": "./dist/container/index.d.ts",
|
|
53
|
+
"default": "./dist/container/index.js"
|
|
54
|
+
},
|
|
51
55
|
"./app": "./dist/core/app/index.js",
|
|
52
56
|
"./app/node": "./dist/core/app/node.js",
|
|
53
57
|
"./client/*": "./dist/runtime/client/*",
|
package/templates/actions.mjs
CHANGED
|
@@ -7,11 +7,33 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '/_actions/') {
|
|
|
7
7
|
return target[objKey];
|
|
8
8
|
}
|
|
9
9
|
const path = aggregatedPath + objKey.toString();
|
|
10
|
-
const action = (
|
|
10
|
+
const action = (param) => actionHandler(param, path);
|
|
11
11
|
action.toString = () => path;
|
|
12
12
|
action.safe = (input) => {
|
|
13
13
|
return callSafely(() => action(input));
|
|
14
14
|
};
|
|
15
|
+
action.safe.toString = () => path;
|
|
16
|
+
|
|
17
|
+
// Add progressive enhancement info for React.
|
|
18
|
+
action.$$FORM_ACTION = function () {
|
|
19
|
+
const data = new FormData();
|
|
20
|
+
data.set('_astroAction', action.toString());
|
|
21
|
+
return {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
name: action.toString(),
|
|
24
|
+
data,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
action.safe.$$FORM_ACTION = function () {
|
|
28
|
+
const data = new FormData();
|
|
29
|
+
data.set('_astroAction', action.toString());
|
|
30
|
+
data.set('_astroActionSafe', 'true');
|
|
31
|
+
return {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
name: action.toString(),
|
|
34
|
+
data,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
15
37
|
// recurse to construct queries for nested object paths
|
|
16
38
|
// ex. actions.user.admins.auth()
|
|
17
39
|
return toActionProxy(action, path + '.');
|
|
@@ -20,24 +42,27 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '/_actions/') {
|
|
|
20
42
|
}
|
|
21
43
|
|
|
22
44
|
/**
|
|
23
|
-
* @param {*}
|
|
24
|
-
* @param {string} path Built path to call action
|
|
25
|
-
* Usage: `actions.[name](
|
|
45
|
+
* @param {*} param argument passed to the action when called server or client-side.
|
|
46
|
+
* @param {string} path Built path to call action by path name.
|
|
47
|
+
* Usage: `actions.[name](param)`.
|
|
26
48
|
*/
|
|
27
|
-
async function actionHandler(
|
|
49
|
+
async function actionHandler(param, path) {
|
|
50
|
+
// When running server-side, import the action and call it.
|
|
28
51
|
if (import.meta.env.SSR) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
const { getAction } = await import('astro/actions/runtime/utils.js');
|
|
53
|
+
const action = await getAction(path);
|
|
54
|
+
if (!action) throw new Error(`Action not found: ${path}`);
|
|
55
|
+
|
|
56
|
+
return action(param);
|
|
34
57
|
}
|
|
58
|
+
|
|
59
|
+
// When running client-side, make a fetch request to the action path.
|
|
35
60
|
const headers = new Headers();
|
|
36
61
|
headers.set('Accept', 'application/json');
|
|
37
|
-
let body =
|
|
62
|
+
let body = param;
|
|
38
63
|
if (!(body instanceof FormData)) {
|
|
39
64
|
try {
|
|
40
|
-
body =
|
|
65
|
+
body = param ? JSON.stringify(param) : undefined;
|
|
41
66
|
} catch (e) {
|
|
42
67
|
throw new ActionError({
|
|
43
68
|
code: 'BAD_REQUEST',
|