astro 5.5.4 → 5.5.5

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.
@@ -0,0 +1,2 @@
1
+ import type { SSRActions } from '../core/app/types.js';
2
+ export declare const NOOP_ACTIONS_MOD: SSRActions;
@@ -0,0 +1,6 @@
1
+ const NOOP_ACTIONS_MOD = {
2
+ server: {}
3
+ };
4
+ export {
5
+ NOOP_ACTIONS_MOD
6
+ };
@@ -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.5.4") {
156
+ if (previousAstroVersion && previousAstroVersion !== "5.5.5") {
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.5.4") {
165
- await this.#store.metaStore().set("astro-version", "5.5.4");
164
+ if ("5.5.5") {
165
+ await this.#store.metaStore().set("astro-version", "5.5.5");
166
166
  }
167
167
  if (currentConfigDigest) {
168
168
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -1,6 +1,7 @@
1
1
  import { collapseDuplicateTrailingSlashes, hasFileExtension } from "@astrojs/internal-helpers/path";
2
2
  import { normalizeTheLocale } from "../../i18n/index.js";
3
3
  import {
4
+ DEFAULT_404_COMPONENT,
4
5
  REROUTABLE_STATUS_CODES,
5
6
  REROUTE_DIRECTIVE_HEADER,
6
7
  clientAddressSymbol,
@@ -36,7 +37,6 @@ class App {
36
37
  #baseWithoutTrailingSlash;
37
38
  #pipeline;
38
39
  #adapterLogger;
39
- #renderOptionsDeprecationWarningShown = false;
40
40
  constructor(manifest, streaming = true) {
41
41
  this.#manifest = manifest;
42
42
  this.#manifestData = {
@@ -234,6 +234,11 @@ class App {
234
234
  this.#logger.debug("router", "Astro matched the following route for " + request.url);
235
235
  this.#logger.debug("router", "RouteData:\n" + routeData);
236
236
  }
237
+ if (!routeData) {
238
+ routeData = this.#manifestData.routes.find(
239
+ (route) => route.component === "404.astro" || route.component === DEFAULT_404_COMPONENT
240
+ );
241
+ }
237
242
  if (!routeData) {
238
243
  this.#logger.debug("router", "Astro hasn't found routes that match " + request.url);
239
244
  this.#logger.debug("router", "Here's the available routes:\n", this.#manifestData);
@@ -67,7 +67,7 @@ export type SSRManifest = {
67
67
  key: Promise<CryptoKey>;
68
68
  i18n: SSRManifestI18n | undefined;
69
69
  middleware?: () => Promise<AstroMiddlewareInstance> | AstroMiddlewareInstance;
70
- actions?: SSRActions;
70
+ actions?: () => Promise<SSRActions> | SSRActions;
71
71
  checkOrigin: boolean;
72
72
  sessionConfig?: ResolvedSessionConfig<any>;
73
73
  cacheDir: string | URL;
@@ -51,7 +51,7 @@ export declare abstract class Pipeline {
51
51
  route: string;
52
52
  component: string;
53
53
  }[];
54
- readonly actions: SSRActions | undefined;
54
+ readonly actions: (() => Promise<SSRActions> | SSRActions) | undefined;
55
55
  readonly internalMiddleware: MiddlewareHandler[];
56
56
  resolvedMiddleware: MiddlewareHandler | undefined;
57
57
  resolvedActions: SSRActions | undefined;
@@ -81,7 +81,7 @@ export declare abstract class Pipeline {
81
81
  matchesComponent(filePath: URL): boolean;
82
82
  route: string;
83
83
  component: string;
84
- }[], actions?: SSRActions | undefined);
84
+ }[], actions?: (() => Promise<SSRActions> | SSRActions) | undefined);
85
85
  abstract headElements(routeData: RouteData): Promise<HeadElements> | HeadElements;
86
86
  abstract componentMetadata(routeData: RouteData): Promise<SSRResult['componentMetadata']> | void;
87
87
  /**
@@ -1,3 +1,4 @@
1
+ import { NOOP_ACTIONS_MOD } from "../actions/noop-actions.js";
1
2
  import { createI18nMiddleware } from "../i18n/middleware.js";
2
3
  import { createOriginCheckMiddleware } from "./app/middlewares.js";
3
4
  import { ActionNotFoundError } from "./errors/errors-data.js";
@@ -63,9 +64,9 @@ class Pipeline {
63
64
  if (this.resolvedActions) {
64
65
  return this.resolvedActions;
65
66
  } else if (this.actions) {
66
- return this.actions;
67
+ return await this.actions();
67
68
  }
68
- return { server: {} };
69
+ return NOOP_ACTIONS_MOD;
69
70
  }
70
71
  async getAction(path) {
71
72
  const pathKeys = path.split(".").map((key) => decodeURIComponent(key));
@@ -3,6 +3,7 @@ import os from "node:os";
3
3
  import { bgGreen, black, blue, bold, dim, green, magenta, red, yellow } from "kleur/colors";
4
4
  import PLimit from "p-limit";
5
5
  import PQueue from "p-queue";
6
+ import { NOOP_ACTIONS_MOD } from "../../actions/noop-actions.js";
6
7
  import {
7
8
  generateImagesForPath,
8
9
  getStaticImageList,
@@ -44,7 +45,7 @@ async function generatePages(options, internals) {
44
45
  const renderersEntryUrl = new URL("renderers.mjs", baseDirectory);
45
46
  const renderers = await import(renderersEntryUrl.toString());
46
47
  const middleware = internals.middlewareEntryPoint ? await import(internals.middlewareEntryPoint.toString()).then((mod) => mod.onRequest) : NOOP_MIDDLEWARE_FN;
47
- const actions = internals.astroActionsEntryPoint ? await import(internals.astroActionsEntryPoint.toString()).then((mod) => mod) : { server: {} };
48
+ const actions = internals.astroActionsEntryPoint ? await import(internals.astroActionsEntryPoint.toString()).then((mod) => mod) : NOOP_ACTIONS_MOD;
48
49
  manifest = createBuildManifest(
49
50
  options.settings,
50
51
  internals,
@@ -405,7 +406,7 @@ function createBuildManifest(settings, internals, renderers, middleware, actions
405
406
  onRequest: middleware
406
407
  };
407
408
  },
408
- actions,
409
+ actions: () => actions,
409
410
  checkOrigin: (settings.config.security?.checkOrigin && settings.buildOutput === "server") ?? false,
410
411
  key
411
412
  };
@@ -139,7 +139,6 @@ function generateSSRCode(adapter, middlewareId) {
139
139
  const edgeMiddleware = adapter?.adapterFeatures?.edgeMiddleware ?? false;
140
140
  const imports = [
141
141
  `import { renderers } from '${RENDERERS_MODULE_ID}';`,
142
- `import * as actions from '${ASTRO_ACTIONS_INTERNAL_MODULE_ID}';`,
143
142
  `import * as serverEntrypointModule from '${ADAPTER_VIRTUAL_MODULE_ID}';`,
144
143
  `import { manifest as defaultManifest } from '${SSR_MANIFEST_VIRTUAL_MODULE_ID}';`,
145
144
  `import { serverIslandMap } from '${VIRTUAL_ISLAND_MAP_ID}';`
@@ -150,7 +149,7 @@ function generateSSRCode(adapter, middlewareId) {
150
149
  ` pageMap,`,
151
150
  ` serverIslandMap,`,
152
151
  ` renderers,`,
153
- ` actions,`,
152
+ ` actions: () => import("${ASTRO_ACTIONS_INTERNAL_MODULE_ID}"),`,
154
153
  ` middleware: ${edgeMiddleware ? "undefined" : `() => import("${middlewareId}")`}`,
155
154
  `});`,
156
155
  `const _args = ${adapter.args ? JSON.stringify(adapter.args, null, 4) : "undefined"};`,
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "5.5.4";
1
+ const ASTRO_VERSION = "5.5.5";
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";
@@ -45,9 +45,10 @@ declare class AstroCookies implements AstroCookiesInterface {
45
45
  * Astro.cookies.has(key) returns a boolean indicating whether this cookie is either
46
46
  * part of the initial request or set via Astro.cookies.set(key)
47
47
  * @param key The cookie to check for.
48
+ * @param _options This parameter is no longer used.
48
49
  * @returns
49
50
  */
50
- has(key: string, options?: AstroCookieGetOptions | undefined): boolean;
51
+ has(key: string, _options?: AstroCookieGetOptions): boolean;
51
52
  /**
52
53
  * Astro.cookies.set(key, value) is used to set a cookie's value. If provided
53
54
  * an object it will be stringified via JSON.stringify(value). Additionally you
@@ -3,6 +3,7 @@ import { AstroError, AstroErrorData } from "../errors/index.js";
3
3
  const DELETED_EXPIRATION = /* @__PURE__ */ new Date(0);
4
4
  const DELETED_VALUE = "deleted";
5
5
  const responseSentSymbol = Symbol.for("astro.responseSent");
6
+ const identity = (value) => value;
6
7
  class AstroCookie {
7
8
  constructor(value) {
8
9
  this.value = value;
@@ -73,11 +74,12 @@ class AstroCookies {
73
74
  return void 0;
74
75
  }
75
76
  }
76
- const values = this.#ensureParsed(options);
77
+ const decode = options?.decode ?? decodeURIComponent;
78
+ const values = this.#ensureParsed();
77
79
  if (key in values) {
78
80
  const value = values[key];
79
81
  if (value) {
80
- return new AstroCookie(value);
82
+ return new AstroCookie(decode(value));
81
83
  }
82
84
  }
83
85
  }
@@ -85,15 +87,16 @@ class AstroCookies {
85
87
  * Astro.cookies.has(key) returns a boolean indicating whether this cookie is either
86
88
  * part of the initial request or set via Astro.cookies.set(key)
87
89
  * @param key The cookie to check for.
90
+ * @param _options This parameter is no longer used.
88
91
  * @returns
89
92
  */
90
- has(key, options = void 0) {
93
+ has(key, _options) {
91
94
  if (this.#outgoing?.has(key)) {
92
95
  let [, , isSetValue] = this.#outgoing.get(key);
93
96
  return isSetValue;
94
97
  }
95
- const values = this.#ensureParsed(options);
96
- return !!values[key];
98
+ const values = this.#ensureParsed();
99
+ return values[key] !== void 0;
97
100
  }
98
101
  /**
99
102
  * Astro.cookies.set(key, value) is used to set a cookie's value. If provided
@@ -170,9 +173,9 @@ class AstroCookies {
170
173
  cookies.#consumed = true;
171
174
  return cookies.headers();
172
175
  }
173
- #ensureParsed(options = void 0) {
176
+ #ensureParsed() {
174
177
  if (!this.#requestValues) {
175
- this.#parse(options);
178
+ this.#parse();
176
179
  }
177
180
  if (!this.#requestValues) {
178
181
  this.#requestValues = {};
@@ -185,12 +188,12 @@ class AstroCookies {
185
188
  }
186
189
  return this.#outgoing;
187
190
  }
188
- #parse(options = void 0) {
191
+ #parse() {
189
192
  const raw = this.#request.headers.get("cookie");
190
193
  if (!raw) {
191
194
  return;
192
195
  }
193
- this.#requestValues = parse(raw, options);
196
+ this.#requestValues = parse(raw, { decode: identity });
194
197
  }
195
198
  }
196
199
  export {
@@ -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.5.4";
25
+ const currentVersion = "5.5.5";
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.5.4";
41
+ const version = "5.5.5";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -282,7 +282,7 @@ function printHelp({
282
282
  message.push(
283
283
  linebreak(),
284
284
  ` ${bgGreen(black(` ${commandName} `))} ${green(
285
- `v${"5.5.4"}`
285
+ `v${"5.5.5"}`
286
286
  )} ${headline}`
287
287
  );
288
288
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.5.4",
3
+ "version": "5.5.5",
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",
@@ -149,7 +149,7 @@
149
149
  "unist-util-visit": "^5.0.0",
150
150
  "unstorage": "^1.15.0",
151
151
  "vfile": "^6.0.3",
152
- "vite": "^6.2.1",
152
+ "vite": "^6.2.3",
153
153
  "vitefu": "^1.0.6",
154
154
  "xxhash-wasm": "^1.1.0",
155
155
  "yargs-parser": "^21.1.1",