@powerlines/plugin-image-compression 0.2.202 → 0.2.204
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/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/index.cjs +4 -157
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -128
- package/dist/index.mjs.map +1 -1
- package/dist/node_modules/.pnpm/@stryke_string-format@0.13.7/node_modules/@stryke/string-format/dist/pretty-bytes.cjs +128 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.13.7/node_modules/@stryke/string-format/dist/pretty-bytes.mjs +128 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.13.7/node_modules/@stryke/string-format/dist/pretty-bytes.mjs.map +1 -0
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.d.cts +1 -2
- package/dist/types/index.d.mts +1 -2
- package/dist/types/index.mjs +0 -3
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +76 -2
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.mts +76 -2
- package/dist/types/plugin.d.mts.map +1 -0
- package/dist/types/plugin.mjs +0 -2
- package/package.json +4 -4
- package/dist/index-BgAdqTbb.d.mts +0 -1
- package/dist/index-CEgs-Dz2.d.cts +0 -1
- package/dist/plugin-BX_Z82RH.d.mts +0 -76
- package/dist/plugin-BX_Z82RH.d.mts.map +0 -1
- package/dist/plugin-C3MaN5jp.mjs +0 -1
- package/dist/plugin-CJ3kcwOQ.d.cts +0 -76
- package/dist/plugin-CJ3kcwOQ.d.cts.map +0 -1
- package/dist/plugin-DHXHjv16.cjs +0 -0
- package/dist/types-CTUnla4x.mjs +0 -1
- package/dist/types-DHkg7xmX.cjs +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
package/dist/index.cjs
CHANGED
|
@@ -1,171 +1,18 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
-
key = keys[i];
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: ((k) => from[k]).bind(null, key),
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
-
value: mod,
|
|
25
|
-
enumerable: true
|
|
26
|
-
}) : target, mod));
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
require('./plugin-DHXHjv16.cjs');
|
|
30
|
-
require('./types-DHkg7xmX.cjs');
|
|
2
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_pretty_bytes = require('./node_modules/.pnpm/@stryke_string-format@0.13.7/node_modules/@stryke/string-format/dist/pretty-bytes.cjs');
|
|
31
4
|
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
32
5
|
let __stryke_fs_list_files = require("@stryke/fs/list-files");
|
|
33
6
|
let __stryke_fs_read_file = require("@stryke/fs/read-file");
|
|
34
7
|
let __stryke_fs_write_file = require("@stryke/fs/write-file");
|
|
35
8
|
let __stryke_path_find = require("@stryke/path/find");
|
|
36
9
|
let chalk = require("chalk");
|
|
37
|
-
chalk = __toESM(chalk);
|
|
10
|
+
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
38
11
|
let node_buffer = require("node:buffer");
|
|
39
12
|
let node_fs_promises = require("node:fs/promises");
|
|
40
13
|
let powerlines_plugin_utils_paths = require("powerlines/plugin-utils/paths");
|
|
41
14
|
let svgo = require("svgo");
|
|
42
15
|
|
|
43
|
-
//#region ../../node_modules/.pnpm/@stryke+string-format@0.13.7/node_modules/@stryke/string-format/dist/pretty-bytes.mjs
|
|
44
|
-
const BYTE_UNITS = [
|
|
45
|
-
"B",
|
|
46
|
-
"kB",
|
|
47
|
-
"MB",
|
|
48
|
-
"GB",
|
|
49
|
-
"TB",
|
|
50
|
-
"PB",
|
|
51
|
-
"EB",
|
|
52
|
-
"ZB",
|
|
53
|
-
"YB"
|
|
54
|
-
];
|
|
55
|
-
const BIBYTE_UNITS = [
|
|
56
|
-
"B",
|
|
57
|
-
"KiB",
|
|
58
|
-
"MiB",
|
|
59
|
-
"GiB",
|
|
60
|
-
"TiB",
|
|
61
|
-
"PiB",
|
|
62
|
-
"EiB",
|
|
63
|
-
"ZiB",
|
|
64
|
-
"YiB"
|
|
65
|
-
];
|
|
66
|
-
const BIT_UNITS = [
|
|
67
|
-
"b",
|
|
68
|
-
"kbit",
|
|
69
|
-
"Mbit",
|
|
70
|
-
"Gbit",
|
|
71
|
-
"Tbit",
|
|
72
|
-
"Pbit",
|
|
73
|
-
"Ebit",
|
|
74
|
-
"Zbit",
|
|
75
|
-
"Ybit"
|
|
76
|
-
];
|
|
77
|
-
const BIBIT_UNITS = [
|
|
78
|
-
"b",
|
|
79
|
-
"kibit",
|
|
80
|
-
"Mibit",
|
|
81
|
-
"Gibit",
|
|
82
|
-
"Tibit",
|
|
83
|
-
"Pibit",
|
|
84
|
-
"Eibit",
|
|
85
|
-
"Zibit",
|
|
86
|
-
"Yibit"
|
|
87
|
-
];
|
|
88
|
-
/**
|
|
89
|
-
* Formats the given number using `Number#toLocaleString`.
|
|
90
|
-
*
|
|
91
|
-
* @remarks
|
|
92
|
-
* - If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
|
93
|
-
* - If locale is true, the system default locale is used for translation.
|
|
94
|
-
* - If no value for locale is specified, the number is returned unmodified.
|
|
95
|
-
*
|
|
96
|
-
* @param number - The number to format.
|
|
97
|
-
* @param locale - The locale to use for formatting the number.
|
|
98
|
-
* @param options - The options to use for formatting the number.
|
|
99
|
-
* @returns The formatted number.
|
|
100
|
-
*/
|
|
101
|
-
const toLocaleString = (number, locale, options = {}) => {
|
|
102
|
-
let result = number;
|
|
103
|
-
let _locale = locale;
|
|
104
|
-
if (typeof _locale === "string") {
|
|
105
|
-
if (!_locale) _locale = process.env.STORM_LOCALE || "en-US";
|
|
106
|
-
if (Array.isArray(_locale)) result = number?.toLocaleString(_locale, options);
|
|
107
|
-
} else if (_locale === true || options !== void 0) result = number?.toLocaleString(void 0, options);
|
|
108
|
-
return String(result);
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Convert bytes to a human readable string: `1337` → `1.34 kB`.
|
|
112
|
-
*
|
|
113
|
-
* @param number - The number to format.
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* ```ts
|
|
117
|
-
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
118
|
-
*
|
|
119
|
-
* prettyBytes(1337);
|
|
120
|
-
* //=> '1.34 kB'
|
|
121
|
-
*
|
|
122
|
-
* prettyBytes(100);
|
|
123
|
-
* //=> '100 B'
|
|
124
|
-
*
|
|
125
|
-
* // Display file size differences
|
|
126
|
-
* prettyBytes(42, {signed: true});
|
|
127
|
-
* //=> '+42 B'
|
|
128
|
-
*
|
|
129
|
-
* // Localized output using German locale
|
|
130
|
-
* prettyBytes(1337, {locale: 'de'});
|
|
131
|
-
* //=> '1,34 kB'
|
|
132
|
-
* ```
|
|
133
|
-
*
|
|
134
|
-
* @param number - The number to format.
|
|
135
|
-
* @param options - The options to use.
|
|
136
|
-
* @returns The formatted string.
|
|
137
|
-
*/
|
|
138
|
-
function prettyBytes(number, options) {
|
|
139
|
-
let _number = number;
|
|
140
|
-
if (!Number.isFinite(_number)) throw new TypeError(`Expected a finite number, got ${typeof _number}: ${_number}`);
|
|
141
|
-
const opts = {
|
|
142
|
-
bits: false,
|
|
143
|
-
binary: false,
|
|
144
|
-
space: true,
|
|
145
|
-
...options
|
|
146
|
-
};
|
|
147
|
-
const UNITS = opts.bits ? opts.binary ? BIBIT_UNITS : BIT_UNITS : opts.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
148
|
-
const separator = opts.space ? " " : "";
|
|
149
|
-
if (opts.signed && _number === 0) return ` 0${separator}${UNITS[0]}`;
|
|
150
|
-
const isNegative = _number < 0;
|
|
151
|
-
const prefix = isNegative ? "-" : opts.signed ? "+" : "";
|
|
152
|
-
if (isNegative) _number = -_number;
|
|
153
|
-
let localeOptions;
|
|
154
|
-
if (opts.minimumFractionDigits !== void 0) localeOptions = { minimumFractionDigits: opts.minimumFractionDigits };
|
|
155
|
-
if (opts.maximumFractionDigits !== void 0) localeOptions = {
|
|
156
|
-
maximumFractionDigits: opts.maximumFractionDigits,
|
|
157
|
-
...localeOptions
|
|
158
|
-
};
|
|
159
|
-
if (_number < 1) return prefix + toLocaleString(_number, opts.locale, localeOptions) + separator + UNITS[0];
|
|
160
|
-
const exponent = Math.min(Math.floor(opts.binary ? Math.log(_number) / Math.log(1024) : Math.log10(_number) / 3), UNITS.length - 1);
|
|
161
|
-
_number /= (opts.binary ? 1024 : 1e3) ** exponent;
|
|
162
|
-
if (!localeOptions) _number = _number.toPrecision(3);
|
|
163
|
-
const numberString = toLocaleString(Number(_number), opts.locale, localeOptions);
|
|
164
|
-
const unit = UNITS[exponent];
|
|
165
|
-
return prefix + numberString + separator + unit;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
//#endregion
|
|
169
16
|
//#region src/index.ts
|
|
170
17
|
/**
|
|
171
18
|
* A Powerlines plugin to optimize image assets used by the project.
|
|
@@ -261,7 +108,7 @@ const plugin = (options = {}) => {
|
|
|
261
108
|
this.error(` ✘ Failed to optimize ${file} - Compression output was not smaller than the original`);
|
|
262
109
|
return;
|
|
263
110
|
}
|
|
264
|
-
this.info(` ✔ Successfully optimized ${file}: ${chalk.default.redBright(prettyBytes(originalSize))} -> ${chalk.default.greenBright(prettyBytes(compressedSize))} (${chalk.default.green((100 - compressedSize / originalSize * 100).toFixed(2))}%) in ${(performance.now() - start).toFixed(2)} ms`);
|
|
111
|
+
this.info(` ✔ Successfully optimized ${file}: ${chalk.default.redBright(require_pretty_bytes.prettyBytes(originalSize))} -> ${chalk.default.greenBright(require_pretty_bytes.prettyBytes(compressedSize))} (${chalk.default.green((100 - compressedSize / originalSize * 100).toFixed(2))}%) in ${(performance.now() - start).toFixed(2)} ms`);
|
|
265
112
|
}));
|
|
266
113
|
}));
|
|
267
114
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./index
|
|
1
|
+
import { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig } from "./types/plugin.cjs";
|
|
2
|
+
import "./types/index.cjs";
|
|
3
3
|
import { Plugin } from "powerlines/types/plugin";
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./index
|
|
1
|
+
import { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig } from "./types/plugin.mjs";
|
|
2
|
+
import "./types/index.mjs";
|
|
3
3
|
import { Plugin } from "powerlines/types/plugin";
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./types-CTUnla4x.mjs";
|
|
1
|
+
import { prettyBytes } from "./node_modules/.pnpm/@stryke_string-format@0.13.7/node_modules/@stryke/string-format/dist/pretty-bytes.mjs";
|
|
3
2
|
import { toArray } from "@stryke/convert/to-array";
|
|
4
3
|
import { listFiles } from "@stryke/fs/list-files";
|
|
5
4
|
import { readFile } from "@stryke/fs/read-file";
|
|
@@ -11,132 +10,6 @@ import { stat } from "node:fs/promises";
|
|
|
11
10
|
import { replacePathTokens } from "powerlines/plugin-utils/paths";
|
|
12
11
|
import { optimize } from "svgo";
|
|
13
12
|
|
|
14
|
-
//#region ../../node_modules/.pnpm/@stryke+string-format@0.13.7/node_modules/@stryke/string-format/dist/pretty-bytes.mjs
|
|
15
|
-
const BYTE_UNITS = [
|
|
16
|
-
"B",
|
|
17
|
-
"kB",
|
|
18
|
-
"MB",
|
|
19
|
-
"GB",
|
|
20
|
-
"TB",
|
|
21
|
-
"PB",
|
|
22
|
-
"EB",
|
|
23
|
-
"ZB",
|
|
24
|
-
"YB"
|
|
25
|
-
];
|
|
26
|
-
const BIBYTE_UNITS = [
|
|
27
|
-
"B",
|
|
28
|
-
"KiB",
|
|
29
|
-
"MiB",
|
|
30
|
-
"GiB",
|
|
31
|
-
"TiB",
|
|
32
|
-
"PiB",
|
|
33
|
-
"EiB",
|
|
34
|
-
"ZiB",
|
|
35
|
-
"YiB"
|
|
36
|
-
];
|
|
37
|
-
const BIT_UNITS = [
|
|
38
|
-
"b",
|
|
39
|
-
"kbit",
|
|
40
|
-
"Mbit",
|
|
41
|
-
"Gbit",
|
|
42
|
-
"Tbit",
|
|
43
|
-
"Pbit",
|
|
44
|
-
"Ebit",
|
|
45
|
-
"Zbit",
|
|
46
|
-
"Ybit"
|
|
47
|
-
];
|
|
48
|
-
const BIBIT_UNITS = [
|
|
49
|
-
"b",
|
|
50
|
-
"kibit",
|
|
51
|
-
"Mibit",
|
|
52
|
-
"Gibit",
|
|
53
|
-
"Tibit",
|
|
54
|
-
"Pibit",
|
|
55
|
-
"Eibit",
|
|
56
|
-
"Zibit",
|
|
57
|
-
"Yibit"
|
|
58
|
-
];
|
|
59
|
-
/**
|
|
60
|
-
* Formats the given number using `Number#toLocaleString`.
|
|
61
|
-
*
|
|
62
|
-
* @remarks
|
|
63
|
-
* - If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
|
64
|
-
* - If locale is true, the system default locale is used for translation.
|
|
65
|
-
* - If no value for locale is specified, the number is returned unmodified.
|
|
66
|
-
*
|
|
67
|
-
* @param number - The number to format.
|
|
68
|
-
* @param locale - The locale to use for formatting the number.
|
|
69
|
-
* @param options - The options to use for formatting the number.
|
|
70
|
-
* @returns The formatted number.
|
|
71
|
-
*/
|
|
72
|
-
const toLocaleString = (number, locale, options = {}) => {
|
|
73
|
-
let result = number;
|
|
74
|
-
let _locale = locale;
|
|
75
|
-
if (typeof _locale === "string") {
|
|
76
|
-
if (!_locale) _locale = process.env.STORM_LOCALE || "en-US";
|
|
77
|
-
if (Array.isArray(_locale)) result = number?.toLocaleString(_locale, options);
|
|
78
|
-
} else if (_locale === true || options !== void 0) result = number?.toLocaleString(void 0, options);
|
|
79
|
-
return String(result);
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Convert bytes to a human readable string: `1337` → `1.34 kB`.
|
|
83
|
-
*
|
|
84
|
-
* @param number - The number to format.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```ts
|
|
88
|
-
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
89
|
-
*
|
|
90
|
-
* prettyBytes(1337);
|
|
91
|
-
* //=> '1.34 kB'
|
|
92
|
-
*
|
|
93
|
-
* prettyBytes(100);
|
|
94
|
-
* //=> '100 B'
|
|
95
|
-
*
|
|
96
|
-
* // Display file size differences
|
|
97
|
-
* prettyBytes(42, {signed: true});
|
|
98
|
-
* //=> '+42 B'
|
|
99
|
-
*
|
|
100
|
-
* // Localized output using German locale
|
|
101
|
-
* prettyBytes(1337, {locale: 'de'});
|
|
102
|
-
* //=> '1,34 kB'
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* @param number - The number to format.
|
|
106
|
-
* @param options - The options to use.
|
|
107
|
-
* @returns The formatted string.
|
|
108
|
-
*/
|
|
109
|
-
function prettyBytes(number, options) {
|
|
110
|
-
let _number = number;
|
|
111
|
-
if (!Number.isFinite(_number)) throw new TypeError(`Expected a finite number, got ${typeof _number}: ${_number}`);
|
|
112
|
-
const opts = {
|
|
113
|
-
bits: false,
|
|
114
|
-
binary: false,
|
|
115
|
-
space: true,
|
|
116
|
-
...options
|
|
117
|
-
};
|
|
118
|
-
const UNITS = opts.bits ? opts.binary ? BIBIT_UNITS : BIT_UNITS : opts.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
119
|
-
const separator = opts.space ? " " : "";
|
|
120
|
-
if (opts.signed && _number === 0) return ` 0${separator}${UNITS[0]}`;
|
|
121
|
-
const isNegative = _number < 0;
|
|
122
|
-
const prefix = isNegative ? "-" : opts.signed ? "+" : "";
|
|
123
|
-
if (isNegative) _number = -_number;
|
|
124
|
-
let localeOptions;
|
|
125
|
-
if (opts.minimumFractionDigits !== void 0) localeOptions = { minimumFractionDigits: opts.minimumFractionDigits };
|
|
126
|
-
if (opts.maximumFractionDigits !== void 0) localeOptions = {
|
|
127
|
-
maximumFractionDigits: opts.maximumFractionDigits,
|
|
128
|
-
...localeOptions
|
|
129
|
-
};
|
|
130
|
-
if (_number < 1) return prefix + toLocaleString(_number, opts.locale, localeOptions) + separator + UNITS[0];
|
|
131
|
-
const exponent = Math.min(Math.floor(opts.binary ? Math.log(_number) / Math.log(1024) : Math.log10(_number) / 3), UNITS.length - 1);
|
|
132
|
-
_number /= (opts.binary ? 1024 : 1e3) ** exponent;
|
|
133
|
-
if (!localeOptions) _number = _number.toPrecision(3);
|
|
134
|
-
const numberString = toLocaleString(Number(_number), opts.locale, localeOptions);
|
|
135
|
-
const unit = UNITS[exponent];
|
|
136
|
-
return prefix + numberString + separator + unit;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
//#endregion
|
|
140
13
|
//#region src/index.ts
|
|
141
14
|
/**
|
|
142
15
|
* A Powerlines plugin to optimize image assets used by the project.
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../node_modules/.pnpm/@stryke+string-format@0.13.7/node_modules/@stryke/string-format/dist/pretty-bytes.mjs","../src/index.ts"],"sourcesContent":["//#region src/pretty-bytes.ts\nconst BYTE_UNITS = [\n\t\"B\",\n\t\"kB\",\n\t\"MB\",\n\t\"GB\",\n\t\"TB\",\n\t\"PB\",\n\t\"EB\",\n\t\"ZB\",\n\t\"YB\"\n];\nconst BIBYTE_UNITS = [\n\t\"B\",\n\t\"KiB\",\n\t\"MiB\",\n\t\"GiB\",\n\t\"TiB\",\n\t\"PiB\",\n\t\"EiB\",\n\t\"ZiB\",\n\t\"YiB\"\n];\nconst BIT_UNITS = [\n\t\"b\",\n\t\"kbit\",\n\t\"Mbit\",\n\t\"Gbit\",\n\t\"Tbit\",\n\t\"Pbit\",\n\t\"Ebit\",\n\t\"Zbit\",\n\t\"Ybit\"\n];\nconst BIBIT_UNITS = [\n\t\"b\",\n\t\"kibit\",\n\t\"Mibit\",\n\t\"Gibit\",\n\t\"Tibit\",\n\t\"Pibit\",\n\t\"Eibit\",\n\t\"Zibit\",\n\t\"Yibit\"\n];\n/**\n* Formats the given number using `Number#toLocaleString`.\n*\n* @remarks\n* - If locale is a string, the value is expected to be a locale-key (for example: `de`).\n* - If locale is true, the system default locale is used for translation.\n* - If no value for locale is specified, the number is returned unmodified.\n*\n* @param number - The number to format.\n* @param locale - The locale to use for formatting the number.\n* @param options - The options to use for formatting the number.\n* @returns The formatted number.\n*/\nconst toLocaleString = (number, locale, options = {}) => {\n\tlet result = number;\n\tlet _locale = locale;\n\tif (typeof _locale === \"string\") {\n\t\tif (!_locale) _locale = process.env.STORM_LOCALE || \"en-US\";\n\t\tif (Array.isArray(_locale)) result = number?.toLocaleString(_locale, options);\n\t} else if (_locale === true || options !== void 0) result = number?.toLocaleString(void 0, options);\n\treturn String(result);\n};\n/**\n* Convert bytes to a human readable string: `1337` → `1.34 kB`.\n*\n* @param number - The number to format.\n*\n* @example\n* ```ts\n* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';\n*\n* prettyBytes(1337);\n* //=> '1.34 kB'\n*\n* prettyBytes(100);\n* //=> '100 B'\n*\n* // Display file size differences\n* prettyBytes(42, {signed: true});\n* //=> '+42 B'\n*\n* // Localized output using German locale\n* prettyBytes(1337, {locale: 'de'});\n* //=> '1,34 kB'\n* ```\n*\n* @param number - The number to format.\n* @param options - The options to use.\n* @returns The formatted string.\n*/\nfunction prettyBytes(number, options) {\n\tlet _number = number;\n\tif (!Number.isFinite(_number)) throw new TypeError(`Expected a finite number, got ${typeof _number}: ${_number}`);\n\tconst opts = {\n\t\tbits: false,\n\t\tbinary: false,\n\t\tspace: true,\n\t\t...options\n\t};\n\tconst UNITS = opts.bits ? opts.binary ? BIBIT_UNITS : BIT_UNITS : opts.binary ? BIBYTE_UNITS : BYTE_UNITS;\n\tconst separator = opts.space ? \" \" : \"\";\n\tif (opts.signed && _number === 0) return ` 0${separator}${UNITS[0]}`;\n\tconst isNegative = _number < 0;\n\tconst prefix = isNegative ? \"-\" : opts.signed ? \"+\" : \"\";\n\tif (isNegative) _number = -_number;\n\tlet localeOptions;\n\tif (opts.minimumFractionDigits !== void 0) localeOptions = { minimumFractionDigits: opts.minimumFractionDigits };\n\tif (opts.maximumFractionDigits !== void 0) localeOptions = {\n\t\tmaximumFractionDigits: opts.maximumFractionDigits,\n\t\t...localeOptions\n\t};\n\tif (_number < 1) return prefix + toLocaleString(_number, opts.locale, localeOptions) + separator + UNITS[0];\n\tconst exponent = Math.min(Math.floor(opts.binary ? Math.log(_number) / Math.log(1024) : Math.log10(_number) / 3), UNITS.length - 1);\n\t_number /= (opts.binary ? 1024 : 1e3) ** exponent;\n\tif (!localeOptions) _number = _number.toPrecision(3);\n\tconst numberString = toLocaleString(Number(_number), opts.locale, localeOptions);\n\tconst unit = UNITS[exponent];\n\treturn prefix + numberString + separator + unit;\n}\n\n//#endregion\nexport { prettyBytes, toLocaleString };\n//# sourceMappingURL=pretty-bytes.mjs.map","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { readFile } from \"@stryke/fs/read-file\";\nimport { writeFile } from \"@stryke/fs/write-file\";\nimport { findFileExtensionSafe } from \"@stryke/path/find\";\nimport { prettyBytes } from \"@stryke/string-format/pretty-bytes\";\nimport chalk from \"chalk\";\nimport { Buffer } from \"node:buffer\";\nimport { stat } from \"node:fs/promises\";\nimport { replacePathTokens } from \"powerlines/plugin-utils/paths\";\nimport type { Plugin } from \"powerlines/types/plugin\";\nimport { optimize } from \"svgo\";\nimport {\n ImageCompressionPluginContext,\n ImageCompressionPluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\n/**\n * A Powerlines plugin to optimize image assets used by the project.\n *\n * @see https://sharp.pixelplumbing.com\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends ImageCompressionPluginContext = ImageCompressionPluginContext\n>(\n options: ImageCompressionPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"image-compression\",\n config() {\n return {\n imageCompression: {\n filter:\n \"{projectRoot}/**/*.{svg,jpg,jpeg,png,webp,avif,heif,gif,tiff,jp2,jxl}\",\n svg: {},\n jpeg: {},\n png: {},\n webp: {},\n avif: {},\n heif: {},\n tiff: {},\n jp2: {},\n jxl: {},\n ...options\n }\n };\n },\n async configResolved() {\n if (!this.config.imageCompression.filter) {\n throw new Error(\n \"ImageCompression plugin requires a filter or glob pattern to be specified in the configuration.\"\n );\n }\n\n this.config.imageCompression.filter = toArray(\n this.config.imageCompression.filter\n )\n .map(path => replacePathTokens(this, path))\n .filter(Boolean);\n },\n async prepare() {\n await Promise.all(\n toArray(this.config.imageCompression.filter).map(async path => {\n await Promise.all(\n (await listFiles(path)).map(async file => {\n const outputPath = this.config.imageCompression.outputPath\n ? replacePathTokens(\n this,\n this.config.imageCompression.outputPath\n ).replace(/\\{fileName\\}/g, file.split(\"/\").pop() || \"output\")\n : file;\n\n const start = performance.now();\n const originalSize = (await stat(file)).size;\n let compressedSize = 0;\n\n const extension = findFileExtensionSafe(file).toLowerCase();\n if (!extension) {\n this.error(\n ` ✘ Failed to optimize ${file} - Unable to determine file extension`\n );\n return;\n }\n\n if (extension === \"svg\") {\n const result = optimize(await readFile(file), {\n multipass: true,\n path: file,\n ...this.config.imageCompression.svg\n });\n if (result.data) {\n compressedSize = Buffer.byteLength(result.data, \"utf8\");\n await writeFile(outputPath, result.data);\n }\n } else {\n let image = await import(\"sharp\").then(sharpModule =>\n sharpModule.default(file, { animated: extension === \"gif\" })\n );\n\n switch (extension) {\n case \"jpeg\":\n case \"jpg\":\n image = image.jpeg(this.config.imageCompression.jpeg);\n break;\n case \"png\":\n image = image.png(this.config.imageCompression.png);\n break;\n case \"webp\":\n image = image.webp(this.config.imageCompression.webp);\n break;\n case \"avif\":\n image = image.avif(this.config.imageCompression.avif);\n break;\n case \"gif\":\n image = image.gif(this.config.imageCompression.gif);\n break;\n case \"heif\":\n image = image.heif(this.config.imageCompression.heif);\n break;\n case \"tiff\":\n image = image.tiff(this.config.imageCompression.tiff);\n break;\n case \"jp2\":\n image = image.jp2(this.config.imageCompression.jp2);\n break;\n case \"jxl\":\n image = image.jxl(this.config.imageCompression.jxl);\n break;\n }\n\n const result = await image.toFile(outputPath);\n compressedSize = result.size;\n }\n\n if (!compressedSize) {\n this.error(` ✘ Failed to optimize ${file} - No data returned`);\n return;\n }\n\n if (compressedSize >= originalSize) {\n this.error(\n ` ✘ Failed to optimize ${file} - Compression output was not smaller than the original`\n );\n return;\n }\n\n this.info(\n ` ✔ Successfully optimized ${\n file\n }: ${chalk.redBright(prettyBytes(originalSize))} -> ${chalk.greenBright(\n prettyBytes(compressedSize)\n )} (${chalk.green(\n (100 - (compressedSize / originalSize) * 100).toFixed(2)\n )}%) in ${(performance.now() - start).toFixed(2)} ms`\n );\n })\n );\n })\n );\n }\n };\n};\n\nexport default plugin;\n"],"x_google_ignoreList":[0],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { readFile } from \"@stryke/fs/read-file\";\nimport { writeFile } from \"@stryke/fs/write-file\";\nimport { findFileExtensionSafe } from \"@stryke/path/find\";\nimport { prettyBytes } from \"@stryke/string-format/pretty-bytes\";\nimport chalk from \"chalk\";\nimport { Buffer } from \"node:buffer\";\nimport { stat } from \"node:fs/promises\";\nimport { replacePathTokens } from \"powerlines/plugin-utils/paths\";\nimport type { Plugin } from \"powerlines/types/plugin\";\nimport { optimize } from \"svgo\";\nimport {\n ImageCompressionPluginContext,\n ImageCompressionPluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\n/**\n * A Powerlines plugin to optimize image assets used by the project.\n *\n * @see https://sharp.pixelplumbing.com\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends ImageCompressionPluginContext = ImageCompressionPluginContext\n>(\n options: ImageCompressionPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"image-compression\",\n config() {\n return {\n imageCompression: {\n filter:\n \"{projectRoot}/**/*.{svg,jpg,jpeg,png,webp,avif,heif,gif,tiff,jp2,jxl}\",\n svg: {},\n jpeg: {},\n png: {},\n webp: {},\n avif: {},\n heif: {},\n tiff: {},\n jp2: {},\n jxl: {},\n ...options\n }\n };\n },\n async configResolved() {\n if (!this.config.imageCompression.filter) {\n throw new Error(\n \"ImageCompression plugin requires a filter or glob pattern to be specified in the configuration.\"\n );\n }\n\n this.config.imageCompression.filter = toArray(\n this.config.imageCompression.filter\n )\n .map(path => replacePathTokens(this, path))\n .filter(Boolean);\n },\n async prepare() {\n await Promise.all(\n toArray(this.config.imageCompression.filter).map(async path => {\n await Promise.all(\n (await listFiles(path)).map(async file => {\n const outputPath = this.config.imageCompression.outputPath\n ? replacePathTokens(\n this,\n this.config.imageCompression.outputPath\n ).replace(/\\{fileName\\}/g, file.split(\"/\").pop() || \"output\")\n : file;\n\n const start = performance.now();\n const originalSize = (await stat(file)).size;\n let compressedSize = 0;\n\n const extension = findFileExtensionSafe(file).toLowerCase();\n if (!extension) {\n this.error(\n ` ✘ Failed to optimize ${file} - Unable to determine file extension`\n );\n return;\n }\n\n if (extension === \"svg\") {\n const result = optimize(await readFile(file), {\n multipass: true,\n path: file,\n ...this.config.imageCompression.svg\n });\n if (result.data) {\n compressedSize = Buffer.byteLength(result.data, \"utf8\");\n await writeFile(outputPath, result.data);\n }\n } else {\n let image = await import(\"sharp\").then(sharpModule =>\n sharpModule.default(file, { animated: extension === \"gif\" })\n );\n\n switch (extension) {\n case \"jpeg\":\n case \"jpg\":\n image = image.jpeg(this.config.imageCompression.jpeg);\n break;\n case \"png\":\n image = image.png(this.config.imageCompression.png);\n break;\n case \"webp\":\n image = image.webp(this.config.imageCompression.webp);\n break;\n case \"avif\":\n image = image.avif(this.config.imageCompression.avif);\n break;\n case \"gif\":\n image = image.gif(this.config.imageCompression.gif);\n break;\n case \"heif\":\n image = image.heif(this.config.imageCompression.heif);\n break;\n case \"tiff\":\n image = image.tiff(this.config.imageCompression.tiff);\n break;\n case \"jp2\":\n image = image.jp2(this.config.imageCompression.jp2);\n break;\n case \"jxl\":\n image = image.jxl(this.config.imageCompression.jxl);\n break;\n }\n\n const result = await image.toFile(outputPath);\n compressedSize = result.size;\n }\n\n if (!compressedSize) {\n this.error(` ✘ Failed to optimize ${file} - No data returned`);\n return;\n }\n\n if (compressedSize >= originalSize) {\n this.error(\n ` ✘ Failed to optimize ${file} - Compression output was not smaller than the original`\n );\n return;\n }\n\n this.info(\n ` ✔ Successfully optimized ${\n file\n }: ${chalk.redBright(prettyBytes(originalSize))} -> ${chalk.greenBright(\n prettyBytes(compressedSize)\n )} (${chalk.green(\n (100 - (compressedSize / originalSize) * 100).toFixed(2)\n )}%) in ${(performance.now() - start).toFixed(2)} ms`\n );\n })\n );\n })\n );\n }\n };\n};\n\nexport default plugin;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../node_modules/.pnpm/@stryke+string-format@0.13.7/node_modules/@stryke/string-format/dist/pretty-bytes.mjs
|
|
3
|
+
const BYTE_UNITS = [
|
|
4
|
+
"B",
|
|
5
|
+
"kB",
|
|
6
|
+
"MB",
|
|
7
|
+
"GB",
|
|
8
|
+
"TB",
|
|
9
|
+
"PB",
|
|
10
|
+
"EB",
|
|
11
|
+
"ZB",
|
|
12
|
+
"YB"
|
|
13
|
+
];
|
|
14
|
+
const BIBYTE_UNITS = [
|
|
15
|
+
"B",
|
|
16
|
+
"KiB",
|
|
17
|
+
"MiB",
|
|
18
|
+
"GiB",
|
|
19
|
+
"TiB",
|
|
20
|
+
"PiB",
|
|
21
|
+
"EiB",
|
|
22
|
+
"ZiB",
|
|
23
|
+
"YiB"
|
|
24
|
+
];
|
|
25
|
+
const BIT_UNITS = [
|
|
26
|
+
"b",
|
|
27
|
+
"kbit",
|
|
28
|
+
"Mbit",
|
|
29
|
+
"Gbit",
|
|
30
|
+
"Tbit",
|
|
31
|
+
"Pbit",
|
|
32
|
+
"Ebit",
|
|
33
|
+
"Zbit",
|
|
34
|
+
"Ybit"
|
|
35
|
+
];
|
|
36
|
+
const BIBIT_UNITS = [
|
|
37
|
+
"b",
|
|
38
|
+
"kibit",
|
|
39
|
+
"Mibit",
|
|
40
|
+
"Gibit",
|
|
41
|
+
"Tibit",
|
|
42
|
+
"Pibit",
|
|
43
|
+
"Eibit",
|
|
44
|
+
"Zibit",
|
|
45
|
+
"Yibit"
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* Formats the given number using `Number#toLocaleString`.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* - If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
|
52
|
+
* - If locale is true, the system default locale is used for translation.
|
|
53
|
+
* - If no value for locale is specified, the number is returned unmodified.
|
|
54
|
+
*
|
|
55
|
+
* @param number - The number to format.
|
|
56
|
+
* @param locale - The locale to use for formatting the number.
|
|
57
|
+
* @param options - The options to use for formatting the number.
|
|
58
|
+
* @returns The formatted number.
|
|
59
|
+
*/
|
|
60
|
+
const toLocaleString = (number, locale, options = {}) => {
|
|
61
|
+
let result = number;
|
|
62
|
+
let _locale = locale;
|
|
63
|
+
if (typeof _locale === "string") {
|
|
64
|
+
if (!_locale) _locale = process.env.STORM_LOCALE || "en-US";
|
|
65
|
+
if (Array.isArray(_locale)) result = number?.toLocaleString(_locale, options);
|
|
66
|
+
} else if (_locale === true || options !== void 0) result = number?.toLocaleString(void 0, options);
|
|
67
|
+
return String(result);
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Convert bytes to a human readable string: `1337` → `1.34 kB`.
|
|
71
|
+
*
|
|
72
|
+
* @param number - The number to format.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
77
|
+
*
|
|
78
|
+
* prettyBytes(1337);
|
|
79
|
+
* //=> '1.34 kB'
|
|
80
|
+
*
|
|
81
|
+
* prettyBytes(100);
|
|
82
|
+
* //=> '100 B'
|
|
83
|
+
*
|
|
84
|
+
* // Display file size differences
|
|
85
|
+
* prettyBytes(42, {signed: true});
|
|
86
|
+
* //=> '+42 B'
|
|
87
|
+
*
|
|
88
|
+
* // Localized output using German locale
|
|
89
|
+
* prettyBytes(1337, {locale: 'de'});
|
|
90
|
+
* //=> '1,34 kB'
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @param number - The number to format.
|
|
94
|
+
* @param options - The options to use.
|
|
95
|
+
* @returns The formatted string.
|
|
96
|
+
*/
|
|
97
|
+
function prettyBytes(number, options) {
|
|
98
|
+
let _number = number;
|
|
99
|
+
if (!Number.isFinite(_number)) throw new TypeError(`Expected a finite number, got ${typeof _number}: ${_number}`);
|
|
100
|
+
const opts = {
|
|
101
|
+
bits: false,
|
|
102
|
+
binary: false,
|
|
103
|
+
space: true,
|
|
104
|
+
...options
|
|
105
|
+
};
|
|
106
|
+
const UNITS = opts.bits ? opts.binary ? BIBIT_UNITS : BIT_UNITS : opts.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
107
|
+
const separator = opts.space ? " " : "";
|
|
108
|
+
if (opts.signed && _number === 0) return ` 0${separator}${UNITS[0]}`;
|
|
109
|
+
const isNegative = _number < 0;
|
|
110
|
+
const prefix = isNegative ? "-" : opts.signed ? "+" : "";
|
|
111
|
+
if (isNegative) _number = -_number;
|
|
112
|
+
let localeOptions;
|
|
113
|
+
if (opts.minimumFractionDigits !== void 0) localeOptions = { minimumFractionDigits: opts.minimumFractionDigits };
|
|
114
|
+
if (opts.maximumFractionDigits !== void 0) localeOptions = {
|
|
115
|
+
maximumFractionDigits: opts.maximumFractionDigits,
|
|
116
|
+
...localeOptions
|
|
117
|
+
};
|
|
118
|
+
if (_number < 1) return prefix + toLocaleString(_number, opts.locale, localeOptions) + separator + UNITS[0];
|
|
119
|
+
const exponent = Math.min(Math.floor(opts.binary ? Math.log(_number) / Math.log(1024) : Math.log10(_number) / 3), UNITS.length - 1);
|
|
120
|
+
_number /= (opts.binary ? 1024 : 1e3) ** exponent;
|
|
121
|
+
if (!localeOptions) _number = _number.toPrecision(3);
|
|
122
|
+
const numberString = toLocaleString(Number(_number), opts.locale, localeOptions);
|
|
123
|
+
const unit = UNITS[exponent];
|
|
124
|
+
return prefix + numberString + separator + unit;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
exports.prettyBytes = prettyBytes;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@stryke+string-format@0.13.7/node_modules/@stryke/string-format/dist/pretty-bytes.mjs
|
|
2
|
+
const BYTE_UNITS = [
|
|
3
|
+
"B",
|
|
4
|
+
"kB",
|
|
5
|
+
"MB",
|
|
6
|
+
"GB",
|
|
7
|
+
"TB",
|
|
8
|
+
"PB",
|
|
9
|
+
"EB",
|
|
10
|
+
"ZB",
|
|
11
|
+
"YB"
|
|
12
|
+
];
|
|
13
|
+
const BIBYTE_UNITS = [
|
|
14
|
+
"B",
|
|
15
|
+
"KiB",
|
|
16
|
+
"MiB",
|
|
17
|
+
"GiB",
|
|
18
|
+
"TiB",
|
|
19
|
+
"PiB",
|
|
20
|
+
"EiB",
|
|
21
|
+
"ZiB",
|
|
22
|
+
"YiB"
|
|
23
|
+
];
|
|
24
|
+
const BIT_UNITS = [
|
|
25
|
+
"b",
|
|
26
|
+
"kbit",
|
|
27
|
+
"Mbit",
|
|
28
|
+
"Gbit",
|
|
29
|
+
"Tbit",
|
|
30
|
+
"Pbit",
|
|
31
|
+
"Ebit",
|
|
32
|
+
"Zbit",
|
|
33
|
+
"Ybit"
|
|
34
|
+
];
|
|
35
|
+
const BIBIT_UNITS = [
|
|
36
|
+
"b",
|
|
37
|
+
"kibit",
|
|
38
|
+
"Mibit",
|
|
39
|
+
"Gibit",
|
|
40
|
+
"Tibit",
|
|
41
|
+
"Pibit",
|
|
42
|
+
"Eibit",
|
|
43
|
+
"Zibit",
|
|
44
|
+
"Yibit"
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* Formats the given number using `Number#toLocaleString`.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* - If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
|
51
|
+
* - If locale is true, the system default locale is used for translation.
|
|
52
|
+
* - If no value for locale is specified, the number is returned unmodified.
|
|
53
|
+
*
|
|
54
|
+
* @param number - The number to format.
|
|
55
|
+
* @param locale - The locale to use for formatting the number.
|
|
56
|
+
* @param options - The options to use for formatting the number.
|
|
57
|
+
* @returns The formatted number.
|
|
58
|
+
*/
|
|
59
|
+
const toLocaleString = (number, locale, options = {}) => {
|
|
60
|
+
let result = number;
|
|
61
|
+
let _locale = locale;
|
|
62
|
+
if (typeof _locale === "string") {
|
|
63
|
+
if (!_locale) _locale = process.env.STORM_LOCALE || "en-US";
|
|
64
|
+
if (Array.isArray(_locale)) result = number?.toLocaleString(_locale, options);
|
|
65
|
+
} else if (_locale === true || options !== void 0) result = number?.toLocaleString(void 0, options);
|
|
66
|
+
return String(result);
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Convert bytes to a human readable string: `1337` → `1.34 kB`.
|
|
70
|
+
*
|
|
71
|
+
* @param number - The number to format.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
76
|
+
*
|
|
77
|
+
* prettyBytes(1337);
|
|
78
|
+
* //=> '1.34 kB'
|
|
79
|
+
*
|
|
80
|
+
* prettyBytes(100);
|
|
81
|
+
* //=> '100 B'
|
|
82
|
+
*
|
|
83
|
+
* // Display file size differences
|
|
84
|
+
* prettyBytes(42, {signed: true});
|
|
85
|
+
* //=> '+42 B'
|
|
86
|
+
*
|
|
87
|
+
* // Localized output using German locale
|
|
88
|
+
* prettyBytes(1337, {locale: 'de'});
|
|
89
|
+
* //=> '1,34 kB'
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @param number - The number to format.
|
|
93
|
+
* @param options - The options to use.
|
|
94
|
+
* @returns The formatted string.
|
|
95
|
+
*/
|
|
96
|
+
function prettyBytes(number, options) {
|
|
97
|
+
let _number = number;
|
|
98
|
+
if (!Number.isFinite(_number)) throw new TypeError(`Expected a finite number, got ${typeof _number}: ${_number}`);
|
|
99
|
+
const opts = {
|
|
100
|
+
bits: false,
|
|
101
|
+
binary: false,
|
|
102
|
+
space: true,
|
|
103
|
+
...options
|
|
104
|
+
};
|
|
105
|
+
const UNITS = opts.bits ? opts.binary ? BIBIT_UNITS : BIT_UNITS : opts.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
106
|
+
const separator = opts.space ? " " : "";
|
|
107
|
+
if (opts.signed && _number === 0) return ` 0${separator}${UNITS[0]}`;
|
|
108
|
+
const isNegative = _number < 0;
|
|
109
|
+
const prefix = isNegative ? "-" : opts.signed ? "+" : "";
|
|
110
|
+
if (isNegative) _number = -_number;
|
|
111
|
+
let localeOptions;
|
|
112
|
+
if (opts.minimumFractionDigits !== void 0) localeOptions = { minimumFractionDigits: opts.minimumFractionDigits };
|
|
113
|
+
if (opts.maximumFractionDigits !== void 0) localeOptions = {
|
|
114
|
+
maximumFractionDigits: opts.maximumFractionDigits,
|
|
115
|
+
...localeOptions
|
|
116
|
+
};
|
|
117
|
+
if (_number < 1) return prefix + toLocaleString(_number, opts.locale, localeOptions) + separator + UNITS[0];
|
|
118
|
+
const exponent = Math.min(Math.floor(opts.binary ? Math.log(_number) / Math.log(1024) : Math.log10(_number) / 3), UNITS.length - 1);
|
|
119
|
+
_number /= (opts.binary ? 1024 : 1e3) ** exponent;
|
|
120
|
+
if (!localeOptions) _number = _number.toPrecision(3);
|
|
121
|
+
const numberString = toLocaleString(Number(_number), opts.locale, localeOptions);
|
|
122
|
+
const unit = UNITS[exponent];
|
|
123
|
+
return prefix + numberString + separator + unit;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
export { prettyBytes };
|
|
128
|
+
//# sourceMappingURL=pretty-bytes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pretty-bytes.mjs","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/@stryke+string-format@0.13.7/node_modules/@stryke/string-format/dist/pretty-bytes.mjs"],"sourcesContent":["//#region src/pretty-bytes.ts\nconst BYTE_UNITS = [\n\t\"B\",\n\t\"kB\",\n\t\"MB\",\n\t\"GB\",\n\t\"TB\",\n\t\"PB\",\n\t\"EB\",\n\t\"ZB\",\n\t\"YB\"\n];\nconst BIBYTE_UNITS = [\n\t\"B\",\n\t\"KiB\",\n\t\"MiB\",\n\t\"GiB\",\n\t\"TiB\",\n\t\"PiB\",\n\t\"EiB\",\n\t\"ZiB\",\n\t\"YiB\"\n];\nconst BIT_UNITS = [\n\t\"b\",\n\t\"kbit\",\n\t\"Mbit\",\n\t\"Gbit\",\n\t\"Tbit\",\n\t\"Pbit\",\n\t\"Ebit\",\n\t\"Zbit\",\n\t\"Ybit\"\n];\nconst BIBIT_UNITS = [\n\t\"b\",\n\t\"kibit\",\n\t\"Mibit\",\n\t\"Gibit\",\n\t\"Tibit\",\n\t\"Pibit\",\n\t\"Eibit\",\n\t\"Zibit\",\n\t\"Yibit\"\n];\n/**\n* Formats the given number using `Number#toLocaleString`.\n*\n* @remarks\n* - If locale is a string, the value is expected to be a locale-key (for example: `de`).\n* - If locale is true, the system default locale is used for translation.\n* - If no value for locale is specified, the number is returned unmodified.\n*\n* @param number - The number to format.\n* @param locale - The locale to use for formatting the number.\n* @param options - The options to use for formatting the number.\n* @returns The formatted number.\n*/\nconst toLocaleString = (number, locale, options = {}) => {\n\tlet result = number;\n\tlet _locale = locale;\n\tif (typeof _locale === \"string\") {\n\t\tif (!_locale) _locale = process.env.STORM_LOCALE || \"en-US\";\n\t\tif (Array.isArray(_locale)) result = number?.toLocaleString(_locale, options);\n\t} else if (_locale === true || options !== void 0) result = number?.toLocaleString(void 0, options);\n\treturn String(result);\n};\n/**\n* Convert bytes to a human readable string: `1337` → `1.34 kB`.\n*\n* @param number - The number to format.\n*\n* @example\n* ```ts\n* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';\n*\n* prettyBytes(1337);\n* //=> '1.34 kB'\n*\n* prettyBytes(100);\n* //=> '100 B'\n*\n* // Display file size differences\n* prettyBytes(42, {signed: true});\n* //=> '+42 B'\n*\n* // Localized output using German locale\n* prettyBytes(1337, {locale: 'de'});\n* //=> '1,34 kB'\n* ```\n*\n* @param number - The number to format.\n* @param options - The options to use.\n* @returns The formatted string.\n*/\nfunction prettyBytes(number, options) {\n\tlet _number = number;\n\tif (!Number.isFinite(_number)) throw new TypeError(`Expected a finite number, got ${typeof _number}: ${_number}`);\n\tconst opts = {\n\t\tbits: false,\n\t\tbinary: false,\n\t\tspace: true,\n\t\t...options\n\t};\n\tconst UNITS = opts.bits ? opts.binary ? BIBIT_UNITS : BIT_UNITS : opts.binary ? BIBYTE_UNITS : BYTE_UNITS;\n\tconst separator = opts.space ? \" \" : \"\";\n\tif (opts.signed && _number === 0) return ` 0${separator}${UNITS[0]}`;\n\tconst isNegative = _number < 0;\n\tconst prefix = isNegative ? \"-\" : opts.signed ? \"+\" : \"\";\n\tif (isNegative) _number = -_number;\n\tlet localeOptions;\n\tif (opts.minimumFractionDigits !== void 0) localeOptions = { minimumFractionDigits: opts.minimumFractionDigits };\n\tif (opts.maximumFractionDigits !== void 0) localeOptions = {\n\t\tmaximumFractionDigits: opts.maximumFractionDigits,\n\t\t...localeOptions\n\t};\n\tif (_number < 1) return prefix + toLocaleString(_number, opts.locale, localeOptions) + separator + UNITS[0];\n\tconst exponent = Math.min(Math.floor(opts.binary ? Math.log(_number) / Math.log(1024) : Math.log10(_number) / 3), UNITS.length - 1);\n\t_number /= (opts.binary ? 1024 : 1e3) ** exponent;\n\tif (!localeOptions) _number = _number.toPrecision(3);\n\tconst numberString = toLocaleString(Number(_number), opts.locale, localeOptions);\n\tconst unit = UNITS[exponent];\n\treturn prefix + numberString + separator + unit;\n}\n\n//#endregion\nexport { prettyBytes, toLocaleString };\n//# sourceMappingURL=pretty-bytes.mjs.map"],"x_google_ignoreList":[0],"mappings":";AACA,MAAM,aAAa;CAClB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,MAAM,eAAe;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,MAAM,YAAY;CACjB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,MAAM,cAAc;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;;;;;;;;;;;;AAcD,MAAM,kBAAkB,QAAQ,QAAQ,UAAU,EAAE,KAAK;CACxD,IAAI,SAAS;CACb,IAAI,UAAU;AACd,KAAI,OAAO,YAAY,UAAU;AAChC,MAAI,CAAC,QAAS,WAAU,QAAQ,IAAI,gBAAgB;AACpD,MAAI,MAAM,QAAQ,QAAQ,CAAE,UAAS,QAAQ,eAAe,SAAS,QAAQ;YACnE,YAAY,QAAQ,YAAY,KAAK,EAAG,UAAS,QAAQ,eAAe,KAAK,GAAG,QAAQ;AACnG,QAAO,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BtB,SAAS,YAAY,QAAQ,SAAS;CACrC,IAAI,UAAU;AACd,KAAI,CAAC,OAAO,SAAS,QAAQ,CAAE,OAAM,IAAI,UAAU,iCAAiC,OAAO,QAAQ,IAAI,UAAU;CACjH,MAAM,OAAO;EACZ,MAAM;EACN,QAAQ;EACR,OAAO;EACP,GAAG;EACH;CACD,MAAM,QAAQ,KAAK,OAAO,KAAK,SAAS,cAAc,YAAY,KAAK,SAAS,eAAe;CAC/F,MAAM,YAAY,KAAK,QAAQ,MAAM;AACrC,KAAI,KAAK,UAAU,YAAY,EAAG,QAAO,KAAK,YAAY,MAAM;CAChE,MAAM,aAAa,UAAU;CAC7B,MAAM,SAAS,aAAa,MAAM,KAAK,SAAS,MAAM;AACtD,KAAI,WAAY,WAAU,CAAC;CAC3B,IAAI;AACJ,KAAI,KAAK,0BAA0B,KAAK,EAAG,iBAAgB,EAAE,uBAAuB,KAAK,uBAAuB;AAChH,KAAI,KAAK,0BAA0B,KAAK,EAAG,iBAAgB;EAC1D,uBAAuB,KAAK;EAC5B,GAAG;EACH;AACD,KAAI,UAAU,EAAG,QAAO,SAAS,eAAe,SAAS,KAAK,QAAQ,cAAc,GAAG,YAAY,MAAM;CACzG,MAAM,WAAW,KAAK,IAAI,KAAK,MAAM,KAAK,SAAS,KAAK,IAAI,QAAQ,GAAG,KAAK,IAAI,KAAK,GAAG,KAAK,MAAM,QAAQ,GAAG,EAAE,EAAE,MAAM,SAAS,EAAE;AACnI,aAAY,KAAK,SAAS,OAAO,QAAQ;AACzC,KAAI,CAAC,cAAe,WAAU,QAAQ,YAAY,EAAE;CACpD,MAAM,eAAe,eAAe,OAAO,QAAQ,EAAE,KAAK,QAAQ,cAAc;CAChF,MAAM,OAAO,MAAM;AACnB,QAAO,SAAS,eAAe,YAAY"}
|
package/dist/types/index.cjs
CHANGED
package/dist/types/index.d.cts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../index-CEgs-Dz2.cjs";
|
|
1
|
+
import { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig } from "./plugin.cjs";
|
|
3
2
|
export { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../index-BgAdqTbb.mjs";
|
|
1
|
+
import { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig } from "./plugin.mjs";
|
|
3
2
|
export { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig };
|
package/dist/types/index.mjs
CHANGED
package/dist/types/plugin.cjs
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('../plugin-DHXHjv16.cjs');
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -1,2 +1,76 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { UserConfig } from "powerlines/types/config";
|
|
2
|
+
import { PluginContext } from "powerlines/types/context";
|
|
3
|
+
import { ResolvedConfig } from "powerlines/types/resolved";
|
|
4
|
+
import { AvifOptions, GifOptions, HeifOptions, Jp2Options, JpegOptions, JxlOptions, PngOptions, TiffOptions, WebpOptions } from "sharp";
|
|
5
|
+
import { Config } from "svgo";
|
|
6
|
+
|
|
7
|
+
//#region src/types/plugin.d.ts
|
|
8
|
+
interface ImageCompressionPluginOptions {
|
|
9
|
+
/**
|
|
10
|
+
* A path or glob pattern (or an array of paths and glob patterns) to image files to optimize during Powerlines processing.
|
|
11
|
+
*
|
|
12
|
+
* @defaultValue "\{projectRoot\}/**\/*.\{svg,jpg,jpeg,png,webp,avif,heif,gif,tiff,jp2,jxl\}"
|
|
13
|
+
*/
|
|
14
|
+
filter?: string | string[];
|
|
15
|
+
/**
|
|
16
|
+
* The output directory for the optimized images.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* By default, it will generate the output files alongside each input image file.
|
|
20
|
+
*/
|
|
21
|
+
outputPath?: string;
|
|
22
|
+
/**
|
|
23
|
+
* These SVGO options used for SVG optimization
|
|
24
|
+
*/
|
|
25
|
+
svg?: Config;
|
|
26
|
+
/**
|
|
27
|
+
* These JPEG options used for output image
|
|
28
|
+
*/
|
|
29
|
+
jpeg?: JpegOptions;
|
|
30
|
+
/**
|
|
31
|
+
* These JP2 (JPEG 2000) options used for output image
|
|
32
|
+
*/
|
|
33
|
+
jp2?: Jp2Options;
|
|
34
|
+
/**
|
|
35
|
+
* These JPEG-XL (JXL) options used for output image
|
|
36
|
+
*/
|
|
37
|
+
jxl?: JxlOptions;
|
|
38
|
+
/**
|
|
39
|
+
* These PNG options used for output image
|
|
40
|
+
*/
|
|
41
|
+
png?: PngOptions;
|
|
42
|
+
/**
|
|
43
|
+
* These WebP options used for output image
|
|
44
|
+
*/
|
|
45
|
+
webp?: WebpOptions;
|
|
46
|
+
/**
|
|
47
|
+
* These GIF options used for output image
|
|
48
|
+
*/
|
|
49
|
+
gif?: GifOptions;
|
|
50
|
+
/**
|
|
51
|
+
* These AVIF options used for output image
|
|
52
|
+
*/
|
|
53
|
+
avif?: AvifOptions;
|
|
54
|
+
/**
|
|
55
|
+
* These HEIF options used for output image
|
|
56
|
+
*/
|
|
57
|
+
heif?: HeifOptions;
|
|
58
|
+
/**
|
|
59
|
+
* These TIFF options used for output image
|
|
60
|
+
*/
|
|
61
|
+
tiff?: TiffOptions;
|
|
62
|
+
}
|
|
63
|
+
interface ImageCompressionPluginUserConfig extends UserConfig {
|
|
64
|
+
imageCompression?: ImageCompressionPluginOptions;
|
|
65
|
+
}
|
|
66
|
+
interface ImageCompressionPluginResolvedConfig extends ResolvedConfig {
|
|
67
|
+
imageCompression: Omit<ImageCompressionPluginOptions, "filter" | "svg" | "jpeg" | "png" | "webp" | "avif" | "heif" | "tiff" | "jp2" | "jxl" | "gif"> & Required<Pick<ImageCompressionPluginOptions, "filter" | "svg" | "jpeg" | "png" | "webp" | "avif" | "heif" | "tiff" | "jp2" | "jxl" | "gif">>;
|
|
68
|
+
}
|
|
69
|
+
type ImageCompressionPluginContext<TResolvedConfig extends ImageCompressionPluginResolvedConfig = ImageCompressionPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
70
|
+
declare type __ΩImageCompressionPluginOptions = any[];
|
|
71
|
+
declare type __ΩImageCompressionPluginUserConfig = any[];
|
|
72
|
+
declare type __ΩImageCompressionPluginResolvedConfig = any[];
|
|
73
|
+
declare type __ΩImageCompressionPluginContext = any[];
|
|
74
|
+
//#endregion
|
|
75
|
+
export { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig };
|
|
76
|
+
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;UAkCiB,6BAAA;;AAAjB;;;;EAkCQ,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA;EAKA;;;;;;EAyBY,UAAA,CAAA,EAAA,MAAA;EAGH;AAIjB;;EACoB,GAAA,CAAA,EArDZ,MAqDY;EAgBZ;;;EAjBsD,IAAA,CAAA,EA/CrD,WA+CqD;EAAc;AAiC5E;;EAEI,GAAA,CAAA,EA7EI,UA6EJ;EACc;;;QAzEV;;;;QAKA;;;;SAKC;;;;QAKD;;;;SAKC;;;;SAKA;;;;SAKA;;UAGQ,gCAAA,SAAyC;qBACrC;;UAGJ,oCAAA,SAA6C;oBAC1C,KAChB,gIAaA,SACE,KACE;;KAgBI,sDACc,uCACtB,wCACA,cAAc"}
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,2 +1,76 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Config } from "svgo";
|
|
2
|
+
import { AvifOptions, GifOptions, HeifOptions, Jp2Options, JpegOptions, JxlOptions, PngOptions, TiffOptions, WebpOptions } from "sharp";
|
|
3
|
+
import { UserConfig } from "powerlines/types/config";
|
|
4
|
+
import { PluginContext } from "powerlines/types/context";
|
|
5
|
+
import { ResolvedConfig } from "powerlines/types/resolved";
|
|
6
|
+
|
|
7
|
+
//#region src/types/plugin.d.ts
|
|
8
|
+
interface ImageCompressionPluginOptions {
|
|
9
|
+
/**
|
|
10
|
+
* A path or glob pattern (or an array of paths and glob patterns) to image files to optimize during Powerlines processing.
|
|
11
|
+
*
|
|
12
|
+
* @defaultValue "\{projectRoot\}/**\/*.\{svg,jpg,jpeg,png,webp,avif,heif,gif,tiff,jp2,jxl\}"
|
|
13
|
+
*/
|
|
14
|
+
filter?: string | string[];
|
|
15
|
+
/**
|
|
16
|
+
* The output directory for the optimized images.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* By default, it will generate the output files alongside each input image file.
|
|
20
|
+
*/
|
|
21
|
+
outputPath?: string;
|
|
22
|
+
/**
|
|
23
|
+
* These SVGO options used for SVG optimization
|
|
24
|
+
*/
|
|
25
|
+
svg?: Config;
|
|
26
|
+
/**
|
|
27
|
+
* These JPEG options used for output image
|
|
28
|
+
*/
|
|
29
|
+
jpeg?: JpegOptions;
|
|
30
|
+
/**
|
|
31
|
+
* These JP2 (JPEG 2000) options used for output image
|
|
32
|
+
*/
|
|
33
|
+
jp2?: Jp2Options;
|
|
34
|
+
/**
|
|
35
|
+
* These JPEG-XL (JXL) options used for output image
|
|
36
|
+
*/
|
|
37
|
+
jxl?: JxlOptions;
|
|
38
|
+
/**
|
|
39
|
+
* These PNG options used for output image
|
|
40
|
+
*/
|
|
41
|
+
png?: PngOptions;
|
|
42
|
+
/**
|
|
43
|
+
* These WebP options used for output image
|
|
44
|
+
*/
|
|
45
|
+
webp?: WebpOptions;
|
|
46
|
+
/**
|
|
47
|
+
* These GIF options used for output image
|
|
48
|
+
*/
|
|
49
|
+
gif?: GifOptions;
|
|
50
|
+
/**
|
|
51
|
+
* These AVIF options used for output image
|
|
52
|
+
*/
|
|
53
|
+
avif?: AvifOptions;
|
|
54
|
+
/**
|
|
55
|
+
* These HEIF options used for output image
|
|
56
|
+
*/
|
|
57
|
+
heif?: HeifOptions;
|
|
58
|
+
/**
|
|
59
|
+
* These TIFF options used for output image
|
|
60
|
+
*/
|
|
61
|
+
tiff?: TiffOptions;
|
|
62
|
+
}
|
|
63
|
+
interface ImageCompressionPluginUserConfig extends UserConfig {
|
|
64
|
+
imageCompression?: ImageCompressionPluginOptions;
|
|
65
|
+
}
|
|
66
|
+
interface ImageCompressionPluginResolvedConfig extends ResolvedConfig {
|
|
67
|
+
imageCompression: Omit<ImageCompressionPluginOptions, "filter" | "svg" | "jpeg" | "png" | "webp" | "avif" | "heif" | "tiff" | "jp2" | "jxl" | "gif"> & Required<Pick<ImageCompressionPluginOptions, "filter" | "svg" | "jpeg" | "png" | "webp" | "avif" | "heif" | "tiff" | "jp2" | "jxl" | "gif">>;
|
|
68
|
+
}
|
|
69
|
+
type ImageCompressionPluginContext<TResolvedConfig extends ImageCompressionPluginResolvedConfig = ImageCompressionPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
70
|
+
declare type __ΩImageCompressionPluginOptions = any[];
|
|
71
|
+
declare type __ΩImageCompressionPluginUserConfig = any[];
|
|
72
|
+
declare type __ΩImageCompressionPluginResolvedConfig = any[];
|
|
73
|
+
declare type __ΩImageCompressionPluginContext = any[];
|
|
74
|
+
//#endregion
|
|
75
|
+
export { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig };
|
|
76
|
+
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;UAkCiB,6BAAA;;AAAjB;;;;EAkCQ,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA;EAKA;;;;;;EAyBY,UAAA,CAAA,EAAA,MAAA;EAGH;AAIjB;;EACoB,GAAA,CAAA,EArDZ,MAqDY;EAgBZ;;;EAjBsD,IAAA,CAAA,EA/CrD,WA+CqD;EAAc;AAiC5E;;EAEI,GAAA,CAAA,EA7EI,UA6EJ;EACc;;;QAzEV;;;;QAKA;;;;SAKC;;;;QAKD;;;;SAKC;;;;SAKA;;;;SAKA;;UAGQ,gCAAA,SAAyC;qBACrC;;UAGJ,oCAAA,SAA6C;oBAC1C,KAChB,gIAaA,SACE,KACE;;KAgBI,sDACc,uCACtB,wCACA,cAAc"}
|
package/dist/types/plugin.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-image-compression",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.204",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Powerlines plugin to optimize images used by the project.",
|
|
6
6
|
"repository": {
|
|
@@ -101,16 +101,16 @@
|
|
|
101
101
|
"chalk": "5.6.2",
|
|
102
102
|
"defu": "^6.1.4",
|
|
103
103
|
"jiti": "^2.6.1",
|
|
104
|
-
"powerlines": "^0.38.
|
|
104
|
+
"powerlines": "^0.38.22",
|
|
105
105
|
"sharp": "^0.34.5",
|
|
106
106
|
"svgo": "^4.0.0"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
109
|
+
"@powerlines/plugin-plugin": "^0.12.206",
|
|
110
110
|
"@storm-software/config": "^1.135.1",
|
|
111
111
|
"@types/node": "^24.10.9"
|
|
112
112
|
},
|
|
113
113
|
"publishConfig": { "access": "public" },
|
|
114
114
|
"types": "./dist/index.d.cts",
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "02ca3097aeae5f5bb4838b4263e8cf7cc44fa3bd"
|
|
116
116
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Config } from "svgo";
|
|
2
|
-
import { AvifOptions, GifOptions, HeifOptions, Jp2Options, JpegOptions, JxlOptions, PngOptions, TiffOptions, WebpOptions } from "sharp";
|
|
3
|
-
import { UserConfig } from "powerlines/types/config";
|
|
4
|
-
import { PluginContext } from "powerlines/types/context";
|
|
5
|
-
import { ResolvedConfig } from "powerlines/types/resolved";
|
|
6
|
-
|
|
7
|
-
//#region src/types/plugin.d.ts
|
|
8
|
-
interface ImageCompressionPluginOptions {
|
|
9
|
-
/**
|
|
10
|
-
* A path or glob pattern (or an array of paths and glob patterns) to image files to optimize during Powerlines processing.
|
|
11
|
-
*
|
|
12
|
-
* @defaultValue "\{projectRoot\}/**\/*.\{svg,jpg,jpeg,png,webp,avif,heif,gif,tiff,jp2,jxl\}"
|
|
13
|
-
*/
|
|
14
|
-
filter?: string | string[];
|
|
15
|
-
/**
|
|
16
|
-
* The output directory for the optimized images.
|
|
17
|
-
*
|
|
18
|
-
* @remarks
|
|
19
|
-
* By default, it will generate the output files alongside each input image file.
|
|
20
|
-
*/
|
|
21
|
-
outputPath?: string;
|
|
22
|
-
/**
|
|
23
|
-
* These SVGO options used for SVG optimization
|
|
24
|
-
*/
|
|
25
|
-
svg?: Config;
|
|
26
|
-
/**
|
|
27
|
-
* These JPEG options used for output image
|
|
28
|
-
*/
|
|
29
|
-
jpeg?: JpegOptions;
|
|
30
|
-
/**
|
|
31
|
-
* These JP2 (JPEG 2000) options used for output image
|
|
32
|
-
*/
|
|
33
|
-
jp2?: Jp2Options;
|
|
34
|
-
/**
|
|
35
|
-
* These JPEG-XL (JXL) options used for output image
|
|
36
|
-
*/
|
|
37
|
-
jxl?: JxlOptions;
|
|
38
|
-
/**
|
|
39
|
-
* These PNG options used for output image
|
|
40
|
-
*/
|
|
41
|
-
png?: PngOptions;
|
|
42
|
-
/**
|
|
43
|
-
* These WebP options used for output image
|
|
44
|
-
*/
|
|
45
|
-
webp?: WebpOptions;
|
|
46
|
-
/**
|
|
47
|
-
* These GIF options used for output image
|
|
48
|
-
*/
|
|
49
|
-
gif?: GifOptions;
|
|
50
|
-
/**
|
|
51
|
-
* These AVIF options used for output image
|
|
52
|
-
*/
|
|
53
|
-
avif?: AvifOptions;
|
|
54
|
-
/**
|
|
55
|
-
* These HEIF options used for output image
|
|
56
|
-
*/
|
|
57
|
-
heif?: HeifOptions;
|
|
58
|
-
/**
|
|
59
|
-
* These TIFF options used for output image
|
|
60
|
-
*/
|
|
61
|
-
tiff?: TiffOptions;
|
|
62
|
-
}
|
|
63
|
-
interface ImageCompressionPluginUserConfig extends UserConfig {
|
|
64
|
-
imageCompression?: ImageCompressionPluginOptions;
|
|
65
|
-
}
|
|
66
|
-
interface ImageCompressionPluginResolvedConfig extends ResolvedConfig {
|
|
67
|
-
imageCompression: Omit<ImageCompressionPluginOptions, "filter" | "svg" | "jpeg" | "png" | "webp" | "avif" | "heif" | "tiff" | "jp2" | "jxl" | "gif"> & Required<Pick<ImageCompressionPluginOptions, "filter" | "svg" | "jpeg" | "png" | "webp" | "avif" | "heif" | "tiff" | "jp2" | "jxl" | "gif">>;
|
|
68
|
-
}
|
|
69
|
-
type ImageCompressionPluginContext<TResolvedConfig extends ImageCompressionPluginResolvedConfig = ImageCompressionPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
70
|
-
declare type __ΩImageCompressionPluginOptions = any[];
|
|
71
|
-
declare type __ΩImageCompressionPluginUserConfig = any[];
|
|
72
|
-
declare type __ΩImageCompressionPluginResolvedConfig = any[];
|
|
73
|
-
declare type __ΩImageCompressionPluginContext = any[];
|
|
74
|
-
//#endregion
|
|
75
|
-
export { __ΩImageCompressionPluginContext as a, __ΩImageCompressionPluginUserConfig as c, ImageCompressionPluginUserConfig as i, ImageCompressionPluginOptions as n, __ΩImageCompressionPluginOptions as o, ImageCompressionPluginResolvedConfig as r, __ΩImageCompressionPluginResolvedConfig as s, ImageCompressionPluginContext as t };
|
|
76
|
-
//# sourceMappingURL=plugin-BX_Z82RH.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-BX_Z82RH.d.mts","names":[],"sources":["../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;UAkCiB,6BAAA;;AAAjB;;;;EAkCQ,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA;EAKA;;;;;;EAyBY,UAAA,CAAA,EAAA,MAAA;EAGH;AAIjB;;EACoB,GAAA,CAAA,EArDZ,MAqDY;EAgBZ;;;EAjBsD,IAAA,CAAA,EA/CrD,WA+CqD;EAAc;AAiC5E;;EAEI,GAAA,CAAA,EA7EI,UA6EJ;EACc;;;QAzEV;;;;QAKA;;;;SAKC;;;;QAKD;;;;SAKC;;;;SAKA;;;;SAKA;;UAGQ,gCAAA,SAAyC;qBACrC;;UAGJ,oCAAA,SAA6C;oBAC1C,KAChB,gIAaA,SACE,KACE;;KAgBI,sDACc,uCACtB,wCACA,cAAc"}
|
package/dist/plugin-C3MaN5jp.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { UserConfig } from "powerlines/types/config";
|
|
2
|
-
import { PluginContext } from "powerlines/types/context";
|
|
3
|
-
import { ResolvedConfig } from "powerlines/types/resolved";
|
|
4
|
-
import { AvifOptions, GifOptions, HeifOptions, Jp2Options, JpegOptions, JxlOptions, PngOptions, TiffOptions, WebpOptions } from "sharp";
|
|
5
|
-
import { Config } from "svgo";
|
|
6
|
-
|
|
7
|
-
//#region src/types/plugin.d.ts
|
|
8
|
-
interface ImageCompressionPluginOptions {
|
|
9
|
-
/**
|
|
10
|
-
* A path or glob pattern (or an array of paths and glob patterns) to image files to optimize during Powerlines processing.
|
|
11
|
-
*
|
|
12
|
-
* @defaultValue "\{projectRoot\}/**\/*.\{svg,jpg,jpeg,png,webp,avif,heif,gif,tiff,jp2,jxl\}"
|
|
13
|
-
*/
|
|
14
|
-
filter?: string | string[];
|
|
15
|
-
/**
|
|
16
|
-
* The output directory for the optimized images.
|
|
17
|
-
*
|
|
18
|
-
* @remarks
|
|
19
|
-
* By default, it will generate the output files alongside each input image file.
|
|
20
|
-
*/
|
|
21
|
-
outputPath?: string;
|
|
22
|
-
/**
|
|
23
|
-
* These SVGO options used for SVG optimization
|
|
24
|
-
*/
|
|
25
|
-
svg?: Config;
|
|
26
|
-
/**
|
|
27
|
-
* These JPEG options used for output image
|
|
28
|
-
*/
|
|
29
|
-
jpeg?: JpegOptions;
|
|
30
|
-
/**
|
|
31
|
-
* These JP2 (JPEG 2000) options used for output image
|
|
32
|
-
*/
|
|
33
|
-
jp2?: Jp2Options;
|
|
34
|
-
/**
|
|
35
|
-
* These JPEG-XL (JXL) options used for output image
|
|
36
|
-
*/
|
|
37
|
-
jxl?: JxlOptions;
|
|
38
|
-
/**
|
|
39
|
-
* These PNG options used for output image
|
|
40
|
-
*/
|
|
41
|
-
png?: PngOptions;
|
|
42
|
-
/**
|
|
43
|
-
* These WebP options used for output image
|
|
44
|
-
*/
|
|
45
|
-
webp?: WebpOptions;
|
|
46
|
-
/**
|
|
47
|
-
* These GIF options used for output image
|
|
48
|
-
*/
|
|
49
|
-
gif?: GifOptions;
|
|
50
|
-
/**
|
|
51
|
-
* These AVIF options used for output image
|
|
52
|
-
*/
|
|
53
|
-
avif?: AvifOptions;
|
|
54
|
-
/**
|
|
55
|
-
* These HEIF options used for output image
|
|
56
|
-
*/
|
|
57
|
-
heif?: HeifOptions;
|
|
58
|
-
/**
|
|
59
|
-
* These TIFF options used for output image
|
|
60
|
-
*/
|
|
61
|
-
tiff?: TiffOptions;
|
|
62
|
-
}
|
|
63
|
-
interface ImageCompressionPluginUserConfig extends UserConfig {
|
|
64
|
-
imageCompression?: ImageCompressionPluginOptions;
|
|
65
|
-
}
|
|
66
|
-
interface ImageCompressionPluginResolvedConfig extends ResolvedConfig {
|
|
67
|
-
imageCompression: Omit<ImageCompressionPluginOptions, "filter" | "svg" | "jpeg" | "png" | "webp" | "avif" | "heif" | "tiff" | "jp2" | "jxl" | "gif"> & Required<Pick<ImageCompressionPluginOptions, "filter" | "svg" | "jpeg" | "png" | "webp" | "avif" | "heif" | "tiff" | "jp2" | "jxl" | "gif">>;
|
|
68
|
-
}
|
|
69
|
-
type ImageCompressionPluginContext<TResolvedConfig extends ImageCompressionPluginResolvedConfig = ImageCompressionPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
70
|
-
declare type __ΩImageCompressionPluginOptions = any[];
|
|
71
|
-
declare type __ΩImageCompressionPluginUserConfig = any[];
|
|
72
|
-
declare type __ΩImageCompressionPluginResolvedConfig = any[];
|
|
73
|
-
declare type __ΩImageCompressionPluginContext = any[];
|
|
74
|
-
//#endregion
|
|
75
|
-
export { __ΩImageCompressionPluginContext as a, __ΩImageCompressionPluginUserConfig as c, ImageCompressionPluginUserConfig as i, ImageCompressionPluginOptions as n, __ΩImageCompressionPluginOptions as o, ImageCompressionPluginResolvedConfig as r, __ΩImageCompressionPluginResolvedConfig as s, ImageCompressionPluginContext as t };
|
|
76
|
-
//# sourceMappingURL=plugin-CJ3kcwOQ.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-CJ3kcwOQ.d.cts","names":[],"sources":["../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;UAkCiB,6BAAA;;AAAjB;;;;EAkCQ,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA;EAKA;;;;;;EAyBY,UAAA,CAAA,EAAA,MAAA;EAGH;AAIjB;;EACoB,GAAA,CAAA,EArDZ,MAqDY;EAgBZ;;;EAjBsD,IAAA,CAAA,EA/CrD,WA+CqD;EAAc;AAiC5E;;EAEI,GAAA,CAAA,EA7EI,UA6EJ;EACc;;;QAzEV;;;;QAKA;;;;SAKC;;;;QAKD;;;;SAKC;;;;SAKA;;;;SAKA;;UAGQ,gCAAA,SAAyC;qBACrC;;UAGJ,oCAAA,SAA6C;oBAC1C,KAChB,gIAaA,SACE,KACE;;KAgBI,sDACc,uCACtB,wCACA,cAAc"}
|
package/dist/plugin-DHXHjv16.cjs
DELETED
|
File without changes
|
package/dist/types-CTUnla4x.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/types-DHkg7xmX.cjs
DELETED
|
File without changes
|