@e-mc/file-manager 0.4.2 → 0.5.1
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/index.js +43 -45
- package/package.json +10 -10
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint @typescript-eslint/no-explicit-any: "off" */
|
|
3
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
3
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const fs = require("fs");
|
|
@@ -640,7 +640,6 @@ class FileManager extends core_1.Host {
|
|
|
640
640
|
}
|
|
641
641
|
constructor(baseDirectory, config, permission, postFinalize) {
|
|
642
642
|
super(config);
|
|
643
|
-
this.archiving = false;
|
|
644
643
|
this.finalizeState = 0 /* FINALIZE_STATE.READY */;
|
|
645
644
|
this.processTimeout = PROCESS_TIMEOUT.filemanager;
|
|
646
645
|
this.Document = [];
|
|
@@ -665,33 +664,26 @@ class FileManager extends core_1.Host {
|
|
|
665
664
|
this.emptyDir = new Set();
|
|
666
665
|
this._moduleName = 'filemanager';
|
|
667
666
|
this._pendingResult = null;
|
|
668
|
-
this[_c] =
|
|
669
|
-
this[_d] =
|
|
670
|
-
this[_e] =
|
|
671
|
-
this[_f] =
|
|
672
|
-
this[_g] =
|
|
673
|
-
this[_h] =
|
|
674
|
-
this[_j] =
|
|
675
|
-
this[_k] =
|
|
676
|
-
|
|
677
|
-
if (typeof permission === 'boolean') {
|
|
678
|
-
this.archiving = permission;
|
|
679
|
-
permission = undefined;
|
|
680
|
-
}
|
|
681
|
-
else if (isFunction(permission)) {
|
|
667
|
+
this[_c] = false;
|
|
668
|
+
this[_d] = 0;
|
|
669
|
+
this[_e] = false;
|
|
670
|
+
this[_f] = null;
|
|
671
|
+
this[_g] = RECURSION_LIMIT;
|
|
672
|
+
this[_h] = {};
|
|
673
|
+
this[_j] = [[0, 0], [0, 0], [0, 0]];
|
|
674
|
+
this[_k] = {};
|
|
675
|
+
if (isFunction(permission)) {
|
|
682
676
|
postFinalize = permission;
|
|
683
677
|
permission = undefined;
|
|
684
678
|
}
|
|
685
|
-
else if (!core_1.Host.isPermission(permission)) {
|
|
686
|
-
permission = undefined;
|
|
687
|
-
}
|
|
688
679
|
if (LOG_TIMEPROCESS) {
|
|
689
680
|
setCpuUsage.call(this);
|
|
690
681
|
}
|
|
691
|
-
|
|
692
|
-
this
|
|
682
|
+
const index = baseDirectory.length - 1;
|
|
683
|
+
this[kBaseDirectory] = path.normalize(baseDirectory[index] === path.sep ? baseDirectory.substring(0, index) : baseDirectory);
|
|
684
|
+
this.permission = permission && core_1.Host.isPermission(permission) ? permission : core_1.Host.getPermissionFromSettings();
|
|
693
685
|
this.sessionId = (++SESSION_ID === SESSION_LIMIT ? SESSION_ID = 1 : SESSION_ID).toString();
|
|
694
|
-
const { assets = [], dataSource, timeout } = config;
|
|
686
|
+
const { assets = [], incremental, dataSource, timeout } = config;
|
|
695
687
|
let targeted;
|
|
696
688
|
for (let i = 0, length = assets.length; i < length; ++i) {
|
|
697
689
|
const item = assets[i];
|
|
@@ -722,6 +714,7 @@ class FileManager extends core_1.Host {
|
|
|
722
714
|
item.id || (item.id = ++ASSET_ID);
|
|
723
715
|
}
|
|
724
716
|
this._assets = assets.slice(0);
|
|
717
|
+
this[kIncremental] = incremental === 'staging' ? 'staging' : 'none';
|
|
725
718
|
if (targeted) {
|
|
726
719
|
this.using(...targeted);
|
|
727
720
|
}
|
|
@@ -758,7 +751,7 @@ class FileManager extends core_1.Host {
|
|
|
758
751
|
}
|
|
759
752
|
}
|
|
760
753
|
}
|
|
761
|
-
*[(_b = Symbol.toStringTag, _c =
|
|
754
|
+
*[(_b = Symbol.toStringTag, _c = kRestarting, _d = kDelayed, _e = kCleared, _f = KTimerMain, _g = kRecursionLimit, _h = kProcessTimeout, _j = kDownloadStats, _k = kReplaceMap, Symbol.iterator)]() {
|
|
762
755
|
for (const file of this.files) {
|
|
763
756
|
yield file;
|
|
764
757
|
}
|
|
@@ -2178,24 +2171,28 @@ class FileManager extends core_1.Host {
|
|
|
2178
2171
|
}, types_1.THRESHOLD.FILEMANAGER_INTERVAL);
|
|
2179
2172
|
const hasIncremental = (value) => value === 'etag' || value === 'exists';
|
|
2180
2173
|
const { assets, cacheToDisk, cacheToMemory, fetchedAssets, Watch: watch } = this;
|
|
2181
|
-
const
|
|
2182
|
-
const downloadble = new Map();
|
|
2174
|
+
const downloadable = new Map();
|
|
2183
2175
|
const completed = Object.create(null);
|
|
2184
2176
|
const processing = Object.create(null);
|
|
2185
2177
|
const downloading = Object.create(null);
|
|
2186
|
-
const appending =
|
|
2187
|
-
const bundling =
|
|
2188
|
-
const originCount =
|
|
2178
|
+
const appending = Object.create(null);
|
|
2179
|
+
const bundling = Object.create(null);
|
|
2180
|
+
const originCount = Object.create(null);
|
|
2189
2181
|
const emptied = [this.baseDirectory];
|
|
2182
|
+
const staging = this[kIncremental] === 'staging';
|
|
2190
2183
|
const incremental = this.config.incremental;
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2184
|
+
let cacheable = false, cacheOpen = false, cacheEtag = false;
|
|
2185
|
+
if (!staging) {
|
|
2186
|
+
cacheable = this[kRecursionLimit] === RECURSION_LIMIT;
|
|
2187
|
+
if (cacheable) {
|
|
2188
|
+
if (cacheOpen = hasIncremental(incremental)) {
|
|
2189
|
+
this[kIncremental] = incremental;
|
|
2190
|
+
}
|
|
2191
|
+
cacheEtag = incremental === 'etag';
|
|
2192
|
+
}
|
|
2193
|
+
else {
|
|
2194
|
+
this[kIncremental] = 'none';
|
|
2195
|
+
}
|
|
2199
2196
|
}
|
|
2200
2197
|
const targeting = this._usingObjects.size > 0;
|
|
2201
2198
|
const isCacheable = (file) => file.initialValue?.cacheable !== false;
|
|
@@ -2207,6 +2204,7 @@ class FileManager extends core_1.Host {
|
|
|
2207
2204
|
case false:
|
|
2208
2205
|
case 'none':
|
|
2209
2206
|
case 'exists':
|
|
2207
|
+
case 'staging':
|
|
2210
2208
|
return false;
|
|
2211
2209
|
case 'etag':
|
|
2212
2210
|
return true;
|
|
@@ -2234,14 +2232,14 @@ class FileManager extends core_1.Host {
|
|
|
2234
2232
|
}
|
|
2235
2233
|
};
|
|
2236
2234
|
const checkQueue = (file, localUri, pathname, content) => {
|
|
2237
|
-
var
|
|
2235
|
+
var _l;
|
|
2238
2236
|
if (!createFolder(file, pathname)) {
|
|
2239
2237
|
return true;
|
|
2240
2238
|
}
|
|
2241
2239
|
const { bundleId, bundleIndex = -1 } = file;
|
|
2242
2240
|
if (!(0, types_1.isEmpty)(bundleId) && bundleIndex >= 0) {
|
|
2243
2241
|
const items = appending[localUri] || (appending[localUri] = []);
|
|
2244
|
-
bundling[
|
|
2242
|
+
bundling[_l = file.uri] || (bundling[_l] = []);
|
|
2245
2243
|
if (bundleIndex > 0) {
|
|
2246
2244
|
items[bundleIndex - 1] = file;
|
|
2247
2245
|
const url = file.url;
|
|
@@ -2668,7 +2666,7 @@ class FileManager extends core_1.Host {
|
|
|
2668
2666
|
item.invalid = true;
|
|
2669
2667
|
}
|
|
2670
2668
|
else if (target.localUri) {
|
|
2671
|
-
|
|
2669
|
+
downloadable.set(item, download);
|
|
2672
2670
|
}
|
|
2673
2671
|
else {
|
|
2674
2672
|
childDownload = download;
|
|
@@ -2706,7 +2704,7 @@ class FileManager extends core_1.Host {
|
|
|
2706
2704
|
}
|
|
2707
2705
|
}
|
|
2708
2706
|
else if (childBundle) {
|
|
2709
|
-
|
|
2707
|
+
downloadable.set(childBundle, childDownload);
|
|
2710
2708
|
}
|
|
2711
2709
|
else if (cached) {
|
|
2712
2710
|
try {
|
|
@@ -2741,16 +2739,16 @@ class FileManager extends core_1.Host {
|
|
|
2741
2739
|
}
|
|
2742
2740
|
}
|
|
2743
2741
|
}
|
|
2744
|
-
|
|
2742
|
+
downloadable.set(item, download);
|
|
2745
2743
|
}
|
|
2746
|
-
if (
|
|
2747
|
-
for (const { url } of
|
|
2744
|
+
if (downloadable.size > 1 && this.Request.httpVersion !== 1) {
|
|
2745
|
+
for (const { url } of downloadable.keys()) {
|
|
2748
2746
|
if (url?.protocol === 'https:') {
|
|
2749
2747
|
originCount[url.origin] = (originCount[url.origin] || 0) + 1;
|
|
2750
2748
|
}
|
|
2751
2749
|
}
|
|
2752
2750
|
}
|
|
2753
|
-
for (const [item, download] of
|
|
2751
|
+
for (const [item, download] of downloadable) {
|
|
2754
2752
|
if (this.aborted) {
|
|
2755
2753
|
break;
|
|
2756
2754
|
}
|
|
@@ -2782,7 +2780,7 @@ class FileManager extends core_1.Host {
|
|
|
2782
2780
|
}
|
|
2783
2781
|
}
|
|
2784
2782
|
else if (uri = item.uri) {
|
|
2785
|
-
const checkDest = (src) =>
|
|
2783
|
+
const checkDest = (src) => staging || !(0, lib_v4_1.hasSameStat)(src, localUri);
|
|
2786
2784
|
const type = item.fetchType;
|
|
2787
2785
|
const bundleMain = !(0, types_1.isEmpty)(item.bundleId) && item.bundleIndex === 0;
|
|
2788
2786
|
let isHttp;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/file-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
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": "BSD 3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/cloud": "0.
|
|
24
|
-
"@e-mc/compress": "0.
|
|
25
|
-
"@e-mc/core": "0.
|
|
26
|
-
"@e-mc/document": "0.
|
|
27
|
-
"@e-mc/image": "0.
|
|
28
|
-
"@e-mc/request": "0.
|
|
29
|
-
"@e-mc/task": "0.
|
|
30
|
-
"@e-mc/types": "0.
|
|
31
|
-
"@e-mc/watch": "0.
|
|
23
|
+
"@e-mc/cloud": "0.5.1",
|
|
24
|
+
"@e-mc/compress": "0.5.1",
|
|
25
|
+
"@e-mc/core": "0.5.1",
|
|
26
|
+
"@e-mc/document": "0.5.1",
|
|
27
|
+
"@e-mc/image": "0.5.1",
|
|
28
|
+
"@e-mc/request": "0.5.1",
|
|
29
|
+
"@e-mc/task": "0.5.1",
|
|
30
|
+
"@e-mc/types": "0.5.1",
|
|
31
|
+
"@e-mc/watch": "0.5.1"
|
|
32
32
|
}
|
|
33
33
|
}
|