fcr-core 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/lib/base-session.d.ts +3 -0
  2. package/lib/base-session.js +8 -0
  3. package/lib/chat-connection/config.d.ts +51 -0
  4. package/lib/chat-connection/config.js +105 -0
  5. package/lib/chat-connection/index.d.ts +25 -0
  6. package/lib/chat-connection/index.js +118 -0
  7. package/lib/chat-connection/type.d.ts +17 -0
  8. package/lib/chat-connection/type.js +12 -0
  9. package/lib/engine/index.d.ts +86 -0
  10. package/lib/engine/index.js +317 -0
  11. package/lib/imports.d.ts +43 -0
  12. package/lib/imports.js +322 -0
  13. package/lib/index.d.ts +22 -0
  14. package/lib/index.js +140 -0
  15. package/lib/media-control/desktop.d.ts +1 -0
  16. package/lib/media-control/desktop.js +120 -0
  17. package/lib/media-control/mobile.d.ts +1 -0
  18. package/lib/media-control/mobile.js +168 -0
  19. package/lib/media-control/type.d.ts +640 -0
  20. package/lib/media-control/type.js +5 -0
  21. package/lib/monitor-control/index.d.ts +1 -0
  22. package/lib/monitor-control/index.js +22 -0
  23. package/lib/monitor-control/type.d.ts +16 -0
  24. package/lib/monitor-control/type.js +5 -0
  25. package/lib/peer-session/index.d.ts +1 -0
  26. package/lib/peer-session/index.js +286 -0
  27. package/lib/peer-session/type.d.ts +54 -0
  28. package/lib/peer-session/type.js +5 -0
  29. package/lib/plugins/chatroom.d.ts +1 -0
  30. package/lib/plugins/chatroom.js +331 -0
  31. package/lib/plugins/electron-rtc-plugin.d.ts +1 -0
  32. package/lib/plugins/electron-rtc-plugin.js +13 -0
  33. package/lib/plugins/rtm-plugin.d.ts +1 -0
  34. package/lib/plugins/rtm-plugin.js +13 -0
  35. package/lib/plugins/web-rtc-plugin.d.ts +1 -0
  36. package/lib/plugins/web-rtc-plugin.js +13 -0
  37. package/lib/room-control/chatroom-control/config.d.ts +51 -0
  38. package/lib/room-control/chatroom-control/config.js +105 -0
  39. package/lib/room-control/chatroom-control/index.d.ts +1 -0
  40. package/lib/room-control/chatroom-control/index.js +323 -0
  41. package/lib/room-control/chatroom-control/type.d.ts +95 -0
  42. package/lib/room-control/chatroom-control/type.js +18 -0
  43. package/lib/room-control/group-control/index.d.ts +25 -0
  44. package/lib/room-control/group-control/index.js +227 -0
  45. package/lib/room-control/index.d.ts +1 -0
  46. package/lib/room-control/index.js +459 -0
  47. package/lib/room-control/interpreter-control/index.d.ts +1 -0
  48. package/lib/room-control/interpreter-control/index.js +136 -0
  49. package/lib/room-control/interpreter-control/room.d.ts +1 -0
  50. package/lib/room-control/interpreter-control/room.js +22 -0
  51. package/lib/room-control/interpreter-control/types.d.ts +66 -0
  52. package/lib/room-control/interpreter-control/types.js +32 -0
  53. package/lib/room-control/mainroom-control/index.d.ts +1 -0
  54. package/lib/room-control/mainroom-control/index.js +181 -0
  55. package/lib/room-control/privilege-control/helper.d.ts +9 -0
  56. package/lib/room-control/privilege-control/helper.js +43 -0
  57. package/lib/room-control/privilege-control/index.d.ts +1 -0
  58. package/lib/room-control/privilege-control/index.js +245 -0
  59. package/lib/room-control/privilege-control/type.d.ts +293 -0
  60. package/lib/room-control/privilege-control/type.js +141 -0
  61. package/lib/room-control/room-connector-control/index.d.ts +1 -0
  62. package/lib/room-control/room-connector-control/index.js +160 -0
  63. package/lib/room-control/room-connector-control/type.d.ts +102 -0
  64. package/lib/room-control/room-connector-control/type.js +34 -0
  65. package/lib/room-control/room-session/index.d.ts +1 -0
  66. package/lib/room-control/room-session/index.js +286 -0
  67. package/lib/room-control/room-session/type.d.ts +61 -0
  68. package/lib/room-control/room-session/type.js +5 -0
  69. package/lib/room-control/stream-control/index.d.ts +1 -0
  70. package/lib/room-control/stream-control/index.js +341 -0
  71. package/lib/room-control/stream-control/type.d.ts +209 -0
  72. package/lib/room-control/stream-control/type.js +5 -0
  73. package/lib/room-control/type.d.ts +281 -0
  74. package/lib/room-control/type.js +23 -0
  75. package/lib/room-control/user-control/index.d.ts +1 -0
  76. package/lib/room-control/user-control/index.js +318 -0
  77. package/lib/room-control/user-control/type.d.ts +177 -0
  78. package/lib/room-control/user-control/type.js +17 -0
  79. package/lib/room-control/waitingroom-control/index.d.ts +1 -0
  80. package/lib/room-control/waitingroom-control/index.js +46 -0
  81. package/lib/room-control/whiteboard-control/board-window.d.ts +47 -0
  82. package/lib/room-control/whiteboard-control/board-window.js +396 -0
  83. package/lib/room-control/whiteboard-control/enums.d.ts +164 -0
  84. package/lib/room-control/whiteboard-control/enums.js +96 -0
  85. package/lib/room-control/whiteboard-control/index.d.ts +1 -0
  86. package/lib/room-control/whiteboard-control/index.js +342 -0
  87. package/lib/room-control/whiteboard-control/mount-manager.d.ts +4 -0
  88. package/lib/room-control/whiteboard-control/mount-manager.js +15 -0
  89. package/lib/room-control/whiteboard-control/types.d.ts +330 -0
  90. package/lib/room-control/whiteboard-control/types.js +12 -0
  91. package/lib/room-control/whiteboard-control/utils.d.ts +51 -0
  92. package/lib/room-control/whiteboard-control/utils.js +273 -0
  93. package/lib/room-control/whiteboard-control-v2/index.d.ts +35 -0
  94. package/lib/room-control/whiteboard-control-v2/index.js +242 -0
  95. package/lib/room-control/whiteboard-control-v2/main-window.d.ts +33 -0
  96. package/lib/room-control/whiteboard-control-v2/main-window.js +213 -0
  97. package/lib/room-control/whiteboard-control-v2/utils.d.ts +3 -0
  98. package/lib/room-control/whiteboard-control-v2/utils.js +39 -0
  99. package/lib/service/api.d.ts +401 -0
  100. package/lib/service/api.js +924 -0
  101. package/lib/service/type.d.ts +7 -0
  102. package/lib/service/type.js +5 -0
  103. package/lib/type.d.ts +254 -0
  104. package/lib/type.js +87 -0
  105. package/lib/utilities/cmd.d.ts +1 -0
  106. package/lib/utilities/cmd.js +7 -0
  107. package/lib/utilities/collection.d.ts +22 -0
  108. package/lib/utilities/collection.js +74 -0
  109. package/lib/utilities/error.d.ts +41 -0
  110. package/lib/utilities/error.js +68 -0
  111. package/lib/utilities/package-info.d.ts +1 -0
  112. package/lib/utilities/package-info.js +12 -0
  113. package/lib/utilities/parameters.d.ts +9 -0
  114. package/lib/utilities/parameters.js +30 -0
  115. package/lib/utilities/stream.d.ts +27 -0
  116. package/lib/utilities/stream.js +34 -0
  117. package/lib/utilities/user.d.ts +7 -0
  118. package/lib/utilities/user.js +34 -0
  119. package/package.json +98 -0
