@openfin/core 25.68.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/LICENSE +13 -0
  2. package/NOTICE +16 -0
  3. package/OpenFin.d.ts +1340 -0
  4. package/README.md +41 -0
  5. package/docs.README(OLD).md +82 -0
  6. package/fin.d.ts +4 -0
  7. package/package.json +33 -0
  8. package/resources/win/OpenFinRVM.exe +0 -0
  9. package/src/api/application/Factory.d.ts +145 -0
  10. package/src/api/application/Factory.js +229 -0
  11. package/src/api/application/Instance.d.ts +302 -0
  12. package/src/api/application/Instance.js +412 -0
  13. package/src/api/application/index.d.ts +3 -0
  14. package/src/api/application/index.js +15 -0
  15. package/src/api/base.d.ts +43 -0
  16. package/src/api/base.js +177 -0
  17. package/src/api/clipboard/index.d.ts +69 -0
  18. package/src/api/clipboard/index.js +88 -0
  19. package/src/api/events/application.d.ts +69 -0
  20. package/src/api/events/application.js +2 -0
  21. package/src/api/events/base.d.ts +17 -0
  22. package/src/api/events/base.js +2 -0
  23. package/src/api/events/channel.d.ts +10 -0
  24. package/src/api/events/channel.js +2 -0
  25. package/src/api/events/emitterMap.d.ts +11 -0
  26. package/src/api/events/emitterMap.js +35 -0
  27. package/src/api/events/eventAggregator.d.ts +5 -0
  28. package/src/api/events/eventAggregator.js +43 -0
  29. package/src/api/events/externalApplication.d.ts +5 -0
  30. package/src/api/events/externalApplication.js +2 -0
  31. package/src/api/events/frame.d.ts +9 -0
  32. package/src/api/events/frame.js +2 -0
  33. package/src/api/events/globalHotkey.d.ts +10 -0
  34. package/src/api/events/globalHotkey.js +2 -0
  35. package/src/api/events/platform.d.ts +18 -0
  36. package/src/api/events/platform.js +2 -0
  37. package/src/api/events/system.d.ts +22 -0
  38. package/src/api/events/system.js +2 -0
  39. package/src/api/events/view.d.ts +56 -0
  40. package/src/api/events/view.js +2 -0
  41. package/src/api/events/webcontents.d.ts +48 -0
  42. package/src/api/events/webcontents.js +2 -0
  43. package/src/api/events/window.d.ts +169 -0
  44. package/src/api/events/window.js +2 -0
  45. package/src/api/external-application/Factory.d.ts +26 -0
  46. package/src/api/external-application/Factory.js +40 -0
  47. package/src/api/external-application/Instance.d.ts +102 -0
  48. package/src/api/external-application/Instance.js +109 -0
  49. package/src/api/external-application/index.d.ts +3 -0
  50. package/src/api/external-application/index.js +15 -0
  51. package/src/api/fin.d.ts +49 -0
  52. package/src/api/fin.js +43 -0
  53. package/src/api/frame/Factory.d.ts +36 -0
  54. package/src/api/frame/Factory.js +69 -0
  55. package/src/api/frame/Instance.d.ts +121 -0
  56. package/src/api/frame/Instance.js +130 -0
  57. package/src/api/frame/index.d.ts +3 -0
  58. package/src/api/frame/index.js +15 -0
  59. package/src/api/global-hotkey/index.d.ts +38 -0
  60. package/src/api/global-hotkey/index.js +58 -0
  61. package/src/api/interappbus/channel/channel.d.ts +26 -0
  62. package/src/api/interappbus/channel/channel.js +77 -0
  63. package/src/api/interappbus/channel/channels-docs.d.ts +318 -0
  64. package/src/api/interappbus/channel/channels-docs.js +376 -0
  65. package/src/api/interappbus/channel/client.d.ts +22 -0
  66. package/src/api/interappbus/channel/client.js +84 -0
  67. package/src/api/interappbus/channel/connection-manager.d.ts +28 -0
  68. package/src/api/interappbus/channel/connection-manager.js +244 -0
  69. package/src/api/interappbus/channel/index.d.ts +22 -0
  70. package/src/api/interappbus/channel/index.js +121 -0
  71. package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +13 -0
  72. package/src/api/interappbus/channel/protocols/classic/message-receiver.js +73 -0
  73. package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +22 -0
  74. package/src/api/interappbus/channel/protocols/classic/strategy.js +84 -0
  75. package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +20 -0
  76. package/src/api/interappbus/channel/protocols/combined/strategy.js +58 -0
  77. package/src/api/interappbus/channel/protocols/index.d.ts +44 -0
  78. package/src/api/interappbus/channel/protocols/index.js +2 -0
  79. package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +10 -0
  80. package/src/api/interappbus/channel/protocols/protocol-manager.js +43 -0
  81. package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +23 -0
  82. package/src/api/interappbus/channel/protocols/rtc/endpoint.js +135 -0
  83. package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +30 -0
  84. package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +131 -0
  85. package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +22 -0
  86. package/src/api/interappbus/channel/protocols/rtc/strategy.js +87 -0
  87. package/src/api/interappbus/channel/protocols/strategy-types.d.ts +13 -0
  88. package/src/api/interappbus/channel/protocols/strategy-types.js +2 -0
  89. package/src/api/interappbus/channel/protocols/strategy.d.ts +15 -0
  90. package/src/api/interappbus/channel/protocols/strategy.js +2 -0
  91. package/src/api/interappbus/channel/provider.d.ts +31 -0
  92. package/src/api/interappbus/channel/provider.js +165 -0
  93. package/src/api/interappbus/index.d.ts +85 -0
  94. package/src/api/interappbus/index.js +175 -0
  95. package/src/api/interop/Factory.d.ts +37 -0
  96. package/src/api/interop/Factory.js +54 -0
  97. package/src/api/interop/InteropBroker.d.ts +363 -0
  98. package/src/api/interop/InteropBroker.js +914 -0
  99. package/src/api/interop/InteropClient.d.ts +268 -0
  100. package/src/api/interop/InteropClient.js +450 -0
  101. package/src/api/interop/SessionContextGroupBroker.d.ts +26 -0
  102. package/src/api/interop/SessionContextGroupBroker.js +107 -0
  103. package/src/api/interop/SessionContextGroupClient.d.ts +20 -0
  104. package/src/api/interop/SessionContextGroupClient.js +85 -0
  105. package/src/api/interop/fdc3/fdc3-1.2.d.ts +187 -0
  106. package/src/api/interop/fdc3/fdc3-1.2.js +385 -0
  107. package/src/api/interop/fdc3/fdc3.js +17 -0
  108. package/src/api/interop/fdc3/utils.d.ts +6 -0
  109. package/src/api/interop/fdc3/utils.js +17 -0
  110. package/src/api/interop/index.d.ts +4 -0
  111. package/src/api/interop/index.js +16 -0
  112. package/src/api/interop/utils.d.ts +11 -0
  113. package/src/api/interop/utils.js +36 -0
  114. package/src/api/me.d.ts +35 -0
  115. package/src/api/me.js +60 -0
  116. package/src/api/platform/Factory.d.ts +109 -0
  117. package/src/api/platform/Factory.js +188 -0
  118. package/src/api/platform/Instance.d.ts +122 -0
  119. package/src/api/platform/Instance.js +299 -0
  120. package/src/api/platform/common-utils.d.ts +6 -0
  121. package/src/api/platform/common-utils.js +16 -0
  122. package/src/api/platform/index.d.ts +3 -0
  123. package/src/api/platform/index.js +15 -0
  124. package/src/api/platform/layout/Factory.d.ts +108 -0
  125. package/src/api/platform/layout/Factory.js +189 -0
  126. package/src/api/platform/layout/Instance.d.ts +48 -0
  127. package/src/api/platform/layout/Instance.js +99 -0
  128. package/src/api/platform/layout/index.d.ts +3 -0
  129. package/src/api/platform/layout/index.js +15 -0
  130. package/src/api/platform/layout/shapes.d.ts +11 -0
  131. package/src/api/platform/layout/shapes.js +2 -0
  132. package/src/api/snapshot-source/Factory.d.ts +36 -0
  133. package/src/api/snapshot-source/Factory.js +65 -0
  134. package/src/api/snapshot-source/Instance.d.ts +30 -0
  135. package/src/api/snapshot-source/Instance.js +134 -0
  136. package/src/api/snapshot-source/index.d.ts +3 -0
  137. package/src/api/snapshot-source/index.js +15 -0
  138. package/src/api/snapshot-source/utils.d.ts +1 -0
  139. package/src/api/snapshot-source/utils.js +5 -0
  140. package/src/api/system/application.d.ts +6 -0
  141. package/src/api/system/application.js +2 -0
  142. package/src/api/system/entity.d.ts +11 -0
  143. package/src/api/system/entity.js +2 -0
  144. package/src/api/system/index.d.ts +957 -0
  145. package/src/api/system/index.js +1241 -0
  146. package/src/api/system/installedApps.d.ts +6 -0
  147. package/src/api/system/installedApps.js +2 -0
  148. package/src/api/system/log.d.ts +11 -0
  149. package/src/api/system/log.js +2 -0
  150. package/src/api/system/process.d.ts +15 -0
  151. package/src/api/system/process.js +2 -0
  152. package/src/api/system/proxy.d.ts +15 -0
  153. package/src/api/system/proxy.js +2 -0
  154. package/src/api/system/queryPermissionTypes.d.ts +1 -0
  155. package/src/api/system/queryPermissionTypes.js +2 -0
  156. package/src/api/system/registry-info.d.ts +7 -0
  157. package/src/api/system/registry-info.js +2 -0
  158. package/src/api/system/window.d.ts +16 -0
  159. package/src/api/system/window.js +2 -0
  160. package/src/api/view/Factory.d.ts +49 -0
  161. package/src/api/view/Factory.js +103 -0
  162. package/src/api/view/Instance.d.ts +379 -0
  163. package/src/api/view/Instance.js +415 -0
  164. package/src/api/view/index.d.ts +3 -0
  165. package/src/api/view/index.js +15 -0
  166. package/src/api/webcontents/main.d.ts +36 -0
  167. package/src/api/webcontents/main.js +82 -0
  168. package/src/api/window/Factory.d.ts +44 -0
  169. package/src/api/window/Factory.js +91 -0
  170. package/src/api/window/Instance.d.ts +966 -0
  171. package/src/api/window/Instance.js +1202 -0
  172. package/src/api/window/bounds-changed.d.ts +10 -0
  173. package/src/api/window/bounds-changed.js +6 -0
  174. package/src/api/window/index.d.ts +5 -0
  175. package/src/api/window/index.js +17 -0
  176. package/src/api/window/shapes.d.ts +13 -0
  177. package/src/api/window/shapes.js +2 -0
  178. package/src/environment/environment.d.ts +28 -0
  179. package/src/environment/environment.js +4 -0
  180. package/src/environment/node-env.d.ts +25 -0
  181. package/src/environment/node-env.js +64 -0
  182. package/src/environment/openfin-env.d.ts +29 -0
  183. package/src/environment/openfin-env.js +105 -0
  184. package/src/mock.d.ts +4 -0
  185. package/src/mock.js +91 -0
  186. package/src/shapes/ERROR_BOX_TYPES.d.ts +6 -0
  187. package/src/shapes/ERROR_BOX_TYPES.js +10 -0
  188. package/src/shapes/EntityType.d.ts +1 -0
  189. package/src/shapes/EntityType.js +2 -0
  190. package/src/shapes/LayoutPresetType.d.ts +1 -0
  191. package/src/shapes/LayoutPresetType.js +2 -0
  192. package/src/shapes/Platform.d.ts +112 -0
  193. package/src/shapes/Platform.js +16 -0
  194. package/src/shapes/WebOptions.d.ts +12 -0
  195. package/src/shapes/WebOptions.js +2 -0
  196. package/src/shapes/WindowOptions.d.ts +42 -0
  197. package/src/shapes/WindowOptions.js +2 -0
  198. package/src/shapes/protocol.d.ts +178 -0
  199. package/src/shapes/protocol.js +2 -0
  200. package/src/transport/fin_store.d.ts +4 -0
  201. package/src/transport/fin_store.js +16 -0
  202. package/src/transport/transport-errors.d.ts +17 -0
  203. package/src/transport/transport-errors.js +39 -0
  204. package/src/transport/transport.d.ts +57 -0
  205. package/src/transport/transport.js +195 -0
  206. package/src/transport/wire.d.ts +76 -0
  207. package/src/transport/wire.js +39 -0
  208. package/src/util/asyncFilter.d.ts +1 -0
  209. package/src/util/asyncFilter.js +7 -0
  210. package/src/util/errors.d.ts +9 -0
  211. package/src/util/errors.js +14 -0
  212. package/src/util/exhaustive.d.ts +1 -0
  213. package/src/util/exhaustive.js +7 -0
  214. package/src/util/http.d.ts +11 -0
  215. package/src/util/http.js +83 -0
  216. package/src/util/normalize-config.d.ts +3 -0
  217. package/src/util/normalize-config.js +47 -0
  218. package/src/util/promises.d.ts +5 -0
  219. package/src/util/promises.js +27 -0
  220. package/src/util/ref-counter.d.ts +7 -0
  221. package/src/util/ref-counter.js +51 -0
  222. package/src/util/runtimeVersioning.d.ts +3 -0
  223. package/src/util/runtimeVersioning.js +25 -0
  224. package/src/util/utilTypes.d.ts +8 -0
  225. package/src/util/utilTypes.js +2 -0
  226. package/src/util/validate.d.ts +3 -0
  227. package/src/util/validate.js +11 -0
