@e-mc/file-manager 0.7.3 → 0.7.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.
- package/index.js +21 -16
- package/package.json +10 -10
package/index.js
CHANGED
|
@@ -216,11 +216,11 @@ function abortedHost() {
|
|
|
216
216
|
return false;
|
|
217
217
|
}
|
|
218
218
|
function observeFile(instance) {
|
|
219
|
-
instance.on('file:delete', (value, options) => this.delete(value, !!options
|
|
219
|
+
instance.on('file:delete', (value, options) => this.delete(value, !!(options === null || options === void 0 ? void 0 : options.emptyDir)));
|
|
220
220
|
instance.on('file:copy', value => this.add(value));
|
|
221
221
|
instance.on('file:move', (value, options) => {
|
|
222
222
|
this.add(value);
|
|
223
|
-
const src = options
|
|
223
|
+
const src = options === null || options === void 0 ? void 0 : options.outSrc;
|
|
224
224
|
if (src) {
|
|
225
225
|
this.delete(src);
|
|
226
226
|
}
|
|
@@ -1158,8 +1158,9 @@ class FileManager extends core_1.Host {
|
|
|
1158
1158
|
if (options.all) {
|
|
1159
1159
|
value = path.resolve(value);
|
|
1160
1160
|
(options.id ? [this.assets.find(item => item.id === options.id)].filter(item => item) : this.assets.filter(item => item.localUri === value)).forEach(asset => {
|
|
1161
|
-
|
|
1162
|
-
asset.
|
|
1161
|
+
var _l, _m;
|
|
1162
|
+
(_l = asset.transforms) === null || _l === void 0 ? void 0 : _l.forEach(file => this.deleteFile(file, emptyDir));
|
|
1163
|
+
(_m = asset.descendants) === null || _m === void 0 ? void 0 : _m.forEach(file => this.deleteFile(file, emptyDir));
|
|
1163
1164
|
});
|
|
1164
1165
|
}
|
|
1165
1166
|
}
|
|
@@ -1715,7 +1716,7 @@ class FileManager extends core_1.Host {
|
|
|
1715
1716
|
this.writeFail(["Unable to read file", path.basename(uri)], err, 32);
|
|
1716
1717
|
}
|
|
1717
1718
|
}
|
|
1718
|
-
if (sourceUTF8
|
|
1719
|
+
if ((sourceUTF8 === null || sourceUTF8 === void 0 ? void 0 : sourceUTF8[0]) === '\uFEFF' && file.encoding !== 'utf16le') {
|
|
1719
1720
|
sourceUTF8 = sourceUTF8.substring(1);
|
|
1720
1721
|
}
|
|
1721
1722
|
return file.sourceUTF8 = sourceUTF8 || '';
|
|
@@ -1793,7 +1794,7 @@ class FileManager extends core_1.Host {
|
|
|
1793
1794
|
const getSeparator = (value) => newline || (newline = (0, util_2.getNewline)(value));
|
|
1794
1795
|
if (content) {
|
|
1795
1796
|
const replacing = this.contentToReplace.get(localUri);
|
|
1796
|
-
if (replacing
|
|
1797
|
+
if (replacing === null || replacing === void 0 ? void 0 : replacing.length) {
|
|
1797
1798
|
for (let i = 0; i < replacing.length; ++i) {
|
|
1798
1799
|
let value = appending[i];
|
|
1799
1800
|
if ((0, types_1.isString)(value)) {
|
|
@@ -1933,6 +1934,7 @@ class FileManager extends core_1.Host {
|
|
|
1933
1934
|
return mimeType;
|
|
1934
1935
|
}
|
|
1935
1936
|
async compressFile(file, overwrite = true) {
|
|
1937
|
+
var _l;
|
|
1936
1938
|
const { localUri, compress } = file;
|
|
1937
1939
|
const instance = this.Compress;
|
|
1938
1940
|
if (instance && compress && localUri && (this.has(localUri) || (0, types_1.existsFlag)(file.flags))) {
|
|
@@ -1961,13 +1963,13 @@ class FileManager extends core_1.Host {
|
|
|
1961
1963
|
if (output && (!condition || withinSizeRange(localUri, condition))) {
|
|
1962
1964
|
try {
|
|
1963
1965
|
if (overwrite || !fs.existsSync(output) || !(0, types_1.existsFlag)(file.flags) && fs.statSync(output).mtimeMs < this.startTime) {
|
|
1964
|
-
config.timeout = this[kProcessTimeout].compress
|
|
1966
|
+
config.timeout = (_l = this[kProcessTimeout].compress) !== null && _l !== void 0 ? _l : PROCESS_TIMEOUT.compress;
|
|
1965
1967
|
tasks.push(instance.tryFile(file.buffer || localUri, output, config, (err, result) => {
|
|
1966
1968
|
if (err) {
|
|
1967
1969
|
this.writeFail(["Unable to compress file", path.basename(localUri)], err, { type: 8, startTime: config.startTime });
|
|
1968
1970
|
}
|
|
1969
1971
|
else if ((0, types_1.isString)(result)) {
|
|
1970
|
-
if (condition
|
|
1972
|
+
if ((condition === null || condition === void 0 ? void 0 : condition.includes('%')) && (0, lib_v4_1.getSize)(result) >= (0, lib_v4_1.getSize)(localUri)) {
|
|
1971
1973
|
queueMicrotask(() => this.deleteFile(result));
|
|
1972
1974
|
}
|
|
1973
1975
|
else {
|
|
@@ -1994,7 +1996,7 @@ class FileManager extends core_1.Host {
|
|
|
1994
1996
|
if (!this.aborted) {
|
|
1995
1997
|
this.processing.push(data);
|
|
1996
1998
|
let mimeType = file.mimeType;
|
|
1997
|
-
if ((mimeType
|
|
1999
|
+
if (((mimeType === null || mimeType === void 0 ? void 0 : mimeType.endsWith('unknown')) || file.commands && !mimeType) && (mimeType = await this.findMime(data.file, true))) {
|
|
1998
2000
|
file.mimeType = mimeType;
|
|
1999
2001
|
data.mimeType = mimeType;
|
|
2000
2002
|
}
|
|
@@ -2169,8 +2171,9 @@ class FileManager extends core_1.Host {
|
|
|
2169
2171
|
}
|
|
2170
2172
|
}
|
|
2171
2173
|
getProcessTimeout(handler) {
|
|
2174
|
+
var _l, _m;
|
|
2172
2175
|
const moduleName = handler.instance.moduleName;
|
|
2173
|
-
return this[kProcessTimeout][moduleName]
|
|
2176
|
+
return (_m = (_l = this[kProcessTimeout][moduleName]) !== null && _l !== void 0 ? _l : PROCESS_TIMEOUT[moduleName]) !== null && _m !== void 0 ? _m : (handler.constructor.PROCESS_TIMEOUT || 0);
|
|
2174
2177
|
}
|
|
2175
2178
|
clearProcessTimeout() {
|
|
2176
2179
|
const timerMain = this[KTimerMain];
|
|
@@ -2415,7 +2418,7 @@ class FileManager extends core_1.Host {
|
|
|
2415
2418
|
}
|
|
2416
2419
|
}
|
|
2417
2420
|
const targeting = this._usingObjects.size > 0;
|
|
2418
|
-
const isCacheable = (file) => file.initialValue
|
|
2421
|
+
const isCacheable = (file) => { var _l; return ((_l = file.initialValue) === null || _l === void 0 ? void 0 : _l.cacheable) !== false; };
|
|
2419
2422
|
const hasEtag = (file) => {
|
|
2420
2423
|
if (!cacheable || !(0, types_1.existsFlag)(file.flags)) {
|
|
2421
2424
|
return false;
|
|
@@ -2967,7 +2970,7 @@ class FileManager extends core_1.Host {
|
|
|
2967
2970
|
}
|
|
2968
2971
|
if (downloadable.size > 1 && this.Request.httpVersion !== 1) {
|
|
2969
2972
|
for (const { url } of downloadable.keys()) {
|
|
2970
|
-
if (url
|
|
2973
|
+
if ((url === null || url === void 0 ? void 0 : url.protocol) === 'https:') {
|
|
2971
2974
|
originCount[url.origin] = (originCount[url.origin] || 0) + 1;
|
|
2972
2975
|
}
|
|
2973
2976
|
}
|
|
@@ -3039,7 +3042,7 @@ class FileManager extends core_1.Host {
|
|
|
3039
3042
|
cacheBuffer = cacheToMemory.has(url);
|
|
3040
3043
|
mainEtag = (0, types_1.mainFlag)(item.flags) && (cacheEtag || item.incremental === 'etag');
|
|
3041
3044
|
}
|
|
3042
|
-
const closeResponse = () => client
|
|
3045
|
+
const closeResponse = () => client === null || client === void 0 ? void 0 : client.destroy();
|
|
3043
3046
|
const downloadUri = (request, etagDir) => {
|
|
3044
3047
|
if (checkEtag) {
|
|
3045
3048
|
item.flags &= ~128;
|
|
@@ -3312,6 +3315,7 @@ class FileManager extends core_1.Host {
|
|
|
3312
3315
|
this.cleared = true;
|
|
3313
3316
|
}
|
|
3314
3317
|
async finalizeCompress(assets) {
|
|
3318
|
+
var _l;
|
|
3315
3319
|
const compress = this.Compress;
|
|
3316
3320
|
if (!(compress && assets.length)) {
|
|
3317
3321
|
return;
|
|
@@ -3336,7 +3340,7 @@ class FileManager extends core_1.Host {
|
|
|
3336
3340
|
for (const config of found.length ? found : output) {
|
|
3337
3341
|
const options = {
|
|
3338
3342
|
...config,
|
|
3339
|
-
timeout: this[kProcessTimeout].compress
|
|
3343
|
+
timeout: (_l = this[kProcessTimeout].compress) !== null && _l !== void 0 ? _l : PROCESS_TIMEOUT.compress,
|
|
3340
3344
|
proxyUrl: (uri) => {
|
|
3341
3345
|
const proxy = this.Request.proxyOf(uri);
|
|
3342
3346
|
return proxy ? proxy.host.href : '';
|
|
@@ -3400,6 +3404,7 @@ class FileManager extends core_1.Host {
|
|
|
3400
3404
|
}
|
|
3401
3405
|
}
|
|
3402
3406
|
async finalize() {
|
|
3407
|
+
var _l;
|
|
3403
3408
|
if (this.aborted) {
|
|
3404
3409
|
return Promise.reject((0, types_1.createAbortError)());
|
|
3405
3410
|
}
|
|
@@ -3452,7 +3457,7 @@ class FileManager extends core_1.Host {
|
|
|
3452
3457
|
}
|
|
3453
3458
|
}
|
|
3454
3459
|
removeFiles();
|
|
3455
|
-
await this.finalizeTask(this.taskAssets.filter(item => item.tasks
|
|
3460
|
+
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));
|
|
3456
3461
|
if (this.aborted) {
|
|
3457
3462
|
return Promise.reject((0, types_1.createAbortError)());
|
|
3458
3463
|
}
|
|
@@ -3532,7 +3537,7 @@ class FileManager extends core_1.Host {
|
|
|
3532
3537
|
}
|
|
3533
3538
|
this.writeTimeElapsed('CLOSE', ['No further modifications', message.join(' | ')], startTime, { ...core_1.Host.LOG_STYLE_WARN });
|
|
3534
3539
|
}
|
|
3535
|
-
this.Watch
|
|
3540
|
+
(_l = this.Watch) === null || _l === void 0 ? void 0 : _l.start(this.assets);
|
|
3536
3541
|
}
|
|
3537
3542
|
close() {
|
|
3538
3543
|
this.Request.close();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/file-manager",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
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": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/cloud": "0.7.
|
|
24
|
-
"@e-mc/compress": "0.7.
|
|
25
|
-
"@e-mc/core": "0.7.
|
|
26
|
-
"@e-mc/document": "0.7.
|
|
27
|
-
"@e-mc/image": "0.7.
|
|
28
|
-
"@e-mc/request": "0.7.
|
|
29
|
-
"@e-mc/task": "0.7.
|
|
30
|
-
"@e-mc/types": "0.7.
|
|
31
|
-
"@e-mc/watch": "0.7.
|
|
23
|
+
"@e-mc/cloud": "0.7.4",
|
|
24
|
+
"@e-mc/compress": "0.7.4",
|
|
25
|
+
"@e-mc/core": "0.7.4",
|
|
26
|
+
"@e-mc/document": "0.7.4",
|
|
27
|
+
"@e-mc/image": "0.7.4",
|
|
28
|
+
"@e-mc/request": "0.7.4",
|
|
29
|
+
"@e-mc/task": "0.7.4",
|
|
30
|
+
"@e-mc/types": "0.7.4",
|
|
31
|
+
"@e-mc/watch": "0.7.4",
|
|
32
32
|
"picomatch": "^3.0.1"
|
|
33
33
|
}
|
|
34
34
|
}
|