@pisell/pisellos 2.0.67 → 2.1.1
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/core/index.js +1 -2
- package/dist/effects/index.d.ts +3 -4
- package/dist/effects/index.js +6 -15
- package/dist/modules/AccountList/index.d.ts +1 -7
- package/dist/modules/AccountList/index.js +14 -81
- package/dist/modules/AccountList/types.d.ts +0 -28
- package/dist/modules/AccountList/types.js +0 -8
- package/dist/modules/ProductList/index.d.ts +2 -12
- package/dist/modules/ProductList/index.js +8 -28
- package/dist/modules/Rules/index.js +14 -27
- package/dist/modules/Rules/types.d.ts +0 -1
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +0 -1
- package/dist/plugins/window.d.ts +0 -1
- package/dist/solution/BookingByStep/utils/resources.js +12 -4
- package/dist/solution/ShopDiscount/index.js +2 -4
- package/dist/solution/index.d.ts +0 -1
- package/dist/solution/index.js +0 -1
- package/dist/types/index.d.ts +1 -3
- package/lib/core/index.js +1 -1
- package/lib/effects/index.d.ts +3 -4
- package/lib/effects/index.js +1 -4
- package/lib/modules/AccountList/index.d.ts +1 -7
- package/lib/modules/AccountList/index.js +0 -27
- package/lib/modules/AccountList/types.d.ts +0 -28
- package/lib/modules/ProductList/index.d.ts +2 -12
- package/lib/modules/ProductList/index.js +6 -30
- package/lib/modules/Rules/index.js +12 -20
- package/lib/modules/Rules/types.d.ts +0 -1
- package/lib/modules/index.d.ts +0 -1
- package/lib/modules/index.js +0 -2
- package/lib/plugins/window.d.ts +0 -1
- package/lib/solution/BookingByStep/utils/resources.js +12 -4
- package/lib/solution/ShopDiscount/index.js +1 -2
- package/lib/solution/index.d.ts +0 -1
- package/lib/solution/index.js +0 -2
- package/lib/types/index.d.ts +1 -3
- package/package.json +1 -1
- package/dist/modules/Customer/constants.d.ts +0 -7
- package/dist/modules/Customer/constants.js +0 -12
- package/dist/modules/Customer/index.d.ts +0 -122
- package/dist/modules/Customer/index.js +0 -697
- package/dist/modules/Customer/types.d.ts +0 -146
- package/dist/modules/Customer/types.js +0 -41
- package/dist/solution/BookingTicket/index.d.ts +0 -172
- package/dist/solution/BookingTicket/index.js +0 -665
- package/dist/solution/BookingTicket/types.d.ts +0 -68
- package/dist/solution/BookingTicket/types.js +0 -43
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +0 -159
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -16
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +0 -174
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -81
- package/dist/solution/BookingTicket/utils/scan/index.js +0 -285
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
- package/dist/solution/BookingTicket/utils/scan/scanCache.js +0 -305
- package/dist/utils/task.d.ts +0 -40
- package/dist/utils/task.js +0 -171
- package/dist/utils/watch.d.ts +0 -102
- package/dist/utils/watch.js +0 -294
- package/lib/modules/Customer/constants.d.ts +0 -7
- package/lib/modules/Customer/constants.js +0 -39
- package/lib/modules/Customer/index.d.ts +0 -122
- package/lib/modules/Customer/index.js +0 -440
- package/lib/modules/Customer/types.d.ts +0 -146
- package/lib/modules/Customer/types.js +0 -37
- package/lib/solution/BookingTicket/index.d.ts +0 -172
- package/lib/solution/BookingTicket/index.js +0 -399
- package/lib/solution/BookingTicket/types.d.ts +0 -68
- package/lib/solution/BookingTicket/types.js +0 -72
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +0 -117
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -16
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +0 -125
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -81
- package/lib/solution/BookingTicket/utils/scan/index.js +0 -210
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +0 -231
- package/lib/utils/task.d.ts +0 -40
- package/lib/utils/task.js +0 -109
- package/lib/utils/watch.d.ts +0 -102
- package/lib/utils/watch.js +0 -217
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LRU缓存类,用于缓存接口数据
|
|
3
|
-
* 限制最多存储100条数据,超过时移除最久未使用的数据
|
|
4
|
-
* 支持数据压缩以减小缓存压力
|
|
5
|
-
* 尾部优先策略:新节点插入尾部,最近使用的节点移动到尾部,删除头部节点
|
|
6
|
-
*/
|
|
7
|
-
declare class LRUCache<T> {
|
|
8
|
-
private head;
|
|
9
|
-
private tail;
|
|
10
|
-
private keyMap;
|
|
11
|
-
private readonly maxSize;
|
|
12
|
-
constructor(maxSize?: number);
|
|
13
|
-
/**
|
|
14
|
-
* 将节点移动到链表尾部(最近使用)
|
|
15
|
-
* @param node 要移动的节点
|
|
16
|
-
*/
|
|
17
|
-
private moveToTail;
|
|
18
|
-
/**
|
|
19
|
-
* 添加新节点到链表尾部
|
|
20
|
-
* @param key 缓存键
|
|
21
|
-
* @param compressedData 压缩后的数据
|
|
22
|
-
* @param timestamp 时间戳
|
|
23
|
-
*/
|
|
24
|
-
private addToTail;
|
|
25
|
-
/**
|
|
26
|
-
* 从链表中移除节点
|
|
27
|
-
* @param node 要移除的节点
|
|
28
|
-
*/
|
|
29
|
-
private removeNode;
|
|
30
|
-
/**
|
|
31
|
-
* 移除最久未使用的节点(链表头部)
|
|
32
|
-
*/
|
|
33
|
-
private removeOldest;
|
|
34
|
-
/**
|
|
35
|
-
* 设置缓存
|
|
36
|
-
* @param key 缓存键
|
|
37
|
-
* @param data 缓存数据
|
|
38
|
-
*/
|
|
39
|
-
set(key: string, data: T): void;
|
|
40
|
-
/**
|
|
41
|
-
* 获取缓存
|
|
42
|
-
* @param key 缓存键
|
|
43
|
-
* @returns 缓存数据或undefined
|
|
44
|
-
*/
|
|
45
|
-
get(key: string): T | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* 检查是否存在缓存
|
|
48
|
-
* @param key 缓存键
|
|
49
|
-
* @returns 是否存在
|
|
50
|
-
*/
|
|
51
|
-
has(key: string): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* 清除所有缓存
|
|
54
|
-
*/
|
|
55
|
-
clear(): void;
|
|
56
|
-
/**
|
|
57
|
-
* 获取缓存大小
|
|
58
|
-
* @returns 当前缓存数量
|
|
59
|
-
*/
|
|
60
|
-
size(): number;
|
|
61
|
-
/**
|
|
62
|
-
* 获取缓存统计信息
|
|
63
|
-
* @returns 缓存统计信息
|
|
64
|
-
*/
|
|
65
|
-
getStats(): {
|
|
66
|
-
size: number;
|
|
67
|
-
maxSize: number;
|
|
68
|
-
usage: number;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* 删除指定的缓存项
|
|
72
|
-
* @param key 要删除的缓存键
|
|
73
|
-
* @returns 是否删除成功
|
|
74
|
-
*/
|
|
75
|
-
delete(key: string): boolean;
|
|
76
|
-
}
|
|
77
|
-
declare const scanCache: LRUCache<any>;
|
|
78
|
-
export default scanCache;
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/solution/BookingTicket/utils/scan/scanCache.ts
|
|
20
|
-
var scanCache_exports = {};
|
|
21
|
-
__export(scanCache_exports, {
|
|
22
|
-
default: () => scanCache_default
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(scanCache_exports);
|
|
25
|
-
var compressData = (data) => {
|
|
26
|
-
try {
|
|
27
|
-
if (data === void 0) {
|
|
28
|
-
return "undefined";
|
|
29
|
-
}
|
|
30
|
-
return JSON.stringify(data);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
console.warn("数据压缩失败:", error);
|
|
33
|
-
return JSON.stringify(data);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var decompressData = (compressedData) => {
|
|
37
|
-
try {
|
|
38
|
-
if (compressedData === "undefined") {
|
|
39
|
-
return void 0;
|
|
40
|
-
}
|
|
41
|
-
return JSON.parse(compressedData);
|
|
42
|
-
} catch (error) {
|
|
43
|
-
console.warn("数据解压缩失败:", error);
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
var LRUCache = class {
|
|
48
|
-
constructor(maxSize = 100) {
|
|
49
|
-
this.head = null;
|
|
50
|
-
// 最久未使用的节点
|
|
51
|
-
this.tail = null;
|
|
52
|
-
// 最近使用的节点
|
|
53
|
-
this.keyMap = /* @__PURE__ */ new Map();
|
|
54
|
-
this.maxSize = maxSize;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* 将节点移动到链表尾部(最近使用)
|
|
58
|
-
* @param node 要移动的节点
|
|
59
|
-
*/
|
|
60
|
-
moveToTail(node) {
|
|
61
|
-
if (this.tail === node)
|
|
62
|
-
return;
|
|
63
|
-
if (node.prev) {
|
|
64
|
-
node.prev.next = node.next;
|
|
65
|
-
}
|
|
66
|
-
if (node.next) {
|
|
67
|
-
node.next.prev = node.prev;
|
|
68
|
-
}
|
|
69
|
-
if (this.head === node) {
|
|
70
|
-
this.head = node.next;
|
|
71
|
-
}
|
|
72
|
-
if (this.tail) {
|
|
73
|
-
this.tail.next = node;
|
|
74
|
-
}
|
|
75
|
-
node.prev = this.tail;
|
|
76
|
-
node.next = null;
|
|
77
|
-
this.tail = node;
|
|
78
|
-
if (!this.head) {
|
|
79
|
-
this.head = node;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* 添加新节点到链表尾部
|
|
84
|
-
* @param key 缓存键
|
|
85
|
-
* @param compressedData 压缩后的数据
|
|
86
|
-
* @param timestamp 时间戳
|
|
87
|
-
*/
|
|
88
|
-
addToTail(key, compressedData, timestamp) {
|
|
89
|
-
const oldTail = this.tail;
|
|
90
|
-
const node = {
|
|
91
|
-
key,
|
|
92
|
-
compressedData,
|
|
93
|
-
timestamp,
|
|
94
|
-
prev: oldTail,
|
|
95
|
-
// 使用保存的引用,避免循环引用
|
|
96
|
-
next: null
|
|
97
|
-
};
|
|
98
|
-
this.keyMap.set(key, node);
|
|
99
|
-
if (oldTail) {
|
|
100
|
-
oldTail.next = node;
|
|
101
|
-
}
|
|
102
|
-
this.tail = node;
|
|
103
|
-
if (!this.head) {
|
|
104
|
-
this.head = node;
|
|
105
|
-
}
|
|
106
|
-
return node;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* 从链表中移除节点
|
|
110
|
-
* @param node 要移除的节点
|
|
111
|
-
*/
|
|
112
|
-
removeNode(node) {
|
|
113
|
-
if (node.prev) {
|
|
114
|
-
node.prev.next = node.next;
|
|
115
|
-
}
|
|
116
|
-
if (node.next) {
|
|
117
|
-
node.next.prev = node.prev;
|
|
118
|
-
}
|
|
119
|
-
if (this.head === node) {
|
|
120
|
-
this.head = node.next;
|
|
121
|
-
}
|
|
122
|
-
if (this.tail === node) {
|
|
123
|
-
this.tail = node.prev;
|
|
124
|
-
}
|
|
125
|
-
this.keyMap.delete(node.key);
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* 移除最久未使用的节点(链表头部)
|
|
129
|
-
*/
|
|
130
|
-
removeOldest() {
|
|
131
|
-
if (this.head) {
|
|
132
|
-
this.removeNode(this.head);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* 设置缓存
|
|
137
|
-
* @param key 缓存键
|
|
138
|
-
* @param data 缓存数据
|
|
139
|
-
*/
|
|
140
|
-
set(key, data) {
|
|
141
|
-
const compressedData = compressData(data);
|
|
142
|
-
const timestamp = Date.now();
|
|
143
|
-
const existingNode = this.keyMap.get(key);
|
|
144
|
-
if (existingNode) {
|
|
145
|
-
existingNode.compressedData = compressedData;
|
|
146
|
-
existingNode.timestamp = timestamp;
|
|
147
|
-
this.moveToTail(existingNode);
|
|
148
|
-
} else {
|
|
149
|
-
if (this.keyMap.size >= this.maxSize) {
|
|
150
|
-
this.removeOldest();
|
|
151
|
-
}
|
|
152
|
-
this.addToTail(key, compressedData, timestamp);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* 获取缓存
|
|
157
|
-
* @param key 缓存键
|
|
158
|
-
* @returns 缓存数据或undefined
|
|
159
|
-
*/
|
|
160
|
-
get(key) {
|
|
161
|
-
const node = this.keyMap.get(key);
|
|
162
|
-
if (node) {
|
|
163
|
-
const decompressedData = decompressData(node.compressedData);
|
|
164
|
-
if (decompressedData !== null) {
|
|
165
|
-
node.timestamp = Date.now();
|
|
166
|
-
this.moveToTail(node);
|
|
167
|
-
return decompressedData;
|
|
168
|
-
} else {
|
|
169
|
-
this.removeNode(node);
|
|
170
|
-
return void 0;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return void 0;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* 检查是否存在缓存
|
|
177
|
-
* @param key 缓存键
|
|
178
|
-
* @returns 是否存在
|
|
179
|
-
*/
|
|
180
|
-
has(key) {
|
|
181
|
-
return this.keyMap.has(key);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* 清除所有缓存
|
|
185
|
-
*/
|
|
186
|
-
clear() {
|
|
187
|
-
let current = this.head;
|
|
188
|
-
while (current) {
|
|
189
|
-
const next = current.next;
|
|
190
|
-
current.prev = null;
|
|
191
|
-
current.next = null;
|
|
192
|
-
current = next;
|
|
193
|
-
}
|
|
194
|
-
this.keyMap.clear();
|
|
195
|
-
this.head = null;
|
|
196
|
-
this.tail = null;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* 获取缓存大小
|
|
200
|
-
* @returns 当前缓存数量
|
|
201
|
-
*/
|
|
202
|
-
size() {
|
|
203
|
-
return this.keyMap.size;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* 获取缓存统计信息
|
|
207
|
-
* @returns 缓存统计信息
|
|
208
|
-
*/
|
|
209
|
-
getStats() {
|
|
210
|
-
return {
|
|
211
|
-
size: this.keyMap.size,
|
|
212
|
-
maxSize: this.maxSize,
|
|
213
|
-
usage: Math.round(this.keyMap.size / this.maxSize * 100)
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* 删除指定的缓存项
|
|
218
|
-
* @param key 要删除的缓存键
|
|
219
|
-
* @returns 是否删除成功
|
|
220
|
-
*/
|
|
221
|
-
delete(key) {
|
|
222
|
-
const node = this.keyMap.get(key);
|
|
223
|
-
if (node) {
|
|
224
|
-
this.removeNode(node);
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
var scanCache = new LRUCache();
|
|
231
|
-
var scanCache_default = scanCache;
|
package/lib/utils/task.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
type Action = (...args: any[]) => Promise<any>;
|
|
2
|
-
type Task = {
|
|
3
|
-
uuid: string;
|
|
4
|
-
type: string;
|
|
5
|
-
actionParams?: Record<string, any>;
|
|
6
|
-
};
|
|
7
|
-
declare class Tasks {
|
|
8
|
-
private actions;
|
|
9
|
-
private taskQueue;
|
|
10
|
-
isRunning: boolean;
|
|
11
|
-
constructor(actions?: Map<string, Action>);
|
|
12
|
-
/**
|
|
13
|
-
* 清空所有任务
|
|
14
|
-
*/
|
|
15
|
-
clear(): void;
|
|
16
|
-
/**
|
|
17
|
-
* 清空任务执行队列
|
|
18
|
-
*/
|
|
19
|
-
clearTaskQueue(): void;
|
|
20
|
-
/**
|
|
21
|
-
* 添加action
|
|
22
|
-
* @param name action名称
|
|
23
|
-
* @param action action函数
|
|
24
|
-
*/
|
|
25
|
-
addAction(name: string, action: Action): void;
|
|
26
|
-
/**
|
|
27
|
-
* 添加任务
|
|
28
|
-
* @param task 任务
|
|
29
|
-
*/
|
|
30
|
-
addTask(task: Task): void;
|
|
31
|
-
/**
|
|
32
|
-
* 执行任务
|
|
33
|
-
*/
|
|
34
|
-
run(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* 判定当前的任务是否依然存在
|
|
37
|
-
*/
|
|
38
|
-
isTaskExist(uuid: string): boolean;
|
|
39
|
-
}
|
|
40
|
-
export default Tasks;
|
package/lib/utils/task.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/utils/task.ts
|
|
20
|
-
var task_exports = {};
|
|
21
|
-
__export(task_exports, {
|
|
22
|
-
default: () => task_default
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(task_exports);
|
|
25
|
-
var Tasks = class {
|
|
26
|
-
constructor(actions) {
|
|
27
|
-
this.actions = /* @__PURE__ */ new Map();
|
|
28
|
-
this.taskQueue = [];
|
|
29
|
-
this.isRunning = false;
|
|
30
|
-
if (actions) {
|
|
31
|
-
this.actions = actions;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* 清空所有任务
|
|
36
|
-
*/
|
|
37
|
-
clear() {
|
|
38
|
-
this.actions.clear();
|
|
39
|
-
this.taskQueue = [];
|
|
40
|
-
this.isRunning = false;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 清空任务执行队列
|
|
44
|
-
*/
|
|
45
|
-
clearTaskQueue() {
|
|
46
|
-
this.taskQueue = [];
|
|
47
|
-
this.isRunning = false;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* 添加action
|
|
51
|
-
* @param name action名称
|
|
52
|
-
* @param action action函数
|
|
53
|
-
*/
|
|
54
|
-
addAction(name, action) {
|
|
55
|
-
this.actions.set(name, action);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* 添加任务
|
|
59
|
-
* @param task 任务
|
|
60
|
-
*/
|
|
61
|
-
addTask(task) {
|
|
62
|
-
this.taskQueue.push(task);
|
|
63
|
-
this.run();
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* 执行任务
|
|
67
|
-
*/
|
|
68
|
-
async run() {
|
|
69
|
-
var _a;
|
|
70
|
-
if (this.isRunning) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (this.taskQueue.length === 0) {
|
|
74
|
-
this.isRunning = false;
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
this.isRunning = true;
|
|
78
|
-
while (this.taskQueue.length > 0) {
|
|
79
|
-
const task = (_a = this.taskQueue) == null ? void 0 : _a[0];
|
|
80
|
-
if (!task) {
|
|
81
|
-
this.isRunning = false;
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const action = this.actions.get(task.type);
|
|
85
|
-
if (action) {
|
|
86
|
-
try {
|
|
87
|
-
await action({ ...(task == null ? void 0 : task.actionParams) || {}, uuid: task == null ? void 0 : task.uuid });
|
|
88
|
-
console.log("task_success>>>>>>>", task);
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.error("task_error>>>>>>>", error);
|
|
91
|
-
} finally {
|
|
92
|
-
const _task = this.taskQueue.shift();
|
|
93
|
-
console.log("task_shift>>>>>>>", _task);
|
|
94
|
-
}
|
|
95
|
-
} else {
|
|
96
|
-
const _task = this.taskQueue.shift();
|
|
97
|
-
console.log("task_action_not_found>>>>>>>", _task);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
this.isRunning = false;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* 判定当前的任务是否依然存在
|
|
104
|
-
*/
|
|
105
|
-
isTaskExist(uuid) {
|
|
106
|
-
return this.taskQueue.some((task) => (task == null ? void 0 : task.uuid) === uuid);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
var task_default = Tasks;
|
package/lib/utils/watch.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 监听模块
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
export type WatchEventCallback = (...args: any[]) => void;
|
|
6
|
-
export type WatchEventItem = {
|
|
7
|
-
key: string;
|
|
8
|
-
callback: WatchEventCallback;
|
|
9
|
-
};
|
|
10
|
-
export interface WatchEventSubscription {
|
|
11
|
-
unsubscribe: () => void;
|
|
12
|
-
}
|
|
13
|
-
declare class Watch {
|
|
14
|
-
private events;
|
|
15
|
-
private enableListMap;
|
|
16
|
-
/**
|
|
17
|
-
* 订阅事件
|
|
18
|
-
* @param event 事件名称
|
|
19
|
-
* @param callback 回调函数
|
|
20
|
-
* @returns 订阅对象,可用于取消订阅
|
|
21
|
-
*/
|
|
22
|
-
subscribe(watchKey: string, event: WatchEventItem): WatchEventSubscription;
|
|
23
|
-
/**
|
|
24
|
-
* 启用事件
|
|
25
|
-
* @param watchKey 监听的key
|
|
26
|
-
* @param event 事件名称
|
|
27
|
-
*/
|
|
28
|
-
enableEvent(watchKey: string, eventKey: string): void;
|
|
29
|
-
/**
|
|
30
|
-
* 禁用某个事件
|
|
31
|
-
* @param watchKey 监听的key
|
|
32
|
-
* @param eventKey 事件名称
|
|
33
|
-
*/
|
|
34
|
-
disableEvent(watchKey: string, eventKey: string): void;
|
|
35
|
-
/**
|
|
36
|
-
* 冻结某个监听下的所有事件
|
|
37
|
-
* @param watchKey 监听的key
|
|
38
|
-
*/
|
|
39
|
-
disabledAllEventByWatchKey(watchKey: string): void;
|
|
40
|
-
/**
|
|
41
|
-
* 启用某个监听下的所有事件
|
|
42
|
-
* @param watchKey 监听的key
|
|
43
|
-
*/
|
|
44
|
-
enableAllEventByWatchKey(watchKey: string): void;
|
|
45
|
-
/**
|
|
46
|
-
* 取消订阅事件
|
|
47
|
-
* @param event 事件名称
|
|
48
|
-
* @param callback 回调函数
|
|
49
|
-
* @returns 是否成功取消订阅
|
|
50
|
-
*/
|
|
51
|
-
unsubscribe(watchKey: string, event: WatchEventItem): void;
|
|
52
|
-
/**
|
|
53
|
-
* 发布事件
|
|
54
|
-
* @param event 事件名称
|
|
55
|
-
* @param args 事件参数
|
|
56
|
-
*/
|
|
57
|
-
publish(watchKey: string, ...args: any[]): void;
|
|
58
|
-
/**
|
|
59
|
-
* 根据事件名称发布事件
|
|
60
|
-
* @param watchKey 监听的key
|
|
61
|
-
* @param eventKey 事件名称
|
|
62
|
-
* @param args 事件参数
|
|
63
|
-
*/
|
|
64
|
-
publishByEventKey(watchKey: string, eventKey: string, ...args: any[]): void;
|
|
65
|
-
/**
|
|
66
|
-
* 获取最后一个启用的事件
|
|
67
|
-
* @param watchKey 监听的key
|
|
68
|
-
* @returns 最后一个启用的事件
|
|
69
|
-
*/
|
|
70
|
-
getLastEnableEventKey(watchKey: string): WatchEventItem['key'] | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* 移除某个事件的所有订阅
|
|
73
|
-
* @param event 事件名称
|
|
74
|
-
* @returns 是否成功移除
|
|
75
|
-
*/
|
|
76
|
-
clearEvent(watchKey: string): void;
|
|
77
|
-
/**
|
|
78
|
-
* 移除所有事件订阅
|
|
79
|
-
*/
|
|
80
|
-
clearAllEvents(): void;
|
|
81
|
-
/**
|
|
82
|
-
* 获取事件的订阅数量
|
|
83
|
-
* @param event 事件名称
|
|
84
|
-
* @returns 订阅数量
|
|
85
|
-
*/
|
|
86
|
-
getSubscriberCount(event: string): number;
|
|
87
|
-
/**
|
|
88
|
-
* 检查事件是否有订阅者
|
|
89
|
-
* @param event 事件名称
|
|
90
|
-
* @returns 是否有订阅者
|
|
91
|
-
*/
|
|
92
|
-
hasSubscribers(event: string): boolean;
|
|
93
|
-
/**
|
|
94
|
-
* 一次性订阅事件,事件触发后自动取消订阅
|
|
95
|
-
* @param event 事件名称
|
|
96
|
-
* @param callback 回调函数
|
|
97
|
-
* @returns 订阅对象,可用于取消订阅
|
|
98
|
-
*/
|
|
99
|
-
once(watchKey: string, event: WatchEventItem): WatchEventSubscription;
|
|
100
|
-
}
|
|
101
|
-
declare const watch: Watch;
|
|
102
|
-
export default watch;
|