@@ -0,0 +1,281 @@
1
+ import { FcrError, FcrStreamLatencyLevel } from '..';
2
+ import { FcrCloudRecordingConfig, FcrLiveStreamingConfig, FcrLiveStreamingLayoutType, FcrLiveStreamingState, FcrMessage, FcrNetworkQualityEvent, FcrNetworkStats, FcrRecordingState, FcrRoomInfo, FcrRoomJoinOptionsWithTicket, FcrRoomJoinSnapshotOptions, FcrRoomPropertiesDeletedEvent, FcrRoomPropertiesUpdatedEvent, FcrRoomSchedule, FcrRoomState, FcrStreamEncryptionConfig, FcrStreamJoinConfig, FcrUserRole } from '../type';
3
+ import { FcrChatRoomControl } from './chatroom-control/type';
4
+ import { FcrInterpreterControl } from './interpreter-control/types';
5
+ import { FcrPrivilegeControl } from './privilege-control/type';
6
+ import { FcrRoomConnectorControl } from './room-connector-control/type';
7
+ import { FcrRoomSessionControl } from './room-session/type';
8
+ import { FcrStreamControl } from './stream-control/type';
9
+ import { FcrUserControl } from './user-control/type';
10
+ import { FcrWhiteboardControl } from './whiteboard-control/types';
11
+ export interface FcrBaseRoomControl {
12
+ /**
13
+ * Gets the user control.
14
+ */
15
+ getUserControl(): FcrUserControl;
16
+ /**
17
+ * Gets the whiteboard control.
18
+ */
19
+ getBoardControl(): FcrWhiteboardControl;
20
+ /**
21
+ * Gets the stream control.
22
+ */
23
+ getStreamControl(): FcrStreamControl;
24
+ /**
25
+ * Gets the room session control.
26
+ */
27
+ getRoomSessionControl(): FcrRoomSessionControl;
28
+ /**
29
+ * Gets the chat room control.
30
+ */
31
+ getChatRoomControl(): FcrChatRoomControl;
32
+ /**
33
+ * Gets the privilege control.
34
+ */
35
+ getPrivilegeControl(): FcrPrivilegeControl;
36
+ /**
37
+ * Gets the room connector control.
38
+ */
39
+ getRoomConnectorControl(): FcrRoomConnectorControl;
40
+ /**
41
+ * Gets the room ID.
42
+ */
43
+ getRoomInfo(): FcrRoomInfo | undefined;
44
+ /**
45
+ * Gets the room schedule.
46
+ */
47
+ getRoomSchedule(): FcrRoomSchedule | undefined;
48
+ /**
49
+ * Joins the room.
50
+ * @param options
51
+ */
52
+ join(options: FcrRoomJoinSnapshotOptions): Promise<void>;
53
+ join(options: FcrRoomJoinOptions): Promise<void>;
54
+ /**
55
+ * Leaves the room.
56
+ */
57
+ leave(): Promise<void>;
58
+ /**
59
+ * Starts the room.
60
+ */
61
+ start(): Promise<void>;
62
+ /**
63
+ * Ends the room.
64
+ */
65
+ end(): Promise<void>;
66
+ /**
67
+ * Closes the room.
68
+ */
69
+ close(): Promise<void>;
70
+ /**
71
+ * Gets the room state.
72
+ */
73
+ getRoomState(): FcrRoomState;
74
+ /**
75
+ * Gets the coordinated timestamp of the room.
76
+ */
77
+ getSyncTimestamp(): number;
78
+ /**
79
+ * Gets the room properties.
80
+ */
81
+ getRoomProperties(): Record<string, unknown>;
82
+ /**
83
+ * Gets the room properties by key path.
84
+ * @param keyPath
85
+ */
86
+ getRoomPropertiesByKeyPath(keyPath: string): unknown;
87
+ /**
88
+ * Updates the room properties.
89
+ * @param properties
90
+ * @param cause
91
+ */
92
+ updateRoomProperties(properties: Record<string, unknown>, cause?: Record<string, unknown>): Promise<void>;
93
+ /**
94
+ * Updates the increment room properties.
95
+ * @param increments
96
+ * @param cause
97
+ */
98
+ updateIncrementRoomProperties(increments: Record<string, number>, cause?: Record<string, unknown>): Promise<void>;
99
+ /**
100
+ * Deletes the room properties.
101
+ * @param keyPaths
102
+ * @param cause
103
+ */
104
+ deleteRoomProperties(keyPaths: string[], cause?: Record<string, unknown>): Promise<void>;
105
+ /**
106
+ * Starts the cloud recording.
107
+ * @param config
108
+ */
109
+ startCloudRecording(config: FcrCloudRecordingConfig): Promise<void>;
110
+ /**
111
+ * Pauses the cloud recording.
112
+ */
113
+ pauseCloudRecording(): Promise<void>;
114
+ /**
115
+ * Resumes the cloud recording.
116
+ */
117
+ resumeCloudRecording(): Promise<void>;
118
+ /**
119
+ * Stops the cloud recording.
120
+ */
121
+ stopCloudRecording(): Promise<void>;
122
+ /**
123
+ * Gets the state of the live streaming.
124
+ */
125
+ getLiveStreamingState(): FcrLiveStreamingState;
126
+ /**
127
+ * Gets the config of the live streaming.
128
+ */
129
+ getLiveStreamingConfig(): FcrLiveStreamingConfig | undefined;
130
+ /**
131
+ * Starts the live streaming.
132
+ * @param data
133
+ */
134
+ startLiveStreaming(data: FcrLiveStreamingConfig): Promise<void>;
135
+ /**
136
+ * Updates the layout of live streaming.
137
+ * @param layoutType
138
+ */
139
+ updateLiveStreamingLayout(layoutType: FcrLiveStreamingLayoutType): Promise<void>;
140
+ /**
141
+ * Stops the live streaming.
142
+ */
143
+ stopLiveStreaming(): Promise<void>;
144
+ /**
145
+ * Gets the state of the cloud recording.
146
+ */
147
+ getCloudRecordingState(): FcrRecordingState;
148
+ /**
149
+ * Sends a message to the room.
150
+ * @param payload
151
+ * @param guaranteedDelivery
152
+ */
153
+ sendRoomMessage(payload: Record<string, unknown>, guaranteedDelivery?: boolean): Promise<void>;
154
+ /**
155
+ * Adds an observer to the room.
156
+ * @param observer
157
+ */
158
+ addObserver(observer: FcrRoomObserver): void;
159
+ /**
160
+ * Removes the observer from the room.
161
+ * @param observer
162
+ */
163
+ removeObserver(observer: FcrRoomObserver): void;
164
+ }
165
+ export interface FcrMainRoomControl extends FcrBaseRoomControl {
166
+ getInterpreterControl(): FcrInterpreterControl;
167
+ enableWaitingRoom(enable: boolean): Promise<void>;
168
+ moveToWaitingRoomByUserIds(userIds: string[]): Promise<void>;
169
+ moveToWaitingRoomByUserRoles(): Promise<void>;
170
+ joinWithTicket(options: FcrRoomJoinOptionsWithTicket): Promise<void>;
171
+ }
172
+ export interface FcrSubRoomControl extends FcrBaseRoomControl {
173
+ }
174
+ export interface FcrWaitingRoomControl extends FcrBaseRoomControl {
175
+ moveToMainRoomByUserIds(userIds: string[]): Promise<void>;
176
+ moveToMainRoomByUserRoles(userRoles: FcrUserRole[]): Promise<void>;
177
+ }
178
+ export type FcrRoomJoinOptions = {
179
+ userName: string;
180
+ userRole: FcrUserRole;
181
+ userProperties?: Record<string, unknown>;
182
+ roomToken: string;
183
+ streamLatency: FcrStreamLatencyLevel;
184
+ streamEncryptionConfig?: FcrStreamEncryptionConfig;
185
+ createStreamConfigs: FcrStreamJoinConfig[];
186
+ password?: string;
187
+ platform?: number;
188
+ };
189
+ export type FcrRoomConfig = {
190
+ roomId: string;
191
+ };
192
+ export declare enum FcrUserKickOutType {
193
+ Once = 1,
194
+ Forever = 2
195
+ }
196
+ export type FcrRoomObserver = {
197
+ /**
198
+ * Callback when join room success.
199
+ * @param roomId
200
+ * @returns
201
+ */
202
+ onJoinRoomSuccess?: (roomId: string) => void;
203
+ /**
204
+ * Callback when join room failure.
205
+ * @param roomId
206
+ * @param error
207
+ * @returns
208
+ */
209
+ onJoinRoomFailure?: (roomId: string, error: FcrError) => void;
210
+ /**
211
+ * Callback to receive the room message.
212
+ * @param roomId
213
+ * @param message
214
+ * @returns
215
+ */
216
+ onRoomMessageReceived?: (roomId: string, message: FcrMessage) => void;
217
+ /**
218
+ * Callback to receive the room state updated event.
219
+ * @param roomId
220
+ * @param state
221
+ * @returns
222
+ */
223
+ onRoomStateUpdated?: (roomId: string, state: FcrRoomState) => void;
224
+ /**
225
+ * Callback to receive the cloud recording state updated event.
226
+ * @param roomId
227
+ * @param state
228
+ * @returns
229
+ */
230
+ onCloudRecordingStateUpdated?: (roomId: string, state: FcrRecordingState) => void;
231
+ /**
232
+ * Callback to receive the room properties updated event.
233
+ * @param roomId
234
+ * @param event
235
+ * @returns
236
+ */
237
+ onRoomPropertiesUpdated?: (roomId: string, event: FcrRoomPropertiesUpdatedEvent) => void;
238
+ /**
239
+ * Callback to receive the room properties deleted event.
240
+ * @param roomId
241
+ * @param event
242
+ * @returns
243
+ */
244
+ onRoomPropertiesDeleted?: (roomId: string, event: FcrRoomPropertiesDeletedEvent) => void;
245
+ /**
246
+ * Callback to receive the network quality updated event.
247
+ * @param roomId
248
+ * @param event
249
+ */
250
+ onNetworkQualityUpdated?(roomId: string, event: FcrNetworkQualityEvent): void;
251
+ /**
252
+ * Callback to receive the network stats updated event.
253
+ * @param roomId
254
+ * @param stats
255
+ */
256
+ onNetworkStatsUpdated?(roomId: string, stats: FcrNetworkStats): void;
257
+ /**
258
+ * Callback to receive the live streaming state updated event.
259
+ * @param roomId
260
+ * @param state
261
+ * @param url
262
+ */
263
+ onLiveStreamingStateUpdated?(roomId: string, state: FcrLiveStreamingState, url?: string, reason?: FcrLiveStreamingStateUpdatedReason): void;
264
+ };
265
+ export type FcrWaitingRoomObserver = FcrRoomObserver & {
266
+ onLocalUserMovedToMainRoom?: (roomId: string, event: FcrLocalUserWaitingRoomMovedEvent) => void;
267
+ };
268
+ export type FcrMainRoomObserver = FcrRoomObserver & {
269
+ onLocalUserMovedToWaitingRoom?: (roomId: string, event: FcrLocalUserWaitingRoomMovedEvent) => void;
270
+ };
271
+ export type FcrLocalUserWaitingRoomMovedEvent = FcrRoomPropertiesUpdatedEvent;
272
+ export declare enum FcrRoomType {
273
+ Mainroom = 11,
274
+ Waitingroom = 102,
275
+ Subroom = 101,
276
+ Interpreterroom = 103
277
+ }
278
+ export declare enum FcrLiveStreamingStateUpdatedReason {
279
+ USERSTOPPED = 1,
280
+ HOSTCHANGED = 2
281
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FcrUserKickOutType = exports.FcrRoomType = exports.FcrLiveStreamingStateUpdatedReason = void 0;
7
+ let FcrUserKickOutType = exports.FcrUserKickOutType = /*#__PURE__*/function (FcrUserKickOutType) {
8
+ FcrUserKickOutType[FcrUserKickOutType["Once"] = 1] = "Once";
9
+ FcrUserKickOutType[FcrUserKickOutType["Forever"] = 2] = "Forever";
10
+ return FcrUserKickOutType;
11
+ }({});
12
+ let FcrRoomType = exports.FcrRoomType = /*#__PURE__*/function (FcrRoomType) {
13
+ FcrRoomType[FcrRoomType["Mainroom"] = 11] = "Mainroom";
14
+ FcrRoomType[FcrRoomType["Waitingroom"] = 102] = "Waitingroom";
15
+ FcrRoomType[FcrRoomType["Subroom"] = 101] = "Subroom";
16
+ FcrRoomType[FcrRoomType["Interpreterroom"] = 103] = "Interpreterroom";
17
+ return FcrRoomType;
18
+ }({});
19
+ let FcrLiveStreamingStateUpdatedReason = exports.FcrLiveStreamingStateUpdatedReason = /*#__PURE__*/function (FcrLiveStreamingStateUpdatedReason) {
20
+ FcrLiveStreamingStateUpdatedReason[FcrLiveStreamingStateUpdatedReason["USERSTOPPED"] = 1] = "USERSTOPPED";
21
+ FcrLiveStreamingStateUpdatedReason[FcrLiveStreamingStateUpdatedReason["HOSTCHANGED"] = 2] = "HOSTCHANGED";
22
+ return FcrLiveStreamingStateUpdatedReason;
23
+ }({});
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,318 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.symbol.description.js");
4
+ require("core-js/modules/es.error.cause.js");
5
+ require("core-js/modules/esnext.async-iterator.filter.js");
6
+ require("core-js/modules/esnext.function.metadata.js");
7
+ require("core-js/modules/esnext.iterator.filter.js");
8
+ require("core-js/modules/esnext.map.delete-all.js");
9
+ require("core-js/modules/esnext.map.emplace.js");
10
+ require("core-js/modules/esnext.map.every.js");
11
+ require("core-js/modules/esnext.map.filter.js");
12
+ require("core-js/modules/esnext.map.find.js");
13
+ require("core-js/modules/esnext.map.find-key.js");
14
+ require("core-js/modules/esnext.map.includes.js");
15
+ require("core-js/modules/esnext.map.key-of.js");
16
+ require("core-js/modules/esnext.map.map-keys.js");
17
+ require("core-js/modules/esnext.map.map-values.js");
18
+ require("core-js/modules/esnext.map.merge.js");
19
+ require("core-js/modules/esnext.map.reduce.js");
20
+ require("core-js/modules/esnext.map.some.js");
21
+ require("core-js/modules/esnext.map.update.js");
22
+ require("core-js/modules/esnext.symbol.metadata.js");
23
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
24
+ Object.defineProperty(exports, "__esModule", {
25
+ value: true
26
+ });
27
+ exports.FcrUserControlImpl = void 0;
28
+ require("core-js/modules/es.array.push.js");
29
+ require("core-js/modules/esnext.async-iterator.find.js");
30
+ require("core-js/modules/esnext.async-iterator.for-each.js");
31
+ require("core-js/modules/esnext.async-iterator.map.js");
32
+ require("core-js/modules/esnext.async-iterator.reduce.js");
33
+ require("core-js/modules/esnext.iterator.constructor.js");
34
+ require("core-js/modules/esnext.iterator.find.js");
35
+ require("core-js/modules/esnext.iterator.for-each.js");
36
+ require("core-js/modules/esnext.iterator.map.js");
37
+ require("core-js/modules/esnext.iterator.reduce.js");
38
+ require("core-js/modules/web.dom-collections.iterator.js");
39
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
40
+ var _imports = require("../../imports");
41
+ var _type = require("../../type");
42
+ var _user = require("../../utilities/user");
43
+ var _type2 = require("./type");
44
+ var _collection = require("../../utilities/collection");
45
+ var _FcrUserControlImpl;
46
+ let _initProto;
47
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
48
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
49
+ function _applyDecs(e, t, r, n, o, a) { function i(e, t, r) { return function (n, o) { return r && r(n), e[t].call(n, o); }; } function c(e, t) { for (var r = 0; r < e.length; r++) e[r].call(t); return t; } function s(e, t, r, n) { if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined")); return e; } function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) { function m(e) { if (!h(e)) throw new TypeError("Attempted to access private element on non-instance"); } var y, v = t[0], g = t[3], b = !u; if (!b) { r || Array.isArray(v) || (v = [v]); var w = {}, S = [], A = 3 === o ? "get" : 4 === o || d ? "set" : "value"; f ? (p || d ? w = { get: _setFunctionName(function () { return g(this); }, n, "get"), set: function (e) { t[4](this, e); } } : w[A] = g, p || _setFunctionName(w[A], n, 2 === o ? "" : A)) : p || (w = Object.getOwnPropertyDescriptor(e, n)); } for (var P = e, j = v.length - 1; j >= 0; j -= r ? 2 : 1) { var D = v[j], E = r ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: n, metadata: a, addInitializer: function (e, t) { if (e.v) throw Error("attempted to call addInitializer after decoration was finished"); s(t, "An initializer", "be", !0), c.push(t); }.bind(null, I) }; try { if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);else { var k, F; O.static = l, O.private = f, f ? 2 === o ? k = function (e) { return m(e), w.value; } : (o < 4 && (k = i(w, "get", m)), 3 !== o && (F = i(w, "set", m))) : (k = function (e) { return e[n]; }, (o < 2 || 4 === o) && (F = function (e, t) { e[n] = t; })); var N = O.access = { has: f ? h.bind() : function (e) { return n in e; } }; if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) { if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); } else s(P, (p ? "field" : "method") + " decorators", "return") && (p ? S.push(P) : w[A] = P); } } finally { I.v = !0; } } return (p || d) && u.push(function (e, t) { for (var r = S.length - 1; r >= 0; r--) t = S[r].call(e, t); return t; }), p || b || (f ? d ? u.push(i(w, "get"), i(w, "set")) : u.push(2 === o ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e, n, w)), P; } function u(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol.for("Symbol.metadata")]; var f = Object.create(null == l ? null : l), p = function (e, t, r, n) { var o, a, i = [], s = function (t) { return _checkInRHS(t) === e; }, u = new Map(); function l(e) { e && i.push(c.bind(null, e)); } for (var f = 0; f < t.length; f++) { var p = t[f]; if (Array.isArray(p)) { var d = p[1], h = p[2], m = p.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v; if (!g && !m) { var w = u.get(b); if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); u.set(b, !(d > 2) || d); } applyDec(v ? e : e.prototype, p, y, m ? "#" + h : _toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r); } } return l(o), l(a), i; }(e, t, o, f); return r.length || u(e, f), { e: p, get c() { var t = []; return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t), f), c.bind(null, t, e)]; } }; }
50
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
51
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
52
+ function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
53
+ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
54
+ /**
55
+ * @internal
56
+ */
57
+ class FcrUserControlImpl {
58
+ constructor(_scene, _api) {
59
+ //@internal
60
+ (0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _imports.getLogger)()));
61
+ //@internal
62
+ (0, _defineProperty2.default)(this, "_observable", new _imports.AgoraObservable());
63
+ //@internal
64
+ (0, _defineProperty2.default)(this, "_userMapByUserId", {});
65
+ //@internal
66
+ (0, _defineProperty2.default)(this, "_userList", []);
67
+ //@internal
68
+ (0, _defineProperty2.default)(this, "_sceneObserver", {
69
+ onRemoteUsersJoined: (roomId, events) => {
70
+ const fcrUserEvents = events.map(e => {
71
+ return {
72
+ modifiedUser: e.modifiedUser && (0, _user.convertRteUserToFcrUser)(e.modifiedUser),
73
+ operatorUser: e.operatorUser && (0, _user.convertRteUserToFcrUser)(e.operatorUser)
74
+ };
75
+ });
76
+ fcrUserEvents.forEach(event => {
77
+ const user = event.modifiedUser;
78
+ const exists = user.userId in this._userMapByUserId;
79
+ if (exists) {
80
+ this.logger.warn("[FcrUserControl] user joined when the user already exists, userId: ".concat(user.userId));
81
+ } else {
82
+ this._userMapByUserId[user.userId] = user;
83
+ this._userList.push(user);
84
+ }
85
+ });
86
+ this._observable.notifyObservers('onRemoteUsersJoined', roomId, fcrUserEvents);
87
+ },
88
+ onRemoteUsersLeft: (roomId, events) => {
89
+ const fcrUserEvents = events.map(e => {
90
+ var _e$cause;
91
+ return {
92
+ modifiedUser: e.modifiedUser && (0, _user.convertRteUserToFcrUser)(e.modifiedUser),
93
+ operatorUser: e.operatorUser && (0, _user.convertRteUserToFcrUser)(e.operatorUser),
94
+ reason: ((_e$cause = e.cause) === null || _e$cause === void 0 ? void 0 : _e$cause.cmd) === 5 ? _type2.FcrUserLeftReason.kickOut : _type2.FcrUserLeftReason.LeaveRoom
95
+ };
96
+ });
97
+ fcrUserEvents.forEach(event => {
98
+ const user = event.modifiedUser;
99
+ const exists = user.userId in this._userMapByUserId;
100
+ if (!exists) {
101
+ this.logger.warn("[FcrUserControl] user left when the user does not exist, userId: ".concat(user.userId));
102
+ } else {
103
+ delete this._userMapByUserId[user.userId];
104
+ const index = this._userList.findIndex(u => user.userId === u.userId);
105
+ if (index !== -1) {
106
+ this._userList.splice(index, 1);
107
+ }
108
+ }
109
+ });
110
+ this._observable.notifyObservers('onRemoteUsersLeft', roomId, fcrUserEvents);
111
+ },
112
+ onUserUpdated: (sceneId, event) => {
113
+ const fcrUserUpdatedEvent = {
114
+ modifiedUser: event.modifiedUser && (0, _user.convertRteUserToFcrUser)(event.modifiedUser),
115
+ operatorUser: event.operatorUser && (0, _user.convertRteUserToFcrUser)(event.operatorUser),
116
+ reason: event.reason
117
+ };
118
+ const user = fcrUserUpdatedEvent.modifiedUser;
119
+ const exists = user.userId in this._userMapByUserId;
120
+ if (!exists) {
121
+ this.logger.warn("[FcrUserControl] user updated when the user does not exist, userId: ".concat(user.userId));
122
+ } else {
123
+ this._userMapByUserId[user.userId] = user;
124
+ const index = this._userList.findIndex(u => user.userId === u.userId);
125
+ if (index !== -1) {
126
+ this._userList.splice(index, 1, user);
127
+ }
128
+ }
129
+ this._observable.notifyObservers('onUserInfoUpdated', sceneId, fcrUserUpdatedEvent);
130
+ },
131
+ onAllUserCountUpdated: (sceneId, count) => {
132
+ this._observable.notifyObservers('onAllUserCountUpdated', sceneId, count);
133
+ },
134
+ onUserPropertiesUpdated: (roomId, event) => {
135
+ var _event$cause, _event$cause2;
136
+ if (((_event$cause = event.cause) === null || _event$cause === void 0 ? void 0 : _event$cause.cmd) === 5 && event.modifiedUser.userId === this._localUserId) {
137
+ const {
138
+ changedProperties
139
+ } = event;
140
+ const dirtyStateMap = {
141
+ '0': _type2.FcrUserKickedOutType.Once,
142
+ '1': _type2.FcrUserKickedOutType.Forever,
143
+ '2': 2
144
+ };
145
+ const key = (0, _imports.get)(changedProperties, 'dirty.state');
146
+ const type = dirtyStateMap[key];
147
+ this._observable.notifyObservers('onLocalUserKickedOut', roomId, {
148
+ type
149
+ });
150
+ }
151
+ if (((_event$cause2 = event.cause) === null || _event$cause2 === void 0 ? void 0 : _event$cause2.cmd) === 8) {
152
+ const changedProperties = {};
153
+ for (const key in event.changedProperties) {
154
+ if (key.startsWith('flexProps')) {
155
+ changedProperties[key] = event.changedProperties[key];
156
+ }
157
+ }
158
+ if (Object.keys(changedProperties).length > 0) {
159
+ const structure = (0, _collection.convertToStructure)(changedProperties);
160
+ this._observable.notifyObservers('onUserPropertiesUpdated', roomId, _objectSpread(_objectSpread({}, event), {}, {
161
+ changedProperties: structure['flexProps']
162
+ }));
163
+ }
164
+ }
165
+ },
166
+ onUserPropertiesDeleted: (roomId, event) => {
167
+ var _event$cause3;
168
+ if (((_event$cause3 = event.cause) === null || _event$cause3 === void 0 ? void 0 : _event$cause3.cmd) === 8) {
169
+ const changedKeyPaths = [];
170
+ for (const keyPath of event.changedKeyPaths) {
171
+ if (keyPath.startsWith('flexProps')) {
172
+ changedKeyPaths.push(keyPath);
173
+ }
174
+ }
175
+ if (changedKeyPaths.length > 0) {
176
+ this._observable.notifyObservers('onUserPropertiesDeleted', roomId, _objectSpread(_objectSpread({}, event), {}, {
177
+ changedKeyPaths
178
+ }));
179
+ }
180
+ }
181
+ }
182
+ });
183
+ this._scene = _scene;
184
+ this._api = _api;
185
+ this._scene.addObserver(this._sceneObserver);
186
+ const users = this._scene.getUsers();
187
+ this._userMapByUserId = Object.keys(users).reduce((prev, userId) => {
188
+ prev[userId] = (0, _user.convertRteUserToFcrUser)(users[userId]);
189
+ return prev;
190
+ }, {});
191
+ this._userList = this._scene.getUserList().map(_user.convertRteUserToFcrUser);
192
+ this._localUserId = this._scene.localUser.getLocalUserId();
193
+ }
194
+ getLocalUser() {
195
+ const localUserId = this._scene.localUser.getLocalUserId();
196
+ return (0, _user.convertRteUserToFcrUser)(this._scene.getUser(localUserId));
197
+ }
198
+ getUsers() {
199
+ return this._userMapByUserId;
200
+ }
201
+ getUserList() {
202
+ return this._userList;
203
+ }
204
+ getUser(userId) {
205
+ const user = this._scene.getUser(userId);
206
+ if (user) {
207
+ return (0, _user.convertRteUserToFcrUser)(user);
208
+ }
209
+ }
210
+ getAllUserCount() {
211
+ return this._scene.getUserCount();
212
+ }
213
+ getWaterMarkContent() {
214
+ const {
215
+ userId
216
+ } = this.getLocalUser();
217
+ return (0, _imports.get)(this._scene.getUserPropertiesByUserId(userId), 'security.watermark.content');
218
+ }
219
+ async fetchUserList(params) {
220
+ return await this._scene.fetchUserList(params);
221
+ }
222
+ async updateUserName(userId, userName) {
223
+ return this._api.updateUserName({
224
+ roomId: this._scene.sceneId,
225
+ userId,
226
+ userName
227
+ });
228
+ }
229
+ updateUserProperties(properties, cause, userId) {
230
+ return this._api.updateUserProperties({
231
+ roomId: this._scene.sceneId,
232
+ userUuid: userId,
233
+ properties,
234
+ cause
235
+ });
236
+ }
237
+ updateIncrementUserProperties(increments, cause, userId) {
238
+ return this._api.updateUserProperties({
239
+ roomId: this._scene.sceneId,
240
+ userUuid: userId,
241
+ increments,
242
+ cause
243
+ });
244
+ }
245
+ async deleteUserProperties(keyPath, cause, userId) {
246
+ await this._api.deleteUserProperties({
247
+ roomId: this._scene.sceneId,
248
+ userUuid: userId,
249
+ properties: keyPath,
250
+ cause
251
+ });
252
+ }
253
+ getUserProperties() {
254
+ const userProperties = this._scene.getUserProperties();
255
+ const res = {};
256
+ for (const userId in userProperties) {
257
+ var _userProperties$userI;
258
+ res[userId] = (_userProperties$userI = userProperties[userId]) === null || _userProperties$userI === void 0 ? void 0 : _userProperties$userI['flexProps'];
259
+ }
260
+ return res;
261
+ }
262
+ getUserPropertiesByUserId(userId) {
263
+ var _this$_scene$getUserP;
264
+ return (_this$_scene$getUserP = this._scene.getUserPropertiesByUserId(userId)) === null || _this$_scene$getUserP === void 0 ? void 0 : _this$_scene$getUserP['flexProps'];
265
+ }
266
+ getUserPropertiesByKeyPath(keyPath, userId) {
267
+ return this._scene.getUserPropertiesByKeyPath('flexProps.' + keyPath, userId);
268
+ }
269
+ async updateRemoteUserRole(userId, userRole) {
270
+ await this._api.updateUserRole({
271
+ roomId: this._scene.sceneId,
272
+ userId,
273
+ localRole: userRole === _type.FcrUserRole.HOST ? _type.FcrUserRoleToStringMap[_type.FcrUserRole.PARTICIPANT] : undefined,
274
+ remoteRole: _type.FcrUserRoleToStringMap[userRole]
275
+ });
276
+ }
277
+ async revokeHost() {
278
+ const userList = this.getUserList();
279
+ const originHostUser = userList.find(user => user.userRole === _type.FcrUserRole.HOST);
280
+ if (originHostUser) {
281
+ await this._api.revokeUserRole({
282
+ roomId: this._scene.sceneId,
283
+ localRole: _type.FcrUserRoleToStringMap[_type.FcrUserRole.HOST],
284
+ remoteRole: _type.FcrUserRoleToStringMap[_type.FcrUserRole.PARTICIPANT],
285
+ userId: originHostUser === null || originHostUser === void 0 ? void 0 : originHostUser.userId
286
+ });
287
+ }
288
+ }
289
+ async kickOut(userId, type) {
290
+ await this._api.kickOut(userId, type, {
291
+ roomId: this._scene.sceneId
292
+ });
293
+ }
294
+ async kickOutByUserIds(userId, type) {
295
+ return this._api.kickOutByUserIds(userId, type, {
296
+ roomId: this._scene.sceneId
297
+ });
298
+ }
299
+ async kickOutByUserRoles(userRoles, type) {
300
+ return this._api.kickOutByUserRoles(type, {
301
+ roomId: this._scene.sceneId
302
+ }, userRoles.map(role => _type.FcrUserRoleToStringMap[role]));
303
+ }
304
+ mergeAudioStream(userId) {
305
+ return this._api.mergeAudioStream(userId, {
306
+ roomId: this._scene.sceneId
307
+ });
308
+ }
309
+ addObserver(observer) {
310
+ this._observable.addObserver(observer);
311
+ }
312
+ removeObserver(observer) {
313
+ this._observable.removeObserver(observer);
314
+ }
315
+ }
316
+ exports.FcrUserControlImpl = FcrUserControlImpl;
317
+ _FcrUserControlImpl = FcrUserControlImpl;
318
+ [_initProto] = _applyDecs(_FcrUserControlImpl, [[_imports.bound, 2, "getLocalUser"], [_imports.bound, 2, "getUsers"], [_imports.bound, 2, "getUserList"], [_imports.bound, 2, "getUser"], [_imports.bound, 2, "getAllUserCount"], [_imports.bound, 2, "getWaterMarkContent"], [_imports.bound, 2, "fetchUserList"], [_imports.bound, 2, "updateUserName"], [_imports.bound, 2, "updateUserProperties"], [_imports.bound, 2, "updateIncrementUserProperties"], [_imports.bound, 2, "deleteUserProperties"], [_imports.bound, 2, "getUserProperties"], [_imports.bound, 2, "getUserPropertiesByUserId"], [_imports.bound, 2, "getUserPropertiesByKeyPath"], [_imports.bound, 2, "updateRemoteUserRole"], [_imports.bound, 2, "revokeHost"], [_imports.bound, 2, "kickOut"], [_imports.bound, 2, "addObserver"], [_imports.bound, 2, "removeObserver"]], []).e;