@realsee/live 0.4.0-beta.7 → 0.5.0-alpha.2

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.
Files changed (33) hide show
  1. package/dist/live/controller.d.ts +75 -38
  2. package/dist/live/createLive.d.ts +5 -3
  3. package/dist/live/createLiveReact.d.ts +49 -3
  4. package/dist/live/live.d.ts +162 -0
  5. package/dist/realsee-live.cjs.development.js +1555 -1446
  6. package/dist/realsee-live.cjs.development.js.map +1 -1
  7. package/dist/realsee-live.cjs.production.js +1 -1
  8. package/dist/realsee-live.cjs.production.js.map +1 -1
  9. package/dist/realsee-live.esm.js +1557 -1448
  10. package/dist/realsee-live.esm.js.map +1 -1
  11. package/dist/realsee-live.umd.development.js +51482 -51302
  12. package/dist/realsee-live.umd.development.js.map +1 -1
  13. package/dist/realsee-live.umd.production.js +1 -1
  14. package/dist/realsee-live.umd.production.js.map +1 -1
  15. package/dist/typings/live/EventType.d.ts +17 -33
  16. package/dist/typings/live/LiveConnectOptions.d.ts +7 -0
  17. package/dist/typings/live/LiveErrorType.d.ts +9 -0
  18. package/dist/typings/live/LiveOptions.d.ts +5 -12
  19. package/dist/typings/live/LiveState.d.ts +15 -0
  20. package/dist/typings/live/index.d.ts +2 -1
  21. package/dist/typings/react/index.d.ts +0 -1
  22. package/dist/utils/RobustWebSocket.d.ts +130 -0
  23. package/dist/utils/logger.d.ts +16 -0
  24. package/docs/assets/search.js +1 -1
  25. package/docs/enums/LiveState.html +7 -0
  26. package/docs/index.html +1 -1
  27. package/docs/interfaces/LiveOptions.html +16 -19
  28. package/docs/modules.html +34 -40
  29. package/package.json +2 -2
  30. package/dist/typings/live/Live.d.ts +0 -128
  31. package/dist/typings/react/LiveReact.d.ts +0 -164
  32. package/docs/interfaces/Live.html +0 -116
  33. package/docs/interfaces/LiveReact.html +0 -52
@@ -1,37 +1,16 @@
1
1
  import { BuiltinMsg, LiveMsg } from './LiveMsg';
2
+ import { LiveState } from './LiveState';
2
3
  import { UserInfo } from './UserInfo';
3
- import { WebSocketError, WebSocketState } from './WebSocket';
4
4
  /**
5
- * WebSocket 相关异步事件
6
- * @description
7
- * @deprecated 这些事件不应暴露给应用层
5
+ * 带看事件列表
8
6
  */
