@node-minify/types 10.1.0 → 10.2.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @node-minify/types
2
2
 
3
+ ## 10.2.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 3c98739: feat: Add image compression support
8
+
9
+ New packages:
10
+
11
+ - `@node-minify/sharp`: Convert and compress images to WebP, AVIF, PNG, JPEG using sharp
12
+ - `@node-minify/svgo`: Optimize SVG files using SVGO
13
+ - `@node-minify/imagemin`: Compress PNG, JPEG, GIF images using imagemin
14
+
15
+ Core changes:
16
+
17
+ - Support for binary (Buffer) content in compressors
18
+ - Multi-format output support (e.g., convert PNG to both WebP and AVIF)
19
+ - New `buffer` and `outputs` fields in CompressorResult type
20
+
21
+ ## 10.1.1
22
+
23
+ ### Patch Changes
24
+
25
+ - eb785b0: Fix npm install error caused by unresolved workspace:\* references in published packages
26
+
3
27
  ## 10.1.0
4
28
 
5
29
  ## 10.0.2
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
- <p align="center"><img src="/static/node-minify.svg" width="348" alt="node-minify"></p>
1
+ <p align="center"><img src="https://raw.githubusercontent.com/srod/node-minify/main/static/node-minify.svg" width="348" alt="node-minify"></p>
2
2
 
3
3
  <p align="center">A very light minifier Node.js module.</p>
4
4
 
5
5
  <p align="center">
6
6
  <br>
7
- <a href="https://npmjs.org/package/@node-minify/types"><img src="https://img.shields.io/npm/v/@node-minify/types.svg"></a>
8
- <a href="https://npmjs.org/package/@node-minify/types"><img src="https://img.shields.io/npm/dm/@node-minify/types.svg"></a>
7
+ <a href="https://npmjs.org/package/@node-minify/types"><img src="https://img.shields.io/npm/v/@node-minify/types.svg" alt="npm version"></a>
8
+ <a href="https://npmjs.org/package/@node-minify/types"><img src="https://img.shields.io/npm/dm/@node-minify/types.svg" alt="npm downloads"></a>
9
9
  <a href="https://github.com/srod/node-minify/actions"><img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fsrod%2Fnode-minify%2Fbadge%3Fref%3Dmain&style=flat" /></a>
10
- <a href="https://codecov.io/gh/srod/node-minify"><img src="https://codecov.io/gh/srod/node-minify/branch/main/graph/badge.svg"></a>
10
+ <a href="https://codecov.io/gh/srod/node-minify"><img src="https://codecov.io/gh/srod/node-minify/branch/main/graph/badge.svg" alt="code coverage"></a>
11
11
  </p>
12
12
 
13
13
  # Types for node-minify
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-minify/types",
3
- "version": "10.1.0",
3
+ "version": "10.2.0",
4
4
  "description": "types for @node-minify",
5
5
  "keywords": [
6
6
  "compressor",
@@ -27,4 +27,4 @@
27
27
  "bugs": {
28
28
  "url": "https://github.com/srod/node-minify/issues"
29
29
  }
30
- }
30
+ }
package/src/types.d.ts CHANGED
@@ -10,12 +10,63 @@
10
10
  */
11
11
  export type CompressorReturnType = string;
12
12
 
13
+ /**
14
+ * Supported image formats for image compression.
15
+ */
16
+ export type ImageFormat =
17
+ | "webp"
18
+ | "avif"
19
+ | "png"
20
+ | "jpeg"
21
+ | "jpg"
22
+ | "gif"
23
+ | "tiff"
24
+ | "heif"
25
+ | "heic";
26
+
27
+ /**
28
+ * Output result for multi-format image compression.
29
+ */
30
+ export type CompressorOutput = {
31
+ /**
32
+ * Format of the output (e.g., 'webp', 'avif').
33
+ */
34
+ format?: string;
35
+
36
+ /**
37
+ * Output content as string or Buffer.
38
+ */
39
+ content: string | Buffer;
40
+ };
41
+
13
42
  /**
14
43
  * Result returned by a compressor function.
15
44
  */
16
45
  export type CompressorResult = {
46
+ /**
47
+ * Minified content as string (for text-based formats like JS, CSS, HTML, SVG).
48
+ */
17
49
  code: string;
50
+
51
+ /**
52
+ * Source map (for JS/CSS compressors).
53
+ */
18
54
  map?: string;
55
+
56
+ /**
57
+ * Minified content as Buffer (for binary formats like images).
58
+ * @example
59
+ * When using sharp for PNG/WebP compression
60
+ */
61
+ buffer?: Buffer;
62
+
63
+ /**
64
+ * Multiple outputs for multi-format image compression.
65
+ * Used when converting to multiple formats simultaneously.
66
+ * @example
67
+ * [{ format: 'webp', content: <Buffer> }, { format: 'avif', content: <Buffer> }]
68
+ */
69
+ outputs?: CompressorOutput[];
19
70
  };
20
71
 
21
72
  /**
@@ -68,8 +119,10 @@ export type Settings<TOptions extends CompressorOptions = CompressorOptions> = {
68
119
  /**
69
120
  * Content to minify (for in-memory minification).
70
121
  * If provided, input/output are not required.
122
+ * For text-based formats (JS, CSS, HTML, SVG): string
123
+ * For binary formats (images): Buffer (handled internally by image compressors)
71
124
  */
72
- content?: string;
125
+ content?: string | Buffer;
73
126
 
74
127
  /**
75
128
  * Input file path(s) or glob pattern.
@@ -154,8 +207,11 @@ export type MinifierOptions<
154
207
 
155
208
  /**
156
209
  * The content to minify.
210
+ * For text-based formats (JS, CSS, HTML, SVG): string
211
+ * For binary formats (images): Buffer
212
+ * For multiple binary files: Buffer[]
157
213
  */
158
- content?: string;
214
+ content?: string | Buffer | Buffer[];
159
215
 
160
216
  /**
161
217
  * Index of current file when processing multiple files.
@@ -0,0 +1,7 @@
1
+ import { defineProject } from "vitest/config";
2
+
3
+ export default defineProject({
4
+ test: {
5
+ include: [],
6
+ },
7
+ });