astro 2.4.1 → 2.4.2

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.
package/client-base.d.ts CHANGED
@@ -389,7 +389,7 @@ declare module '*?inline' {
389
389
  }
390
390
 
391
391
  // eslint-disable-next-line @typescript-eslint/no-namespace
392
- export namespace App {
392
+ declare namespace App {
393
393
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
394
394
  export interface Locals {}
395
395
  }
@@ -976,6 +976,7 @@ export interface AstroUserConfig {
976
976
  * assets: true,
977
977
  * },
978
978
  * }
979
+ * ```
979
980
  */
980
981
  assets?: boolean;
981
982
  /**
@@ -984,8 +985,8 @@ export interface AstroUserConfig {
984
985
  * @type {('always' | 'auto' | 'never')}
985
986
  * @default `never`
986
987
  * @description
987
- * Control whether styles are sent to the browser in a separate css file or inlined into <style> tags. Choose from the following options:
988
- * - `'always'` - all styles are inlined into <style> tags
988
+ * Control whether styles are sent to the browser in a separate css file or inlined into `<style>` tags. Choose from the following options:
989
+ * - `'always'` - all styles are inlined into `<style>` tags
989
990
  * - `'auto'` - only stylesheets smaller than `ViteConfig.build.assetsInlineLimit` (default: 4kb) are inlined. Otherwise, styles are sent in external stylesheets.
990
991
  * - `'never'` - all styles are sent in external stylesheets
991
992
  *
@@ -995,6 +996,7 @@ export interface AstroUserConfig {
995
996
  * inlineStylesheets: `auto`,
996
997
  * },
997
998
  * }
999
+ * ```
998
1000
  */
999
1001
  inlineStylesheets?: 'always' | 'auto' | 'never';
1000
1002
  /**
@@ -1014,6 +1016,7 @@ export interface AstroUserConfig {
1014
1016
  * middleware: true,
1015
1017
  * },
1016
1018
  * }
1019
+ * ```
1017
1020
  */
1018
1021
  middleware?: boolean;
1019
1022
  };
@@ -1,6 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import { basename, join } from "node:path/posix";
3
3
  import { AstroError, AstroErrorData } from "../core/errors/index.js";
4
+ import { warn } from "../core/logger/core.js";
4
5
  import { prependForwardSlash } from "../core/path.js";
5
6
  import { isLocalService } from "./services/service.js";
6
7
  function isESMImportedImage(src) {
@@ -60,9 +61,10 @@ async function generateImage(buildOpts, options, filepath) {
60
61
  try {
61
62
  await fs.promises.mkdir(assetsCacheDir, { recursive: true });
62
63
  } catch (err) {
63
- console.error(
64
- "An error was encountered while creating the cache directory. Proceeding without caching. Error: ",
65
- err
64
+ warn(
65
+ buildOpts.logging,
66
+ "astro:assets",
67
+ `An error was encountered while creating the cache directory. Proceeding without caching. Error: ${err}`
66
68
  );
67
69
  useCache = false;
68
70
  }
@@ -105,9 +107,10 @@ async function generateImage(buildOpts, options, filepath) {
105
107
  await fs.promises.writeFile(cachedFileURL, resultData.data);
106
108
  await fs.promises.copyFile(cachedFileURL, finalFileURL);
107
109
  } catch (e) {
108
- console.error(
109
- `There was an error creating the cache entry for ${filepath}. Attempting to write directly to output directory. Error: `,
110
- e
110
+ warn(
111
+ buildOpts.logging,
112
+ "astro:assets",
113
+ `An error was encountered while creating the cache directory. Proceeding without caching. Error: ${e}`
111
114
  );
112
115
  await fs.promises.writeFile(finalFileURL, resultData.data);
113
116
  }
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "2.4.1";
1
+ const ASTRO_VERSION = "2.4.2";
2
2
  const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
3
3
  ".markdown",
4
4
  ".mdown",
@@ -53,7 +53,7 @@ async function dev(settings, options) {
53
53
  isRestart: options.isRestart
54
54
  })
55
55
  );
56
- const currentVersion = "2.4.1";
56
+ const currentVersion = "2.4.2";
57
57
  if (currentVersion.includes("-")) {
58
58
  warn(options.logging, null, msg.prerelease({ currentVersion }));
59
59
  }
@@ -47,7 +47,7 @@ function serverStart({
47
47
  base,
48
48
  isRestart = false
49
49
  }) {
50
- const version = "2.4.1";
50
+ const version = "2.4.2";
51
51
  const localPrefix = `${dim("\u2503")} Local `;
52
52
  const networkPrefix = `${dim("\u2503")} Network `;
53
53
  const emptyPrefix = " ".repeat(11);
@@ -233,7 +233,7 @@ function printHelp({
233
233
  message.push(
234
234
  linebreak(),
235
235
  ` ${bgGreen(black(` ${commandName} `))} ${green(
236
- `v${"2.4.1"}`
236
+ `v${"2.4.2"}`
237
237
  )} ${headline}`
238
238
  );
239
239
  }
@@ -5,9 +5,11 @@ async function callMiddleware(onRequest, apiContext, responseFunction) {
5
5
  resolveResolve = resolve;
6
6
  });
7
7
  let nextCalled = false;
8
+ let responseFunctionPromise = void 0;
8
9
  const next = async () => {
9
10
  nextCalled = true;
10
- return await responseFunction();
11
+ responseFunctionPromise = responseFunction();
12
+ return responseFunctionPromise;
11
13
  };
12
14
  let middlewarePromise = onRequest(apiContext, next);
13
15
  return await Promise.resolve(middlewarePromise).then(async (value) => {
@@ -18,8 +20,11 @@ async function callMiddleware(onRequest, apiContext, responseFunction) {
18
20
  }
19
21
  return value;
20
22
  } else {
21
- const responseResult = await responseFunction();
22
- return responseResult;
23
+ if (responseFunctionPromise) {
24
+ return responseFunctionPromise;
25
+ } else {
26
+ throw new AstroError(AstroErrorData.MiddlewareNotAResponse);
27
+ }
23
28
  }
24
29
  } else if (typeof value === "undefined") {
25
30
  throw new AstroError(AstroErrorData.MiddlewareNoDataOrNextCalled);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
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",