astro 5.12.9 → 5.13.0

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.
@@ -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.9") {
167
+ if (previousAstroVersion && previousAstroVersion !== "5.13.0") {
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.9") {
176
- await this.#store.metaStore().set("astro-version", "5.12.9");
175
+ if ("5.13.0") {
176
+ await this.#store.metaStore().set("astro-version", "5.13.0");
177
177
  }
178
178
  if (currentConfigDigest) {
179
179
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -75,7 +75,8 @@ export declare const ASTRO_CONFIG_DEFAULTS: {
75
75
  preserveScriptOrder: false;
76
76
  liveContentCollections: false;
77
77
  csp: false;
78
- rawEnvValues: false;
78
+ staticImportMetaEnv: false;
79
+ chromeDevtoolsWorkspace: false;
79
80
  };
80
81
  };
81
82
  export declare const AstroConfigSchema: z.ZodObject<{
@@ -976,7 +977,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
976
977
  strictDynamic?: boolean | undefined;
977
978
  } | undefined;
978
979
  }>]>>>;
979
- rawEnvValues: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
980
+ staticImportMetaEnv: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
981
+ chromeDevtoolsWorkspace: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
980
982
  }, "strict", z.ZodTypeAny, {
981
983
  clientPrerender: boolean;
982
984
  contentIntellisense: boolean;
@@ -996,7 +998,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
996
998
  strictDynamic?: boolean | undefined;
997
999
  } | undefined;
998
1000
  };
999
- rawEnvValues: boolean;
1001
+ staticImportMetaEnv: boolean;
1002
+ chromeDevtoolsWorkspace: boolean;
1000
1003
  fonts?: ({
1001
1004
  name: string;
1002
1005
  cssVariable: string;
@@ -1126,7 +1129,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
1126
1129
  strictDynamic?: boolean | undefined;
1127
1130
  } | undefined;
1128
1131
  } | undefined;
1129
- rawEnvValues?: boolean | undefined;
1132
+ staticImportMetaEnv?: boolean | undefined;
1133
+ chromeDevtoolsWorkspace?: boolean | undefined;
1130
1134
  }>>;
1131
1135
  legacy: z.ZodDefault<z.ZodObject<{
1132
1136
  collections: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
@@ -1286,7 +1290,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
1286
1290
  strictDynamic?: boolean | undefined;
1287
1291
  } | undefined;
1288
1292
  };
1289
- rawEnvValues: boolean;
1293
+ staticImportMetaEnv: boolean;
1294
+ chromeDevtoolsWorkspace: boolean;
1290
1295
  fonts?: ({
1291
1296
  name: string;
1292
1297
  cssVariable: string;
@@ -1615,7 +1620,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
1615
1620
  strictDynamic?: boolean | undefined;
1616
1621
  } | undefined;
1617
1622
  } | undefined;
1618
- rawEnvValues?: boolean | undefined;
1623
+ staticImportMetaEnv?: boolean | undefined;
1624
+ chromeDevtoolsWorkspace?: boolean | undefined;
1619
1625
  } | undefined;
1620
1626
  legacy?: {
1621
1627
  collections?: boolean | undefined;
@@ -59,7 +59,8 @@ const ASTRO_CONFIG_DEFAULTS = {
59
59
  preserveScriptOrder: false,
60
60
  liveContentCollections: false,
61
61
  csp: false,
62
- rawEnvValues: false
62
+ staticImportMetaEnv: false,
63
+ chromeDevtoolsWorkspace: false
63
64
  }
64
65
  };
65
66
  const highlighterTypesSchema = z.union([z.literal("shiki"), z.literal("prism")]).default(syntaxHighlightDefaults.type);
@@ -285,7 +286,8 @@ const AstroConfigSchema = z.object({
285
286
  }).optional()
286
287
  })
287
288
  ]).optional().default(ASTRO_CONFIG_DEFAULTS.experimental.csp),
