@openfin/core 25.68.30 → 25.70.2
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.d.ts +30 -826
- package/README.md +12 -2
- package/package.json +1 -1
- package/src/api/application/Factory.d.ts +145 -145
- package/src/api/application/Factory.js +229 -229
- package/src/api/application/Instance.d.ts +301 -302
- package/src/api/application/Instance.js +412 -412
- package/src/api/application/index.d.ts +3 -3
- package/src/api/application/index.js +15 -15
- package/src/api/base.d.ts +43 -43
- package/src/api/base.js +177 -177
- package/src/api/clipboard/index.d.ts +69 -69
- package/src/api/clipboard/index.js +88 -88
- 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 -11
- package/src/api/events/channel.js +2 -2
- package/src/api/events/emitterMap.d.ts +11 -11
- package/src/api/events/emitterMap.js +35 -35
- package/src/api/events/eventAggregator.d.ts +5 -5
- package/src/api/events/eventAggregator.js +43 -43
- 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 +176 -0
- package/src/api/events/window.js +2 -0
- package/src/api/external-application/Factory.d.ts +26 -26
- package/src/api/external-application/Factory.js +40 -40
- package/src/api/external-application/Instance.d.ts +101 -102
- package/src/api/external-application/Instance.js +109 -109
- package/src/api/external-application/index.d.ts +3 -3
- package/src/api/external-application/index.js +15 -15
- package/src/api/fin.d.ts +49 -49
- package/src/api/fin.js +43 -43
- package/src/api/frame/Factory.d.ts +36 -36
- package/src/api/frame/Factory.js +69 -69
- package/src/api/frame/Instance.d.ts +121 -121
- package/src/api/frame/Instance.js +130 -130
- package/src/api/frame/index.d.ts +3 -3
- package/src/api/frame/index.js +15 -15
- package/src/api/global-hotkey/index.d.ts +38 -38
- package/src/api/global-hotkey/index.js +58 -58
- package/src/api/interappbus/channel/channel.d.ts +26 -26
- package/src/api/interappbus/channel/channel.js +77 -77
- package/src/api/interappbus/channel/channels-docs.d.ts +318 -318
- package/src/api/interappbus/channel/channels-docs.js +376 -376
- package/src/api/interappbus/channel/client.d.ts +22 -22
- package/src/api/interappbus/channel/client.js +84 -84
- package/src/api/interappbus/channel/connection-manager.d.ts +28 -28
- package/src/api/interappbus/channel/connection-manager.js +244 -244
- package/src/api/interappbus/channel/index.d.ts +22 -23
- package/src/api/interappbus/channel/index.js +121 -121
- package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +13 -13
- package/src/api/interappbus/channel/protocols/classic/message-receiver.js +73 -73
- package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +22 -22
- package/src/api/interappbus/channel/protocols/classic/strategy.js +84 -84
- package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +20 -20
- package/src/api/interappbus/channel/protocols/combined/strategy.js +58 -58
- package/src/api/interappbus/channel/protocols/index.d.ts +44 -44
- package/src/api/interappbus/channel/protocols/index.js +2 -2
- package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +10 -10
- package/src/api/interappbus/channel/protocols/protocol-manager.js +43 -43
- package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +23 -23
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +135 -135
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +30 -30
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +131 -131
- package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +22 -22
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +87 -87
- package/src/api/interappbus/channel/protocols/strategy-types.d.ts +13 -13
- package/src/api/interappbus/channel/protocols/strategy-types.js +2 -2
- package/src/api/interappbus/channel/protocols/strategy.d.ts +15 -15
- package/src/api/interappbus/channel/protocols/strategy.js +2 -2
- package/src/api/interappbus/channel/provider.d.ts +31 -31
- package/src/api/interappbus/channel/provider.js +160 -160
- package/src/api/interappbus/index.d.ts +85 -86
- package/src/api/interappbus/index.js +175 -175
- package/src/api/interop/Factory.d.ts +37 -37
- package/src/api/interop/Factory.js +54 -54
- package/src/api/interop/InteropBroker.d.ts +363 -363
- package/src/api/interop/InteropBroker.js +914 -914
- package/src/api/interop/InteropClient.d.ts +268 -268
- package/src/api/interop/InteropClient.js +450 -450
- package/src/api/interop/SessionContextGroupBroker.d.ts +26 -26
- package/src/api/interop/SessionContextGroupBroker.js +107 -107
- package/src/api/interop/SessionContextGroupClient.d.ts +20 -20
- package/src/api/interop/SessionContextGroupClient.js +85 -85
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +187 -187
- package/src/api/interop/fdc3/fdc3-1.2.js +385 -385
- package/src/api/interop/fdc3/fdc3.js +17 -17
- package/src/api/interop/fdc3/utils.d.ts +6 -6
- package/src/api/interop/fdc3/utils.js +17 -17
- package/src/api/interop/index.d.ts +4 -4
- package/src/api/interop/index.js +16 -16
- package/src/api/interop/utils.d.ts +11 -11
- package/src/api/interop/utils.js +36 -36
- package/src/api/me.d.ts +38 -35
- package/src/api/me.js +128 -60
- package/src/api/platform/Factory.d.ts +109 -109
- package/src/api/platform/Factory.js +188 -188
- package/src/api/platform/Instance.d.ts +122 -122
- package/src/api/platform/Instance.js +298 -298
- package/src/api/platform/common-utils.d.ts +6 -6
- package/src/api/platform/common-utils.js +16 -16
- package/src/api/platform/index.d.ts +3 -3
- package/src/api/platform/index.js +15 -15
- package/src/api/platform/layout/Factory.d.ts +108 -108
- package/src/api/platform/layout/Factory.js +189 -189
- package/src/api/platform/layout/Instance.d.ts +49 -49
- package/src/api/platform/layout/Instance.js +99 -99
- package/src/api/platform/layout/index.d.ts +2 -2
- package/src/api/platform/layout/index.js +14 -14
- package/src/api/platform/layout/shapes.d.ts +11 -0
- package/src/api/{window → platform/layout}/shapes.js +2 -2
- package/src/api/snapshot-source/Factory.d.ts +36 -36
- package/src/api/snapshot-source/Factory.js +65 -65
- package/src/api/snapshot-source/Instance.d.ts +30 -30
- package/src/api/snapshot-source/Instance.js +134 -134
- package/src/api/snapshot-source/index.d.ts +3 -3
- package/src/api/snapshot-source/index.js +15 -15
- package/src/api/snapshot-source/utils.d.ts +1 -1
- package/src/api/snapshot-source/utils.js +5 -5
- package/src/api/system/index.d.ts +960 -961
- package/src/api/system/index.js +1241 -1241
- package/src/api/view/Factory.d.ts +49 -49
- package/src/api/view/Factory.js +103 -103
- package/src/api/view/Instance.d.ts +387 -380
- package/src/api/view/Instance.js +422 -415
- package/src/api/view/index.d.ts +3 -3
- package/src/api/view/index.js +15 -15
- package/src/api/webcontents/main.d.ts +36 -36
- package/src/api/webcontents/main.js +82 -82
- package/src/api/window/Factory.d.ts +44 -44
- package/src/api/window/Factory.js +91 -91
- package/src/api/window/Instance.d.ts +972 -966
- package/src/api/window/Instance.js +1209 -1202
- package/src/api/window/index.d.ts +3 -5
- package/src/api/window/index.js +15 -17
- package/src/environment/environment.d.ts +28 -25
- package/src/environment/environment.js +4 -4
- package/src/environment/node-env.d.ts +25 -26
- package/src/environment/node-env.js +64 -64
- package/src/environment/openfin-env.d.ts +29 -30
- package/src/environment/openfin-env.js +107 -107
- package/src/mock.d.ts +3 -3
- package/src/mock.js +91 -90
- package/src/shapes/ERROR_BOX_TYPES.d.ts +1 -0
- package/src/shapes/ERROR_BOX_TYPES.js +2 -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 -4
- package/src/transport/fin_store.js +16 -16
- package/src/transport/transport-errors.d.ts +18 -18
- package/src/transport/transport-errors.js +37 -37
- package/src/transport/transport.d.ts +56 -43
- package/src/transport/transport.js +181 -181
- package/src/transport/wire.d.ts +71 -11
- package/src/transport/wire.js +32 -32
- package/src/util/asyncFilter.d.ts +1 -1
- package/src/util/asyncFilter.js +7 -7
- package/src/util/errors.d.ts +9 -5
- package/src/util/errors.js +11 -11
- package/src/util/exhaustive.d.ts +1 -1
- package/src/util/exhaustive.js +7 -7
- package/src/util/http.d.ts +11 -11
- package/src/util/http.js +83 -83
- package/src/util/normalize-config.d.ts +3 -5
- package/src/util/normalize-config.js +47 -47
- package/src/util/promises.d.ts +5 -5
- package/src/util/promises.js +27 -27
- package/src/util/ref-counter.d.ts +7 -7
- package/src/util/ref-counter.js +51 -51
- package/src/util/runtimeVersioning.d.ts +3 -3
- package/src/util/runtimeVersioning.js +25 -25
- package/src/util/utilTypes.d.ts +8 -8
- package/src/util/utilTypes.js +2 -2
- package/src/util/validate.d.ts +3 -3
- package/src/util/validate.js +11 -11
- package/docs.README(OLD).md +0 -82
- package/resources/win/OpenFinRVM.exe +0 -0
- package/src/api/window/bounds-changed.d.ts +0 -10
- package/src/api/window/bounds-changed.js +0 -6
- package/src/api/window/shapes.d.ts +0 -13
|
@@ -1,86 +1,85 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
import { Base } from '../base';
|
|
4
|
-
import Transport from '../../transport/transport';
|
|
5
|
-
import { Channel } from './channel/index';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @param {
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
* @param {
|
|
50
|
-
* @param {
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*
|
|
65
|
-
* @param {
|
|
66
|
-
* @param {
|
|
67
|
-
* @
|
|
68
|
-
* @
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
private
|
|
76
|
-
|
|
77
|
-
protected
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { Base } from '../base';
|
|
4
|
+
import Transport, { Message } from '../../transport/transport';
|
|
5
|
+
import { Channel } from './channel/index';
|
|
6
|
+
/**
|
|
7
|
+
* A messaging bus that allows for pub/sub messaging between different applications.
|
|
8
|
+
* @namespace
|
|
9
|
+
*/
|
|
10
|
+
export default class InterApplicationBus extends Base {
|
|
11
|
+
Channel: Channel;
|
|
12
|
+
events: {
|
|
13
|
+
subscriberAdded: string;
|
|
14
|
+
subscriberRemoved: string;
|
|
15
|
+
};
|
|
16
|
+
private refCounter;
|
|
17
|
+
protected emitter: EventEmitter;
|
|
18
|
+
on: any;
|
|
19
|
+
removeAllListeners: any;
|
|
20
|
+
constructor(wire: Transport);
|
|
21
|
+
/**
|
|
22
|
+
* Publishes a message to all applications running on OpenFin Runtime that
|
|
23
|
+
* are subscribed to the specified topic.
|
|
24
|
+
* @param { string } topic The topic on which the message is sent
|
|
25
|
+
* @param { any } message The message to be published. Can be either a primitive
|
|
26
|
+
* data type (string, number, or boolean) or composite data type (object, array)
|
|
27
|
+
* that is composed of other primitive or composite data types
|
|
28
|
+
* @return {Promise.<void>}
|
|
29
|
+
* @tutorial InterApplicationBus.publish
|
|
30
|
+
*/
|
|
31
|
+
publish(topic: string, message: any): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Sends a message to a specific application on a specific topic.
|
|
34
|
+
* @param { Identity } destination The identity of the application to which the message is sent
|
|
35
|
+
* @param { string } topic The topic on which the message is sent
|
|
36
|
+
* @param { any } message The message to be sent. Can be either a primitive data
|
|
37
|
+
* type (string, number, or boolean) or composite data type (object, array) that
|
|
38
|
+
* is composed of other primitive or composite data types
|
|
39
|
+
* @return {Promise.<void>}
|
|
40
|
+
* @tutorial InterApplicationBus.send
|
|
41
|
+
*/
|
|
42
|
+
send(destination: {
|
|
43
|
+
uuid: string;
|
|
44
|
+
name?: string;
|
|
45
|
+
}, topic: string, message: any): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Subscribes to messages from the specified application on the specified topic.
|
|
48
|
+
* @param { Identity } source This object is described in the Identity in the typedef
|
|
49
|
+
* @param { string } topic The topic on which the message is sent
|
|
50
|
+
* @param { function } listener A function that is called when a message has
|
|
51
|
+
* been received. It is passed the message, uuid and name of the sending application.
|
|
52
|
+
* The message can be either a primitive data type (string, number, or boolean) or
|
|
53
|
+
* composite data type (object, array) that is composed of other primitive or composite
|
|
54
|
+
* data types
|
|
55
|
+
* @return {Promise.<void>}
|
|
56
|
+
* @tutorial InterApplicationBus.subscribe
|
|
57
|
+
*/
|
|
58
|
+
subscribe(source: {
|
|
59
|
+
uuid: string;
|
|
60
|
+
name?: string;
|
|
61
|
+
}, topic: string, listener: any): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Unsubscribes to messages from the specified application on the specified topic.
|
|
64
|
+
* @param { Identity } source This object is described in the Identity in the typedef
|
|
65
|
+
* @param { string } topic The topic on which the message is sent
|
|
66
|
+
* @param { function } listener A callback previously registered with subscribe()
|
|
67
|
+
* @return {Promise.<void>}
|
|
68
|
+
* @tutorial InterApplicationBus.unsubscribe
|
|
69
|
+
*/
|
|
70
|
+
unsubscribe(source: {
|
|
71
|
+
uuid: string;
|
|
72
|
+
name?: string;
|
|
73
|
+
}, topic: string, listener: any): Promise<void>;
|
|
74
|
+
private processMessage;
|
|
75
|
+
private emitSubscriverEvent;
|
|
76
|
+
protected createSubscriptionKey(uuid: string, name: string, topic: string): string;
|
|
77
|
+
protected onmessage(message: Message<InterAppPayload>): boolean;
|
|
78
|
+
}
|
|
79
|
+
export declare class InterAppPayload {
|
|
80
|
+
sourceUuid: string;
|
|
81
|
+
sourceWindowName: string;
|
|
82
|
+
topic: string;
|
|
83
|
+
destinationUuid?: string;
|
|
84
|
+
message?: any;
|
|
85
|
+
}
|
|
@@ -1,175 +1,175 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InterAppPayload = void 0;
|
|
4
|
-
const events_1 = require("events");
|
|
5
|
-
const base_1 = require("../base");
|
|
6
|
-
const ref_counter_1 = require("../../util/ref-counter");
|
|
7
|
-
const index_1 = require("./channel/index");
|
|
8
|
-
const validate_1 = require("../../util/validate");
|
|
9
|
-
/**
|
|
10
|
-
* A messaging bus that allows for pub/sub messaging between different applications.
|
|
11
|
-
* @namespace
|
|
12
|
-
*/
|
|
13
|
-
class InterApplicationBus extends base_1.Base {
|
|
14
|
-
constructor(wire) {
|
|
15
|
-
super(wire);
|
|
16
|
-
this.events = {
|
|
17
|
-
subscriberAdded: 'subscriber-added',
|
|
18
|
-
subscriberRemoved: 'subscriber-removed'
|
|
19
|
-
};
|
|
20
|
-
this.refCounter = new ref_counter_1.default();
|
|
21
|
-
this.Channel = new index_1.Channel(wire);
|
|
22
|
-
this.emitter = new events_1.EventEmitter();
|
|
23
|
-
wire.registerMessageHandler(this.onmessage.bind(this));
|
|
24
|
-
this.on = this.emitter.on.bind(this.emitter);
|
|
25
|
-
this.removeAllListeners = this.emitter.removeAllListeners.bind(this.emitter);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Publishes a message to all applications running on OpenFin Runtime that
|
|
29
|
-
* are subscribed to the specified topic.
|
|
30
|
-
* @param { string } topic The topic on which the message is sent
|
|
31
|
-
* @param { any } message The message to be published. Can be either a primitive
|
|
32
|
-
* data type (string, number, or boolean) or composite data type (object, array)
|
|
33
|
-
* that is composed of other primitive or composite data types
|
|
34
|
-
* @return {Promise.<void>}
|
|
35
|
-
* @tutorial InterApplicationBus.publish
|
|
36
|
-
*/
|
|
37
|
-
publish(topic, message) {
|
|
38
|
-
return this.wire
|
|
39
|
-
.sendAction('publish-message', {
|
|
40
|
-
topic,
|
|
41
|
-
message,
|
|
42
|
-
sourceWindowName: this.me.name
|
|
43
|
-
})
|
|
44
|
-
.then(() => undefined);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Sends a message to a specific application on a specific topic.
|
|
48
|
-
* @param { Identity } destination The identity of the application to which the message is sent
|
|
49
|
-
* @param { string } topic The topic on which the message is sent
|
|
50
|
-
* @param { any } message The message to be sent. Can be either a primitive data
|
|
51
|
-
* type (string, number, or boolean) or composite data type (object, array) that
|
|
52
|
-
* is composed of other primitive or composite data types
|
|
53
|
-
* @return {Promise.<void>}
|
|
54
|
-
* @tutorial InterApplicationBus.send
|
|
55
|
-
*/
|
|
56
|
-
async send(destination, topic, message) {
|
|
57
|
-
const errorMsg = validate_1.validateIdentity(destination);
|
|
58
|
-
if (errorMsg) {
|
|
59
|
-
throw new Error(errorMsg);
|
|
60
|
-
}
|
|
61
|
-
await this.wire.sendAction('send-message', {
|
|
62
|
-
destinationUuid: destination.uuid,
|
|
63
|
-
destinationWindowName: destination.name,
|
|
64
|
-
topic,
|
|
65
|
-
message,
|
|
66
|
-
sourceWindowName: this.me.name
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Subscribes to messages from the specified application on the specified topic.
|
|
71
|
-
* @param { Identity } source This object is described in the Identity in the typedef
|
|
72
|
-
* @param { string } topic The topic on which the message is sent
|
|
73
|
-
* @param { function } listener A function that is called when a message has
|
|
74
|
-
* been received. It is passed the message, uuid and name of the sending application.
|
|
75
|
-
* The message can be either a primitive data type (string, number, or boolean) or
|
|
76
|
-
* composite data type (object, array) that is composed of other primitive or composite
|
|
77
|
-
* data types
|
|
78
|
-
* @return {Promise.<void>}
|
|
79
|
-
* @tutorial InterApplicationBus.subscribe
|
|
80
|
-
*/
|
|
81
|
-
subscribe(source, topic, listener) {
|
|
82
|
-
const subKey = this.createSubscriptionKey(source.uuid, source.name || '*', topic);
|
|
83
|
-
const sendSubscription = () => {
|
|
84
|
-
return this.wire.sendAction('subscribe', {
|
|
85
|
-
sourceUuid: source.uuid,
|
|
86
|
-
sourceWindowName: source.name || '*',
|
|
87
|
-
topic,
|
|
88
|
-
destinationWindowName: this.me.name
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
const alreadySubscribed = () => {
|
|
92
|
-
return Promise.resolve();
|
|
93
|
-
};
|
|
94
|
-
this.emitter.on(subKey, listener);
|
|
95
|
-
return this.refCounter.actOnFirst(subKey, sendSubscription, alreadySubscribed);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Unsubscribes to messages from the specified application on the specified topic.
|
|
99
|
-
* @param { Identity } source This object is described in the Identity in the typedef
|
|
100
|
-
* @param { string } topic The topic on which the message is sent
|
|
101
|
-
* @param { function } listener A callback previously registered with subscribe()
|
|
102
|
-
* @return {Promise.<void>}
|
|
103
|
-
* @tutorial InterApplicationBus.unsubscribe
|
|
104
|
-
*/
|
|
105
|
-
unsubscribe(source, topic, listener) {
|
|
106
|
-
const sourceWindowName = source.name || '*';
|
|
107
|
-
const subKey = this.createSubscriptionKey(source.uuid, sourceWindowName, topic);
|
|
108
|
-
const sendUnsubscription = () => {
|
|
109
|
-
return this.wire.sendAction('unsubscribe', {
|
|
110
|
-
sourceUuid: source.uuid,
|
|
111
|
-
sourceWindowName,
|
|
112
|
-
topic,
|
|
113
|
-
destinationWindowName: this.me.name
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
const dontSendUnsubscription = () => {
|
|
117
|
-
return new Promise((r) => r).then(() => undefined);
|
|
118
|
-
};
|
|
119
|
-
this.emitter.removeListener(subKey, listener);
|
|
120
|
-
return this.refCounter.actOnLast(subKey, sendUnsubscription, dontSendUnsubscription);
|
|
121
|
-
}
|
|
122
|
-
processMessage(message) {
|
|
123
|
-
const { payload: { message: payloadMessage, sourceWindowName, sourceUuid, topic } } = message;
|
|
124
|
-
const keys = [
|
|
125
|
-
this.createSubscriptionKey(sourceUuid, sourceWindowName, topic),
|
|
126
|
-
this.createSubscriptionKey(sourceUuid, '*', topic),
|
|
127
|
-
this.createSubscriptionKey('*', '*', topic)
|
|
128
|
-
];
|
|
129
|
-
const idOfSender = { uuid: sourceUuid, name: sourceWindowName };
|
|
130
|
-
keys.forEach((key) => {
|
|
131
|
-
this.emitter.emit(key, payloadMessage, idOfSender);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
emitSubscriverEvent(type, message) {
|
|
135
|
-
const { payload: { targetName: name, uuid, topic } } = message;
|
|
136
|
-
const payload = { name, uuid, topic };
|
|
137
|
-
this.emitter.emit(type, payload);
|
|
138
|
-
}
|
|
139
|
-
// eslint-disable-next-line class-methods-use-this
|
|
140
|
-
createSubscriptionKey(uuid, name, topic) {
|
|
141
|
-
const n = name || '*';
|
|
142
|
-
if (!(uuid && n && topic)) {
|
|
143
|
-
throw new Error('Missing uuid, name, or topic string');
|
|
144
|
-
}
|
|
145
|
-
return createKey(uuid, n, topic);
|
|
146
|
-
}
|
|
147
|
-
onmessage(message) {
|
|
148
|
-
const { action } = message;
|
|
149
|
-
switch (action) {
|
|
150
|
-
case 'process-message':
|
|
151
|
-
this.processMessage(message);
|
|
152
|
-
break;
|
|
153
|
-
case this.events.subscriberAdded:
|
|
154
|
-
this.emitSubscriverEvent(this.events.subscriberAdded, message);
|
|
155
|
-
break;
|
|
156
|
-
case this.events.subscriberRemoved:
|
|
157
|
-
this.emitSubscriverEvent(this.events.subscriberRemoved, message);
|
|
158
|
-
break;
|
|
159
|
-
default:
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
return true;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
exports.default = InterApplicationBus;
|
|
166
|
-
class InterAppPayload {
|
|
167
|
-
}
|
|
168
|
-
exports.InterAppPayload = InterAppPayload;
|
|
169
|
-
function createKey(...toHash) {
|
|
170
|
-
return toHash
|
|
171
|
-
.map((item) => {
|
|
172
|
-
return Buffer.from(`${item}`).toString('base64');
|
|
173
|
-
})
|
|
174
|
-
.join('/');
|
|
175
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InterAppPayload = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const base_1 = require("../base");
|
|
6
|
+
const ref_counter_1 = require("../../util/ref-counter");
|
|
7
|
+
const index_1 = require("./channel/index");
|
|
8
|
+
const validate_1 = require("../../util/validate");
|
|
9
|
+
/**
|
|
10
|
+
* A messaging bus that allows for pub/sub messaging between different applications.
|
|
11
|
+
* @namespace
|
|
12
|
+
*/
|
|
13
|
+
class InterApplicationBus extends base_1.Base {
|
|
14
|
+
constructor(wire) {
|
|
15
|
+
super(wire);
|
|
16
|
+
this.events = {
|
|
17
|
+
subscriberAdded: 'subscriber-added',
|
|
18
|
+
subscriberRemoved: 'subscriber-removed'
|
|
19
|
+
};
|
|
20
|
+
this.refCounter = new ref_counter_1.default();
|
|
21
|
+
this.Channel = new index_1.Channel(wire);
|
|
22
|
+
this.emitter = new events_1.EventEmitter();
|
|
23
|
+
wire.registerMessageHandler(this.onmessage.bind(this));
|
|
24
|
+
this.on = this.emitter.on.bind(this.emitter);
|
|
25
|
+
this.removeAllListeners = this.emitter.removeAllListeners.bind(this.emitter);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Publishes a message to all applications running on OpenFin Runtime that
|
|
29
|
+
* are subscribed to the specified topic.
|
|
30
|
+
* @param { string } topic The topic on which the message is sent
|
|
31
|
+
* @param { any } message The message to be published. Can be either a primitive
|
|
32
|
+
* data type (string, number, or boolean) or composite data type (object, array)
|
|
33
|
+
* that is composed of other primitive or composite data types
|
|
34
|
+
* @return {Promise.<void>}
|
|
35
|
+
* @tutorial InterApplicationBus.publish
|
|
36
|
+
*/
|
|
37
|
+
publish(topic, message) {
|
|
38
|
+
return this.wire
|
|
39
|
+
.sendAction('publish-message', {
|
|
40
|
+
topic,
|
|
41
|
+
message,
|
|
42
|
+
sourceWindowName: this.me.name
|
|
43
|
+
})
|
|
44
|
+
.then(() => undefined);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Sends a message to a specific application on a specific topic.
|
|
48
|
+
* @param { Identity } destination The identity of the application to which the message is sent
|
|
49
|
+
* @param { string } topic The topic on which the message is sent
|
|
50
|
+
* @param { any } message The message to be sent. Can be either a primitive data
|
|
51
|
+
* type (string, number, or boolean) or composite data type (object, array) that
|
|
52
|
+
* is composed of other primitive or composite data types
|
|
53
|
+
* @return {Promise.<void>}
|
|
54
|
+
* @tutorial InterApplicationBus.send
|
|
55
|
+
*/
|
|
56
|
+
async send(destination, topic, message) {
|
|
57
|
+
const errorMsg = validate_1.validateIdentity(destination);
|
|
58
|
+
if (errorMsg) {
|
|
59
|
+
throw new Error(errorMsg);
|
|
60
|
+
}
|
|
61
|
+
await this.wire.sendAction('send-message', {
|
|
62
|
+
destinationUuid: destination.uuid,
|
|
63
|
+
destinationWindowName: destination.name,
|
|
64
|
+
topic,
|
|
65
|
+
message,
|
|
66
|
+
sourceWindowName: this.me.name
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Subscribes to messages from the specified application on the specified topic.
|
|
71
|
+
* @param { Identity } source This object is described in the Identity in the typedef
|
|
72
|
+
* @param { string } topic The topic on which the message is sent
|
|
73
|
+
* @param { function } listener A function that is called when a message has
|
|
74
|
+
* been received. It is passed the message, uuid and name of the sending application.
|
|
75
|
+
* The message can be either a primitive data type (string, number, or boolean) or
|
|
76
|
+
* composite data type (object, array) that is composed of other primitive or composite
|
|
77
|
+
* data types
|
|
78
|
+
* @return {Promise.<void>}
|
|
79
|
+
* @tutorial InterApplicationBus.subscribe
|
|
80
|
+
*/
|
|
81
|
+
subscribe(source, topic, listener) {
|
|
82
|
+
const subKey = this.createSubscriptionKey(source.uuid, source.name || '*', topic);
|
|
83
|
+
const sendSubscription = () => {
|
|
84
|
+
return this.wire.sendAction('subscribe', {
|
|
85
|
+
sourceUuid: source.uuid,
|
|
86
|
+
sourceWindowName: source.name || '*',
|
|
87
|
+
topic,
|
|
88
|
+
destinationWindowName: this.me.name
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
const alreadySubscribed = () => {
|
|
92
|
+
return Promise.resolve();
|
|
93
|
+
};
|
|
94
|
+
this.emitter.on(subKey, listener);
|
|
95
|
+
return this.refCounter.actOnFirst(subKey, sendSubscription, alreadySubscribed);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Unsubscribes to messages from the specified application on the specified topic.
|
|
99
|
+
* @param { Identity } source This object is described in the Identity in the typedef
|
|
100
|
+
* @param { string } topic The topic on which the message is sent
|
|
101
|
+
* @param { function } listener A callback previously registered with subscribe()
|
|
102
|
+
* @return {Promise.<void>}
|
|
103
|
+
* @tutorial InterApplicationBus.unsubscribe
|
|
104
|
+
*/
|
|
105
|
+
unsubscribe(source, topic, listener) {
|
|
106
|
+
const sourceWindowName = source.name || '*';
|
|
107
|
+
const subKey = this.createSubscriptionKey(source.uuid, sourceWindowName, topic);
|
|
108
|
+
const sendUnsubscription = () => {
|
|
109
|
+
return this.wire.sendAction('unsubscribe', {
|
|
110
|
+
sourceUuid: source.uuid,
|
|
111
|
+
sourceWindowName,
|
|
112
|
+
topic,
|
|
113
|
+
destinationWindowName: this.me.name
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
const dontSendUnsubscription = () => {
|
|
117
|
+
return new Promise((r) => r).then(() => undefined);
|
|
118
|
+
};
|
|
119
|
+
this.emitter.removeListener(subKey, listener);
|
|
120
|
+
return this.refCounter.actOnLast(subKey, sendUnsubscription, dontSendUnsubscription);
|
|
121
|
+
}
|
|
122
|
+
processMessage(message) {
|
|
123
|
+
const { payload: { message: payloadMessage, sourceWindowName, sourceUuid, topic } } = message;
|
|
124
|
+
const keys = [
|
|
125
|
+
this.createSubscriptionKey(sourceUuid, sourceWindowName, topic),
|
|
126
|
+
this.createSubscriptionKey(sourceUuid, '*', topic),
|
|
127
|
+
this.createSubscriptionKey('*', '*', topic)
|
|
128
|
+
];
|
|
129
|
+
const idOfSender = { uuid: sourceUuid, name: sourceWindowName };
|
|
130
|
+
keys.forEach((key) => {
|
|
131
|
+
this.emitter.emit(key, payloadMessage, idOfSender);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
emitSubscriverEvent(type, message) {
|
|
135
|
+
const { payload: { targetName: name, uuid, topic } } = message;
|
|
136
|
+
const payload = { name, uuid, topic };
|
|
137
|
+
this.emitter.emit(type, payload);
|
|
138
|
+
}
|
|
139
|
+
// eslint-disable-next-line class-methods-use-this
|
|
140
|
+
createSubscriptionKey(uuid, name, topic) {
|
|
141
|
+
const n = name || '*';
|
|
142
|
+
if (!(uuid && n && topic)) {
|
|
143
|
+
throw new Error('Missing uuid, name, or topic string');
|
|
144
|
+
}
|
|
145
|
+
return createKey(uuid, n, topic);
|
|
146
|
+
}
|
|
147
|
+
onmessage(message) {
|
|
148
|
+
const { action } = message;
|
|
149
|
+
switch (action) {
|
|
150
|
+
case 'process-message':
|
|
151
|
+
this.processMessage(message);
|
|
152
|
+
break;
|
|
153
|
+
case this.events.subscriberAdded:
|
|
154
|
+
this.emitSubscriverEvent(this.events.subscriberAdded, message);
|
|
155
|
+
break;
|
|
156
|
+
case this.events.subscriberRemoved:
|
|
157
|
+
this.emitSubscriverEvent(this.events.subscriberRemoved, message);
|
|
158
|
+
break;
|
|
159
|
+
default:
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.default = InterApplicationBus;
|
|
166
|
+
class InterAppPayload {
|
|
167
|
+
}
|
|
168
|
+
exports.InterAppPayload = InterAppPayload;
|
|
169
|
+
function createKey(...toHash) {
|
|
170
|
+
return toHash
|
|
171
|
+
.map((item) => {
|
|
172
|
+
return Buffer.from(`${item}`).toString('base64');
|
|
173
|
+
})
|
|
174
|
+
.join('/');
|
|
175
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { Base } from '../base';
|
|
2
|
-
import { InteropBroker } from './InteropBroker';
|
|
3
|
-
import { InteropClient } from './InteropClient';
|
|
4
|
-
/**
|
|
5
|
-
* @typedef { object } InteropConfig
|
|
6
|
-
* @summary Information relevant to the Interop Broker.
|
|
7
|
-
* @property {string} [currentContextGroup] Context Group for the client. (green, yellow, red, etc.)
|
|
8
|
-
* @property {string} [providerId] When provided, automatically connects the client to the specified provider uuid
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Manages creation of Interop Brokers and Interop Clients. These APIs are called under-the-hood in Platforms.
|
|
12
|
-
* @namespace
|
|
13
|
-
* @alias Interop
|
|
14
|
-
*/
|
|
15
|
-
export default class InteropModule extends Base {
|
|
16
|
-
/**
|
|
17
|
-
* Initializes an Interop Broker. This is called under-the-hood for Platforms.
|
|
18
|
-
* @param { string } name - Name of the Interop Broker.
|
|
19
|
-
* @param { OverrideCallback<InteropBroker> } [override] - A callback function that can be used to extend or replace default Interop Broker behavior.
|
|
20
|
-
* @return {Promise.<InteropBroker>}
|
|
21
|
-
* @tutorial Interop.init
|
|
22
|
-
* @experimental
|
|
23
|
-
* @static
|
|
24
|
-
*/
|
|
25
|
-
init(name: string, override?: OpenFin.OverrideCallback<InteropBroker>): Promise<InteropBroker>;
|
|
26
|
-
/**
|
|
27
|
-
* Connects a client to an Interop broker. This is called under-the-hood for Views in a Platform.
|
|
28
|
-
* @param { string } name - The name of the Interop Broker to connect to. For Platforms, this will default to the uuid of the Platform.
|
|
29
|
-
* @param { InteropConfig } [interopConfig] - Information relevant to the Interop Broker. Typically a declaration of
|
|
30
|
-
* what context(s) the entity wants to subscribe to, and the current Context Group of the entity.
|
|
31
|
-
* @return {InteropClient}
|
|
32
|
-
* @tutorial Interop.connectSync
|
|
33
|
-
* @experimental
|
|
34
|
-
* @static
|
|
35
|
-
*/
|
|
36
|
-
connectSync(name: string, interopConfig: OpenFin.InteropConfig): InteropClient;
|
|
37
|
-
}
|
|
1
|
+
import { Base } from '../base';
|
|
2
|
+
import { InteropBroker } from './InteropBroker';
|
|
3
|
+
import { InteropClient } from './InteropClient';
|
|
4
|
+
/**
|
|
5
|
+
* @typedef { object } InteropConfig
|
|
6
|
+
* @summary Information relevant to the Interop Broker.
|
|
7
|
+
* @property {string} [currentContextGroup] Context Group for the client. (green, yellow, red, etc.)
|
|
8
|
+
* @property {string} [providerId] When provided, automatically connects the client to the specified provider uuid
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Manages creation of Interop Brokers and Interop Clients. These APIs are called under-the-hood in Platforms.
|
|
12
|
+
* @namespace
|
|
13
|
+
* @alias Interop
|
|
14
|
+
*/
|
|
15
|
+
export default class InteropModule extends Base {
|
|
16
|
+
/**
|
|
17
|
+
* Initializes an Interop Broker. This is called under-the-hood for Platforms.
|
|
18
|
+
* @param { string } name - Name of the Interop Broker.
|
|
19
|
+
* @param { OverrideCallback<InteropBroker> } [override] - A callback function that can be used to extend or replace default Interop Broker behavior.
|
|
20
|
+
* @return {Promise.<InteropBroker>}
|
|
21
|
+
* @tutorial Interop.init
|
|
22
|
+
* @experimental
|
|
23
|
+
* @static
|
|
24
|
+
*/
|
|
25
|
+
init(name: string, override?: OpenFin.OverrideCallback<InteropBroker>): Promise<InteropBroker>;
|
|
26
|
+
/**
|
|
27
|
+
* Connects a client to an Interop broker. This is called under-the-hood for Views in a Platform.
|
|
28
|
+
* @param { string } name - The name of the Interop Broker to connect to. For Platforms, this will default to the uuid of the Platform.
|
|
29
|
+
* @param { InteropConfig } [interopConfig] - Information relevant to the Interop Broker. Typically a declaration of
|
|
30
|
+
* what context(s) the entity wants to subscribe to, and the current Context Group of the entity.
|
|
31
|
+
* @return {InteropClient}
|
|
32
|
+
* @tutorial Interop.connectSync
|
|
33
|
+
* @experimental
|
|
34
|
+
* @static
|
|
35
|
+
*/
|
|
36
|
+
connectSync(name: string, interopConfig: OpenFin.InteropConfig): InteropClient;
|
|
37
|
+
}
|