@e-mc/file-manager 0.8.7 → 0.8.8

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 +3 -7
  2. package/README.md +12 -12
  3. package/index.js +20 -15
  4. package/package.json +11 -11
package/LICENSE CHANGED
@@ -1,11 +1,7 @@
1
1
  Copyright 2024 An Pham
2
2
 
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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
 
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
6
 
7
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
-
9
- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
-
11
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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
1
  # @e-mc/file-manager
2
2
 
3
3
  * NodeJS 14
4
- * ES2020
4
+ * ES2019
5
5
 
6
6
  ## General Usage
7
7
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/index.d.ts
12
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/index.d.ts
13
13
 
14
14
  ```typescript
15
15
  import type { DataSource, IncrementalMatch, TaskAction } from "./squared";
@@ -191,16 +191,16 @@ interface FileManagerConstructor extends HostConstructor {
191
191
 
192
192
  ## References
193
193
 
194
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/squared.d.ts
195
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/asset.d.ts
196
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/core.d.ts
197
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/filemanager.d.ts
198
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/logger.d.ts
199
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/module.d.ts
200
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/node.d.ts
201
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/request.d.ts
202
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/settings.d.ts
194
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/squared.d.ts
195
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/asset.d.ts
196
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/core.d.ts
197
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/filemanager.d.ts
198
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/logger.d.ts
199
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/module.d.ts
200
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/node.d.ts
201
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/request.d.ts
202
+ - https://www.unpkg.com/@e-mc/types@0.8.8/lib/settings.d.ts
203
203
 
204
204
  ## LICENSE
205
205
 
206
- BSD 3-Clause
206
+ MIT
package/index.js CHANGED
@@ -224,11 +224,11 @@ function abortedHost() {
224
224
  return false;
225
225
  }
226
226
  function observeFile(instance) {
227
- instance.on('file:delete', (value, options) => this.delete(value, !!options?.emptyDir));
227
+ instance.on('file:delete', (value, options) => this.delete(value, !!(options === null || options === void 0 ? void 0 : options.emptyDir)));
228
228
  instance.on('file:copy', value => this.add(value));
229
229
  instance.on('file:move', (value, options) => {
230
230
  this.add(value);
231
- const src = options?.outSrc;
231
+ const src = options === null || options === void 0 ? void 0 : options.outSrc;
232
232
  if (src) {
233
233
  this.delete(src);
234
234
  }
@@ -1173,8 +1173,9 @@ class FileManager extends core_1.Host {
1173
1173
  if (options.all) {
1174
1174
  value = path.resolve(value);
1175
1175
  (options.id ? [this.assets.find(item => item.id === options.id)].filter(item => item) : this.assets.filter(item => item.localUri === value)).forEach(asset => {
1176
- asset.transforms?.forEach(file => this.deleteFile(file, emptyDir));
1177
- asset.descendants?.forEach(file => this.deleteFile(file, emptyDir));
1176
+ var _l, _m;
1177
+ (_l = asset.transforms) === null || _l === void 0 ? void 0 : _l.forEach(file => this.deleteFile(file, emptyDir));
1178
+ (_m = asset.descendants) === null || _m === void 0 ? void 0 : _m.forEach(file => this.deleteFile(file, emptyDir));
1178
1179
  });
1179
1180
  }
1180
1181
  }
@@ -1723,7 +1724,7 @@ class FileManager extends core_1.Host {
1723
1724
  this.writeFail(["Unable to read file", path.basename(uri)], err, 32);
1724
1725
  }
1725
1726
  }
1726
- if (sourceUTF8?.[0] === '\uFEFF' && file.encoding !== 'utf16le') {
1727
+ if ((sourceUTF8 === null || sourceUTF8 === void 0 ? void 0 : sourceUTF8[0]) === '\uFEFF' && file.encoding !== 'utf16le') {
1727
1728
  sourceUTF8 = sourceUTF8.substring(1);
1728
1729
  }
1729
1730
  return file.sourceUTF8 = sourceUTF8 || '';
@@ -1939,6 +1940,7 @@ class FileManager extends core_1.Host {
1939
1940
  return mimeType;
1940
1941
  }
1941
1942
  async compressFile(file, overwrite = true) {
1943
+ var _l;
1942
1944
  const { localUri, compress } = file;
1943
1945
  const instance = this.Compress;
1944
1946
  if (instance && compress && localUri && (this.has(localUri) || (0, types_1.existsFlag)(file.flags))) {
@@ -1967,13 +1969,13 @@ class FileManager extends core_1.Host {
1967
1969
  if (output && (!condition || withinSizeRange(localUri, condition))) {
1968
1970
  try {
1969
1971
  if (overwrite || !fs.existsSync(output) || !(0, types_1.existsFlag)(file.flags) && fs.statSync(output).mtimeMs < this.startTime) {
1970
- config.timeout = this[kProcessTimeout].compress ?? PROCESS_TIMEOUT.compress;
1972
+ config.timeout = (_l = this[kProcessTimeout].compress) !== null && _l !== void 0 ? _l : PROCESS_TIMEOUT.compress;
1971
1973
  tasks.push(instance.tryFile(file.buffer || localUri, output, config, (err, result) => {
1972
1974
  if (err) {
1973
1975
  this.writeFail(["Unable to compress file", path.basename(localUri)], err, { type: 8, startTime: config.startTime });
1974
1976
  }
1975
1977
  else if ((0, types_1.isString)(result)) {
1976
- if (condition?.includes('%') && (0, lib_v4_1.getSize)(result) >= (0, lib_v4_1.getSize)(localUri)) {
1978
+ if ((condition === null || condition === void 0 ? void 0 : condition.includes('%')) && (0, lib_v4_1.getSize)(result) >= (0, lib_v4_1.getSize)(localUri)) {
1977
1979
  queueMicrotask(() => this.deleteFile(result));
1978
1980
  }
1979
1981
  else {
@@ -2000,7 +2002,7 @@ class FileManager extends core_1.Host {
2000
2002
  if (!this.aborted) {
2001
2003
  this.processing.push(data);
2002
2004
  let mimeType = file.mimeType;
2003
- if ((mimeType?.endsWith('unknown') || file.commands && !mimeType) && (mimeType = await this.findMime(data.file, true))) {
2005
+ if (((mimeType === null || mimeType === void 0 ? void 0 : mimeType.endsWith('unknown')) || file.commands && !mimeType) && (mimeType = await this.findMime(data.file, true))) {
2004
2006
  file.mimeType = mimeType;
2005
2007
  data.mimeType = mimeType;
2006
2008
  }
@@ -2173,8 +2175,9 @@ class FileManager extends core_1.Host {
2173
2175
  }
2174
2176
  }
2175
2177
  getProcessTimeout(handler) {
2178
+ var _l, _m;
2176
2179
  const moduleName = handler.instance.moduleName;
2177
- return this[kProcessTimeout][moduleName] ?? PROCESS_TIMEOUT[moduleName] ?? (handler.constructor.PROCESS_TIMEOUT || 0);
2180
+ return (_m = (_l = this[kProcessTimeout][moduleName]) !== null && _l !== void 0 ? _l : PROCESS_TIMEOUT[moduleName]) !== null && _m !== void 0 ? _m : (handler.constructor.PROCESS_TIMEOUT || 0);
2178
2181
  }
2179
2182
  clearProcessTimeout() {
2180
2183
  const timerMain = this[KTimerMain];
@@ -2404,7 +2407,7 @@ class FileManager extends core_1.Host {
2404
2407
  const emptied = [this.baseDirectory];
2405
2408
  const staging = this[kIncremental] === "staging";
2406
2409
  const incremental = this.config.incremental;
2407
- const isCacheable = (file) => file.initialValue?.cacheable !== false;
2410
+ const isCacheable = (file) => { var _l; return ((_l = file.initialValue) === null || _l === void 0 ? void 0 : _l.cacheable) !== false; };
2408
2411
  const hasIncremental = (value) => value === "etag" || value === "exists";
2409
2412
  let cacheable = false, cacheOpen = false, cacheEtag = false;
2410
2413
  if (!staging) {
@@ -2988,7 +2991,7 @@ class FileManager extends core_1.Host {
2988
2991
  }
2989
2992
  if (downloadable.size > 1 && this.Request.httpVersion !== 1) {
2990
2993
  for (const { url } of downloadable.keys()) {
2991
- if (url?.protocol === 'https:') {
2994
+ if ((url === null || url === void 0 ? void 0 : url.protocol) === 'https:') {
2992
2995
  const count = originCount[url.origin];
2993
2996
  originCount[url.origin] = count ? count + 1 : 1;
2994
2997
  }
@@ -3063,7 +3066,7 @@ class FileManager extends core_1.Host {
3063
3066
  cacheBuffer = cacheToMemory.has(url);
3064
3067
  mainEtag = (0, types_1.mainFlag)(item.flags) && (cacheEtag || item.incremental === "etag");
3065
3068
  }
3066
- const closeResponse = () => client?.destroy();
3069
+ const closeResponse = () => client === null || client === void 0 ? void 0 : client.destroy();
3067
3070
  const downloadUri = (request, etagDir) => {
3068
3071
  if (checkEtag) {
3069
3072
  item.flags &= ~128;
@@ -3355,6 +3358,7 @@ class FileManager extends core_1.Host {
3355
3358
  this.cleared = true;
3356
3359
  }
3357
3360
  async finalizeCompress(assets) {
3361
+ var _l;
3358
3362
  const compress = this.Compress;
3359
3363
  if (!(assets.length && compress)) {
3360
3364
  return;
@@ -3379,7 +3383,7 @@ class FileManager extends core_1.Host {
3379
3383
  for (const config of found.length ? found : output) {
3380
3384
  const options = {
3381
3385
  ...config,
3382
- timeout: this[kProcessTimeout].compress ?? PROCESS_TIMEOUT.compress,
3386
+ timeout: (_l = this[kProcessTimeout].compress) !== null && _l !== void 0 ? _l : PROCESS_TIMEOUT.compress,
3383
3387
  proxyUrl: (uri) => {
3384
3388
  const proxy = this.Request.proxyOf(uri);
3385
3389
  return proxy ? proxy.host.href : '';
@@ -3445,6 +3449,7 @@ class FileManager extends core_1.Host {
3445
3449
  }
3446
3450
  }
3447
3451
  async finalize() {
3452
+ var _l;
3448
3453
  if (this.aborted) {
3449
3454
  return Promise.reject((0, types_1.createAbortError)());
3450
3455
  }
@@ -3497,7 +3502,7 @@ class FileManager extends core_1.Host {
3497
3502
  }
3498
3503
  }
3499
3504
  removeFiles();
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));
3505
+ 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));
3501
3506
  if (this.aborted) {
3502
3507
  return Promise.reject((0, types_1.createAbortError)());
3503
3508
  }
@@ -3577,7 +3582,7 @@ class FileManager extends core_1.Host {
3577
3582
  }
3578
3583
  this.writeTimeElapsed('CLOSE', ['No further modifications', message.join(' | ')], startTime, { ...core_1.Host.LOG_STYLE_WARN });
3579
3584
  }
3580
- this.Watch?.start(this.assets);
3585
+ (_l = this.Watch) === null || _l === void 0 ? void 0 : _l.start(this.assets);
3581
3586
  }
3582
3587
  close() {
3583
3588
  this.Request.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/file-manager",
3
- "version": "0.8.7",
3
+ "version": "0.8.8",
4
4
  "description": "FileManager constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -17,18 +17,18 @@
17
17
  "squared-functions"
18
18
  ],
19
19
  "author": "An Pham <anpham6@gmail.com>",
20
- "license": "BSD 3-Clause",
20
+ "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/cloud": "0.8.7",
24
- "@e-mc/compress": "0.8.7",
25
- "@e-mc/core": "0.8.7",
26
- "@e-mc/document": "0.8.7",
27
- "@e-mc/image": "0.8.7",
28
- "@e-mc/request": "0.8.7",
29
- "@e-mc/task": "0.8.7",
30
- "@e-mc/types": "0.8.7",
31
- "@e-mc/watch": "0.8.7",
23
+ "@e-mc/cloud": "0.8.8",
24
+ "@e-mc/compress": "0.8.8",
25
+ "@e-mc/core": "0.8.8",
26
+ "@e-mc/document": "0.8.8",
27
+ "@e-mc/image": "0.8.8",
28
+ "@e-mc/request": "0.8.8",
29
+ "@e-mc/task": "0.8.8",
30
+ "@e-mc/types": "0.8.8",
31
+ "@e-mc/watch": "0.8.8",
32
32
  "picomatch": "^3.0.1"
33
33
  }
34
34
  }