@unwanted/matrix-sdk-mini 34.12.0-1 → 34.12.0-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/git-revision.txt +1 -1
  2. package/lib/@types/event.d.ts +0 -19
  3. package/lib/@types/event.d.ts.map +1 -1
  4. package/lib/@types/event.js.map +1 -1
  5. package/lib/client.d.ts +2 -50
  6. package/lib/client.d.ts.map +1 -1
  7. package/lib/client.js +391 -501
  8. package/lib/client.js.map +1 -1
  9. package/lib/embedded.d.ts.map +1 -1
  10. package/lib/embedded.js +0 -1
  11. package/lib/embedded.js.map +1 -1
  12. package/lib/matrix.d.ts +0 -6
  13. package/lib/matrix.d.ts.map +1 -1
  14. package/lib/matrix.js +1 -5
  15. package/lib/matrix.js.map +1 -1
  16. package/package.json +1 -1
  17. package/src/@types/event.ts +2 -36
  18. package/src/client.ts +1 -150
  19. package/src/embedded.ts +0 -2
  20. package/src/matrix.ts +0 -13
  21. package/lib/matrixrtc/CallMembership.d.ts +0 -66
  22. package/lib/matrixrtc/CallMembership.d.ts.map +0 -1
  23. package/lib/matrixrtc/CallMembership.js +0 -197
  24. package/lib/matrixrtc/CallMembership.js.map +0 -1
  25. package/lib/matrixrtc/LivekitFocus.d.ts +0 -16
  26. package/lib/matrixrtc/LivekitFocus.d.ts.map +0 -1
  27. package/lib/matrixrtc/LivekitFocus.js +0 -20
  28. package/lib/matrixrtc/LivekitFocus.js.map +0 -1
  29. package/lib/matrixrtc/MatrixRTCSession.d.ts +0 -295
  30. package/lib/matrixrtc/MatrixRTCSession.d.ts.map +0 -1
  31. package/lib/matrixrtc/MatrixRTCSession.js +0 -1043
  32. package/lib/matrixrtc/MatrixRTCSession.js.map +0 -1
  33. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +0 -40
  34. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +0 -1
  35. package/lib/matrixrtc/MatrixRTCSessionManager.js +0 -146
  36. package/lib/matrixrtc/MatrixRTCSessionManager.js.map +0 -1
  37. package/lib/matrixrtc/focus.d.ts +0 -10
  38. package/lib/matrixrtc/focus.d.ts.map +0 -1
  39. package/lib/matrixrtc/focus.js +0 -1
  40. package/lib/matrixrtc/focus.js.map +0 -1
  41. package/lib/matrixrtc/index.d.ts +0 -7
  42. package/lib/matrixrtc/index.d.ts.map +0 -1
  43. package/lib/matrixrtc/index.js +0 -21
  44. package/lib/matrixrtc/index.js.map +0 -1
  45. package/lib/matrixrtc/types.d.ts +0 -19
  46. package/lib/matrixrtc/types.d.ts.map +0 -1
  47. package/lib/matrixrtc/types.js +0 -1
  48. package/lib/matrixrtc/types.js.map +0 -1
  49. package/lib/webrtc/audioContext.d.ts +0 -15
  50. package/lib/webrtc/audioContext.d.ts.map +0 -1
  51. package/lib/webrtc/audioContext.js +0 -46
  52. package/lib/webrtc/audioContext.js.map +0 -1
  53. package/lib/webrtc/call.d.ts +0 -560
  54. package/lib/webrtc/call.d.ts.map +0 -1
  55. package/lib/webrtc/call.js +0 -2541
  56. package/lib/webrtc/call.js.map +0 -1
  57. package/lib/webrtc/callEventHandler.d.ts +0 -37
  58. package/lib/webrtc/callEventHandler.d.ts.map +0 -1
  59. package/lib/webrtc/callEventHandler.js +0 -344
  60. package/lib/webrtc/callEventHandler.js.map +0 -1
  61. package/lib/webrtc/callEventTypes.d.ts +0 -73
  62. package/lib/webrtc/callEventTypes.d.ts.map +0 -1
  63. package/lib/webrtc/callEventTypes.js +0 -13
  64. package/lib/webrtc/callEventTypes.js.map +0 -1
  65. package/lib/webrtc/callFeed.d.ts +0 -128
  66. package/lib/webrtc/callFeed.d.ts.map +0 -1
  67. package/lib/webrtc/callFeed.js +0 -289
  68. package/lib/webrtc/callFeed.js.map +0 -1
  69. package/lib/webrtc/groupCall.d.ts +0 -323
  70. package/lib/webrtc/groupCall.d.ts.map +0 -1
  71. package/lib/webrtc/groupCall.js +0 -1337
  72. package/lib/webrtc/groupCall.js.map +0 -1
  73. package/lib/webrtc/groupCallEventHandler.d.ts +0 -31
  74. package/lib/webrtc/groupCallEventHandler.d.ts.map +0 -1
  75. package/lib/webrtc/groupCallEventHandler.js +0 -178
  76. package/lib/webrtc/groupCallEventHandler.js.map +0 -1
  77. package/lib/webrtc/mediaHandler.d.ts +0 -89
  78. package/lib/webrtc/mediaHandler.d.ts.map +0 -1
  79. package/lib/webrtc/mediaHandler.js +0 -437
  80. package/lib/webrtc/mediaHandler.js.map +0 -1
  81. package/lib/webrtc/stats/callFeedStatsReporter.d.ts +0 -8
  82. package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +0 -1
  83. package/lib/webrtc/stats/callFeedStatsReporter.js +0 -82
  84. package/lib/webrtc/stats/callFeedStatsReporter.js.map +0 -1
  85. package/lib/webrtc/stats/callStatsReportGatherer.d.ts +0 -25
  86. package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +0 -1
  87. package/lib/webrtc/stats/callStatsReportGatherer.js +0 -199
  88. package/lib/webrtc/stats/callStatsReportGatherer.js.map +0 -1
  89. package/lib/webrtc/stats/callStatsReportSummary.d.ts +0 -17
  90. package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +0 -1
  91. package/lib/webrtc/stats/callStatsReportSummary.js +0 -1
  92. package/lib/webrtc/stats/callStatsReportSummary.js.map +0 -1
  93. package/lib/webrtc/stats/connectionStats.d.ts +0 -28
  94. package/lib/webrtc/stats/connectionStats.d.ts.map +0 -1
  95. package/lib/webrtc/stats/connectionStats.js +0 -26
  96. package/lib/webrtc/stats/connectionStats.js.map +0 -1
  97. package/lib/webrtc/stats/connectionStatsBuilder.d.ts +0 -5
  98. package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +0 -1
  99. package/lib/webrtc/stats/connectionStatsBuilder.js +0 -27
  100. package/lib/webrtc/stats/connectionStatsBuilder.js.map +0 -1
  101. package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +0 -7
  102. package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +0 -1
  103. package/lib/webrtc/stats/connectionStatsReportBuilder.js +0 -121
  104. package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +0 -1
  105. package/lib/webrtc/stats/groupCallStats.d.ts +0 -22
  106. package/lib/webrtc/stats/groupCallStats.d.ts.map +0 -1
  107. package/lib/webrtc/stats/groupCallStats.js +0 -78
  108. package/lib/webrtc/stats/groupCallStats.js.map +0 -1
  109. package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +0 -10
  110. package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +0 -1
  111. package/lib/webrtc/stats/media/mediaSsrcHandler.js +0 -57
  112. package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +0 -1
  113. package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +0 -12
  114. package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +0 -1
  115. package/lib/webrtc/stats/media/mediaTrackHandler.js +0 -62
  116. package/lib/webrtc/stats/media/mediaTrackHandler.js.map +0 -1
  117. package/lib/webrtc/stats/media/mediaTrackStats.d.ts +0 -86
  118. package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +0 -1
  119. package/lib/webrtc/stats/media/mediaTrackStats.js +0 -142
  120. package/lib/webrtc/stats/media/mediaTrackStats.js.map +0 -1
  121. package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +0 -22
  122. package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +0 -1
  123. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +0 -76
  124. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +0 -1
  125. package/lib/webrtc/stats/statsReport.d.ts +0 -99
  126. package/lib/webrtc/stats/statsReport.d.ts.map +0 -1
  127. package/lib/webrtc/stats/statsReport.js +0 -32
  128. package/lib/webrtc/stats/statsReport.js.map +0 -1
  129. package/lib/webrtc/stats/statsReportEmitter.d.ts +0 -15
  130. package/lib/webrtc/stats/statsReportEmitter.d.ts.map +0 -1
  131. package/lib/webrtc/stats/statsReportEmitter.js +0 -33
  132. package/lib/webrtc/stats/statsReportEmitter.js.map +0 -1
  133. package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +0 -16
  134. package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +0 -1
  135. package/lib/webrtc/stats/summaryStatsReportGatherer.js +0 -116
  136. package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +0 -1
  137. package/lib/webrtc/stats/trackStatsBuilder.d.ts +0 -19
  138. package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +0 -1
  139. package/lib/webrtc/stats/trackStatsBuilder.js +0 -168
  140. package/lib/webrtc/stats/trackStatsBuilder.js.map +0 -1
  141. package/lib/webrtc/stats/transportStats.d.ts +0 -11
  142. package/lib/webrtc/stats/transportStats.d.ts.map +0 -1
  143. package/lib/webrtc/stats/transportStats.js +0 -1
  144. package/lib/webrtc/stats/transportStats.js.map +0 -1
  145. package/lib/webrtc/stats/transportStatsBuilder.d.ts +0 -5
  146. package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +0 -1
  147. package/lib/webrtc/stats/transportStatsBuilder.js +0 -34
  148. package/lib/webrtc/stats/transportStatsBuilder.js.map +0 -1
  149. package/lib/webrtc/stats/valueFormatter.d.ts +0 -4
  150. package/lib/webrtc/stats/valueFormatter.d.ts.map +0 -1
  151. package/lib/webrtc/stats/valueFormatter.js +0 -25
  152. package/lib/webrtc/stats/valueFormatter.js.map +0 -1
  153. package/src/matrixrtc/CallMembership.ts +0 -247
  154. package/src/matrixrtc/LivekitFocus.ts +0 -39
  155. package/src/matrixrtc/MatrixRTCSession.ts +0 -1319
  156. package/src/matrixrtc/MatrixRTCSessionManager.ts +0 -166
  157. package/src/matrixrtc/focus.ts +0 -25
  158. package/src/matrixrtc/index.ts +0 -22
  159. package/src/matrixrtc/types.ts +0 -36
  160. package/src/webrtc/audioContext.ts +0 -44
  161. package/src/webrtc/call.ts +0 -3074
  162. package/src/webrtc/callEventHandler.ts +0 -425
  163. package/src/webrtc/callEventTypes.ts +0 -93
  164. package/src/webrtc/callFeed.ts +0 -364
  165. package/src/webrtc/groupCall.ts +0 -1735
  166. package/src/webrtc/groupCallEventHandler.ts +0 -234
  167. package/src/webrtc/mediaHandler.ts +0 -484
  168. package/src/webrtc/stats/callFeedStatsReporter.ts +0 -94
  169. package/src/webrtc/stats/callStatsReportGatherer.ts +0 -219
  170. package/src/webrtc/stats/callStatsReportSummary.ts +0 -30
  171. package/src/webrtc/stats/connectionStats.ts +0 -47
  172. package/src/webrtc/stats/connectionStatsBuilder.ts +0 -28
  173. package/src/webrtc/stats/connectionStatsReportBuilder.ts +0 -140
  174. package/src/webrtc/stats/groupCallStats.ts +0 -93
  175. package/src/webrtc/stats/media/mediaSsrcHandler.ts +0 -57
  176. package/src/webrtc/stats/media/mediaTrackHandler.ts +0 -76
  177. package/src/webrtc/stats/media/mediaTrackStats.ts +0 -176
  178. package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +0 -90
  179. package/src/webrtc/stats/statsReport.ts +0 -133
  180. package/src/webrtc/stats/statsReportEmitter.ts +0 -49
  181. package/src/webrtc/stats/summaryStatsReportGatherer.ts +0 -148
  182. package/src/webrtc/stats/trackStatsBuilder.ts +0 -207
  183. package/src/webrtc/stats/transportStats.ts +0 -26
  184. package/src/webrtc/stats/transportStatsBuilder.ts +0 -48
  185. package/src/webrtc/stats/valueFormatter.ts +0 -27
