yjz-web-sdk 1.0.11-beta.7 → 1.0.11-beta.9
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.
- package/lib/{ScreenControlUtil-Bf1obwOj.js → ScreenControlUtil-D4-BTCo9.js} +124 -13
- package/lib/core/WebRTCSdk.d.ts +5 -0
- package/lib/core/data/WebRtcError.d.ts +2 -1
- package/lib/core/rtc/WebRTCClient.d.ts +9 -0
- package/lib/core/rtc/WebRTCConfig.d.ts +2 -0
- package/lib/core/rtc/WebRtcNegotiate.d.ts +1 -1
- package/lib/uni/RemoteCanvasController.d.ts +1 -3
- package/lib/uni-sdk.js +10 -7
- package/lib/yjz-web-sdk.js +6 -2
- package/package.json +1 -1
|
@@ -244,6 +244,7 @@ var FailCode = /* @__PURE__ */ ((FailCode2) => {
|
|
|
244
244
|
FailCode2[FailCode2["KICK_OUT_ERR"] = 10016] = "KICK_OUT_ERR";
|
|
245
245
|
FailCode2[FailCode2["STATE_ERR"] = 10017] = "STATE_ERR";
|
|
246
246
|
FailCode2[FailCode2["OPTION_ERR"] = 10018] = "OPTION_ERR";
|
|
247
|
+
FailCode2[FailCode2["NO_OPTION_LONGTIME"] = 10019] = "NO_OPTION_LONGTIME";
|
|
247
248
|
return FailCode2;
|
|
248
249
|
})(FailCode || {});
|
|
249
250
|
const FailInfoMap = {
|
|
@@ -318,7 +319,11 @@ const FailInfoMap = {
|
|
|
318
319
|
[
|
|
319
320
|
10018
|
|
320
321
|
/* OPTION_ERR */
|
|
321
|
-
]: { type: "option_err", description: "投屏配置异常,请检查配置" }
|
|
322
|
+
]: { type: "option_err", description: "投屏配置异常,请检查配置" },
|
|
323
|
+
[
|
|
324
|
+
10019
|
|
325
|
+
/* NO_OPTION_LONGTIME */
|
|
326
|
+
]: { type: "no_option_long_time", description: "云机长时间未操作,主动断开连接,点击重连恢复投屏" }
|
|
322
327
|
};
|
|
323
328
|
var CameraFailCode = /* @__PURE__ */ ((CameraFailCode2) => {
|
|
324
329
|
CameraFailCode2[CameraFailCode2["LOCAL_STREAM_FAIL"] = 20001] = "LOCAL_STREAM_FAIL";
|
|
@@ -3306,9 +3311,11 @@ const configPeerConnection = (peerConnection, onICEMessage, onTrack, onConnectSt
|
|
|
3306
3311
|
onTrack == null ? void 0 : onTrack(track);
|
|
3307
3312
|
};
|
|
3308
3313
|
};
|
|
3309
|
-
const setRemoteDescriptionWithHandleAnswer = (peerConnection, sdp2, onError) => {
|
|
3314
|
+
const setRemoteDescriptionWithHandleAnswer = (peerConnection, sdp2, onSuccess, onError) => {
|
|
3310
3315
|
const description = new RTCSessionDescription({ type: "answer", sdp: sdp2 });
|
|
3311
|
-
peerConnection.setRemoteDescription(description).
|
|
3316
|
+
peerConnection.setRemoteDescription(description).then(() => {
|
|
3317
|
+
onSuccess == null ? void 0 : onSuccess();
|
|
3318
|
+
}).catch((err) => onError == null ? void 0 : onError(createWebRtcError(FailCode.REMOTE_DES, err)));
|
|
3312
3319
|
};
|
|
3313
3320
|
const createOffer = async (peerConnection, sendOfferMessage) => {
|
|
3314
3321
|
try {
|
|
@@ -3561,6 +3568,7 @@ const formattedTime = (timestamp) => {
|
|
|
3561
3568
|
return `${h}:${m}:${s}.${ms}`;
|
|
3562
3569
|
};
|
|
3563
3570
|
class WebRTCClient extends EventEmitter {
|
|
3571
|
+
// 最近一次触发时间戳
|
|
3564
3572
|
constructor(config) {
|
|
3565
3573
|
super();
|
|
3566
3574
|
__publicField(this, "config");
|
|
@@ -3587,6 +3595,14 @@ class WebRTCClient extends EventEmitter {
|
|
|
3587
3595
|
__publicField(this, "rafId", 0);
|
|
3588
3596
|
__publicField(this, "currentMedia", null);
|
|
3589
3597
|
__publicField(this, "fileImage");
|
|
3598
|
+
__publicField(this, "reConnectTimer", null);
|
|
3599
|
+
__publicField(this, "canPushStream", false);
|
|
3600
|
+
__publicField(this, "idleTimer", null);
|
|
3601
|
+
__publicField(this, "retryCount", 0);
|
|
3602
|
+
// 当前重连里的 retry 次数
|
|
3603
|
+
__publicField(this, "MAX_RETRY_PER_RECONNECT", 2);
|
|
3604
|
+
// 每次重连最多 retry 2 次
|
|
3605
|
+
__publicField(this, "lastIdleResetTime", 0);
|
|
3590
3606
|
__publicField(this, "startPushLocal", async (file) => {
|
|
3591
3607
|
if (this.isPushingLocalStream || !file) return;
|
|
3592
3608
|
try {
|
|
@@ -3638,7 +3654,26 @@ class WebRTCClient extends EventEmitter {
|
|
|
3638
3654
|
}, (err) => this.emit(EmitType.webrtcError, err));
|
|
3639
3655
|
}
|
|
3640
3656
|
handleAnswer(answerSdp) {
|
|
3641
|
-
setRemoteDescriptionWithHandleAnswer(this.peerConnection, answerSdp ?? "", (
|
|
3657
|
+
setRemoteDescriptionWithHandleAnswer(this.peerConnection, answerSdp ?? "", () => {
|
|
3658
|
+
this.canPushStream = true;
|
|
3659
|
+
this.retryCount = 0;
|
|
3660
|
+
}, (_err) => {
|
|
3661
|
+
this.canPushStream = false;
|
|
3662
|
+
if (this.reConnectTimer) {
|
|
3663
|
+
clearTimeout(this.reConnectTimer);
|
|
3664
|
+
this.reConnectTimer = null;
|
|
3665
|
+
}
|
|
3666
|
+
if (this.retryCount < this.MAX_RETRY_PER_RECONNECT) {
|
|
3667
|
+
this.reConnectTimer = setTimeout(async () => {
|
|
3668
|
+
await createOffer(this.peerConnection, (sdp2) => {
|
|
3669
|
+
this.emit(EmitType.sendOffer, sdp2);
|
|
3670
|
+
});
|
|
3671
|
+
}, 3e3);
|
|
3672
|
+
this.retryCount++;
|
|
3673
|
+
} else {
|
|
3674
|
+
this.retryCount = 0;
|
|
3675
|
+
}
|
|
3676
|
+
});
|
|
3642
3677
|
}
|
|
3643
3678
|
handleIceCandidate(candidate) {
|
|
3644
3679
|
addIceCandidate(this.peerConnection, candidate, (err) => this.emit(EmitType.webrtcError, err));
|
|
@@ -3686,6 +3721,7 @@ class WebRTCClient extends EventEmitter {
|
|
|
3686
3721
|
const jsonString = JSON.stringify(channelData);
|
|
3687
3722
|
const buffer = new TextEncoder().encode(jsonString).buffer;
|
|
3688
3723
|
(_a = this.dataChannel) == null ? void 0 : _a.send(buffer);
|
|
3724
|
+
this.resetIdleTimer();
|
|
3689
3725
|
channelData = null;
|
|
3690
3726
|
}
|
|
3691
3727
|
} catch (err) {
|
|
@@ -3724,6 +3760,11 @@ class WebRTCClient extends EventEmitter {
|
|
|
3724
3760
|
(_a2 = transceiver.stop) == null ? void 0 : _a2.call(transceiver);
|
|
3725
3761
|
});
|
|
3726
3762
|
}
|
|
3763
|
+
if (this.reConnectTimer) {
|
|
3764
|
+
clearTimeout(this.reConnectTimer);
|
|
3765
|
+
this.reConnectTimer = null;
|
|
3766
|
+
}
|
|
3767
|
+
this.clearIdleTimer();
|
|
3727
3768
|
this.removeAllListeners();
|
|
3728
3769
|
(_a = this.videoDataChannel) == null ? void 0 : _a.close();
|
|
3729
3770
|
this.videoDataChannel = null;
|
|
@@ -3756,6 +3797,11 @@ class WebRTCClient extends EventEmitter {
|
|
|
3756
3797
|
});
|
|
3757
3798
|
this.rotatedStream = await this.getRotatedStream(this.localStream, useBackCamera);
|
|
3758
3799
|
await this.onConnected();
|
|
3800
|
+
if (!this.canPushStream) {
|
|
3801
|
+
await createOffer(this.peerConnection, (sdp2) => {
|
|
3802
|
+
this.emit(EmitType.sendOffer, sdp2);
|
|
3803
|
+
});
|
|
3804
|
+
}
|
|
3759
3805
|
} catch (err) {
|
|
3760
3806
|
if (err instanceof DOMException) {
|
|
3761
3807
|
switch (err.name) {
|
|
@@ -3794,6 +3840,11 @@ class WebRTCClient extends EventEmitter {
|
|
|
3794
3840
|
const rotatedStream = await this.getRotatedStream(this.localStream, useBackCamera);
|
|
3795
3841
|
this.rotatedStream = rotatedStream;
|
|
3796
3842
|
await this.onConnected();
|
|
3843
|
+
if (!this.canPushStream) {
|
|
3844
|
+
await createOffer(this.peerConnection, (sdp2) => {
|
|
3845
|
+
this.emit(EmitType.sendOffer, sdp2);
|
|
3846
|
+
});
|
|
3847
|
+
}
|
|
3797
3848
|
} catch (err) {
|
|
3798
3849
|
this.isPushingStream = false;
|
|
3799
3850
|
if (err instanceof DOMException) {
|
|
@@ -3922,9 +3973,7 @@ class WebRTCClient extends EventEmitter {
|
|
|
3922
3973
|
this.emit(EmitType.iceConnectionState, state);
|
|
3923
3974
|
if (state === "connected") {
|
|
3924
3975
|
this.checkStats();
|
|
3925
|
-
|
|
3926
|
-
this.emit(EmitType.sendOffer, sdp2);
|
|
3927
|
-
});
|
|
3976
|
+
this.resetIdleTimer();
|
|
3928
3977
|
}
|
|
3929
3978
|
}, (err) => this.emit(EmitType.webrtcError, err));
|
|
3930
3979
|
this.configDataChannel();
|
|
@@ -3953,9 +4002,9 @@ class WebRTCClient extends EventEmitter {
|
|
|
3953
4002
|
}
|
|
3954
4003
|
async handleDataChannelMessage(event) {
|
|
3955
4004
|
const data = JSON.parse(event.data);
|
|
4005
|
+
this.resetIdleTimer();
|
|
3956
4006
|
if (data.type === ChannelDataType.ActionCommandEvent) {
|
|
3957
4007
|
const { action, value, cameraId } = JSON.parse(data.data);
|
|
3958
|
-
console.error("data===>", data.data);
|
|
3959
4008
|
if (action === "ACTION_CONTROL_VIDEO") {
|
|
3960
4009
|
if (value === "ENABLE") {
|
|
3961
4010
|
if (this.isPushingStream) {
|
|
@@ -3986,6 +4035,7 @@ class WebRTCClient extends EventEmitter {
|
|
|
3986
4035
|
}
|
|
3987
4036
|
}
|
|
3988
4037
|
checkStats() {
|
|
4038
|
+
if (this.statsTimer) return;
|
|
3989
4039
|
this.statsTimer = setInterval(() => this.processStatsOptimized(), 1e3);
|
|
3990
4040
|
}
|
|
3991
4041
|
async processStatsOptimized() {
|
|
@@ -4198,6 +4248,33 @@ class WebRTCClient extends EventEmitter {
|
|
|
4198
4248
|
this.fileVideo.src = "";
|
|
4199
4249
|
}
|
|
4200
4250
|
}
|
|
4251
|
+
resetIdleTimer() {
|
|
4252
|
+
const now = Date.now();
|
|
4253
|
+
const DEBOUNCE_MS = 2e3;
|
|
4254
|
+
if (now - this.lastIdleResetTime < DEBOUNCE_MS) {
|
|
4255
|
+
return;
|
|
4256
|
+
}
|
|
4257
|
+
this.lastIdleResetTime = now;
|
|
4258
|
+
if (this.idleTimer) {
|
|
4259
|
+
clearTimeout(this.idleTimer);
|
|
4260
|
+
}
|
|
4261
|
+
this.idleTimer = setTimeout(() => {
|
|
4262
|
+
this.emit(
|
|
4263
|
+
EmitType.webrtcError,
|
|
4264
|
+
createWebRtcError(
|
|
4265
|
+
FailCode.NO_OPTION_LONGTIME,
|
|
4266
|
+
createWebRtcError(FailCode.NO_OPTION_LONGTIME, "")
|
|
4267
|
+
)
|
|
4268
|
+
);
|
|
4269
|
+
}, this.config.operateTimeout);
|
|
4270
|
+
}
|
|
4271
|
+
/** 停止空闲计时器 */
|
|
4272
|
+
clearIdleTimer() {
|
|
4273
|
+
if (this.idleTimer) {
|
|
4274
|
+
clearTimeout(this.idleTimer);
|
|
4275
|
+
this.idleTimer = null;
|
|
4276
|
+
}
|
|
4277
|
+
}
|
|
4201
4278
|
}
|
|
4202
4279
|
class WebRTCConfig {
|
|
4203
4280
|
constructor(options) {
|
|
@@ -4222,6 +4299,7 @@ class WebRTCConfig {
|
|
|
4222
4299
|
__publicField(this, "turnKey");
|
|
4223
4300
|
__publicField(this, "traceId", "");
|
|
4224
4301
|
__publicField(this, "signAgain");
|
|
4302
|
+
__publicField(this, "operateTimeout");
|
|
4225
4303
|
this.signalServerUrl = options.signalServerUrl || "";
|
|
4226
4304
|
this.myId = options.myId || "";
|
|
4227
4305
|
this.roomId = options.roomId || "";
|
|
@@ -4243,6 +4321,7 @@ class WebRTCConfig {
|
|
|
4243
4321
|
this.isGroup = options.isGroup;
|
|
4244
4322
|
this.traceId = options.traceId || "";
|
|
4245
4323
|
this.signAgain = options.signAgain || true;
|
|
4324
|
+
this.operateTimeout = options.operateTimeout || 15 * 60 * 1e3;
|
|
4246
4325
|
}
|
|
4247
4326
|
}
|
|
4248
4327
|
const testTurnServer = (turnConfig, timeoutMs = 1500) => {
|
|
@@ -4350,9 +4429,10 @@ class WebRTCSdk extends EventEmitter {
|
|
|
4350
4429
|
__publicField(this, "options");
|
|
4351
4430
|
__publicField(this, "isConnected", false);
|
|
4352
4431
|
__publicField(this, "isConnecting", false);
|
|
4353
|
-
|
|
4354
|
-
|
|
4432
|
+
__publicField(this, "connectCount", 0);
|
|
4433
|
+
__publicField(this, "MAX_COUNT", 1);
|
|
4355
4434
|
__publicField(this, "timeout", null);
|
|
4435
|
+
__publicField(this, "reconnectTimer", null);
|
|
4356
4436
|
/**
|
|
4357
4437
|
* 处理 signal 消息,根据不同消息类型分发到 webRTCClient 或直接触发 SDK 事件
|
|
4358
4438
|
* @param message 信令消息
|
|
@@ -4598,6 +4678,24 @@ class WebRTCSdk extends EventEmitter {
|
|
|
4598
4678
|
this.isConnecting = false;
|
|
4599
4679
|
}
|
|
4600
4680
|
}
|
|
4681
|
+
scheduleReconnect() {
|
|
4682
|
+
if (this.reconnectTimer) {
|
|
4683
|
+
Logger.warn("reconnect 已在调度中,跳过");
|
|
4684
|
+
return;
|
|
4685
|
+
}
|
|
4686
|
+
this.isConnected = false;
|
|
4687
|
+
const delay = 4e3 + Math.floor(Math.random() * 2e3);
|
|
4688
|
+
Logger.warn(`WebRTC 将在 ${delay}ms 后重连`);
|
|
4689
|
+
this.reconnectTimer = setTimeout(async () => {
|
|
4690
|
+
this.reconnectTimer = null;
|
|
4691
|
+
try {
|
|
4692
|
+
await this.reconnect();
|
|
4693
|
+
} catch (e) {
|
|
4694
|
+
Logger.error("错误信息:", "scheduleReconnect 执行失败");
|
|
4695
|
+
this.emit(EmitType.webrtcError, e);
|
|
4696
|
+
}
|
|
4697
|
+
}, delay);
|
|
4698
|
+
}
|
|
4601
4699
|
async reconnect() {
|
|
4602
4700
|
this.resetConfig();
|
|
4603
4701
|
try {
|
|
@@ -4626,6 +4724,7 @@ class WebRTCSdk extends EventEmitter {
|
|
|
4626
4724
|
this.emit(EmitType.iceConnectionState, state);
|
|
4627
4725
|
if (state === "connected") {
|
|
4628
4726
|
this.isConnected = true;
|
|
4727
|
+
this.clearReconnectTimer();
|
|
4629
4728
|
}
|
|
4630
4729
|
});
|
|
4631
4730
|
(_f = this.webRTCClient) == null ? void 0 : _f.on(
|
|
@@ -4637,8 +4736,14 @@ class WebRTCSdk extends EventEmitter {
|
|
|
4637
4736
|
(clipData) => this.emit(EmitType.cloudClipData, clipData)
|
|
4638
4737
|
);
|
|
4639
4738
|
(_h = this.webRTCClient) == null ? void 0 : _h.on(EmitType.webrtcError, (err) => {
|
|
4640
|
-
|
|
4641
|
-
|
|
4739
|
+
if (err.code === FailCode.ICE_STATE && this.connectCount < this.MAX_COUNT && this.isConnected) {
|
|
4740
|
+
this.connectCount++;
|
|
4741
|
+
this.emit(EmitType.reconnect);
|
|
4742
|
+
this.scheduleReconnect();
|
|
4743
|
+
} else {
|
|
4744
|
+
Logger.error("错误信息:", `sdk调试错误日志======>`, err);
|
|
4745
|
+
this.emit(EmitType.webrtcError, err);
|
|
4746
|
+
}
|
|
4642
4747
|
});
|
|
4643
4748
|
(_i = this.webRTCClient) == null ? void 0 : _i.on(EmitType.cameraError, (err) => {
|
|
4644
4749
|
this.emit(EmitType.cameraError, err);
|
|
@@ -4767,7 +4872,7 @@ class WebRTCSdk extends EventEmitter {
|
|
|
4767
4872
|
sendSignOut() {
|
|
4768
4873
|
var _a, _b;
|
|
4769
4874
|
if (!this.config) return;
|
|
4770
|
-
|
|
4875
|
+
Logger.debug("调试信息:", `sendSignOut=========>主动断开连接`);
|
|
4771
4876
|
if (this.config.connectorType === ConnectorType.LanForwarding) {
|
|
4772
4877
|
const message = {
|
|
4773
4878
|
type: SendType.GroupSignOut,
|
|
@@ -4831,6 +4936,12 @@ class WebRTCSdk extends EventEmitter {
|
|
|
4831
4936
|
this.emit(EmitType.webrtcError, createWebRtcError(FailCode.DATACHANNEL_ERR, err));
|
|
4832
4937
|
}
|
|
4833
4938
|
}
|
|
4939
|
+
clearReconnectTimer() {
|
|
4940
|
+
if (this.reconnectTimer) {
|
|
4941
|
+
clearTimeout(this.reconnectTimer);
|
|
4942
|
+
this.reconnectTimer = null;
|
|
4943
|
+
}
|
|
4944
|
+
}
|
|
4834
4945
|
}
|
|
4835
4946
|
const META_SHIFT_ON = 1;
|
|
4836
4947
|
const META_ALT_ON = 2;
|
package/lib/core/WebRTCSdk.d.ts
CHANGED
|
@@ -12,12 +12,16 @@ export declare class WebRTCSdk extends EventEmitter {
|
|
|
12
12
|
options: WebRTCConfigOptions;
|
|
13
13
|
isConnected: boolean;
|
|
14
14
|
isConnecting: boolean;
|
|
15
|
+
private connectCount;
|
|
16
|
+
private MAX_COUNT;
|
|
15
17
|
private timeout;
|
|
18
|
+
private reconnectTimer;
|
|
16
19
|
constructor(options: WebRTCConfigOptions);
|
|
17
20
|
initConfig(): Promise<void>;
|
|
18
21
|
/** 开始连接 signal 服务 */
|
|
19
22
|
startConnection(): void;
|
|
20
23
|
private prepareConnection;
|
|
24
|
+
private scheduleReconnect;
|
|
21
25
|
reconnect(): Promise<void>;
|
|
22
26
|
initConnectConfig(initConfig?: boolean): void;
|
|
23
27
|
initSignalingClient(): void;
|
|
@@ -51,4 +55,5 @@ export declare class WebRTCSdk extends EventEmitter {
|
|
|
51
55
|
sendPong(): void;
|
|
52
56
|
sendSignOut(): void;
|
|
53
57
|
groupSendAction(type: ChannelDataType, data: any): void;
|
|
58
|
+
private clearReconnectTimer;
|
|
54
59
|
}
|
|
@@ -26,6 +26,12 @@ export declare class WebRTCClient extends EventEmitter {
|
|
|
26
26
|
private rafId;
|
|
27
27
|
private currentMedia;
|
|
28
28
|
private fileImage?;
|
|
29
|
+
private reConnectTimer;
|
|
30
|
+
private canPushStream;
|
|
31
|
+
private idleTimer;
|
|
32
|
+
private retryCount;
|
|
33
|
+
private readonly MAX_RETRY_PER_RECONNECT;
|
|
34
|
+
private lastIdleResetTime;
|
|
29
35
|
constructor(config: WebRTCConfig);
|
|
30
36
|
startPush(useBackCamera?: boolean): Promise<void>;
|
|
31
37
|
handleOffer(offerSdp: string): void;
|
|
@@ -58,4 +64,7 @@ export declare class WebRTCClient extends EventEmitter {
|
|
|
58
64
|
getFileImage(): HTMLImageElement;
|
|
59
65
|
/** 停止推流并释放资源 */
|
|
60
66
|
stopLocal(): void;
|
|
67
|
+
private resetIdleTimer;
|
|
68
|
+
/** 停止空闲计时器 */
|
|
69
|
+
private clearIdleTimer;
|
|
61
70
|
}
|
|
@@ -33,6 +33,7 @@ export interface WebRTCConfigOptions {
|
|
|
33
33
|
cacheTimeout?: number;
|
|
34
34
|
enableLogger?: boolean;
|
|
35
35
|
loggerLevel?: LogLevel;
|
|
36
|
+
operateTimeout?: number;
|
|
36
37
|
}
|
|
37
38
|
export declare class WebRTCConfig {
|
|
38
39
|
signalServerUrl: string;
|
|
@@ -56,5 +57,6 @@ export declare class WebRTCConfig {
|
|
|
56
57
|
turnKey: Array<string>;
|
|
57
58
|
traceId: string;
|
|
58
59
|
signAgain: boolean;
|
|
60
|
+
operateTimeout: number;
|
|
59
61
|
constructor(options: WebRTCConfigOptions);
|
|
60
62
|
}
|
|
@@ -3,7 +3,7 @@ import { WebRTCConfig } from "./WebRTCConfig.ts";
|
|
|
3
3
|
export declare const setRemoteDescriptionWithHandleOffer: (peerConnection: RTCPeerConnection, sdp: string, sendAnswer?: (sdp: string) => void, onError?: (err: WebRtcError) => void) => void;
|
|
4
4
|
export declare const createPeerConnection: (config: WebRTCConfig) => RTCPeerConnection;
|
|
5
5
|
export declare const configPeerConnection: (peerConnection: RTCPeerConnection, onICEMessage: (candidate: string) => void, onTrack?: (track: MediaStreamTrack) => void, onConnectState?: (state: RTCIceConnectionState) => void, onError?: (error: WebRtcError) => void) => void;
|
|
6
|
-
export declare const setRemoteDescriptionWithHandleAnswer: (peerConnection: RTCPeerConnection, sdp: string, onError?: (error: WebRtcError) => void) => void;
|
|
6
|
+
export declare const setRemoteDescriptionWithHandleAnswer: (peerConnection: RTCPeerConnection, sdp: string, onSuccess?: () => void, onError?: (error: WebRtcError) => void) => void;
|
|
7
7
|
export declare const createOffer: (peerConnection: RTCPeerConnection, sendOfferMessage: (sdp: string) => void) => Promise<void>;
|
|
8
8
|
export declare const setLocalDescriptionWithCreateOffer: (peerConnection: RTCPeerConnection, offer: RTCSessionDescriptionInit, sendOfferMessage: (sdp: string) => void) => Promise<void>;
|
|
9
9
|
export declare const addIceCandidate: (peerConnection: RTCPeerConnection, candidate: RTCIceCandidateInit, onError?: (error: WebRtcError) => void) => void;
|
|
@@ -2,9 +2,7 @@ import RemoteControllerBase from "./RemoteControllerBase";
|
|
|
2
2
|
declare class RemoteCanvasController implements RemoteControllerBase {
|
|
3
3
|
remoteElement: HTMLElement | null;
|
|
4
4
|
audioElement?: HTMLAudioElement | null | undefined;
|
|
5
|
-
constructor(
|
|
6
|
-
remoteElement: HTMLElement;
|
|
7
|
-
});
|
|
5
|
+
constructor();
|
|
8
6
|
startDecode(arrayBuffer: ArrayBuffer): void;
|
|
9
7
|
startPlay(track: MediaStreamTrack): void;
|
|
10
8
|
stopPlay(): void;
|
package/lib/uni-sdk.js
CHANGED
|
@@ -10,7 +10,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
10
10
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
11
11
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
12
12
|
var _screenStatus, _isComposing, _direction, _screenWidth, _screenHeight, _clarityLevel, _gestureMode;
|
|
13
|
-
import { W as WheelData, t as transformCoordinate, A as ActionType, v as valueToPercentage, T as TouchData, g as getKeyEventData, I as InputData, i as isFunctionKey, E as EventEmitter, C as ChannelDataType, a as WebRTCSdk, b as EmitType, F as FailCode, c as ContainerDirection, K as KeyEventData, j as ActionCommandEventValue, h as ActionCommandEventType, d as ClarityData, G as GestureData } from "./ScreenControlUtil-
|
|
13
|
+
import { W as WheelData, t as transformCoordinate, A as ActionType, v as valueToPercentage, T as TouchData, g as getKeyEventData, I as InputData, i as isFunctionKey, E as EventEmitter, C as ChannelDataType, a as WebRTCSdk, b as EmitType, F as FailCode, c as ContainerDirection, K as KeyEventData, j as ActionCommandEventValue, h as ActionCommandEventType, d as ClarityData, G as GestureData } from "./ScreenControlUtil-D4-BTCo9.js";
|
|
14
14
|
var DocumentEvent = /* @__PURE__ */ ((DocumentEvent2) => {
|
|
15
15
|
DocumentEvent2["KEY_DOWN"] = "keydown";
|
|
16
16
|
DocumentEvent2["POINTER_ENTER"] = "pointerenter";
|
|
@@ -143,7 +143,7 @@ class RemoteVideoController {
|
|
|
143
143
|
(_a = this.loadedSuccess) == null ? void 0 : _a.call(this);
|
|
144
144
|
});
|
|
145
145
|
this.logger = new Logger({
|
|
146
|
-
prefix: "
|
|
146
|
+
prefix: "RemoteController",
|
|
147
147
|
enabledDebug
|
|
148
148
|
});
|
|
149
149
|
this.rootContainer = rootContainer;
|
|
@@ -241,17 +241,16 @@ class RemoteVideoController {
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
destroy() {
|
|
244
|
-
this.logger.log("
|
|
244
|
+
this.logger.log("destroy");
|
|
245
245
|
this.stopPlay();
|
|
246
246
|
this.offEvent();
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
_screenStatus = new WeakMap();
|
|
250
250
|
class RemoteCanvasController {
|
|
251
|
-
constructor(
|
|
252
|
-
__publicField(this, "remoteElement");
|
|
251
|
+
constructor() {
|
|
252
|
+
__publicField(this, "remoteElement", null);
|
|
253
253
|
__publicField(this, "audioElement");
|
|
254
|
-
this.remoteElement = remoteElement;
|
|
255
254
|
}
|
|
256
255
|
startDecode(arrayBuffer) {
|
|
257
256
|
}
|
|
@@ -444,6 +443,7 @@ class MouseTouchControl {
|
|
|
444
443
|
__publicField(this, "handleMouseEnter", (event) => {
|
|
445
444
|
event.preventDefault();
|
|
446
445
|
event.stopPropagation();
|
|
446
|
+
if (event.pointerType !== "mouse") return;
|
|
447
447
|
if (event.buttons === 1 && !this.pointers.has(event.pointerId)) {
|
|
448
448
|
if (this.remoteElement) {
|
|
449
449
|
this.remoteElement.setPointerCapture(event.pointerId);
|
|
@@ -454,6 +454,7 @@ class MouseTouchControl {
|
|
|
454
454
|
__publicField(this, "handleMouseLeave", (event) => {
|
|
455
455
|
event.preventDefault();
|
|
456
456
|
event.stopPropagation();
|
|
457
|
+
if (event.pointerType !== "mouse") return;
|
|
457
458
|
if (this.pointers.has(event.pointerId)) {
|
|
458
459
|
this.handlePointerEvent(event, ActionType.ACTION_UP, event.pointerId);
|
|
459
460
|
if (this.remoteElement) {
|
|
@@ -562,6 +563,7 @@ class KeyboardControl {
|
|
|
562
563
|
(_a = this.inputMethodEditorElement) == null ? void 0 : _a.blur();
|
|
563
564
|
});
|
|
564
565
|
__publicField(this, "handleKeyDown", (e) => {
|
|
566
|
+
e.preventDefault();
|
|
565
567
|
const data = getKeyEventData(e);
|
|
566
568
|
this.inputDataUpdateCallback(data);
|
|
567
569
|
});
|
|
@@ -746,7 +748,7 @@ const _WebRTCWrapper = class _WebRTCWrapper extends EventEmitter {
|
|
|
746
748
|
__privateAdd(this, _clarityLevel);
|
|
747
749
|
__privateAdd(this, _gestureMode);
|
|
748
750
|
this.logger = new Logger({
|
|
749
|
-
prefix: "
|
|
751
|
+
prefix: "Wrapper",
|
|
750
752
|
enabledDebug
|
|
751
753
|
});
|
|
752
754
|
const webRtcSDKInstance = new WebRTCSdk(connectConfig);
|
|
@@ -889,6 +891,7 @@ const _WebRTCWrapper = class _WebRTCWrapper extends EventEmitter {
|
|
|
889
891
|
}
|
|
890
892
|
destroy() {
|
|
891
893
|
var _a;
|
|
894
|
+
this.logger.log("destroy");
|
|
892
895
|
(_a = this.webRtcSDKInstance) == null ? void 0 : _a.stop();
|
|
893
896
|
this.offEvents();
|
|
894
897
|
this.webRtcSDKInstance = null;
|
package/lib/yjz-web-sdk.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
import { A as ActionType, C as ChannelDataType, W as WheelData, t as transformCoordinate, v as valueToPercentage, T as TouchData, I as InputData, i as isFunctionKey, g as getKeyEventData, E as EventEmitter, a as WebRTCSdk, b as EmitType, e as enableLog, s as setLogLevel, K as KeyEventData } from "./ScreenControlUtil-
|
|
6
|
-
import { h, j, f, d, l, c, F, G, k, m } from "./ScreenControlUtil-
|
|
5
|
+
import { A as ActionType, C as ChannelDataType, W as WheelData, t as transformCoordinate, v as valueToPercentage, T as TouchData, I as InputData, i as isFunctionKey, g as getKeyEventData, E as EventEmitter, a as WebRTCSdk, b as EmitType, e as enableLog, s as setLogLevel, K as KeyEventData } from "./ScreenControlUtil-D4-BTCo9.js";
|
|
6
|
+
import { h, j, f, d, l, c, F, G, k, m } from "./ScreenControlUtil-D4-BTCo9.js";
|
|
7
7
|
import { computed, onMounted, onUnmounted, ref, onBeforeUnmount, defineComponent, toRefs, createElementBlock, openBlock, createElementVNode, normalizeStyle, unref, createCommentVNode, normalizeClass } from "vue";
|
|
8
8
|
function useCursorStyle(cursorType) {
|
|
9
9
|
return computed(() => {
|
|
@@ -296,6 +296,7 @@ function useMouseTouchControl(options) {
|
|
|
296
296
|
const handleMouseEnter = (event) => {
|
|
297
297
|
event.preventDefault();
|
|
298
298
|
event.stopPropagation();
|
|
299
|
+
if (event.pointerType !== "mouse") return;
|
|
299
300
|
if (event.buttons === 1 && !pointers.value.has(event.pointerId)) {
|
|
300
301
|
if (remoteVideoElement.value) remoteVideoElement.value.setPointerCapture(event.pointerId);
|
|
301
302
|
handlePointerEvent(event, ActionType.ACTION_DOWN, event.pointerId);
|
|
@@ -304,6 +305,7 @@ function useMouseTouchControl(options) {
|
|
|
304
305
|
const handleMouseLeave = (event) => {
|
|
305
306
|
event.preventDefault();
|
|
306
307
|
event.stopPropagation();
|
|
308
|
+
if (event.pointerType !== "mouse") return;
|
|
307
309
|
if (pointers.value.has(event.pointerId)) {
|
|
308
310
|
handlePointerEvent(event, ActionType.ACTION_UP, event.pointerId);
|
|
309
311
|
if (remoteVideoElement.value) remoteVideoElement.value.releasePointerCapture(event.pointerId);
|
|
@@ -327,6 +329,7 @@ function useMouseTouchControl(options) {
|
|
|
327
329
|
function useKeyboardControl(imeInput, disabled, emit) {
|
|
328
330
|
const isComposing = ref(false);
|
|
329
331
|
const handleKeyDown = (e) => {
|
|
332
|
+
e.preventDefault();
|
|
330
333
|
const data = getKeyEventData(e);
|
|
331
334
|
emit("channelEvent", ChannelDataType.ActionInput, data);
|
|
332
335
|
};
|
|
@@ -372,6 +375,7 @@ function useKeyboardControl(imeInput, disabled, emit) {
|
|
|
372
375
|
function onKeyDown(event) {
|
|
373
376
|
if (isComposing.value) return;
|
|
374
377
|
if (isFunctionKey(event)) {
|
|
378
|
+
event.preventDefault();
|
|
375
379
|
const data = getKeyEventData(event);
|
|
376
380
|
if (data.keyCode === 50 && data.meta === 4096) return;
|
|
377
381
|
emit("channelEvent", ChannelDataType.ActionInput, data);
|