@e-mc/file-manager 0.8.5 → 0.8.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.
Files changed (4) hide show
  1. package/LICENSE +8 -4
  2. package/README.md +201 -2
  3. package/index.js +168 -166
  4. package/package.json +11 -11
package/index.js CHANGED
@@ -1,23 +1,22 @@
1
1
  "use strict";
2
- /* eslint @typescript-eslint/no-explicit-any: "off" */
3
2
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
4
3
  Object.defineProperty(exports, "__esModule", { value: true });
5
4
  const path = require("path");
6
5
  const fs = require("fs");
7
6
  const pm = require("picomatch");
8
- const lib_v4_1 = require("../module/lib-v4");
9
- const util_1 = require("../request/util");
10
- const asset_1 = require("../document/asset");
11
- const util_2 = require("../document/util");
12
- const types_1 = require("../types");
13
- const core_1 = require("../core");
14
- const request_1 = require("../request");
15
- const document_1 = require("../document");
16
- const task_1 = require("../task");
17
- const image_1 = require("../image");
18
- const watch_1 = require("../watch");
19
- const compress_1 = require("../compress");
20
- const cloud_1 = require("../cloud");
7
+ const lib_v4_1 = require("@e-mc/module/lib-v4");
8
+ const util_1 = require("@e-mc/request/util");
9
+ const asset_1 = require("@e-mc/document/asset");
10
+ const util_2 = require("@e-mc/document/util");
11
+ const types_1 = require("@e-mc/types");
12
+ const core_1 = require("@e-mc/core");
13
+ const request_1 = require("@e-mc/request");
14
+ const document_1 = require("@e-mc/document");
15
+ const task_1 = require("@e-mc/task");
16
+ const image_1 = require("@e-mc/image");
17
+ const watch_1 = require("@e-mc/watch");
18
+ const compress_1 = require("@e-mc/compress");
19
+ const cloud_1 = require("@e-mc/cloud");
21
20
  const kBaseDirectory = Symbol('baseDirectory');
22
21
  const kIncremental = Symbol('incremental');
23
22
  const kRestarting = Symbol('restarting');
@@ -37,7 +36,7 @@ const CACHE_ETAG = {};
37
36
  const DISK = {
38
37
  ENABLED: false,
39
38
  EXPIRES: 0,
40
- LIMIT: (0, types_1.formatSize)("1gb" /* CACHE_SIZE.FILE_MANAGER_DISK_LIMIT */),
39
+ LIMIT: (0, types_1.formatSize)("1gb"),
41
40
  INCLUDE: [],
42
41
  EXCLUDE: []
43
42
  };
