@e-mc/file-manager 0.5.7 → 0.5.9

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,5 @@
1
- # @e-mc/file-manager
2
-
3
- PEP 402 - Forever Any Ketchup
4
-
5
- ## LICENSE
6
-
1
+ # @e-mc/file-manager
2
+
3
+ ## LICENSE
4
+
7
5
  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) {
@@ -3275,6 +3249,23 @@ class FileManager extends core_1.Host {
3275
3249
  close() {
3276
3250
  this.Request.close();
3277
3251
  }
3252
+ resetState() {
3253
+ this.finalizeState = 2;
3254
+ this._pendingResult = null;
3255
+ }
3256
+ abortFinalize(err) {
3257
+ if (!this.restarting) {
3258
+ this.writeFail(["Transaction was not completed", this.baseDirectory], err);
3259
+ this.resetState();
3260
+ }
3261
+ else {
3262
+ this.finalizeState = 4;
3263
+ }
3264
+ this.emit('end', [], collectErrors.call(this), this.collectLog());
3265
+ if (!this.restarting) {
3266
+ this.done = true;
3267
+ }
3268
+ }
3278
3269
  set restarting(value) {
3279
3270
  this.finalizeState = (this[kRestarting] = value) ? 3 : 0;
3280
3271
  }
package/package.json CHANGED
@@ -1,33 +1,33 @@
1
- {
2
- "name": "@e-mc/file-manager",
3
- "version": "0.5.7",
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": "git+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.5.7",
24
- "@e-mc/compress": "0.5.7",
25
- "@e-mc/core": "0.5.7",
26
- "@e-mc/document": "0.5.7",
27
- "@e-mc/image": "0.5.7",
28
- "@e-mc/request": "0.5.7",
29
- "@e-mc/task": "0.5.7",
30
- "@e-mc/types": "0.5.7",
31
- "@e-mc/watch": "0.5.7"
32
- }
33
- }
1
+ {
2
+ "name": "@e-mc/file-manager",
3
+ "version": "0.5.9",
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": "git+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.5.9",
24
+ "@e-mc/compress": "0.5.9",
25
+ "@e-mc/core": "0.5.9",
26
+ "@e-mc/document": "0.5.9",
27
+ "@e-mc/image": "0.5.9",
28
+ "@e-mc/request": "0.5.9",
29
+ "@e-mc/task": "0.5.9",
30
+ "@e-mc/types": "0.5.9",
31
+ "@e-mc/watch": "0.5.9"
32
+ }
33
+ }