astro 5.11.2 → 5.12.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/assets/types.d.ts +9 -9
- package/dist/assets/vite-plugin-assets.js +5 -2
- package/dist/content/content-layer.js +3 -3
- package/dist/content/loaders/errors.js +3 -0
- package/dist/content/loaders/file.js +3 -0
- package/dist/content/runtime.js +1 -1
- package/dist/content/vite-plugin-content-virtual-mod.js +1 -1
- package/dist/core/config/schemas/base.d.ts +6 -0
- package/dist/core/config/schemas/base.js +4 -2
- package/dist/core/config/schemas/relative.d.ts +7 -0
- package/dist/core/config/settings.js +32 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +5 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +2 -2
- package/dist/core/errors/errors-data.js +1 -1
- package/dist/core/errors/utils.d.ts +4 -0
- package/dist/core/errors/utils.js +14 -0
- package/dist/core/messages.js +2 -2
- package/dist/core/routing/astro-designed-error-pages.js +1 -1
- package/dist/env/env-loader.d.ts +1 -1
- package/dist/env/env-loader.js +12 -5
- package/dist/types/public/config.d.ts +21 -1
- package/dist/virtual-modules/live-config.d.ts +12 -0
- package/dist/virtual-modules/live-config.js +37 -0
- package/package.json +4 -3
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;
|
|
@@ -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.
|
|
167
|
+
if (previousAstroVersion && previousAstroVersion !== "5.12.1") {
|
|
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.
|
|
176
|
-
await this.#store.metaStore().set("astro-version", "5.
|
|
175
|
+
if ("5.12.1") {
|
|
176
|
+
await this.#store.metaStore().set("astro-version", "5.12.1");
|
|
177
177
|
}
|
|
178
178
|
if (currentConfigDigest) {
|
|
179
179
|
await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, promises as fs } from "node:fs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import yaml from "js-yaml";
|
|
4
|
+
import toml from "smol-toml";
|
|
4
5
|
import { FileGlobNotSupported, FileParserNotFound } from "../../core/errors/errors-data.js";
|
|
5
6
|
import { AstroError } from "../../core/errors/index.js";
|
|
6
7
|
import { posixRelative } from "../utils.js";
|
|
@@ -16,6 +17,8 @@ function file(fileName, options) {
|
|
|
16
17
|
parse = (text) => yaml.load(text, {
|
|
17
18
|
filename: fileName
|
|
18
19
|
});
|
|
20
|
+
} else if (ext === "toml") {
|
|
21
|
+
parse = toml.parse;
|
|
19
22
|
}
|
|
20
23
|
if (options?.parser) parse = options.parser;
|
|
21
24
|
if (parse === null) {
|
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
|
};
|
|
@@ -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
|
}
|
|
@@ -75,6 +75,7 @@ export declare const ASTRO_CONFIG_DEFAULTS: {
|
|
|
75
75
|
preserveScriptOrder: false;
|
|
76
76
|
liveContentCollections: false;
|
|
77
77
|
csp: false;
|
|
78
|
+
rawEnvValues: false;
|
|
78
79
|
};
|
|
79
80
|
};
|
|
80
81
|
export declare const AstroConfigSchema: z.ZodObject<{
|
|
@@ -975,6 +976,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
975
976
|
strictDynamic?: boolean | undefined;
|
|
976
977
|
} | undefined;
|
|
977
978
|
}>]>>>;
|
|
979
|
+
rawEnvValues: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
978
980
|
}, "strict", z.ZodTypeAny, {
|
|
979
981
|
clientPrerender: boolean;
|
|
980
982
|
contentIntellisense: boolean;
|
|
@@ -994,6 +996,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
994
996
|
strictDynamic?: boolean | undefined;
|
|
995
997
|
} | undefined;
|
|
996
998
|
};
|
|
999
|
+
rawEnvValues: boolean;
|
|
997
1000
|
fonts?: ({
|
|
998
1001
|
name: string;
|
|
999
1002
|
cssVariable: string;
|
|
@@ -1123,6 +1126,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
1123
1126
|
strictDynamic?: boolean | undefined;
|
|
1124
1127
|
} | undefined;
|
|
1125
1128
|
} | undefined;
|
|
1129
|
+
rawEnvValues?: boolean | undefined;
|
|
1126
1130
|
}>>;
|
|
1127
1131
|
legacy: z.ZodDefault<z.ZodObject<{
|
|
1128
1132
|
collections: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -1282,6 +1286,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
1282
1286
|
strictDynamic?: boolean | undefined;
|
|
1283
1287
|
} | undefined;
|
|
1284
1288
|
};
|
|
1289
|
+
rawEnvValues: boolean;
|
|
1285
1290
|
fonts?: ({
|
|
1286
1291
|
name: string;
|
|
1287
1292
|
cssVariable: string;
|
|
@@ -1610,6 +1615,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
1610
1615
|
strictDynamic?: boolean | undefined;
|
|
1611
1616
|
} | undefined;
|
|
1612
1617
|
} | undefined;
|
|
1618
|
+
rawEnvValues?: boolean | undefined;
|
|
1613
1619
|
} | undefined;
|
|
1614
1620
|
legacy?: {
|
|
1615
1621
|
collections?: boolean | undefined;
|
|
@@ -58,7 +58,8 @@ const ASTRO_CONFIG_DEFAULTS = {
|
|
|
58
58
|
headingIdCompat: false,
|
|
59
59
|
preserveScriptOrder: false,
|
|
60
60
|
liveContentCollections: false,
|
|
61
|
-
csp: false
|
|
61
|
+
csp: false,
|
|
62
|
+
rawEnvValues: false
|
|
62
63
|
}
|
|
63
64
|
};
|
|
64
65
|
const highlighterTypesSchema = z.union([z.literal("shiki"), z.literal("prism")]).default(syntaxHighlightDefaults.type);
|
|
@@ -283,7 +284,8 @@ const AstroConfigSchema = z.object({
|
|
|
283
284
|
strictDynamic: z.boolean().optional()
|
|
284
285
|
}).optional()
|
|
285
286
|
})
|
|
286
|
-
]).optional().default(ASTRO_CONFIG_DEFAULTS.experimental.csp)
|
|
287
|
+
]).optional().default(ASTRO_CONFIG_DEFAULTS.experimental.csp),
|
|
288
|
+
rawEnvValues: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.rawEnvValues)
|
|
287
289
|
}).strict(
|
|
288
290
|
`Invalid or outdated experimental feature.
|
|
289
291
|
Check for incorrect spelling or outdated Astro version.
|
|
@@ -898,6 +898,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
898
898
|
strictDynamic?: boolean | undefined;
|
|
899
899
|
} | undefined;
|
|
900
900
|
}>]>>>;
|
|
901
|
+
rawEnvValues: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
901
902
|
}, "strict", z.ZodTypeAny, {
|
|
902
903
|
clientPrerender: boolean;
|
|
903
904
|
contentIntellisense: boolean;
|
|
@@ -917,6 +918,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
917
918
|
strictDynamic?: boolean | undefined;
|
|
918
919
|
} | undefined;
|
|
919
920
|
};
|
|
921
|
+
rawEnvValues: boolean;
|
|
920
922
|
fonts?: ({
|
|
921
923
|
name: string;
|
|
922
924
|
cssVariable: string;
|
|
@@ -1046,6 +1048,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1046
1048
|
strictDynamic?: boolean | undefined;
|
|
1047
1049
|
} | undefined;
|
|
1048
1050
|
} | undefined;
|
|
1051
|
+
rawEnvValues?: boolean | undefined;
|
|
1049
1052
|
}>>;
|
|
1050
1053
|
legacy: z.ZodDefault<z.ZodObject<{
|
|
1051
1054
|
collections: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -1283,6 +1286,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1283
1286
|
strictDynamic?: boolean | undefined;
|
|
1284
1287
|
} | undefined;
|
|
1285
1288
|
};
|
|
1289
|
+
rawEnvValues: boolean;
|
|
1286
1290
|
fonts?: ({
|
|
1287
1291
|
name: string;
|
|
1288
1292
|
cssVariable: string;
|
|
@@ -1611,6 +1615,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1611
1615
|
strictDynamic?: boolean | undefined;
|
|
1612
1616
|
} | undefined;
|
|
1613
1617
|
} | undefined;
|
|
1618
|
+
rawEnvValues?: boolean | undefined;
|
|
1614
1619
|
} | undefined;
|
|
1615
1620
|
legacy?: {
|
|
1616
1621
|
collections?: boolean | undefined;
|
|
@@ -1767,6 +1772,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1767
1772
|
strictDynamic?: boolean | undefined;
|
|
1768
1773
|
} | undefined;
|
|
1769
1774
|
};
|
|
1775
|
+
rawEnvValues: boolean;
|
|
1770
1776
|
fonts?: ({
|
|
1771
1777
|
name: string;
|
|
1772
1778
|
cssVariable: string;
|
|
@@ -2095,6 +2101,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
2095
2101
|
strictDynamic?: boolean | undefined;
|
|
2096
2102
|
} | undefined;
|
|
2097
2103
|
} | undefined;
|
|
2104
|
+
rawEnvValues?: boolean | undefined;
|
|
2098
2105
|
} | undefined;
|
|
2099
2106
|
legacy?: {
|
|
2100
2107
|
collections?: boolean | undefined;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
3
|
import yaml from "js-yaml";
|
|
4
|
+
import toml from "smol-toml";
|
|
4
5
|
import { getContentPaths } from "../../content/index.js";
|
|
5
6
|
import createPreferences from "../../preferences/index.js";
|
|
6
7
|
import { markdownContentEntryType } from "../../vite-plugin-markdown/content-entry-type.js";
|
|
7
8
|
import { getDefaultClientDirectives } from "../client-directive/index.js";
|
|
8
9
|
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "./../constants.js";
|
|
9
10
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
10
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
formatTOMLError,
|
|
13
|
+
formatYAMLException,
|
|
14
|
+
isTOMLError,
|
|
15
|
+
isYAMLException
|
|
16
|
+
} from "../errors/utils.js";
|
|
11
17
|
import { AstroTimer } from "./timer.js";
|
|
12
18
|
import { loadTSConfig } from "./tsconfig.js";
|
|
13
19
|
function createBaseSettings(config) {
|
|
@@ -86,6 +92,31 @@ function createBaseSettings(config) {
|
|
|
86
92
|
});
|
|
87
93
|
}
|
|
88
94
|
}
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
extensions: [".toml"],
|
|
98
|
+
getEntryInfo({ contents, fileUrl }) {
|
|
99
|
+
try {
|
|
100
|
+
const data = toml.parse(contents);
|
|
101
|
+
const rawData = contents;
|
|
102
|
+
return { data, rawData };
|
|
103
|
+
} catch (e) {
|
|
104
|
+
const pathRelToContentDir = path.relative(
|
|
105
|
+
fileURLToPath(contentDir),
|
|
106
|
+
fileURLToPath(fileUrl)
|
|
107
|
+
);
|
|
108
|
+
const formattedError = isTOMLError(e) ? formatTOMLError(e) : new Error("contains invalid TOML.");
|
|
109
|
+
throw new AstroError({
|
|
110
|
+
...AstroErrorData.DataCollectionEntryParseError,
|
|
111
|
+
message: AstroErrorData.DataCollectionEntryParseError.message(
|
|
112
|
+
pathRelToContentDir,
|
|
113
|
+
formattedError.message
|
|
114
|
+
),
|
|
115
|
+
stack: formattedError.stack,
|
|
116
|
+
location: "loc" in formattedError ? { file: fileUrl.pathname, ...formattedError.loc } : { file: fileUrl.pathname }
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
89
120
|
}
|
|
90
121
|
],
|
|
91
122
|
renderers: [],
|
package/dist/core/constants.js
CHANGED
package/dist/core/create-vite.js
CHANGED
|
@@ -85,7 +85,11 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
const srcDirPattern = convertPathToPattern(fileURLToPath(settings.config.srcDir));
|
|
88
|
-
const envLoader = createEnvLoader(
|
|
88
|
+
const envLoader = createEnvLoader(
|
|
89
|
+
mode,
|
|
90
|
+
settings.config,
|
|
91
|
+
settings.config.experimental.rawEnvValues
|
|
92
|
+
);
|
|
89
93
|
const commonConfig = {
|
|
90
94
|
// Tell Vite not to combine config from vite.config.js with our provided inline config
|
|
91
95
|
configFile: false,
|
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.
|
|
25
|
+
const currentVersion = "5.12.1";
|
|
26
26
|
const isPrerelease = currentVersion.includes("-");
|
|
27
27
|
if (!isPrerelease) {
|
|
28
28
|
try {
|
|
@@ -1597,7 +1597,7 @@ export declare const ContentCollectionTypeMismatchError: {
|
|
|
1597
1597
|
* @docs
|
|
1598
1598
|
* @message `COLLECTION_ENTRY_NAME` failed to parse.
|
|
1599
1599
|
* @description
|
|
1600
|
-
* Collection entries of `type: 'data'` must return an object with valid JSON (for `.json` entries)
|
|
1600
|
+
* Collection entries of `type: 'data'` must return an object with valid JSON (for `.json` entries), YAML (for `.yaml` entries) or TOML (for `.toml` entries).
|
|
1601
1601
|
*/
|
|
1602
1602
|
export declare const DataCollectionEntryParseError: {
|
|
1603
1603
|
name: string;
|
|
@@ -1634,7 +1634,7 @@ export declare const UnsupportedConfigTransformError: {
|
|
|
1634
1634
|
* @see
|
|
1635
1635
|
* - [Passing a `parser` to the `file` loader](https://docs.astro.build/en/guides/content-collections/#parser-function)
|
|
1636
1636
|
* @description
|
|
1637
|
-
* The `file` loader can’t determine which parser to use. Please provide a custom parser (e.g. `
|
|
1637
|
+
* The `file` loader can’t determine which parser to use. Please provide a custom parser (e.g. `csv-parse`) to create a collection from your file type.
|
|
1638
1638
|
*/
|
|
1639
1639
|
export declare const FileParserNotFound: {
|
|
1640
1640
|
name: string;
|
|
@@ -635,7 +635,7 @@ const DataCollectionEntryParseError = {
|
|
|
635
635
|
message(entryId, errorMessage) {
|
|
636
636
|
return `**${entryId}** failed to parse: ${errorMessage}`;
|
|
637
637
|
},
|
|
638
|
-
hint: "Ensure your data entry is an object with valid JSON (for `.json` entries)
|
|
638
|
+
hint: "Ensure your data entry is an object with valid JSON (for `.json` entries), YAML (for `.yaml` entries) or TOML (for `.toml` entries)."
|
|
639
639
|
};
|
|
640
640
|
const DuplicateContentEntrySlugError = {
|
|
641
641
|
name: "DuplicateContentEntrySlugError",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { YAMLException } from 'js-yaml';
|
|
2
|
+
import type { TomlError } from 'smol-toml';
|
|
2
3
|
import type { ErrorPayload as ViteErrorPayload } from 'vite';
|
|
3
4
|
/**
|
|
4
5
|
* Get the line and character based on the offset
|
|
@@ -12,6 +13,9 @@ export declare function positionAt(offset: number, text: string): {
|
|
|
12
13
|
export declare function isYAMLException(err: unknown): err is YAMLException;
|
|
13
14
|
/** Format YAML exceptions as Vite errors */
|
|
14
15
|
export declare function formatYAMLException(e: YAMLException): ViteErrorPayload['err'];
|
|
16
|
+
export declare function isTOMLError(err: unknown): err is TomlError;
|
|
17
|
+
/** Format TOML exceptions as Vite errors */
|
|
18
|
+
export declare function formatTOMLError(e: TomlError): ViteErrorPayload['err'];
|
|
15
19
|
/** Coalesce any throw variable to an Error instance. */
|
|
16
20
|
export declare function createSafeError(err: any): Error;
|
|
17
21
|
export declare function normalizeLF(code: string): string;
|
|
@@ -57,6 +57,18 @@ function formatYAMLException(e) {
|
|
|
57
57
|
stack: e.stack ?? ""
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
+
function isTOMLError(err) {
|
|
61
|
+
return err instanceof Error && err.name === "TomlError";
|
|
62
|
+
}
|
|
63
|
+
function formatTOMLError(e) {
|
|
64
|
+
return {
|
|
65
|
+
name: e.name,
|
|
66
|
+
id: e.name,
|
|
67
|
+
loc: { line: e.line + 1, column: e.column },
|
|
68
|
+
message: e.message,
|
|
69
|
+
stack: e.stack ?? ""
|
|
70
|
+
};
|
|
71
|
+
}
|
|
60
72
|
function createSafeError(err) {
|
|
61
73
|
if (err instanceof Error || err?.name && err.message) {
|
|
62
74
|
return err;
|
|
@@ -71,7 +83,9 @@ function normalizeLF(code) {
|
|
|
71
83
|
}
|
|
72
84
|
export {
|
|
73
85
|
createSafeError,
|
|
86
|
+
formatTOMLError,
|
|
74
87
|
formatYAMLException,
|
|
88
|
+
isTOMLError,
|
|
75
89
|
isYAMLException,
|
|
76
90
|
normalizeLF,
|
|
77
91
|
positionAt
|
package/dist/core/messages.js
CHANGED
|
@@ -37,7 +37,7 @@ function serverStart({
|
|
|
37
37
|
host,
|
|
38
38
|
base
|
|
39
39
|
}) {
|
|
40
|
-
const version = "5.
|
|
40
|
+
const version = "5.12.1";
|
|
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.
|
|
277
|
+
`v${"5.12.1"}`
|
|
278
278
|
)} ${headline}`
|
|
279
279
|
);
|
|
280
280
|
}
|
package/dist/env/env-loader.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AstroConfig } from '../types/public/index.js';
|
|
2
|
-
export declare const createEnvLoader: (mode: string, config: AstroConfig) => {
|
|
2
|
+
export declare const createEnvLoader: (mode: string, config: AstroConfig, useRawValues: boolean) => {
|
|
3
3
|
get: () => Record<string, string>;
|
|
4
4
|
getPrivateEnv: () => Record<string, string>;
|
|
5
5
|
};
|
package/dist/env/env-loader.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
2
|
import { loadEnv } from "vite";
|
|
3
3
|
const isValidIdentifierRe = /^[_$a-zA-Z][\w$]*$/;
|
|
4
|
-
function getPrivateEnv(fullEnv, astroConfig) {
|
|
4
|
+
function getPrivateEnv(fullEnv, astroConfig, useRawValues) {
|
|
5
5
|
const viteConfig = astroConfig.vite;
|
|
6
6
|
let envPrefixes = ["PUBLIC_"];
|
|
7
7
|
if (viteConfig.envPrefix) {
|
|
@@ -15,7 +15,7 @@ function getPrivateEnv(fullEnv, astroConfig) {
|
|
|
15
15
|
if (typeof value !== "string") {
|
|
16
16
|
value = `${value}`;
|
|
17
17
|
}
|
|
18
|
-
if (value === "0" || value === "1" || value === "true" || value === "false") {
|
|
18
|
+
if (!useRawValues && (value === "0" || value === "1" || value === "true" || value === "false")) {
|
|
19
19
|
privateEnv[key] = value;
|
|
20
20
|
} else {
|
|
21
21
|
privateEnv[key] = `process.env.${key}`;
|
|
@@ -27,11 +27,18 @@ function getPrivateEnv(fullEnv, astroConfig) {
|
|
|
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
|
-
const privateEnv = getPrivateEnv(loaded, config);
|
|
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
|
};
|
|
@@ -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;
|
|
@@ -2307,6 +2309,24 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
|
|
|
2307
2309
|
*
|
|
2308
2310
|
*/
|
|
2309
2311
|
liveContentCollections?: boolean;
|
|
2312
|
+
/**
|
|
2313
|
+
* @name experimental.rawEnvValues
|
|
2314
|
+
* @type {boolean}
|
|
2315
|
+
* @default `false`
|
|
2316
|
+
* @version 5.12
|
|
2317
|
+
* @description
|
|
2318
|
+
*
|
|
2319
|
+
* Disables coercion of `import.meta.env` values that are populated from `process.env`, allowing you to use the raw value.
|
|
2320
|
+
*
|
|
2321
|
+
* By default, Astro converts your environment variables used through `import.meta.env` in some cases, and this can prevent
|
|
2322
|
+
* access to some values such as the strings `"true"` (which is converted to a boolean value), and `"1"` (which is converted
|
|
2323
|
+
* to a number).
|
|
2324
|
+
*
|
|
2325
|
+
* This flag aligns `import.meta.env`'s behavior in Astro with [Vite](https://vite.dev/guide/env-and-mode.html#env-variables).
|
|
2326
|
+
*
|
|
2327
|
+
* See the [experimental raw environment variables guide](https://docs.astro.build/en/reference/experimental-flags/raw-env-values/) for more information.
|
|
2328
|
+
*/
|
|
2329
|
+
rawEnvValues?: boolean;
|
|
2310
2330
|
};
|
|
2311
2331
|
}
|
|
2312
2332
|
/**
|
|
@@ -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.
|
|
3
|
+
"version": "5.12.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",
|
|
@@ -141,6 +141,7 @@
|
|
|
141
141
|
"rehype": "^13.0.2",
|
|
142
142
|
"semver": "^7.7.1",
|
|
143
143
|
"shiki": "^3.2.1",
|
|
144
|
+
"smol-toml": "^1.3.4",
|
|
144
145
|
"tinyexec": "^0.3.2",
|
|
145
146
|
"tinyglobby": "^0.2.12",
|
|
146
147
|
"tsconfck": "^3.1.5",
|
|
@@ -157,9 +158,9 @@
|
|
|
157
158
|
"zod": "^3.24.2",
|
|
158
159
|
"zod-to-json-schema": "^3.24.5",
|
|
159
160
|
"zod-to-ts": "^1.2.0",
|
|
161
|
+
"@astrojs/markdown-remark": "6.3.3",
|
|
160
162
|
"@astrojs/internal-helpers": "0.6.1",
|
|
161
|
-
"@astrojs/telemetry": "3.3.0"
|
|
162
|
-
"@astrojs/markdown-remark": "6.3.2"
|
|
163
|
+
"@astrojs/telemetry": "3.3.0"
|
|
163
164
|
},
|
|
164
165
|
"optionalDependencies": {
|
|
165
166
|
"sharp": "^0.33.3"
|