@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.
Files changed (116) hide show
  1. package/openfin-core-33.76.36.tgz +0 -0
  2. package/package.json +1 -1
  3. package/src/OpenFin.d.ts +27 -16
  4. package/src/api/application/Factory.d.ts +148 -100
  5. package/src/api/application/Factory.js +148 -100
  6. package/src/api/application/Instance.d.ts +477 -106
  7. package/src/api/application/Instance.js +474 -106
  8. package/src/api/application/index.d.ts +9 -0
  9. package/src/api/application/index.js +9 -0
  10. package/src/api/base.d.ts +69 -0
  11. package/src/api/base.js +69 -0
  12. package/src/api/clipboard/index.d.ts +111 -31
  13. package/src/api/clipboard/index.js +111 -31
  14. package/src/api/events/application.d.ts +12 -0
  15. package/src/api/events/application.js +12 -0
  16. package/src/api/events/channel.d.ts +5 -0
  17. package/src/api/events/channel.js +5 -0
  18. package/src/api/events/externalApplication.d.ts +5 -0
  19. package/src/api/events/externalApplication.js +5 -0
  20. package/src/api/events/frame.d.ts +5 -0
  21. package/src/api/events/globalHotkey.d.ts +5 -0
  22. package/src/api/events/platform.d.ts +9 -1
  23. package/src/api/events/platform.js +8 -0
  24. package/src/api/events/system.d.ts +13 -0
  25. package/src/api/events/system.js +13 -0
  26. package/src/api/events/view.d.ts +19 -9
  27. package/src/api/events/view.js +10 -0
  28. package/src/api/events/webcontents.d.ts +21 -10
  29. package/src/api/events/webcontents.js +11 -0
  30. package/src/api/events/window.d.ts +70 -1
  31. package/src/api/events/window.js +10 -0
  32. package/src/api/external-application/Factory.d.ts +16 -9
  33. package/src/api/external-application/Factory.js +16 -9
  34. package/src/api/external-application/Instance.d.ts +40 -32
  35. package/src/api/external-application/Instance.js +40 -32
  36. package/src/api/external-application/index.d.ts +9 -0
  37. package/src/api/external-application/index.js +9 -0
  38. package/src/api/fin.d.ts +3 -0
  39. package/src/api/fin.js +3 -0
  40. package/src/api/frame/Factory.d.ts +30 -13
  41. package/src/api/frame/Factory.js +30 -13
  42. package/src/api/frame/Instance.d.ts +51 -38
  43. package/src/api/frame/Instance.js +51 -38
  44. package/src/api/frame/index.d.ts +11 -0
  45. package/src/api/frame/index.js +11 -0
  46. package/src/api/global-hotkey/index.d.ts +81 -13
  47. package/src/api/global-hotkey/index.js +81 -13
  48. package/src/api/interappbus/channel/channel.d.ts +257 -0
  49. package/src/api/interappbus/channel/channel.js +257 -0
  50. package/src/api/interappbus/channel/channels-docs.d.ts +59 -57
  51. package/src/api/interappbus/channel/channels-docs.js +71 -68
  52. package/src/api/interappbus/channel/client.d.ts +93 -0
  53. package/src/api/interappbus/channel/client.js +93 -1
  54. package/src/api/interappbus/channel/index.d.ts +164 -0
  55. package/src/api/interappbus/channel/index.js +165 -1
  56. package/src/api/interappbus/channel/provider.d.ts +172 -0
  57. package/src/api/interappbus/channel/provider.js +172 -0
  58. package/src/api/interappbus/index.d.ts +55 -20
  59. package/src/api/interappbus/index.js +55 -20
  60. package/src/api/interop/Factory.d.ts +30 -10
  61. package/src/api/interop/Factory.js +30 -10
  62. package/src/api/interop/InteropBroker.d.ts +298 -70
  63. package/src/api/interop/InteropBroker.js +298 -70
  64. package/src/api/interop/InteropClient.d.ts +286 -62
  65. package/src/api/interop/InteropClient.js +286 -62
  66. package/src/api/interop/SessionContextGroupClient.d.ts +2 -2
  67. package/src/api/interop/SessionContextGroupClient.js +2 -2
  68. package/src/api/interop/fdc3/documentationStub.d.ts +14 -0
  69. package/src/api/interop/fdc3/documentationStub.js +17 -0
  70. package/src/api/interop/fdc3/fdc3-1.2.d.ts +31 -34
  71. package/src/api/interop/fdc3/fdc3-1.2.js +31 -34
  72. package/src/api/interop/fdc3/fdc3-2.0.d.ts +48 -51
  73. package/src/api/interop/fdc3/fdc3-2.0.js +48 -51
  74. package/src/api/interop/index.d.ts +8 -0
  75. package/src/api/interop/index.js +8 -0
  76. package/src/api/platform/Factory.d.ts +121 -65
  77. package/src/api/platform/Factory.js +122 -66
  78. package/src/api/platform/Instance.d.ts +551 -48
  79. package/src/api/platform/Instance.js +551 -49
  80. package/src/api/platform/index.d.ts +9 -0
  81. package/src/api/platform/index.js +9 -0
  82. package/src/api/platform/layout/Factory.d.ts +53 -76
  83. package/src/api/platform/layout/Factory.js +53 -76
  84. package/src/api/platform/layout/Instance.d.ts +158 -23
  85. package/src/api/platform/layout/Instance.js +118 -20
  86. package/src/api/platform/layout/entities/layout-entities.d.ts +222 -30
  87. package/src/api/platform/layout/entities/layout-entities.js +222 -30
  88. package/src/api/platform/layout/index.d.ts +9 -0
  89. package/src/api/platform/layout/index.js +9 -0
  90. package/src/api/platform/provider.d.ts +398 -51
  91. package/src/api/snapshot-source/Factory.d.ts +33 -18
  92. package/src/api/snapshot-source/Factory.js +33 -18
  93. package/src/api/snapshot-source/Instance.d.ts +30 -8
  94. package/src/api/snapshot-source/Instance.js +30 -8
  95. package/src/api/snapshot-source/index.d.ts +9 -0
  96. package/src/api/snapshot-source/index.js +9 -0
  97. package/src/api/system/index.d.ts +1137 -186
  98. package/src/api/system/index.js +1142 -186
  99. package/src/api/view/Factory.d.ts +54 -16
  100. package/src/api/view/Factory.js +54 -16
  101. package/src/api/view/Instance.d.ts +330 -216
  102. package/src/api/view/Instance.js +331 -217
  103. package/src/api/view/index.d.ts +9 -0
  104. package/src/api/view/index.js +9 -0
  105. package/src/api/webcontents/main.d.ts +890 -0
  106. package/src/api/webcontents/main.js +890 -0
  107. package/src/api/window/Factory.d.ts +67 -16
  108. package/src/api/window/Factory.js +67 -16
  109. package/src/api/window/Instance.d.ts +824 -316
  110. package/src/api/window/Instance.js +822 -320
  111. package/src/api/window/index.d.ts +11 -0
  112. package/src/api/window/index.js +11 -0
  113. package/src/namespaces.d.ts +1 -0
  114. package/src/namespaces.js +3 -1
  115. package/src/shapes/protocol.d.ts +4 -0
  116. package/openfin-core-33.76.31.tgz +0 -0
