@e-mc/compress 0.12.2 → 0.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/index.js +1 -1
- package/package.json +3 -3
- package/worker/sfnt2woff.js +10 -1
- package/worker/svg2ttf.js +24 -0
- package/worker/woff2sfnt.js +10 -1
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.12.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.12.4/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { IModule, ModuleConstructor } from "./index";
|
|
@@ -120,9 +120,9 @@ instance.tryImage("/tmp/image.png", "/path/output/compressed.png", options)
|
|
|
120
120
|
|
|
121
121
|
## References
|
|
122
122
|
|
|
123
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
124
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
125
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
123
|
+
- https://www.unpkg.com/@e-mc/types@0.12.4/lib/squared.d.ts
|
|
124
|
+
- https://www.unpkg.com/@e-mc/types@0.12.4/lib/compress.d.ts
|
|
125
|
+
- https://www.unpkg.com/@e-mc/types@0.12.4/lib/settings.d.ts
|
|
126
126
|
|
|
127
127
|
* https://www.npmjs.com/package/@types/node
|
|
128
128
|
|
package/index.js
CHANGED
|
@@ -483,7 +483,7 @@ class Compress extends core_1.Module {
|
|
|
483
483
|
if (cache) {
|
|
484
484
|
CACHE_FONTFROM[hash] = 'woff';
|
|
485
485
|
}
|
|
486
|
-
if (this.hasPermission('worker', options) && (worker = WORKER.get('woff').sendBuffer(data,
|
|
486
|
+
if (this.hasPermission('worker', options) && (worker = WORKER.get('woff').sendBuffer(data, true, checkResult, 'woff'))) {
|
|
487
487
|
startProcess(false);
|
|
488
488
|
}
|
|
489
489
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/compress",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.4",
|
|
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/core": "0.12.
|
|
27
|
-
"@e-mc/types": "0.12.
|
|
26
|
+
"@e-mc/core": "0.12.4",
|
|
27
|
+
"@e-mc/types": "0.12.4",
|
|
28
28
|
"wawoff2": "^2.0.1",
|
|
29
29
|
"woff2sfnt-sfnt2woff": "^1.0.0"
|
|
30
30
|
}
|
package/worker/sfnt2woff.js
CHANGED
|
@@ -3,11 +3,20 @@ const node_worker_threads_1 = require("node:worker_threads");
|
|
|
3
3
|
const { toWoff } = require('woff2sfnt-sfnt2woff');
|
|
4
4
|
const PORT = node_worker_threads_1.workerData[0];
|
|
5
5
|
node_worker_threads_1.parentPort.on('message', (value) => {
|
|
6
|
+
let data = null;
|
|
6
7
|
try {
|
|
7
|
-
|
|
8
|
+
data = toWoff(value);
|
|
8
9
|
PORT.postMessage(data, [data.buffer]);
|
|
9
10
|
}
|
|
10
11
|
catch (err) {
|
|
12
|
+
if (data) {
|
|
13
|
+
try {
|
|
14
|
+
PORT.postMessage(data);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
}
|
|
19
|
+
}
|
|
11
20
|
console.error(err);
|
|
12
21
|
PORT.postMessage(null);
|
|
13
22
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const node_worker_threads_1 = require("node:worker_threads");
|
|
3
|
+
const svg2ttf = require("svg2ttf");
|
|
4
|
+
const PORT = node_worker_threads_1.workerData[0];
|
|
5
|
+
node_worker_threads_1.parentPort.on('message', (value) => {
|
|
6
|
+
let data = null;
|
|
7
|
+
try {
|
|
8
|
+
const decoder = new TextDecoder('utf-8');
|
|
9
|
+
data = svg2ttf(decoder.decode(value)).buffer;
|
|
10
|
+
PORT.postMessage(data, [data.buffer]);
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
if (data) {
|
|
14
|
+
try {
|
|
15
|
+
PORT.postMessage(data);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
console.error(err);
|
|
22
|
+
PORT.postMessage(null);
|
|
23
|
+
}
|
|
24
|
+
});
|
package/worker/woff2sfnt.js
CHANGED
|
@@ -3,11 +3,20 @@ const node_worker_threads_1 = require("node:worker_threads");
|
|
|
3
3
|
const { toSfnt } = require('woff2sfnt-sfnt2woff');
|
|
4
4
|
const PORT = node_worker_threads_1.workerData[0];
|
|
5
5
|
node_worker_threads_1.parentPort.on('message', (value) => {
|
|
6
|
+
let data = null;
|
|
6
7
|
try {
|
|
7
|
-
|
|
8
|
+
data = toSfnt(value);
|
|
8
9
|
PORT.postMessage(data, [data.buffer]);
|
|
9
10
|
}
|
|
10
11
|
catch (err) {
|
|
12
|
+
if (data) {
|
|
13
|
+
try {
|
|
14
|
+
PORT.postMessage(data);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
}
|
|
19
|
+
}
|
|
11
20
|
console.error(err);
|
|
12
21
|
PORT.postMessage(null);
|
|
13
22
|
}
|