@@ -0,0 +1,318 @@
1
+ declare const InterApplicationBus: any;
2
+ /**
3
+ * 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
4
+ * a single client via {@link Channel#ChannelProvider#dispatch dispatch} or all clients via {@link Channel#ChannelProvider#publish publish}
5
+ * and to listen for communication from clients by registering an action via {@link Channel#ChannelProvider#register register}.
6
+ *
7
+ * ##### Constructor
8
+ *
9
+ * Returned by {@link InterApplicationBus.Channel.create Channel.create}.
10
+ *
11
+ * ##### Synchronous Methods
12
+ * * {@link Channel#ChannelProvider#onConnection onConnection(listener)}
13
+ * * {@link Channel#ChannelProvider#onDisconnection onDisconnection(listener)}
14
+ * * {@link Channel#ChannelProvider#publish publish(action, payload)}
15
+ * * {@link Channel#ChannelProvider#register register(action, listener)}
16
+ * * {@link Channel#ChannelProvider#remove remove(action)}
17
+ *
18
+ * ##### Asynchronous Methods
19
+ * * {@link Channel#ChannelProvider#destroy destroy()}
20
+ * * {@link Channel#ChannelProvider#dispatch dispatch(to, action, payload)}
21
+ *
22
+ * ##### Middleware
23
+ * Middleware functions receive the following arguments: (action, payload, senderId).
24
+ * The return value of the middleware function will be passed on as the payload from beforeAction, to the action listener, to afterAction
25
+ * unless it is undefined, in which case the most recently defined payload is used. Middleware can be used for side effects.
26
+ * * {@link Channel#ChannelProvider#setDefaultAction setDefaultAction(middleware)}
27
+ * * {@link Channel#ChannelProvider#onError onError(middleware)}
28
+ * * {@link Channel#ChannelProvider#beforeAction beforeAction(middleware)}
29
+ * * {@link Channel#ChannelProvider#afterAction afterAction(middleware)}
30
+ *
31
+ * @memberof! Channel#
32
+ * @hideconstructor
33
+ * @property {InterApplicationBus.Channel~ClientIdentity[]} connections a read-only array containing all the identities of connecting clients.
34
+ *
35
+ */
36
+ declare class ChannelProvider {
37
+ /**
38
+ *
39
+ * Destroy the channel.
40
+ * @returns {Promise<void>}
41
+ * @tutorial ChannelProvider.destroy
42
+ */
43
+ destroy(): void;
44
+ /**
45
+ *
46
+ * Dispatch an action to a specified client. Returns a promise for the result of executing that action on the client side.
47
+ * @param {InterApplicationBus.Channel~ClientIdentity} to - Identity of the target client.
48
+ * @param {string} action - Name of the action to be invoked by the client.
49
+ * @param {*} payload - Payload to be sent along with the action.
50
+ * @returns {Promise<any>}
51
+ * @tutorial Channel.dispatch
52
+ */
53
+ dispatch(): void;
54
+ /**
55
+ *
56
+ * Register an action to be called
57
+ * @param {string} action - Name of the action to be registered for channel clients to later invoke.
58
+ * @param {Channel#ChannelProvider~Action} listener - Function representing the action to be taken on a client dispatch.
59
+ * @returns {boolean} - Boolean representing the successful registration of the action.
60
+ * @tutorial Channel.register
61
+ */
62
+ register(): void;
63
+ /**
64
+ *
65
+ * Publish an action and payload to every connected client.
66
+ * Synchronously returns an array of promises for each action (see dispatch).
67
+ * @param {string} action
68
+ * @param {*} payload
69
+ * @returns {Array<Promise<any>>}
70
+ * @tutorial ChannelProvider.publish
71
+ */
72
+ publish(): void;
73
+ /**
74
+ *
75
+ * Register a listener that is called on every new client connection.
76
+ * It is passed the identity of the connecting client and a payload if it was provided to {@link Channel.connect}.
77
+ * If you wish to reject the connection, throw an error. Be sure to synchronously provide an onConnection upon receipt of the channelProvider
78
+ * to ensure all potential client connections are caught by the listener.
79
+ * @param {Channel#ChannelProvider~ConnectionListener} listener
80
+ * @returns {void}
81
+ * @tutorial ChannelProvider.onConnection
82
+ */
83
+ onConnection(): void;
84
+ /**
85
+ *
86
+ * Register a listener that is called on every new client disconnection.
87
+ * It is passed the disconnection event of the disconnecting client.
88
+ * @param {InterApplicationBus.Channel~ConnectionEvent} listener
89
+ * @returns {void}
90
+ * @tutorial Channel.onDisconnection
91
+ */
92
+ onDisconnection(): void;
93
+ /**
94
+ *
95
+ * Register middleware that fires before the action.
96
+ * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed before invoking the action.
97
+ * @returns {void}
98
+ * @tutorial ChannelMiddleware.beforeAction
99
+ */
100
+ beforeAction(): void;
101
+ /**
102
+ *
103
+ * Register an error handler. This is called before responding on any error.
104
+ * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed in case of an error.
105
+ * @returns {void}
106
+ * @tutorial ChannelMiddleware.onError
107
+ */
108
+ onError(): void;
109
+ /**
110
+ *
111
+ * Register middleware that fires after the action. This is passed the return value of the action.
112
+ * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed after invoking the action.
113
+ * @returns {void}
114
+ * @tutorial ChannelMiddleware.afterAction
115
+ */
116
+ afterAction(): void;
117
+ /**
118
+ *
119
+ * Remove an action by action name.
120
+ * @param {string} action - Name of the action to be removed.
121
+ * @returns {void}
122
+ * @tutorial Channel.remove
123
+ */
124
+ remove(): void;
125
+ /**
126
+ *
127
+ * Sets a default action. This is used any time an action that has not been registered is invoked.
128
+ * Default behavior if not set is to throw an error.
129
+ * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed when a client invokes an action name that has not been registered.
130
+ * @returns {void}
131
+ * @tutorial ChannelMiddleware.setDefaultAction
132
+ */
133
+ setDefaultAction(): void;
134
+ }
135
+ /**
136
+ * Instance created to enable use of a channel as a client. Allows for communication with the
137
+ * {@link Channel#ChannelProvider ChannelProvider} by invoking an action on the
138
+ * provider via {@link Channel#ChannelClient#dispatch dispatch} and to listen for communication
139
+ * from the provider by registering an action via {@link Channel#ChannelClient#register register}.
140
+ *
141
+ * ##### Constructor
142
+ * Returned by {@link InterApplicationBus.Channel.connect Channel.connect}.
143
+ *
144
+ * ##### Synchronous Methods
145
+ * * {@link Channel#ChannelClient#onDisconnection onDisconnection(listener)}
146
+ * * {@link Channel#ChannelClient#register register(action, listener)}
147
+ * * {@link Channel#ChannelClient#remove remove(action)}
148
+ *
149
+ * ##### Asynchronous Methods
150
+ * * {@link Channel#ChannelClient#disconnect disconnect()}
151
+ * * {@link Channel#ChannelClient#dispatch dispatch(action, payload)}
152
+ *
153
+ * ##### Middleware
154
+ * Middleware functions receive the following arguments: (action, payload, senderId).
155
+ * The return value of the middleware function will be passed on as the payload from beforeAction, to the action listener, to afterAction
156
+ * unless it is undefined, in which case the original payload is used. Middleware can be used for side effects.
157
+ * * {@link Channel#ChannelClient#setDefaultAction setDefaultAction(middleware)}
158
+ * * {@link Channel#ChannelClient#onError onError(middleware)}
159
+ * * {@link Channel#ChannelClient#beforeAction beforeAction(middleware)}
160
+ * * {@link Channel#ChannelClient#afterAction afterAction(middleware)}
161
+ *
162
+ * @hideconstructor
163
+ * @memberof! Channel#
164
+ * @property {InterApplicationBus.Channel~ProviderIdentity} providerIdentity a read-only provider identity
165
+ */
166
+ declare class ChannelClient {
167
+ /**
168
+ *
169
+ * Disconnect from the channel.
170
+ * @tutorial Channel.disconnect
171
+ * @returns {Promise<void>}
172
+ */
173
+ disconnect(): void;
174
+ /**
175
+ *
176
+ * Dispatch the given action to the channel provider. Returns a promise that resolves with the response from the provider for that action.
177
+ * @param {string} action - Name of the action to be invoked by the channel provider.
178
+ * @param {*} payload - Payload to be sent along with the action.
179
+ * @tutorial Channel.dispatch
180
+ * @returns {Promise<any>}
181
+ */
182
+ dispatch(): void;
183
+ /**
184
+ *
185
+ * Register an action to be called by the provider of the channel.
186
+ * @param {string} action - Name of the action to be registered for the channel provider to later invoke.
187
+ * @param {Channel#ChannelClient~Action} listener - Function representing the action to be taken on a provider dispatch.
188
+ * @returns {boolean}
189
+ * @tutorial Channel.register
190
+ */
191
+ register(): void;
192
+ /**
193
+ *
194
+ * Register middleware that fires before the action.
195
+ * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed before invoking the action.
196
+ * @returns {void}
197
+ * @tutorial ChannelMiddleware.beforeAction
198
+ */
199
+ beforeAction(): void;
200
+ /**
201
+ *
202
+ * Register a listener that is called on channel disconnection.
203
+ * It is passed the disconnection event of the disconnecting channel.
204
+ * @param {InterApplicationBus.Channel~ConnectionEvent} listener
205
+ * @returns {void}
206
+ * @tutorial Channel.onDisconnection
207
+ */
208
+ onDisconnection(): void;
209
+ /**
210
+ * Register an error handler. This is called before responding on any error.
211
+ * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed in case of an error.
212
+ * @returns {void}
213
+ * @tutorial ChannelMiddleware.onError
214
+ */
215
+ onError(): void;
216
+ /**
217
+ *
218
+ * Register middleware that fires after the action. This is passed the return value of the action.
219
+ * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed after invoking the action.
220
+ * @returns {void}
221
+ * @tutorial ChannelMiddleware.afterAction
222
+ */
223
+ afterAction(): void;
224
+ /**
225
+ *
226
+ * Remove an action by action name.
227
+ * @param {string} action - Name of the action to be removed.
228
+ * @returns {void}
229
+ * @tutorial Channel.remove
230
+ */
231
+ remove(): void;
232
+ /**
233
+ *
234
+ * Sets a default action. This is used any time an action that has not been registered is invoked.
235
+ * Default behavior if not set is to throw an error.
236
+ * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed when a client invokes an action name that has not been registered.
237
+ * @returns {void}
238
+ * @tutorial ChannelMiddleware.setDefaultAction
239
+ */
240
+ setDefaultAction(): void;
241
+ }
242
+ /**
243
+ * Channel action callback signature
244
+ * @callback Channel#ChannelProvider~Action
245
+ * @param {any} payload - Payload sent along with the message.
246
+ * @param {InterApplicationBus.Channel~ClientIdentity} identity - Identity of the sender.
247
+ */
248
+ /**
249
+ * Channel action callback signature
250
+ * @callback Channel#ChannelClient~Action
251
+ * @param {any} payload - Payload sent along with the message.
252
+ * @param {Identity} identity - Identity of the sender.
253
+ */
254
+ /**
255
+ * Middleware function signature
256
+ * @callback Channel#ChannelProvider~Middleware
257
+ * @param {string} action - Action to be invoked.
258
+ * @param {any} payload - Payload sent along with the message (or error for error middleware).
259
+ * @param {Identity} identity - Identity of the sender.
260
+ */
261
+ /**
262
+ * Middleware function signature
263
+ * @callback Channel#ChannelClient~Middleware
264
+ * @param {string} action - Action to be invoked.
265
+ * @param {any} payload - Payload sent along with the message (or error for error middleware).
266
+ * @param {Identity} identity - Identity of the sender.
267
+ */
268
+ /**
269
+ * Callback for the channel onConnection or onDisconnection. If it errors connection will be rejected.
270
+ * @callback Channel#ChannelProvider~ConnectionListener
271
+ * @param {InterApplicationBus.Channel~ClientIdentity} identity - Identity of the client attempting to connect to the channel.
272
+ * @param {any} payload - Payload sent with connection request.
273
+ */
274
+ /**
275
+ * Callback for onChannelConnect or onChannelDisconnect.
276
+ * @typedef {object} InterApplicationBus.Channel~ConnectionEvent
277
+ * @property {string} channelId - Identifier of the channel.
278
+ * @property {string} uuid - Channel provider uuid.
279
+ * @property {string} [name] - Channel provider name.
280
+ * @property {string} channelName - Name of the channel.
281
+ */
282
+ /**
283
+ * Protocol values for determining channel messaging strategy.
284
+ * @typedef {('classic' | 'rtc')} InterApplicationBus.Channel~MessagingProtocols - EXPERIMENTAL
285
+ *
286
+ */
287
+ /**
288
+ * Channel provider creation options.
289
+ * @typedef {object} InterApplicationBus.Channel~ChannelCreateOptions
290
+ * @property {InterApplicationBus.Channel~MessagingProtocols[]} [protocols=['classic']] - EXPERIMENTAL: Messaging protocols supported by the channel provider.
291
+ *
292
+ */
293
+ /**
294
+ * Options provided on a client connection to a channel.
295
+ * @typedef {object} InterApplicationBus.Channel~ChannelConnectOptions
296
+ * @property {InterApplicationBus.Channel~MessagingProtocols[]} [protocols=['classic']] - EXPERIMENTAL: Messaging protocols requested by the client, connection will fail if the provider protocols are not compatible.
297
+ * @property {any} [payload] - Payload to pass to ChannelProvider onConnection action.
298
+ * @property {boolean} [wait=true] - If true will wait for ChannelProvider to connect. If false will fail if ChannelProvider is not found.
299
+ *
300
+ */
301
+ /**
302
+ * Provider Identity.
303
+ * @typedef {object} InterApplicationBus.Channel~ProviderIdentity
304
+ * @property {string} uuid - Channel provider uuid.
305
+ * @property {string} [name] - Channel provider name.
306
+ * @property {string} channelId - Identifier of the channel.
307
+ * @property {boolean} [isExternal] - true if it's external connection.
308
+ * @property {string} channelName - Name of the channel.
309
+ *
310
+ */
311
+ /**
312
+ * Client Identity.
313
+ * @typedef {object} InterApplicationBus.Channel~ClientIdentity
314
+ * @property {string} uuid - Channel client uuid.
315
+ * @property {string} name - Channel client name.
316
+ * @property {string} endpointId - Unique identifier for a client, because there can be multiple clients at one name/uuid entity.
317
+ *
318
+ */
@@ -0,0 +1,376 @@
1
+ /* eslint-disable class-methods-use-this, @typescript-eslint/no-empty-function, @typescript-eslint/explicit-function-return-type */
2
+ /* todo IMPORTANT PLEASE READ!
3
+ * Make sure any edits to the Table of Contents in the following jsdoc comment are also made to both:
4
+ * 1. docs home page (/docs.README.md)
5
+ * 2. App config web page (https://openfin.co/documentation/application-config/)
6
+ */
7
+ const InterApplicationBus = {};
8
+ /**
9
+ * @namespace
10
+ * @desc The Channel namespace allows an OpenFin application to create a channel as a {@link Channel#ChannelProvider ChannelProvider},
11
+ * or connect to a channel as a {@link Channel#ChannelClient ChannelClient}. The "handshake" between the communication partners is
12
+ * 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
13
+ * provider and client can dispatch actions that have been registered on their opposites, and dispatch returns a promise that resolves with a payload from the other
14
+ * communication participant. There can be only one provider per channel, but many clients. Version `9.61.35.*` or later is required for both communication partners.
15
+ *
16
+ * ##### Asynchronous Methods
17
+ * * {@link InterApplicationBus.Channel.create create(channelName, options)}
18
+ * * {@link InterApplicationBus.Channel.connect connect(channelName, options)}
19
+ * * {@link InterApplicationBus.Channel.onChannelConnect onChannelConnect(listener)}
20
+ * * {@link InterApplicationBus.Channel.onChannelDisconnect onChannelDisconnect(listener)}
21
+ */
22
+ InterApplicationBus.Channel = function () { };
23
+ /**
24
+ *
25
+ * Create a new channel. Returns a promise that resolves with a {@link Channel#ChannelProvider ChannelProvider} instance for your channel.
26
+ * 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}.
30
+ * @tutorial Channel.create
31
+ */
32
+ InterApplicationBus.Channel.create = function () { };
33
+ /**
34
+ *
35
+ * Connect to a channel. Returns a promise for a {@link Channel#ChannelClient ChannelClient} instance for that channel.
36
+ * 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}.
40
+ * @tutorial Channel.connect
41
+ *
42
+ */
43
+ InterApplicationBus.Channel.connect = function (options) { };
44
+ /**
45
+ *
46
+ * Listens for channel connections.
47
+ * @param {InterApplicationBus.Channel~ConnectionEvent} listener - callback to execute.
48
+ * @returns {Promise<void>}
49
+ * @tutorial Channel.onChannelConnect
50
+ */
51
+ InterApplicationBus.Channel.onChannelConnect = function () { };
52
+ /**
53
+ *
54
+ * Listen for channel disconnections.
55
+ * @param {InterApplicationBus.Channel~ConnectionEvent} listener - callback to execute.
56
+ * @returns {Promise<void>}
57
+ * @tutorial Channel.onChannelDisconnect
58
+ */
59
+ InterApplicationBus.Channel.onChannelDisconnect = function () { };
60
+ /**
61
+ * 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
+ * a single client via {@link Channel#ChannelProvider#dispatch dispatch} or all clients via {@link Channel#ChannelProvider#publish publish}
63
+ * and to listen for communication from clients by registering an action via {@link Channel#ChannelProvider#register register}.
64
+ *
65
+ * ##### Constructor
66
+ *
67
+ * Returned by {@link InterApplicationBus.Channel.create Channel.create}.
68
+ *
69
+ * ##### Synchronous Methods
70
+ * * {@link Channel#ChannelProvider#onConnection onConnection(listener)}
71
+ * * {@link Channel#ChannelProvider#onDisconnection onDisconnection(listener)}
72
+ * * {@link Channel#ChannelProvider#publish publish(action, payload)}
73
+ * * {@link Channel#ChannelProvider#register register(action, listener)}
74
+ * * {@link Channel#ChannelProvider#remove remove(action)}
75
+ *
76
+ * ##### Asynchronous Methods
77
+ * * {@link Channel#ChannelProvider#destroy destroy()}
78
+ * * {@link Channel#ChannelProvider#dispatch dispatch(to, action, payload)}
79
+ *
80
+ * ##### Middleware
81
+ * Middleware functions receive the following arguments: (action, payload, senderId).
82
+ * The return value of the middleware function will be passed on as the payload from beforeAction, to the action listener, to afterAction
83
+ * unless it is undefined, in which case the most recently defined payload is used. Middleware can be used for side effects.
84
+ * * {@link Channel#ChannelProvider#setDefaultAction setDefaultAction(middleware)}
85
+ * * {@link Channel#ChannelProvider#onError onError(middleware)}
86
+ * * {@link Channel#ChannelProvider#beforeAction beforeAction(middleware)}
87
+ * * {@link Channel#ChannelProvider#afterAction afterAction(middleware)}
88
+ *
89
+ * @memberof! Channel#
90
+ * @hideconstructor
91
+ * @property {InterApplicationBus.Channel~ClientIdentity[]} connections a read-only array containing all the identities of connecting clients.
92
+ *
93
+ */
94
+ class ChannelProvider {
95
+ /**
96
+ *
97
+ * Destroy the channel.
98
+ * @returns {Promise<void>}
99
+ * @tutorial ChannelProvider.destroy
100
+ */
101
+ destroy() { }
102
+ /**
103
+ *
104
+ * Dispatch an action to a specified client. Returns a promise for the result of executing that action on the client side.
105
+ * @param {InterApplicationBus.Channel~ClientIdentity} to - Identity of the target client.
106
+ * @param {string} action - Name of the action to be invoked by the client.
107
+ * @param {*} payload - Payload to be sent along with the action.
108
+ * @returns {Promise<any>}
109
+ * @tutorial Channel.dispatch
110
+ */
111
+ dispatch() { }
112
+ /**
113
+ *
114
+ * Register an action to be called
115
+ * @param {string} action - Name of the action to be registered for channel clients to later invoke.
116
+ * @param {Channel#ChannelProvider~Action} listener - Function representing the action to be taken on a client dispatch.
117
+ * @returns {boolean} - Boolean representing the successful registration of the action.
118
+ * @tutorial Channel.register
119
+ */
120
+ register() { }
121
+ /**
122
+ *
123
+ * Publish an action and payload to every connected client.
124
+ * Synchronously returns an array of promises for each action (see dispatch).
125
+ * @param {string} action
126
+ * @param {*} payload
127
+ * @returns {Array<Promise<any>>}
128
+ * @tutorial ChannelProvider.publish
129
+ */
130
+ publish() { }
131
+ /**
132
+ *
133
+ * Register a listener that is called on every new client connection.
134
+ * It is passed the identity of the connecting client and a payload if it was provided to {@link Channel.connect}.
135
+ * If you wish to reject the connection, throw an error. Be sure to synchronously provide an onConnection upon receipt of the channelProvider
136
+ * to ensure all potential client connections are caught by the listener.
137
+ * @param {Channel#ChannelProvider~ConnectionListener} listener
138
+ * @returns {void}
139
+ * @tutorial ChannelProvider.onConnection
140
+ */
141
+ onConnection() { }
142
+ /**
143
+ *
144
+ * Register a listener that is called on every new client disconnection.
145
+ * It is passed the disconnection event of the disconnecting client.
146
+ * @param {InterApplicationBus.Channel~ConnectionEvent} listener
147
+ * @returns {void}
148
+ * @tutorial Channel.onDisconnection
149
+ */
150
+ onDisconnection() { }
151
+ /**
152
+ *
153
+ * Register middleware that fires before the action.
154
+ * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed before invoking the action.
155
+ * @returns {void}
156
+ * @tutorial ChannelMiddleware.beforeAction
157
+ */
158
+ beforeAction() { }
159
+ /**
160
+ *
161
+ * Register an error handler. This is called before responding on any error.
162
+ * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed in case of an error.
163
+ * @returns {void}
164
+ * @tutorial ChannelMiddleware.onError
165
+ */
166
+ onError() { }
167
+ /**
168
+ *
169
+ * Register middleware that fires after the action. This is passed the return value of the action.
170
+ * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed after invoking the action.
171
+ * @returns {void}
172
+ * @tutorial ChannelMiddleware.afterAction
173
+ */
174
+ afterAction() { }
175
+ /**
176
+ *
177
+ * Remove an action by action name.
178
+ * @param {string} action - Name of the action to be removed.
179
+ * @returns {void}
180
+ * @tutorial Channel.remove
181
+ */
182
+ remove() { }
183
+ /**
184
+ *
185
+ * Sets a default action. This is used any time an action that has not been registered is invoked.
186
+ * Default behavior if not set is to throw an error.
187
+ * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed when a client invokes an action name that has not been registered.
188
+ * @returns {void}
189
+ * @tutorial ChannelMiddleware.setDefaultAction
190
+ */
191
+ setDefaultAction() { }
192
+ }
193
+ /**
194
+ * Instance created to enable use of a channel as a client. Allows for communication with the
195
+ * {@link Channel#ChannelProvider ChannelProvider} by invoking an action on the
196
+ * provider via {@link Channel#ChannelClient#dispatch dispatch} and to listen for communication
197
+ * from the provider by registering an action via {@link Channel#ChannelClient#register register}.
198
+ *
199
+ * ##### Constructor
200
+ * Returned by {@link InterApplicationBus.Channel.connect Channel.connect}.
201
+ *
202
+ * ##### Synchronous Methods
203
+ * * {@link Channel#ChannelClient#onDisconnection onDisconnection(listener)}
204
+ * * {@link Channel#ChannelClient#register register(action, listener)}
205
+ * * {@link Channel#ChannelClient#remove remove(action)}
206
+ *
207
+ * ##### Asynchronous Methods
208
+ * * {@link Channel#ChannelClient#disconnect disconnect()}
209
+ * * {@link Channel#ChannelClient#dispatch dispatch(action, payload)}
210
+ *
211
+ * ##### Middleware
212
+ * Middleware functions receive the following arguments: (action, payload, senderId).
213
+ * The return value of the middleware function will be passed on as the payload from beforeAction, to the action listener, to afterAction
214
+ * unless it is undefined, in which case the original payload is used. Middleware can be used for side effects.
215
+ * * {@link Channel#ChannelClient#setDefaultAction setDefaultAction(middleware)}
216
+ * * {@link Channel#ChannelClient#onError onError(middleware)}
217
+ * * {@link Channel#ChannelClient#beforeAction beforeAction(middleware)}
218
+ * * {@link Channel#ChannelClient#afterAction afterAction(middleware)}
219
+ *
220
+ * @hideconstructor
221
+ * @memberof! Channel#
222
+ * @property {InterApplicationBus.Channel~ProviderIdentity} providerIdentity a read-only provider identity
223
+ */
224
+ class ChannelClient {
225
+ /**
226
+ *
227
+ * Disconnect from the channel.
228
+ * @tutorial Channel.disconnect
229
+ * @returns {Promise<void>}
230
+ */
231
+ disconnect() { }
232
+ /**
233
+ *
234
+ * Dispatch the given action to the channel provider. Returns a promise that resolves with the response from the provider for that action.
235
+ * @param {string} action - Name of the action to be invoked by the channel provider.
236
+ * @param {*} payload - Payload to be sent along with the action.
237
+ * @tutorial Channel.dispatch
238
+ * @returns {Promise<any>}
239
+ */
240
+ dispatch() { }
241
+ /**
242
+ *
243
+ * Register an action to be called by the provider of the channel.
244
+ * @param {string} action - Name of the action to be registered for the channel provider to later invoke.
245
+ * @param {Channel#ChannelClient~Action} listener - Function representing the action to be taken on a provider dispatch.
246
+ * @returns {boolean}
247
+ * @tutorial Channel.register
248
+ */
249
+ register() { }
250
+ /**
251
+ *
252
+ * Register middleware that fires before the action.
253
+ * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed before invoking the action.
254
+ * @returns {void}
255
+ * @tutorial ChannelMiddleware.beforeAction
256
+ */
257
+ beforeAction() { }
258
+ /**
259
+ *
260
+ * Register a listener that is called on channel disconnection.
261
+ * It is passed the disconnection event of the disconnecting channel.
262
+ * @param {InterApplicationBus.Channel~ConnectionEvent} listener
263
+ * @returns {void}
264
+ * @tutorial Channel.onDisconnection
265
+ */
266
+ onDisconnection() { }
267
+ /**
268
+ * Register an error handler. This is called before responding on any error.
269
+ * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed in case of an error.
270
+ * @returns {void}
271
+ * @tutorial ChannelMiddleware.onError
272
+ */
273
+ onError() { }
274
+ /**
275
+ *
276
+ * Register middleware that fires after the action. This is passed the return value of the action.
277
+ * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed after invoking the action.
278
+ * @returns {void}
279
+ * @tutorial ChannelMiddleware.afterAction
280
+ */
281
+ afterAction() { }
282
+ /**
283
+ *
284
+ * Remove an action by action name.
285
+ * @param {string} action - Name of the action to be removed.
286
+ * @returns {void}
287
+ * @tutorial Channel.remove
288
+ */
289
+ remove() { }
290
+ /**
291
+ *
292
+ * Sets a default action. This is used any time an action that has not been registered is invoked.
293
+ * Default behavior if not set is to throw an error.
294
+ * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed when a client invokes an action name that has not been registered.
295
+ * @returns {void}
296
+ * @tutorial ChannelMiddleware.setDefaultAction
297
+ */
298
+ setDefaultAction() { }
299
+ }
300
+ /**
301
+ * Channel action callback signature
302
+ * @callback Channel#ChannelProvider~Action
303
+ * @param {any} payload - Payload sent along with the message.
304
+ * @param {InterApplicationBus.Channel~ClientIdentity} identity - Identity of the sender.
305
+ */
306
+ /**
307
+ * Channel action callback signature
308
+ * @callback Channel#ChannelClient~Action
309
+ * @param {any} payload - Payload sent along with the message.
310
+ * @param {Identity} identity - Identity of the sender.
311
+ */
312
+ /**
313
+ * Middleware function signature
314
+ * @callback Channel#ChannelProvider~Middleware
315
+ * @param {string} action - Action to be invoked.
316
+ * @param {any} payload - Payload sent along with the message (or error for error middleware).
317
+ * @param {Identity} identity - Identity of the sender.
318
+ */
319
+ /**
320
+ * Middleware function signature
321
+ * @callback Channel#ChannelClient~Middleware
322
+ * @param {string} action - Action to be invoked.
323
+ * @param {any} payload - Payload sent along with the message (or error for error middleware).
324
+ * @param {Identity} identity - Identity of the sender.
325
+ */
326
+ /**
327
+ * Callback for the channel onConnection or onDisconnection. If it errors connection will be rejected.
328
+ * @callback Channel#ChannelProvider~ConnectionListener
329
+ * @param {InterApplicationBus.Channel~ClientIdentity} identity - Identity of the client attempting to connect to the channel.
330
+ * @param {any} payload - Payload sent with connection request.
331
+ */
332
+ /**
333
+ * Callback for onChannelConnect or onChannelDisconnect.
334
+ * @typedef {object} InterApplicationBus.Channel~ConnectionEvent
335
+ * @property {string} channelId - Identifier of the channel.
336
+ * @property {string} uuid - Channel provider uuid.
337
+ * @property {string} [name] - Channel provider name.
338
+ * @property {string} channelName - Name of the channel.
339
+ */
340
+ /**
341
+ * Protocol values for determining channel messaging strategy.
342
+ * @typedef {('classic' | 'rtc')} InterApplicationBus.Channel~MessagingProtocols - EXPERIMENTAL
343
+ *
344
+ */
345
+ /**
346
+ * Channel provider creation options.
347
+ * @typedef {object} InterApplicationBus.Channel~ChannelCreateOptions
348
+ * @property {InterApplicationBus.Channel~MessagingProtocols[]} [protocols=['classic']] - EXPERIMENTAL: Messaging protocols supported by the channel provider.
349
+ *
350
+ */
351
+ /**
352
+ * Options provided on a client connection to a channel.
353
+ * @typedef {object} InterApplicationBus.Channel~ChannelConnectOptions
354
+ * @property {InterApplicationBus.Channel~MessagingProtocols[]} [protocols=['classic']] - EXPERIMENTAL: Messaging protocols requested by the client, connection will fail if the provider protocols are not compatible.
355
+ * @property {any} [payload] - Payload to pass to ChannelProvider onConnection action.
356
+ * @property {boolean} [wait=true] - If true will wait for ChannelProvider to connect. If false will fail if ChannelProvider is not found.
357
+ *
358
+ */
359
+ /**
360
+ * Provider Identity.
361
+ * @typedef {object} InterApplicationBus.Channel~ProviderIdentity
362
+ * @property {string} uuid - Channel provider uuid.
363
+ * @property {string} [name] - Channel provider name.
364
+ * @property {string} channelId - Identifier of the channel.
365
+ * @property {boolean} [isExternal] - true if it's external connection.
366
+ * @property {string} channelName - Name of the channel.
367
+ *
368
+ */
369
+ /**
370
+ * Client Identity.
371
+ * @typedef {object} InterApplicationBus.Channel~ClientIdentity
372
+ * @property {string} uuid - Channel client uuid.
373
+ * @property {string} name - Channel client name.
374
+ * @property {string} endpointId - Unique identifier for a client, because there can be multiple clients at one name/uuid entity.
375
+ *
376
+ */