288
- rawEnvValues: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.rawEnvValues)
289
+ staticImportMetaEnv: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.staticImportMetaEnv),
290
+ chromeDevtoolsWorkspace: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.chromeDevtoolsWorkspace)
289
291
  }).strict(
290
292
  `Invalid or outdated experimental feature.
291
293
  Check for incorrect spelling or outdated Astro version.
@@ -826,7 +826,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
826
826
  strictDynamic?: boolean | undefined;
827
827
  } | undefined;
828
828
  }>]>>>;
829
- rawEnvValues: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
829
+ staticImportMetaEnv: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
830
+ chromeDevtoolsWorkspace: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
830
831
  }, "strict", z.ZodTypeAny, {
831
832
  clientPrerender: boolean;
832
833
  contentIntellisense: boolean;
@@ -846,7 +847,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
846
847
  strictDynamic?: boolean | undefined;
847
848
  } | undefined;
848
849
  };
849
- rawEnvValues: boolean;
850
+ staticImportMetaEnv: boolean;
851
+ chromeDevtoolsWorkspace: boolean;
850
852
  fonts?: ({
851
853
  name: string;
852
854
  cssVariable: string;
@@ -976,7 +978,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
976
978
  strictDynamic?: boolean | undefined;
977
979
  } | undefined;
978
980
  } | undefined;
979
- rawEnvValues?: boolean | undefined;
981
+ staticImportMetaEnv?: boolean | undefined;
982
+ chromeDevtoolsWorkspace?: boolean | undefined;
980
983
  }>>;
981
984
  legacy: z.ZodDefault<z.ZodObject<{
982
985
  collections: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
@@ -1214,7 +1217,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1214
1217
  strictDynamic?: boolean | undefined;
1215
1218
  } | undefined;
1216
1219
  };
1217
- rawEnvValues: boolean;
1220
+ staticImportMetaEnv: boolean;
1221
+ chromeDevtoolsWorkspace: boolean;
1218
1222
  fonts?: ({
1219
1223
  name: string;
1220
1224
  cssVariable: string;
@@ -1543,7 +1547,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1543
1547
  strictDynamic?: boolean | undefined;
1544
1548
  } | undefined;
1545
1549
  } | undefined;
1546
- rawEnvValues?: boolean | undefined;
1550
+ staticImportMetaEnv?: boolean | undefined;
1551
+ chromeDevtoolsWorkspace?: boolean | undefined;
1547
1552
  } | undefined;
1548
1553
  legacy?: {
1549
1554
  collections?: boolean | undefined;
@@ -1700,7 +1705,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1700
1705
  strictDynamic?: boolean | undefined;
1701
1706
  } | undefined;
1702
1707
  };
1703
- rawEnvValues: boolean;
1708
+ staticImportMetaEnv: boolean;
1709
+ chromeDevtoolsWorkspace: boolean;
1704
1710
  fonts?: ({
1705
1711
  name: string;
1706
1712
  cssVariable: string;
@@ -2029,7 +2035,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2029
2035
  strictDynamic?: boolean | undefined;
2030
2036
  } | undefined;
2031
2037
  } | undefined;
2032
- rawEnvValues?: boolean | undefined;
2038
+ staticImportMetaEnv?: boolean | undefined;
2039
+ chromeDevtoolsWorkspace?: boolean | undefined;
2033
2040
  } | undefined;
2034
2041
  legacy?: {
2035
2042
  collections?: boolean | undefined;
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "5.12.9";
1
+ const ASTRO_VERSION = "5.13.0";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
4
4
  const REWRITE_DIRECTIVE_HEADER_VALUE = "yes";
@@ -85,11 +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
89
  mode,
90
- settings.config,
91
- settings.config.experimental.rawEnvValues
92
- );
90
+ config: settings.config,
91
+ useStatic: settings.config.experimental.staticImportMetaEnv
92
+ });
93
93
  const commonConfig = {
94
94
  // Tell Vite not to combine config from vite.config.js with our provided inline config
95
95
  configFile: false,
@@ -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.9";
25
+ const currentVersion = "5.13.0";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -37,7 +37,7 @@ function serverStart({
37
37
  host,
38
38
  base
39
39
  }) {
40
- const version = "5.12.9";
40
+ const version = "5.13.0";
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.9"}`
277
+ `v${"5.13.0"}`
278
278
  )} ${headline}`
279
279
  );
280
280
  }
@@ -1,6 +1,12 @@
1
1
  import type { AstroConfig } from '../types/public/index.js';
2
- export declare const createEnvLoader: (mode: string, config: AstroConfig, useRawValues: boolean) => {
2
+ interface EnvLoaderOptions {
3
+ mode: string;
4
+ config: AstroConfig;
5
+ useStatic: boolean;
6
+ }
7
+ export declare const createEnvLoader: (options: EnvLoaderOptions) => {
3
8
  get: () => Record<string, string>;
4
9
  getPrivateEnv: () => Record<string, string>;
5
10
  };
6
11
  export type EnvLoader = ReturnType<typeof createEnvLoader>;
12
+ export {};
@@ -1,42 +1,46 @@
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, useRawValues) {
5
- const viteConfig = astroConfig.vite;
4
+ function getPrivateEnv({
5
+ fullEnv,
6
+ viteConfig,
7
+ useStatic
8
+ }) {
6
9
  let envPrefixes = ["PUBLIC_"];
7
10
  if (viteConfig.envPrefix) {
8
11
  envPrefixes = Array.isArray(viteConfig.envPrefix) ? viteConfig.envPrefix : [viteConfig.envPrefix];
9
12
  }
10
13
  const privateEnv = {};
11
14
  for (const key in fullEnv) {
12
- if (isValidIdentifierRe.test(key) && envPrefixes.every((prefix) => !key.startsWith(prefix))) {
13
- if (typeof process.env[key] !== "undefined") {
14
- let value = process.env[key];
15
- if (typeof value !== "string") {
16
- value = `${value}`;
17
- }
18
- if (!useRawValues && (value === "0" || value === "1" || value === "true" || value === "false")) {
19
- privateEnv[key] = value;
20
- } else {
21
- privateEnv[key] = `process.env.${key}`;
22
- }
15
+ if (!isValidIdentifierRe.test(key) || envPrefixes.some((prefix) => key.startsWith(prefix))) {
16
+ continue;
17
+ }
18
+ if (!useStatic && typeof process.env[key] !== "undefined") {
19
+ let value = process.env[key];
20
+ if (typeof value !== "string") {
21
+ value = `${value}`;
22
+ }
23
+ if (value === "0" || value === "1" || value === "true" || value === "false") {
24
+ privateEnv[key] = value;
23
25
  } else {
24
- privateEnv[key] = JSON.stringify(fullEnv[key]);
26
+ privateEnv[key] = `process.env.${key}`;
25
27
  }
28
+ } else {
29
+ privateEnv[key] = JSON.stringify(fullEnv[key]);
26
30
  }
27
31
  }
28
32
  return privateEnv;
29
33
  }
30
- function getEnv(mode, config, useRawValues) {
34
+ function getEnv({ mode, config, useStatic }) {
31
35
  const loaded = loadEnv(mode, config.vite.envDir ?? fileURLToPath(config.root), "");
32
- const privateEnv = getPrivateEnv(loaded, config, useRawValues);
36
+ const privateEnv = getPrivateEnv({ fullEnv: loaded, viteConfig: config.vite, useStatic });
33
37
  return { loaded, privateEnv };
34
38
  }
35
- const createEnvLoader = (mode, config, useRawValues) => {
36
- let { loaded, privateEnv } = getEnv(mode, config, useRawValues);
39
+ const createEnvLoader = (options) => {
40
+ let { loaded, privateEnv } = getEnv(options);
37
41
  return {
38
42
  get: () => {
39
- ({ loaded, privateEnv } = getEnv(mode, config, useRawValues));
43
+ ({ loaded, privateEnv } = getEnv(options));
40
44
  return loaded;
41
45
  },
42
46
  getPrivateEnv: () => privateEnv
@@ -2303,30 +2303,55 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
2303
2303
  * @name experimental.liveContentCollections
2304
2304
  * @type {boolean}
2305
2305
  * @default `false`
2306
- * @version 5.x
2306
+ * @version 5.10
2307
2307
  * @description
2308
2308
  * Enables the use of live content collections.
2309
2309
  *
2310
2310
  */
2311
2311
  liveContentCollections?: boolean;
2312
2312
  /**
2313
- * @name experimental.rawEnvValues
2313
+ * @name experimental.staticImportMetaEnv
2314
2314
  * @type {boolean}
2315
2315
  * @default `false`
2316
- * @version 5.12
2316
+ * @version 5.13
2317
2317
  * @description
2318
2318
  *
2319
- * Disables coercion of `import.meta.env` values that are populated from `process.env`, allowing you to use the raw value.
2319
+ * Disables replacement of `import.meta.env` values with `process.env` calls and their coercion
2320
+ *
2321
+ * Currently, non-public `import.meta.env` environment variables are replaced by a reference to `process.env`. Additionally, Astro may also convert the value type of your environment variables used through `import.meta.env`, which can prevent access to some values such as the strings `"true"` (which is converted to a boolean value), and `"1"` (which is converted to a number).
2320
2322
  *
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).
2323
+ * The `experimental.staticImportMetaEnv` flag simplifies Astro's default behavior, making it easier to understand and use. Astro will no longer replace any `import.meta.env` environment variables with a `process.env` call, nor will it coerce values.
2324
2324
  *
2325
2325
  * This flag aligns `import.meta.env`'s behavior in Astro with [Vite](https://vite.dev/guide/env-and-mode.html#env-variables).
2326
2326
  *
2327
- * See the [experimental raw environment variables guide](https://docs.astro.build/en/reference/experimental-flags/raw-env-values/) for more information.
2327
+ * See the [experimental static `import.meta.env` docs](https://docs.astro.build/en/reference/experimental-flags/static-import-meta-env/) for more information.
2328
+ */
2329
+ staticImportMetaEnv?: boolean;
2330
+ /**
2331
+ * @name experimental.chromeDevtoolsWorkspace
2332
+ * @type {boolean}
2333
+ * @default `false`
2334
+ * @version 5.13
2335
+ * @description
2336
+ *
2337
+ * Enables Chrome DevTools workspace integration for the Astro dev server.
2338
+ *
2339
+ * When enabled, the dev server will automatically configure a [Chrome DevTools workspace](https://developer.chrome.com/docs/devtools/workspaces) for your project,
2340
+ * allowing you to edit files directly in the browser and have those changes reflected in your local file system.
2341
+ *
2342
+ * ```js
2343
+ * import { defineConfig } from 'astro/config';
2344
+ *
2345
+ * export default defineConfig({
2346
+ * experimental: {
2347
+ * chromeDevtoolsWorkspace: true,
2348
+ * },
2349
+ * });
2350
+ * ```
2351
+ *
2352
+ * See the [experimental Chrome DevTools workspace feature documentation](https://docs.astro.build/en/reference/experimental-flags/chrome-devtools-workspace/) for more information.
2328
2353
  */
2329
- rawEnvValues?: boolean;
2354
+ chromeDevtoolsWorkspace?: boolean;
2330
2355
  };
2331
2356
  }
2332
2357
  /**
@@ -1,4 +1,7 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { randomUUID } from "node:crypto";
3
+ import { existsSync } from "node:fs";
4
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
5
  import { IncomingMessage } from "node:http";
3
6
  import { fileURLToPath } from "node:url";
4
7
  import { normalizePath } from "vite";
@@ -104,6 +107,35 @@ function createVitePluginAstroServer({
104
107
  route: "",
105
108
  handle: trailingSlashMiddleware(settings)
106
109
  });
110
+ viteServer.middlewares.use(async function chromeDevToolsHandler(request, response, next) {
111
+ if (request.url !== "/.well-known/appspecific/com.chrome.devtools.json") {
112
+ return next();
113
+ }
114
+ if (!settings.config.experimental.chromeDevtoolsWorkspace) {
115
+ response.writeHead(404);
116
+ response.end();
117
+ return;
118
+ }
119
+ const cacheDir = settings.config.cacheDir;
120
+ const configPath = new URL("./chrome-workspace.json", cacheDir);
121
+ if (!existsSync(cacheDir)) {
122
+ await mkdir(cacheDir, { recursive: true });
123
+ }
124
+ let config;
125
+ try {
126
+ config = JSON.parse(await readFile(configPath, "utf-8"));
127
+ } catch {
128
+ config = {
129
+ version: "1.0",
130
+ projectId: randomUUID(),
131
+ workspaceRoot: fileURLToPath(settings.config.root)
132
+ };
133
+ await writeFile(configPath, JSON.stringify(config));
134
+ }
135
+ response.setHeader("Content-Type", "application/json");
136
+ response.end(JSON.stringify(config));
137
+ return;
138
+ });
107
139
  viteServer.middlewares.use(async function astroDevHandler(request, response) {
108
140
  if (request.url === void 0 || !request.method) {
109
141
  response.writeHead(500, "Incomplete request");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.12.9",
3
+ "version": "5.13.0",
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",