@openfin/core 25.68.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/NOTICE +16 -0
- package/OpenFin.d.ts +1340 -0
- package/README.md +41 -0
- package/docs.README(OLD).md +82 -0
- package/fin.d.ts +4 -0
- package/package.json +33 -0
- package/resources/win/OpenFinRVM.exe +0 -0
- package/src/api/application/Factory.d.ts +145 -0
- package/src/api/application/Factory.js +229 -0
- package/src/api/application/Instance.d.ts +302 -0
- package/src/api/application/Instance.js +412 -0
- package/src/api/application/index.d.ts +3 -0
- package/src/api/application/index.js +15 -0
- package/src/api/base.d.ts +43 -0
- package/src/api/base.js +177 -0
- package/src/api/clipboard/index.d.ts +69 -0
- package/src/api/clipboard/index.js +88 -0
- package/src/api/events/application.d.ts +69 -0
- package/src/api/events/application.js +2 -0
- package/src/api/events/base.d.ts +17 -0
- package/src/api/events/base.js +2 -0
- package/src/api/events/channel.d.ts +10 -0
- package/src/api/events/channel.js +2 -0
- package/src/api/events/emitterMap.d.ts +11 -0
- package/src/api/events/emitterMap.js +35 -0
- package/src/api/events/eventAggregator.d.ts +5 -0
- package/src/api/events/eventAggregator.js +43 -0
- package/src/api/events/externalApplication.d.ts +5 -0
- package/src/api/events/externalApplication.js +2 -0
- package/src/api/events/frame.d.ts +9 -0
- package/src/api/events/frame.js +2 -0
- package/src/api/events/globalHotkey.d.ts +10 -0
- package/src/api/events/globalHotkey.js +2 -0
- package/src/api/events/platform.d.ts +18 -0
- package/src/api/events/platform.js +2 -0
- package/src/api/events/system.d.ts +22 -0
- package/src/api/events/system.js +2 -0
- package/src/api/events/view.d.ts +56 -0
- package/src/api/events/view.js +2 -0
- package/src/api/events/webcontents.d.ts +48 -0
- package/src/api/events/webcontents.js +2 -0
- package/src/api/events/window.d.ts +169 -0
- package/src/api/events/window.js +2 -0
- package/src/api/external-application/Factory.d.ts +26 -0
- package/src/api/external-application/Factory.js +40 -0
- package/src/api/external-application/Instance.d.ts +102 -0
- package/src/api/external-application/Instance.js +109 -0
- package/src/api/external-application/index.d.ts +3 -0
- package/src/api/external-application/index.js +15 -0
- package/src/api/fin.d.ts +49 -0
- package/src/api/fin.js +43 -0
- package/src/api/frame/Factory.d.ts +36 -0
- package/src/api/frame/Factory.js +69 -0
- package/src/api/frame/Instance.d.ts +121 -0
- package/src/api/frame/Instance.js +130 -0
- package/src/api/frame/index.d.ts +3 -0
- package/src/api/frame/index.js +15 -0
- package/src/api/global-hotkey/index.d.ts +38 -0
- package/src/api/global-hotkey/index.js +58 -0
- package/src/api/interappbus/channel/channel.d.ts +26 -0
- package/src/api/interappbus/channel/channel.js +77 -0
- package/src/api/interappbus/channel/channels-docs.d.ts +318 -0
- package/src/api/interappbus/channel/channels-docs.js +376 -0
- package/src/api/interappbus/channel/client.d.ts +22 -0
- package/src/api/interappbus/channel/client.js +84 -0
- package/src/api/interappbus/channel/connection-manager.d.ts +28 -0
- package/src/api/interappbus/channel/connection-manager.js +244 -0
- package/src/api/interappbus/channel/index.d.ts +22 -0
- package/src/api/interappbus/channel/index.js +121 -0
- package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +13 -0
- package/src/api/interappbus/channel/protocols/classic/message-receiver.js +73 -0
- package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +22 -0
- package/src/api/interappbus/channel/protocols/classic/strategy.js +84 -0
- package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +20 -0
- package/src/api/interappbus/channel/protocols/combined/strategy.js +58 -0
- package/src/api/interappbus/channel/protocols/index.d.ts +44 -0
- package/src/api/interappbus/channel/protocols/index.js +2 -0
- package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +10 -0
- package/src/api/interappbus/channel/protocols/protocol-manager.js +43 -0
- package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +23 -0
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +135 -0
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +30 -0
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +131 -0
- package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +22 -0
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +87 -0
- package/src/api/interappbus/channel/protocols/strategy-types.d.ts +13 -0
- package/src/api/interappbus/channel/protocols/strategy-types.js +2 -0
- package/src/api/interappbus/channel/protocols/strategy.d.ts +15 -0
- package/src/api/interappbus/channel/protocols/strategy.js +2 -0
- package/src/api/interappbus/channel/provider.d.ts +31 -0
- package/src/api/interappbus/channel/provider.js +165 -0
- package/src/api/interappbus/index.d.ts +85 -0
- package/src/api/interappbus/index.js +175 -0
- package/src/api/interop/Factory.d.ts +37 -0
- package/src/api/interop/Factory.js +54 -0
- package/src/api/interop/InteropBroker.d.ts +363 -0
- package/src/api/interop/InteropBroker.js +914 -0
- package/src/api/interop/InteropClient.d.ts +268 -0
- package/src/api/interop/InteropClient.js +450 -0
- package/src/api/interop/SessionContextGroupBroker.d.ts +26 -0
- package/src/api/interop/SessionContextGroupBroker.js +107 -0
- package/src/api/interop/SessionContextGroupClient.d.ts +20 -0
- package/src/api/interop/SessionContextGroupClient.js +85 -0
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +187 -0
- package/src/api/interop/fdc3/fdc3-1.2.js +385 -0
- package/src/api/interop/fdc3/fdc3.js +17 -0
- package/src/api/interop/fdc3/utils.d.ts +6 -0
- package/src/api/interop/fdc3/utils.js +17 -0
- package/src/api/interop/index.d.ts +4 -0
- package/src/api/interop/index.js +16 -0
- package/src/api/interop/utils.d.ts +11 -0
- package/src/api/interop/utils.js +36 -0
- package/src/api/me.d.ts +35 -0
- package/src/api/me.js +60 -0
- package/src/api/platform/Factory.d.ts +109 -0
- package/src/api/platform/Factory.js +188 -0
- package/src/api/platform/Instance.d.ts +122 -0
- package/src/api/platform/Instance.js +299 -0
- package/src/api/platform/common-utils.d.ts +6 -0
- package/src/api/platform/common-utils.js +16 -0
- package/src/api/platform/index.d.ts +3 -0
- package/src/api/platform/index.js +15 -0
- package/src/api/platform/layout/Factory.d.ts +108 -0
- package/src/api/platform/layout/Factory.js +189 -0
- package/src/api/platform/layout/Instance.d.ts +48 -0
- package/src/api/platform/layout/Instance.js +99 -0
- package/src/api/platform/layout/index.d.ts +3 -0
- package/src/api/platform/layout/index.js +15 -0
- package/src/api/platform/layout/shapes.d.ts +11 -0
- package/src/api/platform/layout/shapes.js +2 -0
- package/src/api/snapshot-source/Factory.d.ts +36 -0
- package/src/api/snapshot-source/Factory.js +65 -0
- package/src/api/snapshot-source/Instance.d.ts +30 -0
- package/src/api/snapshot-source/Instance.js +134 -0
- package/src/api/snapshot-source/index.d.ts +3 -0
- package/src/api/snapshot-source/index.js +15 -0
- package/src/api/snapshot-source/utils.d.ts +1 -0
- package/src/api/snapshot-source/utils.js +5 -0
- package/src/api/system/application.d.ts +6 -0
- package/src/api/system/application.js +2 -0
- package/src/api/system/entity.d.ts +11 -0
- package/src/api/system/entity.js +2 -0
- package/src/api/system/index.d.ts +957 -0
- package/src/api/system/index.js +1241 -0
- package/src/api/system/installedApps.d.ts +6 -0
- package/src/api/system/installedApps.js +2 -0
- package/src/api/system/log.d.ts +11 -0
- package/src/api/system/log.js +2 -0
- package/src/api/system/process.d.ts +15 -0
- package/src/api/system/process.js +2 -0
- package/src/api/system/proxy.d.ts +15 -0
- package/src/api/system/proxy.js +2 -0
- package/src/api/system/queryPermissionTypes.d.ts +1 -0
- package/src/api/system/queryPermissionTypes.js +2 -0
- package/src/api/system/registry-info.d.ts +7 -0
- package/src/api/system/registry-info.js +2 -0
- package/src/api/system/window.d.ts +16 -0
- package/src/api/system/window.js +2 -0
- package/src/api/view/Factory.d.ts +49 -0
- package/src/api/view/Factory.js +103 -0
- package/src/api/view/Instance.d.ts +379 -0
- package/src/api/view/Instance.js +415 -0
- package/src/api/view/index.d.ts +3 -0
- package/src/api/view/index.js +15 -0
- package/src/api/webcontents/main.d.ts +36 -0
- package/src/api/webcontents/main.js +82 -0
- package/src/api/window/Factory.d.ts +44 -0
- package/src/api/window/Factory.js +91 -0
- package/src/api/window/Instance.d.ts +966 -0
- package/src/api/window/Instance.js +1202 -0
- package/src/api/window/bounds-changed.d.ts +10 -0
- package/src/api/window/bounds-changed.js +6 -0
- package/src/api/window/index.d.ts +5 -0
- package/src/api/window/index.js +17 -0
- package/src/api/window/shapes.d.ts +13 -0
- package/src/api/window/shapes.js +2 -0
- package/src/environment/environment.d.ts +28 -0
- package/src/environment/environment.js +4 -0
- package/src/environment/node-env.d.ts +25 -0
- package/src/environment/node-env.js +64 -0
- package/src/environment/openfin-env.d.ts +29 -0
- package/src/environment/openfin-env.js +105 -0
- package/src/mock.d.ts +4 -0
- package/src/mock.js +91 -0
- package/src/shapes/ERROR_BOX_TYPES.d.ts +6 -0
- package/src/shapes/ERROR_BOX_TYPES.js +10 -0
- package/src/shapes/EntityType.d.ts +1 -0
- package/src/shapes/EntityType.js +2 -0
- package/src/shapes/LayoutPresetType.d.ts +1 -0
- package/src/shapes/LayoutPresetType.js +2 -0
- package/src/shapes/Platform.d.ts +112 -0
- package/src/shapes/Platform.js +16 -0
- package/src/shapes/WebOptions.d.ts +12 -0
- package/src/shapes/WebOptions.js +2 -0
- package/src/shapes/WindowOptions.d.ts +42 -0
- package/src/shapes/WindowOptions.js +2 -0
- package/src/shapes/protocol.d.ts +178 -0
- package/src/shapes/protocol.js +2 -0
- package/src/transport/fin_store.d.ts +4 -0
- package/src/transport/fin_store.js +16 -0
- package/src/transport/transport-errors.d.ts +17 -0
- package/src/transport/transport-errors.js +39 -0
- package/src/transport/transport.d.ts +57 -0
- package/src/transport/transport.js +195 -0
- package/src/transport/wire.d.ts +76 -0
- package/src/transport/wire.js +39 -0
- package/src/util/asyncFilter.d.ts +1 -0
- package/src/util/asyncFilter.js +7 -0
- package/src/util/errors.d.ts +9 -0
- package/src/util/errors.js +14 -0
- package/src/util/exhaustive.d.ts +1 -0
- package/src/util/exhaustive.js +7 -0
- package/src/util/http.d.ts +11 -0
- package/src/util/http.js +83 -0
- package/src/util/normalize-config.d.ts +3 -0
- package/src/util/normalize-config.js +47 -0
- package/src/util/promises.d.ts +5 -0
- package/src/util/promises.js +27 -0
- package/src/util/ref-counter.d.ts +7 -0
- package/src/util/ref-counter.js +51 -0
- package/src/util/runtimeVersioning.d.ts +3 -0
- package/src/util/runtimeVersioning.js +25 -0
- package/src/util/utilTypes.d.ts +8 -0
- package/src/util/utilTypes.js +2 -0
- package/src/util/validate.d.ts +3 -0
- package/src/util/validate.js +11 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
|
|
3
|
+
if (!privateMap.has(receiver)) {
|
|
4
|
+
throw new TypeError("attempted to set private field on non-instance");
|
|
5
|
+
}
|
|
6
|
+
privateMap.set(receiver, value);
|
|
7
|
+
return value;
|
|
8
|
+
};
|
|
9
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
|
|
10
|
+
if (!privateMap.has(receiver)) {
|
|
11
|
+
throw new TypeError("attempted to get private field on non-instance");
|
|
12
|
+
}
|
|
13
|
+
return privateMap.get(receiver);
|
|
14
|
+
};
|
|
15
|
+
var _clientPromise;
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const base_1 = require("../base");
|
|
18
|
+
const utils_1 = require("./utils");
|
|
19
|
+
class SessionContextGroupClient extends base_1.Base {
|
|
20
|
+
constructor(wire, client, id) {
|
|
21
|
+
super(wire);
|
|
22
|
+
_clientPromise.set(this, void 0);
|
|
23
|
+
this.id = id;
|
|
24
|
+
__classPrivateFieldSet(this, _clientPromise, client);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Sets a context for the session context group.
|
|
28
|
+
* @param { Context } context - New context to set.
|
|
29
|
+
* @return { Promise<void> }
|
|
30
|
+
* @tutorial interop.setContext
|
|
31
|
+
*/
|
|
32
|
+
async setContext(context) {
|
|
33
|
+
this.wire.sendAction('interop-session-context-group-set-context').catch((e) => {
|
|
34
|
+
// don't expose, analytics-only call
|
|
35
|
+
});
|
|
36
|
+
const client = await __classPrivateFieldGet(this, _clientPromise);
|
|
37
|
+
return client.dispatch(`sessionContextGroup:setContext-${this.id}`, {
|
|
38
|
+
sessionContextGroupId: this.id,
|
|
39
|
+
context
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async getCurrentContext(type) {
|
|
43
|
+
this.wire.sendAction('interop-session-context-group-get-context').catch((e) => {
|
|
44
|
+
// don't expose, analytics-only call
|
|
45
|
+
});
|
|
46
|
+
const client = await __classPrivateFieldGet(this, _clientPromise);
|
|
47
|
+
return client.dispatch(`sessionContextGroup:getContext-${this.id}`, {
|
|
48
|
+
sessionContextGroupId: this.id,
|
|
49
|
+
type
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async addContextHandler(contextHandler, contextType) {
|
|
53
|
+
this.wire.sendAction('interop-session-context-group-add-handler').catch((e) => {
|
|
54
|
+
// don't expose, analytics-only call
|
|
55
|
+
});
|
|
56
|
+
const client = await __classPrivateFieldGet(this, _clientPromise);
|
|
57
|
+
let handlerId;
|
|
58
|
+
if (contextType) {
|
|
59
|
+
handlerId = `sessionContextHandler:invoke-${this.id}-${contextType}-${utils_1.generateId()}`;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
handlerId = `sessionContextHandler:invoke-${this.id}`;
|
|
63
|
+
}
|
|
64
|
+
client.register(handlerId, utils_1.wrapContextHandler(contextHandler, handlerId));
|
|
65
|
+
client.dispatch(`sessionContextGroup:handlerAdded-${this.id}`, { handlerId, contextType });
|
|
66
|
+
return { unsubscribe: await this.createUnsubscribeCb(handlerId) };
|
|
67
|
+
}
|
|
68
|
+
async createUnsubscribeCb(handlerId) {
|
|
69
|
+
const client = await __classPrivateFieldGet(this, _clientPromise);
|
|
70
|
+
return async () => {
|
|
71
|
+
client.remove(handlerId);
|
|
72
|
+
await client.dispatch(`sessionContextGroup:handlerRemoved-${this.id}`, { handlerId });
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
getUserInstance() {
|
|
76
|
+
return {
|
|
77
|
+
id: this.id,
|
|
78
|
+
setContext: utils_1.wrapInTryCatch(this.setContext.bind(this), 'Failed to set context: '),
|
|
79
|
+
getCurrentContext: utils_1.wrapInTryCatch(this.getCurrentContext.bind(this), 'Failed to get context: '),
|
|
80
|
+
addContextHandler: utils_1.wrapInTryCatch(this.addContextHandler.bind(this), 'Failed to add context handler: ')
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.default = SessionContextGroupClient;
|
|
85
|
+
_clientPromise = new WeakMap();
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { Base } from '../../base';
|
|
2
|
+
/**
|
|
3
|
+
* @typedef { object } Listener
|
|
4
|
+
* @summary Listener object returned by addContextListener and addIntentListener
|
|
5
|
+
* @property {function} unsubscribe function for addContextListener and addIntentListener.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef { object } Channel
|
|
9
|
+
* @summary Information for a Context Group. Contains metadata for displaying the group properly.
|
|
10
|
+
* @property {string} id Name of the context group
|
|
11
|
+
* @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.
|
|
12
|
+
* @property {string} type Defaults to system.
|
|
13
|
+
* @property {function} broadcast Broadcasts a context for the channel.
|
|
14
|
+
* @property {function} addContextListener Add a context handler for incoming context.
|
|
15
|
+
* @property {function} getCurrentContext Gets the current context for the channel.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @typedef { object } AppMetadata
|
|
19
|
+
* @summary App metadata is provided by the FDC3 App Directory.
|
|
20
|
+
* @property {string} name
|
|
21
|
+
* @property {string} [appId]
|
|
22
|
+
* @property {string} [version]
|
|
23
|
+
* @property {string} [title]
|
|
24
|
+
* @property {string} [tooltip]
|
|
25
|
+
* @property {string} [description]
|
|
26
|
+
* @property {Array<string>} [icons]
|
|
27
|
+
* @property {Array<string>} [images]
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* @typedef { string | AppMetadata } TargetApp
|
|
31
|
+
* @summary Some operations can identify an app just by its name, or pass full app metadata.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* @typedef { object } IntentResolution
|
|
35
|
+
* @summary IntentResolution provides a standard format for data returned upon resolving an Intent.
|
|
36
|
+
* @property { TargetApp } source identifier for the Application resolving the Intent (null if the Intent could not be resolved)
|
|
37
|
+
* @property { string } [data] Return data structure - if one is provided for the given Intent.
|
|
38
|
+
* @property { string } version The version number of the Intents schema being used
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* @typedef { object } AppIntent
|
|
42
|
+
* @summary An interface that represents the binding of an intent to apps.
|
|
43
|
+
* @property { Intent } intent
|
|
44
|
+
* @property { Array<AppMetadata> } apps
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* @typedef { object } ImplementationMetadata
|
|
48
|
+
* @summary An interface that represents FDC3 implementation meta data.
|
|
49
|
+
* @property { string } fdc3Version The FDC3 version
|
|
50
|
+
* @property { string } provider The provider uuid with prepend 'openfin'
|
|
51
|
+
* @property { string } [providerVersion] The provider runtime version
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
|
|
55
|
+
* while using our Interop API under the hood. In order to use this set of APIs
|
|
56
|
+
* 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
|
|
57
|
+
* our {@link https://developers.openfin.co/of-docs/docs/enable-color-linking Interop API}.
|
|
58
|
+
*
|
|
59
|
+
* We currently support APIs based on FDC3 1.2. To enable the FDC3 APIs in a {@link Window Window} or {@link View View}, add the fdc3InteropApi
|
|
60
|
+
* property to its options:
|
|
61
|
+
*
|
|
62
|
+
* ```js
|
|
63
|
+
* {
|
|
64
|
+
* autoShow: false,
|
|
65
|
+
* saveWindowState: true,
|
|
66
|
+
* url: 'https://openfin.co',
|
|
67
|
+
* fdc3InteropApi: '1.2'
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* If using a {@link Platform Platform } application, you can set this property in defaultWindowOptions and defaultViewOptions.
|
|
72
|
+
*
|
|
73
|
+
* @class
|
|
74
|
+
* @alias Fdc3
|
|
75
|
+
* @hideconstructor
|
|
76
|
+
*/
|
|
77
|
+
export default class Fdc3Module extends Base implements FDC3.DesktopAgent {
|
|
78
|
+
/**
|
|
79
|
+
* 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.
|
|
80
|
+
* @param { string | null } contextType - The type of context you wish to handle.
|
|
81
|
+
* @param { ContextHandler } handler - Handler for incoming context.
|
|
82
|
+
* @returns { Listener }
|
|
83
|
+
* @tutorial fdc3.addContextListener
|
|
84
|
+
* @static
|
|
85
|
+
*/
|
|
86
|
+
addContextListener(contextType: string | null, handler: OpenFin.ContextHandler): FDC3.Listener & Promise<FDC3.Listener>;
|
|
87
|
+
/**
|
|
88
|
+
* Broadcasts a context for the channel of the current entity.
|
|
89
|
+
* @param { Context } context - New context to set.
|
|
90
|
+
* @returns { Promise<void> }
|
|
91
|
+
* @tutorial fdc3.broadcast
|
|
92
|
+
* @static
|
|
93
|
+
*/
|
|
94
|
+
broadcast(context: OpenFin.Context): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
97
|
+
* @returns { Promise<Channel[]>}
|
|
98
|
+
* @tutorial fdc3.getSystemChannels
|
|
99
|
+
* @static
|
|
100
|
+
*/
|
|
101
|
+
getSystemChannels(): Promise<OpenFin.ContextGroupInfo[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Join all Interop Clients at the given identity to context group `contextGroupId`.
|
|
104
|
+
* If no target is specified, it adds the sender to the context group.
|
|
105
|
+
* 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.
|
|
106
|
+
* 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.
|
|
107
|
+
* 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.
|
|
108
|
+
* @param { string } channelId - Id of the context group.
|
|
109
|
+
* @returns { Promise<void> }
|
|
110
|
+
* @tutorial fdc3.joinChannel
|
|
111
|
+
* @static
|
|
112
|
+
*/
|
|
113
|
+
joinChannel(channelId: string): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Removes the specified target from a context group.
|
|
116
|
+
* If no target is specified, it removes the sender from their context group.
|
|
117
|
+
* @returns { Promise<void> }
|
|
118
|
+
* @tutorial fdc3.leaveCurrentChannel
|
|
119
|
+
* @static
|
|
120
|
+
*/
|
|
121
|
+
leaveCurrentChannel(): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Adds a listener for incoming Intents.
|
|
124
|
+
* @param { string } intent - Name of the Intent
|
|
125
|
+
* @param { IntentHandler } handler - Handler for incoming Intent
|
|
126
|
+
* @returns { Listener }
|
|
127
|
+
* @tutorial fdc3.addIntentListener
|
|
128
|
+
* @static
|
|
129
|
+
*/
|
|
130
|
+
addIntentListener(intent: string, handler: OpenFin.ContextHandler): FDC3.Listener & Promise<FDC3.Listener>;
|
|
131
|
+
/**
|
|
132
|
+
* Raises a specific intent.
|
|
133
|
+
* @param { string } intent Name of the Intent.
|
|
134
|
+
* @param { Context } context Context associated with the Intent.
|
|
135
|
+
* @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}.
|
|
136
|
+
* @returns { IntentResolution }
|
|
137
|
+
* @tutorial fdc3.raiseIntent
|
|
138
|
+
* @static
|
|
139
|
+
*/
|
|
140
|
+
raiseIntent(intent: string, context: OpenFin.Context, app?: FDC3.TargetApp): Promise<FDC3.IntentResolution>;
|
|
141
|
+
/**
|
|
142
|
+
* Returns the Channel that the entity is subscribed to. Returns null if not joined to a channel.
|
|
143
|
+
* @returns { Channel | null }
|
|
144
|
+
* @tutorial fdc3.getCurrentChannel
|
|
145
|
+
*/
|
|
146
|
+
getCurrentChannel(): Promise<FDC3.Channel | null>;
|
|
147
|
+
/**
|
|
148
|
+
* Find out more information about a particular intent by passing its name, and optionally its context.
|
|
149
|
+
* @param { string } intent Name of the Intent
|
|
150
|
+
* @param { Context } [context]
|
|
151
|
+
* @return { Promise<AppIntent> }
|
|
152
|
+
* @tutorial fdc3.findIntent
|
|
153
|
+
*/
|
|
154
|
+
findIntent(intent: string, context?: OpenFin.Context): Promise<FDC3.AppIntent>;
|
|
155
|
+
/**
|
|
156
|
+
* Find all the available intents for a particular context.
|
|
157
|
+
* @param { Context } context
|
|
158
|
+
* @return { Promise<Array<AppIntent>> }
|
|
159
|
+
* @tutorial fdc3.findIntentsByContext
|
|
160
|
+
*/
|
|
161
|
+
findIntentsByContext(context: OpenFin.Context): Promise<Array<FDC3.AppIntent>>;
|
|
162
|
+
/**
|
|
163
|
+
* Finds and raises an intent against a target app based purely on context data.
|
|
164
|
+
* @param { Context } context
|
|
165
|
+
* @param { TargetApp } [app]
|
|
166
|
+
* @return { Promise<IntentResolution> }
|
|
167
|
+
* @tutorial fdc3.raiseIntentForContext
|
|
168
|
+
*/
|
|
169
|
+
raiseIntentForContext(context: OpenFin.Context, app?: FDC3.TargetApp): Promise<FDC3.IntentResolution>;
|
|
170
|
+
/**
|
|
171
|
+
* Returns a Channel object for the specified channel, creating it as an App Channel if it does not exist.
|
|
172
|
+
* @param channelId
|
|
173
|
+
* @returns { Promise<Channel> }
|
|
174
|
+
* @tutorial fdc3.getOrCreateChannel
|
|
175
|
+
*/
|
|
176
|
+
getOrCreateChannel(channelId: string): Promise<FDC3.Channel>;
|
|
177
|
+
/**
|
|
178
|
+
* 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.
|
|
179
|
+
* @return { Promise<ImplementationMetadata> }
|
|
180
|
+
* @tutorial fdc3.getInfo
|
|
181
|
+
*/
|
|
182
|
+
getInfo(): FDC3.ImplementationMetadata;
|
|
183
|
+
open(): void;
|
|
184
|
+
private getCurrentContextGroupInfo;
|
|
185
|
+
private buildChannelObject;
|
|
186
|
+
private buildAppChannelObject;
|
|
187
|
+
}
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const base_1 = require("../../base");
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const utils_2 = require("../utils");
|
|
6
|
+
/**
|
|
7
|
+
* @typedef { object } Listener
|
|
8
|
+
* @summary Listener object returned by addContextListener and addIntentListener
|
|
9
|
+
* @property {function} unsubscribe function for addContextListener and addIntentListener.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @typedef { object } Channel
|
|
13
|
+
* @summary Information for a Context Group. Contains metadata for displaying the group properly.
|
|
14
|
+
* @property {string} id Name of the context group
|
|
15
|
+
* @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.
|
|
16
|
+
* @property {string} type Defaults to system.
|
|
17
|
+
* @property {function} broadcast Broadcasts a context for the channel.
|
|
18
|
+
* @property {function} addContextListener Add a context handler for incoming context.
|
|
19
|
+
* @property {function} getCurrentContext Gets the current context for the channel.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef { object } AppMetadata
|
|
23
|
+
* @summary App metadata is provided by the FDC3 App Directory.
|
|
24
|
+
* @property {string} name
|
|
25
|
+
* @property {string} [appId]
|
|
26
|
+
* @property {string} [version]
|
|
27
|
+
* @property {string} [title]
|
|
28
|
+
* @property {string} [tooltip]
|
|
29
|
+
* @property {string} [description]
|
|
30
|
+
* @property {Array<string>} [icons]
|
|
31
|
+
* @property {Array<string>} [images]
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* @typedef { string | AppMetadata } TargetApp
|
|
35
|
+
* @summary Some operations can identify an app just by its name, or pass full app metadata.
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* @typedef { object } IntentResolution
|
|
39
|
+
* @summary IntentResolution provides a standard format for data returned upon resolving an Intent.
|
|
40
|
+
* @property { TargetApp } source identifier for the Application resolving the Intent (null if the Intent could not be resolved)
|
|
41
|
+
* @property { string } [data] Return data structure - if one is provided for the given Intent.
|
|
42
|
+
* @property { string } version The version number of the Intents schema being used
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* @typedef { object } AppIntent
|
|
46
|
+
* @summary An interface that represents the binding of an intent to apps.
|
|
47
|
+
* @property { Intent } intent
|
|
48
|
+
* @property { Array<AppMetadata> } apps
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* @typedef { object } ImplementationMetadata
|
|
52
|
+
* @summary An interface that represents FDC3 implementation meta data.
|
|
53
|
+
* @property { string } fdc3Version The FDC3 version
|
|
54
|
+
* @property { string } provider The provider uuid with prepend 'openfin'
|
|
55
|
+
* @property { string } [providerVersion] The provider runtime version
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
|
|
59
|
+
* while using our Interop API under the hood. In order to use this set of APIs
|
|
60
|
+
* 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
|
|
61
|
+
* our {@link https://developers.openfin.co/of-docs/docs/enable-color-linking Interop API}.
|
|
62
|
+
*
|
|
63
|
+
* We currently support APIs based on FDC3 1.2. To enable the FDC3 APIs in a {@link Window Window} or {@link View View}, add the fdc3InteropApi
|
|
64
|
+
* property to its options:
|
|
65
|
+
*
|
|
66
|
+
* ```js
|
|
67
|
+
* {
|
|
68
|
+
* autoShow: false,
|
|
69
|
+
* saveWindowState: true,
|
|
70
|
+
* url: 'https://openfin.co',
|
|
71
|
+
* fdc3InteropApi: '1.2'
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* If using a {@link Platform Platform } application, you can set this property in defaultWindowOptions and defaultViewOptions.
|
|
76
|
+
*
|
|
77
|
+
* @class
|
|
78
|
+
* @alias Fdc3
|
|
79
|
+
* @hideconstructor
|
|
80
|
+
*/
|
|
81
|
+
class Fdc3Module extends base_1.Base {
|
|
82
|
+
/**
|
|
83
|
+
* 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.
|
|
84
|
+
* @param { string | null } contextType - The type of context you wish to handle.
|
|
85
|
+
* @param { ContextHandler } handler - Handler for incoming context.
|
|
86
|
+
* @returns { Listener }
|
|
87
|
+
* @tutorial fdc3.addContextListener
|
|
88
|
+
* @static
|
|
89
|
+
*/
|
|
90
|
+
addContextListener(contextType, handler) {
|
|
91
|
+
this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
|
|
92
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
93
|
+
});
|
|
94
|
+
let listener;
|
|
95
|
+
if (typeof contextType === 'function') {
|
|
96
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
97
|
+
listener = window.fin.me.interop.addContextHandler(contextType);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
listener = window.fin.me.interop.addContextHandler(handler, contextType === null ? undefined : contextType);
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
...listener,
|
|
104
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Broadcasts a context for the channel of the current entity.
|
|
109
|
+
* @param { Context } context - New context to set.
|
|
110
|
+
* @returns { Promise<void> }
|
|
111
|
+
* @tutorial fdc3.broadcast
|
|
112
|
+
* @static
|
|
113
|
+
*/
|
|
114
|
+
async broadcast(context) {
|
|
115
|
+
this.wire.sendAction('fdc3-broadcast').catch((e) => {
|
|
116
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
117
|
+
});
|
|
118
|
+
window.fin.me.interop.setContext(context);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
122
|
+
* @returns { Promise<Channel[]>}
|
|
123
|
+
* @tutorial fdc3.getSystemChannels
|
|
124
|
+
* @static
|
|
125
|
+
*/
|
|
126
|
+
async getSystemChannels() {
|
|
127
|
+
this.wire.sendAction('fdc3-get-system-channels').catch((e) => {
|
|
128
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
129
|
+
});
|
|
130
|
+
const channels = await window.fin.me.interop.getContextGroups();
|
|
131
|
+
const unsupportedChannelApis = {
|
|
132
|
+
addContextListener: () => {
|
|
133
|
+
throw new utils_1.UnsupportedChannelApiError('Channel.addContextListener');
|
|
134
|
+
},
|
|
135
|
+
broadcast: () => {
|
|
136
|
+
throw new utils_1.UnsupportedChannelApiError('Channel.broadcast');
|
|
137
|
+
},
|
|
138
|
+
getCurrentChannel: () => {
|
|
139
|
+
throw new utils_1.UnsupportedChannelApiError('Channel.getCurrentChannel');
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
// fdc3 implementation of getSystemChannels returns on array of channels, have to decorate over
|
|
143
|
+
// this so people know that these APIs are not supported
|
|
144
|
+
return channels.map((channel) => {
|
|
145
|
+
return { ...channel, type: 'system', ...unsupportedChannelApis };
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Join all Interop Clients at the given identity to context group `contextGroupId`.
|
|
150
|
+
* If no target is specified, it adds the sender to the context group.
|
|
151
|
+
* 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.
|
|
152
|
+
* 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.
|
|
153
|
+
* 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.
|
|
154
|
+
* @param { string } channelId - Id of the context group.
|
|
155
|
+
* @returns { Promise<void> }
|
|
156
|
+
* @tutorial fdc3.joinChannel
|
|
157
|
+
* @static
|
|
158
|
+
*/
|
|
159
|
+
async joinChannel(channelId) {
|
|
160
|
+
this.wire.sendAction('fdc3-join-channel').catch((e) => {
|
|
161
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
162
|
+
});
|
|
163
|
+
window.fin.me.interop.joinContextGroup(channelId);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Removes the specified target from a context group.
|
|
167
|
+
* If no target is specified, it removes the sender from their context group.
|
|
168
|
+
* @returns { Promise<void> }
|
|
169
|
+
* @tutorial fdc3.leaveCurrentChannel
|
|
170
|
+
* @static
|
|
171
|
+
*/
|
|
172
|
+
async leaveCurrentChannel() {
|
|
173
|
+
this.wire.sendAction('fdc3-leave-current-channel').catch((e) => {
|
|
174
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
175
|
+
});
|
|
176
|
+
window.fin.me.interop.removeFromContextGroup();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Adds a listener for incoming Intents.
|
|
180
|
+
* @param { string } intent - Name of the Intent
|
|
181
|
+
* @param { IntentHandler } handler - Handler for incoming Intent
|
|
182
|
+
* @returns { Listener }
|
|
183
|
+
* @tutorial fdc3.addIntentListener
|
|
184
|
+
* @static
|
|
185
|
+
*/
|
|
186
|
+
addIntentListener(intent, handler) {
|
|
187
|
+
this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
|
|
188
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
189
|
+
});
|
|
190
|
+
const contextHandler = (raisedIntent) => {
|
|
191
|
+
handler(raisedIntent.context);
|
|
192
|
+
};
|
|
193
|
+
const listener = window.fin.me.interop.registerIntentHandler(contextHandler, intent);
|
|
194
|
+
return {
|
|
195
|
+
...listener,
|
|
196
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Raises a specific intent.
|
|
201
|
+
* @param { string } intent Name of the Intent.
|
|
202
|
+
* @param { Context } context Context associated with the Intent.
|
|
203
|
+
* @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}.
|
|
204
|
+
* @returns { IntentResolution }
|
|
205
|
+
* @tutorial fdc3.raiseIntent
|
|
206
|
+
* @static
|
|
207
|
+
*/
|
|
208
|
+
async raiseIntent(intent, context, app) {
|
|
209
|
+
this.wire.sendAction('fdc3-raise-intent').catch((e) => {
|
|
210
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
211
|
+
});
|
|
212
|
+
const intentObj = app
|
|
213
|
+
? { name: intent, context, metadata: { target: app } }
|
|
214
|
+
: { name: intent, context };
|
|
215
|
+
try {
|
|
216
|
+
return await window.fin.me.interop.fireIntent(intentObj);
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
const errorToThrow = error.message === utils_2.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error;
|
|
220
|
+
throw new Error(errorToThrow);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Returns the Channel that the entity is subscribed to. Returns null if not joined to a channel.
|
|
225
|
+
* @returns { Channel | null }
|
|
226
|
+
* @tutorial fdc3.getCurrentChannel
|
|
227
|
+
*/
|
|
228
|
+
async getCurrentChannel() {
|
|
229
|
+
this.wire.sendAction('fdc3-get-current-channel').catch((e) => {
|
|
230
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
231
|
+
});
|
|
232
|
+
const currentContextGroupInfo = await this.getCurrentContextGroupInfo();
|
|
233
|
+
if (!currentContextGroupInfo) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
return this.buildChannelObject(currentContextGroupInfo);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Find out more information about a particular intent by passing its name, and optionally its context.
|
|
240
|
+
* @param { string } intent Name of the Intent
|
|
241
|
+
* @param { Context } [context]
|
|
242
|
+
* @return { Promise<AppIntent> }
|
|
243
|
+
* @tutorial fdc3.findIntent
|
|
244
|
+
*/
|
|
245
|
+
async findIntent(intent, context) {
|
|
246
|
+
this.wire.sendAction('fdc3-find-intent').catch((e) => {
|
|
247
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
248
|
+
});
|
|
249
|
+
try {
|
|
250
|
+
return await window.fin.me.interop.getInfoForIntent({ name: intent, context });
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
const errorToThrow = error.message === utils_2.BROKER_ERRORS.getInfoForIntent ? 'ResolverUnavailable' : error;
|
|
254
|
+
throw new Error(errorToThrow);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Find all the available intents for a particular context.
|
|
259
|
+
* @param { Context } context
|
|
260
|
+
* @return { Promise<Array<AppIntent>> }
|
|
261
|
+
* @tutorial fdc3.findIntentsByContext
|
|
262
|
+
*/
|
|
263
|
+
async findIntentsByContext(context) {
|
|
264
|
+
this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
|
|
265
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
266
|
+
});
|
|
267
|
+
try {
|
|
268
|
+
return await window.fin.me.interop.getInfoForIntentsByContext(context);
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
const errorToThrow = error.message === utils_2.BROKER_ERRORS.getInfoForIntentsByContext ? 'ResolverUnavailable' : error;
|
|
272
|
+
throw new Error(errorToThrow);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Finds and raises an intent against a target app based purely on context data.
|
|
277
|
+
* @param { Context } context
|
|
278
|
+
* @param { TargetApp } [app]
|
|
279
|
+
* @return { Promise<IntentResolution> }
|
|
280
|
+
* @tutorial fdc3.raiseIntentForContext
|
|
281
|
+
*/
|
|
282
|
+
async raiseIntentForContext(context, app) {
|
|
283
|
+
this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
|
|
284
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
285
|
+
});
|
|
286
|
+
try {
|
|
287
|
+
return await window.fin.me.interop.fireIntentForContext({ ...context, metadata: { target: app } });
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
const errorToThrow = error.message === utils_2.BROKER_ERRORS.fireIntentForContext ? 'ResolverUnavailable' : error;
|
|
291
|
+
throw new Error(errorToThrow);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Returns a Channel object for the specified channel, creating it as an App Channel if it does not exist.
|
|
296
|
+
* @param channelId
|
|
297
|
+
* @returns { Promise<Channel> }
|
|
298
|
+
* @tutorial fdc3.getOrCreateChannel
|
|
299
|
+
*/
|
|
300
|
+
async getOrCreateChannel(channelId) {
|
|
301
|
+
this.wire.sendAction('fdc3-get-or-create-channel').catch((e) => {
|
|
302
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
303
|
+
});
|
|
304
|
+
const sessionContextGroup = await window.fin.me.interop.joinSessionContextGroup(channelId);
|
|
305
|
+
return this.buildAppChannelObject(sessionContextGroup);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* 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.
|
|
309
|
+
* @return { Promise<ImplementationMetadata> }
|
|
310
|
+
* @tutorial fdc3.getInfo
|
|
311
|
+
*/
|
|
312
|
+
getInfo() {
|
|
313
|
+
this.wire.sendAction('fdc3-get-info').catch((e) => {
|
|
314
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
315
|
+
});
|
|
316
|
+
// @ts-expect-error
|
|
317
|
+
const { uuid, fdc3InteropApi } = fin.__internal_.initialOptions;
|
|
318
|
+
// @ts-expect-error
|
|
319
|
+
const runtimeVersion = fin.desktop.getVersion();
|
|
320
|
+
return {
|
|
321
|
+
fdc3Version: fdc3InteropApi,
|
|
322
|
+
provider: `openfin-${uuid}`,
|
|
323
|
+
providerVersion: runtimeVersion
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
// eslint-disable-next-line class-methods-use-this
|
|
327
|
+
open() {
|
|
328
|
+
throw new utils_1.UnsupportedError('open');
|
|
329
|
+
}
|
|
330
|
+
// utils
|
|
331
|
+
// eslint-disable-next-line class-methods-use-this
|
|
332
|
+
async getCurrentContextGroupInfo() {
|
|
333
|
+
const contextGroups = await window.fin.me.interop.getContextGroups();
|
|
334
|
+
const clientsInCtxGroupsPromise = contextGroups.map(async (ctxGroup) => {
|
|
335
|
+
return window.fin.me.interop.getAllClientsInContextGroup(ctxGroup.id);
|
|
336
|
+
});
|
|
337
|
+
const clientsInCtxGroups = await Promise.all(clientsInCtxGroupsPromise);
|
|
338
|
+
const clientIdx = clientsInCtxGroups.findIndex((clientIdentityArr) => {
|
|
339
|
+
return clientIdentityArr.some((clientIdentity) => {
|
|
340
|
+
const { uuid, name } = clientIdentity;
|
|
341
|
+
return window.fin.me.identity.uuid === uuid && window.fin.me.identity.name === name;
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
return contextGroups[clientIdx];
|
|
345
|
+
}
|
|
346
|
+
async buildChannelObject(currentContextGroupInfo) {
|
|
347
|
+
return {
|
|
348
|
+
...currentContextGroupInfo,
|
|
349
|
+
type: 'system',
|
|
350
|
+
addContextListener: this.addContextListener.bind(this),
|
|
351
|
+
broadcast: this.broadcast.bind(this),
|
|
352
|
+
getCurrentContext: async (contextType) => {
|
|
353
|
+
const context = await window.fin.me.interop.getCurrentContext(contextType);
|
|
354
|
+
return context === undefined ? null : context;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
// eslint-disable-next-line class-methods-use-this
|
|
359
|
+
buildAppChannelObject(sessionContextGroup) {
|
|
360
|
+
return {
|
|
361
|
+
id: sessionContextGroup.id,
|
|
362
|
+
type: 'app',
|
|
363
|
+
broadcast: sessionContextGroup.setContext,
|
|
364
|
+
getCurrentContext: async (contextType) => {
|
|
365
|
+
const context = await sessionContextGroup.getCurrentContext(contextType);
|
|
366
|
+
return context === undefined ? null : context;
|
|
367
|
+
},
|
|
368
|
+
addContextListener: (contextType, handler) => {
|
|
369
|
+
let listener;
|
|
370
|
+
if (typeof contextType === 'function') {
|
|
371
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
372
|
+
listener = sessionContextGroup.addContextHandler(contextType);
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
listener = sessionContextGroup.addContextHandler(handler, contextType === null ? undefined : contextType);
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
...listener,
|
|
379
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
exports.default = Fdc3Module;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerFdc3Shim = exports.versionMap = void 0;
|
|
4
|
+
const fdc3_1_2_1 = require("./fdc3-1.2");
|
|
5
|
+
exports.versionMap = {
|
|
6
|
+
'1.2': fdc3_1_2_1.default
|
|
7
|
+
};
|
|
8
|
+
function registerFdc3Shim(version, transport) {
|
|
9
|
+
if (Object.keys(exports.versionMap).includes(version)) {
|
|
10
|
+
const Api = exports.versionMap[version];
|
|
11
|
+
window.fdc3 = new Api(transport);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
console.error(`FDC3 API version ${version} is not supported`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.registerFdc3Shim = registerFdc3Shim;
|