astro 4.13.1 → 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/actions/runtime/middleware.d.ts +3 -4
- package/dist/actions/runtime/middleware.js +20 -64
- package/dist/actions/runtime/route.js +12 -19
- package/dist/actions/runtime/utils.d.ts +0 -8
- package/dist/actions/runtime/utils.js +0 -15
- 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/shared.d.ts +18 -1
- package/dist/actions/runtime/virtual/shared.js +56 -8
- package/dist/actions/utils.d.ts +2 -1
- package/dist/actions/utils.js +10 -17
- 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/info/index.js +2 -2
- package/dist/cli/install-package.js +2 -2
- 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.js +3 -3
- package/dist/core/build/index.js +7 -1
- package/dist/core/build/plugins/plugin-css.js +2 -2
- 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/errors/dev/vite.js +4 -4
- package/dist/core/errors/errors-data.d.ts +5 -0
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/index.js +1 -1
- package/dist/core/render-context.js +7 -4
- package/dist/core/routing/manifest/create.js +2 -2
- package/dist/events/error.js +1 -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.js +1 -3
- package/dist/transitions/router.js +2 -2
- package/dist/type-utils.d.ts +1 -1
- 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 -11
- package/templates/actions.mjs +23 -19
- package/templates/content/types.d.ts +12 -10
- package/types/content.d.ts +1 -1
|
@@ -78,7 +78,7 @@ function createContext({
|
|
|
78
78
|
};
|
|
79
79
|
return Object.assign(context, {
|
|
80
80
|
getActionResult: createGetActionResult(context.locals),
|
|
81
|
-
callAction: createCallAction(context
|
|
81
|
+
callAction: createCallAction(context)
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
function isLocalsSerializable(value) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { deserializeActionResult } from "../actions/runtime/virtual/shared.js";
|
|
1
2
|
import { createCallAction, createGetActionResult, hasActionsInternal } from "../actions/utils.js";
|
|
2
3
|
import {
|
|
3
4
|
computeCurrentLocale,
|
|
@@ -170,7 +171,7 @@ class RenderContext {
|
|
|
170
171
|
return Object.assign(context, {
|
|
171
172
|
props,
|
|
172
173
|
getActionResult: createGetActionResult(context.locals),
|
|
173
|
-
callAction: createCallAction(context
|
|
174
|
+
callAction: createCallAction(context)
|
|
174
175
|
});
|
|
175
176
|
}
|
|
176
177
|
async #executeRewrite(reroutePayload) {
|
|
@@ -255,7 +256,7 @@ class RenderContext {
|
|
|
255
256
|
throw new AstroError(AstroErrorData.AstroResponseHeadersReassigned);
|
|
256
257
|
}
|
|
257
258
|
};
|
|
258
|
-
const actionResult = hasActionsInternal(this.locals) ? this.locals._actionsInternal
|
|
259
|
+
const actionResult = hasActionsInternal(this.locals) ? deserializeActionResult(this.locals._actionsInternal.actionResult) : void 0;
|
|
259
260
|
const result = {
|
|
260
261
|
base: manifest.base,
|
|
261
262
|
cancelled: false,
|
|
@@ -370,10 +371,12 @@ class RenderContext {
|
|
|
370
371
|
redirect,
|
|
371
372
|
rewrite,
|
|
372
373
|
request: this.request,
|
|
373
|
-
getActionResult: createGetActionResult(locals),
|
|
374
|
-
callAction: createCallAction(locals),
|
|
375
374
|
response,
|
|
376
375
|
site: pipeline.site,
|
|
376
|
+
getActionResult: createGetActionResult(locals),
|
|
377
|
+
get callAction() {
|
|
378
|
+
return createCallAction(this);
|
|
379
|
+
},
|
|
377
380
|
url
|
|
378
381
|
};
|
|
379
382
|
}
|
|
@@ -42,7 +42,7 @@ function getParts(part, file) {
|
|
|
42
42
|
}
|
|
43
43
|
function validateSegment(segment, file = "") {
|
|
44
44
|
if (!file) file = segment;
|
|
45
|
-
if (
|
|
45
|
+
if (segment.includes("][")) {
|
|
46
46
|
throw new Error(`Invalid route ${file} \u2014 parameters must be separated`);
|
|
47
47
|
}
|
|
48
48
|
if (countOccurrences("[", segment) !== countOccurrences("]", segment)) {
|
|
@@ -198,7 +198,7 @@ function createInjectedRoutes({ settings, cwd }) {
|
|
|
198
198
|
let resolved;
|
|
199
199
|
try {
|
|
200
200
|
resolved = require2.resolve(entrypoint, { paths: [cwd || fileURLToPath(config.root)] });
|
|
201
|
-
} catch
|
|
201
|
+
} catch {
|
|
202
202
|
resolved = fileURLToPath(new URL(entrypoint, config.root));
|
|
203
203
|
}
|
|
204
204
|
const component = slash(path.relative(cwd || fileURLToPath(config.root), resolved));
|
package/dist/events/error.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
|
2
2
|
const EVENT_ERROR = "ASTRO_CLI_ERROR";
|
|
3
3
|
const ANONYMIZE_MESSAGE_REGEX = /^(?:\w| )+/;
|
|
4
4
|
function anonymizeErrorMessage(msg) {
|
|
5
|
-
const matchedMessage =
|
|
5
|
+
const matchedMessage = ANONYMIZE_MESSAGE_REGEX.exec(msg);
|
|
6
6
|
if (!matchedMessage?.[0]) {
|
|
7
7
|
return void 0;
|
|
8
8
|
}
|
|
@@ -9,7 +9,7 @@ const icon = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 1 2
|
|
|
9
9
|
try {
|
|
10
10
|
customElements.define("astro-dev-toolbar-audit-window", DevToolbarAuditListWindow);
|
|
11
11
|
customElements.define("astro-dev-toolbar-audit-list-item", DevToolbarAuditListItem);
|
|
12
|
-
} catch
|
|
12
|
+
} catch {
|
|
13
13
|
}
|
|
14
14
|
let showState = false;
|
|
15
15
|
var audit_default = {
|
|
@@ -23,7 +23,8 @@ const perf = [
|
|
|
23
23
|
selector: 'img:not([loading]), img[loading="eager"], iframe:not([loading]), iframe[loading="eager"]',
|
|
24
24
|
match(element) {
|
|
25
25
|
const htmlElement = element;
|
|
26
|
-
|
|
26
|
+
const elementYPosition = htmlElement.getBoundingClientRect().y + window.scrollY;
|
|
27
|
+
if (elementYPosition < window.innerHeight) return false;
|
|
27
28
|
if (htmlElement.src.startsWith("data:")) return false;
|
|
28
29
|
return true;
|
|
29
30
|
}
|
|
@@ -35,7 +36,8 @@ const perf = [
|
|
|
35
36
|
selector: 'img[loading="lazy"], iframe[loading="lazy"]',
|
|
36
37
|
match(element) {
|
|
37
38
|
const htmlElement = element;
|
|
38
|
-
|
|
39
|
+
const elementYPosition = htmlElement.getBoundingClientRect().y + window.scrollY;
|
|
40
|
+
if (elementYPosition > window.innerHeight) return false;
|
|
39
41
|
if (htmlElement.src.startsWith("data:")) return false;
|
|
40
42
|
return true;
|
|
41
43
|
}
|
|
@@ -136,9 +136,7 @@ Did you forget to import the component or is it possible there is a typo?`
|
|
|
136
136
|
}
|
|
137
137
|
if (!renderer) {
|
|
138
138
|
const extname = metadata.componentUrl?.split(".").pop();
|
|
139
|
-
renderer = renderers.
|
|
140
|
-
({ name }) => name === `@astrojs/${extname}` || name === extname
|
|
141
|
-
)[0];
|
|
139
|
+
renderer = renderers.find(({ name }) => name === `@astrojs/${extname}` || name === extname);
|
|
142
140
|
}
|
|
143
141
|
}
|
|
144
142
|
let componentServerRenderEndTime;
|
|
@@ -62,7 +62,7 @@ async function fetchHTML(href, init) {
|
|
|
62
62
|
redirected: res.redirected ? res.url : void 0,
|
|
63
63
|
mediaType
|
|
64
64
|
};
|
|
65
|
-
} catch
|
|
65
|
+
} catch {
|
|
66
66
|
return null;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -189,7 +189,7 @@ async function updateDOM(preparationEvent, options, currentTransition, historySt
|
|
|
189
189
|
if (fallback === "animate" && !currentTransition.transitionSkipped && !preparationEvent.signal.aborted) {
|
|
190
190
|
try {
|
|
191
191
|
await animate("old");
|
|
192
|
-
} catch
|
|
192
|
+
} catch {
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
const pageTitleForBrowserHistory = document.title;
|
package/dist/type-utils.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type WithRequired<T, K extends keyof T> = T & {
|
|
|
5
5
|
[P in K]-?: T[P];
|
|
6
6
|
};
|
|
7
7
|
export type OmitIndexSignature<ObjectType> = {
|
|
8
|
-
[KeyType in keyof ObjectType as
|
|
8
|
+
[KeyType in keyof ObjectType as object extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType];
|
|
9
9
|
};
|
|
10
10
|
export type Kebab<T extends string, A extends string = ''> = T extends `${infer F}${infer R}` ? Kebab<R, `${A}${F extends Lowercase<F> ? '' : '-'}${Lowercase<F>}`> : A;
|
|
11
11
|
export type KebabKeys<T> = {
|
|
@@ -5,7 +5,6 @@ import { hasSpecialQueries } from "../vite-plugin-utils/index.js";
|
|
|
5
5
|
import { isCSSRequest } from "./util.js";
|
|
6
6
|
const fileExtensionsToSSR = /* @__PURE__ */ new Set([".astro", ".mdoc", ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS]);
|
|
7
7
|
const STRIP_QUERY_PARAMS_REGEX = /\?.*$/;
|
|
8
|
-
const ASTRO_PROPAGATED_ASSET_REGEX = /\?astroPropagatedAssets/;
|
|
9
8
|
async function* crawlGraph(loader, _id, isRootFile, scanned = /* @__PURE__ */ new Set()) {
|
|
10
9
|
const id = unwrapId(_id);
|
|
11
10
|
const importedModules = /* @__PURE__ */ new Set();
|
|
@@ -35,7 +34,7 @@ async function* crawlGraph(loader, _id, isRootFile, scanned = /* @__PURE__ */ ne
|
|
|
35
34
|
if (!importedModule.id) continue;
|
|
36
35
|
const importedModulePathname = importedModule.id.replace(STRIP_QUERY_PARAMS_REGEX, "");
|
|
37
36
|
const isFileTypeNeedingSSR = fileExtensionsToSSR.has(npath.extname(importedModulePathname));
|
|
38
|
-
const isPropagationStoppingPoint =
|
|
37
|
+
const isPropagationStoppingPoint = importedModule.id.includes("?astroPropagatedAssets");
|
|
39
38
|
if (isFileTypeNeedingSSR && // Should not SSR a module with ?astroPropagatedAssets
|
|
40
39
|
!isPropagationStoppingPoint) {
|
|
41
40
|
const mod = loader.getModuleById(importedModule.id);
|
|
@@ -50,7 +50,6 @@ async function replaceDefine(code, id, define, config) {
|
|
|
50
50
|
if (env) {
|
|
51
51
|
const marker = `__astro_import_meta_env${"_".repeat(
|
|
52
52
|
env.length - 23
|
|
53
|
-
/* length of preceding string */
|
|
54
53
|
)}`;
|
|
55
54
|
replacementMarkers[marker] = env;
|
|
56
55
|
define = { ...define, "import.meta.env": marker };
|
|
@@ -12,14 +12,14 @@ function loadFallbackPlugin({
|
|
|
12
12
|
const tryLoadModule = async (id) => {
|
|
13
13
|
try {
|
|
14
14
|
return await fs.promises.readFile(cleanUrl(id), "utf-8");
|
|
15
|
-
} catch
|
|
15
|
+
} catch {
|
|
16
16
|
try {
|
|
17
17
|
return await fs.promises.readFile(id, "utf-8");
|
|
18
|
-
} catch
|
|
18
|
+
} catch {
|
|
19
19
|
try {
|
|
20
20
|
const fullpath = new URL("." + id, root);
|
|
21
21
|
return await fs.promises.readFile(fullpath, "utf-8");
|
|
22
|
-
} catch
|
|
22
|
+
} catch {
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
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",
|
|
@@ -156,7 +153,7 @@
|
|
|
156
153
|
"prompts": "^2.4.2",
|
|
157
154
|
"rehype": "^13.0.1",
|
|
158
155
|
"semver": "^7.6.3",
|
|
159
|
-
"shiki": "^1.12.
|
|
156
|
+
"shiki": "^1.12.1",
|
|
160
157
|
"string-width": "^7.2.0",
|
|
161
158
|
"strip-ansi": "^7.1.0",
|
|
162
159
|
"tsconfck": "^3.1.1",
|
|
@@ -169,14 +166,14 @@
|
|
|
169
166
|
"zod": "^3.23.8",
|
|
170
167
|
"zod-to-json-schema": "^3.23.2",
|
|
171
168
|
"@astrojs/internal-helpers": "0.4.1",
|
|
172
|
-
"@astrojs/
|
|
173
|
-
"@astrojs/
|
|
169
|
+
"@astrojs/telemetry": "3.1.0",
|
|
170
|
+
"@astrojs/markdown-remark": "5.2.0"
|
|
174
171
|
},
|
|
175
172
|
"optionalDependencies": {
|
|
176
173
|
"sharp": "^0.33.3"
|
|
177
174
|
},
|
|
178
175
|
"devDependencies": {
|
|
179
|
-
"@astrojs/check": "^0.9.
|
|
176
|
+
"@astrojs/check": "^0.9.1",
|
|
180
177
|
"@playwright/test": "^1.45.3",
|
|
181
178
|
"@types/aria-query": "^5.0.4",
|
|
182
179
|
"@types/babel__generator": "^7.6.8",
|
|
@@ -199,14 +196,14 @@
|
|
|
199
196
|
"expect-type": "^0.19.0",
|
|
200
197
|
"mdast-util-mdx": "^3.0.0",
|
|
201
198
|
"mdast-util-mdx-jsx": "^3.1.2",
|
|
202
|
-
"memfs": "^4.11.
|
|
199
|
+
"memfs": "^4.11.1",
|
|
203
200
|
"node-mocks-http": "^1.15.1",
|
|
204
201
|
"parse-srcset": "^1.0.2",
|
|
205
202
|
"rehype-autolink-headings": "^7.1.0",
|
|
206
203
|
"rehype-slug": "^6.0.0",
|
|
207
204
|
"rehype-toc": "^3.0.2",
|
|
208
205
|
"remark-code-titles": "^0.1.2",
|
|
209
|
-
"rollup": "^4.
|
|
206
|
+
"rollup": "^4.20.0",
|
|
210
207
|
"sass": "^1.77.8",
|
|
211
208
|
"undici": "^6.19.5",
|
|
212
209
|
"unified": "^11.0.5",
|
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, {
|
|
@@ -8,7 +8,7 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '') {
|
|
|
8
8
|
}
|
|
9
9
|
const path = aggregatedPath + objKey.toString();
|
|
10
10
|
function action(param) {
|
|
11
|
-
return
|
|
11
|
+
return handleAction(param, path, this);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
Object.assign(action, {
|
|
@@ -28,8 +28,10 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '') {
|
|
|
28
28
|
// Note: `orThrow` does not have progressive enhancement info.
|
|
29
29
|
// If you want to throw exceptions,
|
|
30
30
|
// you must handle those exceptions with client JS.
|
|
31
|
-
orThrow(param) {
|
|
32
|
-
|
|
31
|
+
async orThrow(param) {
|
|
32
|
+
const { data, error } = await handleAction(param, path, this);
|
|
33
|
+
if (error) throw error;
|
|
34
|
+
return data;
|
|
33
35
|
},
|
|
34
36
|
});
|
|
35
37
|
|
|
@@ -43,17 +45,18 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '') {
|
|
|
43
45
|
/**
|
|
44
46
|
* @param {*} param argument passed to the action when called server or client-side.
|
|
45
47
|
* @param {string} path Built path to call action by path name.
|
|
46
|
-
* @param {import('../
|
|
48
|
+
* @param {import('../dist/@types/astro.d.ts').APIContext | undefined} context Injected API context when calling actions from the server.
|
|
47
49
|
* Usage: `actions.[name](param)`.
|
|
50
|
+
* @returns {Promise<import('../dist/actions/runtime/virtual/shared.js').SafeResult<any, any>>}
|
|
48
51
|
*/
|
|
49
|
-
async function
|
|
52
|
+
async function handleAction(param, path, context) {
|
|
50
53
|
// When running server-side, import the action and call it.
|
|
51
54
|
if (import.meta.env.SSR) {
|
|
52
|
-
const { getAction } = await import('astro/actions/runtime/
|
|
55
|
+
const { getAction } = await import('astro/actions/runtime/virtual/get-action.js');
|
|
53
56
|
const action = await getAction(path);
|
|
54
57
|
if (!action) throw new Error(`Action not found: ${path}`);
|
|
55
58
|
|
|
56
|
-
return action.
|
|
59
|
+
return action.bind(context)(param);
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
// When running client-side, make a fetch request to the action path.
|
|
@@ -62,29 +65,30 @@ async function handleActionOrThrow(param, path, context) {
|
|
|
62
65
|
let body = param;
|
|
63
66
|
if (!(body instanceof FormData)) {
|
|
64
67
|
try {
|
|
65
|
-
body =
|
|
68
|
+
body = JSON.stringify(param);
|
|
66
69
|
} catch (e) {
|
|
67
70
|
throw new ActionError({
|
|
68
71
|
code: 'BAD_REQUEST',
|
|
69
72
|
message: `Failed to serialize request body to JSON. Full error: ${e.message}`,
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
if (body) {
|
|
76
|
+
headers.set('Content-Type', 'application/json');
|
|
77
|
+
} else {
|
|
78
|
+
headers.set('Content-Length', '0');
|
|
79
|
+
}
|
|
74
80
|
}
|
|
75
|
-
const
|
|
81
|
+
const rawResult = await fetch(`/_actions/${path}`, {
|
|
76
82
|
method: 'POST',
|
|
77
83
|
body,
|
|
78
84
|
headers,
|
|
79
85
|
});
|
|
80
|
-
if (
|
|
81
|
-
throw await ActionError.fromResponse(res);
|
|
82
|
-
}
|
|
83
|
-
// Check if response body is empty before parsing.
|
|
84
|
-
if (res.status === 204) return;
|
|
86
|
+
if (rawResult.status === 204) return;
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
return deserializeActionResult({
|
|
89
|
+
type: rawResult.ok ? 'data' : 'error',
|
|
90
|
+
body: await rawResult.text(),
|
|
91
|
+
});
|
|
88
92
|
}
|
|
89
93
|
|
|
90
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 */
|