UNPKG

pluto-mae

Version:
112 lines (111 loc) 3.6 kB
/** * Events that Pluto Multi App sends to all running XRPKs * Subscribe to these events with PMAEventHandler.addEventListener() */ export declare enum PMAEventType { appAdded = "plutomae-event-app-added", appRemoved = "plutomae-event-app-removed", conversationUserUpdate = "plutomae-event-conversation-user-update", promiseResponse = "plutomae-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 = "plutomae-xrpk-event"; /** * 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 { app: { name: string; uuid: string; deviceId: string; }; currentApps: object; } interface AppRemovedArgs { app: { name: string; uuid: string; }; currentApps: object; } interface ConversationUserUpdateArgs { conversationId: string; localUserId: string; users: [object]; } interface Callback { (args: AppAddedArgs | AppRemovedArgs | ConversationUserUpdateArgs | null): void; } interface Vector3 { x: number; y: number; z: number; } interface ModelLoaderData { url: string; name: string; isStatic: boolean; } interface AppState { appId?: string; initialPosition?: Vector3; modelLoader?: ModelLoaderData; } declare global { interface Window { AppState: AppState; } } /** * Pluto Multi App Event Handler * Use this class to send and receive events to and from Pluto Multi App */ export default class PMAEventHandler { private _appId?; private _eventHandler; private _openPromises; constructor(); /** * 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 app. Must link directly to the file (ie. .wbn file) * @param position A vector 3 that tells Pluto Multi App Launcher where to initially position the app once launched (if supported by the app) * @returns A promise once a response is receieved from Pluto Multi App */ launchXRPK(linkUrl: string, position: Vector3): 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>; /** * App State is provided to every app by Pluto Multi App Launcher * @returns The App State object, or an empty object if the App State does not exist */ getAppState(): AppState; private handleResponse; private generateResponseId; private isXRPK; } export {};