@realsee/live 0.5.0-alpha.1 → 0.5.0-alpha.12

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,9 +1,11 @@
1
1
  import { LiveMsg } from '../typings';
2
2
  import { LiveState } from '../typings/live/LiveState';
3
+ import { RobustWebSocketEventDetail } from '../utils/RobustWebSocket';
3
4
  import { Subscribe } from '../utils/subscribe';
4
5
  export declare type LiveControllerEventMap = {
5
6
  stateChange: (state: LiveState, prevState: LiveState) => void;
6
7
  message: (message: LiveMsg) => void;
8
+ reconnected: (detail: RobustWebSocketEventDetail) => void;
7
9
  };
8
10
  export declare class LiveController extends Subscribe<LiveControllerEventMap> {
9
11
  /**
@@ -30,6 +32,10 @@ export declare class LiveController extends Subscribe<LiveControllerEventMap> {
30
32
  * @param event
31
33
  */
32
34
  private _handleCloseEvent;
35
+ /**
36
+ * 处理房间正在关闭事件(这个时候可能是断网了)
37
+ */
38
+ private _handleClosingEvent;
33
39
  /**
34
40
  * 连接中
35
41
  * @param event
@@ -15,12 +15,12 @@ export declare function createLiveReact<KeyframesSnapshot>(options: LiveOptions)
15
15
  LiveProvider: (props: LiveProviderPropTypes<KeyframesSnapshot>) => JSX.Element;
16
16
  unsafe__useLiveInstance: () => Live<KeyframesSnapshot>;
17
17
  unsafe__useRTCInstance: () => import("../typings").RTCProtocol;
18
- useConnect: (options: LiveConnectOptions) => Promise<boolean | Error>;
18
+ useConnect: () => (options: LiveConnectOptions) => Promise<boolean | Error>;
19
19
  useKeyframe: <K extends keyof KeyframesSnapshot>(key: K) => [frame: KeyframesSnapshot[K] | undefined, setFrame: (frame: KeyframesSnapshot[K]) => boolean | Error];
20
20
  useKeyframeUpdateCallback: <KeyOfKeyframe extends keyof KeyframeTypes<KeyframesSnapshot>>(key: KeyOfKeyframe, callback: (...args: Parameters<KeyframeTypes<KeyframesSnapshot>[KeyOfKeyframe]>) => ReturnType<KeyframeTypes<KeyframesSnapshot>[KeyOfKeyframe]>, deps?: React.DependencyList) => () => void;
21
21
  useLiveAction: () => {
22
22
  connect: (options: LiveConnectOptions) => Promise<boolean | Error>;
23
- broadcast: (data: Record<string, any>, toUserIds: string | string[], timeout?: any) => Promise<unknown>;
23
+ broadcast: (data: Record<string, any>, toUserIds: string | string[], timeout?: number) => Promise<unknown>;
24
24
  exit: () => Promise<boolean>;
25
25
  kick: (toUserIds: string | string[]) => Promise<boolean>;
26
26
  toggleMicro: (microStatus: boolean) => Promise<boolean>;
@@ -1,12 +1,16 @@
1
1
  import { JSBridgeProtocol } from '@realsee/jsbridge-x';
2
2
  import { RTCProtocol } from '../rtc';
3
- import { EventType, KeyframeTypes, LiveOptions, RoomInfo, UserInfo, BuiltinEventType, BuiltinActionType, MicroStatus, LiveConnectOptions } from '../typings';
3
+ import { EventType, KeyframeTypes, LiveOptions, RoomInfo, RTCType, UserInfo, BuiltinEventType, BuiltinActionType, MicroStatus, LiveConnectOptions } from '../typings';
4
4
  import { LiveState } from '../typings/live/LiveState';
5
5
  import { Subscribe } from '../utils/subscribe';
6
6
  export declare type LiveBuiltInData<KeyframesSnapshot> = {
7
7
  selfInfo?: UserInfo;
8
8
  userList?: UserInfo[];
9
9
  roomInfo?: RoomInfo;
10
+ rtcInfo?: {
11
+ voiceId: string;
12
+ type: RTCType;
13
+ };
10
14
  keyframes: Partial<KeyframesSnapshot>;
11
15
  };
12
16
  export declare const _clearLiveInstanceIfNeed: () => void;
@@ -94,6 +98,10 @@ export declare class Live<KeyframesSnapshot extends Record<string, any>> extends
94
98
  * @returns
95
99
  */
96
100
  private _handleStateChange;
101
+ /**
102
+ * 消息接收
103
+ * @param liveMsg
104
+ */
97
105
  private _handleMessage;
98
106
  /**
99
107
  * 清理带看缓存的数据
@@ -618,9 +618,12 @@ class VRWebViewRTC extends CoreRTC {
618
618
  this.micro = false;
619
619
  this.voiceId = '';
620
620
  this.options = { jsBridge, getVoiceSign };
621
- this.jsBridge.callAndListen('live/userVolumes', (userVolumes) => {
622
- this.emit('userVolumes', userVolumes);
623
- });
621
+ // TO-DO: 在微信小程序下有个音量上报的BUG会导致消息体过大从而jsbridge异常断开
622
+ if (this.jsBridge.webViewType !== 'WxMiniProgramWebView') {
623
+ this.jsBridge.callAndListen('live/userVolumes', (userVolumes) => {
624
+ this.emit('userVolumes', userVolumes);
625
+ });
626
+ }
624
627
  this.jsBridge.callAndListen('live/weakNetwork', (weakNetwork) => {
625
628
  if (weakNetwork)
626
629
  this.emit('weakNetwork');
@@ -631,25 +634,37 @@ class VRWebViewRTC extends CoreRTC {
631
634
  }
632
635
  join(options) {
633
636
  return __awaiter(this, void 0, void 0, function* () {
634
- this.emit('joinWillStart');
635
- const { sdkAppId, userId, userSig } = yield this.options.getVoiceSign(options);
636
- this.type = options.type;
637
- const [res, error] = yield this.jsBridge.callAndBackfeed(`live/join?sdkAppID=${sdkAppId}&userID=${userId}&roomID=${Number(options.voiceId)}&userSig=${userSig}`);
638
- if (!res) {
639
- this.emit('error', error ? error : new Error('加入房间失败:未知异常。'));
640
- this.joined = false;
641
- }
642
- else {
643
- if (res.code === exports.RTCJoinedInfoCodeEnum.Success) {
644
- this.emit('joined');
645
- this.joined = true;
637
+ try {
638
+ this.emit('joinWillStart');
639
+ const { sdkAppId, userId, userSig } = yield this.options.getVoiceSign(options);
640
+ if (!(Boolean(sdkAppId) && Boolean(userId) && Boolean(userSig))) {
641
+ this.emit('error', new Error('加入房间失败:rtc 签名请求异常'));
642
+ this.joined = false;
643
+ return this.joined;
646
644
  }
647
- else {
648
- this.emit('error', res);
645
+ this.type = options.type;
646
+ const [res, error] = yield this.jsBridge.callAndBackfeed(`live/join?sdkAppID=${sdkAppId}&userID=${userId}&roomID=${Number(options.voiceId)}&userSig=${userSig}`);
647
+ if (!res) {
648
+ this.emit('error', error ? error : new Error('加入房间失败:未知异常。'));
649
649
  this.joined = false;
650
650
  }
651
+ else {
652
+ if (res.code === exports.RTCJoinedInfoCodeEnum.Success) {
653
+ this.emit('joined');
654
+ this.joined = true;
655
+ }
656
+ else {
657
+ this.emit('error', res);
658
+ this.joined = false;
659
+ }
660
+ }
661
+ return this.joined;
662
+ }
663
+ catch (e) {
664
+ this.emit('error', new Error('加入房间失败:' + e.message));
665
+ this.joined = false;
666
+ return this.joined;
651
667
  }
652
- return this.joined;
653
668
  });
654
669
  }
655
670
  quit() {
@@ -795,6 +810,23 @@ function parseLiveMsg(jsonTxt) {
795
810
  }
796
811
  }
797
812
 
813
+ exports.LiveState = void 0;
814
+ (function (LiveState) {
815
+ LiveState[LiveState["NOTINITIALIZED"] = -1] = "NOTINITIALIZED";
816
+ /**
817
+ * 正在链接中
818
+ */
819
+ LiveState[LiveState["CONNECTING"] = 0] = "CONNECTING";
820
+ /**
821
+ * 已经链接并且可以通讯
822
+ */
823
+ LiveState[LiveState["OPEN"] = 1] = "OPEN";
824
+ /**
825
+ * 连接已关闭或者链接失败
826
+ */
827
+ LiveState[LiveState["CLOSED"] = 3] = "CLOSED";
828
+ })(exports.LiveState || (exports.LiveState = {}));
829
+
798
830
  /**
799
831
  * 用户当前状态枚举。
800
832
  */
