@e-mc/file-manager 0.6.4 → 0.6.6

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,7 +1,7 @@
1
- # @e-mc/file-manager
2
-
3
- PEP 402 - Forever Any Mayo
4
-
5
- ## LICENSE
6
-
1
+ # @e-mc/file-manager
2
+
3
+ PEP 402 - Forever Any Mayo
4
+
5
+ ## LICENSE
6
+
7
7
  MIT
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { FileManagerConstructor } from '../types/lib';
2
- import type { ExternalAsset } from '../types/lib/asset';
3
-
4
- declare const FileManager: FileManagerConstructor<ExternalAsset>;
5
-
1
+ import type { FileManagerConstructor } from '../types/lib';
2
+ import type { ExternalAsset } from '../types/lib/asset';
3
+
4
+ declare const FileManager: FileManagerConstructor<ExternalAsset>;
5
+
6
6
  export = FileManager;
package/index.js CHANGED
@@ -874,26 +874,17 @@ class FileManager extends core_1.Host {
874
874
  }
875
875
  switch (name) {
876
876
  case 'cloud': {
877
- const instance = new cloud_1.default(args[0]);
878
- instance.host = this;
879
- instance.init(this.config);
880
- observeFile.call(this, instance);
881
- return this.Cloud = instance;
882
- }
883
- case 'watch': {
884
- const instance = new watch_1.default(...args);
885
- instance.host = this;
886
- instance.init(this.config);
887
- observeFile.call(this, instance);
888
- return this.Watch = instance;
889
- }
890
- case 'compress': {
891
- const instance = new compress_1.default(args[0]);
892
- instance.host = this;
893
- instance.init();
894
- observeFile.call(this, instance);
895
- return this.Compress = instance;
877
+ if ((0, types_1.isArray)(args[1])) {
878
+ const instance = new cloud_1.default(args[0], args[1]);
879
+ instance.host = this;
880
+ instance.init(this.config);
881
+ observeFile.call(this, instance);
882
+ return this.Cloud = instance;
883
+ }
896
884
  }
885
+ case 'watch':
886
+ case 'compress':
887
+ return this.install(name, ...args);
897
888
  default:
898
889
  return null;
899
890
  }
@@ -1323,25 +1314,8 @@ class FileManager extends core_1.Host {
1323
1314
  if (state === 0 && (this.cleared && this[kDelayed] <= 0 || override) || (this.aborted || state === 3) && override) {
1324
1315
  this.clearProcessTimeout();
1325
1316
  this[kDelayed] = Infinity;
1326
- const resetState = () => {
1327
- this.finalizeState = 2;
1328
- this._pendingResult = null;
1329
- };
1330
- const aborted = (err) => {
1331
- if (!this.restarting) {
1332
- this.writeFail(["Transaction was not completed", this.baseDirectory], err);
1333
- resetState();
1334
- }
1335
- else {
1336
- this.finalizeState = 4;
1337
- }
1338
- this.emit('end', [], collectErrors.call(this), this.collectLog());
1339
- if (!this.restarting) {
1340
- this.done = true;
1341
- }
1342
- };
1343
1317
  if (this.aborted) {
1344
- aborted((0, types_1.createAbortError)());
1318
+ this.abortFinalize((0, types_1.createAbortError)());
1345
1319
  return;
1346
1320
  }
1347
1321
  this.finalizeState = 1;
@@ -1361,7 +1335,7 @@ class FileManager extends core_1.Host {
1361
1335
  if (LOG_TIMEELAPSED) {
1362
1336
  this.writeTimeElapsed('END', this.baseDirectory, this.startTime, errors.length > 0 ? { failed: true, ...core_1.Host.LOG_STYLE_FAIL } : { ...core_1.Host.LOG_STYLE_SUCCESS });
1363
1337
  }
1364
- resetState();
1338
+ this.resetState();
1365
1339
  const log = this.config.log;
1366
1340
  let useNumeric = false, showSize = true;
1367
1341
  if ((0, types_1.isPlainObject)(log)) {
@@ -1374,7 +1348,7 @@ class FileManager extends core_1.Host {
1374
1348
  this.emit('end', items, errors, this.collectLog());
1375
1349
  this.done = true;
1376
1350
  })
1377
- .catch(err => aborted(err));
1351
+ .catch(err => this.abortFinalize(err));
1378
1352
  }
1379
1353
  }
1380
1354
  hasDocument(instance, document) {
@@ -3276,6 +3250,23 @@ class FileManager extends core_1.Host {
3276
3250
  close() {
3277
3251
  this.Request.close();
3278
3252
  }
3253
+ resetState() {
3254
+ this.finalizeState = 2;
3255
+ this._pendingResult = null;
3256
+ }
3257
+ abortFinalize(err) {
3258
+ if (!this.restarting) {
3259
+ this.writeFail(["Transaction was not completed", this.baseDirectory], err);
3260
+ this.resetState();
3261
+ }
3262
+ else {
3263
+ this.finalizeState = 4;
3264
+ }
3265
+ this.emit('end', [], collectErrors.call(this), this.collectLog());
3266
+ if (!this.restarting) {
3267
+ this.done = true;
3268
+ }
3269
+ }
3279
3270
  set restarting(value) {
3280
3271
  this.finalizeState = (this[kRestarting] = value) ? 3 : 0;
3281
3272
  }
package/package.json CHANGED
@@ -1,33 +1,33 @@
1
- {
2
- "name": "@e-mc/file-manager",
3
- "version": "0.6.4",
4
- "description": "FileManager constructor 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": "https://github.com/anpham6/e-mc.git",
13
- "directory": "src/file-manager"
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/cloud": "0.6.4",
24
- "@e-mc/compress": "0.6.4",
25
- "@e-mc/core": "0.6.4",
26
- "@e-mc/document": "0.6.4",
27
- "@e-mc/image": "0.6.4",
28
- "@e-mc/request": "0.6.4",
29
- "@e-mc/task": "0.6.4",
30
- "@e-mc/types": "0.6.4",
31
- "@e-mc/watch": "0.6.4"
32
- }
33
- }
1
+ {
2
+ "name": "@e-mc/file-manager",
3
+ "version": "0.6.6",
4
+ "description": "FileManager constructor 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": "https://github.com/anpham6/e-mc.git",
13
+ "directory": "src/file-manager"
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/cloud": "0.6.6",
24
+ "@e-mc/compress": "0.6.6",
25
+ "@e-mc/core": "0.6.6",
26
+ "@e-mc/document": "0.6.6",
27
+ "@e-mc/image": "0.6.6",
28
+ "@e-mc/request": "0.6.6",
29
+ "@e-mc/task": "0.6.6",
30
+ "@e-mc/types": "0.6.6",
31
+ "@e-mc/watch": "0.6.6"
32
+ }
33
+ }