@e-mc/compress 0.13.6 → 0.13.7
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 +7 -7
- package/package.json +3 -3
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.13.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.13.7/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { IModule, ModuleConstructor } from "./index";
|
|
@@ -125,9 +125,9 @@ instance.tryImage("/tmp/image.png", "/path/output/compressed.png", options)
|
|
|
125
125
|
|
|
126
126
|
## References
|
|
127
127
|
|
|
128
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
129
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
130
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
128
|
+
- https://www.unpkg.com/@e-mc/types@0.13.7/lib/squared.d.ts
|
|
129
|
+
- https://www.unpkg.com/@e-mc/types@0.13.7/lib/compress.d.ts
|
|
130
|
+
- https://www.unpkg.com/@e-mc/types@0.13.7/lib/settings.d.ts
|
|
131
131
|
|
|
132
132
|
* https://www.npmjs.com/package/@types/node
|
|
133
133
|
|
package/index.js
CHANGED
|
@@ -13,7 +13,7 @@ function createWorker(filename) {
|
|
|
13
13
|
}
|
|
14
14
|
const SUPPORTED_NODE21 = (0, types_1.supported)(21);
|
|
15
15
|
const CACHE_IMAGE = Object.create(null);
|
|
16
|
-
const CACHE_FONT =
|
|
16
|
+
const CACHE_FONT = new Map();
|
|
17
17
|
const CACHE_FONTFROM = Object.create(null);
|
|
18
18
|
const CACHE_FONTTO = Object.create(null);
|
|
19
19
|
const CACHE_TEMP = {
|
|
@@ -348,7 +348,7 @@ class Compress extends core_1.Module {
|
|
|
348
348
|
}
|
|
349
349
|
fs.writeFile(tempFont, data, err => {
|
|
350
350
|
if (!err) {
|
|
351
|
-
CACHE_FONT
|
|
351
|
+
CACHE_FONT.set(from + '_' + ext + '_' + hash, [tempFont, new Date()]);
|
|
352
352
|
CACHE_FONTTO[hash] = ext;
|
|
353
353
|
}
|
|
354
354
|
});
|
|
@@ -373,7 +373,7 @@ class Compress extends core_1.Module {
|
|
|
373
373
|
const to = CACHE_FONTTO[hash];
|
|
374
374
|
if (from && to) {
|
|
375
375
|
const cacheKey = from + `_${to}_` + hash;
|
|
376
|
-
const tempFont = CACHE_FONT
|
|
376
|
+
const tempFont = CACHE_FONT.get(cacheKey);
|
|
377
377
|
if (tempFont) {
|
|
378
378
|
if (core_1.Module.isPath(tempFont[0])) {
|
|
379
379
|
try {
|
|
@@ -392,7 +392,7 @@ class Compress extends core_1.Module {
|
|
|
392
392
|
catch {
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
delete
|
|
395
|
+
CACHE_FONT.delete(cacheKey);
|
|
396
396
|
}
|
|
397
397
|
return false;
|
|
398
398
|
}
|
|
@@ -807,7 +807,7 @@ class Compress extends core_1.Module {
|
|
|
807
807
|
(function recurse(paths) {
|
|
808
808
|
try {
|
|
809
809
|
const srcDir = path.join(tempDir, ...paths);
|
|
810
|
-
fs.readdirSync(srcDir, { withFileTypes: true })
|
|
810
|
+
for (const item of fs.readdirSync(srcDir, { withFileTypes: true })) {
|
|
811
811
|
const filename = item.name;
|
|
812
812
|
if (item.isFile()) {
|
|
813
813
|
const target = path.join(srcDir, filename);
|
|
@@ -816,7 +816,7 @@ class Compress extends core_1.Module {
|
|
|
816
816
|
const stat = fs.lstatSync(target);
|
|
817
817
|
if (stat.atimeMs + expires > current) {
|
|
818
818
|
if (type === 'font') {
|
|
819
|
-
CACHE_FONT
|
|
819
|
+
CACHE_FONT.set(paths.concat(filename).join('_'), [target, stat.ctime]);
|
|
820
820
|
CACHE_FONTFROM[filename] = paths[0];
|
|
821
821
|
CACHE_FONTTO[filename] = paths[1];
|
|
822
822
|
}
|
|
@@ -834,7 +834,7 @@ class Compress extends core_1.Module {
|
|
|
834
834
|
else if (item.isDirectory()) {
|
|
835
835
|
recurse(paths.concat(filename));
|
|
836
836
|
}
|
|
837
|
-
}
|
|
837
|
+
}
|
|
838
838
|
}
|
|
839
839
|
catch {
|
|
840
840
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/compress",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.7",
|
|
4
4
|
"description": "Compress constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"license": "BSD-3-Clause",
|
|
23
23
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@e-mc/core": "0.13.
|
|
26
|
-
"@e-mc/types": "0.13.
|
|
25
|
+
"@e-mc/core": "0.13.7",
|
|
26
|
+
"@e-mc/types": "0.13.7",
|
|
27
27
|
"wawoff2": "^2.0.1",
|
|
28
28
|
"woff2sfnt-sfnt2woff": "^1.0.0"
|
|
29
29
|
}
|