@openfin/core 33.76.31 → 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.
Files changed (269) hide show
  1. package/OpenFin.d.ts +1 -1
  2. package/README.md +29 -4
  3. package/fin.d.ts +2 -2
  4. package/{src → out}/GlobalOpenFin.d.ts +1 -1
  5. package/out/mock-alpha.d.ts +16112 -0
  6. package/out/mock-beta.d.ts +16112 -0
  7. package/out/mock-public.d.ts +16112 -0
  8. package/out/mock.d.ts +16797 -0
  9. package/out/mock.js +17104 -0
  10. package/package.json +30 -23
  11. package/LICENSE +0 -13
  12. package/NOTICE +0 -16
  13. package/openfin-core-33.76.31.tgz +0 -0
  14. package/src/OpenFin.d.ts +0 -3080
  15. package/src/OpenFin.js +0 -2
  16. package/src/api/api-exposer/api-consumer.d.ts +0 -28
  17. package/src/api/api-exposer/api-consumer.js +0 -28
  18. package/src/api/api-exposer/api-exposer.d.ts +0 -35
  19. package/src/api/api-exposer/api-exposer.js +0 -38
  20. package/src/api/api-exposer/decorators.d.ts +0 -10
  21. package/src/api/api-exposer/decorators.js +0 -18
  22. package/src/api/api-exposer/index.d.ts +0 -4
  23. package/src/api/api-exposer/index.js +0 -20
  24. package/src/api/api-exposer/strategies/index.d.ts +0 -1
  25. package/src/api/api-exposer/strategies/index.js +0 -17
  26. package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.d.ts +0 -14
  27. package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.js +0 -20
  28. package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.d.ts +0 -20
  29. package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.js +0 -23
  30. package/src/api/api-exposer/strategies/openfin-channels/index.d.ts +0 -2
  31. package/src/api/api-exposer/strategies/openfin-channels/index.js +0 -18
  32. package/src/api/application/Factory.d.ts +0 -148
  33. package/src/api/application/Factory.js +0 -230
  34. package/src/api/application/Instance.d.ts +0 -321
  35. package/src/api/application/Instance.js +0 -453
  36. package/src/api/application/index.d.ts +0 -3
  37. package/src/api/application/index.js +0 -19
  38. package/src/api/base.d.ts +0 -48
  39. package/src/api/base.js +0 -177
  40. package/src/api/clipboard/index.d.ts +0 -92
  41. package/src/api/clipboard/index.js +0 -120
  42. package/src/api/events/application.d.ts +0 -146
  43. package/src/api/events/application.js +0 -2
  44. package/src/api/events/base.d.ts +0 -42
  45. package/src/api/events/base.js +0 -2
  46. package/src/api/events/channel.d.ts +0 -30
  47. package/src/api/events/channel.js +0 -2
  48. package/src/api/events/emitterMap.d.ts +0 -11
  49. package/src/api/events/emitterMap.js +0 -35
  50. package/src/api/events/eventAggregator.d.ts +0 -5
  51. package/src/api/events/eventAggregator.js +0 -35
  52. package/src/api/events/externalApplication.d.ts +0 -19
  53. package/src/api/events/externalApplication.js +0 -2
  54. package/src/api/events/frame.d.ts +0 -30
  55. package/src/api/events/frame.js +0 -2
  56. package/src/api/events/globalHotkey.d.ts +0 -20
  57. package/src/api/events/globalHotkey.js +0 -2
  58. package/src/api/events/platform.d.ts +0 -26
  59. package/src/api/events/platform.js +0 -2
  60. package/src/api/events/system.d.ts +0 -113
  61. package/src/api/events/system.js +0 -2
  62. package/src/api/events/typedEventEmitter.d.ts +0 -20
  63. package/src/api/events/typedEventEmitter.js +0 -2
  64. package/src/api/events/view.d.ts +0 -82
  65. package/src/api/events/view.js +0 -2
  66. package/src/api/events/webcontents.d.ts +0 -266
  67. package/src/api/events/webcontents.js +0 -2
  68. package/src/api/events/window.d.ts +0 -352
  69. package/src/api/events/window.js +0 -2
  70. package/src/api/external-application/Factory.d.ts +0 -27
  71. package/src/api/external-application/Factory.js +0 -40
  72. package/src/api/external-application/Instance.d.ts +0 -102
  73. package/src/api/external-application/Instance.js +0 -109
  74. package/src/api/external-application/index.d.ts +0 -3
  75. package/src/api/external-application/index.js +0 -19
  76. package/src/api/fin.d.ts +0 -51
  77. package/src/api/fin.js +0 -42
  78. package/src/api/frame/Factory.d.ts +0 -37
  79. package/src/api/frame/Factory.js +0 -69
  80. package/src/api/frame/Instance.d.ts +0 -123
  81. package/src/api/frame/Instance.js +0 -130
  82. package/src/api/frame/index.d.ts +0 -3
  83. package/src/api/frame/index.js +0 -19
  84. package/src/api/global-hotkey/index.d.ts +0 -38
  85. package/src/api/global-hotkey/index.js +0 -64
  86. package/src/api/interappbus/channel/channel.d.ts +0 -28
  87. package/src/api/interappbus/channel/channel.js +0 -77
  88. package/src/api/interappbus/channel/channels-docs.d.ts +0 -340
  89. package/src/api/interappbus/channel/channels-docs.js +0 -398
  90. package/src/api/interappbus/channel/client.d.ts +0 -24
  91. package/src/api/interappbus/channel/client.js +0 -89
  92. package/src/api/interappbus/channel/connection-manager.d.ts +0 -29
  93. package/src/api/interappbus/channel/connection-manager.js +0 -246
  94. package/src/api/interappbus/channel/index.d.ts +0 -25
  95. package/src/api/interappbus/channel/index.js +0 -169
  96. package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +0 -13
  97. package/src/api/interappbus/channel/protocols/classic/message-receiver.js +0 -73
  98. package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +0 -24
  99. package/src/api/interappbus/channel/protocols/classic/strategy.js +0 -101
  100. package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +0 -20
  101. package/src/api/interappbus/channel/protocols/combined/strategy.js +0 -58
  102. package/src/api/interappbus/channel/protocols/index.d.ts +0 -47
  103. package/src/api/interappbus/channel/protocols/index.js +0 -2
  104. package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +0 -10
  105. package/src/api/interappbus/channel/protocols/protocol-manager.js +0 -43
  106. package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +0 -25
  107. package/src/api/interappbus/channel/protocols/rtc/endpoint.js +0 -141
  108. package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +0 -30
  109. package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +0 -130
  110. package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +0 -24
  111. package/src/api/interappbus/channel/protocols/rtc/strategy.js +0 -85
  112. package/src/api/interappbus/channel/protocols/strategy-types.d.ts +0 -13
  113. package/src/api/interappbus/channel/protocols/strategy-types.js +0 -2
  114. package/src/api/interappbus/channel/protocols/strategy.d.ts +0 -17
  115. package/src/api/interappbus/channel/protocols/strategy.js +0 -2
  116. package/src/api/interappbus/channel/provider.d.ts +0 -34
  117. package/src/api/interappbus/channel/provider.js +0 -166
  118. package/src/api/interappbus/index.d.ts +0 -85
  119. package/src/api/interappbus/index.js +0 -175
  120. package/src/api/interop/Factory.d.ts +0 -37
  121. package/src/api/interop/Factory.js +0 -76
  122. package/src/api/interop/InteropBroker.d.ts +0 -437
  123. package/src/api/interop/InteropBroker.js +0 -1085
  124. package/src/api/interop/InteropClient.d.ts +0 -278
  125. package/src/api/interop/InteropClient.js +0 -459
  126. package/src/api/interop/SessionContextGroupBroker.d.ts +0 -27
  127. package/src/api/interop/SessionContextGroupBroker.js +0 -108
  128. package/src/api/interop/SessionContextGroupClient.d.ts +0 -21
  129. package/src/api/interop/SessionContextGroupClient.js +0 -86
  130. package/src/api/interop/fdc3/PrivateChannelClient.d.ts +0 -20
  131. package/src/api/interop/fdc3/PrivateChannelClient.js +0 -90
  132. package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +0 -55
  133. package/src/api/interop/fdc3/PrivateChannelProvider.js +0 -276
  134. package/src/api/interop/fdc3/fdc3-1.2.d.ts +0 -208
  135. package/src/api/interop/fdc3/fdc3-1.2.js +0 -438
  136. package/src/api/interop/fdc3/fdc3-2.0.d.ts +0 -301
  137. package/src/api/interop/fdc3/fdc3-2.0.js +0 -482
  138. package/src/api/interop/fdc3/fdc3.d.ts +0 -12
  139. package/src/api/interop/fdc3/fdc3.js +0 -35
  140. package/src/api/interop/fdc3/overrideCheck.d.ts +0 -4
  141. package/src/api/interop/fdc3/overrideCheck.js +0 -32
  142. package/src/api/interop/fdc3/shapes/fdc3v1.d.ts +0 -53
  143. package/src/api/interop/fdc3/shapes/fdc3v1.js +0 -4
  144. package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +0 -75
  145. package/src/api/interop/fdc3/shapes/fdc3v2.js +0 -2
  146. package/src/api/interop/fdc3/utils.d.ts +0 -45
  147. package/src/api/interop/fdc3/utils.js +0 -239
  148. package/src/api/interop/fdc3/versions.d.ts +0 -1
  149. package/src/api/interop/fdc3/versions.js +0 -2
  150. package/src/api/interop/index.d.ts +0 -4
  151. package/src/api/interop/index.js +0 -20
  152. package/src/api/interop/utils.d.ts +0 -18
  153. package/src/api/interop/utils.js +0 -61
  154. package/src/api/me.d.ts +0 -40
  155. package/src/api/me.js +0 -134
  156. package/src/api/platform/Factory.d.ts +0 -115
  157. package/src/api/platform/Factory.js +0 -184
  158. package/src/api/platform/Instance.d.ts +0 -150
  159. package/src/api/platform/Instance.js +0 -332
  160. package/src/api/platform/common-utils.d.ts +0 -7
  161. package/src/api/platform/common-utils.js +0 -16
  162. package/src/api/platform/index.d.ts +0 -3
  163. package/src/api/platform/index.js +0 -19
  164. package/src/api/platform/layout/Factory.d.ts +0 -114
  165. package/src/api/platform/layout/Factory.js +0 -174
  166. package/src/api/platform/layout/Instance.d.ts +0 -57
  167. package/src/api/platform/layout/Instance.js +0 -126
  168. package/src/api/platform/layout/controllers/layout-content-cache.d.ts +0 -9
  169. package/src/api/platform/layout/controllers/layout-content-cache.js +0 -54
  170. package/src/api/platform/layout/controllers/layout-entities-controller.d.ts +0 -119
  171. package/src/api/platform/layout/controllers/layout-entities-controller.js +0 -287
  172. package/src/api/platform/layout/entities/layout-entities.d.ts +0 -235
  173. package/src/api/platform/layout/entities/layout-entities.js +0 -312
  174. package/src/api/platform/layout/entities/shapes.d.ts +0 -6
  175. package/src/api/platform/layout/entities/shapes.js +0 -2
  176. package/src/api/platform/layout/index.d.ts +0 -2
  177. package/src/api/platform/layout/index.js +0 -18
  178. package/src/api/platform/layout/layout.constants.d.ts +0 -1
  179. package/src/api/platform/layout/layout.constants.js +0 -4
  180. package/src/api/platform/layout/shapes.d.ts +0 -16
  181. package/src/api/platform/layout/shapes.js +0 -2
  182. package/src/api/platform/layout/utils/layout-traversal.d.ts +0 -4
  183. package/src/api/platform/layout/utils/layout-traversal.js +0 -65
  184. package/src/api/platform/provider.d.ts +0 -163
  185. package/src/api/platform/provider.js +0 -2
  186. package/src/api/snapshot-source/Factory.d.ts +0 -38
  187. package/src/api/snapshot-source/Factory.js +0 -66
  188. package/src/api/snapshot-source/Instance.d.ts +0 -31
  189. package/src/api/snapshot-source/Instance.js +0 -132
  190. package/src/api/snapshot-source/index.d.ts +0 -3
  191. package/src/api/snapshot-source/index.js +0 -19
  192. package/src/api/snapshot-source/utils.d.ts +0 -2
  193. package/src/api/snapshot-source/utils.js +0 -6
  194. package/src/api/system/index.d.ts +0 -517
  195. package/src/api/system/index.js +0 -895
  196. package/src/api/view/Factory.d.ts +0 -50
  197. package/src/api/view/Factory.js +0 -103
  198. package/src/api/view/Instance.d.ts +0 -487
  199. package/src/api/view/Instance.js +0 -557
  200. package/src/api/view/index.d.ts +0 -3
  201. package/src/api/view/index.js +0 -19
  202. package/src/api/webcontents/main.d.ts +0 -32
  203. package/src/api/webcontents/main.js +0 -156
  204. package/src/api/window/Factory.d.ts +0 -45
  205. package/src/api/window/Factory.js +0 -91
  206. package/src/api/window/Instance.d.ts +0 -1090
  207. package/src/api/window/Instance.js +0 -1349
  208. package/src/api/window/index.d.ts +0 -3
  209. package/src/api/window/index.js +0 -19
  210. package/src/browser.d.ts +0 -10
  211. package/src/browser.js +0 -36
  212. package/src/environment/browser.d.ts +0 -29
  213. package/src/environment/browser.js +0 -60
  214. package/src/environment/environment.d.ts +0 -33
  215. package/src/environment/environment.js +0 -4
  216. package/src/environment/mockEnvironment.d.ts +0 -27
  217. package/src/environment/mockEnvironment.js +0 -61
  218. package/src/environment/node-env.d.ts +0 -29
  219. package/src/environment/node-env.js +0 -72
  220. package/src/fdc3.d.ts +0 -3
  221. package/src/fdc3.js +0 -9
  222. package/src/mock.d.ts +0 -3
  223. package/src/mock.js +0 -18
  224. package/src/namespaces.d.ts +0 -21
  225. package/src/namespaces.js +0 -24
  226. package/src/shapes/ERROR_BOX_TYPES.d.ts +0 -1
  227. package/src/shapes/ERROR_BOX_TYPES.js +0 -2
  228. package/src/shapes/WebOptions.d.ts +0 -13
  229. package/src/shapes/WebOptions.js +0 -2
  230. package/src/shapes/WindowOptions.d.ts +0 -43
  231. package/src/shapes/WindowOptions.js +0 -2
  232. package/src/shapes/protocol.d.ts +0 -200
  233. package/src/shapes/protocol.js +0 -2
  234. package/src/transport/mockWire.d.ts +0 -11
  235. package/src/transport/mockWire.js +0 -26
  236. package/src/transport/transport-errors.d.ts +0 -31
  237. package/src/transport/transport-errors.js +0 -79
  238. package/src/transport/transport.d.ts +0 -73
  239. package/src/transport/transport.js +0 -219
  240. package/src/transport/wire.d.ts +0 -77
  241. package/src/transport/wire.js +0 -36
  242. package/src/util/asyncFilter.d.ts +0 -1
  243. package/src/util/asyncFilter.js +0 -7
  244. package/src/util/channel-api-relay.d.ts +0 -13
  245. package/src/util/channel-api-relay.js +0 -47
  246. package/src/util/errors.d.ts +0 -10
  247. package/src/util/errors.js +0 -12
  248. package/src/util/exhaustive.d.ts +0 -1
  249. package/src/util/exhaustive.js +0 -7
  250. package/src/util/http.d.ts +0 -11
  251. package/src/util/http.js +0 -90
  252. package/src/util/inaccessibleObject.d.ts +0 -2
  253. package/src/util/inaccessibleObject.js +0 -49
  254. package/src/util/lazy.d.ts +0 -34
  255. package/src/util/lazy.js +0 -54
  256. package/src/util/normalize-config.d.ts +0 -3
  257. package/src/util/normalize-config.js +0 -52
  258. package/src/util/promises.d.ts +0 -5
  259. package/src/util/promises.js +0 -27
  260. package/src/util/ref-counter.d.ts +0 -7
  261. package/src/util/ref-counter.js +0 -52
  262. package/src/util/reversible-map.d.ts +0 -11
  263. package/src/util/reversible-map.js +0 -49
  264. package/src/util/runtimeVersioning.d.ts +0 -3
  265. package/src/util/runtimeVersioning.js +0 -25
  266. package/src/util/utilTypes.d.ts +0 -8
  267. package/src/util/utilTypes.js +0 -2
  268. package/src/util/validate.d.ts +0 -3
  269. package/src/util/validate.js +0 -11
