@e-mc/file-manager 0.11.2 → 0.11.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.
Files changed (3) hide show
  1. package/README.md +10 -10
  2. package/index.js +44 -36
  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.11.2/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.11.4/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { DataSource, IncrementalMatch, TaskAction } from "./squared";
@@ -306,15 +306,15 @@ NOTE: **FileManager** is a sub-class of [Host](https://www.npmjs.com/package/@e-
306
306
 
307
307
  ## References
308
308
 
309
- - https://www.unpkg.com/@e-mc/types@0.11.2/lib/squared.d.ts
310
- - https://www.unpkg.com/@e-mc/types@0.11.2/lib/asset.d.ts
311
- - https://www.unpkg.com/@e-mc/types@0.11.2/lib/core.d.ts
312
- - https://www.unpkg.com/@e-mc/types@0.11.2/lib/filemanager.d.ts
313
- - https://www.unpkg.com/@e-mc/types@0.11.2/lib/logger.d.ts
314
- - https://www.unpkg.com/@e-mc/types@0.11.2/lib/module.d.ts
315
- - https://www.unpkg.com/@e-mc/types@0.11.2/lib/node.d.ts
316
- - https://www.unpkg.com/@e-mc/types@0.11.2/lib/request.d.ts
317
- - https://www.unpkg.com/@e-mc/types@0.11.2/lib/settings.d.ts
309
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/squared.d.ts
310
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/asset.d.ts
311
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/core.d.ts
312
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/filemanager.d.ts
313
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/logger.d.ts
314
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/module.d.ts
315
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/node.d.ts
316
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/request.d.ts
317
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/settings.d.ts
318
318
 
319
319
  * https://www.npmjs.com/package/@types/node
320
320
 
package/index.js CHANGED
@@ -2459,41 +2459,47 @@ class FileManager extends core_1.Host {
2459
2459
  return '';
2460
2460
  }
2461
2461
  setLocalUri(file, replace) {
2462
- let uri = file.uri, type;
2463
- if (uri && !file.url && !file.content && !file.base64 && !file.dataView) {
2462
+ let uri = file.uri ||= file.url?.toString(), type;
2463
+ if (uri && !file.content && !file.base64 && !file.dataView) {
2464
2464
  if (core_1.Host.isFile(uri, 'torrent')) {
2465
2465
  type = 4;
2466
2466
  }
2467
- else if (core_1.Host.isURL(uri, 'file')) {
2468
- try {
2469
- file.url = new URL(uri);
2470
- file.uri = file.url.toString();
2471
- }
2472
- catch (err) {
2473
- this.writeFail(["Unable to resolve file", uri], err, { type: 1024, fatal: !!file.document });
2474
- return { pathname: '', localUri: '' };
2475
- }
2476
- }
2477
- else {
2478
- try {
2479
- if (!(file.uri = core_1.Host.resolveFile(uri))) {
2480
- throw errorAbsolute(uri);
2481
- }
2482
- if (file.socketPath) {
2483
- if (!path.isAbsolute(file.socketPath)) {
2484
- throw errorAbsolute(file.socketPath);
2467
+ else if (!file.url) {
2468
+ if (core_1.Host.isURL(uri, 'file')) {
2469
+ try {
2470
+ file.url = new URL(uri);
2471
+ file.uri = file.url.toString();
2472
+ if (file.socketPath) {
2473
+ type = 2;
2485
2474
  }
2486
- if (!path.isAbsolute(uri = file.uri)) {
2475
+ }
2476
+ catch (err) {
2477
+ this.writeFail(["Unable to resolve file", uri], err, { type: 1024, fatal: !!file.document });
2478
+ return { pathname: '', localUri: '' };
2479
+ }
2480
+ }
2481
+ else {
2482
+ try {
2483
+ if (!(file.uri = core_1.Host.resolveFile(uri))) {
2487
2484
  throw errorAbsolute(uri);
2488
2485
  }
2489
- const url = new URL('file://' + uri);
2490
- file.url = url;
2491
- file.uri = url.toString();
2486
+ if (file.socketPath) {
2487
+ if (!path.isAbsolute(file.socketPath)) {
2488
+ throw errorAbsolute(file.socketPath);
2489
+ }
2490
+ if (!path.isAbsolute(uri = file.uri)) {
2491
+ throw errorAbsolute(uri);
2492
+ }
2493
+ const url = new URL('file://' + uri);
2494
+ file.url = url;
2495
+ file.uri = url.toString();
2496
+ type = 2;
2497
+ }
2498
+ }
2499
+ catch (err) {
2500
+ this.writeFail(['Unable to resolve file location', uri], err, { type: 32, fatal: !!file.document });
2501
+ return { pathname: '', localUri: '' };
2492
2502
  }
2493
- }
2494
- catch (err) {
2495
- this.writeFail(['Unable to resolve file location', uri], err, { type: 32, fatal: !!file.document });
2496
- return { pathname: '', localUri: '' };
2497
2503
  }
2498
2504
  }
2499
2505
  }
@@ -2502,14 +2508,16 @@ class FileManager extends core_1.Host {
2502
2508
  file.pathname = core_1.Host.toPosix(file.pathname);
2503
2509
  }
2504
2510
  if (url) {
2505
- if (url.protocol.startsWith('http')) {
2506
- type = 1;
2507
- }
2508
- else if (file.socketPath && url.protocol === 'file:') {
2509
- type = 2;
2510
- }
2511
- else if (core_1.Host.isFile(url, 's/ftp')) {
2512
- type = 3;
2511
+ if (type === undefined) {
2512
+ if (url.protocol.startsWith('http')) {
2513
+ type = 1;
2514
+ }
2515
+ else if (file.socketPath && url.protocol === 'file:') {
2516
+ type = 2;
2517
+ }
2518
+ else if (core_1.Host.isFile(url, 's/ftp')) {
2519
+ type = 3;
2520
+ }
2513
2521
  }
2514
2522
  let filename = file.filename;
2515
2523
  if (!filename && !file.document && type !== 4) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/file-manager",
3
- "version": "0.11.2",
3
+ "version": "0.11.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": "BSD-3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/cloud": "0.11.2",
24
- "@e-mc/compress": "0.11.2",
25
- "@e-mc/core": "0.11.2",
26
- "@e-mc/document": "0.11.2",
27
- "@e-mc/image": "0.11.2",
28
- "@e-mc/request": "0.11.2",
29
- "@e-mc/task": "0.11.2",
30
- "@e-mc/types": "0.11.2",
31
- "@e-mc/watch": "0.11.2",
23
+ "@e-mc/cloud": "0.11.4",
24
+ "@e-mc/compress": "0.11.4",
25
+ "@e-mc/core": "0.11.4",
26
+ "@e-mc/document": "0.11.4",
27
+ "@e-mc/image": "0.11.4",
28
+ "@e-mc/request": "0.11.4",
29
+ "@e-mc/task": "0.11.4",
30
+ "@e-mc/types": "0.11.4",
31
+ "@e-mc/watch": "0.11.4",
32
32
  "chalk": "4.1.2",
33
33
  "diff": "^7.0.0",
34
34
  "picomatch": "^4.0.2"