@e-mc/module 0.9.4 → 0.9.5
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 +6 -6
- package/index.js +25 -17
- package/package.json +2 -2
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.9.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.9.5/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -391,11 +391,11 @@ type ForegroundColor = typeof IForegroundColor | `#${string}`;
|
|
|
391
391
|
|
|
392
392
|
## References
|
|
393
393
|
|
|
394
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
395
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
396
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
397
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
398
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
394
|
+
- https://www.unpkg.com/@e-mc/types@0.9.5/lib/core.d.ts
|
|
395
|
+
- https://www.unpkg.com/@e-mc/types@0.9.5/lib/logger.d.ts
|
|
396
|
+
- https://www.unpkg.com/@e-mc/types@0.9.5/lib/module.d.ts
|
|
397
|
+
- https://www.unpkg.com/@e-mc/types@0.9.5/lib/node.d.ts
|
|
398
|
+
- https://www.unpkg.com/@e-mc/types@0.9.5/lib/settings.d.ts
|
|
399
399
|
|
|
400
400
|
* https://www.npmjs.com/package/@types/node
|
|
401
401
|
|
package/index.js
CHANGED
|
@@ -420,7 +420,7 @@ function recurseCause(err, out, visited) {
|
|
|
420
420
|
visited = new WeakSet();
|
|
421
421
|
}
|
|
422
422
|
visited.add(err);
|
|
423
|
-
if (
|
|
423
|
+
if (Object.prototype.hasOwnProperty.call(err, 'cause')) {
|
|
424
424
|
const cause = err.cause;
|
|
425
425
|
if (cause instanceof Error) {
|
|
426
426
|
if (message) {
|
|
@@ -549,9 +549,9 @@ function encryptMessage(data, cipher, algorithm) {
|
|
|
549
549
|
}
|
|
550
550
|
return data;
|
|
551
551
|
}
|
|
552
|
-
function relayMessage(args) {
|
|
553
|
-
const host =
|
|
554
|
-
if (host
|
|
552
|
+
function relayMessage(instance, args) {
|
|
553
|
+
const host = instance.host || instance;
|
|
554
|
+
if (host.logState === 0) {
|
|
555
555
|
host.delayMessage(args);
|
|
556
556
|
}
|
|
557
557
|
else {
|
|
@@ -696,7 +696,7 @@ class Module extends EventEmitter {
|
|
|
696
696
|
this[_f] = new AbortController();
|
|
697
697
|
this[_g] = null;
|
|
698
698
|
}
|
|
699
|
-
static get VERSION() { return "0.9.
|
|
699
|
+
static get VERSION() { return "0.9.5"; }
|
|
700
700
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
701
701
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
702
702
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -990,10 +990,14 @@ class Module extends EventEmitter {
|
|
|
990
990
|
({ color: hintColor, bgColor: hintBgColor } = formatHint);
|
|
991
991
|
hintBold ?? (hintBold = formatHint.bold);
|
|
992
992
|
}
|
|
993
|
-
value = getValue() + (coloring ? chalk.blackBright('[') + formatColumn(truncateEnd(hint, hintWidth), hintColor, hintBgColor, hintBold) + chalk.blackBright(']') : `[${truncateEnd(hint, hintWidth)}]`);
|
|
994
|
-
}
|
|
995
|
-
else if (title) {
|
|
996
993
|
value = getValue();
|
|
994
|
+
hint = coloring ? chalk.blackBright('[') + formatColumn(truncateEnd(hint, hintWidth), hintColor, hintBgColor, hintBold) + chalk.blackBright(']') : `[${truncateEnd(hint, hintWidth)}]`;
|
|
995
|
+
}
|
|
996
|
+
else {
|
|
997
|
+
if (title) {
|
|
998
|
+
value = getValue();
|
|
999
|
+
}
|
|
1000
|
+
hint = '';
|
|
997
1001
|
}
|
|
998
1002
|
const unit = options.messageUnit ? type & 256 ? options.messageUnit.padStart(options.messageUnitMinWidth || 0) : options.messageUnit : '';
|
|
999
1003
|
const getMessage = (m, u) => (type & 256) && messageUnitIndent === undefined ? (u + m).trimEnd() : u ? (m + (messageUnitIndent === undefined ? ' ' : '') + u).trimStart() : m;
|
|
@@ -1038,19 +1042,19 @@ class Module extends EventEmitter {
|
|
|
1038
1042
|
}
|
|
1039
1043
|
}
|
|
1040
1044
|
else {
|
|
1041
|
-
if (!i) {
|
|
1045
|
+
if (!i && !hint) {
|
|
1042
1046
|
v = v.trim();
|
|
1043
1047
|
}
|
|
1044
1048
|
m = '';
|
|
1045
1049
|
}
|
|
1046
|
-
output = (titleIndent !== -1 ? title : title ? formatColumn(title, titleColor || 'green', titleBgColor, (options.titleBold || formatTitle.bold) ?? false) + chalk.blackBright(':') + ' ' : '') + formatColumn(v, valueColor, valueBgColor, valueBold) +
|
|
1050
|
+
output = (titleIndent !== -1 ? title : title ? formatColumn(title, titleColor || 'green', titleBgColor, (options.titleBold || formatTitle.bold) ?? false) + chalk.blackBright(':') + ' ' : '') + formatColumn(v, valueColor, valueBgColor, valueBold) + hint + (i || ' ') + m;
|
|
1047
1051
|
}
|
|
1048
1052
|
catch {
|
|
1049
1053
|
}
|
|
1050
1054
|
}
|
|
1051
1055
|
if (!output) {
|
|
1052
1056
|
const m = truncateStart(stripansi(this.asString(message)), options.messageWidth ?? format.message.width);
|
|
1053
|
-
output = (titleIndent !== -1 ? title : title ? title + ': ' : '') + stripansi(value) + (
|
|
1057
|
+
output = (titleIndent !== -1 ? title : title ? title + ': ' : '') + stripansi(value) + stripansi(hint) + (id || ' ') + (m && SETTINGS.message !== false ? (error ? '{' : '(') + getMessage(m, unit) + (error ? '}' : ')') : '');
|
|
1054
1058
|
}
|
|
1055
1059
|
if (broadcastId) {
|
|
1056
1060
|
if (BROADCAST_OUT) {
|
|
@@ -1334,6 +1338,8 @@ class Module extends EventEmitter {
|
|
|
1334
1338
|
return /^s?ftp:\/\/[^/]/i.test(value);
|
|
1335
1339
|
case 'torrent':
|
|
1336
1340
|
return REGEXP_TORRENT.test(value);
|
|
1341
|
+
case 'file':
|
|
1342
|
+
return isFileURL(value);
|
|
1337
1343
|
}
|
|
1338
1344
|
}
|
|
1339
1345
|
else if (value instanceof URL) {
|
|
@@ -1354,6 +1360,8 @@ class Module extends EventEmitter {
|
|
|
1354
1360
|
return value.protocol === 'ftp:' || value.protocol === 'sftp:';
|
|
1355
1361
|
case 'torrent':
|
|
1356
1362
|
return REGEXP_TORRENT.test(value.toString());
|
|
1363
|
+
case 'file':
|
|
1364
|
+
return value.protocol === 'file:';
|
|
1357
1365
|
}
|
|
1358
1366
|
}
|
|
1359
1367
|
return false;
|
|
@@ -2978,7 +2986,7 @@ class Module extends EventEmitter {
|
|
|
2978
2986
|
if (callback) {
|
|
2979
2987
|
result.catch((err) => callback(errorCheck(err, outSrc)));
|
|
2980
2988
|
}
|
|
2981
|
-
return promises ? result :
|
|
2989
|
+
return promises ? result : void 0;
|
|
2982
2990
|
}
|
|
2983
2991
|
if (tryCreateDir(outSrc)) {
|
|
2984
2992
|
this.emit('dir:create', outSrc, options);
|
|
@@ -3027,7 +3035,7 @@ class Module extends EventEmitter {
|
|
|
3027
3035
|
if (callback) {
|
|
3028
3036
|
result.catch((err) => callback(errorCheck(err, outSrc)));
|
|
3029
3037
|
}
|
|
3030
|
-
return promises ? result :
|
|
3038
|
+
return promises ? result : void 0;
|
|
3031
3039
|
}
|
|
3032
3040
|
const failed = tryRemoveDir(outSrc, emptyDir, !!recursive);
|
|
3033
3041
|
if (failed.length === 0) {
|
|
@@ -3145,7 +3153,7 @@ class Module extends EventEmitter {
|
|
|
3145
3153
|
}
|
|
3146
3154
|
else {
|
|
3147
3155
|
setCpuAndMem.call(this, options);
|
|
3148
|
-
relayMessage
|
|
3156
|
+
relayMessage(this, args);
|
|
3149
3157
|
}
|
|
3150
3158
|
if (!options.bypassLog) {
|
|
3151
3159
|
this.addLog(types_1.STATUS_TYPE.INFO, title + ' -> ' + value, Date.now(), duration);
|
|
@@ -3182,7 +3190,7 @@ class Module extends EventEmitter {
|
|
|
3182
3190
|
this._logQueued.push(args);
|
|
3183
3191
|
}
|
|
3184
3192
|
else {
|
|
3185
|
-
relayMessage
|
|
3193
|
+
relayMessage(this, args);
|
|
3186
3194
|
}
|
|
3187
3195
|
}
|
|
3188
3196
|
formatFail(type, title, value, message, options = {}) {
|
|
@@ -3322,7 +3330,7 @@ class Module extends EventEmitter {
|
|
|
3322
3330
|
this._logQueued.push(args);
|
|
3323
3331
|
}
|
|
3324
3332
|
else {
|
|
3325
|
-
relayMessage
|
|
3333
|
+
relayMessage(this, args);
|
|
3326
3334
|
}
|
|
3327
3335
|
}
|
|
3328
3336
|
checkPackage(err, name, value, options) {
|
|
@@ -3478,7 +3486,7 @@ class Module extends EventEmitter {
|
|
|
3478
3486
|
}
|
|
3479
3487
|
args = [args[0], '', this.supports('stripAnsi') ? stripansi(args[1]) : args[1], null, applyLogId.call(this, { sessionId: '' })];
|
|
3480
3488
|
}
|
|
3481
|
-
|
|
3489
|
+
relayMessage(this, args);
|
|
3482
3490
|
});
|
|
3483
3491
|
logQueued.length = 0;
|
|
3484
3492
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "Module base class for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "BSD 3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/types": "0.9.
|
|
23
|
+
"@e-mc/types": "0.9.5",
|
|
24
24
|
"chalk": "4.1.2",
|
|
25
25
|
"file-type": "16.5.4",
|
|
26
26
|
"js-yaml": "^4.1.0",
|