diff options
author | RaindropsSys <contact@minteck.org> | 2023-04-24 14:03:36 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-04-24 14:03:36 +0200 |
commit | 633c92eae865e957121e08de634aeee11a8b3992 (patch) | |
tree | 09d881bee1dae0b6eee49db1dfaf0f500240606c /includes/external/matrix/node_modules/matrix-widget-api/lib/ClientWidgetApi.d.ts | |
parent | c4657e4509733699c0f26a3c900bab47e915d5a0 (diff) | |
download | pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.gz pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.bz2 pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.zip |
Updated 18 files, added 1692 files and deleted includes/system/compare.inc (automated)
Diffstat (limited to 'includes/external/matrix/node_modules/matrix-widget-api/lib/ClientWidgetApi.d.ts')
-rw-r--r-- | includes/external/matrix/node_modules/matrix-widget-api/lib/ClientWidgetApi.d.ts | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/includes/external/matrix/node_modules/matrix-widget-api/lib/ClientWidgetApi.d.ts b/includes/external/matrix/node_modules/matrix-widget-api/lib/ClientWidgetApi.d.ts new file mode 100644 index 0000000..12a1098 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-widget-api/lib/ClientWidgetApi.d.ts @@ -0,0 +1,114 @@ +import { EventEmitter } from "events"; +import { ITransport } from "./transport/ITransport"; +import { Widget } from "./models/Widget"; +import { Capability } from "./interfaces/Capabilities"; +import { WidgetDriver } from "./driver/WidgetDriver"; +import { IScreenshotActionResponseData } from "./interfaces/ScreenshotAction"; +import { IWidgetApiResponseData } from "./interfaces/IWidgetApiResponse"; +import { IModalWidgetOpenRequestData, IModalWidgetOpenRequestDataButton, IModalWidgetReturnData } from "./interfaces/ModalWidgetActions"; +import { IRoomEvent } from "./interfaces/IRoomEvent"; +import { Symbols } from "./Symbols"; +/** + * API handler for the client side of widgets. This raises events + * for each action received as `action:${action}` (eg: "action:screenshot"). + * Default handling can be prevented by using preventDefault() on the + * raised event. The default handling varies for each action: ones + * which the SDK can handle safely are acknowledged appropriately and + * ones which are unhandled (custom or require the client to do something) + * are rejected with an error. + * + * Events which are preventDefault()ed must reply using the transport. + * The events raised will have a default of an IWidgetApiRequest + * interface. + * + * When the ClientWidgetApi is ready to start sending requests, it will + * raise a "ready" CustomEvent. After the ready event fires, actions can + * be sent and the transport will be ready. + * + * When the widget has indicated it has loaded, this class raises a + * "preparing" CustomEvent. The preparing event does not indicate that + * the widget is ready to receive communications - that is signified by + * the ready event exclusively. + * + * This class only handles one widget at a time. + */ +export declare class ClientWidgetApi extends EventEmitter { + readonly widget: Widget; + private iframe; + private driver; + readonly transport: ITransport; + private contentLoadedActionSent; + private allowedCapabilities; + private allowedEvents; + private isStopped; + private turnServers; + /** + * Creates a new client widget API. This will instantiate the transport + * and start everything. When the iframe is loaded under the widget's + * conditions, a "ready" event will be raised. + * @param {Widget} widget The widget to communicate with. + * @param {HTMLIFrameElement} iframe The iframe the widget is in. + * @param {WidgetDriver} driver The driver for this widget/client. + */ + constructor(widget: Widget, iframe: HTMLIFrameElement, driver: WidgetDriver); + hasCapability(capability: Capability): boolean; + canUseRoomTimeline(roomId: string | Symbols.AnyRoom): boolean; + canSendRoomEvent(eventType: string, msgtype?: string | null): boolean; + canSendStateEvent(eventType: string, stateKey: string): boolean; + canSendToDeviceEvent(eventType: string): boolean; + canReceiveRoomEvent(eventType: string, msgtype?: string | null): boolean; + canReceiveStateEvent(eventType: string, stateKey: string | null): boolean; + canReceiveToDeviceEvent(eventType: string): boolean; + stop(): void; + private beginCapabilities; + private notifyCapabilities; + private onIframeLoad; + private handleContentLoadedAction; + private replyVersions; + private handleCapabilitiesRenegotiate; + private handleNavigate; + private handleOIDC; + private handleReadEvents; + private handleSendEvent; + private handleSendToDevice; + private pollTurnServers; + private handleWatchTurnServers; + private handleUnwatchTurnServers; + private handleReadRelations; + private handleUserDirectorySearch; + private handleMessage; + /** + * Takes a screenshot of the widget. + * @returns Resolves to the widget's screenshot. + * @throws Throws if there is a problem. + */ + takeScreenshot(): Promise<IScreenshotActionResponseData>; + /** + * Alerts the widget to whether or not it is currently visible. + * @param {boolean} isVisible Whether the widget is visible or not. + * @returns {Promise<IWidgetApiResponseData>} Resolves when the widget acknowledges the update. + */ + updateVisibility(isVisible: boolean): Promise<IWidgetApiResponseData>; + sendWidgetConfig(data: IModalWidgetOpenRequestData): Promise<void>; + notifyModalWidgetButtonClicked(id: IModalWidgetOpenRequestDataButton["id"]): Promise<void>; + notifyModalWidgetClose(data: IModalWidgetReturnData): Promise<void>; + /** + * Feeds an event to the widget. If the widget is not able to accept the event due to + * permissions, this will no-op and return calmly. If the widget failed to handle the + * event, this will raise an error. + * @param {IRoomEvent} rawEvent The event to (try to) send to the widget. + * @param {string} currentViewedRoomId The room ID the user is currently interacting with. + * Not the room ID of the event. + * @returns {Promise<void>} Resolves when complete, rejects if there was an error sending. + */ + feedEvent(rawEvent: IRoomEvent, currentViewedRoomId: string): Promise<void>; + /** + * Feeds a to-device event to the widget. If the widget is not able to accept the + * event due to permissions, this will no-op and return calmly. If the widget failed + * to handle the event, this will raise an error. + * @param {IRoomEvent} rawEvent The event to (try to) send to the widget. + * @param {boolean} encrypted Whether the event contents were encrypted. + * @returns {Promise<void>} Resolves when complete, rejects if there was an error sending. + */ + feedToDevice(rawEvent: IRoomEvent, encrypted: boolean): Promise<void>; +} |