yjz-web-sdk 1.0.0 → 1.0.2

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,6 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import { ref, computed, onMounted, onUnmounted, defineComponent, toRefs, createElementBlock, openBlock, createElementVNode, normalizeStyle, unref, normalizeClass } from "vue";
4
5
  function _mergeNamespaces(n, m) {
5
6
  for (var i = 0; i < m.length; i++) {
6
7
  const e = m[i];
@@ -322,6 +323,7 @@ class SignalingClient extends EventEmitter {
322
323
  start() {
323
324
  this.webSocket = new WebSocket(this.config.signalServerUrl);
324
325
  this.webSocket.onopen = () => {
326
+ console.log("sendSignInMessagesendSignInMessagesendSignInMessage");
325
327
  this.sendSignInMessage();
326
328
  if (this.timeout === null) {
327
329
  this.timeout = setTimeout(() => {
@@ -383,144 +385,6 @@ class SignalingClient extends EventEmitter {
383
385
  this.sendMessage(jsonMessage);
384
386
  }
385
387
  }
386
- var ChannelDataType = /* @__PURE__ */ ((ChannelDataType2) => {
387
- ChannelDataType2["ClickData"] = "ClickData";
388
- ChannelDataType2["ClipboardData"] = "ClipboardData";
389
- ChannelDataType2["ActionCommand"] = "ActionCommand";
390
- ChannelDataType2["ActionInput"] = "ActionInput";
391
- ChannelDataType2["ActionChinese"] = "ActionChinese";
392
- ChannelDataType2["ActionRequestCloudDeviceInfo"] = "ActionRequestCloudDeviceInfo";
393
- ChannelDataType2["ActionClarity"] = "ActionClarity";
394
- return ChannelDataType2;
395
- })(ChannelDataType || {});
396
- const ActionType = Object.freeze({
397
- ACTION_DOWN: 0,
398
- ACTION_MOVE: 2,
399
- ACTION_UP: 1
400
- });
401
- const StreamRotation = {
402
- ROTATION_0: 0,
403
- ROTATION_180: 2
404
- };
405
- const ContainerDirection = {
406
- Vertical: 0,
407
- Horizontal: 1
408
- };
409
- class TouchData {
410
- constructor(action, p, x, y, offsetTime, type = "adb") {
411
- __publicField(this, "action");
412
- __publicField(this, "p");
413
- __publicField(this, "x");
414
- __publicField(this, "y");
415
- __publicField(this, "offsetTime");
416
- __publicField(this, "type");
417
- this.action = action;
418
- this.p = p;
419
- this.x = x;
420
- this.y = y;
421
- this.offsetTime = offsetTime;
422
- this.type = type;
423
- }
424
- }
425
- class InputData {
426
- constructor(text) {
427
- __publicField(this, "text");
428
- this.text = text;
429
- }
430
- }
431
- class KeyEventData {
432
- constructor(keyCode, meta) {
433
- __publicField(this, "keyCode");
434
- __publicField(this, "meta");
435
- this.keyCode = keyCode;
436
- this.meta = meta;
437
- }
438
- }
439
- class ChannelData {
440
- constructor(type, data = null) {
441
- __publicField(this, "type");
442
- __publicField(this, "data");
443
- this.type = type;
444
- this.data = data;
445
- }
446
- toString() {
447
- return JSON.stringify({ type: this.type, data: this.data });
448
- }
449
- /**
450
- * 格式化数据
451
- * 如果数据已经是字符串,则直接返回;否则使用 JSON.stringify() 转换为字符串
452
- * @param data 待转换数据
453
- * @returns 格式化后的字符串
454
- */
455
- static formatData(data) {
456
- return typeof data === "string" ? data : JSON.stringify(data);
457
- }
458
- /**
459
- * 生成点击数据
460
- * @param touchData 触摸数据,可以是任意类型
461
- */
462
- static click(touchData) {
463
- return new ChannelData("ClickData", this.formatData(touchData));
464
- }
465
- /**
466
- * 生成剪贴板数据
467
- * @param data 剪贴板数据,可以是字符串或其他类型
468
- */
469
- static clipboard(data) {
470
- return new ChannelData("ClipboardData", this.formatData(data));
471
- }
472
- /**
473
- * 生成输入数据
474
- * @param data 输入数据对象
475
- */
476
- static input(data) {
477
- return new ChannelData("ActionInput", this.formatData(data));
478
- }
479
- /**
480
- * 生成中文输入数据
481
- * @param data 中文输入数据
482
- */
483
- static chinese(data) {
484
- return new ChannelData("ActionChinese", this.formatData(data));
485
- }
486
- /**
487
- * 生成请求云设备信息数据
488
- */
489
- static requestCloudDeviceInfo() {
490
- return new ChannelData("ActionRequestCloudDeviceInfo", "");
491
- }
492
- /**
493
- * 生成清晰度数据(clarity)
494
- * @param data 清晰度数据
495
- */
496
- static clarity(data) {
497
- return new ChannelData("ActionClarity", this.formatData(data));
498
- }
499
- }
500
- class WebRTCConfig {
501
- constructor(options = {}) {
502
- __publicField(this, "signalServerUrl");
503
- __publicField(this, "myId");
504
- __publicField(this, "roomId");
505
- __publicField(this, "targetId");
506
- __publicField(this, "stunServerUri");
507
- __publicField(this, "stunServerUriAli");
508
- __publicField(this, "stunServerUriTel");
509
- __publicField(this, "turnServerUri");
510
- __publicField(this, "turnServerUserName");
511
- __publicField(this, "turnServerPassword");
512
- this.signalServerUrl = options.signalServerUrl || "";
513
- this.myId = options.myId || "";
514
- this.roomId = options.roomId || "";
515
- this.targetId = options.targetId || "";
516
- this.stunServerUri = options.stunServerUri || "stun:stun.l.google.com:19302";
517
- this.stunServerUriAli = options.stunServerUriAli || "stun:stun.middle.aliyun.com:3478";
518
- this.stunServerUriTel = options.stunServerUriTel || "stun:stun.qq.com:3478";
519
- this.turnServerUri = options.turnServerUri || "turn:btweb.yajuzhen.com:3478";
520
- this.turnServerUserName = options.turnServerUserName || "yangyj";
521
- this.turnServerPassword = options.turnServerPassword || "hb@2025@168";
522
- }
523
- }
524
388
  let logDisabled_ = true;
525
389
  let deprecationWarnings_ = true;
526
390
  function extractVersion(uastring, expr, pos) {
@@ -1783,11 +1647,11 @@ function shimLocalStreamsAPI(window2) {
1783
1647
  if (!this._localStreams) {
1784
1648
  this._localStreams = [];
1785
1649
  }
1786
- const index = this._localStreams.indexOf(stream);
1787
- if (index === -1) {
1650
+ const index2 = this._localStreams.indexOf(stream);
1651
+ if (index2 === -1) {
1788
1652
  return;
1789
1653
  }
1790
- this._localStreams.splice(index, 1);
1654
+ this._localStreams.splice(index2, 1);
1791
1655
  const tracks = stream.getTracks();
1792
1656
  this.getSenders().forEach((sender) => {
1793
1657
  if (tracks.includes(sender.track)) {
@@ -1942,7 +1806,7 @@ function shimRTCIceServerUrls(window2) {
1942
1806
  return;
1943
1807
  }
1944
1808
  const OrigPeerConnection = window2.RTCPeerConnection;
1945
- window2.RTCPeerConnection = function RTCPeerConnection(pcConfig, pcConstraints) {
1809
+ window2.RTCPeerConnection = function RTCPeerConnection2(pcConfig, pcConstraints) {
1946
1810
  if (pcConfig && pcConfig.iceServers) {
1947
1811
  const newIceServers = [];
1948
1812
  for (let i = 0; i < pcConfig.iceServers.length; i++) {
@@ -2063,7 +1927,7 @@ function requireSdp() {
2063
1927
  };
2064
1928
  SDPUtils2.splitSections = function(blob) {
2065
1929
  const parts = blob.split("\nm=");
2066
- return parts.map((part, index) => (index > 0 ? "m=" + part : part).trim() + "\r\n");
1930
+ return parts.map((part, index2) => (index2 > 0 ? "m=" + part : part).trim() + "\r\n");
2067
1931
  };
2068
1932
  SDPUtils2.getDescription = function(blob) {
2069
1933
  const sections = SDPUtils2.splitSections(blob);
@@ -3013,7 +2877,7 @@ function adapterFactory({ window: window2 } = {}, options = {
3013
2877
  }) {
3014
2878
  const logging2 = log;
3015
2879
  const browserDetails = detectBrowser(window2);
3016
- const adapter2 = {
2880
+ const adapter = {
3017
2881
  browserDetails,
3018
2882
  commonShim,
3019
2883
  extractVersion,
@@ -3026,14 +2890,14 @@ function adapterFactory({ window: window2 } = {}, options = {
3026
2890
  case "chrome":
3027
2891
  if (!chromeShim || !shimPeerConnection$1 || !options.shimChrome) {
3028
2892
  logging2("Chrome shim is not included in this adapter release.");
3029
- return adapter2;
2893
+ return adapter;
3030
2894
  }
3031
2895
  if (browserDetails.version === null) {
3032
2896
  logging2("Chrome shim can not determine version, not shimming.");
3033
- return adapter2;
2897
+ return adapter;
3034
2898
  }
3035
2899
  logging2("adapter.js shimming chrome.");
3036
- adapter2.browserShim = chromeShim;
2900
+ adapter.browserShim = chromeShim;
3037
2901
  shimAddIceCandidateNullOrEmpty(window2, browserDetails);
3038
2902
  shimParameterlessSetLocalDescription(window2);
3039
2903
  shimGetUserMedia$2(window2, browserDetails);
@@ -3054,10 +2918,10 @@ function adapterFactory({ window: window2 } = {}, options = {
3054
2918
  case "firefox":
3055
2919
  if (!firefoxShim || !shimPeerConnection || !options.shimFirefox) {
3056
2920
  logging2("Firefox shim is not included in this adapter release.");
3057
- return adapter2;
2921
+ return adapter;
3058
2922
  }
3059
2923
  logging2("adapter.js shimming firefox.");
3060
- adapter2.browserShim = firefoxShim;
2924
+ adapter.browserShim = firefoxShim;
3061
2925
  shimAddIceCandidateNullOrEmpty(window2, browserDetails);
3062
2926
  shimParameterlessSetLocalDescription(window2);
3063
2927
  shimGetUserMedia$1(window2, browserDetails);
@@ -3079,10 +2943,10 @@ function adapterFactory({ window: window2 } = {}, options = {
3079
2943
  case "safari":
3080
2944
  if (!safariShim || !options.shimSafari) {
3081
2945
  logging2("Safari shim is not included in this adapter release.");
3082
- return adapter2;
2946
+ return adapter;
3083
2947
  }
3084
2948
  logging2("adapter.js shimming safari.");
3085
- adapter2.browserShim = safariShim;
2949
+ adapter.browserShim = safariShim;
3086
2950
  shimAddIceCandidateNullOrEmpty(window2, browserDetails);
3087
2951
  shimParameterlessSetLocalDescription(window2);
3088
2952
  shimRTCIceServerUrls(window2);
@@ -3103,9 +2967,33 @@ function adapterFactory({ window: window2 } = {}, options = {
3103
2967
  logging2("Unsupported browser!");
3104
2968
  break;
3105
2969
  }
3106
- return adapter2;
2970
+ return adapter;
2971
+ }
2972
+ adapterFactory({ window: typeof window === "undefined" ? void 0 : window });
2973
+ class WebRTCConfig {
2974
+ constructor(options = {}) {
2975
+ __publicField(this, "signalServerUrl");
2976
+ __publicField(this, "myId");
2977
+ __publicField(this, "roomId");
2978
+ __publicField(this, "targetId");
2979
+ __publicField(this, "stunServerUri");
2980
+ __publicField(this, "stunServerUriAli");
2981
+ __publicField(this, "stunServerUriTel");
2982
+ __publicField(this, "turnServerUri");
2983
+ __publicField(this, "turnServerUserName");
2984
+ __publicField(this, "turnServerPassword");
2985
+ this.signalServerUrl = options.signalServerUrl || "";
2986
+ this.myId = options.myId || "";
2987
+ this.roomId = options.roomId || "";
2988
+ this.targetId = options.targetId || "";
2989
+ this.stunServerUri = options.stunServerUri || "stun:stun.l.google.com:19302";
2990
+ this.stunServerUriAli = options.stunServerUriAli || "stun:stun.middle.aliyun.com:3478";
2991
+ this.stunServerUriTel = options.stunServerUriTel || "stun:stun.qq.com:3478";
2992
+ this.turnServerUri = options.turnServerUri || "turn:btweb.yajuzhen.com:3478";
2993
+ this.turnServerUserName = options.turnServerUserName || "yangyj";
2994
+ this.turnServerPassword = options.turnServerPassword || "hb@2025@168";
2995
+ }
3107
2996
  }
3108
- const adapter = adapterFactory({ window: typeof window === "undefined" ? void 0 : window });
3109
2997
  const setRemoteDescriptionWithHandleOffer = (peerConnection, sdp2, sendAnswer, onError) => {
3110
2998
  const description = new RTCSessionDescription({ type: "offer", sdp: sdp2 });
3111
2999
  peerConnection.setRemoteDescription(description).then(() => createAnswer(peerConnection, sendAnswer, onError)).catch((error) => onError == null ? void 0 : onError(createWebRtcError(FailCode.HANDLE_OFFER, error)));
@@ -3116,7 +3004,10 @@ const createAnswer = (peerConnection, sendAnswer, onError) => {
3116
3004
  const setLocalDescriptionWithCreateAnswer = (peerConnection, answer, sendAnswer, onError) => {
3117
3005
  peerConnection.setLocalDescription(answer).then(() => {
3118
3006
  sendAnswer == null ? void 0 : sendAnswer(answer.sdp ?? "");
3119
- }).catch((error) => onError == null ? void 0 : onError(createWebRtcError(FailCode.LOCAL_DES, error)));
3007
+ }).catch((error) => {
3008
+ onError == null ? void 0 : onError(createWebRtcError(FailCode.LOCAL_DES, error));
3009
+ console.log("21321322212213");
3010
+ });
3120
3011
  };
3121
3012
  const createPeerConnection = (config) => {
3122
3013
  const iceServers = [
@@ -3131,23 +3022,15 @@ const createPeerConnection = (config) => {
3131
3022
  const peerConnectionConfig = {
3132
3023
  iceServers,
3133
3024
  iceTransportPolicy: "all",
3134
- sdpSemantics: "unified-plan",
3025
+ bundlePolicy: "max-bundle",
3135
3026
  rtcpMuxPolicy: "require",
3136
- bundlePolicy: "max-bundle"
3137
- };
3138
- if (adapter.browserDetails.browser === "chrome") {
3139
- peerConnectionConfig.sdpSemantics = adapter.browserDetails.version && adapter.browserDetails.version < 72 ? "plan-b" : "unified-plan";
3140
- }
3141
- const constraints = {
3142
- optional: [{ DtlsSrtpKeyAgreement: true }, { googIPv6: true }]
3027
+ iceCandidatePoolSize: 10
3143
3028
  };
3144
- const RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
3145
- return new RTCPeerConnection(peerConnectionConfig, constraints);
3029
+ return new RTCPeerConnection(peerConnectionConfig);
3146
3030
  };
3147
3031
  const configPeerConnection = (peerConnection, onICEMessage, onTrack, onConnectState, onError) => {
3148
3032
  peerConnection.onicecandidate = (event) => {
3149
3033
  if (!event.candidate) {
3150
- console.log("ICE candidate collection completed");
3151
3034
  return;
3152
3035
  }
3153
3036
  const candidateObj = {
@@ -3186,6 +3069,134 @@ const setLocalDescriptionWithCreateOffer = (peerConnection, offer, sendOfferMess
3186
3069
  const addIceCandidate = (peerConnection, candidate, onError) => {
3187
3070
  peerConnection.addIceCandidate(candidate).catch((err) => onError == null ? void 0 : onError(createWebRtcError(FailCode.HANDLE_ICE, err)));
3188
3071
  };
3072
+ var ChannelDataType = /* @__PURE__ */ ((ChannelDataType2) => {
3073
+ ChannelDataType2["ClickData"] = "ClickData";
3074
+ ChannelDataType2["ClipboardData"] = "ClipboardData";
3075
+ ChannelDataType2["ActionCommand"] = "ActionCommand";
3076
+ ChannelDataType2["ActionInput"] = "ActionInput";
3077
+ ChannelDataType2["ActionChinese"] = "ActionChinese";
3078
+ ChannelDataType2["ActionRequestCloudDeviceInfo"] = "ActionRequestCloudDeviceInfo";
3079
+ ChannelDataType2["ActionClarity"] = "ActionClarity";
3080
+ ChannelDataType2["ActionWheel"] = "ActionWheel";
3081
+ return ChannelDataType2;
3082
+ })(ChannelDataType || {});
3083
+ const ActionType = {
3084
+ ACTION_DOWN: 0,
3085
+ ACTION_MOVE: 2,
3086
+ ACTION_UP: 1
3087
+ };
3088
+ const StreamRotation = {
3089
+ ROTATION_0: 0,
3090
+ ROTATION_180: 2
3091
+ };
3092
+ const ContainerDirection = {
3093
+ Vertical: 0,
3094
+ Horizontal: 1
3095
+ };
3096
+ class TouchData {
3097
+ constructor(action, p, x, y, offsetTime, type = "adb") {
3098
+ __publicField(this, "action");
3099
+ __publicField(this, "p");
3100
+ __publicField(this, "x");
3101
+ __publicField(this, "y");
3102
+ __publicField(this, "offsetTime");
3103
+ __publicField(this, "type");
3104
+ this.action = action;
3105
+ this.p = p;
3106
+ this.x = x;
3107
+ this.y = y;
3108
+ this.offsetTime = offsetTime;
3109
+ this.type = type;
3110
+ }
3111
+ }
3112
+ class InputData {
3113
+ constructor(text) {
3114
+ __publicField(this, "text");
3115
+ this.text = text;
3116
+ }
3117
+ }
3118
+ class WheelData {
3119
+ constructor(axis) {
3120
+ __publicField(this, "axis");
3121
+ this.axis = axis;
3122
+ }
3123
+ }
3124
+ class KeyEventData {
3125
+ constructor(keyCode, meta) {
3126
+ __publicField(this, "keyCode");
3127
+ __publicField(this, "meta");
3128
+ this.keyCode = keyCode;
3129
+ this.meta = meta;
3130
+ }
3131
+ }
3132
+ class ChannelData {
3133
+ constructor(type, data = null) {
3134
+ __publicField(this, "type");
3135
+ __publicField(this, "data");
3136
+ this.type = type;
3137
+ this.data = data;
3138
+ }
3139
+ toString() {
3140
+ return JSON.stringify({ type: this.type, data: this.data });
3141
+ }
3142
+ /**
3143
+ * 格式化数据
3144
+ * 如果数据已经是字符串,则直接返回;否则使用 JSON.stringify() 转换为字符串
3145
+ * @param data 待转换数据
3146
+ * @returns 格式化后的字符串
3147
+ */
3148
+ static formatData(data) {
3149
+ return typeof data === "string" ? data : JSON.stringify(data);
3150
+ }
3151
+ /**
3152
+ * 生成点击数据
3153
+ * @param touchData 触摸数据,可以是任意类型
3154
+ */
3155
+ static click(touchData) {
3156
+ return new ChannelData("ClickData", this.formatData(touchData));
3157
+ }
3158
+ /**
3159
+ * 生成剪贴板数据
3160
+ * @param data 剪贴板数据,可以是字符串或其他类型
3161
+ */
3162
+ static clipboard(data) {
3163
+ return new ChannelData("ClipboardData", this.formatData(data));
3164
+ }
3165
+ /**
3166
+ * 生成输入数据
3167
+ * @param data 输入数据对象
3168
+ */
3169
+ static input(data) {
3170
+ return new ChannelData("ActionInput", this.formatData(data));
3171
+ }
3172
+ /**
3173
+ * 生成鼠标滚动数据
3174
+ * @param data 输入数据对象
3175
+ */
3176
+ static wheel(data) {
3177
+ return new ChannelData("ActionWheel", this.formatData(data));
3178
+ }
3179
+ /**
3180
+ * 生成中文输入数据
3181
+ * @param data 中文输入数据
3182
+ */
3183
+ static chinese(data) {
3184
+ return new ChannelData("ActionChinese", this.formatData(data));
3185
+ }
3186
+ /**
3187
+ * 生成请求云设备信息数据
3188
+ */
3189
+ static requestCloudDeviceInfo() {
3190
+ return new ChannelData("ActionRequestCloudDeviceInfo", "");
3191
+ }
3192
+ /**
3193
+ * 生成清晰度数据(clarity)
3194
+ * @param data 清晰度数据
3195
+ */
3196
+ static clarity(data) {
3197
+ return new ChannelData("ActionClarity", this.formatData(data));
3198
+ }
3199
+ }
3189
3200
  class WebRTCClient extends EventEmitter {
3190
3201
  constructor(config) {
3191
3202
  super();
@@ -3194,14 +3205,13 @@ class WebRTCClient extends EventEmitter {
3194
3205
  __publicField(this, "localStream", null);
3195
3206
  __publicField(this, "isPushingStream", false);
3196
3207
  __publicField(this, "dataChannel", null);
3197
- __publicField(this, "statsTimer", null);
3208
+ __publicField(this, "statsTimer");
3198
3209
  __publicField(this, "lastReportTime", 0);
3199
3210
  __publicField(this, "lastBytesReceived", 0);
3200
3211
  __publicField(this, "lastPacketsLost", 0);
3201
3212
  __publicField(this, "lastPacketsReceived", 0);
3202
3213
  __publicField(this, "lostPacketCount", 0);
3203
3214
  __publicField(this, "maxLostRate", 0);
3204
- __publicField(this, "decodedCount", 0);
3205
3215
  __publicField(this, "lastSecondDecodedCount", 0);
3206
3216
  this.config = config;
3207
3217
  }
@@ -3221,14 +3231,15 @@ class WebRTCClient extends EventEmitter {
3221
3231
  }, (err) => this.emit(EmitType.webrtcError, err));
3222
3232
  }
3223
3233
  handleAnswer(answerSdp) {
3224
- setRemoteDescriptionWithHandleAnswer(this.peerConnection, answerSdp, (err) => this.emit(EmitType.webrtcError, err));
3234
+ setRemoteDescriptionWithHandleAnswer(this.peerConnection, answerSdp ?? "", (err) => this.emit(EmitType.webrtcError, err));
3225
3235
  }
3226
3236
  handleIceCandidate(candidate) {
3227
3237
  addIceCandidate(this.peerConnection, candidate, (err) => this.emit(EmitType.webrtcError, err));
3228
3238
  }
3229
3239
  sendChannelData(type, data) {
3240
+ var _a;
3230
3241
  try {
3231
- let channelData = "";
3242
+ let channelData = null;
3232
3243
  switch (type) {
3233
3244
  case ChannelDataType.ClickData:
3234
3245
  channelData = ChannelData.click(data);
@@ -3248,9 +3259,16 @@ class WebRTCClient extends EventEmitter {
3248
3259
  case ChannelDataType.ActionClarity:
3249
3260
  channelData = ChannelData.clarity(data);
3250
3261
  break;
3262
+ case ChannelDataType.ActionWheel:
3263
+ channelData = ChannelData.wheel(data);
3264
+ break;
3265
+ }
3266
+ if (channelData) {
3267
+ const jsonString = JSON.stringify(channelData);
3268
+ const buffer = new TextEncoder().encode(jsonString).buffer;
3269
+ (_a = this.dataChannel) == null ? void 0 : _a.send(buffer);
3270
+ channelData = null;
3251
3271
  }
3252
- const buffer = new TextEncoder().encode(channelData).buffer;
3253
- this.dataChannel.send(buffer);
3254
3272
  } catch (err) {
3255
3273
  this.emit(EmitType.webrtcError, createWebRtcError(FailCode.DATACHANNEL_ERR, err));
3256
3274
  }
@@ -3258,20 +3276,22 @@ class WebRTCClient extends EventEmitter {
3258
3276
  closeConnection() {
3259
3277
  if (this.statsTimer) {
3260
3278
  clearInterval(this.statsTimer);
3261
- this.statsTimer = null;
3279
+ this.statsTimer = void 0;
3262
3280
  }
3263
- if (!this.peerConnection) {
3264
- if (this.peerConnection.getSenders) {
3281
+ if (this.peerConnection) {
3282
+ if (typeof this.peerConnection.getSenders === "function" && this.peerConnection.getSenders) {
3265
3283
  this.peerConnection.getSenders().forEach((sender) => {
3284
+ var _a, _b;
3266
3285
  if (sender.track) {
3267
- sender.track.stop();
3286
+ (_b = (_a = sender.track).stop) == null ? void 0 : _b.call(_a);
3268
3287
  }
3269
3288
  });
3270
3289
  }
3271
- if (this.peerConnection.getReceivers) {
3290
+ if (typeof this.peerConnection.getReceivers === "function" && this.peerConnection.getReceivers) {
3272
3291
  this.peerConnection.getReceivers().forEach((receiver) => {
3292
+ var _a, _b;
3273
3293
  if (receiver.track) {
3274
- receiver.track.stop();
3294
+ (_b = (_a = receiver.track).stop) == null ? void 0 : _b.call(_a);
3275
3295
  }
3276
3296
  });
3277
3297
  }
@@ -3281,7 +3301,6 @@ class WebRTCClient extends EventEmitter {
3281
3301
  (_a = transceiver.stop) == null ? void 0 : _a.call(transceiver);
3282
3302
  });
3283
3303
  }
3284
- this.peerConnection.close();
3285
3304
  this.removeAllListeners();
3286
3305
  this.dataChannel = null;
3287
3306
  this.peerConnection.onicecandidate = null;
@@ -3292,6 +3311,7 @@ class WebRTCClient extends EventEmitter {
3292
3311
  this.peerConnection.onsignalingstatechange = null;
3293
3312
  this.peerConnection.onnegotiationneeded = null;
3294
3313
  this.peerConnection.onicegatheringstatechange = null;
3314
+ this.peerConnection.close();
3295
3315
  this.peerConnection = null;
3296
3316
  }
3297
3317
  }
@@ -3371,7 +3391,6 @@ class WebRTCClient extends EventEmitter {
3371
3391
  configPeerConnection(this.peerConnection, (candidate) => {
3372
3392
  this.emit(EmitType.sendICEMessage, candidate);
3373
3393
  }, (track) => {
3374
- console.error("send track====>", track, Date.now());
3375
3394
  this.emit(EmitType.streamTrack, track);
3376
3395
  }, (state) => {
3377
3396
  this.emit(EmitType.iceConnectionState, state);
@@ -3433,7 +3452,6 @@ class WebRTCClient extends EventEmitter {
3433
3452
  videoFps = report.framesPerSecond || 0;
3434
3453
  totalDecodeTime = report.totalDecodeTime || 0;
3435
3454
  framesDecoded = report.framesDecoded || 0;
3436
- report.framesReceived || 0;
3437
3455
  pliCount = (report.pliCount || 0) + (report.firCount || 0);
3438
3456
  }
3439
3457
  }
@@ -3505,6 +3523,7 @@ class WebRTCSdk extends EventEmitter {
3505
3523
  this.config.myId = message.myId;
3506
3524
  break;
3507
3525
  case MessageType.Offer:
3526
+ console.log("handleSignaling===>", message);
3508
3527
  if (message.senderId && message.sdp) {
3509
3528
  this.config.targetId = message.senderId;
3510
3529
  this.webRTCClient.handleOffer(message.sdp);
@@ -3797,9 +3816,6 @@ function transformCoordinate(viewWidth, viewHeight, cloudWidth, cloudHeight, vie
3797
3816
  const end = short - invalidValue;
3798
3817
  const len = mid - invalidValue;
3799
3818
  if (viewAngle === -90) {
3800
- if (inputY < invalidValue || inputY > viewHeight - invalidValue) {
3801
- return null;
3802
- }
3803
3819
  const resultY = linearTransform(invalidValue, mid, start, end, len, inputY);
3804
3820
  if (streamAngle === -90) {
3805
3821
  return [inputX, resultY];
@@ -3807,12 +3823,9 @@ function transformCoordinate(viewWidth, viewHeight, cloudWidth, cloudHeight, vie
3807
3823
  return [viewHeight - resultY, inputX];
3808
3824
  }
3809
3825
  } else {
3810
- if (inputX < invalidValue || inputX > viewWidth - invalidValue) {
3811
- return null;
3812
- }
3813
3826
  const resultX = linearTransform(invalidValue, mid, start, end, len, inputX);
3814
3827
  if (streamAngle === -90) {
3815
- const [rotX, rotY] = rotatePoint90(viewWidth, viewHeight, cloudWidth, cloudHeight, resultX, inputY);
3828
+ const [rotX, rotY] = rotatePoint90(viewWidth, viewHeight, resultX, inputY);
3816
3829
  return [rotX, rotY];
3817
3830
  } else {
3818
3831
  return [resultX, inputY];
@@ -3848,7 +3861,7 @@ function linearTransform(invalidValue, mid, start, end, len, input) {
3848
3861
  return input;
3849
3862
  }
3850
3863
  }
3851
- function rotatePoint90(width, height, cloudWidth, cloudHeight, inputX, inputY) {
3864
+ function rotatePoint90(width, height, inputX, inputY) {
3852
3865
  const offsetLongSide = height / 2;
3853
3866
  const offsetShortSide = width / 2;
3854
3867
  const x0 = inputX - offsetShortSide;
@@ -3857,6 +3870,431 @@ function rotatePoint90(width, height, cloudWidth, cloudHeight, inputX, inputY) {
3857
3870
  const yRotated = -x0 + offsetShortSide;
3858
3871
  return [xRotated, yRotated];
3859
3872
  }
3873
+ function useDeviceMode() {
3874
+ const isMobile = ref(false);
3875
+ const checkDeviceMode = () => {
3876
+ isMobile.value = /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent);
3877
+ };
3878
+ const checkTouchSupport = () => {
3879
+ if (navigator.maxTouchPoints > 0) {
3880
+ isMobile.value = true;
3881
+ }
3882
+ };
3883
+ const handleUp = () => {
3884
+ };
3885
+ return {
3886
+ isMobile,
3887
+ checkDeviceMode,
3888
+ checkTouchSupport,
3889
+ handleUp
3890
+ };
3891
+ }
3892
+ function useCursorStyle(cursorType) {
3893
+ return computed(() => {
3894
+ switch (cursorType.value) {
3895
+ case 1:
3896
+ return "circle-cursor";
3897
+ case 2:
3898
+ return "triangle-cursor";
3899
+ default:
3900
+ return "default-cursor";
3901
+ }
3902
+ });
3903
+ }
3904
+ function useResizeObserver(target, dimension) {
3905
+ let observer = null;
3906
+ const init = () => {
3907
+ if (!target.value) return;
3908
+ observer = new ResizeObserver((entries) => {
3909
+ for (const entry of entries) {
3910
+ const { width, height } = entry.contentRect;
3911
+ dimension.value = { width, height };
3912
+ }
3913
+ });
3914
+ observer.observe(target.value);
3915
+ };
3916
+ const destroy = () => {
3917
+ observer == null ? void 0 : observer.disconnect();
3918
+ };
3919
+ onMounted(init);
3920
+ onUnmounted(destroy);
3921
+ }
3922
+ function useRemoteVideo(videoContainer, remoteVideoElement, videoAngle) {
3923
+ const screenStatus = ref(false);
3924
+ const remoteVideo = ref({});
3925
+ const dimensions = ref({ width: 0, height: 0 });
3926
+ const widthRadio = ref(0);
3927
+ const heightRadio = ref(0);
3928
+ const resizeObserver = ref(null);
3929
+ const videoSize = computed(() => {
3930
+ let width = 0;
3931
+ let height = 0;
3932
+ const isRotated = videoAngle.value % 180 !== 0;
3933
+ const containerWidth = isRotated ? dimensions.value.height : dimensions.value.width;
3934
+ const containerHeight = isRotated ? dimensions.value.width : dimensions.value.height;
3935
+ if (remoteVideo.value.width && remoteVideo.value.height) {
3936
+ const aspect = remoteVideo.value.width / remoteVideo.value.height;
3937
+ const videoHeight = containerWidth / aspect;
3938
+ if (videoHeight > containerHeight) {
3939
+ height = containerHeight;
3940
+ width = height * aspect;
3941
+ } else {
3942
+ width = containerWidth;
3943
+ height = videoHeight;
3944
+ }
3945
+ widthRadio.value = remoteVideo.value.width / width;
3946
+ heightRadio.value = remoteVideo.value.height / height;
3947
+ }
3948
+ return { width, height };
3949
+ });
3950
+ const initVideoContainer = () => {
3951
+ resizeObserver.value = new ResizeObserver((entries) => {
3952
+ for (const entry of entries) {
3953
+ const { width, height } = entry.contentRect;
3954
+ dimensions.value = { width, height };
3955
+ }
3956
+ });
3957
+ if (videoContainer.value) {
3958
+ resizeObserver.value.observe(videoContainer.value);
3959
+ }
3960
+ if (remoteVideoElement.value) {
3961
+ remoteVideoElement.value.addEventListener("resize", () => {
3962
+ if (!remoteVideoElement.value) return;
3963
+ remoteVideo.value = {
3964
+ width: remoteVideoElement.value.videoWidth,
3965
+ height: remoteVideoElement.value.videoHeight
3966
+ };
3967
+ screenStatus.value = true;
3968
+ });
3969
+ }
3970
+ };
3971
+ const startPlay = (track) => {
3972
+ if (!remoteVideoElement.value) return;
3973
+ if (!remoteVideoElement.value.srcObject) {
3974
+ remoteVideoElement.value.srcObject = new MediaStream();
3975
+ }
3976
+ remoteVideoElement.value.playsInline = true;
3977
+ remoteVideoElement.value.setAttribute("webkit-playsinline", "true");
3978
+ remoteVideoElement.value.srcObject.addTrack(track);
3979
+ };
3980
+ const stopPlay = () => {
3981
+ screenStatus.value = false;
3982
+ if (remoteVideoElement.value && remoteVideoElement.value.srcObject) {
3983
+ remoteVideoElement.value.srcObject.getTracks().forEach((track) => track.stop());
3984
+ remoteVideoElement.value.srcObject = null;
3985
+ }
3986
+ };
3987
+ return {
3988
+ videoSize,
3989
+ remoteVideo,
3990
+ dimensions,
3991
+ widthRadio,
3992
+ heightRadio,
3993
+ screenStatus,
3994
+ initVideoContainer,
3995
+ startPlay,
3996
+ stopPlay
3997
+ };
3998
+ }
3999
+ function useMouseTouchControl(options) {
4000
+ const {
4001
+ isMobile,
4002
+ remoteVideoElement,
4003
+ cloudDeviceSize,
4004
+ streamAngle,
4005
+ videoAngle,
4006
+ widthRadio,
4007
+ emit
4008
+ } = options;
4009
+ const isPointerDown = ref(false);
4010
+ const bound = ref(0);
4011
+ const pointerList = ref(new Array(20).fill(0));
4012
+ const pointerDownTime = ref(new Array(10).fill(0));
4013
+ const endX = ref(0);
4014
+ const endY = ref(0);
4015
+ const handlePointerEvent = (event, action) => {
4016
+ if (!remoteVideoElement.value) return;
4017
+ const offsetTime = Math.trunc((event.timeStamp - pointerDownTime.value[0]) / 2);
4018
+ const rect = remoteVideoElement.value.getBoundingClientRect();
4019
+ let x = event.clientX - rect.left;
4020
+ let y = event.clientY - rect.top;
4021
+ const cloudWidth = cloudDeviceSize.value.width;
4022
+ const cloudHeight = cloudDeviceSize.value.height;
4023
+ const result = transformCoordinate(
4024
+ rect.width,
4025
+ rect.height,
4026
+ cloudWidth,
4027
+ cloudHeight,
4028
+ videoAngle.value,
4029
+ streamAngle.value,
4030
+ x,
4031
+ y
4032
+ );
4033
+ if (!result || result.length < 2) return;
4034
+ x = result[0];
4035
+ y = result[1];
4036
+ if (action === ActionType.ACTION_MOVE) {
4037
+ const flipY = pointerList.value[10] - y;
4038
+ const flipX = pointerList.value[0] - x;
4039
+ if (Math.abs(flipY) < bound.value && Math.abs(flipX) < bound.value) return;
4040
+ }
4041
+ pointerList.value[0] = x;
4042
+ pointerList.value[10] = y;
4043
+ const percentResult = valueToPercentage(
4044
+ rect.width,
4045
+ rect.height,
4046
+ cloudWidth,
4047
+ cloudHeight,
4048
+ videoAngle.value,
4049
+ streamAngle.value,
4050
+ x,
4051
+ y
4052
+ );
4053
+ const touchData = new TouchData(action, 0, percentResult[0], percentResult[1], offsetTime);
4054
+ emit("channelEvent", ChannelDataType.ClickData, touchData);
4055
+ };
4056
+ const onTouchStart = (e) => {
4057
+ if (!isMobile.value) return;
4058
+ const touches = Array.from(e.touches);
4059
+ if (touches.length > 0) {
4060
+ pointerDownTime.value[0] = e.timeStamp;
4061
+ bound.value = Math.trunc(4 / widthRadio.value);
4062
+ endX.value = touches[0].clientX;
4063
+ endY.value = touches[0].clientY;
4064
+ const event = {
4065
+ clientX: endX.value,
4066
+ clientY: endY.value,
4067
+ timeStamp: e.timeStamp
4068
+ };
4069
+ handlePointerEvent(event, ActionType.ACTION_DOWN);
4070
+ }
4071
+ };
4072
+ const onTouchMove = (e) => {
4073
+ if (!isMobile.value) return;
4074
+ const touches = Array.from(e.touches);
4075
+ if (touches.length > 0) {
4076
+ endX.value = touches[0].clientX;
4077
+ endY.value = touches[0].clientY;
4078
+ const event = {
4079
+ clientX: endX.value,
4080
+ clientY: endY.value,
4081
+ timeStamp: e.timeStamp
4082
+ };
4083
+ handlePointerEvent(event, ActionType.ACTION_MOVE);
4084
+ }
4085
+ };
4086
+ const onTouchEnd = (e) => {
4087
+ if (!isMobile.value) return;
4088
+ const event = {
4089
+ clientX: endX.value,
4090
+ clientY: endY.value,
4091
+ timeStamp: e.timeStamp
4092
+ };
4093
+ handlePointerEvent(event, ActionType.ACTION_UP);
4094
+ };
4095
+ const handleMouseDown = (event) => {
4096
+ if (isMobile.value) return;
4097
+ isPointerDown.value = true;
4098
+ if (remoteVideoElement.value) {
4099
+ remoteVideoElement.value.setPointerCapture(event.pointerId);
4100
+ }
4101
+ pointerDownTime.value[0] = event.timeStamp;
4102
+ bound.value = Math.trunc(4 / widthRadio.value);
4103
+ handlePointerEvent(event, ActionType.ACTION_DOWN);
4104
+ };
4105
+ const handleMouseMove = (event) => {
4106
+ if (isMobile.value || !isPointerDown.value) return;
4107
+ handlePointerEvent(event, ActionType.ACTION_MOVE);
4108
+ };
4109
+ const handleMouseUp = (event) => {
4110
+ if (isMobile.value || !isPointerDown.value) return;
4111
+ isPointerDown.value = false;
4112
+ handlePointerEvent(event, ActionType.ACTION_UP);
4113
+ if (remoteVideoElement.value) {
4114
+ remoteVideoElement.value.releasePointerCapture(event.pointerId);
4115
+ }
4116
+ };
4117
+ const handleMouseEnter = (event) => {
4118
+ if (isMobile.value) return;
4119
+ if (event.buttons === 1 && !isPointerDown.value) {
4120
+ isPointerDown.value = true;
4121
+ if (remoteVideoElement.value) {
4122
+ remoteVideoElement.value.setPointerCapture(event.pointerId);
4123
+ }
4124
+ pointerDownTime.value[0] = event.timeStamp;
4125
+ bound.value = Math.trunc(4 / widthRadio.value);
4126
+ handlePointerEvent(event, ActionType.ACTION_DOWN);
4127
+ }
4128
+ };
4129
+ const handleMouseLeave = (event) => {
4130
+ if (isPointerDown.value) {
4131
+ handlePointerEvent(event, ActionType.ACTION_UP);
4132
+ isPointerDown.value = false;
4133
+ if (remoteVideoElement.value) {
4134
+ remoteVideoElement.value.releasePointerCapture(event.pointerId);
4135
+ }
4136
+ }
4137
+ };
4138
+ const handleWheel = (e) => {
4139
+ const delta = Math.sign(e.deltaY) * -1;
4140
+ const wheelData = new WheelData(delta);
4141
+ emit("channelEvent", ChannelDataType.ActionWheel, wheelData);
4142
+ };
4143
+ return {
4144
+ isPointerDown,
4145
+ onTouchStart,
4146
+ onTouchMove,
4147
+ onTouchEnd,
4148
+ handleMouseDown,
4149
+ handleMouseMove,
4150
+ handleMouseEnter,
4151
+ handleMouseUp,
4152
+ handleMouseLeave,
4153
+ handleWheel
4154
+ };
4155
+ }
4156
+ function useKeyboardControl(emit) {
4157
+ const handleKeyDown = (e) => {
4158
+ const data = getKeyEventData(e);
4159
+ emit("channelEvent", ChannelDataType.ActionInput, data);
4160
+ };
4161
+ const startListening = (e) => {
4162
+ const target = e.target;
4163
+ target.focus();
4164
+ };
4165
+ const stopListening = () => {
4166
+ };
4167
+ return {
4168
+ handleKeyDown,
4169
+ startListening,
4170
+ stopListening
4171
+ };
4172
+ }
4173
+ const _sfc_main = /* @__PURE__ */ defineComponent({
4174
+ __name: "index",
4175
+ props: {
4176
+ streamAngle: { type: Number, default: 0 },
4177
+ videoAngle: { type: Number, default: 0 },
4178
+ cursorType: { type: Number, default: 0 },
4179
+ cloudDeviceSize: { type: Object, default: () => ({ width: 0, height: 0 }) },
4180
+ disabled: { type: Boolean, default: true }
4181
+ },
4182
+ emits: ["channelEvent"],
4183
+ setup(__props, { expose: __expose, emit: __emit }) {
4184
+ const emit = __emit;
4185
+ const props = __props;
4186
+ const { streamAngle, videoAngle, cursorType, cloudDeviceSize, disabled } = toRefs(props);
4187
+ const videoContainer = ref(null);
4188
+ const remoteVideoElement = ref(null);
4189
+ const {
4190
+ isMobile,
4191
+ checkDeviceMode,
4192
+ checkTouchSupport,
4193
+ handleUp
4194
+ } = useDeviceMode();
4195
+ const cursorClass = useCursorStyle(cursorType);
4196
+ const {
4197
+ videoSize,
4198
+ dimensions,
4199
+ widthRadio,
4200
+ initVideoContainer,
4201
+ startPlay,
4202
+ stopPlay
4203
+ } = useRemoteVideo(videoContainer, remoteVideoElement, videoAngle);
4204
+ const {
4205
+ onTouchStart,
4206
+ onTouchMove,
4207
+ onTouchEnd,
4208
+ handleMouseDown,
4209
+ handleMouseMove,
4210
+ handleMouseEnter,
4211
+ handleMouseUp,
4212
+ handleMouseLeave,
4213
+ handleWheel
4214
+ } = useMouseTouchControl({
4215
+ isMobile,
4216
+ remoteVideoElement,
4217
+ cloudDeviceSize,
4218
+ streamAngle,
4219
+ videoAngle,
4220
+ widthRadio,
4221
+ emit
4222
+ });
4223
+ const {
4224
+ handleKeyDown,
4225
+ startListening,
4226
+ stopListening
4227
+ } = useKeyboardControl(emit);
4228
+ useResizeObserver(videoContainer, dimensions);
4229
+ onMounted(() => {
4230
+ checkDeviceMode();
4231
+ window.addEventListener("resize", checkDeviceMode);
4232
+ window.addEventListener("pointerdown", checkTouchSupport);
4233
+ window.addEventListener("pointerup", handleUp);
4234
+ initVideoContainer();
4235
+ });
4236
+ onUnmounted(() => {
4237
+ window.removeEventListener("resize", checkDeviceMode);
4238
+ window.removeEventListener("pointerdown", checkTouchSupport);
4239
+ window.removeEventListener("pointerup", handleUp);
4240
+ });
4241
+ __expose({ startPlay, stopPlay });
4242
+ return (_ctx, _cache) => {
4243
+ return openBlock(), createElementBlock("div", {
4244
+ ref_key: "videoContainer",
4245
+ ref: videoContainer,
4246
+ class: "flex flex-1 items-center justify-center",
4247
+ style: { "width": "100%", "height": "100%", "background": "black", "position": "relative", "overflow": "hidden" }
4248
+ }, [
4249
+ createElementVNode("div", {
4250
+ ref: "keyboardArea",
4251
+ onPointerenter: _cache[9] || (_cache[9] = ($event) => unref(disabled) ? null : unref(startListening)),
4252
+ onPointerleave: _cache[10] || (_cache[10] = ($event) => unref(disabled) ? null : unref(stopListening)),
4253
+ tabindex: "0",
4254
+ class: "vContainer",
4255
+ onKeydown: _cache[11] || (_cache[11] = ($event) => unref(disabled) ? null : unref(handleKeyDown)),
4256
+ style: normalizeStyle([{ height: unref(videoSize).height + "px", width: unref(videoSize).width + "px", transform: `rotate(${unref(videoAngle)}deg)` }, { "position": "relative" }])
4257
+ }, [
4258
+ createElementVNode("video", {
4259
+ ref_key: "remoteVideoElement",
4260
+ ref: remoteVideoElement,
4261
+ class: normalizeClass(["video-control", [unref(cursorClass), { "no-events": unref(disabled) }]]),
4262
+ onTouchstart: _cache[0] || (_cache[0] = //@ts-ignore
4263
+ (...args) => unref(onTouchStart) && unref(onTouchStart)(...args)),
4264
+ onTouchmove: _cache[1] || (_cache[1] = //@ts-ignore
4265
+ (...args) => unref(onTouchMove) && unref(onTouchMove)(...args)),
4266
+ onTouchend: _cache[2] || (_cache[2] = //@ts-ignore
4267
+ (...args) => unref(onTouchEnd) && unref(onTouchEnd)(...args)),
4268
+ onPointerenter: _cache[3] || (_cache[3] = //@ts-ignore
4269
+ (...args) => unref(handleMouseEnter) && unref(handleMouseEnter)(...args)),
4270
+ onPointerdown: _cache[4] || (_cache[4] = //@ts-ignore
4271
+ (...args) => unref(handleMouseDown) && unref(handleMouseDown)(...args)),
4272
+ onPointermove: _cache[5] || (_cache[5] = //@ts-ignore
4273
+ (...args) => unref(handleMouseMove) && unref(handleMouseMove)(...args)),
4274
+ onPointerup: _cache[6] || (_cache[6] = //@ts-ignore
4275
+ (...args) => unref(handleMouseUp) && unref(handleMouseUp)(...args)),
4276
+ onPointerleave: _cache[7] || (_cache[7] = //@ts-ignore
4277
+ (...args) => unref(handleMouseLeave) && unref(handleMouseLeave)(...args)),
4278
+ onWheel: _cache[8] || (_cache[8] = //@ts-ignore
4279
+ (...args) => unref(handleWheel) && unref(handleWheel)(...args)),
4280
+ autoplay: "",
4281
+ playsinline: "",
4282
+ muted: "",
4283
+ disablePictureInPicture: ""
4284
+ }, null, 34)
4285
+ ], 36)
4286
+ ], 512);
4287
+ };
4288
+ }
4289
+ });
4290
+ const _export_sfc = (sfc, props) => {
4291
+ const target = sfc.__vccOpts || sfc;
4292
+ for (const [key, val] of props) {
4293
+ target[key] = val;
4294
+ }
4295
+ return target;
4296
+ };
4297
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-27488d0e"]]);
3860
4298
  export {
3861
4299
  ActionType,
3862
4300
  ChannelDataType,
@@ -3864,8 +4302,10 @@ export {
3864
4302
  EmitType,
3865
4303
  InputData,
3866
4304
  KeyEventData,
4305
+ index as RemotePlayer,
3867
4306
  TouchData,
3868
4307
  WebRTCSdk,
4308
+ WheelData,
3869
4309
  getKeyEventData,
3870
4310
  transformCoordinate,
3871
4311
  valueToPercentage