astro 7.0.7 → 7.0.8

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.
@@ -9,7 +9,7 @@ import {
9
9
  readLockFile,
10
10
  removeLockFile,
11
11
  isProcessAlive,
12
- GRACEFUL_SHUTDOWN_TIMEOUT
12
+ killDevServer
13
13
  } from "../../core/dev/lockfile.js";
14
14
  import { resolveRoot } from "../../core/config/config.js";
15
15
  const require2 = createRequire(import.meta.url);
@@ -40,22 +40,7 @@ async function background({
40
40
  return;
41
41
  }
42
42
  if (existing && flags.force) {
43
- try {
44
- process.kill(existing.pid, "SIGTERM");
45
- } catch {
46
- }
47
- const deadline2 = Date.now() + GRACEFUL_SHUTDOWN_TIMEOUT;
48
- while (Date.now() < deadline2) {
49
- if (!isProcessAlive(existing.pid)) break;
50
- await new Promise((r) => setTimeout(r, 100));
51
- }
52
- if (isProcessAlive(existing.pid)) {
53
- try {
54
- process.kill(existing.pid, "SIGKILL");
55
- } catch {
56
- }
57
- }
58
- removeLockFile(root);
43
+ await killDevServer(root, existing);
59
44
  }
60
45
  const args = ["dev"];
61
46
  if (flags.port) args.push("--port", String(flags.port));
@@ -2,7 +2,12 @@ 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";
5
- import { checkExistingServer, removeLockFile, writeLockFile } from "../../core/dev/lockfile.js";
5
+ import {
6
+ checkExistingServer,
7
+ killDevServer,
8
+ removeLockFile,
9
+ writeLockFile
10
+ } from "../../core/dev/lockfile.js";
6
11
  import { resolveRoot } from "../../core/config/config.js";
7
12
  import { printHelp } from "../../core/messages/runtime.js";
8
13
  import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
@@ -83,15 +88,19 @@ Run \`astro dev --help\` to see available commands.`
83
88
  const root = pathToFileURL(resolveRoot(flags.root) + "/");
84
89
  const existingServer = checkExistingServer(root);
85
90
  if (existingServer) {
86
- const message = [
87
- "Another astro dev server is already running.",
88
- "",
89
- ` URL: ${existingServer.url}`,
90
- ` PID: ${existingServer.pid}`,
91
- "",
92
- `Run \`astro dev stop\` to stop it, or use \`astro dev --force\` to replace it.`
93
- ].join("\n");
94
- throw new Error(message);
91
+ if (flags.force) {
92
+ await killDevServer(root, existingServer);
93
+ } else {
94
+ const message = [
95
+ "Another astro dev server is already running.",
96
+ "",
97
+ ` URL: ${existingServer.url}`,
98
+ ` PID: ${existingServer.pid}`,
99
+ "",
100
+ `Run \`astro dev stop\` to stop it, or use \`astro dev --force\` to replace it.`
101
+ ].join("\n");
102
+ throw new Error(message);
103
+ }
95
104
  }
96
105
  const inlineConfig = flagsToAstroInlineConfig(flags);
97
106
  const server = await devServer(inlineConfig);
@@ -1,10 +1,5 @@
1
1
  import { pathToFileURL } from "node:url";
2
- import {
3
- checkExistingServer,
4
- removeLockFile,
5
- isProcessAlive,
6
- GRACEFUL_SHUTDOWN_TIMEOUT
7
- } from "../../core/dev/lockfile.js";
2
+ import { checkExistingServer, killDevServer } from "../../core/dev/lockfile.js";
8
3
  import { resolveRoot } from "../../core/config/config.js";
9
4
  function formatStopOutput(result) {
10
5
  return JSON.stringify(result);
@@ -19,22 +14,7 @@ async function stop({
19
14
  logger.info("SKIP_FORMAT", "No dev server is running.");
20
15
  return;
21
16
  }
22
- try {
23
- process.kill(existing.pid, "SIGTERM");
24
- } catch {
25
- }
26
- const deadline = Date.now() + GRACEFUL_SHUTDOWN_TIMEOUT;
27
- while (Date.now() < deadline) {
28
- if (!isProcessAlive(existing.pid)) break;
29
- await new Promise((r) => setTimeout(r, 100));
30
- }
31
- if (isProcessAlive(existing.pid)) {
32
- try {
33
- process.kill(existing.pid, "SIGKILL");
34
- } catch {
35
- }
36
- }
37
- removeLockFile(root);
17
+ await killDevServer(root, existing);
38
18
  logger.info("SKIP_FORMAT", `Stopped dev server (pid ${existing.pid}).`);
39
19
  }
40
20
  export {
@@ -1,6 +1,6 @@
1
1
  class BuildTimeAstroVersionProvider {
2
2
  // Injected during the build through esbuild define
3
- version = "7.0.7";
3
+ version = "7.0.8";
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.7") {
200
+ if (previousAstroVersion && previousAstroVersion !== "7.0.8") {
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.7") {
209
- this.#store.metaStore().set("astro-version", "7.0.7");
208
+ if ("7.0.8") {
209
+ this.#store.metaStore().set("astro-version", "7.0.8");
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.7";
1
+ const ASTRO_VERSION = "7.0.8";
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.7";
29
+ const currentVersion = "7.0.8";
30
30
  const isPrerelease = currentVersion.includes("-");
31
31
  if (!isPrerelease) {
32
32
  try {
@@ -48,6 +48,14 @@ export declare function removeLockFile(root: URL): void;
48
48
  * This is the pure decision logic, separated from I/O for testability.
49
49
  */
50
50
  export declare function evaluateExistingServer(data: LockFileData | null, alive: boolean): ExistingServer | null;
51
+ /**
52
+ * Kill the dev server identified by `data` and clean up its lock file.
53
+ *
54
+ * Sends SIGTERM and waits up to {@link GRACEFUL_SHUTDOWN_TIMEOUT} for the
55
+ * process to exit, escalating to SIGKILL if it is still alive. The lock file
56
+ * is always removed afterwards so a new server can start.
57
+ */
58
+ export declare function killDevServer(root: URL, data: LockFileData): Promise<void>;
51
59
  /**
52
60
  * Check for an existing dev server by reading the lock file and checking process liveness.
53
61
  * Automatically cleans up stale lock files.
@@ -80,6 +80,24 @@ function evaluateExistingServer(data, alive) {
80
80
  }
81
81
  return { data, stale: !alive };
82
82
  }
83
+ async function killDevServer(root, data) {
84
+ try {
85
+ process.kill(data.pid, "SIGTERM");
86
+ } catch {
87
+ }
88
+ const deadline = Date.now() + GRACEFUL_SHUTDOWN_TIMEOUT;
89
+ while (Date.now() < deadline) {
90
+ if (!isProcessAlive(data.pid)) break;
91
+ await new Promise((r) => setTimeout(r, 100));
92
+ }
93
+ if (isProcessAlive(data.pid)) {
94
+ try {
95
+ process.kill(data.pid, "SIGKILL");
96
+ } catch {
97
+ }
98
+ }
99
+ removeLockFile(root);
100
+ }
83
101
  function checkExistingServer(root) {
84
102
  const data = readLockFile(root);
85
103
  const result = evaluateExistingServer(data, data !== null && isProcessAlive(data.pid));
@@ -98,6 +116,7 @@ export {
98
116
  evaluateExistingServer,
99
117
  getLogFileURL,
100
118
  isProcessAlive,
119
+ killDevServer,
101
120
  parseLockFile,
102
121
  readLockFile,
103
122
  removeLockFile,
@@ -10,14 +10,13 @@ export interface HeadPropagator {
10
10
  * its children, and one of those children may be a `self` component that emits
11
11
  * styles. Slots add a second way to find them — a slot whose markup contains an
12
12
  * `await` only reaches the components after that `await` once it resolves, so
13
- * we also wait for those pending slot pre-renders. We keep initializing
14
- * propagators and waiting on slots until no new ones appear.
13
+ * the pending slot pre-renders are fully drained before moving on to the next
14
+ * propagator.
15
15
  *
16
- * Propagators are tracked in a `seen` set rather than read through a single
17
- * live `Set` iterator. A propagator can be registered after we have already
18
- * iterated to the end of the set (e.g. once a slot's `await` resolves), and a
19
- * `Set` iterator that has reported `done` would never report those late
20
- * additions.
16
+ * A single pass over the live `Set` reaches every late registration: a `Set`
17
+ * iterator visits entries added during iteration (in insertion order), and
18
+ * because slots are drained before the iterator advances, nothing can register
19
+ * a propagator after the iterator has reported `done`.
21
20
  *
22
21
  * @example
23
22
  * If a layout initializes and discovers a nested component that also emits
@@ -1,25 +1,19 @@
1
1
  async function collectPropagatedHeadParts(input) {
2
2
  const collectedHeadParts = [];
3
- const seen = /* @__PURE__ */ new Set();
4
3
  const pendingSlotEvaluations = input.result._metadata?.pendingSlotEvaluations ?? [];
5
- while (true) {
6
- if (pendingSlotEvaluations.length > 0) {
4
+ const drainPendingSlots = async () => {
5
+ while (pendingSlotEvaluations.length > 0) {
7
6
  const batch = pendingSlotEvaluations.splice(0, pendingSlotEvaluations.length);
8
7
  await Promise.all(batch);
9
- continue;
10
8
  }
11
- let progressed = false;
12
- for (const propagator of input.propagators) {
13
- if (seen.has(propagator)) continue;
14
- seen.add(propagator);
15
- progressed = true;
16
- const returnValue = await propagator.init(input.result);
17
- if (input.isHeadAndContent(returnValue) && returnValue.head) {
18
- collectedHeadParts.push(returnValue.head);
19
- }
20
- break;
9
+ };
10
+ await drainPendingSlots();
11
+ for (const propagator of input.propagators) {
12
+ const returnValue = await propagator.init(input.result);
13
+ if (input.isHeadAndContent(returnValue) && returnValue.head) {
14
+ collectedHeadParts.push(returnValue.head);
21
15
  }
22
- if (!progressed) break;
16
+ await drainPendingSlots();
23
17
  }
24
18
  return collectedHeadParts;
25
19
  }
@@ -269,7 +269,7 @@ function printHelp({
269
269
  message.push(
270
270
  linebreak(),
271
271
  ` ${bgGreen(black(` ${commandName} `))} ${green(
272
- `v${"7.0.7"}`
272
+ `v${"7.0.8"}`
273
273
  )} ${headline}`
274
274
  );
275
275
  }
@@ -69,6 +69,7 @@ async function preview(inlineConfig) {
69
69
  logger: new AstroIntegrationLogger(logger.options, settings.adapter.name),
70
70
  headers: settings.config.server.headers,
71
71
  allowedHosts: settings.config.server.allowedHosts,
72
+ open: settings.config.server.open,
72
73
  root: settings.config.root
73
74
  });
74
75
  return server;
@@ -1,7 +1,11 @@
1
+ import { hasFileExtension } from "@astrojs/internal-helpers/path";
1
2
  import { trimSlashes } from "../path.js";
2
3
  import { getRouteGenerator } from "./generator.js";
3
4
  import { validateGetStaticPathsParameter } from "./internal/validation.js";
4
5
  function stringifyParams(params, route, trailingSlash) {
6
+ if (route.type === "endpoint" && hasFileExtension(route.route)) {
7
+ trailingSlash = "never";
8
+ }
5
9
  const validatedParams = {};
6
10
  for (const [key, value] of Object.entries(params)) {
7
11
  validateGetStaticPathsParameter([key, value], route.component);
@@ -120,6 +120,25 @@ export interface AstroGlobal<Props extends Record<string, any> = Record<string,
120
120
  render(slotName: string, args?: any[]): Promise<string>;
121
121
  };
122
122
  }
123
+ /**
124
+ * A type containing functions for logging messages.
125
+ *
126
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#logger)
127
+ */
128
+ export interface AstroRuntimeLogger {
129
+ /**
130
+ * Logs a message with `info` level.
131
+ */
132
+ info: (msg: string) => void;
133
+ /**
134
+ * Logs a message with `warn` level.
135
+ */
136
+ warn: (msg: string) => void;
137
+ /**
138
+ * Logs a message with `error` level.
139
+ */
140
+ error: (msg: string) => void;
141
+ }
123
142
  /**
124
143
  * The `APIContext` is the object made available to endpoints and middleware.
125
144
  * It is a subset of the `Astro` global object available in pages.
@@ -533,20 +552,7 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
533
552
  /**
534
553
  * It exposes utilities for logging messages.
535
554
  */
536
- logger: {
537
- /**
538
- * Logs a message with `info` level.
539
- */
540
- info: (msg: string) => void;
541
- /**
542
- * Logs a message with `warn` level.
543
- */
544
- warn: (msg: string) => void;
545
- /**
546
- * Logs a message with `error` level.
547
- */
548
- error: (msg: string) => void;
549
- };
555
+ logger: AstroRuntimeLogger;
550
556
  /**
551
557
  * The route currently rendered. It's stripped of the `srcDir` and the `pages` folder, and it doesn't contain the extension.
552
558
  *
@@ -21,6 +21,11 @@ export interface PreviewServerParams {
21
21
  * If the `Host` header doesn't match one of the allowed hosts, the server will return a 403 response.
22
22
  */
23
23
  allowedHosts?: string[] | true;
24
+ /**
25
+ * Controls whether the preview server should open in the browser on startup.
26
+ * Pass a full URL string (e.g. "http://example.com") or a pathname (e.g. "/about") to specify the URL to open.
27
+ */
28
+ open?: string | boolean;
24
29
  root: URL;
25
30
  }
26
31
  export type CreatePreviewServer = (params: PreviewServerParams) => PreviewServer | Promise<PreviewServer>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "7.0.7",
3
+ "version": "7.0.8",
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",
@@ -96,7 +96,7 @@
96
96
  "README.md"
97
97
  ],
98
98
  "dependencies": {
99
- "@astrojs/compiler-rs": "^0.3.0",
99
+ "@astrojs/compiler-rs": "^0.3.1",
100
100
  "@capsizecss/unpack": "^4.0.0",
101
101
  "@clack/prompts": "^1.1.0",
102
102
  "@oslojs/encoding": "^1.1.0",
@@ -146,8 +146,8 @@
146
146
  "xxhash-wasm": "^1.1.0",
147
147
  "yargs-parser": "^22.0.0",
148
148
  "zod": "^4.3.6",
149
- "@astrojs/markdown-satteri": "0.3.3",
150
149
  "@astrojs/internal-helpers": "0.10.1",
150
+ "@astrojs/markdown-satteri": "0.3.4",
151
151
  "@astrojs/telemetry": "3.3.3"
152
152
  },
153
153
  "optionalDependencies": {
@@ -186,8 +186,8 @@
186
186
  "typescript": "^6.0.3",
187
187
  "undici": "^7.22.0",
188
188
  "vitest": "^4.1.0",
189
- "@astrojs/markdown-remark": "7.2.1",
190
189
  "@astrojs/check": "0.9.9",
190
+ "@astrojs/markdown-remark": "7.2.1",
191
191
  "astro-scripts": "0.0.14"
192
192
  },
193
193
  "engines": {