@realsee/live 0.5.0-alpha.9 → 0.5.2-dev.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,7 +1,7 @@
1
1
  import JSBridge from '@realsee/jsbridge-x';
2
2
  import TRTC from 'trtc-js-sdk';
3
3
  import { DefaultModality, ConsoleLogger, LogLevel as LogLevel$1, DefaultDeviceController, MeetingSessionConfiguration, DefaultMeetingSession, MeetingSessionStatusCode } from 'amazon-chime-sdk-js';
4
- import React, { createContext, useCallback } from 'react';
4
+ import React, { createContext } from 'react';
5
5
 
6
6
  const EVENT_SYMBOL = Symbol('$$REALSEE_LIVE_EVENT$$');
7
7
  function __generateEventIfNotExisted(instance) {
@@ -194,6 +194,7 @@ class BrowserRTC extends CoreRTC {
194
194
  this._getVoiceSign = () => {
195
195
  throw new Error('方法 getVoiceSign 未实现');
196
196
  };
197
+ this.checkRequirement = () => TRTC.checkSystemRequirements();
197
198
  this.$dom = document.createElement('div');
198
199
  this._trtc = {
199
200
  client: null,
@@ -308,9 +309,10 @@ class BrowserRTC extends CoreRTC {
308
309
  var _a, _b, _c, _d;
309
310
  (_a = this._trtc.client) === null || _a === void 0 ? void 0 : _a.on('stream-added', this._handleStreamAdded);
310
311
  (_b = this._trtc.client) === null || _b === void 0 ? void 0 : _b.on('stream-subscribed', this._handleStreamSubscribed);
311
- (_c = this._trtc.client) === null || _c === void 0 ? void 0 : _c.on('audio-volume', (event) => this.emit('userVolumes', [
312
- { userId: event.userId, audioVolume: event.audioVolume },
313
- ]));
312
+ (_c = this._trtc.client) === null || _c === void 0 ? void 0 : _c.on('audio-volume', (event) => this.emit('userVolumes', event.result.map(({ userId, audioVolume }) => ({
313
+ userId,
314
+ audioVolume,
315
+ }))));
314
316
  (_d = this._trtc.client) === null || _d === void 0 ? void 0 : _d.on('error', (event) => this.emit('error', event));
315
317
  }
316
318
  }
@@ -1705,7 +1707,7 @@ class Live extends Subscribe {
1705
1707
  this._handleMessage = (liveMsg) => __awaiter(this, void 0, void 0, function* () {
1706
1708
  var _b, _c, _d, _e, _f, _g;
1707
1709
  if (typeof liveMsg === 'object') {
1708
- const { command, data, frontRequestId, code, message } = liveMsg;
1710
+ const { command, data = {}, frontRequestId, code, message } = liveMsg;
1709
1711
  if (code === 'SUCCESS') {
1710
1712
  switch (command) {
1711
1713
  /**
@@ -1875,8 +1877,8 @@ class Live extends Subscribe {
1875
1877
  }
1876
1878
  const { force = false } = options;
1877
1879
  // 检测一下麦克风权限,hack
1878
- if (this._options.rtc && this._options.jsBridge) {
1879
- const res = yield this._options.jsBridge.detectMicro();
1880
+ if (this._options.rtc) {
1881
+ const res = yield this._options.rtc.detectMicro();
1880
1882
  if (!res) {
1881
1883
  return new Error('Failed to obtain microphone authorization');
1882
1884
  }
@@ -2255,21 +2257,21 @@ function createLiveReact(options) {
2255
2257
  * @deprecated
2256
2258
  * @returns
2257
2259
  */
2258
- const unsafe__useLiveInstance = useCallback(() => useLiveInstance(), [useLiveInstance]);
2260
+ const unsafe__useLiveInstance = () => live;
2259
2261
  /**
2260
2262
  * 使用rtc实例
2261
2263
  */
2262
- const useRTCInstance = useCallback(() => useLiveInstance().$RTC, [useLiveInstance]);
2264
+ const useRTCInstance = () => live.$RTC;
2263
2265
  /**
2264
2266
  * 不建议这样使用
2265
2267
  * @deprecated
2266
2268
  * @returns
2267
2269
  */
2268
- const unsafe__useRTCInstance = useCallback(() => useRTCInstance(), [useRTCInstance]);
2270
+ const unsafe__useRTCInstance = () => useRTCInstance();
2269
2271
  /**
2270
2272
  * 带看连接操作
2271
2273
  */
2272
- const useConnect = useCallback((options) => __awaiter(this, void 0, void 0, function* () { return yield useLiveInstance().connect(options); }), []);
2274
+ const useConnect = () => (options) => __awaiter(this, void 0, void 0, function* () { return yield live.connect(options); });
2273
2275
  /**
2274
2276
  *
2275
2277
  * @param name
@@ -2293,17 +2295,17 @@ function createLiveReact(options) {
2293
2295
  */
2294
2296
  function useLiveAction() {
2295
2297
  const live = useLiveInstance();
2296
- const connect = React.useCallback((options) => __awaiter(this, void 0, void 0, function* () { return yield live.connect(options); }), [live]);
2297
- const toggleMicro = React.useCallback((microStatus) => live.toggleMicro(microStatus), [live]);
2298
- const broadcast = React.useCallback((data, toUserIds, timeout = 0) => __awaiter(this, void 0, void 0, function* () { return yield live.broadcast(data, toUserIds, timeout); }), [live]);
2299
- const exit = React.useCallback(() => __awaiter(this, void 0, void 0, function* () { return yield live.exit(); }), [live]);
2300
- const kick = React.useCallback((toUserIds) => __awaiter(this, void 0, void 0, function* () { return yield live.kick(toUserIds); }), [live]);
2301
- const forbidMicro = React.useCallback((micro, toUserIds = []) => __awaiter(this, void 0, void 0, function* () { return yield live.forbidMicro(micro, toUserIds); }), [live]);
2302
- const forbidSync = React.useCallback((sync, toUserIds = []) => live.forbidSync(sync, toUserIds), [live]);
2303
- const getFramesByKey = React.useCallback((key) => live.getFramesByKey(key), [live]);
2304
- const sendKeyframe = React.useCallback((key, frame) => live.sendKeyframe(key, frame), [live]);
2305
- const setSelfInfo = React.useCallback((userInfo) => live.setSelfInfo(userInfo), [live]);
2306
- const updateStatus = React.useCallback((evtType, atnType, status, toUserIds) => live.updateStatus(evtType, atnType, status, toUserIds), [live]);
2298
+ const connect = (options) => __awaiter(this, void 0, void 0, function* () { return yield live.connect(options); });
2299
+ const toggleMicro = (microStatus) => live.toggleMicro(microStatus);
2300
+ const broadcast = (data, toUserIds, timeout = 0) => __awaiter(this, void 0, void 0, function* () { return yield live.broadcast(data, toUserIds, timeout); });
2301
+ const exit = () => __awaiter(this, void 0, void 0, function* () { return yield live.exit(); });
2302
+ const kick = (toUserIds) => __awaiter(this, void 0, void 0, function* () { return yield live.kick(toUserIds); });
2303
+ const forbidMicro = (micro, toUserIds = []) => __awaiter(this, void 0, void 0, function* () { return yield live.forbidMicro(micro, toUserIds); });
2304
+ const forbidSync = (sync, toUserIds = []) => live.forbidSync(sync, toUserIds);
2305
+ const getFramesByKey = (key) => live.getFramesByKey(key);
2306
+ const sendKeyframe = (key, frame) => live.sendKeyframe(key, frame);
2307
+ const setSelfInfo = (userInfo) => live.setSelfInfo(userInfo);
2308
+ const updateStatus = (evtType, atnType, status, toUserIds) => live.updateStatus(evtType, atnType, status, toUserIds);
2307
2309
  return {
2308
2310
  connect,
2309
2311
  broadcast,
@@ -2357,11 +2359,11 @@ function createLiveReact(options) {
2357
2359
  }
2358
2360
  function useRTCAction() {
2359
2361
  const live = useLiveInstance();
2360
- const join = React.useCallback((options) => live.$RTC.join(options), [live]);
2361
- const quit = React.useCallback(() => live.$RTC.quit(), [live]);
2362
- const shock = React.useCallback(() => { var _a, _b; return (_b = (_a = live.$RTC).shock) === null || _b === void 0 ? void 0 : _b.call(_a); }, [live]);
2363
- const toggleMicro = React.useCallback((flag) => live.$RTC.toggleMicro(flag), [live]);
2364
- const detectMicro = React.useCallback(() => live.$RTC.detectMicro(), [live]);
2362
+ const join = (options) => live.$RTC.join(options);
2363
+ const quit = () => live.$RTC.quit();
2364
+ const shock = () => { var _a, _b; return (_b = (_a = live.$RTC).shock) === null || _b === void 0 ? void 0 : _b.call(_a); };
2365
+ const toggleMicro = (flag) => live.$RTC.toggleMicro(flag);
2366
+ const detectMicro = () => live.$RTC.detectMicro();
2365
2367
  return {
2366
2368
  join,
2367
2369
  quit,