@e-mc/file-manager 0.9.17 → 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.
Files changed (3) hide show
  1. package/README.md +10 -10
  2. package/index.js +45 -37
  3. 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.17/lib/index.d.ts)
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.17/lib/squared.d.ts
290
- - https://www.unpkg.com/@e-mc/types@0.9.17/lib/asset.d.ts
291
- - https://www.unpkg.com/@e-mc/types@0.9.17/lib/core.d.ts
292
- - https://www.unpkg.com/@e-mc/types@0.9.17/lib/filemanager.d.ts
293
- - https://www.unpkg.com/@e-mc/types@0.9.17/lib/logger.d.ts
294
- - https://www.unpkg.com/@e-mc/types@0.9.17/lib/module.d.ts
295
- - https://www.unpkg.com/@e-mc/types@0.9.17/lib/node.d.ts
296
- - https://www.unpkg.com/@e-mc/types@0.9.17/lib/request.d.ts
297
- - https://www.unpkg.com/@e-mc/types@0.9.17/lib/settings.d.ts
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.url && !file.content && !file.base64 && !file.dataView) {
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 (core_1.Host.isURL(uri, 'file')) {
1747
- try {
1748
- file.url = new URL(uri);
1749
- file.uri = file.url.toString();
1750
- }
1751
- catch (err) {
1752
- this.writeFail(['Unable to parse URL', uri], err, 1024);
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
- if (!path.isAbsolute(uri = file.uri)) {
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
- const url = new URL('file://' + uri);
1770
- file.url = url;
1771
- file.uri = url.toString();
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 (url.protocol.startsWith('http')) {
1783
- type = 1;
1784
- }
1785
- else if (file.socketPath && url.protocol === 'file:') {
1786
- type = 2;
1787
- }
1788
- else if (core_1.Host.isFile(url, 's/ftp')) {
1789
- type = 3;
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.17",
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.17",
24
- "@e-mc/compress": "0.9.17",
25
- "@e-mc/core": "0.9.17",
26
- "@e-mc/document": "0.9.17",
27
- "@e-mc/image": "0.9.17",
28
- "@e-mc/request": "0.9.17",
29
- "@e-mc/task": "0.9.17",
30
- "@e-mc/types": "0.9.17",
31
- "@e-mc/watch": "0.9.17",
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
  }