@realsee/live 0.4.0-alpha.3 → 0.4.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,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,9 +1255,13 @@ 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();
1261
+ const jsBridge = ((_a = options.jsBridge) !== null && _a !== void 0 ? _a : options.useBuiltInJsBridge)
1262
+ ? new JSBridge()
1263
+ : undefined;
1264
+ liveController.options.jsBridge = jsBridge;
1249
1265
  // 没有传rtc实例时
1250
1266
  if (!options.rtc) {
1251
1267
  // 取指定的内部rtc类型
@@ -1253,15 +1269,15 @@ function createLive(options) {
1253
1269
  if (!options.getVoiceSign) {
1254
1270
  throw new Error('GetVoiceSign method must be passed when using built-in RTC instances');
1255
1271
  }
1256
- const getVoiceSign = (_a = options.getVoiceSign) !== null && _a !== void 0 ? _a : unimplementedGetVoiceSign;
1272
+ const getVoiceSign = (_b = options.getVoiceSign) !== null && _b !== void 0 ? _b : unimplementedGetVoiceSign;
1257
1273
  switch (options.rtcType) {
1258
1274
  case RTCType.RealseeVRWebViewRTC: {
1259
1275
  // 内置的 VRWebViewRTC
1260
- if (!options.jsBridge) {
1276
+ if (!jsBridge) {
1261
1277
  throw new Error('JsBridge instance must be passed when using built-in VRWebViewRTC instances');
1262
1278
  }
1263
1279
  liveController.options.rtc = new VRWebViewRTC({
1264
- jsBridge: options.jsBridge,
1280
+ jsBridge,
1265
1281
  getVoiceSign,
1266
1282
  });
1267
1283
  break;
@@ -1286,6 +1302,30 @@ function createLive(options) {
1286
1302
  }
1287
1303
  }
1288
1304
  }
1305
+ // 都不满足时取内置
1306
+ if (options.useBuiltInRTC) {
1307
+ if (!options.getVoiceSign) {
1308
+ throw new Error('GetVoiceSign method must be passed when using built-in RTC instances');
1309
+ }
1310
+ const getVoiceSign = (_c = options.getVoiceSign) !== null && _c !== void 0 ? _c : unimplementedGetVoiceSign;
1311
+ if (!jsBridge) {
1312
+ throw new Error('jsBridge instance must be passed when using built-in RTC instances');
1313
+ }
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.');
@@ -1579,6 +1622,7 @@ function createLive(options) {
1579
1622
  function createLiveReact(options) {
1580
1623
  const LiveContext = React.createContext(null);
1581
1624
  const live = createLive(options);
1625
+ const jsBridge = live.jsBridge;
1582
1626
  function LiveProvider(props) {
1583
1627
  return (React.createElement(LiveContext.Provider, { value: props.live || live }, props.children));
1584
1628
  }
@@ -1774,6 +1818,7 @@ function createLiveReact(options) {
1774
1818
  }
1775
1819
  return {
1776
1820
  live,
1821
+ jsBridge,
1777
1822
  LiveProvider,
1778
1823
  unsafe__useLiveInstance,
1779
1824
  unsafe__useRTCInstance,
@@ -1793,5 +1838,5 @@ function createLiveReact(options) {
1793
1838
  };
1794
1839
  }
1795
1840
 
1796
- export { BrowserRTC, BrowserRTC4Chime, BuiltinActionType, BuiltinEventType, Command, CoreRTC, MemUserStatus, MicroStatus, RTCJoinedInfoCodeEnum, RTCType, UserStatus, VRWebViewRTC, WebSocketCloseError, WebSocketErrorType, WebSocketState, createLive, createLiveReact, parseLiveMsg, parseWSClsErr };
1841
+ export { BrowserRTC, BrowserRTC4Chime, BuiltInRTCType, BuiltinActionType, BuiltinEventType, Command, CoreRTC, MemUserStatus, MicroStatus, RTCJoinedInfoCodeEnum, RTCType, UserStatus, VRWebViewRTC, WebSocketCloseError, WebSocketErrorType, WebSocketState, createLive, createLiveReact, parseLiveMsg, parseWSClsErr };
1797
1842
  //# sourceMappingURL=realsee-live.esm.js.map