@e-mc/module 0.5.3 → 0.6.0
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/index.js +37 -33
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -558,7 +558,7 @@ class Module extends EventEmitter {
|
|
|
558
558
|
this[_f] = new AbortController();
|
|
559
559
|
this[_g] = null;
|
|
560
560
|
}
|
|
561
|
-
static get VERSION() { return "0.
|
|
561
|
+
static get VERSION() { return "0.6.0" /* INTERNAL.VERSION */; }
|
|
562
562
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
563
563
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
564
564
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -1068,7 +1068,10 @@ class Module extends EventEmitter {
|
|
|
1068
1068
|
return cacheKey ? (0, types_1.generateUUID)() : '';
|
|
1069
1069
|
}
|
|
1070
1070
|
static asHash(data, algorithm, minLength = 0) {
|
|
1071
|
-
|
|
1071
|
+
if (!algorithm && !minLength) {
|
|
1072
|
+
return crypto.createHash('sha256').update(data).digest('hex');
|
|
1073
|
+
}
|
|
1074
|
+
let options, digest;
|
|
1072
1075
|
if (typeof minLength !== 'number') {
|
|
1073
1076
|
options = minLength;
|
|
1074
1077
|
minLength = 0;
|
|
@@ -1081,7 +1084,6 @@ class Module extends EventEmitter {
|
|
|
1081
1084
|
options = algorithm;
|
|
1082
1085
|
algorithm = '';
|
|
1083
1086
|
}
|
|
1084
|
-
let digest;
|
|
1085
1087
|
if (options) {
|
|
1086
1088
|
options = { ...options };
|
|
1087
1089
|
if ('minLength' in options) {
|
|
@@ -1229,7 +1231,7 @@ class Module extends EventEmitter {
|
|
|
1229
1231
|
return '';
|
|
1230
1232
|
}
|
|
1231
1233
|
if (/^\\\\\?\\[A-Za-z]:\\/.test(value)) {
|
|
1232
|
-
return
|
|
1234
|
+
return PLATFORM_WIN32 && !/\\\\|\\\.+\\|\\[^\n]+?\.+\\/.test(value = value.substring(4)) ? value : '';
|
|
1233
1235
|
}
|
|
1234
1236
|
return this.fromLocalPath(value) || value;
|
|
1235
1237
|
}
|
|
@@ -3175,17 +3177,18 @@ class Module extends EventEmitter {
|
|
|
3175
3177
|
}
|
|
3176
3178
|
detach() {
|
|
3177
3179
|
const host = this.host;
|
|
3178
|
-
if (host) {
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
this
|
|
3180
|
+
if (!host) {
|
|
3181
|
+
return;
|
|
3182
|
+
}
|
|
3183
|
+
this.abortable = false;
|
|
3184
|
+
host.modules.delete(this);
|
|
3185
|
+
host.subProcesses.delete(this);
|
|
3186
|
+
const listener = this[kAbortEvent];
|
|
3187
|
+
if (listener) {
|
|
3188
|
+
host.signal.removeEventListener('abort', listener);
|
|
3189
|
+
this[kAbortEvent] = null;
|
|
3188
3190
|
}
|
|
3191
|
+
this._host = null;
|
|
3189
3192
|
}
|
|
3190
3193
|
abort() {
|
|
3191
3194
|
if (!this.aborted) {
|
|
@@ -3207,22 +3210,23 @@ class Module extends EventEmitter {
|
|
|
3207
3210
|
}
|
|
3208
3211
|
set host(value) {
|
|
3209
3212
|
this.detach();
|
|
3210
|
-
if (this._host = value) {
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3213
|
+
if (!(this._host = value)) {
|
|
3214
|
+
return;
|
|
3215
|
+
}
|
|
3216
|
+
this.sessionId = value.sessionId;
|
|
3217
|
+
this.broadcastId = value.broadcastId;
|
|
3218
|
+
this._logEnabled = value.willLog(this.moduleName);
|
|
3219
|
+
const aborting = this._hostEvents.includes('abort');
|
|
3220
|
+
if (value.aborted) {
|
|
3221
|
+
if (aborting) {
|
|
3222
|
+
this.abort();
|
|
3219
3223
|
}
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
}
|
|
3224
|
+
}
|
|
3225
|
+
else if (!value.subProcesses.has(this)) {
|
|
3226
|
+
this.abortable = value.willAbort(this);
|
|
3227
|
+
value.modules.add(this);
|
|
3228
|
+
if (aborting) {
|
|
3229
|
+
value.signal.addEventListener('abort', this[kAbortEvent] = () => this.abort(), { once: true });
|
|
3226
3230
|
}
|
|
3227
3231
|
}
|
|
3228
3232
|
}
|
|
@@ -3276,11 +3280,11 @@ class Module extends EventEmitter {
|
|
|
3276
3280
|
}
|
|
3277
3281
|
get logLevel() {
|
|
3278
3282
|
const value = this._logLevel;
|
|
3279
|
-
if (value
|
|
3280
|
-
|
|
3281
|
-
return host ? host.logLevel : 0;
|
|
3283
|
+
if (value !== -1) {
|
|
3284
|
+
return value;
|
|
3282
3285
|
}
|
|
3283
|
-
|
|
3286
|
+
const host = this.host;
|
|
3287
|
+
return host ? host.logLevel : 0;
|
|
3284
3288
|
}
|
|
3285
3289
|
get statusType() {
|
|
3286
3290
|
return types_1.STATUS_TYPE;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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.
|
|
23
|
+
"@e-mc/types": "0.6.0",
|
|
24
24
|
"abort-controller": "^3.0.0",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"event-target-shim": "^5.0.1",
|