@e-mc/module 0.7.9 → 0.7.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 +30 -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.7.
|
|
589
|
+
static get VERSION() { return "0.7.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,40 +1097,34 @@ class Module extends EventEmitter {
|
|
|
1090
1097
|
}
|
|
1091
1098
|
return cacheKey ? (0, types_1.generateUUID)() : '';
|
|
1092
1099
|
}
|
|
1093
|
-
static asHash(data, algorithm,
|
|
1094
|
-
if (!algorithm && !
|
|
1100
|
+
static asHash(data, algorithm, digest) {
|
|
1101
|
+
if (!algorithm && !digest) {
|
|
1095
1102
|
return crypto.createHash("sha256").update(data).digest("hex");
|
|
1096
1103
|
}
|
|
1097
|
-
let options
|
|
1098
|
-
if (
|
|
1099
|
-
options =
|
|
1100
|
-
minLength = 0;
|
|
1101
|
-
}
|
|
1102
|
-
if (typeof algorithm === 'number') {
|
|
1103
|
-
minLength = algorithm;
|
|
1104
|
-
algorithm = undefined;
|
|
1105
|
-
}
|
|
1106
|
-
else if ((0, types_1.isObject)(algorithm)) {
|
|
1107
|
-
options = algorithm;
|
|
1108
|
-
algorithm = undefined;
|
|
1109
|
-
}
|
|
1110
|
-
if (options) {
|
|
1111
|
-
options = { ...options };
|
|
1112
|
-
if ('minLength' in options) {
|
|
1113
|
-
minLength = options.minLength;
|
|
1114
|
-
delete options.minLength;
|
|
1115
|
-
}
|
|
1104
|
+
let options;
|
|
1105
|
+
if ((0, types_1.isObject)(algorithm)) {
|
|
1106
|
+
options = { ...algorithm };
|
|
1116
1107
|
if ('algorithm' in options) {
|
|
1117
1108
|
algorithm = options.algorithm;
|
|
1118
1109
|
delete options.algorithm;
|
|
1119
1110
|
}
|
|
1111
|
+
else {
|
|
1112
|
+
algorithm = undefined;
|
|
1113
|
+
}
|
|
1120
1114
|
if ('digest' in options) {
|
|
1121
1115
|
digest = options.digest;
|
|
1122
1116
|
delete options.digest;
|
|
1123
1117
|
}
|
|
1118
|
+
else {
|
|
1119
|
+
digest = undefined;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
else if ((0, types_1.isObject)(digest)) {
|
|
1123
|
+
options = digest;
|
|
1124
|
+
digest = undefined;
|
|
1124
1125
|
}
|
|
1125
|
-
if (
|
|
1126
|
-
|
|
1126
|
+
else if (typeof digest !== 'string') {
|
|
1127
|
+
digest = undefined;
|
|
1127
1128
|
}
|
|
1128
1129
|
try {
|
|
1129
1130
|
return crypto.createHash(algorithm || "sha256", options).update(data).digest(digest || "hex");
|
|
@@ -2372,7 +2373,7 @@ class Module extends EventEmitter {
|
|
|
2372
2373
|
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()))) {
|
|
2373
2374
|
return true;
|
|
2374
2375
|
}
|
|
2375
|
-
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR);
|
|
2376
|
+
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR, true);
|
|
2376
2377
|
}
|
|
2377
2378
|
canWrite(uri, options) {
|
|
2378
2379
|
let permission = this.permission, ownPermissionOnly = false;
|
|
@@ -2393,7 +2394,7 @@ class Module extends EventEmitter {
|
|
|
2393
2394
|
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()))) {
|
|
2394
2395
|
return true;
|
|
2395
2396
|
}
|
|
2396
|
-
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR);
|
|
2397
|
+
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR, true) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR, true);
|
|
2397
2398
|
}
|
|
2398
2399
|
readFile(src, options = {}, callback) {
|
|
2399
2400
|
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.7.
|
|
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.7.
|
|
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.7.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.7.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
|
+
}
|