@@ -1,234 +0,0 @@
1
- /*
2
- Copyright 2021 Šimon Brandner <simon.bra.ag@gmail.com>
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import { MatrixEvent } from "../models/event.ts";
18
- import { MatrixClient, ClientEvent } from "../client.ts";
19
- import { GroupCall, GroupCallIntent, GroupCallType, IGroupCallDataChannelOptions } from "./groupCall.ts";
20
- import { Room } from "../models/room.ts";
21
- import { RoomState, RoomStateEvent } from "../models/room-state.ts";
22
- import { RoomMember } from "../models/room-member.ts";
23
- import { logger } from "../logger.ts";
24
- import { EventType } from "../@types/event.ts";
25
- import { SyncState } from "../sync.ts";
26
-
27
- export enum GroupCallEventHandlerEvent {
28
- Incoming = "GroupCall.incoming",
29
- Outgoing = "GroupCall.outgoing",
30
- Ended = "GroupCall.ended",
31
- Participants = "GroupCall.participants",
32
- }
33
-
34
- export type GroupCallEventHandlerEventHandlerMap = {
35
- [GroupCallEventHandlerEvent.Incoming]: (call: GroupCall) => void;
36
- [GroupCallEventHandlerEvent.Outgoing]: (call: GroupCall) => void;
37
- [GroupCallEventHandlerEvent.Ended]: (call: GroupCall) => void;
38
- [GroupCallEventHandlerEvent.Participants]: (participants: RoomMember[], call: GroupCall) => void;
39
- };
40
-
41
- interface RoomDeferred {
42
- prom: Promise<void>;
43
- resolve?: () => void;
44
- }
45
-
46
- export class GroupCallEventHandler {
47
- public groupCalls = new Map<string, GroupCall>(); // roomId -> GroupCall
48
-
49
- // All rooms we know about and whether we've seen a 'Room' event
50
- // for them. The promise will be fulfilled once we've processed that
51
- // event which means we're "up to date" on what calls are in a room
52
- // and get
53
- private roomDeferreds = new Map<string, RoomDeferred>();
54
-
55
- public constructor(private client: MatrixClient) {}
56
-
57
- public async start(): Promise<void> {
58
- // We wait until the client has started syncing for real.
59
- // This is because we only support one call at a time, and want
60
- // the latest. We therefore want the latest state of the room before
61
- // we create a group call for the room so we can be fairly sure that
62
- // the group call we create is really the latest one.
63
- if (this.client.getSyncState() !== SyncState.Syncing) {
64
- logger.debug("GroupCallEventHandler start() waiting for client to start syncing");
65
- await new Promise<void>((resolve) => {
66
- const onSync = (): void => {
67
- if (this.client.getSyncState() === SyncState.Syncing) {
68
- this.client.off(ClientEvent.Sync, onSync);
69
- return resolve();
70
- }
71
- };
72
- this.client.on(ClientEvent.Sync, onSync);
73
- });
74
- }
75
-
76
- const rooms = this.client.getRooms();
77
-
78
- for (const room of rooms) {
79
- this.createGroupCallForRoom(room);
80
- }
81
-
82
- this.client.on(ClientEvent.Room, this.onRoomsChanged);
83
- this.client.on(RoomStateEvent.Events, this.onRoomStateChanged);
84
- }
85
-
86
- public stop(): void {
87
- this.client.removeListener(ClientEvent.Room, this.onRoomsChanged);
88
- this.client.removeListener(RoomStateEvent.Events, this.onRoomStateChanged);
89
- }
90
-
91
- private getRoomDeferred(roomId: string): RoomDeferred {
92
- let deferred = this.roomDeferreds.get(roomId);
93
- if (deferred === undefined) {
94
- let resolveFunc: () => void;
95
- deferred = {
96
- prom: new Promise<void>((resolve) => {
97
- resolveFunc = resolve;
98
- }),
99
- };
100
- deferred.resolve = resolveFunc!;
101
- this.roomDeferreds.set(roomId, deferred);
102
- }
103
-
104
- return deferred;
105
- }
106
-
107
- public waitUntilRoomReadyForGroupCalls(roomId: string): Promise<void> {
108
- return this.getRoomDeferred(roomId).prom;
109
- }
110
-
111
- public getGroupCallById(groupCallId: string): GroupCall | undefined {
112
- return [...this.groupCalls.values()].find((groupCall) => groupCall.groupCallId === groupCallId);
113
- }
114
-
115
- private createGroupCallForRoom(room: Room): void {
116
- const callEvents = room.currentState.getStateEvents(EventType.GroupCallPrefix);
117
- const sortedCallEvents = callEvents.sort((a, b) => b.getTs() - a.getTs());
118
-
119
- for (const callEvent of sortedCallEvents) {
120
- const content = callEvent.getContent();
121
-
122
- if (content["m.terminated"] || callEvent.isRedacted()) {
123
- continue;
124
- }
125
-
126
- logger.debug(
127
- `GroupCallEventHandler createGroupCallForRoom() choosing group call from possible calls (stateKey=${callEvent.getStateKey()}, ts=${callEvent.getTs()}, roomId=${
128
- room.roomId
129
- }, numOfPossibleCalls=${callEvents.length})`,
130
- );
131
-
132
- this.createGroupCallFromRoomStateEvent(callEvent);
133
- break;
134
- }
135
-
136
- this.getRoomDeferred(room.roomId).resolve!();
137
- }
138
-
139
- private createGroupCallFromRoomStateEvent(event: MatrixEvent): GroupCall | undefined {
140
- const roomId = event.getRoomId();
141
- const content = event.getContent();
142
-
143
- const room = this.client.getRoom(roomId);
144
-
145
- if (!room) {
146
- logger.warn(
147
- `GroupCallEventHandler createGroupCallFromRoomStateEvent() couldn't find room for call (roomId=${roomId})`,
148
- );
149
- return;
150
- }
151
-
152
- const groupCallId = event.getStateKey();
153
-
154
- const callType = content["m.type"];
155
-
156
- if (!Object.values(GroupCallType).includes(callType)) {
157
- logger.warn(
158
- `GroupCallEventHandler createGroupCallFromRoomStateEvent() received invalid call type (type=${callType}, roomId=${roomId})`,
159
- );
160
- return;
161
- }
162
-
163
- const callIntent = content["m.intent"];
164
-
165
- if (!Object.values(GroupCallIntent).includes(callIntent)) {
166
- logger.warn(`Received invalid group call intent (type=${callType}, roomId=${roomId})`);
167
- return;
168
- }
169
-
170
- const isPtt = Boolean(content["io.element.ptt"]);
171
-
172
- let dataChannelOptions: IGroupCallDataChannelOptions | undefined;
173
-
174
- if (content?.dataChannelsEnabled && content?.dataChannelOptions) {
175
- // Pull out just the dataChannelOptions we want to support.
176
- const { ordered, maxPacketLifeTime, maxRetransmits, protocol } = content.dataChannelOptions;
177
- dataChannelOptions = { ordered, maxPacketLifeTime, maxRetransmits, protocol };
178
- }
179
-
180
- const groupCall = new GroupCall(
181
- this.client,
182
- room,
183
- callType,
184
- isPtt,
185
- callIntent,
186
- groupCallId,
187
- // Because without Media section a WebRTC connection is not possible, so need a RTCDataChannel to set up a
188
- // no media WebRTC connection anyway.
189
- content?.dataChannelsEnabled || this.client.isVoipWithNoMediaAllowed,
190
- dataChannelOptions,
191
- this.client.isVoipWithNoMediaAllowed,
192
- this.client.useLivekitForGroupCalls,
193
- content["io.element.livekit_service_url"],
194
- );
195
-
196
- this.groupCalls.set(room.roomId, groupCall);
197
- this.client.emit(GroupCallEventHandlerEvent.Incoming, groupCall);
198
-
199
- return groupCall;
200
- }
201
-
202
- private onRoomsChanged = (room: Room): void => {
203
- this.createGroupCallForRoom(room);
204
- };
205
-
206
- private onRoomStateChanged = (event: MatrixEvent, state: RoomState): void => {
207
- const eventType = event.getType();
208
-
209
- if (eventType === EventType.GroupCallPrefix) {
210
- const groupCallId = event.getStateKey();
211
- const content = event.getContent();
212
-
213
- const currentGroupCall = this.groupCalls.get(state.roomId);
214
-
215
- if (!currentGroupCall && !content["m.terminated"] && !event.isRedacted()) {
216
- this.createGroupCallFromRoomStateEvent(event);
217
- } else if (currentGroupCall && currentGroupCall.groupCallId === groupCallId) {
218
- if (content["m.terminated"] || event.isRedacted()) {
219
- currentGroupCall.terminate(false);
220
- } else if (content["m.type"] !== currentGroupCall.type) {
221
- // TODO: Handle the callType changing when the room state changes
222
- logger.warn(
223
- `GroupCallEventHandler onRoomStateChanged() currently does not support changing type (roomId=${state.roomId})`,
224
- );
225
- }
226
- } else if (currentGroupCall && currentGroupCall.groupCallId !== groupCallId) {
227
- // TODO: Handle new group calls and multiple group calls
228
- logger.warn(
229
- `GroupCallEventHandler onRoomStateChanged() currently does not support multiple calls (roomId=${state.roomId})`,
230
- );
231
- }
232
- }
233
- };
234
- }