@e-mc/file-manager 0.10.7 → 0.10.9

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