@havue/solutions 1.1.1 → 1.2.0

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 (28) hide show
  1. package/bc-connect/__tests__/bc-connect.spec.ts +73 -0
  2. package/bc-connect/dist/bc-connect.mjs +89 -73
  3. package/bc-connect/dist/bc-connect.umd.js +89 -73
  4. package/bc-connect/dist/types/src/manager.d.ts +72 -62
  5. package/bc-connect/package.json +1 -1
  6. package/bc-connect/src/manager.ts +103 -78
  7. package/dist/solutions.full.js +156 -127
  8. package/dist/solutions.full.min.js +4 -4
  9. package/dist/solutions.full.min.js.map +1 -1
  10. package/dist/types/bc-connect/src/manager.d.ts +72 -62
  11. package/dist/types/ws-video-manager/src/loader/websocket-loader.d.ts +13 -10
  12. package/dist/types/ws-video-manager/src/manager/index.d.ts +54 -37
  13. package/dist/types/ws-video-manager/src/render/drawer.d.ts +7 -7
  14. package/dist/types/ws-video-manager/src/render/index.d.ts +35 -19
  15. package/package.json +4 -4
  16. package/vite.config.ts +1 -1
  17. package/ws-video-manager/dist/types/src/loader/websocket-loader.d.ts +13 -10
  18. package/ws-video-manager/dist/types/src/manager/index.d.ts +54 -37
  19. package/ws-video-manager/dist/types/src/render/drawer.d.ts +7 -7
  20. package/ws-video-manager/dist/types/src/render/index.d.ts +35 -19
  21. package/ws-video-manager/dist/ws-video-manager.mjs +67 -54
  22. package/ws-video-manager/dist/ws-video-manager.umd.js +67 -54
  23. package/ws-video-manager/package.json +1 -1
  24. package/ws-video-manager/src/loader/websocket-loader.ts +15 -11
  25. package/ws-video-manager/src/manager/index.ts +57 -40
  26. package/ws-video-manager/src/render/drawer.ts +22 -20
  27. package/ws-video-manager/src/render/index.ts +61 -27
  28. package/ws-video-manager/src/render/mp4box.ts +1 -1
@@ -6,14 +6,14 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
6
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
7
 
8
8
  var BcConnectEventTypeEnum = /* @__PURE__ */ ((BcConnectEventTypeEnum2) => {
9
- BcConnectEventTypeEnum2["Broadcast"] = "Hello world";
10
- BcConnectEventTypeEnum2["Broadcast_Reply"] = "I can hear you";
11
- BcConnectEventTypeEnum2["Main_Node_Hearbeat"] = "苍天还在,别立黄天";
12
- BcConnectEventTypeEnum2["Res_Main_Node_Hearbeat"] = "苍天在上,受我一拜";
13
- BcConnectEventTypeEnum2["Req_Be_Main_Node"] = "苍天已死,黄天当立";
14
- BcConnectEventTypeEnum2["Res_Be_Main_Node"] = "我是黄天,尔等退下";
15
- BcConnectEventTypeEnum2["Node_Type_Change"] = "node type change";
16
- BcConnectEventTypeEnum2["Friend_List_Update"] = "friend list update";
9
+ BcConnectEventTypeEnum2["Broadcast"] = "__BCM_INIT__";
10
+ BcConnectEventTypeEnum2["Broadcast_Reply"] = "__BCM_INIT_REPLY__";
11
+ BcConnectEventTypeEnum2["Main_Node_Hearbeat"] = "__BCM_MAIN_NODE_HEARBEAT__";
12
+ BcConnectEventTypeEnum2["Res_Main_Node_Hearbeat"] = "__BCM_MAIN_NODE_HEARBEAT_REPLY__";
13
+ BcConnectEventTypeEnum2["Req_Be_Main_Node"] = "__BCM_REQ_BE_MAIN_NODE__";
14
+ BcConnectEventTypeEnum2["Res_Be_Main_Node"] = "__BCM_REQ_BE_MAIN_NODE_REJECT__";
15
+ BcConnectEventTypeEnum2["Node_Type_Change"] = "__BCM_NODE_TYPE_CHANGE__";
16
+ BcConnectEventTypeEnum2["Friend_List_Update"] = "__BCM_FRIEND_LIST_UPDATE__";
17
17
  return BcConnectEventTypeEnum2;
18
18
  })(BcConnectEventTypeEnum || {});
