import { Channel, DesktopAgent, Context, ContextHandler, Listener, AppIntent, IntentResolution, ImplementationMetadata, AppMetadata, IntentHandler, AppIdentifier, PrivateChannel } from "@finos/fdc3"; import { IRouterClient } from "../routerClient"; import { Startup } from "../Startup/Startup"; import { StandardError } from "../../types"; import { InteropChannelType } from "./types"; import { InteropMessage } from "./types"; export declare const isPrivateChannelId: (channelId: string) => Boolean; export type ChannelContextHandler = (context: Context) => void; /** * See https://stackoverflow.com/questions/45847399/friend-class-in-typescript for implementation of "friend" class */ export declare class FinsembleDesktopAgent implements DesktopAgent { #private; constructor({ routerClient, startup, windowName, }: { routerClient: IRouterClient; startup: Startup; windowName?: string; }); private privateChannelId; private isUserChannel; private fetchStartupData; private meta; private handleHeartbeat; private triggerContextListeners; private triggerIntentListener; private handlePrivateChannelEvent; private handleIntentResult; private handleIncoming; /** * Releases the queue, sending API calls to the interop service that had been deferred until a connection * was established. */ private releaseQueue; /** * This is the central point for exchanging data with the interop service. Even though some FDC3 * calls such as broadcast() are one way, we always perform a query/response with the server, at * least getting an empty response to know that it was handled. */ private exchange; /** * Performs the handshake to the interop service and starts heartbeats. * @internal */ private connect; /** * Connect to the interop service. This method can be safely called multiple times. It will only * establish a single connection. * This function is called by FSBLDesktop and FSBLFreestanding. * @internal */ start(): Promise; /** * Stops the client and puts it back into queuing state. The client * can be restarted by calling connect(). * @internal */ stop(): Promise; /** * Registers handlers which will be called if the client is disconnected from Finsemble. This is only useful when * running in freestanding apps that might continue running after Finsemble has been terminated. Users should be * prompted to restart their freestanding app when a disconnect is received. * * @param cb Handler function. * @experimental This method is not part of the FDC3 standard and may be replaced in the future with alternative mechanisms. */ onDisconnect(cb: (error: string) => void): void; /** @internal */ channelGetCurrentContext(channel: string, contextType?: string): Promise; /** * Publishes context to other apps on the desktop. * Calling broadcast at the DesktopAgent scope will push the context to whatever Channel the app is joined to. * If the app is not currently joined to a channel, calling fdc3.broadcast will have no effect. * Apps can still directly broadcast and listen to context on any channel via the methods on the Channel class. * @param context */ broadcast(context: Context): Promise; /** @internal */ channelBroadcast(channel: string, context: Context, channelType?: InteropChannelType): Promise; /** * Retrieves a list of the System channels available for the app to join. * This should include the 'global' channel. */ getUserChannels(): Promise; /** * For backwards compatibility. Retrieves a list of the System channels available for the app to join. */ getSystemChannels(): Promise; /** * Launches/links to an app by name. * If a Context object is passed in, this object will be provided to the opened application via a contextListener. * The Context argument is functionally equivalent to opening the target app with no context and broadcasting the context directly to it. * If opening errors, it returns an Error with a string from the OpenError enumeration. * * @param app * @param context */ open(app: string, context?: Context): Promise; open(app: AppIdentifier, context?: Context): Promise; /** * Find out more information about a particular intent by passing its name, and optionally its context. * * findIntent is effectively granting programmatic access to the Desktop Agent's resolver. * A promise resolving to the intent, its metadata and metadata about the apps that registered it is returned. * This can be used to raise the intent against a specific app. * * If the resolution fails, the promise will return an `Error` with a string from the `ResolveError` enumeration. * * @param intent * @param context */ findIntent(intent: string, context?: Context, resultType?: string): Promise; /** * Find all the available intents for a particular context. * * findIntents is effectively granting programmatic access to the Desktop Agent's resolver. * A promise resolving to all the intents, their metadata and metadata about the apps that registered it is returned, * based on the context types the intents have registered. * * If the resolution fails, the promise will return an `Error` with a string from the `ResolveError` enumeration. * @param context */ findIntentsByContext(context: Context, resultType?: string): Promise>; createPrivateChannel(): Promise; /** * Common implementation for raiseIntent() and raiseIntentForContext(). * * @param intent * @param context * @param target * @param forContext If true then invoked by raiseIntentForContext which gives a different meaning to context parameter */ private raiseIntentInternal; /** * Raises an intent to the desktop agent to resolve. * @param intent * @param context * @param target */ raiseIntent(intent: string, context: Context, target?: AppIdentifier): Promise; raiseIntent(intent: string, context: Context, target?: String): Promise; /** * Finds and raises an intent against a target app based purely on context data. * * raiseIntentForContext is essentially a raiseIntent without a specific intent specified, hence the same "raiseIntent" Interop message is used. * * @param context * @param target */ raiseIntentForContext(context: Context, target?: AppIdentifier): Promise; raiseIntentForContext(context: Context, target?: String): Promise; /** * Adds a listener for incoming Intents from the Agent. Unlike addContextListener, there can only be one listener for an intent. * @param intent * @param handler */ addIntentListener(intent: string, handler: IntentHandler): Promise; private listenerForPrivateChannelEvent; /** @internal */ channelOnAddContextListener(channel: string, handler: (contextType?: string) => void): Listener; /** @internal */ channelOnUnsubscribe(channel: string, handler: (contextType?: string) => void): Listener; /** @internal */ channelOnDisconnect(channel: string, handler: () => void): Listener; /** @internal */ channelDisconnect(channel: string): void; /** @internal */ channelAddContextListener(channel: string | null, contextTypeOrHandler: string | null | ContextHandler, handler?: ContextHandler): Listener & { exchangePromise: Promise<{ err?: StandardError; receiveMessage?: InteropMessage | undefined; }>; }; /** * Adds a listener for incoming context broadcast from the Desktop Agent. * If the consumer is only interested in a context of a particular type, they can use the relevant overload that allows the type to be specified. * @param contextTypeOrHandler * @param handler */ addContextListener(contextTypeOrHandler: string | null | ContextHandler, handler?: ContextHandler): Promise; /** * Joins the app to the specified channel. * If an app is joined to a channel, all fdc3.broadcast calls will go to the channel, and all listeners assigned via fdc3.addContextListener will listen on the channel. * An app can only be joined to one channel at a time. * Rejects with error if the channel is unavailable or the join request is denied. * Error with a string from the ChannelError enumeration. * @param channelId */ joinUserChannel(channelId: string): Promise; joinChannel(channelId: string): Promise; /** * Returns a Channel object for the specified channel, creating it (as an App channel) - if it does not exist. * Error with a string from the ChannelError enumeration if channel could not be created or access was denied. * @param channelId */ getOrCreateChannel(channelId: string): Promise; /** * Get all joined channels * * Known race condition: getCurrentChannels() can return an empty string if it is called before the InteropService's linker module * has completed initializing the app. This can occur if fdc3.getCurrentChannels() is the very first call that an app makes. To work around * this issue, use the interop.autoConnect config flag. A future version of the InteropService will hold off on completed registrations * until submodules have finished their work. */ getCurrentChannels(): Promise; /** * Returns the Channel object for the current channel membership. * Returns null if the app is not joined to a channel. */ getCurrentChannel(): Promise; /** * Removes the app from any channel membership. * Context broadcast and listening through the top-level fdc3.broadcast and fdc3.addContextListener will be in a no-op when the app is not on a channel. */ leaveCurrentChannel(): Promise; /** * Removes the app from the channel. * Context broadcast and listening through the top-level fdc3.broadcast and fdc3.addContextListener will be in a no-op when the app is not on the channel. */ leaveChannel(channelId: string): Promise; /** * Return specified app's meta data. */ getAppMetadata(app: AppIdentifier): Promise; /** * Return all the open instances of given appID. */ findInstances(app: AppIdentifier): Promise>; /** * Retrieves information about the FDC3 Desktop Agent implementation, such as * the implemented version of the FDC3 specification and the name of the implementation * provider. */ getInfo(): Promise; } //# sourceMappingURL=FinsembleDesktopAgent.d.ts.map