@e-mc/module 0.11.8 → 0.11.10
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 +30 -32
- 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.11.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.11.10/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -414,11 +414,11 @@ interface LoggerModule {
|
|
|
414
414
|
|
|
415
415
|
## References
|
|
416
416
|
|
|
417
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
418
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
419
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
420
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
421
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
417
|
+
- https://www.unpkg.com/@e-mc/types@0.11.10/lib/core.d.ts
|
|
418
|
+
- https://www.unpkg.com/@e-mc/types@0.11.10/lib/logger.d.ts
|
|
419
|
+
- https://www.unpkg.com/@e-mc/types@0.11.10/lib/module.d.ts
|
|
420
|
+
- https://www.unpkg.com/@e-mc/types@0.11.10/lib/node.d.ts
|
|
421
|
+
- https://www.unpkg.com/@e-mc/types@0.11.10/lib/settings.d.ts
|
|
422
422
|
|
|
423
423
|
* https://www.npmjs.com/package/@types/node
|
|
424
424
|
|
package/index.js
CHANGED
|
@@ -140,7 +140,6 @@ const MEMORY_CACHE_DISK = {
|
|
|
140
140
|
include: null,
|
|
141
141
|
exclude: null
|
|
142
142
|
};
|
|
143
|
-
const SUPPORTED_CANPARSE = (0, types_1.supported)(19, 9) || (0, types_1.supported)(18, 17, true);
|
|
144
143
|
const REGEXP_TORRENT = /^(?:magnet:\?xt=|(?:https?|s?ftp):\/\/[^/][^\n]*?\.(?:torrent|metalink|meta4)(?:\?[^\n]*)?$)/i;
|
|
145
144
|
const REGEXP_PROTOCOL = /^([a-z][a-z\d+-.]*):\/\/[^@:[\]\\^<>|\s]/i;
|
|
146
145
|
const REGEXP_CLIESCAPE = /[^\w+-.,/:@]/g;
|
|
@@ -984,7 +983,7 @@ class Module extends EventEmitter {
|
|
|
984
983
|
this[_g] = null;
|
|
985
984
|
}
|
|
986
985
|
static get VERSION() {
|
|
987
|
-
return "0.11.
|
|
986
|
+
return "0.11.10";
|
|
988
987
|
}
|
|
989
988
|
static get LOG_TYPE() {
|
|
990
989
|
return types_1.LOG_TYPE;
|
|
@@ -1486,35 +1485,35 @@ class Module extends EventEmitter {
|
|
|
1486
1485
|
return cacheKey ? crypto.randomUUID() : '';
|
|
1487
1486
|
}
|
|
1488
1487
|
static asHash(data, algorithm, digest) {
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
let options;
|
|
1493
|
-
if ((0, types_1.isObject)(algorithm)) {
|
|
1494
|
-
options = { ...algorithm };
|
|
1495
|
-
if ('algorithm' in options) {
|
|
1496
|
-
algorithm = options.algorithm;
|
|
1497
|
-
delete options.algorithm;
|
|
1488
|
+
try {
|
|
1489
|
+
if (!algorithm && !digest) {
|
|
1490
|
+
return crypto.createHash("sha256").update(data).digest("hex");
|
|
1498
1491
|
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1492
|
+
let options;
|
|
1493
|
+
if ((0, types_1.isObject)(algorithm)) {
|
|
1494
|
+
options = { ...algorithm };
|
|
1495
|
+
if ('algorithm' in options) {
|
|
1496
|
+
algorithm = options.algorithm;
|
|
1497
|
+
delete options.algorithm;
|
|
1498
|
+
}
|
|
1499
|
+
else {
|
|
1500
|
+
algorithm = undefined;
|
|
1501
|
+
}
|
|
1502
|
+
if ('digest' in options) {
|
|
1503
|
+
digest = options.digest;
|
|
1504
|
+
delete options.digest;
|
|
1505
|
+
}
|
|
1506
|
+
else {
|
|
1507
|
+
digest = undefined;
|
|
1508
|
+
}
|
|
1501
1509
|
}
|
|
1502
|
-
if (
|
|
1503
|
-
|
|
1504
|
-
|
|
1510
|
+
else if ((0, types_1.isObject)(digest)) {
|
|
1511
|
+
options = digest;
|
|
1512
|
+
digest = undefined;
|
|
1505
1513
|
}
|
|
1506
|
-
else {
|
|
1514
|
+
else if (typeof digest !== 'string') {
|
|
1507
1515
|
digest = undefined;
|
|
1508
1516
|
}
|
|
1509
|
-
}
|
|
1510
|
-
else if ((0, types_1.isObject)(digest)) {
|
|
1511
|
-
options = digest;
|
|
1512
|
-
digest = undefined;
|
|
1513
|
-
}
|
|
1514
|
-
else if (typeof digest !== 'string') {
|
|
1515
|
-
digest = undefined;
|
|
1516
|
-
}
|
|
1517
|
-
try {
|
|
1518
1517
|
return crypto.createHash(algorithm || "sha256", options).update(data).digest(digest || "hex");
|
|
1519
1518
|
}
|
|
1520
1519
|
catch {
|
|
@@ -1586,9 +1585,6 @@ class Module extends EventEmitter {
|
|
|
1586
1585
|
return filename || '';
|
|
1587
1586
|
}
|
|
1588
1587
|
static isURL(value, ...exclude) {
|
|
1589
|
-
if (exclude.length === 0 && SUPPORTED_CANPARSE) {
|
|
1590
|
-
return URL.canParse(value);
|
|
1591
|
-
}
|
|
1592
1588
|
const match = REGEXP_PROTOCOL.exec(value);
|
|
1593
1589
|
return !!match && !exclude.includes(match[1].toLowerCase());
|
|
1594
1590
|
}
|
|
@@ -1711,11 +1707,13 @@ class Module extends EventEmitter {
|
|
|
1711
1707
|
if (typeof values[values.length - 1] === 'boolean') {
|
|
1712
1708
|
normalize = values.pop();
|
|
1713
1709
|
}
|
|
1714
|
-
const paths = values.
|
|
1710
|
+
const paths = values.filter(item => (0, types_1.isString)(item)).map(value => this.toPosix(value, normalize));
|
|
1715
1711
|
let result = paths[0] || '';
|
|
1716
1712
|
for (let i = 1; i < paths.length; ++i) {
|
|
1717
1713
|
const trailing = paths[i];
|
|
1718
|
-
|
|
1714
|
+
if (trailing) {
|
|
1715
|
+
result += (!trailing.startsWith('/') && !result.endsWith('/') ? '/' : '') + trailing;
|
|
1716
|
+
}
|
|
1719
1717
|
}
|
|
1720
1718
|
return result;
|
|
1721
1719
|
}
|
|
@@ -2812,7 +2810,7 @@ class Module extends EventEmitter {
|
|
|
2812
2810
|
dir = dir.substring(ensureDir(PROCESS_CWD).length);
|
|
2813
2811
|
}
|
|
2814
2812
|
else {
|
|
2815
|
-
this.formatMessage(1, "WARN!",
|
|
2813
|
+
this.formatMessage(1, "WARN!", "Not permitted to set absolute path", dir, { ...this.LOG_STYLE_WARN, newline: true });
|
|
2816
2814
|
dir = VALUES["temp.dir"];
|
|
2817
2815
|
}
|
|
2818
2816
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.10",
|
|
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.11.
|
|
23
|
+
"@e-mc/types": "0.11.10",
|
|
24
24
|
"chalk": "4.1.2",
|
|
25
25
|
"file-type": "^18.7.0",
|
|
26
26
|
"js-yaml": "^4.1.0",
|