astro 4.13.0 → 4.13.2
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 +0 -1
- package/astro.js +2 -1
- package/client.d.ts +1 -1
- package/components/Picture.astro +2 -2
- package/components/ViewTransitions.astro +1 -1
- package/config.d.ts +1 -1
- package/dist/@types/astro.d.ts +21 -2
- package/dist/actions/runtime/middleware.d.ts +3 -3
- package/dist/actions/runtime/middleware.js +39 -72
- package/dist/actions/runtime/route.js +16 -23
- package/dist/actions/runtime/utils.d.ts +2 -8
- package/dist/actions/runtime/utils.js +0 -15
- package/dist/actions/runtime/virtual/client.d.ts +0 -1
- package/dist/actions/runtime/virtual/client.js +0 -4
- package/dist/actions/runtime/virtual/get-action.d.ts +8 -0
- package/dist/actions/runtime/virtual/get-action.js +17 -0
- package/dist/actions/runtime/virtual/server.d.ts +1 -4
- package/dist/actions/runtime/virtual/server.js +20 -13
- package/dist/actions/runtime/virtual/shared.d.ts +18 -1
- package/dist/actions/runtime/virtual/shared.js +56 -8
- package/dist/actions/utils.d.ts +2 -0
- package/dist/actions/utils.js +13 -8
- package/dist/assets/build/generate.js +1 -1
- package/dist/assets/endpoint/generic.js +1 -1
- package/dist/assets/endpoint/node.js +3 -3
- package/dist/assets/services/sharp.js +1 -1
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +1 -1
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +1 -1
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +1 -1
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +1 -1
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +1 -1
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +1 -1
- package/dist/assets/utils/metadata.js +1 -1
- package/dist/assets/utils/node/emitAsset.js +1 -1
- package/dist/assets/utils/remoteProbe.js +1 -1
- package/dist/assets/utils/vendor/image-size/lookup.js +1 -1
- package/dist/assets/utils/vendor/image-size/types/svg.js +4 -4
- package/dist/cli/add/index.d.ts +0 -7
- package/dist/cli/add/index.js +1 -2
- package/dist/cli/info/index.js +2 -2
- package/dist/cli/install-package.d.ts +0 -1
- package/dist/cli/install-package.js +3 -4
- 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/app/index.js +1 -1
- package/dist/core/build/css-asset-name.d.ts +3 -3
- package/dist/core/build/css-asset-name.js +15 -8
- package/dist/core/build/generate.d.ts +0 -4
- package/dist/core/build/generate.js +4 -24
- package/dist/core/build/index.js +8 -2
- 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-css.js +2 -2
- 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/config/schema.d.ts +55 -55
- package/dist/core/config/tsconfig.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +2 -2
- 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 +5 -6
- package/dist/core/errors/errors-data.d.ts +21 -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 +9 -4
- package/dist/core/routing/manifest/create.js +2 -2
- package/dist/core/util.d.ts +0 -2
- package/dist/core/util.js +0 -14
- package/dist/events/error.js +1 -1
- package/dist/preferences/index.d.ts +0 -1
- package/dist/preferences/index.js +0 -1
- package/dist/runtime/client/dev-toolbar/apps/audit/index.js +1 -1
- package/dist/runtime/client/dev-toolbar/apps/audit/rules/perf.js +4 -2
- package/dist/runtime/server/render/component.d.ts +0 -3
- package/dist/runtime/server/render/component.js +1 -3
- package/dist/transitions/router.js +2 -2
- package/dist/type-utils.d.ts +1 -1
- package/dist/vite-plugin-astro-server/controller.d.ts +0 -4
- package/dist/vite-plugin-astro-server/controller.js +0 -2
- package/dist/vite-plugin-astro-server/vite.js +1 -2
- package/dist/vite-plugin-env/index.js +0 -1
- package/dist/vite-plugin-load-fallback/index.js +3 -3
- package/dist/vite-plugin-scanner/index.js +1 -1
- package/dist/vite-plugin-scripts/page-ssr.js +1 -1
- package/package.json +8 -17
- package/templates/actions.mjs +25 -18
- package/templates/content/types.d.ts +12 -10
- package/types/content.d.ts +1 -1
- 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.2",
|
|
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",
|
|
@@ -83,9 +83,6 @@
|
|
|
83
83
|
},
|
|
84
84
|
"./virtual-modules/*": "./dist/virtual-modules/*"
|
|
85
85
|
},
|
|
86
|
-
"imports": {
|
|
87
|
-
"#astro/*": "./dist/*.js"
|
|
88
|
-
},
|
|
89
86
|
"bin": {
|
|
90
87
|
"astro": "astro.js"
|
|
91
88
|
},
|
|
@@ -110,7 +107,7 @@
|
|
|
110
107
|
"vendor"
|
|
111
108
|
],
|
|
112
109
|
"dependencies": {
|
|
113
|
-
"@astrojs/compiler": "^2.10.
|
|
110
|
+
"@astrojs/compiler": "^2.10.1",
|
|
114
111
|
"@babel/core": "^7.25.2",
|
|
115
112
|
"@babel/generator": "^7.25.0",
|
|
116
113
|
"@babel/parser": "^7.25.3",
|
|
@@ -123,7 +120,6 @@
|
|
|
123
120
|
"aria-query": "^5.3.0",
|
|
124
121
|
"axobject-query": "^4.1.0",
|
|
125
122
|
"boxen": "7.1.1",
|
|
126
|
-
"chokidar": "^3.6.0",
|
|
127
123
|
"ci-info": "^4.0.0",
|
|
128
124
|
"clsx": "^2.1.1",
|
|
129
125
|
"common-ancestor-path": "^1.0.1",
|
|
@@ -157,7 +153,7 @@
|
|
|
157
153
|
"prompts": "^2.4.2",
|
|
158
154
|
"rehype": "^13.0.1",
|
|
159
155
|
"semver": "^7.6.3",
|
|
160
|
-
"shiki": "^1.12.
|
|
156
|
+
"shiki": "^1.12.1",
|
|
161
157
|
"string-width": "^7.2.0",
|
|
162
158
|
"strip-ansi": "^7.1.0",
|
|
163
159
|
"tsconfck": "^3.1.1",
|
|
@@ -170,20 +166,19 @@
|
|
|
170
166
|
"zod": "^3.23.8",
|
|
171
167
|
"zod-to-json-schema": "^3.23.2",
|
|
172
168
|
"@astrojs/internal-helpers": "0.4.1",
|
|
173
|
-
"@astrojs/
|
|
174
|
-
"@astrojs/
|
|
169
|
+
"@astrojs/telemetry": "3.1.0",
|
|
170
|
+
"@astrojs/markdown-remark": "5.2.0"
|
|
175
171
|
},
|
|
176
172
|
"optionalDependencies": {
|
|
177
173
|
"sharp": "^0.33.3"
|
|
178
174
|
},
|
|
179
175
|
"devDependencies": {
|
|
180
|
-
"@astrojs/check": "^0.9.
|
|
176
|
+
"@astrojs/check": "^0.9.1",
|
|
181
177
|
"@playwright/test": "^1.45.3",
|
|
182
178
|
"@types/aria-query": "^5.0.4",
|
|
183
179
|
"@types/babel__generator": "^7.6.8",
|
|
184
180
|
"@types/babel__traverse": "^7.20.6",
|
|
185
181
|
"@types/common-ancestor-path": "^1.0.2",
|
|
186
|
-
"@types/connect": "^3.4.38",
|
|
187
182
|
"@types/cssesc": "^3.0.2",
|
|
188
183
|
"@types/debug": "^4.1.12",
|
|
189
184
|
"@types/diff": "^5.2.1",
|
|
@@ -193,27 +188,23 @@
|
|
|
193
188
|
"@types/html-escaper": "^3.0.2",
|
|
194
189
|
"@types/http-cache-semantics": "^4.0.4",
|
|
195
190
|
"@types/js-yaml": "^4.0.9",
|
|
196
|
-
"@types/probe-image-size": "^7.2.5",
|
|
197
191
|
"@types/prompts": "^2.4.9",
|
|
198
192
|
"@types/semver": "^7.5.8",
|
|
199
|
-
"@types/send": "^0.17.4",
|
|
200
|
-
"@types/unist": "^3.0.2",
|
|
201
193
|
"@types/yargs-parser": "^21.0.3",
|
|
202
194
|
"cheerio": "1.0.0-rc.12",
|
|
203
195
|
"eol": "^0.9.1",
|
|
204
196
|
"expect-type": "^0.19.0",
|
|
205
197
|
"mdast-util-mdx": "^3.0.0",
|
|
206
198
|
"mdast-util-mdx-jsx": "^3.1.2",
|
|
207
|
-
"memfs": "^4.11.
|
|
199
|
+
"memfs": "^4.11.1",
|
|
208
200
|
"node-mocks-http": "^1.15.1",
|
|
209
201
|
"parse-srcset": "^1.0.2",
|
|
210
202
|
"rehype-autolink-headings": "^7.1.0",
|
|
211
203
|
"rehype-slug": "^6.0.0",
|
|
212
204
|
"rehype-toc": "^3.0.2",
|
|
213
205
|
"remark-code-titles": "^0.1.2",
|
|
214
|
-
"rollup": "^4.
|
|
206
|
+
"rollup": "^4.20.0",
|
|
215
207
|
"sass": "^1.77.8",
|
|
216
|
-
"srcset-parse": "^1.1.0",
|
|
217
208
|
"undici": "^6.19.5",
|
|
218
209
|
"unified": "^11.0.5",
|
|
219
210
|
"astro-scripts": "0.0.14"
|
package/templates/actions.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionError,
|
|
1
|
+
import { ActionError, deserializeActionResult, getActionQueryString } from 'astro:actions';
|
|
2
2
|
|
|
3
3
|
function toActionProxy(actionCallback = {}, aggregatedPath = '') {
|
|
4
4
|
return new Proxy(actionCallback, {
|
|
@@ -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 handleAction(param, path, this);
|
|
12
|
+
}
|
|
11
13
|
|
|
12
14
|
Object.assign(action, {
|
|
13
15
|
queryString: getActionQueryString(path),
|
|
@@ -26,8 +28,10 @@ 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
|
-
|
|
31
|
+
async orThrow(param) {
|
|
32
|
+
const { data, error } = await handleAction(param, path, this);
|
|
33
|
+
if (error) throw error;
|
|
34
|
+
return data;
|
|
31
35
|
},
|
|
32
36
|
});
|
|
33
37
|
|
|
@@ -41,16 +45,18 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '') {
|
|
|
41
45
|
/**
|
|
42
46
|
* @param {*} param argument passed to the action when called server or client-side.
|
|
43
47
|
* @param {string} path Built path to call action by path name.
|
|
48
|
+
* @param {import('../dist/@types/astro.d.ts').APIContext | undefined} context Injected API context when calling actions from the server.
|
|
44
49
|
* Usage: `actions.[name](param)`.
|
|
50
|
+
* @returns {Promise<import('../dist/actions/runtime/virtual/shared.js').SafeResult<any, any>>}
|
|
45
51
|
*/
|
|
46
|
-
async function
|
|
52
|
+
async function handleAction(param, path, context) {
|
|
47
53
|
// When running server-side, import the action and call it.
|
|
48
54
|
if (import.meta.env.SSR) {
|
|
49
|
-
const { getAction } = await import('astro/actions/runtime/
|
|
55
|
+
const { getAction } = await import('astro/actions/runtime/virtual/get-action.js');
|
|
50
56
|
const action = await getAction(path);
|
|
51
57
|
if (!action) throw new Error(`Action not found: ${path}`);
|
|
52
58
|
|
|
53
|
-
return action.
|
|
59
|
+
return action.bind(context)(param);
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
// When running client-side, make a fetch request to the action path.
|
|
@@ -59,29 +65,30 @@ async function handleActionOrThrow(param, path) {
|
|
|
59
65
|
let body = param;
|
|
60
66
|
if (!(body instanceof FormData)) {
|
|
61
67
|
try {
|
|
62
|
-
body =
|
|
68
|
+
body = JSON.stringify(param);
|
|
63
69
|
} catch (e) {
|
|
64
70
|
throw new ActionError({
|
|
65
71
|
code: 'BAD_REQUEST',
|
|
66
72
|
message: `Failed to serialize request body to JSON. Full error: ${e.message}`,
|
|
67
73
|
});
|
|
68
74
|
}
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
if (body) {
|
|
76
|
+
headers.set('Content-Type', 'application/json');
|
|
77
|
+
} else {
|
|
78
|
+
headers.set('Content-Length', '0');
|
|
79
|
+
}
|
|
71
80
|
}
|
|
72
|
-
const
|
|
81
|
+
const rawResult = await fetch(`/_actions/${path}`, {
|
|
73
82
|
method: 'POST',
|
|
74
83
|
body,
|
|
75
84
|
headers,
|
|
76
85
|
});
|
|
77
|
-
if (
|
|
78
|
-
throw await ActionError.fromResponse(res);
|
|
79
|
-
}
|
|
80
|
-
// Check if response body is empty before parsing.
|
|
81
|
-
if (res.status === 204) return;
|
|
86
|
+
if (rawResult.status === 204) return;
|
|
82
87
|
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
return deserializeActionResult({
|
|
89
|
+
type: rawResult.ok ? 'data' : 'error',
|
|
90
|
+
body: await rawResult.text(),
|
|
91
|
+
});
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
export const actions = toActionProxy();
|
|
@@ -22,29 +22,31 @@ declare module 'astro:content' {
|
|
|
22
22
|
ContentEntryMap[C]
|
|
23
23
|
>['slug'];
|
|
24
24
|
|
|
25
|
+
/** @deprecated Use `getEntry` instead. */
|
|
25
26
|
export function getEntryBySlug<
|
|
26
27
|
C extends keyof ContentEntryMap,
|
|
27
28
|
E extends ValidContentEntrySlug<C> | (string & {}),
|
|
28
29
|
>(
|
|
29
30
|
collection: C,
|
|
30
31
|
// Note that this has to accept a regular string too, for SSR
|
|
31
|
-
entrySlug: E
|
|
32
|
+
entrySlug: E,
|
|
32
33
|
): E extends ValidContentEntrySlug<C>
|
|
33
34
|
? Promise<CollectionEntry<C>>
|
|
34
35
|
: Promise<CollectionEntry<C> | undefined>;
|
|
35
36
|
|
|
37
|
+
/** @deprecated Use `getEntry` instead. */
|
|
36
38
|
export function getDataEntryById<C extends keyof DataEntryMap, E extends keyof DataEntryMap[C]>(
|
|
37
39
|
collection: C,
|
|
38
|
-
entryId: E
|
|
40
|
+
entryId: E,
|
|
39
41
|
): Promise<CollectionEntry<C>>;
|
|
40
42
|
|
|
41
43
|
export function getCollection<C extends keyof AnyEntryMap, E extends CollectionEntry<C>>(
|
|
42
44
|
collection: C,
|
|
43
|
-
filter?: (entry: CollectionEntry<C>) => entry is E
|
|
45
|
+
filter?: (entry: CollectionEntry<C>) => entry is E,
|
|
44
46
|
): Promise<E[]>;
|
|
45
47
|
export function getCollection<C extends keyof AnyEntryMap>(
|
|
46
48
|
collection: C,
|
|
47
|
-
filter?: (entry: CollectionEntry<C>) => unknown
|
|
49
|
+
filter?: (entry: CollectionEntry<C>) => unknown,
|
|
48
50
|
): Promise<CollectionEntry<C>[]>;
|
|
49
51
|
|
|
50
52
|
export function getEntry<
|
|
@@ -70,7 +72,7 @@ declare module 'astro:content' {
|
|
|
70
72
|
E extends ValidContentEntrySlug<C> | (string & {}),
|
|
71
73
|
>(
|
|
72
74
|
collection: C,
|
|
73
|
-
slug: E
|
|
75
|
+
slug: E,
|
|
74
76
|
): E extends ValidContentEntrySlug<C>
|
|
75
77
|
? Promise<CollectionEntry<C>>
|
|
76
78
|
: Promise<CollectionEntry<C> | undefined>;
|
|
@@ -79,7 +81,7 @@ declare module 'astro:content' {
|
|
|
79
81
|
E extends keyof DataEntryMap[C] | (string & {}),
|
|
80
82
|
>(
|
|
81
83
|
collection: C,
|
|
82
|
-
id: E
|
|
84
|
+
id: E,
|
|
83
85
|
): E extends keyof DataEntryMap[C]
|
|
84
86
|
? Promise<DataEntryMap[C][E]>
|
|
85
87
|
: Promise<CollectionEntry<C> | undefined>;
|
|
@@ -89,17 +91,17 @@ declare module 'astro:content' {
|
|
|
89
91
|
entries: {
|
|
90
92
|
collection: C;
|
|
91
93
|
slug: ValidContentEntrySlug<C>;
|
|
92
|
-
}[]
|
|
94
|
+
}[],
|
|
93
95
|
): Promise<CollectionEntry<C>[]>;
|
|
94
96
|
export function getEntries<C extends keyof DataEntryMap>(
|
|
95
97
|
entries: {
|
|
96
98
|
collection: C;
|
|
97
99
|
id: keyof DataEntryMap[C];
|
|
98
|
-
}[]
|
|
100
|
+
}[],
|
|
99
101
|
): Promise<CollectionEntry<C>[]>;
|
|
100
102
|
|
|
101
103
|
export function reference<C extends keyof AnyEntryMap>(
|
|
102
|
-
collection: C
|
|
104
|
+
collection: C,
|
|
103
105
|
): import('astro/zod').ZodEffects<
|
|
104
106
|
import('astro/zod').ZodString,
|
|
105
107
|
C extends keyof ContentEntryMap
|
|
@@ -116,7 +118,7 @@ declare module 'astro:content' {
|
|
|
116
118
|
// if `dev` is not running to update as you edit.
|
|
117
119
|
// Invalid collection names will be caught at build time.
|
|
118
120
|
export function reference<C extends string>(
|
|
119
|
-
collection: C
|
|
121
|
+
collection: C,
|
|
120
122
|
): import('astro/zod').ZodEffects<import('astro/zod').ZodString, never>;
|
|
121
123
|
|
|
122
124
|
type ReturnTypeOrOriginal<T> = T extends (...args: any[]) => infer R ? R : T;
|
package/types/content.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ declare module 'astro:content' {
|
|
|
47
47
|
| DataCollectionConfig<S>;
|
|
48
48
|
|
|
49
49
|
export function defineCollection<S extends BaseSchema>(
|
|
50
|
-
input: CollectionConfig<S
|
|
50
|
+
input: CollectionConfig<S>,
|
|
51
51
|
): CollectionConfig<S>;
|
|
52
52
|
|
|
53
53
|
/** Run `astro sync` to generate high fidelity types */
|
|
@@ -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
|
-
};
|