19
19
  var BcConnectNodeTypeEnum = /* @__PURE__ */ ((BcConnectNodeTypeEnum2) => {
@@ -24,25 +24,30 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
24
24
  const MessageTimeout = 300;
25
25
  class BroadcastChannelManager {
26
26
  constructor(name, debug = false) {
27
- /** 通道名称 */
27
+ /** 通道名称 | Channel name */
28
28
  __publicField(this, "_bcName");
29
- /** BroadcastChannel实例 */
29
+ /** BroadcastChannel instance */
30
30
  __publicField(this, "_broadcastChannel");
31
- /** 事件map */
31
+ /** Event map */
32
32
  __publicField(this, "_eventMap");
33
- /** 主节点发送心跳的interval */
33
+ /** 主节点发送心跳的interval | The interval at which the master node sends the heartbeat */
34
34
  __publicField(this, "_mainNodeMsgInterval", null);
35
- /** 认为主节点掉线的timeout */
36
- __publicField(this, "_mainNoceMsgTimeoutTimer", null);
37
- /** 当前实例id */
35
+ /** 认为主节点掉线的timeout | timeout to consider the primary node to be offline */
36
+ __publicField(this, "_mainNodeMsgTimeoutTimer", null);
37
+ /** 更新友方列表的timeout | Update the timeout of the friend list */
38
+ __publicField(this, "_updateFriendListTimer", null);
39
+ /** 当前实例id | Current instance id */
38
40
  __publicField(this, "id", Date.now() + Math.random());
39
- /** 记录的友方id数组 */
41
+ /** 其他广播通道id列表 | List of other broadcast channel ids */
40
42
  __publicField(this, "_oldFrendChannelIdList", []);
41
- /** 正在更新的右方id数组 */
43
+ /** 正在更新的id数组 | The id array being updated */
42
44
  __publicField(this, "_friendChannelIdSet", /* @__PURE__ */ new Set());
43
- /** 当前节点类型 */
45
+ /** 当前节点类型 | Current node type */
44
46
  __publicField(this, "_nodeType");
45
- /** 是否开启调试模式,会在控制台打印相关信息 */
47
+ /**
48
+ * 是否开启调试模式,会在控制台打印相关信息
49
+ * If debug mode is enabled, it will print information to the console
50
+ */
46
51
  __publicField(this, "_debug", false);
47
52
  this._debug = debug;
48
53
  this._bcName = name;
@@ -65,9 +70,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
65
70
  close() {
66
71
  this._debug && console.log("BC:bc close");
67
72
  this._broadcastChannel && this._broadcastChannel.close();
73
+ this._broadcastChannel = void 0;
74
+ this._updateFriendListTimer && clearTimeout(this._updateFriendListTimer);
75
+ this._updateFriendListTimer = null;
76
+ this._mainNodeMsgInterval && clearInterval(this._mainNodeMsgInterval);
77
+ this._mainNodeMsgInterval = null;
78
+ this._mainNodeMsgTimeoutTimer && clearTimeout(this._mainNodeMsgTimeoutTimer);
79
+ this._mainNodeMsgTimeoutTimer = null;
80
+ this._oldFrendChannelIdList = [];
81
+ this._friendChannelIdSet.clear();
82
+ this._nodeType = void 0;
68
83
  }
69
84
  /**
70
- * 切换节点类型
85
+ * 切换节点类型 | Switching node type
71
86
  * @param {BcConnectNodeTypeEnum} type
72
87
  * @returns
73
88
  */
@@ -76,30 +91,31 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
76
91
  return;
77
92
  }
78
93
  this._nodeType = type;
79
- this.emit("node type change", {
80
- type: "node type change",
94
+ this.emit("__BCM_NODE_TYPE_CHANGE__", {
95
+ type: "__BCM_NODE_TYPE_CHANGE__",
81
96
  data: type,
82
97
  id: this.id
83
98
  });
84
99
  }
85
- /** 更新友方列表 */
100
+ /** 更新广播id列表 | Update the list of broadcast ids */
86
101
  _updateFriendList() {
87
102
  this.send(
88
- "Hello world"
103
+ "__BCM_INIT__"
89
104
  /* Broadcast */
90
105
  );
91
- setTimeout(() => {
106
+ this._updateFriendListTimer && clearTimeout(this._updateFriendListTimer);
107
+ this._updateFriendListTimer = setTimeout(() => {
92
108
  this._oldFrendChannelIdList = this._getNewFriendList();
93
109
  this._debug && console.log("BC:connect:updateFriendChannelIdList:", this._oldFrendChannelIdList);
94
- this.emit("friend list update", {
95
- type: "friend list update",
110
+ this.emit("__BCM_FRIEND_LIST_UPDATE__", {
111
+ type: "__BCM_FRIEND_LIST_UPDATE__",
96
112
  data: [...this._oldFrendChannelIdList],
97
113
  id: this.id
98
114
  });
99
115
  this._updataNodeType();
100
116
  }, MessageTimeout);
101
117
  }
102
- /** 绑定事件 */
118
+ /** 绑定事件 | Bind event */
103
119
  _bindBroadcastChannelEvent() {
104
120
  this._broadcastChannel && (this._broadcastChannel.onmessage = (event) => {
105
121
  const { type, targetId } = event.data;
@@ -108,63 +124,63 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
108
124
  }
109
125
  this.emit(type, event.data);
110
126
  });
111
- this.on("Hello world", (data) => {
127
+ this.on("__BCM_INIT__", (data) => {
112
128
  const { id } = data;
113
129
  if (!this._friendChannelIdSet.has(id)) {
114
130
  this._friendChannelIdSet.add(id);
115
131
  }
116
- this.sendToTarget("I can hear you", id);
132
+ this.sendToTarget("__BCM_INIT_REPLY__", id);
117
133
  });
118
- this.on("I can hear you", (data) => {
134
+ this.on("__BCM_INIT_REPLY__", (data) => {
119
135
  const { id } = data;
120
136
  this._addFriend(id);
121
137
  });
122
- this.on("苍天已死,黄天当立", (data) => {
138
+ this.on("__BCM_REQ_BE_MAIN_NODE__", (data) => {
123
139
  const { id } = data;
124
140
  if (id > this.id) {
125
- this.sendToTarget("我是黄天,尔等退下", id);
141
+ this.sendToTarget("__BCM_REQ_BE_MAIN_NODE_REJECT__", id);
126
142
  }
127
143
  });
128
- this.on("苍天在上,受我一拜", (data) => {
144
+ this.on("__BCM_MAIN_NODE_HEARBEAT_REPLY__", (data) => {
129
145
  this._addFriend(data.id);
130
146
  });
131
147
  this._bindNodeEvent();
132
148
  }
133
- /** 监听节点类型切换事件 */
149
+ /** 监听节点类型切换事件 | */
134
150
  _bindNodeEvent() {
135
151
  const onMainNodeHearbeat = (data) => {
136
152
  this._timeoutToBeMainNode();
137
153
  this._catchOldFriend();
138
154
  this._addFriend(data.id);
139
155
  this.send(
140
- "苍天在上,受我一拜"
156
+ "__BCM_MAIN_NODE_HEARBEAT_REPLY__"
141
157
  /* Res_Main_Node_Hearbeat */
142
158
  );
143
159
  };
144
- this.on("node type change", (info) => {
160
+ this.on("__BCM_NODE_TYPE_CHANGE__", (info) => {
145
161
  const { data } = info;
146
162
  this._mainNodeMsgInterval && clearInterval(this._mainNodeMsgInterval);
147
- this._debug && console.log("BC:代理类型切换:", info.data);
163
+ this._debug && console.log("BC:NODE_TYPE_CHANGE:", info.data);
148
164
  if (data === "main") {
149
165
  this._mainNodeMsgInterval = setInterval(() => {
150
166
  this._catchOldFriend();
151
167
  this.send(
152
- "苍天还在,别立黄天"
168
+ "__BCM_MAIN_NODE_HEARBEAT__"
153
169
  /* Main_Node_Hearbeat */
154
170
  );
155
171
  }, MessageTimeout);
156
172
  } else if (data === "normal") {
157
173
  this._timeoutToBeMainNode();
158
174
  }
159
- this.on("苍天还在,别立黄天", onMainNodeHearbeat);
175
+ this.on("__BCM_MAIN_NODE_HEARBEAT__", onMainNodeHearbeat);
160
176
  });
161
177
  }
162
- /** 获取最新的友方列表 */
178
+ /** 获取最新的节点列表 | Get the latest node list */
163
179
  _getNewFriendList() {
164
180
  return [...this._friendChannelIdSet].sort((a, b) => a - b);
165
181
  }
166
182
  /**
167
- * 更新当前节点类型
183
+ * 更新当前节点类型 | Update the current node type
168
184
  */
169
185
  _updataNodeType() {
170
186
  this._mainNodeMsgInterval && clearInterval(this._mainNodeMsgInterval);
@@ -187,21 +203,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
187
203
  }
188
204
  }
189
205
  _timeoutToBeMainNode() {
190
- this._mainNoceMsgTimeoutTimer && clearTimeout(this._mainNoceMsgTimeoutTimer);
191
- this._mainNoceMsgTimeoutTimer = setTimeout(() => {
206
+ this._mainNodeMsgTimeoutTimer && clearTimeout(this._mainNodeMsgTimeoutTimer);
207
+ this._mainNodeMsgTimeoutTimer = setTimeout(() => {
192
208
  this._req_beMainNode();
193
209
  }, MessageTimeout * 3);
194
210
  }
195
211
  /**
196
- * 保持记录的活跃的友方id列表
197
- * 清空正在记录的友方id列表
212
+ * 保存最新的节点列表到_oldFrendChannelIdList,清空_friendChannelIdSet
213
+ * Save the latest node list to _oldFrendChannelIdList and clear _friendChannelIdSet
198
214
  */
199
215
  _catchOldFriend() {
200
216
  const newFriendList = this._getNewFriendList();
201
217
  if (this._oldFrendChannelIdList.join() !== newFriendList.join()) {
202
218
  this._debug && console.log("BC:updateFriendChannelIdList:", newFriendList);
203
- this.emit("friend list update", {
204
- type: "friend list update",
219
+ this.emit("__BCM_FRIEND_LIST_UPDATE__", {
220
+ type: "__BCM_FRIEND_LIST_UPDATE__",
205
221
  data: [...newFriendList],
206
222
  id: this.id
207
223
  });
@@ -216,12 +232,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
216
232
  this._friendChannelIdSet.clear();
217
233
  }
218
234
  /**
219
- * 申请成为主节点
235
+ * 申请成为主节点 | Apply to be a master node
220
236
  */
221
237
  _req_beMainNode() {
222
238
  this._debug && console.log("BC:req_beMainNode");
223
239
  this.send(
224
- "苍天已死,黄天当立"
240
+ "__BCM_REQ_BE_MAIN_NODE__"
225
241
  /* Req_Be_Main_Node */
226
242
  );
227
243
  const timer = setTimeout(() => {
@@ -232,13 +248,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
232
248
  }, MessageTimeout);
233
249
  const handleRes_beMainNode = () => {
234
250
  clearTimeout(timer);
235
- this.off("我是黄天,尔等退下", handleRes_beMainNode);
251
+ this.off("__BCM_REQ_BE_MAIN_NODE_REJECT__", handleRes_beMainNode);
236
252
  };
237
- this.on("我是黄天,尔等退下", handleRes_beMainNode);
253
+ this.on("__BCM_REQ_BE_MAIN_NODE_REJECT__", handleRes_beMainNode);
238
254
  }
239
255
  /**
240
- * 添加友方
241
- * @param id 节点id
256
+ * add node
257
+ * @param id id
242
258
  */
243
259
  _addFriend(id) {
244
260
  if (!this._friendChannelIdSet.has(id)) {
@@ -246,9 +262,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
246
262
  }
247
263
  }
248
264
  /**
249
- * 广播消息
250
- * @param type 消息类型
251
- * @param data 数据
265
+ * 广播消息 | Send Broadcast message
266
+ * @param type 消息类型 | Message type
267
+ * @param data 数据 | data
252
268
  */
253
269
  send(type, data) {
254
270
  var _a;
@@ -259,10 +275,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
259
275
  });
260
276
  }
261
277
  /**
262
- * 给特定id的节点发送消息
263
- * @param type 消息类型
264
- * @param targetId 目标节点id
265
- * @param data 数据
278
+ * 给特定id的节点发送消息 | Send a message to a node with a specific id
279
+ * @param type 消息类型 | Message type
280
+ * @param targetId 目标节点id | Target Node id
281
+ * @param data 数据 | data
266
282
  */
267
283
  sendToTarget(type, targetId, data) {
268
284
  var _a;
@@ -274,9 +290,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
274
290
  });
275
291
  }
276
292
  /**
277
- * 注册事件
278
- * @param { string } event 事件类型
279
- * @param callback 回调
293
+ * 注册事件 | Registering events
294
+ * @param { string } event 事件类型 | Event type
295
+ * @param callback 回调 | callback
280
296
  * @returns void
281
297
  */
282
298
  on(event, callback) {
@@ -291,9 +307,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
291
307
  callbacks.push(callback);
292
308
  }
293
309
  /**
294
- * 注销事件
295
- * @param { string } event 事件类型
296
- * @param callback 事件回调
310
+ * 注销事件 | Remove events
311
+ * @param { string } event 事件类型 | Event type
312
+ * @param callback 事件回调 | callback
297
313
  * @returns
298
314
  */
299
315
  off(event, callback) {
@@ -309,9 +325,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
309
325
  callbacks.splice(index, 1);
310
326
  }
311
327
  /**
312
- * 触发事件
313
- * @param { string } event 事件类型
314
- * @param data 数据
328
+ * 触发事件 | Triggering events
329
+ * @param { string } event 事件类型 | Event type
330
+ * @param data 数据 | data
315
331
  */
316
332
  emit(event, data) {
317
333
  const callbacks = this._eventMap.get(event) || [];
@@ -320,7 +336,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
320
336
  });
321
337
  }
322
338
  /**
323
- * 销毁
339
+ * 销毁 | destroy
324
340
  */
325
341
  destroy() {
326
342
  var _a;
@@ -334,8 +350,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
334
350
  this._nodeType = void 0;
335
351
  this._mainNodeMsgInterval && clearInterval(this._mainNodeMsgInterval);
336
352
  this._mainNodeMsgInterval = null;
337
- this._mainNoceMsgTimeoutTimer && clearInterval(this._mainNoceMsgTimeoutTimer);
338
- this._mainNoceMsgTimeoutTimer = null;
353
+ this._mainNodeMsgTimeoutTimer && clearInterval(this._mainNodeMsgTimeoutTimer);
354
+ this._mainNodeMsgTimeoutTimer = null;
339
355
  this._debug && console.log("BC:destroy");
340
356
  }
341
357
  }
@@ -1,61 +1,71 @@
1
- /** 事件数据类型 */
1
+ /** 事件数据类型 | Event Datatypes */
2
2
  export type BcConnectSendMessageType = {
3
- /** 事件类型 */
3
+ /** 事件类型 | type */
4
4
  type: string;
5
- /** 数据 */
5
+ /** 数据 | data */
6
6
  data: any;
7
- /** 发送事件的实例id */
7
+ /** 发送事件的实例id | BroadcastChannelManager instance id */
8
8
  id: number;
9
- /** 消息是发送给目标实例id */
9
+ /** 此消息的目标实例id | The target instance id for this message */
10
10
  targetId?: number;
11
11
  };
12
- /** 事件类型 */
12
+ /** 事件类型 | Event types */
13
13
  export declare enum BcConnectEventTypeEnum {
14
- /** 初始广播 */
15
- Broadcast = "Hello world",
16
- /** 回复初始广播 */
17
- Broadcast_Reply = "I can hear you",
18
- /** 主节点心跳 */
19
- Main_Node_Hearbeat = "\u82CD\u5929\u8FD8\u5728\uFF0C\u522B\u7ACB\u9EC4\u5929",
20
- /** 回复主节点心跳 */
21
- Res_Main_Node_Hearbeat = "\u82CD\u5929\u5728\u4E0A\uFF0C\u53D7\u6211\u4E00\u62DC",
22
- /** 长时间未收到主节点心跳,我想当主节点,你们同意吗 */
23
- Req_Be_Main_Node = "\u82CD\u5929\u5DF2\u6B7B\uFF0C\u9EC4\u5929\u5F53\u7ACB",
24
- /** 排资论辈,我应是主节点,不同意 */
25
- Res_Be_Main_Node = "\u6211\u662F\u9EC4\u5929\uFF0C\u5C14\u7B49\u9000\u4E0B",
26
- /** 当前BC节点类型更改 */
27
- Node_Type_Change = "node type change",
28
- /** 其他标签页BC节点id列表更新 */
29
- Friend_List_Update = "friend list update"
14
+ /** 初始广播 | Initial broadcast */
15
+ Broadcast = "__BCM_INIT__",
16
+ /** 回复初始广播 | Reply to initial broadcast */
17
+ Broadcast_Reply = "__BCM_INIT_REPLY__",
18
+ /** 主节点心跳 | Master node heartbeat */
19
+ Main_Node_Hearbeat = "__BCM_MAIN_NODE_HEARBEAT__",
20
+ /** 回复主节点心跳 | Reply to the master node heartbeat */
21
+ Res_Main_Node_Hearbeat = "__BCM_MAIN_NODE_HEARBEAT_REPLY__",
22
+ /**
23
+ * 长时间未收到主节点心跳,申请成为主节点
24
+ * It has not received the heartbeat of the master node for a long time.
25
+ * Apply to become the master node
26
+ */
27
+ Req_Be_Main_Node = "__BCM_REQ_BE_MAIN_NODE__",
28
+ /** 拒绝其他节点成为主节点 | Reject other nodes as master nodes */
29
+ Res_Be_Main_Node = "__BCM_REQ_BE_MAIN_NODE_REJECT__",
30
+ /** 当前节点类型更改 | The current node type has changed */
31
+ Node_Type_Change = "__BCM_NODE_TYPE_CHANGE__",
32
+ /** 其他标签页BC节点id列表更新 | Other TAB node id list updated */
33
+ Friend_List_Update = "__BCM_FRIEND_LIST_UPDATE__"
30
34
  }
31
- /** 当前webview BroadcastChannel节点类型 */
35
+ /** BroadcastChannel节点类型 | BroadcastChannel node type */
32
36
  export declare enum BcConnectNodeTypeEnum {
33
37
  Main = "main",
34
38
  Normal = "normal"
35
39
  }
36
40
  /**
37
41
  * 使用BroadcastChannel与其他标签页进行通信
42
+ * Use BroadcastChannel to communicate with other tabs
38
43
  */
39
44
  export declare class BroadcastChannelManager {
40
- /** 通道名称 */
45
+ /** 通道名称 | Channel name */
41
46
  private _bcName;
42
- /** BroadcastChannel实例 */
47
+ /** BroadcastChannel instance */
43
48
  private _broadcastChannel;
44
- /** 事件map */
49
+ /** Event map */
45
50
  private _eventMap;
46
- /** 主节点发送心跳的interval */
51
+ /** 主节点发送心跳的interval | The interval at which the master node sends the heartbeat */
47
52
  private _mainNodeMsgInterval;
48
- /** 认为主节点掉线的timeout */
49
- private _mainNoceMsgTimeoutTimer;
50
- /** 当前实例id */
53
+ /** 认为主节点掉线的timeout | timeout to consider the primary node to be offline */
54
+ private _mainNodeMsgTimeoutTimer;
55
+ /** 更新友方列表的timeout | Update the timeout of the friend list */
56
+ private _updateFriendListTimer;
57
+ /** 当前实例id | Current instance id */
51
58
  id: number;
52
- /** 记录的友方id数组 */
59
+ /** 其他广播通道id列表 | List of other broadcast channel ids */
53
60
  private _oldFrendChannelIdList;
54
- /** 正在更新的右方id数组 */
61
+ /** 正在更新的id数组 | The id array being updated */
55
62
  private _friendChannelIdSet;
56
- /** 当前节点类型 */
63
+ /** 当前节点类型 | Current node type */
57
64
  private _nodeType;
58
- /** 是否开启调试模式,会在控制台打印相关信息 */
65
+ /**
66
+ * 是否开启调试模式,会在控制台打印相关信息
67
+ * If debug mode is enabled, it will print information to the console
68
+ */
59
69
  private _debug;
60
70
  constructor(name: string, debug?: boolean);
61
71
  get nodeType(): BcConnectNodeTypeEnum | undefined;
@@ -63,73 +73,73 @@ export declare class BroadcastChannelManager {
63
73
  connect(): void;
64
74
  close(): void;
65
75
  /**
66
- * 切换节点类型
76
+ * 切换节点类型 | Switching node type
67
77
  * @param {BcConnectNodeTypeEnum} type
68
78
  * @returns
69
79
  */
70
80
  private _setNodeType;
71
- /** 更新友方列表 */
81
+ /** 更新广播id列表 | Update the list of broadcast ids */
72
82
  private _updateFriendList;
73
- /** 绑定事件 */
83
+ /** 绑定事件 | Bind event */
74
84
  private _bindBroadcastChannelEvent;
75
- /** 监听节点类型切换事件 */
85
+ /** 监听节点类型切换事件 | */
76
86
  private _bindNodeEvent;
77
- /** 获取最新的友方列表 */
87
+ /** 获取最新的节点列表 | Get the latest node list */
78
88
  private _getNewFriendList;
79
89
  /**
80
- * 更新当前节点类型
90
+ * 更新当前节点类型 | Update the current node type
81
91
  */
82
92
  private _updataNodeType;
83
93
  private _timeoutToBeMainNode;
84
94
  /**
85
- * 保持记录的活跃的友方id列表
86
- * 清空正在记录的友方id列表
95
+ * 保存最新的节点列表到_oldFrendChannelIdList,清空_friendChannelIdSet
96
+ * Save the latest node list to _oldFrendChannelIdList and clear _friendChannelIdSet
87
97
  */
88
98
  private _catchOldFriend;
89
99
  /**
90
- * 申请成为主节点
100
+ * 申请成为主节点 | Apply to be a master node
91
101
  */
92
102
  private _req_beMainNode;
93
103
  /**
94
- * 添加友方
95
- * @param id 节点id
104
+ * add node
105
+ * @param id id
96
106
  */
97
107
  _addFriend(id: number): void;
98
108
  /**
99
- * 广播消息
100
- * @param type 消息类型
101
- * @param data 数据
109
+ * 广播消息 | Send Broadcast message
110
+ * @param type 消息类型 | Message type
111
+ * @param data 数据 | data
102
112
  */
103
113
  send(type: string, data?: any): void;
104
114
  /**
105
- * 给特定id的节点发送消息
106
- * @param type 消息类型
107
- * @param targetId 目标节点id
108
- * @param data 数据
115
+ * 给特定id的节点发送消息 | Send a message to a node with a specific id
116
+ * @param type 消息类型 | Message type
117
+ * @param targetId 目标节点id | Target Node id
118
+ * @param data 数据 | data
109
119
  */
110
120
  sendToTarget(type: string, targetId: number, data?: any): void;
111
121
  /**
112
- * 注册事件
113
- * @param { string } event 事件类型
114
- * @param callback 回调
122
+ * 注册事件 | Registering events
123
+ * @param { string } event 事件类型 | Event type
124
+ * @param callback 回调 | callback
115
125
  * @returns void
116
126
  */
117
127
  on(event: string, callback: (_: BcConnectSendMessageType) => void): void;
118
128
  /**
119
- * 注销事件
120
- * @param { string } event 事件类型
121
- * @param callback 事件回调
129
+ * 注销事件 | Remove events
130
+ * @param { string } event 事件类型 | Event type
131
+ * @param callback 事件回调 | callback
122
132
  * @returns
123
133
  */
124
134
  off(event: string, callback?: (_: BcConnectSendMessageType) => void): void;
125
135
  /**
126
- * 触发事件
127
- * @param { string } event 事件类型
128
- * @param data 数据
136
+ * 触发事件 | Triggering events
137
+ * @param { string } event 事件类型 | Event type
138
+ * @param data 数据 | data
129
139
  */
130
140
  emit(event: string, data: BcConnectSendMessageType): void;
131
141
  /**
132
- * 销毁
142
+ * 销毁 | destroy
133
143
  */
134
144
  destroy(): void;
135
145
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@havue/bc-connect",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Javascript class for Broadcast channel connect",
5
5
  "keywords": [
6
6
  "havue",