@e-mc/module 0.13.9 → 0.13.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 +7 -7
- package/index.js +16 -12
- 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.10/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -433,12 +433,12 @@ interface LoggerModule {
|
|
|
433
433
|
|
|
434
434
|
## References
|
|
435
435
|
|
|
436
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
437
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
438
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
439
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
440
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
441
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
436
|
+
- https://www.unpkg.com/@e-mc/types@0.13.10/lib/squared.d.ts
|
|
437
|
+
- https://www.unpkg.com/@e-mc/types@0.13.10/lib/core.d.ts
|
|
438
|
+
- https://www.unpkg.com/@e-mc/types@0.13.10/lib/logger.d.ts
|
|
439
|
+
- https://www.unpkg.com/@e-mc/types@0.13.10/lib/module.d.ts
|
|
440
|
+
- https://www.unpkg.com/@e-mc/types@0.13.10/lib/node.d.ts
|
|
441
|
+
- https://www.unpkg.com/@e-mc/types@0.13.10/lib/settings.d.ts
|
|
442
442
|
|
|
443
443
|
* https://www.npmjs.com/package/@types/node
|
|
444
444
|
* https://www.npmjs.com/package/file-type
|
package/index.js
CHANGED
|
@@ -18,7 +18,7 @@ const PROCESS_CWD = process.cwd();
|
|
|
18
18
|
const PROCESS_STDOUT = process.stdout;
|
|
19
19
|
const PLATFORM_WIN32 = process.platform === 'win32';
|
|
20
20
|
const OS_HOMEDIR = os.homedir();
|
|
21
|
-
const MEM_TOTAL =
|
|
21
|
+
const MEM_TOTAL = os.totalmem();
|
|
22
22
|
const CPU_CORETOTAL = os.cpus().length;
|
|
23
23
|
const SUPPORTED_CPUTHREAD = (0, types_1.supported)(23, 9);
|
|
24
24
|
const SUPPORTED_CANPARSE = (0, types_1.supported)(19, 9) || (0, types_1.supported)(18, 17, true);
|
|
@@ -691,14 +691,14 @@ function withinDir(value, base, override = false) {
|
|
|
691
691
|
return value.startsWith(base) && (value !== base || override);
|
|
692
692
|
}
|
|
693
693
|
function formatPercent(value, precision) {
|
|
694
|
-
if (value <= 0) {
|
|
694
|
+
if (value <= 0.0001) {
|
|
695
695
|
return '0%';
|
|
696
696
|
}
|
|
697
697
|
if (value === (value | 0)) {
|
|
698
698
|
return value + '00%';
|
|
699
699
|
}
|
|
700
700
|
value *= 100;
|
|
701
|
-
return value.toPrecision(value < 1 ? 2 : precision) + '%';
|
|
701
|
+
return value.toPrecision(value < 0.001 ? 1 : value < 1 ? 2 : precision) + '%';
|
|
702
702
|
}
|
|
703
703
|
function relayMessage(instance, args) {
|
|
704
704
|
const host = instance.host || instance;
|
|
@@ -879,7 +879,7 @@ class Module extends EventEmitter {
|
|
|
879
879
|
static LOG_STYLE_NOTICE = Object.freeze({ titleBgColor: 'bgGrey', titleColor: 'white' });
|
|
880
880
|
static LOG_STYLE_REVERSE = Object.freeze({ titleBgColor: 'bgWhite', titleColor: 'black', messageBgColor: 'bgGrey' });
|
|
881
881
|
static get VERSION() {
|
|
882
|
-
return "0.13.
|
|
882
|
+
return "0.13.10";
|
|
883
883
|
}
|
|
884
884
|
static get LOG_TYPE() {
|
|
885
885
|
return types_1.LOG_TYPE;
|
|
@@ -1287,10 +1287,14 @@ class Module extends EventEmitter {
|
|
|
1287
1287
|
}
|
|
1288
1288
|
this.formatMessage(((type || 1) | 512), "FAIL!", value, message, applyStyle(options, this.LOG_STYLE_FAIL));
|
|
1289
1289
|
}
|
|
1290
|
-
static parseFunction(value,
|
|
1291
|
-
let context, requireExt, external;
|
|
1292
|
-
if (
|
|
1293
|
-
|
|
1290
|
+
static parseFunction(value, options, sync = true) {
|
|
1291
|
+
let context, requireExt, absolute, external;
|
|
1292
|
+
if (typeof options === 'boolean') {
|
|
1293
|
+
absolute = options;
|
|
1294
|
+
options = undefined;
|
|
1295
|
+
}
|
|
1296
|
+
else if (options) {
|
|
1297
|
+
({ context, requireExt, external, absolute, sync = true } = options);
|
|
1294
1298
|
}
|
|
1295
1299
|
if (requireExt === undefined || requireExt === true) {
|
|
1296
1300
|
requireExt = VALUES["node.require.ext"];
|
|
@@ -1304,7 +1308,7 @@ class Module extends EventEmitter {
|
|
|
1304
1308
|
else if (pathname = absolute && path.isAbsolute(location) ? location : this.fromLocalPath(location)) {
|
|
1305
1309
|
if (requireExt && VALUES["node.require.ext"] && hasString(requireExt, getExtension(pathname))) {
|
|
1306
1310
|
try {
|
|
1307
|
-
result = checkFunction(require(pathname));
|
|
1311
|
+
result = checkFunction(options?.default ? (0, types_1.requireESM)(pathname, options.url) : require(pathname));
|
|
1308
1312
|
}
|
|
1309
1313
|
catch {
|
|
1310
1314
|
}
|
|
@@ -1318,7 +1322,7 @@ class Module extends EventEmitter {
|
|
|
1318
1322
|
}
|
|
1319
1323
|
if (external && !pathname && VALUES["node.require.npm"] && /^(?:@[a-z\d-*~][a-z\d-*._~]*\/|node:)?[a-z\d-~][a-z\d-._~]*(?:\/.*)?$/.test(location)) {
|
|
1320
1324
|
try {
|
|
1321
|
-
result = checkFunction(require(location));
|
|
1325
|
+
result = checkFunction(options?.default ? (0, types_1.requireESM)(location, options.url) : require(location));
|
|
1322
1326
|
}
|
|
1323
1327
|
catch {
|
|
1324
1328
|
}
|
|
@@ -1854,7 +1858,7 @@ class Module extends EventEmitter {
|
|
|
1854
1858
|
if (!this.isDir(outDir)) {
|
|
1855
1859
|
return Promise.reject(errorDirectory(asFile(src) || "Unknown"));
|
|
1856
1860
|
}
|
|
1857
|
-
const pmOpts = PLATFORM_WIN32 ? { nocase: true,
|
|
1861
|
+
const pmOpts = PLATFORM_WIN32 ? { nocase: true, windows: true } : {};
|
|
1858
1862
|
let exclude, excludeDir, recursive;
|
|
1859
1863
|
if ((0, types_1.isObject)(options)) {
|
|
1860
1864
|
if (options.matchBase) {
|
|
@@ -2854,7 +2858,7 @@ class Module extends EventEmitter {
|
|
|
2854
2858
|
}
|
|
2855
2859
|
if (!result) {
|
|
2856
2860
|
try {
|
|
2857
|
-
result = require(outSrc);
|
|
2861
|
+
result = options.default ? (0, types_1.requireESM)(outSrc, options.url) : require(outSrc);
|
|
2858
2862
|
setCache(result, true);
|
|
2859
2863
|
checkFunction(result);
|
|
2860
2864
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.10",
|
|
4
4
|
"description": "Module base class for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"license": "BSD-3-Clause",
|
|
20
20
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@e-mc/types": "0.13.
|
|
22
|
+
"@e-mc/types": "0.13.10",
|
|
23
23
|
"chalk": "4.1.2",
|
|
24
24
|
"file-type": "^20.5.0",
|
|
25
25
|
"js-yaml": "^4.1.1",
|
|
26
26
|
"mime-types": "^3.0.2",
|
|
27
|
-
"picomatch": "^4.0.
|
|
27
|
+
"picomatch": "^4.0.4"
|
|
28
28
|
}
|
|
29
29
|
}
|