@openfin/core 33.76.31 → 33.76.36
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/openfin-core-33.76.36.tgz +0 -0
- package/package.json +1 -1
- package/src/OpenFin.d.ts +27 -16
- package/src/api/application/Factory.d.ts +148 -100
- package/src/api/application/Factory.js +148 -100
- package/src/api/application/Instance.d.ts +477 -106
- package/src/api/application/Instance.js +474 -106
- package/src/api/application/index.d.ts +9 -0
- package/src/api/application/index.js +9 -0
- package/src/api/base.d.ts +69 -0
- package/src/api/base.js +69 -0
- package/src/api/clipboard/index.d.ts +111 -31
- package/src/api/clipboard/index.js +111 -31
- package/src/api/events/application.d.ts +12 -0
- package/src/api/events/application.js +12 -0
- package/src/api/events/channel.d.ts +5 -0
- package/src/api/events/channel.js +5 -0
- package/src/api/events/externalApplication.d.ts +5 -0
- package/src/api/events/externalApplication.js +5 -0
- package/src/api/events/frame.d.ts +5 -0
- package/src/api/events/globalHotkey.d.ts +5 -0
- package/src/api/events/platform.d.ts +9 -1
- package/src/api/events/platform.js +8 -0
- package/src/api/events/system.d.ts +13 -0
- package/src/api/events/system.js +13 -0
- package/src/api/events/view.d.ts +19 -9
- package/src/api/events/view.js +10 -0
- package/src/api/events/webcontents.d.ts +21 -10
- package/src/api/events/webcontents.js +11 -0
- package/src/api/events/window.d.ts +70 -1
- package/src/api/events/window.js +10 -0
- package/src/api/external-application/Factory.d.ts +16 -9
- package/src/api/external-application/Factory.js +16 -9
- package/src/api/external-application/Instance.d.ts +40 -32
- package/src/api/external-application/Instance.js +40 -32
- package/src/api/external-application/index.d.ts +9 -0
- package/src/api/external-application/index.js +9 -0
- package/src/api/fin.d.ts +3 -0
- package/src/api/fin.js +3 -0
- package/src/api/frame/Factory.d.ts +30 -13
- package/src/api/frame/Factory.js +30 -13
- package/src/api/frame/Instance.d.ts +51 -38
- package/src/api/frame/Instance.js +51 -38
- package/src/api/frame/index.d.ts +11 -0
- package/src/api/frame/index.js +11 -0
- package/src/api/global-hotkey/index.d.ts +81 -13
- package/src/api/global-hotkey/index.js +81 -13
- package/src/api/interappbus/channel/channel.d.ts +257 -0
- package/src/api/interappbus/channel/channel.js +257 -0
- package/src/api/interappbus/channel/channels-docs.d.ts +59 -57
- package/src/api/interappbus/channel/channels-docs.js +71 -68
- package/src/api/interappbus/channel/client.d.ts +93 -0
- package/src/api/interappbus/channel/client.js +93 -1
- package/src/api/interappbus/channel/index.d.ts +164 -0
- package/src/api/interappbus/channel/index.js +165 -1
- package/src/api/interappbus/channel/provider.d.ts +172 -0
- package/src/api/interappbus/channel/provider.js +172 -0
- package/src/api/interappbus/index.d.ts +55 -20
- package/src/api/interappbus/index.js +55 -20
- package/src/api/interop/Factory.d.ts +30 -10
- package/src/api/interop/Factory.js +30 -10
- package/src/api/interop/InteropBroker.d.ts +298 -70
- package/src/api/interop/InteropBroker.js +298 -70
- package/src/api/interop/InteropClient.d.ts +286 -62
- package/src/api/interop/InteropClient.js +286 -62
- package/src/api/interop/SessionContextGroupClient.d.ts +2 -2
- package/src/api/interop/SessionContextGroupClient.js +2 -2
- package/src/api/interop/fdc3/documentationStub.d.ts +14 -0
- package/src/api/interop/fdc3/documentationStub.js +17 -0
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +31 -34
- package/src/api/interop/fdc3/fdc3-1.2.js +31 -34
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +48 -51
- package/src/api/interop/fdc3/fdc3-2.0.js +48 -51
- package/src/api/interop/index.d.ts +8 -0
- package/src/api/interop/index.js +8 -0
- package/src/api/platform/Factory.d.ts +121 -65
- package/src/api/platform/Factory.js +122 -66
- package/src/api/platform/Instance.d.ts +551 -48
- package/src/api/platform/Instance.js +551 -49
- package/src/api/platform/index.d.ts +9 -0
- package/src/api/platform/index.js +9 -0
- package/src/api/platform/layout/Factory.d.ts +53 -76
- package/src/api/platform/layout/Factory.js +53 -76
- package/src/api/platform/layout/Instance.d.ts +158 -23
- package/src/api/platform/layout/Instance.js +118 -20
- package/src/api/platform/layout/entities/layout-entities.d.ts +222 -30
- package/src/api/platform/layout/entities/layout-entities.js +222 -30
- package/src/api/platform/layout/index.d.ts +9 -0
- package/src/api/platform/layout/index.js +9 -0
- package/src/api/platform/provider.d.ts +398 -51
- package/src/api/snapshot-source/Factory.d.ts +33 -18
- package/src/api/snapshot-source/Factory.js +33 -18
- package/src/api/snapshot-source/Instance.d.ts +30 -8
- package/src/api/snapshot-source/Instance.js +30 -8
- package/src/api/snapshot-source/index.d.ts +9 -0
- package/src/api/snapshot-source/index.js +9 -0
- package/src/api/system/index.d.ts +1137 -186
- package/src/api/system/index.js +1142 -186
- package/src/api/view/Factory.d.ts +54 -16
- package/src/api/view/Factory.js +54 -16
- package/src/api/view/Instance.d.ts +330 -216
- package/src/api/view/Instance.js +331 -217
- package/src/api/view/index.d.ts +9 -0
- package/src/api/view/index.js +9 -0
- package/src/api/webcontents/main.d.ts +890 -0
- package/src/api/webcontents/main.js +890 -0
- package/src/api/window/Factory.d.ts +67 -16
- package/src/api/window/Factory.js +67 -16
- package/src/api/window/Instance.d.ts +824 -316
- package/src/api/window/Instance.js +822 -320
- package/src/api/window/index.d.ts +11 -0
- package/src/api/window/index.js +11 -0
- package/src/namespaces.d.ts +1 -0
- package/src/namespaces.js +3 -1
- package/src/shapes/protocol.d.ts +4 -0
- package/openfin-core-33.76.31.tgz +0 -0
|
@@ -15,7 +15,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.ChannelProvider = void 0;
|
|
16
16
|
const channel_1 = require("./channel");
|
|
17
17
|
const runtimeVersioning_1 = require("../../../util/runtimeVersioning");
|
|
18
|
+
/**
|
|
19
|
+
* Instance created to enable use of a channel as a provider. Allows for communication with the {@link ChannelClient ChannelClients} by invoking an action on
|
|
20
|
+
* a single client via {@link ChannelProvider#dispatch dispatch} or all clients via {@link ChannelProvider#publish publish}
|
|
21
|
+
* and to listen for communication from clients by registering an action via {@link ChannelProvider#register register}.
|
|
22
|
+
*
|
|
23
|
+
* Synchronous Methods:
|
|
24
|
+
* * {@link ChannelProvider#onConnection onConnection(listener)}
|
|
25
|
+
* * {@link ChannelProvider#onDisconnection onDisconnection(listener)}
|
|
26
|
+
* * {@link ChannelProvider#publish publish(action, payload)}
|
|
27
|
+
* * {@link ChannelProvider#register register(action, listener)}
|
|
28
|
+
* * {@link ChannelProvider#remove remove(action)}
|
|
29
|
+
*
|
|
30
|
+
* Asynchronous Methods:
|
|
31
|
+
* * {@link ChannelProvider#destroy destroy()}
|
|
32
|
+
* * {@link ChannelProvider#dispatch dispatch(to, action, payload)}
|
|
33
|
+
* * {@link ChannelProvider#getAllClientInfo getAllClientInfo()}
|
|
34
|
+
*
|
|
35
|
+
* Middleware:
|
|
36
|
+
* <br>Middleware functions receive the following arguments: (action, payload, senderId).
|
|
37
|
+
* The return value of the middleware function will be passed on as the payload from beforeAction, to the action listener, to afterAction
|
|
38
|
+
* unless it is undefined, in which case the most recently defined payload is used. Middleware can be used for side effects.
|
|
39
|
+
* * {@link ChannelProvider#setDefaultAction setDefaultAction(middleware)}
|
|
40
|
+
* * {@link ChannelProvider#onError onError(middleware)}
|
|
41
|
+
* * {@link ChannelProvider#beforeAction beforeAction(middleware)}
|
|
42
|
+
* * {@link ChannelProvider#afterAction afterAction(middleware)}
|
|
43
|
+
*/
|
|
18
44
|
class ChannelProvider extends channel_1.ChannelBase {
|
|
45
|
+
/**
|
|
46
|
+
* a read-only array containing all the identities of connecting clients.
|
|
47
|
+
*/
|
|
19
48
|
get connections() {
|
|
20
49
|
return [...__classPrivateFieldGet(this, _ChannelProvider_connections, "f")];
|
|
21
50
|
}
|
|
@@ -35,6 +64,9 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
35
64
|
static setProviderRemoval(provider, remove) {
|
|
36
65
|
ChannelProvider.removalMap.set(provider, remove);
|
|
37
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
38
70
|
constructor(providerIdentity, wire, strategy) {
|
|
39
71
|
super();
|
|
40
72
|
_ChannelProvider_connections.set(this, void 0);
|
|
@@ -70,6 +102,32 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
70
102
|
__classPrivateFieldSet(this, _ChannelProvider_strategy, strategy, "f");
|
|
71
103
|
strategy.receive(this.processAction);
|
|
72
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Dispatch an action to a specified client. Returns a promise for the result of executing that action on the client side.
|
|
107
|
+
*
|
|
108
|
+
* @param to - Identity of the target client.
|
|
109
|
+
* @param action - Name of the action to be invoked by the client.
|
|
110
|
+
* @param payload - Payload to be sent along with the action.
|
|
111
|
+
*
|
|
112
|
+
* @remarks
|
|
113
|
+
*
|
|
114
|
+
* Because multiple clients can share the same `name` and `uuid`, when dispatching from a provider to a client,
|
|
115
|
+
* the `identity` you provide must include the client's unique `endpointId` property. This `endpointId` is
|
|
116
|
+
* passed to the provider in both the `Provider.onConnection` callback and in any registered action callbacks.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
*
|
|
120
|
+
* ```js
|
|
121
|
+
* (async ()=> {
|
|
122
|
+
* const provider = await fin.InterApplicationBus.Channel.create('channelName');
|
|
123
|
+
*
|
|
124
|
+
* await provider.register('provider-action', async (payload, identity) => {
|
|
125
|
+
* console.log(payload, identity);
|
|
126
|
+
* return await provider.dispatch(identity, 'client-action', 'Hello, World!');
|
|
127
|
+
* });
|
|
128
|
+
* })();
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
73
131
|
dispatch(to, action, payload) {
|
|
74
132
|
var _a;
|
|
75
133
|
const endpointId = (_a = to.endpointId) !== null && _a !== void 0 ? _a : this.getEndpointIdForOpenFinId(to, action);
|
|
@@ -82,15 +140,99 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
82
140
|
__classPrivateFieldGet(this, _ChannelProvider_connections, "f").push(senderId);
|
|
83
141
|
return this.connectListener(senderId, payload);
|
|
84
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Publish an action and payload to every connected client.
|
|
145
|
+
* Synchronously returns an array of promises for each action (see dispatch).
|
|
146
|
+
*
|
|
147
|
+
* @param action
|
|
148
|
+
* @param payload
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```js
|
|
152
|
+
* (async ()=> {
|
|
153
|
+
* const provider = await fin.InterApplicationBus.Channel.create('channelName');
|
|
154
|
+
*
|
|
155
|
+
* await provider.register('provider-action', async (payload, identity) => {
|
|
156
|
+
* console.log(payload, identity);
|
|
157
|
+
* return await Promise.all(provider.publish('client-action', { message: 'Broadcast from provider'}));
|
|
158
|
+
* });
|
|
159
|
+
* })();
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
85
162
|
publish(action, payload) {
|
|
86
163
|
return this.connections.map((to) => __classPrivateFieldGet(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
|
|
87
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Register a listener that is called on every new client connection.
|
|
167
|
+
*
|
|
168
|
+
* @remarks It is passed the identity of the connecting client and a payload if it was provided to Channel.connect.
|
|
169
|
+
* If you wish to reject the connection, throw an error. Be sure to synchronously provide an onConnection upon receipt of
|
|
170
|
+
* the channelProvider to ensure all potential client connections are caught by the listener.
|
|
171
|
+
*
|
|
172
|
+
* Because multiple clients can exist at the same `name` and `uuid`, in order to distinguish between individual clients,
|
|
173
|
+
* the `identity` argument in a provider's `onConnection` callback contains an `endpointId` property. When dispatching from a
|
|
174
|
+
* provider to a client, the `endpointId` property must be provided in order to send an action to a specific client.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```js
|
|
178
|
+
* (async ()=> {
|
|
179
|
+
* const provider = await fin.InterApplicationBus.Channel.create('channelName');
|
|
180
|
+
*
|
|
181
|
+
* provider.onConnection(identity => {
|
|
182
|
+
* console.log('Client connected', identity);
|
|
183
|
+
* });
|
|
184
|
+
* })();
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* Reject connection:
|
|
188
|
+
* ```js
|
|
189
|
+
* (async ()=> {
|
|
190
|
+
* const provider = await fin.InterApplicationBus.Channel.create('channelName');
|
|
191
|
+
*
|
|
192
|
+
* provider.onConnection(identity => {
|
|
193
|
+
* throw new Error('Connection Rejected');
|
|
194
|
+
* });
|
|
195
|
+
* })();
|
|
196
|
+
* ```
|
|
197
|
+
* @param listener
|
|
198
|
+
*/
|
|
88
199
|
onConnection(listener) {
|
|
89
200
|
this.connectListener = listener;
|
|
90
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Register a listener that is called on client disconnection. It is passed the disconnection event of the disconnecting
|
|
204
|
+
* client.
|
|
205
|
+
*
|
|
206
|
+
* @param listener
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
*
|
|
210
|
+
* ```js
|
|
211
|
+
* (async ()=> {
|
|
212
|
+
* const provider = await fin.InterApplicationBus.Channel.create('channelName');
|
|
213
|
+
*
|
|
214
|
+
* await provider.onDisconnection(evt => {
|
|
215
|
+
* console.log('Client disconnected', `uuid: ${evt.uuid}, name: ${evt.name}`);
|
|
216
|
+
* });
|
|
217
|
+
* })();
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
91
220
|
onDisconnection(listener) {
|
|
92
221
|
this.disconnectListener = listener;
|
|
93
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Destroy the channel, raises `disconnected` events on all connected channel clients.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
*
|
|
228
|
+
* ```js
|
|
229
|
+
* (async ()=> {
|
|
230
|
+
* const provider = await fin.InterApplicationBus.Channel.create('channelName');
|
|
231
|
+
*
|
|
232
|
+
* await provider.destroy();
|
|
233
|
+
* })();
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
94
236
|
async destroy() {
|
|
95
237
|
const protectedObj = __classPrivateFieldGet(this, _ChannelProvider_protectedObj, "f");
|
|
96
238
|
const { channelName } = protectedObj.providerIdentity;
|
|
@@ -98,6 +240,36 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
98
240
|
await protectedObj.wire.sendAction('destroy-channel', { channelName });
|
|
99
241
|
__classPrivateFieldGet(this, _ChannelProvider_close, "f").call(this);
|
|
100
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Returns an array with info on every Client connected to the Provider
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
*
|
|
248
|
+
* ```js
|
|
249
|
+
* const provider = await fin.InterApplicationBus.Channel.create('openfin');
|
|
250
|
+
* const client = await fin.InterApplicationBus.Channel.connect('openfin');
|
|
251
|
+
* const clientInfo = await provider.getAllClientInfo();
|
|
252
|
+
*
|
|
253
|
+
* console.log(clientInfo);
|
|
254
|
+
*
|
|
255
|
+
* // [
|
|
256
|
+
* // {
|
|
257
|
+
* // "uuid": "openfin",
|
|
258
|
+
* // "name": "openfin-view",
|
|
259
|
+
* // "endpointId": "6d4c7ca8-4a74-4634-87f8-760558229613",
|
|
260
|
+
* // "entityType": "view",
|
|
261
|
+
* // "url": "https://openfin.co"
|
|
262
|
+
* // },
|
|
263
|
+
* // {
|
|
264
|
+
* // "uuid": "openfin2",
|
|
265
|
+
* // "name": "openfin-view2",
|
|
266
|
+
* // "endpointId": "4z5d8ab9-2b81-3691-91ex-142179382511",
|
|
267
|
+
* // "entityType": "view",
|
|
268
|
+
* // "url": "https://example.com"
|
|
269
|
+
* // }
|
|
270
|
+
* //]
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
101
273
|
async getAllClientInfo() {
|
|
102
274
|
return this.connections.map((clientInfo) => {
|
|
103
275
|
const { uuid, name, endpointId, entityType, connectionUrl } = clientInfo;
|
|
@@ -5,7 +5,7 @@ import { Transport, Message } from '../../transport/transport';
|
|
|
5
5
|
import { Channel } from './channel/index';
|
|
6
6
|
/**
|
|
7
7
|
* A messaging bus that allows for pub/sub messaging between different applications.
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
*/
|
|
10
10
|
export default class InterApplicationBus extends Base {
|
|
11
11
|
Channel: Channel;
|
|
@@ -17,27 +17,36 @@ export default class InterApplicationBus extends Base {
|
|
|
17
17
|
protected emitter: EventEmitter;
|
|
18
18
|
on: any;
|
|
19
19
|
removeAllListeners: any;
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
20
23
|
constructor(wire: Transport);
|
|
21
24
|
/**
|
|
22
25
|
* Publishes a message to all applications running on OpenFin Runtime that
|
|
23
26
|
* are subscribed to the specified topic.
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
27
|
+
* @param topic The topic on which the message is sent
|
|
28
|
+
* @param message The message to be published. Can be either a primitive
|
|
26
29
|
* data type (string, number, or boolean) or composite data type (object, array)
|
|
27
30
|
* that is composed of other primitive or composite data types
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```js
|
|
34
|
+
* fin.InterApplicationBus.publish('topic', 'hello').then(() => console.log('Published')).catch(err => console.log(err));
|
|
35
|
+
* ```
|
|
30
36
|
*/
|
|
31
37
|
publish(topic: string, message: any): Promise<void>;
|
|
32
38
|
/**
|
|
33
39
|
* Sends a message to a specific application on a specific topic.
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
40
|
+
* @param destination The identity of the application to which the message is sent
|
|
41
|
+
* @param topic The topic on which the message is sent
|
|
42
|
+
* @param message The message to be sent. Can be either a primitive data
|
|
37
43
|
* type (string, number, or boolean) or composite data type (object, array) that
|
|
38
44
|
* is composed of other primitive or composite data types
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```js
|
|
48
|
+
* fin.InterApplicationBus.send(fin.me, 'topic', 'Hello there!').then(() => console.log('Message sent')).catch(err => console.log(err));
|
|
49
|
+
* ```
|
|
41
50
|
*/
|
|
42
51
|
send(destination: {
|
|
43
52
|
uuid: string;
|
|
@@ -45,15 +54,22 @@ export default class InterApplicationBus extends Base {
|
|
|
45
54
|
}, topic: string, message: any): Promise<void>;
|
|
46
55
|
/**
|
|
47
56
|
* Subscribes to messages from the specified application on the specified topic.
|
|
48
|
-
* @param
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
57
|
+
* @param source This object is described in the Identity in the typedef
|
|
58
|
+
* @param topic The topic on which the message is sent
|
|
59
|
+
* @param listener A function that is called when a message has
|
|
51
60
|
* been received. It is passed the message, uuid and name of the sending application.
|
|
52
61
|
* The message can be either a primitive data type (string, number, or boolean) or
|
|
53
62
|
* composite data type (object, array) that is composed of other primitive or composite
|
|
54
63
|
* data types
|
|
55
|
-
*
|
|
56
|
-
* @
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```js
|
|
67
|
+
* // subscribe to a specified application
|
|
68
|
+
* fin.InterApplicationBus.subscribe(fin.me, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
|
|
69
|
+
*
|
|
70
|
+
* // subscribe to wildcard
|
|
71
|
+
* fin.InterApplicationBus.subscribe({ uuid: '*' }, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to *')).catch(err => console.log(err));
|
|
72
|
+
* ```
|
|
57
73
|
*/
|
|
58
74
|
subscribe(source: {
|
|
59
75
|
uuid: string;
|
|
@@ -61,11 +77,27 @@ export default class InterApplicationBus extends Base {
|
|
|
61
77
|
}, topic: string, listener: any): Promise<void>;
|
|
62
78
|
/**
|
|
63
79
|
* Unsubscribes to messages from the specified application on the specified topic.
|
|
64
|
-
*
|
|
65
|
-
* @
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
80
|
+
*
|
|
81
|
+
* @remarks If you are listening to all apps on a topic, (i.e you passed `{ uuid:'*' }` to the subscribe function)
|
|
82
|
+
* then you need to pass `{ uuid:'*' }` to unsubscribe as well. If you are listening to a specific application,
|
|
83
|
+
* (i.e you passed `{ uuid:'some_app' }` to the subscribe function) then you need to provide the same identifier to
|
|
84
|
+
* unsubscribe, unsubscribing to `*` on that same topic will not unhook your initial listener otherwise.
|
|
85
|
+
*
|
|
86
|
+
* @param source This object is described in the Identity in the typedef
|
|
87
|
+
* @param topic The topic on which the message is sent
|
|
88
|
+
* @param listener A callback previously registered with subscribe()
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```js
|
|
92
|
+
* const listener = console.log;
|
|
93
|
+
*
|
|
94
|
+
* // If any application publishes a message on topic `foo`, our listener will be called.
|
|
95
|
+
* await fin.InterApplicationBus.subscribe({ uuid:'*' }, 'foo', listener)
|
|
96
|
+
*
|
|
97
|
+
* // When you want to unsubscribe, you need to specify the uuid of the app you'd like to
|
|
98
|
+
* // unsubscribe from (or `*`) and provide the same function you gave the subscribe function
|
|
99
|
+
* await fin.InterApplicationBus.unsubscribe({ uuid:'*' }, 'foo', listener)
|
|
100
|
+
* ```
|
|
69
101
|
*/
|
|
70
102
|
unsubscribe(source: {
|
|
71
103
|
uuid: string;
|
|
@@ -76,6 +108,9 @@ export default class InterApplicationBus extends Base {
|
|
|
76
108
|
protected createSubscriptionKey(uuid: string, name: string, topic: string): string;
|
|
77
109
|
protected onmessage(message: Message<InterAppPayload>): boolean;
|
|
78
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
79
114
|
export declare class InterAppPayload {
|
|
80
115
|
sourceUuid: string;
|
|
81
116
|
sourceWindowName: string;
|
|
@@ -8,9 +8,12 @@ const index_1 = require("./channel/index");
|
|
|
8
8
|
const validate_1 = require("../../util/validate");
|
|
9
9
|
/**
|
|
10
10
|
* A messaging bus that allows for pub/sub messaging between different applications.
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
12
|
*/
|
|
13
13
|
class InterApplicationBus extends base_1.Base {
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
14
17
|
constructor(wire) {
|
|
15
18
|
super(wire);
|
|
16
19
|
this.events = {
|
|
@@ -27,12 +30,15 @@ class InterApplicationBus extends base_1.Base {
|
|
|
27
30
|
/**
|
|
28
31
|
* Publishes a message to all applications running on OpenFin Runtime that
|
|
29
32
|
* are subscribed to the specified topic.
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
33
|
+
* @param topic The topic on which the message is sent
|
|
34
|
+
* @param message The message to be published. Can be either a primitive
|
|
32
35
|
* data type (string, number, or boolean) or composite data type (object, array)
|
|
33
36
|
* that is composed of other primitive or composite data types
|
|
34
|
-
*
|
|
35
|
-
* @
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```js
|
|
40
|
+
* fin.InterApplicationBus.publish('topic', 'hello').then(() => console.log('Published')).catch(err => console.log(err));
|
|
41
|
+
* ```
|
|
36
42
|
*/
|
|
37
43
|
publish(topic, message) {
|
|
38
44
|
return this.wire
|
|
@@ -45,13 +51,16 @@ class InterApplicationBus extends base_1.Base {
|
|
|
45
51
|
}
|
|
46
52
|
/**
|
|
47
53
|
* Sends a message to a specific application on a specific topic.
|
|
48
|
-
* @param
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
54
|
+
* @param destination The identity of the application to which the message is sent
|
|
55
|
+
* @param topic The topic on which the message is sent
|
|
56
|
+
* @param message The message to be sent. Can be either a primitive data
|
|
51
57
|
* type (string, number, or boolean) or composite data type (object, array) that
|
|
52
58
|
* is composed of other primitive or composite data types
|
|
53
|
-
*
|
|
54
|
-
* @
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```js
|
|
62
|
+
* fin.InterApplicationBus.send(fin.me, 'topic', 'Hello there!').then(() => console.log('Message sent')).catch(err => console.log(err));
|
|
63
|
+
* ```
|
|
55
64
|
*/
|
|
56
65
|
async send(destination, topic, message) {
|
|
57
66
|
const errorMsg = (0, validate_1.validateIdentity)(destination);
|
|
@@ -68,15 +77,22 @@ class InterApplicationBus extends base_1.Base {
|
|
|
68
77
|
}
|
|
69
78
|
/**
|
|
70
79
|
* Subscribes to messages from the specified application on the specified topic.
|
|
71
|
-
* @param
|
|
72
|
-
* @param
|
|
73
|
-
* @param
|
|
80
|
+
* @param source This object is described in the Identity in the typedef
|
|
81
|
+
* @param topic The topic on which the message is sent
|
|
82
|
+
* @param listener A function that is called when a message has
|
|
74
83
|
* been received. It is passed the message, uuid and name of the sending application.
|
|
75
84
|
* The message can be either a primitive data type (string, number, or boolean) or
|
|
76
85
|
* composite data type (object, array) that is composed of other primitive or composite
|
|
77
86
|
* data types
|
|
78
|
-
*
|
|
79
|
-
* @
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```js
|
|
90
|
+
* // subscribe to a specified application
|
|
91
|
+
* fin.InterApplicationBus.subscribe(fin.me, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to the specified application')).catch(err => console.log(err));
|
|
92
|
+
*
|
|
93
|
+
* // subscribe to wildcard
|
|
94
|
+
* fin.InterApplicationBus.subscribe({ uuid: '*' }, 'topic', sub_msg => console.log(sub_msg)).then(() => console.log('Subscribed to *')).catch(err => console.log(err));
|
|
95
|
+
* ```
|
|
80
96
|
*/
|
|
81
97
|
subscribe(source, topic, listener) {
|
|
82
98
|
const subKey = this.createSubscriptionKey(source.uuid, source.name || '*', topic);
|
|
@@ -96,11 +112,27 @@ class InterApplicationBus extends base_1.Base {
|
|
|
96
112
|
}
|
|
97
113
|
/**
|
|
98
114
|
* Unsubscribes to messages from the specified application on the specified topic.
|
|
99
|
-
*
|
|
100
|
-
* @
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
115
|
+
*
|
|
116
|
+
* @remarks If you are listening to all apps on a topic, (i.e you passed `{ uuid:'*' }` to the subscribe function)
|
|
117
|
+
* then you need to pass `{ uuid:'*' }` to unsubscribe as well. If you are listening to a specific application,
|
|
118
|
+
* (i.e you passed `{ uuid:'some_app' }` to the subscribe function) then you need to provide the same identifier to
|
|
119
|
+
* unsubscribe, unsubscribing to `*` on that same topic will not unhook your initial listener otherwise.
|
|
120
|
+
*
|
|
121
|
+
* @param source This object is described in the Identity in the typedef
|
|
122
|
+
* @param topic The topic on which the message is sent
|
|
123
|
+
* @param listener A callback previously registered with subscribe()
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```js
|
|
127
|
+
* const listener = console.log;
|
|
128
|
+
*
|
|
129
|
+
* // If any application publishes a message on topic `foo`, our listener will be called.
|
|
130
|
+
* await fin.InterApplicationBus.subscribe({ uuid:'*' }, 'foo', listener)
|
|
131
|
+
*
|
|
132
|
+
* // When you want to unsubscribe, you need to specify the uuid of the app you'd like to
|
|
133
|
+
* // unsubscribe from (or `*`) and provide the same function you gave the subscribe function
|
|
134
|
+
* await fin.InterApplicationBus.unsubscribe({ uuid:'*' }, 'foo', listener)
|
|
135
|
+
* ```
|
|
104
136
|
*/
|
|
105
137
|
unsubscribe(source, topic, listener) {
|
|
106
138
|
const sourceWindowName = source.name || '*';
|
|
@@ -163,6 +195,9 @@ class InterApplicationBus extends base_1.Base {
|
|
|
163
195
|
}
|
|
164
196
|
}
|
|
165
197
|
exports.default = InterApplicationBus;
|
|
198
|
+
/**
|
|
199
|
+
* @internal
|
|
200
|
+
*/
|
|
166
201
|
class InterAppPayload {
|
|
167
202
|
}
|
|
168
203
|
exports.InterAppPayload = InterAppPayload;
|
|
@@ -11,26 +11,46 @@ import { InteropClient } from './InteropClient';
|
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
13
|
* Manages creation of Interop Brokers and Interop Clients. These APIs are called under-the-hood in Platforms.
|
|
14
|
-
*
|
|
15
|
-
* @alias Interop
|
|
14
|
+
*
|
|
16
15
|
*/
|
|
17
16
|
export default class InteropModule extends Base {
|
|
18
17
|
/**
|
|
19
18
|
* Initializes an Interop Broker. This is called under-the-hood for Platforms.
|
|
20
|
-
*
|
|
21
|
-
* @
|
|
22
|
-
* @
|
|
23
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* @remarks For Platforms, this is set up automatically. We advise to only create your own Interop Broker
|
|
21
|
+
* when not using a Platform app. You can override functions in the Interop Broker. More info {@link InteropBroker here}.
|
|
22
|
+
*
|
|
23
|
+
* @param name - Name of the Interop Broker.
|
|
24
|
+
* @param override - A callback function that can be used to extend or replace default Interop Broker behavior.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ``` js
|
|
28
|
+
* const interopBroker = await fin.Interop.init('openfin');
|
|
29
|
+
* const contextGroups = await interopBroker.getContextGroups();
|
|
30
|
+
* console.log(contextGroups);
|
|
31
|
+
* ```
|
|
24
32
|
* @static
|
|
25
33
|
*/
|
|
26
34
|
init(name: string, override?: OpenFin.OverrideCallback<InteropBroker>): Promise<InteropBroker>;
|
|
27
35
|
/**
|
|
28
36
|
* Connects a client to an Interop broker. This is called under-the-hood for Views in a Platform.
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* @param name - The name of the Interop Broker to connect to. For Platforms, this will default to the uuid of the Platform.
|
|
40
|
+
* @param interopConfig - Information relevant to the Interop Broker. Typically a declaration of
|
|
31
41
|
* what context(s) the entity wants to subscribe to, and the current Context Group of the entity.
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```js
|
|
45
|
+
* const interopConfig = {
|
|
46
|
+
* currentContextGroup: 'green'
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* const interopBroker = await fin.Interop.init('openfin');
|
|
50
|
+
* const client = await fin.Interop.connectSync('openfin', interopConfig);
|
|
51
|
+
* const contextGroupInfo = await client.getInfoForContextGroup();
|
|
52
|
+
* console.log(contextGroupInfo);
|
|
53
|
+
* ```
|
|
34
54
|
* @static
|
|
35
55
|
*/
|
|
36
56
|
connectSync(name: string, interopConfig?: OpenFin.InteropConfig): InteropClient;
|
|
@@ -17,16 +17,24 @@ const BrokerParamAccessError = 'You have attempted to use or modify InteropBroke
|
|
|
17
17
|
*/
|
|
18
18
|
/**
|
|
19
19
|
* Manages creation of Interop Brokers and Interop Clients. These APIs are called under-the-hood in Platforms.
|
|
20
|
-
*
|
|
21
|
-
* @alias Interop
|
|
20
|
+
*
|
|
22
21
|
*/
|
|
23
22
|
class InteropModule extends base_1.Base {
|
|
24
23
|
/**
|
|
25
24
|
* Initializes an Interop Broker. This is called under-the-hood for Platforms.
|
|
26
|
-
*
|
|
27
|
-
* @
|
|
28
|
-
* @
|
|
29
|
-
*
|
|
25
|
+
*
|
|
26
|
+
* @remarks For Platforms, this is set up automatically. We advise to only create your own Interop Broker
|
|
27
|
+
* when not using a Platform app. You can override functions in the Interop Broker. More info {@link InteropBroker here}.
|
|
28
|
+
*
|
|
29
|
+
* @param name - Name of the Interop Broker.
|
|
30
|
+
* @param override - A callback function that can be used to extend or replace default Interop Broker behavior.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ``` js
|
|
34
|
+
* const interopBroker = await fin.Interop.init('openfin');
|
|
35
|
+
* const contextGroups = await interopBroker.getContextGroups();
|
|
36
|
+
* console.log(contextGroups);
|
|
37
|
+
* ```
|
|
30
38
|
* @static
|
|
31
39
|
*/
|
|
32
40
|
async init(name, override = defaultOverride) {
|
|
@@ -59,11 +67,23 @@ class InteropModule extends base_1.Base {
|
|
|
59
67
|
}
|
|
60
68
|
/**
|
|
61
69
|
* Connects a client to an Interop broker. This is called under-the-hood for Views in a Platform.
|
|
62
|
-
*
|
|
63
|
-
* @
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* @param name - The name of the Interop Broker to connect to. For Platforms, this will default to the uuid of the Platform.
|
|
73
|
+
* @param interopConfig - Information relevant to the Interop Broker. Typically a declaration of
|
|
64
74
|
* what context(s) the entity wants to subscribe to, and the current Context Group of the entity.
|
|
65
|
-
*
|
|
66
|
-
* @
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```js
|
|
78
|
+
* const interopConfig = {
|
|
79
|
+
* currentContextGroup: 'green'
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
* const interopBroker = await fin.Interop.init('openfin');
|
|
83
|
+
* const client = await fin.Interop.connectSync('openfin', interopConfig);
|
|
84
|
+
* const contextGroupInfo = await client.getInfoForContextGroup();
|
|
85
|
+
* console.log(contextGroupInfo);
|
|
86
|
+
* ```
|
|
67
87
|
* @static
|
|
68
88
|
*/
|
|
69
89
|
connectSync(name, interopConfig) {
|