ddan-js 2.9.4 → 2.9.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/types/browser.d.ts +1 -1
- package/bin/types/index.d.ts +1 -1
- package/bin/types/modules/node/aliyun.d.ts +1 -1
- package/bin/types/upload.d.ts +2 -0
- package/bin/upload.js +1 -0
- package/package.json +18 -13
- package/bin/lib/browser.js +0 -111
- package/bin/lib/class/event.js +0 -104
- package/bin/lib/class/getset.js +0 -12
- package/bin/lib/class/icon.js +0 -94
- package/bin/lib/class/joker.js +0 -121
- package/bin/lib/class/kvalue.js +0 -29
- package/bin/lib/class/mapping.js +0 -82
- package/bin/lib/class/persist.js +0 -65
- package/bin/lib/class/pipeTask.js +0 -42
- package/bin/lib/class/pipeparallel.js +0 -24
- package/bin/lib/class/store.js +0 -87
- package/bin/lib/class/tracker.js +0 -125
- package/bin/lib/class/watermark.js +0 -63
- package/bin/lib/common/_Symbol.js +0 -5
- package/bin/lib/common/_freeGlobal.js +0 -5
- package/bin/lib/common/_object.js +0 -40
- package/bin/lib/common/_root.js +0 -10
- package/bin/lib/common/internal/asciiToArray.js +0 -13
- package/bin/lib/common/internal/castSlice.js +0 -18
- package/bin/lib/common/internal/createCaseFirst.js +0 -30
- package/bin/lib/common/internal/hasUnicode.js +0 -26
- package/bin/lib/common/internal/nodeTypes.js +0 -26
- package/bin/lib/common/internal/slice.js +0 -46
- package/bin/lib/common/internal/stringToArray.js +0 -18
- package/bin/lib/common/internal/unicodeToArray.js +0 -40
- package/bin/lib/common/internal/unicodeWords.js +0 -67
- package/bin/lib/index.js +0 -114
- package/bin/lib/modules/browser/ecdh.js +0 -124
- package/bin/lib/modules/browser/index.js +0 -4
- package/bin/lib/modules/cdn.js +0 -62
- package/bin/lib/modules/convert/base.js +0 -125
- package/bin/lib/modules/convert/base64.js +0 -114
- package/bin/lib/modules/convert/index.js +0 -99
- package/bin/lib/modules/convert/md5.js +0 -222
- package/bin/lib/modules/convert/pkcs.js +0 -16
- package/bin/lib/modules/convert/utf8.js +0 -106
- package/bin/lib/modules/crypto/base64.js +0 -14
- package/bin/lib/modules/crypto/const.js +0 -7
- package/bin/lib/modules/crypto/index.js +0 -30
- package/bin/lib/modules/crypto/rsa.js +0 -143
- package/bin/lib/modules/crypto/tea.js +0 -79
- package/bin/lib/modules/crypto/uuid.js +0 -34
- package/bin/lib/modules/css.js +0 -137
- package/bin/lib/modules/decorator.js +0 -14
- package/bin/lib/modules/fetch.js +0 -82
- package/bin/lib/modules/gbk.js +0 -46
- package/bin/lib/modules/hook/base.js +0 -60
- package/bin/lib/modules/hook/hooker.js +0 -39
- package/bin/lib/modules/hook/index.js +0 -49
- package/bin/lib/modules/hook/log.js +0 -54
- package/bin/lib/modules/hook/modules/bezier.js +0 -121
- package/bin/lib/modules/hook/modules/debounce.js +0 -127
- package/bin/lib/modules/hook/modules/mutex.js +0 -22
- package/bin/lib/modules/hook/modules/pipeline.js +0 -59
- package/bin/lib/modules/hook/modules/polling.js +0 -20
- package/bin/lib/modules/hook/modules/safeTask.js +0 -25
- package/bin/lib/modules/hook/modules/throttle.js +0 -30
- package/bin/lib/modules/html.js +0 -293
- package/bin/lib/modules/http/index.js +0 -171
- package/bin/lib/modules/http/interceptor.js +0 -22
- package/bin/lib/modules/list/base.js +0 -37
- package/bin/lib/modules/list/index.js +0 -90
- package/bin/lib/modules/logger.js +0 -55
- package/bin/lib/modules/math/index.js +0 -118
- package/bin/lib/modules/mini/diff.js +0 -97
- package/bin/lib/modules/mini/http/index.js +0 -155
- package/bin/lib/modules/mini/index.js +0 -71
- package/bin/lib/modules/node/aliyun.js +0 -156
- package/bin/lib/modules/node/brotli.js +0 -46
- package/bin/lib/modules/node/child.js +0 -18
- package/bin/lib/modules/node/ecdh-web.js +0 -11
- package/bin/lib/modules/node/ecdh.js +0 -115
- package/bin/lib/modules/node/file.js +0 -25
- package/bin/lib/modules/node/index.js +0 -11
- package/bin/lib/modules/node/proxy.js +0 -147
- package/bin/lib/modules/node/rsa-web.js +0 -19
- package/bin/lib/modules/node/socks5.js +0 -424
- package/bin/lib/modules/obj/index.js +0 -184
- package/bin/lib/modules/qs/base.js +0 -5
- package/bin/lib/modules/qs/decode.js +0 -45
- package/bin/lib/modules/qs/encode.js +0 -53
- package/bin/lib/modules/qs/index.js +0 -152
- package/bin/lib/modules/regex.js +0 -16
- package/bin/lib/modules/rsa.js +0 -18
- package/bin/lib/modules/rule/async-validator/index.js +0 -306
- package/bin/lib/modules/rule/async-validator/interface.js +0 -2
- package/bin/lib/modules/rule/async-validator/messages.js +0 -59
- package/bin/lib/modules/rule/async-validator/rule/enum.js +0 -13
- package/bin/lib/modules/rule/async-validator/rule/index.js +0 -16
- package/bin/lib/modules/rule/async-validator/rule/pattern.js +0 -27
- package/bin/lib/modules/rule/async-validator/rule/range.js +0 -54
- package/bin/lib/modules/rule/async-validator/rule/required.js +0 -12
- package/bin/lib/modules/rule/async-validator/rule/type.js +0 -98
- package/bin/lib/modules/rule/async-validator/rule/url.js +0 -55
- package/bin/lib/modules/rule/async-validator/rule/whitespace.js +0 -20
- package/bin/lib/modules/rule/async-validator/util.js +0 -255
- package/bin/lib/modules/rule/async-validator/validator/any.js +0 -16
- package/bin/lib/modules/rule/async-validator/validator/array.js +0 -19
- package/bin/lib/modules/rule/async-validator/validator/boolean.js +0 -20
- package/bin/lib/modules/rule/async-validator/validator/date.js +0 -31
- package/bin/lib/modules/rule/async-validator/validator/enum.js +0 -20
- package/bin/lib/modules/rule/async-validator/validator/float.js +0 -20
- package/bin/lib/modules/rule/async-validator/validator/index.js +0 -36
- package/bin/lib/modules/rule/async-validator/validator/integer.js +0 -20
- package/bin/lib/modules/rule/async-validator/validator/method.js +0 -19
- package/bin/lib/modules/rule/async-validator/validator/number.js +0 -23
- package/bin/lib/modules/rule/async-validator/validator/object.js +0 -19
- package/bin/lib/modules/rule/async-validator/validator/pattern.js +0 -19
- package/bin/lib/modules/rule/async-validator/validator/regexp.js +0 -19
- package/bin/lib/modules/rule/async-validator/validator/required.js +0 -10
- package/bin/lib/modules/rule/async-validator/validator/string.js +0 -24
- package/bin/lib/modules/rule/async-validator/validator/type.js +0 -20
- package/bin/lib/modules/rule/index.js +0 -67
- package/bin/lib/modules/string/index.js +0 -121
- package/bin/lib/modules/string/words.js +0 -33
- package/bin/lib/modules/time/const.js +0 -11
- package/bin/lib/modules/time/dtime.js +0 -132
- package/bin/lib/modules/time/frame.js +0 -49
- package/bin/lib/modules/time/index.js +0 -84
- package/bin/lib/typings/index.js +0 -2
- package/bin/lib/util/function.js +0 -33
- package/bin/lib/util/includes.js +0 -96
- package/bin/lib/util/index.js +0 -26
- package/bin/lib/util/is.js +0 -148
- package/bin/lib/util/to.js +0 -47
package/bin/lib/class/persist.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.persistConfig = void 0;
|
|
4
|
-
const hook_1 = require("../modules/hook");
|
|
5
|
-
const obj_1 = require("../modules/obj");
|
|
6
|
-
const persistConfig = (key, fields, storage) => {
|
|
7
|
-
const persit = {
|
|
8
|
-
key,
|
|
9
|
-
fields,
|
|
10
|
-
storage
|
|
11
|
-
};
|
|
12
|
-
return persit;
|
|
13
|
-
};
|
|
14
|
-
exports.persistConfig = persistConfig;
|
|
15
|
-
class DPersist {
|
|
16
|
-
key;
|
|
17
|
-
storage;
|
|
18
|
-
fields = [];
|
|
19
|
-
constructor(config) {
|
|
20
|
-
this.key = config?.key || "";
|
|
21
|
-
this.fields = config?.fields || [];
|
|
22
|
-
this.storage = config?.storage || undefined;
|
|
23
|
-
}
|
|
24
|
-
save = hook_1.default.debounce((data) => {
|
|
25
|
-
if (!this.key || !this.storage)
|
|
26
|
-
return;
|
|
27
|
-
try {
|
|
28
|
-
const { setItem, setStorageSync } = this.storage;
|
|
29
|
-
if (setStorageSync) {
|
|
30
|
-
return setStorageSync(this.key, data);
|
|
31
|
-
}
|
|
32
|
-
if (setItem) {
|
|
33
|
-
return setItem(this.key, JSON.stringify(data));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
console.error("persit save ", error);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
read() {
|
|
41
|
-
if (!this.key || !this.storage)
|
|
42
|
-
return undefined;
|
|
43
|
-
try {
|
|
44
|
-
const { getItem, getStorageSync } = this.storage;
|
|
45
|
-
if (getStorageSync) {
|
|
46
|
-
return getStorageSync(this.key);
|
|
47
|
-
}
|
|
48
|
-
if (getItem) {
|
|
49
|
-
const value = getItem(this.key);
|
|
50
|
-
return JSON.parse(value);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
console.error("persit read ", error);
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
handleSave(target, key) {
|
|
59
|
-
if (!this.fields.includes(key) || !target)
|
|
60
|
-
return;
|
|
61
|
-
const data = obj_1.default.copy(target, { fields: this.fields });
|
|
62
|
-
this.save(data);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.default = DPersist;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const is_1 = require("../util/is");
|
|
4
|
-
class DPipeTask {
|
|
5
|
-
__list = [];
|
|
6
|
-
constructor(_task) {
|
|
7
|
-
this.push(_task);
|
|
8
|
-
}
|
|
9
|
-
push(_task) {
|
|
10
|
-
_task && this.__list.push(_task);
|
|
11
|
-
return this;
|
|
12
|
-
}
|
|
13
|
-
clear() {
|
|
14
|
-
this.__list = [];
|
|
15
|
-
return this;
|
|
16
|
-
}
|
|
17
|
-
_exec(task, payload) {
|
|
18
|
-
let temp;
|
|
19
|
-
if (is_1.default.isFunction(task)) {
|
|
20
|
-
temp = task(payload);
|
|
21
|
-
}
|
|
22
|
-
else if (is_1.default.isPromise(task)) {
|
|
23
|
-
return task.then(res => {
|
|
24
|
-
return { ...payload, ...res };
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
temp = task;
|
|
29
|
-
}
|
|
30
|
-
return is_1.default.isPromise(temp) ? temp : Promise.resolve({ ...temp, ...payload });
|
|
31
|
-
}
|
|
32
|
-
run(param) {
|
|
33
|
-
try {
|
|
34
|
-
const result = this.__list.reduce((prev, curTask) => prev.then((res) => this._exec(curTask, res)), Promise.resolve(param));
|
|
35
|
-
return result.then(data => [undefined, data]).catch(err => [err, undefined]);
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
return Promise.reject([err, undefined]);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.default = DPipeTask;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const hook_1 = require("../modules/hook");
|
|
4
|
-
class DPipeparallel {
|
|
5
|
-
__list = [];
|
|
6
|
-
constructor() {
|
|
7
|
-
this.clear();
|
|
8
|
-
}
|
|
9
|
-
add(_task) {
|
|
10
|
-
const _p = hook_1.default.run(_task);
|
|
11
|
-
this.__list.push(_p);
|
|
12
|
-
return this;
|
|
13
|
-
}
|
|
14
|
-
clear() {
|
|
15
|
-
this.__list = [];
|
|
16
|
-
return this;
|
|
17
|
-
}
|
|
18
|
-
wait() {
|
|
19
|
-
const _tempList = this.__list;
|
|
20
|
-
this.clear();
|
|
21
|
-
return Promise.allSettled(_tempList);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.default = DPipeparallel;
|
package/bin/lib/class/store.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.storeRef = void 0;
|
|
4
|
-
const hook_1 = require("../modules/hook");
|
|
5
|
-
const event_1 = require("./event");
|
|
6
|
-
const obj_1 = require("../modules/obj");
|
|
7
|
-
const is_1 = require("../util/is");
|
|
8
|
-
const persist_1 = require("./persist");
|
|
9
|
-
class DStore extends event_1.default {
|
|
10
|
-
setters = {};
|
|
11
|
-
getters = {};
|
|
12
|
-
actions = {};
|
|
13
|
-
persist;
|
|
14
|
-
constructor() {
|
|
15
|
-
super();
|
|
16
|
-
}
|
|
17
|
-
async dispatch(key, payload = undefined) {
|
|
18
|
-
const self = this;
|
|
19
|
-
const action = Reflect.get(self.actions, key);
|
|
20
|
-
if (!is_1.default.isFunction(action))
|
|
21
|
-
return undefined;
|
|
22
|
-
const [, data] = await hook_1.default.run(action({
|
|
23
|
-
...self,
|
|
24
|
-
commit: self.commit.bind(self),
|
|
25
|
-
query: self.query.bind(self),
|
|
26
|
-
dispatch: self.dispatch.bind(self),
|
|
27
|
-
}, payload));
|
|
28
|
-
return data;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* 查询
|
|
32
|
-
* @param key 字段
|
|
33
|
-
* @returns
|
|
34
|
-
*/
|
|
35
|
-
async query(key) {
|
|
36
|
-
const val = Reflect.get(this, key);
|
|
37
|
-
let result = undefined;
|
|
38
|
-
if (val !== null && val !== undefined && val !== '') {
|
|
39
|
-
// result = JSON.parse(JSON.stringify(val));
|
|
40
|
-
result = obj_1.default.copy(val);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
const [, data] = await hook_1.default.exec(() => this.dispatch(key), `${this.__eventId}_${key}`);
|
|
44
|
-
result = data;
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* 提交
|
|
50
|
-
* @param name 字段
|
|
51
|
-
* @param payload 值
|
|
52
|
-
*/
|
|
53
|
-
commit(name, payload) {
|
|
54
|
-
if (is_1.default.isObject(payload)) {
|
|
55
|
-
payload = obj_1.default.copy(payload);
|
|
56
|
-
}
|
|
57
|
-
this[name] = payload;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.default = DStore;
|
|
61
|
-
const storeRef = (source, persistConfig) => {
|
|
62
|
-
const _initSource = Object.assign(new DStore(), source || {});
|
|
63
|
-
_initSource.__persist = new persist_1.default(persistConfig || _initSource.persist);
|
|
64
|
-
const _initData = _initSource.__persist.read();
|
|
65
|
-
const _source = _initData ? Object.assign(_initSource, _initData) : _initSource;
|
|
66
|
-
return new Proxy(_source, {
|
|
67
|
-
get: (target, key, receiver) => {
|
|
68
|
-
const getFunc = Reflect.get(target.getters, key);
|
|
69
|
-
if (is_1.default.isFunction(getFunc))
|
|
70
|
-
return getFunc(target);
|
|
71
|
-
return Reflect.get(target, key, receiver);
|
|
72
|
-
},
|
|
73
|
-
set: (target, key, value, receiver) => {
|
|
74
|
-
const setFunc = Reflect.get(target.setters, key);
|
|
75
|
-
if (is_1.default.isFunction(setFunc) && !setFunc(target, value))
|
|
76
|
-
return true;
|
|
77
|
-
const ret = Reflect.set(target, key, value, receiver);
|
|
78
|
-
if (ret) {
|
|
79
|
-
target.emit(key.toString(), value);
|
|
80
|
-
target?.__persist?.handleSave(target, key.toString());
|
|
81
|
-
}
|
|
82
|
-
return ret;
|
|
83
|
-
},
|
|
84
|
-
has: (target, key) => Reflect.has(target, key),
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
exports.storeRef = storeRef;
|
package/bin/lib/class/tracker.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DTracker = exports.DTrack = void 0;
|
|
4
|
-
const list_1 = require("../modules/list");
|
|
5
|
-
const obj_1 = require("../modules/obj");
|
|
6
|
-
const uuid_1 = require("../modules/crypto/uuid");
|
|
7
|
-
const time_1 = require("../modules/time");
|
|
8
|
-
class DTrack {
|
|
9
|
-
id = "";
|
|
10
|
-
/** 开始时间戳 */
|
|
11
|
-
start = 0;
|
|
12
|
-
/** 结束时间戳 */
|
|
13
|
-
end = 0;
|
|
14
|
-
/** 耗时 */
|
|
15
|
-
cost = 0;
|
|
16
|
-
name = "";
|
|
17
|
-
type = "";
|
|
18
|
-
desc = "";
|
|
19
|
-
/** 开始时间描述 */
|
|
20
|
-
timeStartDesc = "";
|
|
21
|
-
/** 结束时间描述 */
|
|
22
|
-
timeEndDesc = "";
|
|
23
|
-
/** 是否完成 */
|
|
24
|
-
isDone = false;
|
|
25
|
-
/** 标志 0:默认,1:结束 */
|
|
26
|
-
flag = 0;
|
|
27
|
-
constructor() {
|
|
28
|
-
this.id = (0, uuid_1.default)();
|
|
29
|
-
this.start = Date.now();
|
|
30
|
-
this.timeStartDesc = time_1.default.format(this.start, "hh:mm:ss.SSS");
|
|
31
|
-
}
|
|
32
|
-
/** 执行时间戳 */
|
|
33
|
-
get time() {
|
|
34
|
-
return this.flag ? this.end : this.start;
|
|
35
|
-
}
|
|
36
|
-
/** 执行时间描述 */
|
|
37
|
-
get timeDesc() {
|
|
38
|
-
return this.flag ? this.timeEndDesc : this.timeStartDesc;
|
|
39
|
-
}
|
|
40
|
-
done = (t = Date.now()) => {
|
|
41
|
-
if (!this.start)
|
|
42
|
-
return;
|
|
43
|
-
this.end = t;
|
|
44
|
-
this.cost = this.end - this.start;
|
|
45
|
-
this.timeEndDesc = time_1.default.format(this.end, "hh:mm:ss.SSS");
|
|
46
|
-
this.isDone = true;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
exports.DTrack = DTrack;
|
|
50
|
-
class DTracker {
|
|
51
|
-
__map = new Map();
|
|
52
|
-
__trackList = [];
|
|
53
|
-
opened = true;
|
|
54
|
-
clear() {
|
|
55
|
-
this.__map.clear();
|
|
56
|
-
this.__trackList = [];
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
add(name, { desc = "", type = "" } = {}) {
|
|
60
|
-
if (!name || !this.opened)
|
|
61
|
-
return "";
|
|
62
|
-
const _track = new DTrack();
|
|
63
|
-
_track.name = name;
|
|
64
|
-
_track.type = type;
|
|
65
|
-
_track.desc = desc;
|
|
66
|
-
this.__trackList.push(_track);
|
|
67
|
-
return _track.id;
|
|
68
|
-
}
|
|
69
|
-
done(id) {
|
|
70
|
-
if (!id || !this.opened)
|
|
71
|
-
return;
|
|
72
|
-
const _track = this.__trackList.find(e => e.id === id);
|
|
73
|
-
if (!_track || _track.isDone)
|
|
74
|
-
return;
|
|
75
|
-
_track.done();
|
|
76
|
-
const endTrack = obj_1.default.cloneClass(_track); // Object.assign({}, _track);
|
|
77
|
-
endTrack.id = this._endId(id);
|
|
78
|
-
endTrack.flag = 1;
|
|
79
|
-
endTrack.desc = `${_track.desc} | end`;
|
|
80
|
-
this.__trackList.push(endTrack);
|
|
81
|
-
}
|
|
82
|
-
getTrack(id) {
|
|
83
|
-
return this.__trackList.find(e => e.id === id);
|
|
84
|
-
}
|
|
85
|
-
getLine(id) {
|
|
86
|
-
if (!id || id.endsWith("-end"))
|
|
87
|
-
return [];
|
|
88
|
-
const idx_s = this.__trackList.findIndex(e => e.id === id);
|
|
89
|
-
if (idx_s < 0)
|
|
90
|
-
return [];
|
|
91
|
-
const endid = this._endId(id);
|
|
92
|
-
const idx_e = this.__trackList.findIndex(e => e.id === endid);
|
|
93
|
-
const count = idx_e < 0 ? this.__trackList.length - idx_s : idx_e - idx_s + 1;
|
|
94
|
-
return list_1.default.take(this.__trackList, count, idx_s);
|
|
95
|
-
}
|
|
96
|
-
getList(name, id = "") {
|
|
97
|
-
if (!name)
|
|
98
|
-
return [];
|
|
99
|
-
const _nameList = this.__trackList.filter(e => e.name === name);
|
|
100
|
-
if (_nameList.length <= 0)
|
|
101
|
-
return [];
|
|
102
|
-
if (!id)
|
|
103
|
-
return _nameList;
|
|
104
|
-
const endid = this._endId(id);
|
|
105
|
-
return this.__trackList.filter(e => e.id === id || e.id === endid);
|
|
106
|
-
}
|
|
107
|
-
get list() {
|
|
108
|
-
return this.__trackList;
|
|
109
|
-
}
|
|
110
|
-
get size() {
|
|
111
|
-
return this.__trackList.length;
|
|
112
|
-
}
|
|
113
|
-
_endId = (id) => `${id}-end`;
|
|
114
|
-
report(cb) {
|
|
115
|
-
// report(cb?: dd.Callback <[DTrack, number]>) {
|
|
116
|
-
const arr = this.list;
|
|
117
|
-
if (!arr || arr.length <= 0)
|
|
118
|
-
return;
|
|
119
|
-
const start = arr[0].time;
|
|
120
|
-
arr.forEach((e) => cb && cb(e, start));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.DTracker = DTracker;
|
|
124
|
-
const tracker = new DTracker();
|
|
125
|
-
exports.default = tracker;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DWatermark = void 0;
|
|
4
|
-
const crypto_1 = require("../modules/crypto");
|
|
5
|
-
const qs_1 = require("../modules/qs");
|
|
6
|
-
class DWatermark {
|
|
7
|
-
host = "";
|
|
8
|
-
list = [];
|
|
9
|
-
constructor(bg, size = {}) {
|
|
10
|
-
this._parseHost(bg);
|
|
11
|
-
const { width = 500, height = 400 } = size;
|
|
12
|
-
const _kv = qs_1.default.parseUrl(bg)?.params || {};
|
|
13
|
-
_kv["x-oss-process"] = `image/resize,w_${width},h_${height},m_fill`;
|
|
14
|
-
const query = qs_1.default.stringify(_kv, { uri: false });
|
|
15
|
-
this.list.push(`${bg}?${query}`);
|
|
16
|
-
}
|
|
17
|
-
_parseHost(url) {
|
|
18
|
-
if (!url || this.host)
|
|
19
|
-
return;
|
|
20
|
-
if (/^http[s]?:\/\/([\w.]+)/.test(url)) {
|
|
21
|
-
this.host = url.replace(/^http[s]?:\/\/([\w.]+)[\w\W]+/, "$1");
|
|
22
|
-
}
|
|
23
|
-
;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 图片
|
|
27
|
-
* @param url
|
|
28
|
-
* @param params
|
|
29
|
-
* @returns
|
|
30
|
-
*/
|
|
31
|
-
image(url, params = {}) {
|
|
32
|
-
if (!url || !url.includes(this.host))
|
|
33
|
-
return;
|
|
34
|
-
if (this.list.length <= 0)
|
|
35
|
-
return;
|
|
36
|
-
const opts = { g: "nw", ...params };
|
|
37
|
-
const link = url.replace(/^http[s]?:\/\/[\w.]+\/([\w-.,_/?%&=]+)$/, "$1");
|
|
38
|
-
const watermark = crypto_1.default.base64.encodeByOss(link);
|
|
39
|
-
const str = qs_1.default.stringify({ image: watermark, ...opts }, { sep: ",", eq: "_" });
|
|
40
|
-
this.list.push(`/watermark,${str}`);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 文本内容
|
|
44
|
-
* @param content
|
|
45
|
-
* @param params
|
|
46
|
-
* @param iText
|
|
47
|
-
* @returns
|
|
48
|
-
*/
|
|
49
|
-
text(content, params = {}, iText = {}) {
|
|
50
|
-
if (!content)
|
|
51
|
-
return;
|
|
52
|
-
const opts = { g: "nw", ...params };
|
|
53
|
-
const watermark = crypto_1.default.base64.encodeByOss(content);
|
|
54
|
-
const str = qs_1.default.stringify({ text: watermark, ...opts, ...iText, }, { sep: ",", eq: "_" });
|
|
55
|
-
this.list.push(`/watermark,${str}`);
|
|
56
|
-
}
|
|
57
|
-
result() {
|
|
58
|
-
return this.list.join("");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.DWatermark = DWatermark;
|
|
62
|
-
const watermark = (bg, size) => new DWatermark(bg, size);
|
|
63
|
-
exports.default = watermark;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const _Symbol_1 = require("./_Symbol");
|
|
4
|
-
const { toString, hasOwnProperty, propertyIsEnumerable } = Object.prototype;
|
|
5
|
-
/** Built-in value references. */
|
|
6
|
-
const symToStringTag = _Symbol_1.default ? _Symbol_1.default.toStringTag : undefined;
|
|
7
|
-
function getRawTag(value) {
|
|
8
|
-
const isOwn = hasOwnProperty.call(value, symToStringTag);
|
|
9
|
-
const tag = value[symToStringTag];
|
|
10
|
-
let unmasked = false;
|
|
11
|
-
try {
|
|
12
|
-
value[symToStringTag] = undefined;
|
|
13
|
-
unmasked = true;
|
|
14
|
-
}
|
|
15
|
-
catch (e) { }
|
|
16
|
-
const result = toString.call(value);
|
|
17
|
-
if (unmasked) {
|
|
18
|
-
if (isOwn) {
|
|
19
|
-
value[symToStringTag] = tag;
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
delete value[symToStringTag];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
function getTag(value) {
|
|
28
|
-
if (value == null) {
|
|
29
|
-
return value === undefined ? "[object Undefined]" : "[object Null]";
|
|
30
|
-
}
|
|
31
|
-
return (symToStringTag && symToStringTag in Object(value))
|
|
32
|
-
? getRawTag(value)
|
|
33
|
-
: toString.call(value);
|
|
34
|
-
}
|
|
35
|
-
function getType(value) {
|
|
36
|
-
let str = getTag(value);
|
|
37
|
-
const mat = str.match(/\w+/g) || ["object", "Undefined"];
|
|
38
|
-
return mat[1] || "";
|
|
39
|
-
}
|
|
40
|
-
exports.default = { getTag, getType, toString, hasOwnProperty, propertyIsEnumerable };
|
package/bin/lib/common/_root.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const _freeGlobal_1 = require("./_freeGlobal");
|
|
4
|
-
/** Detect free variable `globalThis` */
|
|
5
|
-
const freeGlobalThis = typeof globalThis === 'object' && globalThis !== null && globalThis.Object === Object && globalThis;
|
|
6
|
-
/** Detect free variable `self`. */
|
|
7
|
-
const freeSelf = typeof self === 'object' && self !== null && self.Object === Object && self;
|
|
8
|
-
/** Used as a reference to the global object. */
|
|
9
|
-
const root = freeGlobalThis || _freeGlobal_1.default || freeSelf || Function('return this')();
|
|
10
|
-
exports.default = root;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Converts an ASCII `string` to an array.
|
|
5
|
-
*
|
|
6
|
-
* @private
|
|
7
|
-
* @param {string} string The string to convert.
|
|
8
|
-
* @returns {Array} Returns the converted array.
|
|
9
|
-
*/
|
|
10
|
-
function asciiToArray(string) {
|
|
11
|
-
return string.split('');
|
|
12
|
-
}
|
|
13
|
-
exports.default = asciiToArray;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const slice_1 = require("./slice");
|
|
4
|
-
/**
|
|
5
|
-
* Casts `array` to a slice if it's needed.
|
|
6
|
-
*
|
|
7
|
-
* @private
|
|
8
|
-
* @param {Array} array The array to inspect.
|
|
9
|
-
* @param {number} start The start position.
|
|
10
|
-
* @param {number} [end=array.length] The end position.
|
|
11
|
-
* @returns {Array} Returns the cast slice.
|
|
12
|
-
*/
|
|
13
|
-
function castSlice(array, start, end) {
|
|
14
|
-
const { length } = array;
|
|
15
|
-
end = end === undefined ? length : end;
|
|
16
|
-
return (!start && end >= length) ? array : (0, slice_1.default)(array, start, end);
|
|
17
|
-
}
|
|
18
|
-
exports.default = castSlice;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const castSlice_1 = require("./castSlice");
|
|
4
|
-
const hasUnicode_1 = require("./hasUnicode");
|
|
5
|
-
const stringToArray_1 = require("./stringToArray");
|
|
6
|
-
/**
|
|
7
|
-
* Creates a function like `lowerFirst`.
|
|
8
|
-
*
|
|
9
|
-
* @private
|
|
10
|
-
* @param {string} methodName The name of the `String` case method to use.
|
|
11
|
-
* @returns {Function} Returns the new case function.
|
|
12
|
-
*/
|
|
13
|
-
function createCaseFirst(methodName) {
|
|
14
|
-
return (string) => {
|
|
15
|
-
if (!string) {
|
|
16
|
-
return '';
|
|
17
|
-
}
|
|
18
|
-
const strSymbols = (0, hasUnicode_1.default)(string)
|
|
19
|
-
? (0, stringToArray_1.default)(string)
|
|
20
|
-
: undefined;
|
|
21
|
-
const chr = strSymbols
|
|
22
|
-
? strSymbols[0]
|
|
23
|
-
: string[0];
|
|
24
|
-
const trailing = strSymbols
|
|
25
|
-
? (0, castSlice_1.default)(strSymbols, 1).join('')
|
|
26
|
-
: string.slice(1);
|
|
27
|
-
return chr[methodName]() + trailing;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
exports.default = createCaseFirst;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/** Used to compose unicode character classes. */
|
|
4
|
-
const rsAstralRange = '\\ud800-\\udfff';
|
|
5
|
-
const rsComboMarksRange = '\\u0300-\\u036f';
|
|
6
|
-
const reComboHalfMarksRange = '\\ufe20-\\ufe2f';
|
|
7
|
-
const rsComboSymbolsRange = '\\u20d0-\\u20ff';
|
|
8
|
-
const rsComboMarksExtendedRange = '\\u1ab0-\\u1aff';
|
|
9
|
-
const rsComboMarksSupplementRange = '\\u1dc0-\\u1dff';
|
|
10
|
-
const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange;
|
|
11
|
-
const rsVarRange = '\\ufe0e\\ufe0f';
|
|
12
|
-
/** Used to compose unicode capture groups. */
|
|
13
|
-
const rsZWJ = '\\u200d';
|
|
14
|
-
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
|
15
|
-
const reHasUnicode = RegExp(`[${rsZWJ + rsAstralRange + rsComboRange + rsVarRange}]`);
|
|
16
|
-
/**
|
|
17
|
-
* Checks if `string` contains Unicode symbols.
|
|
18
|
-
*
|
|
19
|
-
* @private
|
|
20
|
-
* @param {string} string The string to inspect.
|
|
21
|
-
* @returns {boolean} Returns `true` if a symbol is found, else `false`.
|
|
22
|
-
*/
|
|
23
|
-
function hasUnicode(string) {
|
|
24
|
-
return reHasUnicode.test(string);
|
|
25
|
-
}
|
|
26
|
-
exports.default = hasUnicode;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const _freeGlobal_1 = require("../_freeGlobal");
|
|
4
|
-
/** Detect free variable `exports`. */
|
|
5
|
-
const freeExports = typeof exports === 'object' && exports !== null && !exports.nodeType && exports;
|
|
6
|
-
/** Detect free variable `module`. */
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
const freeModule = freeExports && typeof module === 'object' && module !== null && !module.nodeType && module;
|
|
9
|
-
/** Detect the popular CommonJS extension `module.exports`. */
|
|
10
|
-
const moduleExports = freeModule && freeModule.exports === freeExports;
|
|
11
|
-
/** Detect free variable `process` from Node.js. */
|
|
12
|
-
const freeProcess = moduleExports && _freeGlobal_1.default.process;
|
|
13
|
-
/** Used to access faster Node.js helpers. */
|
|
14
|
-
const nodeTypes = ((() => {
|
|
15
|
-
try {
|
|
16
|
-
/* Detect public `util.types` helpers for Node.js v10+. */
|
|
17
|
-
/* Node.js deprecation code: DEP0103. */
|
|
18
|
-
const typesHelper = freeModule && freeModule.require && freeModule.require('util').types;
|
|
19
|
-
return typesHelper
|
|
20
|
-
? typesHelper
|
|
21
|
-
/* Legacy process.binding('util') for Node.js earlier than v10. */
|
|
22
|
-
: freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
23
|
-
}
|
|
24
|
-
catch (e) { }
|
|
25
|
-
})());
|
|
26
|
-
exports.default = nodeTypes;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Creates a slice of `array` from `start` up to, but not including, `end`.
|
|
5
|
-
*
|
|
6
|
-
* **Note:** This method is used instead of
|
|
7
|
-
* [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
|
|
8
|
-
* returned.
|
|
9
|
-
*
|
|
10
|
-
* @since 3.0.0
|
|
11
|
-
* @category Array
|
|
12
|
-
* @param {Array} array The array to slice.
|
|
13
|
-
* @param {number} [start=0] The start position. A negative index will be treated as an offset from the end.
|
|
14
|
-
* @param {number} [end=array.length] The end position. A negative index will be treated as an offset from the end.
|
|
15
|
-
* @returns {Array} Returns the slice of `array`.
|
|
16
|
-
* @example
|
|
17
|
-
*
|
|
18
|
-
* var array = [1, 2, 3, 4]
|
|
19
|
-
*
|
|
20
|
-
* _.slice(array, 2)
|
|
21
|
-
* // => [3, 4]
|
|
22
|
-
*/
|
|
23
|
-
function slice(array, start, end) {
|
|
24
|
-
let length = array == null ? 0 : array.length;
|
|
25
|
-
if (!length) {
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
start = start == null ? 0 : start;
|
|
29
|
-
end = end === undefined ? length : end;
|
|
30
|
-
if (start < 0) {
|
|
31
|
-
start = -start > length ? 0 : (length + start);
|
|
32
|
-
}
|
|
33
|
-
end = end > length ? length : end;
|
|
34
|
-
if (end < 0) {
|
|
35
|
-
end += length;
|
|
36
|
-
}
|
|
37
|
-
length = start > end ? 0 : ((end - start) >>> 0);
|
|
38
|
-
start >>>= 0;
|
|
39
|
-
let index = -1;
|
|
40
|
-
const result = new Array(length);
|
|
41
|
-
while (++index < length) {
|
|
42
|
-
result[index] = array[index + start];
|
|
43
|
-
}
|
|
44
|
-
return result;
|
|
45
|
-
}
|
|
46
|
-
exports.default = slice;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const asciiToArray_1 = require("./asciiToArray");
|
|
4
|
-
const hasUnicode_1 = require("./hasUnicode");
|
|
5
|
-
const unicodeToArray_1 = require("./unicodeToArray");
|
|
6
|
-
/**
|
|
7
|
-
* Converts `string` to an array.
|
|
8
|
-
*
|
|
9
|
-
* @private
|
|
10
|
-
* @param {string} string The string to convert.
|
|
11
|
-
* @returns {Array} Returns the converted array.
|
|
12
|
-
*/
|
|
13
|
-
function stringToArray(string) {
|
|
14
|
-
return (0, hasUnicode_1.default)(string)
|
|
15
|
-
? (0, unicodeToArray_1.default)(string)
|
|
16
|
-
: (0, asciiToArray_1.default)(string);
|
|
17
|
-
}
|
|
18
|
-
exports.default = stringToArray;
|