@e-mc/request 0.8.22 → 0.8.23
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 +4 -4
- package/http/adapter/index.js +11 -18
- package/index.js +20 -12
- package/package.json +3 -3
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.23/lib/index.d.ts
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { IModule, ModuleConstructor } from "./index";
|
|
@@ -82,9 +82,9 @@ interface RequestConstructor extends ModuleConstructor {
|
|
|
82
82
|
|
|
83
83
|
## References
|
|
84
84
|
|
|
85
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
86
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
87
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
85
|
+
- https://www.unpkg.com/@e-mc/types@0.8.23/lib/http.d.ts
|
|
86
|
+
- https://www.unpkg.com/@e-mc/types@0.8.23/lib/request.d.ts
|
|
87
|
+
- https://www.unpkg.com/@e-mc/types@0.8.23/lib/settings.d.ts
|
|
88
88
|
|
|
89
89
|
## LICENSE
|
|
90
90
|
|
package/http/adapter/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
2
3
|
const fs = require("node:fs");
|
|
3
4
|
const http2 = require("node:http2");
|
|
4
5
|
const yaml = require("js-yaml");
|
|
@@ -9,9 +10,6 @@ const kOutStream = Symbol('outStream');
|
|
|
9
10
|
const kOptions = Symbol('options');
|
|
10
11
|
let LOG_TIMEFORMAT = 'readable';
|
|
11
12
|
class HttpAdapter {
|
|
12
|
-
instance;
|
|
13
|
-
state;
|
|
14
|
-
uri;
|
|
15
13
|
static isUnsupported(value) {
|
|
16
14
|
return value === 421 || value === 505;
|
|
17
15
|
}
|
|
@@ -40,25 +38,19 @@ class HttpAdapter {
|
|
|
40
38
|
break;
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
|
-
contentLength = 0;
|
|
44
|
-
retries = 0;
|
|
45
|
-
redirects = 0;
|
|
46
|
-
closed = false;
|
|
47
|
-
aborted = false;
|
|
48
|
-
timeout = null;
|
|
49
|
-
dataTime = null;
|
|
50
|
-
delayTime = undefined;
|
|
51
|
-
opts;
|
|
52
|
-
client;
|
|
53
|
-
resolve;
|
|
54
|
-
reject;
|
|
55
|
-
startTime;
|
|
56
|
-
[kOutStream] = null;
|
|
57
|
-
[kOptions];
|
|
58
41
|
constructor(instance, state, uri, options) {
|
|
59
42
|
this.instance = instance;
|
|
60
43
|
this.state = state;
|
|
61
44
|
this.uri = uri;
|
|
45
|
+
this.contentLength = 0;
|
|
46
|
+
this.retries = 0;
|
|
47
|
+
this.redirects = 0;
|
|
48
|
+
this.closed = false;
|
|
49
|
+
this.aborted = false;
|
|
50
|
+
this.timeout = null;
|
|
51
|
+
this.dataTime = null;
|
|
52
|
+
this.delayTime = undefined;
|
|
53
|
+
this[_a] = null;
|
|
62
54
|
this[kOptions] = options;
|
|
63
55
|
this.startTime = state.log ? process.hrtime.bigint() : BigInt(0);
|
|
64
56
|
this.setOpts();
|
|
@@ -558,4 +550,5 @@ class HttpAdapter {
|
|
|
558
550
|
return this.state.config.redirectLimit;
|
|
559
551
|
}
|
|
560
552
|
}
|
|
553
|
+
_a = kOutStream;
|
|
561
554
|
module.exports = HttpAdapter;
|
package/index.js
CHANGED
|
@@ -400,7 +400,7 @@ class Request extends module_1.default {
|
|
|
400
400
|
if ((lowest_speed_limit = parseSize(lowest_speed_limit, true)) !== undefined) {
|
|
401
401
|
ARIA2.LOWEST_SPEED_LIMIT = lowest_speed_limit;
|
|
402
402
|
}
|
|
403
|
-
if (always_resume) {
|
|
403
|
+
if (typeof always_resume === 'boolean') {
|
|
404
404
|
ARIA2.ALWAYS_RESUME = always_resume;
|
|
405
405
|
}
|
|
406
406
|
if ((0, types_1.isString)(file_allocation)) {
|
|
@@ -414,7 +414,7 @@ class Request extends module_1.default {
|
|
|
414
414
|
break;
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
if (conf_path && this.isPath(conf_path = path.resolve(conf_path))) {
|
|
417
|
+
if (conf_path === '' || (0, types_1.isString)(conf_path) && this.isPath(conf_path = path.resolve(conf_path))) {
|
|
418
418
|
ARIA2.CONF_PATH = conf_path;
|
|
419
419
|
}
|
|
420
420
|
}
|
|
@@ -1081,7 +1081,7 @@ class Request extends module_1.default {
|
|
|
1081
1081
|
case 'string': {
|
|
1082
1082
|
const value = opt.trim();
|
|
1083
1083
|
if (value.startsWith('--')) {
|
|
1084
|
-
const match = /^(--[a-z]+[a-z0-9-]*)(=)?\s*(.*)
|
|
1084
|
+
const match = /^(--[a-z]+[a-z0-9-]*)(=)?\s*(.*)$/s.exec(value);
|
|
1085
1085
|
if (match) {
|
|
1086
1086
|
switch (match[1]) {
|
|
1087
1087
|
case '--daemon':
|
|
@@ -1137,8 +1137,8 @@ class Request extends module_1.default {
|
|
|
1137
1137
|
({ protocol, origin, username, password, href: uri } = uri);
|
|
1138
1138
|
}
|
|
1139
1139
|
const escapeQuote = (value) => {
|
|
1140
|
-
value = value.replace(/"/g, '\\"');
|
|
1141
|
-
return PLATFORM_WIN32 ? value : value.replace(/
|
|
1140
|
+
value = value.replace(/(?<!\\)"/g, '\\"');
|
|
1141
|
+
return PLATFORM_WIN32 ? value : value.replace(/(?<!\\)\$/g, '\\$');
|
|
1142
1142
|
};
|
|
1143
1143
|
const init = [
|
|
1144
1144
|
`--dir="${escapeQuote(pathname)}"`,
|
|
@@ -1283,10 +1283,13 @@ class Request extends module_1.default {
|
|
|
1283
1283
|
}
|
|
1284
1284
|
if (binOpts) {
|
|
1285
1285
|
for (const leading of binOpts) {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1286
|
+
if (leading.startsWith('-')) {
|
|
1287
|
+
const pattern = new RegExp(`^${leading}(?:=|$)`);
|
|
1288
|
+
for (let i = 0; i < opts.length; ++i) {
|
|
1289
|
+
if (pattern.test(opts[i])) {
|
|
1290
|
+
opts.splice(i--, i);
|
|
1291
|
+
break;
|
|
1292
|
+
}
|
|
1290
1293
|
}
|
|
1291
1294
|
}
|
|
1292
1295
|
}
|
|
@@ -1345,10 +1348,15 @@ class Request extends module_1.default {
|
|
|
1345
1348
|
break;
|
|
1346
1349
|
}
|
|
1347
1350
|
}
|
|
1348
|
-
if (result.length
|
|
1349
|
-
|
|
1351
|
+
if (result.length > 0) {
|
|
1352
|
+
if (!silent && LOG_HTTP && LOG_TIMEPROCESS) {
|
|
1353
|
+
this.writeTimeProcess("aria2", uri, startTime, { type: 1024, queue: true, messageUnit, messageUnitMinWidth: 9, bypassLog: true });
|
|
1354
|
+
}
|
|
1355
|
+
this.addLog(types_1.STATUS_TYPE.INFO, out, currentTime, currentTime - startTime, "aria2", uri);
|
|
1356
|
+
}
|
|
1357
|
+
else {
|
|
1358
|
+
this.addLog(types_1.STATUS_TYPE.ERROR, "No files were successfully downloaded", currentTime, currentTime - startTime, "aria2", uri);
|
|
1350
1359
|
}
|
|
1351
|
-
this.addLog(result.length ? types_1.STATUS_TYPE.INFO : types_1.STATUS_TYPE.ERROR, out, currentTime, currentTime - startTime, "aria2", uri);
|
|
1352
1360
|
resolve(result);
|
|
1353
1361
|
}
|
|
1354
1362
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/request",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.23",
|
|
4
4
|
"description": "Request constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/module": "0.8.
|
|
24
|
-
"@e-mc/types": "0.8.
|
|
23
|
+
"@e-mc/module": "0.8.23",
|
|
24
|
+
"@e-mc/types": "0.8.23",
|
|
25
25
|
"combined-stream": "^1.0.8",
|
|
26
26
|
"js-yaml": "^4.1.0",
|
|
27
27
|
"picomatch": "^3.0.1",
|