astro 4.16.8 → 4.16.9

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.
@@ -1,4 +1,4 @@
1
- import type { WithRequired } from '../type-utils.js';
1
+ import type { OmitPreservingIndexSignature, Simplify, WithRequired } from '../type-utils.js';
2
2
  import type { VALID_INPUT_FORMATS, VALID_OUTPUT_FORMATS } from './consts.js';
3
3
  import type { ImageService } from './services/service.js';
4
4
  export type ImageQualityPreset = 'low' | 'mid' | 'high' | 'max' | (string & {});
@@ -48,12 +48,12 @@ export type SrcSetValue = UnresolvedSrcSetValue & {
48
48
  /**
49
49
  * A yet to be resolved image transform. Used by `getImage`
50
50
  */
51
- export type UnresolvedImageTransform = Omit<ImageTransform, 'src'> & {
51
+ export type UnresolvedImageTransform = Simplify<OmitPreservingIndexSignature<ImageTransform, 'src'> & {
52
52
  src: ImageMetadata | string | Promise<{
53
53
  default: ImageMetadata;
54
54
  }>;
55
55
  inferSize?: boolean;
56
- } & {
56
+ }> & {
57
57
  [isESMImport]?: never;
58
58
  };
59
59
  /**
@@ -1,4 +1,3 @@
1
- import { Logger } from "../core/logger/core.js";
2
1
  function defineConfig(config) {
3
2
  return config;
4
3
  }
@@ -8,7 +7,7 @@ function getViteConfig(userViteConfig, inlineAstroConfig = {}) {
8
7
  const [
9
8
  fs,
10
9
  { mergeConfig },
11
- { nodeLogDestination },
10
+ { createNodeLogger },
12
11
  { resolveConfig, createSettings },
13
12
  { createVite },
14
13
  { runHookConfigSetup, runHookConfigDone },
@@ -16,16 +15,13 @@ function getViteConfig(userViteConfig, inlineAstroConfig = {}) {
16
15
  ] = await Promise.all([
17
16
  import("node:fs"),
18
17
  import("vite"),
19
- import("../core/logger/node.js"),
18
+ import("../core/config/logging.js"),
20
19
  import("../core/config/index.js"),
21
20
  import("../core/create-vite.js"),
22
21
  import("../integrations/hooks.js"),
23
22
  import("./vite-plugin-content-listen.js")
24
23
  ]);
25
- const logger = new Logger({
26
- dest: nodeLogDestination,
27
- level: "info"
28
- });
24
+ const logger = createNodeLogger(inlineAstroConfig);
29
25
  const { astroConfig: config } = await resolveConfig(inlineAstroConfig, cmd);
30
26
  let settings = await createSettings(config, userViteConfig.root);
31
27
  settings = await runHookConfigSetup({ settings, command: cmd, logger });
@@ -121,7 +121,7 @@ class ContentLayer {
121
121
  logger.info("Content config changed");
122
122
  shouldClear = true;
123
123
  }
124
- if (previousAstroVersion !== "4.16.8") {
124
+ if (previousAstroVersion !== "4.16.9") {
125
125
  logger.info("Astro version changed");
126
126
  shouldClear = true;
127
127
  }
@@ -129,8 +129,8 @@ class ContentLayer {
129
129
  logger.info("Clearing content store");
130
130
  this.#store.clearAll();
131
131
  }
132
- if ("4.16.8") {
133
- await this.#store.metaStore().set("astro-version", "4.16.8");
132
+ if ("4.16.9") {
133
+ await this.#store.metaStore().set("astro-version", "4.16.9");
134
134
  }
135
135
  if (currentConfigDigest) {
136
136
  await this.#store.metaStore().set("config-digest", currentConfigDigest);
@@ -100,8 +100,10 @@ class NodeApp extends App {
100
100
  result = await reader.read();
101
101
  }
102
102
  destination.end();
103
- } catch {
104
- destination.end("Internal server error");
103
+ } catch (err) {
104
+ destination.write("Internal server error", () => {
105
+ err instanceof Error ? destination.destroy(err) : destination.destroy();
106
+ });
105
107
  }
106
108
  }
107
109
  }
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.16.8";
1
+ const ASTRO_VERSION = "4.16.9";
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";
@@ -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 = "4.16.8";
25
+ const currentVersion = "4.16.9";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -118,7 +118,9 @@ async function createContainerWithAutomaticRestart({
118
118
  watcher.on("change", handleChangeRestart("Configuration file updated."));
119
119
  watcher.on("unlink", handleChangeRestart("Configuration file removed."));
120
120
  watcher.on("add", handleChangeRestart("Configuration file added."));
121
- restart.container.viteServer.restart = () => handleServerRestart();
121
+ restart.container.viteServer.restart = async () => {
122
+ if (!restart.container.restartInFlight) await handleServerRestart();
123
+ };
122
124
  const customShortcuts = [
123
125
  // Disable default Vite shortcuts that don't work well with Astro
124
126
  { key: "r", description: "" },
@@ -38,7 +38,7 @@ function serverStart({
38
38
  host,
39
39
  base
40
40
  }) {
41
- const version = "4.16.8";
41
+ const version = "4.16.9";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -270,7 +270,7 @@ function printHelp({
270
270
  message.push(
271
271
  linebreak(),
272
272
  ` ${bgGreen(black(` ${commandName} `))} ${green(
273
- `v${"4.16.8"}`
273
+ `v${"4.16.9"}`
274
274
  )} ${headline}`
275
275
  );
276
276
  }
@@ -1,11 +1,7 @@
1
1
  import { AstroError, AstroErrorData } from "../core/errors/index.js";
2
2
  import { invalidVariablesToError } from "./errors.js";
3
- import { ENV_SYMBOL } from "./runtime-constants.js";
4
3
  import { validateEnvVariable, getEnvFieldType } from "./validators.js";
5
- let _getEnv = (key) => {
6
- const env = globalThis[ENV_SYMBOL] ?? {};
7
- return env[key];
8
- };
4
+ let _getEnv = (key) => process.env[key];
9
5
  function setGetEnv(fn, reset = false) {
10
6
  _getEnv = fn;
11
7
  _onSetGetEnv(reset);
@@ -7,7 +7,6 @@ import {
7
7
  VIRTUAL_MODULES_IDS_VALUES
8
8
  } from "./constants.js";
9
9
  import { invalidVariablesToError } from "./errors.js";
10
- import { ENV_SYMBOL } from "./runtime-constants.js";
11
10
  import { getEnvFieldType, validateEnvVariable } from "./validators.js";
12
11
  function astroEnv({
13
12
  settings,
@@ -29,7 +28,11 @@ function astroEnv({
29
28
  fileURLToPath(settings.config.root),
30
29
  ""
31
30
  );
32
- globalThis[ENV_SYMBOL] = loadedEnv;
31
+ for (const [key, value] of Object.entries(loadedEnv)) {
32
+ if (value !== void 0) {
33
+ process.env[key] = value;
34
+ }
35
+ }
33
36
  const validatedVariables = validatePublicVariables({
34
37
  schema,
35
38
  loadedEnv,
@@ -30,10 +30,20 @@ function astroPrefetch({ settings }) {
30
30
  },
31
31
  transform(code, id) {
32
32
  if (id.includes(prefetchInternalModuleFsSubpath)) {
33
- return code.replace("__PREFETCH_PREFETCH_ALL__", JSON.stringify(prefetch?.prefetchAll)).replace("__PREFETCH_DEFAULT_STRATEGY__", JSON.stringify(prefetch?.defaultStrategy)).replace(
33
+ code = code.replace(
34
+ "__PREFETCH_PREFETCH_ALL__",
35
+ // length: 25
36
+ `${JSON.stringify(prefetch?.prefetchAll)}`.padEnd(25)
37
+ ).replace(
38
+ "__PREFETCH_DEFAULT_STRATEGY__",
39
+ // length: 29
40
+ `${JSON.stringify(prefetch?.defaultStrategy)}`.padEnd(29)
41
+ ).replace(
34
42
  "__EXPERIMENTAL_CLIENT_PRERENDER__",
35
- JSON.stringify(settings.config.experimental.clientPrerender)
43
+ // length: 33
44
+ `${JSON.stringify(settings.config.experimental.clientPrerender)}`.padEnd(33)
36
45
  );
46
+ return { code, map: null };
37
47
  }
38
48
  }
39
49
  };
@@ -7,6 +7,9 @@ export type WithRequired<T, K extends keyof T> = T & {
7
7
  export type OmitIndexSignature<ObjectType> = {
8
8
  [KeyType in keyof ObjectType as object extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType];
9
9
  };
10
+ export type OmitPreservingIndexSignature<T, K extends PropertyKey> = {
11
+ [P in keyof T as Exclude<P, K>]: T[P];
12
+ };
10
13
  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
14
  export type KebabKeys<T> = {
12
15
  [K in keyof T as K extends string ? Kebab<K> : K]: T[K];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.16.8",
3
+ "version": "4.16.9",
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",
@@ -168,8 +168,8 @@
168
168
  "zod-to-json-schema": "^3.23.5",
169
169
  "zod-to-ts": "^1.2.0",
170
170
  "@astrojs/internal-helpers": "0.4.1",
171
- "@astrojs/markdown-remark": "5.3.0",
172
- "@astrojs/telemetry": "3.1.0"
171
+ "@astrojs/telemetry": "3.1.0",
172
+ "@astrojs/markdown-remark": "5.3.0"
173
173
  },
174
174
  "optionalDependencies": {
175
175
  "sharp": "^0.33.3"
@@ -1 +0,0 @@
1
- export declare const ENV_SYMBOL: unique symbol;
@@ -1,4 +0,0 @@
1
- const ENV_SYMBOL = Symbol.for("astro:env/dev");
2
- export {
3
- ENV_SYMBOL
4
- };