blob: f0cde3b7a95be6ba0687f4ad1d70f3ae51aef5f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import { Widget } from "./Widget";
import { IWidget } from "..";
export interface IStateEvent {
event_id: string;
room_id: string;
type: string;
sender: string;
origin_server_ts: number;
unsigned?: unknown;
content: unknown;
state_key: string;
}
export interface IAccountDataWidgets {
[widgetId: string]: {
type: "m.widget";
state_key: string;
sender: string;
content: IWidget;
id?: string;
};
}
export declare class WidgetParser {
private constructor();
/**
* Parses widgets from the "m.widgets" account data event. This will always
* return an array, though may be empty if no valid widgets were found.
* @param {IAccountDataWidgets} content The content of the "m.widgets" account data.
* @returns {Widget[]} The widgets in account data, or an empty array.
*/
static parseAccountData(content: IAccountDataWidgets): Widget[];
/**
* Parses all the widgets possible in the given array. This will always return
* an array, though may be empty if no widgets could be parsed.
* @param {IStateEvent[]} currentState The room state to parse.
* @returns {Widget[]} The widgets in the state, or an empty array.
*/
static parseWidgetsFromRoomState(currentState: IStateEvent[]): Widget[];
/**
* Parses a state event into a widget. If the state event does not represent
* a widget (wrong event type, invalid widget, etc) then null is returned.
* @param {IStateEvent} stateEvent The state event.
* @returns {Widget|null} The widget, or null if invalid
*/
static parseRoomWidget(stateEvent: IStateEvent): Widget | null;
private static processEstimatedWidget;
}
|