astro 5.1.6 → 5.1.7

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.
@@ -84,10 +84,14 @@ const getSizesAttribute = ({
84
84
  return void 0;
85
85
  }
86
86
  switch (layout) {
87
+ // If screen is wider than the max size then image width is the max size,
88
+ // otherwise it's the width of the screen
87
89
  case `responsive`:
88
90
  return `(min-width: ${width}px) ${width}px, 100vw`;
91
+ // Image is always the same width, whatever the size of the screen
89
92
  case `fixed`:
90
93
  return `${width}px`;
94
+ // Image is always the width of the screen
91
95
  case `full-width`:
92
96
  return `100vw`;
93
97
  case "none":
@@ -307,6 +307,8 @@ async function add(names, { flags }) {
307
307
  logger.info("SKIP_FORMAT", msg.success(`Configuration up-to-date.`));
308
308
  break;
309
309
  }
310
+ // NOTE: failure shouldn't happen in practice because `updateAstroConfig` doesn't return that.
311
+ // Pipe this to the same handling as `UpdateResult.updated` for now.
310
312
  case 3 /* failure */:
311
313
  case 1 /* updated */:
312
314
  case void 0: {
@@ -148,7 +148,7 @@ ${contentConfig.error.message}`);
148
148
  logger.info("Content config changed");
149
149
  shouldClear = true;
150
150
  }
151
- if (previousAstroVersion && previousAstroVersion !== "5.1.6") {
151
+ if (previousAstroVersion && previousAstroVersion !== "5.1.7") {
152
152
  logger.info("Astro version changed");
153
153
  shouldClear = true;
154
154
  }
@@ -156,8 +156,8 @@ ${contentConfig.error.message}`);
156
156
  logger.info("Clearing content store");
157
157
  this.#store.clearAll();
158
158
  }
159
- if ("5.1.6") {
160
- await this.#store.metaStore().set("astro-version", "5.1.6");
159
+ if ("5.1.7") {
160
+ await this.#store.metaStore().set("astro-version", "5.1.7");
161
161
  }
162
162
  if (currentConfigDigest) {
163
163
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "5.1.6";
1
+ const ASTRO_VERSION = "5.1.7";
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 = "5.1.6";
25
+ const currentVersion = "5.1.7";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -38,7 +38,7 @@ function serverStart({
38
38
  host,
39
39
  base
40
40
  }) {
41
- const version = "5.1.6";
41
+ const version = "5.1.7";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -276,7 +276,7 @@ function printHelp({
276
276
  message.push(
277
277
  linebreak(),
278
278
  ` ${bgGreen(black(` ${commandName} `))} ${green(
279
- `v${"5.1.6"}`
279
+ `v${"5.1.7"}`
280
280
  )} ${headline}`
281
281
  );
282
282
  }
@@ -4,6 +4,8 @@ import type { RouteData } from '../../types/public/internal.js';
4
4
  export declare function matchRoute(pathname: string, manifest: ManifestData): RouteData | undefined;
5
5
  /** Finds all matching routes from pathname */
6
6
  export declare function matchAllRoutes(pathname: string, manifest: ManifestData): RouteData[];
7
+ export declare function isRoute404(route: string): boolean;
8
+ export declare function isRoute500(route: string): boolean;
7
9
  /**
8
10
  * Determines if the given route matches a 404 or 500 error page.
9
11
  *
@@ -7,11 +7,21 @@ function matchRoute(pathname, manifest) {
7
7
  function matchAllRoutes(pathname, manifest) {
8
8
  return manifest.routes.filter((route) => route.pattern.test(decodeURI(pathname)));
9
9
  }
10
+ const ROUTE404_RE = /^\/404\/?$/;
11
+ const ROUTE500_RE = /^\/500\/?$/;
12
+ function isRoute404(route) {
13
+ return ROUTE404_RE.test(route);
14
+ }
15
+ function isRoute500(route) {
16
+ return ROUTE500_RE.test(route);
17
+ }
10
18
  function isRoute404or500(route) {
11
- return route.pattern.test("/404") || route.pattern.test("/500");
19
+ return isRoute404(route.route) || isRoute500(route.route);
12
20
  }
13
21
  export {
22
+ isRoute404,
14
23
  isRoute404or500,
24
+ isRoute500,
15
25
  matchAllRoutes,
16
26
  matchRoute
17
27
  };
@@ -3,6 +3,7 @@ import { shouldAppendForwardSlash } from "../core/build/util.js";
3
3
  import { REROUTE_DIRECTIVE_HEADER } from "../core/constants.js";
4
4
  import { MissingLocale, i18nNoLocaleFoundInPath } from "../core/errors/errors-data.js";
5
5
  import { AstroError } from "../core/errors/index.js";
6
+ import { isRoute404, isRoute500 } from "../core/routing/match.js";
6
7
  import { createI18nMiddleware } from "./middleware.js";
7
8
  function requestHasLocale(locales) {
8
9
  return function(context) {
@@ -11,7 +12,8 @@ function requestHasLocale(locales) {
11
12
  }
12
13
  function requestIs404Or500(request, base = "") {
13
14
  const url = new URL(request.url);
14
- return url.pathname.startsWith(`${base}/404`) || url.pathname.startsWith(`${base}/500`);
15
+ const pathname = url.pathname.slice(base.length);
16
+ return isRoute404(pathname) || isRoute500(pathname);
15
17
  }
16
18
  function pathHasLocale(path, locales) {
17
19
  const segments = path.split("/");
@@ -60,6 +60,7 @@ function createI18nMiddleware(i18n, base, trailingSlash, format) {
60
60
  }
61
61
  const { currentLocale } = context;
62
62
  switch (i18n.strategy) {
63
+ // NOTE: theoretically, we should never hit this code path
63
64
  case "manual": {
64
65
  return response;
65
66
  }
@@ -111,14 +111,17 @@ function findMatchingImport(tagName, imports) {
111
111
  if (local === tagSpecifier) {
112
112
  if (tagSpecifier !== tagName) {
113
113
  switch (imported) {
114
+ // Namespace import: "<buttons.Foo.Bar />" => name: "Foo.Bar"
114
115
  case "*": {
115
116
  const accessPath = tagName.slice(tagSpecifier.length + 1);
116
117
  return { name: accessPath, path: source };
117
118
  }
119
+ // Default import: "<buttons.Foo.Bar />" => name: "default.Foo.Bar"
118
120
  case "default": {
119
121
  const accessPath = tagName.slice(tagSpecifier.length + 1);
120
122
  return { name: `default.${accessPath}`, path: source };
121
123
  }
124
+ // Named import: "<buttons.Foo.Bar />" => name: "buttons.Foo.Bar"
122
125
  default: {
123
126
  return { name: tagName, path: source };
124
127
  }
@@ -37,6 +37,8 @@ function extractDirectives(inputProps, clientDirectives) {
37
37
  extracted.hydration.componentExport.value = value;
38
38
  break;
39
39
  }
40
+ // This is a special prop added to prove that the client hydration method
41
+ // was added statically.
40
42
  case "client:component-hydration": {
41
43
  break;
42
44
  }
@@ -14,6 +14,7 @@ import { getProps } from "../core/render/index.js";
14
14
  import { createRequest } from "../core/request.js";
15
15
  import { redirectTemplate } from "../core/routing/3xx.js";
16
16
  import { matchAllRoutes } from "../core/routing/index.js";
17
+ import { isRoute404, isRoute500 } from "../core/routing/match.js";
17
18
  import { PERSIST_SYMBOL } from "../core/session.js";
18
19
  import { getSortedPreloadedMatches } from "../prerender/routing.js";
19
20
  import { writeSSRResult, writeWebResponse } from "./response.js";
@@ -21,12 +22,10 @@ function isLoggedRequest(url) {
21
22
  return url !== "/favicon.ico";
22
23
  }
23
24
  function getCustom404Route(manifestData) {
24
- const route404 = /^\/404\/?$/;
25
- return manifestData.routes.find((r) => route404.test(r.route));
25
+ return manifestData.routes.find((r) => isRoute404(r.route));
26
26
  }
27
27
  function getCustom500Route(manifestData) {
28
- const route500 = /^\/500\/?$/;
29
- return manifestData.routes.find((r) => route500.test(r.route));
28
+ return manifestData.routes.find((r) => isRoute500(r.route));
30
29
  }
31
30
  async function matchRoute(pathname, manifestData, pipeline) {
32
31
  const { config, logger, routeCache, serverLike, settings } = pipeline;
@@ -175,7 +174,9 @@ async function handleRoute({
175
174
  })
176
175
  );
177
176
  }
178
- if (statusCode === 404 && response.headers.get(REROUTE_DIRECTIVE_HEADER) !== "no") {
177
+ if (statusCode === 404 && // If the body isn't null, that means the user sets the 404 status
178
+ // but uses the current route to handle the 404
179
+ response.body === null && response.headers.get(REROUTE_DIRECTIVE_HEADER) !== "no") {
179
180
  const fourOhFourRoute = await matchRoute("/404", manifestData, pipeline);
180
181
  if (fourOhFourRoute) {
181
182
  renderContext = await RenderContext.create({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.1.6",
3
+ "version": "5.1.7",
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",
@@ -105,7 +105,7 @@
105
105
  "dependencies": {
106
106
  "@astrojs/compiler": "^2.10.3",
107
107
  "@oslojs/encoding": "^1.1.0",
108
- "@rollup/pluginutils": "^5.1.3",
108
+ "@rollup/pluginutils": "^5.1.4",
109
109
  "@types/cookie": "^0.6.0",
110
110
  "acorn": "^8.14.0",
111
111
  "aria-query": "^5.3.2",
@@ -116,51 +116,51 @@
116
116
  "common-ancestor-path": "^1.0.1",
117
117
  "cookie": "^0.7.2",
118
118
  "cssesc": "^3.0.0",
119
- "debug": "^4.3.7",
119
+ "debug": "^4.4.0",
120
120
  "deterministic-object-hash": "^2.0.2",
121
121
  "devalue": "^5.1.1",
122
122
  "diff": "^5.2.0",
123
123
  "dlv": "^1.1.3",
124
124
  "dset": "^3.1.4",
125
- "es-module-lexer": "^1.5.4",
126
- "esbuild": "^0.21.5",
125
+ "es-module-lexer": "^1.6.0",
126
+ "esbuild": "^0.24.2",
127
127
  "estree-walker": "^3.0.3",
128
- "fast-glob": "^3.3.2",
128
+ "fast-glob": "^3.3.3",
129
129
  "flattie": "^1.1.1",
130
130
  "github-slugger": "^2.0.0",
131
131
  "html-escaper": "^3.0.3",
132
132
  "http-cache-semantics": "^4.1.1",
133
133
  "js-yaml": "^4.1.0",
134
134
  "kleur": "^4.1.5",
135
- "magic-string": "^0.30.14",
135
+ "magic-string": "^0.30.17",
136
136
  "magicast": "^0.3.5",
137
137
  "micromatch": "^4.0.8",
138
138
  "mrmime": "^2.0.0",
139
139
  "neotraverse": "^0.6.18",
140
- "p-limit": "^6.1.0",
140
+ "p-limit": "^6.2.0",
141
141
  "p-queue": "^8.0.1",
142
142
  "preferred-pm": "^4.0.0",
143
143
  "prompts": "^2.4.2",
144
144
  "rehype": "^13.0.2",
145
145
  "semver": "^7.6.3",
146
- "shiki": "^1.23.1",
147
- "tinyexec": "^0.3.1",
146
+ "shiki": "^1.26.2",
147
+ "tinyexec": "^0.3.2",
148
148
  "tsconfck": "^3.1.4",
149
149
  "ultrahtml": "^1.5.3",
150
150
  "unist-util-visit": "^5.0.0",
151
- "unstorage": "^1.14.0",
151
+ "unstorage": "^1.14.4",
152
152
  "vfile": "^6.0.3",
153
- "vite": "^6.0.5",
154
- "vitefu": "^1.0.4",
153
+ "vite": "^6.0.7",
154
+ "vitefu": "^1.0.5",
155
155
  "which-pm": "^3.0.0",
156
156
  "xxhash-wasm": "^1.1.0",
157
157
  "yargs-parser": "^21.1.1",
158
- "yocto-spinner": "^0.1.0",
159
- "zod": "^3.23.8",
160
- "zod-to-json-schema": "^3.23.5",
158
+ "yocto-spinner": "^0.1.2",
159
+ "zod": "^3.24.1",
160
+ "zod-to-json-schema": "^3.24.1",
161
161
  "zod-to-ts": "^1.2.0",
162
162
  "@astrojs/internal-helpers": "0.4.2",
163
- "@astrojs/markdown-remark": "6.0.1",
163
+ "@astrojs/markdown-remark": "6.0.2",
164
164
  "@astrojs/telemetry": "3.2.0"
165
165
  },
166
166
  "optionalDependencies": {
@@ -168,7 +168,7 @@
168
168
  },
169
169
  "devDependencies": {
170
170
  "@astrojs/check": "^0.9.4",
171
- "@playwright/test": "^1.49.0",
171
+ "@playwright/test": "^1.49.1",
172
172
  "@types/aria-query": "^5.0.4",
173
173
  "@types/common-ancestor-path": "^1.0.2",
174
174
  "@types/cssesc": "^3.0.2",
@@ -189,18 +189,18 @@
189
189
  "expect-type": "^1.1.0",
190
190
  "fs-fixture": "^2.6.0",
191
191
  "mdast-util-mdx": "^3.0.0",
192
- "mdast-util-mdx-jsx": "^3.1.3",
193
- "node-mocks-http": "^1.16.1",
192
+ "mdast-util-mdx-jsx": "^3.2.0",
193
+ "node-mocks-http": "^1.16.2",
194
194
  "parse-srcset": "^1.0.2",
195
195
  "rehype-autolink-headings": "^7.1.0",
196
196
  "rehype-slug": "^6.0.0",
197
197
  "rehype-toc": "^3.0.2",
198
198
  "remark-code-titles": "^0.1.2",
199
- "rollup": "^4.27.4",
200
- "sass": "^1.81.0",
201
- "undici": "^7.2.0",
199
+ "rollup": "^4.30.1",
200
+ "sass": "^1.83.1",
201
+ "undici": "^7.2.1",
202
202
  "unified": "^11.0.5",
203
- "vitest": "^3.0.0-beta.3",
203
+ "vitest": "^3.0.0-beta.4",
204
204
  "astro-scripts": "0.0.14"
205
205
  },
206
206
  "engines": {