astro 2.4.0 → 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 +1 -1
- package/config.d.ts +12 -0
- package/config.mjs +14 -0
- package/dist/@types/astro.d.ts +6 -3
- package/dist/assets/index.d.ts +0 -3
- package/dist/assets/index.js +1 -15
- package/dist/assets/internal.js +9 -6
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/callMiddleware.js +8 -3
- package/package.json +1 -1
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
|
-
|
|
392
|
+
declare namespace App {
|
|
393
393
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
394
394
|
export interface Locals {}
|
|
395
395
|
}
|
package/config.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
type ViteUserConfig = import('vite').UserConfig;
|
|
2
2
|
type ViteUserConfigFn = import('vite').UserConfigFn;
|
|
3
3
|
type AstroUserConfig = import('./dist/@types/astro.js').AstroUserConfig;
|
|
4
|
+
type ImageServiceConfig = import('./dist/@types/astro.js').ImageServiceConfig;
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* See the full Astro Configuration API Documentation
|
|
@@ -12,3 +13,14 @@ export function defineConfig(config: AstroUserConfig): AstroUserConfig;
|
|
|
12
13
|
* Use Astro to generate a fully resolved Vite config
|
|
13
14
|
*/
|
|
14
15
|
export function getViteConfig(config: ViteUserConfig): ViteUserConfigFn;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Return the configuration needed to use the Sharp-based image service
|
|
19
|
+
* See: https://docs.astro.build/en/guides/assets/#using-sharp
|
|
20
|
+
*/
|
|
21
|
+
export function sharpImageService(): ImageServiceConfig;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Return the configuration needed to use the Squoosh-based image service
|
|
25
|
+
*/
|
|
26
|
+
export function squooshImageService(): ImageServiceConfig;
|
package/config.mjs
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
1
|
export { defineConfig, getViteConfig } from './dist/config/index.js';
|
|
2
|
+
|
|
3
|
+
export function sharpImageService() {
|
|
4
|
+
return {
|
|
5
|
+
entrypoint: 'astro/assets/services/sharp',
|
|
6
|
+
config: {},
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function squooshImageService() {
|
|
11
|
+
return {
|
|
12
|
+
entrypoint: 'astro/assets/services/squoosh',
|
|
13
|
+
config: {},
|
|
14
|
+
};
|
|
15
|
+
}
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -460,8 +460,8 @@ export interface AstroUserConfig {
|
|
|
460
460
|
* @name scopedStyleStrategy
|
|
461
461
|
* @type {('where' | 'class')}
|
|
462
462
|
* @default `'where'`
|
|
463
|
-
* @description
|
|
464
463
|
* @version 2.4
|
|
464
|
+
* @description
|
|
465
465
|
*
|
|
466
466
|
* Specify the strategy used for scoping styles within Astro components. Choose from:
|
|
467
467
|
* - `'where'` - Use `:where` selectors, causing no specifity increase.
|
|
@@ -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
|
|
988
|
-
* - `'always'` - all styles are inlined into
|
|
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
|
};
|
package/dist/assets/index.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type { ImageServiceConfig } from '../@types/astro.js';
|
|
2
1
|
export { getConfiguredImageService, getImage } from './internal.js';
|
|
3
2
|
export { baseService, isLocalService } from './services/service.js';
|
|
4
3
|
export { type LocalImageProps, type RemoteImageProps } from './types.js';
|
|
5
4
|
export { emitESMImage } from './utils/emitAsset.js';
|
|
6
5
|
export { imageMetadata } from './utils/metadata.js';
|
|
7
|
-
export declare function sharpImageService(): ImageServiceConfig;
|
|
8
|
-
export declare function squooshImageService(): ImageServiceConfig;
|
package/dist/assets/index.js
CHANGED
|
@@ -3,25 +3,11 @@ import { baseService, isLocalService } from "./services/service.js";
|
|
|
3
3
|
import {} from "./types.js";
|
|
4
4
|
import { emitESMImage } from "./utils/emitAsset.js";
|
|
5
5
|
import { imageMetadata } from "./utils/metadata.js";
|
|
6
|
-
function sharpImageService() {
|
|
7
|
-
return {
|
|
8
|
-
entrypoint: "astro/assets/services/sharp",
|
|
9
|
-
config: {}
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function squooshImageService() {
|
|
13
|
-
return {
|
|
14
|
-
entrypoint: "astro/assets/services/squoosh",
|
|
15
|
-
config: {}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
6
|
export {
|
|
19
7
|
baseService,
|
|
20
8
|
emitESMImage,
|
|
21
9
|
getConfiguredImageService,
|
|
22
10
|
getImage,
|
|
23
11
|
imageMetadata,
|
|
24
|
-
isLocalService
|
|
25
|
-
sharpImageService,
|
|
26
|
-
squooshImageService
|
|
12
|
+
isLocalService
|
|
27
13
|
};
|
package/dist/assets/internal.js
CHANGED
|
@@ -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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
}
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -53,7 +53,7 @@ async function dev(settings, options) {
|
|
|
53
53
|
isRestart: options.isRestart
|
|
54
54
|
})
|
|
55
55
|
);
|
|
56
|
-
const currentVersion = "2.4.
|
|
56
|
+
const currentVersion = "2.4.2";
|
|
57
57
|
if (currentVersion.includes("-")) {
|
|
58
58
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
59
59
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
base,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "2.4.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
22
|
-
|
|
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);
|