import type * as FDC3v1 from './shapes/fdc3v1'; import { Base } from '../../base'; /** * @typedef { object } Listener * @summary Listener object returned by addContextListener and addIntentListener * @property {function} unsubscribe function for addContextListener and addIntentListener. */ /** * @typedef { object } Channel * @summary Information for a Context Group. Contains metadata for displaying the group properly. * @property {string} id Name of the context group * @property {DisplayMetadata} displayMetadata Metadata for the Context Group. Contains the group's human-readable name, color, and an image, as defined by the Interop Broker. * @property {string} type Defaults to system. * @property {function} broadcast Broadcasts a context for the channel. * @property {function} addContextListener Add a context handler for incoming context. * @property {function} getCurrentContext Gets the current context for the channel. */ /** * @typedef { object } AppMetadata * @summary App metadata is provided by the FDC3 App Directory. * @property {string} name * @property {string} [appId] * @property {string} [version] * @property {string} [title] * @property {string} [tooltip] * @property {string} [description] * @property {Array} [icons] * @property {Array} [images] */ /** * @typedef { string | AppMetadata } TargetApp * @summary Some operations can identify an app just by its name, or pass full app metadata. */ /** * @typedef { object } IntentResolution * @summary IntentResolution provides a standard format for data returned upon resolving an Intent. * @property { TargetApp } source identifier for the Application resolving the Intent (null if the Intent could not be resolved) * @property { string } [data] Return data structure - if one is provided for the given Intent. * @property { string } version The version number of the Intents schema being used */ /** * @typedef { object } AppIntent * @summary An interface that represents the binding of an intent to apps. * @property { Intent } intent * @property { Array } apps */ /** * @typedef { object } ImplementationMetadata * @summary An interface that represents FDC3 implementation meta data. * @property { string } fdc3Version The FDC3 version * @property { string } provider The provider uuid with prepend 'openfin' * @property { string } [providerVersion] The provider runtime version */ /** * @class * @alias fdc3 * @version 1.2 * @hideconstructor * @desc The FDC3 Client Library provides a set APIs to be used for FDC3 compliance, * while using our Interop API under the hood. In order to use this set of APIs * you will need to set up your own {@link InteropBroker InteropBroker} or use a Platform application, which does the setup for you. Refer to our documentation on * our {@link https://developers.openfin.co/of-docs/docs/enable-color-linking Interop API}. * * To enable the FDC3 APIs in a {@link Window Window} or {@link View View}, add the fdc3InteropApi * property to its options: * * ```js * { * autoShow: false, * saveWindowState: true, * url: 'https://openfin.co', * fdc3InteropApi: '1.2' * } * ``` * * If using a {@link Platform Platform } application, you can set this property in defaultWindowOptions and defaultViewOptions. * * In order to ensure that the FDC3 Api is ready before use, you can use the 'fdc3Ready' event fired on the DOM Window object: * * ```js * function fdc3Action() { * // Make some fdc3 API calls here * } * * if (window.fdc3) { * fdc3Action(); * } else { * window.addEventListener('fdc3Ready', fdc3Action); * } * ``` */ export default class Fdc3Module extends Base implements FDC3v1.DesktopAgent { /** * Add a context handler for incoming context. If an entity is part of a context group, and then sets its context handler, it will receive all of its declared contexts. If you wish to listen for all incoming contexts, pass `null` for the contextType argument. * @param { string | null } contextType - The type of context you wish to handle. * @param { ContextHandler } handler - Handler for incoming context. * @returns { Listener } * @tutorial fdc3.addContextListener * @static */ addContextListener(contextType: string | null, handler: FDC3v1.ContextHandler): FDC3v1.Listener & Promise; /** * Broadcasts a context for the channel of the current entity. * @param { Context } context - New context to set. * @returns { Promise } * @tutorial fdc3.broadcast * @static */ broadcast(context: FDC3v1.Context): Promise; /** * Returns the Interop-Broker-defined context groups available for an entity to join. * @returns { Promise} * @tutorial fdc3.getSystemChannels * @static */ getSystemChannels(): Promise; /** * Join all Interop Clients at the given identity to context group `contextGroupId`. * If no target is specified, it adds the sender to the context group. * Because multiple Channel connections/Interop Clients can potentially exist at a `uuid`/`name` combo, we currently join all Channel connections/Interop Clients at the given identity to the context group. * If an `endpointId` is provided (which is unlikely, unless the call is coming from an external adapter), then we only join that single connection to the context group. * For all intents and purposes, there will only be 1 connection present in Platform and Browser implementations, so this point is more-or-less moot. * @param { string } channelId - Id of the context group. * @returns { Promise } * @tutorial fdc3.joinChannel * @static */ joinChannel(channelId: string): Promise; /** * Removes the specified target from a context group. * If no target is specified, it removes the sender from their context group. * @returns { Promise } * @tutorial fdc3.leaveCurrentChannel * @static */ leaveCurrentChannel(): Promise; /** * Adds a listener for incoming Intents. * @param { string } intent - Name of the Intent * @param { IntentHandler } handler - Handler for incoming Intent * @returns { Listener } * @tutorial fdc3.addIntentListener * @static */ addIntentListener(intent: string, handler: FDC3v1.ContextHandler): FDC3v1.Listener & Promise; /** * Raises a specific intent. * @param { string } intent Name of the Intent. * @param { Context } context Context associated with the Intent. * @param { TargetApp } app App that will resolve the Intent. This is added as metadata to the Intent. Can be accessed by the app provider in {@link InteropBroker#handleFiredIntent InteropBroker.handleFiredIntent}. * @returns { IntentResolution } * @tutorial fdc3.raiseIntent * @static */ raiseIntent(intent: string, context: FDC3v1.Context, app?: FDC3v1.TargetApp): Promise; /** * Returns the Channel that the entity is subscribed to. Returns null if not joined to a channel. * @returns { Channel | null } * @tutorial fdc3.getCurrentChannel */ getCurrentChannel(): Promise; /** * Find out more information about a particular intent by passing its name, and optionally its context. * @param { string } intent Name of the Intent * @param { Context } [context] * @return { Promise } * @tutorial fdc3.findIntent */ findIntent(intent: string, context?: FDC3v1.Context): Promise; /** * Find all the available intents for a particular context. * @param { Context } context * @return { Promise> } * @tutorial fdc3.findIntentsByContext */ findIntentsByContext(context: FDC3v1.Context): Promise>; /** * Finds and raises an intent against a target app based purely on context data. * @param { Context } context * @param { TargetApp } [app] * @return { Promise } * @tutorial fdc3.raiseIntentForContext */ raiseIntentForContext(context: FDC3v1.Context, app?: FDC3v1.TargetApp): Promise; /** * Returns a Channel object for the specified channel, creating it as an App Channel if it does not exist. * @param channelId * @returns { Promise } * @tutorial fdc3.getOrCreateChannel */ getOrCreateChannel(channelId: string): Promise; /** * Returns metadata relating to the FDC3 object and its provider, including the supported version of the FDC3 specification and the name of the provider of the implementation. * @return { Promise } * @tutorial fdc3.getInfo */ getInfo(): FDC3v1.ImplementationMetadata; /** * Launches an app with target information, which can either be a string or an AppMetadata object. * @param { TargetApp } app * @param { Context } [context] * @return { Promise } * @tutorial fdc3.open */ open(app: FDC3v1.TargetApp, context?: FDC3v1.Context): Promise; private getCurrentContextGroupInfo; private buildChannelObject; }