@@ -6,7 +6,8 @@
6
6
  */
7
7
  const InterApplicationBus = {};
8
8
  /**
9
- * @namespace
9
+ * @PORTED
10
+ *
10
11
  * @desc The Channel namespace allows an OpenFin application to create a channel as a {@link Channel#ChannelProvider ChannelProvider},
11
12
  * or connect to a channel as a {@link Channel#ChannelClient ChannelClient}. The "handshake" between the communication partners is
12
13
  * simplified when using a channel. A request to connect to a channel as a client will return a promise that resolves if/when the channel has been created. Both the
@@ -24,9 +25,9 @@ InterApplicationBus.Channel = function () { };
24
25
  *
25
26
  * Create a new channel. Returns a promise that resolves with a {@link Channel#ChannelProvider ChannelProvider} instance for your channel.
26
27
  * You must provide a unique channelName. If a channelName is not provided, or it is not unique, the creation will fail. EXPERIMENTAL: pass { protocols: ['rtc'] } as options to opt-in to High Throughput Channels.
27
- * @param {string} channelName - Name of the channel to be created.
28
- * @param {InterApplicationBus.Channel~ChannelCreateOptions} options - Creation options.
29
- * @returns {Promise<Channel#ChannelProvider>} Returns promise that resolves with an instance of {@link Channel#ChannelProvider ChannelProvider}.
28
+ * @param channelName - Name of the channel to be created.
29
+ * @param options - Creation options.
30
+ *
30
31
  * @tutorial Channel.create
31
32
  */
