@e-mc/file-manager 0.5.5 → 0.5.7

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 +1 -1
  2. package/README.md +1 -1
  3. package/index.js +21 -16
  4. package/package.json +10 -10
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 Anya Forger
1
+ Copyright 2024 An Pham
2
2
 
3
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
4
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @e-mc/file-manager
2
2
 
3
- PEP 402 - Forever
3
+ PEP 402 - Forever Any Ketchup
4
4
 
5
5
  ## LICENSE
6
6
 
package/index.js CHANGED
@@ -134,11 +134,11 @@ function abortedHost() {
134
134
  return false;
135
135
  }
136
136
  function observeFile(instance) {
137
- instance.on('file:delete', (value, options) => this.delete(value, !!options?.emptyDir));
137
+ instance.on('file:delete', (value, options) => this.delete(value, !!(options === null || options === void 0 ? void 0 : options.emptyDir)));
138
138
  instance.on('file:copy', value => this.add(value));
139
139
  instance.on('file:move', (value, options) => {
140
140
  this.add(value);
141
- const src = options?.outSrc;
141
+ const src = options === null || options === void 0 ? void 0 : options.outSrc;
142
142
  if (src) {
143
143
  this.delete(src);
144
144
  }
@@ -934,8 +934,9 @@ class FileManager extends core_1.Host {
934
934
  if (options.all) {
935
935
  value = path.resolve(value);
936
936
  (options.id ? [this.assets.find(item => item.id === options.id)].filter(item => item) : this.assets.filter(item => item.localUri === value)).forEach(asset => {
937
- asset.transforms?.forEach(file => this.deleteFile(file, emptyDir));
938
- asset.descendants?.forEach(file => this.deleteFile(file, emptyDir));
937
+ var _l, _m;
938
+ (_l = asset.transforms) === null || _l === void 0 ? void 0 : _l.forEach(file => this.deleteFile(file, emptyDir));
939
+ (_m = asset.descendants) === null || _m === void 0 ? void 0 : _m.forEach(file => this.deleteFile(file, emptyDir));
939
940
  });
940
941
  }
941
942
  }
@@ -1491,7 +1492,7 @@ class FileManager extends core_1.Host {
1491
1492
  this.writeFail(["Unable to read file", path.basename(uri)], err, 32);
1492
1493
  }
1493
1494
  }
1494
- if (sourceUTF8?.[0] === '\uFEFF' && file.encoding !== 'utf16le') {
1495
+ if ((sourceUTF8 === null || sourceUTF8 === void 0 ? void 0 : sourceUTF8[0]) === '\uFEFF' && file.encoding !== 'utf16le') {
1495
1496
  sourceUTF8 = sourceUTF8.substring(1);
1496
1497
  }
1497
1498
  return file.sourceUTF8 = sourceUTF8 || '';
@@ -1569,7 +1570,7 @@ class FileManager extends core_1.Host {
1569
1570
  const getSeparator = (value) => newline || (newline = (0, util_2.getNewline)(value));
1570
1571
  if (content) {
1571
1572
  const replacing = this.contentToReplace.get(localUri);
1572
- if (replacing?.length) {
1573
+ if (replacing === null || replacing === void 0 ? void 0 : replacing.length) {
1573
1574
  for (let i = 0; i < replacing.length; ++i) {
1574
1575
  let value = appending[i];
1575
1576
  if ((0, types_1.isString)(value)) {
@@ -1709,6 +1710,7 @@ class FileManager extends core_1.Host {
1709
1710
  return mimeType;
1710
1711
  }
1711
1712
  async compressFile(file, overwrite = true) {
1713
+ var _l;
1712
1714
  const { localUri, compress } = file;
1713
1715
  const instance = this.Compress;
1714
1716
  if (instance && compress && localUri && (this.has(localUri) || (0, types_1.existsFlag)(file.flags))) {
@@ -1737,13 +1739,13 @@ class FileManager extends core_1.Host {
1737
1739
  if (output && (!condition || withinSizeRange(localUri, condition))) {
1738
1740
  try {
1739
1741
  if (overwrite || !fs.existsSync(output) || !(0, types_1.existsFlag)(file.flags) && fs.statSync(output).mtimeMs < this.startTime) {
1740
- config.timeout = this[kProcessTimeout].compress ?? PROCESS_TIMEOUT.compress;
1742
+ config.timeout = (_l = this[kProcessTimeout].compress) !== null && _l !== void 0 ? _l : PROCESS_TIMEOUT.compress;
1741
1743
  tasks.push(instance.tryFile(file.buffer || localUri, output, config, (err, result) => {
1742
1744
  if (err) {
1743
1745
  this.writeFail(["Unable to compress file", path.basename(localUri)], err, { type: 8, startTime: config.startTime });
1744
1746
  }
1745
1747
  else if ((0, types_1.isString)(result)) {
1746
- if (condition?.includes('%') && (0, lib_v4_1.getSize)(result) >= (0, lib_v4_1.getSize)(localUri)) {
1748
+ if ((condition === null || condition === void 0 ? void 0 : condition.includes('%')) && (0, lib_v4_1.getSize)(result) >= (0, lib_v4_1.getSize)(localUri)) {
1747
1749
  queueMicrotask(() => this.deleteFile(result));
1748
1750
  }
1749
1751
  else {
@@ -1770,7 +1772,7 @@ class FileManager extends core_1.Host {
1770
1772
  if (!this.aborted) {
1771
1773
  this.processing.push(data);
1772
1774
  let mimeType = file.mimeType;
1773
- if ((mimeType?.endsWith('unknown') || file.commands && !mimeType) && (mimeType = await this.findMime(data.file, true))) {
1775
+ if (((mimeType === null || mimeType === void 0 ? void 0 : mimeType.endsWith('unknown')) || file.commands && !mimeType) && (mimeType = await this.findMime(data.file, true))) {
1774
1776
  file.mimeType = mimeType;
1775
1777
  data.mimeType = mimeType;
1776
1778
  }
@@ -1945,8 +1947,9 @@ class FileManager extends core_1.Host {
1945
1947
  }
1946
1948
  }
1947
1949
  getProcessTimeout(handler) {
1950
+ var _l, _m;
1948
1951
  const moduleName = handler.instance.moduleName;
1949
- return this[kProcessTimeout][moduleName] ?? PROCESS_TIMEOUT[moduleName] ?? (handler.constructor.PROCESS_TIMEOUT || 0);
1952
+ return (_m = (_l = this[kProcessTimeout][moduleName]) !== null && _l !== void 0 ? _l : PROCESS_TIMEOUT[moduleName]) !== null && _m !== void 0 ? _m : (handler.constructor.PROCESS_TIMEOUT || 0);
1950
1953
  }
1951
1954
  clearProcessTimeout() {
1952
1955
  const timerMain = this[KTimerMain];
@@ -2191,7 +2194,7 @@ class FileManager extends core_1.Host {
2191
2194
  }
2192
2195
  }
2193
2196
  const targeting = this._usingObjects.size > 0;
2194
- const isCacheable = (file) => file.initialValue?.cacheable !== false;
2197
+ const isCacheable = (file) => { var _l; return ((_l = file.initialValue) === null || _l === void 0 ? void 0 : _l.cacheable) !== false; };
2195
2198
  const hasEtag = (file) => {
2196
2199
  if (!cacheable || !(0, types_1.existsFlag)(file.flags)) {
2197
2200
  return false;
@@ -2739,7 +2742,7 @@ class FileManager extends core_1.Host {
2739
2742
  }
2740
2743
  if (downloadable.size > 1 && this.Request.httpVersion !== 1) {
2741
2744
  for (const { url } of downloadable.keys()) {
2742
- if (url?.protocol === 'https:') {
2745
+ if ((url === null || url === void 0 ? void 0 : url.protocol) === 'https:') {
2743
2746
  originCount[url.origin] = (originCount[url.origin] || 0) + 1;
2744
2747
  }
2745
2748
  }
@@ -2806,7 +2809,7 @@ class FileManager extends core_1.Host {
2806
2809
  cacheBuffer = cacheToMemory.has(url);
2807
2810
  mainEtag = (0, types_1.mainFlag)(item.flags) && (cacheEtag || item.incremental === 'etag');
2808
2811
  }
2809
- const closeResponse = () => client?.destroy();
2812
+ const closeResponse = () => client === null || client === void 0 ? void 0 : client.destroy();
2810
2813
  const downloadUri = (request, etagDir) => {
2811
2814
  if (checkEtag) {
2812
2815
  item.flags &= ~128;
@@ -3082,6 +3085,7 @@ class FileManager extends core_1.Host {
3082
3085
  this.cleared = true;
3083
3086
  }
3084
3087
  async finalizeCompress(assets) {
3088
+ var _l;
3085
3089
  const compress = this.Compress;
3086
3090
  if (!(compress && assets.length)) {
3087
3091
  return;
@@ -3102,7 +3106,7 @@ class FileManager extends core_1.Host {
3102
3106
  const found = output.filter(value => value.format === format);
3103
3107
  for (const config of found.length ? found : output) {
3104
3108
  const options = { ...config };
3105
- options.timeout = this[kProcessTimeout].compress ?? PROCESS_TIMEOUT.compress;
3109
+ options.timeout = (_l = this[kProcessTimeout].compress) !== null && _l !== void 0 ? _l : PROCESS_TIMEOUT.compress;
3106
3110
  options.proxyUrl = (uri) => {
3107
3111
  const proxy = this.Request.proxyOf(uri);
3108
3112
  return proxy ? proxy.host.href : '';
@@ -3176,6 +3180,7 @@ class FileManager extends core_1.Host {
3176
3180
  }
3177
3181
  }
3178
3182
  async finalize() {
3183
+ var _l;
3179
3184
  if (this.aborted) {
3180
3185
  return Promise.reject((0, types_1.createAbortError)());
3181
3186
  }
@@ -3228,7 +3233,7 @@ class FileManager extends core_1.Host {
3228
3233
  }
3229
3234
  }
3230
3235
  removeFiles();
3231
- 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));
3236
+ await this.finalizeTask(this.taskAssets.filter(item => { var _l; return ((_l = item.tasks) === null || _l === void 0 ? void 0 : _l.find(data => !data.preceding)) && item.localUri && this.has(item.localUri) && !ignoreAsset(item); })).catch(err => rejectModule.call(this, err, 4));
3232
3237
  if (this.aborted) {
3233
3238
  return Promise.reject((0, types_1.createAbortError)());
3234
3239
  }
@@ -3265,7 +3270,7 @@ class FileManager extends core_1.Host {
3265
3270
  }
3266
3271
  this.writeTimeElapsed('CLOSE', ['No further modifications', message.join(' | ')], startTime, { ...core_1.Host.LOG_STYLE_WARN });
3267
3272
  }
3268
- this.Watch?.start(this.assets);
3273
+ (_l = this.Watch) === null || _l === void 0 ? void 0 : _l.start(this.assets);
3269
3274
  }
3270
3275
  close() {
3271
3276
  this.Request.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/file-manager",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "FileManager constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,14 +20,14 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/cloud": "0.5.5",
24
- "@e-mc/compress": "0.5.5",
25
- "@e-mc/core": "0.5.5",
26
- "@e-mc/document": "0.5.5",
27
- "@e-mc/image": "0.5.5",
28
- "@e-mc/request": "0.5.5",
29
- "@e-mc/task": "0.5.5",
30
- "@e-mc/types": "0.5.5",
31
- "@e-mc/watch": "0.5.5"
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
32
  }
33
33
  }