@realsee/live 0.4.0-alpha.3 → 0.4.0-alpha.4

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,3 +1,4 @@
1
+ import JSBridge from '@realsee/jsbridge-x';
1
2
  import { DefaultModality, ConsoleLogger, LogLevel, DefaultDeviceController, MeetingSessionConfiguration, DefaultMeetingSession, MeetingSessionStatusCode } from 'amazon-chime-sdk-js';
2
3
  import TRTC from 'trtc-js-sdk';
3
4
  import React from 'react';
@@ -128,7 +129,12 @@ var RTCType;
128
129
  RTCType["RealseeBrowserRTC"] = "RealseeBrowserRTC";
129
130
  RTCType["RealseeVRWebViewRTC"] = "RealseeVRWebViewRTC";
130
131
  RTCType["RealseeBrowserChimeRTC"] = "RealseeBrowserChimeRTC";
131
- })(RTCType || (RTCType = {}));
132
+ })(RTCType || (RTCType = {}));
133
+ var BuiltInRTCType;
134
+ (function (BuiltInRTCType) {
135
+ BuiltInRTCType["RealseeXTRTC"] = "trtc";
136
+ BuiltInRTCType["RealseeXChimeRTC"] = "chime";
137
+ })(BuiltInRTCType || (BuiltInRTCType = {}));
132
138
 
133
139
  // uuid
134
140
  function S4() {
@@ -879,6 +885,12 @@ function appendUri(uri, query) {
879
885
  return uri + newQuery;
880
886
  }
881
887
 
888
+ const userAgent = globalThis.navigator.userAgent;
889
+ const isAndroid = /android/gi.test(userAgent);
890
+ const isIOS = /iPhone|iPad\s+OS/gi.test(userAgent);
891
+ const isWxMiniProgram = /MicroMessenger/gi.test(userAgent) && /miniProgram/gi.test(userAgent);
892
+ const isRealseeVRWebview = /realsee/gi.test(userAgent);
893
+
882
894
  /**
883
895
  * 判断是否是真实的对象类型
884
896
  * @param value
@@ -1243,7 +1255,7 @@ function createLive(options) {
1243
1255
  };
1244
1256
  class LiveTpl extends Subscribe {
1245
1257
  constructor() {
1246
- var _a;
1258
+ var _a, _b, _c;
1247
1259
  super();
1248
1260
  this.keyframes = new Subscribe();
1249
1261
  // 没有传rtc实例时
@@ -1286,6 +1298,34 @@ function createLive(options) {
1286
1298
  }
1287
1299
  }
1288
1300
  }
1301
+ // 都不满足时取内置
1302
+ if (options.useBuiltInRTC) {
1303
+ if (!options.getVoiceSign) {
1304
+ throw new Error('GetVoiceSign method must be passed when using built-in RTC instances');
1305
+ }
1306
+ const getVoiceSign = (_b = options.getVoiceSign) !== null && _b !== void 0 ? _b : unimplementedGetVoiceSign;
1307
+ const jsBridge = ((_c = options.jsBridge) !== null && _c !== void 0 ? _c : options.useBuiltInJsBridge)
1308
+ ? new JSBridge()
1309
+ : null;
1310
+ if (!jsBridge) {
1311
+ throw new Error('jsBridge instance must be passed when using built-in RTC instances');
1312
+ }
1313
+ options.jsBridge = jsBridge;
1314
+ // vrwebview 默认
1315
+ if ((isRealseeVRWebview && (isAndroid || isIOS)) || isWxMiniProgram) {
1316
+ liveController.options.rtc = new VRWebViewRTC({
1317
+ jsBridge,
1318
+ getVoiceSign,
1319
+ });
1320
+ }
1321
+ else {
1322
+ // 其它终端使用
1323
+ liveController.options.rtc =
1324
+ options.builtInRTCType === BuiltInRTCType.RealseeXChimeRTC
1325
+ ? new BrowserRTC4Chime({ getVoiceSign })
1326
+ : new BrowserRTC({ getVoiceSign });
1327
+ }
1328
+ }
1289
1329
  }
1290
1330
  if (!liveController.options.rtc) {
1291
1331
  console.warn('unused rtc');
@@ -1333,6 +1373,9 @@ function createLive(options) {
1333
1373
  get $RTC() {
1334
1374
  return liveController.options.rtc;
1335
1375
  }
1376
+ get jsBridge() {
1377
+ return liveController.options.jsBridge;
1378
+ }
1336
1379
  async setSelfInfo(userInfo) {
1337
1380
  if (this.readyState !== WebSocketState.OPEN) {
1338
1381
  return new Error('The connection is not open and ready to communicate.');
@@ -1793,5 +1836,5 @@ function createLiveReact(options) {
1793
1836
  };
1794
1837
  }
1795
1838
 
1796
- export { BrowserRTC, BrowserRTC4Chime, BuiltinActionType, BuiltinEventType, Command, CoreRTC, MemUserStatus, MicroStatus, RTCJoinedInfoCodeEnum, RTCType, UserStatus, VRWebViewRTC, WebSocketCloseError, WebSocketErrorType, WebSocketState, createLive, createLiveReact, parseLiveMsg, parseWSClsErr };
1839
+ export { BrowserRTC, BrowserRTC4Chime, BuiltInRTCType, BuiltinActionType, BuiltinEventType, Command, CoreRTC, MemUserStatus, MicroStatus, RTCJoinedInfoCodeEnum, RTCType, UserStatus, VRWebViewRTC, WebSocketCloseError, WebSocketErrorType, WebSocketState, createLive, createLiveReact, parseLiveMsg, parseWSClsErr };
1797
1840
  //# sourceMappingURL=realsee-live.esm.js.map