astro 4.11.3 → 4.11.4

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.
@@ -648,10 +648,12 @@ export interface AstroUserConfig {
648
648
  * @default `true`
649
649
  * @description
650
650
  *
651
- * This is an option to minify your HTML output and reduce the size of your HTML files, occuring both in development mode and in the final build.
652
- * By default, Astro removes whitespace from your HTML, including line breaks, from .astro components in a lossless manner.
653
- * It is important to note that some whitespace may be kept to preserve the visual rendering of your HTML.
654
- * To disable HTML compression, set the compressHTML flag to false.
651
+ * This is an option to minify your HTML output and reduce the size of your HTML files.
652
+ *
653
+ * By default, Astro removes whitespace from your HTML, including line breaks, from `.astro` components in a lossless manner.
654
+ * Some whitespace may be kept as needed to preserve the visual rendering of your HTML. This occurs both in development mode and in the final build.
655
+ *
656
+ * To disable HTML compression, set `compressHTML` to false.
655
657
  *
656
658
  * ```js
657
659
  * {
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.11.3";
1
+ const ASTRO_VERSION = "4.11.4";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
4
4
  const DEFAULT_404_COMPONENT = "astro-default-404.astro";
@@ -19,7 +19,7 @@ async function dev(inlineConfig) {
19
19
  await telemetry.record([]);
20
20
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
21
21
  const logger = restart.container.logger;
22
- const currentVersion = "4.11.3";
22
+ const currentVersion = "4.11.4";
23
23
  const isPrerelease = currentVersion.includes("-");
24
24
  if (!isPrerelease) {
25
25
  try {
@@ -76,7 +76,7 @@ const style = (
76
76
  --astro-code-token-parameter: #aa0000;
77
77
  --astro-code-token-function: #4ca48f;
78
78
  --astro-code-token-string-expression: #9f722a;
79
- --astro-code-token-punctuation: #ffffff;
79
+ --astro-code-token-punctuation: #000000;
80
80
  --astro-code-token-link: #9f722a;
81
81
  }
82
82
 
@@ -37,7 +37,7 @@ function serverStart({
37
37
  host,
38
38
  base
39
39
  }) {
40
- const version = "4.11.3";
40
+ const version = "4.11.4";
41
41
  const localPrefix = `${dim("\u2503")} Local `;
42
42
  const networkPrefix = `${dim("\u2503")} Network `;
43
43
  const emptyPrefix = " ".repeat(11);
@@ -269,7 +269,7 @@ function printHelp({
269
269
  message.push(
270
270
  linebreak(),
271
271
  ` ${bgGreen(black(` ${commandName} `))} ${green(
272
- `v${"4.11.3"}`
272
+ `v${"4.11.4"}`
273
273
  )} ${headline}`
274
274
  );
275
275
  }
@@ -113,8 +113,9 @@ class RenderContext {
113
113
  this.routeData = routeData;
114
114
  componentInstance = component;
115
115
  this.isRewriting = true;
116
+ this.status = 200;
116
117
  } else {
117
- this.pipeline.logger.warn(
118
+ this.pipeline.logger.error(
118
119
  "router",
119
120
  "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
120
121
  );
@@ -179,30 +180,47 @@ class RenderContext {
179
180
  getActionResult: createGetActionResult(context.locals)
180
181
  });
181
182
  }
183
+ async #executeRewrite(reroutePayload) {
184
+ this.pipeline.logger.debug("router", "Calling rewrite: ", reroutePayload);
185
+ if (!this.pipeline.manifest.rewritingEnabled) {
186
+ this.pipeline.logger.error(
187
+ "router",
188
+ "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
189
+ );
190
+ return new Response(
191
+ "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config.",
192
+ {
193
+ status: 500,
194
+ statusText: "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
195
+ }
196
+ );
197
+ }
198
+ const [routeData, component, newURL] = await this.pipeline.tryRewrite(
199
+ reroutePayload,
200
+ this.request,
201
+ this.originalRoute
202
+ );
203
+ this.routeData = routeData;
204
+ if (reroutePayload instanceof Request) {
205
+ this.request = reroutePayload;
206
+ } else {
207
+ this.request = this.#copyRequest(newURL, this.request);
208
+ }
209
+ this.url = new URL(this.request.url);
210
+ this.cookies = new AstroCookies(this.request);
211
+ this.params = getParams(routeData, this.url.pathname);
212
+ this.pathname = this.url.pathname;
213
+ this.isRewriting = true;
214
+ this.status = 200;
215
+ return await this.render(component);
216
+ }
182
217
  createActionAPIContext() {
183
218
  const renderContext = this;
184
219
  const { cookies, params, pipeline, url } = this;
185
220
  const generator = `Astro v${ASTRO_VERSION}`;
186
221
  const redirect = (path, status = 302) => new Response(null, { status, headers: { Location: path } });
187
222
  const rewrite = async (reroutePayload) => {
188
- pipeline.logger.debug("router", "Called rewriting to:", reroutePayload);
189
- const [routeData, component, newURL] = await pipeline.tryRewrite(
190
- reroutePayload,
191
- this.request,
192
- this.originalRoute
193
- );
194
- this.routeData = routeData;
195
- if (reroutePayload instanceof Request) {
196
- this.request = reroutePayload;
197
- } else {
198
- this.request = this.#copyRequest(newURL, this.request);
199
- }
200
- this.url = newURL;
201
- this.cookies = new AstroCookies(this.request);
202
- this.params = getParams(routeData, this.url.pathname);
203
- this.isRewriting = true;
204
- this.pathname = this.url.pathname;
205
- return await this.render(component);
223
+ return await this.#executeRewrite(reroutePayload);
206
224
  };
207
225
  return {
208
226
  cookies,
@@ -345,24 +363,7 @@ class RenderContext {
345
363
  return new Response(null, { status, headers: { Location: path } });
346
364
  };
347
365
  const rewrite = async (reroutePayload) => {
348
- pipeline.logger.debug("router", "Calling rewrite: ", reroutePayload);
349
- const [routeData, component, newURL] = await pipeline.tryRewrite(
350
- reroutePayload,
351
- this.request,
352
- this.originalRoute
353
- );
354
- this.routeData = routeData;
355
- if (reroutePayload instanceof Request) {
356
- this.request = reroutePayload;
357
- } else {
358
- this.request = this.#copyRequest(newURL, this.request);
359
- }
360
- this.url = new URL(this.request.url);
361
- this.cookies = new AstroCookies(this.request);
362
- this.params = getParams(routeData, this.url.pathname);
363
- this.pathname = this.url.pathname;
364
- this.isRewriting = true;
365
- return await this.render(component);
366
+ return await this.#executeRewrite(reroutePayload);
366
367
  };
367
368
  return {
368
369
  generator: astroStaticPartial.generator,
@@ -2,8 +2,6 @@ import { clsx } from "clsx";
2
2
  import { HTMLString, markHTMLString } from "../escape.js";
3
3
  const voidElementNames = /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
4
4
  const htmlBooleanAttributes = /^(?:allowfullscreen|async|autofocus|autoplay|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|hidden|loop|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|itemscope)$/i;
5
- const htmlEnumAttributes = /^(?:contenteditable|draggable|spellcheck|value)$/i;
6
- const svgEnumAttributes = /^(?:autoReverse|externalResourcesRequired|focusable|preserveAlpha)$/i;
7
5
  const AMPERSAND_REGEX = /&/g;
8
6
  const DOUBLE_QUOTE_REGEX = /"/g;
9
7
  const STATIC_DIRECTIVES = /* @__PURE__ */ new Set(["set:html", "set:text"]);
@@ -38,12 +36,6 @@ function addAttribute(value, key, shouldEscape = true) {
38
36
  if (value == null) {
39
37
  return "";
40
38
  }
41
- if (value === false) {
42
- if (htmlEnumAttributes.test(key) || svgEnumAttributes.test(key)) {
43
- return markHTMLString(` ${key}="false"`);
44
- }
45
- return "";
46
- }
47
39
  if (STATIC_DIRECTIVES.has(key)) {
48
40
  console.warn(`[astro] The "${key}" directive cannot be applied dynamically at runtime. It will not be rendered as an attribute.
49
41
 
@@ -73,11 +65,13 @@ Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the
73
65
  if (typeof value === "string" && value.includes("&") && isHttpUrl(value)) {
74
66
  return markHTMLString(` ${key}="${toAttributeString(value, false)}"`);
75
67
  }
76
- if (value === true && (key.startsWith("data-") || htmlBooleanAttributes.test(key))) {
68
+ if (htmlBooleanAttributes.test(key)) {
69
+ return markHTMLString(value ? ` ${key}` : "");
70
+ }
71
+ if (value === "") {
77
72
  return markHTMLString(` ${key}`);
78
- } else {
79
- return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
80
73
  }
74
+ return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
81
75
  }
82
76
  function internalSpreadAttributes(values, shouldEscape = true) {
83
77
  let output = "";
@@ -9,7 +9,7 @@ const { trailingSlash, format, site, i18n, isBuild } = (
9
9
  );
10
10
  const { defaultLocale, locales, domains, fallback, routing } = i18n;
11
11
  const base = import.meta.env.BASE_URL;
12
- const strategy = toRoutingStrategy(routing, domains);
12
+ let strategy = toRoutingStrategy(routing, domains);
13
13
  const noop = (method) => function() {
14
14
  throw new AstroError({
15
15
  ...IncorrectStrategyForI18n,
@@ -123,10 +123,11 @@ if (i18n?.routing === "manual") {
123
123
  let middleware;
124
124
  if (i18n?.routing === "manual") {
125
125
  middleware = (customOptions) => {
126
+ strategy = toRoutingStrategy(customOptions, {});
126
127
  const manifest = {
127
128
  ...i18n,
128
129
  fallback: void 0,
129
- strategy: toRoutingStrategy(customOptions, {}),
130
+ strategy,
130
131
  domainLookupTable: {}
131
132
  };
132
133
  return I18nInternals.createMiddleware(manifest, base, trailingSlash, format);
@@ -11,9 +11,8 @@ import { getProps } from "../core/render/index.js";
11
11
  import { createRequest } from "../core/request.js";
12
12
  import { default404Page } from "../core/routing/astro-designed-error-pages.js";
13
13
  import { matchAllRoutes } from "../core/routing/index.js";
14
- import { normalizeTheLocale } from "../i18n/index.js";
15
14
  import { getSortedPreloadedMatches } from "../prerender/routing.js";
16
- import { handle404Response, writeSSRResult, writeWebResponse } from "./response.js";
15
+ import { writeSSRResult, writeWebResponse } from "./response.js";
17
16
  function isLoggedRequest(url) {
18
17
  return url !== "/favicon.ico";
19
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.11.3",
3
+ "version": "4.11.4",
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",
@@ -156,13 +156,13 @@
156
156
  "prompts": "^2.4.2",
157
157
  "rehype": "^13.0.1",
158
158
  "semver": "^7.6.2",
159
- "shiki": "^1.9.0",
160
- "string-width": "^7.1.0",
159
+ "shiki": "^1.10.0",
160
+ "string-width": "^7.2.0",
161
161
  "strip-ansi": "^7.1.0",
162
- "tsconfck": "^3.1.0",
162
+ "tsconfck": "^3.1.1",
163
163
  "unist-util-visit": "^5.0.0",
164
164
  "vfile": "^6.0.1",
165
- "vite": "^5.3.1",
165
+ "vite": "^5.3.2",
166
166
  "vitefu": "^0.2.5",
167
167
  "which-pm": "^2.2.0",
168
168
  "yargs-parser": "^21.1.1",
@@ -177,7 +177,7 @@
177
177
  },
178
178
  "devDependencies": {
179
179
  "@astrojs/check": "^0.7.0",
180
- "@playwright/test": "^1.44.1",
180
+ "@playwright/test": "^1.45.0",
181
181
  "@types/aria-query": "^5.0.4",
182
182
  "@types/babel__generator": "^7.6.8",
183
183
  "@types/babel__traverse": "^7.20.6",