ddan-js 2.5.4 → 2.5.6
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/bin/ddan-js.esm.js +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/lib/class/joker.js +0 -2
- package/bin/lib/index.js +1 -3
- package/bin/lib/modules/cdn.js +2 -2
- package/bin/lib/modules/hook/hooker.js +39 -0
- package/bin/lib/modules/hook/index.js +7 -2
- package/bin/lib/{class → modules/hook/modules}/pipeline.js +4 -4
- package/bin/lib/modules/html.js +2 -2
- package/bin/lib/modules/qs/index.js +35 -51
- package/bin/lib/typings/index.js +0 -10
- package/bin/lib/util/function.js +3 -0
- package/bin/types/class/joker.d.ts +0 -2
- package/bin/types/index.d.ts +59 -41
- package/bin/types/modules/hook/hooker.d.ts +16 -0
- package/bin/types/modules/hook/index.d.ts +5 -2
- package/bin/types/{class → modules/hook/modules}/pipeline.d.ts +2 -1
- package/bin/types/modules/qs/index.d.ts +18 -14
- package/bin/types/typings/index.d.ts +13 -4
- package/bin/types/util/function.d.ts +1 -0
- package/bin/types/util/index.d.ts +1 -0
- package/package.json +1 -1
- package/bin/lib/class/task.js +0 -39
- package/bin/types/class/task.d.ts +0 -9
|
@@ -9,55 +9,29 @@ const https = (url) => {
|
|
|
9
9
|
};
|
|
10
10
|
const RegHost = /^(http[s]?):\/\/([\w.]+)(?::(\d+))?/;
|
|
11
11
|
const parseUrl = (url) => {
|
|
12
|
-
let host = '';
|
|
13
|
-
let origin = '';
|
|
14
|
-
// if (/^http[s]?:\/\/([\w.]+)/.test(url)) {
|
|
15
|
-
// host = url.replace(/^http[s]?:\/\/([\w.]+)[\w\W]+/, '$1')
|
|
16
|
-
// origin = url.replace(/^(http[s]?:\/\/)([\w.]+)[\w\W]+/, '$1$2')
|
|
17
|
-
// }
|
|
18
12
|
const hostInfo = parseHost(url);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
origin = hostInfo.origin;
|
|
22
|
-
}
|
|
23
|
-
const arr = url.split('?');
|
|
24
|
-
const _path = arr[0];
|
|
25
|
-
const query = arr.length > 1 ? arr[1] : '';
|
|
26
|
-
let page = '';
|
|
27
|
-
const mat = _path.match(/[\/]?([\w\_\-]+)[.]?[\w]*[?]?$/);
|
|
28
|
-
if (mat) {
|
|
29
|
-
page = mat[1];
|
|
30
|
-
}
|
|
13
|
+
const { origin = '', url: _url = '', query = '' } = hostInfo;
|
|
14
|
+
const pathInfo = parsePath(_url);
|
|
31
15
|
const params = (0, decode_1.default)(query, { multiple: true, uri: false });
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const extension = filename.substring(last);
|
|
37
|
-
const root = _path.substring(0, idx);
|
|
38
|
-
return {
|
|
39
|
-
host,
|
|
40
|
-
origin,
|
|
41
|
-
url,
|
|
42
|
-
path: _path,
|
|
43
|
-
page,
|
|
44
|
-
query,
|
|
45
|
-
filename: filenameWithoutExtension ? filename : '',
|
|
46
|
-
filenameWithoutExtension,
|
|
47
|
-
extension: filenameWithoutExtension ? extension : '',
|
|
48
|
-
route: filenameWithoutExtension ? root : '',
|
|
16
|
+
const result = {
|
|
17
|
+
...hostInfo,
|
|
18
|
+
...pathInfo,
|
|
19
|
+
pathname: _url.substring(_url.indexOf(origin || '') + origin.length),
|
|
49
20
|
params,
|
|
50
21
|
};
|
|
22
|
+
return result;
|
|
51
23
|
};
|
|
52
|
-
const parsePath = (
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
24
|
+
const parsePath = (url) => {
|
|
25
|
+
const _url = (url || '').replace(/\\/g, '/').split('?')[0];
|
|
26
|
+
const mat = _url.match(/[\/]?([\w\_\-]+)[.]?[\w]*[?]?$/);
|
|
27
|
+
const page = mat ? mat[1] : '';
|
|
28
|
+
const idx = _url.lastIndexOf('/') + 1;
|
|
29
|
+
const name = _url.substring(idx);
|
|
56
30
|
const last = name.lastIndexOf('.');
|
|
57
|
-
const withoutExtension = name.substring(0, last);
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
return {
|
|
31
|
+
const withoutExtension = name.substring(0, last) || '';
|
|
32
|
+
const extname = last >= 0 ? name.substring(last) : '';
|
|
33
|
+
const route = _url.substring(0, idx) || '';
|
|
34
|
+
return { route, page, name, withoutExtension, extname };
|
|
61
35
|
};
|
|
62
36
|
const join = (...args) => {
|
|
63
37
|
const arr = [];
|
|
@@ -70,18 +44,28 @@ const join = (...args) => {
|
|
|
70
44
|
return arr.join('/');
|
|
71
45
|
};
|
|
72
46
|
const parseHost = (url) => {
|
|
47
|
+
const result = {
|
|
48
|
+
href: url,
|
|
49
|
+
url: '',
|
|
50
|
+
origin: '',
|
|
51
|
+
protocol: '',
|
|
52
|
+
host: '',
|
|
53
|
+
port: '',
|
|
54
|
+
query: '',
|
|
55
|
+
};
|
|
73
56
|
if (!url)
|
|
74
|
-
return
|
|
57
|
+
return result;
|
|
75
58
|
const matches = url.match(RegHost);
|
|
76
59
|
if (!matches || matches.length < 4)
|
|
77
|
-
return
|
|
60
|
+
return result;
|
|
78
61
|
const port = matches[3] || '';
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
62
|
+
const arr = url.split('?');
|
|
63
|
+
result.url = arr[0];
|
|
64
|
+
result.origin = matches[0];
|
|
65
|
+
result.protocol = `${matches[1]}:`;
|
|
66
|
+
result.host = `${matches[2]}${port ? ':' + port : ''}`;
|
|
67
|
+
result.port = port;
|
|
68
|
+
result.query = arr.length > 1 ? arr[1] : '';
|
|
85
69
|
return result;
|
|
86
70
|
};
|
|
87
71
|
exports.default = { parse: decode_1.default, stringify: encode_1.default, https, parseUrl, parsePath, parseHost, join };
|
package/bin/lib/typings/index.js
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dd = exports.Ddan = void 0;
|
|
4
|
-
var Ddan;
|
|
5
|
-
(function (Ddan) {
|
|
6
|
-
;
|
|
7
|
-
;
|
|
8
|
-
})(Ddan || (exports.Ddan = Ddan = {}));
|
|
9
|
-
var dd;
|
|
10
|
-
(function (dd) {
|
|
11
|
-
;
|
|
12
|
-
})(dd || (exports.dd = dd = {}));
|
package/bin/lib/util/function.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Store from "./store";
|
|
2
2
|
import LoopFrame from "../modules/time/frame";
|
|
3
|
-
import DPipeline from "./pipeline";
|
|
4
3
|
import DPipeparallel from "./pipeparallel";
|
|
5
4
|
export interface ITriggerRecord {
|
|
6
5
|
time: number;
|
|
@@ -46,7 +45,6 @@ export declare class Joker {
|
|
|
46
45
|
* @returns
|
|
47
46
|
*/
|
|
48
47
|
timesClean: (mode?: "storage" | "running") => void;
|
|
49
|
-
pipeline: () => DPipeline;
|
|
50
48
|
parallel: () => DPipeparallel;
|
|
51
49
|
}
|
|
52
50
|
declare const joker: Joker;
|
package/bin/types/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ declare const dUtil: {
|
|
|
11
11
|
new (): {};
|
|
12
12
|
__instance__: any;
|
|
13
13
|
readonly Instance: T;
|
|
14
|
+
readonly I: T;
|
|
14
15
|
};
|
|
15
16
|
getset: <T_1 = any>(t?: T_1 | undefined) => import("./typings").Ddan.IGetset<T_1>;
|
|
16
17
|
copy: (source: any, options?: {
|
|
@@ -186,12 +187,14 @@ declare const dUtil: {
|
|
|
186
187
|
declare const dHook: {
|
|
187
188
|
sleep: (ms?: number) => Promise<unknown>;
|
|
188
189
|
run: <T = any>(task?: Function | Promise<T> | undefined, wait?: number) => Promise<[any, undefined] | [null, T]>;
|
|
189
|
-
exec: (func: Function, taskId?: string) => Promise<any[]>;
|
|
190
|
+
exec: (func: Function, taskId?: string) => Promise<[any, undefined] | [null, any]>;
|
|
190
191
|
debounce: typeof import("./modules/hook/debounce").default;
|
|
191
192
|
throttle: typeof import("./modules/hook/throttle").default;
|
|
192
193
|
task: (param?: import("./typings").Ddan.Func1<any, any> | undefined) => import("./class/pipeTask").default;
|
|
193
194
|
mutex: typeof import("./modules/hook/mutex").default;
|
|
194
195
|
polling: typeof import("./modules/hook/polling").default;
|
|
196
|
+
pipe: (func: Function) => import("./modules/hook/modules/pipeline").default;
|
|
197
|
+
pipeline: () => import("./modules/hook/modules/pipeline").default;
|
|
195
198
|
to: <T_1 = any, U extends object = any>(promise: Promise<T_1>, errorExt?: object | undefined) => Promise<[null, T_1] | [U, undefined]>;
|
|
196
199
|
go: <T_2 = any>(task?: Function | Promise<T_2> | undefined) => Promise<[any, undefined] | [null, T_2]>;
|
|
197
200
|
delay: (ms?: number) => Promise<unknown>;
|
|
@@ -252,25 +255,29 @@ declare const dMini: {
|
|
|
252
255
|
}) => string;
|
|
253
256
|
https: (url: string) => string;
|
|
254
257
|
parseUrl: (url: string) => {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
path: string;
|
|
258
|
+
pathname: string;
|
|
259
|
+
params: {};
|
|
260
|
+
route: string;
|
|
259
261
|
page: string;
|
|
262
|
+
name: string;
|
|
263
|
+
withoutExtension: string;
|
|
264
|
+
extname: string;
|
|
265
|
+
href: string;
|
|
266
|
+
url: string;
|
|
267
|
+
origin: string;
|
|
268
|
+
host: string;
|
|
269
|
+
protocol: string;
|
|
270
|
+
port: string;
|
|
260
271
|
query: string;
|
|
261
|
-
filename: string;
|
|
262
|
-
filenameWithoutExtension: string;
|
|
263
|
-
extension: string;
|
|
264
|
-
route: string;
|
|
265
|
-
params: {};
|
|
266
272
|
};
|
|
267
|
-
parsePath: (
|
|
268
|
-
|
|
273
|
+
parsePath: (url: string) => {
|
|
274
|
+
route: string;
|
|
275
|
+
page: string;
|
|
269
276
|
name: string;
|
|
270
277
|
withoutExtension: string;
|
|
271
|
-
|
|
278
|
+
extname: string;
|
|
272
279
|
};
|
|
273
|
-
parseHost: (url: string) => import("./typings").Ddan.IHttpHost
|
|
280
|
+
parseHost: (url: string) => import("./typings").Ddan.IHttpHost;
|
|
274
281
|
join: (...args: string[]) => string;
|
|
275
282
|
};
|
|
276
283
|
icon: import("./class/icon").DIcon;
|
|
@@ -385,25 +392,29 @@ declare const dWeb: {
|
|
|
385
392
|
}) => string;
|
|
386
393
|
https: (url: string) => string;
|
|
387
394
|
parseUrl: (url: string) => {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
path: string;
|
|
395
|
+
pathname: string;
|
|
396
|
+
params: {};
|
|
397
|
+
route: string;
|
|
392
398
|
page: string;
|
|
399
|
+
name: string;
|
|
400
|
+
withoutExtension: string;
|
|
401
|
+
extname: string;
|
|
402
|
+
href: string;
|
|
403
|
+
url: string;
|
|
404
|
+
origin: string;
|
|
405
|
+
host: string;
|
|
406
|
+
protocol: string;
|
|
407
|
+
port: string;
|
|
393
408
|
query: string;
|
|
394
|
-
filename: string;
|
|
395
|
-
filenameWithoutExtension: string;
|
|
396
|
-
extension: string;
|
|
397
|
-
route: string;
|
|
398
|
-
params: {};
|
|
399
409
|
};
|
|
400
|
-
parsePath: (
|
|
401
|
-
|
|
410
|
+
parsePath: (url: string) => {
|
|
411
|
+
route: string;
|
|
412
|
+
page: string;
|
|
402
413
|
name: string;
|
|
403
414
|
withoutExtension: string;
|
|
404
|
-
|
|
415
|
+
extname: string;
|
|
405
416
|
};
|
|
406
|
-
parseHost: (url: string) => import("./typings").Ddan.IHttpHost
|
|
417
|
+
parseHost: (url: string) => import("./typings").Ddan.IHttpHost;
|
|
407
418
|
join: (...args: string[]) => string;
|
|
408
419
|
};
|
|
409
420
|
icon: import("./class/icon").DIcon;
|
|
@@ -461,12 +472,14 @@ declare const _default: {
|
|
|
461
472
|
hook: {
|
|
462
473
|
sleep: (ms?: number) => Promise<unknown>;
|
|
463
474
|
run: <T = any>(task?: Function | Promise<T> | undefined, wait?: number) => Promise<[any, undefined] | [null, T]>;
|
|
464
|
-
exec: (func: Function, taskId?: string) => Promise<any[]>;
|
|
475
|
+
exec: (func: Function, taskId?: string) => Promise<[any, undefined] | [null, any]>;
|
|
465
476
|
debounce: typeof import("./modules/hook/debounce").default;
|
|
466
477
|
throttle: typeof import("./modules/hook/throttle").default;
|
|
467
478
|
task: (param?: import("./typings").Ddan.Func1<any, any> | undefined) => import("./class/pipeTask").default;
|
|
468
479
|
mutex: typeof import("./modules/hook/mutex").default;
|
|
469
480
|
polling: typeof import("./modules/hook/polling").default;
|
|
481
|
+
pipe: (func: Function) => import("./modules/hook/modules/pipeline").default;
|
|
482
|
+
pipeline: () => import("./modules/hook/modules/pipeline").default;
|
|
470
483
|
to: <T_1 = any, U extends object = any>(promise: Promise<T_1>, errorExt?: object | undefined) => Promise<[null, T_1] | [U, undefined]>;
|
|
471
484
|
go: <T_2 = any>(task?: Function | Promise<T_2> | undefined) => Promise<[any, undefined] | [null, T_2]>;
|
|
472
485
|
delay: (ms?: number) => Promise<unknown>;
|
|
@@ -499,6 +512,7 @@ declare const _default: {
|
|
|
499
512
|
new (): {};
|
|
500
513
|
__instance__: any;
|
|
501
514
|
readonly Instance: T_4;
|
|
515
|
+
readonly I: T_4;
|
|
502
516
|
};
|
|
503
517
|
getset: <T_5 = any>(t?: T_5 | undefined) => import("./typings").Ddan.IGetset<T_5>;
|
|
504
518
|
copy: (source: any, options?: {
|
|
@@ -630,25 +644,29 @@ declare const _default: {
|
|
|
630
644
|
}) => string;
|
|
631
645
|
https: (url: string) => string;
|
|
632
646
|
parseUrl: (url: string) => {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
path: string;
|
|
647
|
+
pathname: string;
|
|
648
|
+
params: {};
|
|
649
|
+
route: string;
|
|
637
650
|
page: string;
|
|
651
|
+
name: string;
|
|
652
|
+
withoutExtension: string;
|
|
653
|
+
extname: string;
|
|
654
|
+
href: string;
|
|
655
|
+
url: string;
|
|
656
|
+
origin: string;
|
|
657
|
+
host: string;
|
|
658
|
+
protocol: string;
|
|
659
|
+
port: string;
|
|
638
660
|
query: string;
|
|
639
|
-
filename: string;
|
|
640
|
-
filenameWithoutExtension: string;
|
|
641
|
-
extension: string;
|
|
642
|
-
route: string;
|
|
643
|
-
params: {};
|
|
644
661
|
};
|
|
645
|
-
parsePath: (
|
|
646
|
-
|
|
662
|
+
parsePath: (url: string) => {
|
|
663
|
+
route: string;
|
|
664
|
+
page: string;
|
|
647
665
|
name: string;
|
|
648
666
|
withoutExtension: string;
|
|
649
|
-
|
|
667
|
+
extname: string;
|
|
650
668
|
};
|
|
651
|
-
parseHost: (url: string) => import("./typings").Ddan.IHttpHost
|
|
669
|
+
parseHost: (url: string) => import("./typings").Ddan.IHttpHost;
|
|
652
670
|
join: (...args: string[]) => string;
|
|
653
671
|
};
|
|
654
672
|
css: {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import DPipeline from './modules/pipeline';
|
|
2
|
+
declare const DHooker_base: {
|
|
3
|
+
new (): {};
|
|
4
|
+
__instance__: any;
|
|
5
|
+
readonly Instance: DHooker;
|
|
6
|
+
readonly I: DHooker;
|
|
7
|
+
};
|
|
8
|
+
export default class DHooker extends DHooker_base {
|
|
9
|
+
__lockedMap: Map<string, Promise<[any, undefined] | [null, any]>>;
|
|
10
|
+
pipeline: DPipeline;
|
|
11
|
+
constructor();
|
|
12
|
+
lock(id: string, func: Function): Promise<[any, undefined] | [null, any]> | undefined;
|
|
13
|
+
unlock(id: string): void;
|
|
14
|
+
exec(func: Function, taskId: string): Promise<[any, undefined] | [null, any]>;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Ddan } from '../../typings';
|
|
1
2
|
import debounce from './debounce';
|
|
2
3
|
import throttle from './throttle';
|
|
3
4
|
import mutex from './mutex';
|
|
4
5
|
import DPipeTask from '../../class/pipeTask';
|
|
5
|
-
import { Ddan } from '../../typings';
|
|
6
6
|
import polling from './polling';
|
|
7
|
+
import DPipeline from './modules/pipeline';
|
|
7
8
|
/**
|
|
8
9
|
*
|
|
9
10
|
* @param task 任务
|
|
@@ -14,12 +15,14 @@ declare function run<T = any>(task?: Promise<T> | Function, wait?: number): Prom
|
|
|
14
15
|
declare const _default: {
|
|
15
16
|
sleep: (ms?: number) => Promise<unknown>;
|
|
16
17
|
run: typeof run;
|
|
17
|
-
exec: (func: Function, taskId?: string) => Promise<any[]>;
|
|
18
|
+
exec: (func: Function, taskId?: string) => Promise<[any, undefined] | [null, any]>;
|
|
18
19
|
debounce: typeof debounce;
|
|
19
20
|
throttle: typeof throttle;
|
|
20
21
|
task: (param?: Ddan.Func1<any, any> | undefined) => DPipeTask;
|
|
21
22
|
mutex: typeof mutex;
|
|
22
23
|
polling: typeof polling;
|
|
24
|
+
pipe: (func: Function) => DPipeline;
|
|
25
|
+
pipeline: () => DPipeline;
|
|
23
26
|
to: <T = any, U extends object = any>(promise: Promise<T>, errorExt?: object | undefined) => Promise<[null, T] | [U, undefined]>;
|
|
24
27
|
go: <T_1 = any>(task?: Function | Promise<T_1> | undefined) => Promise<[any, undefined] | [null, T_1]>;
|
|
25
28
|
delay: (ms?: number) => Promise<unknown>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ddan } from '
|
|
1
|
+
import { Ddan } from '../../typings';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
parse: (qs: any, { sep, eq, max, multiple, uri, parseNumber, parseBoolean }?: {
|
|
4
4
|
sep?: string | undefined;
|
|
@@ -20,25 +20,29 @@ declare const _default: {
|
|
|
20
20
|
}) => string;
|
|
21
21
|
https: (url: string) => string;
|
|
22
22
|
parseUrl: (url: string) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
path: string;
|
|
23
|
+
pathname: string;
|
|
24
|
+
params: {};
|
|
25
|
+
route: string;
|
|
27
26
|
page: string;
|
|
27
|
+
name: string;
|
|
28
|
+
withoutExtension: string;
|
|
29
|
+
extname: string;
|
|
30
|
+
href: string;
|
|
31
|
+
url: string;
|
|
32
|
+
origin: string;
|
|
33
|
+
host: string;
|
|
34
|
+
protocol: string;
|
|
35
|
+
port: string;
|
|
28
36
|
query: string;
|
|
29
|
-
filename: string;
|
|
30
|
-
filenameWithoutExtension: string;
|
|
31
|
-
extension: string;
|
|
32
|
-
route: string;
|
|
33
|
-
params: {};
|
|
34
37
|
};
|
|
35
|
-
parsePath: (
|
|
36
|
-
|
|
38
|
+
parsePath: (url: string) => {
|
|
39
|
+
route: string;
|
|
40
|
+
page: string;
|
|
37
41
|
name: string;
|
|
38
42
|
withoutExtension: string;
|
|
39
|
-
|
|
43
|
+
extname: string;
|
|
40
44
|
};
|
|
41
|
-
parseHost: (url: string) => Ddan.IHttpHost
|
|
45
|
+
parseHost: (url: string) => Ddan.IHttpHost;
|
|
42
46
|
join: (...args: string[]) => string;
|
|
43
47
|
};
|
|
44
48
|
export default _default;
|
|
@@ -16,10 +16,13 @@ export declare namespace Ddan {
|
|
|
16
16
|
type Func4<T0 = any, T1 = any, T2 = any, T3 = any, R = any> = Callback<[T0, T1, T2, T3], R>;
|
|
17
17
|
type Result<T = any> = T | Promise<T>;
|
|
18
18
|
interface IHttpHost {
|
|
19
|
+
href: string;
|
|
20
|
+
url: string;
|
|
19
21
|
origin: string;
|
|
20
22
|
host: string;
|
|
21
23
|
protocol: string;
|
|
22
24
|
port: string;
|
|
25
|
+
query: string;
|
|
23
26
|
}
|
|
24
27
|
interface IGetset<T> {
|
|
25
28
|
set(value?: T): void;
|
|
@@ -119,7 +122,7 @@ export declare namespace Ddan {
|
|
|
119
122
|
}
|
|
120
123
|
interface IRegexRule {
|
|
121
124
|
key: string;
|
|
122
|
-
flag?:
|
|
125
|
+
flag?: 'i' | 'g' | 'm' | 'gi' | 'mi';
|
|
123
126
|
value: string;
|
|
124
127
|
}
|
|
125
128
|
interface IIgnoreParams {
|
|
@@ -139,6 +142,12 @@ export declare namespace Ddan {
|
|
|
139
142
|
maxWait?: number;
|
|
140
143
|
trailing?: boolean;
|
|
141
144
|
}
|
|
145
|
+
interface IPipeline {
|
|
146
|
+
pipe(func?: any): IPipeline;
|
|
147
|
+
delay(t?: number): IPipeline;
|
|
148
|
+
clear(): IPipeline;
|
|
149
|
+
whenAll(): Promise<IPipeline>;
|
|
150
|
+
}
|
|
142
151
|
}
|
|
143
152
|
export declare namespace dd {
|
|
144
153
|
interface IHttpRequest {
|
|
@@ -162,7 +171,7 @@ export declare namespace dd {
|
|
|
162
171
|
[key: string]: any;
|
|
163
172
|
url: string;
|
|
164
173
|
model?: string;
|
|
165
|
-
method:
|
|
174
|
+
method: 'get' | 'post' | 'put';
|
|
166
175
|
body?: string;
|
|
167
176
|
plugins?: Record<string, any>;
|
|
168
177
|
}
|
|
@@ -190,7 +199,7 @@ export declare namespace dd {
|
|
|
190
199
|
interface IDWatermarkParams {
|
|
191
200
|
[key: string]: any;
|
|
192
201
|
t?: number;
|
|
193
|
-
g?:
|
|
202
|
+
g?: 'nw' | 'north' | 'ne' | 'west' | 'center' | 'east' | 'sw' | 'south' | 'se';
|
|
194
203
|
x?: number;
|
|
195
204
|
y?: number;
|
|
196
205
|
voffset?: number;
|
|
@@ -199,7 +208,7 @@ export declare namespace dd {
|
|
|
199
208
|
pady?: number;
|
|
200
209
|
}
|
|
201
210
|
interface IDWatermarkText {
|
|
202
|
-
type?:
|
|
211
|
+
type?: 'd3F5LXplbmhlaQ' | 'd3F5LW1pY3JvaGVp' | 'ZmFuZ3poZW5nc2h1c29uZw' | 'ZmFuZ3poZW5na2FpdGk' | 'ZmFuZ3poZW5naGVpdGk' | 'ZmFuZ3poZW5nZmFuZ3Nvbmc' | 'ZHJvaWRzYW5zZmFsbGJhY2s';
|
|
203
212
|
color?: string;
|
|
204
213
|
size?: number;
|
|
205
214
|
shadow?: number;
|
package/package.json
CHANGED
package/bin/lib/class/task.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const base_1 = require("../modules/hook/base");
|
|
4
|
-
class DTask {
|
|
5
|
-
__source;
|
|
6
|
-
constructor(source) {
|
|
7
|
-
this.__source = source;
|
|
8
|
-
}
|
|
9
|
-
run = () => base_1.default.safeDo(this.__source);
|
|
10
|
-
static _lockedMap = new Map();
|
|
11
|
-
static _lock(id, func) {
|
|
12
|
-
if (!id || !func)
|
|
13
|
-
return undefined;
|
|
14
|
-
const task = new DTask(func).run();
|
|
15
|
-
this._lockedMap.set(id, task);
|
|
16
|
-
return task;
|
|
17
|
-
}
|
|
18
|
-
static _unlock(id) {
|
|
19
|
-
if (!id)
|
|
20
|
-
return;
|
|
21
|
-
this._lockedMap.delete(id);
|
|
22
|
-
}
|
|
23
|
-
static async exec(func, taskId) {
|
|
24
|
-
if (!func || !taskId) {
|
|
25
|
-
return new DTask(func).run();
|
|
26
|
-
}
|
|
27
|
-
const _task = this._lockedMap.get(taskId);
|
|
28
|
-
if (_task) {
|
|
29
|
-
return _task;
|
|
30
|
-
}
|
|
31
|
-
const _newTask = this._lock(taskId, func);
|
|
32
|
-
if (!_newTask)
|
|
33
|
-
return new DTask(func).run();
|
|
34
|
-
const result = await _newTask;
|
|
35
|
-
this._unlock(taskId);
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.default = DTask;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export default class DTask<T = any> {
|
|
2
|
-
__source: any;
|
|
3
|
-
constructor(source?: any);
|
|
4
|
-
run: () => Promise<[any, undefined] | [null, T]>;
|
|
5
|
-
static _lockedMap: Map<string, Promise<any[]>>;
|
|
6
|
-
static _lock(id: string, func: Function): Promise<[any, undefined] | [null, any]> | undefined;
|
|
7
|
-
static _unlock(id: string): void;
|
|
8
|
-
static exec(func: Function, taskId: string): Promise<any[]>;
|
|
9
|
-
}
|