@powerlines/plugin-image-compression 0.2.120 → 0.2.121

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/README.md ADDED
@@ -0,0 +1,304 @@
1
+ <!-- START header -->
2
+ <!-- prettier-ignore-start -->
3
+ <!-- markdownlint-disable -->
4
+
5
+
6
+ <div align="center">
7
+ <picture>
8
+ <source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/powerlines/banner-1280x640-dark.gif">
9
+ <source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/powerlines/banner-1280x640-light.gif">
10
+ <img src="https://public.storm-cdn.com/powerlines/banner-1280x640-dark.gif" width="100%" alt="Powerlines" />
11
+ </picture>
12
+ </div>
13
+ <br />
14
+
15
+ <div align="center">
16
+ <b>
17
+ <a href="https://stormsoftware.com" target="_blank">Website</a> •
18
+ <a href="https://github.com/storm-software/powerlines" target="_blank">GitHub</a> •
19
+ <a href="https://discord.gg/MQ6YVzakM5">Discord</a> • <a href="https://stormstack.github.io/stormstack/" target="_blank">Docs</a> • <a href="https://stormsoftware.com/contact" target="_blank">Contact</a> •
20
+ <a href="https://github.com/storm-software/powerlines/issues/new?assignees=&labels=bug&template=bug-report.yml&title=Bug Report%3A+">Report a Bug</a>
21
+ </b>
22
+ </div>
23
+
24
+ <br />
25
+ This package is part of the 🔌 <b>Powerlines</b> monorepo. Powerlines packages include CLI utility applications, tools, and various libraries used to create modern, scalable web applications.
26
+ <br />
27
+
28
+ <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
29
+
30
+ [![Version](https://img.shields.io/badge/version-0.2.0-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/powerlines/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
31
+
32
+ <!-- prettier-ignore-start -->
33
+ <!-- markdownlint-disable -->
34
+
35
+ > [!IMPORTANT]
36
+ > This repository, and the apps, libraries, and tools contained within, is still in it's initial development phase. As a result, bugs and issues are expected with it's usage. When the main development phase completes, a proper release will be performed, the packages will be available through NPM (and other distributions), and this message will be removed. However, in the meantime, please feel free to report any issues you may come across.
37
+
38
+ <!-- markdownlint-restore -->
39
+ <!-- prettier-ignore-end -->
40
+
41
+ <div align="center">
42
+ <a href="https://github.com/storm-software/powerlines" target="_blank"><b>Be sure to ⭐ this repository on GitHub so you can keep up to date with it's progress!</b></a>
43
+ </div>
44
+
45
+ <br />
46
+
47
+ <!-- markdownlint-restore -->
48
+ <!-- prettier-ignore-end -->
49
+
50
+ <!-- END header -->
51
+
52
+ # Powerlines - Image Compression Plugin
53
+
54
+ A Powerlines plugin to use [Sharp](https://sharp.pixelplumbing.com) to optimize images used by the project.
55
+
56
+ <!-- START doctoc -->
57
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
58
+ ## Table of Contents
59
+
60
+ - [Powerlines - Image Compression Plugin](#powerlines---image-compression-plugin)
61
+ - [Table of Contents](#table-of-contents)
62
+ - [Installing](#installing)
63
+ - [Reduced Package Size](#reduced-package-size)
64
+ - [Development](#development)
65
+ - [Building](#building)
66
+ - [Running unit tests](#running-unit-tests)
67
+ - [Linting](#linting)
68
+ - [Storm Workspaces](#storm-workspaces)
69
+ - [Roadmap](#roadmap)
70
+ - [Support](#support)
71
+ - [License](#license)
72
+ - [Changelog](#changelog)
73
+ - [Contributing](#contributing)
74
+ - [Contributors](#contributors)
75
+
76
+ <!-- END doctoc -->
77
+
78
+ ## Installing
79
+
80
+ Using [pnpm](http://pnpm.io):
81
+
82
+ ```bash
83
+ pnpm add @powerlines/plugin-image-compression
84
+ ```
85
+
86
+ <details>
87
+ <summary>Using npm</summary>
88
+
89
+ ```bash
90
+ npm install @powerlines/plugin-image-compression
91
+ ```
92
+
93
+ </details>
94
+
95
+ <details>
96
+ <summary>Using yarn</summary>
97
+
98
+ ```bash
99
+ yarn add @powerlines/plugin-image-compression
100
+ ```
101
+
102
+ </details>
103
+
104
+ ## Reduced Package Size
105
+
106
+ This project uses [tsup](https://tsup.egoist.dev/) to package the source code
107
+ due to its ability to remove unused code and ship smaller javascript files
108
+ thanks to code splitting. This helps to greatly reduce the size of the package
109
+ and to make it easier to use in other projects.
110
+
111
+ ## Development
112
+
113
+ This project is built using [Nx](https://nx.dev). As a result, many of the usual
114
+ commands are available to assist in development.
115
+
116
+ ### Building
117
+
118
+ Run `nx build plugin-image-compression` to build the library.
119
+
120
+ ### Running unit tests
121
+
122
+ Run `nx test plugin-image-compression` to execute the unit tests via
123
+ [Jest](https://jestjs.io).
124
+
125
+ ### Linting
126
+
127
+ Run `nx lint plugin-image-compression` to run
128
+ [ESLint](https://eslint.org/) on the package.
129
+
130
+ <!-- START footer -->
131
+ <!-- prettier-ignore-start -->
132
+ <!-- markdownlint-disable -->
133
+
134
+
135
+ ## Storm Workspaces
136
+
137
+ Storm workspaces are built using
138
+ <a href="https://nx.dev/" target="_blank">Nx</a>, a set of extensible dev tools
139
+ for monorepos, which helps you develop like Google, Facebook, and Microsoft.
140
+ Building on top of Nx, the Open System provides a set of tools and patterns that
141
+ help you scale your monorepo to many teams while keeping the codebase
142
+ maintainable.
143
+
144
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
145
+ <br />
146
+
147
+ ## Roadmap
148
+
149
+ See the [open issues](https://github.com/storm-software/powerlines/issues) for
150
+ a list of proposed features (and known issues).
151
+
152
+ - [Top Feature Requests](https://github.com/storm-software/powerlines/issues?q=label%3Aenhancement+is%3Aopen+sort%3Areactions-%2B1-desc)
153
+ (Add your votes using the 👍 reaction)
154
+ - [Top Bugs](https://github.com/storm-software/powerlines/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions-%2B1-desc)
155
+ (Add your votes using the 👍 reaction)
156
+ - [Newest Bugs](https://github.com/storm-software/powerlines/issues?q=is%3Aopen+is%3Aissue+label%3Abug)
157
+
158
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
159
+ <br />
160
+
161
+ ## Support
162
+
163
+ Reach out to the maintainer at one of the following places:
164
+
165
+ - [Contact](https://stormsoftware.com/contact)
166
+ - [GitHub discussions](https://github.com/storm-software/powerlines/discussions)
167
+ - <support@stormsoftware.com>
168
+
169
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
170
+ <br />
171
+
172
+ ## License
173
+
174
+ This project is licensed under the **Apache License 2.0**. Feel free to edit and
175
+ distribute this template as you like.
176
+
177
+ See [LICENSE](LICENSE) for more information.
178
+
179
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
180
+ <br />
181
+
182
+ ## Changelog
183
+
184
+ This project adheres to
185
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Every release, along
186
+ with the migration instructions, is documented in the [CHANGELOG](CHANGELOG.md)
187
+ file
188
+
189
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
190
+ <br />
191
+
192
+ ## Contributing
193
+
194
+ First off, thanks for taking the time to contribute! Contributions are what
195
+ makes the open-source community such an amazing place to learn, inspire, and
196
+ create. Any contributions you make will benefit everybody else and are **greatly
197
+ appreciated**.
198
+
199
+ Please try to create bug reports that are:
200
+
201
+ - _Reproducible._ Include steps to reproduce the problem.
202
+ - _Specific._ Include as much detail as possible: which version, what
203
+ environment, etc.
204
+ - _Unique._ Do not duplicate existing opened issues.
205
+ - _Scoped to a Single Bug._ One bug per report.
206
+
207
+ Please adhere to this project's [code of conduct](.github/CODE_OF_CONDUCT.md).
208
+
209
+ You can use
210
+ [markdownlint-cli](https://github.com/storm-software/powerlines/markdownlint-cli)
211
+ to check for common markdown style inconsistency.
212
+
213
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
214
+ <br />
215
+
216
+ ## Contributors
217
+
218
+ Thanks goes to these wonderful people
219
+ ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
220
+
221
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
222
+
223
+ <table>
224
+ <tbody>
225
+ <tr>
226
+ <td align="center" valign="top" width="14.28%"><a href="http://www.sullypat.com/"><img src="https://avatars.githubusercontent.com/u/99053093?v=4?s=100" width="100px;" alt="Patrick Sullivan"/><br /><sub><b>Patrick Sullivan</b></sub></a><br /><a href="#design-sullivanpj" title="Design">🎨</a> <a href="https://github.com/storm-software/powerlines/commits?author=sullivanpj" title="Code">💻</a> <a href="#tool-sullivanpj" title="Tools">🔧</a> <a href="https://github.com/storm-software/powerlines/commits?author=sullivanpj" title="Documentation">📖</a> <a href="https://github.com/storm-software/powerlines/commits?author=sullivanpj" title="Tests">⚠️</a></td>
227
+ <td align="center" valign="top" width="14.28%"><a href="https://tylerbenning.com/"><img src="https://avatars.githubusercontent.com/u/7265547?v=4?s=100" width="100px;" alt="Tyler Benning"/><br /><sub><b>Tyler Benning</b></sub></a><br /><a href="#design-tbenning" title="Design">🎨</a></td>
228
+ <td align="center" valign="top" width="14.28%"><a href="http://stormsoftware.com"><img src="https://avatars.githubusercontent.com/u/149802440?v=4?s=100" width="100px;" alt="Stormie"/><br /><sub><b>Stormie</b></sub></a><br /><a href="#maintenance-stormie-bot" title="Maintenance">🚧</a></td>
229
+ </tr>
230
+ </tbody>
231
+ <tfoot>
232
+ <tr>
233
+ <td align="center" size="13px" colspan="7">
234
+ <img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg" alt="All Contributors">
235
+ <a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
236
+ </img>
237
+ </td>
238
+ </tr>
239
+ </tfoot>
240
+ </table>
241
+
242
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
243
+
244
+ This project follows the
245
+ [all-contributors](https://github.com/all-contributors/all-contributors)
246
+ specification. Contributions of any kind welcome!
247
+
248
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
249
+ <br />
250
+
251
+ <hr />
252
+ <br />
253
+
254
+ <div align="center">
255
+ <picture>
256
+ <source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/storm-software/banner-1280x320-dark.webp">
257
+ <source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/storm-software/banner-1280x320-light.webp">
258
+ <img src="https://public.storm-cdn.com/storm-software/banner-1280x320-dark.webp" width="100%" alt="Storm Software" />
259
+ </picture>
260
+ </div>
261
+ <br />
262
+
263
+ <div align="center">
264
+ <a href="https://stormsoftware.com" target="_blank">Website</a> • <a href="https://stormsoftware.com/contact" target="_blank">Contact</a> • <a href="https://linkedin.com/in/patrick-sullivan-865526b0" target="_blank">LinkedIn</a> • <a href="https://medium.com/@pat.joseph.sullivan" target="_blank">Medium</a> • <a href="https://github.com/storm-software" target="_blank">GitHub</a> • <a href="https://keybase.io/sullivanp" target="_blank">OpenPGP Key</a>
265
+ </div>
266
+
267
+ <div align="center">
268
+ <b>Fingerprint:</b> 1BD2 7192 7770 2549 F4C9 F238 E6AD C420 DA5C 4C2D
269
+ </div>
270
+ <br />
271
+
272
+ Storm Software is an open source software development organization and creator
273
+ of Acidic, StormStack and StormCloud.
274
+
275
+ Our mission is to make software development more accessible. Our ideal future is
276
+ one where anyone can create software without years of prior development
277
+ experience serving as a barrier to entry. We hope to achieve this via LLMs,
278
+ Generative AI, and intuitive, high-level data modeling/programming languages.
279
+
280
+ Join us on [Discord](https://discord.gg/MQ6YVzakM5) to chat with the team,
281
+ receive release notifications, ask questions, and get involved.
282
+
283
+ If this sounds interesting, and you would like to help us in creating the next
284
+ generation of development tools, please reach out on our
285
+ [website](https://stormsoftware.com/contact) or join our
286
+ [Slack channel](https://join.slack.com/t/storm-software/shared_invite/zt-2gsmk04hs-i6yhK_r6urq0dkZYAwq2pA)!
287
+
288
+ <br />
289
+
290
+ <div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://public.storm-cdn.com/icon-fill.png" alt="Storm Software" width="200px"/></a></div>
291
+ <br />
292
+ <div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://public.storm-cdn.com/visit-us-text.svg" alt="Visit us at stormsoftware.com" height="90px"/></a></div>
293
+
294
+ <br />
295
+
296
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
297
+ <br />
298
+ <br />
299
+
300
+
301
+ <!-- markdownlint-restore -->
302
+ <!-- prettier-ignore-end -->
303
+
304
+ <!-- END footer -->
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
- const require_pretty_bytes = require('./node_modules/.pnpm/@stryke_string-format@0.13.1/node_modules/@stryke/string-format/dist/pretty-bytes.cjs');
3
+ const require_pretty_bytes = require('./node_modules/.pnpm/@stryke_string-format@0.13.3/node_modules/@stryke/string-format/dist/pretty-bytes.cjs');
4
4
  let __stryke_convert_to_array = require("@stryke/convert/to-array");
5
5
  let __stryke_fs_list_files = require("@stryke/fs/list-files");
6
6
  let __stryke_fs_read_file = require("@stryke/fs/read-file");
@@ -108,7 +108,7 @@ const plugin = (options = {}) => {
108
108
  this.error(` ✘ Failed to optimize ${file} - Compression output was not smaller than the original`);
109
109
  return;
110
110
  }
111
- this.info(` ✔ Successfully optimized ${file}: ${chalk.default.redBright(require_pretty_bytes.a(originalSize))} -> ${chalk.default.greenBright(require_pretty_bytes.a(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`);
112
112
  }));
113
113
  }));
114
114
  }
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a } from "./node_modules/.pnpm/@stryke_string-format@0.13.1/node_modules/@stryke/string-format/dist/pretty-bytes.mjs";
1
+ import { prettyBytes } from "./node_modules/.pnpm/@stryke_string-format@0.13.3/node_modules/@stryke/string-format/dist/pretty-bytes.mjs";
2
2
  import { toArray } from "@stryke/convert/to-array";
3
3
  import { listFiles } from "@stryke/fs/list-files";
4
4
  import { readFile } from "@stryke/fs/read-file";
@@ -105,7 +105,7 @@ const plugin = (options = {}) => {
105
105
  this.error(` ✘ Failed to optimize ${file} - Compression output was not smaller than the original`);
106
106
  return;
107
107
  }
108
- this.info(` ✔ Successfully optimized ${file}: ${chalk.redBright(a(originalSize))} -> ${chalk.greenBright(a(compressedSize))} (${chalk.green((100 - compressedSize / originalSize * 100).toFixed(2))}%) in ${(performance.now() - start).toFixed(2)} ms`);
108
+ this.info(` ✔ Successfully optimized ${file}: ${chalk.redBright(prettyBytes(originalSize))} -> ${chalk.greenBright(prettyBytes(compressedSize))} (${chalk.green((100 - compressedSize / originalSize * 100).toFixed(2))}%) in ${(performance.now() - start).toFixed(2)} ms`);
109
109
  }));
110
110
  }));
111
111
  }
@@ -0,0 +1,128 @@
1
+
2
+ //#region ../../node_modules/.pnpm/@stryke+string-format@0.13.3/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,127 @@
1
+ //#region ../../node_modules/.pnpm/@stryke+string-format@0.13.3/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 };
File without changes
@@ -0,0 +1,2 @@
1
+ import { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig } from "./plugin.cjs";
2
+ export { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig };
@@ -1 +1,2 @@
1
- import { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig } from "./plugin.mjs";
1
+ import { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig } from "./plugin.mjs";
2
+ export { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig };
@@ -0,0 +1 @@
1
+ export { };
File without changes
@@ -0,0 +1 @@
1
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-image-compression",
3
- "version": "0.2.120",
3
+ "version": "0.2.121",
4
4
  "type": "module",
5
5
  "description": "A Powerlines plugin to optimize images used by the project.",
6
6
  "repository": {
@@ -123,21 +123,21 @@
123
123
  "powerlines-plugin"
124
124
  ],
125
125
  "dependencies": {
126
- "@stryke/convert": "^0.6.32",
127
- "@stryke/fs": "^0.33.30",
128
- "@stryke/path": "^0.24.3",
126
+ "@stryke/convert": "^0.6.34",
127
+ "@stryke/fs": "^0.33.35",
128
+ "@stryke/path": "^0.25.3",
129
129
  "chalk": "5.6.2",
130
130
  "defu": "^6.1.4",
131
131
  "jiti": "^2.6.1",
132
- "powerlines": "^0.37.45",
132
+ "powerlines": "^0.37.46",
133
133
  "sharp": "^0.34.5",
134
134
  "svgo": "^4.0.0"
135
135
  },
136
136
  "devDependencies": {
137
- "@powerlines/plugin-plugin": "^0.12.123",
137
+ "@powerlines/plugin-plugin": "^0.12.124",
138
138
  "@storm-software/config": "^1.135.0",
139
139
  "@types/node": "^24.10.9"
140
140
  },
141
141
  "publishConfig": { "access": "public" },
142
- "gitHead": "98320250bde7e4d99e3bfbb71b01b64392686868"
142
+ "gitHead": "032b11dbd79e039303ebe2942ed230ea8956ece1"
143
143
  }
@@ -1,71 +0,0 @@
1
-
2
- //#region ../../node_modules/.pnpm/@stryke+string-format@0.13.1/node_modules/@stryke/string-format/dist/pretty-bytes.mjs
3
- const e = [
4
- `B`,
5
- `kB`,
6
- `MB`,
7
- `GB`,
8
- `TB`,
9
- `PB`,
10
- `EB`,
11
- `ZB`,
12
- `YB`
13
- ], t = [
14
- `B`,
15
- `KiB`,
16
- `MiB`,
17
- `GiB`,
18
- `TiB`,
19
- `PiB`,
20
- `EiB`,
21
- `ZiB`,
22
- `YiB`
23
- ], n = [
24
- `b`,
25
- `kbit`,
26
- `Mbit`,
27
- `Gbit`,
28
- `Tbit`,
29
- `Pbit`,
30
- `Ebit`,
31
- `Zbit`,
32
- `Ybit`
33
- ], r = [
34
- `b`,
35
- `kibit`,
36
- `Mibit`,
37
- `Gibit`,
38
- `Tibit`,
39
- `Pibit`,
40
- `Eibit`,
41
- `Zibit`,
42
- `Yibit`
43
- ], i = (e$1, t$1, n$1 = {}) => {
44
- let r$1 = e$1, i$1 = t$1;
45
- return typeof i$1 == `string` ? (i$1 ||= process.env.STORM_LOCALE || `en-US`, Array.isArray(i$1) && (r$1 = e$1?.toLocaleString(i$1, n$1))) : (i$1 === !0 || n$1 !== void 0) && (r$1 = e$1?.toLocaleString(void 0, n$1)), String(r$1);
46
- };
47
- function a(a$1, o) {
48
- let s = a$1;
49
- if (!Number.isFinite(s)) throw TypeError(`Expected a finite number, got ${typeof s}: ${s}`);
50
- let c = {
51
- bits: !1,
52
- binary: !1,
53
- space: !0,
54
- ...o
55
- }, l = c.bits ? c.binary ? r : n : c.binary ? t : e, u = c.space ? ` ` : ``;
56
- if (c.signed && s === 0) return ` 0${u}${l[0]}`;
57
- let d = s < 0, f = d ? `-` : c.signed ? `+` : ``;
58
- d && (s = -s);
59
- let p;
60
- if (c.minimumFractionDigits !== void 0 && (p = { minimumFractionDigits: c.minimumFractionDigits }), c.maximumFractionDigits !== void 0 && (p = {
61
- maximumFractionDigits: c.maximumFractionDigits,
62
- ...p
63
- }), s < 1) return f + i(s, c.locale, p) + u + l[0];
64
- let m = Math.min(Math.floor(c.binary ? Math.log(s) / Math.log(1024) : Math.log10(s) / 3), l.length - 1);
65
- s /= (c.binary ? 1024 : 1e3) ** m, p || (s = s.toPrecision(3));
66
- let h = i(Number(s), c.locale, p), g = l[m];
67
- return f + h + u + g;
68
- }
69
-
70
- //#endregion
71
- exports.a = a;
@@ -1,70 +0,0 @@
1
- //#region ../../node_modules/.pnpm/@stryke+string-format@0.13.1/node_modules/@stryke/string-format/dist/pretty-bytes.mjs
2
- const e = [
3
- `B`,
4
- `kB`,
5
- `MB`,
6
- `GB`,
7
- `TB`,
8
- `PB`,
9
- `EB`,
10
- `ZB`,
11
- `YB`
12
- ], t = [
13
- `B`,
14
- `KiB`,
15
- `MiB`,
16
- `GiB`,
17
- `TiB`,
18
- `PiB`,
19
- `EiB`,
20
- `ZiB`,
21
- `YiB`
22
- ], n = [
23
- `b`,
24
- `kbit`,
25
- `Mbit`,
26
- `Gbit`,
27
- `Tbit`,
28
- `Pbit`,
29
- `Ebit`,
30
- `Zbit`,
31
- `Ybit`
32
- ], r = [
33
- `b`,
34
- `kibit`,
35
- `Mibit`,
36
- `Gibit`,
37
- `Tibit`,
38
- `Pibit`,
39
- `Eibit`,
40
- `Zibit`,
41
- `Yibit`
42
- ], i = (e$1, t$1, n$1 = {}) => {
43
- let r$1 = e$1, i$1 = t$1;
44
- return typeof i$1 == `string` ? (i$1 ||= process.env.STORM_LOCALE || `en-US`, Array.isArray(i$1) && (r$1 = e$1?.toLocaleString(i$1, n$1))) : (i$1 === !0 || n$1 !== void 0) && (r$1 = e$1?.toLocaleString(void 0, n$1)), String(r$1);
45
- };
46
- function a(a$1, o) {
47
- let s = a$1;
48
- if (!Number.isFinite(s)) throw TypeError(`Expected a finite number, got ${typeof s}: ${s}`);
49
- let c = {
50
- bits: !1,
51
- binary: !1,
52
- space: !0,
53
- ...o
54
- }, l = c.bits ? c.binary ? r : n : c.binary ? t : e, u = c.space ? ` ` : ``;
55
- if (c.signed && s === 0) return ` 0${u}${l[0]}`;
56
- let d = s < 0, f = d ? `-` : c.signed ? `+` : ``;
57
- d && (s = -s);
58
- let p;
59
- if (c.minimumFractionDigits !== void 0 && (p = { minimumFractionDigits: c.minimumFractionDigits }), c.maximumFractionDigits !== void 0 && (p = {
60
- maximumFractionDigits: c.maximumFractionDigits,
61
- ...p
62
- }), s < 1) return f + i(s, c.locale, p) + u + l[0];
63
- let m = Math.min(Math.floor(c.binary ? Math.log(s) / Math.log(1024) : Math.log10(s) / 3), l.length - 1);
64
- s /= (c.binary ? 1024 : 1e3) ** m, p || (s = s.toPrecision(3));
65
- let h = i(Number(s), c.locale, p), g = l[m];
66
- return f + h + u + g;
67
- }
68
-
69
- //#endregion
70
- export { a };