astro 4.16.3 → 4.16.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.
@@ -121,7 +121,7 @@ class ContentLayer {
121
121
  logger.info("Content config changed");
122
122
  shouldClear = true;
123
123
  }
124
- if (previousAstroVersion !== "4.16.3") {
124
+ if (previousAstroVersion !== "4.16.4") {
125
125
  logger.info("Astro version changed");
126
126
  shouldClear = true;
127
127
  }
@@ -129,8 +129,8 @@ class ContentLayer {
129
129
  logger.info("Clearing content store");
130
130
  this.#store.clearAll();
131
131
  }
132
- if ("4.16.3") {
133
- await this.#store.metaStore().set("astro-version", "4.16.3");
132
+ if ("4.16.4") {
133
+ await this.#store.metaStore().set("astro-version", "4.16.4");
134
134
  }
135
135
  if (currentConfigDigest) {
136
136
  await this.#store.metaStore().set("config-digest", currentConfigDigest);
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.16.3";
1
+ const ASTRO_VERSION = "4.16.4";
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 = "4.16.3";
25
+ const currentVersion = "4.16.4";
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 = "4.16.3";
41
+ const version = "4.16.4";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -270,7 +270,7 @@ function printHelp({
270
270
  message.push(
271
271
  linebreak(),
272
272
  ` ${bgGreen(black(` ${commandName} `))} ${green(
273
- `v${"4.16.3"}`
273
+ `v${"4.16.4"}`
274
274
  )} ${headline}`
275
275
  );
276
276
  }
@@ -7,6 +7,7 @@ import {
7
7
  import { ASTRO_VERSION, clientAddressSymbol, clientLocalsSymbol } from "../constants.js";
8
8
  import { AstroCookies } from "../cookies/index.js";
9
9
  import { AstroError, AstroErrorData } from "../errors/index.js";
10
+ import { getClientIpAddress } from "../routing/request.js";
10
11
  import { sequence } from "./sequence.js";
11
12
  function defineMiddleware(fn) {
12
13
  return fn;
@@ -20,6 +21,7 @@ function createContext({
20
21
  let preferredLocale = void 0;
21
22
  let preferredLocaleList = void 0;
22
23
  let currentLocale = void 0;
24
+ let clientIpAddress;
23
25
  const url = new URL(request.url);
24
26
  const route = url.pathname;
25
27
  const rewrite = (_reroutePayload) => {
@@ -52,10 +54,14 @@ function createContext({
52
54
  },
53
55
  url,
54
56
  get clientAddress() {
55
- if (clientAddressSymbol in request) {
56
- return Reflect.get(request, clientAddressSymbol);
57
+ if (clientIpAddress) {
58
+ return clientIpAddress;
57
59
  }
58
- throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable);
60
+ clientIpAddress = getClientIpAddress(request);
61
+ if (!clientIpAddress) {
62
+ throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable);
63
+ }
64
+ return clientIpAddress;
59
65
  },
60
66
  get locals() {
61
67
  let locals = Reflect.get(request, clientLocalsSymbol);
@@ -428,7 +428,17 @@ class RenderContext {
428
428
  if (!i18n) return;
429
429
  const { defaultLocale, locales, strategy } = i18n;
430
430
  const fallbackTo = strategy === "pathname-prefix-other-locales" || strategy === "domains-prefix-other-locales" ? defaultLocale : void 0;
431
- return this.#currentLocale ??= computeCurrentLocale(routeData.route, locales, defaultLocale) ?? computeCurrentLocale(url.pathname, locales, defaultLocale) ?? fallbackTo;
431
+ if (this.#currentLocale) {
432
+ return this.#currentLocale;
433
+ }
434
+ let computedLocale;
435
+ if (routeData.pathname) {
436
+ computedLocale = computeCurrentLocale(routeData.pathname, locales, defaultLocale);
437
+ } else {
438
+ computedLocale = computeCurrentLocale(url.pathname, locales, defaultLocale);
439
+ }
440
+ this.#currentLocale = computedLocale ?? fallbackTo;
441
+ return this.#currentLocale;
432
442
  }
433
443
  #preferredLocale;
434
444
  computePreferredLocale() {
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Utilities for extracting information from `Request`
3
+ */
4
+ export declare function getFirstForwardedValue(multiValueHeader?: string | string[] | null): string | undefined;
5
+ /**
6
+ * Returns the first value associated to the `x-forwarded-for` header.
7
+ *
8
+ * @param {Request} request
9
+ */
10
+ export declare function getClientIpAddress(request: Request): string | undefined;
@@ -0,0 +1,10 @@
1
+ function getFirstForwardedValue(multiValueHeader) {
2
+ return multiValueHeader?.toString()?.split(",").map((e) => e.trim())?.[0];
3
+ }
4
+ function getClientIpAddress(request) {
5
+ return getFirstForwardedValue(request.headers.get("x-forwarded-for"));
6
+ }
7
+ export {
8
+ getClientIpAddress,
9
+ getFirstForwardedValue
10
+ };
@@ -53,7 +53,7 @@ const interactiveElements = [
53
53
  "textarea",
54
54
  ...MAYBE_INTERACTIVE.keys()
55
55
  ];
56
- const labellableElements = ["input", "meter", "output", "progress", "select", "textarea"];
56
+ const labellableElements = ["button", "input", "meter", "output", "progress", "select", "textarea"];
57
57
  const aria_non_interactive_roles = [
58
58
  "alert",
59
59
  "alertdialog",
@@ -59,6 +59,9 @@ function createVitePluginAstroServer({
59
59
  );
60
60
  }
61
61
  process.on("unhandledRejection", handleUnhandledRejection);
62
+ viteServer.httpServer?.on("close", () => {
63
+ process.off("unhandledRejection", handleUnhandledRejection);
64
+ });
62
65
  return () => {
63
66
  viteServer.middlewares.stack.unshift({
64
67
  route: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.16.3",
3
+ "version": "4.16.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",
@@ -109,9 +109,9 @@
109
109
  ],
110
110
  "dependencies": {
111
111
  "@astrojs/compiler": "^2.10.3",
112
- "@babel/core": "^7.25.7",
112
+ "@babel/core": "^7.25.8",
113
113
  "@babel/plugin-transform-react-jsx": "^7.25.7",
114
- "@babel/types": "^7.25.7",
114
+ "@babel/types": "^7.25.8",
115
115
  "@oslojs/encoding": "^1.1.0",
116
116
  "@rollup/pluginutils": "^5.1.2",
117
117
  "@types/babel__core": "^7.20.5",
@@ -142,7 +142,7 @@
142
142
  "http-cache-semantics": "^4.1.1",
143
143
  "js-yaml": "^4.1.0",
144
144
  "kleur": "^4.1.5",
145
- "magic-string": "^0.30.11",
145
+ "magic-string": "^0.30.12",
146
146
  "magicast": "^0.3.5",
147
147
  "micromatch": "^4.0.8",
148
148
  "mrmime": "^2.0.0",
@@ -156,11 +156,11 @@
156
156
  "semver": "^7.6.3",
157
157
  "shiki": "^1.22.0",
158
158
  "tinyexec": "^0.3.0",
159
- "tsconfck": "^3.1.3",
159
+ "tsconfck": "^3.1.4",
160
160
  "unist-util-visit": "^5.0.0",
161
161
  "vfile": "^6.0.3",
162
- "vite": "^5.4.8",
163
- "vitefu": "^1.0.2",
162
+ "vite": "^5.4.9",
163
+ "vitefu": "^1.0.3",
164
164
  "which-pm": "^3.0.0",
165
165
  "xxhash-wasm": "^1.0.2",
166
166
  "yargs-parser": "^21.1.1",
@@ -176,12 +176,12 @@
176
176
  },
177
177
  "devDependencies": {
178
178
  "@astrojs/check": "^0.9.4",
179
- "@playwright/test": "^1.47.2",
179
+ "@playwright/test": "^1.48.0",
180
180
  "@types/aria-query": "^5.0.4",
181
181
  "@types/common-ancestor-path": "^1.0.2",
182
182
  "@types/cssesc": "^3.0.2",
183
183
  "@types/debug": "^4.1.12",
184
- "@types/diff": "^5.2.2",
184
+ "@types/diff": "^5.2.3",
185
185
  "@types/dlv": "^1.1.4",
186
186
  "@types/hast": "^3.0.4",
187
187
  "@types/html-escaper": "^3.0.2",
@@ -194,10 +194,10 @@
194
194
  "cheerio": "1.0.0",
195
195
  "eol": "^0.10.0",
196
196
  "execa": "^8.0.1",
197
- "expect-type": "^1.0.0",
197
+ "expect-type": "^1.1.0",
198
+ "fs-fixture": "^2.4.0",
198
199
  "mdast-util-mdx": "^3.0.0",
199
200
  "mdast-util-mdx-jsx": "^3.1.3",
200
- "memfs": "^4.12.0",
201
201
  "node-mocks-http": "^1.16.1",
202
202
  "parse-srcset": "^1.0.2",
203
203
  "rehype-autolink-headings": "^7.1.0",
@@ -205,8 +205,8 @@
205
205
  "rehype-toc": "^3.0.2",
206
206
  "remark-code-titles": "^0.1.2",
207
207
  "rollup": "^4.24.0",
208
- "sass": "^1.79.4",
209
- "undici": "^6.19.8",
208
+ "sass": "^1.79.5",
209
+ "undici": "^6.20.1",
210
210
  "unified": "^11.0.5",
211
211
  "astro-scripts": "0.0.14"
212
212
  },
@@ -223,13 +223,14 @@
223
223
  "build": "pnpm run prebuild && astro-scripts build \"src/**/*.{ts,js}\" --copy-wasm && tsc",
224
224
  "build:ci": "pnpm run prebuild && astro-scripts build \"src/**/*.{ts,js}\" --copy-wasm",
225
225
  "dev": "astro-scripts dev --copy-wasm --prebuild \"src/runtime/server/astro-island.ts\" --prebuild \"src/runtime/client/{idle,load,media,only,visible}.ts\" \"src/**/*.{ts,js}\"",
226
- "test": "pnpm run test:node && pnpm run test:types",
227
- "test:match": "pnpm run test:node --match",
226
+ "test": "pnpm run test:unit && pnpm run test:integration && pnpm run test:types",
227
+ "test:match": "astro-scripts test \"test/**/*.test.js\" --match",
228
228
  "test:e2e": "pnpm test:e2e:chrome && pnpm test:e2e:firefox",
229
229
  "test:e2e:match": "playwright test -g",
230
230
  "test:e2e:chrome": "playwright test",
231
231
  "test:e2e:firefox": "playwright test --config playwright.firefox.config.js",
232
232
  "test:types": "tsc --project tsconfig.tests.json",
233
- "test:node": "astro-scripts test \"test/**/*.test.js\""
233
+ "test:unit": "astro-scripts test \"test/units/**/*.test.js\" --teardown ./test/units/teardown.js",
234
+ "test:integration": "astro-scripts test \"test/*.test.js\""
234
235
  }
235
236
  }