@e-mc/module 0.7.9 → 0.7.10

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 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
- return (PLATFORM_WIN32 ? value.toLowerCase() : value).startsWith(ensureDir(PLATFORM_WIN32 ? base.toLowerCase() : base));
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.9"; }
589
+ static get VERSION() { return "0.7.10"; }
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; }
@@ -2372,7 +2379,7 @@ class Module extends EventEmitter {
2372
2379
  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
2380
  return true;
2374
2381
  }
2375
- return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR);
2382
+ return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR, true);
2376
2383
  }
2377
2384
  canWrite(uri, options) {
2378
2385
  let permission = this.permission, ownPermissionOnly = false;
@@ -2393,7 +2400,7 @@ class Module extends EventEmitter {
2393
2400
  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
2401
  return true;
2395
2402
  }
2396
- return VALUES["temp.write"] && withinDir(uri, TEMP_DIR) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR);
2403
+ return VALUES["temp.write"] && withinDir(uri, TEMP_DIR, true) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR, true);
2397
2404
  }
2398
2405
  readFile(src, options = {}, callback) {
2399
2406
  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.9",
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.9",
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.10",
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.10",
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
+ }