@e-mc/module 0.13.5 → 0.13.6
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 +8 -7
- package/index.js +27 -8
- 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.13.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.13.6/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -35,7 +35,7 @@ interface IModule extends EventEmitter, IAbortComponent {
|
|
|
35
35
|
readonly status: LogStatus<StatusType>[];
|
|
36
36
|
readonly errors: unknown[];
|
|
37
37
|
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
38
|
-
supports(name: string, value?: boolean): boolean;
|
|
38
|
+
supports(name: string, value?: boolean, locked?: boolean): boolean;
|
|
39
39
|
getTempDir(options: TempDirOptions): string;
|
|
40
40
|
getTempDir(uuidDir: boolean, createDir: boolean): string;
|
|
41
41
|
getTempDir(pathname: string, createDir: boolean): string;
|
|
@@ -247,6 +247,7 @@ interface ModuleConstructor {
|
|
|
247
247
|
purgeMemory(percent: number, parent: boolean): Promise<number>;
|
|
248
248
|
purgeMemory(percent: number, limit: number, parent?: boolean): Promise<number>;
|
|
249
249
|
purgeMemory(percent?: number, limit?: number | boolean, parent?: unknown): Promise<number>;
|
|
250
|
+
availableParallelism(factor?: number): number;
|
|
250
251
|
canWrite(name: "temp" | "home"): boolean;
|
|
251
252
|
loadSettings(settings: Settings, password?: string): boolean;
|
|
252
253
|
readonly prototype: IModule<IHost>;
|
|
@@ -421,11 +422,11 @@ interface LoggerModule {
|
|
|
421
422
|
|
|
422
423
|
## References
|
|
423
424
|
|
|
424
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
425
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
426
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
427
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
428
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
425
|
+
- https://www.unpkg.com/@e-mc/types@0.13.6/lib/core.d.ts
|
|
426
|
+
- https://www.unpkg.com/@e-mc/types@0.13.6/lib/logger.d.ts
|
|
427
|
+
- https://www.unpkg.com/@e-mc/types@0.13.6/lib/module.d.ts
|
|
428
|
+
- https://www.unpkg.com/@e-mc/types@0.13.6/lib/node.d.ts
|
|
429
|
+
- https://www.unpkg.com/@e-mc/types@0.13.6/lib/settings.d.ts
|
|
429
430
|
|
|
430
431
|
* https://www.npmjs.com/package/@types/node
|
|
431
432
|
|
package/index.js
CHANGED
|
@@ -878,7 +878,7 @@ class Module extends EventEmitter {
|
|
|
878
878
|
static LOG_STYLE_NOTICE = Object.freeze({ titleBgColor: 'bgGrey', titleColor: 'white' });
|
|
879
879
|
static LOG_STYLE_REVERSE = Object.freeze({ titleBgColor: 'bgWhite', titleColor: 'black', messageBgColor: 'bgGrey' });
|
|
880
880
|
static get VERSION() {
|
|
881
|
-
return "0.13.
|
|
881
|
+
return "0.13.6";
|
|
882
882
|
}
|
|
883
883
|
static get LOG_TYPE() {
|
|
884
884
|
return types_1.LOG_TYPE;
|
|
@@ -2302,6 +2302,9 @@ class Module extends EventEmitter {
|
|
|
2302
2302
|
}
|
|
2303
2303
|
return result;
|
|
2304
2304
|
}
|
|
2305
|
+
static availableParallelism(factor = 1) {
|
|
2306
|
+
return Math.ceil(((0, types_1.supported)(19, 4) || (0, types_1.supported)(18, 14, true) ? os.availableParallelism() : os.cpus().length) * factor);
|
|
2307
|
+
}
|
|
2305
2308
|
static canWrite(name) {
|
|
2306
2309
|
switch (name) {
|
|
2307
2310
|
case 'temp':
|
|
@@ -2699,20 +2702,27 @@ class Module extends EventEmitter {
|
|
|
2699
2702
|
#tempDir = VALUES["temp.dir"];
|
|
2700
2703
|
#broadcastId = '';
|
|
2701
2704
|
#permission = null;
|
|
2702
|
-
#supports = { stripAnsi: { value: true, modified: false } };
|
|
2705
|
+
#supports = { stripAnsi: { value: true, modified: false, locked: false } };
|
|
2703
2706
|
#abortController = new AbortController();
|
|
2704
2707
|
#abortEvent = null;
|
|
2705
2708
|
supported(major, minor, patch, lts) {
|
|
2706
2709
|
return (0, types_1.supported)(major, minor, patch, lts);
|
|
2707
2710
|
}
|
|
2708
|
-
supports(name, value) {
|
|
2711
|
+
supports(name, value, locked) {
|
|
2709
2712
|
if (typeof value === 'boolean') {
|
|
2710
|
-
this.#supports[name]
|
|
2713
|
+
const item = this.#supports[name];
|
|
2714
|
+
if (item?.locked) {
|
|
2715
|
+
return item.value;
|
|
2716
|
+
}
|
|
2717
|
+
this.#supports[name] = { value, modified: true, locked: !!locked };
|
|
2711
2718
|
return value;
|
|
2712
2719
|
}
|
|
2713
2720
|
const host = this.host;
|
|
2714
2721
|
const item = this.#supports[name];
|
|
2715
|
-
|
|
2722
|
+
if (item && (item.modified || !host)) {
|
|
2723
|
+
return item.value;
|
|
2724
|
+
}
|
|
2725
|
+
return host ? host.supports(name) : false;
|
|
2716
2726
|
}
|
|
2717
2727
|
getTempDir(pathname, filename, createDir) {
|
|
2718
2728
|
let increment = 0, moduleDir, uuidDir;
|
|
@@ -3855,6 +3865,9 @@ class Module extends EventEmitter {
|
|
|
3855
3865
|
}
|
|
3856
3866
|
return options;
|
|
3857
3867
|
}
|
|
3868
|
+
#supportsProperty(name) {
|
|
3869
|
+
return !(name in this.#supports) || this.supports(name);
|
|
3870
|
+
}
|
|
3858
3871
|
get moduleName() {
|
|
3859
3872
|
return this._moduleName;
|
|
3860
3873
|
}
|
|
@@ -3884,19 +3897,25 @@ class Module extends EventEmitter {
|
|
|
3884
3897
|
return this._host;
|
|
3885
3898
|
}
|
|
3886
3899
|
set sessionId(value) {
|
|
3887
|
-
this.#sessionId
|
|
3900
|
+
if (this.#supportsProperty('sessionId')) {
|
|
3901
|
+
this.#sessionId = value;
|
|
3902
|
+
}
|
|
3888
3903
|
}
|
|
3889
3904
|
get sessionId() {
|
|
3890
3905
|
return this.#sessionId || this.host?.sessionId || '';
|
|
3891
3906
|
}
|
|
3892
3907
|
set broadcastId(value) {
|
|
3893
|
-
this.#broadcastId
|
|
3908
|
+
if (this.#supportsProperty('broadcastId')) {
|
|
3909
|
+
this.#broadcastId = value;
|
|
3910
|
+
}
|
|
3894
3911
|
}
|
|
3895
3912
|
get broadcastId() {
|
|
3896
3913
|
return this.#broadcastId || this.host?.broadcastId || '';
|
|
3897
3914
|
}
|
|
3898
3915
|
set permission(value) {
|
|
3899
|
-
this.#permission
|
|
3916
|
+
if (this.#supportsProperty('permission')) {
|
|
3917
|
+
this.#permission = value;
|
|
3918
|
+
}
|
|
3900
3919
|
}
|
|
3901
3920
|
get permission() {
|
|
3902
3921
|
return this.#permission || this.host?.permission || null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.6",
|
|
4
4
|
"description": "Module base class for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
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.6",
|
|
23
23
|
"chalk": "4.1.2",
|
|
24
24
|
"file-type": "^20.5.0",
|
|
25
25
|
"js-yaml": "^4.1.1",
|