@@ -47,8 +46,8 @@ const MEMORY = {
47
46
  SIZE: 0,
48
47
  TOTAL: 0,
49
48
  EXPIRES: 0,
50
- LIMIT: (0, types_1.formatSize)("100mb" /* CACHE_SIZE.FILE_MANAGER_MEMORY_LIMIT */),
51
- LIMIT_ALL: (0, types_1.formatSize)("512mb" /* CACHE_SIZE.FILE_MANAGER_MEMORY_LIMIT_ALL */),
49
+ LIMIT: (0, types_1.formatSize)("100mb"),
50
+ LIMIT_ALL: (0, types_1.formatSize)("512mb"),
52
51
  INCLUDE: [],
53
52
  EXCLUDE: [],
54
53
  PURGE: 0.25,
@@ -62,11 +61,11 @@ let RECURSION_LIMIT = 10;
62
61
  let LOG_TIMEELAPSED = true;
63
62
  let LOG_TIMEPROCESS = true;
64
63
  const HTTP_CLIENT = {
65
- timeout: 60000 /* TIME.m */,
66
- connectTimeout: 20 * 1000 /* TIME.S */,
64
+ timeout: 60000,
65
+ connectTimeout: 20 * 1000,
67
66
  redirectLimit: 3,
68
- retryWait: 1000 /* TIME.S */,
69
- retryAfter: 30 * 1000 /* TIME.S */,
67
+ retryWait: 1000,
68
+ retryAfter: 30 * 1000,
70
69
  retryLimit: 10
71
70
  };
72
71
  function applyTimeout(target, options) {
@@ -97,7 +96,7 @@ function withinSizeRange(uri, value, pattern) {
97
96
  return true;
98
97
  }
99
98
  function startMessage() {
100
- this.formatMessage(128 /* LOG_TYPE.TIME_ELAPSED */, 'START', [new Date().toLocaleString(), this.assets.length + ' assets'], this.baseDirectory, { ...core_1.Host.LOG_STYLE_SUCCESS });
99
+ this.formatMessage(128, 'START', [new Date().toLocaleString(), this.assets.length + ' assets'], this.baseDirectory, { ...core_1.Host.LOG_STYLE_SUCCESS });
101
100
  }
102
101
  function clearAssets() {
103
102
  this.assets.forEach(item => {
@@ -117,7 +116,7 @@ function bundleTorrent(files, mimeType, encoding) {
117
116
  output += fs.readFileSync(file, encoding);
118
117
  }
119
118
  catch (err) {
120
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(file)], err, 32 /* LOG_TYPE.FILE */);
119
+ this.writeFail(["Unable to read file", path.basename(file)], err, 32);
121
120
  }
122
121
  }
123
122
  }
@@ -134,13 +133,13 @@ function recurseDir(output, subDirs, options) {
134
133
  .sort((a, b) => {
135
134
  if (sortBy > 0) {
136
135
  if (a.isDirectory() && !b.isDirectory()) {
137
- return sortBy & 1 /* READDIR_SORT.DIRECTORY */ ? -1 : 1;
136
+ return sortBy & 1 ? -1 : 1;
138
137
  }
139
138
  if (!a.isDirectory() && b.isDirectory()) {
140
- return sortBy & 1 /* READDIR_SORT.DIRECTORY */ ? 1 : -1;
139
+ return sortBy & 1 ? 1 : -1;
141
140
  }
142
141
  }
143
- return (a.name < b.name ? -1 : 1) * (2 /* READDIR_SORT.DESCENDING */ & 2 ? -1 : 1);
142
+ return (a.name < b.name ? -1 : 1) * (2 & 2 ? -1 : 1);
144
143
  });
145
144
  for (const item of items) {
146
145
  if (!item.isDirectory()) {
@@ -164,7 +163,7 @@ function checkHash(localUri, output, options, data) {
164
163
  value = options;
165
164
  }
166
165
  if ((0, types_1.isString)(value)) {
167
- algorithm || (algorithm = "sha256" /* HASH_OUTPUT.ALGORITHM */);
166
+ algorithm || (algorithm = "sha256");
168
167
  if (!data) {
169
168
  try {
170
169
  data = fs.readFileSync(localUri);
@@ -179,7 +178,7 @@ function checkHash(localUri, output, options, data) {
179
178
  }
180
179
  }
181
180
  if ((value = value.toLowerCase()) === core_1.Host.asHash(data, { algorithm, digest })) {
182
- this.formatMessage(32 /* LOG_TYPE.FILE */, algorithm, ["Checksum matched" /* VAL_MESSAGE.CHECKSUM */ + (output ? ' (output)' : ''), path.basename(localUri)], value, { ...core_1.Host.LOG_STYLE_INFO, queue: true });
181
+ this.formatMessage(32, algorithm, ["Checksum matched" + (output ? ' (output)' : ''), path.basename(localUri)], value, { ...core_1.Host.LOG_STYLE_INFO, queue: true });
183
182
  return true;
184
183
  }
185
184
  return false;
@@ -217,7 +216,7 @@ function filterPaths(values, include, exclude, dot) {
217
216
  return values;
218
217
  }
219
218
  function abortedHost() {
220
- if (this.finalizeState === 6 /* FINALIZE_STATE.ABORTED */) {
219
+ if (this.finalizeState === 6) {
221
220
  this.restarting = false;
222
221
  this.performFinalize(true);
223
222
  return this.done;
@@ -261,7 +260,7 @@ function collectErrors() {
261
260
  const clearModule = (instance) => {
262
261
  const { moduleName, errors } = instance;
263
262
  if (errors.length) {
264
- errors.forEach(value => result.push(`[${moduleName}] ` + (core_1.Host.asString(value) || "Unknown" /* ERR_MESSAGE.UNKNOWN */)));
263
+ errors.forEach(value => result.push(`[${moduleName}] ` + (core_1.Host.asString(value) || "Unknown")));
265
264
  errors.length = 0;
266
265
  }
267
266
  };
@@ -283,12 +282,12 @@ function collectErrors() {
283
282
  return result;
284
283
  }
285
284
  function rejectModule(err, type, hint) {
286
- this.writeFail(["Handled rejection" /* ERR_MESSAGE.HANDLED_REJECTION */, this.moduleName + (hint ? ': ' + hint : '')], err, type);
285
+ this.writeFail(["Handled rejection", this.moduleName + (hint ? ': ' + hint : '')], err, type);
287
286
  }
288
- const checksumFile = (algorithm) => "checksum" /* HASH_OUTPUT.FILENAME */ + '.' + ((0, types_1.isString)(algorithm) ? algorithm.toLowerCase() : "sha256" /* HASH_OUTPUT.ALGORITHM */);
289
- const checksumError = (algorithm) => new Error("Invalid parameters" /* ERR_MESSAGE.PARAMETERS */ + ` (${algorithm || "sha256" /* HASH_OUTPUT.ALGORITHM */})`);
287
+ const checksumFile = (algorithm) => "checksum" + '.' + ((0, types_1.isString)(algorithm) ? algorithm.toLowerCase() : "sha256");
288
+ const checksumError = (algorithm) => new Error("Invalid parameters" + ` (${algorithm || "sha256"})`);
290
289
  const isFunction = (value) => typeof value === 'function';
291
- const ignoreAsset = (item, exists) => item.invalid || (0, types_1.hasBit)(item.flags, 1 /* ASSET_FLAG.IGNORE */ | (!exists ? 128 /* ASSET_FLAG.EXISTS */ : 0));
290
+ const ignoreAsset = (item, exists) => item.invalid || (0, types_1.hasBit)(item.flags, 1 | (!exists ? 128 : 0));
292
291
  class HttpDiskCache {
293
292
  constructor(host, enabled) {
294
293
  this.host = host;
@@ -420,7 +419,7 @@ class HttpDiskCache {
420
419
  }
421
420
  class HttpMemoryCache extends HttpDiskCache {
422
421
  constructor(host, enabled) {
423
- super(host, enabled && core_1.Host.enabled("memory.settings.users" /* KEY_NAME.MEMORY_SETTINGS_USERS */, host.username));
422
+ super(host, enabled && core_1.Host.enabled("memory.settings.users", host.username));
424
423
  this.limit = MEMORY.LIMIT;
425
424
  this.expires = MEMORY.EXPIRES;
426
425
  this.toDisk = [MEMORY.DISK_MIN, MEMORY.DISK_MAX];
@@ -603,8 +602,8 @@ class FileManager extends core_1.Host {
603
602
  SESSION_LIMIT = Math.pow(10, value);
604
603
  }
605
604
  }
606
- LOG_TIMEELAPSED = this.hasLogType(128 /* LOG_TYPE.TIME_ELAPSED */);
607
- LOG_TIMEPROCESS = this.hasLogType(256 /* LOG_TYPE.TIME_PROCESS */);
605
+ LOG_TIMEELAPSED = this.hasLogType(128);
606
+ LOG_TIMEPROCESS = this.hasLogType(256);
608
607
  return true;
609
608
  }
610
609
  static sanitizeAssets(assets, exclusions = []) {
@@ -622,7 +621,7 @@ class FileManager extends core_1.Host {
622
621
  for (const attr in item) {
623
622
  switch (attr) {
624
623
  case 'flags':
625
- item.flags &= ~(128 /* ASSET_FLAG.EXISTS */ | 16 /* ASSET_FLAG.MODIFIED */);
624
+ item.flags &= ~(128 | 16);
626
625
  break;
627
626
  case 'watch':
628
627
  if ((0, types_1.isPlainObject)(item.watch) && item.watch.assets) {
@@ -692,7 +691,7 @@ class FileManager extends core_1.Host {
692
691
  if (options.throwsEmpty) {
693
692
  throw err;
694
693
  }
695
- this.writeFail(["Unable to read directory" /* ERR_MESSAGE.READ_DIRECTORY */, root], err, 32 /* LOG_TYPE.FILE */);
694
+ this.writeFail(["Unable to read directory", root], err, 32);
696
695
  return null;
697
696
  }
698
697
  return result;
@@ -745,7 +744,7 @@ class FileManager extends core_1.Host {
745
744
  fail.push(pathname);
746
745
  }
747
746
  else if (verbose) {
748
- process.stdout.write("+" /* SUMDIR_STATUS.PASS */ + ' ' + pathname + '\n');
747
+ process.stdout.write("+" + ' ' + pathname + '\n');
749
748
  }
750
749
  valid = true;
751
750
  }
@@ -785,7 +784,7 @@ class FileManager extends core_1.Host {
785
784
  if (options.throwsEmpty) {
786
785
  throw err;
787
786
  }
788
- this.writeFail(["Unable to read directory" /* ERR_MESSAGE.READ_DIRECTORY */, root], err, 32 /* LOG_TYPE.FILE */);
787
+ this.writeFail(["Unable to read directory", root], err, 32);
789
788
  return null;
790
789
  }
791
790
  if (parent) {
@@ -796,14 +795,14 @@ class FileManager extends core_1.Host {
796
795
  missing = Array.from(new Set(missing));
797
796
  }
798
797
  }
799
- if (verbose === true) { // eslint-disable-line @typescript-eslint/no-unnecessary-boolean-literal-compare
798
+ if (verbose === true) {
800
799
  const max = Math.max(...fail.concat(missing).map(item => item.length));
801
800
  const writeLog = (items, symbol) => {
802
- const [bg, fg] = symbol === "-" /* SUMDIR_STATUS.FAIL */ ? ['\x1b[31m', '\x1b[89m'] : ['\x1b[33m', '\x1b[89m'];
801
+ const [bg, fg] = symbol === "-" ? ['\x1b[31m', '\x1b[89m'] : ['\x1b[33m', '\x1b[89m'];
803
802
  items.forEach((value, index) => process.stdout.write(bg + symbol + ` ${value.padEnd(max)} (${(index + 1).toString()})${fg}\n`));
804
803
  };
805
- writeLog(fail, "-" /* SUMDIR_STATUS.FAIL */);
806
- writeLog(missing, "?" /* SUMDIR_STATUS.MISSING */);
804
+ writeLog(fail, "-");
805
+ writeLog(missing, "?");
807
806
  }
808
807
  return [fail, missing];
809
808
  }
@@ -876,7 +875,7 @@ class FileManager extends core_1.Host {
876
875
  HTTP_CLIENT.connectTimeout = timeout;
877
876
  }
878
877
  if ((retry_wait = (0, util_1.fromSeconds)(retry_wait)) >= 0) {
879
- HTTP_CLIENT.retryWait = Math.min(retry_wait, 600 * 1000 /* TIME.S */);
878
+ HTTP_CLIENT.retryWait = Math.min(retry_wait, 600 * 1000);
880
879
  }
881
880
  if ((retry_after = (0, util_1.fromSeconds)(retry_after)) >= 0) {
882
881
  HTTP_CLIENT.retryAfter = Math.min(retry_after, this.MAX_TIMEOUT);
@@ -890,7 +889,7 @@ class FileManager extends core_1.Host {
890
889
  }
891
890
  constructor(baseDirectory, config, permission, postFinalize) {
892
891
  super(config);
893
- this.finalizeState = 0 /* FINALIZE_STATE.READY */;
892
+ this.finalizeState = 0;
894
893
  this.processTimeout = PROCESS_TIMEOUT.filemanager;
895
894
  this.Document = [];
896
895
  this.Task = [];
@@ -953,7 +952,7 @@ class FileManager extends core_1.Host {
953
952
  item.id || (item.id = ++ASSET_ID);
954
953
  }
955
954
  this._assets = assets.slice(0);
956
- this[kIncremental] = incremental === "staging" /* INCREMENTAL.STAGING */ ? "staging" /* INCREMENTAL.STAGING */ : "none" /* INCREMENTAL.NONE */;
955
+ this[kIncremental] = incremental === "staging" ? "staging" : "none";
957
956
  if (targeted) {
958
957
  this.using(...targeted);
959
958
  }
@@ -981,7 +980,7 @@ class FileManager extends core_1.Host {
981
980
  request.host = this;
982
981
  this.Request = request;
983
982
  if (this.aborted) {
984
- this.finalizeState = 6 /* FINALIZE_STATE.ABORTED */;
983
+ this.finalizeState = 6;
985
984
  }
986
985
  else {
987
986
  request.init(config).apply({ client: HTTP_CLIENT });
@@ -1091,7 +1090,7 @@ class FileManager extends core_1.Host {
1091
1090
  }
1092
1091
  if (this.restartable && (!recursive || --this[kRecursionLimit] >= 0)) {
1093
1092
  if (this.reset()) {
1094
- this.finalizeState = 5 /* FINALIZE_STATE.RESTARTED */;
1093
+ this.finalizeState = 5;
1095
1094
  FileManager.sanitizeAssets(this.assets, exclusions);
1096
1095
  for (const { instance } of this.Document) {
1097
1096
  instance.restart();
@@ -1139,7 +1138,7 @@ class FileManager extends core_1.Host {
1139
1138
  }
1140
1139
  }
1141
1140
  reset() {
1142
- if (this.finalizeState === 1 /* FINALIZE_STATE.COMMIT */) {
1141
+ if (this.finalizeState === 1) {
1143
1142
  return false;
1144
1143
  }
1145
1144
  super.reset();
@@ -1161,7 +1160,7 @@ class FileManager extends core_1.Host {
1161
1160
  clearAssets.call(this);
1162
1161
  this.cleared = false;
1163
1162
  this[kDelayed] = 0;
1164
- this.finalizeState = 0 /* FINALIZE_STATE.READY */;
1163
+ this.finalizeState = 0;
1165
1164
  return true;
1166
1165
  }
1167
1166
  deleteFile(value, options = {}, callback) {
@@ -1186,11 +1185,11 @@ class FileManager extends core_1.Host {
1186
1185
  }
1187
1186
  resumeThread(options) {
1188
1187
  if (this.aborted || options.aborted) {
1189
- this.finalizeState = 0 /* FINALIZE_STATE.READY */;
1188
+ this.finalizeState = 0;
1190
1189
  this.performFinalize(true);
1191
1190
  return;
1192
1191
  }
1193
- this.finalizeState = 5 /* FINALIZE_STATE.RESTARTED */;
1192
+ this.finalizeState = 5;
1194
1193
  startMessage.call(this);
1195
1194
  this.processAssets(...options.args);
1196
1195
  }
@@ -1226,7 +1225,7 @@ class FileManager extends core_1.Host {
1226
1225
  if (typeof target === 'string') {
1227
1226
  const module = args.shift();
1228
1227
  if ((0, types_1.isObject)(module)) {
1229
- if (target === "@e-mc/cloud" /* PACKAGE_NAME.CLOUD */) {
1228
+ if (target === "@e-mc/cloud") {
1230
1229
  instance = new cloud_1.default(module, database);
1231
1230
  }
1232
1231
  else {
@@ -1236,11 +1235,11 @@ class FileManager extends core_1.Host {
1236
1235
  instance = new Handler(module, database);
1237
1236
  }
1238
1237
  else {
1239
- throw (0, types_1.errorMessage)(this.moduleName, "Not a Cloud constructor" /* ERR_CLOUD.CONSTRUCTOR */, target);
1238
+ throw (0, types_1.errorMessage)(this.moduleName, "Not a Cloud constructor", target);
1240
1239
  }
1241
1240
  }
1242
1241
  catch (err) {
1243
- this.checkPackage(err, target, ["Unable to load handler" /* ERR_MESSAGE.LOAD_HANDLER */, this.moduleName], 64 /* LOG_TYPE.CLOUD */);
1242
+ this.checkPackage(err, target, ["Unable to load handler", this.moduleName], 64);
1244
1243
  }
1245
1244
  }
1246
1245
  }
@@ -1273,7 +1272,7 @@ class FileManager extends core_1.Host {
1273
1272
  }
1274
1273
  }
1275
1274
  }
1276
- const manager = new FileManager(this.baseDirectory, { ...this.config, incremental: "none" /* INCREMENTAL.NONE */, assets }, postFinalize);
1275
+ const manager = new FileManager(this.baseDirectory, { ...this.config, incremental: "none", assets }, postFinalize);
1277
1276
  for (const { constructor, params } of this.Document) {
1278
1277
  manager.install('document', constructor, ...params);
1279
1278
  }
@@ -1284,17 +1283,20 @@ class FileManager extends core_1.Host {
1284
1283
  manager.install('cloud', this.Cloud.module);
1285
1284
  }
1286
1285
  if (this.Image) {
1287
- for (const handler of this.Image) {
1288
- if ((0, types_1.isPlainObject)(handler)) {
1289
- const image = handler.instance;
1290
- image.reset();
1291
- image.host = manager;
1292
- observeFile.call(manager, image);
1286
+ const mimeMap = new Map();
1287
+ let params = [];
1288
+ for (const [mimeType, handler] of this.Image) {
1289
+ const { constructor, params: trailing } = handler;
1290
+ if (params.length === 0 || mimeType === 'handler') {
1291
+ params = trailing;
1293
1292
  }
1293
+ mimeMap.set(mimeType, constructor);
1294
1294
  }
1295
- manager.Image = this.Image;
1295
+ manager.install('image', mimeMap, ...params);
1296
+ }
1297
+ if (this.Compress) {
1298
+ manager.install('compress', this.Compress.module);
1296
1299
  }
1297
- manager.Compress = this.Compress;
1298
1300
  manager.sessionId = this.sessionId;
1299
1301
  manager.permission = this.permission;
1300
1302
  manager.cacheToDisk = this.cacheToDisk;
@@ -1304,7 +1306,7 @@ class FileManager extends core_1.Host {
1304
1306
  manager.processAssets();
1305
1307
  }
1306
1308
  catch (err) {
1307
- manager.writeFail("Unknown" /* ERR_MESSAGE.UNKNOWN */, err, { startTime: manager.startTime });
1309
+ manager.writeFail("Unknown", err, { startTime: manager.startTime });
1308
1310
  }
1309
1311
  }
1310
1312
  return manager;
@@ -1315,7 +1317,7 @@ class FileManager extends core_1.Host {
1315
1317
  if (target instanceof Map) {
1316
1318
  const handler = new Map();
1317
1319
  for (const [mimeType, constructor] of target) {
1318
- if (constructor.prototype instanceof image_1.default) {
1320
+ if (isFunction(constructor) && constructor.prototype instanceof image_1.default) {
1319
1321
  const instance = new constructor(args[0]);
1320
1322
  instance.host = this;
1321
1323
  instance.init(this.config);
@@ -1466,7 +1468,7 @@ class FileManager extends core_1.Host {
1466
1468
  }
1467
1469
  }
1468
1470
  catch (err) {
1469
- this.writeFail(["Unable to rename file" /* ERR_MESSAGE.RENAME_FILE */, name], err, 32 /* LOG_TYPE.FILE */);
1471
+ this.writeFail(["Unable to rename file", name], err, 32);
1470
1472
  return false;
1471
1473
  }
1472
1474
  }
@@ -1487,7 +1489,7 @@ class FileManager extends core_1.Host {
1487
1489
  file.pathname = pathname;
1488
1490
  file.filename = filename;
1489
1491
  this.setLocalUri(file, true);
1490
- this.writeFail(["Unable to rename file" /* ERR_MESSAGE.RENAME_FILE */, name], err, 32 /* LOG_TYPE.FILE */);
1492
+ this.writeFail(["Unable to rename file", name], err, 32);
1491
1493
  return false;
1492
1494
  }
1493
1495
  }
@@ -1524,7 +1526,7 @@ class FileManager extends core_1.Host {
1524
1526
  }
1525
1527
  }
1526
1528
  catch (err) {
1527
- this.writeFail(["Unable to rename file" /* ERR_MESSAGE.RENAME_FILE */, path.basename(value)], err, 32 /* LOG_TYPE.FILE */);
1529
+ this.writeFail(["Unable to rename file", path.basename(value)], err, 32);
1528
1530
  return false;
1529
1531
  }
1530
1532
  if (!copy) {
@@ -1552,25 +1554,25 @@ class FileManager extends core_1.Host {
1552
1554
  this.performFinalize();
1553
1555
  }
1554
1556
  if (err) {
1555
- this.writeFail(["Unknown" /* ERR_MESSAGE.UNKNOWN */, uri], err, 32 /* LOG_TYPE.FILE */);
1557
+ this.writeFail(["Unknown", uri], err, 32);
1556
1558
  }
1557
1559
  }
1558
1560
  performFinalize(override) {
1559
1561
  const state = this.finalizeState;
1560
- if (state === 0 /* FINALIZE_STATE.READY */ && (this.cleared && this[kDelayed] <= 0 || override) || (this.aborted || state === 3 /* FINALIZE_STATE.RESTART */) && override) {
1562
+ if (state === 0 && (this.cleared && this[kDelayed] <= 0 || override) || (this.aborted || state === 3) && override) {
1561
1563
  this.clearProcessTimeout();
1562
1564
  this[kDelayed] = Infinity;
1563
1565
  const resetState = () => {
1564
- this.finalizeState = 2 /* FINALIZE_STATE.END */;
1566
+ this.finalizeState = 2;
1565
1567
  this._pendingResult = null;
1566
1568
  };
1567
1569
  const aborted = (err) => {
1568
1570
  if (!this.restarting) {
1569
- this.writeFail(["Transaction was not completed" /* ERR_MESSAGE.INCOMPLETE */, this.baseDirectory], err);
1571
+ this.writeFail(["Transaction was not completed", this.baseDirectory], err);
1570
1572
  resetState();
1571
1573
  }
1572
1574
  else {
1573
- this.finalizeState = 4 /* FINALIZE_STATE.QUEUED */;
1575
+ this.finalizeState = 4;
1574
1576
  }
1575
1577
  this.emit('end', [], collectErrors.call(this), this.collectLog());
1576
1578
  if (!this.restarting) {
@@ -1581,7 +1583,7 @@ class FileManager extends core_1.Host {
1581
1583
  aborted((0, types_1.createAbortError)());
1582
1584
  return;
1583
1585
  }
1584
- this.finalizeState = 1 /* FINALIZE_STATE.COMMIT */;
1586
+ this.finalizeState = 1;
1585
1587
  this.finalize()
1586
1588
  .then(() => {
1587
1589
  const errors = collectErrors.call(this);
@@ -1622,7 +1624,7 @@ class FileManager extends core_1.Host {
1622
1624
  let uri = file.uri, type;
1623
1625
  if (uri && !file.url && !file.content && !file.base64 && !file.dataView) {
1624
1626
  if (core_1.Host.isFile(uri, 'torrent')) {
1625
- type = 4 /* FETCH_TYPE.TORRENT */;
1627
+ type = 4;
1626
1628
  }
1627
1629
  else if (core_1.Host.isURL(uri, 'file')) {
1628
1630
  try {
@@ -1630,7 +1632,7 @@ class FileManager extends core_1.Host {
1630
1632
  file.uri = file.url.toString();
1631
1633
  }
1632
1634
  catch (err) {
1633
- this.writeFail(['Unable to parse URL', uri], err, 1024 /* LOG_TYPE.HTTP */);
1635
+ this.writeFail(['Unable to parse URL', uri], err, 1024);
1634
1636
  return { pathname: '', localUri: '' };
1635
1637
  }
1636
1638
  }
@@ -1653,7 +1655,7 @@ class FileManager extends core_1.Host {
1653
1655
  }
1654
1656
  }
1655
1657
  catch (err) {
1656
- this.writeFail(['Unable to resolve file location', uri], err, 32 /* LOG_TYPE.FILE */);
1658
+ this.writeFail(['Unable to resolve file location', uri], err, 32);
1657
1659
  return { pathname: '', localUri: '' };
1658
1660
  }
1659
1661
  }
@@ -1661,13 +1663,13 @@ class FileManager extends core_1.Host {
1661
1663
  const url = file.url;
1662
1664
  if (url) {
1663
1665
  if (url.protocol.startsWith('http')) {
1664
- type = 1 /* FETCH_TYPE.HTTP */;
1666
+ type = 1;
1665
1667
  }
1666
1668
  else if (file.socketPath && url.protocol === 'file:') {
1667
- type = 2 /* FETCH_TYPE.UNIX_SOCKET */;
1669
+ type = 2;
1668
1670
  }
1669
1671
  else if (core_1.Host.isFile(url, 's/ftp')) {
1670
- type = 3 /* FETCH_TYPE.FTP */;
1672
+ type = 3;
1671
1673
  }
1672
1674
  }
1673
1675
  file.fetchType = type;
@@ -1688,7 +1690,7 @@ class FileManager extends core_1.Host {
1688
1690
  const pathname = segments.length ? path.join(this.baseDirectory, ...segments) : this.baseDirectory;
1689
1691
  const localUri = file.filename ? path.join(pathname, file.filename) : pathname;
1690
1692
  file.localUri = localUri;
1691
- if (type !== 4 /* FETCH_TYPE.TORRENT */) {
1693
+ if (type !== 4) {
1692
1694
  file.mimeType || (file.mimeType = file.url && core_1.Host.lookupMime(path.basename(file.url.pathname)) || core_1.Host.lookupMime(file.filename));
1693
1695
  }
1694
1696
  return { pathname, localUri };
@@ -1718,7 +1720,7 @@ class FileManager extends core_1.Host {
1718
1720
  sourceUTF8 = fs.readFileSync(uri, file.encoding);
1719
1721
  }
1720
1722
  catch (err) {
1721
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(uri)], err, 32 /* LOG_TYPE.FILE */);
1723
+ this.writeFail(["Unable to read file", path.basename(uri)], err, 32);
1722
1724
  }
1723
1725
  }
1724
1726
  if (sourceUTF8?.[0] === '\uFEFF' && file.encoding !== 'utf16le') {
@@ -1741,7 +1743,7 @@ class FileManager extends core_1.Host {
1741
1743
  return fs.readFileSync(uri);
1742
1744
  }
1743
1745
  catch (err) {
1744
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(uri)], err, 32 /* LOG_TYPE.FILE */);
1746
+ this.writeFail(["Unable to read file", path.basename(uri)], err, 32);
1745
1747
  }
1746
1748
  }
1747
1749
  const result = file.base64 ? Buffer.from(file.base64, 'base64') : null;
@@ -1838,7 +1840,7 @@ class FileManager extends core_1.Host {
1838
1840
  return file.buffer = buffer;
1839
1841
  }
1840
1842
  catch (err) {
1841
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
1843
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
1842
1844
  }
1843
1845
  }
1844
1846
  return null;
@@ -1879,7 +1881,7 @@ class FileManager extends core_1.Host {
1879
1881
  fs.copyFileSync(localUri, output);
1880
1882
  }
1881
1883
  catch (err) {
1882
- this.writeFail(["Unable to copy file" /* ERR_MESSAGE.COPY_FILE */, path.basename(localUri)], err, 32 /* LOG_TYPE.FILE */);
1884
+ this.writeFail(["Unable to copy file", path.basename(localUri)], err, 32);
1883
1885
  return;
1884
1886
  }
1885
1887
  }
@@ -1909,7 +1911,7 @@ class FileManager extends core_1.Host {
1909
1911
  }
1910
1912
  }
1911
1913
  catch (err) {
1912
- this.writeFail(["Unable to read buffer" /* ERR_MESSAGE.READ_BUFFER */, path.basename(localUri)], err, 32 /* LOG_TYPE.FILE */);
1914
+ this.writeFail(["Unable to read buffer", path.basename(localUri)], err, 32);
1913
1915
  }
1914
1916
  if (rename) {
1915
1917
  if (!ext) {
@@ -1926,7 +1928,7 @@ class FileManager extends core_1.Host {
1926
1928
  }
1927
1929
  }
1928
1930
  catch (err) {
1929
- this.writeFail(["Unable to rename file" /* ERR_MESSAGE.RENAME_FILE */, path.basename(output)], err, 32 /* LOG_TYPE.FILE */);
1931
+ this.writeFail(["Unable to rename file", path.basename(output)], err, 32);
1930
1932
  }
1931
1933
  }
1932
1934
  }
@@ -1968,7 +1970,7 @@ class FileManager extends core_1.Host {
1968
1970
  config.timeout = this[kProcessTimeout].compress ?? PROCESS_TIMEOUT.compress;
1969
1971
  tasks.push(instance.tryFile(file.buffer || localUri, output, config, (err, result) => {
1970
1972
  if (err) {
1971
- this.writeFail(["Unable to compress file" /* ERR_MESSAGE.COMPRESS_FILE */, path.basename(localUri)], err, { type: 8 /* LOG_TYPE.COMPRESS */, startTime: config.startTime });
1973
+ this.writeFail(["Unable to compress file", path.basename(localUri)], err, { type: 8, startTime: config.startTime });
1972
1974
  }
1973
1975
  else if ((0, types_1.isString)(result)) {
1974
1976
  if (condition?.includes('%') && (0, lib_v4_1.getSize)(result) >= (0, lib_v4_1.getSize)(localUri)) {
@@ -1982,7 +1984,7 @@ class FileManager extends core_1.Host {
1982
1984
  }
1983
1985
  }
1984
1986
  catch (err) {
1985
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(output)], err, 32 /* LOG_TYPE.FILE */);
1987
+ this.writeFail(["Unable to read file", path.basename(output)], err, 32);
1986
1988
  }
1987
1989
  }
1988
1990
  }
@@ -2002,7 +2004,7 @@ class FileManager extends core_1.Host {
2002
2004
  file.mimeType = mimeType;
2003
2005
  data.mimeType = mimeType;
2004
2006
  }
2005
- const errorAsset = (instance, err, type = 4 /* LOG_TYPE.PROCESS */) => rejectModule.call(instance, err, type, path.basename(localUri));
2007
+ const errorAsset = (instance, err, type = 4) => rejectModule.call(instance, err, type, path.basename(localUri));
2006
2008
  if (file.tasks) {
2007
2009
  const taskName = [];
2008
2010
  for (const { task, handler: moduleName, preceding } of file.tasks) {
@@ -2050,7 +2052,7 @@ class FileManager extends core_1.Host {
2050
2052
  .then(() => this.closeThread(instance, data))
2051
2053
  .catch(err => {
2052
2054
  this.closeThread(instance, data);
2053
- errorAsset(instance, err, 2048 /* LOG_TYPE.IMAGE */);
2055
+ errorAsset(instance, err, 2048);
2054
2056
  });
2055
2057
  }
2056
2058
  }
@@ -2060,7 +2062,7 @@ class FileManager extends core_1.Host {
2060
2062
  }
2061
2063
  }
2062
2064
  catch (err) {
2063
- errorAsset(instance, err, 2048 /* LOG_TYPE.IMAGE */);
2065
+ errorAsset(instance, err, 2048);
2064
2066
  }
2065
2067
  }
2066
2068
  }
@@ -2139,7 +2141,7 @@ class FileManager extends core_1.Host {
2139
2141
  task();
2140
2142
  }
2141
2143
  catch (err) {
2142
- this.writeFail(["Unable to perform task" /* ERR_MESSAGE.PERFORM_TASK */, path.basename(this.getLocalUri(data))], err);
2144
+ this.writeFail(["Unable to perform task", path.basename(this.getLocalUri(data))], err);
2143
2145
  }
2144
2146
  this.removeAsyncTask();
2145
2147
  });
@@ -2270,19 +2272,19 @@ class FileManager extends core_1.Host {
2270
2272
  });
2271
2273
  }
2272
2274
  switch (this.finalizeState) {
2273
- case 0 /* FINALIZE_STATE.READY */:
2275
+ case 0:
2274
2276
  if (this.delayed === 0 && !this.cleared) {
2275
2277
  break;
2276
2278
  }
2277
- case 1 /* FINALIZE_STATE.COMMIT */:
2278
- case 3 /* FINALIZE_STATE.RESTART */:
2279
- case 5 /* FINALIZE_STATE.RESTARTED */:
2280
- case 4 /* FINALIZE_STATE.QUEUED */:
2279
+ case 1:
2280
+ case 3:
2281
+ case 5:
2282
+ case 4:
2281
2283
  if (this._pendingResult) {
2282
2284
  return this._pendingResult;
2283
2285
  }
2284
- this.finalizeState = 0 /* FINALIZE_STATE.READY */;
2285
- case 2 /* FINALIZE_STATE.END */:
2286
+ this.finalizeState = 0;
2287
+ case 2:
2286
2288
  resetAssets.call(this);
2287
2289
  break;
2288
2290
  }
@@ -2302,14 +2304,14 @@ class FileManager extends core_1.Host {
2302
2304
  abortedHost.call(this);
2303
2305
  return;
2304
2306
  }
2305
- if (this.finalizeState === 5 /* FINALIZE_STATE.RESTARTED */) {
2307
+ if (this.finalizeState === 5) {
2306
2308
  this.restarting = false;
2307
2309
  }
2308
2310
  else if (this._pendingResult) {
2309
2311
  return;
2310
2312
  }
2311
2313
  if (!this.canWrite(this.baseDirectory, { ownPermissionOnly: true })) {
2312
- this.writeFail("Unsupported access" /* ERR_MESSAGE.UNSUPPORTED_ACCESS */, new Error(this.baseDirectory), 8192 /* LOG_TYPE.PERMISSION */);
2314
+ this.writeFail("Unsupported access", new Error(this.baseDirectory), 8192);
2313
2315
  this.cleared = true;
2314
2316
  if (this.queued) {
2315
2317
  this.joinQueue({ reject: true });
@@ -2317,15 +2319,15 @@ class FileManager extends core_1.Host {
2317
2319
  return;
2318
2320
  }
2319
2321
  switch (this.finalizeState) {
2320
- case 0 /* FINALIZE_STATE.READY */:
2322
+ case 0:
2321
2323
  if (this.delayed === 0 && !this.cleared) {
2322
2324
  break;
2323
2325
  }
2324
- case 1 /* FINALIZE_STATE.COMMIT */:
2325
- case 3 /* FINALIZE_STATE.RESTART */:
2326
- case 4 /* FINALIZE_STATE.QUEUED */:
2326
+ case 1:
2327
+ case 3:
2328
+ case 4:
2327
2329
  return;
2328
- case 2 /* FINALIZE_STATE.END */:
2330
+ case 2:
2329
2331
  resetAssets.call(this);
2330
2332
  break;
2331
2333
  }
@@ -2333,10 +2335,10 @@ class FileManager extends core_1.Host {
2333
2335
  const length = arguments.length;
2334
2336
  const args = new Array(length);
2335
2337
  for (let i = 0; i < length; ++i) {
2336
- args[i] = arguments[i]; // eslint-disable-line prefer-rest-params
2338
+ args[i] = arguments[i];
2337
2339
  }
2338
2340
  if (this.joinQueue({ args })) {
2339
- this.finalizeState = 4 /* FINALIZE_STATE.QUEUED */;
2341
+ this.finalizeState = 4;
2340
2342
  return;
2341
2343
  }
2342
2344
  }
@@ -2346,7 +2348,7 @@ class FileManager extends core_1.Host {
2346
2348
  this.clearProcessTimeout();
2347
2349
  this[KTimerMain] = setInterval(() => {
2348
2350
  const { processing, processTimeout, finalizeState } = this;
2349
- if (finalizeState === 4 /* FINALIZE_STATE.QUEUED */) {
2351
+ if (finalizeState === 4) {
2350
2352
  return;
2351
2353
  }
2352
2354
  const currentTime = Date.now();
@@ -2374,12 +2376,12 @@ class FileManager extends core_1.Host {
2374
2376
  file.invalid = true;
2375
2377
  const localUri = file.localUri;
2376
2378
  if (expired) {
2377
- data.abort(new Error("Timeout was exceeded" /* ERR_MESSAGE.TIMEOUT */));
2379
+ data.abort(new Error("Timeout was exceeded"));
2378
2380
  if (localUri) {
2379
2381
  this.deleteFile(localUri, { id: file.id, emptyDir: true, all: true });
2380
2382
  }
2381
2383
  }
2382
- (moduleName && this.find(moduleName) || this).formatFail(16384 /* LOG_TYPE.TIMEOUT */, "FAIL!" /* ERR_MESSAGE.FAIL */, ["Unable to process file" /* ERR_MESSAGE.PROCESS_FILE */, moduleName || 'main'], (0, types_1.errorValue)(expired ? "Timeout was exceeded" /* ERR_MESSAGE.TIMEOUT */ : "Aborted" /* ERR_MESSAGE.ABORTED */, localUri), { queue: false, startTime: data.startTime });
2384
+ (moduleName && this.find(moduleName) || this).formatFail(16384, "FAIL!", ["Unable to process file", moduleName || 'main'], (0, types_1.errorValue)(expired ? "Timeout was exceeded" : "Aborted", localUri), { queue: false, startTime: data.startTime });
2383
2385
  processing.splice(i--, 1);
2384
2386
  aborted = true;
2385
2387
  }
@@ -2400,10 +2402,10 @@ class FileManager extends core_1.Host {
2400
2402
  const bundling = Object.create(null);
2401
2403
  const originCount = Object.create(null);
2402
2404
  const emptied = [this.baseDirectory];
2403
- const staging = this[kIncremental] === "staging" /* INCREMENTAL.STAGING */;
2405
+ const staging = this[kIncremental] === "staging";
2404
2406
  const incremental = this.config.incremental;
2405
2407
  const isCacheable = (file) => file.initialValue?.cacheable !== false;
2406
- const hasIncremental = (value) => value === "etag" /* INCREMENTAL.ETAG */ || value === "exists" /* INCREMENTAL.EXISTS */;
2408
+ const hasIncremental = (value) => value === "etag" || value === "exists";
2407
2409
  let cacheable = false, cacheOpen = false, cacheEtag = false;
2408
2410
  if (!staging) {
2409
2411
  cacheable = this[kRecursionLimit] === RECURSION_LIMIT;
@@ -2411,10 +2413,10 @@ class FileManager extends core_1.Host {
2411
2413
  if (cacheOpen = hasIncremental(incremental)) {
2412
2414
  this[kIncremental] = incremental;
2413
2415
  }
2414
- cacheEtag = incremental === "etag" /* INCREMENTAL.ETAG */;
2416
+ cacheEtag = incremental === "etag";
2415
2417
  }
2416
2418
  else {
2417
- this[kIncremental] = "none" /* INCREMENTAL.NONE */;
2419
+ this[kIncremental] = "none";
2418
2420
  }
2419
2421
  }
2420
2422
  const targeting = this._usingObjects.size > 0;
@@ -2424,11 +2426,11 @@ class FileManager extends core_1.Host {
2424
2426
  }
2425
2427
  switch (file.incremental) {
2426
2428
  case false:
2427
- case "none" /* INCREMENTAL.NONE */:
2428
- case "exists" /* INCREMENTAL.EXISTS */:
2429
- case "staging" /* INCREMENTAL.STAGING */:
2429
+ case "none":
2430
+ case "exists":
2431
+ case "staging":
2430
2432
  return false;
2431
- case "etag" /* INCREMENTAL.ETAG */:
2433
+ case "etag":
2432
2434
  return true;
2433
2435
  default:
2434
2436
  return cacheEtag;
@@ -2465,11 +2467,11 @@ class FileManager extends core_1.Host {
2465
2467
  if (bundleIndex > 0) {
2466
2468
  items[bundleIndex - 1] = file;
2467
2469
  let url, parent;
2468
- if (file.fetchType === 1 /* FETCH_TYPE.HTTP */ && (cacheToDisk.has(url = file.url) || cacheToMemory.has(url)) && (parent = assets.find(item => item.bundleIndex === 0 && item.bundleId === bundleId))) {
2470
+ if (file.fetchType === 1 && (cacheToDisk.has(url = file.url) || cacheToMemory.has(url)) && (parent = assets.find(item => item.bundleIndex === 0 && item.bundleId === bundleId))) {
2469
2471
  (parent.bundleQueue || (parent.bundleQueue = [])).push(new Promise(resolve => {
2470
2472
  this.Request.open(url, { method: 'HEAD', httpVersion: 1 })
2471
2473
  .on('response', res => {
2472
- if (res.statusCode < 300 /* HTTP_STATUS.MULTIPLE_CHOICES */) {
2474
+ if (res.statusCode < 300) {
2473
2475
  applyHeaders(file, res.headers);
2474
2476
  }
2475
2477
  resolve(file);
@@ -2533,7 +2535,7 @@ class FileManager extends core_1.Host {
2533
2535
  }
2534
2536
  catch (err) {
2535
2537
  items.forEach(queue => queue.invalid = true);
2536
- this.writeFail([buffer ? "Unable to write buffer" /* ERR_MESSAGE.WRITE_BUFFER */ : "Unable to copy file" /* ERR_MESSAGE.COPY_FILE */, path.basename(file.localUri)], err, 32 /* LOG_TYPE.FILE */);
2538
+ this.writeFail([buffer ? "Unable to write buffer" : "Unable to copy file", path.basename(file.localUri)], err, 32);
2537
2539
  }
2538
2540
  }
2539
2541
  };
@@ -2588,7 +2590,7 @@ class FileManager extends core_1.Host {
2588
2590
  checkEtag = false;
2589
2591
  }
2590
2592
  else if (uri) {
2591
- if (type === 1 /* FETCH_TYPE.HTTP */ || type === 2 /* FETCH_TYPE.UNIX_SOCKET */) {
2593
+ if (type === 1 || type === 2) {
2592
2594
  const url = queue.url;
2593
2595
  const options = {
2594
2596
  url,
@@ -2596,7 +2598,7 @@ class FileManager extends core_1.Host {
2596
2598
  statusMessage: uri + ` (${queue.bundleIndex})`
2597
2599
  };
2598
2600
  let etag, pipeTo;
2599
- if (type === 2 /* FETCH_TYPE.UNIX_SOCKET */) {
2601
+ if (type === 2) {
2600
2602
  options.socketPath = queue.socketPath;
2601
2603
  options.httpVersion = 1;
2602
2604
  }
@@ -2688,7 +2690,7 @@ class FileManager extends core_1.Host {
2688
2690
  const pathname = this.getTempDir({ uuidDir: true });
2689
2691
  if (!pathname || !mimeType) {
2690
2692
  queue.invalid = true;
2691
- tasks.push(Promise.reject(!pathname ? new Error("Unable to create temp directory" /* ERR_MESSAGE.TEMP_DIRECTORY */) : (0, types_1.errorValue)("MIME not found" /* ERR_MESSAGE.NOTFOUND_MIME */, uri)));
2693
+ tasks.push(Promise.reject(!pathname ? new Error("Unable to create temp directory") : (0, types_1.errorValue)("MIME not found", uri)));
2692
2694
  break;
2693
2695
  }
2694
2696
  tasks.push(this.fetchFiles(queue.url || uri, { pathname, binOpts: queue.binOpts || file.binOpts })
@@ -2726,7 +2728,7 @@ class FileManager extends core_1.Host {
2726
2728
  success = await Promise.all(tasks)
2727
2729
  .then(() => true)
2728
2730
  .catch(err => {
2729
- this.writeFail(["Unable to download file" /* ERR_MESSAGE.DOWNLOAD_FILE */, 'bundle: ' + path.basename(localUri)], err, 1024 /* LOG_TYPE.HTTP */);
2731
+ this.writeFail(["Unable to download file", 'bundle: ' + path.basename(localUri)], err, 1024);
2730
2732
  return false;
2731
2733
  });
2732
2734
  }
@@ -2792,10 +2794,10 @@ class FileManager extends core_1.Host {
2792
2794
  if (!preceding) {
2793
2795
  this.completeAsyncTask();
2794
2796
  }
2795
- this.writeFail(["Unable to download file" /* ERR_MESSAGE.DOWNLOAD_FILE */, uri], err, err instanceof Error && err.message.startsWith("Timeout was exceeded" /* ERR_MESSAGE.TIMEOUT */) ? 16384 /* LOG_TYPE.TIMEOUT */ : 1024 /* LOG_TYPE.HTTP */);
2797
+ this.writeFail(["Unable to download file", uri], err, err instanceof Error && err.message.startsWith("Timeout was exceeded") ? 16384 : 1024);
2796
2798
  };
2797
2799
  const errorPermission = (file) => {
2798
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, file.uri], (0, types_1.errorValue)('Operation not permitted', file.uri || "Unknown" /* ERR_MESSAGE.UNKNOWN */), 8192 /* LOG_TYPE.PERMISSION */);
2800
+ this.writeFail(["Unable to read file", file.uri], (0, types_1.errorValue)('Operation not permitted', file.uri || "Unknown"), 8192);
2799
2801
  file.invalid = true;
2800
2802
  };
2801
2803
  const createFolder = (file, pathname) => {
@@ -2808,7 +2810,7 @@ class FileManager extends core_1.Host {
2808
2810
  }
2809
2811
  else {
2810
2812
  file.invalid = true;
2811
- this.writeFail("Unable to create directory" /* ERR_MESSAGE.CREATE_DIRECTORY */, (0, types_1.errorValue)('Path not found', pathname));
2813
+ this.writeFail("Unable to create directory", (0, types_1.errorValue)('Path not found', pathname));
2812
2814
  return false;
2813
2815
  }
2814
2816
  }
@@ -2824,7 +2826,7 @@ class FileManager extends core_1.Host {
2824
2826
  item.invalid = true;
2825
2827
  this.filesToRemove.add(localUri);
2826
2828
  this.completeAsyncTask();
2827
- this.writeFail(["Checksum did not match" /* ERR_MESSAGE.FAILED_CHECKSUM */, path.basename(localUri)], (0, types_1.errorValue)(item.uri || localUri, "Invalid checksum" /* ERR_MESSAGE.CHECKSUM */), { type: 32 /* LOG_TYPE.FILE */, queue: true });
2829
+ this.writeFail(["Checksum did not match", path.basename(localUri)], (0, types_1.errorValue)(item.uri || localUri, "Invalid checksum"), { type: 32, queue: true });
2828
2830
  return;
2829
2831
  }
2830
2832
  if (fetched) {
@@ -2867,7 +2869,7 @@ class FileManager extends core_1.Host {
2867
2869
  const type = item.incremental;
2868
2870
  let valid = cacheOpen;
2869
2871
  if (valid) {
2870
- if (type === false || type === "none" /* INCREMENTAL.NONE */) {
2872
+ if (type === false || type === "none") {
2871
2873
  valid = false;
2872
2874
  }
2873
2875
  }
@@ -2880,9 +2882,9 @@ class FileManager extends core_1.Host {
2880
2882
  }
2881
2883
  }
2882
2884
  if (valid && filename) {
2883
- const etag = (cacheEtag && type !== "exists" /* INCREMENTAL.EXISTS */ || type === "etag" /* INCREMENTAL.ETAG */) && !!uri;
2885
+ const etag = (cacheEtag && type !== "exists" || type === "etag") && !!uri;
2884
2886
  if (etag && imported.some(file => file.imported.includes(uri))) {
2885
- item.incremental = "none" /* INCREMENTAL.NONE */;
2887
+ item.incremental = "none";
2886
2888
  }
2887
2889
  else if (!(0, types_1.mainFlag)(item.flags)) {
2888
2890
  let cached;
@@ -2895,7 +2897,7 @@ class FileManager extends core_1.Host {
2895
2897
  }
2896
2898
  return false;
2897
2899
  };
2898
- if ((!etag || item.fetchType === 1 /* FETCH_TYPE.HTTP */ && ((0, types_1.isEmpty)(bundleId) || bundleIndex <= 0)) && (!watch || !item.watch || setBuffer(item))) {
2900
+ if ((!etag || item.fetchType === 1 && ((0, types_1.isEmpty)(bundleId) || bundleIndex <= 0)) && (!watch || !item.watch || setBuffer(item))) {
2899
2901
  let childBundle, childDownload;
2900
2902
  if (!(0, types_1.isEmpty)(bundleId) && bundleIndex > 0) {
2901
2903
  const target = assets.find(parent => parent.bundleIndex === 0 && parent.bundleId === bundleId);
@@ -2932,8 +2934,8 @@ class FileManager extends core_1.Host {
2932
2934
  }
2933
2935
  const checksumOutput = item.checksumOutput;
2934
2936
  if (core_1.Host.isPath(localUri) && (!checksumOutput || checkHash.call(this, localUri, true, checksumOutput))) {
2935
- item.flags |= 128 /* ASSET_FLAG.EXISTS */;
2936
- if (!etag || item.fetchType !== 1 /* FETCH_TYPE.HTTP */ || checksumOutput) {
2937
+ item.flags |= 128;
2938
+ if (!etag || item.fetchType !== 1 || checksumOutput) {
2937
2939
  if (bundleIndex === 0 && !(0, types_1.isEmpty)(bundleId)) {
2938
2940
  assets.filter(child => child.bundleId === bundleId && child.bundleIndex > 0).forEach(child => {
2939
2941
  setBuffer(child);
@@ -3032,10 +3034,10 @@ class FileManager extends core_1.Host {
3032
3034
  continue;
3033
3035
  }
3034
3036
  const checkDest = (src) => staging || !(0, lib_v4_1.hasSameStat)(src, localUri);
3035
- const type = item.fetchType || 0 /* FETCH_TYPE.UNKNOWN */;
3037
+ const type = item.fetchType || 0;
3036
3038
  const bundleMain = item.bundleIndex === 0 && !(0, types_1.isEmpty)(item.bundleId);
3037
- const isHttp = type === 1 /* FETCH_TYPE.HTTP */;
3038
- if (isHttp || type === 2 /* FETCH_TYPE.UNIX_SOCKET */) {
3039
+ const isHttp = type === 1;
3040
+ if (isHttp || type === 2) {
3039
3041
  let checkEtag;
3040
3042
  if (bundling[uri] && (0, types_1.isEmpty)(item.bundleId)) {
3041
3043
  bundling[uri].push(item);
@@ -3059,12 +3061,12 @@ class FileManager extends core_1.Host {
3059
3061
  if (isHttp) {
3060
3062
  cacheDir = cacheToDisk.has(url) && isCacheable(item);
3061
3063
  cacheBuffer = cacheToMemory.has(url);
3062
- mainEtag = (0, types_1.mainFlag)(item.flags) && (cacheEtag || item.incremental === "etag" /* INCREMENTAL.ETAG */);
3064
+ mainEtag = (0, types_1.mainFlag)(item.flags) && (cacheEtag || item.incremental === "etag");
3063
3065
  }
3064
3066
  const closeResponse = () => client?.destroy();
3065
3067
  const downloadUri = (request, etagDir) => {
3066
3068
  if (checkEtag) {
3067
- item.flags &= ~128 /* ASSET_FLAG.EXISTS */;
3069
+ item.flags &= ~128;
3068
3070
  }
3069
3071
  closeResponse();
3070
3072
  const location = request.url.toString();
@@ -3116,7 +3118,7 @@ class FileManager extends core_1.Host {
3116
3118
  (client = request.open(href, target))
3117
3119
  .on('response', res => {
3118
3120
  const statusCode = res.statusCode;
3119
- if (statusCode < 300 /* HTTP_STATUS.MULTIPLE_CHOICES */) {
3121
+ if (statusCode < 300) {
3120
3122
  const etag = applyHeaders(item, res.headers, false, mainEtag);
3121
3123
  let tempDir, etagDir;
3122
3124
  if (etag) {
@@ -3208,7 +3210,7 @@ class FileManager extends core_1.Host {
3208
3210
  fs.writeFileSync(localUri, buffer);
3209
3211
  this.addDownload(Buffer.byteLength(buffer, encoding), types_1.DOWNLOAD_TYPE.CACHE);
3210
3212
  if (checkEtag) {
3211
- item.flags &= ~128 /* ASSET_FLAG.EXISTS */;
3213
+ item.flags &= ~128;
3212
3214
  }
3213
3215
  fileReceived(item, localUri, null, true, false, true);
3214
3216
  closeResponse();
@@ -3224,7 +3226,7 @@ class FileManager extends core_1.Host {
3224
3226
  }
3225
3227
  downloadUri(target, etagDir);
3226
3228
  }
3227
- else if (statusCode < 400 /* HTTP_STATUS.BAD_REQUEST */) {
3229
+ else if (statusCode < 400) {
3228
3230
  closeResponse();
3229
3231
  const location = res.headers.location;
3230
3232
  if (location && ++redirects <= HTTP_CLIENT.redirectLimit) {
@@ -3270,7 +3272,7 @@ class FileManager extends core_1.Host {
3270
3272
  }
3271
3273
  else if (type) {
3272
3274
  if (bundleMain && !item.mimeType) {
3273
- errorRequest(item, (0, types_1.errorValue)("MIME not found" /* ERR_MESSAGE.NOTFOUND_MIME */, uri), true);
3275
+ errorRequest(item, (0, types_1.errorValue)("MIME not found", uri), true);
3274
3276
  }
3275
3277
  else if (!checkQueue(item, localUri, pathname, false)) {
3276
3278
  if (downloading[uri]) {
@@ -3308,7 +3310,7 @@ class FileManager extends core_1.Host {
3308
3310
  found = true;
3309
3311
  }
3310
3312
  catch (err) {
3311
- this.writeFail(["Unable to rename file" /* ERR_MESSAGE.RENAME_FILE */, item.filename], err, 32 /* LOG_TYPE.FILE */);
3313
+ this.writeFail(["Unable to rename file", item.filename], err, 32);
3312
3314
  }
3313
3315
  }
3314
3316
  else {
@@ -3389,7 +3391,7 @@ class FileManager extends core_1.Host {
3389
3391
  item.buffer = result;
3390
3392
  }
3391
3393
  })
3392
- .catch(err => this.writeFail(["Unable to compress file" /* ERR_MESSAGE.COMPRESS_FILE */, path.basename(file)], err, { type: 8 /* LOG_TYPE.COMPRESS */, startTime: options.startTime })));
3394
+ .catch(err => this.writeFail(["Unable to compress file", path.basename(file)], err, { type: 8, startTime: options.startTime })));
3393
3395
  }
3394
3396
  }
3395
3397
  }
@@ -3400,7 +3402,7 @@ class FileManager extends core_1.Host {
3400
3402
  async finalizeDocument() {
3401
3403
  for (const { instance, constructor } of this.Document) {
3402
3404
  if (constructor.finalize && instance.assets.length) {
3403
- await constructor.finalize.call(this, instance).catch(err => rejectModule.call(instance, err, 4 /* LOG_TYPE.PROCESS */));
3405
+ await constructor.finalize.call(this, instance).catch(err => rejectModule.call(instance, err, 4));
3404
3406
  if (this.aborted) {
3405
3407
  return;
3406
3408
  }
@@ -3412,7 +3414,7 @@ class FileManager extends core_1.Host {
3412
3414
  for (const { instance, constructor } of this.Task) {
3413
3415
  const items = assets.filter(item => item.tasks.find(data => data.handler === instance.moduleName));
3414
3416
  if (items.length) {
3415
- await (constructor.using || constructor.finalize).call(this, instance, items).catch(err => rejectModule.call(instance, err, 4 /* LOG_TYPE.PROCESS */));
3417
+ await (constructor.using || constructor.finalize).call(this, instance, items).catch(err => rejectModule.call(instance, err, 4));
3416
3418
  if (this.aborted) {
3417
3419
  return;
3418
3420
  }
@@ -3423,7 +3425,7 @@ class FileManager extends core_1.Host {
3423
3425
  async finalizeCloud() {
3424
3426
  const cloud = this.Cloud;
3425
3427
  if (cloud) {
3426
- return cloud_1.default.finalize.call(this, cloud).catch(err => rejectModule.call(cloud, err, 64 /* LOG_TYPE.CLOUD */));
3428
+ return cloud_1.default.finalize.call(this, cloud).catch(err => rejectModule.call(cloud, err, 64));
3427
3429
  }
3428
3430
  }
3429
3431
  async finalizeCleanup() {
@@ -3438,7 +3440,7 @@ class FileManager extends core_1.Host {
3438
3440
  }
3439
3441
  for (const { instance, constructor } of this.Document) {
3440
3442
  if (constructor.cleanup && instance.assets.length) {
3441
- await constructor.cleanup.call(this, instance).catch(err => rejectModule.call(instance, err, 4 /* LOG_TYPE.PROCESS */));
3443
+ await constructor.cleanup.call(this, instance).catch(err => rejectModule.call(instance, err, 4));
3442
3444
  }
3443
3445
  }
3444
3446
  }
@@ -3476,11 +3478,11 @@ class FileManager extends core_1.Host {
3476
3478
  }
3477
3479
  }
3478
3480
  removeFiles();
3479
- await this.finalizeCompress(this.assets.filter(item => item.compress && !ignoreAsset(item))).catch(err => rejectModule.call(this, err, 8 /* LOG_TYPE.COMPRESS */));
3481
+ await this.finalizeCompress(this.assets.filter(item => item.compress && !ignoreAsset(item))).catch(err => rejectModule.call(this, err, 8));
3480
3482
  if (this.aborted) {
3481
3483
  return Promise.reject((0, types_1.createAbortError)());
3482
3484
  }
3483
- await this.finalizeDocument().catch(err => rejectModule.call(this, err, 4 /* LOG_TYPE.PROCESS */));
3485
+ await this.finalizeDocument().catch(err => rejectModule.call(this, err, 4));
3484
3486
  if (this.aborted) {
3485
3487
  return Promise.reject((0, types_1.createAbortError)());
3486
3488
  }
@@ -3490,12 +3492,12 @@ class FileManager extends core_1.Host {
3490
3492
  fs.writeFileSync(item.localUri, item.sourceUTF8, item.encoding || (item.encoding = 'utf-8'));
3491
3493
  }
3492
3494
  catch (err) {
3493
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(item.localUri)], err, { type: 32 /* LOG_TYPE.FILE */, startTime });
3495
+ this.writeFail(["Unable to write file", path.basename(item.localUri)], err, { type: 32, startTime });
3494
3496
  }
3495
3497
  }
3496
3498
  }
3497
3499
  removeFiles();
3498
- await this.finalizeTask(this.taskAssets.filter(item => item.tasks?.find(data => !data.preceding) && item.localUri && this.has(item.localUri) && !ignoreAsset(item))).catch(err => rejectModule.call(this, err, 4 /* LOG_TYPE.PROCESS */));
3500
+ await this.finalizeTask(this.taskAssets.filter(item => item.tasks?.find(data => !data.preceding) && item.localUri && this.has(item.localUri) && !ignoreAsset(item))).catch(err => rejectModule.call(this, err, 4));
3499
3501
  if (this.aborted) {
3500
3502
  return Promise.reject((0, types_1.createAbortError)());
3501
3503
  }
@@ -3506,12 +3508,12 @@ class FileManager extends core_1.Host {
3506
3508
  if (!filesToRemove.has(localUri) && !checkHash.call(this, localUri, true, item.checksumOutput)) {
3507
3509
  item.invalid = true;
3508
3510
  filesToRemove.add(localUri);
3509
- this.writeFail(["Checksum did not match" /* ERR_MESSAGE.FAILED_CHECKSUM */, path.basename(localUri)], (0, types_1.errorValue)(localUri, "Invalid checksum" /* ERR_MESSAGE.CHECKSUM */), { type: 32 /* LOG_TYPE.FILE */, startTime, queue: true });
3511
+ this.writeFail(["Checksum did not match", path.basename(localUri)], (0, types_1.errorValue)(localUri, "Invalid checksum"), { type: 32, startTime, queue: true });
3510
3512
  }
3511
3513
  }
3512
3514
  }
3513
3515
  removeFiles();
3514
- await this.finalizeCloud().catch(err => rejectModule.call(this, err, 64 /* LOG_TYPE.CLOUD */));
3516
+ await this.finalizeCloud().catch(err => rejectModule.call(this, err, 64));
3515
3517
  if (this.aborted) {
3516
3518
  return Promise.reject((0, types_1.createAbortError)());
3517
3519
  }
@@ -3540,22 +3542,22 @@ class FileManager extends core_1.Host {
3540
3542
  try {
3541
3543
  const files = (await FileManager.writeChecksum(baseDirectory, checksum.filename, checksum));
3542
3544
  if (sumTime) {
3543
- this.writeTimeElapsed(checksum.algorithm || "sha256" /* HASH_OUTPUT.ALGORITHM */, [baseDirectory, files.length + (files.length === 1 ? ' file' : ' files')], sumTime, { ...core_1.Host.LOG_STYLE_WARN });
3545
+ this.writeTimeElapsed(checksum.algorithm || "sha256", [baseDirectory, files.length + (files.length === 1 ? ' file' : ' files')], sumTime, { ...core_1.Host.LOG_STYLE_WARN });
3544
3546
  }
3545
3547
  }
3546
3548
  catch (err) {
3547
- this.writeFail(["Unable to read directory" /* ERR_MESSAGE.READ_DIRECTORY */, path.basename(baseDirectory)], err, { type: 32 /* LOG_TYPE.FILE */, startTime });
3549
+ this.writeFail(["Unable to read directory", path.basename(baseDirectory)], err, { type: 32, startTime });
3548
3550
  }
3549
3551
  }
3550
3552
  }
3551
- await this.finalizeCleanup().catch(err => rejectModule.call(this, err, 1 /* LOG_TYPE.SYSTEM */));
3553
+ await this.finalizeCleanup().catch(err => rejectModule.call(this, err, 1));
3552
3554
  removeFiles();
3553
3555
  if (LOG_TIMEELAPSED) {
3554
3556
  const [h, d, c] = this[kDownloadStats];
3555
3557
  const errorCount = this.errorCount;
3556
3558
  const message = [];
3557
3559
  if (errorCount) {
3558
- message.push('ERROR ' + errorCount); // eslint-disable-line @typescript-eslint/no-base-to-string
3560
+ message.push('ERROR ' + errorCount);
3559
3561
  }
3560
3562
  let [size, count] = h;
3561
3563
  if (count) {
@@ -3581,7 +3583,7 @@ class FileManager extends core_1.Host {
3581
3583
  this.Request.close();
3582
3584
  }
3583
3585
  set restarting(value) {
3584
- this.finalizeState = (this[kRestarting] = value) ? 3 /* FINALIZE_STATE.RESTART */ : 0 /* FINALIZE_STATE.READY */;
3586
+ this.finalizeState = (this[kRestarting] = value) ? 3 : 0;
3585
3587
  }
3586
3588
  get restarting() {
3587
3589
  return this[kRestarting];