xjs-common 9.1.2 → 9.1.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.
package/dist/func/u-file.d.ts
CHANGED
|
@@ -41,6 +41,11 @@ export declare namespace UFile {
|
|
|
41
41
|
* @param destDir directory that the decompress files export to.
|
|
42
42
|
*/
|
|
43
43
|
function unzip(zipPath: MaybeArray<string>, destDir?: MaybeArray<string>): void;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated since v9.1.4
|
|
46
|
+
* @removed this will be removed in v10.
|
|
47
|
+
* @replaced it should uses this without namespace `UFile`.
|
|
48
|
+
*/
|
|
44
49
|
function joinPath(...p: MaybeArray<string>[]): string;
|
|
45
50
|
}
|
|
46
51
|
export {};
|
package/dist/func/u-file.js
CHANGED
|
@@ -159,6 +159,11 @@ var UFile;
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
UFile.unzip = unzip;
|
|
162
|
+
/**
|
|
163
|
+
* @deprecated since v9.1.4
|
|
164
|
+
* @removed this will be removed in v10.
|
|
165
|
+
* @replaced it should uses this without namespace `UFile`.
|
|
166
|
+
*/
|
|
162
167
|
function joinPath(...p) {
|
|
163
168
|
return path.join(...p.flatMap(u_type_1.UType.takeAsArray));
|
|
164
169
|
}
|
package/dist/func/u.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Loggable } from "../const/types";
|
|
1
|
+
import { Loggable, MaybeArray } from "../const/types";
|
|
2
2
|
export declare function getJSTDate(d?: Date): Date;
|
|
3
3
|
export declare function delay(sec: number): Promise<void>;
|
|
4
4
|
export declare function int2array(size: number): number[];
|
|
@@ -23,3 +23,4 @@ export declare function retry<T>(cb: () => T, op?: RetryOption<void>): T;
|
|
|
23
23
|
export declare function retry<T>(cb: () => T, op?: RetryOption<Promise<void>>): Promise<T>;
|
|
24
24
|
export declare function retry<T>(cb: () => Promise<T>, op?: RetryOption<void>): Promise<T>;
|
|
25
25
|
export declare function retry<T>(cb: () => Promise<T>, op?: RetryOption<Promise<void>>): Promise<T>;
|
|
26
|
+
export declare function joinPath(...p: MaybeArray<string>[]): string;
|
package/dist/func/u.js
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.retry = exports.checkPortAvailability = exports.bitor = exports.array2map = exports.int2array = exports.delay = exports.getJSTDate = void 0;
|
|
26
|
+
exports.joinPath = exports.retry = exports.checkPortAvailability = exports.bitor = exports.array2map = exports.int2array = exports.delay = exports.getJSTDate = void 0;
|
|
27
|
+
const path = __importStar(require("path"));
|
|
4
28
|
const xjs_err_1 = require("../obj/xjs-err");
|
|
29
|
+
const u_type_1 = require("./u-type");
|
|
5
30
|
const s_errCode = 10;
|
|
6
31
|
function getJSTDate(d) {
|
|
7
32
|
return new Date((d ? d.getTime() : Date.now()) + 9 * 60 * 60 * 1000);
|
|
@@ -83,3 +108,7 @@ function retry(cb, op) {
|
|
|
83
108
|
return prcs(initialCount);
|
|
84
109
|
}
|
|
85
110
|
exports.retry = retry;
|
|
111
|
+
function joinPath(...p) {
|
|
112
|
+
return path.join(...p.flatMap(u_type_1.UType.takeAsArray));
|
|
113
|
+
}
|
|
114
|
+
exports.joinPath = joinPath;
|
|
@@ -3,7 +3,7 @@ import { ClientOption, HttpResponse, IHttpClient, RequestOption } from "./i-http
|
|
|
3
3
|
import { Loggable } from "../../const/types";
|
|
4
4
|
export declare const s_clientMode: Record<string, ClientMode>;
|
|
5
5
|
export declare class HttpResolverContext implements IHttpClient {
|
|
6
|
-
|
|
6
|
+
readonly cmv: number;
|
|
7
7
|
private _l;
|
|
8
8
|
private readonly _als;
|
|
9
9
|
private readonly _mode;
|
|
@@ -11,7 +11,8 @@ export declare class HttpResolverContext implements IHttpClient {
|
|
|
11
11
|
private readonly _proxyConfig?;
|
|
12
12
|
private readonly _chHeaders;
|
|
13
13
|
private _cookies?;
|
|
14
|
-
|
|
14
|
+
get clientMode(): string;
|
|
15
|
+
constructor(cmv: number, op?: ClientOption, _l?: Loggable);
|
|
15
16
|
/**
|
|
16
17
|
* request GET to the url.
|
|
17
18
|
* @param url target url.
|
|
@@ -83,7 +83,7 @@ const s_mode2headers = new Map([
|
|
|
83
83
|
}]
|
|
84
84
|
]);
|
|
85
85
|
class HttpResolverContext {
|
|
86
|
-
|
|
86
|
+
cmv;
|
|
87
87
|
_l;
|
|
88
88
|
_als = new async_hooks_1.AsyncLocalStorage();
|
|
89
89
|
_mode;
|
|
@@ -91,14 +91,14 @@ class HttpResolverContext {
|
|
|
91
91
|
_proxyConfig;
|
|
92
92
|
_chHeaders;
|
|
93
93
|
_cookies;
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
get clientMode() { return Object.keys(exports.s_clientMode).find((_, i) => i === this._mode.id); }
|
|
95
|
+
constructor(cmv, op, _l = console) {
|
|
96
|
+
this.cmv = cmv;
|
|
96
97
|
this._l = _l;
|
|
97
98
|
this._mode = op?.mode ?? u_array_1.UArray.randomPick([exports.s_clientMode.chrome, exports.s_clientMode.firefox]);
|
|
98
99
|
this._ciphers = this.createCiphers(this._mode);
|
|
99
100
|
this._proxyConfig = op?.proxy;
|
|
100
|
-
this._chHeaders = s_mode2headers.get(this._mode)(this.
|
|
101
|
-
this._l.log(`Context launched with ${Object.keys(exports.s_clientMode).find((_, i) => i === this._mode.id)}:${this._cmv}.`);
|
|
101
|
+
this._chHeaders = s_mode2headers.get(this._mode)(this.cmv);
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* request GET to the url.
|