@e-mc/file-manager 0.8.22 → 0.8.24
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 +47 -39
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
12
|
+
- https://www.unpkg.com/@e-mc/types@0.8.24/lib/index.d.ts
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { DataSource, IncrementalMatch, TaskAction } from "./squared";
|
|
@@ -191,15 +191,15 @@ interface FileManagerConstructor extends HostConstructor {
|
|
|
191
191
|
|
|
192
192
|
## References
|
|
193
193
|
|
|
194
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
195
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
196
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
197
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
198
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
199
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
200
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
201
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
202
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
194
|
+
- https://www.unpkg.com/@e-mc/types@0.8.24/lib/squared.d.ts
|
|
195
|
+
- https://www.unpkg.com/@e-mc/types@0.8.24/lib/asset.d.ts
|
|
196
|
+
- https://www.unpkg.com/@e-mc/types@0.8.24/lib/core.d.ts
|
|
197
|
+
- https://www.unpkg.com/@e-mc/types@0.8.24/lib/filemanager.d.ts
|
|
198
|
+
- https://www.unpkg.com/@e-mc/types@0.8.24/lib/logger.d.ts
|
|
199
|
+
- https://www.unpkg.com/@e-mc/types@0.8.24/lib/module.d.ts
|
|
200
|
+
- https://www.unpkg.com/@e-mc/types@0.8.24/lib/node.d.ts
|
|
201
|
+
- https://www.unpkg.com/@e-mc/types@0.8.24/lib/request.d.ts
|
|
202
|
+
- https://www.unpkg.com/@e-mc/types@0.8.24/lib/settings.d.ts
|
|
203
203
|
|
|
204
204
|
## LICENSE
|
|
205
205
|
|
package/index.js
CHANGED
|
@@ -1597,63 +1597,71 @@ class FileManager extends core_1.Host {
|
|
|
1597
1597
|
return document === moduleName || Array.isArray(document) && document.includes(moduleName);
|
|
1598
1598
|
}
|
|
1599
1599
|
setLocalUri(file, replace) {
|
|
1600
|
-
var _l;
|
|
1601
|
-
let uri = file.uri, type;
|
|
1602
|
-
if (uri && !file.
|
|
1600
|
+
var _l, _m;
|
|
1601
|
+
let uri = file.uri || (file.uri = (_l = file.url) === null || _l === void 0 ? void 0 : _l.toString()), type;
|
|
1602
|
+
if (uri && !file.content && !file.base64 && !file.dataView) {
|
|
1603
1603
|
if (core_1.Host.isFile(uri, 'torrent')) {
|
|
1604
1604
|
type = 4;
|
|
1605
1605
|
}
|
|
1606
|
-
else if (
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
return { pathname: '', localUri: '' };
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
else {
|
|
1617
|
-
try {
|
|
1618
|
-
const errorAbsolute = (value) => (0, types_1.errorValue)('Path not absolute', value);
|
|
1619
|
-
if (!(file.uri = core_1.Host.resolveFile(uri))) {
|
|
1620
|
-
throw errorAbsolute(uri);
|
|
1621
|
-
}
|
|
1622
|
-
if (file.socketPath) {
|
|
1623
|
-
if (!path.isAbsolute(file.socketPath)) {
|
|
1624
|
-
throw errorAbsolute(file.socketPath);
|
|
1606
|
+
else if (!file.url) {
|
|
1607
|
+
if (core_1.Host.isURL(uri, 'file')) {
|
|
1608
|
+
try {
|
|
1609
|
+
file.url = new URL(uri);
|
|
1610
|
+
file.uri = file.url.toString();
|
|
1611
|
+
if (file.socketPath) {
|
|
1612
|
+
type = 2;
|
|
1625
1613
|
}
|
|
1626
|
-
|
|
1614
|
+
}
|
|
1615
|
+
catch (err) {
|
|
1616
|
+
this.writeFail(["Unable to resolve file", uri], err, { type: 1024, fatal: !!file.document });
|
|
1617
|
+
return { pathname: '', localUri: '' };
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
else {
|
|
1621
|
+
try {
|
|
1622
|
+
const errorAbsolute = (value) => (0, types_1.errorValue)('Path not absolute', value);
|
|
1623
|
+
if (!(file.uri = core_1.Host.resolveFile(uri))) {
|
|
1627
1624
|
throw errorAbsolute(uri);
|
|
1628
1625
|
}
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1626
|
+
if (file.socketPath) {
|
|
1627
|
+
if (!path.isAbsolute(file.socketPath)) {
|
|
1628
|
+
throw errorAbsolute(file.socketPath);
|
|
1629
|
+
}
|
|
1630
|
+
if (!path.isAbsolute(uri = file.uri)) {
|
|
1631
|
+
throw errorAbsolute(uri);
|
|
1632
|
+
}
|
|
1633
|
+
const url = new URL('file://' + uri);
|
|
1634
|
+
file.url = url;
|
|
1635
|
+
file.uri = url.toString();
|
|
1636
|
+
type = 2;
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
catch (err) {
|
|
1640
|
+
this.writeFail(['Unable to resolve file location', uri], err, { type: 32, fatal: !!file.document });
|
|
1641
|
+
return { pathname: '', localUri: '' };
|
|
1632
1642
|
}
|
|
1633
|
-
}
|
|
1634
|
-
catch (err) {
|
|
1635
|
-
this.writeFail(['Unable to resolve file location', uri], err, 32);
|
|
1636
|
-
return { pathname: '', localUri: '' };
|
|
1637
1643
|
}
|
|
1638
1644
|
}
|
|
1639
1645
|
}
|
|
1640
1646
|
const url = file.url;
|
|
1641
1647
|
if (url) {
|
|
1642
|
-
if (
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1648
|
+
if (type === undefined) {
|
|
1649
|
+
if (url.protocol.startsWith('http')) {
|
|
1650
|
+
type = 1;
|
|
1651
|
+
}
|
|
1652
|
+
else if (file.socketPath && url.protocol === 'file:') {
|
|
1653
|
+
type = 2;
|
|
1654
|
+
}
|
|
1655
|
+
else if (core_1.Host.isFile(url, 's/ftp')) {
|
|
1656
|
+
type = 3;
|
|
1657
|
+
}
|
|
1650
1658
|
}
|
|
1651
1659
|
}
|
|
1652
1660
|
file.fetchType = type;
|
|
1653
1661
|
if (file.document) {
|
|
1654
1662
|
for (const { instance } of this.Document) {
|
|
1655
1663
|
if (this.hasDocument(instance, file.document)) {
|
|
1656
|
-
(
|
|
1664
|
+
(_m = instance.setLocalUri) === null || _m === void 0 ? void 0 : _m.call(instance, file, replace);
|
|
1657
1665
|
}
|
|
1658
1666
|
}
|
|
1659
1667
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/file-manager",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.24",
|
|
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.8.
|
|
24
|
-
"@e-mc/compress": "0.8.
|
|
25
|
-
"@e-mc/core": "0.8.
|
|
26
|
-
"@e-mc/document": "0.8.
|
|
27
|
-
"@e-mc/image": "0.8.
|
|
28
|
-
"@e-mc/request": "0.8.
|
|
29
|
-
"@e-mc/task": "0.8.
|
|
30
|
-
"@e-mc/types": "0.8.
|
|
31
|
-
"@e-mc/watch": "0.8.
|
|
23
|
+
"@e-mc/cloud": "0.8.24",
|
|
24
|
+
"@e-mc/compress": "0.8.24",
|
|
25
|
+
"@e-mc/core": "0.8.24",
|
|
26
|
+
"@e-mc/document": "0.8.24",
|
|
27
|
+
"@e-mc/image": "0.8.24",
|
|
28
|
+
"@e-mc/request": "0.8.24",
|
|
29
|
+
"@e-mc/task": "0.8.24",
|
|
30
|
+
"@e-mc/types": "0.8.24",
|
|
31
|
+
"@e-mc/watch": "0.8.24",
|
|
32
32
|
"picomatch": "^3.0.1"
|
|
33
33
|
}
|
|
34
34
|
}
|