@@ -1,86 +0,0 @@
1
- "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- 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");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- 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");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _SessionContextGroupClient_clientPromise;
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const base_1 = require("../base");
16
- const utils_1 = require("./utils");
17
- class SessionContextGroupClient extends base_1.Base {
18
- constructor(wire, client, id) {
19
- super(wire);
20
- _SessionContextGroupClient_clientPromise.set(this, void 0);
21
- this.id = id;
22
- __classPrivateFieldSet(this, _SessionContextGroupClient_clientPromise, client, "f");
23
- }
24
- /**
25
- * Sets a context for the session context group.
26
- * @param { Context } context - New context to set.
27
- * @return { Promise<void> }
28
- * @tutorial interop.setContext
29
- */
30
- async setContext(context) {
31
- this.wire.sendAction('interop-session-context-group-set-context').catch((e) => {
32
- // don't expose, analytics-only call
33
- });
34
- const client = await __classPrivateFieldGet(this, _SessionContextGroupClient_clientPromise, "f");
35
- return client.dispatch(`sessionContextGroup:setContext-${this.id}`, {
36
- sessionContextGroupId: this.id,
37
- context
38
- });
39
- }
40
- async getCurrentContext(type) {
41
- this.wire.sendAction('interop-session-context-group-get-context').catch((e) => {
42
- // don't expose, analytics-only call
43
- });
44
- const client = await __classPrivateFieldGet(this, _SessionContextGroupClient_clientPromise, "f");
45
- return client.dispatch(`sessionContextGroup:getContext-${this.id}`, {
46
- sessionContextGroupId: this.id,
47
- type
48
- });
49
- }
50
- async addContextHandler(contextHandler, contextType) {
51
- this.wire.sendAction('interop-session-context-group-add-handler').catch((e) => {
52
- // don't expose, analytics-only call
53
- });
54
- if (typeof contextHandler !== 'function') {
55
- throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
56
- }
57
- const client = await __classPrivateFieldGet(this, _SessionContextGroupClient_clientPromise, "f");
58
- let handlerId;
59
- if (contextType) {
60
- handlerId = `sessionContextHandler:invoke-${this.id}-${contextType}-${(0, utils_1.generateId)()}`;
61
- }
62
- else {
63
- handlerId = `sessionContextHandler:invoke-${this.id}`;
64
- }
65
- client.register(handlerId, (0, utils_1.wrapContextHandler)(contextHandler, handlerId));
66
- await client.dispatch(`sessionContextGroup:handlerAdded-${this.id}`, { handlerId, contextType });
67
- return { unsubscribe: await this.createUnsubscribeCb(handlerId) };
68
- }
69
- async createUnsubscribeCb(handlerId) {
70
- const client = await __classPrivateFieldGet(this, _SessionContextGroupClient_clientPromise, "f");
71
- return async () => {
72
- client.remove(handlerId);
73
- await client.dispatch(`sessionContextGroup:handlerRemoved-${this.id}`, { handlerId });
74
- };
75
- }
76
- getUserInstance() {
77
- return {
78
- id: this.id,
79
- setContext: (0, utils_1.wrapInTryCatch)(this.setContext.bind(this), 'Failed to set context: '),
80
- getCurrentContext: (0, utils_1.wrapInTryCatch)(this.getCurrentContext.bind(this), 'Failed to get context: '),
81
- addContextHandler: (0, utils_1.wrapInTryCatch)(this.addContextHandler.bind(this), 'Failed to add context handler: ')
82
- };
83
- }
84
- }
85
- exports.default = SessionContextGroupClient;
86
- _SessionContextGroupClient_clientPromise = new WeakMap();
@@ -1,20 +0,0 @@
1
- import type * as OpenFin from '../../../OpenFin';
2
- import type { Listener, Context, ContextHandler } from './shapes/fdc3v2';
3
- type HandlerId = string;
4
- export declare class PrivateChannelClient {
5
- id: string;
6
- client: OpenFin.ChannelClient;
7
- listeners: Map<HandlerId, Listener>;
8
- constructor(client: OpenFin.ChannelClient, id: string);
9
- broadcast(context: Context): Promise<void>;
10
- getCurrentContext(contextType?: string): Promise<Context | null>;
11
- addContextListener(contextType: string | null, handler: ContextHandler): Promise<Listener>;
12
- private createNonStandardUnsubscribeCb;
13
- private createContextUnsubscribeCb;
14
- onAddContextListener(handler: (contextType?: string) => void): Listener;
15
- onDisconnect(handler: () => void): Listener;
16
- onUnsubscribe(handler: (contextType?: string) => void): Listener;
17
- cleanUpAllSubs(): Promise<void>;
18
- disconnect(): Promise<void>;
19
- }
20
- export {};
@@ -1,90 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PrivateChannelClient = void 0;
4
- const utils_1 = require("../utils");
5
- class PrivateChannelClient {
6
- constructor(client, id) {
7
- this.id = id;
8
- this.client = client;
9
- this.listeners = new Map();
10
- }
11
- async broadcast(context) {
12
- return this.client.dispatch('broadcast', { context });
13
- }
14
- async getCurrentContext(contextType) {
15
- return this.client.dispatch('getCurrentContext', { contextType });
16
- }
17
- async addContextListener(contextType, handler) {
18
- if (typeof handler !== 'function') {
19
- throw new Error("Non-function argument passed to the second parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
20
- }
21
- let handlerId;
22
- if (contextType) {
23
- handlerId = `contextHandler:invoke-${this.id}-${contextType}-${(0, utils_1.generateId)()}`;
24
- }
25
- else {
26
- handlerId = `contextHandler:invoke-${this.id}-${(0, utils_1.generateId)()}`;
27
- }
28
- this.client.register(handlerId, (0, utils_1.wrapContextHandler)(handler, handlerId));
29
- const listener = { unsubscribe: await this.createContextUnsubscribeCb(handlerId) };
30
- this.listeners.set(handlerId, listener);
31
- await this.client.dispatch(`contextHandlerAdded`, { handlerId, contextType });
32
- return listener;
33
- }
34
- createNonStandardUnsubscribeCb(handlerId) {
35
- return async () => {
36
- this.client.remove(handlerId);
37
- this.listeners.delete(handlerId);
38
- await this.client.dispatch('nonStandardHandlerRemoved', { handlerId });
39
- };
40
- }
41
- createContextUnsubscribeCb(handlerId) {
42
- return async () => {
43
- this.client.remove(handlerId);
44
- this.listeners.delete(handlerId);
45
- await this.client.dispatch('contextHandlerRemoved', { handlerId });
46
- };
47
- }
48
- onAddContextListener(handler) {
49
- const handlerId = `onContextHandlerAdded:invoke-${this.id}-${(0, utils_1.generateId)()}`;
50
- this.client.register(handlerId, handler);
51
- const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
52
- this.listeners.set(handlerId, listener);
53
- this.client.dispatch(`onAddContextHandlerAdded`, { handlerId });
54
- return listener;
55
- }
56
- onDisconnect(handler) {
57
- const handlerId = `onDisconnect:invoke-${this.id}-${(0, utils_1.generateId)()}`;
58
- this.client.register(handlerId, handler);
59
- const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
60
- this.listeners.set(handlerId, listener);
61
- this.client.dispatch(`onDisconnectHandlerAdded`, { handlerId });
62
- return listener;
63
- }
64
- onUnsubscribe(handler) {
65
- const handlerId = `onUnsubscribe:invoke-${this.id}-${(0, utils_1.generateId)()}`;
66
- this.client.register(handlerId, handler);
67
- const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
68
- this.listeners.set(handlerId, listener);
69
- this.client.dispatch(`onUnsubscribeHandlerAdded`, { handlerId });
70
- return listener;
71
- }
72
- async cleanUpAllSubs() {
73
- const listenerUnsubscribers = Array.from(this.listeners.keys());
74
- listenerUnsubscribers.forEach((handlerId) => {
75
- this.client.remove(handlerId);
76
- this.listeners.delete(handlerId);
77
- });
78
- }
79
- async disconnect() {
80
- try {
81
- await this.client.dispatch('clientDisconnecting');
82
- await this.cleanUpAllSubs();
83
- await this.client.disconnect();
84
- }
85
- catch (error) {
86
- throw new Error(error.message);
87
- }
88
- }
89
- }
90
- exports.PrivateChannelClient = PrivateChannelClient;
@@ -1,55 +0,0 @@
1
- import type * as OpenFin from '../../../OpenFin';
2
- type ChannelProvider = OpenFin.ChannelProvider;
3
- type HandlerId = string;
4
- type ContextType = string;
5
- interface PrivateChannelClientState {
6
- clientIdentity: OpenFin.ClientIdentity;
7
- handlerIdsByContextTypes: Map<ContextType, HandlerId[]>;
8
- globalHandler: HandlerId | undefined;
9
- onAddContextListenerHandlerId: HandlerId | undefined;
10
- onUnsubscribeHandlerId: HandlerId | undefined;
11
- onDisconnectHandlerId: HandlerId | undefined;
12
- }
13
- export declare class PrivateChannelProvider {
14
- id: string;
15
- private provider;
16
- private clients;
17
- private contextByContextType;
18
- private lastContext;
19
- constructor(provider: ChannelProvider, id: string);
20
- private getClientState;
21
- registerListeners(): void;
22
- broadcast(payload: {
23
- context: OpenFin.Context;
24
- }, broadcasterClientIdentity: OpenFin.ClientIdentity): void;
25
- getCurrentContext(payload: {
26
- contextType?: string;
27
- }, senderClientIdentity: OpenFin.ClientIdentity): OpenFin.Context | null;
28
- contextHandlerAdded(payload: {
29
- handlerId: HandlerId;
30
- contextType?: string;
31
- }, senderClientIdentity: OpenFin.ClientIdentity): void;
32
- contextHandlerRemoved(payload: {
33
- handlerId: HandlerId;
34
- }, removingClientIdentity: OpenFin.ClientIdentity): Promise<void>;
35
- nonStandardHandlerRemoved(payload: {
36
- handlerId: HandlerId;
37
- }, id: OpenFin.ClientIdentity): void;
38
- onAddContextHandlerAdded(payload: {
39
- handlerId: HandlerId;
40
- }, senderClientIdentity: OpenFin.ClientIdentity): void;
41
- onDisconnectHandlerAdded(payload: {
42
- handlerId: HandlerId;
43
- }, id: OpenFin.ClientIdentity): void;
44
- onUnsubscribeHandlerAdded(payload: {
45
- handlerId: HandlerId;
46
- }, id: OpenFin.ClientIdentity): void;
47
- removeClient(disconnectingClientIdentity: OpenFin.ClientIdentity): void;
48
- fireOnDisconnectForOtherClients(disconnectingClientIdentity: OpenFin.ClientIdentity): Promise<void>;
49
- unsubscribeAll(clientIdentity: OpenFin.ClientIdentity): Promise<void>;
50
- handleClientDisconnecting(disconnectingClientIdentity: OpenFin.ClientIdentity): Promise<void>;
51
- registerNewClient(clientIdentity: OpenFin.ClientIdentity): void;
52
- getConnectedClients(): Promise<PrivateChannelClientState[]>;
53
- static init(channelProvider: OpenFin.ChannelProvider, id: string): PrivateChannelProvider;
54
- }
55
- export {};
@@ -1,276 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PrivateChannelProvider = void 0;
4
- const InteropBroker_1 = require("../InteropBroker");
5
- class PrivateChannelProvider {
6
- constructor(provider, id) {
7
- this.provider = provider;
8
- this.id = id;
9
- this.clients = new Map();
10
- this.registerListeners();
11
- this.contextByContextType = new Map();
12
- this.lastContext = undefined;
13
- this.provider.onConnection((clientIdentity) => this.registerNewClient(clientIdentity));
14
- this.provider.onDisconnection(async (clientIdentity) => {
15
- const { endpointId } = clientIdentity;
16
- if (this.clients.has(endpointId)) {
17
- await this.handleClientDisconnecting(clientIdentity);
18
- }
19
- if ((await this.provider.getAllClientInfo()).length === 0) {
20
- this.provider.destroy();
21
- }
22
- });
23
- }
24
- getClientState(id) {
25
- return this.clients.get(id.endpointId);
26
- }
27
- registerListeners() {
28
- this.provider.register('broadcast', this.broadcast.bind(this));
29
- this.provider.register('getCurrentContext', this.getCurrentContext.bind(this));
30
- this.provider.register('contextHandlerAdded', this.contextHandlerAdded.bind(this));
31
- this.provider.register('contextHandlerRemoved', this.contextHandlerRemoved.bind(this));
32
- this.provider.register('nonStandardHandlerRemoved', this.nonStandardHandlerRemoved.bind(this));
33
- this.provider.register('onAddContextHandlerAdded', this.onAddContextHandlerAdded.bind(this));
34
- this.provider.register('onDisconnectHandlerAdded', this.onDisconnectHandlerAdded.bind(this));
35
- this.provider.register('onUnsubscribeHandlerAdded', this.onUnsubscribeHandlerAdded.bind(this));
36
- this.provider.register('clientDisconnecting', (payload, clientIdentity) => {
37
- this.handleClientDisconnecting(clientIdentity);
38
- });
39
- }
40
- broadcast(payload, broadcasterClientIdentity) {
41
- const { context } = payload;
42
- const broadcasterClientState = this.getClientState(broadcasterClientIdentity);
43
- if (!broadcasterClientState) {
44
- throw new Error(`Client with Identity: ${broadcasterClientIdentity.uuid} ${broadcasterClientIdentity.name}, tried to call broadcast, is not connected to this Private Channel`);
45
- }
46
- const contextIntegrityCheckResult = InteropBroker_1.InteropBroker.checkContextIntegrity(context);
47
- if (contextIntegrityCheckResult.isValid === false) {
48
- throw new Error(`Failed to broadcast - bad Context. Reason: ${contextIntegrityCheckResult.reason}. Context: ${JSON.stringify(context)}`);
49
- }
50
- this.contextByContextType.set(context.type, context);
51
- this.lastContext = context;
52
- Array.from(this.clients.values()).forEach((currClientState) => {
53
- const handlerIdsForContextType = currClientState.handlerIdsByContextTypes.get(context.type);
54
- if (handlerIdsForContextType) {
55
- handlerIdsForContextType.forEach((handlerId) => {
56
- this.provider.dispatch(currClientState.clientIdentity, handlerId, context);
57
- });
58
- }
59
- if (currClientState.globalHandler) {
60
- this.provider.dispatch(currClientState.clientIdentity, currClientState.globalHandler, context);
61
- }
62
- });
63
- }
64
- getCurrentContext(payload, senderClientIdentity) {
65
- const { contextType } = payload;
66
- const clientState = this.getClientState(senderClientIdentity);
67
- if (!clientState) {
68
- throw new Error(`Client with Identity: ${senderClientIdentity.uuid} ${senderClientIdentity.name}, tried to call getCurrentContext, is not connected to this Private Channel`);
69
- }
70
- if (contextType !== undefined) {
71
- const currentContext = this.contextByContextType.get(contextType);
72
- if (currentContext)
73
- return currentContext;
74
- return null;
75
- }
76
- return this.lastContext ? this.lastContext : null;
77
- }
78
- contextHandlerAdded(payload, senderClientIdentity) {
79
- const { handlerId, contextType } = payload;
80
- const senderClientState = this.getClientState(senderClientIdentity);
81
- if (!senderClientState) {
82
- throw new Error(`Client with Identity: ${senderClientIdentity.uuid} ${senderClientIdentity.name}, tried to call addContextListener, is not connected to this Private Channel`);
83
- }
84
- if (contextType) {
85
- const currentHandlersList = senderClientState.handlerIdsByContextTypes.get(contextType) || [];
86
- senderClientState.handlerIdsByContextTypes.set(contextType, [...currentHandlersList, handlerId]);
87
- }
88
- else {
89
- senderClientState.globalHandler = handlerId;
90
- }
91
- Array.from(this.clients.values()).forEach((currClientState) => {
92
- if (currClientState.clientIdentity.endpointId !== senderClientIdentity.endpointId &&
93
- currClientState.onAddContextListenerHandlerId) {
94
- this.provider.dispatch(currClientState.clientIdentity, currClientState.onAddContextListenerHandlerId, contextType);
95
- }
96
- });
97
- }
98
- async contextHandlerRemoved(payload, removingClientIdentity) {
99
- // MC: Made this removal async to ensure that onUnsubscribe handlers are hit before anything else happens.
100
- const { handlerId } = payload;
101
- const removingClientState = this.getClientState(removingClientIdentity);
102
- if (removingClientState) {
103
- let contextType;
104
- if (removingClientState.globalHandler === handlerId) {
105
- removingClientState.globalHandler = undefined;
106
- }
107
- else {
108
- for (const [currContextType, handlersIds] of removingClientState.handlerIdsByContextTypes) {
109
- const index = handlersIds.indexOf(handlerId);
110
- if (index > -1) {
111
- handlersIds.splice(index, 1);
112
- contextType = currContextType;
113
- }
114
- }
115
- }
116
- // getting only valid client connections here, it is possible we haven't removed a disconnected client from the map yet
117
- // so we need to ensure we don't dispatch to any disconnected client
118
- // TODO: Take a look at our client disconnection logic and see if we can handle client disconnection cleanly
119
- const clientsToDispatchTo = await this.getConnectedClients();
120
- const dispatchPromises = clientsToDispatchTo.map(async (otherClientState) => {
121
- const { clientIdentity, clientIdentity: { endpointId }, onUnsubscribeHandlerId } = otherClientState;
122
- if (endpointId !== removingClientIdentity.endpointId && onUnsubscribeHandlerId) {
123
- await this.provider.dispatch(clientIdentity, onUnsubscribeHandlerId, contextType);
124
- }
125
- });
126
- try {
127
- await Promise.all(dispatchPromises);
128
- }
129
- catch (error) {
130
- console.error(`Problem when attempting to dispatch to onUnsubscribeHandlers. Error: ${error} Removing Client: ${handlerId}. uuid: ${removingClientIdentity.uuid}. name: ${removingClientIdentity.name}. endpointId: ${removingClientIdentity.endpointId}`);
131
- throw new Error(error);
132
- }
133
- }
134
- else {
135
- console.warn(`Trying to remove a handler from a client that isn't mapped. handlerId: ${handlerId}. uuid: ${removingClientIdentity.uuid}. name: ${removingClientIdentity.name}. endpointId: ${removingClientIdentity.endpointId}.`);
136
- }
137
- }
138
- nonStandardHandlerRemoved(payload, id) {
139
- const { handlerId } = payload;
140
- const clientState = this.getClientState(id);
141
- if (clientState) {
142
- if (clientState.onDisconnectHandlerId === handlerId) {
143
- clientState.onDisconnectHandlerId = undefined;
144
- }
145
- else if (clientState.onAddContextListenerHandlerId === handlerId) {
146
- clientState.onAddContextListenerHandlerId = undefined;
147
- }
148
- else if (clientState.onUnsubscribeHandlerId === handlerId) {
149
- clientState.onUnsubscribeHandlerId = undefined;
150
- }
151
- }
152
- else {
153
- console.warn(`Trying to remove a handler from a client that isn't mapped. handlerId: ${handlerId}. clientIdentity: ${id}`);
154
- }
155
- }
156
- onAddContextHandlerAdded(payload, senderClientIdentity) {
157
- const clientState = this.getClientState(senderClientIdentity);
158
- const { handlerId } = payload;
159
- if (!clientState) {
160
- throw new Error(`Client with Identity: ${senderClientIdentity.uuid} ${senderClientIdentity.name}, tried to call onAddContextListener, is not connected to this Private Channel`);
161
- }
162
- clientState.onAddContextListenerHandlerId = handlerId;
163
- // FDC3 Spec says that the added listener should fire for all previously-registered addContextListeners from the other client
164
- Array.from(this.clients.values()).forEach((otherClientState) => {
165
- if (otherClientState.clientIdentity.endpointId !== senderClientIdentity.endpointId) {
166
- Array.from(otherClientState.handlerIdsByContextTypes.keys()).forEach((subscribedContextType) => {
167
- this.provider.dispatch(senderClientIdentity, handlerId, subscribedContextType);
168
- });
169
- }
170
- });
171
- }
172
- onDisconnectHandlerAdded(payload, id) {
173
- const clientState = this.getClientState(id);
174
- const { handlerId } = payload;
175
- if (!clientState) {
176
- throw new Error(`Client with Identity: ${id.uuid} ${id.name}, tried to call onDisconnect, is not connected to this Private Channel`);
177
- }
178
- clientState.onDisconnectHandlerId = handlerId;
179
- }
180
- onUnsubscribeHandlerAdded(payload, id) {
181
- const clientState = this.getClientState(id);
182
- const { handlerId } = payload;
183
- if (!clientState) {
184
- throw new Error(`Client with Identity: ${id.uuid} ${id.name}, tried to call onUnsubscribe, is not connected to this Private Channel`);
185
- }
186
- clientState.onUnsubscribeHandlerId = handlerId;
187
- }
188
- removeClient(disconnectingClientIdentity) {
189
- const disconnectingClientState = this.getClientState(disconnectingClientIdentity);
190
- if (!disconnectingClientState) {
191
- throw new Error(`Client with Identity: ${disconnectingClientIdentity.uuid} ${disconnectingClientIdentity.name}, tried to call disconnect, is not connected to this Private Channel`);
192
- }
193
- disconnectingClientState.handlerIdsByContextTypes.clear();
194
- this.clients.delete(disconnectingClientIdentity.endpointId);
195
- }
196
- async fireOnDisconnectForOtherClients(disconnectingClientIdentity) {
197
- // TODO: call onDisconnect Handler of the other client only.
198
- // CURRENTLY, just calling the onDisconnect handler for all the other clients. Once we limit it to just one other client, we can eliminate all the iteration code.
199
- const { endpointId } = disconnectingClientIdentity;
200
- // getting only valid client connections here, it is possible we haven't removed a disconnected client from the map yet
201
- // so we need to ensure we don't dispatch to any disconnected client
202
- // TODO: Take a look at our client disconnection logic and see if we can handle client disconnection cleanly
203
- const clientsToDispatchTo = await this.getConnectedClients();
204
- const dispatchPromises = clientsToDispatchTo.map(async (otherClientState) => {
205
- const { clientIdentity: { endpointId: otherClientEndpointId }, onDisconnectHandlerId } = otherClientState;
206
- if (otherClientEndpointId !== endpointId && onDisconnectHandlerId) {
207
- await this.provider.dispatch(otherClientState.clientIdentity, onDisconnectHandlerId);
208
- }
209
- });
210
- try {
211
- await Promise.all(dispatchPromises);
212
- }
213
- catch (error) {
214
- console.error(`Problem when attempting to dispatch to onDisconnectHandlers. Error: ${error} Disconnecting Client: uuid: ${disconnectingClientIdentity.uuid}. name: ${disconnectingClientIdentity.name}. endpointId: ${disconnectingClientIdentity.endpointId}`);
215
- throw new Error(error);
216
- }
217
- }
218
- async unsubscribeAll(clientIdentity) {
219
- const { endpointId } = clientIdentity;
220
- const state = this.clients.get(endpointId);
221
- if (state) {
222
- const contextTypeHandlerIds = Array.from(state.handlerIdsByContextTypes.values()).flat();
223
- const globalHandlerId = state.globalHandler;
224
- if (contextTypeHandlerIds.length > 0) {
225
- const unsubPromises = contextTypeHandlerIds.map(async (handlerId) => {
226
- return this.contextHandlerRemoved({ handlerId }, clientIdentity);
227
- });
228
- try {
229
- await Promise.all(unsubPromises);
230
- }
231
- catch (error) {
232
- console.error(error.message);
233
- }
234
- }
235
- if (globalHandlerId) {
236
- try {
237
- await this.contextHandlerRemoved({ handlerId: globalHandlerId }, clientIdentity);
238
- }
239
- catch (error) {
240
- console.error(error.message);
241
- }
242
- }
243
- }
244
- }
245
- async handleClientDisconnecting(disconnectingClientIdentity) {
246
- await this.unsubscribeAll(disconnectingClientIdentity);
247
- this.removeClient(disconnectingClientIdentity);
248
- await this.fireOnDisconnectForOtherClients(disconnectingClientIdentity);
249
- }
250
- registerNewClient(clientIdentity) {
251
- if (!this.clients.has(clientIdentity.endpointId)) {
252
- const clientSubscriptionState = {
253
- clientIdentity,
254
- handlerIdsByContextTypes: new Map(),
255
- globalHandler: undefined,
256
- onAddContextListenerHandlerId: undefined,
257
- onUnsubscribeHandlerId: undefined,
258
- onDisconnectHandlerId: undefined
259
- };
260
- this.clients.set(clientIdentity.endpointId, clientSubscriptionState);
261
- }
262
- }
263
- async getConnectedClients() {
264
- const allClientInfo = await this.provider.getAllClientInfo();
265
- return Array.from(this.clients.values()).filter((clientState) => {
266
- const { uuid, name } = clientState.clientIdentity;
267
- return allClientInfo.some((clientInfo) => {
268
- return name === clientInfo.name && uuid === clientInfo.uuid;
269
- });
270
- });
271
- }
272
- static init(channelProvider, id) {
273
- return new PrivateChannelProvider(channelProvider, id);
274
- }
275
- }
276
- exports.PrivateChannelProvider = PrivateChannelProvider;