astro 5.2.2 → 5.2.3

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.
@@ -153,7 +153,7 @@ ${contentConfig.error.message}`);
153
153
  logger.info("Content config changed");
154
154
  shouldClear = true;
155
155
  }
156
- if (previousAstroVersion && previousAstroVersion !== "5.2.2") {
156
+ if (previousAstroVersion && previousAstroVersion !== "5.2.3") {
157
157
  logger.info("Astro version changed");
158
158
  shouldClear = true;
159
159
  }
@@ -161,8 +161,8 @@ ${contentConfig.error.message}`);
161
161
  logger.info("Clearing content store");
162
162
  this.#store.clearAll();
163
163
  }
164
- if ("5.2.2") {
165
- await this.#store.metaStore().set("astro-version", "5.2.2");
164
+ if ("5.2.3") {
165
+ await this.#store.metaStore().set("astro-version", "5.2.3");
166
166
  }
167
167
  if (currentConfigDigest) {
168
168
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "5.2.2";
1
+ const ASTRO_VERSION = "5.2.3";
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.2.2";
25
+ const currentVersion = "5.2.3";
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.2.2";
41
+ const version = "5.2.3";
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.2.2"}`
279
+ `v${"5.2.3"}`
280
280
  )} ${headline}`
281
281
  );
282
282
  }
@@ -24,9 +24,8 @@ import { callMiddleware } from "./middleware/callMiddleware.js";
24
24
  import { sequence } from "./middleware/index.js";
25
25
  import { renderRedirect } from "./redirects/render.js";
26
26
  import { Slots, getParams, getProps } from "./render/index.js";
27
- import { isRoute404or500 } from "./routing/match.js";
27
+ import { isRoute404or500, isRouteServerIsland } from "./routing/match.js";
28
28
  import { copyRequest, getOriginPathname, setOriginPathname } from "./routing/rewrite.js";
29
- import { SERVER_ISLAND_COMPONENT } from "./server-islands/endpoint.js";
30
29
  import { AstroSession } from "./session.js";
31
30
  const apiContextRoutesSymbol = Symbol.for("context.routes");
32
31
  class RenderContext {
@@ -479,7 +478,7 @@ class RenderContext {
479
478
  return this.#currentLocale;
480
479
  }
481
480
  let computedLocale;
482
- if (routeData.component === SERVER_ISLAND_COMPONENT) {
481
+ if (isRouteServerIsland(routeData)) {
483
482
  let referer = this.request.headers.get("referer");
484
483
  if (referer) {
485
484
  if (URL.canParse(referer)) {
@@ -190,8 +190,7 @@ function createInjectedRoutes({ settings, cwd }) {
190
190
  return getParts(s, component);
191
191
  });
192
192
  const type = resolved.endsWith(".astro") ? "page" : "endpoint";
193
- const isPage = type === "page";
194
- const trailingSlash = isPage ? config.trailingSlash : "never";
193
+ const { trailingSlash } = config;
195
194
  const pattern = getPattern(segments, settings.config.base, trailingSlash);
196
195
  const generate = getRouteGenerator(segments, trailingSlash);
197
196
  const pathname = segments.every((segment) => segment.length === 1 && !segment[0].dynamic) ? `/${segments.map((segment) => segment[0].content).join("/")}` : null;
@@ -13,3 +13,26 @@ export declare function isRoute500(route: string): boolean;
13
13
  * @returns {boolean} `true` if the route matches a 404 or 500 error page, otherwise `false`.
14
14
  */
15
15
  export declare function isRoute404or500(route: RouteData): boolean;
16
+ /**
17
+ * Determines if a given route is associated with the server island component.
18
+ *
19
+ * @param {RouteData} route - The route data object to evaluate.
20
+ * @return {boolean} Returns true if the route's component is the server island component, otherwise false.
21
+ */
22
+ export declare function isRouteServerIsland(route: RouteData): boolean;
23
+ /**
24
+ * Determines whether the given `Request` is targeted to a "server island" based on its URL.
25
+ *
26
+ * @param {Request} request - The request object to be evaluated.
27
+ * @param {string} [base=''] - The base path provided via configuration.
28
+ * @return {boolean} - Returns `true` if the request is for a server island, otherwise `false`.
29
+ */
30
+ export declare function isRequestServerIsland(request: Request, base?: string): boolean;
31
+ /**
32
+ * Checks if the given request corresponds to a 404 or 500 route based on the specified base path.
33
+ *
34
+ * @param {Request} request - The HTTP request object to be checked.
35
+ * @param {string} [base=''] - The base path to trim from the request's URL before checking the route. Default is an empty string.
36
+ * @return {boolean} Returns true if the request matches a 404 or 500 route; otherwise, returns false.
37
+ */
38
+ export declare function requestIs404Or500(request: Request, base?: string): boolean;
@@ -1,3 +1,4 @@
1
+ import { SERVER_ISLAND_BASE_PREFIX, SERVER_ISLAND_COMPONENT } from "../server-islands/endpoint.js";
1
2
  function matchRoute(pathname, manifest) {
2
3
  const decodedPathname = decodeURI(pathname);
3
4
  return manifest.routes.find((route) => {
@@ -18,10 +19,26 @@ function isRoute500(route) {
18
19
  function isRoute404or500(route) {
19
20
  return isRoute404(route.route) || isRoute500(route.route);
20
21
  }
22
+ function isRouteServerIsland(route) {
23
+ return route.component === SERVER_ISLAND_COMPONENT;
24
+ }
25
+ function isRequestServerIsland(request, base = "") {
26
+ const url = new URL(request.url);
27
+ const pathname = url.pathname.slice(base.length);
28
+ return pathname.startsWith(SERVER_ISLAND_BASE_PREFIX);
29
+ }
30
+ function requestIs404Or500(request, base = "") {
31
+ const url = new URL(request.url);
32
+ const pathname = url.pathname.slice(base.length);
33
+ return isRoute404(pathname) || isRoute500(pathname);
34
+ }
21
35
  export {
36
+ isRequestServerIsland,
22
37
  isRoute404,
23
38
  isRoute404or500,
24
39
  isRoute500,
40
+ isRouteServerIsland,
25
41
  matchAllRoutes,
26
- matchRoute
42
+ matchRoute,
43
+ requestIs404Or500
27
44
  };
@@ -25,9 +25,10 @@ function findRouteToRewrite({
25
25
  pathname = shouldAppendForwardSlash(trailingSlash, buildFormat) ? appendForwardSlash(newUrl.pathname) : removeTrailingForwardSlash(newUrl.pathname);
26
26
  pathname = pathname.slice(base.length);
27
27
  }
28
+ const decodedPathname = decodeURI(pathname);
28
29
  let foundRoute;
29
30
  for (const route of routes) {
30
- if (route.pattern.test(decodeURI(pathname))) {
31
+ if (route.pattern.test(decodedPathname)) {
31
32
  foundRoute = route;
32
33
  break;
33
34
  }
@@ -36,7 +37,7 @@ function findRouteToRewrite({
36
37
  return {
37
38
  routeData: foundRoute,
38
39
  newUrl,
39
- pathname
40
+ pathname: decodedPathname
40
41
  };
41
42
  } else {
42
43
  const custom404 = routes.find((route) => route.route === "/404");
@@ -2,6 +2,7 @@ import type { ComponentInstance, RoutesList } from '../../types/astro.js';
2
2
  import type { RouteData, SSRManifest } from '../../types/public/internal.js';
3
3
  export declare const SERVER_ISLAND_ROUTE = "/_server-islands/[name]";
4
4
  export declare const SERVER_ISLAND_COMPONENT = "_server-islands.astro";
5
+ export declare const SERVER_ISLAND_BASE_PREFIX = "_server-islands";
5
6
  type ConfigFields = Pick<SSRManifest, 'base' | 'trailingSlash'>;
6
7
  export declare function getServerIslandRouteData(config: ConfigFields): RouteData;
7
8
  export declare function injectServerIslandRoute(config: ConfigFields, routeManifest: RoutesList): void;
@@ -8,6 +8,7 @@ import { decryptString } from "../encryption.js";
8
8
  import { getPattern } from "../routing/manifest/pattern.js";
9
9
  const SERVER_ISLAND_ROUTE = "/_server-islands/[name]";
10
10
  const SERVER_ISLAND_COMPONENT = "_server-islands.astro";
11
+ const SERVER_ISLAND_BASE_PREFIX = "_server-islands";
11
12
  function getServerIslandRouteData(config) {
12
13
  const segments = [
13
14
  [{ content: "_server-islands", dynamic: false, spread: false }],
@@ -120,6 +121,7 @@ function createEndpoint(manifest) {
120
121
  return instance;
121
122
  }
122
123
  export {
124
+ SERVER_ISLAND_BASE_PREFIX,
123
125
  SERVER_ISLAND_COMPONENT,
124
126
  SERVER_ISLAND_ROUTE,
125
127
  createEndpoint,
@@ -3,7 +3,6 @@ import type { AstroConfig, Locales, ValidRedirectStatus } from '../types/public/
3
3
  import type { APIContext } from '../types/public/context.js';
4
4
  import type { RoutingStrategies } from './utils.js';
5
5
  export declare function requestHasLocale(locales: Locales): (context: APIContext) => boolean;
6
- export declare function requestIs404Or500(request: Request, base?: string): boolean;
7
6
  export declare function pathHasLocale(path: string, locales: Locales): boolean;
8
7
  type GetLocaleRelativeUrl = GetLocaleOptions & {
9
8
  locale: string;
@@ -3,18 +3,12 @@ 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";
7
6
  import { createI18nMiddleware } from "./middleware.js";
8
7
  function requestHasLocale(locales) {
9
8
  return function(context) {
10
9
  return pathHasLocale(context.url.pathname, locales);
11
10
  };
12
11
  }
13
- function requestIs404Or500(request, base = "") {
14
- const url = new URL(request.url);
15
- const pathname = url.pathname.slice(base.length);
16
- return isRoute404(pathname) || isRoute500(pathname);
17
- }
18
12
  function pathHasLocale(path, locales) {
19
13
  const segments = path.split("/");
20
14
  for (const segment of segments) {
@@ -276,7 +270,6 @@ export {
276
270
  redirectToDefaultLocale,
277
271
  redirectToFallback,
278
272
  requestHasLocale,
279
- requestIs404Or500,
280
273
  toCodes,
281
274
  toPaths
282
275
  };
@@ -1,11 +1,11 @@
1
1
  import { REROUTE_DIRECTIVE_HEADER, ROUTE_TYPE_HEADER } from "../core/constants.js";
2
+ import { isRequestServerIsland, requestIs404Or500 } from "../core/routing/match.js";
2
3
  import {
3
4
  normalizeTheLocale,
4
5
  notFound,
5
6
  redirectToDefaultLocale,
6
7
  redirectToFallback,
7
- requestHasLocale,
8
- requestIs404Or500
8
+ requestHasLocale
9
9
  } from "./index.js";
10
10
  function createI18nMiddleware(i18n, base, trailingSlash, format) {
11
11
  if (!i18n) return (_, next) => next();
@@ -58,6 +58,9 @@ function createI18nMiddleware(i18n, base, trailingSlash, format) {
58
58
  if (requestIs404Or500(context.request, base)) {
59
59
  return response;
60
60
  }
61
+ if (isRequestServerIsland(context.request, base)) {
62
+ return response;
63
+ }
61
64
  const { currentLocale } = context;
62
65
  switch (i18n.strategy) {
63
66
  // NOTE: theoretically, we should never hit this code path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.2.2",
3
+ "version": "5.2.3",
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",
@@ -128,7 +128,7 @@
128
128
  "fast-glob": "^3.3.3",
129
129
  "flattie": "^1.1.1",
130
130
  "github-slugger": "^2.0.0",
131
- "html-escaper": "^3.0.3",
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",
@@ -138,12 +138,12 @@
138
138
  "mrmime": "^2.0.0",
139
139
  "neotraverse": "^0.6.18",
140
140
  "p-limit": "^6.2.0",
141
- "p-queue": "^8.0.1",
142
- "preferred-pm": "^4.0.0",
141
+ "p-queue": "^8.1.0",
142
+ "preferred-pm": "^4.1.0",
143
143
  "prompts": "^2.4.2",
144
144
  "rehype": "^13.0.2",
145
- "semver": "^7.6.3",
146
- "shiki": "^1.29.1",
145
+ "semver": "^7.7.0",
146
+ "shiki": "^1.29.2",
147
147
  "tinyexec": "^0.3.2",
148
148
  "tsconfck": "^3.1.4",
149
149
  "ultrahtml": "^1.5.3",
@@ -155,20 +155,20 @@
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.2",
158
+ "yocto-spinner": "^0.2.0",
159
159
  "zod": "^3.24.1",
160
160
  "zod-to-json-schema": "^3.24.1",
161
161
  "zod-to-ts": "^1.2.0",
162
162
  "@astrojs/internal-helpers": "0.5.0",
163
- "@astrojs/telemetry": "3.2.0",
164
- "@astrojs/markdown-remark": "6.1.0"
163
+ "@astrojs/markdown-remark": "6.1.0",
164
+ "@astrojs/telemetry": "3.2.0"
165
165
  },
166
166
  "optionalDependencies": {
167
167
  "sharp": "^0.33.3"
168
168
  },
169
169
  "devDependencies": {
170
170
  "@astrojs/check": "^0.9.4",
171
- "@playwright/test": "^1.49.1",
171
+ "@playwright/test": "^1.50.0",
172
172
  "@types/aria-query": "^5.0.4",
173
173
  "@types/common-ancestor-path": "^1.0.2",
174
174
  "@types/cssesc": "^3.0.2",
@@ -176,7 +176,7 @@
176
176
  "@types/diff": "^5.2.3",
177
177
  "@types/dlv": "^1.1.5",
178
178
  "@types/hast": "^3.0.4",
179
- "@types/html-escaper": "^3.0.2",
179
+ "@types/html-escaper": "3.0.2",
180
180
  "@types/http-cache-semantics": "^4.0.4",
181
181
  "@types/js-yaml": "^4.0.9",
182
182
  "@types/micromatch": "^4.0.9",
@@ -187,7 +187,7 @@
187
187
  "eol": "^0.10.0",
188
188
  "execa": "^8.0.1",
189
189
  "expect-type": "^1.1.0",
190
- "fs-fixture": "^2.6.0",
190
+ "fs-fixture": "^2.7.0",
191
191
  "mdast-util-mdx": "^3.0.0",
192
192
  "mdast-util-mdx-jsx": "^3.2.0",
193
193
  "node-mocks-http": "^1.16.2",
@@ -196,11 +196,11 @@
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.31.0",
199
+ "rollup": "^4.32.1",
200
200
  "sass": "^1.83.4",
201
- "undici": "^7.2.3",
201
+ "undici": "^7.3.0",
202
202
  "unified": "^11.0.5",
203
- "vitest": "^3.0.2",
203
+ "vitest": "^3.0.4",
204
204
  "astro-scripts": "0.0.14"
205
205
  },
206
206
  "engines": {