astro 5.12.0 → 5.12.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/client.d.ts +5 -0
- package/components/Code.astro +3 -9
- package/dist/assets/runtime.js +4 -0
- package/dist/assets/types.d.ts +9 -9
- package/dist/assets/vite-plugin-assets.js +5 -2
- package/dist/cli/throw-and-exit.js +3 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/content/loaders/errors.js +3 -0
- package/dist/content/loaders/file.js +7 -0
- package/dist/content/runtime.d.ts +1 -0
- package/dist/content/runtime.js +10 -1
- package/dist/content/vite-plugin-content-virtual-mod.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +3 -4
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/routing/astro-designed-error-pages.js +1 -1
- package/dist/env/env-loader.js +9 -2
- package/dist/jsx-runtime/index.d.ts +1 -1
- package/dist/jsx-runtime/index.js +5 -2
- package/dist/types/public/common.d.ts +2 -0
- package/dist/types/public/config.d.ts +3 -1
- package/dist/virtual-modules/live-config.d.ts +12 -0
- package/dist/virtual-modules/live-config.js +37 -0
- package/package.json +3 -3
- package/templates/content/module.mjs +5 -1
package/client.d.ts
CHANGED
package/components/Code.astro
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { ThemePresets } from '@astrojs/markdown-remark';
|
|
3
|
-
import type {
|
|
4
|
-
BuiltinLanguage,
|
|
5
|
-
LanguageRegistration,
|
|
6
|
-
ShikiTransformer,
|
|
7
|
-
SpecialLanguage,
|
|
8
|
-
ThemeRegistration,
|
|
9
|
-
ThemeRegistrationRaw,
|
|
10
|
-
} from 'shiki';
|
|
3
|
+
import type { ShikiTransformer, ThemeRegistration, ThemeRegistrationRaw } from 'shiki';
|
|
11
4
|
import { bundledLanguages } from 'shiki/langs';
|
|
12
5
|
import { getCachedHighlighter } from '../dist/core/shiki.js';
|
|
6
|
+
import type { CodeLanguage } from '../dist/types/public';
|
|
13
7
|
import type { HTMLAttributes } from '../types';
|
|
14
8
|
|
|
15
9
|
interface Props extends Omit<HTMLAttributes<'pre'>, 'lang'> {
|
|
@@ -22,7 +16,7 @@ interface Props extends Omit<HTMLAttributes<'pre'>, 'lang'> {
|
|
|
22
16
|
*
|
|
23
17
|
* @default "plaintext"
|
|
24
18
|
*/
|
|
25
|
-
lang?:
|
|
19
|
+
lang?: CodeLanguage;
|
|
26
20
|
/**
|
|
27
21
|
* A metastring to pass to the highlighter.
|
|
28
22
|
* Allows passing information to transformers: https://shiki.style/guide/transformers#meta
|
package/dist/assets/runtime.js
CHANGED
|
@@ -15,6 +15,10 @@ function createSvgComponent({ meta, attributes, children }) {
|
|
|
15
15
|
value: (_, opts, inspect) => inspect(meta, opts)
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
+
Object.defineProperty(Component, "toJSON", {
|
|
19
|
+
value: () => meta,
|
|
20
|
+
enumerable: false
|
|
21
|
+
});
|
|
18
22
|
return Object.assign(Component, meta);
|
|
19
23
|
}
|
|
20
24
|
const ATTRS_TO_DROP = ["xmlns", "xmlns:xlink", "version"];
|
package/dist/assets/types.d.ts
CHANGED
|
@@ -136,6 +136,15 @@ type ImageSharedProps<T> = T & {
|
|
|
136
136
|
* ```
|
|
137
137
|
*/
|
|
138
138
|
quality?: ImageQuality;
|
|
139
|
+
/**
|
|
140
|
+
* If true, the image will be loaded with a higher priority. This can be useful for images that are visible above the fold. There should usually be only one image with `priority` set to `true` per page.
|
|
141
|
+
* All other images will be lazy-loaded according to when they are in the viewport.
|
|
142
|
+
* **Example**:
|
|
143
|
+
* ```astro
|
|
144
|
+
* <Image src={...} priority alt="..." />
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
priority?: boolean;
|
|
139
148
|
} & ({
|
|
140
149
|
/**
|
|
141
150
|
* The layout type for responsive images.
|
|
@@ -174,15 +183,6 @@ type ImageSharedProps<T> = T & {
|
|
|
174
183
|
* ```
|
|
175
184
|
*/
|
|
176
185
|
position?: string;
|
|
177
|
-
/**
|
|
178
|
-
* If true, the image will be loaded with a higher priority. This can be useful for images that are visible above the fold. There should usually be only one image with `priority` set to `true` per page.
|
|
179
|
-
* All other images will be lazy-loaded according to when they are in the viewport.
|
|
180
|
-
* **Example**:
|
|
181
|
-
* ```astro
|
|
182
|
-
* <Image src={...} priority alt="..." />
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
priority?: boolean;
|
|
186
186
|
/**
|
|
187
187
|
* A list of widths to generate images for. The value of this property will be used to assign the `srcset` property on the final `img` element.
|
|
188
188
|
*
|
|
@@ -79,9 +79,12 @@ function assets({ fs, settings, sync, logger }) {
|
|
|
79
79
|
config(_, env) {
|
|
80
80
|
isBuild = env.command === "build";
|
|
81
81
|
},
|
|
82
|
-
async resolveId(id) {
|
|
82
|
+
async resolveId(id, _importer, options) {
|
|
83
83
|
if (id === VIRTUAL_SERVICE_ID) {
|
|
84
|
-
|
|
84
|
+
if (options?.ssr) {
|
|
85
|
+
return await this.resolve(settings.config.image.service.entrypoint);
|
|
86
|
+
}
|
|
87
|
+
return await this.resolve("astro/assets/services/noop");
|
|
85
88
|
}
|
|
86
89
|
if (id === VIRTUAL_MODULE_ID) {
|
|
87
90
|
return resolvedVirtualModuleId;
|
|
@@ -5,7 +5,9 @@ import { debug } from "../core/logger/core.js";
|
|
|
5
5
|
import { formatErrorMessage } from "../core/messages.js";
|
|
6
6
|
import { eventError, telemetry } from "../events/index.js";
|
|
7
7
|
async function throwAndExit(cmd, err) {
|
|
8
|
-
if (isAstroConfigZodError(err))
|
|
8
|
+
if (isAstroConfigZodError(err)) {
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
9
11
|
let telemetryPromise;
|
|
10
12
|
let errorMessage;
|
|
11
13
|
function exitWithErrorMessage() {
|
|
@@ -164,7 +164,7 @@ ${contentConfig.error.message}`);
|
|
|
164
164
|
logger.info("Content config changed");
|
|
165
165
|
shouldClear = true;
|
|
166
166
|
}
|
|
167
|
-
if (previousAstroVersion && previousAstroVersion !== "5.12.
|
|
167
|
+
if (previousAstroVersion && previousAstroVersion !== "5.12.2") {
|
|
168
168
|
logger.info("Astro version changed");
|
|
169
169
|
shouldClear = true;
|
|
170
170
|
}
|
|
@@ -172,8 +172,8 @@ ${contentConfig.error.message}`);
|
|
|
172
172
|
logger.info("Clearing content store");
|
|
173
173
|
this.#store.clearAll();
|
|
174
174
|
}
|
|
175
|
-
if ("5.12.
|
|
176
|
-
await this.#store.metaStore().set("astro-version", "5.12.
|
|
175
|
+
if ("5.12.2") {
|
|
176
|
+
await this.#store.metaStore().set("astro-version", "5.12.2");
|
|
177
177
|
}
|
|
178
178
|
if (currentConfigDigest) {
|
|
179
179
|
await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -44,12 +44,19 @@ function file(fileName, options) {
|
|
|
44
44
|
}
|
|
45
45
|
logger.debug(`Found ${data.length} item array in ${fileName}`);
|
|
46
46
|
store.clear();
|
|
47
|
+
const idList = /* @__PURE__ */ new Set();
|
|
47
48
|
for (const rawItem of data) {
|
|
48
49
|
const id = (rawItem.id ?? rawItem.slug)?.toString();
|
|
49
50
|
if (!id) {
|
|
50
51
|
logger.error(`Item in ${fileName} is missing an id or slug field.`);
|
|
51
52
|
continue;
|
|
52
53
|
}
|
|
54
|
+
if (idList.has(id)) {
|
|
55
|
+
logger.warn(
|
|
56
|
+
`Duplicate id "${id}" found in ${fileName}. Later items with the same id will overwrite earlier ones.`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
idList.add(id);
|
|
53
60
|
const parsedData = await parseData({ id, data: rawItem, filePath });
|
|
54
61
|
store.set({ id, data: parsedData, filePath: normalizedFilePath });
|
|
55
62
|
}
|
|
@@ -139,3 +139,4 @@ export declare function createReference({ lookupMap }: {
|
|
|
139
139
|
collection: string;
|
|
140
140
|
}>;
|
|
141
141
|
export declare function defineCollection(config: any): import("./config.js").CollectionConfig<import("./config.js").BaseSchema>;
|
|
142
|
+
export declare function defineLiveCollection(): void;
|
package/dist/content/runtime.js
CHANGED
|
@@ -424,7 +424,7 @@ function createGetLiveCollection({
|
|
|
424
424
|
return {
|
|
425
425
|
error: new LiveCollectionError(
|
|
426
426
|
collection,
|
|
427
|
-
`Unexpected error loading collection ${collection}`,
|
|
427
|
+
`Unexpected error loading collection ${collection}${error instanceof Error ? `: ${error.message}` : ""}`,
|
|
428
428
|
error
|
|
429
429
|
)
|
|
430
430
|
};
|
|
@@ -700,6 +700,14 @@ function defineCollection(config) {
|
|
|
700
700
|
}
|
|
701
701
|
return defineCollectionOrig(config);
|
|
702
702
|
}
|
|
703
|
+
function defineLiveCollection() {
|
|
704
|
+
throw new AstroError({
|
|
705
|
+
...AstroErrorData.LiveContentConfigError,
|
|
706
|
+
message: AstroErrorData.LiveContentConfigError.message(
|
|
707
|
+
"Live collections must be defined in a `src/live.config.ts` file."
|
|
708
|
+
)
|
|
709
|
+
});
|
|
710
|
+
}
|
|
703
711
|
export {
|
|
704
712
|
LiveCollectionCacheHintError,
|
|
705
713
|
LiveCollectionError,
|
|
@@ -715,5 +723,6 @@ export {
|
|
|
715
723
|
createGetLiveEntry,
|
|
716
724
|
createReference,
|
|
717
725
|
defineCollection,
|
|
726
|
+
defineLiveCollection,
|
|
718
727
|
renderEntry
|
|
719
728
|
};
|
|
@@ -73,7 +73,7 @@ function astroContentVirtualModPlugin({
|
|
|
73
73
|
async resolveId(id, importer) {
|
|
74
74
|
if (id === VIRTUAL_MODULE_ID) {
|
|
75
75
|
if (liveConfig && importer && liveConfig === normalizePath(importer)) {
|
|
76
|
-
return this.resolve("astro/
|
|
76
|
+
return this.resolve("astro/virtual-modules/live-config", importer, {
|
|
77
77
|
skipSelf: true
|
|
78
78
|
});
|
|
79
79
|
}
|
package/dist/core/constants.js
CHANGED
package/dist/core/create-vite.js
CHANGED
|
@@ -85,8 +85,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
const srcDirPattern = convertPathToPattern(fileURLToPath(settings.config.srcDir));
|
|
88
|
-
const
|
|
89
|
-
const importMetaEnvLoader = createEnvLoader(
|
|
88
|
+
const envLoader = createEnvLoader(
|
|
90
89
|
mode,
|
|
91
90
|
settings.config,
|
|
92
91
|
settings.config.experimental.rawEnvValues
|
|
@@ -116,8 +115,8 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
|
|
116
115
|
// the build to run very slow as the filewatcher is triggered often.
|
|
117
116
|
command === "dev" && vitePluginAstroServer({ settings, logger, fs, routesList, manifest }),
|
|
118
117
|
// manifest is only required in dev mode, where it gets created before a Vite instance is created, and get passed to this function
|
|
119
|
-
importMetaEnv({ envLoader
|
|
120
|
-
astroEnv({ settings, sync, envLoader
|
|
118
|
+
importMetaEnv({ envLoader }),
|
|
119
|
+
astroEnv({ settings, sync, envLoader }),
|
|
121
120
|
markdownVitePlugin({ settings, logger }),
|
|
122
121
|
htmlVitePlugin(),
|
|
123
122
|
astroPostprocessVitePlugin(),
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
|
|
|
22
22
|
await telemetry.record([]);
|
|
23
23
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
24
24
|
const logger = restart.container.logger;
|
|
25
|
-
const currentVersion = "5.12.
|
|
25
|
+
const currentVersion = "5.12.2";
|
|
26
26
|
const isPrerelease = currentVersion.includes("-");
|
|
27
27
|
if (!isPrerelease) {
|
|
28
28
|
try {
|
package/dist/core/messages.js
CHANGED
|
@@ -37,7 +37,7 @@ function serverStart({
|
|
|
37
37
|
host,
|
|
38
38
|
base
|
|
39
39
|
}) {
|
|
40
|
-
const version = "5.12.
|
|
40
|
+
const version = "5.12.2";
|
|
41
41
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
42
42
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
43
43
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -274,7 +274,7 @@ function printHelp({
|
|
|
274
274
|
message.push(
|
|
275
275
|
linebreak(),
|
|
276
276
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
277
|
-
`v${"5.12.
|
|
277
|
+
`v${"5.12.2"}`
|
|
278
278
|
)} ${headline}`
|
|
279
279
|
);
|
|
280
280
|
}
|
package/dist/env/env-loader.js
CHANGED
|
@@ -27,11 +27,18 @@ function getPrivateEnv(fullEnv, astroConfig, useRawValues) {
|
|
|
27
27
|
}
|
|
28
28
|
return privateEnv;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
function getEnv(mode, config, useRawValues) {
|
|
31
31
|
const loaded = loadEnv(mode, config.vite.envDir ?? fileURLToPath(config.root), "");
|
|
32
32
|
const privateEnv = getPrivateEnv(loaded, config, useRawValues);
|
|
33
|
+
return { loaded, privateEnv };
|
|
34
|
+
}
|
|
35
|
+
const createEnvLoader = (mode, config, useRawValues) => {
|
|
36
|
+
let { loaded, privateEnv } = getEnv(mode, config, useRawValues);
|
|
33
37
|
return {
|
|
34
|
-
get: () =>
|
|
38
|
+
get: () => {
|
|
39
|
+
({ loaded, privateEnv } = getEnv(mode, config, useRawValues));
|
|
40
|
+
return loaded;
|
|
41
|
+
},
|
|
35
42
|
getPrivateEnv: () => privateEnv
|
|
36
43
|
};
|
|
37
44
|
};
|
|
@@ -8,5 +8,5 @@ export interface AstroVNode {
|
|
|
8
8
|
}
|
|
9
9
|
export declare function isVNode(vnode: any): vnode is AstroVNode;
|
|
10
10
|
export declare function transformSlots(vnode: AstroVNode): AstroVNode | undefined;
|
|
11
|
-
declare function createVNode(type: any, props
|
|
11
|
+
declare function createVNode(type: any, props?: Record<string, any>, key?: string | number): AstroVNode;
|
|
12
12
|
export { AstroJSX, Fragment, createVNode as jsx, createVNode as jsxDEV, createVNode as jsxs };
|
|
@@ -54,12 +54,15 @@ function transformSetDirectives(vnode) {
|
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
function createVNode(type, props) {
|
|
57
|
+
function createVNode(type, props = {}, key) {
|
|
58
|
+
if (key) {
|
|
59
|
+
props.key = key;
|
|
60
|
+
}
|
|
58
61
|
const vnode = {
|
|
59
62
|
[Renderer]: "astro:jsx",
|
|
60
63
|
[AstroJSX]: true,
|
|
61
64
|
type,
|
|
62
|
-
props
|
|
65
|
+
props
|
|
63
66
|
};
|
|
64
67
|
transformSetDirectives(vnode);
|
|
65
68
|
transformSlots(vnode);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BundledLanguage, LanguageRegistration, SpecialLanguage } from 'shiki';
|
|
1
2
|
import type { OmitIndexSignature, Simplify } from '../../type-utils.js';
|
|
2
3
|
import type { APIContext } from './context.js';
|
|
3
4
|
/**
|
|
@@ -136,3 +137,4 @@ export type InferGetStaticPropsType<T> = T extends (opts: GetStaticPathsOptions)
|
|
|
136
137
|
} ? P : never : never : never;
|
|
137
138
|
export type Params = Record<string, string | undefined>;
|
|
138
139
|
export type Props = Record<string, unknown>;
|
|
140
|
+
export type CodeLanguage = BundledLanguage | LanguageRegistration | SpecialLanguage;
|
|
@@ -132,7 +132,9 @@ interface TestSessionConfig extends CommonSessionConfig {
|
|
|
132
132
|
mockStorage: Storage;
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
|
-
export type SessionConfig<TDriver extends SessionDriverName> =
|
|
135
|
+
export type SessionConfig<TDriver extends SessionDriverName> = [
|
|
136
|
+
TDriver
|
|
137
|
+
] extends [never] ? CustomSessionConfig : TDriver extends keyof BuiltinDriverOptions ? BuiltinSessionConfig<TDriver> : TDriver extends 'test' ? TestSessionConfig : CustomSessionConfig;
|
|
136
138
|
export type ResolvedSessionConfig<TDriver extends SessionDriverName> = SessionConfig<TDriver> & {
|
|
137
139
|
driverModule?: () => Promise<{
|
|
138
140
|
default: () => Driver;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * as z from 'zod';
|
|
2
|
+
export { defineLiveCollection } from '../content/config.js';
|
|
3
|
+
export declare const getCollection: () => never;
|
|
4
|
+
export declare const render: () => never;
|
|
5
|
+
export declare const getEntry: () => never;
|
|
6
|
+
export declare const getEntryBySlug: () => never;
|
|
7
|
+
export declare const getDataEntryById: () => never;
|
|
8
|
+
export declare const getEntries: () => never;
|
|
9
|
+
export declare const reference: () => never;
|
|
10
|
+
export declare const getLiveCollection: () => never;
|
|
11
|
+
export declare const getLiveEntry: () => never;
|
|
12
|
+
export declare const defineCollection: () => never;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { defineLiveCollection } from "../content/config.js";
|
|
3
|
+
function createErrorFunction(message) {
|
|
4
|
+
return () => {
|
|
5
|
+
const error = new Error(`The ${message}() function is not available in live config files.`);
|
|
6
|
+
const stackLines = error.stack?.split("\n");
|
|
7
|
+
if (stackLines && stackLines.length > 1) {
|
|
8
|
+
stackLines.splice(1, 1);
|
|
9
|
+
error.stack = stackLines.join("\n");
|
|
10
|
+
}
|
|
11
|
+
throw error;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const getCollection = createErrorFunction("getCollection");
|
|
15
|
+
const render = createErrorFunction("render");
|
|
16
|
+
const getEntry = createErrorFunction("getEntry");
|
|
17
|
+
const getEntryBySlug = createErrorFunction("getEntryBySlug");
|
|
18
|
+
const getDataEntryById = createErrorFunction("getDataEntryById");
|
|
19
|
+
const getEntries = createErrorFunction("getEntries");
|
|
20
|
+
const reference = createErrorFunction("reference");
|
|
21
|
+
const getLiveCollection = createErrorFunction("getLiveCollection");
|
|
22
|
+
const getLiveEntry = createErrorFunction("getLiveEntry");
|
|
23
|
+
const defineCollection = createErrorFunction("defineCollection");
|
|
24
|
+
export {
|
|
25
|
+
defineCollection,
|
|
26
|
+
defineLiveCollection,
|
|
27
|
+
getCollection,
|
|
28
|
+
getDataEntryById,
|
|
29
|
+
getEntries,
|
|
30
|
+
getEntry,
|
|
31
|
+
getEntryBySlug,
|
|
32
|
+
getLiveCollection,
|
|
33
|
+
getLiveEntry,
|
|
34
|
+
reference,
|
|
35
|
+
render,
|
|
36
|
+
z
|
|
37
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.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",
|
|
@@ -158,9 +158,9 @@
|
|
|
158
158
|
"zod": "^3.24.2",
|
|
159
159
|
"zod-to-json-schema": "^3.24.5",
|
|
160
160
|
"zod-to-ts": "^1.2.0",
|
|
161
|
-
"@astrojs/
|
|
161
|
+
"@astrojs/internal-helpers": "0.6.1",
|
|
162
162
|
"@astrojs/telemetry": "3.3.0",
|
|
163
|
-
"@astrojs/
|
|
163
|
+
"@astrojs/markdown-remark": "6.3.3"
|
|
164
164
|
},
|
|
165
165
|
"optionalDependencies": {
|
|
166
166
|
"sharp": "^0.33.3"
|
|
@@ -11,7 +11,11 @@ import {
|
|
|
11
11
|
createReference,
|
|
12
12
|
} from 'astro/content/runtime';
|
|
13
13
|
|
|
14
|
-
export {
|
|
14
|
+
export {
|
|
15
|
+
defineCollection,
|
|
16
|
+
defineLiveCollection,
|
|
17
|
+
renderEntry as render,
|
|
18
|
+
} from 'astro/content/runtime';
|
|
15
19
|
export { z } from 'astro/zod';
|
|
16
20
|
|
|
17
21
|
/* @@LIVE_CONTENT_CONFIG@@ */
|