@pisell/core 0.0.2
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 +1 -0
- package/es/app/app.d.ts +101 -0
- package/es/app/app.js +177 -0
- package/es/app/const.d.ts +4 -0
- package/es/app/const.js +6 -0
- package/es/app/index.d.ts +14 -0
- package/es/app/index.js +52 -0
- package/es/applicationManager/application.d.ts +197 -0
- package/es/applicationManager/application.js +469 -0
- package/es/applicationManager/index.d.ts +19 -0
- package/es/applicationManager/index.js +206 -0
- package/es/aws/index.d.ts +16 -0
- package/es/aws/index.js +76 -0
- package/es/cmd/const.d.ts +11 -0
- package/es/cmd/const.js +13 -0
- package/es/cmd/index.d.ts +13 -0
- package/es/cmd/index.js +91 -0
- package/es/cmd/type.d.ts +5 -0
- package/es/cmd/type.js +1 -0
- package/es/communicationManager/index.d.ts +59 -0
- package/es/communicationManager/index.js +174 -0
- package/es/config.d.ts +3 -0
- package/es/config.js +14 -0
- package/es/cookie/index.d.ts +13 -0
- package/es/cookie/index.js +47 -0
- package/es/css/global.less +73 -0
- package/es/css/index.less +31 -0
- package/es/css/variables.css +84 -0
- package/es/data/index.d.ts +8 -0
- package/es/data/index.js +16 -0
- package/es/history/config.d.ts +24 -0
- package/es/history/config.js +43 -0
- package/es/history/index.d.ts +26 -0
- package/es/history/index.js +80 -0
- package/es/history/type.d.ts +2 -0
- package/es/history/type.js +1 -0
- package/es/hooks/index.d.ts +12 -0
- package/es/hooks/index.js +13 -0
- package/es/hooks/useDelayedValue/index.d.ts +2 -0
- package/es/hooks/useDelayedValue/index.js +26 -0
- package/es/hooks/useDispatch/index.d.ts +2 -0
- package/es/hooks/useDispatch/index.js +2 -0
- package/es/hooks/useLowCode/index.d.ts +13 -0
- package/es/hooks/useLowCode/index.js +74 -0
- package/es/hooks/useStore/index.d.ts +6 -0
- package/es/hooks/useStore/index.js +11 -0
- package/es/index.d.ts +8 -0
- package/es/index.js +10 -0
- package/es/indexDB/index.d.ts +296 -0
- package/es/indexDB/index.js +1619 -0
- package/es/locales/en.d.ts +3 -0
- package/es/locales/en.js +5 -0
- package/es/locales/index.d.ts +39 -0
- package/es/locales/index.js +199 -0
- package/es/locales/original.d.ts +3 -0
- package/es/locales/original.js +7 -0
- package/es/locales/type.d.ts +19 -0
- package/es/locales/type.js +1 -0
- package/es/locales/zh-CN.d.ts +3 -0
- package/es/locales/zh-CN.js +5 -0
- package/es/locales/zh-HK.d.ts +3 -0
- package/es/locales/zh-HK.js +5 -0
- package/es/logger/feishu.d.ts +11 -0
- package/es/logger/feishu.js +50 -0
- package/es/logger/index.d.ts +135 -0
- package/es/logger/index.js +870 -0
- package/es/menuManager/hooks.d.ts +17 -0
- package/es/menuManager/hooks.js +136 -0
- package/es/menuManager/index.d.ts +28 -0
- package/es/menuManager/index.js +165 -0
- package/es/models/global.d.ts +32 -0
- package/es/models/global.js +66 -0
- package/es/models/index.d.ts +45 -0
- package/es/models/index.js +65 -0
- package/es/models/type.d.ts +2 -0
- package/es/models/type.js +1 -0
- package/es/plugin/index.d.ts +0 -0
- package/es/plugin/index.js +0 -0
- package/es/pubsub/example.d.ts +5 -0
- package/es/pubsub/example.js +92 -0
- package/es/pubsub/index.d.ts +73 -0
- package/es/pubsub/index.js +166 -0
- package/es/render/index.d.ts +0 -0
- package/es/render/index.js +0 -0
- package/es/request/cache.d.ts +46 -0
- package/es/request/cache.js +372 -0
- package/es/request/cancelToken.d.ts +38 -0
- package/es/request/cancelToken.js +59 -0
- package/es/request/config.d.ts +3 -0
- package/es/request/config.js +63 -0
- package/es/request/constants.d.ts +2 -0
- package/es/request/constants.js +6 -0
- package/es/request/index.d.ts +24 -0
- package/es/request/index.js +267 -0
- package/es/request/pisell2Request.d.ts +6 -0
- package/es/request/pisell2Request.js +62 -0
- package/es/request/type.d.ts +57 -0
- package/es/request/type.js +10 -0
- package/es/request/utils.d.ts +46 -0
- package/es/request/utils.js +147 -0
- package/es/routes/config.d.ts +7 -0
- package/es/routes/config.js +17 -0
- package/es/routes/index.d.ts +28 -0
- package/es/routes/index.js +151 -0
- package/es/socket/components/SocketMonitorPage.d.ts +6 -0
- package/es/socket/components/SocketMonitorPage.js +485 -0
- package/es/socket/components/index.d.ts +2 -0
- package/es/socket/components/index.js +2 -0
- package/es/socket/constants.d.ts +33 -0
- package/es/socket/constants.js +39 -0
- package/es/socket/events.d.ts +31 -0
- package/es/socket/events.js +19 -0
- package/es/socket/heartbeat.d.ts +66 -0
- package/es/socket/heartbeat.js +184 -0
- package/es/socket/index.d.ts +61 -0
- package/es/socket/index.js +246 -0
- package/es/socket/monitor.d.ts +169 -0
- package/es/socket/monitor.js +448 -0
- package/es/socket/reconnect.d.ts +61 -0
- package/es/socket/reconnect.js +199 -0
- package/es/socket/socket.d.ts +130 -0
- package/es/socket/socket.js +613 -0
- package/es/socket/types.d.ts +85 -0
- package/es/socket/types.js +35 -0
- package/es/storage/index.d.ts +17 -0
- package/es/storage/index.js +46 -0
- package/es/tasks/index.d.ts +127 -0
- package/es/tasks/index.js +1119 -0
- package/es/tasks/scheduledTasksExample.d.ts +61 -0
- package/es/tasks/scheduledTasksExample.js +351 -0
- package/es/tasks/type.d.ts +100 -0
- package/es/tasks/type.js +1 -0
- package/es/tasks/useTasks.d.ts +5 -0
- package/es/tasks/useTasks.js +25 -0
- package/es/type.d.ts +2 -0
- package/es/type.js +1 -0
- package/es/utils/adaptiveThrottle/index.d.ts +36 -0
- package/es/utils/adaptiveThrottle/index.js +136 -0
- package/es/variables/VariablesProvider.d.ts +7 -0
- package/es/variables/VariablesProvider.js +12 -0
- package/es/variables/config.d.ts +3 -0
- package/es/variables/config.js +16 -0
- package/es/variables/index.d.ts +6 -0
- package/es/variables/index.js +5 -0
- package/es/variables/type.d.ts +2 -0
- package/es/variables/type.js +1 -0
- package/es/website/index.d.ts +6 -0
- package/es/website/index.js +65 -0
- package/lib/app/app.d.ts +101 -0
- package/lib/app/app.js +171 -0
- package/lib/app/const.d.ts +4 -0
- package/lib/app/const.js +33 -0
- package/lib/app/index.d.ts +14 -0
- package/lib/app/index.js +76 -0
- package/lib/applicationManager/application.d.ts +197 -0
- package/lib/applicationManager/application.js +280 -0
- package/lib/applicationManager/index.d.ts +19 -0
- package/lib/applicationManager/index.js +88 -0
- package/lib/aws/index.d.ts +16 -0
- package/lib/aws/index.js +67 -0
- package/lib/cmd/const.d.ts +11 -0
- package/lib/cmd/const.js +39 -0
- package/lib/cmd/index.d.ts +13 -0
- package/lib/cmd/index.js +96 -0
- package/lib/cmd/type.d.ts +5 -0
- package/lib/cmd/type.js +17 -0
- package/lib/communicationManager/index.d.ts +59 -0
- package/lib/communicationManager/index.js +102 -0
- package/lib/config.d.ts +3 -0
- package/lib/config.js +36 -0
- package/lib/cookie/index.d.ts +13 -0
- package/lib/cookie/index.js +62 -0
- package/lib/css/global.less +73 -0
- package/lib/css/index.less +31 -0
- package/lib/css/variables.css +84 -0
- package/lib/data/index.d.ts +8 -0
- package/lib/data/index.js +38 -0
- package/lib/history/config.d.ts +24 -0
- package/lib/history/config.js +41 -0
- package/lib/history/index.d.ts +26 -0
- package/lib/history/index.js +99 -0
- package/lib/history/type.d.ts +2 -0
- package/lib/history/type.js +17 -0
- package/lib/hooks/index.d.ts +12 -0
- package/lib/hooks/index.js +44 -0
- package/lib/hooks/useDelayedValue/index.d.ts +2 -0
- package/lib/hooks/useDelayedValue/index.js +36 -0
- package/lib/hooks/useDispatch/index.d.ts +2 -0
- package/lib/hooks/useDispatch/index.js +26 -0
- package/lib/hooks/useLowCode/index.d.ts +13 -0
- package/lib/hooks/useLowCode/index.js +75 -0
- package/lib/hooks/useStore/index.d.ts +6 -0
- package/lib/hooks/useStore/index.js +33 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +58 -0
- package/lib/indexDB/index.d.ts +296 -0
- package/lib/indexDB/index.js +767 -0
- package/lib/locales/en.d.ts +3 -0
- package/lib/locales/en.js +29 -0
- package/lib/locales/index.d.ts +39 -0
- package/lib/locales/index.js +159 -0
- package/lib/locales/original.d.ts +3 -0
- package/lib/locales/original.js +31 -0
- package/lib/locales/type.d.ts +19 -0
- package/lib/locales/type.js +17 -0
- package/lib/locales/zh-CN.d.ts +3 -0
- package/lib/locales/zh-CN.js +29 -0
- package/lib/locales/zh-HK.d.ts +3 -0
- package/lib/locales/zh-HK.js +29 -0
- package/lib/logger/feishu.d.ts +11 -0
- package/lib/logger/feishu.js +52 -0
- package/lib/logger/index.d.ts +135 -0
- package/lib/logger/index.js +476 -0
- package/lib/menuManager/hooks.d.ts +17 -0
- package/lib/menuManager/hooks.js +135 -0
- package/lib/menuManager/index.d.ts +28 -0
- package/lib/menuManager/index.js +125 -0
- package/lib/models/global.d.ts +32 -0
- package/lib/models/global.js +62 -0
- package/lib/models/index.d.ts +45 -0
- package/lib/models/index.js +69 -0
- package/lib/models/type.d.ts +2 -0
- package/lib/models/type.js +17 -0
- package/lib/plugin/index.d.ts +0 -0
- package/lib/plugin/index.js +0 -0
- package/lib/pubsub/example.d.ts +5 -0
- package/lib/pubsub/example.js +61 -0
- package/lib/pubsub/index.d.ts +73 -0
- package/lib/pubsub/index.js +141 -0
- package/lib/render/index.d.ts +0 -0
- package/lib/render/index.js +0 -0
- package/lib/request/cache.d.ts +46 -0
- package/lib/request/cache.js +195 -0
- package/lib/request/cancelToken.d.ts +38 -0
- package/lib/request/cancelToken.js +59 -0
- package/lib/request/config.d.ts +3 -0
- package/lib/request/config.js +69 -0
- package/lib/request/constants.d.ts +2 -0
- package/lib/request/constants.js +34 -0
- package/lib/request/index.d.ts +24 -0
- package/lib/request/index.js +210 -0
- package/lib/request/pisell2Request.d.ts +6 -0
- package/lib/request/pisell2Request.js +75 -0
- package/lib/request/type.d.ts +57 -0
- package/lib/request/type.js +36 -0
- package/lib/request/utils.d.ts +46 -0
- package/lib/request/utils.js +113 -0
- package/lib/routes/config.d.ts +7 -0
- package/lib/routes/config.js +50 -0
- package/lib/routes/index.d.ts +28 -0
- package/lib/routes/index.js +121 -0
- package/lib/socket/components/SocketMonitorPage.d.ts +6 -0
- package/lib/socket/components/SocketMonitorPage.js +340 -0
- package/lib/socket/components/index.d.ts +2 -0
- package/lib/socket/components/index.js +39 -0
- package/lib/socket/constants.d.ts +33 -0
- package/lib/socket/constants.js +62 -0
- package/lib/socket/events.d.ts +31 -0
- package/lib/socket/events.js +44 -0
- package/lib/socket/heartbeat.d.ts +66 -0
- package/lib/socket/heartbeat.js +157 -0
- package/lib/socket/index.d.ts +61 -0
- package/lib/socket/index.js +198 -0
- package/lib/socket/monitor.d.ts +169 -0
- package/lib/socket/monitor.js +350 -0
- package/lib/socket/reconnect.d.ts +61 -0
- package/lib/socket/reconnect.js +157 -0
- package/lib/socket/socket.d.ts +130 -0
- package/lib/socket/socket.js +426 -0
- package/lib/socket/types.d.ts +85 -0
- package/lib/socket/types.js +36 -0
- package/lib/storage/index.d.ts +17 -0
- package/lib/storage/index.js +64 -0
- package/lib/tasks/index.d.ts +127 -0
- package/lib/tasks/index.js +710 -0
- package/lib/tasks/scheduledTasksExample.d.ts +61 -0
- package/lib/tasks/scheduledTasksExample.js +267 -0
- package/lib/tasks/type.d.ts +100 -0
- package/lib/tasks/type.js +17 -0
- package/lib/tasks/useTasks.d.ts +5 -0
- package/lib/tasks/useTasks.js +37 -0
- package/lib/type.d.ts +2 -0
- package/lib/type.js +17 -0
- package/lib/utils/adaptiveThrottle/index.d.ts +36 -0
- package/lib/utils/adaptiveThrottle/index.js +121 -0
- package/lib/variables/VariablesProvider.d.ts +7 -0
- package/lib/variables/VariablesProvider.js +51 -0
- package/lib/variables/config.d.ts +3 -0
- package/lib/variables/config.js +38 -0
- package/lib/variables/index.d.ts +6 -0
- package/lib/variables/index.js +29 -0
- package/lib/variables/type.d.ts +2 -0
- package/lib/variables/type.js +17 -0
- package/lib/website/index.d.ts +6 -0
- package/lib/website/index.js +75 -0
- package/package.json +49 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Socket配置选项
|
|
3
|
+
*/
|
|
4
|
+
export interface SocketOptions {
|
|
5
|
+
/** 是否自动连接 */
|
|
6
|
+
autoConnect?: boolean;
|
|
7
|
+
/** 是否启用重连功能 */
|
|
8
|
+
reconnection?: boolean;
|
|
9
|
+
/** 最大重连尝试次数,默认无限 */
|
|
10
|
+
reconnectionAttempts?: number;
|
|
11
|
+
/** 重连延迟时间(毫秒) */
|
|
12
|
+
reconnectionDelay?: number;
|
|
13
|
+
/** 最大重连延迟时间(毫秒) */
|
|
14
|
+
reconnectionDelayMax?: number;
|
|
15
|
+
/** 是否启用心跳检测 */
|
|
16
|
+
heartbeat?: boolean;
|
|
17
|
+
/** 心跳间隔时间(毫秒) */
|
|
18
|
+
heartbeatInterval?: number;
|
|
19
|
+
/** 请求超时时间(毫秒) */
|
|
20
|
+
timeout?: number;
|
|
21
|
+
/** 心跳超时时间(毫秒) */
|
|
22
|
+
heartbeatTimeout?: number;
|
|
23
|
+
/** 自定义协议 */
|
|
24
|
+
protocols?: string | string[];
|
|
25
|
+
/** 连接URL */
|
|
26
|
+
url: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Socket连接状态
|
|
30
|
+
*/
|
|
31
|
+
export declare enum SocketStatus {
|
|
32
|
+
CONNECTING = 0,
|
|
33
|
+
OPEN = 1,
|
|
34
|
+
CLOSING = 2,
|
|
35
|
+
CLOSED = 3,
|
|
36
|
+
RECONNECTING = 4
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Socket消息格式
|
|
40
|
+
*/
|
|
41
|
+
export interface SocketMessage {
|
|
42
|
+
/** 事件类型 */
|
|
43
|
+
type: string;
|
|
44
|
+
/** 消息数据 */
|
|
45
|
+
data?: any;
|
|
46
|
+
/** 消息ID */
|
|
47
|
+
id?: string;
|
|
48
|
+
event?: any;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 心跳配置选项
|
|
52
|
+
*/
|
|
53
|
+
export interface HeartbeatOptions {
|
|
54
|
+
/** 心跳间隔时间(毫秒) */
|
|
55
|
+
interval: number;
|
|
56
|
+
/** 心跳超时时间(毫秒) */
|
|
57
|
+
timeout: number;
|
|
58
|
+
/** 心跳探测消息 */
|
|
59
|
+
message?: SocketMessage;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 重连配置选项
|
|
63
|
+
*/
|
|
64
|
+
export interface ReconnectOptions {
|
|
65
|
+
/** 是否启用重连 */
|
|
66
|
+
enabled: boolean;
|
|
67
|
+
/** 最大重连尝试次数 */
|
|
68
|
+
attempts?: number;
|
|
69
|
+
/** 重连延迟时间(毫秒) */
|
|
70
|
+
delay: number;
|
|
71
|
+
/** 最大重连延迟时间(毫秒) */
|
|
72
|
+
delayMax?: number;
|
|
73
|
+
/** 是否使用指数退避算法 */
|
|
74
|
+
jitter?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 事件处理函数类型
|
|
78
|
+
*/
|
|
79
|
+
export declare type EventHandler = (...args: any[]) => void;
|
|
80
|
+
/**
|
|
81
|
+
* 事件处理函数映射
|
|
82
|
+
*/
|
|
83
|
+
export interface EventHandlerMap {
|
|
84
|
+
[event: string]: EventHandler[];
|
|
85
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Socket配置选项
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Socket连接状态
|
|
7
|
+
*/
|
|
8
|
+
export var SocketStatus = /*#__PURE__*/function (SocketStatus) {
|
|
9
|
+
SocketStatus[SocketStatus["CONNECTING"] = 0] = "CONNECTING";
|
|
10
|
+
SocketStatus[SocketStatus["OPEN"] = 1] = "OPEN";
|
|
11
|
+
SocketStatus[SocketStatus["CLOSING"] = 2] = "CLOSING";
|
|
12
|
+
SocketStatus[SocketStatus["CLOSED"] = 3] = "CLOSED";
|
|
13
|
+
SocketStatus[SocketStatus["RECONNECTING"] = 4] = "RECONNECTING";
|
|
14
|
+
return SocketStatus;
|
|
15
|
+
}({});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Socket消息格式
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 心跳配置选项
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 重连配置选项
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 事件处理函数类型
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 事件处理函数映射
|
|
35
|
+
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import App from '../app';
|
|
2
|
+
export interface StorageOptions {
|
|
3
|
+
storageKey?: string;
|
|
4
|
+
removeStorageAfter?: (key: string) => void;
|
|
5
|
+
setStorageAfter?: (key: string, value: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare class Storage {
|
|
8
|
+
private storageKey;
|
|
9
|
+
private app?;
|
|
10
|
+
private options;
|
|
11
|
+
constructor(app?: App, options?: StorageOptions);
|
|
12
|
+
createKey: (key: string) => string;
|
|
13
|
+
setStorage: (key: string, value: string) => void;
|
|
14
|
+
getStorage: (key: string) => string | null;
|
|
15
|
+
removeStorage: (key: string) => void;
|
|
16
|
+
clear: () => void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
3
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
// 优先级
|
|
9
|
+
// 失效期
|
|
10
|
+
// 主动清理
|
|
11
|
+
export var Storage = /*#__PURE__*/_createClass(function Storage(app, options) {
|
|
12
|
+
var _this = this;
|
|
13
|
+
_classCallCheck(this, Storage);
|
|
14
|
+
_defineProperty(this, "storageKey", 'CapacitorStorage.native_');
|
|
15
|
+
_defineProperty(this, "app", void 0);
|
|
16
|
+
_defineProperty(this, "options", {});
|
|
17
|
+
_defineProperty(this, "createKey", function (key) {
|
|
18
|
+
if (key.indexOf(_this.storageKey) !== -1) {
|
|
19
|
+
return key;
|
|
20
|
+
}
|
|
21
|
+
return _this.storageKey + key;
|
|
22
|
+
});
|
|
23
|
+
_defineProperty(this, "setStorage", function (key, value) {
|
|
24
|
+
var _this$options, _this$options$setStor;
|
|
25
|
+
localStorage.setItem(_this.createKey(key), value);
|
|
26
|
+
(_this$options = _this.options) === null || _this$options === void 0 || (_this$options$setStor = _this$options.setStorageAfter) === null || _this$options$setStor === void 0 || _this$options$setStor.call(_this$options, key, value);
|
|
27
|
+
});
|
|
28
|
+
_defineProperty(this, "getStorage", function (key) {
|
|
29
|
+
return localStorage.getItem(_this.createKey(key));
|
|
30
|
+
});
|
|
31
|
+
_defineProperty(this, "removeStorage", function (key) {
|
|
32
|
+
var _this$options2, _this$options2$remove;
|
|
33
|
+
localStorage.removeItem(_this.createKey(key));
|
|
34
|
+
(_this$options2 = _this.options) === null || _this$options2 === void 0 || (_this$options2$remove = _this$options2.removeStorageAfter) === null || _this$options2$remove === void 0 || _this$options2$remove.call(_this$options2, key);
|
|
35
|
+
});
|
|
36
|
+
_defineProperty(this, "clear", function () {
|
|
37
|
+
localStorage.clear();
|
|
38
|
+
});
|
|
39
|
+
this.app = app;
|
|
40
|
+
if (options) {
|
|
41
|
+
this.options = options;
|
|
42
|
+
}
|
|
43
|
+
if (options !== null && options !== void 0 && options.storageKey) {
|
|
44
|
+
this.storageKey = options.storageKey;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Task, TasksModule, RunTaskParams, AddTaskParams, DeleteTaskParams } from "./type";
|
|
2
|
+
import App from "../app";
|
|
3
|
+
export declare class TasksManager {
|
|
4
|
+
private static instance;
|
|
5
|
+
private taskFunctions;
|
|
6
|
+
private tasks;
|
|
7
|
+
private app;
|
|
8
|
+
private db;
|
|
9
|
+
useTasks: () => {
|
|
10
|
+
tasks: TasksModule;
|
|
11
|
+
};
|
|
12
|
+
watchTaskCallback: (taskModule: TasksModule) => void;
|
|
13
|
+
private timerIds;
|
|
14
|
+
constructor(app: App);
|
|
15
|
+
static getInstance(app?: App): TasksManager;
|
|
16
|
+
addTaskFunction<T>(name: string, fun: T): void;
|
|
17
|
+
addTaskFunctions<T>(tasks: {
|
|
18
|
+
name: string;
|
|
19
|
+
fun: T;
|
|
20
|
+
}[]): void;
|
|
21
|
+
getTasks(): TasksModule;
|
|
22
|
+
getTaskFunction(name: string): any;
|
|
23
|
+
init(): Promise<void>;
|
|
24
|
+
private saveTaskQueueToLocal;
|
|
25
|
+
private loadTaskQueueFromLocal;
|
|
26
|
+
/**
|
|
27
|
+
* @title: 执行任务
|
|
28
|
+
* @description:
|
|
29
|
+
* @param {Task} task
|
|
30
|
+
* @return {*}
|
|
31
|
+
* @Author: zhiwei.Wang
|
|
32
|
+
* @Date: 2024-09-26 13:53
|
|
33
|
+
*/
|
|
34
|
+
private runTask;
|
|
35
|
+
/**
|
|
36
|
+
* @title: 清除任务定时器
|
|
37
|
+
*/
|
|
38
|
+
private clearTaskTimer;
|
|
39
|
+
/**
|
|
40
|
+
* @title: 计算下一次执行时间
|
|
41
|
+
* @description: 根据定时任务配置计算下一次执行时间
|
|
42
|
+
* @param {Task} task
|
|
43
|
+
* @return {string | null} 下一次执行时间
|
|
44
|
+
*/
|
|
45
|
+
private calculateNextExecuteTime;
|
|
46
|
+
/**
|
|
47
|
+
* @title: 启动定时任务
|
|
48
|
+
* @description: 在特定时间点执行任务(仅在 scheduledTasks 模块中生效)
|
|
49
|
+
* @param {Task} task
|
|
50
|
+
* @return {*}
|
|
51
|
+
*/
|
|
52
|
+
private startScheduledTask;
|
|
53
|
+
/**
|
|
54
|
+
* @title: 启动轮询
|
|
55
|
+
* @description: 根据轮询间隔定期执行任务
|
|
56
|
+
* @param {Task} task
|
|
57
|
+
* @return {*}
|
|
58
|
+
*/
|
|
59
|
+
private startPolling;
|
|
60
|
+
/**
|
|
61
|
+
* @title: 创建任务数据
|
|
62
|
+
* @description:
|
|
63
|
+
* @param {Partial} payload
|
|
64
|
+
* @return {*}
|
|
65
|
+
* @Author: zhiwei.Wang
|
|
66
|
+
* @Date: 2024-09-26 13:54
|
|
67
|
+
*/
|
|
68
|
+
private createTaskData;
|
|
69
|
+
private getTaskQueue;
|
|
70
|
+
private timeout;
|
|
71
|
+
/**
|
|
72
|
+
* @title: 执行任务队列
|
|
73
|
+
* @description:
|
|
74
|
+
* @return {*}
|
|
75
|
+
* @Author: zhiwei.Wang
|
|
76
|
+
* @Date: 2024-09-26 13:52
|
|
77
|
+
*/
|
|
78
|
+
run(payload: RunTaskParams): Promise<void>;
|
|
79
|
+
deleteTask(payload: DeleteTaskParams): void;
|
|
80
|
+
/**
|
|
81
|
+
* @title: 重试任务
|
|
82
|
+
* @description:
|
|
83
|
+
* @return {*}
|
|
84
|
+
* @Author: zhiwei.Wang
|
|
85
|
+
* @Date: 2024-09-26 13:53
|
|
86
|
+
*/
|
|
87
|
+
retryTask(payload: RunTaskParams): void;
|
|
88
|
+
addTask(payload: AddTaskParams): void;
|
|
89
|
+
private updateTask;
|
|
90
|
+
private updateQueueStatus;
|
|
91
|
+
/**
|
|
92
|
+
* @title: 更新队列运行状态
|
|
93
|
+
* @description: 标记队列是否正在执行
|
|
94
|
+
*/
|
|
95
|
+
private updateQueueRunningState;
|
|
96
|
+
private setTasksData;
|
|
97
|
+
private setTasks;
|
|
98
|
+
clearAllTaskTimer(tasks: Task[]): void;
|
|
99
|
+
clearTasks(payload: RunTaskParams): void;
|
|
100
|
+
clearAllTasks(): void;
|
|
101
|
+
watchTask(callback: (taskModule: TasksModule) => void): void;
|
|
102
|
+
/**
|
|
103
|
+
* @title: 获取队列执行状态
|
|
104
|
+
* @description: 获取指定队列的执行状态和进度信息
|
|
105
|
+
* @param {string} module - 模块名
|
|
106
|
+
* @param {string} queueId - 队列ID
|
|
107
|
+
* @return {object} 队列状态信息
|
|
108
|
+
*/
|
|
109
|
+
getQueueStatus(module: string, queueId: string): {
|
|
110
|
+
isRunning: boolean;
|
|
111
|
+
status: "uncompleted" | "completed";
|
|
112
|
+
progress: {
|
|
113
|
+
total: number;
|
|
114
|
+
completed: number;
|
|
115
|
+
failed: number;
|
|
116
|
+
inProgress: number;
|
|
117
|
+
};
|
|
118
|
+
lastRunAt: string | null;
|
|
119
|
+
tasksCount: number;
|
|
120
|
+
} | null;
|
|
121
|
+
/**
|
|
122
|
+
* @title: 获取所有队列状态
|
|
123
|
+
* @description: 获取所有任务队列的执行状态概览
|
|
124
|
+
* @return {object} 所有队列的状态信息
|
|
125
|
+
*/
|
|
126
|
+
getAllQueuesStatus(): any;
|
|
127
|
+
}
|