UNPKG

pluto-mams

Version:
86 lines (85 loc) 2.95 kB
/** * Events that Pluto Multi App sends to all running XRPKs * Subscribe to these events with PMAEventHandler.addEventListener() */ export declare enum PMAEventType { appAdded = "plutomams-event-app-added", appRemoved = "plutomams-event-app-removed", conversationUserUpdate = "plutomams-event-conversation-user-update", promiseResponse = "plutomams-event-promise-response" } /** * All events from an XRPK are sent using this type * @disclaimer Not intended to be used directly. Use the provided public functions to send events to Pluto Multi App * */ export declare const XRPKEventType = "plutomams-xrpk-message"; /** * Event descriptions that can be sent to Pluto Multi App from an XRPK * @disclaimer These are not event types, but descriptions of events. Use the provided public functions to send events to Pluto Multi App */ export declare enum XRPKEventTypeDescription { launchXRPK = "launch-xrpk", removeXRPK = "remove-xrpk", getAppList = "retrieve-app-list" } interface AppAddedArgs { name: string; uuid: string; deviceId: string; currentApps: object; } interface AppRemovedArgs { name: string; uuid: string; currentApps: object; } interface ConversationUserUpdateArgs { conversationId: string; localUserId: string; users: [object]; } interface Callback { (args: AppAddedArgs | AppRemovedArgs | ConversationUserUpdateArgs | null): void; } /** * Pluto Multi App Event Handler * Use this class to send and receive messages to and from Pluto Multi App */ export default class PMAEventHandler { private _appId; private _eventHandler; private _openPromises; constructor(); /** * Get the app ID of this XRPK, provided by Pluto Multi App */ get appId(): string; /** * Add an event listenter for Pluto Multi App Events * @param type The `PlutoMAEventType` to subscribe to * @param callback The callback to run when the event is receieved */ addEventListener(type: PMAEventType, callback: Callback): void; /** * Request to launch an XRPK in Pluto Multi App * @param linkUrl The url of the XRPK. Must link directly to the file (ie. .wbn file) * @returns A promise once a response is receieved from Pluto Multi App */ launchXRPK(linkUrl: string): Promise<unknown>; /** * Request to remove an XRPK in Pluto Multi App * @param appIdToRemove The app ID of the app to be removed * @returns A promise once a response is receieved from Pluto Multi App */ removeXRPK(appIdToRemove: string): Promise<unknown>; /** * Get the current app list from Pluto Multi App * @return A promise that when resolved includes the app list * @returns A promise once a response is receieved from Pluto Multi App */ retrieveAppList(): Promise<unknown>; private handleResponse; private generateResponseId; private isIframe; } export {};