@e-mc/file-manager 0.9.17 → 0.9.19

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 (4) hide show
  1. package/LICENSE +4 -8
  2. package/README.md +10 -10
  3. package/index.js +45 -37
  4. package/package.json +11 -11
package/LICENSE CHANGED
@@ -1,11 +1,7 @@
1
- Copyright 2024 An Pham
1
+ Copyright 2025 An Pham
2
2
 
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
6
 
7
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
-
9
- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
-
11
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.19/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.19/lib/squared.d.ts
290
+ - https://www.unpkg.com/@e-mc/types@0.9.19/lib/asset.d.ts
291
+ - https://www.unpkg.com/@e-mc/types@0.9.19/lib/core.d.ts
292
+ - https://www.unpkg.com/@e-mc/types@0.9.19/lib/filemanager.d.ts
293
+ - https://www.unpkg.com/@e-mc/types@0.9.19/lib/logger.d.ts
294
+ - https://www.unpkg.com/@e-mc/types@0.9.19/lib/module.d.ts
295
+ - https://www.unpkg.com/@e-mc/types@0.9.19/lib/node.d.ts
296
+ - https://www.unpkg.com/@e-mc/types@0.9.19/lib/request.d.ts
297
+ - https://www.unpkg.com/@e-mc/types@0.9.19/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.19",
4
4
  "description": "FileManager constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -17,18 +17,18 @@
17
17
  "squared-functions"
18
18
  ],
19
19
  "author": "An Pham <anpham6@gmail.com>",
20
- "license": "BSD-3-Clause",
20
+ "license": "MIT",
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.19",
24
+ "@e-mc/compress": "0.9.19",
25
+ "@e-mc/core": "0.9.19",
26
+ "@e-mc/document": "0.9.19",
27
+ "@e-mc/image": "0.9.19",
28
+ "@e-mc/request": "0.9.19",
29
+ "@e-mc/task": "0.9.19",
30
+ "@e-mc/types": "0.9.19",
31
+ "@e-mc/watch": "0.9.19",
32
32
  "chalk": "4.1.2",
33
33
  "picomatch": "^4.0.2"
34
34
  }