@e-mc/module 0.10.7 → 0.10.9
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 +16 -31
- 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.10.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.10.9/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -407,11 +407,11 @@ interface LoggerModule {
|
|
|
407
407
|
|
|
408
408
|
## References
|
|
409
409
|
|
|
410
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
411
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
412
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
413
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
414
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
410
|
+
- https://www.unpkg.com/@e-mc/types@0.10.9/lib/core.d.ts
|
|
411
|
+
- https://www.unpkg.com/@e-mc/types@0.10.9/lib/logger.d.ts
|
|
412
|
+
- https://www.unpkg.com/@e-mc/types@0.10.9/lib/module.d.ts
|
|
413
|
+
- https://www.unpkg.com/@e-mc/types@0.10.9/lib/node.d.ts
|
|
414
|
+
- https://www.unpkg.com/@e-mc/types@0.10.9/lib/settings.d.ts
|
|
415
415
|
|
|
416
416
|
* https://www.npmjs.com/package/@types/node
|
|
417
417
|
|
package/index.js
CHANGED
|
@@ -142,7 +142,7 @@ const SUPPORTED_CANPARSE = (0, types_1.supported)(19, 9) || (0, types_1.supporte
|
|
|
142
142
|
const REGEXP_TORRENT = /^(?:magnet:\?xt=|(?:https?|s?ftp):\/\/[^/][^\n]*?\.(?:torrent|metalink|meta4)(?:\?[^\n]*)?$)/i;
|
|
143
143
|
const REGEXP_PROTOCOL = /^([a-z][a-z\d+-.]*):\/\/[^@:[\]\\^<>|\s]/i;
|
|
144
144
|
const REGEXP_CLIESCAPE = /[^\w+-.,/:@]/g;
|
|
145
|
-
const REGEXP_CLIOPTION = /^(-[^\s=]+|--[^-\s=][^\s=]*)(=)?\s*(.*)
|
|
145
|
+
const REGEXP_CLIOPTION = /^(-[^\s=]+|--[^-\s=][^\s=]*)(=)?\s*(.*)$/s;
|
|
146
146
|
const REGEXP_ANSIESCAPE = /[\u001B\u009B]/;
|
|
147
147
|
const LOG_CPUBARCOLOR = SETTINGS.process.cpu_bar_color;
|
|
148
148
|
const LOG_DIVIDER = chalk.blackBright('|');
|
|
@@ -917,11 +917,10 @@ function truncateStart(value, length = LOG_MIN_WIDTH, style = false) {
|
|
|
917
917
|
function truncateEnd(value, length) {
|
|
918
918
|
return (REGEXP_ANSIESCAPE.test(value) ? stripansi(value) : value).length > length ? '...' + value.substring(value.length - length + 3) : value;
|
|
919
919
|
}
|
|
920
|
-
const escapeArg = (value) => value.replace(REGEXP_CLIESCAPE, capture => capture === '\n' ? "'\n'" : (capture === '$' || capture === '`' ? '\\' : '') + '\\' + capture);
|
|
921
920
|
const isMeterUnit = (type, ident) => (type & 256) === 256 && !ident;
|
|
922
921
|
const formatLogMessage = (type, message, unit, ident) => isMeterUnit(type, ident) ? (unit + LOG_DIVIDER + message).trimEnd() : unit ? (message + (ident ? '' : ' ') + unit).trimStart() : message;
|
|
923
922
|
const hideAbort = (err) => err.name === 'AbortError' && SETTINGS.abort === false;
|
|
924
|
-
const asFile = (value) => typeof value === 'string' ? value.trim() : value instanceof URL && value.protocol === 'file:' ? (0, url_1.fileURLToPath)(value) : '';
|
|
923
|
+
const asFile = (value) => typeof value === 'string' ? PLATFORM_WIN32 ? value.trim() : value : value instanceof URL && value.protocol === 'file:' ? (0, url_1.fileURLToPath)(value) : '';
|
|
925
924
|
const wrapQuote = (value) => '"' + value.replaceAll('"', '\\"') + '"';
|
|
926
925
|
const isFunction = (value) => typeof value === 'function';
|
|
927
926
|
const isFileURL = (value) => /^file:\/\//i.test(value);
|
|
@@ -961,7 +960,7 @@ class Module extends EventEmitter {
|
|
|
961
960
|
this[_g] = null;
|
|
962
961
|
}
|
|
963
962
|
static get VERSION() {
|
|
964
|
-
return "0.10.
|
|
963
|
+
return "0.10.9";
|
|
965
964
|
}
|
|
966
965
|
static get LOG_TYPE() {
|
|
967
966
|
return types_1.LOG_TYPE;
|
|
@@ -1049,7 +1048,7 @@ class Module extends EventEmitter {
|
|
|
1049
1048
|
if (error && hideAbort(message)) {
|
|
1050
1049
|
return;
|
|
1051
1050
|
}
|
|
1052
|
-
if (options.type) {
|
|
1051
|
+
if (typeof options.type === 'number') {
|
|
1053
1052
|
type |= options.type;
|
|
1054
1053
|
}
|
|
1055
1054
|
const BROADCAST_OUT = VALUES["broadcast.out"];
|
|
@@ -1534,7 +1533,7 @@ class Module extends EventEmitter {
|
|
|
1534
1533
|
filename = undefined;
|
|
1535
1534
|
}
|
|
1536
1535
|
if (typeof value === 'string') {
|
|
1537
|
-
let pathname = value.trim(), convert = true;
|
|
1536
|
+
let pathname = PLATFORM_WIN32 ? value.trim() : value, convert = true;
|
|
1538
1537
|
if (normalize) {
|
|
1539
1538
|
pathname = path.normalize(pathname);
|
|
1540
1539
|
convert = PLATFORM_WIN32;
|
|
@@ -1649,7 +1648,7 @@ class Module extends EventEmitter {
|
|
|
1649
1648
|
return false;
|
|
1650
1649
|
}
|
|
1651
1650
|
static resolveFile(value) {
|
|
1652
|
-
if (isFileURL(value = value instanceof URL ? value.toString() : value
|
|
1651
|
+
if (isFileURL(value = value instanceof URL ? value.toString() : value)) {
|
|
1653
1652
|
try {
|
|
1654
1653
|
return (0, url_1.fileURLToPath)(value);
|
|
1655
1654
|
}
|
|
@@ -1664,7 +1663,7 @@ class Module extends EventEmitter {
|
|
|
1664
1663
|
}
|
|
1665
1664
|
static resolvePath(value, base) {
|
|
1666
1665
|
try {
|
|
1667
|
-
if (this.isURL(value
|
|
1666
|
+
if (this.isURL(value)) {
|
|
1668
1667
|
return isFileURL(value) ? (0, url_1.fileURLToPath)(value) : new URL(value).href;
|
|
1669
1668
|
}
|
|
1670
1669
|
if (base instanceof URL || this.isURL(base)) {
|
|
@@ -1696,7 +1695,7 @@ class Module extends EventEmitter {
|
|
|
1696
1695
|
flags = flags ? 2 : 0;
|
|
1697
1696
|
}
|
|
1698
1697
|
if (typeof value === 'string') {
|
|
1699
|
-
let result = value.trim();
|
|
1698
|
+
let result = PLATFORM_WIN32 ? value.trim() : value;
|
|
1700
1699
|
result = flags & 1 ? path.resolve(result) : path.normalize(result);
|
|
1701
1700
|
if ((flags & 2) && result.length > 0) {
|
|
1702
1701
|
result = ensureDir(result);
|
|
@@ -2353,7 +2352,7 @@ class Module extends EventEmitter {
|
|
|
2353
2352
|
value = opt[3];
|
|
2354
2353
|
}
|
|
2355
2354
|
if (value) {
|
|
2356
|
-
const quoted = /^(["'])(.*)\1
|
|
2355
|
+
const quoted = /^(["'])(.*)\1$/s.exec(value);
|
|
2357
2356
|
if (PLATFORM_WIN32) {
|
|
2358
2357
|
if (quoted) {
|
|
2359
2358
|
if (quoted[1] === '"') {
|
|
@@ -2366,33 +2365,19 @@ class Module extends EventEmitter {
|
|
|
2366
2365
|
value = wrapQuote(value);
|
|
2367
2366
|
}
|
|
2368
2367
|
}
|
|
2369
|
-
else {
|
|
2370
|
-
let type = doubleQuote;
|
|
2371
|
-
if (quoted) {
|
|
2372
|
-
if (quoted[1] === "'") {
|
|
2373
|
-
result[i] = leading + value;
|
|
2374
|
-
continue;
|
|
2375
|
-
}
|
|
2376
|
-
value = quoted[2];
|
|
2377
|
-
type = true;
|
|
2378
|
-
}
|
|
2368
|
+
else if (!quoted) {
|
|
2379
2369
|
if (REGEXP_CLIESCAPE.test(value)) {
|
|
2380
|
-
|
|
2381
|
-
value = '"' + escapeArg(value) + '"';
|
|
2382
|
-
}
|
|
2383
|
-
else {
|
|
2384
|
-
value = "'" + value.replaceAll("'", "'\\''") + "'";
|
|
2385
|
-
}
|
|
2370
|
+
value = doubleQuote ? `"${value.replace(/(?<!\\)"/g, '\\"')}"` : `'${value.replaceAll("'", "'\\''")}'`;
|
|
2386
2371
|
}
|
|
2387
2372
|
else if (RESERVED_SHELL.includes(value)) {
|
|
2388
|
-
value =
|
|
2373
|
+
value = `'${value}'`;
|
|
2389
2374
|
}
|
|
2390
2375
|
}
|
|
2391
2376
|
}
|
|
2392
2377
|
else if (opt) {
|
|
2393
2378
|
leading = leading.trim();
|
|
2394
2379
|
if (!PLATFORM_WIN32 && leading.length > 2 && leading[1] !== '-') {
|
|
2395
|
-
leading
|
|
2380
|
+
leading.replace(REGEXP_CLIESCAPE, capture => '\\' + capture);
|
|
2396
2381
|
}
|
|
2397
2382
|
}
|
|
2398
2383
|
}
|
|
@@ -3671,12 +3656,12 @@ class Module extends EventEmitter {
|
|
|
3671
3656
|
}
|
|
3672
3657
|
}
|
|
3673
3658
|
writeLog(type, value, timeStamp, duration) {
|
|
3674
|
-
let queue;
|
|
3659
|
+
let queue = false;
|
|
3675
3660
|
if ((0, types_1.isObject)(type)) {
|
|
3676
3661
|
if (typeof value === 'boolean') {
|
|
3677
3662
|
queue = value;
|
|
3678
3663
|
}
|
|
3679
|
-
|
|
3664
|
+
value = type.value;
|
|
3680
3665
|
}
|
|
3681
3666
|
const output = Module.asString(value);
|
|
3682
3667
|
if (output) {
|
|
@@ -3704,7 +3689,7 @@ class Module extends EventEmitter {
|
|
|
3704
3689
|
from = timeStamp;
|
|
3705
3690
|
timeStamp = 0;
|
|
3706
3691
|
}
|
|
3707
|
-
else if ((0, types_1.
|
|
3692
|
+
else if ((0, types_1.isPlainObject)(timeStamp)) {
|
|
3708
3693
|
({ timeStamp, duration, from, source } = timeStamp);
|
|
3709
3694
|
}
|
|
3710
3695
|
const name = types_1.STATUS_TYPE[type] || types_1.STATUS_TYPE[type = 0];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.9",
|
|
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.10.
|
|
23
|
+
"@e-mc/types": "0.10.9",
|
|
24
24
|
"chalk": "4.1.2",
|
|
25
25
|
"file-type": "^18.7.0",
|
|
26
26
|
"js-yaml": "^4.1.0",
|