astro 7.0.0 → 7.0.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.
@@ -37,7 +37,7 @@ function generateImageStylesCSS(defaultObjectFit, defaultObjectPosition) {
37
37
  :where([data-astro-image]:not([data-astro-image-pos])) {
38
38
  object-position: ${defaultObjectPosition};
39
39
  }` : "";
40
- return `
40
+ const rules = `
41
41
  :where([data-astro-image]) {
42
42
  height: auto;
43
43
  }
@@ -52,6 +52,9 @@ ${defaultFitStyle}
52
52
  ${positionStyles}
53
53
  ${defaultPositionStyle}
54
54
  `.trim();
55
+ return `@layer astro.images {
56
+ ${rules}
57
+ }`;
55
58
  }
56
59
  export {
57
60
  generateImageStylesCSS
@@ -1,5 +1,6 @@
1
1
  import type { AstroLogger } from '../../core/logger/core.js';
2
2
  import type { Flags } from '../flags.js';
3
+ import { type LockFileData } from '../../core/dev/lockfile.js';
3
4
  export interface BackgroundResult {
4
5
  pid: number;
5
6
  url: string;
@@ -10,6 +11,14 @@ export interface BackgroundErrorResult {
10
11
  message: string;
11
12
  }
12
13
  export declare function formatBackgroundOutput(result: BackgroundResult | BackgroundErrorResult): string;
14
+ /**
15
+ * Build the human-readable message shown when a background dev server is running.
16
+ * Lists every network address (when `--host` exposed any) so the output matches
17
+ * the foreground dev server, then appends the management command hints.
18
+ */
19
+ export declare function formatServerRunningMessage(data: LockFileData, { existing }?: {
20
+ existing?: boolean;
21
+ }): string;
13
22
  export declare function background({ flags, logger, }: {
14
23
  flags: Flags;
15
24
  logger: AstroLogger;
@@ -14,6 +14,19 @@ import { resolveRoot } from "../../core/config/config.js";
14
14
  function formatBackgroundOutput(result) {
15
15
  return JSON.stringify(result);
16
16
  }
17
+ function formatServerRunningMessage(data, { existing = false } = {}) {
18
+ const lines = [
19
+ `Dev server ${existing ? "already running" : "running"} at ${data.url} (pid ${data.pid})`
20
+ ];
21
+ if (data.urls && data.urls.network.length > 0) {
22
+ lines.push(" Network:");
23
+ for (const url of data.urls.network) {
24
+ lines.push(` ${url}`);
25
+ }
26
+ }
27
+ lines.push(" Stop: astro dev stop", " Status: astro dev status", " Logs: astro dev logs");
28
+ return lines.join("\n");
29
+ }
17
30
  async function background({
18
31
  flags,
19
32
  logger
@@ -21,13 +34,7 @@ async function background({
21
34
  const root = pathToFileURL(resolveRoot(flags.root) + "/");
22
35
  const existing = checkExistingServer(root);
23
36
  if (existing && !flags.force) {
24
- logger.info(
25
- "SKIP_FORMAT",
26
- `Dev server already running at ${existing.url} (pid ${existing.pid})
27
- Stop: astro dev stop
28
- Status: astro dev status
29
- Logs: astro dev logs`
30
- );
37
+ logger.info("SKIP_FORMAT", formatServerRunningMessage(existing, { existing: true }));
31
38
  return;
32
39
  }
33
40
  if (existing && flags.force) {
@@ -69,8 +76,8 @@ async function background({
69
76
  }
70
77
  const logFd = openSync(logFilePath, "w");
71
78
  const rootPath = fileURLToPath(root);
72
- const astroBin = resolve(rootPath, "node_modules", ".bin", "astro");
73
- const child = spawn(astroBin, args, {
79
+ const astroBin = resolve(rootPath, "node_modules", "astro", "bin", "astro.mjs");
80
+ const child = spawn(process.execPath, [astroBin, ...args], {
74
81
  detached: true,
75
82
  stdio: ["ignore", logFd, logFd],
76
83
  cwd: rootPath,
@@ -91,13 +98,7 @@ async function background({
91
98
  }
92
99
  const lockData = readLockFile(root);
93
100
  if (lockData && lockData.pid === childPid) {
94
- logger.info(
95
- "SKIP_FORMAT",
96
- `Dev server running at ${lockData.url} (pid ${lockData.pid})
97
- Stop: astro dev stop
98
- Status: astro dev status
99
- Logs: astro dev logs`
100
- );
101
+ logger.info("SKIP_FORMAT", formatServerRunningMessage(lockData));
101
102
  return;
102
103
  }
103
104
  await new Promise((r) => setTimeout(r, 200));
@@ -112,5 +113,6 @@ async function background({
112
113
  }
113
114
  export {
114
115
  background,
115
- formatBackgroundOutput
116
+ formatBackgroundOutput,
117
+ formatServerRunningMessage
116
118
  };
@@ -1,4 +1,4 @@
1
- import { isAgent } from "am-i-vibing";
1
+ import { detectAgenticEnvironment } from "am-i-vibing";
2
2
  import colors from "piccolore";
3
3
  import devServer from "../../core/dev/index.js";
4
4
  import { pathToFileURL } from "node:url";
@@ -8,7 +8,7 @@ import { printHelp } from "../../core/messages/runtime.js";
8
8
  import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
9
9
  function isRunByAgent() {
10
10
  try {
11
- return isAgent();
11
+ return detectAgenticEnvironment().type === "agent";
12
12
  } catch {
13
13
  return false;
14
14
  }
@@ -100,6 +100,7 @@ Run \`astro dev --help\` to see available commands.`
100
100
  pid: process.pid,
101
101
  port: server.address.port,
102
102
  url: serverUrl,
103
+ urls: server.resolvedUrls,
103
104
  background: !!process.env.ASTRO_DEV_BACKGROUND,
104
105
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
105
106
  });
@@ -16,10 +16,16 @@ async function status({
16
16
  }
17
17
  const startedAt = new Date(existing.startedAt).getTime();
18
18
  const uptime = Math.floor((Date.now() - startedAt) / 1e3);
19
- logger.info(
20
- "SKIP_FORMAT",
19
+ const lines = [
21
20
  `Dev server running at ${existing.url} (pid ${existing.pid}, uptime ${uptime}s${existing.background ? ", background" : ""})`
22
- );
21
+ ];
22
+ if (existing.urls && existing.urls.network.length > 0) {
23
+ lines.push(" Network:");
24
+ for (const url of existing.urls.network) {
25
+ lines.push(` ${url}`);
26
+ }
27
+ }
28
+ logger.info("SKIP_FORMAT", lines.join("\n"));
23
29
  }
24
30
  export {
25
31
  formatStatusOutput,
@@ -1,6 +1,6 @@
1
1
  class BuildTimeAstroVersionProvider {
2
2
  // Injected during the build through esbuild define
3
- version = "7.0.0";
3
+ version = "7.0.1";
4
4
  }
5
5
  export {
6
6
  BuildTimeAstroVersionProvider
@@ -197,7 +197,7 @@ ${contentConfig.error.message}`
197
197
  logger.info("Content config changed");
198
198
  shouldClear = true;
199
199
  }
200
- if (previousAstroVersion && previousAstroVersion !== "7.0.0") {
200
+ if (previousAstroVersion && previousAstroVersion !== "7.0.1") {
201
201
  logger.info("Astro version changed");
202
202
  shouldClear = true;
203
203
  }
@@ -205,8 +205,8 @@ ${contentConfig.error.message}`
205
205
  logger.info("Clearing content store");
206
206
  this.#store.clearAll();
207
207
  }
208
- if ("7.0.0") {
209
- this.#store.metaStore().set("astro-version", "7.0.0");
208
+ if ("7.0.1") {
209
+ this.#store.metaStore().set("astro-version", "7.0.1");
210
210
  }
211
211
  if (currentConfigDigest) {
212
212
  this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "7.0.0";
1
+ const ASTRO_VERSION = "7.0.1";
2
2
  const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`;
3
3
  const ASTRO_ERROR_HEADER = "X-Astro-Error";
4
4
  const DEFAULT_404_COMPONENT = "astro-default-404.astro";
@@ -26,7 +26,7 @@ async function dev(inlineConfig) {
26
26
  await telemetry.record([]);
27
27
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
28
28
  const logger = restart.container.logger;
29
- const currentVersion = "7.0.0";
29
+ const currentVersion = "7.0.1";
30
30
  const isPrerelease = currentVersion.includes("-");
31
31
  if (!isPrerelease) {
32
32
  try {
@@ -1,9 +1,11 @@
1
+ import type { ResolvedServerUrls } from 'vite';
1
2
  /** Maximum time (ms) to wait for a process to exit after SIGTERM before escalating to SIGKILL. */
2
3
  export declare const GRACEFUL_SHUTDOWN_TIMEOUT = 5000;
3
4
  export interface LockFileData {
4
5
  pid: number;
5
6
  port: number;
6
7
  url: string;
8
+ urls?: ResolvedServerUrls;
7
9
  background: boolean;
8
10
  startedAt: string;
9
11
  }
@@ -7,12 +7,25 @@ function getLockFileURL(root) {
7
7
  function getLogFileURL(root) {
8
8
  return new URL(".astro/dev.log", root);
9
9
  }
10
+ function isStringArray(value) {
11
+ return Array.isArray(value) && value.every((item) => typeof item === "string");
12
+ }
13
+ function isResolvedServerUrls(value) {
14
+ if (typeof value !== "object" || value === null) {
15
+ return false;
16
+ }
17
+ const { local, network } = value;
18
+ return isStringArray(local) && isStringArray(network);
19
+ }
10
20
  function parseLockFile(content) {
11
21
  try {
12
22
  const data = JSON.parse(content);
13
23
  if (typeof data.pid !== "number" || typeof data.port !== "number" || typeof data.url !== "string" || typeof data.background !== "boolean" || typeof data.startedAt !== "string") {
14
24
  return null;
15
25
  }
26
+ if (data.urls !== void 0 && !isResolvedServerUrls(data.urls)) {
27
+ return null;
28
+ }
16
29
  return data;
17
30
  } catch {
18
31
  return null;
@@ -269,7 +269,7 @@ function printHelp({
269
269
  message.push(
270
270
  linebreak(),
271
271
  ` ${bgGreen(black(` ${commandName} `))} ${green(
272
- `v${"7.0.0"}`
272
+ `v${"7.0.1"}`
273
273
  )} ${headline}`
274
274
  );
275
275
  }
@@ -44,6 +44,7 @@ function resolveWithAlias(id, configAlias) {
44
44
  return null;
45
45
  }
46
46
  const cssImportRE = /@import\s+(?:url\(\s*)?['"]([^'"]+)['"]\s*\)?/g;
47
+ const cssUrlRE = /(?<!@import\s+)url\(\s*['"]([^'"]+)['"]\s*\)/g;
47
48
  function configAliasVitePlugin({
48
49
  settings
49
50
  }) {
@@ -64,9 +65,8 @@ function configAliasVitePlugin({
64
65
  }
65
66
  },
66
67
  handler(code) {
67
- if (!code.includes("@import")) return;
68
68
  let hasReplacement = false;
69
- const result = code.replace(cssImportRE, (match, importId) => {
69
+ const replaceAliases = (match, importId) => {
70
70
  if (!importId) return match;
71
71
  const resolved = resolveWithAlias(importId, configAlias);
72
72
  if (resolved) {
@@ -74,7 +74,14 @@ function configAliasVitePlugin({
74
74
  return match.replace(importId, resolved);
75
75
  }
76
76
  return match;
77
- });
77
+ };
78
+ let result = code;
79
+ if (result.includes("@import")) {
80
+ result = result.replace(cssImportRE, replaceAliases);
81
+ }
82
+ if (result.includes("url(")) {
83
+ result = result.replace(cssUrlRE, replaceAliases);
84
+ }
78
85
  if (hasReplacement) {
79
86
  return { code: result, map: null };
80
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "7.0.0",
3
+ "version": "7.0.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",
@@ -118,7 +118,7 @@
118
118
  "@clack/prompts": "^1.1.0",
119
119
  "@oslojs/encoding": "^1.1.0",
120
120
  "@rollup/pluginutils": "^5.3.0",
121
- "am-i-vibing": "^0.3.0",
121
+ "am-i-vibing": "^0.4.0",
122
122
  "aria-query": "^5.3.2",
123
123
  "axobject-query": "^4.1.0",
124
124
  "ci-info": "^4.4.0",