@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
  }
@@ -7682,29 +7698,32 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7682
7698
  // private divID = ''
7683
7699
  constructor(options = {}) {
7684
7700
  super();
7685
- /** video元素 */
7701
+ /** video元素 | videw element */
7686
7702
  __publicField(this, "_videoEl");
7687
- /** mp4box 实例 */
7703
+ /** mp4box file */
7688
7704
  __publicField(this, "_mp4box", MP4Box.createFile());
7689
- /** mp4box onFragment获取的视频数据buffer数组 */
7705
+ /**
7706
+ * mp4box onFragment获取的视频数据buffer数组
7707
+ * mp4box onFragment gets a buffer array of audio and video data
7708
+ */
7690
7709
  __publicField(this, "_audioBufsQueue", []);
7691
7710
  __publicField(this, "_videoBufsQueue", []);
7692
- /** MediaSource 实例 */
7711
+ /** MediaSource instance */
7693
7712
  __publicField(this, "_mediaSource");
7694
- /** SourceBuffer 实例 */
7713
+ /** SourceBuffer instance */
7695
7714
  __publicField(this, "_audioSourceBuffer");
7696
7715
  __publicField(this, "_videoSourceBuffer");
7697
7716
  __publicField(this, "_audioTrackId");
7698
7717
  __publicField(this, "_videoTrackId");
7699
- /** 用于MediaSource的mimeType */
7718
+ /** 用于MediaSource的mimeType | mime type of the video */
7700
7719
  __publicField(this, "_mimeType", "");
7701
7720
  __publicField(this, "_audioMimeType", "");
7702
7721
  __publicField(this, "_videoMimeType", "");
7703
- /** 是否暂停播放 */
7722
+ /** 是否暂停播放 | Pause or not */
7704
7723
  __publicField(this, "_paused", false);
7705
7724
  __publicField(this, "_options");
7706
7725
  __publicField(this, "_cacheAnimationID");
7707
- /** fmp4初始化片段是否已经添加 */
7726
+ /** fmp4初始化片段是否已经添加 | fmp4 Initializes whether the fragment has been added */
7708
7727
  __publicField(this, "_isAudioInitSegmentAdded", false);
7709
7728
  __publicField(this, "_isVideoInitSegmentAdded", false);
7710
7729
  __publicField(this, "_offset", 0);
@@ -7737,14 +7756,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7737
7756
  get videoEl() {
7738
7757
  return this._videoEl;
7739
7758
  }
7740
- /** 更新实例配置 */
7759
+ /** 更新实例配置 | Update configuration */
7741
7760
  updateOptions(option = {}) {
7742
7761
  Object.assign(this._options, {
7743
7762
  ...option
7744
7763
  });
7745
7764
  }
7746
7765
  /**
7747
- * 添加视频流buffer数据
7766
+ * 添加视频流buffer数据 | Add video stream buffer data
7748
7767
  * @param buf
7749
7768
  */
7750
7769
  appendMediaBuffer(bufs) {
@@ -7759,8 +7778,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7759
7778
  return;
7760
7779
  }
7761
7780
  /**
7762
- * mp4box解析完成
7763
- * @param info mp4box解析信息
7781
+ * mp4box解析完成 | handle Mp4box onReady
7782
+ * @param info mp4box解析信息 | mp4box parses the information
7764
7783
  */
7765
7784
  _onMp4boxReady(info) {
7766
7785
  console.log("onMp4boxReady", info);
@@ -7837,7 +7856,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7837
7856
  this._cache(isVideo);
7838
7857
  }
7839
7858
  /**
7840
- * 初始化视频元素
7859
+ * 初始化视频元素 | Initialize the video element
7841
7860
  */
7842
7861
  _setupVideo() {
7843
7862
  this._videoEl = document.createElement("video");
@@ -7893,13 +7912,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7893
7912
  }
7894
7913
  /**
7895
7914
  * 是否支持Media Source Extention
7915
+ * whether Media Source Extention is supported
7896
7916
  * @returns boolean
7897
7917
  */
7898
7918
  isSupportMSE() {
7899
7919
  return "MediaSource" in window;
7900
7920
  }
7901
7921
  /**
7902
- * 初始化MSE
7922
+ * 初始化MSE | Init MSE
7903
7923
  * @returns
7904
7924
  */
7905
7925
  _setupMSE() {
@@ -7976,6 +7996,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7976
7996
  }
7977
7997
  /**
7978
7998
  * 将_bufsQueue中的数据添加到SourceBuffer中
7999
+ * Add the data from _bufsQueue to the SourceBuffer
7979
8000
  * @returns
7980
8001
  */
7981
8002
  _cache(isVideo = false) {
@@ -8019,6 +8040,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8019
8040
  }
8020
8041
  /**
8021
8042
  * 刷新播放时间为最新
8043
+ * Refresh the playback time to the latest
8022
8044
  */
8023
8045
  refresh() {
8024
8046
  if (this._videoEl && this._videoEl.buffered.length) {
@@ -8026,7 +8048,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8026
8048
  this._videoEl.currentTime = end;
8027
8049
  }
8028
8050
  }
8029
- /** 重置解析的视频mime type */
8051
+ /** 重置解析的视频mime type | Reset the parsed video mime type */
8030
8052
  resetMimeType() {
8031
8053
  this.destroyMp4box();
8032
8054
  this.destroyMediaSource();
@@ -8077,7 +8099,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8077
8099
  this._mp4box = null;
8078
8100
  }
8079
8101
  /**
8080
- * 销毁
8102
+ * 销毁 | Destroy
8081
8103
  */
8082
8104
  destroy() {
8083
8105
  if (this._videoEl) {
@@ -8128,7 +8150,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8128
8150
  this._ctx2d.fillRect(0, 0, this._canvas.width, this._canvas.height);
8129
8151
  }
8130
8152
  /**
8131
- * 初始化 webgl
8153
+ * 初始化 webgl | Initialize webgl
8132
8154
  */
8133
8155
  initGl() {
8134
8156
  if (!this._canvas) return;
@@ -8170,7 +8192,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8170
8192
  this._glReady = true;
8171
8193
  }
8172
8194
  /**
8173
- * 创建着色器源码
8195
+ * 创建着色器源码 | Create shader source code
8174
8196
  */
8175
8197
  createShaderSource(gl, type) {
8176
8198
  const vertexShaderSource = `
@@ -8197,7 +8219,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8197
8219
  }
8198
8220
  }
8199
8221
  /**
8200
- * 创建着色器
8222
+ * 创建着色器 | Create shaders
8201
8223
  */
8202
8224
  createShader(gl, type, source) {
8203
8225
  const shader = gl.createShader(type);
@@ -8215,7 +8237,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8215
8237
  return shader;
8216
8238
  }
8217
8239
  /**
8218
- * 创建着色器程序
8240
+ * 创建着色器程序 | Create program
8219
8241
  */
8220
8242
  createProgram(gl, vertexShader, fragmentShader) {
8221
8243
  const program = gl.createProgram();
@@ -8234,7 +8256,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8234
8256
  return program;
8235
8257
  }
8236
8258
  /**
8237
- * 绘制
8259
+ * 绘制 | draw
8238
8260
  */
8239
8261
  draw(video) {
8240
8262
  if (this._useGl) {
@@ -8273,7 +8295,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8273
8295
  }
8274
8296
  }
8275
8297
  /**
8276
- * 销毁
8298
+ * 销毁 | Destroy
8277
8299
  */
8278
8300
  destroy() {
8279
8301
  this._canvas = null;
@@ -8309,7 +8331,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8309
8331
  class WsVideoManager extends EventBus {
8310
8332
  constructor(options) {
8311
8333
  super();
8312
- /** socket连接 渲染相关对应信息 */
8334
+ /** socket相关信息map | map of socket information */
8313
8335
  __publicField(this, "_wsInfoMap", /* @__PURE__ */ new Map());
8314
8336
  __publicField(this, "_option", DEFAULT_OPTIONS);
8315
8337
  __publicField(this, "_reqAnimationID", null);
@@ -8342,8 +8364,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8342
8364
  render();
8343
8365
  }
8344
8366
  /**
8345
- * 添加socket实例
8346
- * @param url socket地址
8367
+ * 添加socket连接 | Adding a socket connection
8368
+ * @param url socket url
8347
8369
  * @returns
8348
8370
  */
8349
8371
  _addSocket(url, renderOptions) {
@@ -8372,9 +8394,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8372
8394
  socket.open();
8373
8395
  }
8374
8396
  /**
8375
- * 绑定render事件
8376
- * @param url 连接地址
8377
- * @param render Render实例
8397
+ * 绑定render事件 | Binding the render event
8398
+ * @param url 连接地址 | websocket url
8399
+ * @param render Render instance
8378
8400
  */
8379
8401
  _bindRenderEvent(url, render) {
8380
8402
  render.on(RenderEventsEnum.AUDIO_STATE_CHANGE, (state) => {
@@ -8388,8 +8410,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8388
8410
  });
8389
8411
  }
8390
8412
  /**
8391
- * 销毁socket实例
8392
- * @param url socket地址
8413
+ * Destroying the socket connect
8414
+ * @param url socket url
8393
8415
  */
8394
8416
  _removeSocket(url) {
8395
8417
  const wsInfo = this._wsInfoMap.get(url);
@@ -8403,9 +8425,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8403
8425
  }
8404
8426
  }
8405
8427
  /**
8406
- * 绑定socket事件
8407
- * @param url 连接地址
8408
- * @param socket WebSocketLoader实例
8428
+ * 绑定socket事件 | Binding socket events
8429
+ * @param url websocket url
8430
+ * @param socket WebSocketLoader instance
8409
8431
  */
8410
8432
  _bindSocketEvent(socket, render, url) {
8411
8433
  socket.on("close", () => {
@@ -8435,8 +8457,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8435
8457
  }
8436
8458
  }
8437
8459
  /**
8438
- * url对应的 socket实例是否已存在
8439
- * @param url socket地址
8460
+ * url对应的 socket实例是否已存在 | Whether the socket instance for the url already exists
8461
+ * @param url websocket url
8440
8462
  * @returns boolean
8441
8463
  */
8442
8464
  _isSocketExist(url) {
@@ -8444,8 +8466,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8444
8466
  }
8445
8467
  /**
8446
8468
  * 添加url对应socket,以及需要绘制的canvas元素
8447
- * @param canvas canvas元素
8448
- * @param url socket url地址
8469
+ * Add the socket for the url and the canvas element to draw
8470
+ * @param canvas canvas
8471
+ * @param url websocket url
8449
8472
  */
8450
8473
  addCanvas(canvas, url, renderOptions) {
8451
8474
  this._addSocket(url, renderOptions);
@@ -8464,8 +8487,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8464
8487
  }
8465
8488
  }
8466
8489
  /**
8467
- * 初始化canvas背景
8468
- * @param canvas canvas元素
8490
+ * 初始化canvas背景 | Initialize the canvas background
8491
+ * @param canvas canvas
8469
8492
  * @returns
8470
8493
  */
8471
8494
  // private _setupCanvas(canvas: HTMLCanvasElement) {
@@ -8477,8 +8500,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8477
8500
  // ctx.fillRect(0, 0, canvas.width, canvas.height)
8478
8501
  // }
8479
8502
  /**
8480
- * 删除canvas元素
8481
- * @param canvas canvas元素
8503
+ * 删除canvas元素 || Remove the canvas element
8504
+ * @param canvas canvas
8482
8505
  */
8483
8506
  removeCanvas(canvas) {
8484
8507
  const entries = this._wsInfoMap.entries();
@@ -8497,8 +8520,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8497
8520
  });
8498
8521
  }
8499
8522
  /**
8500
- * 返回canvas是否已经添加过
8501
- * @param canvas canvas元素
8523
+ * 获取canvas是否已经添加过 | Gets whether the canvas has already been added
8524
+ * @param canvas canvas
8502
8525
  * @returns boolean
8503
8526
  */
8504
8527
  isCanvasExist(canvas) {
@@ -8507,13 +8530,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8507
8530
  return info.canvasMap.has(canvas);
8508
8531
  });
8509
8532
  }
8510
- /** 设置全部render静音状态 */
8533
+ /** 设置全部render静音状态 | Mute all render */
8511
8534
  setAllVideoMutedState(muted) {
8512
8535
  this._wsInfoMap.forEach((wsInfo) => {
8513
8536
  wsInfo.render.muted = muted;
8514
8537
  });
8515
8538
  }
8516
- /** 更新单个render实例的配置 */
8539
+ /** 更新单个render实例的配置 | Update the configuration of a single render instance */
8517
8540
  updateRenderOptions(url, options) {
8518
8541
  if (options) {
8519
8542
  const wsInfo = this._wsInfoMap.get(url);
@@ -8521,9 +8544,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8521
8544
  }
8522
8545
  }
8523
8546
  /**
8524
- * 设置单个render静音状态
8547
+ * 设置单个render静音状态 | Set a single render to be silent
8525
8548
  * @param url
8526
- * @param muted boolean 是否静音
8549
+ * @param {boolean} muted 是否静音 | Muted or not
8527
8550
  */
8528
8551
  setOneMutedState(url, muted) {
8529
8552
  const wsInfo = this._wsInfoMap.get(url);
@@ -8534,7 +8557,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8534
8557
  }
8535
8558
  /**
8536
8559
  * 获取url对应render video元素是否静音
8537
- * @param url socket地址
8560
+ * Gets whether the render video element of the url is muted
8561
+ * @param url websocket url
8538
8562
  */
8539
8563
  getOneMutedState(url) {
8540
8564
  const wsInfo = this._wsInfoMap.get(url);
@@ -8545,7 +8569,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8545
8569
  }
8546
8570
  /**
8547
8571
  * 单个解除静音,其他未静音的变成静音,只播放一个
8548
- * @param url socket地址
8572
+ * Unmute a single video and mute all other videos
8573
+ * @param url websocket url
8549
8574
  */
8550
8575
  playOneAudio(url) {
8551
8576
  this.setAllVideoMutedState(true);
@@ -8553,6 +8578,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8553
8578
  }
8554
8579
  /**
8555
8580
  * 设置单个render是否继续处理ws数据
8581
+ * Sets whether a single render continues to process ws data
8556
8582
  * @param url
8557
8583
  */
8558
8584
  setOneVideoPausedState(url, paused) {
@@ -8562,15 +8588,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8562
8588
  }
8563
8589
  wsInfo.render.paused = paused;
8564
8590
  }
8565
- /** 设置全部render是否继续处理ws数据 */
8591
+ /** 设置全部render是否继续处理ws数据 | Sets whether all render continues to process ws data */
8566
8592
  setAllVideoPausedState(paused) {
8567
8593
  this._wsInfoMap.forEach((wsInfo) => {
8568
8594
  wsInfo.render.paused = paused;
8569
8595
  });
8570
8596
  }
8571
8597
  /**
8572
- * 获取url对应render video元素是否继续播放
8573
- * @param url socket地址
8598
+ * 获取url对应render video元素的播放状态
8599
+ * Get the playback status of the render video element corresponding to the url
8600
+ * @param url websocket url
8574
8601
  */
8575
8602
  getOneVideoPausedState(url) {
8576
8603
  const wsInfo = this._wsInfoMap.get(url);
@@ -8581,7 +8608,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8581
8608
  }
8582
8609
  /**
8583
8610
  * 单个视频继续播放,其他暂停处理数据
8584
- * @param url socket地址
8611
+ * A single video continues to play while others pause to process data
8612
+ * @param url websocket url
8585
8613
  */
8586
8614
  playOneVideo(url) {
8587
8615
  this.setAllVideoPausedState(true);
@@ -8589,6 +8617,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8589
8617
  }
8590
8618
  /**
8591
8619
  * 刷新socket,以及播放时间
8620
+ * Refresh the socket, and the playback time
8592
8621
  */
8593
8622
  refresh(url) {
8594
8623
  if (url) {
@@ -8609,7 +8638,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8609
8638
  }
8610
8639
  }
8611
8640
  /**
8612
- * 销毁
8641
+ * 销毁 | Destroy
8613
8642
  */
8614
8643
  destroy() {
8615
8644
  this._wsInfoMap.forEach((wsInfo) => {