@@ -952,23 +984,6 @@ exports.default = LogLevel;
952
984
 
953
985
  var LogLevel = /*@__PURE__*/getDefaultExportFromCjs(LogLevel_1);
954
986
 
955
- var LiveState;
956
- (function (LiveState) {
957
- LiveState[LiveState["NOTINITIALIZED"] = -1] = "NOTINITIALIZED";
958
- /**
959
- * 正在链接中
960
- */
961
- LiveState[LiveState["CONNECTING"] = 0] = "CONNECTING";
962
- /**
963
- * 已经链接并且可以通讯
964
- */
965
- LiveState[LiveState["OPEN"] = 1] = "OPEN";
966
- /**
967
- * 连接已关闭或者链接失败
968
- */
969
- LiveState[LiveState["CLOSED"] = 3] = "CLOSED";
970
- })(LiveState || (LiveState = {}));
971
-
972
987
  function appendUri(uri, query) {
973
988
  const hasQuery = uri.indexOf('?') !== -1;
974
989
  const newQuery = Object.keys(query).reduce((accu, curr, idx) => `${accu}${(idx === 0 && !hasQuery) ? '?' : '&'}${curr}=${query[curr]}`, '');
@@ -1170,6 +1185,7 @@ class RobustWebSocket extends Subscribe {
1170
1185
  constructor(options) {
1171
1186
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
1172
1187
  super();
1188
+ this._readyState = exports.WebSocketState.NOTINITIALIZED;
1173
1189
  this._options = {
1174
1190
  timeout: 10000,
1175
1191
  shouldReconnect: (event, ws) => {
@@ -1186,6 +1202,43 @@ class RobustWebSocket extends Subscribe {
1186
1202
  this._reconnectWhenOnlineAgain = false;
1187
1203
  this._explicitlyClosed = false;
1188
1204
  this._connectivityEventsAttached = false;
1205
+ /**
1206
+ * 做一个健康检查
1207
+ */
1208
+ this._healthCheck = () => __awaiter(this, void 0, void 0, function* () {
1209
+ if (this._realWebSocket &&
1210
+ this._realWebSocket.readyState !== this._readyState) {
1211
+ this._readyState = this._realWebSocket.readyState;
1212
+ // 太惨了,断网的时候,ws不会直接closed,而是处于closing的状态
1213
+ if (this._readyState === exports.WebSocketState.CLOSING) {
1214
+ this.emit('closing');
1215
+ }
1216
+ }
1217
+ yield new Promise((resolve) => setTimeout(resolve, 2000));
1218
+ this._heathCheckTimer = requestAnimationFrame(this._healthCheck);
1219
+ });
1220
+ /**
1221
+ * 清理健康检查
1222
+ */
1223
+ this._clearHeathCheckIfNeed = () => {
1224
+ if (this._heathCheckTimer) {
1225
+ cancelAnimationFrame(this._heathCheckTimer);
1226
+ this._heathCheckTimer = undefined;
1227
+ }
1228
+ };
1229
+ /**
1230
+ * 开启健康检查
1231
+ */
1232
+ this._startHealthCheck = () => {
1233
+ this._clearHeathCheckIfNeed();
1234
+ this._heathCheckTimer = requestAnimationFrame(this._healthCheck);
1235
+ };
1236
+ /**
1237
+ * 停止健康检查
1238
+ */
1239
+ this._stopHealthCheck = () => {
1240
+ this._clearHeathCheckIfNeed();
1241
+ };
1189
1242
  /**
1190
1243
  * 清理连接中的请求
1191
1244
  */
@@ -1211,7 +1264,7 @@ class RobustWebSocket extends Subscribe {
1211
1264
  this._offline = () => {
1212
1265
  var _a;
1213
1266
  this._reconnectWhenOnlineAgain = true;
1214
- (_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.close(1000);
1267
+ (_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.close(1000, 'offline');
1215
1268
  };
1216
1269
  /**
1217
1270
  * 解除网络监听事件
@@ -1238,7 +1291,12 @@ class RobustWebSocket extends Subscribe {
1238
1291
  * @param data
1239
1292
  * @returns
1240
1293
  */
1241
- this.send = (data) => { var _a; return (_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.send(data); };
1294
+ this.send = (data) => {
1295
+ var _a, _b, _c;
1296
+ if (((_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.readyState) === ((_b = this._realWebSocket) === null || _b === void 0 ? void 0 : _b.OPEN)) {
1297
+ (_c = this._realWebSocket) === null || _c === void 0 ? void 0 : _c.send(data);
1298
+ }
1299
+ };
1242
1300
  /**
1243
1301
  * 关闭连接
1244
1302
  * @param code 代码
@@ -1282,6 +1340,7 @@ class RobustWebSocket extends Subscribe {
1282
1340
  if (!newUrl)
1283
1341
  return;
1284
1342
  this._pendingReconnect = undefined;
1343
+ this._removeWebSocketEvent();
1285
1344
  this._realWebSocket = new WebSocket(newUrl, this._protocols || undefined);
1286
1345
  this._attempts = this._attempts + 1;
1287
1346
  this.emit('connecting', new CustomEvent('connecting', {
@@ -1303,6 +1362,16 @@ class RobustWebSocket extends Subscribe {
1303
1362
  this._attachConnectivityEvents();
1304
1363
  }
1305
1364
  };
1365
+ /**
1366
+ * 断开ws事件
1367
+ */
1368
+ this._removeWebSocketEvent = () => {
1369
+ var _a, _b, _c, _d;
1370
+ (_a = this._realWebSocket) === null || _a === void 0 ? void 0 : _a.removeEventListener('open', this._webSocketOpenHandler);
1371
+ (_b = this._realWebSocket) === null || _b === void 0 ? void 0 : _b.removeEventListener('close', this._webSocketCloseHandler);
1372
+ (_c = this._realWebSocket) === null || _c === void 0 ? void 0 : _c.removeEventListener('error', this._webSocketErrorHandler);
1373
+ (_d = this._realWebSocket) === null || _d === void 0 ? void 0 : _d.removeEventListener('message', this._webSocketMessageHandler);
1374
+ };
1306
1375
  /**
1307
1376
  * 分发ws事件
1308
1377
  */
@@ -1326,6 +1395,7 @@ class RobustWebSocket extends Subscribe {
1326
1395
  const attempts = this._attempts;
1327
1396
  this._attempts = 0;
1328
1397
  this._reconnectWhenOnlineAgain = false;
1398
+ this._startHealthCheck();
1329
1399
  return this.emit('open', Object.assign(event, { detail: { reconnects, attempts } }));
1330
1400
  };
1331
1401
  /**
@@ -1335,6 +1405,7 @@ class RobustWebSocket extends Subscribe {
1335
1405
  */
1336
1406
  this._webSocketCloseHandler = (event) => {
1337
1407
  this._reconnect(event);
1408
+ this._stopHealthCheck();
1338
1409
  return this.emit('close', event);
1339
1410
  };
1340
1411
  /**
@@ -1356,6 +1427,7 @@ class RobustWebSocket extends Subscribe {
1356
1427
  if (options) {
1357
1428
  this.setOptions(options);
1358
1429
  }
1430
+ this._startHealthCheck();
1359
1431
  }
1360
1432
  get attempts() {
1361
1433
  return this._attempts;
@@ -1406,16 +1478,20 @@ class LiveController extends Subscribe {
1406
1478
  /**
1407
1479
  * ws代理器
1408
1480
  */
1409
- this._ws = new RobustWebSocket();
1481
+ this._ws = new RobustWebSocket({
1482
+ url: '',
1483
+ robustOptions: { timeout: 180000 },
1484
+ });
1410
1485
  /**
1411
1486
  * 带看连接状态
1412
1487
  */
1413
- this._state = LiveState.NOTINITIALIZED;
1488
+ this._state = exports.LiveState.NOTINITIALIZED;
1414
1489
  /**
1415
1490
  * 添加事件监听
1416
1491
  */
1417
1492
  this._addWebSocketEventListeners = () => {
1418
1493
  this._ws.on('close', this._handleCloseEvent);
1494
+ this._ws.on('closing', this._handleClosingEvent);
1419
1495
  this._ws.on('connecting', this._handleConnectingEvent);
1420
1496
  this._ws.on('error', this._handleErrorEvent);
1421
1497
  this._ws.on('message', this._handleMessageEvent);
@@ -1427,6 +1503,7 @@ class LiveController extends Subscribe {
1427
1503
  */
1428
1504
  this._removeWebSocketEventListeners = () => {
1429
1505
  this._ws.off('close', this._handleCloseEvent);
1506
+ this._ws.off('closing', this._handleClosingEvent);
1430
1507
  this._ws.off('connecting', this._handleConnectingEvent);
1431
1508
  this._ws.off('error', this._handleErrorEvent);
1432
1509
  this._ws.off('message', this._handleMessageEvent);
@@ -1439,15 +1516,23 @@ class LiveController extends Subscribe {
1439
1516
  */
1440
1517
  this._handleCloseEvent = (event) => {
1441
1518
  logger$1.info(`live room closed bacause of ${event.code}-${event.reason || parseWSClsErr(event.code)}`);
1442
- this.state = LiveState.CLOSED;
1519
+ this.state = exports.LiveState.CLOSED;
1520
+ };
1521
+ /**
1522
+ * 处理房间正在关闭事件(这个时候可能是断网了)
1523
+ */
1524
+ this._handleClosingEvent = () => {
1525
+ var _a;
1526
+ logger$1.info(`live room is closing, onLine:`, (_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _a === void 0 ? void 0 : _a.onLine);
1527
+ this.state = exports.LiveState.CLOSED;
1443
1528
  };
1444
1529
  /**
1445
1530
  * 连接中
1446
1531
  * @param event
1447
1532
  */
1448
- this._handleConnectingEvent = (event) => {
1449
- logger$1.info(`live room is connecting`, event.detail);
1450
- this.state = LiveState.CONNECTING;
1533
+ this._handleConnectingEvent = () => {
1534
+ logger$1.info(`live room is connecting`);
1535
+ this.state = exports.LiveState.CONNECTING;
1451
1536
  };
1452
1537
  /**
1453
1538
  * 连接发送异常
@@ -1455,7 +1540,7 @@ class LiveController extends Subscribe {
1455
1540
  */
1456
1541
  this._handleErrorEvent = (event) => {
1457
1542
  logger$1.error(`live room error`, event);
1458
- this.state = LiveState.CLOSED;
1543
+ this.state = exports.LiveState.CLOSED;
1459
1544
  };
1460
1545
  /**
1461
1546
  * 接收到消息
@@ -1479,7 +1564,10 @@ class LiveController extends Subscribe {
1479
1564
  */
1480
1565
  this._handleOpenEvent = (event) => {
1481
1566
  logger$1.info('live room open', event.detail);
1482
- this.state = LiveState.OPEN;
1567
+ this.state = exports.LiveState.OPEN;
1568
+ if (event.detail.reconnects > 0) {
1569
+ this.emit('reconnected', event.detail);
1570
+ }
1483
1571
  };
1484
1572
  /**
1485
1573
  * 处理超时
@@ -1487,7 +1575,7 @@ class LiveController extends Subscribe {
1487
1575
  */
1488
1576
  this._handleTimeoutEvent = (event) => {
1489
1577
  logger$1.error('live room connect timeout!', event.detail);
1490
- this.state = LiveState.CLOSED;
1578
+ this.state = exports.LiveState.CLOSED;
1491
1579
  };
1492
1580
  /**
1493
1581
  * 释放资源,释放之后需要重新实例化
@@ -1530,7 +1618,7 @@ class LiveController extends Subscribe {
1530
1618
  if (data === undefined || data === null || data === '') {
1531
1619
  throw new Error('live message is empty!');
1532
1620
  }
1533
- if (this.state === LiveState.OPEN) {
1621
+ if (this.state === exports.LiveState.OPEN) {
1534
1622
  return this._ws.send(JSON.stringify(data));
1535
1623
  }
1536
1624
  else {
@@ -1583,7 +1671,7 @@ class Live extends Subscribe {
1583
1671
  * @returns
1584
1672
  */
1585
1673
  this.sendKeyframe = (key, frame) => {
1586
- if (this.state !== LiveState.OPEN)
1674
+ if (this.state !== exports.LiveState.OPEN)
1587
1675
  return false;
1588
1676
  this._buildInData.keyframes = Object.assign(Object.assign({}, this._buildInData.keyframes), { [key]: frame });
1589
1677
  const liveMsg = createLiveMsg(exports.Command.KeyframeSync, this.snapshot);
@@ -1620,6 +1708,10 @@ class Live extends Subscribe {
1620
1708
  * @returns
1621
1709
  */
1622
1710
  this._handleStateChange = (state, prevState) => this.emit('stateChange', state, prevState);
1711
+ /**
1712
+ * 消息接收
1713
+ * @param liveMsg
1714
+ */
1623
1715
  this._handleMessage = (liveMsg) => __awaiter(this, void 0, void 0, function* () {
1624
1716
  var _b, _c, _d, _e, _f, _g;
1625
1717
  if (typeof liveMsg === 'object') {
@@ -1651,6 +1743,7 @@ class Live extends Subscribe {
1651
1743
  */
1652
1744
  case exports.Command.RTCInfo: {
1653
1745
  const { voice_id: voiceId, type } = data;
1746
+ this._buildInData.rtcInfo = { voiceId, type };
1654
1747
  if (!((_b = this.$RTC) === null || _b === void 0 ? void 0 : _b.joined)) {
1655
1748
  const result = yield ((_c = this.$RTC) === null || _c === void 0 ? void 0 : _c.join({
1656
1749
  voiceId,
@@ -1791,10 +1884,17 @@ class Live extends Subscribe {
1791
1884
  return false;
1792
1885
  }
1793
1886
  const { force = false } = options;
1887
+ // 检测一下麦克风权限,hack
1888
+ if (this._options.rtc && this._options.jsBridge) {
1889
+ const res = yield this._options.jsBridge.detectMicro();
1890
+ if (!res) {
1891
+ return new Error('Failed to obtain microphone authorization');
1892
+ }
1893
+ }
1794
1894
  // 检查是否已有实例在使用
1795
1895
  const currentState = this.state;
1796
- if (currentState === LiveState.CONNECTING ||
1797
- currentState === LiveState.OPEN) {
1896
+ if (currentState === exports.LiveState.CONNECTING ||
1897
+ currentState === exports.LiveState.OPEN) {
1798
1898
  if (force) {
1799
1899
  try {
1800
1900
  yield this._controller.close('force close by connect');
@@ -2080,7 +2180,7 @@ class Live extends Subscribe {
2080
2180
  */
2081
2181
  updateStatus(evtType, atnType, status, toUserIds) {
2082
2182
  return __awaiter(this, void 0, void 0, function* () {
2083
- if (this.state !== LiveState.OPEN)
2183
+ if (this.state !== exports.LiveState.OPEN)
2084
2184
  return false;
2085
2185
  const data = Object.assign({ event_type: evtType, action: atnType }, { data: status });
2086
2186
  const liveMsg = createLiveMsg(exports.Command.BuiltinMsg, data, toUserIds);
@@ -2102,7 +2202,7 @@ class Live extends Subscribe {
2102
2202
  * @returns
2103
2203
  */
2104
2204
  broadcast(request, toUserIds, timeout) {
2105
- if (this.state !== LiveState.OPEN)
2205
+ if (this.state !== exports.LiveState.OPEN)
2106
2206
  return false;
2107
2207
  return new Promise((resolve, reject) => {
2108
2208
  const customEvent = createLiveMsg(exports.Command.CustomEvent, request, toUserIds);
@@ -2165,21 +2265,21 @@ function createLiveReact(options) {
2165
2265
  * @deprecated
2166
2266
  * @returns
2167
2267
  */
2168
- const unsafe__useLiveInstance = React.useCallback(() => useLiveInstance(), [useLiveInstance]);
2268
+ const unsafe__useLiveInstance = () => useLiveInstance();
2169
2269
  /**
2170
2270
  * 使用rtc实例
2171
2271
  */
2172
- const useRTCInstance = React.useCallback(() => useLiveInstance().$RTC, [useLiveInstance]);
2272
+ const useRTCInstance = () => useLiveInstance().$RTC;
2173
2273
  /**
2174
2274
  * 不建议这样使用
2175
2275
  * @deprecated
2176
2276
  * @returns
2177
2277
  */
2178
- const unsafe__useRTCInstance = React.useCallback(() => useRTCInstance(), [useRTCInstance]);
2278
+ const unsafe__useRTCInstance = () => useRTCInstance();
2179
2279
  /**
2180
2280
  * 带看连接操作
2181
2281
  */
2182
- const useConnect = React.useCallback((options) => __awaiter(this, void 0, void 0, function* () { return yield useLiveInstance().connect(options); }), []);
2282
+ const useConnect = () => (options) => __awaiter(this, void 0, void 0, function* () { return yield useLiveInstance().connect(options); });
2183
2283
  /**
2184
2284
  *
2185
2285
  * @param name
@@ -2203,17 +2303,17 @@ function createLiveReact(options) {
2203
2303
  */
2204
2304
  function useLiveAction() {
2205
2305
  const live = useLiveInstance();
2206
- const connect = React__default["default"].useCallback((options) => __awaiter(this, void 0, void 0, function* () { return yield live.connect(options); }), [live]);
2207
- const toggleMicro = React__default["default"].useCallback((microStatus) => live.toggleMicro(microStatus), [live]);
2208
- const broadcast = React__default["default"].useCallback((data, toUserIds, timeout = 0) => __awaiter(this, void 0, void 0, function* () { return yield live.broadcast(data, toUserIds, timeout); }), [live]);
2209
- const exit = React__default["default"].useCallback(() => __awaiter(this, void 0, void 0, function* () { return yield live.exit(); }), [live]);
2210
- const kick = React__default["default"].useCallback((toUserIds) => __awaiter(this, void 0, void 0, function* () { return yield live.kick(toUserIds); }), [live]);
2211
- const forbidMicro = React__default["default"].useCallback((micro, toUserIds = []) => __awaiter(this, void 0, void 0, function* () { return yield live.forbidMicro(micro, toUserIds); }), [live]);
2212
- const forbidSync = React__default["default"].useCallback((sync, toUserIds = []) => live.forbidSync(sync, toUserIds), [live]);
2213
- const getFramesByKey = React__default["default"].useCallback((key) => live.getFramesByKey(key), [live]);
2214
- const sendKeyframe = React__default["default"].useCallback((key, frame) => live.sendKeyframe(key, frame), [live]);
2215
- const setSelfInfo = React__default["default"].useCallback((userInfo) => live.setSelfInfo(userInfo), [live]);
2216
- const updateStatus = React__default["default"].useCallback((evtType, atnType, status, toUserIds) => live.updateStatus(evtType, atnType, status, toUserIds), [live]);
2306
+ const connect = (options) => __awaiter(this, void 0, void 0, function* () { return yield live.connect(options); });
2307
+ const toggleMicro = (microStatus) => live.toggleMicro(microStatus);
2308
+ const broadcast = (data, toUserIds, timeout = 0) => __awaiter(this, void 0, void 0, function* () { return yield live.broadcast(data, toUserIds, timeout); });
2309
+ const exit = () => __awaiter(this, void 0, void 0, function* () { return yield live.exit(); });
2310
+ const kick = (toUserIds) => __awaiter(this, void 0, void 0, function* () { return yield live.kick(toUserIds); });
2311
+ const forbidMicro = (micro, toUserIds = []) => __awaiter(this, void 0, void 0, function* () { return yield live.forbidMicro(micro, toUserIds); });
2312
+ const forbidSync = (sync, toUserIds = []) => live.forbidSync(sync, toUserIds);
2313
+ const getFramesByKey = (key) => live.getFramesByKey(key);
2314
+ const sendKeyframe = (key, frame) => live.sendKeyframe(key, frame);
2315
+ const setSelfInfo = (userInfo) => live.setSelfInfo(userInfo);
2316
+ const updateStatus = (evtType, atnType, status, toUserIds) => live.updateStatus(evtType, atnType, status, toUserIds);
2217
2317
  return {
2218
2318
  connect,
2219
2319
  broadcast,
@@ -2267,11 +2367,11 @@ function createLiveReact(options) {
2267
2367
  }
2268
2368
  function useRTCAction() {
2269
2369
  const live = useLiveInstance();
2270
- const join = React__default["default"].useCallback((options) => live.$RTC.join(options), [live]);
2271
- const quit = React__default["default"].useCallback(() => live.$RTC.quit(), [live]);
2272
- const shock = React__default["default"].useCallback(() => { var _a, _b; return (_b = (_a = live.$RTC).shock) === null || _b === void 0 ? void 0 : _b.call(_a); }, [live]);
2273
- const toggleMicro = React__default["default"].useCallback((flag) => live.$RTC.toggleMicro(flag), [live]);
2274
- const detectMicro = React__default["default"].useCallback(() => live.$RTC.detectMicro(), [live]);
2370
+ const join = (options) => live.$RTC.join(options);
2371
+ const quit = () => live.$RTC.quit();
2372
+ const shock = () => { var _a, _b; return (_b = (_a = live.$RTC).shock) === null || _b === void 0 ? void 0 : _b.call(_a); };
2373
+ const toggleMicro = (flag) => live.$RTC.toggleMicro(flag);
2374
+ const detectMicro = () => live.$RTC.detectMicro();
2275
2375
  return {
2276
2376
  join,
2277
2377
  quit,