32
33
  InterApplicationBus.Channel.create = function () { };
@@ -34,9 +35,9 @@ InterApplicationBus.Channel.create = function () { };
34
35
  *
35
36
  * Connect to a channel. Returns a promise for a {@link Channel#ChannelClient ChannelClient} instance for that channel.
36
37
  * If you wish to send a payload to the provider, add a payload property to the options argument. EXPERIMENTAL: pass { protocols: ['rtc'] } as options to opt-in to High Throughput Channels.
37
- * @param {string} channelName - Name of the target channel.
38
- * @param {InterApplicationBus.Channel~ChannelConnectOptions} options - Connection options.
39
- * @returns {Promise<Channel#ChannelClient>} Returns promise that resolves with an instance of {@link Channel#ChannelClient ChannelClient}.
38
+ * @param channelName - Name of the target channel.
39
+ * @param options - Connection options.
40
+ *
40
41
  * @tutorial Channel.connect
41
42
  *
42
43
  */
@@ -44,20 +45,21 @@ InterApplicationBus.Channel.connect = function (options) { };
44
45
  /**
45
46
  *
46
47
  * Listens for channel connections.
47
- * @param {InterApplicationBus.Channel~ConnectionEvent} listener - callback to execute.
48
- * @returns {Promise<void>}
48
+ * @param listener - callback to execute.
49
+ *
49
50
  * @tutorial Channel.onChannelConnect
50
51
  */
51
52
  InterApplicationBus.Channel.onChannelConnect = function () { };
52
53
  /**
53
54
  *
54
55
  * Listen for channel disconnections.
55
- * @param {InterApplicationBus.Channel~ConnectionEvent} listener - callback to execute.
56
- * @returns {Promise<void>}
56
+ * @param listener - callback to execute.
57
+ *
57
58
  * @tutorial Channel.onChannelDisconnect
58
59
  */
59
60
  InterApplicationBus.Channel.onChannelDisconnect = function () { };
60
61
  /**
62
+ * @PORTED
61
63
  * Instance created to enable use of a channel as a provider. Allows for communication with the {@link Channel#ChannelClient ChannelClients} by invoking an action on
62
64
  * a single client via {@link Channel#ChannelProvider#dispatch dispatch} or all clients via {@link Channel#ChannelProvider#publish publish}
63
65
  * and to listen for communication from clients by registering an action via {@link Channel#ChannelProvider#register register}.
@@ -96,26 +98,26 @@ class ChannelProvider {
96
98
  /**
97
99
  *
98
100
  * Destroy the channel.
99
- * @returns {Promise<void>}
101
+ *
100
102
  * @tutorial ChannelProvider.destroy
101
103
  */
102
104
  destroy() { }
103
105
  /**
104
106
  *
105
107
  * Dispatch an action to a specified client. Returns a promise for the result of executing that action on the client side.
106
- * @param {InterApplicationBus.Channel~ClientIdentity} to - Identity of the target client.
107
- * @param {string} action - Name of the action to be invoked by the client.
108
- * @param {*} payload - Payload to be sent along with the action.
109
- * @returns {Promise<any>}
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
+ *
110
112
  * @tutorial Channel.dispatch
111
113
  */
112
114
  dispatch() { }
113
115
  /**
114
116
  *
115
117
  * Register an action to be called
116
- * @param {string} action - Name of the action to be registered for channel clients to later invoke.
117
- * @param {Channel#ChannelProvider~Action} listener - Function representing the action to be taken on a client dispatch.
118
- * @returns {boolean} - Boolean representing the successful registration of the action.
118
+ * @param action - Name of the action to be registered for channel clients to later invoke.
119
+ * @param listener - Function representing the action to be taken on a client dispatch.
120
+ * @returns - Boolean representing the successful registration of the action.
119
121
  * @tutorial Channel.register
120
122
  */
121
123
  register() { }
@@ -123,9 +125,9 @@ class ChannelProvider {
123
125
  *
124
126
  * Publish an action and payload to every connected client.
125
127
  * Synchronously returns an array of promises for each action (see dispatch).
126
- * @param {string} action
127
- * @param {*} payload
128
- * @returns {Array<Promise<any>>}
128
+ * @param action
129
+ * @param payload
130
+ *
129
131
  * @tutorial ChannelProvider.publish
130
132
  */
131
133
  publish() { }
@@ -135,8 +137,8 @@ class ChannelProvider {
135
137
  * It is passed the identity of the connecting client and a payload if it was provided to {@link Channel.connect}.
136
138
  * If you wish to reject the connection, throw an error. Be sure to synchronously provide an onConnection upon receipt of the channelProvider
137
139
  * to ensure all potential client connections are caught by the listener.
138
- * @param {Channel#ChannelProvider~ConnectionListener} listener
139
- * @returns {void}
140
+ * @param listener
141
+ *
140
142
  * @tutorial ChannelProvider.onConnection
141
143
  */
142
144
  onConnection() { }
@@ -144,40 +146,40 @@ class ChannelProvider {
144
146
  *
145
147
  * Register a listener that is called on every new client disconnection.
146
148
  * It is passed the disconnection event of the disconnecting client.
147
- * @param {InterApplicationBus.Channel~ConnectionEvent} listener
148
- * @returns {void}
149
+ * @param listener
150
+ *
149
151
  * @tutorial Channel.onDisconnection
150
152
  */
151
153
  onDisconnection() { }
152
154
  /**
153
155
  *
154
156
  * Register middleware that fires before the action.
155
- * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed before invoking the action.
156
- * @returns {void}
157
+ * @param middleware - Function to be executed before invoking the action.
158
+ *
157
159
  * @tutorial ChannelMiddleware.beforeAction
158
160
  */
159
161
  beforeAction() { }
160
162
  /**
161
163
  *
162
164
  * Register an error handler. This is called before responding on any error.
163
- * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed in case of an error.
164
- * @returns {void}
165
+ * @param middleware - Function to be executed in case of an error.
166
+ *
165
167
  * @tutorial ChannelMiddleware.onError
166
168
  */
167
169
  onError() { }
168
170
  /**
169
171
  *
170
172
  * Register middleware that fires after the action. This is passed the return value of the action.
171
- * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed after invoking the action.
172
- * @returns {void}
173
+ * @param middleware - Function to be executed after invoking the action.
174
+ *
173
175
  * @tutorial ChannelMiddleware.afterAction
174
176
  */
175
177
  afterAction() { }
176
178
  /**
177
179
  *
178
180
  * Remove an action by action name.
179
- * @param {string} action - Name of the action to be removed.
180
- * @returns {void}
181
+ * @param action - Name of the action to be removed.
182
+ *
181
183
  * @tutorial Channel.remove
182
184
  */
183
185
  remove() { }
@@ -185,18 +187,19 @@ class ChannelProvider {
185
187
  *
186
188
  * Sets a default action. This is used any time an action that has not been registered is invoked.
187
189
  * Default behavior if not set is to throw an error.
188
- * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed when a client invokes an action name that has not been registered.
189
- * @returns {void}
190
+ * @param middleware - Function to be executed when a client invokes an action name that has not been registered.
191
+ *
190
192
  * @tutorial ChannelMiddleware.setDefaultAction
191
193
  */
192
194
  setDefaultAction() { }
193
195
  /** Returns an array with info on every Client connected to the Provider
194
- * @returns { Promise<Array<ClientInfo>> }
196
+ *
195
197
  * @tutorial Channel.getAllClientInfo
196
198
  */
197
199
  getAllClientInfo() { }
198
200
  }
199
201
  /**
202
+ * @PORTED
200
203
  * Instance created to enable use of a channel as a client. Allows for communication with the
201
204
  * {@link Channel#ChannelProvider ChannelProvider} by invoking an action on the
202
205
  * provider via {@link Channel#ChannelClient#dispatch dispatch} and to listen for communication
@@ -232,32 +235,32 @@ class ChannelClient {
232
235
  *
233
236
  * Disconnect from the channel.
234
237
  * @tutorial Channel.disconnect
235
- * @returns {Promise<void>}
238
+ *
236
239
  */
237
240
  disconnect() { }
238
241
  /**
239
242
  *
240
243
  * Dispatch the given action to the channel provider. Returns a promise that resolves with the response from the provider for that action.
241
- * @param {string} action - Name of the action to be invoked by the channel provider.
242
- * @param {*} payload - Payload to be sent along with the action.
244
+ * @param action - Name of the action to be invoked by the channel provider.
245
+ * @param payload - Payload to be sent along with the action.
243
246
  * @tutorial Channel.dispatch
244
- * @returns {Promise<any>}
247
+ *
245
248
  */
246
249
  dispatch() { }
247
250
  /**
248
251
  *
249
252
  * Register an action to be called by the provider of the channel.
250
- * @param {string} action - Name of the action to be registered for the channel provider to later invoke.
251
- * @param {Channel#ChannelClient~Action} listener - Function representing the action to be taken on a provider dispatch.
252
- * @returns {boolean}
253
+ * @param action - Name of the action to be registered for the channel provider to later invoke.
254
+ * @param listener - Function representing the action to be taken on a provider dispatch.
255
+ *
253
256
  * @tutorial Channel.register
254
257
  */
255
258
  register() { }
256
259
  /**
257
260
  *
258
261
  * Register middleware that fires before the action.
259
- * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed before invoking the action.
260
- * @returns {void}
262
+ * @param middleware - Function to be executed before invoking the action.
263
+ *
261
264
  * @tutorial ChannelMiddleware.beforeAction
262
265
  */
263
266
  beforeAction() { }
@@ -265,31 +268,31 @@ class ChannelClient {
265
268
  *
266
269
  * Register a listener that is called on channel disconnection.
267
270
  * It is passed the disconnection event of the disconnecting channel.
268
- * @param {InterApplicationBus.Channel~ConnectionEvent} listener
269
- * @returns {void}
271
+ * @param listener
272
+ *
270
273
  * @tutorial Channel.onDisconnection
271
274
  */
272
275
  onDisconnection() { }
273
276
  /**
274
277
  * Register an error handler. This is called before responding on any error.
275
- * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed in case of an error.
276
- * @returns {void}
278
+ * @param middleware - Function to be executed in case of an error.
279
+ *
277
280
  * @tutorial ChannelMiddleware.onError
278
281
  */
279
282
  onError() { }
280
283
  /**
281
284
  *
282
285
  * Register middleware that fires after the action. This is passed the return value of the action.
283
- * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed after invoking the action.
284
- * @returns {void}
286
+ * @param middleware - Function to be executed after invoking the action.
287
+ *
285
288
  * @tutorial ChannelMiddleware.afterAction
286
289
  */
287
290
  afterAction() { }
288
291
  /**
289
292
  *
290
293
  * Remove an action by action name.
291
- * @param {string} action - Name of the action to be removed.
292
- * @returns {void}
294
+ * @param action - Name of the action to be removed.
295
+ *
293
296
  * @tutorial Channel.remove
294
297
  */
295
298
  remove() { }
@@ -297,8 +300,8 @@ class ChannelClient {
297
300
  *
298
301
  * Sets a default action. This is used any time an action that has not been registered is invoked.
299
302
  * Default behavior if not set is to throw an error.
300
- * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed when a client invokes an action name that has not been registered.
301
- * @returns {void}
303
+ * @param middleware - Function to be executed when a client invokes an action name that has not been registered.
304
+ *
302
305
  * @tutorial ChannelMiddleware.setDefaultAction
303
306
  */
304
307
  setDefaultAction() { }
@@ -306,34 +309,34 @@ class ChannelClient {
306
309
  /**
307
310
  * Channel action callback signature
308
311
  * @callback Channel#ChannelProvider~Action
309
- * @param {any} payload - Payload sent along with the message.
310
- * @param {InterApplicationBus.Channel~ClientIdentity} identity - Identity of the sender.
312
+ * @param payload - Payload sent along with the message.
313
+ * @param identity - Identity of the sender.
311
314
  */
312
315
  /**
313
316
  * Channel action callback signature
314
317
  * @callback Channel#ChannelClient~Action
315
- * @param {any} payload - Payload sent along with the message.
316
- * @param {Identity} identity - Identity of the sender.
318
+ * @param payload - Payload sent along with the message.
319
+ * @param identity - Identity of the sender.
317
320
  */
318
321
  /**
319
322
  * Middleware function signature
320
323
  * @callback Channel#ChannelProvider~Middleware
321
- * @param {string} action - Action to be invoked.
322
- * @param {any} payload - Payload sent along with the message (or error for error middleware).
323
- * @param {Identity} identity - Identity of the sender.
324
+ * @param action - Action to be invoked.
325
+ * @param payload - Payload sent along with the message (or error for error middleware).
326
+ * @param identity - Identity of the sender.
324
327
  */
325
328
  /**
326
329
  * Middleware function signature
327
330
  * @callback Channel#ChannelClient~Middleware
328
- * @param {string} action - Action to be invoked.
329
- * @param {any} payload - Payload sent along with the message (or error for error middleware).
330
- * @param {Identity} identity - Identity of the sender.
331
+ * @param action - Action to be invoked.
332
+ * @param payload - Payload sent along with the message (or error for error middleware).
333
+ * @param identity - Identity of the sender.
331
334
  */
332
335
  /**
333
336
  * Callback for the channel onConnection or onDisconnection. If it errors connection will be rejected.
334
337
  * @callback Channel#ChannelProvider~ConnectionListener
335
- * @param {InterApplicationBus.Channel~ClientIdentity} identity - Identity of the client attempting to connect to the channel.
336
- * @param {any} payload - Payload sent with connection request.
338
+ * @param identity - Identity of the client attempting to connect to the channel.
339
+ * @param payload - Payload sent with connection request.
337
340
  */
338
341
  /**
339
342
  * @REMOVED
@@ -7,17 +7,110 @@ type DisconnectionListener = (providerIdentity: ProviderIdentity) => any;
7
7
  export type RoutingInfo = ProviderIdentity & {
8
8
  endpointId: string;
9
9
  };
10
+ /**
11
+ * Instance created to enable use of a channel as a client. Allows for communication with the
12
+ * {@link ChannelProvider ChannelProvider} by invoking an action on the
13
+ * provider via {@link ChannelClient#dispatch dispatch} and to listen for communication
14
+ * from the provider by registering an action via {@link ChannelClient#register register}.
15
+ *
16
+ * Synchronous Methods:
17
+ * * {@link ChannelClient#onDisconnection onDisconnection(listener)}
18
+ * * {@link ChannelClient#register register(action, listener)}
19
+ * * {@link ChannelClient#remove remove(action)}
20
+ *
21
+ * Asynchronous Methods:
22
+ * * {@link ChannelClient#disconnect disconnect()}
23
+ * * {@link ChannelClient#dispatch dispatch(action, payload)}
24
+ *
25
+ * Middleware:
26
+ * <br>Middleware functions receive the following arguments: (action, payload, senderId).
27
+ * The return value of the middleware function will be passed on as the payload from beforeAction, to the action listener, to afterAction
28
+ * unless it is undefined, in which case the original payload is used. Middleware can be used for side effects.
29
+ * * {@link ChannelClient#setDefaultAction setDefaultAction(middleware)}
30
+ * * {@link ChannelClient#onError onError(middleware)}
31
+ * * {@link ChannelClient#beforeAction beforeAction(middleware)}
32
+ * * {@link ChannelClient#afterAction afterAction(middleware)}
33
+ */
10
34
  export default class ChannelClient extends ChannelBase {
11
35
  #private;
12
36
  private disconnectListener;
13
37
  private endpointId;
38
+ /**
39
+ * @internal
40
+ */
14
41
  static closeChannelByEndpointId(id: string): void;
42
+ /**
43
+ * @internal
44
+ * closes the corresponding channel and invokes the disconnect listener if an event payload is passed.
45
+ */
15
46
  static handleProviderDisconnect(eventPayload: ProviderIdentity): void;
47
+ /**
48
+ * @internal
49
+ */
16
50
  constructor(routingInfo: RoutingInfo, wire: Transport, strategy: AnyStrategy);
17
51
  protected processAction: (action: string, payload: any, senderIdentity: ProviderIdentity | OpenFin.ClientIdentity) => Promise<any>;
52
+ /**
53
+ * a read-only provider identity
54
+ */
18
55
  get providerIdentity(): ProviderIdentity;
56
+ /**
57
+ * Dispatch the given action to the channel provider. Returns a promise that resolves with the response from
58
+ * the provider for that action.
59
+ *
60
+ * @param action
61
+ * @param payload
62
+ *
63
+ * @example
64
+ *
65
+ * ```js
66
+ * (async ()=> {
67
+ * const client = await fin.InterApplicationBus.Channel.connect('channelName');
68
+ *
69
+ * await client.register('client-action', (payload, identity) => {
70
+ * console.log(payload, identity);
71
+ * return {
72
+ * echo: payload
73
+ * };
74
+ * });
75
+ *
76
+ * const providerResponse = await client.dispatch('provider-action', { message: 'Hello From the client'});
77
+ * console.log(providerResponse);
78
+ * })();
79
+ * ```
80
+ */
19
81
  dispatch(action: string, payload?: any): Promise<any>;
82
+ /**
83
+ * Register a listener that is called on provider disconnection. It is passed the disconnection event of the
84
+ * disconnecting provider.
85
+ *
86
+ * @param listener
87
+ *
88
+ * @example
89
+ *
90
+ * ```js
91
+ * (async ()=> {
92
+ * const client = await fin.InterApplicationBus.Channel.connect('channelName');
93
+ *
94
+ * await client.onDisconnection(evt => {
95
+ * console.log('Provider disconnected', `uuid: ${evt.uuid}, name: ${evt.name}`);
96
+ * });
97
+ * })();
98
+ * ```
99
+ */
20
100
  onDisconnection(listener: DisconnectionListener): void;
101
+ /**
102
+ * Disconnects the client from the channel.
103
+ *
104
+ * @example
105
+ *
106
+ * ```js
107
+ * (async ()=> {
108
+ * const client = await fin.InterApplicationBus.Channel.connect('channelName');
109
+ *
110
+ * await client.disconnect();
111
+ * })();
112
+ * ```
113
+ */
21
114
  disconnect(): Promise<void>;
22
115
  sendDisconnectAction(): Promise<void>;
23
116
  }
@@ -14,14 +14,44 @@ var _ChannelClient_protectedObj, _ChannelClient_strategy, _ChannelClient_close;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const channel_1 = require("./channel");
16
16
  const channelClientsByEndpointId = new Map();
17
+ /**
18
+ * Instance created to enable use of a channel as a client. Allows for communication with the
19
+ * {@link ChannelProvider ChannelProvider} by invoking an action on the
20
+ * provider via {@link ChannelClient#dispatch dispatch} and to listen for communication
21
+ * from the provider by registering an action via {@link ChannelClient#register register}.
22
+ *
23
+ * Synchronous Methods:
24
+ * * {@link ChannelClient#onDisconnection onDisconnection(listener)}
25
+ * * {@link ChannelClient#register register(action, listener)}
26
+ * * {@link ChannelClient#remove remove(action)}
27
+ *
28
+ * Asynchronous Methods:
29
+ * * {@link ChannelClient#disconnect disconnect()}
30
+ * * {@link ChannelClient#dispatch dispatch(action, payload)}
31
+ *
32
+ * Middleware:
33
+ * <br>Middleware functions receive the following arguments: (action, payload, senderId).
34
+ * The return value of the middleware function will be passed on as the payload from beforeAction, to the action listener, to afterAction
35
+ * unless it is undefined, in which case the original payload is used. Middleware can be used for side effects.
36
+ * * {@link ChannelClient#setDefaultAction setDefaultAction(middleware)}
37
+ * * {@link ChannelClient#onError onError(middleware)}
38
+ * * {@link ChannelClient#beforeAction beforeAction(middleware)}
39
+ * * {@link ChannelClient#afterAction afterAction(middleware)}
40
+ */
17
41
  class ChannelClient extends channel_1.ChannelBase {
42
+ /**
43
+ * @internal
44
+ */
18
45
  static closeChannelByEndpointId(id) {
19
46
  const channel = channelClientsByEndpointId.get(id);
20
47
  if (channel) {
21
48
  __classPrivateFieldGet(channel, _ChannelClient_close, "f").call(channel);
22
49
  }
23
50
  }
24
- // closes the corresponding channel and invokes the disconnect listener if an event payload is passed.
51
+ /**
52
+ * @internal
53
+ * closes the corresponding channel and invokes the disconnect listener if an event payload is passed.
54
+ */
25
55
  static handleProviderDisconnect(eventPayload) {
26
56
  for (const channelClient of channelClientsByEndpointId.values()) {
27
57
  if (channelClient.providerIdentity.channelId === eventPayload.channelId) {
@@ -30,6 +60,9 @@ class ChannelClient extends channel_1.ChannelBase {
30
60
  }
31
61
  }
32
62
  }
63
+ /**
64
+ * @internal
65
+ */
33
66
  constructor(routingInfo, wire, strategy) {
34
67
  super();
35
68
  _ChannelClient_protectedObj.set(this, void 0);
@@ -47,16 +80,62 @@ class ChannelClient extends channel_1.ChannelBase {
47
80
  channelClientsByEndpointId.set(this.endpointId, this);
48
81
  strategy.receive(this.processAction);
49
82
  }
83
+ /**
84
+ * a read-only provider identity
85
+ */
50
86
  get providerIdentity() {
51
87
  const protectedObj = __classPrivateFieldGet(this, _ChannelClient_protectedObj, "f");
52
88
  return protectedObj.providerIdentity;
53
89
  }
90
+ /**
91
+ * Dispatch the given action to the channel provider. Returns a promise that resolves with the response from
92
+ * the provider for that action.
93
+ *
94
+ * @param action
95
+ * @param payload
96
+ *
97
+ * @example
98
+ *
99
+ * ```js
100
+ * (async ()=> {
101
+ * const client = await fin.InterApplicationBus.Channel.connect('channelName');
102
+ *
103
+ * await client.register('client-action', (payload, identity) => {
104
+ * console.log(payload, identity);
105
+ * return {
106
+ * echo: payload
107
+ * };
108
+ * });
109
+ *
110
+ * const providerResponse = await client.dispatch('provider-action', { message: 'Hello From the client'});
111
+ * console.log(providerResponse);
112
+ * })();
113
+ * ```
114
+ */
54
115
  async dispatch(action, payload) {
55
116
  if (__classPrivateFieldGet(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
56
117
  return __classPrivateFieldGet(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload);
57
118
  }
58
119
  throw new Error('The client you are trying to dispatch from is disconnected from the target provider.');
59
120
  }
121
+ /**
122
+ * Register a listener that is called on provider disconnection. It is passed the disconnection event of the
123
+ * disconnecting provider.
124
+ *
125
+ * @param listener
126
+ *
127
+ * @example
128
+ *
129
+ * ```js
130
+ * (async ()=> {
131
+ * const client = await fin.InterApplicationBus.Channel.connect('channelName');
132
+ *
133
+ * await client.onDisconnection(evt => {
134
+ * console.log('Provider disconnected', `uuid: ${evt.uuid}, name: ${evt.name}`);
135
+ * });
136
+ * })();
137
+ * ```
138
+ */
60
139
  onDisconnection(listener) {
61
140
  this.disconnectListener = (payload) => {
62
141
  try {
@@ -70,6 +149,19 @@ class ChannelClient extends channel_1.ChannelBase {
70
149
  }
71
150
  };
72
151
  }
152
+ /**
153
+ * Disconnects the client from the channel.
154
+ *
155
+ * @example
156
+ *
157
+ * ```js
158
+ * (async ()=> {
159
+ * const client = await fin.InterApplicationBus.Channel.connect('channelName');
160
+ *
161
+ * await client.disconnect();
162
+ * })();
163
+ * ```
164
+ */
73
165
  async disconnect() {
74
166
  await this.sendDisconnectAction();
75
167
  __classPrivateFieldGet(this, _ChannelClient_close, "f").call(this);