@ylink-sdk/meeting 0.1.1 → 0.1.5

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,5 +1,5 @@
1
- import { ENDPOINT_TYPE } from './enums';
2
- import { UserState, Inbox, ResultInfo } from './data';
1
+ import { ENDPOINT_TYPE, ROLE } from './enums';
2
+ import { UserState, Inbox, ResultInfo, CustomLayout, BasicLayout, Barrage } from './data';
3
3
  /**
4
4
  * SFU会控返回响应值
5
5
  */
@@ -19,8 +19,59 @@ export interface Result<T = any> extends Response {
19
19
  export interface Ctrl {
20
20
  /**
21
21
  * 取消请求,目前只针对polling和keepalive有效
22
+ * @since 1.0.0
22
23
  */
23
24
  cancelToken: (reason: string) => void;
25
+ /**
26
+ * 获取当前会议通告推送的收件箱信息
27
+ * @since 1.0.0
28
+ * @ignore
29
+ */
30
+ inbox: (params: {
31
+ basic: {
32
+ /**
33
+ * 租户Id,目前为100
34
+ */
35
+ tenantId: number;
36
+ /**
37
+ * 终端标识,由客户端保证唯一
38
+ */
39
+ clientId: string;
40
+ /**
41
+ * 每次会议的唯一标识
42
+ */
43
+ meetingId: string;
44
+ };
45
+ /**
46
+ * 终端订阅的topic对应的收件箱标识。
47
+ */
48
+ inboxes: Array<string>;
49
+ }) => Promise<Result>;
50
+ /**
51
+ * 消息轮询
52
+ * @since 1.0.0
53
+ * @ignore
54
+ */
55
+ polling: (params: {
56
+ basic: {
57
+ /**
58
+ * 租户Id,目前为100
59
+ */
60
+ tenantId: number;
61
+ /**
62
+ * 终端标识,由客户端保证唯一
63
+ */
64
+ clientId: string;
65
+ /**
66
+ * 每次会议的唯一标识
67
+ */
68
+ meetingId: string;
69
+ };
70
+ /**
71
+ * 收件箱对象的信息列表
72
+ */
73
+ inboxes: Array<Inbox>;
74
+ }) => Promise<Result>;
24
75
  /**
25
76
  * ## 获取入会秘钥
26
77
  * @since 1.0.0
@@ -67,25 +118,59 @@ export interface Ctrl {
67
118
  */
68
119
  inviteTransID?: string;
69
120
  /**
70
- * 组织架构id列表,有账号则必选
121
+ * 组织架构id列表
71
122
  */
72
123
  groupIDs?: Array<string>;
73
124
  /**
74
- * 账号
125
+ * 云账号
75
126
  */
76
127
  account?: string;
77
128
  /**
78
- * 终端设备类型UA,用于通话统计,有必带, 非cdr用户可不带
129
+ * 终端设备类型UA
79
130
  */
80
131
  userAgent?: string;
81
132
  /**
82
- * 账号的GroupName名称,有必带,用于通话统计, 有多个的情况取第一个上报, 非cdr用户可不带
133
+ * 账号的GroupName名称
83
134
  */
84
135
  groupName?: string;
85
136
  /**
86
- * 终端的 YTMS 设备id,保证全局唯一,如果无法保证唯一 则不要带该id,主要用于判断同一台设备重复入会
137
+ * 终端设备ID
87
138
  */
88
139
  clientID?: string;
140
+ /**
141
+ * 网关主机uuid
142
+ */
143
+ gwID?: string;
144
+ /**
145
+ * 终端IP地址
146
+ */
147
+ clientIP?: string;
148
+ /**
149
+ * 分辨率信息,高清端口参数
150
+ */
151
+ mediaContentReq?: {
152
+ /**
153
+ * 视频参数设置
154
+ */
155
+ video?: {
156
+ /**
157
+ * 分辨率宽
158
+ */
159
+ width: number;
160
+ /**
161
+ * 分辨率高
162
+ */
163
+ height: number;
164
+ /**
165
+ * 帧率
166
+ */
167
+ fr: number;
168
+ };
169
+ /**
170
+ * 仅音频
171
+ */
172
+ audioOnly: boolean;
173
+ };
89
174
  }) => Promise<Result>;
90
175
  /**
91
176
  * 上报用户媒体信息
@@ -94,86 +179,230 @@ export interface Ctrl {
94
179
  */
95
180
  updateUserState: (params: UserState) => Promise<Result>;
96
181
  /**
97
- * 获取当前会议通告推送的收件箱信息
182
+ * 订阅通告
98
183
  * @since 1.0.0
99
184
  * @ignore
100
185
  */
