@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
@@ -7315,29 +7315,32 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7315
7315
  // private divID = ''
7316
7316
  constructor(options = {}) {
7317
7317
  super();
7318
- /** video元素 */
7318
+ /** video元素 | videw element */
7319
7319
  __publicField(this, "_videoEl");
7320
- /** mp4box 实例 */
7320
+ /** mp4box file */
7321
7321
  __publicField(this, "_mp4box", MP4Box.createFile());
7322
- /** mp4box onFragment获取的视频数据buffer数组 */
7322
+ /**
7323
+ * mp4box onFragment获取的视频数据buffer数组
7324
+ * mp4box onFragment gets a buffer array of audio and video data
7325
+ */
7323
7326
  __publicField(this, "_audioBufsQueue", []);
7324
7327
  __publicField(this, "_videoBufsQueue", []);
7325
- /** MediaSource 实例 */
7328
+ /** MediaSource instance */
7326
7329
  __publicField(this, "_mediaSource");
7327
- /** SourceBuffer 实例 */
7330
+ /** SourceBuffer instance */
7328
7331
  __publicField(this, "_audioSourceBuffer");
7329
7332
  __publicField(this, "_videoSourceBuffer");
7330
7333
  __publicField(this, "_audioTrackId");
7331
7334
  __publicField(this, "_videoTrackId");
7332
- /** 用于MediaSource的mimeType */
7335
+ /** 用于MediaSource的mimeType | mime type of the video */
7333
7336
  __publicField(this, "_mimeType", "");
7334
7337
  __publicField(this, "_audioMimeType", "");
7335
7338
  __publicField(this, "_videoMimeType", "");
7336
- /** 是否暂停播放 */
7339
+ /** 是否暂停播放 | Pause or not */
7337
7340
  __publicField(this, "_paused", false);
7338
7341
  __publicField(this, "_options");
7339
7342
  __publicField(this, "_cacheAnimationID");
7340
- /** fmp4初始化片段是否已经添加 */
7343
+ /** fmp4初始化片段是否已经添加 | fmp4 Initializes whether the fragment has been added */
7341
7344
  __publicField(this, "_isAudioInitSegmentAdded", false);
7342
7345
  __publicField(this, "_isVideoInitSegmentAdded", false);
7343
7346
  __publicField(this, "_offset", 0);
@@ -7370,14 +7373,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7370
7373
  get videoEl() {
7371
7374
  return this._videoEl;
7372
7375
  }
7373
- /** 更新实例配置 */
7376
+ /** 更新实例配置 | Update configuration */
7374
7377
  updateOptions(option = {}) {
7375
7378
  Object.assign(this._options, {
7376
7379
  ...option
7377
7380
  });
7378
7381
  }
7379
7382
  /**
7380
- * 添加视频流buffer数据
7383
+ * 添加视频流buffer数据 | Add video stream buffer data
7381
7384
  * @param buf
7382
7385
  */
7383
7386
  appendMediaBuffer(bufs) {
@@ -7392,8 +7395,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7392
7395
  return;
7393
7396
  }
7394
7397
  /**
7395
- * mp4box解析完成
7396
- * @param info mp4box解析信息
7398
+ * mp4box解析完成 | handle Mp4box onReady
7399
+ * @param info mp4box解析信息 | mp4box parses the information
7397
7400
  */
7398
7401
  _onMp4boxReady(info) {
7399
7402
  console.log("onMp4boxReady", info);
@@ -7470,7 +7473,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7470
7473
  this._cache(isVideo);
7471
7474
  }
7472
7475
  /**
7473
- * 初始化视频元素
7476
+ * 初始化视频元素 | Initialize the video element
7474
7477
  */
7475
7478
  _setupVideo() {
7476
7479
  this._videoEl = document.createElement("video");
@@ -7526,13 +7529,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7526
7529
  }
7527
7530
  /**
7528
7531
  * 是否支持Media Source Extention
7532
+ * whether Media Source Extention is supported
7529
7533
  * @returns boolean
7530
7534
  */
7531
7535
  isSupportMSE() {
7532
7536
  return "MediaSource" in window;
7533
7537
  }
7534
7538
  /**
7535
- * 初始化MSE
7539
+ * 初始化MSE | Init MSE
7536
7540
  * @returns
7537
7541
  */
7538
7542
  _setupMSE() {
@@ -7609,6 +7613,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7609
7613
  }
7610
7614
  /**
7611
7615
  * 将_bufsQueue中的数据添加到SourceBuffer中
7616
+ * Add the data from _bufsQueue to the SourceBuffer
7612
7617
  * @returns
7613
7618
  */
7614
7619
  _cache(isVideo = false) {
@@ -7652,6 +7657,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7652
7657
  }
7653
7658
  /**
7654
7659
  * 刷新播放时间为最新
7660
+ * Refresh the playback time to the latest
7655
7661
  */
7656
7662
  refresh() {
7657
7663
  if (this._videoEl && this._videoEl.buffered.length) {
@@ -7659,7 +7665,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7659
7665
  this._videoEl.currentTime = end;
7660
7666
  }
7661
7667
  }
7662
- /** 重置解析的视频mime type */
7668
+ /** 重置解析的视频mime type | Reset the parsed video mime type */
7663
7669
  resetMimeType() {
7664
7670
  this.destroyMp4box();
7665
7671
  this.destroyMediaSource();
@@ -7710,7 +7716,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7710
7716
  this._mp4box = null;
7711
7717
  }
7712
7718
  /**
7713
- * 销毁
7719
+ * 销毁 | Destroy
7714
7720
  */
7715
7721
  destroy() {
7716
7722
  if (this._videoEl) {
@@ -7761,7 +7767,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7761
7767
  this._ctx2d.fillRect(0, 0, this._canvas.width, this._canvas.height);
7762
7768
  }
7763
7769
  /**
7764
- * 初始化 webgl
7770
+ * 初始化 webgl | Initialize webgl
7765
7771
  */
7766
7772
  initGl() {
7767
7773
  if (!this._canvas) return;
@@ -7803,7 +7809,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7803
7809
  this._glReady = true;
7804
7810
  }
7805
7811
  /**
7806
- * 创建着色器源码
7812
+ * 创建着色器源码 | Create shader source code
7807
7813
  */
7808
7814
  createShaderSource(gl, type) {
7809
7815
  const vertexShaderSource = `
@@ -7830,7 +7836,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7830
7836
  }
7831
7837
  }
7832
7838
  /**
7833
- * 创建着色器
7839
+ * 创建着色器 | Create shaders
7834
7840
  */
7835
7841
  createShader(gl, type, source) {
7836
7842
  const shader = gl.createShader(type);
@@ -7848,7 +7854,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7848
7854
  return shader;
7849
7855
  }
7850
7856
  /**
7851
- * 创建着色器程序
7857
+ * 创建着色器程序 | Create program
7852
7858
  */
7853
7859
  createProgram(gl, vertexShader, fragmentShader) {
7854
7860
  const program = gl.createProgram();
@@ -7867,7 +7873,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7867
7873
  return program;
7868
7874
  }
7869
7875
  /**
7870
- * 绘制
7876
+ * 绘制 | draw
7871
7877
  */
7872
7878
  draw(video) {
7873
7879
  if (this._useGl) {
@@ -7906,7 +7912,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7906
7912
  }
7907
7913
  }
7908
7914
  /**
7909
- * 销毁
7915
+ * 销毁 | Destroy
7910
7916
  */
7911
7917
  destroy() {
7912
7918
  this._canvas = null;
@@ -7942,7 +7948,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7942
7948
  class WsVideoManager extends shared.EventBus {
7943
7949
  constructor(options) {
7944
7950
  super();
7945
- /** socket连接 渲染相关对应信息 */
7951
+ /** socket相关信息map | map of socket information */
7946
7952
  __publicField(this, "_wsInfoMap", /* @__PURE__ */ new Map());
7947
7953
  __publicField(this, "_option", DEFAULT_OPTIONS);
7948
7954
  __publicField(this, "_reqAnimationID", null);
@@ -7975,8 +7981,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7975
7981
  render();
7976
7982
  }
7977
7983
  /**
7978
- * 添加socket实例
7979
- * @param url socket地址
7984
+ * 添加socket连接 | Adding a socket connection
7985
+ * @param url socket url
7980
7986
  * @returns
7981
7987
  */
7982
7988
  _addSocket(url, renderOptions) {
@@ -8005,9 +8011,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8005
8011
  socket.open();
8006
8012
  }
8007
8013
  /**
8008
- * 绑定render事件
8009
- * @param url 连接地址
8010
- * @param render Render实例
8014
+ * 绑定render事件 | Binding the render event
8015
+ * @param url 连接地址 | websocket url
8016
+ * @param render Render instance
8011
8017
  */
8012
8018
  _bindRenderEvent(url, render) {
8013
8019
  render.on(RenderEventsEnum.AUDIO_STATE_CHANGE, (state) => {
@@ -8021,8 +8027,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8021
8027
  });
8022
8028
  }
8023
8029
  /**
8024
- * 销毁socket实例
8025
- * @param url socket地址
8030
+ * Destroying the socket connect
8031
+ * @param url socket url
8026
8032
  */
8027
8033
  _removeSocket(url) {
8028
8034
  const wsInfo = this._wsInfoMap.get(url);
@@ -8036,9 +8042,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8036
8042
  }
8037
8043
  }
8038
8044
  /**
8039
- * 绑定socket事件
8040
- * @param url 连接地址
8041
- * @param socket WebSocketLoader实例
8045
+ * 绑定socket事件 | Binding socket events
8046
+ * @param url websocket url
8047
+ * @param socket WebSocketLoader instance
8042
8048
  */
8043
8049
  _bindSocketEvent(socket, render, url) {
8044
8050
  socket.on("close", () => {
@@ -8068,8 +8074,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8068
8074
  }
8069
8075
  }
8070
8076
  /**
8071
- * url对应的 socket实例是否已存在
8072
- * @param url socket地址
8077
+ * url对应的 socket实例是否已存在 | Whether the socket instance for the url already exists
8078
+ * @param url websocket url
8073
8079
  * @returns boolean
8074
8080
  */
8075
8081
  _isSocketExist(url) {
@@ -8077,8 +8083,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8077
8083
  }
8078
8084
  /**
8079
8085
  * 添加url对应socket,以及需要绘制的canvas元素
8080
- * @param canvas canvas元素
8081
- * @param url socket url地址
8086
+ * Add the socket for the url and the canvas element to draw
8087
+ * @param canvas canvas
8088
+ * @param url websocket url
8082
8089
  */
8083
8090
  addCanvas(canvas, url, renderOptions) {
8084
8091
  this._addSocket(url, renderOptions);
@@ -8097,8 +8104,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8097
8104
  }
8098
8105
  }
8099
8106
  /**
8100
- * 初始化canvas背景
8101
- * @param canvas canvas元素
8107
+ * 初始化canvas背景 | Initialize the canvas background
8108
+ * @param canvas canvas
8102
8109
  * @returns
8103
8110
  */
8104
8111
  // private _setupCanvas(canvas: HTMLCanvasElement) {
@@ -8110,8 +8117,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8110
8117
  // ctx.fillRect(0, 0, canvas.width, canvas.height)
8111
8118
  // }
8112
8119
  /**
8113
- * 删除canvas元素
8114
- * @param canvas canvas元素
8120
+ * 删除canvas元素 || Remove the canvas element
8121
+ * @param canvas canvas
8115
8122
  */
8116
8123
  removeCanvas(canvas) {
8117
8124
  const entries = this._wsInfoMap.entries();
@@ -8130,8 +8137,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8130
8137
  });
8131
8138
  }
8132
8139
  /**
8133
- * 返回canvas是否已经添加过
8134
- * @param canvas canvas元素
8140
+ * 获取canvas是否已经添加过 | Gets whether the canvas has already been added
8141
+ * @param canvas canvas
8135
8142
  * @returns boolean
8136
8143
  */
8137
8144
  isCanvasExist(canvas) {
@@ -8140,13 +8147,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8140
8147
  return info.canvasMap.has(canvas);
8141
8148
  });
8142
8149
  }
8143
- /** 设置全部render静音状态 */
8150
+ /** 设置全部render静音状态 | Mute all render */
8144
8151
  setAllVideoMutedState(muted) {
8145
8152
  this._wsInfoMap.forEach((wsInfo) => {
8146
8153
  wsInfo.render.muted = muted;
8147
8154
  });
8148
8155
  }
8149
- /** 更新单个render实例的配置 */
8156
+ /** 更新单个render实例的配置 | Update the configuration of a single render instance */
8150
8157
  updateRenderOptions(url, options) {
8151
8158
  if (options) {
8152
8159
  const wsInfo = this._wsInfoMap.get(url);
@@ -8154,9 +8161,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8154
8161
  }
8155
8162
  }
8156
8163
  /**
8157
- * 设置单个render静音状态
8164
+ * 设置单个render静音状态 | Set a single render to be silent
8158
8165
  * @param url
8159
- * @param muted boolean 是否静音
8166
+ * @param {boolean} muted 是否静音 | Muted or not
8160
8167
  */
8161
8168
  setOneMutedState(url, muted) {
8162
8169
  const wsInfo = this._wsInfoMap.get(url);
@@ -8167,7 +8174,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8167
8174
  }
8168
8175
  /**
8169
8176
  * 获取url对应render video元素是否静音
8170
- * @param url socket地址
8177
+ * Gets whether the render video element of the url is muted
8178
+ * @param url websocket url
8171
8179
  */
8172
8180
  getOneMutedState(url) {
8173
8181
  const wsInfo = this._wsInfoMap.get(url);
@@ -8178,7 +8186,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8178
8186
  }
8179
8187
  /**
8180
8188
  * 单个解除静音,其他未静音的变成静音,只播放一个
8181
- * @param url socket地址
8189
+ * Unmute a single video and mute all other videos
8190
+ * @param url websocket url
8182
8191
  */
8183
8192
  playOneAudio(url) {
8184
8193
  this.setAllVideoMutedState(true);
@@ -8186,6 +8195,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8186
8195
  }
8187
8196
  /**
8188
8197
  * 设置单个render是否继续处理ws数据
8198
+ * Sets whether a single render continues to process ws data
8189
8199
  * @param url
8190
8200
  */
8191
8201
  setOneVideoPausedState(url, paused) {
@@ -8195,15 +8205,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8195
8205
  }
8196
8206
  wsInfo.render.paused = paused;
8197
8207
  }
8198
- /** 设置全部render是否继续处理ws数据 */
8208
+ /** 设置全部render是否继续处理ws数据 | Sets whether all render continues to process ws data */
8199
8209
  setAllVideoPausedState(paused) {
8200
8210
  this._wsInfoMap.forEach((wsInfo) => {
8201
8211
  wsInfo.render.paused = paused;
8202
8212
  });
8203
8213
  }
8204
8214
  /**
8205
- * 获取url对应render video元素是否继续播放
8206
- * @param url socket地址
8215
+ * 获取url对应render video元素的播放状态
8216
+ * Get the playback status of the render video element corresponding to the url
8217
+ * @param url websocket url
8207
8218
  */
8208
8219
  getOneVideoPausedState(url) {
8209
8220
  const wsInfo = this._wsInfoMap.get(url);
@@ -8214,7 +8225,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8214
8225
  }
8215
8226
  /**
8216
8227
  * 单个视频继续播放,其他暂停处理数据
8217
- * @param url socket地址
8228
+ * A single video continues to play while others pause to process data
8229
+ * @param url websocket url
8218
8230
  */
8219
8231
  playOneVideo(url) {
8220
8232
  this.setAllVideoPausedState(true);
@@ -8222,6 +8234,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8222
8234
  }
8223
8235
  /**
8224
8236
  * 刷新socket,以及播放时间
8237
+ * Refresh the socket, and the playback time
8225
8238
  */
8226
8239
  refresh(url) {
8227
8240
  if (url) {
@@ -8242,7 +8255,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
8242
8255
  }
8243
8256
  }
8244
8257
  /**
8245
- * 销毁
8258
+ * 销毁 | Destroy
8246
8259
  */
8247
8260
  destroy() {
8248
8261
  this._wsInfoMap.forEach((wsInfo) => {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@havue/ws-video-manager",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Javascript class for websocket video manager",
5
5
  "keywords": [
6
6
  "havue",
@@ -1,28 +1,31 @@
1
1
  // #region typedefine
2
- /** 心跳配置 */
2
+ /** 心跳配置 | Heartbeat configuration */
3
3
  type HeartbeatConfigType = {
4
- /** 只发送一次 */
4
+ /** 只发送一次 | Only send it once */
5
5
  once: boolean
6
- /** 心跳消息 */
6
+ /** 心跳消息 | Heartbeat message */
7
7
  message: string
8
- /** 时间间隔 */
8
+ /** 心跳间隔 | Interval of heartbeat */
9
9
  interval?: number
10
10
  }
11
11
 
12
- /** 重连配置 */
12
+ /** 重连配置 | Reconnect configuration */
13
13
  type InterruptConfigType = {
14
- /** 是否重连 */
14
+ /** 是否重连 | Reconnect or not */
15
15
  reconnect: boolean
16
- /** 最大重连次数 */
16
+ /** 最大重连次数 | Maximum number of reconnections */
17
17
  maxReconnectTimes: number
18
- /** 每次重连延时 */
18
+ /** 每次重连延时 | Delay per reconnection */
19
19
  delay: number
20
20
  }
21
21
 
22
22
  export type WebSocketOptionsType = {
23
- /** WebSocket 子协议 WebSocket(url: string, protocols: string | string[]) */
23
+ /** WebSocket subprotocol: WebSocket(url: string, protocols: string | string[]) */
24
24
  protocols?: string | string[]
25
- /** WebSocket 连接所传输二进制数据的类型 */
25
+ /**
26
+ * WebSocket 连接接收的二进制数据类型
27
+ * the type of binary data being received over the WebSocket connection
28
+ */
26
29
  binaryType?: WebSocket['binaryType']
27
30
  heartbeat?: HeartbeatConfigType
28
31
  interrupt?: InterruptConfigType
@@ -121,6 +124,7 @@ class WebSocketLoader {
121
124
  }
122
125
 
123
126
  // 非手动关闭导致连接意外中断
127
+ // Non-manual shutdown results in unexpected connection interruption
124
128
  if (this._interruptConfig.reconnect && this._interruptReconnectTimes < this._interruptConfig.maxReconnectTimes) {
125
129
  this._interruptReconnectTimes++
126
130
 
@@ -157,7 +161,7 @@ class WebSocketLoader {
157
161
 
158
162
  const { message, interval, once } = this._heartbeatConfig
159
163
 
160
- // 只发一次心跳
164
+ // 只发一次心跳 | Only one heartbeat
161
165
  if (once) {
162
166
  this.sendMessage(message)
163
167
  return