@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.
- package/dist/live/createLive.d.ts +1 -1
- package/dist/live/createLiveReact.d.ts +4 -4
- package/dist/live/live.d.ts +1 -1
- package/dist/realsee-live.cjs.development.js +33 -24
- package/dist/realsee-live.cjs.development.js.map +1 -1
- package/dist/realsee-live.cjs.production.js +1 -1
- package/dist/realsee-live.cjs.production.js.map +1 -1
- package/dist/realsee-live.esm.js +34 -25
- package/dist/realsee-live.esm.js.map +1 -1
- package/dist/realsee-live.umd.development.js +849 -1015
- package/dist/realsee-live.umd.development.js.map +1 -1
- package/dist/realsee-live.umd.production.js +1 -1
- package/dist/realsee-live.umd.production.js.map +1 -1
- package/dist/rtc/BrowserRTC.d.ts +1 -0
- package/dist/typings/rtc/protocol.d.ts +5 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/BrowserRTC.html +10 -10
- package/docs/interfaces/RTCProtocol.html +12 -10
- package/docs/modules.html +10 -4
- package/package.json +6 -5
|
@@ -5,4 +5,4 @@ import { Live } from './live';
|
|
|
5
5
|
* @param opts
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare const createLive: <KeyframesSnapshot
|
|
8
|
+
export declare const createLive: <KeyframesSnapshot extends Record<string, any>>(opts: LiveOptions) => Live<KeyframesSnapshot>;
|
|
@@ -2,25 +2,25 @@ import React from 'react';
|
|
|
2
2
|
import { BuiltinActionType, BuiltinEventType, KeyframeTypes, LiveConnectOptions, LiveEventType, LiveOptions, MicroStatus, RTCEventType, RTCType, UserInfo } from '../typings';
|
|
3
3
|
import { LiveState } from '../typings/live/LiveState';
|
|
4
4
|
import { Live } from './live';
|
|
5
|
-
export declare type LiveProviderPropTypes<KeyframesSnapshot
|
|
5
|
+
export declare type LiveProviderPropTypes<KeyframesSnapshot extends Record<string, any>> = {
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
live?: Live<KeyframesSnapshot>;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
10
|
* 创建 {@link LiveReact} 实例,并提供 `React` 技术栈相关工具链。
|
|
11
11
|
*/
|
|
12
|
-
export declare function createLiveReact<KeyframesSnapshot
|
|
12
|
+
export declare function createLiveReact<KeyframesSnapshot extends Record<string, any>>(options: LiveOptions): {
|
|
13
13
|
live: Live<KeyframesSnapshot>;
|
|
14
14
|
jsBridge: import("@realsee/jsbridge-x").JSBridgeProtocol;
|
|
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?:
|
|
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>;
|
package/dist/live/live.d.ts
CHANGED
|
@@ -145,7 +145,7 @@ export declare class Live<KeyframesSnapshot extends Record<string, any>> extends
|
|
|
145
145
|
* @param timeout
|
|
146
146
|
* @returns
|
|
147
147
|
*/
|
|
148
|
-
broadcast<Request, Response>(request: Request, toUserIds: string | string[], timeout: number): Promise<Response> | Error | false;
|
|
148
|
+
broadcast<Request extends Record<string, any>, Response>(request: Request, toUserIds: string | string[], timeout: number): Promise<Response> | Error | false;
|
|
149
149
|
toggleMicro: (microStatus: boolean) => Promise<boolean>;
|
|
150
150
|
/**
|
|
151
151
|
* 控制别人的麦
|
|
@@ -204,6 +204,7 @@ class BrowserRTC extends CoreRTC {
|
|
|
204
204
|
this._getVoiceSign = () => {
|
|
205
205
|
throw new Error('方法 getVoiceSign 未实现');
|
|
206
206
|
};
|
|
207
|
+
this.checkRequirement = () => TRTC__default["default"].checkSystemRequirements();
|
|
207
208
|
this.$dom = document.createElement('div');
|
|
208
209
|
this._trtc = {
|
|
209
210
|
client: null,
|
|
@@ -318,9 +319,10 @@ class BrowserRTC extends CoreRTC {
|
|
|
318
319
|
var _a, _b, _c, _d;
|
|
319
320
|
(_a = this._trtc.client) === null || _a === void 0 ? void 0 : _a.on('stream-added', this._handleStreamAdded);
|
|
320
321
|
(_b = this._trtc.client) === null || _b === void 0 ? void 0 : _b.on('stream-subscribed', this._handleStreamSubscribed);
|
|
321
|
-
(_c = this._trtc.client) === null || _c === void 0 ? void 0 : _c.on('audio-volume', (event) => this.emit('userVolumes',
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
(_c = this._trtc.client) === null || _c === void 0 ? void 0 : _c.on('audio-volume', (event) => this.emit('userVolumes', event.result.map(({ userId, audioVolume }) => ({
|
|
323
|
+
userId,
|
|
324
|
+
audioVolume,
|
|
325
|
+
}))));
|
|
324
326
|
(_d = this._trtc.client) === null || _d === void 0 ? void 0 : _d.on('error', (event) => this.emit('error', event));
|
|
325
327
|
}
|
|
326
328
|
}
|
|
@@ -1715,7 +1717,7 @@ class Live extends Subscribe {
|
|
|
1715
1717
|
this._handleMessage = (liveMsg) => __awaiter(this, void 0, void 0, function* () {
|
|
1716
1718
|
var _b, _c, _d, _e, _f, _g;
|
|
1717
1719
|
if (typeof liveMsg === 'object') {
|
|
1718
|
-
const { command, data, frontRequestId, code, message } = liveMsg;
|
|
1720
|
+
const { command, data = {}, frontRequestId, code, message } = liveMsg;
|
|
1719
1721
|
if (code === 'SUCCESS') {
|
|
1720
1722
|
switch (command) {
|
|
1721
1723
|
/**
|
|
@@ -1884,6 +1886,13 @@ class Live extends Subscribe {
|
|
|
1884
1886
|
return false;
|
|
1885
1887
|
}
|
|
1886
1888
|
const { force = false } = options;
|
|
1889
|
+
// 检测一下麦克风权限,hack
|
|
1890
|
+
if (this._options.rtc) {
|
|
1891
|
+
const res = yield this._options.rtc.detectMicro();
|
|
1892
|
+
if (!res) {
|
|
1893
|
+
return new Error('Failed to obtain microphone authorization');
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1887
1896
|
// 检查是否已有实例在使用
|
|
1888
1897
|
const currentState = this.state;
|
|
1889
1898
|
if (currentState === exports.LiveState.CONNECTING ||
|
|
@@ -2258,21 +2267,21 @@ function createLiveReact(options) {
|
|
|
2258
2267
|
* @deprecated
|
|
2259
2268
|
* @returns
|
|
2260
2269
|
*/
|
|
2261
|
-
const unsafe__useLiveInstance =
|
|
2270
|
+
const unsafe__useLiveInstance = () => live;
|
|
2262
2271
|
/**
|
|
2263
2272
|
* 使用rtc实例
|
|
2264
2273
|
*/
|
|
2265
|
-
const useRTCInstance =
|
|
2274
|
+
const useRTCInstance = () => live.$RTC;
|
|
2266
2275
|
/**
|
|
2267
2276
|
* 不建议这样使用
|
|
2268
2277
|
* @deprecated
|
|
2269
2278
|
* @returns
|
|
2270
2279
|
*/
|
|
2271
|
-
const unsafe__useRTCInstance =
|
|
2280
|
+
const unsafe__useRTCInstance = () => useRTCInstance();
|
|
2272
2281
|
/**
|
|
2273
2282
|
* 带看连接操作
|
|
2274
2283
|
*/
|
|
2275
|
-
const useConnect =
|
|
2284
|
+
const useConnect = () => (options) => __awaiter(this, void 0, void 0, function* () { return yield live.connect(options); });
|
|
2276
2285
|
/**
|
|
2277
2286
|
*
|
|
2278
2287
|
* @param name
|
|
@@ -2296,17 +2305,17 @@ function createLiveReact(options) {
|
|
|
2296
2305
|
*/
|
|
2297
2306
|
function useLiveAction() {
|
|
2298
2307
|
const live = useLiveInstance();
|
|
2299
|
-
const connect =
|
|
2300
|
-
const toggleMicro =
|
|
2301
|
-
const broadcast =
|
|
2302
|
-
const exit =
|
|
2303
|
-
const kick =
|
|
2304
|
-
const forbidMicro =
|
|
2305
|
-
const forbidSync =
|
|
2306
|
-
const getFramesByKey =
|
|
2307
|
-
const sendKeyframe =
|
|
2308
|
-
const setSelfInfo =
|
|
2309
|
-
const updateStatus =
|
|
2308
|
+
const connect = (options) => __awaiter(this, void 0, void 0, function* () { return yield live.connect(options); });
|
|
2309
|
+
const toggleMicro = (microStatus) => live.toggleMicro(microStatus);
|
|
2310
|
+
const broadcast = (data, toUserIds, timeout = 0) => __awaiter(this, void 0, void 0, function* () { return yield live.broadcast(data, toUserIds, timeout); });
|
|
2311
|
+
const exit = () => __awaiter(this, void 0, void 0, function* () { return yield live.exit(); });
|
|
2312
|
+
const kick = (toUserIds) => __awaiter(this, void 0, void 0, function* () { return yield live.kick(toUserIds); });
|
|
2313
|
+
const forbidMicro = (micro, toUserIds = []) => __awaiter(this, void 0, void 0, function* () { return yield live.forbidMicro(micro, toUserIds); });
|
|
2314
|
+
const forbidSync = (sync, toUserIds = []) => live.forbidSync(sync, toUserIds);
|
|
2315
|
+
const getFramesByKey = (key) => live.getFramesByKey(key);
|
|
2316
|
+
const sendKeyframe = (key, frame) => live.sendKeyframe(key, frame);
|
|
2317
|
+
const setSelfInfo = (userInfo) => live.setSelfInfo(userInfo);
|
|
2318
|
+
const updateStatus = (evtType, atnType, status, toUserIds) => live.updateStatus(evtType, atnType, status, toUserIds);
|
|
2310
2319
|
return {
|
|
2311
2320
|
connect,
|
|
2312
2321
|
broadcast,
|
|
@@ -2360,11 +2369,11 @@ function createLiveReact(options) {
|
|
|
2360
2369
|
}
|
|
2361
2370
|
function useRTCAction() {
|
|
2362
2371
|
const live = useLiveInstance();
|
|
2363
|
-
const join =
|
|
2364
|
-
const quit =
|
|
2365
|
-
const shock =
|
|
2366
|
-
const toggleMicro =
|
|
2367
|
-
const detectMicro =
|
|
2372
|
+
const join = (options) => live.$RTC.join(options);
|
|
2373
|
+
const quit = () => live.$RTC.quit();
|
|
2374
|
+
const shock = () => { var _a, _b; return (_b = (_a = live.$RTC).shock) === null || _b === void 0 ? void 0 : _b.call(_a); };
|
|
2375
|
+
const toggleMicro = (flag) => live.$RTC.toggleMicro(flag);
|
|
2376
|
+
const detectMicro = () => live.$RTC.detectMicro();
|
|
2368
2377
|
return {
|
|
2369
2378
|
join,
|
|
2370
2379
|
quit,
|