@e-mc/module 0.5.9 → 0.5.11
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 +6 -6
- package/README.md +4 -4
- package/index.d.ts +4 -4
- package/index.js +32 -29
- package/lib-v4.d.ts +4 -4
- package/package.json +31 -31
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Copyright 2024 An Pham
|
|
2
|
-
|
|
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
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
7
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# @e-mc/module
|
|
2
|
-
|
|
3
|
-
## LICENSE
|
|
4
|
-
|
|
1
|
+
# @e-mc/module
|
|
2
|
+
|
|
3
|
+
## LICENSE
|
|
4
|
+
|
|
5
5
|
MIT
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ModuleConstructor } from '../types/lib';
|
|
2
|
-
|
|
3
|
-
declare const Module: ModuleConstructor;
|
|
4
|
-
|
|
1
|
+
import type { ModuleConstructor } from '../types/lib';
|
|
2
|
+
|
|
3
|
+
declare const Module: ModuleConstructor;
|
|
4
|
+
|
|
5
5
|
export = Module;
|
package/index.js
CHANGED
|
@@ -411,7 +411,7 @@ function addCacheItem(map, key, data) {
|
|
|
411
411
|
}
|
|
412
412
|
function checkFunction(value) {
|
|
413
413
|
if (typeof value === 'function') {
|
|
414
|
-
Object.defineProperty(value, "__cjs__", { value: true });
|
|
414
|
+
Object.defineProperty(value, "__cjs__", { value: true, writable: false, enumerable: false });
|
|
415
415
|
return value;
|
|
416
416
|
}
|
|
417
417
|
return null;
|
|
@@ -514,9 +514,16 @@ function applyLogId(options) {
|
|
|
514
514
|
}
|
|
515
515
|
return options;
|
|
516
516
|
}
|
|
517
|
-
function withinDir(value, base) {
|
|
517
|
+
function withinDir(value, base, override = false) {
|
|
518
518
|
value = path.normalize(value);
|
|
519
|
-
|
|
519
|
+
if (PLATFORM_WIN32) {
|
|
520
|
+
value = value.toLowerCase();
|
|
521
|
+
base = ensureDir(base.toLowerCase());
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
base = ensureDir(base);
|
|
525
|
+
}
|
|
526
|
+
return value.startsWith(base) && (value !== base || override);
|
|
520
527
|
}
|
|
521
528
|
function formatPercent(value, precision) {
|
|
522
529
|
if (value <= 0) {
|
|
@@ -579,7 +586,7 @@ class Module extends EventEmitter {
|
|
|
579
586
|
this[_f] = new AbortController();
|
|
580
587
|
this[_g] = null;
|
|
581
588
|
}
|
|
582
|
-
static get VERSION() { return "0.5.
|
|
589
|
+
static get VERSION() { return "0.5.11"; }
|
|
583
590
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
584
591
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
585
592
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -1090,41 +1097,37 @@ class Module extends EventEmitter {
|
|
|
1090
1097
|
}
|
|
1091
1098
|
return cacheKey ? (0, types_1.generateUUID)() : '';
|
|
1092
1099
|
}
|
|
1093
|
-
static asHash(data, algorithm,
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
options = minLength;
|
|
1097
|
-
minLength = 0;
|
|
1100
|
+
static asHash(data, algorithm, digest) {
|
|
1101
|
+
if (!algorithm && !digest) {
|
|
1102
|
+
return crypto.createHash("sha256").update(data).digest("hex");
|
|
1098
1103
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
}
|
|
1103
|
-
else if ((0, types_1.isObject)(algorithm)) {
|
|
1104
|
-
options = algorithm;
|
|
1105
|
-
algorithm = '';
|
|
1106
|
-
}
|
|
1107
|
-
let digest;
|
|
1108
|
-
if (options) {
|
|
1109
|
-
options = { ...options };
|
|
1110
|
-
if ('minLength' in options) {
|
|
1111
|
-
minLength = options.minLength;
|
|
1112
|
-
delete options.minLength;
|
|
1113
|
-
}
|
|
1104
|
+
let options;
|
|
1105
|
+
if ((0, types_1.isObject)(algorithm)) {
|
|
1106
|
+
options = { ...algorithm };
|
|
1114
1107
|
if ('algorithm' in options) {
|
|
1115
1108
|
algorithm = options.algorithm;
|
|
1116
1109
|
delete options.algorithm;
|
|
1117
1110
|
}
|
|
1111
|
+
else {
|
|
1112
|
+
algorithm = undefined;
|
|
1113
|
+
}
|
|
1118
1114
|
if ('digest' in options) {
|
|
1119
1115
|
digest = options.digest;
|
|
1120
1116
|
delete options.digest;
|
|
1121
1117
|
}
|
|
1118
|
+
else {
|
|
1119
|
+
digest = undefined;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
else if ((0, types_1.isObject)(digest)) {
|
|
1123
|
+
options = digest;
|
|
1124
|
+
digest = undefined;
|
|
1122
1125
|
}
|
|
1123
|
-
if (
|
|
1124
|
-
|
|
1126
|
+
else if (typeof digest !== 'string') {
|
|
1127
|
+
digest = undefined;
|
|
1125
1128
|
}
|
|
1126
1129
|
try {
|
|
1127
|
-
return crypto.createHash(algorithm ||
|
|
1130
|
+
return crypto.createHash(algorithm || "sha256", options).update(data).digest(digest || "hex");
|
|
1128
1131
|
}
|
|
1129
1132
|
catch {
|
|
1130
1133
|
return '';
|
|
@@ -2338,7 +2341,7 @@ class Module extends EventEmitter {
|
|
|
2338
2341
|
if (permission && (Module.isFile(uri, 'unc') ? permission.hasUNCRead(path.normalize(uri)) || ownPermissionOnly && !permission.getUNCRead() : path.isAbsolute(uri = path.resolve(uri)) && (permission.hasDiskRead(uri) || ownPermissionOnly && !permission.getDiskRead()))) {
|
|
2339
2342
|
return true;
|
|
2340
2343
|
}
|
|
2341
|
-
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR);
|
|
2344
|
+
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR, true);
|
|
2342
2345
|
}
|
|
2343
2346
|
canWrite(uri, options) {
|
|
2344
2347
|
let permission = this.permission, ownPermissionOnly = false;
|
|
@@ -2359,7 +2362,7 @@ class Module extends EventEmitter {
|
|
|
2359
2362
|
if (permission && (Module.isFile(uri, 'unc') ? permission.hasUNCWrite(path.normalize(uri)) || ownPermissionOnly && !permission.getUNCWrite() : path.isAbsolute(uri = path.resolve(uri)) && (permission.hasDiskWrite(uri) || ownPermissionOnly && !permission.getDiskWrite()))) {
|
|
2360
2363
|
return true;
|
|
2361
2364
|
}
|
|
2362
|
-
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR);
|
|
2365
|
+
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR, true) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR, true);
|
|
2363
2366
|
}
|
|
2364
2367
|
readFile(src, options = {}, callback) {
|
|
2365
2368
|
let promises, outSrc;
|
package/lib-v4.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IModuleLibV4 } from '../types/lib/compat-v4';
|
|
2
|
-
|
|
3
|
-
declare const LibV4: IModuleLibV4;
|
|
4
|
-
|
|
1
|
+
import type { IModuleLibV4 } from '../types/lib/compat-v4';
|
|
2
|
+
|
|
3
|
+
declare const LibV4: IModuleLibV4;
|
|
4
|
+
|
|
5
5
|
export = LibV4;
|
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "Module base class for E-mc.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/anpham6/e-mc.git",
|
|
13
|
-
"directory": "src/module"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"squared",
|
|
17
|
-
"squared-functions"
|
|
18
|
-
],
|
|
19
|
-
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@e-mc/types": "0.5.
|
|
24
|
-
"abort-controller": "^3.0.0",
|
|
25
|
-
"chalk": "4.1.2",
|
|
26
|
-
"event-target-shim": "^5.0.1",
|
|
27
|
-
"file-type": "16.5.4",
|
|
28
|
-
"mime-types": "^2.1.35",
|
|
29
|
-
"strip-ansi": "6.0.1"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@e-mc/module",
|
|
3
|
+
"version": "0.5.11",
|
|
4
|
+
"description": "Module base class for E-mc.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/anpham6/e-mc.git",
|
|
13
|
+
"directory": "src/module"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"squared",
|
|
17
|
+
"squared-functions"
|
|
18
|
+
],
|
|
19
|
+
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@e-mc/types": "0.5.11",
|
|
24
|
+
"abort-controller": "^3.0.0",
|
|
25
|
+
"chalk": "4.1.2",
|
|
26
|
+
"event-target-shim": "^5.0.1",
|
|
27
|
+
"file-type": "16.5.4",
|
|
28
|
+
"mime-types": "^2.1.35",
|
|
29
|
+
"strip-ansi": "6.0.1"
|
|
30
|
+
}
|
|
31
|
+
}
|