@e-mc/file-manager 0.9.4 → 0.9.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.
- package/README.md +10 -10
- package/index.js +39 -39
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.9.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.9.6/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { DataSource, IncrementalMatch, TaskAction } from "./squared";
|
|
@@ -286,15 +286,15 @@ NOTE: **FileManager** is a sub-class of [Host](https://www.npmjs.com/package/@e-
|
|
|
286
286
|
|
|
287
287
|
## References
|
|
288
288
|
|
|
289
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
290
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
291
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
292
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
293
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
294
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
295
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
296
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
297
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
289
|
+
- https://www.unpkg.com/@e-mc/types@0.9.6/lib/squared.d.ts
|
|
290
|
+
- https://www.unpkg.com/@e-mc/types@0.9.6/lib/asset.d.ts
|
|
291
|
+
- https://www.unpkg.com/@e-mc/types@0.9.6/lib/core.d.ts
|
|
292
|
+
- https://www.unpkg.com/@e-mc/types@0.9.6/lib/filemanager.d.ts
|
|
293
|
+
- https://www.unpkg.com/@e-mc/types@0.9.6/lib/logger.d.ts
|
|
294
|
+
- https://www.unpkg.com/@e-mc/types@0.9.6/lib/module.d.ts
|
|
295
|
+
- https://www.unpkg.com/@e-mc/types@0.9.6/lib/node.d.ts
|
|
296
|
+
- https://www.unpkg.com/@e-mc/types@0.9.6/lib/request.d.ts
|
|
297
|
+
- https://www.unpkg.com/@e-mc/types@0.9.6/lib/settings.d.ts
|
|
298
298
|
|
|
299
299
|
* https://www.npmjs.com/package/@types/node
|
|
300
300
|
|
package/index.js
CHANGED
|
@@ -1201,26 +1201,17 @@ class FileManager extends core_1.Host {
|
|
|
1201
1201
|
}
|
|
1202
1202
|
switch (name) {
|
|
1203
1203
|
case 'cloud': {
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
const instance = new watch_1(...args);
|
|
1212
|
-
instance.host = this;
|
|
1213
|
-
instance.init(this.config);
|
|
1214
|
-
observeFile.call(this, instance);
|
|
1215
|
-
return this.Watch = instance;
|
|
1216
|
-
}
|
|
1217
|
-
case 'compress': {
|
|
1218
|
-
const instance = new compress_1(args[0]);
|
|
1219
|
-
instance.host = this;
|
|
1220
|
-
instance.init();
|
|
1221
|
-
observeFile.call(this, instance);
|
|
1222
|
-
return this.Compress = instance;
|
|
1204
|
+
if ((0, types_1.isArray)(args[1])) {
|
|
1205
|
+
const instance = new cloud_1(args[0], args[1]);
|
|
1206
|
+
instance.host = this;
|
|
1207
|
+
instance.init(this.config);
|
|
1208
|
+
observeFile.call(this, instance);
|
|
1209
|
+
return this.Cloud = instance;
|
|
1210
|
+
}
|
|
1223
1211
|
}
|
|
1212
|
+
case 'watch':
|
|
1213
|
+
case 'compress':
|
|
1214
|
+
return this.install(name, ...args);
|
|
1224
1215
|
default:
|
|
1225
1216
|
return null;
|
|
1226
1217
|
}
|
|
@@ -1787,25 +1778,25 @@ class FileManager extends core_1.Host {
|
|
|
1787
1778
|
}
|
|
1788
1779
|
}
|
|
1789
1780
|
file.fetchType = type;
|
|
1781
|
+
if (file.document) {
|
|
1782
|
+
for (const { instance } of this.Document) {
|
|
1783
|
+
if (this.hasDocument(instance, file.document)) {
|
|
1784
|
+
instance.setLocalUri?.(file, replace);
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1790
1788
|
const segments = [];
|
|
1791
1789
|
if (file.moveTo) {
|
|
1792
1790
|
segments.push(file.moveTo);
|
|
1793
1791
|
}
|
|
1794
1792
|
if (file.pathname) {
|
|
1795
|
-
segments.push(file.pathname
|
|
1796
|
-
}
|
|
1797
|
-
if (file.document) {
|
|
1798
|
-
for (const { instance } of this.Document) {
|
|
1799
|
-
if (instance.setLocalUri && this.hasDocument(instance, file.document)) {
|
|
1800
|
-
instance.setLocalUri(file, replace);
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1793
|
+
segments.push(file.pathname);
|
|
1803
1794
|
}
|
|
1804
|
-
const pathname = segments.length ? path.join(this.baseDirectory, ...segments) : this.baseDirectory;
|
|
1795
|
+
const pathname = segments.length > 0 ? path.join(this.baseDirectory, ...segments) : this.baseDirectory;
|
|
1805
1796
|
const localUri = file.filename ? path.join(pathname, file.filename) : pathname;
|
|
1806
1797
|
file.localUri = localUri;
|
|
1807
|
-
if (type !== 4) {
|
|
1808
|
-
file.mimeType
|
|
1798
|
+
if (!file.mimeType && type !== 4) {
|
|
1799
|
+
file.mimeType = file.url && core_1.Host.lookupMime(path.basename(file.url.pathname)) || core_1.Host.lookupMime(file.filename);
|
|
1809
1800
|
}
|
|
1810
1801
|
return { pathname, localUri };
|
|
1811
1802
|
}
|
|
@@ -2304,12 +2295,14 @@ class FileManager extends core_1.Host {
|
|
|
2304
2295
|
return 0;
|
|
2305
2296
|
}
|
|
2306
2297
|
const stat = this[kDownloadStats][type];
|
|
2307
|
-
stat
|
|
2308
|
-
|
|
2298
|
+
if (stat) {
|
|
2299
|
+
stat[0] += result;
|
|
2300
|
+
stat[1]++;
|
|
2301
|
+
}
|
|
2309
2302
|
return result;
|
|
2310
2303
|
}
|
|
2311
2304
|
getDownload(type = 0) {
|
|
2312
|
-
return this[kDownloadStats][type];
|
|
2305
|
+
return this[kDownloadStats][type] || [NaN, 0];
|
|
2313
2306
|
}
|
|
2314
2307
|
async fetchObject(uri, options = {}) {
|
|
2315
2308
|
if (typeof options === 'string') {
|
|
@@ -3195,7 +3188,7 @@ class FileManager extends core_1.Host {
|
|
|
3195
3188
|
request.httpVersion = (originCount[request.url.origin] || 0) <= 1 ? 1 : undefined;
|
|
3196
3189
|
request.connected = headers => {
|
|
3197
3190
|
applyHeaders(item, headers, true, mainEtag);
|
|
3198
|
-
return item.willChange || !!etagDir && (cacheDir || !item.contentLength || cacheToMemory.within(item.contentLength));
|
|
3191
|
+
return item.willChange || !!etagDir && (cacheDir || !item.contentLength || cacheToMemory.within(item.contentLength)) || this.hasLog('progress');
|
|
3199
3192
|
};
|
|
3200
3193
|
}
|
|
3201
3194
|
else {
|
|
@@ -3500,13 +3493,14 @@ class FileManager extends core_1.Host {
|
|
|
3500
3493
|
}
|
|
3501
3494
|
const length = status.length;
|
|
3502
3495
|
const logCurrent = (0, types_1.getLogCurrent)();
|
|
3503
|
-
const redraw = processTask.logCurrent !== logCurrent;
|
|
3504
3496
|
const formatSegment = (endTime, value) => endTime ? value : chalk.bgGray.black(value);
|
|
3497
|
+
let redraw = processTask.logCurrent !== logCurrent;
|
|
3505
3498
|
if (redraw || length > processTask.length) {
|
|
3506
3499
|
this.pauseLog();
|
|
3507
3500
|
processTask.logCurrent = logCurrent;
|
|
3508
3501
|
PROCESS_STDOUT.write('\n'.repeat(redraw ? length : length - processTask.length));
|
|
3509
3502
|
processTask.length = length;
|
|
3503
|
+
redraw = true;
|
|
3510
3504
|
}
|
|
3511
3505
|
PROCESS_STDOUT.moveCursor(0, -length);
|
|
3512
3506
|
processTask.updated = currentTime;
|
|
@@ -3518,11 +3512,12 @@ class FileManager extends core_1.Host {
|
|
|
3518
3512
|
if (!endTime) {
|
|
3519
3513
|
finished = false;
|
|
3520
3514
|
}
|
|
3521
|
-
if (item.previousBytes === receivedBytes
|
|
3515
|
+
if (!redraw && item.previousBytes === receivedBytes) {
|
|
3522
3516
|
PROCESS_STDOUT.moveCursor(0, 1);
|
|
3523
3517
|
continue;
|
|
3524
3518
|
}
|
|
3525
3519
|
if (item.output) {
|
|
3520
|
+
PROCESS_STDOUT.clearLine(0);
|
|
3526
3521
|
PROCESS_STDOUT.write(item.output);
|
|
3527
3522
|
continue;
|
|
3528
3523
|
}
|
|
@@ -3544,9 +3539,14 @@ class FileManager extends core_1.Host {
|
|
|
3544
3539
|
}
|
|
3545
3540
|
const diffTime = currentTime - item.startTime;
|
|
3546
3541
|
const time = formatSegment(endTime, formatMinutes(diffTime).padStart(titleWidth));
|
|
3547
|
-
const size = formatSegment(endTime, (0, types_1.formatSize)(receivedBytes, { unit: receivedBytes < 1048576 ? 'KB' : receivedBytes < 1073741824 ? 'MB' : 'GB', unitSeparator: ' ' }).padStart(9));
|
|
3542
|
+
const size = formatSegment(endTime, (0, types_1.formatSize)(receivedBytes, { unit: receivedBytes < 1048576 ? 'KB' : receivedBytes < 1073741824 ? 'MB' : 'GB', unitSeparator: ' ', fixedDecimals: true, decimalPlaces: 2 }).padStart(9));
|
|
3548
3543
|
const speed = formatSegment(endTime, (0, util_1.getTransferRate)(receivedBytes, item.dataTime ? (0, types_1.convertTime)(process.hrtime(item.dataTime), false) * 1000 : diffTime, ' ').padStart(10));
|
|
3549
|
-
|
|
3544
|
+
let output = time + ` ${chalk.blackBright(':')} ${endTime && bars !== -1 ? chalk.bgBlack.gray(item.url) : item.url}| ${size} |`;
|
|
3545
|
+
if (!isNaN(percent)) {
|
|
3546
|
+
output += speed + ` |${bars === -1 ? chalk.bgBlack.green.bold('>'.repeat(25)) : (bars > 0 ? chalk.yellow('>'.repeat(bars)) : '') + (25 - bars > 0 ? chalk.gray((endTime ? '#' : '-').repeat(25 - bars)) : '')}| ` + (endTime ? bars === -1 ? chalk.bold('100%') : chalk.red('ERR!') : Math.trunc(percent).toString().padStart(3) + '%');
|
|
3547
|
+
}
|
|
3548
|
+
output += '\n';
|
|
3549
|
+
PROCESS_STDOUT.clearLine(0);
|
|
3550
3550
|
PROCESS_STDOUT.write(output);
|
|
3551
3551
|
if (endTime) {
|
|
3552
3552
|
item.output = output;
|
|
@@ -3608,7 +3608,7 @@ class FileManager extends core_1.Host {
|
|
|
3608
3608
|
}
|
|
3609
3609
|
else {
|
|
3610
3610
|
if (data instanceof URL && data.protocol === 'file:') {
|
|
3611
|
-
data =
|
|
3611
|
+
data = core_1.Host.resolveFile(data);
|
|
3612
3612
|
}
|
|
3613
3613
|
if ((0, types_1.isString)(data) && core_1.Host.isPath(data, true) && this.canRead(data)) {
|
|
3614
3614
|
data = fs.createReadStream(data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/file-manager",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"description": "FileManager constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
"license": "BSD 3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/cloud": "0.9.
|
|
24
|
-
"@e-mc/compress": "0.9.
|
|
25
|
-
"@e-mc/core": "0.9.
|
|
26
|
-
"@e-mc/document": "0.9.
|
|
27
|
-
"@e-mc/image": "0.9.
|
|
28
|
-
"@e-mc/request": "0.9.
|
|
29
|
-
"@e-mc/task": "0.9.
|
|
30
|
-
"@e-mc/types": "0.9.
|
|
31
|
-
"@e-mc/watch": "0.9.
|
|
23
|
+
"@e-mc/cloud": "0.9.6",
|
|
24
|
+
"@e-mc/compress": "0.9.6",
|
|
25
|
+
"@e-mc/core": "0.9.6",
|
|
26
|
+
"@e-mc/document": "0.9.6",
|
|
27
|
+
"@e-mc/image": "0.9.6",
|
|
28
|
+
"@e-mc/request": "0.9.6",
|
|
29
|
+
"@e-mc/task": "0.9.6",
|
|
30
|
+
"@e-mc/types": "0.9.6",
|
|
31
|
+
"@e-mc/watch": "0.9.6",
|
|
32
32
|
"chalk": "4.1.2",
|
|
33
33
|
"picomatch": "^4.0.2"
|
|
34
34
|
}
|