@pisell/core 1.0.49 → 1.0.51
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/es/app/app.d.ts +7 -7
- package/es/app/index.d.ts +1 -1
- package/es/applicationManager/application.d.ts +2 -2
- package/es/cmd/const.d.ts +5 -5
- package/es/hooks/useStore/index.d.ts +1 -1
- package/es/indexDB/index.d.ts +28 -0
- package/es/indexDB/index.js +663 -314
- package/es/locales/type.d.ts +3 -3
- package/es/logger/index.d.ts +1 -1
- package/es/models/index.d.ts +4 -4
- package/es/pubsub/index.d.ts +1 -1
- package/es/request/cache.d.ts +1 -1
- package/es/request/cache.js +2 -2
- package/es/request/constants.js +1 -1
- package/es/request/index.js +3 -1
- package/es/request/pisell2Request.d.ts +1 -1
- package/es/request/type.d.ts +1 -1
- package/es/routes/index.d.ts +2 -2
- package/es/socket/types.d.ts +1 -1
- package/es/tasks/index.d.ts +1 -1
- package/es/tasks/type.d.ts +4 -4
- package/es/utils/adaptiveThrottle/index.d.ts +2 -2
- package/es/variables/index.d.ts +3 -3
- package/lib/app/app.d.ts +7 -7
- package/lib/app/index.d.ts +1 -1
- package/lib/applicationManager/application.d.ts +2 -2
- package/lib/aws/index.js +3 -0
- package/lib/cmd/const.d.ts +5 -5
- package/lib/cmd/const.js +5 -5
- package/lib/cmd/index.js +2 -0
- package/lib/cookie/index.js +2 -4
- package/lib/data/index.js +3 -0
- package/lib/hooks/useStore/index.d.ts +1 -1
- package/lib/indexDB/index.d.ts +28 -0
- package/lib/indexDB/index.js +157 -1
- package/lib/locales/index.js +95 -94
- package/lib/locales/type.d.ts +3 -3
- package/lib/logger/index.d.ts +1 -1
- package/lib/models/index.d.ts +4 -4
- package/lib/pubsub/index.d.ts +1 -1
- package/lib/pubsub/index.js +1 -3
- package/lib/request/cache.d.ts +1 -1
- package/lib/request/cache.js +2 -2
- package/lib/request/constants.js +1 -1
- package/lib/request/pisell2Request.d.ts +1 -1
- package/lib/request/type.d.ts +1 -1
- package/lib/routes/index.d.ts +2 -2
- package/lib/routes/index.js +3 -1
- package/lib/socket/components/SocketMonitorPage.js +6 -12
- package/lib/socket/heartbeat.js +10 -5
- package/lib/socket/index.js +1 -3
- package/lib/socket/monitor.js +26 -24
- package/lib/socket/reconnect.js +10 -3
- package/lib/socket/socket.js +12 -10
- package/lib/socket/types.d.ts +1 -1
- package/lib/storage/index.js +25 -24
- package/lib/tasks/index.d.ts +1 -1
- package/lib/tasks/index.js +333 -329
- package/lib/tasks/type.d.ts +4 -4
- package/lib/utils/adaptiveThrottle/index.d.ts +2 -2
- package/lib/variables/index.d.ts +3 -3
- package/package.json +1 -1
package/lib/locales/index.js
CHANGED
|
@@ -39,101 +39,15 @@ var import_zh_CN = __toESM(require("./zh-CN"));
|
|
|
39
39
|
var import_zh_HK = __toESM(require("./zh-HK"));
|
|
40
40
|
var import_original = __toESM(require("./original"));
|
|
41
41
|
var Locales = class {
|
|
42
|
+
app;
|
|
43
|
+
// 当前语言 本地语言 > 英文语言包
|
|
44
|
+
locale = import_en.default.locale;
|
|
45
|
+
// 语言包
|
|
46
|
+
library = [import_original.default, import_en.default, import_zh_CN.default, import_zh_HK.default].reduce((pre, cur) => {
|
|
47
|
+
pre[cur.locale] = cur;
|
|
48
|
+
return pre;
|
|
49
|
+
}, {});
|
|
42
50
|
constructor(app, options) {
|
|
43
|
-
// 当前语言 本地语言 > 英文语言包
|
|
44
|
-
this.locale = import_en.default.locale;
|
|
45
|
-
// 语言包
|
|
46
|
-
this.library = [import_original.default, import_en.default, import_zh_CN.default, import_zh_HK.default].reduce((pre, cur) => {
|
|
47
|
-
pre[cur.locale] = cur;
|
|
48
|
-
return pre;
|
|
49
|
-
}, {});
|
|
50
|
-
this.getLocale = () => {
|
|
51
|
-
return this.locale;
|
|
52
|
-
};
|
|
53
|
-
this.getCurrentTexts = (locale) => {
|
|
54
|
-
return this.library[locale || this.locale].translations;
|
|
55
|
-
};
|
|
56
|
-
this.setLocale = (locale, reload = false) => {
|
|
57
|
-
this.locale = locale;
|
|
58
|
-
if (reload) {
|
|
59
|
-
window.location.reload();
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
this.getText = (id, locale) => {
|
|
64
|
-
var _a;
|
|
65
|
-
return ((_a = this.getCurrentTexts(locale)) == null ? void 0 : _a[id]) || id;
|
|
66
|
-
};
|
|
67
|
-
this.isCN = () => {
|
|
68
|
-
let locale = this.getLocale();
|
|
69
|
-
return locale === "zh-CN" || locale === "zh-HK";
|
|
70
|
-
};
|
|
71
|
-
this.loadLibraryByUrl = async (urls) => {
|
|
72
|
-
try {
|
|
73
|
-
let fetchList = urls.map((item) => {
|
|
74
|
-
if (typeof item === "string") {
|
|
75
|
-
return fetch(item);
|
|
76
|
-
}
|
|
77
|
-
if (typeof item === "function") {
|
|
78
|
-
return item();
|
|
79
|
-
}
|
|
80
|
-
if (typeof item === "object" && item !== null && "locale" in item) {
|
|
81
|
-
return Promise.resolve(item);
|
|
82
|
-
}
|
|
83
|
-
return item;
|
|
84
|
-
});
|
|
85
|
-
let res = await Promise.all(fetchList);
|
|
86
|
-
let library = { ...this.library };
|
|
87
|
-
for (const item of res) {
|
|
88
|
-
const _item = item instanceof Response ? await item.json() : item;
|
|
89
|
-
library = {
|
|
90
|
-
...library,
|
|
91
|
-
[_item.locale]: import_lodash.default.mergeWith(library[_item.locale] || {}, _item)
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
this.library = library;
|
|
95
|
-
return library;
|
|
96
|
-
} catch (err) {
|
|
97
|
-
console.log(err);
|
|
98
|
-
throw err;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
this.loadLibrary = (urls) => {
|
|
102
|
-
return this.loadLibraryByUrl(urls);
|
|
103
|
-
};
|
|
104
|
-
this.translation = (text, locale) => {
|
|
105
|
-
if (!text) {
|
|
106
|
-
return "";
|
|
107
|
-
}
|
|
108
|
-
if ((0, import_utils.isString)(text) || (0, import_utils.isNumber)(text)) {
|
|
109
|
-
return text;
|
|
110
|
-
}
|
|
111
|
-
let primary = locale || this.getLocale();
|
|
112
|
-
if (typeof text === "string") {
|
|
113
|
-
return text;
|
|
114
|
-
}
|
|
115
|
-
return text[primary] || text["original"] || text["en"] || text["zh-CN"] || text["zh-HK"];
|
|
116
|
-
};
|
|
117
|
-
this.getLibraryByData = (data) => {
|
|
118
|
-
return data.reduce((pre, next) => {
|
|
119
|
-
return {
|
|
120
|
-
...pre,
|
|
121
|
-
[next.locale]: next
|
|
122
|
-
};
|
|
123
|
-
}, {});
|
|
124
|
-
};
|
|
125
|
-
this.createTextsByLibrary = (id, library) => {
|
|
126
|
-
const _library = library || this.library;
|
|
127
|
-
return Object.keys(_library).reduce((pre, next) => {
|
|
128
|
-
var _a;
|
|
129
|
-
let _pre = { ...pre };
|
|
130
|
-
let cur = (_a = _library[next].translations) == null ? void 0 : _a[id];
|
|
131
|
-
if (cur) {
|
|
132
|
-
_pre[_library[next].locale] = cur;
|
|
133
|
-
}
|
|
134
|
-
return _pre;
|
|
135
|
-
}, {});
|
|
136
|
-
};
|
|
137
51
|
this.app = app;
|
|
138
52
|
this.locale = (options == null ? void 0 : options.locale) || this.app.storage.getStorage("locale") || import_en.default.locale;
|
|
139
53
|
this.library = (options == null ? void 0 : options.library) || [import_original.default, import_en.default, import_zh_CN.default, import_zh_HK.default].reduce((pre, cur) => {
|
|
@@ -141,6 +55,57 @@ var Locales = class {
|
|
|
141
55
|
return pre;
|
|
142
56
|
}, {});
|
|
143
57
|
}
|
|
58
|
+
getLocale = () => {
|
|
59
|
+
return this.locale;
|
|
60
|
+
};
|
|
61
|
+
getCurrentTexts = (locale) => {
|
|
62
|
+
return this.library[locale || this.locale].translations;
|
|
63
|
+
};
|
|
64
|
+
setLocale = (locale, reload = false) => {
|
|
65
|
+
this.locale = locale;
|
|
66
|
+
if (reload) {
|
|
67
|
+
window.location.reload();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
getText = (id, locale) => {
|
|
72
|
+
var _a;
|
|
73
|
+
return ((_a = this.getCurrentTexts(locale)) == null ? void 0 : _a[id]) || id;
|
|
74
|
+
};
|
|
75
|
+
isCN = () => {
|
|
76
|
+
let locale = this.getLocale();
|
|
77
|
+
return locale === "zh-CN" || locale === "zh-HK";
|
|
78
|
+
};
|
|
79
|
+
loadLibraryByUrl = async (urls) => {
|
|
80
|
+
try {
|
|
81
|
+
let fetchList = urls.map((item) => {
|
|
82
|
+
if (typeof item === "string") {
|
|
83
|
+
return fetch(item);
|
|
84
|
+
}
|
|
85
|
+
if (typeof item === "function") {
|
|
86
|
+
return item();
|
|
87
|
+
}
|
|
88
|
+
if (typeof item === "object" && item !== null && "locale" in item) {
|
|
89
|
+
return Promise.resolve(item);
|
|
90
|
+
}
|
|
91
|
+
return item;
|
|
92
|
+
});
|
|
93
|
+
let res = await Promise.all(fetchList);
|
|
94
|
+
let library = { ...this.library };
|
|
95
|
+
for (const item of res) {
|
|
96
|
+
const _item = item instanceof Response ? await item.json() : item;
|
|
97
|
+
library = {
|
|
98
|
+
...library,
|
|
99
|
+
[_item.locale]: import_lodash.default.mergeWith(library[_item.locale] || {}, _item)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
this.library = library;
|
|
103
|
+
return library;
|
|
104
|
+
} catch (err) {
|
|
105
|
+
console.log(err);
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
144
109
|
loadLibraryByItems(libraryList) {
|
|
145
110
|
let library = { ...this.library };
|
|
146
111
|
libraryList.forEach((item) => {
|
|
@@ -151,6 +116,42 @@ var Locales = class {
|
|
|
151
116
|
});
|
|
152
117
|
this.library = library;
|
|
153
118
|
}
|
|
119
|
+
loadLibrary = (urls) => {
|
|
120
|
+
return this.loadLibraryByUrl(urls);
|
|
121
|
+
};
|
|
122
|
+
translation = (text, locale) => {
|
|
123
|
+
if (!text) {
|
|
124
|
+
return "";
|
|
125
|
+
}
|
|
126
|
+
if ((0, import_utils.isString)(text) || (0, import_utils.isNumber)(text)) {
|
|
127
|
+
return text;
|
|
128
|
+
}
|
|
129
|
+
let primary = locale || this.getLocale();
|
|
130
|
+
if (typeof text === "string") {
|
|
131
|
+
return text;
|
|
132
|
+
}
|
|
133
|
+
return text[primary] || text["original"] || text["en"] || text["zh-CN"] || text["zh-HK"];
|
|
134
|
+
};
|
|
135
|
+
getLibraryByData = (data) => {
|
|
136
|
+
return data.reduce((pre, next) => {
|
|
137
|
+
return {
|
|
138
|
+
...pre,
|
|
139
|
+
[next.locale]: next
|
|
140
|
+
};
|
|
141
|
+
}, {});
|
|
142
|
+
};
|
|
143
|
+
createTextsByLibrary = (id, library) => {
|
|
144
|
+
const _library = library || this.library;
|
|
145
|
+
return Object.keys(_library).reduce((pre, next) => {
|
|
146
|
+
var _a;
|
|
147
|
+
let _pre = { ...pre };
|
|
148
|
+
let cur = (_a = _library[next].translations) == null ? void 0 : _a[id];
|
|
149
|
+
if (cur) {
|
|
150
|
+
_pre[_library[next].locale] = cur;
|
|
151
|
+
}
|
|
152
|
+
return _pre;
|
|
153
|
+
}, {});
|
|
154
|
+
};
|
|
154
155
|
};
|
|
155
156
|
// Annotate the CommonJS export names for ESM import in node:
|
|
156
157
|
0 && (module.exports = {
|
package/lib/locales/type.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type Locale = 'original' | 'en' | 'zh-CN' | 'zh-HK' | string;
|
|
2
|
-
export type MultiLanguage = {
|
|
1
|
+
export declare type Locale = 'original' | 'en' | 'zh-CN' | 'zh-HK' | string;
|
|
2
|
+
export declare type MultiLanguage = {
|
|
3
3
|
[key in Locale]: string;
|
|
4
4
|
};
|
|
5
5
|
export interface LibraryItem {
|
|
@@ -16,4 +16,4 @@ export interface LocaleConfig {
|
|
|
16
16
|
[key in Locale]: LibraryItem;
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
export type LoadLibraryByUrlParams = (string | Promise<LibraryItem> | (() => Promise<LibraryItem>) | LibraryItem)[];
|
|
19
|
+
export declare type LoadLibraryByUrlParams = (string | Promise<LibraryItem> | (() => Promise<LibraryItem>) | LibraryItem)[];
|
package/lib/logger/index.d.ts
CHANGED
package/lib/models/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import hooks from '../hooks';
|
|
2
2
|
import { Provider as StoreProvider } from "react-redux";
|
|
3
3
|
declare const models: import("./global").GlobalModal[];
|
|
4
|
-
type ModalsType = (typeof models[number]);
|
|
4
|
+
declare type ModalsType = (typeof models[number]);
|
|
5
5
|
export interface Store {
|
|
6
6
|
getDataByModel: typeof getDataByModel;
|
|
7
7
|
useStore: typeof hooks.useStore;
|
|
@@ -10,8 +10,8 @@ export interface Store {
|
|
|
10
10
|
dispatch: any;
|
|
11
11
|
getState: any;
|
|
12
12
|
}
|
|
13
|
-
export type ModelsNames = ModalsType['namespace'];
|
|
14
|
-
export type ModelsState = {
|
|
13
|
+
export declare type ModelsNames = ModalsType['namespace'];
|
|
14
|
+
export declare type ModelsState = {
|
|
15
15
|
[K in (ModalsType['namespace'])]: Extract<ModalsType, {
|
|
16
16
|
namespace: K;
|
|
17
17
|
}>['state'];
|
|
@@ -25,7 +25,7 @@ export type ModelsState = {
|
|
|
25
25
|
* @Author: zhiwei.Wang
|
|
26
26
|
* @Date: 2024-09-03 11:07
|
|
27
27
|
*/
|
|
28
|
-
declare const getDataByModel: <T extends "global", D extends keyof ModelsState[T]>(model: string, key?: D) => D extends undefined ? ModelsState[T] : ModelsState[T][D];
|
|
28
|
+
declare const getDataByModel: <T extends "global", D extends keyof ModelsState[T]>(model: string, key?: D | undefined) => D extends undefined ? ModelsState[T] : ModelsState[T][D];
|
|
29
29
|
/**
|
|
30
30
|
* @title: 设置数据到store
|
|
31
31
|
* @description:
|
package/lib/pubsub/index.d.ts
CHANGED
package/lib/pubsub/index.js
CHANGED
package/lib/request/cache.d.ts
CHANGED
package/lib/request/cache.js
CHANGED
|
@@ -65,9 +65,9 @@ var setCache = async (key, data, cache) => {
|
|
|
65
65
|
if (app.dbManager) {
|
|
66
66
|
let tasksData = await app.dbManager.get("requests", key);
|
|
67
67
|
if (!tasksData) {
|
|
68
|
-
await app.dbManager.
|
|
68
|
+
await app.dbManager.debouncedAdd("requests", cacheData);
|
|
69
69
|
} else {
|
|
70
|
-
await app.dbManager.
|
|
70
|
+
await app.dbManager.debouncedUpdate("requests", cacheData);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
package/lib/request/constants.js
CHANGED
package/lib/request/type.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare enum RequestModeENUM {
|
|
|
31
31
|
REMOTE_LOCAL = "remote_local",
|
|
32
32
|
OS_SERVER = "os_server"
|
|
33
33
|
}
|
|
34
|
-
export type RequestModeType = RequestModeENUM.LOCAL | RequestModeENUM.REMOTE | RequestModeENUM.LOCAL_REMOTE | RequestModeENUM.REMOTE_LOCAL | RequestModeENUM.OS_SERVER;
|
|
34
|
+
export declare type RequestModeType = RequestModeENUM.LOCAL | RequestModeENUM.REMOTE | RequestModeENUM.LOCAL_REMOTE | RequestModeENUM.REMOTE_LOCAL | RequestModeENUM.OS_SERVER;
|
|
35
35
|
export interface CacheProps {
|
|
36
36
|
key?: string;
|
|
37
37
|
type?: CacheType;
|
package/lib/routes/index.d.ts
CHANGED
|
@@ -20,9 +20,9 @@ export declare class RouterManager {
|
|
|
20
20
|
get(name: string): RouteType;
|
|
21
21
|
has(name: string): boolean;
|
|
22
22
|
remove(name: string): void;
|
|
23
|
-
renderComponent(item: RouteType, children?: React.ReactNode): string | number | boolean |
|
|
23
|
+
renderComponent(item: RouteType, children?: React.ReactNode): string | number | boolean | JSX.Element | React.ReactFragment | null | undefined;
|
|
24
24
|
getPageByRoute(route: string): ApplicationInterface | undefined;
|
|
25
25
|
getRouterComponent({ fallback }: {
|
|
26
26
|
fallback?: React.ReactNode;
|
|
27
|
-
}):
|
|
27
|
+
}): JSX.Element[];
|
|
28
28
|
}
|
package/lib/routes/index.js
CHANGED
|
@@ -35,8 +35,10 @@ module.exports = __toCommonJS(routes_exports);
|
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
36
|
var import_react_router_dom = require("react-router-dom");
|
|
37
37
|
var RouterManager = class {
|
|
38
|
+
routes = {};
|
|
39
|
+
options;
|
|
40
|
+
app;
|
|
38
41
|
constructor(options = {}, app) {
|
|
39
|
-
this.routes = {};
|
|
40
42
|
this.options = options;
|
|
41
43
|
this.app = app;
|
|
42
44
|
this.routes = options.routes || {};
|
|
@@ -36,14 +36,12 @@ var import_react = __toESM(require("react"));
|
|
|
36
36
|
var import__ = __toESM(require("../index"));
|
|
37
37
|
var import__2 = require("../index");
|
|
38
38
|
var formatTime = (timestamp) => {
|
|
39
|
-
if (timestamp === null)
|
|
40
|
-
return "无";
|
|
39
|
+
if (timestamp === null) return "无";
|
|
41
40
|
const date = new Date(timestamp);
|
|
42
41
|
return date.toLocaleString();
|
|
43
42
|
};
|
|
44
43
|
var formatDuration = (ms) => {
|
|
45
|
-
if (ms === null)
|
|
46
|
-
return "无";
|
|
44
|
+
if (ms === null) return "无";
|
|
47
45
|
const seconds = Math.floor(ms / 1e3);
|
|
48
46
|
const minutes = Math.floor(seconds / 60);
|
|
49
47
|
const hours = Math.floor(minutes / 60);
|
|
@@ -52,8 +50,7 @@ var formatDuration = (ms) => {
|
|
|
52
50
|
return `${hours}小时 ${remainingMinutes}分钟 ${remainingSeconds}秒`;
|
|
53
51
|
};
|
|
54
52
|
var formatBytes = (bytes) => {
|
|
55
|
-
if (bytes === 0)
|
|
56
|
-
return "0 B";
|
|
53
|
+
if (bytes === 0) return "0 B";
|
|
57
54
|
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
58
55
|
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
59
56
|
return `${(bytes / Math.pow(1024, i)).toFixed(2)} ${units[i]}`;
|
|
@@ -93,15 +90,12 @@ var SocketMonitorPage = () => {
|
|
|
93
90
|
}
|
|
94
91
|
}, [selectedKey]);
|
|
95
92
|
const loadSocketData = (0, import_react.useCallback)(() => {
|
|
96
|
-
if (!selectedKey)
|
|
97
|
-
return;
|
|
93
|
+
if (!selectedKey) return;
|
|
98
94
|
const socketInstance = import__.default.get(selectedKey);
|
|
99
|
-
if (!socketInstance)
|
|
100
|
-
return;
|
|
95
|
+
if (!socketInstance) return;
|
|
101
96
|
setCurrentSocket(socketInstance);
|
|
102
97
|
const monitor = socketInstance.getMonitor() || socketInstance.enableMonitoring();
|
|
103
|
-
if (!monitor)
|
|
104
|
-
return;
|
|
98
|
+
if (!monitor) return;
|
|
105
99
|
setStats(monitor.getStats());
|
|
106
100
|
const direction = messageFilter === "all" ? void 0 : messageFilter === "in" ? "in" : "out";
|
|
107
101
|
setMessageHistory(monitor.getMessageHistory(50, direction));
|
package/lib/socket/heartbeat.js
CHANGED
|
@@ -24,6 +24,16 @@ __export(heartbeat_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(heartbeat_exports);
|
|
25
25
|
var import_constants = require("./constants");
|
|
26
26
|
var HeartbeatManager = class {
|
|
27
|
+
options;
|
|
28
|
+
intervalTimer = null;
|
|
29
|
+
timeoutTimer = null;
|
|
30
|
+
lastHeartbeatTime = 0;
|
|
31
|
+
lastHeartbeatResponse = 0;
|
|
32
|
+
active = false;
|
|
33
|
+
// 心跳回调函数
|
|
34
|
+
sendHeartbeat;
|
|
35
|
+
onTimeout;
|
|
36
|
+
onResponse;
|
|
27
37
|
/**
|
|
28
38
|
* 创建心跳管理器
|
|
29
39
|
* @param options 心跳配置选项
|
|
@@ -31,11 +41,6 @@ var HeartbeatManager = class {
|
|
|
31
41
|
* @param callbacks 回调函数集合
|
|
32
42
|
*/
|
|
33
43
|
constructor(options, sendHeartbeat, callbacks = {}) {
|
|
34
|
-
this.intervalTimer = null;
|
|
35
|
-
this.timeoutTimer = null;
|
|
36
|
-
this.lastHeartbeatTime = 0;
|
|
37
|
-
this.lastHeartbeatResponse = 0;
|
|
38
|
-
this.active = false;
|
|
39
44
|
this.options = {
|
|
40
45
|
...options,
|
|
41
46
|
interval: Math.max(options.interval, import_constants.MIN_HEARTBEAT_INTERVAL),
|
package/lib/socket/index.js
CHANGED
|
@@ -46,9 +46,7 @@ function createSocket(url, options = {}) {
|
|
|
46
46
|
return new import_socket.Socket({ url, ...options });
|
|
47
47
|
}
|
|
48
48
|
var SocketFactory = class {
|
|
49
|
-
|
|
50
|
-
this.sockets = /* @__PURE__ */ new Map();
|
|
51
|
-
}
|
|
49
|
+
sockets = /* @__PURE__ */ new Map();
|
|
52
50
|
/**
|
|
53
51
|
* 创建新的Socket实例
|
|
54
52
|
* @param url WebSocket连接URL
|
package/lib/socket/monitor.js
CHANGED
|
@@ -25,36 +25,38 @@ module.exports = __toCommonJS(monitor_exports);
|
|
|
25
25
|
var import_events = require("./events");
|
|
26
26
|
var import_types = require("./types");
|
|
27
27
|
var SocketMonitor = class {
|
|
28
|
+
socket;
|
|
29
|
+
options;
|
|
30
|
+
isMonitoring = false;
|
|
31
|
+
// 历史记录存储
|
|
32
|
+
messageHistory = [];
|
|
33
|
+
statusHistory = [];
|
|
34
|
+
// 统计数据
|
|
35
|
+
stats = {
|
|
36
|
+
totalSent: 0,
|
|
37
|
+
totalReceived: 0,
|
|
38
|
+
bytesSent: 0,
|
|
39
|
+
bytesReceived: 0,
|
|
40
|
+
connectionCount: 0,
|
|
41
|
+
reconnectionCount: 0,
|
|
42
|
+
errorCount: 0,
|
|
43
|
+
heartbeatCount: 0,
|
|
44
|
+
heartbeatTimeoutCount: 0,
|
|
45
|
+
firstConnectTime: null,
|
|
46
|
+
lastConnectTime: null,
|
|
47
|
+
currentConnectionDuration: null,
|
|
48
|
+
averageMessageSize: 0
|
|
49
|
+
};
|
|
50
|
+
// 用于计算连接持续时间
|
|
51
|
+
connectStartTime = null;
|
|
52
|
+
// 事件句柄映射
|
|
53
|
+
eventHandlers = /* @__PURE__ */ new Map();
|
|
28
54
|
/**
|
|
29
55
|
* 创建Socket监控器
|
|
30
56
|
* @param socket 要监控的Socket实例
|
|
31
57
|
* @param options 监控配置选项
|
|
32
58
|
*/
|
|
33
59
|
constructor(socket, options = {}) {
|
|
34
|
-
this.isMonitoring = false;
|
|
35
|
-
// 历史记录存储
|
|
36
|
-
this.messageHistory = [];
|
|
37
|
-
this.statusHistory = [];
|
|
38
|
-
// 统计数据
|
|
39
|
-
this.stats = {
|
|
40
|
-
totalSent: 0,
|
|
41
|
-
totalReceived: 0,
|
|
42
|
-
bytesSent: 0,
|
|
43
|
-
bytesReceived: 0,
|
|
44
|
-
connectionCount: 0,
|
|
45
|
-
reconnectionCount: 0,
|
|
46
|
-
errorCount: 0,
|
|
47
|
-
heartbeatCount: 0,
|
|
48
|
-
heartbeatTimeoutCount: 0,
|
|
49
|
-
firstConnectTime: null,
|
|
50
|
-
lastConnectTime: null,
|
|
51
|
-
currentConnectionDuration: null,
|
|
52
|
-
averageMessageSize: 0
|
|
53
|
-
};
|
|
54
|
-
// 用于计算连接持续时间
|
|
55
|
-
this.connectStartTime = null;
|
|
56
|
-
// 事件句柄映射
|
|
57
|
-
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
58
60
|
this.socket = socket;
|
|
59
61
|
this.options = {
|
|
60
62
|
maxHistoryItems: 100,
|
package/lib/socket/reconnect.js
CHANGED
|
@@ -24,6 +24,16 @@ __export(reconnect_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(reconnect_exports);
|
|
25
25
|
var import_constants = require("./constants");
|
|
26
26
|
var ReconnectManager = class {
|
|
27
|
+
options;
|
|
28
|
+
attempts = 0;
|
|
29
|
+
timer = null;
|
|
30
|
+
isReconnecting = false;
|
|
31
|
+
// 重连回调函数
|
|
32
|
+
reconnectCallback;
|
|
33
|
+
onAttempt;
|
|
34
|
+
onSuccess;
|
|
35
|
+
onFail;
|
|
36
|
+
onMaxAttemptsExceeded;
|
|
27
37
|
/**
|
|
28
38
|
* 创建重连管理器实例
|
|
29
39
|
* @param options 重连配置
|
|
@@ -31,9 +41,6 @@ var ReconnectManager = class {
|
|
|
31
41
|
* @param callbacks 回调函数集合
|
|
32
42
|
*/
|
|
33
43
|
constructor(options, reconnectCallback, callbacks = {}) {
|
|
34
|
-
this.attempts = 0;
|
|
35
|
-
this.timer = null;
|
|
36
|
-
this.isReconnecting = false;
|
|
37
44
|
this.options = {
|
|
38
45
|
...options,
|
|
39
46
|
delay: Math.max(options.delay, import_constants.MIN_RECONNECTION_DELAY)
|
package/lib/socket/socket.js
CHANGED
|
@@ -30,21 +30,23 @@ var import_reconnect = require("./reconnect");
|
|
|
30
30
|
var import_monitor = require("./monitor");
|
|
31
31
|
var import_app = require("../app");
|
|
32
32
|
var Socket = class {
|
|
33
|
+
ws = null;
|
|
34
|
+
url;
|
|
35
|
+
options;
|
|
36
|
+
status = import_types.SocketStatus.CLOSED;
|
|
37
|
+
eventHandlers = {};
|
|
38
|
+
// 心跳和重连管理器
|
|
39
|
+
heartbeatManager = null;
|
|
40
|
+
reconnectManager = null;
|
|
41
|
+
// 监控器
|
|
42
|
+
monitor = null;
|
|
43
|
+
// 消息ID计数器
|
|
44
|
+
messageIdCounter = 0;
|
|
33
45
|
/**
|
|
34
46
|
* 创建Socket实例
|
|
35
47
|
* @param options Socket配置选项
|
|
36
48
|
*/
|
|
37
49
|
constructor(options) {
|
|
38
|
-
this.ws = null;
|
|
39
|
-
this.status = import_types.SocketStatus.CLOSED;
|
|
40
|
-
this.eventHandlers = {};
|
|
41
|
-
// 心跳和重连管理器
|
|
42
|
-
this.heartbeatManager = null;
|
|
43
|
-
this.reconnectManager = null;
|
|
44
|
-
// 监控器
|
|
45
|
-
this.monitor = null;
|
|
46
|
-
// 消息ID计数器
|
|
47
|
-
this.messageIdCounter = 0;
|
|
48
50
|
this.url = options.url;
|
|
49
51
|
this.options = {
|
|
50
52
|
...import_constants.DEFAULT_SOCKET_OPTIONS,
|
package/lib/socket/types.d.ts
CHANGED
package/lib/storage/index.js
CHANGED
|
@@ -23,31 +23,10 @@ __export(storage_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(storage_exports);
|
|
25
25
|
var Storage = class {
|
|
26
|
+
storageKey = "CapacitorStorage.native_";
|
|
27
|
+
app;
|
|
28
|
+
options = {};
|
|
26
29
|
constructor(app, options) {
|
|
27
|
-
this.storageKey = "CapacitorStorage.native_";
|
|
28
|
-
this.options = {};
|
|
29
|
-
this.createKey = (key) => {
|
|
30
|
-
if (key.indexOf(this.storageKey) !== -1) {
|
|
31
|
-
return key;
|
|
32
|
-
}
|
|
33
|
-
return this.storageKey + key;
|
|
34
|
-
};
|
|
35
|
-
this.setStorage = (key, value) => {
|
|
36
|
-
var _a, _b;
|
|
37
|
-
localStorage.setItem(this.createKey(key), value);
|
|
38
|
-
(_b = (_a = this.options) == null ? void 0 : _a.setStorageAfter) == null ? void 0 : _b.call(_a, key, value);
|
|
39
|
-
};
|
|
40
|
-
this.getStorage = (key) => {
|
|
41
|
-
return localStorage.getItem(this.createKey(key));
|
|
42
|
-
};
|
|
43
|
-
this.removeStorage = (key) => {
|
|
44
|
-
var _a, _b;
|
|
45
|
-
localStorage.removeItem(this.createKey(key));
|
|
46
|
-
(_b = (_a = this.options) == null ? void 0 : _a.removeStorageAfter) == null ? void 0 : _b.call(_a, key);
|
|
47
|
-
};
|
|
48
|
-
this.clear = () => {
|
|
49
|
-
localStorage.clear();
|
|
50
|
-
};
|
|
51
30
|
this.app = app;
|
|
52
31
|
if (options) {
|
|
53
32
|
this.options = options;
|
|
@@ -56,6 +35,28 @@ var Storage = class {
|
|
|
56
35
|
this.storageKey = options.storageKey;
|
|
57
36
|
}
|
|
58
37
|
}
|
|
38
|
+
createKey = (key) => {
|
|
39
|
+
if (key.indexOf(this.storageKey) !== -1) {
|
|
40
|
+
return key;
|
|
41
|
+
}
|
|
42
|
+
return this.storageKey + key;
|
|
43
|
+
};
|
|
44
|
+
setStorage = (key, value) => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
localStorage.setItem(this.createKey(key), value);
|
|
47
|
+
(_b = (_a = this.options) == null ? void 0 : _a.setStorageAfter) == null ? void 0 : _b.call(_a, key, value);
|
|
48
|
+
};
|
|
49
|
+
getStorage = (key) => {
|
|
50
|
+
return localStorage.getItem(this.createKey(key));
|
|
51
|
+
};
|
|
52
|
+
removeStorage = (key) => {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
localStorage.removeItem(this.createKey(key));
|
|
55
|
+
(_b = (_a = this.options) == null ? void 0 : _a.removeStorageAfter) == null ? void 0 : _b.call(_a, key);
|
|
56
|
+
};
|
|
57
|
+
clear = () => {
|
|
58
|
+
localStorage.clear();
|
|
59
|
+
};
|
|
59
60
|
};
|
|
60
61
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
62
|
0 && (module.exports = {
|
package/lib/tasks/index.d.ts
CHANGED
|
@@ -108,7 +108,7 @@ export declare class TasksManager {
|
|
|
108
108
|
*/
|
|
109
109
|
getQueueStatus(module: string, queueId: string): {
|
|
110
110
|
isRunning: boolean;
|
|
111
|
-
status: "
|
|
111
|
+
status: "completed" | "uncompleted";
|
|
112
112
|
progress: {
|
|
113
113
|
total: number;
|
|
114
114
|
completed: number;
|