@e-mc/file-manager 0.9.16 → 0.9.18
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 +45 -37
- 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.18/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.18/lib/squared.d.ts
|
|
290
|
+
- https://www.unpkg.com/@e-mc/types@0.9.18/lib/asset.d.ts
|
|
291
|
+
- https://www.unpkg.com/@e-mc/types@0.9.18/lib/core.d.ts
|
|
292
|
+
- https://www.unpkg.com/@e-mc/types@0.9.18/lib/filemanager.d.ts
|
|
293
|
+
- https://www.unpkg.com/@e-mc/types@0.9.18/lib/logger.d.ts
|
|
294
|
+
- https://www.unpkg.com/@e-mc/types@0.9.18/lib/module.d.ts
|
|
295
|
+
- https://www.unpkg.com/@e-mc/types@0.9.18/lib/node.d.ts
|
|
296
|
+
- https://www.unpkg.com/@e-mc/types@0.9.18/lib/request.d.ts
|
|
297
|
+
- https://www.unpkg.com/@e-mc/types@0.9.18/lib/settings.d.ts
|
|
298
298
|
|
|
299
299
|
* https://www.npmjs.com/package/@types/node
|
|
300
300
|
|
package/index.js
CHANGED
|
@@ -1738,55 +1738,63 @@ class FileManager extends core_1.Host {
|
|
|
1738
1738
|
return document === moduleName || Array.isArray(document) && document.includes(moduleName);
|
|
1739
1739
|
}
|
|
1740
1740
|
setLocalUri(file, replace) {
|
|
1741
|
-
let uri = file.uri, type;
|
|
1742
|
-
if (uri && !file.
|
|
1741
|
+
let uri = file.uri ||= file.url?.toString(), type;
|
|
1742
|
+
if (uri && !file.content && !file.base64 && !file.dataView) {
|
|
1743
1743
|
if (core_1.Host.isFile(uri, 'torrent')) {
|
|
1744
1744
|
type = 4;
|
|
1745
1745
|
}
|
|
1746
|
-
else if (
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
return { pathname: '', localUri: '' };
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
else {
|
|
1757
|
-
try {
|
|
1758
|
-
const errorAbsolute = (value) => (0, types_1.errorValue)("Path is not absolute", value);
|
|
1759
|
-
if (!(file.uri = core_1.Host.resolveFile(uri))) {
|
|
1760
|
-
throw errorAbsolute(uri);
|
|
1761
|
-
}
|
|
1762
|
-
if (file.socketPath) {
|
|
1763
|
-
if (!path.isAbsolute(file.socketPath)) {
|
|
1764
|
-
throw errorAbsolute(file.socketPath);
|
|
1746
|
+
else if (!file.url) {
|
|
1747
|
+
if (core_1.Host.isURL(uri, 'file')) {
|
|
1748
|
+
try {
|
|
1749
|
+
file.url = new URL(uri);
|
|
1750
|
+
file.uri = file.url.toString();
|
|
1751
|
+
if (file.socketPath) {
|
|
1752
|
+
type = 2;
|
|
1765
1753
|
}
|
|
1766
|
-
|
|
1754
|
+
}
|
|
1755
|
+
catch (err) {
|
|
1756
|
+
this.writeFail(["Unable to resolve file", uri], err, { type: 1024, fatal: !!file.document });
|
|
1757
|
+
return { pathname: '', localUri: '' };
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
else {
|
|
1761
|
+
try {
|
|
1762
|
+
const errorAbsolute = (value) => (0, types_1.errorValue)("Path is not absolute", value);
|
|
1763
|
+
if (!(file.uri = core_1.Host.resolveFile(uri))) {
|
|
1767
1764
|
throw errorAbsolute(uri);
|
|
1768
1765
|
}
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1766
|
+
if (file.socketPath) {
|
|
1767
|
+
if (!path.isAbsolute(file.socketPath)) {
|
|
1768
|
+
throw errorAbsolute(file.socketPath);
|
|
1769
|
+
}
|
|
1770
|
+
if (!path.isAbsolute(uri = file.uri)) {
|
|
1771
|
+
throw errorAbsolute(uri);
|
|
1772
|
+
}
|
|
1773
|
+
const url = new URL('file://' + uri);
|
|
1774
|
+
file.url = url;
|
|
1775
|
+
file.uri = url.toString();
|
|
1776
|
+
type = 2;
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
catch (err) {
|
|
1780
|
+
this.writeFail(['Unable to resolve file location', uri], err, { type: 32, fatal: !!file.document });
|
|
1781
|
+
return { pathname: '', localUri: '' };
|
|
1772
1782
|
}
|
|
1773
|
-
}
|
|
1774
|
-
catch (err) {
|
|
1775
|
-
this.writeFail(['Unable to resolve file location', uri], err, 32);
|
|
1776
|
-
return { pathname: '', localUri: '' };
|
|
1777
1783
|
}
|
|
1778
1784
|
}
|
|
1779
1785
|
}
|
|
1780
1786
|
const url = file.url;
|
|
1781
1787
|
if (url) {
|
|
1782
|
-
if (
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1788
|
+
if (type === undefined) {
|
|
1789
|
+
if (url.protocol.startsWith('http')) {
|
|
1790
|
+
type = 1;
|
|
1791
|
+
}
|
|
1792
|
+
else if (file.socketPath && url.protocol === 'file:') {
|
|
1793
|
+
type = 2;
|
|
1794
|
+
}
|
|
1795
|
+
else if (core_1.Host.isFile(url, 's/ftp')) {
|
|
1796
|
+
type = 3;
|
|
1797
|
+
}
|
|
1790
1798
|
}
|
|
1791
1799
|
}
|
|
1792
1800
|
file.fetchType = type;
|
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.18",
|
|
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.18",
|
|
24
|
+
"@e-mc/compress": "0.9.18",
|
|
25
|
+
"@e-mc/core": "0.9.18",
|
|
26
|
+
"@e-mc/document": "0.9.18",
|
|
27
|
+
"@e-mc/image": "0.9.18",
|
|
28
|
+
"@e-mc/request": "0.9.18",
|
|
29
|
+
"@e-mc/task": "0.9.18",
|
|
30
|
+
"@e-mc/types": "0.9.18",
|
|
31
|
+
"@e-mc/watch": "0.9.18",
|
|
32
32
|
"chalk": "4.1.2",
|
|
33
33
|
"picomatch": "^4.0.2"
|
|
34
34
|
}
|