@e-mc/module 0.5.4 → 0.6.1
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/LICENSE +1 -1
- package/README.md +1 -1
- package/index.js +38 -34
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2023
|
|
1
|
+
Copyright 2023 Studio Trigger
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -557,7 +557,7 @@ class Module extends EventEmitter {
|
|
|
557
557
|
this[_f] = new AbortController();
|
|
558
558
|
this[_g] = null;
|
|
559
559
|
}
|
|
560
|
-
static get VERSION() { return "0.
|
|
560
|
+
static get VERSION() { return "0.6.1"; }
|
|
561
561
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
562
562
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
563
563
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -1064,7 +1064,10 @@ class Module extends EventEmitter {
|
|
|
1064
1064
|
return cacheKey ? (0, types_1.generateUUID)() : '';
|
|
1065
1065
|
}
|
|
1066
1066
|
static asHash(data, algorithm, minLength = 0) {
|
|
1067
|
-
|
|
1067
|
+
if (!algorithm && !minLength) {
|
|
1068
|
+
return crypto.createHash('sha256').update(data).digest('hex');
|
|
1069
|
+
}
|
|
1070
|
+
let options, digest;
|
|
1068
1071
|
if (typeof minLength !== 'number') {
|
|
1069
1072
|
options = minLength;
|
|
1070
1073
|
minLength = 0;
|
|
@@ -1077,7 +1080,6 @@ class Module extends EventEmitter {
|
|
|
1077
1080
|
options = algorithm;
|
|
1078
1081
|
algorithm = '';
|
|
1079
1082
|
}
|
|
1080
|
-
let digest;
|
|
1081
1083
|
if (options) {
|
|
1082
1084
|
options = { ...options };
|
|
1083
1085
|
if ('minLength' in options) {
|
|
@@ -1225,7 +1227,7 @@ class Module extends EventEmitter {
|
|
|
1225
1227
|
return '';
|
|
1226
1228
|
}
|
|
1227
1229
|
if (/^\\\\\?\\[A-Za-z]:\\/.test(value)) {
|
|
1228
|
-
return
|
|
1230
|
+
return PLATFORM_WIN32 && !/\\\\|\\\.+\\|\\[^\n]+?\.+\\/.test(value = value.substring(4)) ? value : '';
|
|
1229
1231
|
}
|
|
1230
1232
|
return this.fromLocalPath(value) || value;
|
|
1231
1233
|
}
|
|
@@ -2376,7 +2378,7 @@ class Module extends EventEmitter {
|
|
|
2376
2378
|
}
|
|
2377
2379
|
if (isFunction(callback)) {
|
|
2378
2380
|
if (result) {
|
|
2379
|
-
|
|
2381
|
+
callback(null, result);
|
|
2380
2382
|
}
|
|
2381
2383
|
else {
|
|
2382
2384
|
fs.readFile(outSrc, encoding, (err, data) => {
|
|
@@ -3180,17 +3182,18 @@ class Module extends EventEmitter {
|
|
|
3180
3182
|
}
|
|
3181
3183
|
detach() {
|
|
3182
3184
|
const host = this.host;
|
|
3183
|
-
if (host) {
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
this
|
|
3185
|
+
if (!host) {
|
|
3186
|
+
return;
|
|
3187
|
+
}
|
|
3188
|
+
this.abortable = false;
|
|
3189
|
+
host.modules.delete(this);
|
|
3190
|
+
host.subProcesses.delete(this);
|
|
3191
|
+
const listener = this[kAbortEvent];
|
|
3192
|
+
if (listener) {
|
|
3193
|
+
host.signal.removeEventListener('abort', listener);
|
|
3194
|
+
this[kAbortEvent] = null;
|
|
3193
3195
|
}
|
|
3196
|
+
this._host = null;
|
|
3194
3197
|
}
|
|
3195
3198
|
abort() {
|
|
3196
3199
|
if (!this.aborted) {
|
|
@@ -3212,22 +3215,23 @@ class Module extends EventEmitter {
|
|
|
3212
3215
|
}
|
|
3213
3216
|
set host(value) {
|
|
3214
3217
|
this.detach();
|
|
3215
|
-
if (this._host = value) {
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3218
|
+
if (!(this._host = value)) {
|
|
3219
|
+
return;
|
|
3220
|
+
}
|
|
3221
|
+
this.sessionId = value.sessionId;
|
|
3222
|
+
this.broadcastId = value.broadcastId;
|
|
3223
|
+
this._logEnabled = value.willLog(this.moduleName);
|
|
3224
|
+
const aborting = this._hostEvents.includes('abort');
|
|
3225
|
+
if (value.aborted) {
|
|
3226
|
+
if (aborting) {
|
|
3227
|
+
this.abort();
|
|
3224
3228
|
}
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
}
|
|
3229
|
+
}
|
|
3230
|
+
else if (!value.subProcesses.has(this)) {
|
|
3231
|
+
this.abortable = value.willAbort(this);
|
|
3232
|
+
value.modules.add(this);
|
|
3233
|
+
if (aborting) {
|
|
3234
|
+
value.signal.addEventListener('abort', this[kAbortEvent] = () => this.abort(), { once: true });
|
|
3231
3235
|
}
|
|
3232
3236
|
}
|
|
3233
3237
|
}
|
|
@@ -3281,11 +3285,11 @@ class Module extends EventEmitter {
|
|
|
3281
3285
|
}
|
|
3282
3286
|
get logLevel() {
|
|
3283
3287
|
const value = this._logLevel;
|
|
3284
|
-
if (value
|
|
3285
|
-
|
|
3286
|
-
return host ? host.logLevel : 0;
|
|
3288
|
+
if (value !== -1) {
|
|
3289
|
+
return value;
|
|
3287
3290
|
}
|
|
3288
|
-
|
|
3291
|
+
const host = this.host;
|
|
3292
|
+
return host ? host.logLevel : 0;
|
|
3289
3293
|
}
|
|
3290
3294
|
get statusType() {
|
|
3291
3295
|
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.1",
|
|
4
4
|
"description": "Module base class for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "
|
|
12
|
+
"url": "https://github.com/anpham6/e-mc.git",
|
|
13
13
|
"directory": "src/module"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/types": "0.
|
|
23
|
+
"@e-mc/types": "0.6.1",
|
|
24
24
|
"abort-controller": "^3.0.0",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"event-target-shim": "^5.0.1",
|