101
- inbox: (params: {
102
- basic: {
103
- /**
104
- * 租户Id,目前为100
105
- */
106
- tenantId: number;
107
- /**
108
- * 终端标识,由客户端保证唯一
109
- */
110
- clientId: string;
111
- /**
112
- * 每次会议的唯一标识
113
- */
114
- meetingId: string;
115
- };
186
+ subscribe: (params: {
116
187
  /**
117
- * 终端订阅的topic对应的收件箱标识。
188
+ * 要订阅的的topic和inbox接口的inboxes一致
118
189
  */
119
- inboxes: Array<string>;
190
+ topics: Array<string>;
120
191
  }) => Promise<Result>;
121
192
  /**
122
- * 消息轮询
123
- * @ignore
193
+ * 邀请 trying
194
+ * @since 1.0.0
124
195
  */
125
- polling: (params: {
126
- basic: {
127
- /**
128
- * 租户Id,目前为100
129
- */
130
- tenantId: number;
131
- /**
132
- * 终端标识,由客户端保证唯一
133
- */
134
- clientId: string;
135
- /**
136
- * 每次会议的唯一标识
137
- */
138
- meetingId: string;
139
- };
196
+ trying: (params: {
140
197
  /**
141
- * 收件箱对象的信息列表
198
+ * 账户token
142
199
  */
143
- inboxes: Array<Inbox>;
200
+ token: string;
201
+ /**
202
+ * 终端类型
203
+ */
204
+ endpointType: ENDPOINT_TYPE;
205
+ /**
206
+ * 会议号
207
+ */
208
+ meetingNum: string;
209
+ /**
210
+ * credential接口获取到的入会秘钥
211
+ */
212
+ credential: string;
213
+ /**
214
+ * 邀请事务id
215
+ */
216
+ inviteTransID: string;
217
+ /**
218
+ * 0 默认,终端通知服务器已收到邀请通知,多次调用都能成功(目前不用调)
219
+ * 1 独占模式,用于一呼多只能一方入会的场景,多次trying只有第一次能成功,比如邀请IP或直播录播2 兼容3x使用,仅用于邀请v3x亿联终端,多次trying都成功且返回meetingID等数据
220
+ */
221
+ inviteMode?: number;
144
222
  }) => Promise<Result>;
145
223
  /**
146
- * 订阅通告
147
- * @ignore
224
+ * 邀请拒接
225
+ * @since 1.0.0
148
226
  */
149
- subscribe: (params: {
227
+ rejectCall: (params: {
150
228
  /**
151
- * 要订阅的的topic和inbox接口的inboxes一致
229
+ * 账户token
152
230
  */
153
- topics: Array<string>;
231
+ token: string;
232
+ /**
233
+ * 终端类型
234
+ */
235
+ endpointType: ENDPOINT_TYPE;
236
+ /**
237
+ * 会议号
238
+ */
239
+ meetingNum: string;
240
+ /**
241
+ * credential接口获取到的入会秘钥
242
+ */
243
+ credential: string;
244
+ /**
245
+ * 退会的信息
246
+ */
247
+ resultInfo?: ResultInfo;
248
+ /**
249
+ * 邀请事务id
250
+ */
251
+ inviteTransID: string;
252
+ /**
253
+ * YTMS设备id,也是会议邀请推送的ID
254
+ */
255
+ clientID?: string;
154
256
  }) => Promise<Result>;
155
257
  /**
156
- * 用户保活
157
- * @ignore
258
+ * 离开会议
259
+ * @since 1.0.0
158
260
  */
159
- keepalive: (params: {
261
+ leave: (params: {
262
+ resultInfo: ResultInfo;
263
+ }) => Promise<Result>;
264
+ /**
265
+ * 上报通话统计
266
+ */
267
+ callStatsReport: (params: {
160
268
  /**
161
- * 入会用户ID
269
+ * 用户ID
162
270
  */
163
271
  userID: number;
272
+ stats: any;
273
+ deviceInfo: string;
274
+ protocol: string;
164
275
  }) => Promise<Result>;
165
276
  /**
166
- * 离开会议
277
+ * 闭音
167
278
  * @since 1.0.0
168
279
  */
169
- leave: (params: {
170
- resultInfo: ResultInfo;
280
+ pauseAudio: (params: {
281
+ /**
282
+ * 用户ID
283
+ */
284
+ userID: number;
171
285
  }) => Promise<Result>;
172
286
  /**
173
- * 结束会议
287
+ * 开音
174
288
  * @since 1.0.0
175
289
  */
176
- end: () => Promise<Result>;
290
+ resumeAudio: (params: {
291
+ /**
292
+ * 用户ID
293
+ */
294
+ userID: number;
295
+ }) => Promise<Result>;
296
+ /**
297
+ * 大厅切换
298
+ * @since 1.0.0
299
+ */
300
+ lobbyState: (params: {
301
+ /**
302
+ * 用户ID
303
+ */
304
+ userID: number;
305
+ /**
306
+ * 当isInLobby=true, 用户从会议中被移到会议大厅同时互动方切换为大厅用户。
307
+ * 当isInLobby=false, 用户从会议大厅被移到会议中,大厅用户切换为互动方。
308
+ */
309
+ isInLobby: boolean;
310
+ }) => Promise<Result>;
311
+ /**
312
+ * 改名
313
+ * @since 1.0.0
314
+ */
315
+ displayName: (params: {
316
+ /**
317
+ * 用户ID
318
+ */
319
+ userID: number;
320
+ /**
321
+ * 新用户名
322
+ */
323
+ displayName: string;
324
+ }) => Promise<Result>;
325
+ /**
326
+ * 获取通话统计
327
+ * @since 1.0.0
328
+ */
329
+ callStats: (params: {
330
+ /**
331
+ * 用户ID
332
+ */
333
+ userID: number;
334
+ }) => Promise<Result>;
335
+ /**
336
+ * 获取用户信息,若某个用户的seq发生跳变或者终端想获取单个用户的最新信息
337
+ * @since 1.0.0
338
+ */
339
+ user: (params: {
340
+ /**
341
+ * 用户ID
342
+ */
343
+ userID: number;
344
+ }) => Promise<Result>;
345
+ /**
346
+ * 禁屏
347
+ * @since 1.0.0
348
+ */
349
+ blockVideo: (params: {
350
+ /**
351
+ * 用户ID
352
+ */
353
+ userID: number;
354
+ }) => Promise<Result>;
355
+ /**
356
+ * 取消禁屏
357
+ * @since 1.0.0
358
+ */
359
+ unblockVideo: (params: {
360
+ /**
361
+ * 用户ID
362
+ */
363
+ userID: number;
364
+ }) => Promise<Result>;
365
+ /**
366
+ * 举手
367
+ * @since 1.0.0
368
+ */
369
+ handUp: (params: {
370
+ /**
371
+ * 用户ID
372
+ */
373
+ userID: number;
374
+ /**
375
+ * 是否举手,可选true举手,false手放下
376
+ */
377
+ handUp: boolean;
378
+ }) => Promise<Result>;
379
+ /**
380
+ * 响应举手
381
+ * @since 1.0.0
382
+ */
383
+ replyHandUp: (params: {
384
+ /**
385
+ * 用户ID
386
+ */
387
+ userID: number;
388
+ /**
389
+ * 当permit=true,主持人同意用户发言,若是与会者,同意举手就是允许发言;
390
+ * 若是观众同意举手,会切换广播方的状态为互动方并允许发言,但角色还是观众。
391
+ * permit=false,主持人不同意发言,手放下
392
+ */
393
+ permit: boolean;
394
+ }) => Promise<Result>;
395
+ /**
396
+ * 用户保活
397
+ * @since 1.0.0
398
+ * @ignore
399
+ */
400
+ keepalive: (params: {
401
+ /**
402
+ * 入会用户ID
403
+ */
404
+ userID: number;
405
+ }) => Promise<Result>;
177
406
  /**
178
407
  * 设置音频
179
408
  * @since 1.0.0
@@ -223,6 +452,10 @@ export interface Ctrl {
223
452
  * 辅流状态
224
453
  */
225
454
  sendOn: boolean;
455
+ /**
456
+ * 认证信息,当远端请求开启时下发的cred
457
+ */
458
+ cred?: string;
226
459
  /**
227
460
  * 是否需服务器提供辅流协助
228
461
  */
@@ -237,17 +470,354 @@ export interface Ctrl {
237
470
  mode?: number;
238
471
  }) => Promise<Result>;
239
472
  /**
240
- * 举手
473
+ * 修改角色
474
+ * @since 1.0.0
241
475
  */
242
- handUp: (params: {
476
+ role: (params: {
243
477
  /**
244
478
  * 用户ID
245
479
  */
246
480
  userID: number;
247
481
  /**
248
- * 是否举手,可选true举手,false手放下
482
+ * 用户角色
249
483
  */
250
- handUp: boolean;
484
+ role: ROLE | string;
485
+ }) => Promise<Result>;
486
+ /**
487
+ * 移出会议
488
+ * @since 1.0.0
489
+ */
490
+ remove: (params: {
491
+ /**
492
+ * 用户ID
493
+ */
494
+ userID: number;
495
+ /**
496
+ * 移出原因
497
+ */
498
+ resultInfo?: ResultInfo;
499
+ }) => Promise<Result>;
500
+ /**
501
+ * DTMF
502
+ * @since 1.0.0
503
+ */
504
+ dtmf: (params: {
505
+ /**
506
+ * 用户ID
507
+ */
508
+ userID: number;
509
+ /**
510
+ * 0~9,*,#
511
+ */
512
+ dtmf: string;
513
+ }) => Promise<Result>;
514
+ /**
515
+ * FECC
516
+ * @since 1.0.0
517
+ */
518
+ fecc: (params: {
519
+ /**
520
+ * 用户ID
521
+ */
522
+ userID: number;
523
+ /**
524
+ * 行为动作,取值可选:panLeft(摄像头左移)、panRight(摄像头右移)、tiltDown(摄像头下移)、tiltUp(摄像头上移)、zoomOut(缩小)、zoomIn(放大)、focusOut(分散)、focusIn(聚焦)
525
+ */
526
+ action: string;
527
+ /**
528
+ * 动作执行次数
529
+ */
530
+ actionPlayTimes: number;
531
+ }) => Promise<Result>;
532
+ /**
533
+ * 设置主持人布局
534
+ * @since 1.0.0
535
+ */
536
+ hostLayout: (params: {
537
+ /**
538
+ * 布局模式,可选参数:basic、custom
539
+ * 当mode=basic时,终端入会默认显示服务器推送的布局类型,但允许主持人、与会者本地切换为其它布局,研讨会观众无法切换
540
+ * 当mode=custom时,终端都固定显示,无法本地切换布局
541
+ */
542
+ mode: string;
543
+ /**
544
+ * 布局结构体;当mode=basic时无需带;当mode=custom,采用customLayout结构体
545
+ */
546
+ layout?: CustomLayout | BasicLayout;
547
+ /**
548
+ * 自定义布局是否同时应用于与会者
549
+ */
550
+ applyToAttendee?: boolean;
551
+ }) => Promise<Result>;
552
+ /**
553
+ * 设置与会者布局
554
+ * @since 1.0.0
555
+ */
556
+ attendeeLayout: (params: {
557
+ /**
558
+ * 布局模式,可选参数:basic、custom
559
+ * 当mode=basic时,终端入会默认显示服务器推送的布局类型,但允许主持人、与会者本地切换为其它布局,研讨会观众无法切换
560
+ * 当mode=custom时,终端都固定显示,无法本地切换布局
561
+ */
562
+ mode: string;
563
+ /**
564
+ * 布局结构体;当mode=basic时无需带;当mode=custom,采用customLayout结构体
565
+ */
566
+ layout?: CustomLayout | BasicLayout;
567
+ }) => Promise<Result>;
568
+ /**
569
+ * 设置观众布局
570
+ * @since 1.0.0
571
+ */
572
+ audienceLayout: (params: {
573
+ /**
574
+ * 布局模式,可选参数:basic、custom
575
+ * 当mode=basic时,终端入会默认显示服务器推送的布局类型,但允许主持人、与会者本地切换为其它布局,研讨会观众无法切换
576
+ * 当mode=custom时,终端都固定显示,无法本地切换布局
577
+ */
578
+ mode: string;
579
+ /**
580
+ * 布局结构体;当mode=basic时无需带;当mode=custom,采用customLayout结构体
581
+ */
582
+ layout?: CustomLayout | BasicLayout;
583
+ }) => Promise<Result>;
584
+ /**
585
+ * 应用个人布局
586
+ * @since 1.0.0
587
+ */
588
+ personalLayout: (params: {
589
+ /**
590
+ * 布局模式,为custom
591
+ */
592
+ mode: string;
593
+ /**
594
+ * 布局结构体,采用customLayout
595
+ */
596
+ layout: CustomLayout;
597
+ /**
598
+ * 个人布局订阅者信息
599
+ */
600
+ subscriber: {
601
+ userID?: number;
602
+ subjectID?: string;
603
+ };
604
+ }) => Promise<Result>;
605
+ /**
606
+ * 取消个人布局
607
+ * @since 1.0.0
608
+ */
609
+ personalLayoutDelete: (params: {
610
+ /**
611
+ * 个人布局订阅者参数
612
+ */
613
+ subscriber: {
614
+ userID?: number;
615
+ subjectID?: string;
616
+ };
617
+ }) => Promise<Result>;
618
+ /**
619
+ * 设置虚拟教室
620
+ * @since 1.0.0
621
+ */
622
+ virtualClassLayout: (params: {
623
+ /**
624
+ * 布局结构体,采用customLayout
625
+ */
626
+ layout: CustomLayout;
627
+ /**
628
+ * 布局个数,也是大屏终端屏幕个数
629
+ */
630
+ count: number;
631
+ /**
632
+ * 黑名单subjectID列表
633
+ */
634
+ blackList: string[];
635
+ }) => Promise<Result>;
636
+ /**
637
+ * 关闭虚拟教室
638
+ * @since 1.0.0
639
+ */
640
+ virtualClassClose: () => Promise<Result>;
641
+ /**
642
+ * 设置焦点视频
643
+ * @since 1.0.0
644
+ */
645
+ spotlight: (params: {
646
+ /**
647
+ * 操作类型 add/remove/replace/removeAll
648
+ */
649
+ action: string;
650
+ /**
651
+ * 被操作的用户,action不是removeAll则必选
652
+ */
653
+ userID?: number;
654
+ }) => Promise<Result>;
655
+ /**
656
+ * 大厅全部拒绝
657
+ * @since 1.0.0
658
+ */
659
+ lobbyRefuseAll: () => Promise<Result>;
660
+ /**
661
+ * 大厅全部准入
662
+ * @since 1.0.0
663
+ */
664
+ lobbyAdmitAll: () => Promise<Result>;
665
+ /**
666
+ * 发送弹幕
667
+ * @since 1.0.0
668
+ */
669
+ barrage: (params: Barrage) => Promise<Result>;
670
+ /**
671
+ * 关闭弹幕
672
+ * @since 1.0.0
673
+ */
674
+ deleteBarrage: () => Promise<Result>;
675
+ /**
676
+ * 获取操作记录
677
+ * @since 1.0.0
678
+ */
679
+ operationRecord: (params: {
680
+ /**
681
+ * 分页查询参数
682
+ */
683
+ skip: number;
684
+ /**
685
+ * 查询的数量
686
+ */
687
+ limit: number;
688
+ /**
689
+ * 排序的规则
690
+ */
691
+ orderbys?: {
692
+ /**
693
+ * 排序的字段
694
+ */
695
+ field: string;
696
+ /**
697
+ * 排序的类型,1:升序,-1:降序
698
+ */
699
+ order: number;
700
+ };
701
+ /**
702
+ * 搜索的key
703
+ */
704
+ searchKey?: string;
705
+ /**
706
+ * 查询role角色操作
707
+ */
708
+ role?: string;
709
+ /**
710
+ * 查询对应模块操作
711
+ */
712
+ opModule?: string;
713
+ /**
714
+ * 操作的结果,true:成功,false:失败
715
+ */
716
+ opResult?: boolean;
717
+ }) => Promise<Result>;
718
+ /**
719
+ * 获取分享信息
720
+ * @since 1.0.0
721
+ */
722
+ shareInfo: (params: {
723
+ /**
724
+ * 会议号码
725
+ */
726
+ meetingNum: string;
727
+ /**
728
+ * 需要预约成员信息带true
729
+ */
730
+ participant?: boolean;
731
+ }) => Promise<Result>;
732
+ /**
733
+ * 结束会议
734
+ * @since 1.0.0
735
+ */
736
+ end: () => Promise<Result>;
737
+ /**
738
+ * 结束准备模式
739
+ * @since 1.0.0
740
+ */
741
+ practiceSession: () => Promise<Result>;
742
+ /**
743
+ * 全部手放下
744
+ * @since 1.0.0
745
+ */
746
+ replyAllHandUp: () => Promise<Result>;
747
+ /**
748
+ * 全体解禁言
749
+ * @since 1.0.0
750
+ */
751
+ unmuteAll: () => Promise<Result>;
752
+ /**
753
+ * 全体禁言
754
+ * @since 1.0.0
755
+ */
756
+ muteAll: () => Promise<Result>;
757
+ /**
758
+ * 通知上报音频转储
759
+ * @since 1.0.0
760
+ */
761
+ audioDump: () => Promise<Result>;
762
+ /**
763
+ * 问答
764
+ * @since 1.0.0
765
+ */
766
+ /**
767
+ * 发送聊天信息
768
+ */
769
+ msg: (params: {
770
+ /**
771
+ * 终端生成消息唯一id,可用随机数
772
+ */
773
+ msgID: string;
774
+ /**
775
+ * 消息的类型:text/plain。(后续根据产品需求可拓展支持text/enriched)
776
+ */
777
+ contentType: string;
778
+ /**
779
+ * 消息内容
780
+ */
781
+ content: string;
782
+ /**
783
+ * 消息类型,可选:0(群聊)、1(私聊)、2(发给大厅)
784
+ */
785
+ msgType?: number;
786
+ /**
787
+ * 接收者的信息
788
+ */
789
+ receiver?: {
790
+ userID: number;
791
+ };
792
+ /**
793
+ * 时间戳,服务器填
794
+ */
795
+ timestamp?: number;
796
+ /**
797
+ * 发送者的信息,服务器填
798
+ */
799
+ sender?: {
800
+ userID?: number;
801
+ displayName?: string;
802
+ };
803
+ }) => Promise<Result>;
804
+ /**
805
+ * 查询聊天历史信息
806
+ */
807
+ historyMsg: (params: {
808
+ /**
809
+ * 最大只返回100条,limit>100 或 limit<1时,limit都取100
810
+ */
811
+ limit: number;
812
+ }) => Promise<Result>;
813
+ /**
814
+ * 通过会议号结束会议
815
+ */
816
+ endMeeting: (params: {
817
+ /**
818
+ * 会议号
819
+ */
820
+ meetingNum: string;
251
821
  }) => Promise<Result>;
252
822
  /**
253
823
  * 获取请求baseURL
@@ -276,9 +276,59 @@ export interface Data {
276
276
  /**
277
277
  * 主持人布局
278
278
  */
279
+ hostLayout?: {
280
+ /**
281
+ * 序列号
282
+ */
283
+ seq?: number;
284
+ /**
285
+ * 布局模式
286
+ */
287
+ mode?: 'basic' | 'custom';
288
+ /**
289
+ * 布局
290
+ */
291
+ layout?: BasicLayout | CustomLayout;
292
+ /**
293
+ * 自定义布局是否同时应用于与会者
294
+ */
295
+ applyToAttendee?: boolean;
296
+ };
279
297
  /**
280
298
  * 与会者布局
281
299
  */
300
+ attendeeLayout?: {
301
+ /**
302
+ * 序列号
303
+ */
304
+ seq?: number;
305
+ /**
306
+ * 布局模式
307
+ */
308
+ mode?: 'basic' | 'custom';
309
+ /**
310
+ * 布局
311
+ */
312
+ layout?: BasicLayout | CustomLayout;
313
+ /**
314
+ * 自定义布局是否同时应用于与会者
315
+ */
316
+ applyToAttendee?: boolean;
317
+ };
318
+ audienceLayout?: {
319
+ /**
320
+ * 序列号
321
+ */
322
+ seq?: number;
323
+ /**
324
+ * 布局模式
325
+ */
326
+ mode?: 'basic' | 'custom';
327
+ /**
328
+ * 布局
329
+ */
330
+ layout?: BasicLayout | CustomLayout;
331
+ };
282
332
  /**
283
333
  * 录制
284
334
  */
@@ -354,10 +404,6 @@ export interface Barrage {
354
404
  * 背景颜色,可选:红色(#F54849)、黄色(#FFA51E)、蓝色(#006CE6)、黑色(#1A1A1A)、透明(传空值)
355
405
  */
356
406
  backgroundColor?: string;
357
- /**
358
- * 字幕类型
359
- */
360
- type: string;
361
407
  }
362
408
  /**
363
409
  * 媒体状态
@@ -595,3 +641,47 @@ export interface UserState {
595
641
  */
596
642
  perm?: number;
597
643
  }
644
+ export interface BasicLayout {
645
+ /**
646
+ * 基础布局类型
647
+ */
648
+ type: 'speaker' | 'gallery' | 'pip' | 'single';
649
+ }
650
+ export interface CustomLayout {
651
+ /**
652
+ * 布局名称
653
+ */
654
+ name: string;
655
+ /**
656
+ * 布局类型
657
+ */
658
+ type: string;
659
+ /**
660
+ * 画面列表
661
+ */
662
+ pictures: {
663
+ /**
664
+ * 画面序号
665
+ */
666
+ index: number;
667
+ /**
668
+ * 视频源类型
669
+ */
670
+ subscribeType: 'speaker' | 'poll' | 'users';
671
+ /**
672
+ * 用户视频源列表
673
+ */
674
+ subscribeToUsers?: {
675
+ userID?: number;
676
+ subjectID?: number;
677
+ };
678
+ }[];
679
+ /**
680
+ * 轮询秒数
681
+ */
682
+ pollSeconds: number;
683
+ /**
684
+ * 最大轮询图数量,-1表示无上限,全屏轮询
685
+ */
686
+ pollCount: number;
687
+ }
@@ -1 +1 @@
1
- var e=function(){return(e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};function t(e,t,n,i){return new(n||(n=Promise))((function(a,s){function r(e){try{u(i.next(e))}catch(e){s(e)}}function o(e){try{u(i.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,o)}u((i=i.apply(e,t||[])).next())}))}function n(e,t){var n,i,a,s,r={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(a=2&s[0]?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,i=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!(a=r.trys,(a=a.length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){r.label=s[1];break}if(6===s[0]&&r.label<a[1]){r.label=a[1],a=s;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(s);break}a[2]&&r.ops.pop(),r.trys.pop();continue}s=t.call(e,r)}catch(e){s=[6,e],i=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}}var i,a,s,r,o,u,l=function(){function e(e){this.defaultHeaders={},this.baseURL=e.baseURL,this.beforeRequest=e.beforeRequest}return e.prototype.setDefaultHeader=function(e,t){e in this.defaultHeaders&&(""===t||null===t)?delete this.defaultHeaders[e]:this.defaultHeaders[e]=t},e.prototype.request=function(e){var t=e.url,n=void 0===t?"":t,i=e.timeout,a=void 0===i?6e4:i,s=e.headers,r=void 0===s?{}:s;return e.url=this.baseURL.replace(/\/+$/,"")+"/"+f(n.replace(/^\/+/,""),e.params),r=Object.assign(r,this.defaultHeaders),Object.keys(r).forEach((function(e){"Content-Type"!==e&&e.toUpperCase()==="Content-Type".toUpperCase()&&(r["Content-Type"]=r[e],delete r[e])})),p(e.data)&&(r&&!r["Content-Type"]&&(r["Content-Type"]="application/json;charset=utf-8"),e.data=JSON.stringify(e.data)),e.headers=r,e.timeout=a,this.beforeRequest&&this.beforeRequest(e),"undefined"!=typeof wx?d(e):c(e)},e.prototype.get=function(e,t){return this.request(Object.assign(t||{},{url:e,method:"GET"}))},e.prototype.post=function(e,t,n){return this.request(Object.assign(n||{},{url:e,method:"POST",data:t}))},e}(),c=function(e){return new Promise((function(t,n){var i=e.data,a=void 0===i?null:i,s=e.url,r=e.method,o=void 0===r?"GET":r,u=e.headers,l=e.cancelToken,c=new XMLHttpRequest;c.open(o.toUpperCase(),s,!0),c.timeout=e.timeout;var d="",m=function(){if(c){if(c.status>=200&&c.status<300)try{t(JSON.parse(c.responseText))}catch(e){n(new Error("E_JSON_PARSE"+c.responseText))}else n(new Error("Request failed with status code "+c.status));c=null}};"onloadend"in c?c.onloadend=m:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(m)},c.onabort=function(){c&&(n(new Error("Request aborted "+d)),c=null)},c.onerror=function(){n(new Error("Network Error")),c=null},c.ontimeout=function(){n(new Error("timeout of "+e.timeout+"ms exceeded")),c=null},"setRequestHeader"in c&&Object.keys(u).forEach((function(e){null===a&&"content-type"===e.toLowerCase()?delete u[e]:c.setRequestHeader(e,u[e])})),l&&l.promise.then((function(e){c&&(d=e,c.abort(),n(e),c=null)})),c.send(a)}))},d=function(e){return new Promise((function(t,n){var i=e.data,a=void 0===i?null:i,s=e.url,r=e.method,o=void 0===r?"GET":r,u=e.headers,l=e.cancelToken,c=wx.request({url:s,data:a,method:o.toUpperCase(),timeout:e.timeout,header:u,success:function(e){e.statusCode>=200&&e.statusCode<300?t(e.data):n(new Error("Request failed with status code "+e.statusCode))},fail:function(e){"request:fail abort"===e.errMsg&&l?n(l.reason):n(e)}});l&&l.promise.then((function(){c&&c.abort()}))}))},m=function(){function e(e){var t,n=this;this.promise=new Promise((function(e){t=e})),e((function(e){n.reason||(n.reason=e,t(n.reason))}))}return e.source=function(){var t,n=new e((function(e){t=e}));return{cancel:t,token:n}},e}(),h=Object.prototype.toString,p=function(e){if("[object Object]"!==h.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},v=function(e){return encodeURIComponent(e).replace(/%40/g,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},f=function(e,t){if(!t)return e;var n=[];Object.keys(t).forEach((function(e){var i,a=t[e];null!=a&&(Array.isArray(a)?(i=a,e+="[]"):i=[a],i.forEach((function(t){null!==t&&"object"==typeof t&&(t=JSON.stringify(t)),n.push(v(e)+"="+v(t))})))}));var i=n.join("&");if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e},g=function(){for(var e=[],t="0123456789abcdef",n=0;n<36;n++)e[n]=t.substr(Math.floor(16*Math.random()),1);return e[14]="4",e[19]=t.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-",e.join("").split("-").join("")},E=function(e){return null==e},b=g(),S=function(e,t){void 0===e&&(e=new Date);var n={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};for(var i in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+i+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?n[i]:("00"+n[i]).substr((""+n[i]).length)));return t},O=function(e,t){return e?(Object.entries(e).forEach((function(e){var n,i=[e[0],e[1]],a=i[0],s=i[1];if(null!==s)return"object"==typeof(n=s)&&null!==n?(t[a]||(t[a]={}),void(t[a]=O(s,t[a]))):void(t[a]=s)})),t):t},D=function(e){var t="/meeting-ctrl/api/v1/",n=new l({baseURL:e,beforeRequest:function(e){e.headers["X-Y-Request-Id"]=g()}}),i=m.source(),a="",s="",r="",o="";return{cancelToken:function(e){i.cancel(e),i=m.source()},credential:function(e){return n.get(t+"credential",{params:e})},join:function(e){return n.post(t+"join?meetingNum="+e.meetingNum+"&credential="+e.credential,e,{headers:{"X-Y-Endpoint-Type":e.endpointType,"X-Y-Endpoint-Id":a}})},updateUserState:function(e){return n.post(t+"/meetings/"+s+"/updateUserState",e)},inbox:function(e){return n.post("/ypush/api/v1/meeting-control/inbox",e)},polling:function(e){return n.post("/ypush/api/v1/meeting-control/polling",e,{cancelToken:i.token})},subscribe:function(e){return n.post(t+"/meetings/"+s+"/subscribe",e)},keepalive:function(e){return n.post(t+"/meetings/"+s+"/users/"+e.userID+"/keepalive",{},{cancelToken:i.token})},leave:function(e){return n.post(t+"/meetings/"+s+"/leave",e)},end:function(){return n.post(t+"/meetings/"+s+"/end")},audio:function(e){return n.post(t+"/meetings/"+s+"/users/"+e.userID+"/audio",e)},video:function(e){return n.post(t+"/meetings/"+s+"/users/"+e.userID+"/video",e)},share:function(e){return n.post(t+"/meetings/"+s+"/users/"+e.userID+"/share",e)},handUp:function(e){return n.post(t+"/meetings/"+s+"/users/"+e.userID+"/handUp",e)},get baseURL(){return n.baseURL},setBaseURL:function(e){n.baseURL=e},get sessionID(){return a},setSessionID:function(e){void 0===e&&(e=""),a=e,n.setDefaultHeader("X-Y-Session-Id",a)},get meetingID(){return s},setMeetingID:function(e){void 0===e&&(e=""),s=e},get location(){return o},setLocation:function(e){void 0===e&&(e=""),o=e,n.setDefaultHeader("X-Y-Location",o)},get ctrlID(){return r},setCtrlID:function(e){void 0===e&&(e=""),r=e,n.setDefaultHeader("X-Y-Ctrl-Id",r)}}},C=function(){function e(){this.events=new Map}return e.prototype.emit=function(e,t){var n=this.events.get(e);n&&n.slice().map((function(e){e(t)}))},e.prototype.off=function(e,t){var n=this.events.get(e);n&&(t?n.splice(n.indexOf(t)>>>0,1):this.events.set(e,[]))},e.prototype.on=function(e,t){var n=this.events.get(e);n?n.push(t):this.events.set(e,[t])},e}();!function(e){e.WEBAPP="webApp",e.WEBCTRL="webCtrl",e.WECHATMP="weChatMP",e.SUPERVISION="supervision"}(i||(i={})),function(e){e.HOST="host",e.COHOST="coHost",e.ATTENDEE="attendee",e.AUDIENCE="audience"}(a||(a={})),function(e){e.CONNECTION_STATE="CONNECTION_STATE",e.MEETING_CHANGE="MEETING_CHANGE",e.ME_CHANGE="ME_CHANGE",e.UPDATE_USER_STATE="UPDATE_USER_STATE"}(s||(s={})),function(e){e.CONNECTED="connected",e.SUBSCRIBED="subscribed",e.CLOSED="closed"}(r||(r={})),function(e){e.ROLECHANGE="roleChange",e.AUDIOCHANGE="audioChange",e.HANDUPCHANGE="handupChange",e.SETAUDIO="setAudio",e.VIDEOCHANGE="videoChange",e.SETVIDEO="setVideo",e.SHARECHANGE="shareChange",e.DISPLAYNAMECHANGE="displayNameChange",e.SPOTLIGHTVIDEOCHANGE="spotlightVideoChange",e.LOBBYCHANGE="lobbyChange",e.BARRAGECHANGE="barrageChange",e.LEAVE="leave"}(o||(o={})),function(e){e.MEETINGINFO="meetingInfo",e.MEETINGSTATE="meetingState",e.MEETINGSETTING="meetingSetting",e.MEETINGVIEW="meetingView",e.MEETINGBARRAGE="meetingBarrage",e.RECORDING="recording",e.LIVESTREAM="liveStream",e.INTERACTIVEUSERS="interactiveUsers",e.BROADCASTUSERS="broadcastUsers",e.LOBBYUSERS="lobbyUsers",e.VIRTUALUSERS="virtualUsers",e.CHATMSG="chatMsg",e.INVITESTATE="inviteState",e.CALLRECORD="callRecord",e.ME="me"}(u||(u={}));var I=function(){function l(e){this.mtgData={me:{isHandUp:!1,isUpdatedUserState:!1}},this.pollingStatus={attempts:0,errorTimes:0,errors:[]},this.keepaliveStatus={attempts:0,errorTimes:0,errors:[]},this.connectionState=r.CLOSED,this.isClosedStateEmited=!1,this.barrageTimer=null,this.ctrl=D(e.baseURL),this.emitter=new C}return l.createInstance=function(e){return null===this.instance||void 0===this.instance?this.instance=new l(e):(this.instance.emitter&&(this.instance.emitter=new C),this.instance.ctrl&&(this.instance.ctrl=D(e.baseURL))),l.instance},l.prototype.join=function(i){return t(this,void 0,void 0,(function(){var t,a,r,u,l,c,d,m,h,p,v,f,g,E=this;return n(this,(function(n){switch(n.label){case 0:return this.isClosedStateEmited=!1,[4,this.ctrl.credential({meetingNum:i.meetingNum,pwd:i.pwd,url:i.url}).catch((function(e){E.emitClosedState({cause:"credential",data:e.message})}))];case 1:return(t=n.sent())&&t.data&&t.data.credential?(this.ctrl.setLocation(t.data.location),delete i.pwd,delete i.url,[4,this.ctrl.join(e(e({},i),{credential:t.data.credential})).catch((function(e){E.emitClosedState({cause:"join",data:e.message})}))]):[3,3];case 2:return(a=n.sent())&&a.data?(r=a.data,u=r.meetingID,l=void 0===u?"":u,c=r.ctrlID,d=void 0===c?"":c,m=r.user,h=void 0===m?{}:m,p=r.mediaContent,v=void 0===p?{}:p,f=r.initialMediaState,g=void 0===f?{}:f,this.ctrl.setMeetingID(l),this.ctrl.setCtrlID(d),this.mtgData.me=e(e({},h),{mediaContent:v,initialMediaState:g}),this.mtgData.me.isInLobby?this.emitter.emit(s.ME_CHANGE,{event:o.LOBBYCHANGE,body:{newVal:!0,oldVal:null}}):this.emitter.emit(s.UPDATE_USER_STATE),[2,!0]):(this.emitClosedState({cause:"join",data:a}),[2,!1]);case 3:return this.emitClosedState({cause:"credential",data:t}),[2,!1];case 4:return[2]}}))}))},l.prototype.startPolling=function(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return[4,this.inbox()];case 1:return e=t.sent(),[4,this.subscribe()];case 2:return t.sent()&&(this.pollingStatus.running=!0,this.polling(e)),[2]}}))}))},l.prototype.stopPolling=function(){this.pollingStatus.running=!1,this.pollingStatus.timer&&clearTimeout(this.pollingStatus.timer),this.ctrl.cancelToken("cancel")},l.prototype.startKeepalive=function(){return t(this,void 0,void 0,(function(){return n(this,(function(e){return this.keepaliveStatus.running=!0,this.keepalive(),[2]}))}))},l.prototype.stopKeepalive=function(){this.keepaliveStatus.running=!1,this.keepaliveStatus.timer&&clearTimeout(this.keepaliveStatus.timer),this.ctrl.cancelToken("cancel")},l.prototype.clean=function(){this.ctrl.setCtrlID(""),this.ctrl.setLocation(""),this.ctrl.setMeetingID(""),this.ctrl.setSessionID(""),this.mtgData={me:{isHandUp:!1,isUpdatedUserState:!1}}},l.prototype.handleBarrage=function(e,t){var n=this;if(void 0===t&&(t=!1),e||t){var i=JSON.parse(JSON.stringify(this.mtgData.me.barrage||{})),r=this.mtgData.me.role,u=void 0===r?"":r,l=this.mtgData.meetingBarrage;e||(e=l),u===a.COHOST&&(u=a.HOST),(null==e?void 0:e.receiver[u])?this.mtgData.me.barrage={position:e.position,contentType:e.contentType,content:e.content}:delete this.mtgData.me.barrage;var c={newVal:this.mtgData.me.barrage||null,oldVal:"{}"===JSON.stringify(i)?null:i};(c.newVal||c.oldVal)&&this.emitter.emit(s.ME_CHANGE,{event:o.BARRAGECHANGE,body:c})}if(e&&this.barrageTimer&&(clearTimeout(this.barrageTimer),this.barrageTimer=null),e&&-1!==e.duration){var d=JSON.parse(JSON.stringify(this.mtgData.me.barrage||{}));this.barrageTimer=setTimeout((function(){delete n.mtgData.me.barrage,n.emitter.emit(s.ME_CHANGE,{event:o.BARRAGECHANGE,body:{newVal:null,oldVal:"{}"===JSON.stringify(d)?null:d}})}),1e3*e.duration)}},l.prototype.emitClosedState=function(e){this.isClosedStateEmited||(this.connectionState=r.CLOSED,this.emitter.emit(s.CONNECTION_STATE,{state:r.CLOSED,reason:e}),this.isClosedStateEmited=!0,this.clean())},l.prototype.subscribe=function(){return t(this,void 0,void 0,(function(){var e,t,i=this;return n(this,(function(n){switch(n.label){case 0:return e=this.getTopics(this.mtgData.me),[4,this.ctrl.subscribe({topics:e}).catch((function(e){i.emitClosedState({cause:"subscribe",data:e.message})}))];case 1:return(t=n.sent())&&t.data?(t.data.eventMsgs.forEach((function(e){i.mtgData[e.event]=e.body,e.event.indexOf("Users")>-1&&e.body.users.forEach((function(e){e.userID===i.mtgData.me.userID&&(delete e.audio,delete e.video,delete e.share,O(e,i.mtgData.me))})),e.event===u.MEETINGBARRAGE&&i.handleBarrage(e.body)})),this.mtgData.me.reSub?delete this.mtgData.me.reSub:(this.connectionState=r.SUBSCRIBED,this.emitter.emit(s.CONNECTION_STATE,{state:r.SUBSCRIBED})),[2,!0]):(this.emitClosedState({cause:"subscribe",data:t}),[2,!1])}}))}))},l.prototype.inbox=function(){return t(this,void 0,void 0,(function(){var e,t,i;return n(this,(function(n){switch(n.label){case 0:return e=this.getTopics(this.mtgData.me),[4,this.ctrl.inbox({basic:{tenantId:100,clientId:this.ctrl.sessionID,meetingId:this.ctrl.meetingID},inboxes:e})];case 1:return(t=n.sent())?(i=[],t.data&&Object.keys(t.data).forEach((function(e){i.push({name:e,seqId:t.data[e].maxSeqId,limit:200})})),[2,i]):[2,[]]}}))}))},l.prototype.polling=function(e){return t(this,void 0,void 0,(function(){var i,u,l=this;return n(this,(function(c){switch(c.label){case 0:return i=function(){return t(l,void 0,void 0,(function(){var i,r,u,l,c,d=this;return n(this,(function(m){switch(m.label){case 0:return this.pollingStatus.lastReqTime=(new Date).valueOf(),[4,this.ctrl.polling({basic:{tenantId:100,clientId:this.ctrl.sessionID,meetingId:this.ctrl.meetingID},inboxes:e}).catch((function(e){d.pollingStatus.attempts++,d.pollingStatus.errorTimes++,d.pollingStatus.errors.push({msg:e.message,time:(new Date).valueOf()})}))];case 1:return(i=m.sent())&&i.data?(r=i.data,u=void 0===r?{}:r,l=function(e){return t(d,void 0,void 0,(function(){var t,i,r,u,l,c,d,m,h,p,v,f,g,b,S,D,C,I,N,T,y,A,U,H,R,w;return n(this,(function(n){switch(n.label){case 0:return e.userID!==this.mtgData.me.userID?[3,6]:(t=JSON.parse(JSON.stringify(this.mtgData.me)),e.role&&e.role!==t.role?(i=t.role,e.role!==a.AUDIENCE&&t.role!==a.AUDIENCE?[3,2]:(this.mtgData.me.role=e.role,this.mtgData.me.reSub=!0,this.stopPolling(),[4,this.startPolling()])):[3,3]);case 1:n.sent(),this.mtgData.me.isUpdatedUserState=!1,this.emitter.emit(s.UPDATE_USER_STATE),n.label=2;case 2:e.role===a.AUDIENCE&&(e.audio={deviceOn:!0,sendOn:!1,recvOn:!1},e.video={deviceOn:!0,sendOn:!1,recvOn:!1},e.share={deviceOn:!0,sendOn:!1,recvOn:!1}),O(e,this.mtgData.me),this.emitter.emit(s.ME_CHANGE,{event:o.ROLECHANGE,body:{newVal:e.role,oldVal:i}}),this.handleBarrage(null,!0),n.label=3;case 3:return e.displayName&&e.displayName!==t.displayName&&(O(e,this.mtgData.me),this.emitter.emit(s.ME_CHANGE,{event:o.DISPLAYNAMECHANGE,body:{newVal:e.displayName,oldVal:t.displayName}})),e.audio&&(r=e.audio,c=r.deviceOn,d=r.sendOn,m=r.opBy,(!E(c)&&c!==(null===(h=t.audio)||void 0===h?void 0:h.deviceOn)||!E(d)&&d!==(null===(p=t.audio)||void 0===p?void 0:p.sendOn))&&(O(e,this.mtgData.me),this.emitter.emit(s.ME_CHANGE,{event:o.AUDIOCHANGE,body:{newVal:{deviceOn:E(c)?null===(v=this.mtgData.me.audio)||void 0===v?void 0:v.deviceOn:c,sendOn:E(d)?null===(f=this.mtgData.me.audio)||void 0===f?void 0:f.sendOn:d,opBy:m},oldVal:{deviceOn:null===(g=t.audio)||void 0===g?void 0:g.deviceOn,sendOn:null===(b=t.audio)||void 0===b?void 0:b.sendOn}}}))),"isHandUp"in e&&(O(e,this.mtgData.me),e.isHandUp!==t.isHandUp&&"isHandUp"in t&&this.emitter.emit(s.ME_CHANGE,{event:o.HANDUPCHANGE,body:{newVal:e.isHandUp,oldVal:t.isHandUp}})),e.video&&(u=e.video,c=u.deviceOn,d=u.sendOn,m=u.opBy,(!E(c)&&c!==(null===(S=t.video)||void 0===S?void 0:S.deviceOn)||!E(d)&&d!==(null===(D=t.video)||void 0===D?void 0:D.sendOn))&&(O(e,this.mtgData.me),this.emitter.emit(s.ME_CHANGE,{event:o.VIDEOCHANGE,body:{newVal:{deviceOn:E(c)?null===(C=this.mtgData.me.video)||void 0===C?void 0:C.deviceOn:c,sendOn:E(d)?null===(I=this.mtgData.me.video)||void 0===I?void 0:I.sendOn:d,opBy:m},oldVal:{deviceOn:null===(N=t.video)||void 0===N?void 0:N.deviceOn,sendOn:null===(T=t.video)||void 0===T?void 0:T.sendOn}}}))),e.share&&(l=e.share,c=l.deviceOn,d=l.sendOn,m=l.opBy,(!E(c)&&c!==(null===(y=t.share)||void 0===y?void 0:y.deviceOn)||!E(d)&&d!==(null===(A=t.share)||void 0===A?void 0:A.sendOn))&&(O(e,this.mtgData.me),this.emitter.emit(s.ME_CHANGE,{event:o.SHARECHANGE,body:{newVal:{deviceOn:E(c)?null===(U=this.mtgData.me.share)||void 0===U?void 0:U.deviceOn:c,sendOn:E(d)?null===(H=this.mtgData.me.share)||void 0===H?void 0:H.sendOn:d,opBy:m},oldVal:{deviceOn:null===(R=t.share)||void 0===R?void 0:R.deviceOn,sendOn:null===(w=t.share)||void 0===w?void 0:w.sendOn}}}))),"isSpotlightVideo"in e&&(e.isSpotlightVideo?(this.mtgData.me.isSpotlightVideo=!0,this.emitter.emit(s.ME_CHANGE,{event:o.SPOTLIGHTVIDEOCHANGE,body:{newVal:!0,oldVal:null}})):(this.mtgData.me.isSpotlightVideo=!1,this.emitter.emit(s.ME_CHANGE,{event:o.SPOTLIGHTVIDEOCHANGE,body:{newVal:!1,oldVal:!0}}))),!("isInLobby"in e)||E(t.isInLobby)?[3,5]:t.isInLobby===e.isInLobby?[3,5]:(this.mtgData.me.isInLobby=e.isInLobby,this.mtgData.me.reSub=!0,this.stopPolling(),[4,this.startPolling()]);case 4:n.sent(),O(e,this.mtgData.me),!1===e.isInLobby&&(this.mtgData.me.isUpdatedUserState=!1,this.emitter.emit(s.UPDATE_USER_STATE)),this.emitter.emit(s.ME_CHANGE,{event:o.LOBBYCHANGE,body:{newVal:e.isInLobby,oldVal:!e.isInLobby}}),n.label=5;case 5:"isLeave"in e&&(this.stopKeepalive(),this.stopPolling(),this.clean(),this.emitter.emit(s.ME_CHANGE,{event:o.LEAVE,body:e.resultInfo}),e={}),delete e.reSub,delete e.resultInfo,O(e,this.mtgData.me),n.label=6;case 6:return[2]}}))}))},c=function(t){var n=e.find((function(e){return e.name===t}));if(n){if(n.seqId=u[t].maxSeqId,!u[t].items)return;u[t].items.forEach((function(e){var t=JSON.parse(e.content),n=t.event,i=t.state,r=t.body;if("full"===i)d.mtgData[n]=r;else if("update"===i)if(d.mtgData[n]||(d.mtgData[n]=r),n.indexOf("Users")>-1)r.users&&r.users.forEach((function(e){var t=d.mtgData[n].users.findIndex((function(t){return t.userID===e.userID}));-1===t?d.mtgData[n].users.push(e):O(e,d.mtgData[n].users[t]),e.userID===d.mtgData.me.userID&&d.mtgData.me.role!==a.AUDIENCE&&l(e)}));else if("me"===n)r.users&&r.users.forEach((function(e){"userID"in e||(e.userID=d.mtgData.me.userID),l(e)}));else if("spotlightVideo"===n){(r.userIDs&&r.userIDs.findIndex((function(e){return e===d.mtgData.me.userID})))>-1?l({userID:d.mtgData.me.userID,isSpotlightVideo:!0}):d.mtgData.me.isSpotlightVideo&&l({userID:d.mtgData.me.userID,isSpotlightVideo:!1})}else"meetingState"===n&&"ended"===r.state?l({userID:d.mtgData.me.userID,resultInfo:r.resultInfo,isLeave:!0}):O(r,d.mtgData[n]);else"delete"===i?n.indexOf("Users")>-1?r.users&&r.users.forEach((function(e){if(d.mtgData[n]){var t=d.mtgData[n].users.findIndex((function(t){return t.userID===e.userID}));if(t>-1&&d.mtgData[n].users.splice(t,1),e.userID===d.mtgData.me.userID){var i=Object.keys(e).length;e.role?l(e):e.resultInfo&&2===i&&(e.isLeave=!0,l(e))}}})):"me"===n&&l({userID:d.mtgData.me.userID,isLeave:!0,resultInfo:r.users&&r.users[0]&&r.users[0].resultInfo}):("meetingBarrage"===n&&d.handleBarrage(r),"setUserAudio"===n?d.emitter.emit(s.ME_CHANGE,{event:o.SETAUDIO,body:r}):"setUserVideo"===n?d.emitter.emit(s.ME_CHANGE,{event:o.SETVIDEO,body:r}):d.mtgData[n]?O(r,d.mtgData[n]):d.mtgData[n]=r);d.emitter.emit(s.MEETING_CHANGE,{event:n,body:JSON.parse(JSON.stringify(r)),state:i,stime:null})}))}},Object.keys(u).forEach(c),this.pollingStatus.attempts=0,[2]):[2]}}))}))},this.pollingStatus.timer&&(clearTimeout(this.pollingStatus.timer),this.pollingStatus.timer=null),5!==this.pollingStatus.errorTimes?[3,2]:(this.stopKeepalive(),this.clean(),this.emitter.emit(s.ME_CHANGE,{event:o.LEAVE,body:"polling.error"}),this.connectionState=r.CLOSED,this.emitter.emit(s.CONNECTION_STATE,{state:r.CLOSED,reason:{cause:"polling",data:this.pollingStatus.errors}}),[4,this.ctrl.leave({resultInfo:{bizCode:901359}})]);case 1:return c.sent(),[2];case 2:return[4,i()];case 3:return c.sent(),this.pollingStatus.running?(u=this.pollingStatus.attempts?200*this.pollingStatus.attempts:0,this.pollingStatus.timer=setTimeout((function(){l.pollingStatus.running&&l.polling(e)}),u),[2]):[2]}}))}))},l.prototype.keepalive=function(){return t(this,void 0,void 0,(function(){var e,i=this;return n(this,(function(a){switch(a.label){case 0:return e=function(){return t(i,void 0,void 0,(function(){var e,t,i,a=this;return n(this,(function(n){switch(n.label){case 0:return this.keepaliveStatus.lastReqTime=(new Date).valueOf(),[4,this.ctrl.keepalive({userID:this.mtgData.me.userID||-1}).catch((function(e){a.keepaliveStatus.attempts++,a.keepaliveStatus.errorTimes++,a.keepaliveStatus.errors.push({msg:e.message,time:(new Date).valueOf()})}))];case 1:return(e=n.sent())&&e.data?(t=e.data,(i=(void 0===t?{}:t).interval||"")?(this.keepaliveStatus.interval=i,this.keepaliveStatus.attempts=0,[2]):(this.keepaliveStatus.attempts++,[2])):(this.keepaliveStatus.attempts++,[2])}}))}))},this.keepaliveStatus.timer&&(clearTimeout(this.keepaliveStatus.timer),this.keepaliveStatus.timer=null),5!==this.keepaliveStatus.errorTimes?[3,2]:(this.stopPolling(),this.clean(),this.emitter.emit(s.ME_CHANGE,{event:o.LEAVE,body:"keepalive.error"}),this.connectionState=r.CLOSED,this.emitter.emit(s.CONNECTION_STATE,{state:r.CLOSED,reason:{cause:"polling",data:this.keepaliveStatus.errors}}),[4,this.ctrl.leave({resultInfo:{bizCode:901359}})]);case 1:return a.sent(),[2];case 2:return[4,e()];case 3:return a.sent(),this.keepaliveStatus.running?(this.keepaliveStatus.timer=setTimeout((function(){i.keepaliveStatus.running&&i.keepalive()}),1e3*(this.keepaliveStatus.interval||0)),[2]):[2]}}))}))},l.prototype.getTopics=function(e){var t=[];switch(e.endpointType){case i.WEBCTRL:t=["meeting","interactive","broadcast","lobby","hostAttendee","audience","advCtrl"];break;case i.WEBAPP:t=e.isInLobby?["lobbyMember"]:"audience"===e.role?["meeting","interactive","chat","audience"]:["meeting","interactive","broadcast","lobby","chat","hostAttendee"];break;case i.WECHATMP:t=e.isInLobby?["lobbyMember"]:"audience"===e.role?["meeting","interactive"]:["meeting","interactive","broadcast","lobby"];break;case i.SUPERVISION:t=["meeting","interactive","broadcast"]}return t},l}(),N=function(){return I.instance},T=function(){function e(e){!function(e){I.createInstance(e)}(e)}return Object.defineProperty(e.prototype,"ctrl",{get:function(){return N().ctrl},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return N().mtgData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectionState",{get:function(){return N().connectionState},enumerable:!1,configurable:!0}),e.prototype.on=function(e,t){return N().emitter.on(e,t)},e.prototype.off=function(e,t){return N().emitter.off(e,t)},e.prototype.getBaseURL=function(){return N().ctrl.baseURL},e.prototype.setBaseURL=function(e){N().ctrl.setBaseURL(e)},e.prototype.getJobStatus=function(){return{polling:N().pollingStatus,keepalive:N().keepaliveStatus}},e.prototype.join=function(e){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return(t=N()).ctrl.setSessionID((i=e.endpointType,a=e.meetingNum,""+(null==i?void 0:i.toLocaleUpperCase())+b+"_"+S(new Date,"MMddHHmmss")+"_"+a)),[4,t.join(e)];case 1:return n.sent()?(t.connectionState=r.CONNECTED,t.emitter.emit(s.CONNECTION_STATE,{state:r.CONNECTED,data:t.mtgData.me.mediaContent}),[4,Promise.all([t.startPolling(),t.startKeepalive()])]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}var i,a}))}))},e.prototype.updateUserState=function(e){return t(this,void 0,void 0,(function(){var t,i,r,u,l,c,d;return n(this,(function(n){switch(n.label){case 0:return t=N(),i={audio:{deviceOn:!0,sendOn:!0,recvOn:!1},video:{deviceOn:!0,sendOn:!0,recvOn:!1},share:{deviceOn:!0,sendOn:!1,recvOn:!1}},i=e?O(e,i):i,r=JSON.parse(JSON.stringify(i)),O(r,N().mtgData.me),u=t.mtgData.me,l=u.role,c=u.initialMediaState,d=void 0===c?{audio:{sendOn:!0},video:{sendOn:!0}}:c,i.audio.sendOn=i.audio.sendOn&&d.audio.sendOn,i.video.sendOn=i.video.sendOn&&d.video.sendOn,l===a.AUDIENCE&&(i.audio.sendOn=!1,i.video.sendOn=!1),t.mtgData.me.isUpdatedUserState=!0,[4,t.ctrl.updateUserState(i)];case 1:return n.sent(),l===a.AUDIENCE&&(O(i,N().mtgData.me),!1!==r.audio.sendOn&&t.emitter.emit(s.ME_CHANGE,{event:o.AUDIOCHANGE,body:{newVal:i.audio,oldVal:r.audio}}),!1!==r.video.sendOn&&t.emitter.emit(s.ME_CHANGE,{event:o.VIDEOCHANGE,body:{newVal:i.video,oldVal:r.video}})),[2]}}))}))},e.prototype.leave=function(e){return t(this,void 0,void 0,(function(){var t,i;return n(this,(function(n){switch(n.label){case 0:return t=N(),e||(e={bizCode:901359}),[4,t.ctrl.leave({resultInfo:e})];case 1:return i=n.sent().error,[4,Promise.all([t.stopPolling(),t.stopKeepalive()])];case 2:return n.sent(),t.clean(),t.connectionState=r.CLOSED,i?(t.emitter.emit(s.CONNECTION_STATE,{state:r.CLOSED,reason:{cause:"leave",data:i}}),[2,!1]):(t.emitter.emit(s.CONNECTION_STATE,{state:r.CLOSED}),[2,!0])}}))}))},e.prototype.end=function(){return t(this,void 0,void 0,(function(){var e,t;return n(this,(function(n){switch(n.label){case 0:return[4,(e=N()).ctrl.end()];case 1:return t=n.sent().error,[4,Promise.all([e.stopPolling(),e.stopKeepalive()])];case 2:return n.sent(),e.clean(),e.connectionState=r.CLOSED,t?(e.emitter.emit(s.CONNECTION_STATE,{state:r.CLOSED,reason:{cause:"end",data:t}}),[2,!1]):(e.emitter.emit(s.CONNECTION_STATE,{state:r.CLOSED}),[2,!0])}}))}))},e.ENDPOINT_TYPE=i,e.EVENT=s,e.CONNECTION_STATE=r,e.ROLE=a,e.ME_CHANGE=o,e.MEETING_CHANGE=u,e}();export default T;
1
+ var e=function(){return(e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};function t(e,t,n,i){return new(n||(n=Promise))((function(s,r){function a(e){try{u(i.next(e))}catch(e){r(e)}}function o(e){try{u(i.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,o)}u((i=i.apply(e,t||[])).next())}))}function n(e,t){var n,i,s,r,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return r={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function o(r){return function(o){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(s=2&r[0]?i.return:r[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,r[1])).done)return s;switch(i=0,s&&(r=[2&r[0],s.value]),r[0]){case 0:case 1:s=r;break;case 4:return a.label++,{value:r[1],done:!1};case 5:a.label++,i=r[1],r=[0];continue;case 7:r=a.ops.pop(),a.trys.pop();continue;default:if(!(s=a.trys,(s=s.length>0&&s[s.length-1])||6!==r[0]&&2!==r[0])){a=0;continue}if(3===r[0]&&(!s||r[1]>s[0]&&r[1]<s[3])){a.label=r[1];break}if(6===r[0]&&a.label<s[1]){a.label=s[1],s=r;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(r);break}s[2]&&a.ops.pop(),a.trys.pop();continue}r=t.call(e,a)}catch(e){r=[6,e],i=0}finally{n=s=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,o])}}}var i,s,r,a,o,u,l=function(){function e(e){this.defaultHeaders={},this.baseURL=e.baseURL,this.beforeRequest=e.beforeRequest}return e.prototype.setDefaultHeader=function(e,t){e in this.defaultHeaders&&(""===t||null===t)?delete this.defaultHeaders[e]:this.defaultHeaders[e]=t},e.prototype.request=function(e){var t=e.url,n=void 0===t?"":t,i=e.timeout,s=void 0===i?6e4:i,r=e.headers,a=void 0===r?{}:r;return e.url=this.baseURL.replace(/\/+$/,"")+"/"+g(n.replace(/^\/+/,""),e.params),a=Object.assign(a,this.defaultHeaders),Object.keys(a).forEach((function(e){"Content-Type"!==e&&e.toUpperCase()==="Content-Type".toUpperCase()&&(a["Content-Type"]=a[e],delete a[e])})),h(e.data)&&(a&&!a["Content-Type"]&&(a["Content-Type"]="application/json;charset=utf-8"),e.data=JSON.stringify(e.data)),e.headers=a,e.timeout=s,this.beforeRequest&&this.beforeRequest(e),"undefined"!=typeof wx?d(e):c(e)},e.prototype.get=function(e,t){return this.request(Object.assign(t||{},{url:e,method:"GET"}))},e.prototype.post=function(e,t,n){return this.request(Object.assign(n||{},{url:e,method:"POST",data:t}))},e}(),c=function(e){return new Promise((function(t,n){var i=e.data,s=void 0===i?null:i,r=e.url,a=e.method,o=void 0===a?"GET":a,u=e.headers,l=e.cancelToken,c=new XMLHttpRequest;c.open(o.toUpperCase(),r,!0),c.timeout=e.timeout;var d="",m=function(){if(c){if(c.status>=200&&c.status<300)try{t(JSON.parse(c.responseText))}catch(e){n(new Error("E_JSON_PARSE"+c.responseText))}else n(new Error("Request failed with status code "+c.status));c=null}};"onloadend"in c?c.onloadend=m:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(m)},c.onabort=function(){c&&(n(new Error("Request aborted "+d)),c=null)},c.onerror=function(){n(new Error("Network Error")),c=null},c.ontimeout=function(){n(new Error("timeout of "+e.timeout+"ms exceeded")),c=null},"setRequestHeader"in c&&Object.keys(u).forEach((function(e){null===s&&"content-type"===e.toLowerCase()?delete u[e]:c.setRequestHeader(e,u[e])})),l&&l.promise.then((function(e){c&&(d=e,c.abort(),n(e),c=null)})),c.send(s)}))},d=function(e){return new Promise((function(t,n){var i=e.data,s=void 0===i?null:i,r=e.url,a=e.method,o=void 0===a?"GET":a,u=e.headers,l=e.cancelToken,c=wx.request({url:r,data:s,method:o.toUpperCase(),timeout:e.timeout,header:u,success:function(e){e.statusCode>=200&&e.statusCode<300?t(e.data):n(new Error("Request failed with status code "+e.statusCode))},fail:function(e){"request:fail abort"===e.errMsg&&l?n(l.reason):n(e)}});l&&l.promise.then((function(){c&&c.abort()}))}))},m=function(){function e(e){var t,n=this;this.promise=new Promise((function(e){t=e})),e((function(e){n.reason||(n.reason=e,t(n.reason))}))}return e.source=function(){var t,n=new e((function(e){t=e}));return{cancel:t,token:n}},e}(),p=Object.prototype.toString,h=function(e){if("[object Object]"!==p.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},f=function(e){return encodeURIComponent(e).replace(/%40/g,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},g=function(e,t){if(!t)return e;var n=[];Object.keys(t).forEach((function(e){var i,s=t[e];null!=s&&(Array.isArray(s)?(i=s,e+="[]"):i=[s],i.forEach((function(t){null!==t&&"object"==typeof t&&(t=JSON.stringify(t)),n.push(f(e)+"="+f(t))})))}));var i=n.join("&");if(i){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e},v=function(){for(var e=[],t="0123456789abcdef",n=0;n<36;n++)e[n]=t.substr(Math.floor(16*Math.random()),1);return e[14]="4",e[19]=t.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-",e.join("").split("-").join("")},E=function(e){return null==e},b=v(),S=function(e,t){void 0===e&&(e=new Date);var n={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};for(var i in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+i+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?n[i]:("00"+n[i]).substr((""+n[i]).length)));return t},D=function(e,t){return e?(Object.entries(e).forEach((function(e){var n,i=[e[0],e[1]],s=i[0],r=i[1];if(null!==r)return"object"==typeof(n=r)&&null!==n?(t[s]||(t[s]={}),void(t[s]=D(r,t[s]))):void(t[s]=r)})),t):t},O=function(e){var t="/meeting-ctrl/api/v1",n=new l({baseURL:e,beforeRequest:function(e){e.headers["X-Y-Request-Id"]=v()}}),i=m.source(),s="",r="",a="",o="";return{cancelToken:function(e){i.cancel(e),i=m.source()},credential:function(e){return n.get(t+"/credential",{params:e})},join:function(e){return n.post(t+"/join?meetingNum="+e.meetingNum+"&credential="+e.credential,e,{headers:{"X-Y-Endpoint-Type":e.endpointType,"X-Y-Endpoint-Id":s}})},updateUserState:function(e){return n.post(t+"/meetings/"+r+"/updateUserState",e)},inbox:function(e){return n.post("/ypush/api/v1/meeting-control/inbox",e)},polling:function(e){return n.post("/ypush/api/v1/meeting-control/polling",e,{cancelToken:i.token})},subscribe:function(e){return n.post(t+"/meetings/"+r+"/subscribe",e)},keepalive:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/keepalive",{},{cancelToken:i.token})},leave:function(e){return n.post(t+"/meetings/"+r+"/leave",e)},end:function(){return n.post(t+"/meetings/"+r+"/end")},audio:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/audio",e)},video:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/video",e)},share:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/share",e)},handUp:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/handUp",e)},replyHandUp:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/replyHandUp",e)},shareInfo:function(e){return n.get(t+"/meetings/"+r+"/shareInfo",{params:e})},trying:function(e){return n.post(t+"/trying?meetingNum="+e.meetingNum+"&credential="+e.credential,e,{headers:{token:e.token,"X-Y-Endpoint-Type":e.endpointType,"X-Y-Endpoint-Id":s}})},rejectCall:function(e){return n.post(t+"/rejectCall?meetingNum="+e.meetingNum+"&credential="+e.credential,e,{headers:{token:e.token,"X-Y-Endpoint-Type":e.endpointType,"X-Y-Endpoint-Id":s}})},pauseAudio:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/pauseAudio")},resumeAudio:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/resumeAudio")},lobbyState:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/lobbyState",e)},displayName:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/displayName",e)},callStats:function(e){return n.get(t+"/meetings/"+r+"/users/"+e.userID+"/callStats")},user:function(e){return n.get(t+"/meetings/"+r+"/users/"+e.userID)},blockVideo:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/blockVideo")},unblockVideo:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/unblockVideo")},role:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/role",e)},remove:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/remove",e)},dtmf:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/dtmf",e)},fecc:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/fecc",e)},hostLayout:function(e){return n.post(t+"/meetings/"+r+"/view/hostLayout",e)},attendeeLayout:function(e){return n.post(t+"/meetings/"+r+"/view/attendeeLayout",e)},audienceLayout:function(e){return n.post(t+"/meetings/"+r+"/view/audienceLayout",e)},personalLayout:function(e){return n.post(t+"/meetings/"+r+"/view/personalLayout",e)},personalLayoutDelete:function(e){return n.post(t+"/meetings/"+r+"/view/personalLayout/delete",e)},virtualClassLayout:function(e){return n.post(t+"/meetings/"+r+"/view/virtualClass/layout",e)},virtualClassClose:function(){return n.post(t+"/meetings/"+r+"/view/virtualClass/close")},spotlight:function(e){return n.post(t+"/meetings/"+r+"/view/spotlight",e)},lobbyRefuseAll:function(){return n.post(t+"/meetings/"+r+"/lobby/refuseAll")},lobbyAdmitAll:function(){return n.post(t+"/meetings/"+r+"/lobby/admitAll")},barrage:function(e){return n.post(t+"/meetings/"+r+"/barrage",e)},deleteBarrage:function(){return n.post(t+"/meetings/"+r+"/deleteBarrage")},operationRecord:function(e){return n.post(t+"/meetings/"+r+"/operationRecord",e)},practiceSession:function(){return n.post(t+"/meetings/"+r+"/info/practiceSession")},replyAllHandUp:function(){return n.post(t+"/meetings/"+r+"/replyAllHandUp")},unmuteAll:function(){return n.post(t+"/meetings/"+r+"/unmuteAll")},muteAll:function(){return n.post(t+"/meetings/"+r+"/muteAll")},audioDump:function(){return n.post(t+"/meetings/"+r+"/audioDump")},endMeeting:function(e){return n.post(t+"/meetingNum/"+e.meetingNum+"/end")},msg:function(e){return n.post(t+"/meetings/"+r+"/chat/msg",e)},historyMsg:function(e){return n.post(t+"/meetings/"+r+"/chat/historyMsg",e)},callStatsReport:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/callStats/report",e)},get baseURL(){return n.baseURL},setBaseURL:function(e){n.baseURL=e},get sessionID(){return s},setSessionID:function(e){void 0===e&&(e=""),s=e,n.setDefaultHeader("X-Y-Session-Id",s)},get meetingID(){return r},setMeetingID:function(e){void 0===e&&(e=""),r=e},get location(){return o},setLocation:function(e){void 0===e&&(e=""),o=e,n.setDefaultHeader("X-Y-Location",o)},get ctrlID(){return a},setCtrlID:function(e){void 0===e&&(e=""),a=e,n.setDefaultHeader("X-Y-Ctrl-Id",a)}}},y=function(){function e(){this.events=new Map}return e.prototype.emit=function(e,t){var n=this.events.get(e);n&&n.slice().map((function(e){e(t)}))},e.prototype.off=function(e,t){var n=this.events.get(e);n&&(t?n.splice(n.indexOf(t)>>>0,1):this.events.set(e,[]))},e.prototype.on=function(e,t){var n=this.events.get(e);n?n.push(t):this.events.set(e,[t])},e}();!function(e){e.WEBAPP="webApp",e.WEBCTRL="webCtrl",e.WECHATMP="weChatMP",e.SUPERVISION="supervision"}(i||(i={})),function(e){e.HOST="host",e.COHOST="coHost",e.ATTENDEE="attendee",e.AUDIENCE="audience"}(s||(s={})),function(e){e.CONNECTION_STATE="CONNECTION_STATE",e.MEETING_CHANGE="MEETING_CHANGE",e.ME_CHANGE="ME_CHANGE",e.UPDATE_USER_STATE="UPDATE_USER_STATE"}(r||(r={})),function(e){e.CONNECTED="connected",e.SUBSCRIBED="subscribed",e.CLOSED="closed"}(a||(a={})),function(e){e.ROLECHANGE="roleChange",e.AUDIOCHANGE="audioChange",e.HANDUPCHANGE="handupChange",e.SETAUDIO="setAudio",e.VIDEOCHANGE="videoChange",e.SETVIDEO="setVideo",e.SHARECHANGE="shareChange",e.DISPLAYNAMECHANGE="displayNameChange",e.SPOTLIGHTVIDEOCHANGE="spotlightVideoChange",e.LOBBYCHANGE="lobbyChange",e.BARRAGECHANGE="barrageChange",e.LEAVE="leave"}(o||(o={})),function(e){e.MEETINGINFO="meetingInfo",e.MEETINGSTATE="meetingState",e.MEETINGSETTING="meetingSetting",e.MEETINGVIEW="meetingView",e.MEETINGBARRAGE="meetingBarrage",e.RECORDING="recording",e.LIVESTREAM="liveStream",e.INTERACTIVEUSERS="interactiveUsers",e.BROADCASTUSERS="broadcastUsers",e.LOBBYUSERS="lobbyUsers",e.VIRTUALUSERS="virtualUsers",e.CHATMSG="chatMsg",e.INVITESTATE="inviteState",e.CALLRECORD="callRecord",e.ME="me"}(u||(u={}));var I=function(){function l(e){this.mtgData={me:{isHandUp:!1,isUpdatedUserState:!1}},this.pollingStatus={attempts:0,errorTimes:0,errors:[]},this.keepaliveStatus={attempts:0,errorTimes:0,errors:[]},this.connectionState=a.CLOSED,this.isClosedStateEmited=!1,this.barrageTimer=null,this.ctrl=O(e.baseURL),this.emitter=new y}return l.createInstance=function(e){return null===this.instance||void 0===this.instance?this.instance=new l(e):(this.instance.emitter&&(this.instance.emitter=new y),this.instance.ctrl&&(this.instance.ctrl=O(e.baseURL))),l.instance},l.prototype.join=function(i){return t(this,void 0,void 0,(function(){var t,s,a,u,l,c,d,m,p,h,f,g,v,E=this;return n(this,(function(n){switch(n.label){case 0:return this.isClosedStateEmited=!1,[4,this.ctrl.credential({meetingNum:i.meetingNum,pwd:i.pwd,url:i.url}).catch((function(e){E.emitClosedState({cause:"credential",data:e.message})}))];case 1:return(t=n.sent())&&t.data&&t.data.credential?(this.ctrl.setLocation(t.data.location),delete i.pwd,delete i.url,[4,this.ctrl.join(e(e({},i),{credential:t.data.credential})).catch((function(e){E.emitClosedState({cause:"join",data:e.message})}))]):[3,3];case 2:return(s=n.sent())&&s.data?(a=s.data,u=a.meetingID,l=void 0===u?"":u,c=a.ctrlID,d=void 0===c?"":c,m=a.user,p=void 0===m?{}:m,h=a.mediaContent,f=void 0===h?{}:h,g=a.initialMediaState,v=void 0===g?{}:g,this.ctrl.setMeetingID(l),this.ctrl.setCtrlID(d),this.mtgData.me=e(e({},p),{mediaContent:f,initialMediaState:v}),this.mtgData.me.isInLobby?this.emitter.emit(r.ME_CHANGE,{event:o.LOBBYCHANGE,body:{newVal:!0,oldVal:null}}):this.emitter.emit(r.UPDATE_USER_STATE),[2,!0]):(this.emitClosedState({cause:"join",data:s}),[2,!1]);case 3:return this.emitClosedState({cause:"credential",data:t}),[2,!1];case 4:return[2]}}))}))},l.prototype.startPolling=function(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return this.pollingStatus.attempts=0,this.pollingStatus.errorTimes=0,this.pollingStatus.errors=[],[4,this.inbox()];case 1:return e=t.sent(),[4,this.subscribe()];case 2:return t.sent()&&(this.pollingStatus.running=!0,this.polling(e)),[2]}}))}))},l.prototype.stopPolling=function(){this.pollingStatus.running=!1,this.pollingStatus.timer&&clearTimeout(this.pollingStatus.timer),this.ctrl.cancelToken("cancel")},l.prototype.startKeepalive=function(){return t(this,void 0,void 0,(function(){return n(this,(function(e){return this.keepaliveStatus.attempts=0,this.keepaliveStatus.errorTimes=0,this.keepaliveStatus.errors=[],this.keepaliveStatus.running=!0,this.keepalive(),[2]}))}))},l.prototype.stopKeepalive=function(){this.keepaliveStatus.running=!1,this.keepaliveStatus.timer&&clearTimeout(this.keepaliveStatus.timer),this.ctrl.cancelToken("cancel")},l.prototype.clean=function(){this.ctrl.setCtrlID(""),this.ctrl.setLocation(""),this.ctrl.setMeetingID(""),this.ctrl.setSessionID(""),this.mtgData={me:{isHandUp:!1,isUpdatedUserState:!1}}},l.prototype.handleBarrage=function(e,t){var n=this;if(void 0===t&&(t=!1),e||t){var i=JSON.parse(JSON.stringify(this.mtgData.me.barrage||{})),a=this.mtgData.me.role,u=void 0===a?"":a,l=this.mtgData.meetingBarrage;e||(e=l),u===s.COHOST&&(u=s.HOST),(null==e?void 0:e.receiver[u])?this.mtgData.me.barrage={position:e.position,contentType:e.contentType,content:e.content}:delete this.mtgData.me.barrage;var c={newVal:this.mtgData.me.barrage||null,oldVal:"{}"===JSON.stringify(i)?null:i};(c.newVal||c.oldVal)&&this.emitter.emit(r.ME_CHANGE,{event:o.BARRAGECHANGE,body:c})}if(e&&this.barrageTimer&&(clearTimeout(this.barrageTimer),this.barrageTimer=null),e&&-1!==e.duration){var d=JSON.parse(JSON.stringify(this.mtgData.me.barrage||{}));this.barrageTimer=setTimeout((function(){delete n.mtgData.me.barrage,n.emitter.emit(r.ME_CHANGE,{event:o.BARRAGECHANGE,body:{newVal:null,oldVal:"{}"===JSON.stringify(d)?null:d}})}),1e3*e.duration)}},l.prototype.emitClosedState=function(e){this.isClosedStateEmited||(this.connectionState=a.CLOSED,this.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED,reason:e}),this.isClosedStateEmited=!0,this.clean())},l.prototype.subscribe=function(){return t(this,void 0,void 0,(function(){var e,t,i=this;return n(this,(function(n){switch(n.label){case 0:return e=this.getTopics(this.mtgData.me),[4,this.ctrl.subscribe({topics:e}).catch((function(e){i.emitClosedState({cause:"subscribe",data:e.message})}))];case 1:return(t=n.sent())&&t.data?(t.data.eventMsgs.forEach((function(e){i.mtgData[e.event]=e.body,e.event.indexOf("Users")>-1&&e.body.users.forEach((function(e){if(e.userID===i.mtgData.me.userID){var t=Object.assign({},e);delete t.audio,delete t.video,delete t.share,D(t,i.mtgData.me)}})),e.event===u.MEETINGBARRAGE&&i.handleBarrage(e.body)})),this.mtgData.me.reSub?delete this.mtgData.me.reSub:(this.connectionState=a.SUBSCRIBED,this.emitter.emit(r.CONNECTION_STATE,{state:a.SUBSCRIBED})),[2,!0]):(this.emitClosedState({cause:"subscribe",data:t}),[2,!1])}}))}))},l.prototype.inbox=function(){return t(this,void 0,void 0,(function(){var e,t,i;return n(this,(function(n){switch(n.label){case 0:return e=this.getTopics(this.mtgData.me),[4,this.ctrl.inbox({basic:{tenantId:100,clientId:this.ctrl.sessionID,meetingId:this.ctrl.meetingID},inboxes:e})];case 1:return(t=n.sent())?(i=[],t.data&&Object.keys(t.data).forEach((function(e){i.push({name:e,seqId:t.data[e].maxSeqId,limit:200})})),[2,i]):[2,[]]}}))}))},l.prototype.polling=function(e){return t(this,void 0,void 0,(function(){var i,u,l=this;return n(this,(function(c){switch(c.label){case 0:return i=function(){return t(l,void 0,void 0,(function(){var i,u,l,c,d,m=this;return n(this,(function(p){switch(p.label){case 0:return this.pollingStatus.lastReqTime=(new Date).valueOf(),[4,this.ctrl.polling({basic:{tenantId:100,clientId:this.ctrl.sessionID,meetingId:this.ctrl.meetingID},inboxes:e}).catch((function(e){m.pollingStatus.attempts++,m.pollingStatus.errorTimes++,m.pollingStatus.errors.push({msg:e.message,time:(new Date).valueOf()})}))];case 1:return(i=p.sent())&&i.data?(u=i.data,l=void 0===u?{}:u,c=function(e){return t(m,void 0,void 0,(function(){var t,i,u,l,c,d,m,p,h,f,g,v,b,S,O,y,I,C,N,T,A,U,H,L,w,R;return n(this,(function(n){switch(n.label){case 0:return e.userID!==this.mtgData.me.userID?[3,6]:(t=JSON.parse(JSON.stringify(this.mtgData.me)),e.role&&e.role!==t.role?(i=t.role,e.role!==s.AUDIENCE&&t.role!==s.AUDIENCE?[3,2]:(this.mtgData.me.role=e.role,this.mtgData.me.reSub=!0,this.stopPolling(),[4,this.startPolling()])):[3,3]);case 1:n.sent(),this.mtgData.me.isUpdatedUserState=!1,this.emitter.emit(r.UPDATE_USER_STATE),n.label=2;case 2:e.role===s.AUDIENCE&&(e.audio={deviceOn:!0,sendOn:!1,recvOn:!1},e.video={deviceOn:!0,sendOn:!1,recvOn:!1},e.share={deviceOn:!0,sendOn:!1,recvOn:!1}),D(e,this.mtgData.me),this.emitter.emit(r.ME_CHANGE,{event:o.ROLECHANGE,body:{newVal:e.role,oldVal:i}}),this.handleBarrage(null,!0),n.label=3;case 3:return e.displayName&&e.displayName!==t.displayName&&(D(e,this.mtgData.me),this.emitter.emit(r.ME_CHANGE,{event:o.DISPLAYNAMECHANGE,body:{newVal:e.displayName,oldVal:t.displayName}})),e.audio&&(u=e.audio,d=u.deviceOn,m=u.sendOn,p=u.opBy,(!E(d)&&d!==(null===(h=t.audio)||void 0===h?void 0:h.deviceOn)||!E(m)&&m!==(null===(f=t.audio)||void 0===f?void 0:f.sendOn))&&(D(e,this.mtgData.me),this.emitter.emit(r.ME_CHANGE,{event:o.AUDIOCHANGE,body:{newVal:{deviceOn:E(d)?null===(g=this.mtgData.me.audio)||void 0===g?void 0:g.deviceOn:d,sendOn:E(m)?null===(v=this.mtgData.me.audio)||void 0===v?void 0:v.sendOn:m,opBy:p},oldVal:{deviceOn:null===(b=t.audio)||void 0===b?void 0:b.deviceOn,sendOn:null===(S=t.audio)||void 0===S?void 0:S.sendOn}}}))),"isHandUp"in e&&(D(e,this.mtgData.me),e.isHandUp!==t.isHandUp&&"isHandUp"in t&&this.emitter.emit(r.ME_CHANGE,{event:o.HANDUPCHANGE,body:{newVal:e.isHandUp,oldVal:t.isHandUp}})),e.video&&(l=e.video,d=l.deviceOn,m=l.sendOn,p=l.opBy,(!E(d)&&d!==(null===(O=t.video)||void 0===O?void 0:O.deviceOn)||!E(m)&&m!==(null===(y=t.video)||void 0===y?void 0:y.sendOn))&&(D(e,this.mtgData.me),this.emitter.emit(r.ME_CHANGE,{event:o.VIDEOCHANGE,body:{newVal:{deviceOn:E(d)?null===(I=this.mtgData.me.video)||void 0===I?void 0:I.deviceOn:d,sendOn:E(m)?null===(C=this.mtgData.me.video)||void 0===C?void 0:C.sendOn:m,opBy:p},oldVal:{deviceOn:null===(N=t.video)||void 0===N?void 0:N.deviceOn,sendOn:null===(T=t.video)||void 0===T?void 0:T.sendOn}}}))),e.share&&(c=e.share,d=c.deviceOn,m=c.sendOn,p=c.opBy,(!E(d)&&d!==(null===(A=t.share)||void 0===A?void 0:A.deviceOn)||!E(m)&&m!==(null===(U=t.share)||void 0===U?void 0:U.sendOn))&&(D(e,this.mtgData.me),this.emitter.emit(r.ME_CHANGE,{event:o.SHARECHANGE,body:{newVal:{deviceOn:E(d)?null===(H=this.mtgData.me.share)||void 0===H?void 0:H.deviceOn:d,sendOn:E(m)?null===(L=this.mtgData.me.share)||void 0===L?void 0:L.sendOn:m,opBy:p},oldVal:{deviceOn:null===(w=t.share)||void 0===w?void 0:w.deviceOn,sendOn:null===(R=t.share)||void 0===R?void 0:R.sendOn}}}))),"isSpotlightVideo"in e&&(e.isSpotlightVideo?(this.mtgData.me.isSpotlightVideo=!0,this.emitter.emit(r.ME_CHANGE,{event:o.SPOTLIGHTVIDEOCHANGE,body:{newVal:!0,oldVal:null}})):(this.mtgData.me.isSpotlightVideo=!1,this.emitter.emit(r.ME_CHANGE,{event:o.SPOTLIGHTVIDEOCHANGE,body:{newVal:!1,oldVal:!0}}))),!("isInLobby"in e)||E(t.isInLobby)?[3,5]:t.isInLobby===e.isInLobby?[3,5]:(this.mtgData.me.isInLobby=e.isInLobby,this.mtgData.me.reSub=!0,this.stopPolling(),[4,this.startPolling()]);case 4:n.sent(),D(e,this.mtgData.me),!1===e.isInLobby&&(this.mtgData.me.isUpdatedUserState=!1,this.emitter.emit(r.UPDATE_USER_STATE)),this.emitter.emit(r.ME_CHANGE,{event:o.LOBBYCHANGE,body:{newVal:e.isInLobby,oldVal:!e.isInLobby}}),n.label=5;case 5:"isLeave"in e&&(this.stopKeepalive(),this.stopPolling(),this.clean(),this.connectionState=a.CLOSED,this.emitter.emit(r.ME_CHANGE,{event:o.LEAVE,body:e.resultInfo}),this.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED}),e={}),delete e.reSub,delete e.resultInfo,D(e,this.mtgData.me),n.label=6;case 6:return[2]}}))}))},d=function(t){var n=e.find((function(e){return e.name===t}));if(n){if(n.seqId=l[t].maxSeqId,!l[t].items)return;l[t].items.forEach((function(e){var t=JSON.parse(e.content),n=t.event,i=t.state,a=t.body;if("full"===i)m.mtgData[n]=a;else if("update"===i)if(m.mtgData[n]||(m.mtgData[n]=a),n.indexOf("Users")>-1)a.users&&a.users.forEach((function(e){var t=m.mtgData[n].users.findIndex((function(t){return t.userID===e.userID}));-1===t?m.mtgData[n].users.push(e):D(e,m.mtgData[n].users[t]),e.userID===m.mtgData.me.userID&&m.mtgData.me.role!==s.AUDIENCE&&c(e)}));else if("me"===n)a.users&&a.users.forEach((function(e){"userID"in e||(e.userID=m.mtgData.me.userID),c(e)}));else if("spotlightVideo"===n){(a.userIDs&&a.userIDs.findIndex((function(e){return e===m.mtgData.me.userID})))>-1?c({userID:m.mtgData.me.userID,isSpotlightVideo:!0}):m.mtgData.me.isSpotlightVideo&&c({userID:m.mtgData.me.userID,isSpotlightVideo:!1})}else"meetingState"===n&&"ended"===a.state?c({userID:m.mtgData.me.userID,resultInfo:a.resultInfo,isLeave:!0}):n.indexOf("Layout")>-1?m.mtgData[n]=a:D(a,m.mtgData[n]);else"delete"===i?n.indexOf("Users")>-1?a.users&&a.users.forEach((function(e){if(m.mtgData[n]){var t=m.mtgData[n].users.findIndex((function(t){return t.userID===e.userID}));if(t>-1&&m.mtgData[n].users.splice(t,1),e.userID===m.mtgData.me.userID){var i=Object.keys(e).length;e.role?c(e):e.resultInfo&&2===i&&(e.isLeave=!0,c(e))}}})):"me"===n&&c({userID:m.mtgData.me.userID,isLeave:!0,resultInfo:a.users&&a.users[0]&&a.users[0].resultInfo}):("meetingBarrage"===n&&m.handleBarrage(a),"setUserAudio"===n?m.emitter.emit(r.ME_CHANGE,{event:o.SETAUDIO,body:a}):"setUserVideo"===n?m.emitter.emit(r.ME_CHANGE,{event:o.SETVIDEO,body:a}):m.mtgData[n]?D(a,m.mtgData[n]):m.mtgData[n]=a);m.emitter.emit(r.MEETING_CHANGE,{event:n,body:JSON.parse(JSON.stringify(a)),state:i,stime:null})}))}},Object.keys(l).forEach(d),this.pollingStatus.attempts=0,[2]):[2]}}))}))},this.pollingStatus.timer&&(clearTimeout(this.pollingStatus.timer),this.pollingStatus.timer=null),5!==this.pollingStatus.errorTimes?[3,2]:(this.stopKeepalive(),this.clean(),this.emitter.emit(r.ME_CHANGE,{event:o.LEAVE,body:"polling.error"}),this.connectionState=a.CLOSED,this.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED,reason:{cause:"polling",data:this.pollingStatus.errors}}),[4,this.ctrl.leave({resultInfo:{bizCode:901359}})]);case 1:return c.sent(),[2];case 2:return[4,i()];case 3:return c.sent(),this.pollingStatus.running?(u=this.pollingStatus.attempts?200*this.pollingStatus.attempts:0,this.pollingStatus.timer=setTimeout((function(){l.pollingStatus.running&&l.polling(e)}),u),[2]):[2]}}))}))},l.prototype.keepalive=function(){return t(this,void 0,void 0,(function(){var e,i=this;return n(this,(function(s){switch(s.label){case 0:return e=function(){return t(i,void 0,void 0,(function(){var e,t,i,s=this;return n(this,(function(n){switch(n.label){case 0:return this.keepaliveStatus.lastReqTime=(new Date).valueOf(),[4,this.ctrl.keepalive({userID:this.mtgData.me.userID||-1}).catch((function(e){s.keepaliveStatus.attempts++,s.keepaliveStatus.errorTimes++,s.keepaliveStatus.errors.push({msg:e.message,time:(new Date).valueOf()})}))];case 1:return(e=n.sent())&&e.data?(t=e.data,(i=(void 0===t?{}:t).interval||"")?(this.keepaliveStatus.interval=i,this.keepaliveStatus.attempts=0,[2]):(this.keepaliveStatus.attempts++,[2])):(this.keepaliveStatus.attempts++,[2])}}))}))},this.keepaliveStatus.timer&&(clearTimeout(this.keepaliveStatus.timer),this.keepaliveStatus.timer=null),5!==this.keepaliveStatus.errorTimes?[3,2]:(this.stopPolling(),this.clean(),this.emitter.emit(r.ME_CHANGE,{event:o.LEAVE,body:"keepalive.error"}),this.connectionState=a.CLOSED,this.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED,reason:{cause:"polling",data:this.keepaliveStatus.errors}}),[4,this.ctrl.leave({resultInfo:{bizCode:901359}})]);case 1:return s.sent(),[2];case 2:return[4,e()];case 3:return s.sent(),this.keepaliveStatus.running?(this.keepaliveStatus.timer=setTimeout((function(){i.keepaliveStatus.running&&i.keepalive()}),1e3*(this.keepaliveStatus.interval||0)),[2]):[2]}}))}))},l.prototype.getTopics=function(e){var t=[];switch(e.endpointType){case i.WEBCTRL:t=["meeting","interactive","broadcast","lobby","hostAttendee","audience","advCtrl"];break;case i.WEBAPP:t=e.isInLobby?["lobbyMember"]:"audience"===e.role?["meeting","interactive","chat","audience"]:["meeting","interactive","broadcast","lobby","chat","hostAttendee"];break;case i.WECHATMP:t=e.isInLobby?["lobbyMember"]:"audience"===e.role?["meeting","interactive"]:["meeting","interactive","broadcast","lobby"];break;case i.SUPERVISION:t=["meeting","interactive","broadcast"]}return t},l}(),C=function(){return I.instance},N=function(){function e(e){!function(e){I.createInstance(e)}(e)}return Object.defineProperty(e.prototype,"ctrl",{get:function(){return C().ctrl},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return C().mtgData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectionState",{get:function(){return C().connectionState},enumerable:!1,configurable:!0}),e.prototype.on=function(e,t){return C().emitter.on(e,t)},e.prototype.off=function(e,t){return C().emitter.off(e,t)},e.prototype.getBaseURL=function(){return C().ctrl.baseURL},e.prototype.setBaseURL=function(e){C().ctrl.setBaseURL(e)},e.prototype.getJobStatus=function(){return{polling:C().pollingStatus,keepalive:C().keepaliveStatus}},e.prototype.join=function(e){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return(t=C()).ctrl.setSessionID((i=e.endpointType,s=e.meetingNum,""+(null==i?void 0:i.toLocaleUpperCase())+b+"_"+S(new Date,"MMddHHmmss")+"_"+s)),[4,t.join(e)];case 1:return n.sent()?(t.connectionState=a.CONNECTED,t.emitter.emit(r.CONNECTION_STATE,{state:a.CONNECTED,data:t.mtgData.me.mediaContent}),[4,Promise.all([t.startPolling(),t.startKeepalive()])]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}var i,s}))}))},e.prototype.updateUserState=function(e){return t(this,void 0,void 0,(function(){var t,i,a,u,l,c,d;return n(this,(function(n){switch(n.label){case 0:return t=C(),i={audio:{deviceOn:!0,sendOn:!0,recvOn:!1},video:{deviceOn:!0,sendOn:!0,recvOn:!1},share:{deviceOn:!0,sendOn:!1,recvOn:!1}},i=e?D(e,i):i,a=JSON.parse(JSON.stringify(i)),D(a,C().mtgData.me),u=t.mtgData.me,l=u.role,c=u.initialMediaState,d=void 0===c?{audio:{sendOn:!0},video:{sendOn:!0}}:c,i.audio.sendOn=i.audio.sendOn&&d.audio.sendOn,i.video.sendOn=i.video.sendOn&&d.video.sendOn,l===s.AUDIENCE&&(i.audio.sendOn=!1,i.video.sendOn=!1),t.mtgData.me.isUpdatedUserState=!0,[4,t.ctrl.updateUserState(i)];case 1:return n.sent(),l===s.AUDIENCE&&(D(i,C().mtgData.me),!1!==a.audio.sendOn&&t.emitter.emit(r.ME_CHANGE,{event:o.AUDIOCHANGE,body:{newVal:i.audio,oldVal:a.audio}}),!1!==a.video.sendOn&&t.emitter.emit(r.ME_CHANGE,{event:o.VIDEOCHANGE,body:{newVal:i.video,oldVal:a.video}})),[2]}}))}))},e.prototype.leave=function(e){return t(this,void 0,void 0,(function(){var t,i;return n(this,(function(n){switch(n.label){case 0:return t=C(),e||(e={bizCode:901359}),[4,t.ctrl.leave({resultInfo:e})];case 1:return i=n.sent().error,[4,Promise.all([t.stopPolling(),t.stopKeepalive()])];case 2:return n.sent(),t.clean(),t.connectionState=a.CLOSED,i?(t.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED,reason:{cause:"leave",data:i}}),[2,!1]):(t.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED}),[2,!0])}}))}))},e.prototype.end=function(){return t(this,void 0,void 0,(function(){var e,t;return n(this,(function(n){switch(n.label){case 0:return[4,(e=C()).ctrl.end()];case 1:return t=n.sent().error,[4,Promise.all([e.stopPolling(),e.stopKeepalive()])];case 2:return n.sent(),e.clean(),e.connectionState=a.CLOSED,t?(e.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED,reason:{cause:"end",data:t}}),[2,!1]):(e.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED}),[2,!0])}}))}))},e.ENDPOINT_TYPE=i,e.EVENT=r,e.CONNECTION_STATE=a,e.ROLE=s,e.ME_CHANGE=o,e.MEETING_CHANGE=u,e}();export default N;
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Meeting=t()}(this,(function(){"use strict";var e=function(){return(e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};function t(e,t,n,i){return new(n||(n=Promise))((function(s,a){function r(e){try{u(i.next(e))}catch(e){a(e)}}function o(e){try{u(i.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,o)}u((i=i.apply(e,t||[])).next())}))}function n(e,t){var n,i,s,a,r={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=2&a[0]?i.return:a[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,a[1])).done)return s;switch(i=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(!(s=r.trys,(s=s.length>0&&s[s.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){r.label=a[1];break}if(6===a[0]&&r.label<s[1]){r.label=s[1],s=a;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(a);break}s[2]&&r.ops.pop(),r.trys.pop();continue}a=t.call(e,r)}catch(e){a=[6,e],i=0}finally{n=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}var i,s,a,r,o,u,l=function(){function e(e){this.defaultHeaders={},this.baseURL=e.baseURL,this.beforeRequest=e.beforeRequest}return e.prototype.setDefaultHeader=function(e,t){e in this.defaultHeaders&&(""===t||null===t)?delete this.defaultHeaders[e]:this.defaultHeaders[e]=t},e.prototype.request=function(e){var t=e.url,n=void 0===t?"":t,i=e.timeout,s=void 0===i?6e4:i,a=e.headers,r=void 0===a?{}:a;return e.url=this.baseURL.replace(/\/+$/,"")+"/"+v(n.replace(/^\/+/,""),e.params),r=Object.assign(r,this.defaultHeaders),Object.keys(r).forEach((function(e){"Content-Type"!==e&&e.toUpperCase()==="Content-Type".toUpperCase()&&(r["Content-Type"]=r[e],delete r[e])})),p(e.data)&&(r&&!r["Content-Type"]&&(r["Content-Type"]="application/json;charset=utf-8"),e.data=JSON.stringify(e.data)),e.headers=r,e.timeout=s,this.beforeRequest&&this.beforeRequest(e),"undefined"!=typeof wx?d(e):c(e)},e.prototype.get=function(e,t){return this.request(Object.assign(t||{},{url:e,method:"GET"}))},e.prototype.post=function(e,t,n){return this.request(Object.assign(n||{},{url:e,method:"POST",data:t}))},e}(),c=function(e){return new Promise((function(t,n){var i=e.data,s=void 0===i?null:i,a=e.url,r=e.method,o=void 0===r?"GET":r,u=e.headers,l=e.cancelToken,c=new XMLHttpRequest;c.open(o.toUpperCase(),a,!0),c.timeout=e.timeout;var d="",m=function(){if(c){if(c.status>=200&&c.status<300)try{t(JSON.parse(c.responseText))}catch(e){n(new Error("E_JSON_PARSE"+c.responseText))}else n(new Error("Request failed with status code "+c.status));c=null}};"onloadend"in c?c.onloadend=m:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(m)},c.onabort=function(){c&&(n(new Error("Request aborted "+d)),c=null)},c.onerror=function(){n(new Error("Network Error")),c=null},c.ontimeout=function(){n(new Error("timeout of "+e.timeout+"ms exceeded")),c=null},"setRequestHeader"in c&&Object.keys(u).forEach((function(e){null===s&&"content-type"===e.toLowerCase()?delete u[e]:c.setRequestHeader(e,u[e])})),l&&l.promise.then((function(e){c&&(d=e,c.abort(),n(e),c=null)})),c.send(s)}))},d=function(e){return new Promise((function(t,n){var i=e.data,s=void 0===i?null:i,a=e.url,r=e.method,o=void 0===r?"GET":r,u=e.headers,l=e.cancelToken,c=wx.request({url:a,data:s,method:o.toUpperCase(),timeout:e.timeout,header:u,success:function(e){e.statusCode>=200&&e.statusCode<300?t(e.data):n(new Error("Request failed with status code "+e.statusCode))},fail:function(e){"request:fail abort"===e.errMsg&&l?n(l.reason):n(e)}});l&&l.promise.then((function(){c&&c.abort()}))}))},m=function(){function e(e){var t,n=this;this.promise=new Promise((function(e){t=e})),e((function(e){n.reason||(n.reason=e,t(n.reason))}))}return e.source=function(){var t,n=new e((function(e){t=e}));return{cancel:t,token:n}},e}(),h=Object.prototype.toString,p=function(e){if("[object Object]"!==h.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},f=function(e){return encodeURIComponent(e).replace(/%40/g,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},v=function(e,t){if(!t)return e;var n=[];Object.keys(t).forEach((function(e){var i,s=t[e];null!=s&&(Array.isArray(s)?(i=s,e+="[]"):i=[s],i.forEach((function(t){null!==t&&"object"==typeof t&&(t=JSON.stringify(t)),n.push(f(e)+"="+f(t))})))}));var i=n.join("&");if(i){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e},g=function(){for(var e=[],t="0123456789abcdef",n=0;n<36;n++)e[n]=t.substr(Math.floor(16*Math.random()),1);return e[14]="4",e[19]=t.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-",e.join("").split("-").join("")},E=function(e){return null==e},b=g(),S=function(e,t){void 0===e&&(e=new Date);var n={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};for(var i in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+i+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?n[i]:("00"+n[i]).substr((""+n[i]).length)));return t},O=function(e,t){return e?(Object.entries(e).forEach((function(e){var n,i=[e[0],e[1]],s=i[0],a=i[1];if(null!==a)return"object"==typeof(n=a)&&null!==n?(t[s]||(t[s]={}),void(t[s]=O(a,t[s]))):void(t[s]=a)})),t):t},D=function(e){var t="/meeting-ctrl/api/v1/",n=new l({baseURL:e,beforeRequest:function(e){e.headers["X-Y-Request-Id"]=g()}}),i=m.source(),s="",a="",r="",o="";return{cancelToken:function(e){i.cancel(e),i=m.source()},credential:function(e){return n.get(t+"credential",{params:e})},join:function(e){return n.post(t+"join?meetingNum="+e.meetingNum+"&credential="+e.credential,e,{headers:{"X-Y-Endpoint-Type":e.endpointType,"X-Y-Endpoint-Id":s}})},updateUserState:function(e){return n.post(t+"/meetings/"+a+"/updateUserState",e)},inbox:function(e){return n.post("/ypush/api/v1/meeting-control/inbox",e)},polling:function(e){return n.post("/ypush/api/v1/meeting-control/polling",e,{cancelToken:i.token})},subscribe:function(e){return n.post(t+"/meetings/"+a+"/subscribe",e)},keepalive:function(e){return n.post(t+"/meetings/"+a+"/users/"+e.userID+"/keepalive",{},{cancelToken:i.token})},leave:function(e){return n.post(t+"/meetings/"+a+"/leave",e)},end:function(){return n.post(t+"/meetings/"+a+"/end")},audio:function(e){return n.post(t+"/meetings/"+a+"/users/"+e.userID+"/audio",e)},video:function(e){return n.post(t+"/meetings/"+a+"/users/"+e.userID+"/video",e)},share:function(e){return n.post(t+"/meetings/"+a+"/users/"+e.userID+"/share",e)},handUp:function(e){return n.post(t+"/meetings/"+a+"/users/"+e.userID+"/handUp",e)},get baseURL(){return n.baseURL},setBaseURL:function(e){n.baseURL=e},get sessionID(){return s},setSessionID:function(e){void 0===e&&(e=""),s=e,n.setDefaultHeader("X-Y-Session-Id",s)},get meetingID(){return a},setMeetingID:function(e){void 0===e&&(e=""),a=e},get location(){return o},setLocation:function(e){void 0===e&&(e=""),o=e,n.setDefaultHeader("X-Y-Location",o)},get ctrlID(){return r},setCtrlID:function(e){void 0===e&&(e=""),r=e,n.setDefaultHeader("X-Y-Ctrl-Id",r)}}},C=function(){function e(){this.events=new Map}return e.prototype.emit=function(e,t){var n=this.events.get(e);n&&n.slice().map((function(e){e(t)}))},e.prototype.off=function(e,t){var n=this.events.get(e);n&&(t?n.splice(n.indexOf(t)>>>0,1):this.events.set(e,[]))},e.prototype.on=function(e,t){var n=this.events.get(e);n?n.push(t):this.events.set(e,[t])},e}();!function(e){e.WEBAPP="webApp",e.WEBCTRL="webCtrl",e.WECHATMP="weChatMP",e.SUPERVISION="supervision"}(i||(i={})),function(e){e.HOST="host",e.COHOST="coHost",e.ATTENDEE="attendee",e.AUDIENCE="audience"}(s||(s={})),function(e){e.CONNECTION_STATE="CONNECTION_STATE",e.MEETING_CHANGE="MEETING_CHANGE",e.ME_CHANGE="ME_CHANGE",e.UPDATE_USER_STATE="UPDATE_USER_STATE"}(a||(a={})),function(e){e.CONNECTED="connected",e.SUBSCRIBED="subscribed",e.CLOSED="closed"}(r||(r={})),function(e){e.ROLECHANGE="roleChange",e.AUDIOCHANGE="audioChange",e.HANDUPCHANGE="handupChange",e.SETAUDIO="setAudio",e.VIDEOCHANGE="videoChange",e.SETVIDEO="setVideo",e.SHARECHANGE="shareChange",e.DISPLAYNAMECHANGE="displayNameChange",e.SPOTLIGHTVIDEOCHANGE="spotlightVideoChange",e.LOBBYCHANGE="lobbyChange",e.BARRAGECHANGE="barrageChange",e.LEAVE="leave"}(o||(o={})),function(e){e.MEETINGINFO="meetingInfo",e.MEETINGSTATE="meetingState",e.MEETINGSETTING="meetingSetting",e.MEETINGVIEW="meetingView",e.MEETINGBARRAGE="meetingBarrage",e.RECORDING="recording",e.LIVESTREAM="liveStream",e.INTERACTIVEUSERS="interactiveUsers",e.BROADCASTUSERS="broadcastUsers",e.LOBBYUSERS="lobbyUsers",e.VIRTUALUSERS="virtualUsers",e.CHATMSG="chatMsg",e.INVITESTATE="inviteState",e.CALLRECORD="callRecord",e.ME="me"}(u||(u={}));var I=function(){function l(e){this.mtgData={me:{isHandUp:!1,isUpdatedUserState:!1}},this.pollingStatus={attempts:0,errorTimes:0,errors:[]},this.keepaliveStatus={attempts:0,errorTimes:0,errors:[]},this.connectionState=r.CLOSED,this.isClosedStateEmited=!1,this.barrageTimer=null,this.ctrl=D(e.baseURL),this.emitter=new C}return l.createInstance=function(e){return null===this.instance||void 0===this.instance?this.instance=new l(e):(this.instance.emitter&&(this.instance.emitter=new C),this.instance.ctrl&&(this.instance.ctrl=D(e.baseURL))),l.instance},l.prototype.join=function(i){return t(this,void 0,void 0,(function(){var t,s,r,u,l,c,d,m,h,p,f,v,g,E=this;return n(this,(function(n){switch(n.label){case 0:return this.isClosedStateEmited=!1,[4,this.ctrl.credential({meetingNum:i.meetingNum,pwd:i.pwd,url:i.url}).catch((function(e){E.emitClosedState({cause:"credential",data:e.message})}))];case 1:return(t=n.sent())&&t.data&&t.data.credential?(this.ctrl.setLocation(t.data.location),delete i.pwd,delete i.url,[4,this.ctrl.join(e(e({},i),{credential:t.data.credential})).catch((function(e){E.emitClosedState({cause:"join",data:e.message})}))]):[3,3];case 2:return(s=n.sent())&&s.data?(r=s.data,u=r.meetingID,l=void 0===u?"":u,c=r.ctrlID,d=void 0===c?"":c,m=r.user,h=void 0===m?{}:m,p=r.mediaContent,f=void 0===p?{}:p,v=r.initialMediaState,g=void 0===v?{}:v,this.ctrl.setMeetingID(l),this.ctrl.setCtrlID(d),this.mtgData.me=e(e({},h),{mediaContent:f,initialMediaState:g}),this.mtgData.me.isInLobby?this.emitter.emit(a.ME_CHANGE,{event:o.LOBBYCHANGE,body:{newVal:!0,oldVal:null}}):this.emitter.emit(a.UPDATE_USER_STATE),[2,!0]):(this.emitClosedState({cause:"join",data:s}),[2,!1]);case 3:return this.emitClosedState({cause:"credential",data:t}),[2,!1];case 4:return[2]}}))}))},l.prototype.startPolling=function(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return[4,this.inbox()];case 1:return e=t.sent(),[4,this.subscribe()];case 2:return t.sent()&&(this.pollingStatus.running=!0,this.polling(e)),[2]}}))}))},l.prototype.stopPolling=function(){this.pollingStatus.running=!1,this.pollingStatus.timer&&clearTimeout(this.pollingStatus.timer),this.ctrl.cancelToken("cancel")},l.prototype.startKeepalive=function(){return t(this,void 0,void 0,(function(){return n(this,(function(e){return this.keepaliveStatus.running=!0,this.keepalive(),[2]}))}))},l.prototype.stopKeepalive=function(){this.keepaliveStatus.running=!1,this.keepaliveStatus.timer&&clearTimeout(this.keepaliveStatus.timer),this.ctrl.cancelToken("cancel")},l.prototype.clean=function(){this.ctrl.setCtrlID(""),this.ctrl.setLocation(""),this.ctrl.setMeetingID(""),this.ctrl.setSessionID(""),this.mtgData={me:{isHandUp:!1,isUpdatedUserState:!1}}},l.prototype.handleBarrage=function(e,t){var n=this;if(void 0===t&&(t=!1),e||t){var i=JSON.parse(JSON.stringify(this.mtgData.me.barrage||{})),r=this.mtgData.me.role,u=void 0===r?"":r,l=this.mtgData.meetingBarrage;e||(e=l),u===s.COHOST&&(u=s.HOST),(null==e?void 0:e.receiver[u])?this.mtgData.me.barrage={position:e.position,contentType:e.contentType,content:e.content}:delete this.mtgData.me.barrage;var c={newVal:this.mtgData.me.barrage||null,oldVal:"{}"===JSON.stringify(i)?null:i};(c.newVal||c.oldVal)&&this.emitter.emit(a.ME_CHANGE,{event:o.BARRAGECHANGE,body:c})}if(e&&this.barrageTimer&&(clearTimeout(this.barrageTimer),this.barrageTimer=null),e&&-1!==e.duration){var d=JSON.parse(JSON.stringify(this.mtgData.me.barrage||{}));this.barrageTimer=setTimeout((function(){delete n.mtgData.me.barrage,n.emitter.emit(a.ME_CHANGE,{event:o.BARRAGECHANGE,body:{newVal:null,oldVal:"{}"===JSON.stringify(d)?null:d}})}),1e3*e.duration)}},l.prototype.emitClosedState=function(e){this.isClosedStateEmited||(this.connectionState=r.CLOSED,this.emitter.emit(a.CONNECTION_STATE,{state:r.CLOSED,reason:e}),this.isClosedStateEmited=!0,this.clean())},l.prototype.subscribe=function(){return t(this,void 0,void 0,(function(){var e,t,i=this;return n(this,(function(n){switch(n.label){case 0:return e=this.getTopics(this.mtgData.me),[4,this.ctrl.subscribe({topics:e}).catch((function(e){i.emitClosedState({cause:"subscribe",data:e.message})}))];case 1:return(t=n.sent())&&t.data?(t.data.eventMsgs.forEach((function(e){i.mtgData[e.event]=e.body,e.event.indexOf("Users")>-1&&e.body.users.forEach((function(e){e.userID===i.mtgData.me.userID&&(delete e.audio,delete e.video,delete e.share,O(e,i.mtgData.me))})),e.event===u.MEETINGBARRAGE&&i.handleBarrage(e.body)})),this.mtgData.me.reSub?delete this.mtgData.me.reSub:(this.connectionState=r.SUBSCRIBED,this.emitter.emit(a.CONNECTION_STATE,{state:r.SUBSCRIBED})),[2,!0]):(this.emitClosedState({cause:"subscribe",data:t}),[2,!1])}}))}))},l.prototype.inbox=function(){return t(this,void 0,void 0,(function(){var e,t,i;return n(this,(function(n){switch(n.label){case 0:return e=this.getTopics(this.mtgData.me),[4,this.ctrl.inbox({basic:{tenantId:100,clientId:this.ctrl.sessionID,meetingId:this.ctrl.meetingID},inboxes:e})];case 1:return(t=n.sent())?(i=[],t.data&&Object.keys(t.data).forEach((function(e){i.push({name:e,seqId:t.data[e].maxSeqId,limit:200})})),[2,i]):[2,[]]}}))}))},l.prototype.polling=function(e){return t(this,void 0,void 0,(function(){var i,u,l=this;return n(this,(function(c){switch(c.label){case 0:return i=function(){return t(l,void 0,void 0,(function(){var i,r,u,l,c,d=this;return n(this,(function(m){switch(m.label){case 0:return this.pollingStatus.lastReqTime=(new Date).valueOf(),[4,this.ctrl.polling({basic:{tenantId:100,clientId:this.ctrl.sessionID,meetingId:this.ctrl.meetingID},inboxes:e}).catch((function(e){d.pollingStatus.attempts++,d.pollingStatus.errorTimes++,d.pollingStatus.errors.push({msg:e.message,time:(new Date).valueOf()})}))];case 1:return(i=m.sent())&&i.data?(r=i.data,u=void 0===r?{}:r,l=function(e){return t(d,void 0,void 0,(function(){var t,i,r,u,l,c,d,m,h,p,f,v,g,b,S,D,C,I,y,N,T,A,U,H,R,w;return n(this,(function(n){switch(n.label){case 0:return e.userID!==this.mtgData.me.userID?[3,6]:(t=JSON.parse(JSON.stringify(this.mtgData.me)),e.role&&e.role!==t.role?(i=t.role,e.role!==s.AUDIENCE&&t.role!==s.AUDIENCE?[3,2]:(this.mtgData.me.role=e.role,this.mtgData.me.reSub=!0,this.stopPolling(),[4,this.startPolling()])):[3,3]);case 1:n.sent(),this.mtgData.me.isUpdatedUserState=!1,this.emitter.emit(a.UPDATE_USER_STATE),n.label=2;case 2:e.role===s.AUDIENCE&&(e.audio={deviceOn:!0,sendOn:!1,recvOn:!1},e.video={deviceOn:!0,sendOn:!1,recvOn:!1},e.share={deviceOn:!0,sendOn:!1,recvOn:!1}),O(e,this.mtgData.me),this.emitter.emit(a.ME_CHANGE,{event:o.ROLECHANGE,body:{newVal:e.role,oldVal:i}}),this.handleBarrage(null,!0),n.label=3;case 3:return e.displayName&&e.displayName!==t.displayName&&(O(e,this.mtgData.me),this.emitter.emit(a.ME_CHANGE,{event:o.DISPLAYNAMECHANGE,body:{newVal:e.displayName,oldVal:t.displayName}})),e.audio&&(r=e.audio,c=r.deviceOn,d=r.sendOn,m=r.opBy,(!E(c)&&c!==(null===(h=t.audio)||void 0===h?void 0:h.deviceOn)||!E(d)&&d!==(null===(p=t.audio)||void 0===p?void 0:p.sendOn))&&(O(e,this.mtgData.me),this.emitter.emit(a.ME_CHANGE,{event:o.AUDIOCHANGE,body:{newVal:{deviceOn:E(c)?null===(f=this.mtgData.me.audio)||void 0===f?void 0:f.deviceOn:c,sendOn:E(d)?null===(v=this.mtgData.me.audio)||void 0===v?void 0:v.sendOn:d,opBy:m},oldVal:{deviceOn:null===(g=t.audio)||void 0===g?void 0:g.deviceOn,sendOn:null===(b=t.audio)||void 0===b?void 0:b.sendOn}}}))),"isHandUp"in e&&(O(e,this.mtgData.me),e.isHandUp!==t.isHandUp&&"isHandUp"in t&&this.emitter.emit(a.ME_CHANGE,{event:o.HANDUPCHANGE,body:{newVal:e.isHandUp,oldVal:t.isHandUp}})),e.video&&(u=e.video,c=u.deviceOn,d=u.sendOn,m=u.opBy,(!E(c)&&c!==(null===(S=t.video)||void 0===S?void 0:S.deviceOn)||!E(d)&&d!==(null===(D=t.video)||void 0===D?void 0:D.sendOn))&&(O(e,this.mtgData.me),this.emitter.emit(a.ME_CHANGE,{event:o.VIDEOCHANGE,body:{newVal:{deviceOn:E(c)?null===(C=this.mtgData.me.video)||void 0===C?void 0:C.deviceOn:c,sendOn:E(d)?null===(I=this.mtgData.me.video)||void 0===I?void 0:I.sendOn:d,opBy:m},oldVal:{deviceOn:null===(y=t.video)||void 0===y?void 0:y.deviceOn,sendOn:null===(N=t.video)||void 0===N?void 0:N.sendOn}}}))),e.share&&(l=e.share,c=l.deviceOn,d=l.sendOn,m=l.opBy,(!E(c)&&c!==(null===(T=t.share)||void 0===T?void 0:T.deviceOn)||!E(d)&&d!==(null===(A=t.share)||void 0===A?void 0:A.sendOn))&&(O(e,this.mtgData.me),this.emitter.emit(a.ME_CHANGE,{event:o.SHARECHANGE,body:{newVal:{deviceOn:E(c)?null===(U=this.mtgData.me.share)||void 0===U?void 0:U.deviceOn:c,sendOn:E(d)?null===(H=this.mtgData.me.share)||void 0===H?void 0:H.sendOn:d,opBy:m},oldVal:{deviceOn:null===(R=t.share)||void 0===R?void 0:R.deviceOn,sendOn:null===(w=t.share)||void 0===w?void 0:w.sendOn}}}))),"isSpotlightVideo"in e&&(e.isSpotlightVideo?(this.mtgData.me.isSpotlightVideo=!0,this.emitter.emit(a.ME_CHANGE,{event:o.SPOTLIGHTVIDEOCHANGE,body:{newVal:!0,oldVal:null}})):(this.mtgData.me.isSpotlightVideo=!1,this.emitter.emit(a.ME_CHANGE,{event:o.SPOTLIGHTVIDEOCHANGE,body:{newVal:!1,oldVal:!0}}))),!("isInLobby"in e)||E(t.isInLobby)?[3,5]:t.isInLobby===e.isInLobby?[3,5]:(this.mtgData.me.isInLobby=e.isInLobby,this.mtgData.me.reSub=!0,this.stopPolling(),[4,this.startPolling()]);case 4:n.sent(),O(e,this.mtgData.me),!1===e.isInLobby&&(this.mtgData.me.isUpdatedUserState=!1,this.emitter.emit(a.UPDATE_USER_STATE)),this.emitter.emit(a.ME_CHANGE,{event:o.LOBBYCHANGE,body:{newVal:e.isInLobby,oldVal:!e.isInLobby}}),n.label=5;case 5:"isLeave"in e&&(this.stopKeepalive(),this.stopPolling(),this.clean(),this.emitter.emit(a.ME_CHANGE,{event:o.LEAVE,body:e.resultInfo}),e={}),delete e.reSub,delete e.resultInfo,O(e,this.mtgData.me),n.label=6;case 6:return[2]}}))}))},c=function(t){var n=e.find((function(e){return e.name===t}));if(n){if(n.seqId=u[t].maxSeqId,!u[t].items)return;u[t].items.forEach((function(e){var t=JSON.parse(e.content),n=t.event,i=t.state,r=t.body;if("full"===i)d.mtgData[n]=r;else if("update"===i)if(d.mtgData[n]||(d.mtgData[n]=r),n.indexOf("Users")>-1)r.users&&r.users.forEach((function(e){var t=d.mtgData[n].users.findIndex((function(t){return t.userID===e.userID}));-1===t?d.mtgData[n].users.push(e):O(e,d.mtgData[n].users[t]),e.userID===d.mtgData.me.userID&&d.mtgData.me.role!==s.AUDIENCE&&l(e)}));else if("me"===n)r.users&&r.users.forEach((function(e){"userID"in e||(e.userID=d.mtgData.me.userID),l(e)}));else if("spotlightVideo"===n){(r.userIDs&&r.userIDs.findIndex((function(e){return e===d.mtgData.me.userID})))>-1?l({userID:d.mtgData.me.userID,isSpotlightVideo:!0}):d.mtgData.me.isSpotlightVideo&&l({userID:d.mtgData.me.userID,isSpotlightVideo:!1})}else"meetingState"===n&&"ended"===r.state?l({userID:d.mtgData.me.userID,resultInfo:r.resultInfo,isLeave:!0}):O(r,d.mtgData[n]);else"delete"===i?n.indexOf("Users")>-1?r.users&&r.users.forEach((function(e){if(d.mtgData[n]){var t=d.mtgData[n].users.findIndex((function(t){return t.userID===e.userID}));if(t>-1&&d.mtgData[n].users.splice(t,1),e.userID===d.mtgData.me.userID){var i=Object.keys(e).length;e.role?l(e):e.resultInfo&&2===i&&(e.isLeave=!0,l(e))}}})):"me"===n&&l({userID:d.mtgData.me.userID,isLeave:!0,resultInfo:r.users&&r.users[0]&&r.users[0].resultInfo}):("meetingBarrage"===n&&d.handleBarrage(r),"setUserAudio"===n?d.emitter.emit(a.ME_CHANGE,{event:o.SETAUDIO,body:r}):"setUserVideo"===n?d.emitter.emit(a.ME_CHANGE,{event:o.SETVIDEO,body:r}):d.mtgData[n]?O(r,d.mtgData[n]):d.mtgData[n]=r);d.emitter.emit(a.MEETING_CHANGE,{event:n,body:JSON.parse(JSON.stringify(r)),state:i,stime:null})}))}},Object.keys(u).forEach(c),this.pollingStatus.attempts=0,[2]):[2]}}))}))},this.pollingStatus.timer&&(clearTimeout(this.pollingStatus.timer),this.pollingStatus.timer=null),5!==this.pollingStatus.errorTimes?[3,2]:(this.stopKeepalive(),this.clean(),this.emitter.emit(a.ME_CHANGE,{event:o.LEAVE,body:"polling.error"}),this.connectionState=r.CLOSED,this.emitter.emit(a.CONNECTION_STATE,{state:r.CLOSED,reason:{cause:"polling",data:this.pollingStatus.errors}}),[4,this.ctrl.leave({resultInfo:{bizCode:901359}})]);case 1:return c.sent(),[2];case 2:return[4,i()];case 3:return c.sent(),this.pollingStatus.running?(u=this.pollingStatus.attempts?200*this.pollingStatus.attempts:0,this.pollingStatus.timer=setTimeout((function(){l.pollingStatus.running&&l.polling(e)}),u),[2]):[2]}}))}))},l.prototype.keepalive=function(){return t(this,void 0,void 0,(function(){var e,i=this;return n(this,(function(s){switch(s.label){case 0:return e=function(){return t(i,void 0,void 0,(function(){var e,t,i,s=this;return n(this,(function(n){switch(n.label){case 0:return this.keepaliveStatus.lastReqTime=(new Date).valueOf(),[4,this.ctrl.keepalive({userID:this.mtgData.me.userID||-1}).catch((function(e){s.keepaliveStatus.attempts++,s.keepaliveStatus.errorTimes++,s.keepaliveStatus.errors.push({msg:e.message,time:(new Date).valueOf()})}))];case 1:return(e=n.sent())&&e.data?(t=e.data,(i=(void 0===t?{}:t).interval||"")?(this.keepaliveStatus.interval=i,this.keepaliveStatus.attempts=0,[2]):(this.keepaliveStatus.attempts++,[2])):(this.keepaliveStatus.attempts++,[2])}}))}))},this.keepaliveStatus.timer&&(clearTimeout(this.keepaliveStatus.timer),this.keepaliveStatus.timer=null),5!==this.keepaliveStatus.errorTimes?[3,2]:(this.stopPolling(),this.clean(),this.emitter.emit(a.ME_CHANGE,{event:o.LEAVE,body:"keepalive.error"}),this.connectionState=r.CLOSED,this.emitter.emit(a.CONNECTION_STATE,{state:r.CLOSED,reason:{cause:"polling",data:this.keepaliveStatus.errors}}),[4,this.ctrl.leave({resultInfo:{bizCode:901359}})]);case 1:return s.sent(),[2];case 2:return[4,e()];case 3:return s.sent(),this.keepaliveStatus.running?(this.keepaliveStatus.timer=setTimeout((function(){i.keepaliveStatus.running&&i.keepalive()}),1e3*(this.keepaliveStatus.interval||0)),[2]):[2]}}))}))},l.prototype.getTopics=function(e){var t=[];switch(e.endpointType){case i.WEBCTRL:t=["meeting","interactive","broadcast","lobby","hostAttendee","audience","advCtrl"];break;case i.WEBAPP:t=e.isInLobby?["lobbyMember"]:"audience"===e.role?["meeting","interactive","chat","audience"]:["meeting","interactive","broadcast","lobby","chat","hostAttendee"];break;case i.WECHATMP:t=e.isInLobby?["lobbyMember"]:"audience"===e.role?["meeting","interactive"]:["meeting","interactive","broadcast","lobby"];break;case i.SUPERVISION:t=["meeting","interactive","broadcast"]}return t},l}(),y=function(){return I.instance};return function(){function e(e){!function(e){I.createInstance(e)}(e)}return Object.defineProperty(e.prototype,"ctrl",{get:function(){return y().ctrl},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return y().mtgData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectionState",{get:function(){return y().connectionState},enumerable:!1,configurable:!0}),e.prototype.on=function(e,t){return y().emitter.on(e,t)},e.prototype.off=function(e,t){return y().emitter.off(e,t)},e.prototype.getBaseURL=function(){return y().ctrl.baseURL},e.prototype.setBaseURL=function(e){y().ctrl.setBaseURL(e)},e.prototype.getJobStatus=function(){return{polling:y().pollingStatus,keepalive:y().keepaliveStatus}},e.prototype.join=function(e){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return(t=y()).ctrl.setSessionID((i=e.endpointType,s=e.meetingNum,""+(null==i?void 0:i.toLocaleUpperCase())+b+"_"+S(new Date,"MMddHHmmss")+"_"+s)),[4,t.join(e)];case 1:return n.sent()?(t.connectionState=r.CONNECTED,t.emitter.emit(a.CONNECTION_STATE,{state:r.CONNECTED,data:t.mtgData.me.mediaContent}),[4,Promise.all([t.startPolling(),t.startKeepalive()])]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}var i,s}))}))},e.prototype.updateUserState=function(e){return t(this,void 0,void 0,(function(){var t,i,r,u,l,c,d;return n(this,(function(n){switch(n.label){case 0:return t=y(),i={audio:{deviceOn:!0,sendOn:!0,recvOn:!1},video:{deviceOn:!0,sendOn:!0,recvOn:!1},share:{deviceOn:!0,sendOn:!1,recvOn:!1}},i=e?O(e,i):i,r=JSON.parse(JSON.stringify(i)),O(r,y().mtgData.me),u=t.mtgData.me,l=u.role,c=u.initialMediaState,d=void 0===c?{audio:{sendOn:!0},video:{sendOn:!0}}:c,i.audio.sendOn=i.audio.sendOn&&d.audio.sendOn,i.video.sendOn=i.video.sendOn&&d.video.sendOn,l===s.AUDIENCE&&(i.audio.sendOn=!1,i.video.sendOn=!1),t.mtgData.me.isUpdatedUserState=!0,[4,t.ctrl.updateUserState(i)];case 1:return n.sent(),l===s.AUDIENCE&&(O(i,y().mtgData.me),!1!==r.audio.sendOn&&t.emitter.emit(a.ME_CHANGE,{event:o.AUDIOCHANGE,body:{newVal:i.audio,oldVal:r.audio}}),!1!==r.video.sendOn&&t.emitter.emit(a.ME_CHANGE,{event:o.VIDEOCHANGE,body:{newVal:i.video,oldVal:r.video}})),[2]}}))}))},e.prototype.leave=function(e){return t(this,void 0,void 0,(function(){var t,i;return n(this,(function(n){switch(n.label){case 0:return t=y(),e||(e={bizCode:901359}),[4,t.ctrl.leave({resultInfo:e})];case 1:return i=n.sent().error,[4,Promise.all([t.stopPolling(),t.stopKeepalive()])];case 2:return n.sent(),t.clean(),t.connectionState=r.CLOSED,i?(t.emitter.emit(a.CONNECTION_STATE,{state:r.CLOSED,reason:{cause:"leave",data:i}}),[2,!1]):(t.emitter.emit(a.CONNECTION_STATE,{state:r.CLOSED}),[2,!0])}}))}))},e.prototype.end=function(){return t(this,void 0,void 0,(function(){var e,t;return n(this,(function(n){switch(n.label){case 0:return[4,(e=y()).ctrl.end()];case 1:return t=n.sent().error,[4,Promise.all([e.stopPolling(),e.stopKeepalive()])];case 2:return n.sent(),e.clean(),e.connectionState=r.CLOSED,t?(e.emitter.emit(a.CONNECTION_STATE,{state:r.CLOSED,reason:{cause:"end",data:t}}),[2,!1]):(e.emitter.emit(a.CONNECTION_STATE,{state:r.CLOSED}),[2,!0])}}))}))},e.ENDPOINT_TYPE=i,e.EVENT=a,e.CONNECTION_STATE=r,e.ROLE=s,e.ME_CHANGE=o,e.MEETING_CHANGE=u,e}()}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Meeting=t()}(this,(function(){"use strict";var e=function(){return(e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};function t(e,t,n,i){return new(n||(n=Promise))((function(s,r){function a(e){try{u(i.next(e))}catch(e){r(e)}}function o(e){try{u(i.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,o)}u((i=i.apply(e,t||[])).next())}))}function n(e,t){var n,i,s,r,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return r={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function o(r){return function(o){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(s=2&r[0]?i.return:r[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,r[1])).done)return s;switch(i=0,s&&(r=[2&r[0],s.value]),r[0]){case 0:case 1:s=r;break;case 4:return a.label++,{value:r[1],done:!1};case 5:a.label++,i=r[1],r=[0];continue;case 7:r=a.ops.pop(),a.trys.pop();continue;default:if(!(s=a.trys,(s=s.length>0&&s[s.length-1])||6!==r[0]&&2!==r[0])){a=0;continue}if(3===r[0]&&(!s||r[1]>s[0]&&r[1]<s[3])){a.label=r[1];break}if(6===r[0]&&a.label<s[1]){a.label=s[1],s=r;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(r);break}s[2]&&a.ops.pop(),a.trys.pop();continue}r=t.call(e,a)}catch(e){r=[6,e],i=0}finally{n=s=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,o])}}}var i,s,r,a,o,u,l=function(){function e(e){this.defaultHeaders={},this.baseURL=e.baseURL,this.beforeRequest=e.beforeRequest}return e.prototype.setDefaultHeader=function(e,t){e in this.defaultHeaders&&(""===t||null===t)?delete this.defaultHeaders[e]:this.defaultHeaders[e]=t},e.prototype.request=function(e){var t=e.url,n=void 0===t?"":t,i=e.timeout,s=void 0===i?6e4:i,r=e.headers,a=void 0===r?{}:r;return e.url=this.baseURL.replace(/\/+$/,"")+"/"+g(n.replace(/^\/+/,""),e.params),a=Object.assign(a,this.defaultHeaders),Object.keys(a).forEach((function(e){"Content-Type"!==e&&e.toUpperCase()==="Content-Type".toUpperCase()&&(a["Content-Type"]=a[e],delete a[e])})),h(e.data)&&(a&&!a["Content-Type"]&&(a["Content-Type"]="application/json;charset=utf-8"),e.data=JSON.stringify(e.data)),e.headers=a,e.timeout=s,this.beforeRequest&&this.beforeRequest(e),"undefined"!=typeof wx?d(e):c(e)},e.prototype.get=function(e,t){return this.request(Object.assign(t||{},{url:e,method:"GET"}))},e.prototype.post=function(e,t,n){return this.request(Object.assign(n||{},{url:e,method:"POST",data:t}))},e}(),c=function(e){return new Promise((function(t,n){var i=e.data,s=void 0===i?null:i,r=e.url,a=e.method,o=void 0===a?"GET":a,u=e.headers,l=e.cancelToken,c=new XMLHttpRequest;c.open(o.toUpperCase(),r,!0),c.timeout=e.timeout;var d="",m=function(){if(c){if(c.status>=200&&c.status<300)try{t(JSON.parse(c.responseText))}catch(e){n(new Error("E_JSON_PARSE"+c.responseText))}else n(new Error("Request failed with status code "+c.status));c=null}};"onloadend"in c?c.onloadend=m:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(m)},c.onabort=function(){c&&(n(new Error("Request aborted "+d)),c=null)},c.onerror=function(){n(new Error("Network Error")),c=null},c.ontimeout=function(){n(new Error("timeout of "+e.timeout+"ms exceeded")),c=null},"setRequestHeader"in c&&Object.keys(u).forEach((function(e){null===s&&"content-type"===e.toLowerCase()?delete u[e]:c.setRequestHeader(e,u[e])})),l&&l.promise.then((function(e){c&&(d=e,c.abort(),n(e),c=null)})),c.send(s)}))},d=function(e){return new Promise((function(t,n){var i=e.data,s=void 0===i?null:i,r=e.url,a=e.method,o=void 0===a?"GET":a,u=e.headers,l=e.cancelToken,c=wx.request({url:r,data:s,method:o.toUpperCase(),timeout:e.timeout,header:u,success:function(e){e.statusCode>=200&&e.statusCode<300?t(e.data):n(new Error("Request failed with status code "+e.statusCode))},fail:function(e){"request:fail abort"===e.errMsg&&l?n(l.reason):n(e)}});l&&l.promise.then((function(){c&&c.abort()}))}))},m=function(){function e(e){var t,n=this;this.promise=new Promise((function(e){t=e})),e((function(e){n.reason||(n.reason=e,t(n.reason))}))}return e.source=function(){var t,n=new e((function(e){t=e}));return{cancel:t,token:n}},e}(),p=Object.prototype.toString,h=function(e){if("[object Object]"!==p.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},f=function(e){return encodeURIComponent(e).replace(/%40/g,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},g=function(e,t){if(!t)return e;var n=[];Object.keys(t).forEach((function(e){var i,s=t[e];null!=s&&(Array.isArray(s)?(i=s,e+="[]"):i=[s],i.forEach((function(t){null!==t&&"object"==typeof t&&(t=JSON.stringify(t)),n.push(f(e)+"="+f(t))})))}));var i=n.join("&");if(i){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e},v=function(){for(var e=[],t="0123456789abcdef",n=0;n<36;n++)e[n]=t.substr(Math.floor(16*Math.random()),1);return e[14]="4",e[19]=t.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-",e.join("").split("-").join("")},E=function(e){return null==e},b=v(),S=function(e,t){void 0===e&&(e=new Date);var n={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};for(var i in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+i+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?n[i]:("00"+n[i]).substr((""+n[i]).length)));return t},D=function(e,t){return e?(Object.entries(e).forEach((function(e){var n,i=[e[0],e[1]],s=i[0],r=i[1];if(null!==r)return"object"==typeof(n=r)&&null!==n?(t[s]||(t[s]={}),void(t[s]=D(r,t[s]))):void(t[s]=r)})),t):t},O=function(e){var t="/meeting-ctrl/api/v1",n=new l({baseURL:e,beforeRequest:function(e){e.headers["X-Y-Request-Id"]=v()}}),i=m.source(),s="",r="",a="",o="";return{cancelToken:function(e){i.cancel(e),i=m.source()},credential:function(e){return n.get(t+"/credential",{params:e})},join:function(e){return n.post(t+"/join?meetingNum="+e.meetingNum+"&credential="+e.credential,e,{headers:{"X-Y-Endpoint-Type":e.endpointType,"X-Y-Endpoint-Id":s}})},updateUserState:function(e){return n.post(t+"/meetings/"+r+"/updateUserState",e)},inbox:function(e){return n.post("/ypush/api/v1/meeting-control/inbox",e)},polling:function(e){return n.post("/ypush/api/v1/meeting-control/polling",e,{cancelToken:i.token})},subscribe:function(e){return n.post(t+"/meetings/"+r+"/subscribe",e)},keepalive:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/keepalive",{},{cancelToken:i.token})},leave:function(e){return n.post(t+"/meetings/"+r+"/leave",e)},end:function(){return n.post(t+"/meetings/"+r+"/end")},audio:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/audio",e)},video:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/video",e)},share:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/share",e)},handUp:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/handUp",e)},replyHandUp:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/replyHandUp",e)},shareInfo:function(e){return n.get(t+"/meetings/"+r+"/shareInfo",{params:e})},trying:function(e){return n.post(t+"/trying?meetingNum="+e.meetingNum+"&credential="+e.credential,e,{headers:{token:e.token,"X-Y-Endpoint-Type":e.endpointType,"X-Y-Endpoint-Id":s}})},rejectCall:function(e){return n.post(t+"/rejectCall?meetingNum="+e.meetingNum+"&credential="+e.credential,e,{headers:{token:e.token,"X-Y-Endpoint-Type":e.endpointType,"X-Y-Endpoint-Id":s}})},pauseAudio:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/pauseAudio")},resumeAudio:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/resumeAudio")},lobbyState:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/lobbyState",e)},displayName:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/displayName",e)},callStats:function(e){return n.get(t+"/meetings/"+r+"/users/"+e.userID+"/callStats")},user:function(e){return n.get(t+"/meetings/"+r+"/users/"+e.userID)},blockVideo:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/blockVideo")},unblockVideo:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/unblockVideo")},role:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/role",e)},remove:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/remove",e)},dtmf:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/dtmf",e)},fecc:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/fecc",e)},hostLayout:function(e){return n.post(t+"/meetings/"+r+"/view/hostLayout",e)},attendeeLayout:function(e){return n.post(t+"/meetings/"+r+"/view/attendeeLayout",e)},audienceLayout:function(e){return n.post(t+"/meetings/"+r+"/view/audienceLayout",e)},personalLayout:function(e){return n.post(t+"/meetings/"+r+"/view/personalLayout",e)},personalLayoutDelete:function(e){return n.post(t+"/meetings/"+r+"/view/personalLayout/delete",e)},virtualClassLayout:function(e){return n.post(t+"/meetings/"+r+"/view/virtualClass/layout",e)},virtualClassClose:function(){return n.post(t+"/meetings/"+r+"/view/virtualClass/close")},spotlight:function(e){return n.post(t+"/meetings/"+r+"/view/spotlight",e)},lobbyRefuseAll:function(){return n.post(t+"/meetings/"+r+"/lobby/refuseAll")},lobbyAdmitAll:function(){return n.post(t+"/meetings/"+r+"/lobby/admitAll")},barrage:function(e){return n.post(t+"/meetings/"+r+"/barrage",e)},deleteBarrage:function(){return n.post(t+"/meetings/"+r+"/deleteBarrage")},operationRecord:function(e){return n.post(t+"/meetings/"+r+"/operationRecord",e)},practiceSession:function(){return n.post(t+"/meetings/"+r+"/info/practiceSession")},replyAllHandUp:function(){return n.post(t+"/meetings/"+r+"/replyAllHandUp")},unmuteAll:function(){return n.post(t+"/meetings/"+r+"/unmuteAll")},muteAll:function(){return n.post(t+"/meetings/"+r+"/muteAll")},audioDump:function(){return n.post(t+"/meetings/"+r+"/audioDump")},endMeeting:function(e){return n.post(t+"/meetingNum/"+e.meetingNum+"/end")},msg:function(e){return n.post(t+"/meetings/"+r+"/chat/msg",e)},historyMsg:function(e){return n.post(t+"/meetings/"+r+"/chat/historyMsg",e)},callStatsReport:function(e){return n.post(t+"/meetings/"+r+"/users/"+e.userID+"/callStats/report",e)},get baseURL(){return n.baseURL},setBaseURL:function(e){n.baseURL=e},get sessionID(){return s},setSessionID:function(e){void 0===e&&(e=""),s=e,n.setDefaultHeader("X-Y-Session-Id",s)},get meetingID(){return r},setMeetingID:function(e){void 0===e&&(e=""),r=e},get location(){return o},setLocation:function(e){void 0===e&&(e=""),o=e,n.setDefaultHeader("X-Y-Location",o)},get ctrlID(){return a},setCtrlID:function(e){void 0===e&&(e=""),a=e,n.setDefaultHeader("X-Y-Ctrl-Id",a)}}},y=function(){function e(){this.events=new Map}return e.prototype.emit=function(e,t){var n=this.events.get(e);n&&n.slice().map((function(e){e(t)}))},e.prototype.off=function(e,t){var n=this.events.get(e);n&&(t?n.splice(n.indexOf(t)>>>0,1):this.events.set(e,[]))},e.prototype.on=function(e,t){var n=this.events.get(e);n?n.push(t):this.events.set(e,[t])},e}();!function(e){e.WEBAPP="webApp",e.WEBCTRL="webCtrl",e.WECHATMP="weChatMP",e.SUPERVISION="supervision"}(i||(i={})),function(e){e.HOST="host",e.COHOST="coHost",e.ATTENDEE="attendee",e.AUDIENCE="audience"}(s||(s={})),function(e){e.CONNECTION_STATE="CONNECTION_STATE",e.MEETING_CHANGE="MEETING_CHANGE",e.ME_CHANGE="ME_CHANGE",e.UPDATE_USER_STATE="UPDATE_USER_STATE"}(r||(r={})),function(e){e.CONNECTED="connected",e.SUBSCRIBED="subscribed",e.CLOSED="closed"}(a||(a={})),function(e){e.ROLECHANGE="roleChange",e.AUDIOCHANGE="audioChange",e.HANDUPCHANGE="handupChange",e.SETAUDIO="setAudio",e.VIDEOCHANGE="videoChange",e.SETVIDEO="setVideo",e.SHARECHANGE="shareChange",e.DISPLAYNAMECHANGE="displayNameChange",e.SPOTLIGHTVIDEOCHANGE="spotlightVideoChange",e.LOBBYCHANGE="lobbyChange",e.BARRAGECHANGE="barrageChange",e.LEAVE="leave"}(o||(o={})),function(e){e.MEETINGINFO="meetingInfo",e.MEETINGSTATE="meetingState",e.MEETINGSETTING="meetingSetting",e.MEETINGVIEW="meetingView",e.MEETINGBARRAGE="meetingBarrage",e.RECORDING="recording",e.LIVESTREAM="liveStream",e.INTERACTIVEUSERS="interactiveUsers",e.BROADCASTUSERS="broadcastUsers",e.LOBBYUSERS="lobbyUsers",e.VIRTUALUSERS="virtualUsers",e.CHATMSG="chatMsg",e.INVITESTATE="inviteState",e.CALLRECORD="callRecord",e.ME="me"}(u||(u={}));var I=function(){function l(e){this.mtgData={me:{isHandUp:!1,isUpdatedUserState:!1}},this.pollingStatus={attempts:0,errorTimes:0,errors:[]},this.keepaliveStatus={attempts:0,errorTimes:0,errors:[]},this.connectionState=a.CLOSED,this.isClosedStateEmited=!1,this.barrageTimer=null,this.ctrl=O(e.baseURL),this.emitter=new y}return l.createInstance=function(e){return null===this.instance||void 0===this.instance?this.instance=new l(e):(this.instance.emitter&&(this.instance.emitter=new y),this.instance.ctrl&&(this.instance.ctrl=O(e.baseURL))),l.instance},l.prototype.join=function(i){return t(this,void 0,void 0,(function(){var t,s,a,u,l,c,d,m,p,h,f,g,v,E=this;return n(this,(function(n){switch(n.label){case 0:return this.isClosedStateEmited=!1,[4,this.ctrl.credential({meetingNum:i.meetingNum,pwd:i.pwd,url:i.url}).catch((function(e){E.emitClosedState({cause:"credential",data:e.message})}))];case 1:return(t=n.sent())&&t.data&&t.data.credential?(this.ctrl.setLocation(t.data.location),delete i.pwd,delete i.url,[4,this.ctrl.join(e(e({},i),{credential:t.data.credential})).catch((function(e){E.emitClosedState({cause:"join",data:e.message})}))]):[3,3];case 2:return(s=n.sent())&&s.data?(a=s.data,u=a.meetingID,l=void 0===u?"":u,c=a.ctrlID,d=void 0===c?"":c,m=a.user,p=void 0===m?{}:m,h=a.mediaContent,f=void 0===h?{}:h,g=a.initialMediaState,v=void 0===g?{}:g,this.ctrl.setMeetingID(l),this.ctrl.setCtrlID(d),this.mtgData.me=e(e({},p),{mediaContent:f,initialMediaState:v}),this.mtgData.me.isInLobby?this.emitter.emit(r.ME_CHANGE,{event:o.LOBBYCHANGE,body:{newVal:!0,oldVal:null}}):this.emitter.emit(r.UPDATE_USER_STATE),[2,!0]):(this.emitClosedState({cause:"join",data:s}),[2,!1]);case 3:return this.emitClosedState({cause:"credential",data:t}),[2,!1];case 4:return[2]}}))}))},l.prototype.startPolling=function(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return this.pollingStatus.attempts=0,this.pollingStatus.errorTimes=0,this.pollingStatus.errors=[],[4,this.inbox()];case 1:return e=t.sent(),[4,this.subscribe()];case 2:return t.sent()&&(this.pollingStatus.running=!0,this.polling(e)),[2]}}))}))},l.prototype.stopPolling=function(){this.pollingStatus.running=!1,this.pollingStatus.timer&&clearTimeout(this.pollingStatus.timer),this.ctrl.cancelToken("cancel")},l.prototype.startKeepalive=function(){return t(this,void 0,void 0,(function(){return n(this,(function(e){return this.keepaliveStatus.attempts=0,this.keepaliveStatus.errorTimes=0,this.keepaliveStatus.errors=[],this.keepaliveStatus.running=!0,this.keepalive(),[2]}))}))},l.prototype.stopKeepalive=function(){this.keepaliveStatus.running=!1,this.keepaliveStatus.timer&&clearTimeout(this.keepaliveStatus.timer),this.ctrl.cancelToken("cancel")},l.prototype.clean=function(){this.ctrl.setCtrlID(""),this.ctrl.setLocation(""),this.ctrl.setMeetingID(""),this.ctrl.setSessionID(""),this.mtgData={me:{isHandUp:!1,isUpdatedUserState:!1}}},l.prototype.handleBarrage=function(e,t){var n=this;if(void 0===t&&(t=!1),e||t){var i=JSON.parse(JSON.stringify(this.mtgData.me.barrage||{})),a=this.mtgData.me.role,u=void 0===a?"":a,l=this.mtgData.meetingBarrage;e||(e=l),u===s.COHOST&&(u=s.HOST),(null==e?void 0:e.receiver[u])?this.mtgData.me.barrage={position:e.position,contentType:e.contentType,content:e.content}:delete this.mtgData.me.barrage;var c={newVal:this.mtgData.me.barrage||null,oldVal:"{}"===JSON.stringify(i)?null:i};(c.newVal||c.oldVal)&&this.emitter.emit(r.ME_CHANGE,{event:o.BARRAGECHANGE,body:c})}if(e&&this.barrageTimer&&(clearTimeout(this.barrageTimer),this.barrageTimer=null),e&&-1!==e.duration){var d=JSON.parse(JSON.stringify(this.mtgData.me.barrage||{}));this.barrageTimer=setTimeout((function(){delete n.mtgData.me.barrage,n.emitter.emit(r.ME_CHANGE,{event:o.BARRAGECHANGE,body:{newVal:null,oldVal:"{}"===JSON.stringify(d)?null:d}})}),1e3*e.duration)}},l.prototype.emitClosedState=function(e){this.isClosedStateEmited||(this.connectionState=a.CLOSED,this.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED,reason:e}),this.isClosedStateEmited=!0,this.clean())},l.prototype.subscribe=function(){return t(this,void 0,void 0,(function(){var e,t,i=this;return n(this,(function(n){switch(n.label){case 0:return e=this.getTopics(this.mtgData.me),[4,this.ctrl.subscribe({topics:e}).catch((function(e){i.emitClosedState({cause:"subscribe",data:e.message})}))];case 1:return(t=n.sent())&&t.data?(t.data.eventMsgs.forEach((function(e){i.mtgData[e.event]=e.body,e.event.indexOf("Users")>-1&&e.body.users.forEach((function(e){if(e.userID===i.mtgData.me.userID){var t=Object.assign({},e);delete t.audio,delete t.video,delete t.share,D(t,i.mtgData.me)}})),e.event===u.MEETINGBARRAGE&&i.handleBarrage(e.body)})),this.mtgData.me.reSub?delete this.mtgData.me.reSub:(this.connectionState=a.SUBSCRIBED,this.emitter.emit(r.CONNECTION_STATE,{state:a.SUBSCRIBED})),[2,!0]):(this.emitClosedState({cause:"subscribe",data:t}),[2,!1])}}))}))},l.prototype.inbox=function(){return t(this,void 0,void 0,(function(){var e,t,i;return n(this,(function(n){switch(n.label){case 0:return e=this.getTopics(this.mtgData.me),[4,this.ctrl.inbox({basic:{tenantId:100,clientId:this.ctrl.sessionID,meetingId:this.ctrl.meetingID},inboxes:e})];case 1:return(t=n.sent())?(i=[],t.data&&Object.keys(t.data).forEach((function(e){i.push({name:e,seqId:t.data[e].maxSeqId,limit:200})})),[2,i]):[2,[]]}}))}))},l.prototype.polling=function(e){return t(this,void 0,void 0,(function(){var i,u,l=this;return n(this,(function(c){switch(c.label){case 0:return i=function(){return t(l,void 0,void 0,(function(){var i,u,l,c,d,m=this;return n(this,(function(p){switch(p.label){case 0:return this.pollingStatus.lastReqTime=(new Date).valueOf(),[4,this.ctrl.polling({basic:{tenantId:100,clientId:this.ctrl.sessionID,meetingId:this.ctrl.meetingID},inboxes:e}).catch((function(e){m.pollingStatus.attempts++,m.pollingStatus.errorTimes++,m.pollingStatus.errors.push({msg:e.message,time:(new Date).valueOf()})}))];case 1:return(i=p.sent())&&i.data?(u=i.data,l=void 0===u?{}:u,c=function(e){return t(m,void 0,void 0,(function(){var t,i,u,l,c,d,m,p,h,f,g,v,b,S,O,y,I,C,N,T,A,U,H,L,w,R;return n(this,(function(n){switch(n.label){case 0:return e.userID!==this.mtgData.me.userID?[3,6]:(t=JSON.parse(JSON.stringify(this.mtgData.me)),e.role&&e.role!==t.role?(i=t.role,e.role!==s.AUDIENCE&&t.role!==s.AUDIENCE?[3,2]:(this.mtgData.me.role=e.role,this.mtgData.me.reSub=!0,this.stopPolling(),[4,this.startPolling()])):[3,3]);case 1:n.sent(),this.mtgData.me.isUpdatedUserState=!1,this.emitter.emit(r.UPDATE_USER_STATE),n.label=2;case 2:e.role===s.AUDIENCE&&(e.audio={deviceOn:!0,sendOn:!1,recvOn:!1},e.video={deviceOn:!0,sendOn:!1,recvOn:!1},e.share={deviceOn:!0,sendOn:!1,recvOn:!1}),D(e,this.mtgData.me),this.emitter.emit(r.ME_CHANGE,{event:o.ROLECHANGE,body:{newVal:e.role,oldVal:i}}),this.handleBarrage(null,!0),n.label=3;case 3:return e.displayName&&e.displayName!==t.displayName&&(D(e,this.mtgData.me),this.emitter.emit(r.ME_CHANGE,{event:o.DISPLAYNAMECHANGE,body:{newVal:e.displayName,oldVal:t.displayName}})),e.audio&&(u=e.audio,d=u.deviceOn,m=u.sendOn,p=u.opBy,(!E(d)&&d!==(null===(h=t.audio)||void 0===h?void 0:h.deviceOn)||!E(m)&&m!==(null===(f=t.audio)||void 0===f?void 0:f.sendOn))&&(D(e,this.mtgData.me),this.emitter.emit(r.ME_CHANGE,{event:o.AUDIOCHANGE,body:{newVal:{deviceOn:E(d)?null===(g=this.mtgData.me.audio)||void 0===g?void 0:g.deviceOn:d,sendOn:E(m)?null===(v=this.mtgData.me.audio)||void 0===v?void 0:v.sendOn:m,opBy:p},oldVal:{deviceOn:null===(b=t.audio)||void 0===b?void 0:b.deviceOn,sendOn:null===(S=t.audio)||void 0===S?void 0:S.sendOn}}}))),"isHandUp"in e&&(D(e,this.mtgData.me),e.isHandUp!==t.isHandUp&&"isHandUp"in t&&this.emitter.emit(r.ME_CHANGE,{event:o.HANDUPCHANGE,body:{newVal:e.isHandUp,oldVal:t.isHandUp}})),e.video&&(l=e.video,d=l.deviceOn,m=l.sendOn,p=l.opBy,(!E(d)&&d!==(null===(O=t.video)||void 0===O?void 0:O.deviceOn)||!E(m)&&m!==(null===(y=t.video)||void 0===y?void 0:y.sendOn))&&(D(e,this.mtgData.me),this.emitter.emit(r.ME_CHANGE,{event:o.VIDEOCHANGE,body:{newVal:{deviceOn:E(d)?null===(I=this.mtgData.me.video)||void 0===I?void 0:I.deviceOn:d,sendOn:E(m)?null===(C=this.mtgData.me.video)||void 0===C?void 0:C.sendOn:m,opBy:p},oldVal:{deviceOn:null===(N=t.video)||void 0===N?void 0:N.deviceOn,sendOn:null===(T=t.video)||void 0===T?void 0:T.sendOn}}}))),e.share&&(c=e.share,d=c.deviceOn,m=c.sendOn,p=c.opBy,(!E(d)&&d!==(null===(A=t.share)||void 0===A?void 0:A.deviceOn)||!E(m)&&m!==(null===(U=t.share)||void 0===U?void 0:U.sendOn))&&(D(e,this.mtgData.me),this.emitter.emit(r.ME_CHANGE,{event:o.SHARECHANGE,body:{newVal:{deviceOn:E(d)?null===(H=this.mtgData.me.share)||void 0===H?void 0:H.deviceOn:d,sendOn:E(m)?null===(L=this.mtgData.me.share)||void 0===L?void 0:L.sendOn:m,opBy:p},oldVal:{deviceOn:null===(w=t.share)||void 0===w?void 0:w.deviceOn,sendOn:null===(R=t.share)||void 0===R?void 0:R.sendOn}}}))),"isSpotlightVideo"in e&&(e.isSpotlightVideo?(this.mtgData.me.isSpotlightVideo=!0,this.emitter.emit(r.ME_CHANGE,{event:o.SPOTLIGHTVIDEOCHANGE,body:{newVal:!0,oldVal:null}})):(this.mtgData.me.isSpotlightVideo=!1,this.emitter.emit(r.ME_CHANGE,{event:o.SPOTLIGHTVIDEOCHANGE,body:{newVal:!1,oldVal:!0}}))),!("isInLobby"in e)||E(t.isInLobby)?[3,5]:t.isInLobby===e.isInLobby?[3,5]:(this.mtgData.me.isInLobby=e.isInLobby,this.mtgData.me.reSub=!0,this.stopPolling(),[4,this.startPolling()]);case 4:n.sent(),D(e,this.mtgData.me),!1===e.isInLobby&&(this.mtgData.me.isUpdatedUserState=!1,this.emitter.emit(r.UPDATE_USER_STATE)),this.emitter.emit(r.ME_CHANGE,{event:o.LOBBYCHANGE,body:{newVal:e.isInLobby,oldVal:!e.isInLobby}}),n.label=5;case 5:"isLeave"in e&&(this.stopKeepalive(),this.stopPolling(),this.clean(),this.connectionState=a.CLOSED,this.emitter.emit(r.ME_CHANGE,{event:o.LEAVE,body:e.resultInfo}),this.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED}),e={}),delete e.reSub,delete e.resultInfo,D(e,this.mtgData.me),n.label=6;case 6:return[2]}}))}))},d=function(t){var n=e.find((function(e){return e.name===t}));if(n){if(n.seqId=l[t].maxSeqId,!l[t].items)return;l[t].items.forEach((function(e){var t=JSON.parse(e.content),n=t.event,i=t.state,a=t.body;if("full"===i)m.mtgData[n]=a;else if("update"===i)if(m.mtgData[n]||(m.mtgData[n]=a),n.indexOf("Users")>-1)a.users&&a.users.forEach((function(e){var t=m.mtgData[n].users.findIndex((function(t){return t.userID===e.userID}));-1===t?m.mtgData[n].users.push(e):D(e,m.mtgData[n].users[t]),e.userID===m.mtgData.me.userID&&m.mtgData.me.role!==s.AUDIENCE&&c(e)}));else if("me"===n)a.users&&a.users.forEach((function(e){"userID"in e||(e.userID=m.mtgData.me.userID),c(e)}));else if("spotlightVideo"===n){(a.userIDs&&a.userIDs.findIndex((function(e){return e===m.mtgData.me.userID})))>-1?c({userID:m.mtgData.me.userID,isSpotlightVideo:!0}):m.mtgData.me.isSpotlightVideo&&c({userID:m.mtgData.me.userID,isSpotlightVideo:!1})}else"meetingState"===n&&"ended"===a.state?c({userID:m.mtgData.me.userID,resultInfo:a.resultInfo,isLeave:!0}):n.indexOf("Layout")>-1?m.mtgData[n]=a:D(a,m.mtgData[n]);else"delete"===i?n.indexOf("Users")>-1?a.users&&a.users.forEach((function(e){if(m.mtgData[n]){var t=m.mtgData[n].users.findIndex((function(t){return t.userID===e.userID}));if(t>-1&&m.mtgData[n].users.splice(t,1),e.userID===m.mtgData.me.userID){var i=Object.keys(e).length;e.role?c(e):e.resultInfo&&2===i&&(e.isLeave=!0,c(e))}}})):"me"===n&&c({userID:m.mtgData.me.userID,isLeave:!0,resultInfo:a.users&&a.users[0]&&a.users[0].resultInfo}):("meetingBarrage"===n&&m.handleBarrage(a),"setUserAudio"===n?m.emitter.emit(r.ME_CHANGE,{event:o.SETAUDIO,body:a}):"setUserVideo"===n?m.emitter.emit(r.ME_CHANGE,{event:o.SETVIDEO,body:a}):m.mtgData[n]?D(a,m.mtgData[n]):m.mtgData[n]=a);m.emitter.emit(r.MEETING_CHANGE,{event:n,body:JSON.parse(JSON.stringify(a)),state:i,stime:null})}))}},Object.keys(l).forEach(d),this.pollingStatus.attempts=0,[2]):[2]}}))}))},this.pollingStatus.timer&&(clearTimeout(this.pollingStatus.timer),this.pollingStatus.timer=null),5!==this.pollingStatus.errorTimes?[3,2]:(this.stopKeepalive(),this.clean(),this.emitter.emit(r.ME_CHANGE,{event:o.LEAVE,body:"polling.error"}),this.connectionState=a.CLOSED,this.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED,reason:{cause:"polling",data:this.pollingStatus.errors}}),[4,this.ctrl.leave({resultInfo:{bizCode:901359}})]);case 1:return c.sent(),[2];case 2:return[4,i()];case 3:return c.sent(),this.pollingStatus.running?(u=this.pollingStatus.attempts?200*this.pollingStatus.attempts:0,this.pollingStatus.timer=setTimeout((function(){l.pollingStatus.running&&l.polling(e)}),u),[2]):[2]}}))}))},l.prototype.keepalive=function(){return t(this,void 0,void 0,(function(){var e,i=this;return n(this,(function(s){switch(s.label){case 0:return e=function(){return t(i,void 0,void 0,(function(){var e,t,i,s=this;return n(this,(function(n){switch(n.label){case 0:return this.keepaliveStatus.lastReqTime=(new Date).valueOf(),[4,this.ctrl.keepalive({userID:this.mtgData.me.userID||-1}).catch((function(e){s.keepaliveStatus.attempts++,s.keepaliveStatus.errorTimes++,s.keepaliveStatus.errors.push({msg:e.message,time:(new Date).valueOf()})}))];case 1:return(e=n.sent())&&e.data?(t=e.data,(i=(void 0===t?{}:t).interval||"")?(this.keepaliveStatus.interval=i,this.keepaliveStatus.attempts=0,[2]):(this.keepaliveStatus.attempts++,[2])):(this.keepaliveStatus.attempts++,[2])}}))}))},this.keepaliveStatus.timer&&(clearTimeout(this.keepaliveStatus.timer),this.keepaliveStatus.timer=null),5!==this.keepaliveStatus.errorTimes?[3,2]:(this.stopPolling(),this.clean(),this.emitter.emit(r.ME_CHANGE,{event:o.LEAVE,body:"keepalive.error"}),this.connectionState=a.CLOSED,this.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED,reason:{cause:"polling",data:this.keepaliveStatus.errors}}),[4,this.ctrl.leave({resultInfo:{bizCode:901359}})]);case 1:return s.sent(),[2];case 2:return[4,e()];case 3:return s.sent(),this.keepaliveStatus.running?(this.keepaliveStatus.timer=setTimeout((function(){i.keepaliveStatus.running&&i.keepalive()}),1e3*(this.keepaliveStatus.interval||0)),[2]):[2]}}))}))},l.prototype.getTopics=function(e){var t=[];switch(e.endpointType){case i.WEBCTRL:t=["meeting","interactive","broadcast","lobby","hostAttendee","audience","advCtrl"];break;case i.WEBAPP:t=e.isInLobby?["lobbyMember"]:"audience"===e.role?["meeting","interactive","chat","audience"]:["meeting","interactive","broadcast","lobby","chat","hostAttendee"];break;case i.WECHATMP:t=e.isInLobby?["lobbyMember"]:"audience"===e.role?["meeting","interactive"]:["meeting","interactive","broadcast","lobby"];break;case i.SUPERVISION:t=["meeting","interactive","broadcast"]}return t},l}(),C=function(){return I.instance};return function(){function e(e){!function(e){I.createInstance(e)}(e)}return Object.defineProperty(e.prototype,"ctrl",{get:function(){return C().ctrl},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return C().mtgData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectionState",{get:function(){return C().connectionState},enumerable:!1,configurable:!0}),e.prototype.on=function(e,t){return C().emitter.on(e,t)},e.prototype.off=function(e,t){return C().emitter.off(e,t)},e.prototype.getBaseURL=function(){return C().ctrl.baseURL},e.prototype.setBaseURL=function(e){C().ctrl.setBaseURL(e)},e.prototype.getJobStatus=function(){return{polling:C().pollingStatus,keepalive:C().keepaliveStatus}},e.prototype.join=function(e){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return(t=C()).ctrl.setSessionID((i=e.endpointType,s=e.meetingNum,""+(null==i?void 0:i.toLocaleUpperCase())+b+"_"+S(new Date,"MMddHHmmss")+"_"+s)),[4,t.join(e)];case 1:return n.sent()?(t.connectionState=a.CONNECTED,t.emitter.emit(r.CONNECTION_STATE,{state:a.CONNECTED,data:t.mtgData.me.mediaContent}),[4,Promise.all([t.startPolling(),t.startKeepalive()])]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}var i,s}))}))},e.prototype.updateUserState=function(e){return t(this,void 0,void 0,(function(){var t,i,a,u,l,c,d;return n(this,(function(n){switch(n.label){case 0:return t=C(),i={audio:{deviceOn:!0,sendOn:!0,recvOn:!1},video:{deviceOn:!0,sendOn:!0,recvOn:!1},share:{deviceOn:!0,sendOn:!1,recvOn:!1}},i=e?D(e,i):i,a=JSON.parse(JSON.stringify(i)),D(a,C().mtgData.me),u=t.mtgData.me,l=u.role,c=u.initialMediaState,d=void 0===c?{audio:{sendOn:!0},video:{sendOn:!0}}:c,i.audio.sendOn=i.audio.sendOn&&d.audio.sendOn,i.video.sendOn=i.video.sendOn&&d.video.sendOn,l===s.AUDIENCE&&(i.audio.sendOn=!1,i.video.sendOn=!1),t.mtgData.me.isUpdatedUserState=!0,[4,t.ctrl.updateUserState(i)];case 1:return n.sent(),l===s.AUDIENCE&&(D(i,C().mtgData.me),!1!==a.audio.sendOn&&t.emitter.emit(r.ME_CHANGE,{event:o.AUDIOCHANGE,body:{newVal:i.audio,oldVal:a.audio}}),!1!==a.video.sendOn&&t.emitter.emit(r.ME_CHANGE,{event:o.VIDEOCHANGE,body:{newVal:i.video,oldVal:a.video}})),[2]}}))}))},e.prototype.leave=function(e){return t(this,void 0,void 0,(function(){var t,i;return n(this,(function(n){switch(n.label){case 0:return t=C(),e||(e={bizCode:901359}),[4,t.ctrl.leave({resultInfo:e})];case 1:return i=n.sent().error,[4,Promise.all([t.stopPolling(),t.stopKeepalive()])];case 2:return n.sent(),t.clean(),t.connectionState=a.CLOSED,i?(t.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED,reason:{cause:"leave",data:i}}),[2,!1]):(t.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED}),[2,!0])}}))}))},e.prototype.end=function(){return t(this,void 0,void 0,(function(){var e,t;return n(this,(function(n){switch(n.label){case 0:return[4,(e=C()).ctrl.end()];case 1:return t=n.sent().error,[4,Promise.all([e.stopPolling(),e.stopKeepalive()])];case 2:return n.sent(),e.clean(),e.connectionState=a.CLOSED,t?(e.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED,reason:{cause:"end",data:t}}),[2,!1]):(e.emitter.emit(r.CONNECTION_STATE,{state:a.CLOSED}),[2,!0])}}))}))},e.ENDPOINT_TYPE=i,e.EVENT=r,e.CONNECTION_STATE=a,e.ROLE=s,e.ME_CHANGE=o,e.MEETING_CHANGE=u,e}()}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ylink-sdk/meeting",
3
- "version": "0.1.1",
3
+ "version": "0.1.5",
4
4
  "main": "dist/ylink-sdk-meeting.umd.js",
5
5
  "module": "dist/ylink-sdk-meeting.es.js",
6
6
  "typings": "dist/index.d.ts",