@e-mc/compress 0.7.1 → 0.8.1
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/index.js +16 -16
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -207,7 +207,7 @@ class Compress extends module_1.default {
|
|
|
207
207
|
createWriteStreamAsBrotli(file, output, options) {
|
|
208
208
|
return this.createBrotliCompress(file, options).pipe(fs.createWriteStream(output));
|
|
209
209
|
}
|
|
210
|
-
tryFile(file, output, config, callback) {
|
|
210
|
+
async tryFile(file, output, config, callback) {
|
|
211
211
|
if (typeof config === 'function') {
|
|
212
212
|
callback = config;
|
|
213
213
|
config = undefined;
|
|
@@ -244,7 +244,7 @@ class Compress extends module_1.default {
|
|
|
244
244
|
}
|
|
245
245
|
else {
|
|
246
246
|
if (!fromCache) {
|
|
247
|
-
this.writeTimeProcess(ext || format, (0, types_1.isString)(result) ? path.basename(result) : filename ||
|
|
247
|
+
this.writeTimeProcess(ext || format, (0, types_1.isString)(result) ? path.basename(result) : filename || "Completed" /* VAL_MESSAGE.COMPLETED */, startTime, { type: 8 /* LOG_TYPE.COMPRESS */, sessionId, broadcastId });
|
|
248
248
|
}
|
|
249
249
|
if (callback) {
|
|
250
250
|
callback(null, result || data, ext);
|
|
@@ -311,7 +311,7 @@ class Compress extends module_1.default {
|
|
|
311
311
|
else {
|
|
312
312
|
endProcess(null, data, to, '', true);
|
|
313
313
|
}
|
|
314
|
-
this.formatMessage(8 /* LOG_TYPE.COMPRESS */, from, [pathname ? path.basename(pathname) :
|
|
314
|
+
this.formatMessage(8 /* LOG_TYPE.COMPRESS */, from, [pathname ? path.basename(pathname) : "Completed" /* VAL_MESSAGE.COMPLETED */ + ` -> font/${to}`, 'cache'], tempFont[1].toLocaleString(), { ...module_1.default.LOG_STYLE_NOTICE, hintBold: true, sessionId, broadcastId });
|
|
315
315
|
return true;
|
|
316
316
|
}
|
|
317
317
|
catch {
|
|
@@ -357,8 +357,8 @@ class Compress extends module_1.default {
|
|
|
357
357
|
const checkResult = (result, from) => {
|
|
358
358
|
module_1.default.resolveMime(result).then(font => {
|
|
359
359
|
switch (font?.mime) {
|
|
360
|
-
case
|
|
361
|
-
case
|
|
360
|
+
case "font/ttf" /* MIME_TYPE.TTF */:
|
|
361
|
+
case "font/otf" /* MIME_TYPE.OTF */:
|
|
362
362
|
writeFont(result, font.ext, from);
|
|
363
363
|
break;
|
|
364
364
|
default:
|
|
@@ -370,13 +370,13 @@ class Compress extends module_1.default {
|
|
|
370
370
|
module_1.default.resolveMime(data).then(font => {
|
|
371
371
|
try {
|
|
372
372
|
switch (font?.mime) {
|
|
373
|
-
case
|
|
373
|
+
case "font/woff" /* MIME_TYPE.WOFF */:
|
|
374
374
|
if (cache) {
|
|
375
375
|
CACHE_FONTFROM[hash] = 'woff';
|
|
376
376
|
}
|
|
377
377
|
checkResult(toSfnt(data), 'woff');
|
|
378
378
|
break;
|
|
379
|
-
case
|
|
379
|
+
case "font/woff2" /* MIME_TYPE.WOFF2 */:
|
|
380
380
|
if (cache) {
|
|
381
381
|
CACHE_FONTFROM[hash] = 'woff2';
|
|
382
382
|
}
|
|
@@ -412,17 +412,17 @@ class Compress extends module_1.default {
|
|
|
412
412
|
module_1.default.resolveMime(data).then(font => {
|
|
413
413
|
try {
|
|
414
414
|
switch (font?.mime) {
|
|
415
|
-
case
|
|
415
|
+
case "font/ttf" /* MIME_TYPE.TTF */:
|
|
416
416
|
if (cache) {
|
|
417
417
|
CACHE_FONTFROM[hash] = 'ttf';
|
|
418
418
|
}
|
|
419
|
-
wawoff2.compress(data).then(result => checkResult(result,
|
|
419
|
+
wawoff2.compress(data).then(result => checkResult(result, "font/woff2" /* MIME_TYPE.WOFF2 */, 'ttf'));
|
|
420
420
|
break;
|
|
421
|
-
case
|
|
421
|
+
case "font/otf" /* MIME_TYPE.OTF */:
|
|
422
422
|
if (cache) {
|
|
423
423
|
CACHE_FONTFROM[hash] = 'otf';
|
|
424
424
|
}
|
|
425
|
-
checkResult(toWoff(data),
|
|
425
|
+
checkResult(toWoff(data), "font/woff" /* MIME_TYPE.WOFF */, 'otf');
|
|
426
426
|
break;
|
|
427
427
|
default:
|
|
428
428
|
errorResponse(font);
|
|
@@ -467,7 +467,7 @@ class Compress extends module_1.default {
|
|
|
467
467
|
}
|
|
468
468
|
});
|
|
469
469
|
}
|
|
470
|
-
tryImage(file, output, config, callback) {
|
|
470
|
+
async tryImage(file, output, config, callback) {
|
|
471
471
|
if (typeof config === 'function') {
|
|
472
472
|
callback = config;
|
|
473
473
|
config = undefined;
|
|
@@ -509,7 +509,7 @@ class Compress extends module_1.default {
|
|
|
509
509
|
}
|
|
510
510
|
const complete = (err) => {
|
|
511
511
|
const value = output ? path.basename(output) : filename || (0, types_1.isString)(file) && path.basename(file);
|
|
512
|
-
const status = value ? plugin + ' -> ' + value :
|
|
512
|
+
const status = value ? plugin + ' -> ' + value : "Completed" /* VAL_MESSAGE.COMPLETED */;
|
|
513
513
|
if (ctime) {
|
|
514
514
|
this.formatMessage(8 /* LOG_TYPE.COMPRESS */, value ? path.extname(value).substring(1) : '', [status, 'cache'], ctime.toLocaleString(), { ...module_1.default.LOG_STYLE_NOTICE, hintBold: true, sessionId, broadcastId });
|
|
515
515
|
}
|
|
@@ -557,9 +557,9 @@ class Compress extends module_1.default {
|
|
|
557
557
|
return;
|
|
558
558
|
}
|
|
559
559
|
switch (module_1.default.lookupMime(ext)) {
|
|
560
|
-
case
|
|
561
|
-
case
|
|
562
|
-
case
|
|
560
|
+
case "image/jpeg" /* MIME_TYPE.JPEG */:
|
|
561
|
+
case "image/png" /* MIME_TYPE.PNG */:
|
|
562
|
+
case "image/webp" /* MIME_TYPE.WEBP */:
|
|
563
563
|
break;
|
|
564
564
|
default:
|
|
565
565
|
failed((0, types_1.errorMessage)(plugin, 'Unsupported format', getFormat()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/compress",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
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.
|
|
27
|
-
"@e-mc/types": "0.
|
|
26
|
+
"@e-mc/module": "0.8.1",
|
|
27
|
+
"@e-mc/types": "0.8.1",
|
|
28
28
|
"tinify": "^1.7.1",
|
|
29
29
|
"wawoff2": "^2.0.1",
|
|
30
30
|
"woff2sfnt-sfnt2woff": "^1.0.0"
|