@e-mc/file-manager 0.6.2 → 0.6.4

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 Ninja Scroll
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 Kagerō
3
+ PEP 402 - Forever Any Mayo
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;
@@ -2737,7 +2740,7 @@ class FileManager extends core_1.Host {
2737
2740
  }
2738
2741
  if (downloadable.size > 1 && this.Request.httpVersion !== 1) {
2739
2742
  for (const { url } of downloadable.keys()) {
2740
- if (url?.protocol === 'https:') {
2743
+ if ((url === null || url === void 0 ? void 0 : url.protocol) === 'https:') {
2741
2744
  originCount[url.origin] = (originCount[url.origin] || 0) + 1;
2742
2745
  }
2743
2746
  }
@@ -2809,7 +2812,7 @@ class FileManager extends core_1.Host {
2809
2812
  cacheBuffer = cacheToMemory.has(url);
2810
2813
  mainEtag = (0, types_1.mainFlag)(item.flags) && (cacheEtag || item.incremental === 'etag');
2811
2814
  }
2812
- const closeResponse = () => client?.destroy();
2815
+ const closeResponse = () => client === null || client === void 0 ? void 0 : client.destroy();
2813
2816
  const downloadUri = (request, etagDir) => {
2814
2817
  if (checkEtag) {
2815
2818
  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;
@@ -3106,7 +3110,7 @@ class FileManager extends core_1.Host {
3106
3110
  for (const config of found.length ? found : output) {
3107
3111
  const options = {
3108
3112
  ...config,
3109
- timeout: this[kProcessTimeout].compress ?? PROCESS_TIMEOUT.compress,
3113
+ timeout: (_l = this[kProcessTimeout].compress) !== null && _l !== void 0 ? _l : PROCESS_TIMEOUT.compress,
3110
3114
  proxyUrl: (uri) => {
3111
3115
  const proxy = this.Request.proxyOf(uri);
3112
3116
  return proxy ? proxy.host.href : '';
@@ -3177,6 +3181,7 @@ class FileManager extends core_1.Host {
3177
3181
  }
3178
3182
  }
3179
3183
  async finalize() {
3184
+ var _l;
3180
3185
  if (this.aborted) {
3181
3186
  return Promise.reject((0, types_1.createAbortError)());
3182
3187
  }
@@ -3229,7 +3234,7 @@ class FileManager extends core_1.Host {
3229
3234
  }
3230
3235
  }
3231
3236
  removeFiles();
3232
- 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));
3237
+ 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));
3233
3238
  if (this.aborted) {
3234
3239
  return Promise.reject((0, types_1.createAbortError)());
3235
3240
  }
@@ -3266,7 +3271,7 @@ class FileManager extends core_1.Host {
3266
3271
  }
3267
3272
  this.writeTimeElapsed('CLOSE', ['No further modifications', message.join(' | ')], startTime, { ...core_1.Host.LOG_STYLE_WARN });
3268
3273
  }
3269
- this.Watch?.start(this.assets);
3274
+ (_l = this.Watch) === null || _l === void 0 ? void 0 : _l.start(this.assets);
3270
3275
  }
3271
3276
  close() {
3272
3277
  this.Request.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/file-manager",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
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.6.2",
24
- "@e-mc/compress": "0.6.2",
25
- "@e-mc/core": "0.6.2",
26
- "@e-mc/document": "0.6.2",
27
- "@e-mc/image": "0.6.2",
28
- "@e-mc/request": "0.6.2",
29
- "@e-mc/task": "0.6.2",
30
- "@e-mc/types": "0.6.2",
31
- "@e-mc/watch": "0.6.2"
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
32
  }
33
33
  }