@matrix-widget-toolkit/api 3.4.1 → 4.0.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.
- package/build/cjs/api/WidgetApiImpl.d.cts +179 -0
- package/build/cjs/api/WidgetApiImpl.test.d.cts +1 -0
- package/build/cjs/api/extras/capabilities.d.cts +12 -0
- package/build/cjs/api/extras/capabilities.test.d.cts +1 -0
- package/build/cjs/api/extras/displayName.d.cts +12 -0
- package/build/cjs/api/extras/displayName.test.d.cts +1 -0
- package/build/cjs/api/extras/events.d.cts +15 -0
- package/build/cjs/api/extras/events.test.d.cts +1 -0
- package/build/cjs/api/extras/index.d.cts +14 -0
- package/build/cjs/api/extras/navigateTo.d.cts +24 -0
- package/build/cjs/api/extras/navigateTo.test.d.cts +1 -0
- package/build/cjs/api/extras/originServerTs.d.cts +10 -0
- package/build/cjs/api/extras/originServerTs.test.d.cts +1 -0
- package/build/cjs/api/extras/powerLevel.d.cts +105 -0
- package/build/cjs/api/extras/powerLevel.test.d.cts +1 -0
- package/build/cjs/api/extras/redactions.d.cts +42 -0
- package/build/cjs/api/extras/redactions.test.d.cts +1 -0
- package/build/cjs/api/extras/relatesTo.d.cts +60 -0
- package/build/cjs/api/extras/relatesTo.test.d.cts +1 -0
- package/build/cjs/api/extras/roomMember.d.cts +35 -0
- package/build/cjs/api/extras/roomMember.test.d.cts +1 -0
- package/build/cjs/api/index.d.cts +8 -0
- package/build/cjs/api/parameters.d.cts +58 -0
- package/build/cjs/api/parameters.test.d.cts +1 -0
- package/build/cjs/api/registration.d.cts +33 -0
- package/build/cjs/api/registration.test.d.cts +1 -0
- package/build/cjs/api/types.d.cts +466 -0
- package/build/cjs/api/utils.d.cts +20 -0
- package/build/cjs/api/utils.test.d.cts +1 -0
- package/build/cjs/{index.js → index.cjs} +100 -48
- package/build/cjs/index.d.cts +5 -0
- package/build/esm/api/WidgetApiImpl.d.ts +179 -0
- package/build/esm/api/WidgetApiImpl.test.d.ts +1 -0
- package/build/esm/api/extras/capabilities.d.ts +12 -0
- package/build/esm/api/extras/capabilities.test.d.ts +1 -0
- package/build/esm/api/extras/displayName.d.ts +12 -0
- package/build/esm/api/extras/displayName.test.d.ts +1 -0
- package/build/esm/api/extras/events.d.ts +15 -0
- package/build/esm/api/extras/events.test.d.ts +1 -0
- package/build/esm/api/extras/index.d.ts +14 -0
- package/build/esm/api/extras/navigateTo.d.ts +24 -0
- package/build/esm/api/extras/navigateTo.test.d.ts +1 -0
- package/build/esm/api/extras/originServerTs.d.ts +10 -0
- package/build/esm/api/extras/originServerTs.test.d.ts +1 -0
- package/build/esm/api/extras/powerLevel.d.ts +105 -0
- package/build/esm/api/extras/powerLevel.test.d.ts +1 -0
- package/build/esm/api/extras/redactions.d.ts +42 -0
- package/build/esm/api/extras/redactions.test.d.ts +1 -0
- package/build/esm/api/extras/relatesTo.d.ts +60 -0
- package/build/esm/api/extras/relatesTo.test.d.ts +1 -0
- package/build/esm/api/extras/roomMember.d.ts +35 -0
- package/build/esm/api/extras/roomMember.test.d.ts +1 -0
- package/build/esm/api/index.d.ts +8 -0
- package/build/esm/api/parameters.d.ts +58 -0
- package/build/esm/api/parameters.test.d.ts +1 -0
- package/build/esm/api/registration.d.ts +33 -0
- package/build/esm/api/registration.test.d.ts +1 -0
- package/build/esm/api/types.d.ts +466 -0
- package/build/esm/api/utils.d.ts +20 -0
- package/build/esm/api/utils.test.d.ts +1 -0
- package/build/esm/index.d.ts +5 -0
- package/build/esm/index.js +99 -49
- package/build/index.d.ts +17 -2
- package/package.json +27 -15
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { Capability, IDownloadFileActionFromWidgetResponseData, IGetMediaConfigActionFromWidgetResponseData, IModalWidgetCreateData, IModalWidgetOpenRequestDataButton, IModalWidgetReturnData, IOpenIDCredentials, IRoomEvent, ISendEventFromWidgetResponseData, IUploadFileActionFromWidgetResponseData, IWidget, IWidgetApiRequest, IWidgetApiRequestData, ModalButtonID, Symbols, WidgetEventCapability } from 'matrix-widget-api';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
/**
|
|
4
|
+
* Parameters passed from the client to the widget during initialization.
|
|
5
|
+
*/
|
|
6
|
+
export type WidgetParameters = {
|
|
7
|
+
/**
|
|
8
|
+
* The user id of the current user.
|
|
9
|
+
*/
|
|
10
|
+
userId?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The display name of the current user.
|
|
13
|
+
*
|
|
14
|
+
* Might be the user id, if the user has no display name configured.
|
|
15
|
+
*/
|
|
16
|
+
displayName?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The URL of the avatar of the current user.
|
|
19
|
+
*
|
|
20
|
+
* Might be unset, if the user has no avatar configured.
|
|
21
|
+
*/
|
|
22
|
+
avatarUrl?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The room id of the room the widget is registered in.
|
|
25
|
+
*/
|
|
26
|
+
roomId?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The current selected theme in the client.
|
|
29
|
+
*
|
|
30
|
+
* Right now, it's either "light" or "dark".
|
|
31
|
+
*/
|
|
32
|
+
theme?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The id of the client that this widget is running in, for example
|
|
35
|
+
* "io.element.web".
|
|
36
|
+
*/
|
|
37
|
+
clientId?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The current selected language in the client.
|
|
40
|
+
*/
|
|
41
|
+
clientLanguage?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The homeserver base URL.
|
|
44
|
+
*/
|
|
45
|
+
baseUrl?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the widget was opened by a client or not.
|
|
48
|
+
*
|
|
49
|
+
* This is independent from whether the widget API is available or not.
|
|
50
|
+
* For example, in mobile clients this can be true, but we don't have
|
|
51
|
+
* access to widgets API there.
|
|
52
|
+
*/
|
|
53
|
+
isOpenedByClient: boolean;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Generic type for state events.
|
|
57
|
+
*/
|
|
58
|
+
export type StateEvent<T = unknown> = Omit<IRoomEvent, 'content' | 'unsigned' | 'state_key'> & {
|
|
59
|
+
state_key: string;
|
|
60
|
+
content: T;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Generic type for room events.
|
|
64
|
+
*/
|
|
65
|
+
export type RoomEvent<T = unknown> = Omit<IRoomEvent, 'content' | 'state_key' | 'unsigned'> & {
|
|
66
|
+
content: T;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Generic type for to device message events.
|
|
70
|
+
*/
|
|
71
|
+
export type ToDeviceMessageEvent<T = unknown> = {
|
|
72
|
+
type: string;
|
|
73
|
+
sender: string;
|
|
74
|
+
encrypted: boolean;
|
|
75
|
+
content: T;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Configuration of a widget, including data passed to it.
|
|
79
|
+
*/
|
|
80
|
+
export type WidgetConfig<T extends IWidgetApiRequestData> = Omit<IWidgetApiRequest & IWidget, 'data'> & {
|
|
81
|
+
data: T;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* WebRTC Ice server credentials like turn servers, type is compatible to
|
|
85
|
+
* `RTCIceServer` from WebRTC.
|
|
86
|
+
*/
|
|
87
|
+
export type TurnServer = {
|
|
88
|
+
/** One or more URLs for this turn server. */
|
|
89
|
+
urls: string[];
|
|
90
|
+
/** Username for this turn server. */
|
|
91
|
+
username: string;
|
|
92
|
+
/** Credentials for this turn server. */
|
|
93
|
+
credential: string;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Configuration of the widget in the room.
|
|
97
|
+
*/
|
|
98
|
+
export type WidgetRegistration = {
|
|
99
|
+
/**
|
|
100
|
+
* Configure an optional type.
|
|
101
|
+
*
|
|
102
|
+
* Make sure to include a custom prefix when using built-in names.
|
|
103
|
+
* You can discover the available icons in the [Element source code](https://github.com/matrix-org/matrix-react-sdk/blob/9d6d8fc666855ca0c06c71ccb30c74ac4fc8fd12/src/components/views/avatars/WidgetAvatar.tsx#L29-L39).
|
|
104
|
+
*/
|
|
105
|
+
type?: string;
|
|
106
|
+
/**
|
|
107
|
+
* The display name of the widget.
|
|
108
|
+
*/
|
|
109
|
+
name?: string;
|
|
110
|
+
/**
|
|
111
|
+
* The avatar URL used to display an icon on the widget.
|
|
112
|
+
*
|
|
113
|
+
* @remarks Not supported at the moment, as uploading avatars to the channel
|
|
114
|
+
* is not possible from a widget right now.
|
|
115
|
+
*/
|
|
116
|
+
avatarUrl?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Optional additional data that can be used to initialize the widget.
|
|
119
|
+
*/
|
|
120
|
+
data?: Record<string, unknown> | {
|
|
121
|
+
/**
|
|
122
|
+
* An optional sub title for the widget.
|
|
123
|
+
*/
|
|
124
|
+
title?: string;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* API for communication from the widget to the client.
|
|
129
|
+
*/
|
|
130
|
+
export type WidgetApi = {
|
|
131
|
+
/**
|
|
132
|
+
* The widget Id of the current widget used for the registration in the room.
|
|
133
|
+
*/
|
|
134
|
+
readonly widgetId: string;
|
|
135
|
+
/**
|
|
136
|
+
* Parameters to the widget that are transmitted via the widget URL.
|
|
137
|
+
*/
|
|
138
|
+
readonly widgetParameters: Readonly<WidgetParameters>;
|
|
139
|
+
/**
|
|
140
|
+
* Get the configuration of the widget, if available.
|
|
141
|
+
*
|
|
142
|
+
* @remarks At the moment, this is only available for modal widgets,
|
|
143
|
+
* otherwise it's `undefined`.
|
|
144
|
+
*/
|
|
145
|
+
getWidgetConfig<T extends IWidgetApiRequestData>(): Readonly<WidgetConfig<T> | undefined>;
|
|
146
|
+
/**
|
|
147
|
+
* Rerequests capabilities initially passed in the constructor.
|
|
148
|
+
*
|
|
149
|
+
* This is useful in case the user denied one or all of them.
|
|
150
|
+
*/
|
|
151
|
+
rerequestInitialCapabilities(): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* True, if the initial capabilities passed via the constructor were granted.
|
|
154
|
+
*/
|
|
155
|
+
hasInitialCapabilities(): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Request a list of capabilities.
|
|
158
|
+
*
|
|
159
|
+
* Can be called at any time, not just initially.
|
|
160
|
+
* Resolves once the user has answered the capabilities request.
|
|
161
|
+
*
|
|
162
|
+
* @param capabilities - A list of capabilities that should be requested
|
|
163
|
+
* @throws error if the capabilities request or one of the capabilities was
|
|
164
|
+
* rejected by the user
|
|
165
|
+
*/
|
|
166
|
+
requestCapabilities(capabilities: Array<WidgetEventCapability | Capability>): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Checks whether the widget has already access to the provided capabilities,
|
|
169
|
+
* without requesting them.
|
|
170
|
+
*
|
|
171
|
+
* @param capabilities - A list of capabilities that should be checked.
|
|
172
|
+
*/
|
|
173
|
+
hasCapabilities(capabilities: Array<WidgetEventCapability | Capability>): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Receive the last state event of a give type and state key from the current
|
|
176
|
+
* room if any exists.
|
|
177
|
+
*
|
|
178
|
+
* @remarks While one can type the returned event using the generic parameter
|
|
179
|
+
* `T`, it is not recommended to rely on this type till further
|
|
180
|
+
* validation of the event structure is performed.
|
|
181
|
+
*
|
|
182
|
+
* @param eventType - The type of the event to receive.
|
|
183
|
+
* @param stateKey - Specifies the state key to retrieve, uses `''` (empty
|
|
184
|
+
* string) if no state key is passed.
|
|
185
|
+
*/
|
|
186
|
+
receiveSingleStateEvent<T>(eventType: string, stateKey?: string): Promise<StateEvent<T> | undefined>;
|
|
187
|
+
/**
|
|
188
|
+
* Receives the state events of a give type from the current room if any
|
|
189
|
+
* exists.
|
|
190
|
+
*
|
|
191
|
+
* @remarks While one can type the returned event using the generic parameter
|
|
192
|
+
* `T`, it is not recommended to rely on this type till further
|
|
193
|
+
* validation of the event structure is performed.
|
|
194
|
+
*
|
|
195
|
+
* @param eventType - The type of the event to receive.
|
|
196
|
+
* @param options - Options for receiving the state event.
|
|
197
|
+
* Use `stateKey` to receive events with a specifc state
|
|
198
|
+
* key.
|
|
199
|
+
* Use `roomIds` to receive the state events from other
|
|
200
|
+
* rooms.
|
|
201
|
+
* Pass `Symbols.AnyRoom` to receive from all rooms of the
|
|
202
|
+
* user.
|
|
203
|
+
*/
|
|
204
|
+
receiveStateEvents<T>(eventType: string, options?: {
|
|
205
|
+
stateKey?: string;
|
|
206
|
+
roomIds?: string[] | Symbols.AnyRoom;
|
|
207
|
+
}): Promise<StateEvent<T>[]>;
|
|
208
|
+
/**
|
|
209
|
+
* Provide an observable that can be used to listen to state event updates of
|
|
210
|
+
* a given type in the current room.
|
|
211
|
+
* Initially, the current state event is emitted, if one exists.
|
|
212
|
+
*
|
|
213
|
+
* @remarks While one can type the returned event using the generic parameter
|
|
214
|
+
* `T`, it is not recommended to rely on this type till further
|
|
215
|
+
* validation of the event structure is performed.
|
|
216
|
+
*
|
|
217
|
+
* @param eventType - The type of the event to receive.
|
|
218
|
+
* @param options - Options for receiving the state event.
|
|
219
|
+
* Use `stateKey` to receive events with a specifc state
|
|
220
|
+
* key.
|
|
221
|
+
* Use `roomIds` to receive the state events from other
|
|
222
|
+
* rooms.
|
|
223
|
+
* Pass `Symbols.AnyRoom` to receive from all rooms of the
|
|
224
|
+
* user.
|
|
225
|
+
*/
|
|
226
|
+
observeStateEvents<T>(eventType: string, options?: {
|
|
227
|
+
stateKey?: string;
|
|
228
|
+
roomIds?: string[] | Symbols.AnyRoom;
|
|
229
|
+
}): Observable<StateEvent<T>>;
|
|
230
|
+
/**
|
|
231
|
+
* Send a state event with a given type to the current room and wait till the
|
|
232
|
+
* operation is completed.
|
|
233
|
+
* @param eventType - The type of the event to send.
|
|
234
|
+
* @param content - The content of the event.
|
|
235
|
+
* @param options - Options for sending the state event.
|
|
236
|
+
* Use `roomId` to send the state event to another room.
|
|
237
|
+
* Use `stateKey` to send a state event with a custom state
|
|
238
|
+
* key.
|
|
239
|
+
*/
|
|
240
|
+
sendStateEvent<T>(eventType: string, content: T, options?: {
|
|
241
|
+
roomId?: string;
|
|
242
|
+
stateKey?: string;
|
|
243
|
+
}): Promise<ISendEventFromWidgetResponseData>;
|
|
244
|
+
/**
|
|
245
|
+
* Receive all room events of a given type from the current room.
|
|
246
|
+
*
|
|
247
|
+
* @remarks While one can type the returned event using the generic parameter
|
|
248
|
+
* `T`, it is not recommended to rely on this type till further
|
|
249
|
+
* validation of the event structure is performed.
|
|
250
|
+
*
|
|
251
|
+
* @param eventType - The type of the event to receive.
|
|
252
|
+
* @param options - Options for receiving the room event.
|
|
253
|
+
* Use `messageType` to receive events with a specific
|
|
254
|
+
* message type.
|
|
255
|
+
* Use `roomIds` to receive the state events from other
|
|
256
|
+
* rooms.
|
|
257
|
+
* Pass `Symbols.AnyRoom` to receive from all rooms of the
|
|
258
|
+
* user.
|
|
259
|
+
*/
|
|
260
|
+
receiveRoomEvents<T>(eventType: string, options?: {
|
|
261
|
+
messageType?: string;
|
|
262
|
+
roomIds?: string[] | Symbols.AnyRoom;
|
|
263
|
+
}): Promise<Array<RoomEvent<T>>>;
|
|
264
|
+
/**
|
|
265
|
+
* Provide an observable that can be used to listen to room event updates of
|
|
266
|
+
* a given type in the current room.
|
|
267
|
+
* Initially, the previous room events are emitted.
|
|
268
|
+
*
|
|
269
|
+
* @remarks While one can type the returned event using the generic parameter
|
|
270
|
+
* `T`, it is not recommended to rely on this type till further
|
|
271
|
+
* validation of the event structure is performed.
|
|
272
|
+
*
|
|
273
|
+
* @param eventType - The type of the event to receive.
|
|
274
|
+
* @param options - Options for receiving the room event.
|
|
275
|
+
* Use `messageType` to receive events with a specific
|
|
276
|
+
* message type.
|
|
277
|
+
* Use `roomIds` to receive the state events from other
|
|
278
|
+
* rooms.
|
|
279
|
+
* Pass `Symbols.AnyRoom` to receive from all rooms of the
|
|
280
|
+
* user.
|
|
281
|
+
*/
|
|
282
|
+
observeRoomEvents<T>(eventType: string, options?: {
|
|
283
|
+
messageType?: string;
|
|
284
|
+
roomIds?: string[] | Symbols.AnyRoom;
|
|
285
|
+
}): Observable<RoomEvent<T>>;
|
|
286
|
+
/**
|
|
287
|
+
* Send a room event with a given type to the current room and wait till the
|
|
288
|
+
* operation is completed.
|
|
289
|
+
* @param eventType - The type of the event to send.
|
|
290
|
+
* @param content - The content of the event.
|
|
291
|
+
* @param options - Options for sending the room event.
|
|
292
|
+
* Use `roomId` to send the room event to another room.
|
|
293
|
+
*/
|
|
294
|
+
sendRoomEvent<T>(eventType: string, content: T, options?: {
|
|
295
|
+
roomId?: string;
|
|
296
|
+
}): Promise<RoomEvent<T>>;
|
|
297
|
+
/**
|
|
298
|
+
* Receive all events that relate to a given `eventId` by means of MSC2674.
|
|
299
|
+
* `chunk` can include state events or room events.
|
|
300
|
+
*
|
|
301
|
+
* @remarks You can only receive events where the capability to receive it was
|
|
302
|
+
* approved. If an event in `chunk` is not approved, it is silently
|
|
303
|
+
* skipped. Note that the call might return less than `limit` events
|
|
304
|
+
* due to various reasons, including missing capabilities or encrypted
|
|
305
|
+
* events.
|
|
306
|
+
*
|
|
307
|
+
* @param eventId - The id of the event to receive
|
|
308
|
+
* @param options - Options for receiving the related events.
|
|
309
|
+
* Use `roomId` to receive the event from another room.
|
|
310
|
+
* Use `limit` to control the page size.
|
|
311
|
+
* Use `from` to request the next page of events by providing
|
|
312
|
+
* `nextToken` of a previous call. If `nextToken === undefined`,
|
|
313
|
+
* no further page exists.
|
|
314
|
+
* Use `relationType` to only return events with that `rel_type`.
|
|
315
|
+
* Use `eventType` to only return events with that `type`.
|
|
316
|
+
* Use `direction` to change time-order of the chunks
|
|
317
|
+
* (default: 'b').
|
|
318
|
+
*
|
|
319
|
+
* @throws if the capability to receive the type of event is missing.
|
|
320
|
+
*/
|
|
321
|
+
readEventRelations(eventId: string, options?: {
|
|
322
|
+
roomId?: string;
|
|
323
|
+
limit?: number;
|
|
324
|
+
from?: string;
|
|
325
|
+
relationType?: string;
|
|
326
|
+
eventType?: string;
|
|
327
|
+
direction?: 'f' | 'b';
|
|
328
|
+
}): Promise<{
|
|
329
|
+
chunk: Array<RoomEvent | StateEvent>;
|
|
330
|
+
nextToken?: string;
|
|
331
|
+
}>;
|
|
332
|
+
/**
|
|
333
|
+
* Send a message to a device of a user (or multiple users / devices).
|
|
334
|
+
*
|
|
335
|
+
* @param eventType - The type of the event.
|
|
336
|
+
* @param encrypted - Whether the event should be encrypted.
|
|
337
|
+
* @param content - The content to send. This is a map of user ids, to device
|
|
338
|
+
* ids, to the content that should be send. It is possible to
|
|
339
|
+
* specify a `'*'` device, to send the content to all devices
|
|
340
|
+
* of a user.
|
|
341
|
+
*/
|
|
342
|
+
sendToDeviceMessage<T>(eventType: string, encrypted: boolean, content: {
|
|
343
|
+
[userId: string]: {
|
|
344
|
+
[deviceId: string | '*']: T;
|
|
345
|
+
};
|
|
346
|
+
}): Promise<void>;
|
|
347
|
+
/**
|
|
348
|
+
* Observes all to device messages send to the current device.
|
|
349
|
+
*
|
|
350
|
+
* @param eventType - The type of the event.
|
|
351
|
+
*/
|
|
352
|
+
observeToDeviceMessages<T>(eventType: string): Observable<ToDeviceMessageEvent<T>>;
|
|
353
|
+
/**
|
|
354
|
+
* Open a new modal, wait until the modal closes, and return the result.
|
|
355
|
+
*
|
|
356
|
+
* This function can only be called from a Widget.
|
|
357
|
+
*
|
|
358
|
+
* @param pathName - The path to include a sub path in the URL.
|
|
359
|
+
* @param name - The name of the modal.
|
|
360
|
+
* @param options - Options for opening the Modal.
|
|
361
|
+
* Use `buttons` to show buttons in the widget.
|
|
362
|
+
* Use `data` to supply optional data to the modal widget.
|
|
363
|
+
* @returns The result data of the modal widget.
|
|
364
|
+
*
|
|
365
|
+
* @throws if called from a modal widget
|
|
366
|
+
*/
|
|
367
|
+
openModal<T extends Record<string, unknown> = Record<string, unknown>, U extends IModalWidgetCreateData = IModalWidgetCreateData>(pathName: string, name: string, options?: {
|
|
368
|
+
buttons?: IModalWidgetOpenRequestDataButton[];
|
|
369
|
+
data?: U;
|
|
370
|
+
}): Promise<T | undefined>;
|
|
371
|
+
/**
|
|
372
|
+
* Enable or disable a button on a modal widget.
|
|
373
|
+
*
|
|
374
|
+
* This function can only be called from a Modal.
|
|
375
|
+
*
|
|
376
|
+
* @param buttonId - The id of the button to enable/disable.
|
|
377
|
+
* @param isEnabled - If `true`, the button is enabled.
|
|
378
|
+
* If `false`, the button is disabled.
|
|
379
|
+
*
|
|
380
|
+
* @throws if called from a non-modal widget
|
|
381
|
+
*/
|
|
382
|
+
setModalButtonEnabled(buttonId: ModalButtonID, isEnabled: boolean): Promise<void>;
|
|
383
|
+
/**
|
|
384
|
+
* Provide an observable that emits button clicks.
|
|
385
|
+
* The emitted values are the button ids.
|
|
386
|
+
*
|
|
387
|
+
* This function can only be called from a Modal.
|
|
388
|
+
*
|
|
389
|
+
* @throws if called from a non-modal widget
|
|
390
|
+
*/
|
|
391
|
+
observeModalButtons(): Observable<ModalButtonID>;
|
|
392
|
+
/**
|
|
393
|
+
* Close the modal widget.
|
|
394
|
+
*
|
|
395
|
+
* This function can only be called from a Modal.
|
|
396
|
+
*
|
|
397
|
+
* @param data - Optional data to pass to the widget that opened the modal.
|
|
398
|
+
* Defaults to `{ 'm.exited': true }`.
|
|
399
|
+
*
|
|
400
|
+
* @throws if called from a non-modal widget
|
|
401
|
+
*/
|
|
402
|
+
closeModal<T extends IModalWidgetReturnData>(data?: T): Promise<void>;
|
|
403
|
+
/**
|
|
404
|
+
* Navigate the client to the given Matrix URI.
|
|
405
|
+
*
|
|
406
|
+
* This supports:
|
|
407
|
+
* - matrix.to urls ({@link https://spec.matrix.org/v1.2/appendices/#matrixto-navigation})
|
|
408
|
+
*
|
|
409
|
+
* @remarks In future, the Matrix URI scheme will also be defined. This
|
|
410
|
+
* requires the `org.matrix.msc2931.navigate` capability.
|
|
411
|
+
*
|
|
412
|
+
* @param uri - the URI to navigate to.
|
|
413
|
+
* @throws Throws if the URI is invalid or cannot be processed.
|
|
414
|
+
*/
|
|
415
|
+
navigateTo(uri: string): Promise<void>;
|
|
416
|
+
/**
|
|
417
|
+
* Requests an OIDC token that can be used to verify the identity of the
|
|
418
|
+
* current user at the `/_matrix/federation/v1/openid/userinfo` endpoint of
|
|
419
|
+
* the home server ({@link https://spec.matrix.org/v1.2/server-server-api/#openid}).
|
|
420
|
+
* The home server can be accessed from the `matrix_server_name` property.
|
|
421
|
+
*
|
|
422
|
+
* @remarks The methods caches the token and only requests a new once if the
|
|
423
|
+
* old one expired.
|
|
424
|
+
*/
|
|
425
|
+
requestOpenIDConnectToken(): Promise<IOpenIDCredentials>;
|
|
426
|
+
/**
|
|
427
|
+
* Returns an observable containing WebRTC Ice server credentials, like turn
|
|
428
|
+
* servers, if available.
|
|
429
|
+
*/
|
|
430
|
+
observeTurnServers(): Observable<TurnServer>;
|
|
431
|
+
/**
|
|
432
|
+
* Search for users in the user directory.
|
|
433
|
+
*
|
|
434
|
+
* @param searchTerm - The term to search for.
|
|
435
|
+
* @param options - Options for searching.
|
|
436
|
+
* Use `limit` to limit the number of results to return.
|
|
437
|
+
* @returns The search results.
|
|
438
|
+
*/
|
|
439
|
+
searchUserDirectory(searchTerm: string, options?: {
|
|
440
|
+
limit?: number;
|
|
441
|
+
}): Promise<{
|
|
442
|
+
results: Array<{
|
|
443
|
+
userId: string;
|
|
444
|
+
displayName?: string;
|
|
445
|
+
avatarUrl?: string;
|
|
446
|
+
}>;
|
|
447
|
+
}>;
|
|
448
|
+
/**
|
|
449
|
+
* Get the config for the media repository.
|
|
450
|
+
* @returns Promise which resolves with an object containing the config.
|
|
451
|
+
*/
|
|
452
|
+
getMediaConfig(): Promise<IGetMediaConfigActionFromWidgetResponseData>;
|
|
453
|
+
/**
|
|
454
|
+
* Upload a file to the media repository on the homeserver.
|
|
455
|
+
* @param file - The object to upload. Something that can be sent to
|
|
456
|
+
* XMLHttpRequest.send (typically a File).
|
|
457
|
+
* @returns Resolves to the location of the uploaded file.
|
|
458
|
+
*/
|
|
459
|
+
uploadFile(file: XMLHttpRequestBodyInit): Promise<IUploadFileActionFromWidgetResponseData>;
|
|
460
|
+
/**
|
|
461
|
+
* Download a file to the media repository on the homeserver.
|
|
462
|
+
* @param contentUrl - MXC URI of the file to download
|
|
463
|
+
* @returns resolves to an object with: file - the file contents
|
|
464
|
+
*/
|
|
465
|
+
downloadFile(contentUrl: string): Promise<IDownloadFileActionFromWidgetResponseData>;
|
|
466
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Capability, IRoomEvent, ISendEventFromWidgetResponseData, Symbols, WidgetEventCapability } from 'matrix-widget-api';
|
|
2
|
+
import { StateEvent, WidgetApi } from './types';
|
|
3
|
+
export declare function convertToRawCapabilities(rawCapabilities: Array<WidgetEventCapability | Capability>): string[];
|
|
4
|
+
export declare function isDefined<T>(arg: T | null | undefined): arg is T;
|
|
5
|
+
export declare function unique<T>(items: Iterable<T>): T[];
|
|
6
|
+
export declare function equalsSet<T>(as: Set<T>, bs: Set<T>): boolean;
|
|
7
|
+
export declare function subtractSet<T>(as: Set<T>, bs: Set<T>): Set<T>;
|
|
8
|
+
export declare function isInRoom(matrixEvent: IRoomEvent, currentRoomId: string, roomIds?: string[] | Symbols.AnyRoom): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Create a state event from the arguments.
|
|
11
|
+
*
|
|
12
|
+
* @returns A state event with current timestamp origin_server_ts.
|
|
13
|
+
*/
|
|
14
|
+
export declare function makeEventFromSendStateEventResult<T>(type: string, stateKey: string, content: T, sender: string, sendResult: ISendEventFromWidgetResponseData): StateEvent<T>;
|
|
15
|
+
/**
|
|
16
|
+
* Send a state event and resolve to a "virtual" state event.
|
|
17
|
+
*
|
|
18
|
+
* @returns Promise, that resolves to a state event with current timestamp origin_server_ts.
|
|
19
|
+
*/
|
|
20
|
+
export declare function sendStateEventWithEventResult<T>(widgetApi: WidgetApi, type: string, stateKey: string, content: T): Promise<StateEvent<T>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|