summaryrefslogtreecommitdiff
path: root/includes/external/matrix/node_modules/matrix-events-sdk/lib/ExtensibleEvents.d.ts
blob: 3103c2f41a480940a3353fe2199f182483474b90 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { IPartialEvent } from "./IPartialEvent";
import { ExtensibleEvent } from "./events/ExtensibleEvent";
import { Optional } from "./types";
import { NamespacedValue } from "./NamespacedValue";
export declare type EventInterpreter<TContentIn = object, TEvent extends ExtensibleEvent = ExtensibleEvent> = (wireEvent: IPartialEvent<TContentIn>) => Optional<TEvent>;
/**
 * Utility class for parsing and identifying event types in a renderable form. An
 * instance of this class can be created to change rendering preference depending
 * on use-case.
 */
export declare class ExtensibleEvents {
    private static _defaultInstance;
    private interpreters;
    private _unknownInterpretOrder;
    constructor();
    /**
     * Gets the default instance for all extensible event parsing.
     */
    static get defaultInstance(): ExtensibleEvents;
    /**
     * Gets the order the internal processor will use for unknown primary
     * event types.
     */
    get unknownInterpretOrder(): NamespacedValue<string, string>[];
    /**
     * Sets the order the internal processor will use for unknown primary
     * event types.
     * @param {NamespacedValue<string, string>[]} val The parsing order.
     */
    set unknownInterpretOrder(val: NamespacedValue<string, string>[]);
    /**
     * Gets the order the internal processor will use for unknown primary
     * event types.
     */
    static get unknownInterpretOrder(): NamespacedValue<string, string>[];
    /**
     * Sets the order the internal processor will use for unknown primary
     * event types.
     * @param {NamespacedValue<string, string>[]} val The parsing order.
     */
    static set unknownInterpretOrder(val: NamespacedValue<string, string>[]);
    /**
     * Registers a primary event type interpreter. Note that the interpreter might be
     * called with non-primary events if the event is being parsed as a fallback.
     * @param {NamespacedValue<string, string>} wireEventType The event type.
     * @param {EventInterpreter} interpreter The interpreter.
     */
    registerInterpreter(wireEventType: NamespacedValue<string, string>, interpreter: EventInterpreter): void;
    /**
     * Registers a primary event type interpreter. Note that the interpreter might be
     * called with non-primary events if the event is being parsed as a fallback.
     * @param {NamespacedValue<string, string>} wireEventType The event type.
     * @param {EventInterpreter} interpreter The interpreter.
     */
    static registerInterpreter(wireEventType: NamespacedValue<string, string>, interpreter: EventInterpreter): void;
    /**
     * Parses an event, trying the primary event type first. If the primary type is not known
     * then the content will be inspected to find the most suitable fallback.
     *
     * If the parsing failed or was a completely unknown type, this will return falsy.
     * @param {IPartialEvent<object>} wireFormat The event to parse.
     * @returns {Optional<ExtensibleEvent>} The parsed extensible event.
     */
    parse(wireFormat: IPartialEvent<object>): Optional<ExtensibleEvent>;
    /**
     * Parses an event, trying the primary event type first. If the primary type is not known
     * then the content will be inspected to find the most suitable fallback.
     *
     * If the parsing failed or was a completely unknown type, this will return falsy.
     * @param {IPartialEvent<object>} wireFormat The event to parse.
     * @returns {Optional<ExtensibleEvent>} The parsed extensible event.
     */
    static parse(wireFormat: IPartialEvent<object>): Optional<ExtensibleEvent>;
}