yjz-web-sdk 1.0.11-beta.6 → 1.0.11-beta.8
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-C-S0QaJL.js → ScreenControlUtil-hkrPNY6q.js} +118 -44
- package/lib/core/rtc/WebRTCClient.d.ts +2 -0
- package/lib/core/rtc/WebRtcNegotiate.d.ts +1 -1
- package/lib/core/util/TurnTestUtil.d.ts +2 -2
- package/lib/index.d.ts +2 -2
- package/lib/uni/RemoteCanvasController.d.ts +1 -3
- package/lib/uni-sdk.js +7 -7
- package/lib/yjz-web-sdk.js +8 -4
- package/package.json +1 -1
|
@@ -3202,6 +3202,8 @@ function adapterFactory({ window: window2 } = {}, options = {
|
|
|
3202
3202
|
return adapter;
|
|
3203
3203
|
}
|
|
3204
3204
|
adapterFactory({ window: typeof window === "undefined" ? void 0 : window });
|
|
3205
|
+
let checkingTimer = null;
|
|
3206
|
+
let disconnectedTimer = null;
|
|
3205
3207
|
const setRemoteDescriptionWithHandleOffer = (peerConnection, sdp2, sendAnswer, onError) => {
|
|
3206
3208
|
Logger.info("信息日志:", "设置远程offer Description=======>");
|
|
3207
3209
|
const description = new RTCSessionDescription({ type: "offer", sdp: sdp2 });
|
|
@@ -3255,8 +3257,45 @@ const configPeerConnection = (peerConnection, onICEMessage, onTrack, onConnectSt
|
|
|
3255
3257
|
return;
|
|
3256
3258
|
}
|
|
3257
3259
|
Logger.debug("信息日志:", `webrtc p2p连接状态===>`, state);
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
+
switch (state) {
|
|
3261
|
+
case "new":
|
|
3262
|
+
case "checking":
|
|
3263
|
+
if (!checkingTimer) {
|
|
3264
|
+
checkingTimer = setTimeout(() => {
|
|
3265
|
+
onError == null ? void 0 : onError(createWebRtcError(
|
|
3266
|
+
FailCode.ICE_STATE,
|
|
3267
|
+
"TURN服务器连接超时"
|
|
3268
|
+
));
|
|
3269
|
+
}, 6e3);
|
|
3270
|
+
}
|
|
3271
|
+
break;
|
|
3272
|
+
case "connected":
|
|
3273
|
+
case "completed":
|
|
3274
|
+
if (checkingTimer) {
|
|
3275
|
+
clearTimeout(checkingTimer);
|
|
3276
|
+
checkingTimer = null;
|
|
3277
|
+
}
|
|
3278
|
+
if (disconnectedTimer) {
|
|
3279
|
+
clearTimeout(disconnectedTimer);
|
|
3280
|
+
disconnectedTimer = null;
|
|
3281
|
+
}
|
|
3282
|
+
break;
|
|
3283
|
+
case "disconnected":
|
|
3284
|
+
if (!disconnectedTimer) {
|
|
3285
|
+
disconnectedTimer = setTimeout(() => {
|
|
3286
|
+
onError == null ? void 0 : onError(createWebRtcError(
|
|
3287
|
+
FailCode.ICE_STATE,
|
|
3288
|
+
"TURN disconnected时间过长"
|
|
3289
|
+
));
|
|
3290
|
+
}, 8e3);
|
|
3291
|
+
}
|
|
3292
|
+
break;
|
|
3293
|
+
case "failed":
|
|
3294
|
+
onError == null ? void 0 : onError(createWebRtcError(
|
|
3295
|
+
FailCode.ICE_STATE,
|
|
3296
|
+
"TURN ICE failed"
|
|
3297
|
+
));
|
|
3298
|
+
break;
|
|
3260
3299
|
}
|
|
3261
3300
|
onConnectState == null ? void 0 : onConnectState(state);
|
|
3262
3301
|
};
|
|
@@ -3267,9 +3306,11 @@ const configPeerConnection = (peerConnection, onICEMessage, onTrack, onConnectSt
|
|
|
3267
3306
|
onTrack == null ? void 0 : onTrack(track);
|
|
3268
3307
|
};
|
|
3269
3308
|
};
|
|
3270
|
-
const setRemoteDescriptionWithHandleAnswer = (peerConnection, sdp2, onError) => {
|
|
3309
|
+
const setRemoteDescriptionWithHandleAnswer = (peerConnection, sdp2, onSuccess, onError) => {
|
|
3271
3310
|
const description = new RTCSessionDescription({ type: "answer", sdp: sdp2 });
|
|
3272
|
-
peerConnection.setRemoteDescription(description).
|
|
3311
|
+
peerConnection.setRemoteDescription(description).then(() => {
|
|
3312
|
+
onSuccess == null ? void 0 : onSuccess();
|
|
3313
|
+
}).catch((err) => onError == null ? void 0 : onError(createWebRtcError(FailCode.REMOTE_DES, err)));
|
|
3273
3314
|
};
|
|
3274
3315
|
const createOffer = async (peerConnection, sendOfferMessage) => {
|
|
3275
3316
|
try {
|
|
@@ -3434,7 +3475,6 @@ class ChannelData {
|
|
|
3434
3475
|
* @param data 剪贴板数据,可以是字符串或其他类型
|
|
3435
3476
|
*/
|
|
3436
3477
|
static clipboard(data) {
|
|
3437
|
-
console.log(`剪贴板数据,可以是字符串或其他类型 ${data}`);
|
|
3438
3478
|
return new ChannelData("ClipboardData", this.formatData(data), "");
|
|
3439
3479
|
}
|
|
3440
3480
|
/**
|
|
@@ -3549,6 +3589,8 @@ class WebRTCClient extends EventEmitter {
|
|
|
3549
3589
|
__publicField(this, "rafId", 0);
|
|
3550
3590
|
__publicField(this, "currentMedia", null);
|
|
3551
3591
|
__publicField(this, "fileImage");
|
|
3592
|
+
__publicField(this, "reConnectTimer", null);
|
|
3593
|
+
__publicField(this, "canPushStream", false);
|
|
3552
3594
|
__publicField(this, "startPushLocal", async (file) => {
|
|
3553
3595
|
if (this.isPushingLocalStream || !file) return;
|
|
3554
3596
|
try {
|
|
@@ -3600,7 +3642,16 @@ class WebRTCClient extends EventEmitter {
|
|
|
3600
3642
|
}, (err) => this.emit(EmitType.webrtcError, err));
|
|
3601
3643
|
}
|
|
3602
3644
|
handleAnswer(answerSdp) {
|
|
3603
|
-
setRemoteDescriptionWithHandleAnswer(this.peerConnection, answerSdp ?? "", (
|
|
3645
|
+
setRemoteDescriptionWithHandleAnswer(this.peerConnection, answerSdp ?? "", () => {
|
|
3646
|
+
this.canPushStream = true;
|
|
3647
|
+
}, (_err) => {
|
|
3648
|
+
this.canPushStream = false;
|
|
3649
|
+
this.reConnectTimer = setTimeout(async () => {
|
|
3650
|
+
await createOffer(this.peerConnection, (sdp2) => {
|
|
3651
|
+
this.emit(EmitType.sendOffer, sdp2);
|
|
3652
|
+
});
|
|
3653
|
+
}, 3e3);
|
|
3654
|
+
});
|
|
3604
3655
|
}
|
|
3605
3656
|
handleIceCandidate(candidate) {
|
|
3606
3657
|
addIceCandidate(this.peerConnection, candidate, (err) => this.emit(EmitType.webrtcError, err));
|
|
@@ -3686,6 +3737,10 @@ class WebRTCClient extends EventEmitter {
|
|
|
3686
3737
|
(_a2 = transceiver.stop) == null ? void 0 : _a2.call(transceiver);
|
|
3687
3738
|
});
|
|
3688
3739
|
}
|
|
3740
|
+
if (this.reConnectTimer) {
|
|
3741
|
+
clearTimeout(this.reConnectTimer);
|
|
3742
|
+
this.reConnectTimer = null;
|
|
3743
|
+
}
|
|
3689
3744
|
this.removeAllListeners();
|
|
3690
3745
|
(_a = this.videoDataChannel) == null ? void 0 : _a.close();
|
|
3691
3746
|
this.videoDataChannel = null;
|
|
@@ -3718,6 +3773,11 @@ class WebRTCClient extends EventEmitter {
|
|
|
3718
3773
|
});
|
|
3719
3774
|
this.rotatedStream = await this.getRotatedStream(this.localStream, useBackCamera);
|
|
3720
3775
|
await this.onConnected();
|
|
3776
|
+
if (!this.canPushStream) {
|
|
3777
|
+
await createOffer(this.peerConnection, (sdp2) => {
|
|
3778
|
+
this.emit(EmitType.sendOffer, sdp2);
|
|
3779
|
+
});
|
|
3780
|
+
}
|
|
3721
3781
|
} catch (err) {
|
|
3722
3782
|
if (err instanceof DOMException) {
|
|
3723
3783
|
switch (err.name) {
|
|
@@ -3756,6 +3816,11 @@ class WebRTCClient extends EventEmitter {
|
|
|
3756
3816
|
const rotatedStream = await this.getRotatedStream(this.localStream, useBackCamera);
|
|
3757
3817
|
this.rotatedStream = rotatedStream;
|
|
3758
3818
|
await this.onConnected();
|
|
3819
|
+
if (!this.canPushStream) {
|
|
3820
|
+
await createOffer(this.peerConnection, (sdp2) => {
|
|
3821
|
+
this.emit(EmitType.sendOffer, sdp2);
|
|
3822
|
+
});
|
|
3823
|
+
}
|
|
3759
3824
|
} catch (err) {
|
|
3760
3825
|
this.isPushingStream = false;
|
|
3761
3826
|
if (err instanceof DOMException) {
|
|
@@ -3884,9 +3949,6 @@ class WebRTCClient extends EventEmitter {
|
|
|
3884
3949
|
this.emit(EmitType.iceConnectionState, state);
|
|
3885
3950
|
if (state === "connected") {
|
|
3886
3951
|
this.checkStats();
|
|
3887
|
-
await createOffer(this.peerConnection, (sdp2) => {
|
|
3888
|
-
this.emit(EmitType.sendOffer, sdp2);
|
|
3889
|
-
});
|
|
3890
3952
|
}
|
|
3891
3953
|
}, (err) => this.emit(EmitType.webrtcError, err));
|
|
3892
3954
|
this.configDataChannel();
|
|
@@ -3917,7 +3979,6 @@ class WebRTCClient extends EventEmitter {
|
|
|
3917
3979
|
const data = JSON.parse(event.data);
|
|
3918
3980
|
if (data.type === ChannelDataType.ActionCommandEvent) {
|
|
3919
3981
|
const { action, value, cameraId } = JSON.parse(data.data);
|
|
3920
|
-
console.error("data===>", data.data);
|
|
3921
3982
|
if (action === "ACTION_CONTROL_VIDEO") {
|
|
3922
3983
|
if (value === "ENABLE") {
|
|
3923
3984
|
if (this.isPushingStream) {
|
|
@@ -4207,14 +4268,13 @@ class WebRTCConfig {
|
|
|
4207
4268
|
this.signAgain = options.signAgain || true;
|
|
4208
4269
|
}
|
|
4209
4270
|
}
|
|
4210
|
-
const testTurnServer = (turnConfig, timeoutMs =
|
|
4271
|
+
const testTurnServer = (turnConfig, timeoutMs = 1500) => {
|
|
4211
4272
|
return new Promise((resolve) => {
|
|
4212
4273
|
const start = performance.now();
|
|
4213
4274
|
let resolved = false;
|
|
4214
4275
|
const pc = new RTCPeerConnection({
|
|
4215
4276
|
iceServers: [turnConfig],
|
|
4216
4277
|
iceTransportPolicy: "relay"
|
|
4217
|
-
// 强制走 TURN
|
|
4218
4278
|
});
|
|
4219
4279
|
pc.createDataChannel("test");
|
|
4220
4280
|
pc.createOffer().then((offer) => pc.setLocalDescription(offer)).catch(() => {
|
|
@@ -4233,9 +4293,11 @@ const testTurnServer = (turnConfig, timeoutMs = 600) => {
|
|
|
4233
4293
|
resolve({ ...turnConfig, rtt });
|
|
4234
4294
|
}
|
|
4235
4295
|
if (event.candidate === null) {
|
|
4236
|
-
resolved
|
|
4237
|
-
|
|
4238
|
-
|
|
4296
|
+
if (!resolved) {
|
|
4297
|
+
resolved = true;
|
|
4298
|
+
pc.close();
|
|
4299
|
+
resolve({ ...turnConfig, rtt: Infinity });
|
|
4300
|
+
}
|
|
4239
4301
|
}
|
|
4240
4302
|
};
|
|
4241
4303
|
setTimeout(() => {
|
|
@@ -4247,43 +4309,56 @@ const testTurnServer = (turnConfig, timeoutMs = 600) => {
|
|
|
4247
4309
|
}, timeoutMs);
|
|
4248
4310
|
});
|
|
4249
4311
|
};
|
|
4250
|
-
const
|
|
4312
|
+
const limitConcurrency = async (tasks, concurrency) => {
|
|
4313
|
+
const results = [];
|
|
4314
|
+
const executing = [];
|
|
4315
|
+
for (const task of tasks) {
|
|
4316
|
+
const p = task().then((r) => results.push(r));
|
|
4317
|
+
executing.push(p);
|
|
4318
|
+
if (executing.length >= concurrency) {
|
|
4319
|
+
await Promise.race(executing);
|
|
4320
|
+
for (let i = executing.length - 1; i >= 0; i--) {
|
|
4321
|
+
if (executing[i].resolved) executing.splice(i, 1);
|
|
4322
|
+
}
|
|
4323
|
+
}
|
|
4324
|
+
}
|
|
4325
|
+
await Promise.all(executing);
|
|
4326
|
+
return results;
|
|
4327
|
+
};
|
|
4328
|
+
const testMultipleTurnServersFast = async (servers, timeoutMs = 600, concurrency = 3) => {
|
|
4251
4329
|
const turnServers = servers.map((url) => ({
|
|
4252
4330
|
urls: url,
|
|
4253
4331
|
username: "yangyj",
|
|
4254
4332
|
credential: "hb@2025@168"
|
|
4255
4333
|
}));
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
const best = available.sort((a, b) => a.rtt - b.rtt)[0];
|
|
4269
|
-
return {
|
|
4270
|
-
best: best ? stripTurnAuth(best) : void 0,
|
|
4271
|
-
all: results.map(stripTurnAuth)
|
|
4272
|
-
};
|
|
4273
|
-
};
|
|
4274
|
-
const stripTurnAuth = (result) => {
|
|
4334
|
+
let bestResult = void 0;
|
|
4335
|
+
const allResults = [];
|
|
4336
|
+
const tasks = turnServers.map((cfg) => async () => {
|
|
4337
|
+
const res = await testTurnServer(cfg, timeoutMs);
|
|
4338
|
+
allResults.push(res);
|
|
4339
|
+
if (!bestResult && res.rtt !== Infinity) {
|
|
4340
|
+
bestResult = res;
|
|
4341
|
+
}
|
|
4342
|
+
return res;
|
|
4343
|
+
});
|
|
4344
|
+
await limitConcurrency(tasks, concurrency);
|
|
4345
|
+
Logger.debug("调试日志:", `TURN 测试结果======>`, allResults);
|
|
4275
4346
|
return {
|
|
4276
|
-
|
|
4277
|
-
|
|
4347
|
+
best: bestResult ? stripTurnAuth(bestResult) : void 0,
|
|
4348
|
+
all: allResults.map(stripTurnAuth)
|
|
4278
4349
|
};
|
|
4279
4350
|
};
|
|
4351
|
+
const stripTurnAuth = (result) => ({
|
|
4352
|
+
urls: result.urls,
|
|
4353
|
+
rtt: result.rtt
|
|
4354
|
+
});
|
|
4280
4355
|
const areTurnListsEmpty = (options) => {
|
|
4281
4356
|
return (!options.hostTurn || options.hostTurn.length === 0) && (!options.spareTurn || options.spareTurn.length === 0);
|
|
4282
4357
|
};
|
|
4283
|
-
const
|
|
4358
|
+
const selectBestTurnServerFast = async (turnList) => {
|
|
4284
4359
|
var _a, _b;
|
|
4285
4360
|
try {
|
|
4286
|
-
const result = await
|
|
4361
|
+
const result = await testMultipleTurnServersFast(turnList);
|
|
4287
4362
|
return { url: (_a = result.best) == null ? void 0 : _a.urls, rtt: (_b = result.best) == null ? void 0 : _b.rtt };
|
|
4288
4363
|
} catch (e) {
|
|
4289
4364
|
return { error: e.message || "未知错误" };
|
|
@@ -4309,7 +4384,6 @@ class WebRTCSdk extends EventEmitter {
|
|
|
4309
4384
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
4310
4385
|
if (!this.config) return;
|
|
4311
4386
|
Logger.debug("调试信息:", `信令消息=========>`, message);
|
|
4312
|
-
console.log(`信令消息=========>`, message);
|
|
4313
4387
|
switch (message.type) {
|
|
4314
4388
|
case MessageType.Peers:
|
|
4315
4389
|
this.config.myId = message.myId;
|
|
@@ -4479,9 +4553,9 @@ class WebRTCSdk extends EventEmitter {
|
|
|
4479
4553
|
const tryTurnList = async (list, isHost) => {
|
|
4480
4554
|
if (list.length === 0) return false;
|
|
4481
4555
|
try {
|
|
4482
|
-
const result = await
|
|
4556
|
+
const result = await selectBestTurnServerFast(list);
|
|
4483
4557
|
if (result.url && typeof result.rtt === "number") {
|
|
4484
|
-
if (isHost && result.rtt >
|
|
4558
|
+
if (isHost && result.rtt > 250) {
|
|
4485
4559
|
return false;
|
|
4486
4560
|
}
|
|
4487
4561
|
this.options.turnServerUri = result.url;
|
|
@@ -5060,8 +5134,8 @@ export {
|
|
|
5060
5134
|
isFunctionKey as i,
|
|
5061
5135
|
ActionCommandEventValue as j,
|
|
5062
5136
|
TrackEventData as k,
|
|
5063
|
-
|
|
5064
|
-
|
|
5137
|
+
ConnectorType as l,
|
|
5138
|
+
selectBestTurnServerFast as m,
|
|
5065
5139
|
setLogLevel as s,
|
|
5066
5140
|
transformCoordinate as t,
|
|
5067
5141
|
valueToPercentage as v
|
|
@@ -26,6 +26,8 @@ export declare class WebRTCClient extends EventEmitter {
|
|
|
26
26
|
private rafId;
|
|
27
27
|
private currentMedia;
|
|
28
28
|
private fileImage?;
|
|
29
|
+
private reConnectTimer;
|
|
30
|
+
private canPushStream;
|
|
29
31
|
constructor(config: WebRTCConfig);
|
|
30
32
|
startPush(useBackCamera?: boolean): Promise<void>;
|
|
31
33
|
handleOffer(offerSdp: string): void;
|
|
@@ -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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TurnSelectionResult, TurnServerConfig, TurnTestResult, TurnTestSummary } from '../data/TurnType.ts';
|
|
2
2
|
import type { WebRTCConfigOptions } from '../rtc/WebRTCConfig.ts';
|
|
3
3
|
export declare const testTurnServer: (turnConfig: TurnServerConfig, timeoutMs?: number) => Promise<TurnTestResult>;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const testMultipleTurnServersFast: (servers: string[], timeoutMs?: number, concurrency?: number) => Promise<TurnTestSummary>;
|
|
5
5
|
export declare const areTurnListsEmpty: (options: WebRTCConfigOptions) => boolean;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const selectBestTurnServerFast: (turnList: string[]) => Promise<TurnSelectionResult>;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WebRTCSdk } from './core/WebRTCSdk';
|
|
2
2
|
import { getKeyEventData } from "./core/util/KeyCodeUtil";
|
|
3
|
-
import {
|
|
3
|
+
import { selectBestTurnServerFast } from './core/util/TurnTestUtil';
|
|
4
4
|
import { transformCoordinate, valueToPercentage } from "./core/util/ScreenControlUtil";
|
|
5
5
|
import { ActionType, ChannelDataType, ContainerDirection, InputData, KeyEventData, TouchData, WheelData, GestureData, type ActionCommand, ActionCommandType, ActionCommandEventType, ActionCommandEventValue, TrackEventData, ClarityData } from "./core/data/WebrtcDataType";
|
|
6
6
|
import { type TurnServerConfig, type TurnTestResult, type TurnTestSummary } from "./core/data/TurnType";
|
|
@@ -9,4 +9,4 @@ import { EmitType, FailCode, type CameraError, type WebRtcError } from "./core/d
|
|
|
9
9
|
import RemotePlayer from './components/RemotePlayer/index.vue';
|
|
10
10
|
import { ConnectorType } from './core/data/MessageType';
|
|
11
11
|
import { GroupCtrlSocketManager } from './core/groupctrl/GroupCtrlSocketManager';
|
|
12
|
-
export { WebRTCSdk, getKeyEventData, transformCoordinate, valueToPercentage, ActionType, ChannelDataType, InputData, KeyEventData, TouchData, ContainerDirection, EmitType, WheelData, GestureData, ClarityData, type ActionCommand, ActionCommandType, type WebRTCConfigOptions, ActionCommandEventType, ActionCommandEventValue, RemotePlayer, TrackEventData, type TurnServerConfig, type TurnTestResult, type TurnTestSummary,
|
|
12
|
+
export { WebRTCSdk, getKeyEventData, transformCoordinate, valueToPercentage, ActionType, ChannelDataType, InputData, KeyEventData, TouchData, ContainerDirection, EmitType, WheelData, GestureData, ClarityData, type ActionCommand, ActionCommandType, type WebRTCConfigOptions, ActionCommandEventType, ActionCommandEventValue, RemotePlayer, TrackEventData, type TurnServerConfig, type TurnTestResult, type TurnTestSummary, type CameraError, type WebRtcError, ConnectorType, GroupCtrlSocketManager, FailCode, selectBestTurnServerFast };
|
|
@@ -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-hkrPNY6q.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
|
}
|
|
@@ -746,7 +745,7 @@ const _WebRTCWrapper = class _WebRTCWrapper extends EventEmitter {
|
|
|
746
745
|
__privateAdd(this, _clarityLevel);
|
|
747
746
|
__privateAdd(this, _gestureMode);
|
|
748
747
|
this.logger = new Logger({
|
|
749
|
-
prefix: "
|
|
748
|
+
prefix: "Wrapper",
|
|
750
749
|
enabledDebug
|
|
751
750
|
});
|
|
752
751
|
const webRtcSDKInstance = new WebRTCSdk(connectConfig);
|
|
@@ -889,6 +888,7 @@ const _WebRTCWrapper = class _WebRTCWrapper extends EventEmitter {
|
|
|
889
888
|
}
|
|
890
889
|
destroy() {
|
|
891
890
|
var _a;
|
|
891
|
+
this.logger.log("destroy");
|
|
892
892
|
(_a = this.webRtcSDKInstance) == null ? void 0 : _a.stop();
|
|
893
893
|
this.offEvents();
|
|
894
894
|
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,
|
|
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-hkrPNY6q.js";
|
|
6
|
+
import { h, j, f, d, l, c, F, G, k, m } from "./ScreenControlUtil-hkrPNY6q.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);
|
|
@@ -701,7 +705,7 @@ export {
|
|
|
701
705
|
ActionType,
|
|
702
706
|
ChannelDataType,
|
|
703
707
|
d as ClarityData,
|
|
704
|
-
|
|
708
|
+
l as ConnectorType,
|
|
705
709
|
c as ContainerDirection,
|
|
706
710
|
EmitType,
|
|
707
711
|
F as FailCode,
|
|
@@ -715,7 +719,7 @@ export {
|
|
|
715
719
|
WebRTCSdk,
|
|
716
720
|
WheelData,
|
|
717
721
|
getKeyEventData,
|
|
718
|
-
|
|
722
|
+
m as selectBestTurnServerFast,
|
|
719
723
|
transformCoordinate,
|
|
720
724
|
valueToPercentage
|
|
721
725
|
};
|