@e-mc/compress 0.11.9 → 0.11.11
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 +4 -4
- package/index.js +14 -3
- package/package.json +3 -3
- package/worker/plugin-image.js +1 -5
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.11.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.11.11/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { IModule, ModuleConstructor } from "./index";
|
|
@@ -116,9 +116,9 @@ instance.tryImage("/tmp/image.png", "/path/output/compressed.png", options)
|
|
|
116
116
|
|
|
117
117
|
## References
|
|
118
118
|
|
|
119
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
120
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
121
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
119
|
+
- https://www.unpkg.com/@e-mc/types@0.11.11/lib/squared.d.ts
|
|
120
|
+
- https://www.unpkg.com/@e-mc/types@0.11.11/lib/compress.d.ts
|
|
121
|
+
- https://www.unpkg.com/@e-mc/types@0.11.11/lib/settings.d.ts
|
|
122
122
|
|
|
123
123
|
* https://www.npmjs.com/package/@types/node
|
|
124
124
|
|
package/index.js
CHANGED
|
@@ -205,10 +205,15 @@ class Compress extends module_1 {
|
|
|
205
205
|
if (options) {
|
|
206
206
|
({ level, chunkSize, mimeType } = options);
|
|
207
207
|
}
|
|
208
|
-
|
|
209
|
-
let brotli = this.module.brotli;
|
|
208
|
+
let brotli = this.module.brotli, params = {};
|
|
210
209
|
if ((0, types_1.isPlainObject)(brotli)) {
|
|
211
|
-
|
|
210
|
+
if ((0, types_1.isPlainObject)(brotli.params)) {
|
|
211
|
+
brotli = (0, types_1.cloneObject)(brotli, true);
|
|
212
|
+
params = brotli.params;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
brotli = { ...brotli, params };
|
|
216
|
+
}
|
|
212
217
|
}
|
|
213
218
|
else {
|
|
214
219
|
brotli = { params };
|
|
@@ -225,6 +230,12 @@ class Compress extends module_1 {
|
|
|
225
230
|
else {
|
|
226
231
|
brotli.chunkSize ??= this.chunkSize;
|
|
227
232
|
}
|
|
233
|
+
if (typeof level === 'number') {
|
|
234
|
+
params[zlib.constants.BROTLI_PARAM_QUALITY] = level;
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
params[zlib.constants.BROTLI_PARAM_QUALITY] ??= this.level.br;
|
|
238
|
+
}
|
|
228
239
|
return this.getReadable(file, options).pipe(zlib.createBrotliCompress(brotli));
|
|
229
240
|
}
|
|
230
241
|
createWriteStreamAsGzip(file, output, options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/compress",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.11",
|
|
4
4
|
"description": "Compress constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"license": "BSD-3-Clause",
|
|
24
24
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@e-mc/module": "0.11.
|
|
27
|
-
"@e-mc/types": "0.11.
|
|
26
|
+
"@e-mc/module": "0.11.11",
|
|
27
|
+
"@e-mc/types": "0.11.11",
|
|
28
28
|
"wawoff2": "^2.0.1",
|
|
29
29
|
"woff2sfnt-sfnt2woff": "^1.0.0"
|
|
30
30
|
}
|
package/worker/plugin-image.js
CHANGED
|
@@ -13,7 +13,7 @@ node_worker_threads_1.parentPort.on('message', async (value) => {
|
|
|
13
13
|
catch {
|
|
14
14
|
transform = require(plugin);
|
|
15
15
|
}
|
|
16
|
-
transform(options, metadata)(index_1.asBuffer(data))
|
|
16
|
+
void transform(options, metadata)(index_1.asBuffer(data))
|
|
17
17
|
.then(result => {
|
|
18
18
|
try {
|
|
19
19
|
PORT.postMessage(result, [result.buffer]);
|
|
@@ -21,10 +21,6 @@ node_worker_threads_1.parentPort.on('message', async (value) => {
|
|
|
21
21
|
catch {
|
|
22
22
|
PORT.postMessage(result);
|
|
23
23
|
}
|
|
24
|
-
})
|
|
25
|
-
.catch((err) => {
|
|
26
|
-
console.error(err);
|
|
27
|
-
PORT.postMessage(null);
|
|
28
24
|
});
|
|
29
25
|
}
|
|
30
26
|
catch (err) {
|