@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.
Files changed (62) hide show
  1. package/es/app/app.d.ts +7 -7
  2. package/es/app/index.d.ts +1 -1
  3. package/es/applicationManager/application.d.ts +2 -2
  4. package/es/cmd/const.d.ts +5 -5
  5. package/es/hooks/useStore/index.d.ts +1 -1
  6. package/es/indexDB/index.d.ts +28 -0
  7. package/es/indexDB/index.js +663 -314
  8. package/es/locales/type.d.ts +3 -3
  9. package/es/logger/index.d.ts +1 -1
  10. package/es/models/index.d.ts +4 -4
  11. package/es/pubsub/index.d.ts +1 -1
  12. package/es/request/cache.d.ts +1 -1
  13. package/es/request/cache.js +2 -2
  14. package/es/request/constants.js +1 -1
  15. package/es/request/index.js +3 -1
  16. package/es/request/pisell2Request.d.ts +1 -1
  17. package/es/request/type.d.ts +1 -1
  18. package/es/routes/index.d.ts +2 -2
  19. package/es/socket/types.d.ts +1 -1
  20. package/es/tasks/index.d.ts +1 -1
  21. package/es/tasks/type.d.ts +4 -4
  22. package/es/utils/adaptiveThrottle/index.d.ts +2 -2
  23. package/es/variables/index.d.ts +3 -3
  24. package/lib/app/app.d.ts +7 -7
  25. package/lib/app/index.d.ts +1 -1
  26. package/lib/applicationManager/application.d.ts +2 -2
  27. package/lib/aws/index.js +3 -0
  28. package/lib/cmd/const.d.ts +5 -5
  29. package/lib/cmd/const.js +5 -5
  30. package/lib/cmd/index.js +2 -0
  31. package/lib/cookie/index.js +2 -4
  32. package/lib/data/index.js +3 -0
  33. package/lib/hooks/useStore/index.d.ts +1 -1
  34. package/lib/indexDB/index.d.ts +28 -0
  35. package/lib/indexDB/index.js +157 -1
  36. package/lib/locales/index.js +95 -94
  37. package/lib/locales/type.d.ts +3 -3
  38. package/lib/logger/index.d.ts +1 -1
  39. package/lib/models/index.d.ts +4 -4
  40. package/lib/pubsub/index.d.ts +1 -1
  41. package/lib/pubsub/index.js +1 -3
  42. package/lib/request/cache.d.ts +1 -1
  43. package/lib/request/cache.js +2 -2
  44. package/lib/request/constants.js +1 -1
  45. package/lib/request/pisell2Request.d.ts +1 -1
  46. package/lib/request/type.d.ts +1 -1
  47. package/lib/routes/index.d.ts +2 -2
  48. package/lib/routes/index.js +3 -1
  49. package/lib/socket/components/SocketMonitorPage.js +6 -12
  50. package/lib/socket/heartbeat.js +10 -5
  51. package/lib/socket/index.js +1 -3
  52. package/lib/socket/monitor.js +26 -24
  53. package/lib/socket/reconnect.js +10 -3
  54. package/lib/socket/socket.js +12 -10
  55. package/lib/socket/types.d.ts +1 -1
  56. package/lib/storage/index.js +25 -24
  57. package/lib/tasks/index.d.ts +1 -1
  58. package/lib/tasks/index.js +333 -329
  59. package/lib/tasks/type.d.ts +4 -4
  60. package/lib/utils/adaptiveThrottle/index.d.ts +2 -2
  61. package/lib/variables/index.d.ts +3 -3
  62. package/package.json +1 -1
@@ -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 = {
@@ -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)[];
@@ -1,5 +1,5 @@
1
1
  import App from "../app";
2
- export type LogConsoleType = "info" | "warning" | "error" | "debug";
2
+ export declare type LogConsoleType = "info" | "warning" | "error" | "debug";
3
3
  /**
4
4
  * 日志项接口
5
5
  */
@@ -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:
@@ -2,7 +2,7 @@
2
2
  * 发布订阅模块
3
3
  * 用于组件/服务间的事件通信
4
4
  */
5
- type EventCallback = (...args: any[]) => void;
5
+ declare type EventCallback = (...args: any[]) => void;
6
6
  interface EventSubscription {
7
7
  unsubscribe: () => void;
8
8
  }
@@ -24,9 +24,7 @@ __export(pubsub_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(pubsub_exports);
26
26
  var PubSub = class {
27
- constructor() {
28
- this.events = /* @__PURE__ */ new Map();
29
- }
27
+ events = /* @__PURE__ */ new Map();
30
28
  /**
31
29
  * 订阅事件
32
30
  * @param event 事件名称
@@ -1,5 +1,5 @@
1
1
  import { CacheProps } from './type';
2
- export type CacheType = 'memory' | 'storage' | 'indexDB';
2
+ export declare type CacheType = 'memory' | 'storage' | 'indexDB';
3
3
  /**
4
4
  * @title: 设置缓存
5
5
  * @description:
@@ -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.add("requests", cacheData);
68
+ await app.dbManager.debouncedAdd("requests", cacheData);
69
69
  } else {
70
- await app.dbManager.update("requests", cacheData);
70
+ await app.dbManager.debouncedUpdate("requests", cacheData);
71
71
  }
72
72
  }
73
73
  }
@@ -23,7 +23,7 @@ __export(constants_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(constants_exports);
25
25
  var axiosConfig = {
26
- timeout: 1e3 * 60,
26
+ timeout: 1e3 * 60 * 2,
27
27
  headers: {
28
28
  "Content-Type": "application/json"
29
29
  }
@@ -1,4 +1,4 @@
1
- type RequestMethod = any;
1
+ declare type RequestMethod = any;
2
2
  declare const pisell2Get: RequestMethod;
3
3
  declare const pisell2Post: RequestMethod;
4
4
  declare const pisell2Put: RequestMethod;
@@ -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;
@@ -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 | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
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
- }): React.JSX.Element[];
27
+ }): JSX.Element[];
28
28
  }
@@ -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));
@@ -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),
@@ -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
- constructor() {
50
- this.sockets = /* @__PURE__ */ new Map();
51
- }
49
+ sockets = /* @__PURE__ */ new Map();
52
50
  /**
53
51
  * 创建新的Socket实例
54
52
  * @param url WebSocket连接URL
@@ -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,
@@ -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)
@@ -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,
@@ -76,7 +76,7 @@ export interface ReconnectOptions {
76
76
  /**
77
77
  * 事件处理函数类型
78
78
  */
79
- export type EventHandler = (...args: any[]) => void;
79
+ export declare type EventHandler = (...args: any[]) => void;
80
80
  /**
81
81
  * 事件处理函数映射
82
82
  */
@@ -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 = {
@@ -108,7 +108,7 @@ export declare class TasksManager {
108
108
  */
109
109
  getQueueStatus(module: string, queueId: string): {
110
110
  isRunning: boolean;
111
- status: "uncompleted" | "completed";
111
+ status: "completed" | "uncompleted";
112
112
  progress: {
113
113
  total: number;
114
114
  completed: number;