astro 2.8.2 → 2.8.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.
- package/components/Code.astro +1 -1
- package/dist/@types/astro.d.ts +2 -2
- package/dist/assets/consts.d.ts +4 -4
- package/dist/assets/consts.js +11 -3
- package/dist/assets/index.d.ts +0 -2
- package/dist/assets/index.js +0 -4
- package/dist/assets/services/service.d.ts +1 -1
- package/dist/assets/services/service.js +6 -3
- package/dist/assets/services/sharp.js +3 -0
- package/dist/assets/services/squoosh.js +25 -0
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +3 -3
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +3 -3
- package/dist/assets/services/vendor/squoosh/image-pool.js +2 -2
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +3 -3
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +3 -3
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +3 -3
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +3 -3
- package/dist/assets/types.d.ts +1 -0
- package/dist/assets/utils/emitAsset.d.ts +2 -2
- package/dist/assets/utils/metadata.d.ts +1 -4
- package/dist/assets/utils/transformToPath.js +1 -1
- package/dist/assets/vendor/image-size/index.js +2 -2
- package/dist/assets/vendor/image-size/types/tiff.js +1 -1
- package/dist/cli/add/index.d.ts +1 -2
- package/dist/cli/add/index.js +7 -4
- package/dist/cli/check/index.d.ts +1 -1
- package/dist/cli/check/index.js +2 -2
- package/dist/cli/check/print.js +1 -1
- package/dist/cli/dev/index.js +1 -1
- package/dist/cli/index.js +8 -28
- package/dist/cli/info/index.d.ts +1 -2
- package/dist/cli/info/index.js +2 -2
- package/dist/cli/load-settings.js +1 -1
- package/dist/cli/sync/index.js +1 -1
- package/dist/cli/throw-and-exit.d.ts +2 -0
- package/dist/cli/throw-and-exit.js +21 -0
- package/dist/config/index.js +1 -1
- package/dist/content/runtime-assets.d.ts +1 -1
- package/dist/content/runtime-assets.js +1 -1
- package/dist/content/vite-plugin-content-imports.js +1 -1
- package/dist/core/app/index.d.ts +3 -1
- package/dist/core/app/index.js +33 -47
- package/dist/core/app/node.d.ts +1 -1
- package/dist/core/app/node.js +3 -3
- package/dist/core/build/common.js +2 -2
- package/dist/core/build/css-asset-name.js +2 -2
- package/dist/core/build/generate.d.ts +1 -1
- package/dist/core/build/generate.js +21 -43
- package/dist/core/build/index.js +9 -2
- package/dist/core/build/static-build.js +8 -6
- package/dist/core/compile/compile.js +1 -1
- package/dist/core/compile/style.js +1 -1
- package/dist/core/config/config.d.ts +1 -1
- package/dist/core/config/config.js +16 -22
- package/dist/core/config/merge.js +10 -0
- package/dist/core/config/schema.d.ts +1 -1
- package/dist/core/config/schema.js +1 -6
- package/dist/core/config/settings.js +1 -1
- package/dist/core/config/timer.js +1 -1
- package/dist/core/config/tsconfig.js +2 -2
- package/dist/core/config/vite-load.d.ts +1 -1
- package/dist/core/config/vite-load.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.d.ts +1 -1
- package/dist/core/create-vite.js +2 -2
- package/dist/core/dev/container.d.ts +3 -3
- package/dist/core/dev/container.js +1 -1
- package/dist/core/dev/dev.d.ts +2 -2
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/dev/vite.js +2 -2
- package/dist/core/errors/errors-data.d.ts +1 -1
- package/dist/core/errors/errors-data.js +2 -2
- package/dist/core/fs/index.js +4 -4
- package/dist/core/logger/node.d.ts +1 -1
- package/dist/core/logger/node.js +2 -2
- package/dist/core/messages.js +2 -2
- package/dist/core/module-loader/loader.d.ts +1 -1
- package/dist/core/module-loader/loader.js +1 -1
- package/dist/core/module-loader/vite.js +1 -1
- package/dist/core/preview/index.js +1 -1
- package/dist/core/preview/static-preview-server.d.ts +1 -1
- package/dist/core/preview/static-preview-server.js +1 -1
- package/dist/core/preview/vite-plugin-astro-preview.js +2 -2
- package/dist/core/render/core.d.ts +9 -2
- package/dist/core/render/core.js +34 -1
- package/dist/core/render/dev/environment.d.ts +2 -2
- package/dist/core/render/dev/environment.js +6 -7
- package/dist/core/render/dev/index.js +3 -29
- package/dist/core/render/dev/vite.js +1 -1
- package/dist/core/render/index.d.ts +1 -1
- package/dist/core/render/index.js +2 -2
- package/dist/core/request.d.ts +1 -1
- package/dist/core/routing/manifest/create.d.ts +1 -1
- package/dist/core/routing/manifest/create.js +22 -3
- package/dist/core/util.js +3 -3
- package/dist/integrations/index.d.ts +1 -1
- package/dist/vite-plugin-astro-server/base.js +1 -1
- package/dist/vite-plugin-astro-server/plugin.d.ts +10 -2
- package/dist/vite-plugin-astro-server/plugin.js +34 -9
- package/dist/vite-plugin-astro-server/request.d.ts +12 -3
- package/dist/vite-plugin-astro-server/request.js +23 -15
- package/dist/vite-plugin-astro-server/response.d.ts +1 -1
- package/dist/vite-plugin-astro-server/route.d.ts +15 -3
- package/dist/vite-plugin-astro-server/route.js +32 -20
- package/dist/vite-plugin-config-alias/index.js +1 -1
- package/dist/vite-plugin-env/index.js +5 -2
- package/dist/vite-plugin-jsx/index.js +1 -1
- package/dist/vite-plugin-load-fallback/index.d.ts +1 -1
- package/dist/vite-plugin-load-fallback/index.js +2 -2
- package/dist/vite-plugin-utils/index.js +1 -1
- package/package.json +3 -3
package/components/Code.astro
CHANGED
package/dist/@types/astro.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
import type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig } from '@astrojs/markdown-remark';
|
|
5
5
|
import type * as babel from '@babel/core';
|
|
6
|
-
import type { OutgoingHttpHeaders } from 'http';
|
|
7
|
-
import type { AddressInfo } from 'net';
|
|
6
|
+
import type { OutgoingHttpHeaders } from 'node:http';
|
|
7
|
+
import type { AddressInfo } from 'node:net';
|
|
8
8
|
import type * as rollup from 'rollup';
|
|
9
9
|
import type { TsConfigJson } from 'tsconfig-resolver';
|
|
10
10
|
import type * as vite from 'vite';
|
package/dist/assets/consts.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export declare const VIRTUAL_MODULE_ID = "astro:assets";
|
|
|
2
2
|
export declare const VIRTUAL_SERVICE_ID = "virtual:image-service";
|
|
3
3
|
export declare const VALID_INPUT_FORMATS: readonly ["jpeg", "jpg", "png", "tiff", "webp", "gif", "svg"];
|
|
4
4
|
/**
|
|
5
|
-
* Valid formats
|
|
6
|
-
* Certain formats can be imported (namely SVGs) but not processed
|
|
5
|
+
* Valid formats that our base services support.
|
|
6
|
+
* Certain formats can be imported (namely SVGs) but will not be processed.
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const VALID_OUTPUT_FORMATS: readonly ["avif", "png", "webp", "jpeg", "jpg"];
|
|
8
|
+
export declare const VALID_SUPPORTED_FORMATS: readonly ["jpeg", "jpg", "png", "tiff", "webp", "gif", "svg"];
|
|
9
|
+
export declare const VALID_OUTPUT_FORMATS: readonly ["avif", "png", "webp", "jpeg", "jpg", "svg"];
|
package/dist/assets/consts.js
CHANGED
|
@@ -17,12 +17,20 @@ const VALID_INPUT_FORMATS = [
|
|
|
17
17
|
"gif",
|
|
18
18
|
"svg"
|
|
19
19
|
];
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const VALID_SUPPORTED_FORMATS = [
|
|
21
|
+
"jpeg",
|
|
22
|
+
"jpg",
|
|
23
|
+
"png",
|
|
24
|
+
"tiff",
|
|
25
|
+
"webp",
|
|
26
|
+
"gif",
|
|
27
|
+
"svg"
|
|
28
|
+
];
|
|
29
|
+
const VALID_OUTPUT_FORMATS = ["avif", "png", "webp", "jpeg", "jpg", "svg"];
|
|
22
30
|
export {
|
|
23
31
|
VALID_INPUT_FORMATS,
|
|
24
|
-
VALID_OPTIMIZABLE_FORMATS,
|
|
25
32
|
VALID_OUTPUT_FORMATS,
|
|
33
|
+
VALID_SUPPORTED_FORMATS,
|
|
26
34
|
VIRTUAL_MODULE_ID,
|
|
27
35
|
VIRTUAL_SERVICE_ID
|
|
28
36
|
};
|
package/dist/assets/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
export { getConfiguredImageService, getImage } from './internal.js';
|
|
2
2
|
export { baseService, isLocalService } from './services/service.js';
|
|
3
3
|
export { type LocalImageProps, type RemoteImageProps } from './types.js';
|
|
4
|
-
export { emitESMImage } from './utils/emitAsset.js';
|
|
5
|
-
export { imageMetadata } from './utils/metadata.js';
|
package/dist/assets/index.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { getConfiguredImageService, getImage } from "./internal.js";
|
|
2
2
|
import { baseService, isLocalService } from "./services/service.js";
|
|
3
3
|
import {} from "./types.js";
|
|
4
|
-
import { emitESMImage } from "./utils/emitAsset.js";
|
|
5
|
-
import { imageMetadata } from "./utils/metadata.js";
|
|
6
4
|
export {
|
|
7
5
|
baseService,
|
|
8
|
-
emitESMImage,
|
|
9
6
|
getConfiguredImageService,
|
|
10
7
|
getImage,
|
|
11
|
-
imageMetadata,
|
|
12
8
|
isLocalService
|
|
13
9
|
};
|
|
@@ -31,7 +31,7 @@ interface SharedServiceProps {
|
|
|
31
31
|
validateOptions?: (options: ImageTransform, serviceConfig: Record<string, any>) => ImageTransform;
|
|
32
32
|
}
|
|
33
33
|
export type ExternalImageService = SharedServiceProps;
|
|
34
|
-
type LocalImageTransform = {
|
|
34
|
+
export type LocalImageTransform = {
|
|
35
35
|
src: string;
|
|
36
36
|
[key: string]: any;
|
|
37
37
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstroError, AstroErrorData } from "../../core/errors/index.js";
|
|
2
2
|
import { joinPaths } from "../../core/path.js";
|
|
3
|
-
import {
|
|
3
|
+
import { VALID_SUPPORTED_FORMATS } from "../consts.js";
|
|
4
4
|
import { isESMImportedImage } from "../internal.js";
|
|
5
5
|
function isLocalService(service) {
|
|
6
6
|
if (!service) {
|
|
@@ -45,16 +45,19 @@ const baseService = {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
} else {
|
|
48
|
-
if (!
|
|
48
|
+
if (!VALID_SUPPORTED_FORMATS.includes(options.src.format)) {
|
|
49
49
|
throw new AstroError({
|
|
50
50
|
...AstroErrorData.UnsupportedImageFormat,
|
|
51
51
|
message: AstroErrorData.UnsupportedImageFormat.message(
|
|
52
52
|
options.src.format,
|
|
53
53
|
options.src.src,
|
|
54
|
-
|
|
54
|
+
VALID_SUPPORTED_FORMATS
|
|
55
55
|
)
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
+
if (options.src.format === "svg") {
|
|
59
|
+
options.format = "svg";
|
|
60
|
+
}
|
|
58
61
|
}
|
|
59
62
|
if (!options.format) {
|
|
60
63
|
options.format = "webp";
|
|
@@ -27,7 +27,10 @@ const sharpService = {
|
|
|
27
27
|
if (!sharp)
|
|
28
28
|
sharp = await loadSharp();
|
|
29
29
|
const transform = transformOptions;
|
|
30
|
+
if (transform.format === "svg")
|
|
31
|
+
return { data: inputBuffer, format: "svg" };
|
|
30
32
|
let result = sharp(inputBuffer, { failOnError: false, pages: -1 });
|
|
33
|
+
result.rotate();
|
|
31
34
|
if (transform.height && !transform.width) {
|
|
32
35
|
result.resize({ height: transform.height });
|
|
33
36
|
} else if (transform.width) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { imageMetadata } from "../utils/metadata.js";
|
|
1
2
|
import {
|
|
2
3
|
baseService,
|
|
3
4
|
parseQuality
|
|
@@ -17,6 +18,24 @@ const qualityTable = {
|
|
|
17
18
|
webp: baseQuality
|
|
18
19
|
// Squoosh's PNG encoder does not support a quality setting, so we can skip that here
|
|
19
20
|
};
|
|
21
|
+
async function getRotationForEXIF(transform, inputBuffer) {
|
|
22
|
+
const filePath = transform.src.slice("/@fs".length);
|
|
23
|
+
const filePathURL = new URL("." + filePath, "file:");
|
|
24
|
+
const meta = await imageMetadata(filePathURL, inputBuffer);
|
|
25
|
+
if (!meta)
|
|
26
|
+
return void 0;
|
|
27
|
+
switch (meta.orientation) {
|
|
28
|
+
case 3:
|
|
29
|
+
case 4:
|
|
30
|
+
return { type: "rotate", numRotations: 2 };
|
|
31
|
+
case 5:
|
|
32
|
+
case 6:
|
|
33
|
+
return { type: "rotate", numRotations: 1 };
|
|
34
|
+
case 7:
|
|
35
|
+
case 8:
|
|
36
|
+
return { type: "rotate", numRotations: 3 };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
20
39
|
const service = {
|
|
21
40
|
validateOptions: baseService.validateOptions,
|
|
22
41
|
getURL: baseService.getURL,
|
|
@@ -25,7 +44,13 @@ const service = {
|
|
|
25
44
|
async transform(inputBuffer, transformOptions) {
|
|
26
45
|
const transform = transformOptions;
|
|
27
46
|
let format = transform.format;
|
|
47
|
+
if (format === "svg")
|
|
48
|
+
return { data: inputBuffer, format: "svg" };
|
|
28
49
|
const operations = [];
|
|
50
|
+
const rotation = await getRotationForEXIF(transform, inputBuffer);
|
|
51
|
+
if (rotation) {
|
|
52
|
+
operations.push(rotation);
|
|
53
|
+
}
|
|
29
54
|
if (transform.height && !transform.width) {
|
|
30
55
|
operations.push({
|
|
31
56
|
type: "resize",
|
|
@@ -37,15 +37,15 @@ var Module = function() {
|
|
|
37
37
|
var nodePath;
|
|
38
38
|
if (ENVIRONMENT_IS_NODE) {
|
|
39
39
|
if (ENVIRONMENT_IS_WORKER) {
|
|
40
|
-
scriptDirectory = require2("path").dirname(scriptDirectory) + "/";
|
|
40
|
+
scriptDirectory = require2("node:path").dirname(scriptDirectory) + "/";
|
|
41
41
|
} else {
|
|
42
42
|
scriptDirectory = dirname(getModuleURL(import.meta.url)) + "/";
|
|
43
43
|
}
|
|
44
44
|
read_ = function shell_read(filename, binary) {
|
|
45
45
|
if (!nodeFS)
|
|
46
|
-
nodeFS = require2("fs");
|
|
46
|
+
nodeFS = require2("node:fs");
|
|
47
47
|
if (!nodePath)
|
|
48
|
-
nodePath = require2("path");
|
|
48
|
+
nodePath = require2("node:path");
|
|
49
49
|
filename = nodePath["normalize"](filename);
|
|
50
50
|
return nodeFS["readFileSync"](filename, binary ? null : "utf8");
|
|
51
51
|
};
|
|
@@ -37,15 +37,15 @@ var Module = function() {
|
|
|
37
37
|
var nodePath;
|
|
38
38
|
if (ENVIRONMENT_IS_NODE) {
|
|
39
39
|
if (ENVIRONMENT_IS_WORKER) {
|
|
40
|
-
scriptDirectory = require2("path").dirname(scriptDirectory) + "/";
|
|
40
|
+
scriptDirectory = require2("node:path").dirname(scriptDirectory) + "/";
|
|
41
41
|
} else {
|
|
42
42
|
scriptDirectory = dirname(getModuleURL(import.meta.url)) + "/";
|
|
43
43
|
}
|
|
44
44
|
read_ = function shell_read(filename, binary) {
|
|
45
45
|
if (!nodeFS)
|
|
46
|
-
nodeFS = require2("fs");
|
|
46
|
+
nodeFS = require2("node:fs");
|
|
47
47
|
if (!nodePath)
|
|
48
|
-
nodePath = require2("path");
|
|
48
|
+
nodePath = require2("node:path");
|
|
49
49
|
filename = nodePath["normalize"](filename);
|
|
50
50
|
return nodeFS["readFileSync"](filename, binary ? null : "utf8");
|
|
51
51
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { cpus } from "node:os";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
1
3
|
import { isMainThread } from "node:worker_threads";
|
|
2
|
-
import { cpus } from "os";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
4
|
import { getModuleURL } from "./emscripten-utils.js";
|
|
5
5
|
import * as impl from "./impl.js";
|
|
6
6
|
import execOnce from "./utils/execOnce.js";
|
|
@@ -37,15 +37,15 @@ var Module = function() {
|
|
|
37
37
|
var nodePath;
|
|
38
38
|
if (ENVIRONMENT_IS_NODE) {
|
|
39
39
|
if (ENVIRONMENT_IS_WORKER) {
|
|
40
|
-
scriptDirectory = require2("path").dirname(scriptDirectory) + "/";
|
|
40
|
+
scriptDirectory = require2("node:path").dirname(scriptDirectory) + "/";
|
|
41
41
|
} else {
|
|
42
42
|
scriptDirectory = dirname(getModuleURL(import.meta.url)) + "/";
|
|
43
43
|
}
|
|
44
44
|
read_ = function shell_read(filename, binary) {
|
|
45
45
|
if (!nodeFS)
|
|
46
|
-
nodeFS = require2("fs");
|
|
46
|
+
nodeFS = require2("node:fs");
|
|
47
47
|
if (!nodePath)
|
|
48
|
-
nodePath = require2("path");
|
|
48
|
+
nodePath = require2("node:path");
|
|
49
49
|
filename = nodePath["normalize"](filename);
|
|
50
50
|
return nodeFS["readFileSync"](filename, binary ? null : "utf8");
|
|
51
51
|
};
|
|
@@ -37,15 +37,15 @@ var Module = function() {
|
|
|
37
37
|
var nodePath;
|
|
38
38
|
if (ENVIRONMENT_IS_NODE) {
|
|
39
39
|
if (ENVIRONMENT_IS_WORKER) {
|
|
40
|
-
scriptDirectory = require2("path").dirname(scriptDirectory) + "/";
|
|
40
|
+
scriptDirectory = require2("node:path").dirname(scriptDirectory) + "/";
|
|
41
41
|
} else {
|
|
42
42
|
scriptDirectory = dirname(getModuleURL(import.meta.url)) + "/";
|
|
43
43
|
}
|
|
44
44
|
read_ = function shell_read(filename, binary) {
|
|
45
45
|
if (!nodeFS)
|
|
46
|
-
nodeFS = require2("fs");
|
|
46
|
+
nodeFS = require2("node:fs");
|
|
47
47
|
if (!nodePath)
|
|
48
|
-
nodePath = require2("path");
|
|
48
|
+
nodePath = require2("node:path");
|
|
49
49
|
filename = nodePath["normalize"](filename);
|
|
50
50
|
return nodeFS["readFileSync"](filename, binary ? null : "utf8");
|
|
51
51
|
};
|
|
@@ -37,15 +37,15 @@ var Module = function() {
|
|
|
37
37
|
var nodePath;
|
|
38
38
|
if (ENVIRONMENT_IS_NODE) {
|
|
39
39
|
if (ENVIRONMENT_IS_WORKER) {
|
|
40
|
-
scriptDirectory = require2("path").dirname(scriptDirectory) + "/";
|
|
40
|
+
scriptDirectory = require2("node:path").dirname(scriptDirectory) + "/";
|
|
41
41
|
} else {
|
|
42
42
|
scriptDirectory = dirname(getModuleURL(import.meta.url)) + "/";
|
|
43
43
|
}
|
|
44
44
|
read_ = function shell_read(filename, binary) {
|
|
45
45
|
if (!nodeFS)
|
|
46
|
-
nodeFS = require2("fs");
|
|
46
|
+
nodeFS = require2("node:fs");
|
|
47
47
|
if (!nodePath)
|
|
48
|
-
nodePath = require2("path");
|
|
48
|
+
nodePath = require2("node:path");
|
|
49
49
|
filename = nodePath["normalize"](filename);
|
|
50
50
|
return nodeFS["readFileSync"](filename, binary ? null : "utf8");
|
|
51
51
|
};
|
|
@@ -37,15 +37,15 @@ var Module = function() {
|
|
|
37
37
|
var nodePath;
|
|
38
38
|
if (ENVIRONMENT_IS_NODE) {
|
|
39
39
|
if (ENVIRONMENT_IS_WORKER) {
|
|
40
|
-
scriptDirectory = require2("path").dirname(scriptDirectory) + "/";
|
|
40
|
+
scriptDirectory = require2("node:path").dirname(scriptDirectory) + "/";
|
|
41
41
|
} else {
|
|
42
42
|
scriptDirectory = dirname(getModuleURL(import.meta.url)) + "/";
|
|
43
43
|
}
|
|
44
44
|
read_ = function shell_read(filename, binary) {
|
|
45
45
|
if (!nodeFS)
|
|
46
|
-
nodeFS = require2("fs");
|
|
46
|
+
nodeFS = require2("node:fs");
|
|
47
47
|
if (!nodePath)
|
|
48
|
-
nodePath = require2("path");
|
|
48
|
+
nodePath = require2("node:path");
|
|
49
49
|
filename = nodePath["normalize"](filename);
|
|
50
50
|
return nodeFS["readFileSync"](filename, binary ? null : "utf8");
|
|
51
51
|
};
|
package/dist/assets/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function emitESMImage(id: string | undefined, watchMode: boolean, fileEmitter: any): Promise<
|
|
1
|
+
import type { ImageMetadata } from '../types.js';
|
|
2
|
+
export declare function emitESMImage(id: string | undefined, watchMode: boolean, fileEmitter: any): Promise<ImageMetadata | undefined>;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { ImageMetadata } from '../types.js';
|
|
3
|
-
export
|
|
4
|
-
orientation?: number;
|
|
5
|
-
}
|
|
6
|
-
export declare function imageMetadata(src: URL | string, data?: Buffer): Promise<Metadata | undefined>;
|
|
3
|
+
export declare function imageMetadata(src: URL | string, data?: Buffer): Promise<ImageMetadata | undefined>;
|
package/dist/cli/add/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { type LogOptions } from '../../core/logger/core.js';
|
|
|
3
3
|
interface AddOptions {
|
|
4
4
|
logging: LogOptions;
|
|
5
5
|
flags: yargs.Arguments;
|
|
6
|
-
cwd?: string;
|
|
7
6
|
}
|
|
8
7
|
interface IntegrationInfo {
|
|
9
8
|
id: string;
|
|
@@ -11,6 +10,6 @@ interface IntegrationInfo {
|
|
|
11
10
|
dependencies: [name: string, version: string][];
|
|
12
11
|
type: 'integration' | 'adapter';
|
|
13
12
|
}
|
|
14
|
-
export declare function add(names: string[], {
|
|
13
|
+
export declare function add(names: string[], { flags, logging }: AddOptions): Promise<void>;
|
|
15
14
|
export declare function validateIntegrations(integrations: string[]): Promise<IntegrationInfo[]>;
|
|
16
15
|
export {};
|
package/dist/cli/add/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import boxen from "boxen";
|
|
2
2
|
import { diffWords } from "diff";
|
|
3
3
|
import { execa } from "execa";
|
|
4
|
-
import fsMod, { existsSync, promises as fs } from "fs";
|
|
5
4
|
import { bold, cyan, dim, green, magenta, red, yellow } from "kleur/colors";
|
|
5
|
+
import fsMod, { existsSync, promises as fs } from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
8
|
import ora from "ora";
|
|
7
|
-
import path from "path";
|
|
8
9
|
import preferredPM from "preferred-pm";
|
|
9
10
|
import prompts from "prompts";
|
|
10
|
-
import { fileURLToPath, pathToFileURL } from "url";
|
|
11
11
|
import { loadTSConfig, resolveConfigPath } from "../../core/config/index.js";
|
|
12
12
|
import {
|
|
13
13
|
defaultTSConfig,
|
|
@@ -20,6 +20,7 @@ import { printHelp } from "../../core/messages.js";
|
|
|
20
20
|
import { appendForwardSlash } from "../../core/path.js";
|
|
21
21
|
import { apply as applyPolyfill } from "../../core/polyfill.js";
|
|
22
22
|
import { parseNpmName } from "../../core/util.js";
|
|
23
|
+
import { eventCliSession, telemetry } from "../../events/index.js";
|
|
23
24
|
import { generate, parse, t, visit } from "./babel.js";
|
|
24
25
|
import { ensureImport } from "./imports.js";
|
|
25
26
|
import { wrapDefaultExport } from "./wrapper.js";
|
|
@@ -65,8 +66,9 @@ async function getRegistry() {
|
|
|
65
66
|
return "https://registry.npmjs.org";
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
|
-
async function add(names, {
|
|
69
|
+
async function add(names, { flags, logging }) {
|
|
69
70
|
var _a;
|
|
71
|
+
telemetry.record(eventCliSession("add"));
|
|
70
72
|
applyPolyfill();
|
|
71
73
|
if (flags.help || names.length === 0) {
|
|
72
74
|
printHelp({
|
|
@@ -106,6 +108,7 @@ async function add(names, { cwd, flags, logging }) {
|
|
|
106
108
|
});
|
|
107
109
|
return;
|
|
108
110
|
}
|
|
111
|
+
const cwd = flags.root;
|
|
109
112
|
const integrationNames = names.map((name) => ALIASES.has(name) ? ALIASES.get(name) : name);
|
|
110
113
|
const integrations = await validateIntegrations(integrationNames);
|
|
111
114
|
let installResult = await tryToInstallIntegrations({ integrations, cwd, flags, logging });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { AstroCheck } from '@astrojs/language-server';
|
|
3
|
-
import fs from 'fs';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
4
|
import type { Arguments as Flags } from 'yargs-parser';
|
|
5
5
|
import type { AstroSettings } from '../../@types/astro';
|
|
6
6
|
import type { LogOptions } from '../../core/logger/core.js';
|
package/dist/cli/check/index.js
CHANGED
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
DiagnosticSeverity
|
|
4
4
|
} from "@astrojs/language-server";
|
|
5
5
|
import glob from "fast-glob";
|
|
6
|
-
import fs from "fs";
|
|
7
6
|
import { bold, dim, red, yellow } from "kleur/colors";
|
|
8
7
|
import { createRequire } from "module";
|
|
8
|
+
import fs from "node:fs";
|
|
9
9
|
import { join } from "node:path";
|
|
10
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
10
11
|
import ora from "ora";
|
|
11
|
-
import { fileURLToPath, pathToFileURL } from "url";
|
|
12
12
|
import { debug, info } from "../../core/logger/core.js";
|
|
13
13
|
import { printHelp } from "../../core/messages.js";
|
|
14
14
|
import { loadSettings } from "../load-settings.js";
|
package/dist/cli/check/print.js
CHANGED
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
white,
|
|
12
12
|
yellow
|
|
13
13
|
} from "kleur/colors";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
14
15
|
import stringWidth from "string-width";
|
|
15
|
-
import { fileURLToPath } from "url";
|
|
16
16
|
function printDiagnostic(filePath, text, diag) {
|
|
17
17
|
let result = [];
|
|
18
18
|
const realStartLine = diag.range.start.line + 1;
|
package/dist/cli/dev/index.js
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import * as colors from "kleur/colors";
|
|
2
2
|
import yargs from "yargs-parser";
|
|
3
3
|
import { ASTRO_VERSION } from "../core/constants.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { debug } from "../core/logger/core.js";
|
|
7
|
-
import { enableVerboseLogging, nodeLogDestination } from "../core/logger/node.js";
|
|
8
|
-
import { formatErrorMessage, printHelp } from "../core/messages.js";
|
|
9
|
-
import * as event from "../events/index.js";
|
|
10
|
-
import { eventError, telemetry } from "../events/index.js";
|
|
11
|
-
function printAstroHelp() {
|
|
4
|
+
async function printAstroHelp() {
|
|
5
|
+
const { printHelp } = await import("../core/messages.js");
|
|
12
6
|
printHelp({
|
|
13
7
|
commandName: "astro",
|
|
14
8
|
usage: "[command] [...flags]",
|
|
@@ -64,21 +58,19 @@ function resolveCommand(flags) {
|
|
|
64
58
|
}
|
|
65
59
|
async function runCommand(cmd, flags) {
|
|
66
60
|
var _a;
|
|
67
|
-
const root = flags.root;
|
|
68
61
|
switch (cmd) {
|
|
69
62
|
case "help":
|
|
70
|
-
printAstroHelp();
|
|
63
|
+
await printAstroHelp();
|
|
71
64
|
return;
|
|
72
65
|
case "version":
|
|
73
66
|
printVersion();
|
|
74
67
|
return;
|
|
75
68
|
case "info": {
|
|
76
69
|
const { printInfo } = await import("./info/index.js");
|
|
77
|
-
await printInfo({
|
|
70
|
+
await printInfo({ flags });
|
|
78
71
|
return;
|
|
79
72
|
}
|
|
80
73
|
case "docs": {
|
|
81
|
-
telemetry.record(event.eventCliSession(cmd));
|
|
82
74
|
const { docs } = await import("./docs/index.js");
|
|
83
75
|
await docs({ flags });
|
|
84
76
|
return;
|
|
@@ -90,6 +82,7 @@ async function runCommand(cmd, flags) {
|
|
|
90
82
|
return;
|
|
91
83
|
}
|
|
92
84
|
}
|
|
85
|
+
const { enableVerboseLogging, nodeLogDestination } = await import("../core/logger/node.js");
|
|
93
86
|
const logging = {
|
|
94
87
|
dest: nodeLogDestination,
|
|
95
88
|
level: "info"
|
|
@@ -105,10 +98,9 @@ async function runCommand(cmd, flags) {
|
|
|
105
98
|
}
|
|
106
99
|
switch (cmd) {
|
|
107
100
|
case "add": {
|
|
108
|
-
telemetry.record(event.eventCliSession(cmd));
|
|
109
101
|
const { add } = await import("./add/index.js");
|
|
110
102
|
const packages = flags._.slice(3);
|
|
111
|
-
await add(packages, {
|
|
103
|
+
await add(packages, { flags, logging });
|
|
112
104
|
return;
|
|
113
105
|
}
|
|
114
106
|
case "dev": {
|
|
@@ -142,7 +134,7 @@ async function runCommand(cmd, flags) {
|
|
|
142
134
|
return await new Promise(() => {
|
|
143
135
|
});
|
|
144
136
|
} else {
|
|
145
|
-
|
|
137
|
+
const checkResult = await checkServer.check();
|
|
146
138
|
return process.exit(checkResult);
|
|
147
139
|
}
|
|
148
140
|
}
|
|
@@ -162,22 +154,10 @@ async function cli(args) {
|
|
|
162
154
|
try {
|
|
163
155
|
await runCommand(cmd, flags);
|
|
164
156
|
} catch (err) {
|
|
157
|
+
const { throwAndExit } = await import("./throw-and-exit.js");
|
|
165
158
|
await throwAndExit(cmd, err);
|
|
166
159
|
}
|
|
167
160
|
}
|
|
168
|
-
async function throwAndExit(cmd, err) {
|
|
169
|
-
let telemetryPromise;
|
|
170
|
-
let errorMessage;
|
|
171
|
-
function exitWithErrorMessage() {
|
|
172
|
-
console.error(errorMessage);
|
|
173
|
-
process.exit(1);
|
|
174
|
-
}
|
|
175
|
-
const errorWithMetadata = collectErrorMetadata(createSafeError(err));
|
|
176
|
-
telemetryPromise = telemetry.record(eventError({ cmd, err: errorWithMetadata, isFatal: true }));
|
|
177
|
-
errorMessage = formatErrorMessage(errorWithMetadata);
|
|
178
|
-
setTimeout(exitWithErrorMessage, 400);
|
|
179
|
-
await telemetryPromise.catch((err2) => debug("telemetry", `record() error: ${err2.message}`)).then(exitWithErrorMessage);
|
|
180
|
-
}
|
|
181
161
|
export {
|
|
182
162
|
cli
|
|
183
163
|
};
|
package/dist/cli/info/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type yargs from 'yargs-parser';
|
|
2
2
|
interface InfoOptions {
|
|
3
|
-
cwd?: string;
|
|
4
3
|
flags: yargs.Arguments;
|
|
5
4
|
}
|
|
6
|
-
export declare function printInfo({
|
|
5
|
+
export declare function printInfo({ flags }: InfoOptions): Promise<void>;
|
|
7
6
|
export {};
|
package/dist/cli/info/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { arch, platform } from "node:os";
|
|
|
3
3
|
import whichPm from "which-pm";
|
|
4
4
|
import { openConfig } from "../../core/config/index.js";
|
|
5
5
|
import { ASTRO_VERSION } from "../../core/constants.js";
|
|
6
|
-
async function printInfo({
|
|
6
|
+
async function printInfo({ flags }) {
|
|
7
7
|
var _a;
|
|
8
8
|
const packageManager = await whichPm(process.cwd());
|
|
9
9
|
let adapter = "Couldn't determine.";
|
|
@@ -15,7 +15,7 @@ async function printInfo({ cwd, flags }) {
|
|
|
15
15
|
}
|
|
16
16
|
try {
|
|
17
17
|
const { userConfig } = await openConfig({
|
|
18
|
-
cwd,
|
|
18
|
+
cwd: flags.root,
|
|
19
19
|
flags,
|
|
20
20
|
cmd: "info"
|
|
21
21
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
1
|
import * as colors from "kleur/colors";
|
|
2
|
+
import fs from "node:fs";
|
|
3
3
|
import { ZodError } from "zod";
|
|
4
4
|
import { createSettings, openConfig, resolveConfigPath } from "../core/config/index.js";
|
|
5
5
|
import { collectErrorMetadata } from "../core/errors/dev/index.js";
|
package/dist/cli/sync/index.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { collectErrorMetadata } from "../core/errors/dev/index.js";
|
|
2
|
+
import { createSafeError } from "../core/errors/index.js";
|
|
3
|
+
import { debug } from "../core/logger/core.js";
|
|
4
|
+
import { formatErrorMessage } from "../core/messages.js";
|
|
5
|
+
import { eventError, telemetry } from "../events/index.js";
|
|
6
|
+
async function throwAndExit(cmd, err) {
|
|
7
|
+
let telemetryPromise;
|
|
8
|
+
let errorMessage;
|
|
9
|
+
function exitWithErrorMessage() {
|
|
10
|
+
console.error(errorMessage);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
const errorWithMetadata = collectErrorMetadata(createSafeError(err));
|
|
14
|
+
telemetryPromise = telemetry.record(eventError({ cmd, err: errorWithMetadata, isFatal: true }));
|
|
15
|
+
errorMessage = formatErrorMessage(errorWithMetadata);
|
|
16
|
+
setTimeout(exitWithErrorMessage, 400);
|
|
17
|
+
await telemetryPromise.catch((err2) => debug("telemetry", `record() error: ${err2.message}`)).then(exitWithErrorMessage);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
throwAndExit
|
|
21
|
+
};
|
package/dist/config/index.js
CHANGED
|
@@ -13,7 +13,7 @@ function getViteConfig(inlineConfig) {
|
|
|
13
13
|
{ runHookConfigSetup, runHookConfigDone },
|
|
14
14
|
{ astroContentListenPlugin }
|
|
15
15
|
] = await Promise.all([
|
|
16
|
-
import("fs"),
|
|
16
|
+
import("node:fs"),
|
|
17
17
|
import("vite"),
|
|
18
18
|
import("../core/logger/node.js"),
|
|
19
19
|
import("../core/config/index.js"),
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { PluginContext } from 'rollup';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
export declare function createImage(pluginContext: PluginContext, entryFilePath: string): () => z.ZodEffects<z.ZodString, import("../assets/
|
|
3
|
+
export declare function createImage(pluginContext: PluginContext, entryFilePath: string): () => z.ZodEffects<z.ZodString, import("../assets/types.js").ImageMetadata | z.ZodNever, string>;
|