9
- declare type WebSocketEventType = {
7
+ export declare type LiveEventType<KeyframesSnapshot> = {
10
8
  /**
11
- * WebSocket 状态发生更新
12
- * @param readyState - 当前状态枚举值。
9
+ * 带看状态变化
10
+ * @param state
11
+ * @param prevState
13
12
  */
14
- 'ws.readyStateUpdate'(readyState: WebSocketState): void;
15
- /**
16
- * WebSocket 连接前
17
- */
18
- 'ws.beforeConnect'(reConnect?: number): void;
19
- /**
20
- * WebSocket 连接后
21
- */
22
- 'ws.afterConnect'(reConnect?: number): void;
23
- /**
24
- * WebSocket 连接过程中遭遇的异常情况信息。
25
- * @param error - 错误信息。
26
- */
27
- 'ws.error'(error: WebSocketError): void;
28
- /**
29
- * WebSocket 收到的消息
30
- * @param liveMsg - 透传 WebSocket 消息
31
- */
32
- 'ws.message'(liveMsg: LiveMsg): void;
33
- };
34
- declare type LiveEventType<Snapshot> = {
13
+ 'stateChange'(state: LiveState, prevState?: LiveState): void;
35
14
  /**
36
15
  * 内置消息事件
37
16
  * @param builtinMsg
@@ -56,12 +35,12 @@ declare type LiveEventType<Snapshot> = {
56
35
  * 带看已经就绪,可以发送帧数据。
57
36
  * @param lastKeyframe 带看最后一帧数据(链接切换、断网等重连恢复上次会话帧状态),你可以通过此数据拉齐当前UI状态。
58
37
  */
59
- 'readyKeyframeSync'(lastKeyframe: Partial<Snapshot>): void;
38
+ 'readyKeyframeSync'(lastKeyframe: Partial<KeyframesSnapshot>): void;
60
39
  /**
61
40
  * 获取其他用户输送的帧数据:根据此帧数据更新UI状态。
62
41
  * @param keyframes
63
42
  */
64
- 'keyframes'(keyframes: Partial<Snapshot>, frontRequestId: string): void;
43
+ 'keyframes'(keyframes: Partial<KeyframesSnapshot>, frontRequestId: string): void;
65
44
  /**
66
45
  * 个人信息发生更新。
67
46
  * @param userInfo
@@ -83,8 +62,13 @@ declare type LiveEventType<Snapshot> = {
83
62
  */
84
63
  'error'(liveMsg: LiveMsg): void;
85
64
  };
86
- declare type KeyframeTypes<Type> = {
65
+ /**
66
+ * 帧数据类型
67
+ */
68
+ export declare type KeyframeTypes<Type> = {
87
69
  [Property in keyof Type as Property]: (nextKeyframes: Type[Property], prevKeyframes: Type[Property], frontRequestId: string) => void;
88
70
  };
89
- declare type EventType<Snapshot> = LiveEventType<Snapshot> & WebSocketEventType;
90
- export { LiveEventType, WebSocketEventType, KeyframeTypes, EventType };
71
+ /**
72
+ * 事件解析
73
+ */
74
+ export declare type EventType<KeyframesSnapshot> = LiveEventType<KeyframesSnapshot>;
@@ -0,0 +1,7 @@
1
+ import { MicroStatus } from "./LiveMsg";
2
+ export declare type LiveConnectOptions = {
3
+ url?: string;
4
+ force?: boolean;
5
+ getTicket?: () => Promise<string>;
6
+ rtcMicStatus?: MicroStatus;
7
+ };
@@ -0,0 +1,9 @@
1
+ export declare enum LiveErrorType {
2
+ Error = "Error",
3
+ Close = "Close",
4
+ MicroAuth = "MicroAuth",
5
+ DuplicateConnect = "DuplicateConnect",
6
+ IllegalURL = "IllegalURL",
7
+ Unknown = "Unknown",
8
+ IllegalArgs = "IllegalArgs"
9
+ }
@@ -2,6 +2,7 @@ import { JSBridgeProtocol } from '@realsee/jsbridge-x';
2
2
  import { RTCProtocol } from '../rtc/protocol';
3
3
  import { BuiltInRTCType, RTCType } from '../rtc/type';
4
4
  import { GetVoiceSign } from './GetVoiceSign';
5
+ import { MicroStatus } from './LiveMsg';
5
6
  /**
6
7
  * 依赖配置。
7
8
  */
@@ -20,6 +21,10 @@ export interface LiveOptions {
20
21
  * rtc 为空时使用内置的rtc实例类型
21
22
  */
22
23
  rtcType?: RTCType;
24
+ /**
25
+ * 麦克风初始状态
26
+ */
27
+ initialMicroStatus?: MicroStatus;
23
28
  /**
24
29
  * 获取建立 WebSocket 连接的依赖Tick
25
30
  */
@@ -47,18 +52,6 @@ export interface LiveOptions {
47
52
  * 使用内置的jsBridge实例
48
53
  */
49
54
  useBuiltInJsBridge?: boolean;
50
- /**
51
- * 初始化自动连接,false 需手动执行 live.connect() 方法
52
- */
53
- /**
54
- * 异常断开是否自动重连:默认 `true` 重连三次.
55
- * 可以设置 `false` 关闭自动重连,以监控 `ws.readyStateUpdate` 事件自己来实现重连逻辑。
56
- */
57
- autoReconnect?: boolean | number;
58
- /**
59
- * 是否开启定时健康检查
60
- */
61
- healthCheck?: boolean | number;
62
55
  /**
63
56
  * 能否禁用某个/些用户的麦克风
64
57
  */
@@ -0,0 +1,15 @@
1
+ export declare enum LiveState {
2
+ NOTINITIALIZED = -1,
3
+ /**
4
+ * 正在链接中
5
+ */
6
+ CONNECTING = 0,
7
+ /**
8
+ * 已经链接并且可以通讯
9
+ */
10
+ OPEN = 1,
11
+ /**
12
+ * 连接已关闭或者链接失败
13
+ */
14
+ CLOSED = 3
15
+ }
@@ -1,8 +1,9 @@
1
1
  export * from './EventType';
2
2
  export * from './GetVoiceSign';
3
- export * from './Live';
4
3
  export * from './LiveMsg';
5
4
  export * from './LiveOptions';
5
+ export * from './LiveState';
6
+ export * from './LiveConnectOptions';
6
7
  export * from './RoomInfo';
7
8
  export * from './UserInfo';
8
9
  export * from './UserVolume';
@@ -1,2 +1 @@
1
- export * from './LiveReact';
2
1
  export * from './RTCActionReactCallback';
@@ -0,0 +1,130 @@
1
+ import { Subscribe } from './subscribe';
2
+ /**
3
+ * 鲁棒ws的配置参数
4
+ */
5
+ export declare type RobustWebSocketConstructorOptions = {
6
+ url: string | ((ws: RobustWebSocket) => string);
7
+ protocols?: string[];
8
+ robustOptions?: RobustOptions;
9
+ };
10
+ /**
11
+ * ws 鲁棒性的配置
12
+ */
13
+ export declare type RobustOptions = {
14
+ timeout?: number;
15
+ shouldReconnect?: (event: CloseEvent, ws: RobustWebSocket) => undefined | number;
16
+ should1000Reconnect?: boolean;
17
+ ignoreConnectivityEvents?: boolean;
18
+ automaticOpen?: boolean;
19
+ };
20
+ export declare type RobustWebSocketEventDetail = {
21
+ reconnects: number;
22
+ attempts: number;
23
+ };
24
+ export declare type RobustWebSocketEvent<T> = Event & {
25
+ detail: T;
26
+ };
27
+ export declare type RobustWebSocketEventMap = {
28
+ connecting: (event: RobustWebSocketEvent<RobustWebSocketEventDetail>) => void;
29
+ timeout: (event: RobustWebSocketEvent<RobustWebSocketEventDetail>) => void;
30
+ open: (event: RobustWebSocketEvent<RobustWebSocketEventDetail>) => void;
31
+ close: (event: CloseEvent) => void;
32
+ error: (event: Event) => void;
33
+ message: (event: MessageEvent<string | ArrayBuffer | Blob | ArrayBufferView>) => void;
34
+ };
35
+ /**
36
+ * 具有鲁棒性的WebSocket封装
37
+ * 1、自动重连
38
+ * 2、可根据网络情况进行重连
39
+ */
40
+ export declare class RobustWebSocket extends Subscribe<RobustWebSocketEventMap> {
41
+ private _realWebSocket;
42
+ private _url?;
43
+ private _protocols;
44
+ private _options;
45
+ private _connectTimeout;
46
+ private _attempts;
47
+ private _reconnects;
48
+ private _reconnectWhenOnlineAgain;
49
+ private _explicitlyClosed;
50
+ private _pendingReconnect;
51
+ private _connectivityEventsAttached;
52
+ get attempts(): number;
53
+ constructor(options?: RobustWebSocketConstructorOptions);
54
+ setOptions(options: RobustWebSocketConstructorOptions): void;
55
+ /**
56
+ * 清理连接中的请求
57
+ */
58
+ private _clearPendingReconnectIfNeeded;
59
+ /**
60
+ * 当网页连接上网络进行重连
61
+ * @param event
62
+ */
63
+ private _online;
64
+ /**
65
+ * 当网页断开网络进行关闭
66
+ */
67
+ private _offline;
68
+ /**
69
+ * 解除网络监听事件
70
+ */
71
+ private _detachConnectivityEvents;
72
+ /**
73
+ * 注册网络监听事件
74
+ */
75
+ private _attachConnectivityEvents;
76
+ /**
77
+ * 发送消息
78
+ * @param data
79
+ * @returns
80
+ */
81
+ send: (data: string | ArrayBuffer | Blob | ArrayBufferView) => void | undefined;
82
+ /**
83
+ * 关闭连接
84
+ * @param code 代码
85
+ * @param reason 原因
86
+ * @returns
87
+ */
88
+ close: (code?: number | string, reason?: string) => void | undefined;
89
+ /**
90
+ * 进行ws连接
91
+ */
92
+ open: (url?: string) => void;
93
+ /**
94
+ * 创建ws连接
95
+ */
96
+ private _createWebSocket;
97
+ /**
98
+ * 分发ws事件
99
+ */
100
+ private _dispatchWebSocketEvent;
101
+ /**
102
+ * ws连接事件
103
+ * @returns
104
+ */
105
+ private _webSocketOpenHandler;
106
+ /**
107
+ * ws 关闭事件
108
+ * @param event
109
+ * @returns
110
+ */
111
+ private _webSocketCloseHandler;
112
+ /**
113
+ * ws 异常
114
+ * @param event
115
+ * @returns
116
+ */
117
+ private _webSocketErrorHandler;
118
+ /**
119
+ * ws消息
120
+ * @param event
121
+ * @returns
122
+ */
123
+ private _webSocketMessageHandler;
124
+ /**
125
+ * 进行重连
126
+ * @param event
127
+ * @returns
128
+ */
129
+ private _reconnect;
130
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 输出格式化日志
3
+ */
4
+ export declare enum LOG_LEVEL {
5
+ info = "INFO",
6
+ log = "LOG",
7
+ error = "ERROR",
8
+ warn = "WARN"
9
+ }
10
+ declare const logger: {
11
+ log: (...args: any[]) => void;
12
+ info: (...args: any[]) => void;
13
+ error: (...args: any[]) => void;
14
+ warn: (...args: any[]) => void;
15
+ };
16
+ export default logger;