@realsee/live 0.5.0-alpha.8 → 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
  /**
@@ -1874,6 +1876,13 @@ class Live extends Subscribe {
1874
1876
  return false;
1875
1877
  }
1876
1878
  const { force = false } = options;
1879
+ // 检测一下麦克风权限,hack
1880
+ if (this._options.rtc) {
1881
+ const res = yield this._options.rtc.detectMicro();
1882
+ if (!res) {
1883
+ return new Error('Failed to obtain microphone authorization');
1884
+ }
1885
+ }
1877
1886
  // 检查是否已有实例在使用
1878
1887
  const currentState = this.state;
1879
1888
  if (currentState === LiveState.CONNECTING ||
@@ -2248,21 +2257,21 @@ function createLiveReact(options) {
2248
2257
  * @deprecated
2249
2258
  * @returns
2250
2259
  */
2251
- const unsafe__useLiveInstance = useCallback(() => useLiveInstance(), [useLiveInstance]);
2260
+ const unsafe__useLiveInstance = () => live;
2252
2261
  /**
2253
2262
  * 使用rtc实例
2254
2263
  */
2255
- const useRTCInstance = useCallback(() => useLiveInstance().$RTC, [useLiveInstance]);
2264
+ const useRTCInstance = () => live.$RTC;
2256
2265
  /**
2257
2266
  * 不建议这样使用
2258
2267
  * @deprecated
2259
2268
  * @returns
2260
2269
  */
2261
- const unsafe__useRTCInstance = useCallback(() => useRTCInstance(), [useRTCInstance]);
2270
+ const unsafe__useRTCInstance = () => useRTCInstance();
2262
2271
  /**
2263
2272
  * 带看连接操作
2264
2273
  */
2265
- 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); });
2266
2275
  /**
2267
2276
  *
2268
2277
  * @param name
@@ -2286,17 +2295,17 @@ function createLiveReact(options) {
2286
2295
  */
2287
2296
  function useLiveAction() {
2288
2297
  const live = useLiveInstance();
2289
- const connect = React.useCallback((options) => __awaiter(this, void 0, void 0, function* () { return yield live.connect(options); }), [live]);
2290
- const toggleMicro = React.useCallback((microStatus) => live.toggleMicro(microStatus), [live]);
2291
- const broadcast = React.useCallback((data, toUserIds, timeout = 0) => __awaiter(this, void 0, void 0, function* () { return yield live.broadcast(data, toUserIds, timeout); }), [live]);
2292
- const exit = React.useCallback(() => __awaiter(this, void 0, void 0, function* () { return yield live.exit(); }), [live]);
2293
- const kick = React.useCallback((toUserIds) => __awaiter(this, void 0, void 0, function* () { return yield live.kick(toUserIds); }), [live]);
2294
- const forbidMicro = React.useCallback((micro, toUserIds = []) => __awaiter(this, void 0, void 0, function* () { return yield live.forbidMicro(micro, toUserIds); }), [live]);
2295
- const forbidSync = React.useCallback((sync, toUserIds = []) => live.forbidSync(sync, toUserIds), [live]);
2296
- const getFramesByKey = React.useCallback((key) => live.getFramesByKey(key), [live]);
2297
- const sendKeyframe = React.useCallback((key, frame) => live.sendKeyframe(key, frame), [live]);
2298
- const setSelfInfo = React.useCallback((userInfo) => live.setSelfInfo(userInfo), [live]);
2299
- 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);
2300
2309
  return {
2301
2310
  connect,
2302
2311
  broadcast,
@@ -2350,11 +2359,11 @@ function createLiveReact(options) {
2350
2359
  }
2351
2360
  function useRTCAction() {
2352
2361
  const live = useLiveInstance();
2353
- const join = React.useCallback((options) => live.$RTC.join(options), [live]);
2354
- const quit = React.useCallback(() => live.$RTC.quit(), [live]);
2355
- const shock = React.useCallback(() => { var _a, _b; return (_b = (_a = live.$RTC).shock) === null || _b === void 0 ? void 0 : _b.call(_a); }, [live]);
2356
- const toggleMicro = React.useCallback((flag) => live.$RTC.toggleMicro(flag), [live]);
2357
- 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();
2358
2367
  return {
2359
2368
  join,
2360
2369
  quit,