yjz-web-sdk 1.0.9-beta.5 → 1.0.11-beta.1

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.
@@ -1,4 +1,7 @@
1
- !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode(".vContainer[data-v-92723927]{transition:transform .2s linear;transform-origin:center center;margin:0;overflow:hidden;transform:translateZ(0);will-change:transform}.flex[data-v-92723927]{display:flex}.flex-1[data-v-92723927]{flex:1 1 0}.items-center[data-v-92723927]{align-items:center}.justify-center[data-v-92723927]{justify-content:center}.canvas-control[data-v-92723927]{width:100%;height:100%;display:block;-webkit-user-select:none;user-select:none;-webkit-user-drag:none;touch-action:none;object-fit:cover;backface-visibility:hidden;transform:translateZ(0);clip-path:inset(0 1px)}.circle-cursor[data-v-92723927]{cursor:url(\"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='none'%3e%3ccircle%20cx='12'%20cy='12'%20r='12'%20fill='%23fff'%20opacity='.6'/%3e%3ccircle%20cx='12'%20cy='12'%20r='10'%20fill='%23000'%20opacity='.6'/%3e%3c/svg%3e\") 12 12,auto}.triangle-cursor[data-v-92723927]{cursor:url(\"data:image/svg+xml,%3csvg%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='22'%20height='22'%3e%3cpath%20d='M143.832313%205.834982H143.686438A108.676545%20108.676545%200%200%200%205.834982%20143.686438l34.499333-11.815839-34.499333%2011.815839%200.072938%200.218812%200.145874%200.437624%200.583498%201.750494%202.333993%206.71023%208.752474%2025.528047L49.232663%20269.867929a2254749.467572%202254749.467572%200%200%201%20223.917444%20652.351017l9.335972%2027.205605%202.552804%207.585476%200.729373%202.188119a72.572592%2072.572592%200%200%200%20126.181491%2040.844876%2072.134968%2072.134968%200%200%200%2014.076895-18.963693c3.282178-6.41848%205.689108-13.639271%208.023101-20.3495l0.072937-0.291749%2072.572592-209.329989%2047.409231-136.830334%2015.53564-44.710551%200.145874-0.364687%200.510561-0.145874%2045.002301-15.900327%20137.486769-48.649165c99.340573-35.228705%20202.984445-71.989094%20209.913487-74.906584l3.355115-1.312871c8.023101-3.136303%2022.391744-8.606599%2033.915834-20.130689a72.499655%2072.499655%200%200%200%200-102.549813L999.240712%20304.877823c-1.823432-1.969307-7.293728-7.731351-13.274585-11.961714a89.056417%2089.056417%200%200%200-27.205605-12.3264h-0.145874l-2.552805-0.875247L948.184617%20277.161657l-27.86204-9.263034-94.672588-31.800653A405018.007245%20405018.007245%200%200%201%20268.919745%2048.138604L178.039896%2017.504947%20152.657723%208.752473%20145.874556%206.637292%20144.196999%205.90792%20143.832313%205.834982z'%20fill='%23000000'%20opacity='.7'%3e%3c/path%3e%3c/svg%3e\") 1 1,auto}.default-cursor[data-v-92723927]{cursor:default}.no-events[data-v-92723927]{pointer-events:none!important}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();
1
+ !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode(".vContainer[data-v-611728c2]{transition:transform .2s linear;transform-origin:center center;margin:0;overflow:hidden;transform:translateZ(0);will-change:transform}.flex[data-v-611728c2]{display:flex}.flex-1[data-v-611728c2]{flex:1 1 0}.items-center[data-v-611728c2]{align-items:center}.justify-center[data-v-611728c2]{justify-content:center}.video-control[data-v-611728c2]{width:100%;height:100%;display:block;-webkit-user-select:none;user-select:none;object-fit:cover;clip-path:inset(0 1px);-webkit-user-drag:none;touch-action:none;backface-visibility:hidden;-webkit-backface-visibility:hidden;transform:translateZ(0)}.circle-cursor[data-v-611728c2]{cursor:url(\"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='none'%3e%3ccircle%20cx='12'%20cy='12'%20r='12'%20fill='%23fff'%20opacity='.6'/%3e%3ccircle%20cx='12'%20cy='12'%20r='10'%20fill='%23000'%20opacity='.6'/%3e%3c/svg%3e\") 12 12,auto}.triangle-cursor[data-v-611728c2]{cursor:url(\"data:image/svg+xml,%3csvg%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='22'%20height='22'%3e%3cpath%20d='M143.832313%205.834982H143.686438A108.676545%20108.676545%200%200%200%205.834982%20143.686438l34.499333-11.815839-34.499333%2011.815839%200.072938%200.218812%200.145874%200.437624%200.583498%201.750494%202.333993%206.71023%208.752474%2025.528047L49.232663%20269.867929a2254749.467572%202254749.467572%200%200%201%20223.917444%20652.351017l9.335972%2027.205605%202.552804%207.585476%200.729373%202.188119a72.572592%2072.572592%200%200%200%20126.181491%2040.844876%2072.134968%2072.134968%200%200%200%2014.076895-18.963693c3.282178-6.41848%205.689108-13.639271%208.023101-20.3495l0.072937-0.291749%2072.572592-209.329989%2047.409231-136.830334%2015.53564-44.710551%200.145874-0.364687%200.510561-0.145874%2045.002301-15.900327%20137.486769-48.649165c99.340573-35.228705%20202.984445-71.989094%20209.913487-74.906584l3.355115-1.312871c8.023101-3.136303%2022.391744-8.606599%2033.915834-20.130689a72.499655%2072.499655%200%200%200%200-102.549813L999.240712%20304.877823c-1.823432-1.969307-7.293728-7.731351-13.274585-11.961714a89.056417%2089.056417%200%200%200-27.205605-12.3264h-0.145874l-2.552805-0.875247L948.184617%20277.161657l-27.86204-9.263034-94.672588-31.800653A405018.007245%20405018.007245%200%200%201%20268.919745%2048.138604L178.039896%2017.504947%20152.657723%208.752473%20145.874556%206.637292%20144.196999%205.90792%20143.832313%205.834982z'%20fill='%23000000'%20opacity='.7'%3e%3c/path%3e%3c/svg%3e\") 1 1,auto}.default-cursor[data-v-611728c2]{cursor:default}.no-events[data-v-611728c2]{pointer-events:none!important}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
2
5
  import { computed, onMounted, onUnmounted, ref, onBeforeUnmount, defineComponent, toRefs, createElementBlock, openBlock, createElementVNode, normalizeStyle, unref, normalizeClass } from "vue";
3
6
  function _mergeNamespaces(n, m) {
4
7
  for (var i = 0; i < m.length; i++) {
@@ -28,7 +31,7 @@ function requireEventemitter3() {
28
31
  if (hasRequiredEventemitter3) return eventemitter3.exports;
29
32
  hasRequiredEventemitter3 = 1;
30
33
  (function(module) {
31
- var has2 = Object.prototype.hasOwnProperty, prefix = "~";
34
+ var has = Object.prototype.hasOwnProperty, prefix = "~";
32
35
  function Events() {
33
36
  }
34
37
  if (Object.create) {
@@ -62,7 +65,7 @@ function requireEventemitter3() {
62
65
  var names = [], events, name;
63
66
  if (this._eventsCount === 0) return names;
64
67
  for (name in events = this._events) {
65
- if (has2.call(events, name)) names.push(prefix ? name.slice(1) : name);
68
+ if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
66
69
  }
67
70
  if (Object.getOwnPropertySymbols) {
68
71
  return names.concat(Object.getOwnPropertySymbols(events));
@@ -187,8 +190,7 @@ function requireEventemitter3() {
187
190
  }
188
191
  var eventemitter3Exports = requireEventemitter3();
189
192
  const EventEmitter = /* @__PURE__ */ getDefaultExportFromCjs(eventemitter3Exports);
190
- var MessageType;
191
- (function(MessageType2) {
193
+ var MessageType = /* @__PURE__ */ ((MessageType2) => {
192
194
  MessageType2["Peers"] = "Peers";
193
195
  MessageType2["Offer"] = "Offer";
194
196
  MessageType2["Answer"] = "Answer";
@@ -201,9 +203,9 @@ var MessageType;
201
203
  MessageType2["KickOut"] = "KickOut";
202
204
  MessageType2["GroupPeersMessage"] = "GroupPeer";
203
205
  MessageType2["Error"] = "Error";
204
- })(MessageType || (MessageType = {}));
205
- var SendType;
206
- (function(SendType2) {
206
+ return MessageType2;
207
+ })(MessageType || {});
208
+ var SendType = /* @__PURE__ */ ((SendType2) => {
207
209
  SendType2["SignIn"] = "SignIn";
208
210
  SendType2["SignOut"] = "SignOut";
209
211
  SendType2["Answer"] = "Answer";
@@ -217,25 +219,15 @@ var SendType;
217
219
  SendType2["GroupSendAction"] = "GroupSendAction";
218
220
  SendType2["SwitchControlToMain"] = "SwitchControlToMain";
219
221
  SendType2["GroupAcceptControl"] = "GroupAcceptControl";
220
- })(SendType || (SendType = {}));
221
- var ConnectorType;
222
- (function(ConnectorType2) {
222
+ return SendType2;
223
+ })(SendType || {});
224
+ var ConnectorType = /* @__PURE__ */ ((ConnectorType2) => {
223
225
  ConnectorType2["WebRTC"] = "webrtc";
224
226
  ConnectorType2["LanForwarding"] = "lanForwarding";
225
227
  ConnectorType2["Hybrid"] = "hybrid";
226
- })(ConnectorType || (ConnectorType = {}));
227
- var IceConnectionState;
228
- (function(IceConnectionState2) {
229
- IceConnectionState2["NEW"] = "new";
230
- IceConnectionState2["CHECKING"] = "checking";
231
- IceConnectionState2["CONNECTED"] = "connected";
232
- IceConnectionState2["COMPLETED"] = "completed";
233
- IceConnectionState2["DISCONNECTED"] = "disconnected";
234
- IceConnectionState2["FAILED"] = "failed";
235
- IceConnectionState2["CLOSED"] = "closed";
236
- })(IceConnectionState || (IceConnectionState = {}));
237
- var FailCode;
238
- (function(FailCode2) {
228
+ return ConnectorType2;
229
+ })(ConnectorType || {});
230
+ var FailCode = /* @__PURE__ */ ((FailCode2) => {
239
231
  FailCode2[FailCode2["SOCKET"] = 10001] = "SOCKET";
240
232
  FailCode2[FailCode2["SOCKET_CLOSE"] = 10002] = "SOCKET_CLOSE";
241
233
  FailCode2[FailCode2["CREATE_OFFER"] = 10003] = "CREATE_OFFER";
@@ -254,32 +246,87 @@ var FailCode;
254
246
  FailCode2[FailCode2["KICK_OUT_ERR"] = 10016] = "KICK_OUT_ERR";
255
247
  FailCode2[FailCode2["STATE_ERR"] = 10017] = "STATE_ERR";
256
248
  FailCode2[FailCode2["OPTION_ERR"] = 10018] = "OPTION_ERR";
257
- })(FailCode || (FailCode = {}));
249
+ return FailCode2;
250
+ })(FailCode || {});
258
251
  const FailInfoMap = {
259
- [FailCode.SOCKET]: { type: "socket", description: "WebSocket连接失败" },
260
- [FailCode.SOCKET_CLOSE]: { type: "socket_close", description: "WebSocket已关闭" },
261
- [FailCode.CREATE_OFFER]: { type: "createOffer", description: "创建offer失败" },
262
- [FailCode.HANDLE_OFFER]: { type: "handleOffer", description: "处理offer失败" },
263
- [FailCode.CREATE_ANSWER]: { type: "createAnswer", description: "创建answer失败" },
264
- [FailCode.HANDLE_ANSWER]: { type: "handleAnswer", description: "处理answer失败" },
265
- [FailCode.LOCAL_DES]: { type: "setLocalDescription", description: "设置本地描述失败" },
266
- [FailCode.REMOTE_DES]: { type: "setRemoteDescription", description: "设置远端描述失败" },
267
- [FailCode.HANDLE_ICE]: { type: "handleICE", description: "处理 ICE 失败" },
268
- [FailCode.ICE_STATE]: { type: "iceState", description: "ICE 状态异常" },
269
- [FailCode.CAMERA]: { type: "camera", description: "摄像头异常" },
270
- [FailCode.NOT_AVAILABLE]: { type: "notAvailable", description: "网络环境异常" },
271
- [FailCode.DATACHANNEL_ERR]: { type: "datachannel_err", description: "信令通道错误" },
272
- [FailCode.STREAM_STATE]: { type: "stream_state", description: "webrtc统计信息获取失败" },
273
- [FailCode.AUTH_FAILED]: { type: "auth_failed", description: "鉴权失败" },
274
- [FailCode.KICK_OUT_ERR]: { type: "kick_out_err", description: "被踢出投屏房间" },
275
- [FailCode.STATE_ERR]: { type: "state_err", description: "云机无响应,请联系客服" },
276
- [FailCode.OPTION_ERR]: { type: "option_err", description: "投屏配置异常,请检查配置" }
252
+ [
253
+ 10001
254
+ /* SOCKET */
255
+ ]: { type: "socket", description: "WebSocket连接失败" },
256
+ [
257
+ 10002
258
+ /* SOCKET_CLOSE */
259
+ ]: { type: "socket_close", description: "WebSocket已关闭" },
260
+ [
261
+ 10003
262
+ /* CREATE_OFFER */
263
+ ]: { type: "createOffer", description: "创建offer失败" },
264
+ [
265
+ 10004
266
+ /* HANDLE_OFFER */
267
+ ]: { type: "handleOffer", description: "处理offer失败" },
268
+ [
269
+ 10005
270
+ /* CREATE_ANSWER */
271
+ ]: { type: "createAnswer", description: "创建answer失败" },
272
+ [
273
+ 10006
274
+ /* HANDLE_ANSWER */
275
+ ]: { type: "handleAnswer", description: "处理answer失败" },
276
+ [
277
+ 10007
278
+ /* LOCAL_DES */
279
+ ]: { type: "setLocalDescription", description: "设置本地描述失败" },
280
+ [
281
+ 10008
282
+ /* REMOTE_DES */
283
+ ]: { type: "setRemoteDescription", description: "设置远端描述失败" },
284
+ [
285
+ 10009
286
+ /* HANDLE_ICE */
287
+ ]: { type: "handleICE", description: "处理 ICE 失败" },
288
+ [
289
+ 10010
290
+ /* ICE_STATE */
291
+ ]: { type: "iceState", description: "ICE 状态异常" },
292
+ [
293
+ 10011
294
+ /* CAMERA */
295
+ ]: { type: "camera", description: "摄像头异常" },
296
+ [
297
+ 10012
298
+ /* NOT_AVAILABLE */
299
+ ]: { type: "notAvailable", description: "网络环境异常" },
300
+ [
301
+ 10013
302
+ /* DATACHANNEL_ERR */
303
+ ]: { type: "datachannel_err", description: "信令通道错误" },
304
+ [
305
+ 10014
306
+ /* STREAM_STATE */
307
+ ]: { type: "stream_state", description: "webrtc统计信息获取失败" },
308
+ [
309
+ 10015
310
+ /* AUTH_FAILED */
311
+ ]: { type: "auth_failed", description: "鉴权失败" },
312
+ [
313
+ 10016
314
+ /* KICK_OUT_ERR */
315
+ ]: { type: "kick_out_err", description: "被踢出投屏房间" },
316
+ [
317
+ 10017
318
+ /* STATE_ERR */
319
+ ]: { type: "state_err", description: "云机无响应,请联系客服" },
320
+ [
321
+ 10018
322
+ /* OPTION_ERR */
323
+ ]: { type: "option_err", description: "投屏配置异常,请检查配置" }
277
324
  };
278
- var CameraFailCode;
279
- (function(CameraFailCode2) {
325
+ var CameraFailCode = /* @__PURE__ */ ((CameraFailCode2) => {
280
326
  CameraFailCode2[CameraFailCode2["LOCAL_STREAM_FAIL"] = 20001] = "LOCAL_STREAM_FAIL";
281
327
  CameraFailCode2[CameraFailCode2["CAMERA_STREAM_FAIL"] = 20002] = "CAMERA_STREAM_FAIL";
282
- })(CameraFailCode || (CameraFailCode = {}));
328
+ return CameraFailCode2;
329
+ })(CameraFailCode || {});
283
330
  function createWebRtcError(code, rawError) {
284
331
  const info = FailInfoMap[code];
285
332
  return {
@@ -295,8 +342,7 @@ function createCameraError(code, message) {
295
342
  message
296
343
  };
297
344
  }
298
- var EmitType;
299
- (function(EmitType2) {
345
+ var EmitType = /* @__PURE__ */ ((EmitType2) => {
300
346
  EmitType2["signalMessage"] = "signalMessage";
301
347
  EmitType2["webrtcError"] = "webrtcError";
302
348
  EmitType2["cameraError"] = "cameraError";
@@ -311,17 +357,17 @@ var EmitType;
311
357
  EmitType2["screenshot"] = "screenshot";
312
358
  EmitType2["reconnect"] = "reconnect";
313
359
  EmitType2["groupError"] = "groupError";
314
- EmitType2["arrayBuffer"] = "arrayBuffer";
315
- })(EmitType || (EmitType = {}));
316
- var LogLevel;
317
- (function(LogLevel2) {
360
+ return EmitType2;
361
+ })(EmitType || {});
362
+ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
318
363
  LogLevel2[LogLevel2["DEBUG"] = 10] = "DEBUG";
319
364
  LogLevel2[LogLevel2["INFO"] = 20] = "INFO";
320
365
  LogLevel2[LogLevel2["WARN"] = 30] = "WARN";
321
366
  LogLevel2[LogLevel2["ERROR"] = 40] = "ERROR";
322
367
  LogLevel2[LogLevel2["OFF"] = 100] = "OFF";
323
- })(LogLevel || (LogLevel = {}));
324
- let globalLogLevel = LogLevel.DEBUG;
368
+ return LogLevel2;
369
+ })(LogLevel || {});
370
+ let globalLogLevel = 10;
325
371
  let globalEnable = true;
326
372
  let globalNamespace = "SDK";
327
373
  function setLogLevel(level) {
@@ -331,56 +377,74 @@ function enableLog(enable) {
331
377
  globalEnable = enable;
332
378
  }
333
379
  const levelStyle = {
334
- [LogLevel.DEBUG]: "color: #999",
335
- [LogLevel.INFO]: "color: #2b90d9",
336
- [LogLevel.WARN]: "color: #e6a23c",
337
- [LogLevel.ERROR]: "color: #f56c6c",
338
- [LogLevel.OFF]: "color: inherit"
380
+ [
381
+ 10
382
+ /* DEBUG */
383
+ ]: "color: #999",
384
+ [
385
+ 20
386
+ /* INFO */
387
+ ]: "color: #2b90d9",
388
+ [
389
+ 30
390
+ /* WARN */
391
+ ]: "color: #e6a23c",
392
+ [
393
+ 40
394
+ /* ERROR */
395
+ ]: "color: #f56c6c",
396
+ [
397
+ 100
398
+ /* OFF */
399
+ ]: "color: inherit"
339
400
  };
340
401
  class LoggerCore {
341
402
  canLog(level) {
342
403
  return globalEnable && level >= globalLogLevel;
343
404
  }
344
405
  log(level, ...args) {
345
- if (!this.canLog(level))
346
- return;
406
+ if (!this.canLog(level)) return;
347
407
  const levelName = LogLevel[level];
348
408
  const prefix = `%c[${globalNamespace}] [${levelName}]`;
349
409
  const style = levelStyle[level];
350
410
  switch (level) {
351
- case LogLevel.DEBUG:
411
+ case 10:
352
412
  console.log(prefix, style, ...args);
353
413
  break;
354
- case LogLevel.INFO:
414
+ case 20:
355
415
  console.info(prefix, style, ...args);
356
416
  break;
357
- case LogLevel.WARN:
417
+ case 30:
358
418
  console.warn(prefix, style, ...args);
359
419
  break;
360
- case LogLevel.ERROR:
420
+ case 40:
361
421
  console.error(prefix, style, ...args);
362
422
  break;
363
423
  }
364
424
  }
365
425
  debug(...args) {
366
- this.log(LogLevel.DEBUG, ...args);
426
+ this.log(10, ...args);
367
427
  }
368
428
  info(...args) {
369
- this.log(LogLevel.INFO, ...args);
429
+ this.log(20, ...args);
370
430
  }
371
431
  warn(...args) {
372
- this.log(LogLevel.WARN, ...args);
432
+ this.log(30, ...args);
373
433
  }
374
434
  error(...args) {
375
- this.log(LogLevel.ERROR, ...args);
435
+ this.log(40, ...args);
376
436
  }
377
437
  }
378
438
  const Logger = new LoggerCore();
379
439
  class SignalingClient extends EventEmitter {
380
440
  constructor(config) {
381
441
  super();
382
- this.webSocket = null;
383
- this.timeout = null;
442
+ // 私有属性 config,用于存储 WebRTC 配置信息
443
+ __publicField(this, "config");
444
+ // 根据实际情况替换为具体配置类型
445
+ // 私有属性 webSocket,用于存储 WebSocket 连接实例,初始值为 null
446
+ __publicField(this, "webSocket", null);
447
+ __publicField(this, "timeout", null);
384
448
  this.config = config;
385
449
  }
386
450
  /**
@@ -817,9 +881,9 @@ function shimGetUserMedia$2(window2, browserDetails) {
817
881
  }
818
882
  return cc;
819
883
  };
820
- const shimConstraints_ = function(constraints, func2) {
884
+ const shimConstraints_ = function(constraints, func) {
821
885
  if (browserDetails.version >= 61) {
822
- return func2(constraints);
886
+ return func(constraints);
823
887
  }
824
888
  constraints = JSON.parse(JSON.stringify(constraints));
825
889
  if (constraints && typeof constraints.audio === "object") {
@@ -858,14 +922,14 @@ function shimGetUserMedia$2(window2, browserDetails) {
858
922
  }
859
923
  constraints.video = constraintsToChrome_(constraints.video);
860
924
  logging("chrome: " + JSON.stringify(constraints));
861
- return func2(constraints);
925
+ return func(constraints);
862
926
  });
863
927
  }
864
928
  }
865
929
  constraints.video = constraintsToChrome_(constraints.video);
866
930
  }
867
931
  logging("chrome: " + JSON.stringify(constraints));
868
- return func2(constraints);
932
+ return func(constraints);
869
933
  };
870
934
  const shimError_ = function(e) {
871
935
  if (browserDetails.version >= 64) {
@@ -3025,8 +3089,8 @@ function shimParameterlessSetLocalDescription(window2, browserDetails) {
3025
3089
  if (desc.sdp || desc.type !== "offer" && desc.type !== "answer") {
3026
3090
  return nativeSetLocalDescription.apply(this, [desc]);
3027
3091
  }
3028
- const func2 = desc.type === "offer" ? this.createOffer : this.createAnswer;
3029
- return func2.apply(this).then((d) => nativeSetLocalDescription.apply(this, [d]));
3092
+ const func = desc.type === "offer" ? this.createOffer : this.createAnswer;
3093
+ return func.apply(this).then((d) => nativeSetLocalDescription.apply(this, [d]));
3030
3094
  };
3031
3095
  }
3032
3096
  const commonShim = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -3140,6 +3204,52 @@ function adapterFactory({ window: window2 } = {}, options = {
3140
3204
  return adapter;
3141
3205
  }
3142
3206
  adapterFactory({ window: typeof window === "undefined" ? void 0 : window });
3207
+ class WebRTCConfig {
3208
+ constructor(options) {
3209
+ __publicField(this, "signalServerUrl");
3210
+ __publicField(this, "myId");
3211
+ __publicField(this, "roomId");
3212
+ __publicField(this, "targetId");
3213
+ __publicField(this, "stunServerUri");
3214
+ __publicField(this, "stunServerUriAli");
3215
+ __publicField(this, "stunServerUriTel");
3216
+ __publicField(this, "turnServerUri");
3217
+ __publicField(this, "turnServerUserName");
3218
+ __publicField(this, "turnServerPassword");
3219
+ __publicField(this, "token");
3220
+ __publicField(this, "connectorType");
3221
+ __publicField(this, "mainRoomIdOfGroup");
3222
+ __publicField(this, "subRoomIdsOfGroup");
3223
+ __publicField(this, "mainCloudMyId");
3224
+ __publicField(this, "connectorAndRoomId");
3225
+ __publicField(this, "groupId");
3226
+ __publicField(this, "isGroup");
3227
+ __publicField(this, "turnKey");
3228
+ __publicField(this, "traceId", "");
3229
+ __publicField(this, "signAgain");
3230
+ this.signalServerUrl = options.signalServerUrl || "";
3231
+ this.myId = options.myId || "";
3232
+ this.roomId = options.roomId || "";
3233
+ this.targetId = options.targetId || "";
3234
+ this.turnKey = options.turnKey || [];
3235
+ this.stunServerUri = options.stunServerUri || "stun:stun.l.google.com:19302";
3236
+ this.stunServerUriAli = options.stunServerUriAli || "stun:stun.middle.aliyun.com:3478";
3237
+ this.stunServerUriTel = options.stunServerUriTel || "stun:stun.qq.com:3478";
3238
+ this.turnServerUri = options.turnServerUri || "turn:121.37.25.106:3478";
3239
+ this.turnServerUserName = options.turnServerUserName || "yangyj";
3240
+ this.turnServerPassword = options.turnServerPassword || "hb@2025@168";
3241
+ this.token = options.token;
3242
+ this.connectorType = options.connectorType || ConnectorType.WebRTC;
3243
+ this.mainRoomIdOfGroup = options.mainRoomIdOfGroup;
3244
+ this.subRoomIdsOfGroup = options.subRoomIdsOfGroup;
3245
+ this.connectorAndRoomId = options.connectorAndRoomId;
3246
+ this.mainCloudMyId = options.mainCloudMyId;
3247
+ this.groupId = options.groupId;
3248
+ this.isGroup = options.isGroup;
3249
+ this.traceId = options.traceId || "";
3250
+ this.signAgain = options.signAgain || true;
3251
+ }
3252
+ }
3143
3253
  const setRemoteDescriptionWithHandleOffer = (peerConnection, sdp2, sendAnswer, onError) => {
3144
3254
  Logger.info("信息日志:", "设置远程offer Description=======>");
3145
3255
  const description = new RTCSessionDescription({ type: "offer", sdp: sdp2 });
@@ -3169,7 +3279,7 @@ const createPeerConnection = (config) => {
3169
3279
  ];
3170
3280
  const peerConnectionConfig = {
3171
3281
  iceServers,
3172
- iceTransportPolicy: "all",
3282
+ iceTransportPolicy: "relay",
3173
3283
  bundlePolicy: "max-bundle"
3174
3284
  };
3175
3285
  return new RTCPeerConnection(peerConnectionConfig);
@@ -3211,7 +3321,7 @@ const setRemoteDescriptionWithHandleAnswer = (peerConnection, sdp2, onError) =>
3211
3321
  };
3212
3322
  const createOffer = async (peerConnection, sendOfferMessage) => {
3213
3323
  try {
3214
- const offer = await peerConnection.createOffer({ "offerToReceiveAudio": true, "offerToReceiveVideo": true });
3324
+ const offer = await peerConnection.createOffer();
3215
3325
  await setLocalDescriptionWithCreateOffer(peerConnection, offer, sendOfferMessage);
3216
3326
  } catch (err) {
3217
3327
  throw new Error("摄像头视频流添加失败");
@@ -3230,8 +3340,7 @@ const addIceCandidate = (peerConnection, candidate, onError) => {
3230
3340
  Logger.info("信息日志:", "接收远程ice 并设置=======>");
3231
3341
  peerConnection.addIceCandidate(candidate).catch((err) => onError == null ? void 0 : onError(createWebRtcError(FailCode.HANDLE_ICE, err)));
3232
3342
  };
3233
- var ChannelDataType;
3234
- (function(ChannelDataType2) {
3343
+ var ChannelDataType = /* @__PURE__ */ ((ChannelDataType2) => {
3235
3344
  ChannelDataType2["ClickData"] = "ClickData";
3236
3345
  ChannelDataType2["ClipboardData"] = "ClipboardData";
3237
3346
  ChannelDataType2["ActionCommand"] = "ActionCommand";
@@ -3245,27 +3354,27 @@ var ChannelDataType;
3245
3354
  ChannelDataType2["ActionUpdateCloudStatus"] = "ActionUpdateCloudStatus";
3246
3355
  ChannelDataType2["ActionGesture"] = "ActionGesture";
3247
3356
  ChannelDataType2["ActionTrack"] = "ActionTrack";
3248
- ChannelDataType2["RequestKeyFrame"] = "RequestKeyFrame";
3249
- })(ChannelDataType || (ChannelDataType = {}));
3250
- var ActionCommandEventValue;
3251
- (function(ActionCommandEventValue2) {
3357
+ return ChannelDataType2;
3358
+ })(ChannelDataType || {});
3359
+ var ActionCommandEventValue = /* @__PURE__ */ ((ActionCommandEventValue2) => {
3252
3360
  ActionCommandEventValue2["ENABLE"] = "ENABLE";
3253
3361
  ActionCommandEventValue2["DISABLE"] = "DISABLE";
3254
- })(ActionCommandEventValue || (ActionCommandEventValue = {}));
3255
- var ActionCommandType;
3256
- (function(ActionCommandType2) {
3362
+ return ActionCommandEventValue2;
3363
+ })(ActionCommandEventValue || {});
3364
+ var ActionCommandType = /* @__PURE__ */ ((ActionCommandType2) => {
3257
3365
  ActionCommandType2["ActionBack"] = "ActionBack";
3258
3366
  ActionCommandType2["ActionHome"] = "ActionHome";
3259
3367
  ActionCommandType2["ActionRecent"] = "ActionRecent";
3260
3368
  ActionCommandType2["ActionSwitchNavButtons"] = "ActionSwitchNavButtons";
3261
3369
  ActionCommandType2["ActionSwitchNavGestural"] = "ActionSwitchNavGestural";
3262
- })(ActionCommandType || (ActionCommandType = {}));
3263
- var ActionCommandEventType;
3264
- (function(ActionCommandEventType2) {
3370
+ return ActionCommandType2;
3371
+ })(ActionCommandType || {});
3372
+ var ActionCommandEventType = /* @__PURE__ */ ((ActionCommandEventType2) => {
3265
3373
  ActionCommandEventType2["ACTION_CONTROL_VIDEO_AND_AUDIO"] = "ACTION_CONTROL_VIDEO_AND_AUDIO";
3266
3374
  ActionCommandEventType2["ACTION_CONTROL_VIDEO"] = "ACTION_CONTROL_VIDEO";
3267
3375
  ActionCommandEventType2["ACTION_CONTROL_AUDIO"] = "ACTION_CONTROL_AUDIO";
3268
- })(ActionCommandEventType || (ActionCommandEventType = {}));
3376
+ return ActionCommandEventType2;
3377
+ })(ActionCommandEventType || {});
3269
3378
  const ActionType = {
3270
3379
  ACTION_DOWN: 0,
3271
3380
  ACTION_MOVE: 2,
@@ -3281,6 +3390,14 @@ const ContainerDirection = {
3281
3390
  };
3282
3391
  class TouchData {
3283
3392
  constructor(action, p, x, y, offsetTime, type = "adb", index2 = -1, groupIndex = -1) {
3393
+ __publicField(this, "action");
3394
+ __publicField(this, "p");
3395
+ __publicField(this, "x");
3396
+ __publicField(this, "y");
3397
+ __publicField(this, "offsetTime");
3398
+ __publicField(this, "type");
3399
+ __publicField(this, "index");
3400
+ __publicField(this, "groupIndex");
3284
3401
  this.action = action;
3285
3402
  this.p = p;
3286
3403
  this.x = x;
@@ -3293,37 +3410,47 @@ class TouchData {
3293
3410
  }
3294
3411
  class InputData {
3295
3412
  constructor(text) {
3413
+ __publicField(this, "text");
3296
3414
  this.text = text;
3297
3415
  }
3298
3416
  }
3299
3417
  class WheelData {
3300
3418
  constructor(axis) {
3419
+ __publicField(this, "axis");
3301
3420
  this.axis = axis;
3302
3421
  }
3303
3422
  }
3304
3423
  class TrackEventData {
3305
3424
  constructor(visible) {
3425
+ __publicField(this, "visible");
3306
3426
  this.visible = visible;
3307
3427
  }
3308
3428
  }
3309
3429
  class KeyEventData {
3310
3430
  constructor(keyCode, meta) {
3431
+ __publicField(this, "keyCode");
3432
+ __publicField(this, "meta");
3311
3433
  this.keyCode = keyCode;
3312
3434
  this.meta = meta;
3313
3435
  }
3314
3436
  }
3315
3437
  class GestureData {
3316
3438
  constructor(mode) {
3439
+ __publicField(this, "mode");
3317
3440
  this.mode = mode;
3318
3441
  }
3319
3442
  }
3320
3443
  class ClarityData {
3321
3444
  constructor(level) {
3445
+ __publicField(this, "level");
3322
3446
  this.level = level;
3323
3447
  }
3324
3448
  }
3325
3449
  class ChannelData {
3326
3450
  constructor(type, data = null, myId = null) {
3451
+ __publicField(this, "type");
3452
+ __publicField(this, "data");
3453
+ __publicField(this, "myId");
3327
3454
  this.type = type;
3328
3455
  this.data = data;
3329
3456
  this.myId = myId;
@@ -3345,10 +3472,10 @@ class ChannelData {
3345
3472
  * @param touchData 触摸数据,可以是任意类型
3346
3473
  */
3347
3474
  static click(touchData) {
3348
- return new ChannelData(ChannelDataType.ClickData, this.formatData(touchData), "");
3475
+ return new ChannelData("ClickData", this.formatData(touchData), "");
3349
3476
  }
3350
3477
  static action(actionData) {
3351
- return new ChannelData(ChannelDataType.ActionCommand, this.formatData(actionData), "");
3478
+ return new ChannelData("ActionCommand", this.formatData(actionData), "");
3352
3479
  }
3353
3480
  /**
3354
3481
  * 生成剪贴板数据
@@ -3356,57 +3483,54 @@ class ChannelData {
3356
3483
  */
3357
3484
  static clipboard(data) {
3358
3485
  console.log(`剪贴板数据,可以是字符串或其他类型 ${data}`);
3359
- return new ChannelData(ChannelDataType.ClipboardData, this.formatData(data), "");
3486
+ return new ChannelData("ClipboardData", this.formatData(data), "");
3360
3487
  }
3361
3488
  /**
3362
3489
  * 生成输入数据
3363
3490
  * @param data 输入数据对象
3364
3491
  */
3365
3492
  static input(data, myId) {
3366
- return new ChannelData(ChannelDataType.ActionInput, this.formatData(data), myId);
3493
+ return new ChannelData("ActionInput", this.formatData(data), myId);
3367
3494
  }
3368
3495
  /**
3369
3496
  * 生成鼠标滚动数据
3370
3497
  * @param data 输入数据对象
3371
3498
  */
3372
3499
  static wheel(data) {
3373
- return new ChannelData(ChannelDataType.ActionWheel, this.formatData(data));
3500
+ return new ChannelData("ActionWheel", this.formatData(data));
3374
3501
  }
3375
3502
  /**
3376
3503
  * 切换手势模式数据
3377
3504
  * @param data 输入数据对象
3378
3505
  */
3379
3506
  static gesture(data) {
3380
- return new ChannelData(ChannelDataType.ActionGesture, this.formatData(data));
3507
+ return new ChannelData("ActionGesture", this.formatData(data));
3381
3508
  }
3382
3509
  /**
3383
3510
  * 生成中文输入数据
3384
3511
  * @param data 中文输入数据
3385
3512
  */
3386
3513
  static chinese(data) {
3387
- return new ChannelData(ChannelDataType.ActionChinese, this.formatData(data));
3514
+ return new ChannelData("ActionChinese", this.formatData(data));
3388
3515
  }
3389
3516
  /**
3390
3517
  * 生成请求云设备信息数据
3391
3518
  */
3392
3519
  static requestCloudDeviceInfo() {
3393
- return new ChannelData(ChannelDataType.ActionRequestCloudDeviceInfo, "");
3520
+ return new ChannelData("ActionRequestCloudDeviceInfo", "");
3394
3521
  }
3395
3522
  /**
3396
3523
  * 生成清晰度数据(clarity)
3397
3524
  * @param data 清晰度数据
3398
3525
  */
3399
3526
  static clarity(data) {
3400
- return new ChannelData(ChannelDataType.ActionClarity, this.formatData(data));
3527
+ return new ChannelData("ActionClarity", this.formatData(data));
3401
3528
  }
3402
3529
  static switchAudio(data) {
3403
- return new ChannelData(ChannelDataType.ActionCommandEvent, this.formatData(data));
3530
+ return new ChannelData("ActionCommandEvent", this.formatData(data));
3404
3531
  }
3405
3532
  static changeSender(data) {
3406
- return new ChannelData(ChannelDataType.ActionTrack, this.formatData(data));
3407
- }
3408
- static requestKeyFrame(data) {
3409
- return new ChannelData(ChannelDataType.RequestKeyFrame, this.formatData(data));
3533
+ return new ChannelData("ActionTrack", this.formatData(data));
3410
3534
  }
3411
3535
  }
3412
3536
  class FileTypeUtils {
@@ -3447,31 +3571,33 @@ const formattedTime = (timestamp) => {
3447
3571
  return `${h}:${m}:${s}.${ms}`;
3448
3572
  };
3449
3573
  class WebRTCClient extends EventEmitter {
3574
+ // private isFireFox: boolean = false;
3450
3575
  constructor(config) {
3451
3576
  super();
3452
- this.peerConnection = null;
3453
- this.localStream = null;
3454
- this.rotatedStream = null;
3455
- this.isPushingStream = false;
3456
- this.isPushingLocalStream = false;
3457
- this.dataChannel = null;
3458
- this.videoDataChannel = null;
3459
- this.statsTimer = void 0;
3460
- this.lastReportTime = 0;
3461
- this.lastBytesReceived = 0;
3462
- this.lastPacketsLost = 0;
3463
- this.lastPacketsReceived = 0;
3464
- this.lostPacketCount = 0;
3465
- this.maxLostRate = 0;
3466
- this.lastSecondDecodedCount = 0;
3467
- this.canvasStream = null;
3468
- this.rafId = 0;
3469
- this.currentMedia = null;
3470
- this.isFirst = true;
3471
- this.startPushLocal = async (file) => {
3577
+ __publicField(this, "config");
3578
+ __publicField(this, "peerConnection", null);
3579
+ __publicField(this, "localStream", null);
3580
+ __publicField(this, "rotatedStream", null);
3581
+ __publicField(this, "isPushingStream", false);
3582
+ __publicField(this, "isPushingLocalStream", false);
3583
+ __publicField(this, "dataChannel", null);
3584
+ __publicField(this, "statsTimer");
3585
+ __publicField(this, "lastReportTime", 0);
3586
+ __publicField(this, "lastBytesReceived", 0);
3587
+ __publicField(this, "lastPacketsLost", 0);
3588
+ __publicField(this, "lastPacketsReceived", 0);
3589
+ __publicField(this, "lostPacketCount", 0);
3590
+ __publicField(this, "maxLostRate", 0);
3591
+ __publicField(this, "lastSecondDecodedCount", 0);
3592
+ __publicField(this, "fileVideo");
3593
+ __publicField(this, "canvas");
3594
+ __publicField(this, "canvasStream", null);
3595
+ __publicField(this, "rafId", 0);
3596
+ __publicField(this, "currentMedia", null);
3597
+ __publicField(this, "fileImage");
3598
+ __publicField(this, "startPushLocal", async (file) => {
3472
3599
  var _a;
3473
- if (this.isPushingLocalStream || !file)
3474
- return;
3600
+ if (this.isPushingLocalStream || !file) return;
3475
3601
  try {
3476
3602
  await this.loadMedia(file);
3477
3603
  this.startCanvasStream();
@@ -3494,9 +3620,12 @@ class WebRTCClient extends EventEmitter {
3494
3620
  } else {
3495
3621
  errorMessage = String(err);
3496
3622
  }
3497
- this.emit(EmitType.cameraError, createCameraError(CameraFailCode.LOCAL_STREAM_FAIL, errorMessage));
3623
+ this.emit(
3624
+ EmitType.cameraError,
3625
+ createCameraError(CameraFailCode.LOCAL_STREAM_FAIL, errorMessage)
3626
+ );
3498
3627
  }
3499
- };
3628
+ });
3500
3629
  this.config = config;
3501
3630
  }
3502
3631
  async startPush(useBackCamera = true) {
@@ -3514,7 +3643,10 @@ class WebRTCClient extends EventEmitter {
3514
3643
  } else {
3515
3644
  errorMessage = String(err);
3516
3645
  }
3517
- this.emit(EmitType.cameraError, createCameraError(CameraFailCode.CAMERA_STREAM_FAIL, errorMessage));
3646
+ this.emit(
3647
+ EmitType.cameraError,
3648
+ createCameraError(CameraFailCode.CAMERA_STREAM_FAIL, errorMessage)
3649
+ );
3518
3650
  }
3519
3651
  }
3520
3652
  handleOffer(offerSdp) {
@@ -3567,9 +3699,6 @@ class WebRTCClient extends EventEmitter {
3567
3699
  case ChannelDataType.ActionTrack:
3568
3700
  channelData = ChannelData.changeSender(data);
3569
3701
  break;
3570
- case ChannelDataType.RequestKeyFrame:
3571
- channelData = ChannelData.requestKeyFrame(data);
3572
- break;
3573
3702
  }
3574
3703
  if (channelData) {
3575
3704
  const jsonString = JSON.stringify(channelData);
@@ -3582,7 +3711,6 @@ class WebRTCClient extends EventEmitter {
3582
3711
  }
3583
3712
  }
3584
3713
  closeConnection() {
3585
- var _a, _b;
3586
3714
  Logger.info("信息日志:", "关闭webrtc连接=======>");
3587
3715
  if (this.statsTimer) {
3588
3716
  clearInterval(this.statsTimer);
@@ -3593,30 +3721,27 @@ class WebRTCClient extends EventEmitter {
3593
3721
  if (this.peerConnection) {
3594
3722
  if (typeof this.peerConnection.getSenders === "function" && this.peerConnection.getSenders) {
3595
3723
  this.peerConnection.getSenders().forEach((sender) => {
3596
- var _a2, _b2;
3724
+ var _a, _b;
3597
3725
  if (sender.track) {
3598
- (_b2 = (_a2 = sender.track).stop) == null ? void 0 : _b2.call(_a2);
3726
+ (_b = (_a = sender.track).stop) == null ? void 0 : _b.call(_a);
3599
3727
  }
3600
3728
  });
3601
3729
  }
3602
3730
  if (typeof this.peerConnection.getReceivers === "function" && this.peerConnection.getReceivers) {
3603
3731
  this.peerConnection.getReceivers().forEach((receiver) => {
3604
- var _a2, _b2;
3732
+ var _a, _b;
3605
3733
  if (receiver.track) {
3606
- (_b2 = (_a2 = receiver.track).stop) == null ? void 0 : _b2.call(_a2);
3734
+ (_b = (_a = receiver.track).stop) == null ? void 0 : _b.call(_a);
3607
3735
  }
3608
3736
  });
3609
3737
  }
3610
3738
  if (this.peerConnection.getTransceivers) {
3611
3739
  this.peerConnection.getTransceivers().forEach((transceiver) => {
3612
- var _a2;
3613
- (_a2 = transceiver.stop) == null ? void 0 : _a2.call(transceiver);
3740
+ var _a;
3741
+ (_a = transceiver.stop) == null ? void 0 : _a.call(transceiver);
3614
3742
  });
3615
3743
  }
3616
3744
  this.removeAllListeners();
3617
- (_a = this.videoDataChannel) == null ? void 0 : _a.close();
3618
- this.videoDataChannel = null;
3619
- (_b = this.dataChannel) == null ? void 0 : _b.close();
3620
3745
  this.dataChannel = null;
3621
3746
  this.peerConnection.onicecandidate = null;
3622
3747
  this.peerConnection.ontrack = null;
@@ -3637,9 +3762,9 @@ class WebRTCClient extends EventEmitter {
3637
3762
  try {
3638
3763
  this.localStream = await navigator.mediaDevices.getUserMedia({
3639
3764
  video: {
3640
- width: { ideal: 1280 },
3765
+ width: { ideal: 960 },
3641
3766
  height: { ideal: 720 },
3642
- facingMode: useBackCamera ? { ideal: "user" } : { ideal: "user" },
3767
+ facingMode: useBackCamera ? { ideal: "environment" } : { ideal: "user" },
3643
3768
  frameRate: { ideal: 20, max: 30 }
3644
3769
  },
3645
3770
  audio: true
@@ -3684,7 +3809,7 @@ class WebRTCClient extends EventEmitter {
3684
3809
  this.isPushingStream = true;
3685
3810
  this.localStream = await navigator.mediaDevices.getUserMedia({
3686
3811
  video: {
3687
- width: { ideal: 1280 },
3812
+ width: { ideal: 960 },
3688
3813
  height: { ideal: 720 },
3689
3814
  facingMode: useBackCamera ? { ideal: "environment" } : { ideal: "user" },
3690
3815
  frameRate: { ideal: 20, max: 30 }
@@ -3720,8 +3845,8 @@ class WebRTCClient extends EventEmitter {
3720
3845
  }
3721
3846
  async getRotatedStream(localStream, useBackCamera) {
3722
3847
  const canvas = document.createElement("canvas");
3723
- canvas.width = 1280;
3724
- canvas.height = 720;
3848
+ canvas.width = 640;
3849
+ canvas.height = 480;
3725
3850
  canvas.style.position = "absolute";
3726
3851
  canvas.style.top = "-9999px";
3727
3852
  canvas.style.left = "-9999px";
@@ -3808,8 +3933,7 @@ class WebRTCClient extends EventEmitter {
3808
3933
  }
3809
3934
  stopPush() {
3810
3935
  var _a, _b, _c;
3811
- if (!this.isPushingStream)
3812
- return;
3936
+ if (!this.isPushingStream) return;
3813
3937
  this.isPushingStream = false;
3814
3938
  Logger.info("信息日志:", "停止推流到云机=======>");
3815
3939
  (_a = this.localStream) == null ? void 0 : _a.getTracks().forEach((track) => track.stop());
@@ -3843,33 +3967,13 @@ class WebRTCClient extends EventEmitter {
3843
3967
  }
3844
3968
  configDataChannel() {
3845
3969
  this.peerConnection.ondatachannel = (event) => {
3846
- const channel = event.channel;
3847
- switch (channel.label) {
3848
- case `dataChannel${this.config.myId}`:
3849
- this.dataChannel = channel;
3850
- this.dataChannel.onmessage = (ev) => this.handleDataChannelMessage(ev);
3851
- this.dataChannel.onerror = (err) => this.emit(EmitType.webrtcError, createWebRtcError(FailCode.DATACHANNEL_ERR, err));
3852
- this.sendChannelData(ChannelDataType.ActionRequestCloudDeviceInfo, "");
3853
- break;
3854
- case `video${this.config.myId}`:
3855
- this.videoDataChannel = channel;
3856
- this.videoDataChannel.onmessage = (ev) => this.handleVideoChannelMessage(ev);
3857
- this.videoDataChannel.onerror = (err) => this.emit(EmitType.webrtcError, createWebRtcError(FailCode.DATACHANNEL_ERR, err));
3858
- break;
3859
- default:
3860
- console.warn("Unknown data channel:", channel.label);
3861
- break;
3862
- }
3970
+ this.dataChannel = event.channel;
3971
+ this.dataChannel.onmessage = (event2) => this.handleDataChannelMessage(event2);
3972
+ this.dataChannel.onerror = (error) => this.emit(EmitType.webrtcError, createWebRtcError(FailCode.DATACHANNEL_ERR, error));
3973
+ this.sendChannelData(ChannelDataType.ActionRequestCloudDeviceInfo, "");
3863
3974
  };
3864
3975
  }
3865
- async handleVideoChannelMessage(event) {
3866
- const databuffer = event.data;
3867
- if (databuffer instanceof ArrayBuffer || databuffer instanceof Blob) {
3868
- const arrayBuffer = databuffer instanceof Blob ? await databuffer.arrayBuffer() : databuffer;
3869
- this.emit(EmitType.arrayBuffer, arrayBuffer);
3870
- }
3871
- }
3872
- async handleDataChannelMessage(event) {
3976
+ handleDataChannelMessage(event) {
3873
3977
  const data = JSON.parse(event.data);
3874
3978
  if (data.type === ChannelDataType.ActionCommandEvent) {
3875
3979
  const { action, value, cameraId } = JSON.parse(data.data);
@@ -3906,15 +4010,13 @@ class WebRTCClient extends EventEmitter {
3906
4010
  }
3907
4011
  async processStatsOptimized() {
3908
4012
  const pc = this.peerConnection;
3909
- if (!pc)
3910
- return;
3911
- const ua2 = navigator.userAgent;
3912
- const isSafari = /Safari/.test(ua2) && !/Chrome/.test(ua2);
3913
- const isMobile = /iPhone|iPad|Android/i.test(ua2);
4013
+ if (!pc) return;
4014
+ const ua = navigator.userAgent;
4015
+ const isSafari = /Safari/.test(ua) && !/Chrome/.test(ua);
4016
+ const isMobile = /iPhone|iPad|Android/i.test(ua);
3914
4017
  const minInterval = isSafari || isMobile ? 3e3 : 1e3;
3915
4018
  const now = Date.now();
3916
- if (this.lastReportTime && now - this.lastReportTime < minInterval)
3917
- return;
4019
+ if (this.lastReportTime && now - this.lastReportTime < minInterval) return;
3918
4020
  try {
3919
4021
  const statsReport = await pc.getStats(null);
3920
4022
  let videoFps = 0;
@@ -3990,10 +4092,8 @@ class WebRTCClient extends EventEmitter {
3990
4092
  }
3991
4093
  }
3992
4094
  getConnectionType(local, remote) {
3993
- if (local.candidateType === "host" && remote.candidateType === "host")
3994
- return "直连";
3995
- if (local.candidateType === "relay" || remote.candidateType === "relay")
3996
- return "中继";
4095
+ if (local.candidateType === "host" && remote.candidateType === "host") return "直连";
4096
+ if (local.candidateType === "relay" || remote.candidateType === "relay") return "中继";
3997
4097
  return "NAT";
3998
4098
  }
3999
4099
  /** 获取或创建 video 元素(懒初始化) */
@@ -4033,7 +4133,8 @@ class WebRTCClient extends EventEmitter {
4033
4133
  }
4034
4134
  if (kind === "video") {
4035
4135
  return new Promise((resolve, reject) => {
4036
- video.src = URL.createObjectURL(file);
4136
+ const url = URL.createObjectURL(file);
4137
+ video.src = url;
4037
4138
  video.onloadedmetadata = () => resolve();
4038
4139
  video.onerror = () => reject(new Error(`视频文件加载失败: ${file.name}`));
4039
4140
  video.play().catch((err) => reject(new Error(`视频播放失败: ${err}`)));
@@ -4041,7 +4142,8 @@ class WebRTCClient extends EventEmitter {
4041
4142
  });
4042
4143
  } else if (kind === "image") {
4043
4144
  return new Promise((resolve, reject) => {
4044
- img.src = URL.createObjectURL(file);
4145
+ const url = URL.createObjectURL(file);
4146
+ img.src = url;
4045
4147
  img.onload = () => resolve();
4046
4148
  img.onerror = () => reject(new Error(`图片文件加载失败: ${file.name}`));
4047
4149
  this.currentMedia = img;
@@ -4055,8 +4157,7 @@ class WebRTCClient extends EventEmitter {
4055
4157
  const canvas = this.getCanvas();
4056
4158
  const ctx = canvas.getContext("2d");
4057
4159
  const media = this.currentMedia;
4058
- if (!media)
4059
- throw new Error("请先加载媒体文件");
4160
+ if (!media) throw new Error("请先加载媒体文件");
4060
4161
  let lastTime = 0;
4061
4162
  const frameInterval = 1e3 / fps;
4062
4163
  let rafId = 1;
@@ -4109,8 +4210,7 @@ class WebRTCClient extends EventEmitter {
4109
4210
  /** 停止推流并释放资源 */
4110
4211
  stopLocal() {
4111
4212
  var _a, _b;
4112
- if (!this.isPushingLocalStream)
4113
- return;
4213
+ if (!this.isPushingLocalStream) return;
4114
4214
  this.isPushingLocalStream = false;
4115
4215
  cancelAnimationFrame(this.rafId);
4116
4216
  (_a = this.canvasStream) == null ? void 0 : _a.getTracks().forEach((track) => track.stop());
@@ -4129,32 +4229,6 @@ class WebRTCClient extends EventEmitter {
4129
4229
  }
4130
4230
  }
4131
4231
  }
4132
- class WebRTCConfig {
4133
- constructor(options) {
4134
- this.traceId = "";
4135
- this.signalServerUrl = options.signalServerUrl || "";
4136
- this.myId = options.myId || "";
4137
- this.roomId = options.roomId || "";
4138
- this.targetId = options.targetId || "";
4139
- this.turnKey = options.turnKey || [];
4140
- this.stunServerUri = options.stunServerUri || "stun:stun.l.google.com:19302";
4141
- this.stunServerUriAli = options.stunServerUriAli || "stun:stun.middle.aliyun.com:3478";
4142
- this.stunServerUriTel = options.stunServerUriTel || "stun:stun.qq.com:3478";
4143
- this.turnServerUri = options.turnServerUri || "turn:121.37.25.106:3478";
4144
- this.turnServerUserName = options.turnServerUserName || "yangyj";
4145
- this.turnServerPassword = options.turnServerPassword || "hb@2025@168";
4146
- this.token = options.token;
4147
- this.connectorType = options.connectorType || ConnectorType.WebRTC;
4148
- this.mainRoomIdOfGroup = options.mainRoomIdOfGroup;
4149
- this.subRoomIdsOfGroup = options.subRoomIdsOfGroup;
4150
- this.connectorAndRoomId = options.connectorAndRoomId;
4151
- this.mainCloudMyId = options.mainCloudMyId;
4152
- this.groupId = options.groupId;
4153
- this.isGroup = options.isGroup;
4154
- this.traceId = options.traceId || "";
4155
- this.signAgain = options.signAgain || true;
4156
- }
4157
- }
4158
4232
  const testTurnServer = (turnConfig, timeoutMs = 600) => {
4159
4233
  return new Promise((resolve) => {
4160
4234
  const start = performance.now();
@@ -4173,8 +4247,7 @@ const testTurnServer = (turnConfig, timeoutMs = 600) => {
4173
4247
  }
4174
4248
  });
4175
4249
  pc.onicecandidate = (event) => {
4176
- if (resolved)
4177
- return;
4250
+ if (resolved) return;
4178
4251
  if (event.candidate && event.candidate.candidate.includes("relay")) {
4179
4252
  const rtt = Math.trunc(performance.now() - start);
4180
4253
  resolved = true;
@@ -4202,10 +4275,12 @@ const testMultipleTurnServers = async (servers, timeoutMs = 600) => {
4202
4275
  username: "yangyj",
4203
4276
  credential: "hb@2025@168"
4204
4277
  }));
4205
- const testPromises = turnServers.map((cfg) => testTurnServer(cfg, timeoutMs).then((res) => res).catch((err) => {
4206
- Logger.warn("警告日志:", `中继计算超时=====>`, err);
4207
- return { ...cfg, rtt: Infinity };
4208
- }));
4278
+ const testPromises = turnServers.map(
4279
+ (cfg) => testTurnServer(cfg, timeoutMs).then((res) => res).catch((err) => {
4280
+ Logger.warn("警告日志:", `中继计算超时=====>`, err);
4281
+ return { ...cfg, rtt: Infinity };
4282
+ })
4283
+ );
4209
4284
  const results = await Promise.all(testPromises);
4210
4285
  Logger.debug("调试日志:", `信令计算结果======>`, results);
4211
4286
  const available = results.filter((r) => r.rtt !== Infinity);
@@ -4239,19 +4314,24 @@ const selectBestTurnServer = async (turnList) => {
4239
4314
  class WebRTCSdk extends EventEmitter {
4240
4315
  constructor(options) {
4241
4316
  super();
4242
- this.config = null;
4243
- this.signalingClient = null;
4244
- this.webRTCClient = null;
4245
- this.isConnected = false;
4246
- this.isConnecting = false;
4247
- this.connectCount = 0;
4248
- this.MAX_COUNT = 1;
4249
- this.timeout = null;
4250
- this.handleSignaling = (message) => {
4317
+ __publicField(this, "config", null);
4318
+ __publicField(this, "signalingClient", null);
4319
+ __publicField(this, "webRTCClient", null);
4320
+ __publicField(this, "options");
4321
+ __publicField(this, "isConnected", false);
4322
+ __publicField(this, "isConnecting", false);
4323
+ __publicField(this, "connectCount", 0);
4324
+ __publicField(this, "MAX_COUNT", 1);
4325
+ __publicField(this, "timeout", null);
4326
+ /**
4327
+ * 处理 signal 消息,根据不同消息类型分发到 webRTCClient 或直接触发 SDK 事件
4328
+ * @param message 信令消息
4329
+ */
4330
+ __publicField(this, "handleSignaling", (message) => {
4251
4331
  var _a, _b, _c, _d, _e, _f, _g;
4252
- if (!this.config)
4253
- return;
4332
+ if (!this.config) return;
4254
4333
  Logger.debug("调试信息:", `信令消息=========>`, message);
4334
+ console.log(`信令消息=========>`, message);
4255
4335
  switch (message.type) {
4256
4336
  case MessageType.Peers:
4257
4337
  this.config.myId = message.myId;
@@ -4328,17 +4408,17 @@ class WebRTCSdk extends EventEmitter {
4328
4408
  (_g = this.config.connectorAndRoomId) == null ? void 0 : _g.set(this.config.roomId, this.config.mainCloudMyId ?? "");
4329
4409
  break;
4330
4410
  }
4331
- };
4332
- this.clearTimer = () => {
4411
+ });
4412
+ __publicField(this, "clearTimer", () => {
4333
4413
  if (this.timeout) {
4334
4414
  clearTimeout(this.timeout);
4335
4415
  this.timeout = null;
4336
4416
  }
4337
- };
4338
- this.sendOffer = (offerSdp) => {
4417
+ });
4418
+ /** 发送 Offer 信令 */
4419
+ __publicField(this, "sendOffer", (offerSdp) => {
4339
4420
  var _a, _b;
4340
- if (!this.config)
4341
- return;
4421
+ if (!this.config) return;
4342
4422
  if (offerSdp && offerSdp.length > 0) {
4343
4423
  const groupModeTargetId = ((_a = this.config.connectorAndRoomId) == null ? void 0 : _a.get(this.config.roomId)) ?? "";
4344
4424
  let targetId = this.config.targetId;
@@ -4355,11 +4435,11 @@ class WebRTCSdk extends EventEmitter {
4355
4435
  };
4356
4436
  (_b = this.signalingClient) == null ? void 0 : _b.sendMessage(JSON.stringify(message));
4357
4437
  }
4358
- };
4359
- this.sendAnswer = (answerSdp) => {
4438
+ });
4439
+ /** 发送 Answer 信令 */
4440
+ __publicField(this, "sendAnswer", (answerSdp) => {
4360
4441
  var _a, _b;
4361
- if (!this.config)
4362
- return;
4442
+ if (!this.config) return;
4363
4443
  if (answerSdp && answerSdp.length > 0) {
4364
4444
  const groupModeTargetId = ((_a = this.config.connectorAndRoomId) == null ? void 0 : _a.get(this.config.roomId)) ?? "";
4365
4445
  let targetId = this.config.targetId;
@@ -4377,11 +4457,11 @@ class WebRTCSdk extends EventEmitter {
4377
4457
  };
4378
4458
  (_b = this.signalingClient) == null ? void 0 : _b.sendMessage(JSON.stringify(message));
4379
4459
  }
4380
- };
4381
- this.sendICEMessage = (ice) => {
4460
+ });
4461
+ /** 发送 ICE 候选信息 */
4462
+ __publicField(this, "sendICEMessage", (ice) => {
4382
4463
  var _a, _b;
4383
- if (!this.config)
4384
- return;
4464
+ if (!this.config) return;
4385
4465
  const groupModeTargetId = ((_a = this.config.connectorAndRoomId) == null ? void 0 : _a.get(this.config.roomId)) ?? "";
4386
4466
  let targetId = this.config.targetId;
4387
4467
  if (groupModeTargetId) {
@@ -4399,7 +4479,7 @@ class WebRTCSdk extends EventEmitter {
4399
4479
  };
4400
4480
  (_b = this.signalingClient) == null ? void 0 : _b.sendMessage(JSON.stringify(message));
4401
4481
  }
4402
- };
4482
+ });
4403
4483
  this.options = options;
4404
4484
  if (this.options.connectorType !== ConnectorType.LanForwarding) {
4405
4485
  enableLog(!!this.options.enableLogger);
@@ -4421,11 +4501,10 @@ class WebRTCSdk extends EventEmitter {
4421
4501
  if (areTurnListsEmpty(this.options)) {
4422
4502
  throw createWebRtcError(FailCode.OPTION_ERR, "中继配置为空");
4423
4503
  }
4424
- const tryTurnList = async (list2, isHost) => {
4425
- if (list2.length === 0)
4426
- return false;
4504
+ const tryTurnList = async (list, isHost) => {
4505
+ if (list.length === 0) return false;
4427
4506
  try {
4428
- const result = await selectBestTurnServer(list2);
4507
+ const result = await selectBestTurnServer(list);
4429
4508
  if (result.url && typeof result.rtt === "number") {
4430
4509
  if (isHost && result.rtt > 150) {
4431
4510
  return false;
@@ -4471,8 +4550,7 @@ class WebRTCSdk extends EventEmitter {
4471
4550
  }
4472
4551
  async prepareConnection() {
4473
4552
  var _a;
4474
- if (this.isConnecting)
4475
- return;
4553
+ if (this.isConnecting) return;
4476
4554
  this.isConnecting = true;
4477
4555
  try {
4478
4556
  if (areTurnListsEmpty(this.options)) {
@@ -4504,7 +4582,7 @@ class WebRTCSdk extends EventEmitter {
4504
4582
  }
4505
4583
  }
4506
4584
  initConnectConfig(initConfig = true) {
4507
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
4585
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4508
4586
  if (initConfig) {
4509
4587
  this.config = new WebRTCConfig(this.options);
4510
4588
  }
@@ -4514,20 +4592,25 @@ class WebRTCSdk extends EventEmitter {
4514
4592
  (_a = this.webRTCClient) == null ? void 0 : _a.on(EmitType.sendOffer, (sdp2) => this.sendOffer(sdp2));
4515
4593
  (_b = this.webRTCClient) == null ? void 0 : _b.on(EmitType.sendAnswer, (sdp2) => this.sendAnswer(sdp2));
4516
4594
  (_c = this.webRTCClient) == null ? void 0 : _c.on(EmitType.sendICEMessage, (candidate) => this.sendICEMessage(candidate));
4517
- (_d = this.webRTCClient) == null ? void 0 : _d.on(EmitType.arrayBuffer, (buffer) => this.emit(EmitType.arrayBuffer, buffer));
4518
- (_e = this.webRTCClient) == null ? void 0 : _e.on(EmitType.streamTrack, (track) => {
4595
+ (_d = this.webRTCClient) == null ? void 0 : _d.on(EmitType.streamTrack, (track) => {
4519
4596
  Logger.debug("调试信息:", "=========> EmitType.streamTrack callback");
4520
4597
  this.emit(EmitType.streamTrack, track);
4521
4598
  });
4522
- (_f = this.webRTCClient) == null ? void 0 : _f.on(EmitType.iceConnectionState, (state) => {
4599
+ (_e = this.webRTCClient) == null ? void 0 : _e.on(EmitType.iceConnectionState, (state) => {
4523
4600
  this.emit(EmitType.iceConnectionState, state);
4524
4601
  if (state === "connected") {
4525
4602
  this.isConnected = true;
4526
4603
  }
4527
4604
  });
4528
- (_g = this.webRTCClient) == null ? void 0 : _g.on(EmitType.cloudStatusChanged, (info) => this.emit(EmitType.cloudStatusChanged, info));
4529
- (_h = this.webRTCClient) == null ? void 0 : _h.on(EmitType.cloudClipData, (clipData) => this.emit(EmitType.cloudClipData, clipData));
4530
- (_i = this.webRTCClient) == null ? void 0 : _i.on(EmitType.webrtcError, (err) => {
4605
+ (_f = this.webRTCClient) == null ? void 0 : _f.on(
4606
+ EmitType.cloudStatusChanged,
4607
+ (info) => this.emit(EmitType.cloudStatusChanged, info)
4608
+ );
4609
+ (_g = this.webRTCClient) == null ? void 0 : _g.on(
4610
+ EmitType.cloudClipData,
4611
+ (clipData) => this.emit(EmitType.cloudClipData, clipData)
4612
+ );
4613
+ (_h = this.webRTCClient) == null ? void 0 : _h.on(EmitType.webrtcError, (err) => {
4531
4614
  if (err.code === FailCode.ICE_STATE && this.connectCount < this.MAX_COUNT && this.isConnected) {
4532
4615
  this.connectCount++;
4533
4616
  this.emit(EmitType.reconnect);
@@ -4537,10 +4620,10 @@ class WebRTCSdk extends EventEmitter {
4537
4620
  this.emit(EmitType.webrtcError, err);
4538
4621
  }
4539
4622
  });
4540
- (_j = this.webRTCClient) == null ? void 0 : _j.on(EmitType.cameraError, (err) => {
4623
+ (_i = this.webRTCClient) == null ? void 0 : _i.on(EmitType.cameraError, (err) => {
4541
4624
  this.emit(EmitType.cameraError, err);
4542
4625
  });
4543
- (_k = this.webRTCClient) == null ? void 0 : _k.on(EmitType.statisticInfo, (info) => {
4626
+ (_j = this.webRTCClient) == null ? void 0 : _j.on(EmitType.statisticInfo, (info) => {
4544
4627
  this.emit(EmitType.statisticInfo, info);
4545
4628
  });
4546
4629
  }
@@ -4609,7 +4692,10 @@ class WebRTCSdk extends EventEmitter {
4609
4692
  } else {
4610
4693
  errorMessage = String(error);
4611
4694
  }
4612
- this.emit(EmitType.cameraError, createCameraError(CameraFailCode.CAMERA_STREAM_FAIL, errorMessage));
4695
+ this.emit(
4696
+ EmitType.cameraError,
4697
+ createCameraError(CameraFailCode.CAMERA_STREAM_FAIL, errorMessage)
4698
+ );
4613
4699
  }
4614
4700
  }
4615
4701
  async startPushLocal(file) {
@@ -4623,7 +4709,10 @@ class WebRTCSdk extends EventEmitter {
4623
4709
  } else {
4624
4710
  errorMessage = String(error);
4625
4711
  }
4626
- this.emit(EmitType.cameraError, createCameraError(CameraFailCode.LOCAL_STREAM_FAIL, errorMessage));
4712
+ this.emit(
4713
+ EmitType.cameraError,
4714
+ createCameraError(CameraFailCode.LOCAL_STREAM_FAIL, errorMessage)
4715
+ );
4627
4716
  }
4628
4717
  }
4629
4718
  stopPush() {
@@ -4658,8 +4747,7 @@ class WebRTCSdk extends EventEmitter {
4658
4747
  }
4659
4748
  sendSignOut() {
4660
4749
  var _a, _b;
4661
- if (!this.config)
4662
- return;
4750
+ if (!this.config) return;
4663
4751
  if (this.config.connectorType === ConnectorType.LanForwarding) {
4664
4752
  const message = {
4665
4753
  type: SendType.GroupSignOut,
@@ -4730,14 +4818,10 @@ const META_CTRL_ON = 4096;
4730
4818
  const META_META_ON = 65536;
4731
4819
  const computeAndroidMetaState = (event) => {
4732
4820
  let state = 0;
4733
- if (event.shiftKey)
4734
- state |= META_SHIFT_ON;
4735
- if (event.altKey)
4736
- state |= META_ALT_ON;
4737
- if (event.ctrlKey)
4738
- state |= META_CTRL_ON;
4739
- if (event.metaKey)
4740
- state |= META_META_ON;
4821
+ if (event.shiftKey) state |= META_SHIFT_ON;
4822
+ if (event.altKey) state |= META_ALT_ON;
4823
+ if (event.ctrlKey) state |= META_CTRL_ON;
4824
+ if (event.metaKey) state |= META_META_ON;
4741
4825
  return state;
4742
4826
  };
4743
4827
  const KeyCodeMap = {
@@ -4946,8 +5030,7 @@ function useCursorStyle(cursorType) {
4946
5030
  function useResizeObserver(target, dimension) {
4947
5031
  let observer = null;
4948
5032
  const init = () => {
4949
- if (!target.value)
4950
- return;
5033
+ if (!target.value) return;
4951
5034
  observer = new ResizeObserver((entries) => {
4952
5035
  for (const entry of entries) {
4953
5036
  const { width, height } = entry.contentRect;
@@ -4962,767 +5045,18 @@ function useResizeObserver(target, dimension) {
4962
5045
  onMounted(init);
4963
5046
  onUnmounted(destroy);
4964
5047
  }
4965
- const FALSE = false;
4966
- const NULL = null;
4967
- const UNDEFINED = void 0;
4968
- const RAW_UNDEFINED = "undefined";
4969
- const RAW_FUNCTION = "function";
4970
- const WINDOW = typeof window !== RAW_UNDEFINED ? window : UNDEFINED;
4971
- const EMPTY_FUNCTION = function() {
4972
- };
4973
- const EMPTY_STRING = "";
4974
- function func(value) {
4975
- return typeof value === RAW_FUNCTION;
4976
- }
4977
- function string(value) {
4978
- return typeof value === "string";
4979
- }
4980
- function number(value) {
4981
- return typeof value === "number" && !isNaN(value);
4982
- }
4983
- function numeric(value) {
4984
- return number(value) || string(value) && !isNaN(parseFloat(value)) && isFinite(+value);
4985
- }
4986
- function each$1(array, callback, reversed) {
4987
- if (!array) {
4988
- return;
4989
- }
4990
- const { length } = array;
4991
- if (length) {
4992
- {
4993
- for (let i = 0; i < length; i++) {
4994
- if (callback(array[i], i) === FALSE) {
4995
- break;
4996
- }
4997
- }
4998
- }
4999
- }
5000
- }
5001
- function toString(target, defaultValue) {
5002
- return target != NULL && target.toString ? target.toString() : EMPTY_STRING;
5003
- }
5004
- function indexOf(str, part, start) {
5005
- return str.indexOf(part, 0);
5006
- }
5007
- function has(str, part) {
5008
- return indexOf(str, part) >= 0;
5009
- }
5010
- function isDef(target) {
5011
- return target !== UNDEFINED;
5012
- }
5013
- function each(object, callback) {
5014
- for (let key in object) {
5015
- if (callback(object[key], key) === FALSE) {
5016
- break;
5017
- }
5018
- }
5019
- }
5020
- function reverse(obj) {
5021
- const result = {};
5022
- each(obj, (value, key) => {
5023
- result[value] = key;
5024
- });
5025
- return result;
5026
- }
5027
- const INFO = 2;
5028
- const WARN = 3;
5029
- /common/.test(toString(EMPTY_FUNCTION)) ? INFO : WARN;
5030
- function isNative(target) {
5031
- return func(target) && has(toString(target), "[native code]");
5032
- }
5033
- if (typeof setImmediate === RAW_FUNCTION && isNative(setImmediate)) {
5034
- setImmediate;
5035
- }
5036
- if (typeof MessageChannel === RAW_FUNCTION && isNative(MessageChannel)) ;
5037
- function isAudioWorklet() {
5038
- return typeof registerProcessor === "function" && typeof sampleRate === "number" && typeof currentFrame === "number" && typeof currentTime === "number";
5039
- }
5040
- function isWorker() {
5041
- return !(typeof window === "object" && isDef(window.document)) && !isAudioWorklet();
5042
- }
5043
- function toNumber(target, defaultValue) {
5044
- return numeric(target) ? +target : 0;
5045
- }
5046
- function checkVersion(version, checkVersion2, equal = false) {
5047
- const checkVersionArr = checkVersion2.split(".");
5048
- const versionArr = version.split(".");
5049
- for (let i = 0; i < versionArr.length; i++) {
5050
- if (equal && i == versionArr.length - 1 && toNumber(versionArr[i]) >= toNumber(checkVersionArr[i])) {
5051
- return versionArr.length >= checkVersionArr.length;
5052
- }
5053
- if (toNumber(versionArr[i]) > toNumber(checkVersionArr[i])) {
5054
- return true;
5055
- } else if (toNumber(versionArr[i]) < toNumber(checkVersionArr[i])) {
5056
- return false;
5057
- }
5058
- if (i === checkVersionArr.length - 1 && i === versionArr.length - 1) {
5059
- return equal;
5060
- }
5061
- if (i === checkVersionArr.length - 1) {
5062
- return true;
5063
- } else if (i === versionArr.length - 1) {
5064
- return false;
5065
- }
5066
- }
5067
- return true;
5068
- }
5069
- const list$2 = [
5070
- ["harmony", /harmonyos ([\d_.]+)/],
5071
- ["harmony", /openharmony ([\d_.]+)/],
5072
- ["iphone", /iphone os ([\d_.]+)/],
5073
- ["ipad", /ipad; cpu os ([\d_.]+)/],
5074
- ["itouch", /itouch; cpu os ([\d_.]+)/],
5075
- ["android", /android ([\d_.]+)/],
5076
- ["wp", /windows phone ([\d_.]+)/],
5077
- ["windows", /windows nt ([\d_.]+)/],
5078
- ["linux", /linux/],
5079
- ["mac", /mac os x ([\d_.]+)/]
5080
- ];
5081
- const iosMap = {
5082
- iphone: 1,
5083
- ipad: 1,
5084
- itouch: 1
5085
- };
5086
- function parseUA$1(ua2) {
5087
- let name;
5088
- let version;
5089
- each$1(list$2, (item) => {
5090
- let match = item[1].exec(ua2);
5091
- if (match) {
5092
- name = item[0];
5093
- version = match[1];
5094
- if (version) {
5095
- version = version.replace(/_/g, ".");
5096
- }
5097
- return false;
5098
- }
5099
- });
5100
- return {
5101
- name: name || "",
5102
- version: version || "",
5103
- mobile: ua2.indexOf("mobile") > -1
5104
- };
5105
- }
5106
- const os = parseUA$1((typeof navigator === "object" && navigator.userAgent || "").toLowerCase());
5107
- if (os.name) {
5108
- os[os.name] = true;
5109
- if (iosMap[os.name]) {
5110
- os.ios = true;
5111
- }
5112
- }
5113
- function getMajorVersion(version) {
5114
- if (!string(version)) {
5115
- return "";
5116
- }
5117
- return version.split(".").shift() || "";
5118
- }
5119
- const list$1 = [
5120
- ["alipay", /alipay/],
5121
- ["wechat", /micromessenger/],
5122
- ["dingtalk", /dingtalk[ \/]([\d_.]+)/],
5123
- ["baiduApp", /baiduboxapp/],
5124
- ["baidu", /baidubrowser/],
5125
- ["baidu", /bdbrowser/],
5126
- ["uc", /ucbrowser/],
5127
- ["uc", /ucweb/],
5128
- ["qq", /qqbrowser/],
5129
- ["qqApp", /qq/],
5130
- ["ie", /iemobile[ \/]([\d_.]+)/],
5131
- // IE10- 所有版本都有的信息是 MSIE x.0
5132
- ["ie", /msie[ \/]([\d_.]+)/],
5133
- ["ie", /trident[ \/]([\d_.]+)/, 4],
5134
- ["edge", /edge[ \/]([\d_.]+)/],
5135
- ["newEdge", /edg[ \/]([\d_.]+)/],
5136
- ["chrome", /chrome[ \/]([\d_.]+)/],
5137
- ["firefox", /firefox[ \/]([\d_.]+)/],
5138
- ["opera", /opera(?:.*version)?[ \/]([\d_.]+)/],
5139
- ["safari", /version[ \/]([\d_.]+) safari/],
5140
- // 新版 Safari UA
5141
- ["safari", /version[ \/]([\d_.]+) \S* safari/],
5142
- ["safari", /safari/]
5143
- ];
5144
- const getMajorVersionMap = {};
5145
- const checkVersionMap = {};
5146
- function parseUA(ua2) {
5147
- let name;
5148
- let version;
5149
- each$1(list$1, (item) => {
5150
- let match = item[1].exec(ua2);
5151
- if (match) {
5152
- name = item[0];
5153
- version = match[1];
5154
- if (version) {
5155
- version = version.replace(/_/g, ".");
5156
- if (item[2]) {
5157
- version = parseInt(version, 10) + item[2] + ".0";
5158
- }
5159
- }
5160
- return false;
5161
- }
5162
- });
5163
- if (name === "safari" && !version) {
5164
- version = os.version;
5165
- }
5166
- return {
5167
- name: name || "",
5168
- version: version || "",
5169
- majorVersion: (getMajorVersionMap[name] || getMajorVersion)(version),
5170
- checkVersion: checkVersionMap[name] || checkVersion
5171
- };
5172
- }
5173
- const browser = parseUA((typeof navigator === "object" && navigator.userAgent || "").toLowerCase());
5174
- if (browser.name) {
5175
- browser[browser.name] = true;
5176
- }
5177
- function supportedFeatures() {
5178
- let blob = typeof Blob === "function";
5179
- let wasm = typeof WebAssembly === "object" && typeof WebAssembly.instantiate === "function";
5180
- let fetchSupported = typeof fetch === "function";
5181
- let documentSupport = typeof document === "object";
5182
- let canvas = documentSupport && document.createElement("canvas");
5183
- let webgl = canvas && !!canvas.getContext("webgl");
5184
- let offscreenCanvas = typeof OffscreenCanvas === "function";
5185
- let worker = typeof Worker === "function";
5186
- let arrayBuffer = typeof ArrayBuffer === "function";
5187
- let atomics = typeof Atomics === "object" && Atomics[Symbol.toStringTag] === "Atomics";
5188
- let audioContext = typeof AudioContext === "function" || typeof webkitAudioContext === "function";
5189
- let audioWorklet = typeof AudioWorklet === "function";
5190
- let videoDecoder = typeof VideoDecoder === "function";
5191
- let videoEncoder = typeof VideoEncoder === "function";
5192
- let audioDecoder = typeof AudioDecoder === "function";
5193
- let audioEncoder = typeof AudioEncoder === "function";
5194
- let shareArrayBuffer = typeof SharedArrayBuffer === "function";
5195
- let mse = typeof MediaSource == "function" || typeof ManagedMediaSource === "function";
5196
- let proxy = typeof Proxy === "function";
5197
- let thread = (worker || isWorker() || isAudioWorklet()) && shareArrayBuffer && atomics && proxy;
5198
- let jspi = typeof WebAssembly.Suspending === "function" && typeof WebAssembly.promising === "function";
5199
- if (browser.safari && !browser.checkVersion(browser.majorVersion, "11", true) || os.ios && !browser.checkVersion(os.version, "11", true)) {
5200
- wasm = false;
5201
- }
5202
- if (browser.chrome && !browser.checkVersion(browser.majorVersion, "94", true)) {
5203
- videoDecoder = false;
5204
- audioDecoder = false;
5205
- }
5206
- if (browser.safari && !browser.checkVersion(browser.majorVersion, "17", true) || os.ios && !browser.checkVersion(os.version, "17", true)) {
5207
- videoDecoder = false;
5208
- }
5209
- let webgpu = typeof navigator === "object" && typeof navigator.gpu === "object";
5210
- let workerMSE = typeof MediaSourceHandle === "function";
5211
- let webAssemblyGlobal = wasm && typeof WebAssembly.Global === "function";
5212
- let trackGenerator = typeof MediaStreamTrackGenerator === "function";
5213
- return {
5214
- browser,
5215
- blob,
5216
- wasm,
5217
- fetch: fetchSupported,
5218
- webgl,
5219
- worker,
5220
- mse,
5221
- arrayBuffer,
5222
- audioContext,
5223
- audioWorklet,
5224
- videoDecoder,
5225
- videoEncoder,
5226
- audioDecoder,
5227
- audioEncoder,
5228
- atomics,
5229
- shareArrayBuffer,
5230
- thread,
5231
- webgpu,
5232
- offscreenCanvas,
5233
- workerMSE,
5234
- webAssemblyGlobal,
5235
- jspi,
5236
- proxy,
5237
- simd: (browser.chrome || browser.newEdge) && browser.checkVersion(browser.majorVersion, "91", true) || browser.firefox && browser.checkVersion(browser.majorVersion, "89", true) || browser.safari && browser.checkVersion(browser.version, "16.4", true) || os.ios && browser.checkVersion(os.version, "16.4", true),
5238
- wasmPlayerSupported: fetchSupported && wasm && webgl && audioContext && arrayBuffer && webAssemblyGlobal,
5239
- wasmBaseSupported: wasm && webAssemblyGlobal && arrayBuffer,
5240
- trackGenerator
5241
- };
5242
- }
5243
- supportedFeatures();
5244
- let networkStr;
5245
- let networkType;
5246
- const ua$1 = typeof navigator === "object" && navigator.userAgent || "";
5247
- networkStr = ua$1.match(/NetType\/\w+/) ? ua$1.match(/NetType\/\w+/)[0] : "NetType/other";
5248
- networkStr = networkStr.toLowerCase().replace("nettype/", "");
5249
- const networkMap = {
5250
- "ethernet": "ethernet",
5251
- "wifi": "wifi",
5252
- "5g": "5g",
5253
- "4g": "4g",
5254
- "3g": "3g",
5255
- "3gnet": "3g",
5256
- "2g": "2g",
5257
- "slow-2g": "2g"
5258
- };
5259
- networkType = networkMap[networkStr];
5260
- if (!networkType && typeof navigator === "object") {
5261
- let connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
5262
- if (connection) {
5263
- networkType = networkMap[connection.type];
5264
- if (!networkType) {
5265
- networkType = networkMap[connection.effectiveType];
5266
- }
5267
- }
5268
- }
5269
- if (!networkType) {
5270
- networkType = "unknown";
5271
- }
5272
- let vendor = "unknown";
5273
- let renderer;
5274
- if (typeof window === "object" && window.document) {
5275
- const canvas = document.createElement("canvas");
5276
- const gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
5277
- if (gl == null ? void 0 : gl.getExtension) {
5278
- const extension = gl.getExtension("WEBGL_debug_renderer_info");
5279
- if (extension) {
5280
- let ven = (gl.getParameter(extension.UNMASKED_VENDOR_WEBGL) || "").toLocaleLowerCase();
5281
- renderer = (gl.getParameter(extension.UNMASKED_RENDERER_WEBGL) || "").toLocaleLowerCase();
5282
- if (ven) {
5283
- if (ven.indexOf("apple") > -1) {
5284
- vendor = "apple";
5285
- } else if (ven.indexOf("intel") > -1) {
5286
- vendor = "intel";
5287
- } else if (ven.indexOf("amd") > -1) {
5288
- vendor = "amd";
5289
- } else if (ven.indexOf("nvidia") > -1) {
5290
- vendor = "nvidia";
5291
- }
5292
- }
5293
- }
5294
- }
5295
- }
5296
- const gpu = {
5297
- vendor,
5298
- renderer
5299
- };
5300
- const ua = (typeof navigator === "object" && navigator.userAgent || "").toLocaleLowerCase();
5301
- if (ua.indexOf("intel") > -1) ;
5302
- else if (ua.indexOf("amd") > -1) ;
5303
- if (gpu.vendor === "apple" && gpu.renderer.indexOf("m1") > -1) ;
5304
- if (gpu.vendor === "apple" && gpu.renderer.indexOf("m2") > -1) ;
5305
- const base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
5306
- function atobCustom(encodedString) {
5307
- function decodeBase64(char) {
5308
- const index2 = base64.indexOf(char);
5309
- return index2 === -1 ? 0 : index2;
5310
- }
5311
- let decodedString = "";
5312
- for (let i = 0; i < encodedString.length; ) {
5313
- const enc1 = decodeBase64(encodedString[i++]);
5314
- const enc2 = decodeBase64(encodedString[i++]);
5315
- const enc3 = decodeBase64(encodedString[i++]);
5316
- const enc4 = decodeBase64(encodedString[i++]);
5317
- const chr1 = enc1 << 2 | enc2 >> 4;
5318
- const chr2 = (enc2 & 15) << 4 | enc3 >> 2;
5319
- const chr3 = (enc3 & 3) << 6 | enc4;
5320
- decodedString += String.fromCharCode(chr1);
5321
- if (enc3 !== 64) {
5322
- decodedString += String.fromCharCode(chr2);
5323
- }
5324
- if (enc4 !== 64) {
5325
- decodedString += String.fromCharCode(chr3);
5326
- }
5327
- }
5328
- return decodedString;
5329
- }
5330
- function base64ToUint8Array(string2) {
5331
- const binaryData = typeof atob === "function" ? atob(string2) : atobCustom(string2);
5332
- const uint8Array = new Uint8Array(binaryData.length);
5333
- for (let i = 0; i < binaryData.length; i++) {
5334
- uint8Array[i] = binaryData.charCodeAt(i);
5335
- }
5336
- return uint8Array;
5337
- }
5338
- const list = [
5339
- "A",
5340
- "B",
5341
- "C",
5342
- "D",
5343
- "E",
5344
- "F",
5345
- "G",
5346
- "H",
5347
- "I",
5348
- "J",
5349
- "K",
5350
- "L",
5351
- "M",
5352
- "N",
5353
- "O",
5354
- "P",
5355
- "Q",
5356
- "R",
5357
- "S",
5358
- "T",
5359
- "U",
5360
- "V",
5361
- "W",
5362
- "X",
5363
- "Y",
5364
- "Z",
5365
- "a",
5366
- "b",
5367
- "c",
5368
- "d",
5369
- "e",
5370
- "f",
5371
- "g",
5372
- "h",
5373
- "i",
5374
- "j",
5375
- "k",
5376
- "l",
5377
- "m",
5378
- "n",
5379
- "o",
5380
- "p",
5381
- "q",
5382
- "r",
5383
- "s",
5384
- "t",
5385
- "u",
5386
- "v",
5387
- "w",
5388
- "x",
5389
- "y",
5390
- "z",
5391
- "0",
5392
- "1",
5393
- "2",
5394
- "3",
5395
- "4",
5396
- "5",
5397
- "6",
5398
- "7",
5399
- "8",
5400
- "9",
5401
- "+",
5402
- "/"
5403
- ];
5404
- each$1(list, (char, index2) => {
5405
- });
5406
- typeof TextEncoder === "function" ? new TextEncoder() : null;
5407
- typeof TextDecoder === "function" ? new TextDecoder() : null;
5408
- const charKey = {
5409
- // 英文字母
5410
- a: 65,
5411
- b: 66,
5412
- c: 67,
5413
- d: 68,
5414
- e: 69,
5415
- f: 70,
5416
- g: 71,
5417
- h: 72,
5418
- i: 73,
5419
- j: 74,
5420
- k: 75,
5421
- l: 76,
5422
- m: 77,
5423
- n: 78,
5424
- o: 79,
5425
- p: 80,
5426
- q: 81,
5427
- r: 82,
5428
- s: 83,
5429
- t: 84,
5430
- u: 85,
5431
- v: 86,
5432
- w: 87,
5433
- x: 88,
5434
- y: 89,
5435
- z: 90,
5436
- // 主键盘数字键
5437
- "0": 48,
5438
- "1": 49,
5439
- "2": 50,
5440
- "3": 51,
5441
- "4": 52,
5442
- "5": 53,
5443
- "6": 54,
5444
- "7": 55,
5445
- "8": 56,
5446
- "9": 57,
5447
- // 主键盘几个特殊字符
5448
- "`": 192,
5449
- "+": 187,
5450
- "-": 189,
5451
- "=": 61,
5452
- "[": 219,
5453
- "]": 221,
5454
- "\\": 220,
5455
- ";": 59,
5456
- "'": 222,
5457
- ",": 188,
5458
- ".": 190,
5459
- "/": 191,
5460
- // 小键盘(统一加前缀 $)
5461
- "$0": 96,
5462
- "$1": 97,
5463
- "$2": 98,
5464
- "$3": 99,
5465
- "$4": 100,
5466
- "$5": 101,
5467
- "$6": 102,
5468
- "$7": 103,
5469
- "$8": 104,
5470
- "$9": 105,
5471
- "$.": 110,
5472
- "$+": 107,
5473
- "$-": 109,
5474
- "$*": 106,
5475
- "$/": 111,
5476
- space: 32,
5477
- tab: 9
5478
- };
5479
- const deleteKey = {
5480
- backspace: 8,
5481
- "delete": 46
5482
- };
5483
- const functionKey = {
5484
- // F1 -> F12
5485
- f1: 112,
5486
- f2: 113,
5487
- f3: 114,
5488
- f4: 115,
5489
- f5: 116,
5490
- f6: 117,
5491
- f7: 118,
5492
- f8: 119,
5493
- f9: 120,
5494
- f10: 121,
5495
- f11: 122,
5496
- f12: 123,
5497
- // 常用的控制键
5498
- enter: 13,
5499
- esc: 27,
5500
- capslock: 20,
5501
- insert: 45,
5502
- home: 36,
5503
- end: 35,
5504
- pageup: 33,
5505
- pagedown: 34,
5506
- // 方向键
5507
- left: 37,
5508
- right: 39,
5509
- up: 38,
5510
- down: 40
5511
- };
5512
- const combinationKey = {
5513
- shift: 16,
5514
- ctrl: 17,
5515
- meta: 91,
5516
- alt: 18
5517
- };
5518
- reverse(charKey);
5519
- reverse(deleteKey);
5520
- reverse(functionKey);
5521
- reverse(combinationKey);
5522
- /common/.test(toString(EMPTY_FUNCTION)) && (!WINDOW || WINDOW.DEBUG !== false) || WINDOW && WINDOW.DEBUG;
5523
- WebAssembly.validate(base64ToUint8Array("AGFzbQEAAAABBgFgAX8BfwISAQNlbnYGbWVtb3J5AgMBgIACAwIBAAcJAQVsb2FkOAAACgoBCAAgAP4SAAAL"));
5524
- WebAssembly.validate(base64ToUint8Array("AGFzbQEAAAABBQFgAAF7AhIBA2VudgZtZW1vcnkCAwGAgAIDAgEACgoBCABBAP0ABAAL"));
5525
- var VideoCodecType;
5526
- (function(VideoCodecType2) {
5527
- VideoCodecType2["H264"] = "h264";
5528
- VideoCodecType2["H265"] = "h265";
5529
- VideoCodecType2["VP8"] = "vp8";
5530
- VideoCodecType2["VP9"] = "vp9";
5531
- VideoCodecType2["AV1"] = "av1";
5532
- })(VideoCodecType || (VideoCodecType = {}));
5533
- const CodecStringMap = {
5534
- [VideoCodecType.H264]: "avc1.42E01E",
5535
- // baseline profile
5536
- [VideoCodecType.H265]: "hvc1.1.6.L93.B0",
5537
- // HEVC main profile
5538
- [VideoCodecType.VP8]: "vp8",
5539
- [VideoCodecType.VP9]: "vp09.00.10.08",
5540
- [VideoCodecType.AV1]: "av01.0.04M.08"
5541
- };
5542
- async function checkDecoderSupport(codec) {
5543
- if (typeof VideoDecoder === "undefined" || !VideoDecoder.isConfigSupported) {
5544
- return { supported: false, hardware: false, software: false };
5545
- }
5546
- const baseConfig = {
5547
- codec: CodecStringMap[codec],
5548
- codedWidth: 720,
5549
- codedHeight: 1280
5550
- };
5551
- let supported = false;
5552
- let hardware = false;
5553
- let software = false;
5554
- try {
5555
- const basic = await VideoDecoder.isConfigSupported(baseConfig);
5556
- supported = basic.supported === true;
5557
- } catch {
5558
- }
5559
- if (!supported) {
5560
- return { supported: false, hardware: false, software: false };
5561
- }
5562
- try {
5563
- const hard = await VideoDecoder.isConfigSupported({
5564
- ...baseConfig,
5565
- hardwareAcceleration: "prefer-hardware"
5566
- });
5567
- if (hard.supported) {
5568
- hardware = true;
5569
- }
5570
- } catch {
5571
- }
5572
- try {
5573
- const soft = await VideoDecoder.isConfigSupported({
5574
- ...baseConfig,
5575
- hardwareAcceleration: "prefer-software"
5576
- });
5577
- if (soft.supported) {
5578
- software = true;
5579
- }
5580
- } catch {
5581
- }
5582
- if (!hardware && !software) {
5583
- const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
5584
- if (isSafari) {
5585
- software = true;
5586
- }
5587
- }
5588
- return { supported, hardware, software };
5589
- }
5590
- const isMobileDevice = () => {
5591
- if (typeof navigator === "undefined")
5592
- return true;
5593
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS|OPiOS/i.test(navigator.userAgent);
5594
- };
5595
- let _webgpuChecked = false;
5596
- let _webgpuSupported = false;
5597
- const isWebGPUSupported = async () => {
5598
- var _a;
5599
- if (_webgpuChecked)
5600
- return _webgpuSupported;
5601
- if (isMobileDevice()) {
5602
- _webgpuSupported = false;
5603
- _webgpuChecked = true;
5604
- return false;
5605
- }
5606
- if (!("gpu" in navigator) || typeof ((_a = navigator.gpu) == null ? void 0 : _a.requestAdapter) !== "function") {
5607
- _webgpuSupported = false;
5608
- _webgpuChecked = true;
5609
- return false;
5610
- }
5611
- try {
5612
- const adapter = await navigator.gpu.requestAdapter();
5613
- _webgpuSupported = !!adapter;
5614
- } catch (e) {
5615
- console.warn("[WebGPU] detection failed:", e);
5616
- _webgpuSupported = false;
5617
- } finally {
5618
- _webgpuChecked = true;
5619
- }
5620
- return _webgpuSupported;
5621
- };
5622
- let _webgl2Checked = false;
5623
- let _webgl2Supported = false;
5624
- const isWebGL2Supported = (canvas) => {
5625
- if (_webgl2Checked)
5626
- return _webgl2Supported;
5627
- const testCanvas = document.createElement("canvas");
5628
- const contextNames = ["webgl2", "experimental-webgl2"];
5629
- let gl = null;
5630
- for (const name of contextNames) {
5631
- try {
5632
- gl = testCanvas.getContext(name);
5633
- if (gl)
5634
- break;
5635
- } catch (_) {
5636
- }
5637
- }
5638
- _webgl2Supported = !!gl;
5639
- _webgl2Checked = true;
5640
- return _webgl2Supported;
5641
- };
5642
- let _webgl1Checked = false;
5643
- let _webgl1Supported = false;
5644
- const isWebGL1Supported = (canvas) => {
5645
- if (_webgl1Checked)
5646
- return _webgl1Supported;
5647
- const testCanvas = document.createElement("canvas");
5648
- const contextNames = [
5649
- "webgl",
5650
- "experimental-webgl",
5651
- "webkit-3d",
5652
- "moz-webgl"
5653
- ];
5654
- let gl = null;
5655
- for (const name of contextNames) {
5656
- try {
5657
- gl = testCanvas.getContext(name);
5658
- if (gl)
5659
- break;
5660
- } catch (_) {
5661
- }
5662
- }
5663
- if (gl) {
5664
- const debugInfo = gl.getExtension("WEBGL_debug_renderer_info");
5665
- if (debugInfo) {
5666
- const renderer2 = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
5667
- if (renderer2 && /llvmpipe|software/i.test(renderer2)) {
5668
- gl = null;
5669
- }
5670
- }
5671
- }
5672
- _webgl1Supported = !!gl;
5673
- _webgl1Checked = true;
5674
- return _webgl1Supported;
5675
- };
5676
- let _canvas2dChecked = false;
5677
- let _canvas2dSupported = false;
5678
- const isCanvas2DSupported = (canvas) => {
5679
- if (_canvas2dChecked)
5680
- return _canvas2dSupported;
5681
- const testCanvas = document.createElement("canvas");
5682
- let ctx = null;
5683
- try {
5684
- ctx = testCanvas.getContext("2d", {
5685
- // 防止某些极端隐私模式下返回 null
5686
- alpha: true,
5687
- desynchronized: false
5688
- });
5689
- } catch (_) {
5690
- ctx = null;
5691
- }
5692
- if (ctx && typeof ctx.fillRect === "function") {
5693
- _canvas2dSupported = true;
5694
- } else {
5695
- _canvas2dSupported = false;
5696
- }
5697
- _canvas2dChecked = true;
5698
- return _canvas2dSupported;
5699
- };
5700
- const detectRenderingCapabilities = async () => {
5701
- const [webgpu, webgl2, webgl1, canvas2d] = await Promise.all([
5702
- isWebGPUSupported(),
5703
- Promise.resolve(isWebGL2Supported()),
5704
- Promise.resolve(isWebGL1Supported()),
5705
- Promise.resolve(isCanvas2DSupported())
5706
- ]);
5707
- const best = webgpu && "webgpu" || webgl2 && "webgl2" || webgl1 && "webgl1" || canvas2d && "canvas2d" || "none";
5708
- return { webgpu, webgl2, webgl1, canvas2d, best };
5709
- };
5710
- function useRemoteVideo(videoContainer, remoteVideoElement, audioElement, videoAngle, emit) {
5048
+ function useRemoteVideo(videoContainer, remoteVideoElement, videoAngle, emit) {
5711
5049
  const screenStatus = ref(false);
5712
5050
  const remoteVideo = ref({});
5713
5051
  const dimensions = ref({ width: 0, height: 0 });
5714
5052
  const widthRadio = ref(0);
5715
5053
  const heightRadio = ref(0);
5716
5054
  const resizeObserver = ref(null);
5717
- const renderType = ref(null);
5718
5055
  const isRotated = computed(() => videoAngle.value % 180 !== 0);
5719
- const worker = ref(null);
5720
- const offscreen = ref(null);
5721
- const workerInited = ref(false);
5722
- const visible = ref(true);
5056
+ const frameCallbackId = ref(0);
5723
5057
  const videoSize = computed(() => {
5724
- let width;
5725
- let height;
5058
+ let width = 0;
5059
+ let height = 0;
5726
5060
  const containerWidth = isRotated.value ? dimensions.value.height : dimensions.value.width;
5727
5061
  const containerHeight = isRotated.value ? dimensions.value.width : dimensions.value.height;
5728
5062
  const vWidth = remoteVideo.value.width ?? 720;
@@ -5740,156 +5074,98 @@ function useRemoteVideo(videoContainer, remoteVideoElement, audioElement, videoA
5740
5074
  heightRadio.value = vHeight / height;
5741
5075
  return { width, height };
5742
5076
  });
5743
- const waitingKeyFrame = ref(true);
5744
- const checkResult = ref(null);
5745
5077
  const observeContainer = () => {
5746
- if (!videoContainer.value)
5747
- return;
5078
+ if (!videoContainer.value) return;
5748
5079
  resizeObserver.value = new ResizeObserver(([entry]) => {
5749
5080
  const { width, height } = entry.contentRect;
5750
5081
  dimensions.value = { width, height };
5751
5082
  });
5752
5083
  resizeObserver.value.observe(videoContainer.value);
5753
5084
  };
5085
+ const bindVideoEvents = () => {
5086
+ const video = remoteVideoElement.value;
5087
+ if (!video) return;
5088
+ const handleMetadata = () => {
5089
+ remoteVideo.value = {
5090
+ width: video.videoWidth,
5091
+ height: video.videoHeight
5092
+ };
5093
+ screenStatus.value = true;
5094
+ emit("loadedSuccess");
5095
+ };
5096
+ video.addEventListener("loadedmetadata", handleMetadata);
5097
+ onBeforeUnmount(() => {
5098
+ video.removeEventListener("loadedmetadata", handleMetadata);
5099
+ if (frameCallbackId.value) video.cancelVideoFrameCallback(frameCallbackId.value);
5100
+ });
5101
+ };
5754
5102
  const initVideoContainer = () => {
5755
5103
  observeContainer();
5756
5104
  bindVideoEvents();
5757
5105
  };
5758
- const bindVideoEvents = async () => {
5106
+ const startPlay = (track) => {
5759
5107
  const video = remoteVideoElement.value;
5760
- if (!video)
5761
- return;
5762
- checkResult.value = await checkDecoderSupport(VideoCodecType.H265);
5763
- renderType.value = (await detectRenderingCapabilities()).best;
5764
- initWorker(video);
5765
- };
5766
- const initWorker = (video) => {
5767
- var _a, _b;
5768
- if (workerInited.value)
5769
- return;
5770
- worker.value = new Worker(new URL(
5771
- /* @vite-ignore */
5772
- "/worker/worker.js",
5773
- import.meta.url
5774
- ), {
5775
- type: "module"
5776
- });
5777
- if (!offscreen.value) {
5778
- offscreen.value = video.transferControlToOffscreen();
5779
- offscreen.value.width = 720;
5780
- offscreen.value.height = 1280;
5781
- }
5782
- worker.value.onmessage = (event) => {
5783
- const { data } = event;
5784
- switch (data.type) {
5785
- case "decoderError":
5786
- case "rendererError":
5787
- emit("loadedFailure", data.error);
5788
- break;
5789
- }
5790
- };
5791
- worker.value.postMessage({
5792
- type: "init",
5793
- supportH265: (_a = checkResult.value) == null ? void 0 : _a.supported,
5794
- isHardware: (_b = checkResult.value) == null ? void 0 : _b.hardware,
5795
- canvas: offscreen.value,
5796
- pixelRatio: window.devicePixelRatio | 1,
5797
- renderType: renderType.value
5798
- }, [offscreen.value]);
5799
- workerInited.value = true;
5800
- };
5801
- const startDecode = (arrayBuffer) => {
5802
- handleMessage(arrayBuffer);
5108
+ if (!video) return;
5109
+ video.play();
5110
+ replaceVideoTrack(video, track);
5803
5111
  };
5804
- const handleMessage = (arrayBuffer) => {
5805
- const data = new Uint8Array(arrayBuffer);
5806
- if (data.length < 4)
5807
- return;
5808
- const labelLen = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
5809
- if (data.length < 4 + labelLen)
5810
- return;
5811
- const labelBytes = data.subarray(4, 4 + labelLen);
5812
- const label = new TextDecoder().decode(labelBytes);
5813
- const frame = data.subarray(4 + labelLen);
5814
- decodeVideo(label, frame);
5815
- };
5816
- const decodeVideo = (label, data) => {
5817
- var _a;
5818
- if (label !== "key" && !visible) {
5819
- return;
5820
- }
5821
- if (label === "config") {
5822
- return;
5823
- }
5824
- if (waitingKeyFrame.value) {
5825
- if (label === "delta") {
5826
- return;
5827
- }
5828
- waitingKeyFrame.value = false;
5829
- emit("loadedSuccess");
5830
- }
5831
- (_a = worker.value) == null ? void 0 : _a.postMessage({
5832
- type: "decode",
5833
- label,
5834
- data
5835
- }, [data.buffer]);
5836
- };
5837
- const stopPlay = () => {
5838
- var _a;
5839
- screenStatus.value = false;
5840
- waitingKeyFrame.value = true;
5841
- const audio = audioElement.value;
5842
- (_a = worker.value) == null ? void 0 : _a.postMessage({ type: "clearRender" });
5843
- if (audio && audio.srcObject) {
5844
- const stream = audio.srcObject;
5845
- stream.getTracks().forEach((t) => t.stop());
5846
- audio.pause();
5847
- audio.srcObject = null;
5848
- }
5849
- };
5850
- const startPlayTrack = (track) => {
5851
- const audio = audioElement.value;
5852
- if (!audio)
5853
- return;
5854
- replaceAudioTrack(audio, track);
5855
- audio.autoplay = true;
5856
- audio.muted = false;
5857
- audio.setAttribute("playsinline", "true");
5858
- audio.setAttribute("webkit-playsinline", "true");
5859
- };
5860
- const replaceAudioTrack = (audioEl, newTrack) => {
5861
- if (!audioEl.srcObject) {
5862
- audioEl.srcObject = new MediaStream();
5863
- }
5864
- const stream = audioEl.srcObject;
5865
- updateTrack(stream, newTrack);
5112
+ const replaceVideoTrack = (videoEl, newTrack) => {
5113
+ if (!videoEl.srcObject) {
5114
+ videoEl.srcObject = new MediaStream();
5115
+ }
5116
+ const mediaStream = videoEl.srcObject;
5117
+ updateTrack(mediaStream, newTrack);
5118
+ videoEl.playbackRate = 1;
5119
+ videoEl.playsInline = true;
5120
+ videoEl.disablePictureInPicture = true;
5121
+ videoEl.setAttribute("playsinline", "true");
5122
+ videoEl.setAttribute("webkit-playsinline", "true");
5123
+ videoEl.setAttribute("x5-video-player-type", "h5");
5124
+ videoEl.setAttribute("x5-video-player-fullscreen", "false");
5125
+ videoEl.setAttribute("x5-video-orientation", "portraint");
5126
+ videoEl.preload = "auto";
5866
5127
  };
5867
5128
  const updateTrack = (stream, newTrack) => {
5868
- if (newTrack.kind === "audio") {
5869
- stream.getAudioTracks().forEach((oldTrack) => {
5129
+ if (newTrack.kind === "video") {
5130
+ stream.getVideoTracks().forEach((oldTrack) => {
5870
5131
  stream.removeTrack(oldTrack);
5871
5132
  oldTrack.stop();
5872
5133
  });
5873
5134
  stream.addTrack(newTrack);
5135
+ } else if (newTrack.kind === "audio") {
5136
+ if (!stream.getAudioTracks().some((t) => t.id === newTrack.id)) {
5137
+ stream.addTrack(newTrack);
5138
+ }
5139
+ }
5140
+ };
5141
+ const stopPlay = () => {
5142
+ screenStatus.value = false;
5143
+ const video = remoteVideoElement.value;
5144
+ if (video && video.srcObject) {
5145
+ video.srcObject.getTracks().forEach((track) => track.stop());
5146
+ video.srcObject = null;
5147
+ video.pause();
5148
+ if (frameCallbackId.value) video.cancelVideoFrameCallback(frameCallbackId.value);
5874
5149
  }
5875
5150
  };
5876
5151
  const handleVisibilityChange = () => {
5877
- visible.value = document.visibilityState === "visible";
5152
+ const video = remoteVideoElement.value;
5153
+ if (!video || !video.srcObject) return;
5154
+ video.srcObject.getTracks().forEach((track) => {
5155
+ if (track.kind === "audio") {
5156
+ track.enabled = document.visibilityState === "visible";
5157
+ }
5158
+ });
5878
5159
  };
5879
5160
  onMounted(() => {
5880
5161
  document.addEventListener("visibilitychange", handleVisibilityChange);
5881
5162
  });
5882
- onBeforeUnmount(async () => {
5883
- var _a;
5163
+ onBeforeUnmount(() => {
5884
5164
  document.removeEventListener("visibilitychange", handleVisibilityChange);
5885
5165
  if (resizeObserver.value && videoContainer.value) {
5886
5166
  resizeObserver.value.unobserve(videoContainer.value);
5887
5167
  }
5888
5168
  stopPlay();
5889
- (_a = worker.value) == null ? void 0 : _a.postMessage({ type: "stopDecode" });
5890
- if (worker.value) {
5891
- worker.value.terminate();
5892
- }
5893
5169
  });
5894
5170
  return {
5895
5171
  videoSize,
@@ -5899,13 +5175,20 @@ function useRemoteVideo(videoContainer, remoteVideoElement, audioElement, videoA
5899
5175
  heightRadio,
5900
5176
  screenStatus,
5901
5177
  initVideoContainer,
5902
- startDecode,
5903
- stopPlay,
5904
- startPlayTrack
5178
+ startPlay,
5179
+ stopPlay
5905
5180
  };
5906
5181
  }
5907
5182
  function useMouseTouchControl(options) {
5908
- const { remoteVideoElement, cloudDeviceSize, streamAngle, videoAngle, widthRadio, isGroup, emit } = options;
5183
+ const {
5184
+ remoteVideoElement,
5185
+ cloudDeviceSize,
5186
+ streamAngle,
5187
+ videoAngle,
5188
+ widthRadio,
5189
+ isGroup,
5190
+ emit
5191
+ } = options;
5909
5192
  const isPointerDown = ref(false);
5910
5193
  const bound = ref(0);
5911
5194
  const pointerList = ref(new Array(20).fill(0));
@@ -5913,24 +5196,30 @@ function useMouseTouchControl(options) {
5913
5196
  const index2 = ref(0);
5914
5197
  const groupIndex = ref(0);
5915
5198
  const handlePointerEvent = (event, action) => {
5916
- if (!remoteVideoElement.value)
5917
- return;
5199
+ if (!remoteVideoElement.value) return;
5918
5200
  const offsetTime = Math.trunc(event.timeStamp - pointerDownTime.value[0]);
5919
5201
  const rect = remoteVideoElement.value.getBoundingClientRect();
5920
5202
  let x = event.clientX - rect.left;
5921
5203
  let y = event.clientY - rect.top;
5922
5204
  const cloudWidth = cloudDeviceSize.value.width;
5923
5205
  const cloudHeight = cloudDeviceSize.value.height;
5924
- const result = transformCoordinate(rect.width, rect.height, cloudWidth, cloudHeight, videoAngle.value, streamAngle.value, x, y);
5925
- if (!result || result.length < 2)
5926
- return;
5206
+ const result = transformCoordinate(
5207
+ rect.width,
5208
+ rect.height,
5209
+ cloudWidth,
5210
+ cloudHeight,
5211
+ videoAngle.value,
5212
+ streamAngle.value,
5213
+ x,
5214
+ y
5215
+ );
5216
+ if (!result || result.length < 2) return;
5927
5217
  x = result[0];
5928
5218
  y = result[1];
5929
5219
  if (action === ActionType.ACTION_MOVE) {
5930
5220
  const flipY = pointerList.value[10] - y;
5931
5221
  const flipX = pointerList.value[0] - x;
5932
- if (Math.abs(flipY) < bound.value && Math.abs(flipX) < bound.value)
5933
- return;
5222
+ if (Math.abs(flipY) < bound.value && Math.abs(flipX) < bound.value) return;
5934
5223
  }
5935
5224
  if (isGroup.value) {
5936
5225
  if (action === ActionType.ACTION_DOWN) {
@@ -5942,7 +5231,16 @@ function useMouseTouchControl(options) {
5942
5231
  }
5943
5232
  pointerList.value[0] = x;
5944
5233
  pointerList.value[10] = y;
5945
- const [px, py] = valueToPercentage(rect.width, rect.height, cloudWidth, cloudHeight, videoAngle.value, streamAngle.value, x, y);
5234
+ const [px, py] = valueToPercentage(
5235
+ rect.width,
5236
+ rect.height,
5237
+ cloudWidth,
5238
+ cloudHeight,
5239
+ videoAngle.value,
5240
+ streamAngle.value,
5241
+ x,
5242
+ y
5243
+ );
5946
5244
  const touchData = isGroup.value ? new TouchData(action, 0, px, py, offsetTime, "web", index2.value, groupIndex.value) : new TouchData(action, 0, px, py, offsetTime, "web");
5947
5245
  emit("channelEvent", ChannelDataType.ClickData, touchData);
5948
5246
  };
@@ -5956,8 +5254,7 @@ function useMouseTouchControl(options) {
5956
5254
  handlePointerEvent(event, ActionType.ACTION_DOWN);
5957
5255
  };
5958
5256
  const handleMouseMove = (event) => {
5959
- if (!isPointerDown.value)
5960
- return;
5257
+ if (!isPointerDown.value) return;
5961
5258
  handlePointerEvent(event, ActionType.ACTION_MOVE);
5962
5259
  if (!remoteVideoElement.value) {
5963
5260
  return;
@@ -5969,8 +5266,7 @@ function useMouseTouchControl(options) {
5969
5266
  }
5970
5267
  };
5971
5268
  const handleMouseUp = (event) => {
5972
- if (!isPointerDown.value)
5973
- return;
5269
+ if (!isPointerDown.value) return;
5974
5270
  isPointerDown.value = false;
5975
5271
  handlePointerEvent(event, ActionType.ACTION_UP);
5976
5272
  if (remoteVideoElement.value) {
@@ -6048,24 +5344,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6048
5344
  bgColor: { default: "transparent" },
6049
5345
  isGroup: { type: Boolean, default: false }
6050
5346
  },
6051
- emits: ["channelEvent", "groupControlEvent", "loadedSuccess", "loadedFailure"],
5347
+ emits: ["channelEvent", "groupControlEvent", "loadedSuccess"],
6052
5348
  setup(__props, { expose: __expose, emit: __emit }) {
6053
5349
  const emit = __emit;
6054
5350
  const props = __props;
6055
5351
  const { streamAngle, videoAngle, cursorType, cloudDeviceSize, disabled, bgColor, isGroup } = toRefs(props);
6056
5352
  const videoContainer = ref(null);
6057
5353
  const remoteVideoElement = ref(null);
6058
- const audioElement = ref(null);
6059
5354
  const cursorClass = useCursorStyle(cursorType);
6060
5355
  const {
6061
5356
  videoSize,
6062
5357
  dimensions,
6063
5358
  widthRadio,
6064
5359
  initVideoContainer,
6065
- startDecode,
6066
- stopPlay,
6067
- startPlayTrack
6068
- } = useRemoteVideo(videoContainer, remoteVideoElement, audioElement, videoAngle, emit);
5360
+ startPlay,
5361
+ stopPlay
5362
+ } = useRemoteVideo(videoContainer, remoteVideoElement, videoAngle, emit);
6069
5363
  const {
6070
5364
  handleMouseDown,
6071
5365
  handleMouseMove,
@@ -6088,10 +5382,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6088
5382
  } = useKeyboardControl(disabled, emit);
6089
5383
  useResizeObserver(videoContainer, dimensions);
6090
5384
  const handleClick = () => {
6091
- if (audioElement.value) {
6092
- audioElement.value.muted = false;
6093
- audioElement.value.play().catch(() => {
6094
- });
5385
+ var _a;
5386
+ if ((_a = remoteVideoElement.value) == null ? void 0 : _a.srcObject) {
5387
+ remoteVideoElement.value.muted = false;
6095
5388
  }
6096
5389
  };
6097
5390
  onMounted(() => {
@@ -6101,7 +5394,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6101
5394
  onBeforeUnmount(() => {
6102
5395
  document.removeEventListener("click", handleClick);
6103
5396
  });
6104
- __expose({ startDecode, stopPlay, remoteVideoElement, startPlayTrack });
5397
+ __expose({ startPlay, stopPlay, remoteVideoElement });
6105
5398
  return (_ctx, _cache) => {
6106
5399
  return openBlock(), createElementBlock("div", {
6107
5400
  ref_key: "videoContainer",
@@ -6118,10 +5411,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6118
5411
  class: "vContainer",
6119
5412
  style: normalizeStyle([{ height: unref(videoSize).height + "px", width: unref(videoSize).width + "px", transform: `rotate(${unref(videoAngle)}deg)` }, { "position": "relative", "overflow": "hidden" }])
6120
5413
  }, [
6121
- createElementVNode("canvas", {
5414
+ createElementVNode("video", {
6122
5415
  ref_key: "remoteVideoElement",
6123
5416
  ref: remoteVideoElement,
6124
- class: normalizeClass(["canvas-control", [unref(cursorClass), { "no-events": unref(disabled) }]]),
5417
+ class: normalizeClass(["video-control", [unref(cursorClass), { "no-events": unref(disabled) }]]),
6125
5418
  onPointerenter: _cache[0] || (_cache[0] = //@ts-ignore
6126
5419
  (...args) => unref(handleMouseEnter) && unref(handleMouseEnter)(...args)),
6127
5420
  onPointerdown: _cache[1] || (_cache[1] = //@ts-ignore
@@ -6134,17 +5427,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6134
5427
  (...args) => unref(handleMouseLeave) && unref(handleMouseLeave)(...args)),
6135
5428
  onWheel: _cache[5] || (_cache[5] = //@ts-ignore
6136
5429
  (...args) => unref(handleWheel) && unref(handleWheel)(...args)),
6137
- hidden: "hidden",
6138
- style: normalizeStyle({ backgroundColor: `${unref(bgColor)}` })
6139
- }, null, 38),
6140
- createElementVNode("audio", {
6141
- ref_key: "audioElement",
6142
- ref: audioElement,
5430
+ style: normalizeStyle({ backgroundColor: `${unref(bgColor)}` }),
6143
5431
  autoplay: "",
6144
5432
  playsinline: "",
6145
5433
  muted: "",
6146
- style: { "display": "none" }
6147
- }, null, 512)
5434
+ disablePictureInPicture: true
5435
+ }, null, 38)
6148
5436
  ], 36)
6149
5437
  ], 512);
6150
5438
  };
@@ -6157,10 +5445,12 @@ const _export_sfc = (sfc, props) => {
6157
5445
  }
6158
5446
  return target;
6159
5447
  };
6160
- const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-92723927"]]);
5448
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-611728c2"]]);
6161
5449
  class SdkController extends EventEmitter {
6162
5450
  constructor(config) {
6163
5451
  super();
5452
+ __publicField(this, "sdk");
5453
+ __publicField(this, "config");
6164
5454
  this.config = config;
6165
5455
  this.sdk = new WebRTCSdk(this.config);
6166
5456
  this.initSdk();
@@ -6231,7 +5521,9 @@ class SdkController extends EventEmitter {
6231
5521
  }
6232
5522
  class GroupCtrlSocketManager {
6233
5523
  constructor(config) {
6234
- this.isSynchronous = true;
5524
+ __publicField(this, "config");
5525
+ __publicField(this, "websocketModeSdkController");
5526
+ __publicField(this, "isSynchronous", true);
6235
5527
  this.config = config;
6236
5528
  enableLog(!!this.config.enableLogger);
6237
5529
  if (this.config.enableLogger !== void 0 && this.config.enableLogger) {