astro 4.13.0 → 4.13.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 +21 -2
- package/dist/actions/runtime/middleware.d.ts +1 -0
- package/dist/actions/runtime/middleware.js +35 -24
- package/dist/actions/runtime/route.js +4 -4
- package/dist/actions/runtime/utils.d.ts +2 -0
- package/dist/actions/runtime/virtual/client.d.ts +0 -1
- package/dist/actions/runtime/virtual/client.js +0 -4
- package/dist/actions/runtime/virtual/server.d.ts +1 -4
- package/dist/actions/runtime/virtual/server.js +20 -13
- package/dist/actions/utils.d.ts +1 -0
- package/dist/actions/utils.js +12 -0
- package/dist/cli/add/index.d.ts +0 -7
- package/dist/cli/add/index.js +1 -2
- package/dist/cli/install-package.d.ts +0 -1
- package/dist/cli/install-package.js +1 -2
- package/dist/content/runtime-assets.d.ts +1 -1
- package/dist/content/utils.d.ts +2 -11
- package/dist/content/utils.js +0 -8
- package/dist/core/build/generate.d.ts +0 -4
- package/dist/core/build/generate.js +1 -21
- package/dist/core/build/index.js +1 -1
- package/dist/core/build/internal.d.ts +0 -18
- package/dist/core/build/internal.js +0 -17
- package/dist/core/build/page-data.d.ts +1 -1
- package/dist/core/build/page-data.js +1 -18
- package/dist/core/build/plugins/plugin-analyzer.js +0 -4
- package/dist/core/build/plugins/plugin-internals.js +0 -7
- package/dist/core/build/plugins/plugin-manifest.d.ts +0 -10
- package/dist/core/build/plugins/plugin-manifest.js +0 -2
- package/dist/core/build/plugins/plugin-ssr.js +0 -1
- package/dist/core/build/types.d.ts +1 -8
- package/dist/core/compile/index.d.ts +0 -1
- package/dist/core/compile/types.d.ts +0 -7
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/restart.d.ts +0 -2
- package/dist/core/dev/restart.js +1 -3
- package/dist/core/errors/dev/vite.d.ts +0 -13
- package/dist/core/errors/dev/vite.js +1 -2
- package/dist/core/errors/errors-data.d.ts +16 -5
- package/dist/core/errors/errors-data.js +13 -6
- package/dist/core/fs/index.d.ts +0 -2
- package/dist/core/fs/index.js +0 -5
- package/dist/core/logger/core.d.ts +0 -1
- package/dist/core/logger/core.js +0 -18
- package/dist/core/messages.d.ts +0 -1
- package/dist/core/messages.js +2 -3
- package/dist/core/middleware/index.js +3 -2
- package/dist/core/render/ssr-element.d.ts +0 -1
- package/dist/core/render/ssr-element.js +0 -6
- package/dist/core/render-context.d.ts +1 -1
- package/dist/core/render-context.js +4 -2
- package/dist/core/util.d.ts +0 -2
- package/dist/core/util.js +0 -14
- package/dist/preferences/index.d.ts +0 -1
- package/dist/preferences/index.js +0 -1
- package/dist/runtime/server/render/component.d.ts +0 -3
- package/dist/vite-plugin-astro-server/controller.d.ts +0 -4
- package/dist/vite-plugin-astro-server/controller.js +0 -2
- package/package.json +1 -7
- package/templates/actions.mjs +8 -5
- package/dist/actions/runtime/store.d.ts +0 -5
- package/dist/actions/runtime/store.js +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.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",
|
|
@@ -123,7 +123,6 @@
|
|
|
123
123
|
"aria-query": "^5.3.0",
|
|
124
124
|
"axobject-query": "^4.1.0",
|
|
125
125
|
"boxen": "7.1.1",
|
|
126
|
-
"chokidar": "^3.6.0",
|
|
127
126
|
"ci-info": "^4.0.0",
|
|
128
127
|
"clsx": "^2.1.1",
|
|
129
128
|
"common-ancestor-path": "^1.0.1",
|
|
@@ -183,7 +182,6 @@
|
|
|
183
182
|
"@types/babel__generator": "^7.6.8",
|
|
184
183
|
"@types/babel__traverse": "^7.20.6",
|
|
185
184
|
"@types/common-ancestor-path": "^1.0.2",
|
|
186
|
-
"@types/connect": "^3.4.38",
|
|
187
185
|
"@types/cssesc": "^3.0.2",
|
|
188
186
|
"@types/debug": "^4.1.12",
|
|
189
187
|
"@types/diff": "^5.2.1",
|
|
@@ -193,11 +191,8 @@
|
|
|
193
191
|
"@types/html-escaper": "^3.0.2",
|
|
194
192
|
"@types/http-cache-semantics": "^4.0.4",
|
|
195
193
|
"@types/js-yaml": "^4.0.9",
|
|
196
|
-
"@types/probe-image-size": "^7.2.5",
|
|
197
194
|
"@types/prompts": "^2.4.9",
|
|
198
195
|
"@types/semver": "^7.5.8",
|
|
199
|
-
"@types/send": "^0.17.4",
|
|
200
|
-
"@types/unist": "^3.0.2",
|
|
201
196
|
"@types/yargs-parser": "^21.0.3",
|
|
202
197
|
"cheerio": "1.0.0-rc.12",
|
|
203
198
|
"eol": "^0.9.1",
|
|
@@ -213,7 +208,6 @@
|
|
|
213
208
|
"remark-code-titles": "^0.1.2",
|
|
214
209
|
"rollup": "^4.19.1",
|
|
215
210
|
"sass": "^1.77.8",
|
|
216
|
-
"srcset-parse": "^1.1.0",
|
|
217
211
|
"undici": "^6.19.5",
|
|
218
212
|
"unified": "^11.0.5",
|
|
219
213
|
"astro-scripts": "0.0.14"
|
package/templates/actions.mjs
CHANGED
|
@@ -7,7 +7,9 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '') {
|
|
|
7
7
|
return target[objKey];
|
|
8
8
|
}
|
|
9
9
|
const path = aggregatedPath + objKey.toString();
|
|
10
|
-
|
|
10
|
+
function action(param) {
|
|
11
|
+
return callSafely(() => handleActionOrThrow(param, path, this));
|
|
12
|
+
}
|
|
11
13
|
|
|
12
14
|
Object.assign(action, {
|
|
13
15
|
queryString: getActionQueryString(path),
|
|
@@ -26,8 +28,8 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '') {
|
|
|
26
28
|
// Note: `orThrow` does not have progressive enhancement info.
|
|
27
29
|
// If you want to throw exceptions,
|
|
28
30
|
// you must handle those exceptions with client JS.
|
|
29
|
-
orThrow
|
|
30
|
-
return handleActionOrThrow(param, path);
|
|
31
|
+
orThrow(param) {
|
|
32
|
+
return handleActionOrThrow(param, path, this);
|
|
31
33
|
},
|
|
32
34
|
});
|
|
33
35
|
|
|
@@ -41,16 +43,17 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '') {
|
|
|
41
43
|
/**
|
|
42
44
|
* @param {*} param argument passed to the action when called server or client-side.
|
|
43
45
|
* @param {string} path Built path to call action by path name.
|
|
46
|
+
* @param {import('../src/@types/astro.d.ts').APIContext | undefined} context Injected API context when calling actions from the server.
|
|
44
47
|
* Usage: `actions.[name](param)`.
|
|
45
48
|
*/
|
|
46
|
-
async function handleActionOrThrow(param, path) {
|
|
49
|
+
async function handleActionOrThrow(param, path, context) {
|
|
47
50
|
// When running server-side, import the action and call it.
|
|
48
51
|
if (import.meta.env.SSR) {
|
|
49
52
|
const { getAction } = await import('astro/actions/runtime/utils.js');
|
|
50
53
|
const action = await getAction(path);
|
|
51
54
|
if (!action) throw new Error(`Action not found: ${path}`);
|
|
52
55
|
|
|
53
|
-
return action.orThrow(param);
|
|
56
|
+
return action.orThrow.bind(context)(param);
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
// When running client-side, make a fetch request to the action path.
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
import type { APIContext } from '../../@types/astro.js';
|
|
3
|
-
export type ActionAPIContext = Omit<APIContext, 'getActionResult' | 'props'>;
|
|
4
|
-
export declare const ApiContextStorage: AsyncLocalStorage<ActionAPIContext>;
|
|
5
|
-
export declare function getApiContext(): ActionAPIContext;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import { AstroError } from "../../core/errors/errors.js";
|
|
3
|
-
const ApiContextStorage = new AsyncLocalStorage();
|
|
4
|
-
function getApiContext() {
|
|
5
|
-
const context = ApiContextStorage.getStore();
|
|
6
|
-
if (!context) {
|
|
7
|
-
throw new AstroError({
|
|
8
|
-
name: "AstroActionError",
|
|
9
|
-
message: "Unable to get API context.",
|
|
10
|
-
hint: "If you attempted to call this action from server code, trying using `Astro.getActionResult()` instead."
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
return context;
|
|
14
|
-
}
|
|
15
|
-
export {
|
|
16
|
-
ApiContextStorage,
|
|
17
|
-
getApiContext
|
|
18
|
-
};
|