@openfin/core 33.76.36 → 33.76.38
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 +1 -1
- package/README.md +29 -4
- package/fin.d.ts +2 -2
- package/{src → out}/GlobalOpenFin.d.ts +1 -1
- package/out/mock-alpha.d.ts +16112 -0
- package/out/mock-beta.d.ts +16112 -0
- package/out/mock-public.d.ts +16112 -0
- package/out/mock.d.ts +16797 -0
- package/out/mock.js +17104 -0
- package/package.json +30 -23
- package/LICENSE +0 -13
- package/NOTICE +0 -16
- package/openfin-core-33.76.36.tgz +0 -0
- package/src/OpenFin.d.ts +0 -3091
- package/src/OpenFin.js +0 -2
- package/src/api/api-exposer/api-consumer.d.ts +0 -28
- package/src/api/api-exposer/api-consumer.js +0 -28
- package/src/api/api-exposer/api-exposer.d.ts +0 -35
- package/src/api/api-exposer/api-exposer.js +0 -38
- package/src/api/api-exposer/decorators.d.ts +0 -10
- package/src/api/api-exposer/decorators.js +0 -18
- package/src/api/api-exposer/index.d.ts +0 -4
- package/src/api/api-exposer/index.js +0 -20
- package/src/api/api-exposer/strategies/index.d.ts +0 -1
- package/src/api/api-exposer/strategies/index.js +0 -17
- package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.d.ts +0 -14
- package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.js +0 -20
- package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.d.ts +0 -20
- package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.js +0 -23
- package/src/api/api-exposer/strategies/openfin-channels/index.d.ts +0 -2
- package/src/api/api-exposer/strategies/openfin-channels/index.js +0 -18
- package/src/api/application/Factory.d.ts +0 -196
- package/src/api/application/Factory.js +0 -278
- package/src/api/application/Instance.d.ts +0 -692
- package/src/api/application/Instance.js +0 -821
- package/src/api/application/index.d.ts +0 -12
- package/src/api/application/index.js +0 -28
- package/src/api/base.d.ts +0 -117
- package/src/api/base.js +0 -246
- package/src/api/clipboard/index.d.ts +0 -172
- package/src/api/clipboard/index.js +0 -200
- package/src/api/events/application.d.ts +0 -158
- package/src/api/events/application.js +0 -14
- package/src/api/events/base.d.ts +0 -42
- package/src/api/events/base.js +0 -2
- package/src/api/events/channel.d.ts +0 -35
- package/src/api/events/channel.js +0 -7
- package/src/api/events/emitterMap.d.ts +0 -11
- package/src/api/events/emitterMap.js +0 -35
- package/src/api/events/eventAggregator.d.ts +0 -5
- package/src/api/events/eventAggregator.js +0 -35
- package/src/api/events/externalApplication.d.ts +0 -24
- package/src/api/events/externalApplication.js +0 -7
- package/src/api/events/frame.d.ts +0 -35
- package/src/api/events/frame.js +0 -2
- package/src/api/events/globalHotkey.d.ts +0 -25
- package/src/api/events/globalHotkey.js +0 -2
- package/src/api/events/platform.d.ts +0 -34
- package/src/api/events/platform.js +0 -10
- package/src/api/events/system.d.ts +0 -126
- package/src/api/events/system.js +0 -15
- package/src/api/events/typedEventEmitter.d.ts +0 -20
- package/src/api/events/typedEventEmitter.js +0 -2
- package/src/api/events/view.d.ts +0 -92
- package/src/api/events/view.js +0 -12
- package/src/api/events/webcontents.d.ts +0 -277
- package/src/api/events/webcontents.js +0 -13
- package/src/api/events/window.d.ts +0 -421
- package/src/api/events/window.js +0 -12
- package/src/api/external-application/Factory.d.ts +0 -34
- package/src/api/external-application/Factory.js +0 -47
- package/src/api/external-application/Instance.d.ts +0 -110
- package/src/api/external-application/Instance.js +0 -117
- package/src/api/external-application/index.d.ts +0 -12
- package/src/api/external-application/index.js +0 -28
- package/src/api/fin.d.ts +0 -54
- package/src/api/fin.js +0 -45
- package/src/api/frame/Factory.d.ts +0 -54
- package/src/api/frame/Factory.js +0 -86
- package/src/api/frame/Instance.d.ts +0 -136
- package/src/api/frame/Instance.js +0 -143
- package/src/api/frame/index.d.ts +0 -14
- package/src/api/frame/index.js +0 -30
- package/src/api/global-hotkey/index.d.ts +0 -106
- package/src/api/global-hotkey/index.js +0 -132
- package/src/api/interappbus/channel/channel.d.ts +0 -285
- package/src/api/interappbus/channel/channel.js +0 -334
- package/src/api/interappbus/channel/channels-docs.d.ts +0 -342
- package/src/api/interappbus/channel/channels-docs.js +0 -401
- package/src/api/interappbus/channel/client.d.ts +0 -117
- package/src/api/interappbus/channel/client.js +0 -181
- package/src/api/interappbus/channel/connection-manager.d.ts +0 -29
- package/src/api/interappbus/channel/connection-manager.js +0 -246
- package/src/api/interappbus/channel/index.d.ts +0 -189
- package/src/api/interappbus/channel/index.js +0 -333
- package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +0 -13
- package/src/api/interappbus/channel/protocols/classic/message-receiver.js +0 -73
- package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +0 -24
- package/src/api/interappbus/channel/protocols/classic/strategy.js +0 -101
- package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +0 -20
- package/src/api/interappbus/channel/protocols/combined/strategy.js +0 -58
- package/src/api/interappbus/channel/protocols/index.d.ts +0 -47
- package/src/api/interappbus/channel/protocols/index.js +0 -2
- package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +0 -10
- package/src/api/interappbus/channel/protocols/protocol-manager.js +0 -43
- package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +0 -25
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +0 -141
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +0 -30
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +0 -130
- package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +0 -24
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +0 -85
- package/src/api/interappbus/channel/protocols/strategy-types.d.ts +0 -13
- package/src/api/interappbus/channel/protocols/strategy-types.js +0 -2
- package/src/api/interappbus/channel/protocols/strategy.d.ts +0 -17
- package/src/api/interappbus/channel/protocols/strategy.js +0 -2
- package/src/api/interappbus/channel/provider.d.ts +0 -206
- package/src/api/interappbus/channel/provider.js +0 -338
- package/src/api/interappbus/index.d.ts +0 -120
- package/src/api/interappbus/index.js +0 -210
- package/src/api/interop/Factory.d.ts +0 -57
- package/src/api/interop/Factory.js +0 -96
- package/src/api/interop/InteropBroker.d.ts +0 -665
- package/src/api/interop/InteropBroker.js +0 -1313
- package/src/api/interop/InteropClient.d.ts +0 -502
- package/src/api/interop/InteropClient.js +0 -683
- package/src/api/interop/SessionContextGroupBroker.d.ts +0 -27
- package/src/api/interop/SessionContextGroupBroker.js +0 -108
- package/src/api/interop/SessionContextGroupClient.d.ts +0 -21
- package/src/api/interop/SessionContextGroupClient.js +0 -86
- package/src/api/interop/fdc3/PrivateChannelClient.d.ts +0 -20
- package/src/api/interop/fdc3/PrivateChannelClient.js +0 -90
- package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +0 -55
- package/src/api/interop/fdc3/PrivateChannelProvider.js +0 -276
- package/src/api/interop/fdc3/documentationStub.d.ts +0 -14
- package/src/api/interop/fdc3/documentationStub.js +0 -17
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +0 -205
- package/src/api/interop/fdc3/fdc3-1.2.js +0 -435
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +0 -298
- package/src/api/interop/fdc3/fdc3-2.0.js +0 -479
- package/src/api/interop/fdc3/fdc3.d.ts +0 -12
- package/src/api/interop/fdc3/fdc3.js +0 -35
- package/src/api/interop/fdc3/overrideCheck.d.ts +0 -4
- package/src/api/interop/fdc3/overrideCheck.js +0 -32
- package/src/api/interop/fdc3/shapes/fdc3v1.d.ts +0 -53
- package/src/api/interop/fdc3/shapes/fdc3v1.js +0 -4
- package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +0 -75
- package/src/api/interop/fdc3/shapes/fdc3v2.js +0 -2
- package/src/api/interop/fdc3/utils.d.ts +0 -45
- package/src/api/interop/fdc3/utils.js +0 -239
- package/src/api/interop/fdc3/versions.d.ts +0 -1
- package/src/api/interop/fdc3/versions.js +0 -2
- package/src/api/interop/index.d.ts +0 -12
- package/src/api/interop/index.js +0 -28
- package/src/api/interop/utils.d.ts +0 -18
- package/src/api/interop/utils.js +0 -61
- package/src/api/me.d.ts +0 -40
- package/src/api/me.js +0 -134
- package/src/api/platform/Factory.d.ts +0 -171
- package/src/api/platform/Factory.js +0 -240
- package/src/api/platform/Instance.d.ts +0 -653
- package/src/api/platform/Instance.js +0 -834
- package/src/api/platform/common-utils.d.ts +0 -7
- package/src/api/platform/common-utils.js +0 -16
- package/src/api/platform/index.d.ts +0 -12
- package/src/api/platform/index.js +0 -28
- package/src/api/platform/layout/Factory.d.ts +0 -91
- package/src/api/platform/layout/Factory.js +0 -151
- package/src/api/platform/layout/Instance.d.ts +0 -192
- package/src/api/platform/layout/Instance.js +0 -224
- package/src/api/platform/layout/controllers/layout-content-cache.d.ts +0 -9
- package/src/api/platform/layout/controllers/layout-content-cache.js +0 -54
- package/src/api/platform/layout/controllers/layout-entities-controller.d.ts +0 -119
- package/src/api/platform/layout/controllers/layout-entities-controller.js +0 -287
- package/src/api/platform/layout/entities/layout-entities.d.ts +0 -427
- package/src/api/platform/layout/entities/layout-entities.js +0 -504
- package/src/api/platform/layout/entities/shapes.d.ts +0 -6
- package/src/api/platform/layout/entities/shapes.js +0 -2
- package/src/api/platform/layout/index.d.ts +0 -11
- package/src/api/platform/layout/index.js +0 -27
- package/src/api/platform/layout/layout.constants.d.ts +0 -1
- package/src/api/platform/layout/layout.constants.js +0 -4
- package/src/api/platform/layout/shapes.d.ts +0 -16
- package/src/api/platform/layout/shapes.js +0 -2
- package/src/api/platform/layout/utils/layout-traversal.d.ts +0 -4
- package/src/api/platform/layout/utils/layout-traversal.js +0 -65
- package/src/api/platform/provider.d.ts +0 -510
- package/src/api/platform/provider.js +0 -2
- package/src/api/snapshot-source/Factory.d.ts +0 -53
- package/src/api/snapshot-source/Factory.js +0 -81
- package/src/api/snapshot-source/Instance.d.ts +0 -53
- package/src/api/snapshot-source/Instance.js +0 -154
- package/src/api/snapshot-source/index.d.ts +0 -12
- package/src/api/snapshot-source/index.js +0 -28
- package/src/api/snapshot-source/utils.d.ts +0 -2
- package/src/api/snapshot-source/utils.js +0 -6
- package/src/api/system/index.d.ts +0 -1468
- package/src/api/system/index.js +0 -1851
- package/src/api/view/Factory.d.ts +0 -88
- package/src/api/view/Factory.js +0 -141
- package/src/api/view/Instance.d.ts +0 -601
- package/src/api/view/Instance.js +0 -671
- package/src/api/view/index.d.ts +0 -12
- package/src/api/view/index.js +0 -28
- package/src/api/webcontents/main.d.ts +0 -922
- package/src/api/webcontents/main.js +0 -1046
- package/src/api/window/Factory.d.ts +0 -96
- package/src/api/window/Factory.js +0 -142
- package/src/api/window/Instance.d.ts +0 -1598
- package/src/api/window/Instance.js +0 -1851
- package/src/api/window/index.d.ts +0 -14
- package/src/api/window/index.js +0 -30
- package/src/browser.d.ts +0 -10
- package/src/browser.js +0 -36
- package/src/environment/browser.d.ts +0 -29
- package/src/environment/browser.js +0 -60
- package/src/environment/environment.d.ts +0 -33
- package/src/environment/environment.js +0 -4
- package/src/environment/mockEnvironment.d.ts +0 -27
- package/src/environment/mockEnvironment.js +0 -61
- package/src/environment/node-env.d.ts +0 -29
- package/src/environment/node-env.js +0 -72
- package/src/fdc3.d.ts +0 -3
- package/src/fdc3.js +0 -9
- package/src/mock.d.ts +0 -3
- package/src/mock.js +0 -18
- package/src/namespaces.d.ts +0 -22
- package/src/namespaces.js +0 -26
- package/src/shapes/ERROR_BOX_TYPES.d.ts +0 -1
- package/src/shapes/ERROR_BOX_TYPES.js +0 -2
- package/src/shapes/WebOptions.d.ts +0 -13
- package/src/shapes/WebOptions.js +0 -2
- package/src/shapes/WindowOptions.d.ts +0 -43
- package/src/shapes/WindowOptions.js +0 -2
- package/src/shapes/protocol.d.ts +0 -204
- package/src/shapes/protocol.js +0 -2
- package/src/transport/mockWire.d.ts +0 -11
- package/src/transport/mockWire.js +0 -26
- package/src/transport/transport-errors.d.ts +0 -31
- package/src/transport/transport-errors.js +0 -79
- package/src/transport/transport.d.ts +0 -73
- package/src/transport/transport.js +0 -219
- package/src/transport/wire.d.ts +0 -77
- package/src/transport/wire.js +0 -36
- package/src/util/asyncFilter.d.ts +0 -1
- package/src/util/asyncFilter.js +0 -7
- package/src/util/channel-api-relay.d.ts +0 -13
- package/src/util/channel-api-relay.js +0 -47
- package/src/util/errors.d.ts +0 -10
- package/src/util/errors.js +0 -12
- package/src/util/exhaustive.d.ts +0 -1
- package/src/util/exhaustive.js +0 -7
- package/src/util/http.d.ts +0 -11
- package/src/util/http.js +0 -90
- package/src/util/inaccessibleObject.d.ts +0 -2
- package/src/util/inaccessibleObject.js +0 -49
- package/src/util/lazy.d.ts +0 -34
- package/src/util/lazy.js +0 -54
- package/src/util/normalize-config.d.ts +0 -3
- package/src/util/normalize-config.js +0 -52
- package/src/util/promises.d.ts +0 -5
- package/src/util/promises.js +0 -27
- package/src/util/ref-counter.d.ts +0 -7
- package/src/util/ref-counter.js +0 -52
- package/src/util/reversible-map.d.ts +0 -11
- package/src/util/reversible-map.js +0 -49
- package/src/util/runtimeVersioning.d.ts +0 -3
- package/src/util/runtimeVersioning.js +0 -25
- package/src/util/utilTypes.d.ts +0 -8
- package/src/util/utilTypes.js +0 -2
- package/src/util/validate.d.ts +0 -3
- package/src/util/validate.js +0 -11
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import type * as OpenFin from '../../../OpenFin';
|
|
2
|
-
import { ChannelBase } from './channel';
|
|
3
|
-
import { Transport } from '../../../transport/transport';
|
|
4
|
-
import { AnyStrategy } from './protocols/strategy-types';
|
|
5
|
-
type ProviderIdentity = OpenFin.ProviderIdentity;
|
|
6
|
-
type ClientIdentity = OpenFin.ClientIdentity;
|
|
7
|
-
export type ConnectionListener = (identity: ClientIdentity, connectionMessage?: any) => Promise<any> | any;
|
|
8
|
-
export type DisconnectionListener = (identity: ClientIdentity) => any;
|
|
9
|
-
/**
|
|
10
|
-
* Instance created to enable use of a channel as a provider. Allows for communication with the {@link ChannelClient ChannelClients} by invoking an action on
|
|
11
|
-
* a single client via {@link ChannelProvider#dispatch dispatch} or all clients via {@link ChannelProvider#publish publish}
|
|
12
|
-
* and to listen for communication from clients by registering an action via {@link ChannelProvider#register register}.
|
|
13
|
-
*
|
|
14
|
-
* Synchronous Methods:
|
|
15
|
-
* * {@link ChannelProvider#onConnection onConnection(listener)}
|
|
16
|
-
* * {@link ChannelProvider#onDisconnection onDisconnection(listener)}
|
|
17
|
-
* * {@link ChannelProvider#publish publish(action, payload)}
|
|
18
|
-
* * {@link ChannelProvider#register register(action, listener)}
|
|
19
|
-
* * {@link ChannelProvider#remove remove(action)}
|
|
20
|
-
*
|
|
21
|
-
* Asynchronous Methods:
|
|
22
|
-
* * {@link ChannelProvider#destroy destroy()}
|
|
23
|
-
* * {@link ChannelProvider#dispatch dispatch(to, action, payload)}
|
|
24
|
-
* * {@link ChannelProvider#getAllClientInfo getAllClientInfo()}
|
|
25
|
-
*
|
|
26
|
-
* Middleware:
|
|
27
|
-
* <br>Middleware functions receive the following arguments: (action, payload, senderId).
|
|
28
|
-
* The return value of the middleware function will be passed on as the payload from beforeAction, to the action listener, to afterAction
|
|
29
|
-
* unless it is undefined, in which case the most recently defined payload is used. Middleware can be used for side effects.
|
|
30
|
-
* * {@link ChannelProvider#setDefaultAction setDefaultAction(middleware)}
|
|
31
|
-
* * {@link ChannelProvider#onError onError(middleware)}
|
|
32
|
-
* * {@link ChannelProvider#beforeAction beforeAction(middleware)}
|
|
33
|
-
* * {@link ChannelProvider#afterAction afterAction(middleware)}
|
|
34
|
-
*/
|
|
35
|
-
export declare class ChannelProvider extends ChannelBase {
|
|
36
|
-
#private;
|
|
37
|
-
private static removalMap;
|
|
38
|
-
private connectListener;
|
|
39
|
-
private disconnectListener;
|
|
40
|
-
/**
|
|
41
|
-
* a read-only array containing all the identities of connecting clients.
|
|
42
|
-
*/
|
|
43
|
-
get connections(): OpenFin.ClientConnectionPayload[];
|
|
44
|
-
static handleClientDisconnection(channel: ChannelProvider, payload: any): void;
|
|
45
|
-
static setProviderRemoval(provider: ChannelProvider, remove: Function): void;
|
|
46
|
-
/**
|
|
47
|
-
* @internal
|
|
48
|
-
*/
|
|
49
|
-
constructor(providerIdentity: ProviderIdentity, wire: Transport, strategy: AnyStrategy);
|
|
50
|
-
/**
|
|
51
|
-
* Dispatch an action to a specified client. Returns a promise for the result of executing that action on the client side.
|
|
52
|
-
*
|
|
53
|
-
* @param to - Identity of the target client.
|
|
54
|
-
* @param action - Name of the action to be invoked by the client.
|
|
55
|
-
* @param payload - Payload to be sent along with the action.
|
|
56
|
-
*
|
|
57
|
-
* @remarks
|
|
58
|
-
*
|
|
59
|
-
* Because multiple clients can share the same `name` and `uuid`, when dispatching from a provider to a client,
|
|
60
|
-
* the `identity` you provide must include the client's unique `endpointId` property. This `endpointId` is
|
|
61
|
-
* passed to the provider in both the `Provider.onConnection` callback and in any registered action callbacks.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
*
|
|
65
|
-
* ```js
|
|
66
|
-
* (async ()=> {
|
|
67
|
-
* const provider = await fin.InterApplicationBus.Channel.create('channelName');
|
|
68
|
-
*
|
|
69
|
-
* await provider.register('provider-action', async (payload, identity) => {
|
|
70
|
-
* console.log(payload, identity);
|
|
71
|
-
* return await provider.dispatch(identity, 'client-action', 'Hello, World!');
|
|
72
|
-
* });
|
|
73
|
-
* })();
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
dispatch(to: OpenFin.ClientIdentity | OpenFin.Identity, action: string, payload?: any): Promise<any>;
|
|
77
|
-
protected processAction: (action: string, payload: any, senderIdentity: OpenFin.ClientIdentity | OpenFin.ClientIdentityMultiRuntime) => Promise<any>;
|
|
78
|
-
processConnection(senderId: OpenFin.ClientConnectionPayload, payload: any): Promise<any>;
|
|
79
|
-
/**
|
|
80
|
-
* Publish an action and payload to every connected client.
|
|
81
|
-
* Synchronously returns an array of promises for each action (see dispatch).
|
|
82
|
-
*
|
|
83
|
-
* @param action
|
|
84
|
-
* @param payload
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```js
|
|
88
|
-
* (async ()=> {
|
|
89
|
-
* const provider = await fin.InterApplicationBus.Channel.create('channelName');
|
|
90
|
-
*
|
|
91
|
-
* await provider.register('provider-action', async (payload, identity) => {
|
|
92
|
-
* console.log(payload, identity);
|
|
93
|
-
* return await Promise.all(provider.publish('client-action', { message: 'Broadcast from provider'}));
|
|
94
|
-
* });
|
|
95
|
-
* })();
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
publish(action: string, payload: any): Promise<any>[];
|
|
99
|
-
/**
|
|
100
|
-
* Register a listener that is called on every new client connection.
|
|
101
|
-
*
|
|
102
|
-
* @remarks It is passed the identity of the connecting client and a payload if it was provided to Channel.connect.
|
|
103
|
-
* If you wish to reject the connection, throw an error. Be sure to synchronously provide an onConnection upon receipt of
|
|
104
|
-
* the channelProvider to ensure all potential client connections are caught by the listener.
|
|
105
|
-
*
|
|
106
|
-
* Because multiple clients can exist at the same `name` and `uuid`, in order to distinguish between individual clients,
|
|
107
|
-
* the `identity` argument in a provider's `onConnection` callback contains an `endpointId` property. When dispatching from a
|
|
108
|
-
* provider to a client, the `endpointId` property must be provided in order to send an action to a specific client.
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```js
|
|
112
|
-
* (async ()=> {
|
|
113
|
-
* const provider = await fin.InterApplicationBus.Channel.create('channelName');
|
|
114
|
-
*
|
|
115
|
-
* provider.onConnection(identity => {
|
|
116
|
-
* console.log('Client connected', identity);
|
|
117
|
-
* });
|
|
118
|
-
* })();
|
|
119
|
-
* ```
|
|
120
|
-
*
|
|
121
|
-
* Reject connection:
|
|
122
|
-
* ```js
|
|
123
|
-
* (async ()=> {
|
|
124
|
-
* const provider = await fin.InterApplicationBus.Channel.create('channelName');
|
|
125
|
-
*
|
|
126
|
-
* provider.onConnection(identity => {
|
|
127
|
-
* throw new Error('Connection Rejected');
|
|
128
|
-
* });
|
|
129
|
-
* })();
|
|
130
|
-
* ```
|
|
131
|
-
* @param listener
|
|
132
|
-
*/
|
|
133
|
-
onConnection(listener: ConnectionListener): void;
|
|
134
|
-
/**
|
|
135
|
-
* Register a listener that is called on client disconnection. It is passed the disconnection event of the disconnecting
|
|
136
|
-
* client.
|
|
137
|
-
*
|
|
138
|
-
* @param listener
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
*
|
|
142
|
-
* ```js
|
|
143
|
-
* (async ()=> {
|
|
144
|
-
* const provider = await fin.InterApplicationBus.Channel.create('channelName');
|
|
145
|
-
*
|
|
146
|
-
* await provider.onDisconnection(evt => {
|
|
147
|
-
* console.log('Client disconnected', `uuid: ${evt.uuid}, name: ${evt.name}`);
|
|
148
|
-
* });
|
|
149
|
-
* })();
|
|
150
|
-
* ```
|
|
151
|
-
*/
|
|
152
|
-
onDisconnection(listener: DisconnectionListener): void;
|
|
153
|
-
/**
|
|
154
|
-
* Destroy the channel, raises `disconnected` events on all connected channel clients.
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
*
|
|
158
|
-
* ```js
|
|
159
|
-
* (async ()=> {
|
|
160
|
-
* const provider = await fin.InterApplicationBus.Channel.create('channelName');
|
|
161
|
-
*
|
|
162
|
-
* await provider.destroy();
|
|
163
|
-
* })();
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
|
-
destroy(): Promise<void>;
|
|
167
|
-
/**
|
|
168
|
-
* Returns an array with info on every Client connected to the Provider
|
|
169
|
-
*
|
|
170
|
-
* @example
|
|
171
|
-
*
|
|
172
|
-
* ```js
|
|
173
|
-
* const provider = await fin.InterApplicationBus.Channel.create('openfin');
|
|
174
|
-
* const client = await fin.InterApplicationBus.Channel.connect('openfin');
|
|
175
|
-
* const clientInfo = await provider.getAllClientInfo();
|
|
176
|
-
*
|
|
177
|
-
* console.log(clientInfo);
|
|
178
|
-
*
|
|
179
|
-
* // [
|
|
180
|
-
* // {
|
|
181
|
-
* // "uuid": "openfin",
|
|
182
|
-
* // "name": "openfin-view",
|
|
183
|
-
* // "endpointId": "6d4c7ca8-4a74-4634-87f8-760558229613",
|
|
184
|
-
* // "entityType": "view",
|
|
185
|
-
* // "url": "https://openfin.co"
|
|
186
|
-
* // },
|
|
187
|
-
* // {
|
|
188
|
-
* // "uuid": "openfin2",
|
|
189
|
-
* // "name": "openfin-view2",
|
|
190
|
-
* // "endpointId": "4z5d8ab9-2b81-3691-91ex-142179382511",
|
|
191
|
-
* // "entityType": "view",
|
|
192
|
-
* // "url": "https://example.com"
|
|
193
|
-
* // }
|
|
194
|
-
* //]
|
|
195
|
-
* ```
|
|
196
|
-
*/
|
|
197
|
-
getAllClientInfo(): Promise<Array<OpenFin.ClientInfo>>;
|
|
198
|
-
private checkForClientConnection;
|
|
199
|
-
private isClientConnected;
|
|
200
|
-
private isLegacyClientConnected;
|
|
201
|
-
private handleMultiRuntimeLegacyClient;
|
|
202
|
-
private getEndpointIdForOpenFinId;
|
|
203
|
-
private static clientIdentityIncludesEndpointId;
|
|
204
|
-
private static clientIsMultiRuntime;
|
|
205
|
-
}
|
|
206
|
-
export {};
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
-
};
|
|
13
|
-
var _ChannelProvider_connections, _ChannelProvider_protectedObj, _ChannelProvider_strategy, _ChannelProvider_removeEndpoint, _ChannelProvider_close;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.ChannelProvider = void 0;
|
|
16
|
-
const channel_1 = require("./channel");
|
|
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
|
-
*/
|
|
44
|
-
class ChannelProvider extends channel_1.ChannelBase {
|
|
45
|
-
/**
|
|
46
|
-
* a read-only array containing all the identities of connecting clients.
|
|
47
|
-
*/
|
|
48
|
-
get connections() {
|
|
49
|
-
return [...__classPrivateFieldGet(this, _ChannelProvider_connections, "f")];
|
|
50
|
-
}
|
|
51
|
-
static handleClientDisconnection(channel, payload) {
|
|
52
|
-
const removeById = channel.connections.find((identity) => identity.endpointId === payload.endpointId);
|
|
53
|
-
if (removeById) {
|
|
54
|
-
__classPrivateFieldGet(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
const multipleRemoves = channel.connections.filter((identity) => {
|
|
58
|
-
return identity.uuid === payload.uuid && identity.name === payload.name;
|
|
59
|
-
});
|
|
60
|
-
multipleRemoves.forEach(__classPrivateFieldGet(channel, _ChannelProvider_removeEndpoint, "f"));
|
|
61
|
-
}
|
|
62
|
-
channel.disconnectListener(payload);
|
|
63
|
-
}
|
|
64
|
-
static setProviderRemoval(provider, remove) {
|
|
65
|
-
ChannelProvider.removalMap.set(provider, remove);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* @internal
|
|
69
|
-
*/
|
|
70
|
-
constructor(providerIdentity, wire, strategy) {
|
|
71
|
-
super();
|
|
72
|
-
_ChannelProvider_connections.set(this, void 0);
|
|
73
|
-
_ChannelProvider_protectedObj.set(this, void 0);
|
|
74
|
-
_ChannelProvider_strategy.set(this, void 0);
|
|
75
|
-
_ChannelProvider_removeEndpoint.set(this, (identity) => {
|
|
76
|
-
const remainingConnections = this.connections.filter((clientIdentity) => clientIdentity.endpointId !== identity.endpointId);
|
|
77
|
-
__classPrivateFieldGet(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
|
|
78
|
-
__classPrivateFieldSet(this, _ChannelProvider_connections, remainingConnections, "f");
|
|
79
|
-
});
|
|
80
|
-
// Must be bound.
|
|
81
|
-
this.processAction = async (action, payload, senderIdentity) => {
|
|
82
|
-
if (ChannelProvider.clientIsMultiRuntime(senderIdentity) &&
|
|
83
|
-
!(0, runtimeVersioning_1.runtimeUuidMeetsMinimumRuntimeVersion)(senderIdentity.runtimeUuid, '18.87.56.0')) {
|
|
84
|
-
this.handleMultiRuntimeLegacyClient(senderIdentity);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
this.checkForClientConnection(senderIdentity);
|
|
88
|
-
}
|
|
89
|
-
return super.processAction(action, payload, senderIdentity);
|
|
90
|
-
};
|
|
91
|
-
_ChannelProvider_close.set(this, () => {
|
|
92
|
-
__classPrivateFieldGet(this, _ChannelProvider_strategy, "f").close();
|
|
93
|
-
const remove = ChannelProvider.removalMap.get(this);
|
|
94
|
-
if (remove) {
|
|
95
|
-
remove();
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
__classPrivateFieldSet(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, wire), "f");
|
|
99
|
-
this.connectListener = () => undefined;
|
|
100
|
-
this.disconnectListener = () => undefined;
|
|
101
|
-
__classPrivateFieldSet(this, _ChannelProvider_connections, [], "f");
|
|
102
|
-
__classPrivateFieldSet(this, _ChannelProvider_strategy, strategy, "f");
|
|
103
|
-
strategy.receive(this.processAction);
|
|
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
|
-
*/
|
|
131
|
-
dispatch(to, action, payload) {
|
|
132
|
-
var _a;
|
|
133
|
-
const endpointId = (_a = to.endpointId) !== null && _a !== void 0 ? _a : this.getEndpointIdForOpenFinId(to, action);
|
|
134
|
-
if (endpointId && __classPrivateFieldGet(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
|
|
135
|
-
return __classPrivateFieldGet(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload);
|
|
136
|
-
}
|
|
137
|
-
return Promise.reject(new Error(`Client connection with identity uuid: ${to.uuid} / name: ${to.name} / endpointId: ${endpointId} no longer connected.`));
|
|
138
|
-
}
|
|
139
|
-
async processConnection(senderId, payload) {
|
|
140
|
-
__classPrivateFieldGet(this, _ChannelProvider_connections, "f").push(senderId);
|
|
141
|
-
return this.connectListener(senderId, payload);
|
|
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
|
-
*/
|
|
162
|
-
publish(action, payload) {
|
|
163
|
-
return this.connections.map((to) => __classPrivateFieldGet(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
|
|
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
|
-
*/
|
|
199
|
-
onConnection(listener) {
|
|
200
|
-
this.connectListener = listener;
|
|
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
|
-
*/
|
|
220
|
-
onDisconnection(listener) {
|
|
221
|
-
this.disconnectListener = listener;
|
|
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
|
-
*/
|
|
236
|
-
async destroy() {
|
|
237
|
-
const protectedObj = __classPrivateFieldGet(this, _ChannelProvider_protectedObj, "f");
|
|
238
|
-
const { channelName } = protectedObj.providerIdentity;
|
|
239
|
-
__classPrivateFieldSet(this, _ChannelProvider_connections, [], "f");
|
|
240
|
-
await protectedObj.wire.sendAction('destroy-channel', { channelName });
|
|
241
|
-
__classPrivateFieldGet(this, _ChannelProvider_close, "f").call(this);
|
|
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
|
-
*/
|
|
273
|
-
async getAllClientInfo() {
|
|
274
|
-
return this.connections.map((clientInfo) => {
|
|
275
|
-
const { uuid, name, endpointId, entityType, connectionUrl } = clientInfo;
|
|
276
|
-
return { uuid, name, endpointId, entityType, connectionUrl };
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
checkForClientConnection(clientIdentity) {
|
|
280
|
-
if (!this.isClientConnected(clientIdentity)) {
|
|
281
|
-
throw new Error(`This action was sent from a client that is not connected to the provider.
|
|
282
|
-
Client Identity: {uuid: ${clientIdentity.uuid}, name: ${clientIdentity.name}, endpointId: ${clientIdentity.endpointId}}`);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
isClientConnected(clientIdentity) {
|
|
286
|
-
if (ChannelProvider.clientIdentityIncludesEndpointId(clientIdentity)) {
|
|
287
|
-
return this.connections.some((identity) => {
|
|
288
|
-
return (
|
|
289
|
-
// Might be redundant to check for uuid and name here after we get an endpointId match, but just in case
|
|
290
|
-
identity.endpointId === clientIdentity.endpointId &&
|
|
291
|
-
identity.uuid === clientIdentity.uuid &&
|
|
292
|
-
identity.name === clientIdentity.name);
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
return this.isLegacyClientConnected(clientIdentity);
|
|
296
|
-
}
|
|
297
|
-
isLegacyClientConnected(clientIdentity) {
|
|
298
|
-
return this.connections.some((identity) => {
|
|
299
|
-
return identity.uuid === clientIdentity.uuid && identity.name === clientIdentity.name;
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
handleMultiRuntimeLegacyClient(senderIdentity) {
|
|
303
|
-
if (!this.isLegacyClientConnected(senderIdentity)) {
|
|
304
|
-
throw new Error(`This action was sent from a client that is not connected to the provider. Client Identity:
|
|
305
|
-
{uuid: ${senderIdentity.uuid}, name: ${senderIdentity.name}, endpointId: ${senderIdentity.endpointId}}`);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
getEndpointIdForOpenFinId(clientIdentity, action) {
|
|
309
|
-
var _a;
|
|
310
|
-
const matchingConnections = this.connections.filter((c) => c.name === clientIdentity.name && c.uuid === clientIdentity.uuid);
|
|
311
|
-
if (matchingConnections.length >= 2) {
|
|
312
|
-
const protectedObj = __classPrivateFieldGet(this, _ChannelProvider_protectedObj, "f");
|
|
313
|
-
const { uuid, name } = clientIdentity;
|
|
314
|
-
const providerUuid = protectedObj === null || protectedObj === void 0 ? void 0 : protectedObj.providerIdentity.uuid;
|
|
315
|
-
const providerName = protectedObj === null || protectedObj === void 0 ? void 0 : protectedObj.providerIdentity.name;
|
|
316
|
-
// eslint-disable-next-line no-console
|
|
317
|
-
console.warn(`WARNING: Dispatch call may have unintended results. The "to" argument of your dispatch call is missing the
|
|
318
|
-
"endpointId" parameter. The identity you are dispatching to ({uuid: ${uuid}, name: ${name}})
|
|
319
|
-
has multiple channelClients for this channel. Your dispatched action: (${action}) from the provider:
|
|
320
|
-
({uuid: ${providerUuid}, name: ${providerName}}) will only be processed by the most recently-created client.`);
|
|
321
|
-
}
|
|
322
|
-
// Pop to return the most recently created endpointId.
|
|
323
|
-
return (_a = matchingConnections.pop()) === null || _a === void 0 ? void 0 : _a.endpointId;
|
|
324
|
-
}
|
|
325
|
-
// eslint-disable-next-line class-methods-use-this
|
|
326
|
-
static clientIdentityIncludesEndpointId(subscriptionIdentity) {
|
|
327
|
-
return subscriptionIdentity.endpointId !== undefined;
|
|
328
|
-
}
|
|
329
|
-
// eslint-disable-next-line class-methods-use-this
|
|
330
|
-
static clientIsMultiRuntime(subscriptionIdentity) {
|
|
331
|
-
return subscriptionIdentity.runtimeUuid !== undefined;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
exports.ChannelProvider = ChannelProvider;
|
|
335
|
-
_ChannelProvider_connections = new WeakMap(), _ChannelProvider_protectedObj = new WeakMap(), _ChannelProvider_strategy = new WeakMap(), _ChannelProvider_removeEndpoint = new WeakMap(), _ChannelProvider_close = new WeakMap();
|
|
336
|
-
// The following line should be changed following a typescript update.
|
|
337
|
-
// static #removalMap = new WeakMap<ChannelProvider, Function>();
|
|
338
|
-
ChannelProvider.removalMap = new WeakMap();
|
|
@@ -1,120 +0,0 @@
|
|
|
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
|
-
*
|
|
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
|
-
/**
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
constructor(wire: Transport);
|
|
24
|
-
/**
|
|
25
|
-
* Publishes a message to all applications running on OpenFin Runtime that
|
|
26
|
-
* are subscribed to the specified topic.
|
|
27
|
-
* @param topic The topic on which the message is sent
|
|
28
|
-
* @param message The message to be published. Can be either a primitive
|
|
29
|
-
* data type (string, number, or boolean) or composite data type (object, array)
|
|
30
|
-
* that is composed of other primitive or composite data types
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```js
|
|
34
|
-
* fin.InterApplicationBus.publish('topic', 'hello').then(() => console.log('Published')).catch(err => console.log(err));
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
publish(topic: string, message: any): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Sends a message to a specific application on a specific topic.
|
|
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
|
|
43
|
-
* type (string, number, or boolean) or composite data type (object, array) that
|
|
44
|
-
* is composed of other primitive or composite data types
|
|
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
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
send(destination: {
|
|
52
|
-
uuid: string;
|
|
53
|
-
name?: string;
|
|
54
|
-
}, topic: string, message: any): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Subscribes to messages from the specified application on the specified topic.
|
|
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
|
|
60
|
-
* been received. It is passed the message, uuid and name of the sending application.
|
|
61
|
-
* The message can be either a primitive data type (string, number, or boolean) or
|
|
62
|
-
* composite data type (object, array) that is composed of other primitive or composite
|
|
63
|
-
* data types
|
|
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
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
subscribe(source: {
|
|
75
|
-
uuid: string;
|
|
76
|
-
name?: string;
|
|
77
|
-
}, topic: string, listener: any): Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* Unsubscribes to messages from the specified application on the specified topic.
|
|
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
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
unsubscribe(source: {
|
|
103
|
-
uuid: string;
|
|
104
|
-
name?: string;
|
|
105
|
-
}, topic: string, listener: any): Promise<void>;
|
|
106
|
-
private processMessage;
|
|
107
|
-
private emitSubscriverEvent;
|
|
108
|
-
protected createSubscriptionKey(uuid: string, name: string, topic: string): string;
|
|
109
|
-
protected onmessage(message: Message<InterAppPayload>): boolean;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* @internal
|
|
113
|
-
*/
|
|
114
|
-
export declare class InterAppPayload {
|
|
115
|
-
sourceUuid: string;
|
|
116
|
-
sourceWindowName: string;
|
|
117
|
-
topic: string;
|
|
118
|
-
destinationUuid?: string;
|
|
119
|
-
message?: any;
|
|
120
|
-
}
|