@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,48 @@
1
+ import Transport from '../../../transport/transport';
2
+ import { InitLayoutOptions, PresetLayoutOptions } from './shapes';
3
+ import { Base } from '../../base';
4
+ import Identity = OpenFin.Identity;
5
+ /**
6
+ * @lends Platform#Layout
7
+ */
8
+ export declare class Layout extends Base {
9
+ init: (options?: InitLayoutOptions) => Promise<Layout>;
10
+ identity: Identity;
11
+ private platform;
12
+ wire: Transport;
13
+ constructor(identity: OpenFin.Identity, wire: Transport);
14
+ /**
15
+ * Returns the configuration of the window's layout. Returns the same information that is returned for all windows in getSnapshot.
16
+ * @return { Promise<LayoutConfig> }
17
+ * @tutorial Layout.getConfig
18
+ */
19
+ getConfig(): Promise<any>;
20
+ /**
21
+ * Replaces a Platform window's layout with a new layout. Any views that were in the old layout but not the new layout
22
+ * will be destroyed.
23
+ * @param { LayoutConfig } layout New layout to implement in the target window.
24
+ * Please see explanation of a layout {@link https://developers.openfin.co/docs/platform-api#section-layout here}.
25
+ * @return { Promise<void> }
26
+ * @tutorial Layout.replace
27
+ */
28
+ replace: (layout: any) => Promise<void>;
29
+ /**
30
+ * Replaces the specified view with a view with the provided configuration.
31
+ * The old view is stripped of its listeners and either closed or attached to the provider window
32
+ * depending on `detachOnClose` view option.
33
+ * @param { Identity } viewToReplace Identity of the view to be replaced
34
+ * @param { View~options } newView Creation options of the new view.
35
+ * @return { Promise<void> }
36
+ * @tutorial Layout.replaceView
37
+ */
38
+ replaceView: (viewToReplace: Identity, newView: OpenFin.PlatformViewCreationOptions) => Promise<void>;
39
+ /**
40
+ * Replaces a Platform window's layout with a preset layout arrangement using the existing Views attached to the window.
41
+ * The preset options are `columns`, `grid`, `rows`, and `tabs`.
42
+ * @param { PresetLayoutOptions } options Mandatory object with `presetType` property that sets which preset layout arrangement to use.
43
+ * The preset options are `columns`, `grid`, `rows`, and `tabs`.
44
+ * @return { Promise<void> }
45
+ * @tutorial Layout.applyPreset
46
+ */
47
+ applyPreset: (options: PresetLayoutOptions) => Promise<void>;
48
+ }
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ /* eslint-disable no-undef, import/prefer-default-export */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Layout = void 0;
5
+ const validate_1 = require("../../../util/validate");
6
+ const common_utils_1 = require("../common-utils");
7
+ const base_1 = require("../../base");
8
+ /**
9
+ * @lends Platform#Layout
10
+ */
11
+ class Layout extends base_1.Base {
12
+ // eslint-disable-next-line no-shadow
13
+ constructor(identity, wire) {
14
+ super(wire);
15
+ /**
16
+ * Replaces a Platform window's layout with a new layout. Any views that were in the old layout but not the new layout
17
+ * will be destroyed.
18
+ * @param { LayoutConfig } layout New layout to implement in the target window.
19
+ * Please see explanation of a layout {@link https://developers.openfin.co/docs/platform-api#section-layout here}.
20
+ * @return { Promise<void> }
21
+ * @tutorial Layout.replace
22
+ */
23
+ this.replace = async (layout) => {
24
+ this.wire.sendAction('layout-replace').catch((e) => {
25
+ // don't expose
26
+ });
27
+ const client = await this.platform.getClient();
28
+ await client.dispatch('replace-layout', {
29
+ target: this.identity,
30
+ opts: { layout }
31
+ });
32
+ };
33
+ /**
34
+ * Replaces the specified view with a view with the provided configuration.
35
+ * The old view is stripped of its listeners and either closed or attached to the provider window
36
+ * depending on `detachOnClose` view option.
37
+ * @param { Identity } viewToReplace Identity of the view to be replaced
38
+ * @param { View~options } newView Creation options of the new view.
39
+ * @return { Promise<void> }
40
+ * @tutorial Layout.replaceView
41
+ */
42
+ this.replaceView = async (viewToReplace, newView) => {
43
+ this.wire.sendAction('layout-replace-view').catch((e) => {
44
+ // don't expose
45
+ });
46
+ const client = await this.platform.getClient();
47
+ await client.dispatch('replace-view', {
48
+ target: this.identity,
49
+ opts: { viewToReplace, newView }
50
+ });
51
+ };
52
+ /**
53
+ * Replaces a Platform window's layout with a preset layout arrangement using the existing Views attached to the window.
54
+ * The preset options are `columns`, `grid`, `rows`, and `tabs`.
55
+ * @param { PresetLayoutOptions } options Mandatory object with `presetType` property that sets which preset layout arrangement to use.
56
+ * The preset options are `columns`, `grid`, `rows`, and `tabs`.
57
+ * @return { Promise<void> }
58
+ * @tutorial Layout.applyPreset
59
+ */
60
+ this.applyPreset = async (options) => {
61
+ this.wire.sendAction('layout-apply-preset').catch((e) => {
62
+ // don't expose
63
+ });
64
+ const client = await this.platform.getClient();
65
+ const { presetType } = options;
66
+ if (!presetType || !common_utils_1.isValidPresetType(presetType)) {
67
+ throw new Error('Cannot apply preset layout, please include an applicable presetType property in the PresetLayoutOptions.');
68
+ }
69
+ await client.dispatch('apply-preset-layout', {
70
+ target: this.identity,
71
+ opts: { presetType }
72
+ });
73
+ };
74
+ const errorMsg = validate_1.validateIdentity(identity);
75
+ if (errorMsg) {
76
+ throw new Error(errorMsg);
77
+ }
78
+ this.identity = identity;
79
+ this.platform = this.fin.Platform.wrapSync({ uuid: identity.uuid });
80
+ if (identity.uuid === this.fin.me.uuid && identity.name === this.fin.me.name) {
81
+ this.init = this.fin.Platform.Layout.init;
82
+ }
83
+ }
84
+ /**
85
+ * Returns the configuration of the window's layout. Returns the same information that is returned for all windows in getSnapshot.
86
+ * @return { Promise<LayoutConfig> }
87
+ * @tutorial Layout.getConfig
88
+ */
89
+ async getConfig() {
90
+ this.wire.sendAction('layout-get-config').catch((e) => {
91
+ // don't expose
92
+ });
93
+ const client = await this.platform.getClient();
94
+ return client.dispatch('get-frame-snapshot', {
95
+ target: this.identity
96
+ });
97
+ }
98
+ }
99
+ exports.Layout = Layout;
@@ -0,0 +1,3 @@
1
+ export * from './Factory';
2
+ export * from './Instance';
3
+ export * from './shapes';
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
+ }
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./Factory"), exports);
14
+ __exportStar(require("./Instance"), exports);
15
+ __exportStar(require("./shapes"), exports);
@@ -0,0 +1,11 @@
1
+ import { LayoutPresetType } from '../../../shapes/LayoutPresetType';
2
+ export interface InitLayoutOptions {
3
+ containerId?: string;
4
+ }
5
+ export interface PresetLayoutOptions {
6
+ presetType: LayoutPresetType;
7
+ }
8
+ export interface DragPayload {
9
+ 'view-config': OpenFin.ViewCreationOptions;
10
+ 'view-identity': [string, string, string];
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,36 @@
1
+ import { Base } from '../base';
2
+ import { SnapshotSource } from './Instance';
3
+ /**
4
+ * @typedef { object } SnapshotProvider
5
+ * @property {getSnapshot} [getSnapshot]
6
+ * @property {applySnapshot} [applySnapshot]
7
+ */
8
+ /**
9
+ * @lends SnapshotSource
10
+ */
11
+ export default class SnapshotSourceModule extends Base {
12
+ /**
13
+ * Initializes a SnapshotSource with the getSnapshot and applySnapshot methods defined.
14
+ * @param { SnapshotProvider } provider
15
+ * @return { Promise<void> }
16
+ * @tutorial SnapshotSource.init
17
+ * @static
18
+ */
19
+ init<T = any>(provider: OpenFin.SnapshotProvider<T>): Promise<void>;
20
+ /**
21
+ * Synchronously returns a SnapshotSource object that represents the current SnapshotSource.
22
+ * @param { Identity } identity
23
+ * @return { SnapshotSource }
24
+ * @tutorial SnapshotSource.wrapSync
25
+ * @static
26
+ */
27
+ wrapSync(identity: OpenFin.ApplicationIdentity): SnapshotSource;
28
+ /**
29
+ * Asynchronously returns a SnapshotSource object that represents the current SnapshotSource.
30
+ * @param { Identity } identity
31
+ * @return { Promise.<SnapshotSource> }
32
+ * @tutorial SnapshotSource.wrap
33
+ * @static
34
+ */
35
+ wrap(identity: OpenFin.ApplicationIdentity): Promise<SnapshotSource>;
36
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const base_1 = require("../base");
4
+ const Instance_1 = require("./Instance");
5
+ const utils_1 = require("./utils");
6
+ /**
7
+ * @typedef { object } SnapshotProvider
8
+ * @property {getSnapshot} [getSnapshot]
9
+ * @property {applySnapshot} [applySnapshot]
10
+ */
11
+ /**
12
+ * @lends SnapshotSource
13
+ */
14
+ class SnapshotSourceModule extends base_1.Base {
15
+ /**
16
+ * Initializes a SnapshotSource with the getSnapshot and applySnapshot methods defined.
17
+ * @param { SnapshotProvider } provider
18
+ * @return { Promise<void> }
19
+ * @tutorial SnapshotSource.init
20
+ * @static
21
+ */
22
+ async init(provider) {
23
+ this.wire.sendAction('snapshot-source-init').catch((e) => {
24
+ // don't expose, analytics-only call
25
+ });
26
+ if (typeof provider !== 'object' ||
27
+ typeof provider.getSnapshot !== 'function' ||
28
+ typeof provider.applySnapshot !== 'function') {
29
+ throw new Error('you must pass in a valid SnapshotProvider');
30
+ }
31
+ const channel = await this.fin.InterApplicationBus.Channel.create(utils_1.getSnapshotSourceChannelName(fin.me.identity));
32
+ channel.register('get-snapshot', async () => {
33
+ const snapshot = await provider.getSnapshot();
34
+ return { snapshot };
35
+ });
36
+ channel.register('apply-snapshot', ({ snapshot }) => provider.applySnapshot(snapshot));
37
+ }
38
+ /**
39
+ * Synchronously returns a SnapshotSource object that represents the current SnapshotSource.
40
+ * @param { Identity } identity
41
+ * @return { SnapshotSource }
42
+ * @tutorial SnapshotSource.wrapSync
43
+ * @static
44
+ */
45
+ wrapSync(identity) {
46
+ this.wire.sendAction('snapshot-source-wrap-sync').catch((e) => {
47
+ // don't expose, analytics-only call
48
+ });
49
+ return new Instance_1.SnapshotSource(this.wire, identity);
50
+ }
51
+ /**
52
+ * Asynchronously returns a SnapshotSource object that represents the current SnapshotSource.
53
+ * @param { Identity } identity
54
+ * @return { Promise.<SnapshotSource> }
55
+ * @tutorial SnapshotSource.wrap
56
+ * @static
57
+ */
58
+ async wrap(identity) {
59
+ this.wire.sendAction('snapshot-source-wrap').catch((e) => {
60
+ // don't expose, analytics-only call
61
+ });
62
+ return this.wrapSync(identity);
63
+ }
64
+ }
65
+ exports.default = SnapshotSourceModule;
@@ -0,0 +1,30 @@
1
+ import { Base } from '../base';
2
+ import Transport from '../../transport/transport';
3
+ /**
4
+ * Enables configuring a SnapshotSource with custom getSnapshot and applySnapshot methods.
5
+ * @namespace
6
+ */
7
+ export declare class SnapshotSource<T = any> extends Base {
8
+ #private;
9
+ constructor(wire: Transport, id: OpenFin.ApplicationIdentity);
10
+ get identity(): OpenFin.ApplicationIdentity;
11
+ /**
12
+ * Method to determine if the SnapshotSource has been initialized.
13
+ *
14
+ * Use when the parent application is starting up to ensure the SnapshotSource is able to accept and
15
+ * apply a snapshot using the {@link SnapshotSource#applySnapshot applySnapshot} method.
16
+ * @return { Promise<void> }
17
+ * @tutorial SnapshotSource.ready
18
+ */
19
+ ready(): Promise<void>;
20
+ /**
21
+ * Call the SnapshotSource's getSnapshot method defined by {@link SnapshotSource#init init}.
22
+ * @return { Promise<any> }
23
+ */
24
+ getSnapshot(): Promise<T>;
25
+ /**
26
+ * Call the SnapshotSource's applySnapshot method defined by {@link SnapshotSource#init init}.
27
+ * @return { Promise<void> }
28
+ */
29
+ applySnapshot(snapshot: T): Promise<void>;
30
+ }
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
3
+ if (!privateMap.has(receiver)) {
4
+ throw new TypeError("attempted to set private field on non-instance");
5
+ }
6
+ privateMap.set(receiver, value);
7
+ return value;
8
+ };
9
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
10
+ if (!privateMap.has(receiver)) {
11
+ throw new TypeError("attempted to get private field on non-instance");
12
+ }
13
+ return privateMap.get(receiver);
14
+ };
15
+ var _identity, _getConnection, _getClient, _startConnection, _setUpConnectionListener;
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.SnapshotSource = void 0;
18
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
19
+ const base_1 = require("../base");
20
+ const utils_1 = require("./utils");
21
+ const connectionMap = new Map();
22
+ /**
23
+ * Enables configuring a SnapshotSource with custom getSnapshot and applySnapshot methods.
24
+ * @namespace
25
+ */
26
+ class SnapshotSource extends base_1.Base {
27
+ constructor(wire, id) {
28
+ super(wire);
29
+ _identity.set(this, void 0);
30
+ _getConnection.set(this, () => {
31
+ if (!connectionMap.has(this.identity.uuid)) {
32
+ connectionMap.set(this.identity.uuid, { eventFired: null, clientPromise: null });
33
+ }
34
+ return connectionMap.get(this.identity.uuid);
35
+ });
36
+ _getClient.set(this, () => {
37
+ if (!__classPrivateFieldGet(this, _getConnection).call(this).clientPromise) {
38
+ __classPrivateFieldGet(this, _getConnection).call(this).clientPromise = __classPrivateFieldGet(this, _startConnection).call(this);
39
+ }
40
+ return __classPrivateFieldGet(this, _getConnection).call(this).clientPromise;
41
+ });
42
+ _startConnection.set(this, async () => {
43
+ const channelName = utils_1.getSnapshotSourceChannelName(this.identity);
44
+ try {
45
+ if (!__classPrivateFieldGet(this, _getConnection).call(this).eventFired) {
46
+ await __classPrivateFieldGet(this, _setUpConnectionListener).call(this);
47
+ }
48
+ const client = await this.fin.InterApplicationBus.Channel.connect(channelName, { wait: false });
49
+ client.onDisconnection(() => {
50
+ __classPrivateFieldGet(this, _getConnection).call(this).clientPromise = null;
51
+ __classPrivateFieldGet(this, _getConnection).call(this).eventFired = null;
52
+ });
53
+ return client;
54
+ }
55
+ catch (e) {
56
+ __classPrivateFieldGet(this, _getConnection).call(this).clientPromise = null;
57
+ throw new Error("The targeted SnapshotSource is not currently initialized. Await this object's ready() method.");
58
+ }
59
+ });
60
+ _setUpConnectionListener.set(this, async () => {
61
+ const channelName = utils_1.getSnapshotSourceChannelName(this.identity);
62
+ let resolve;
63
+ let reject;
64
+ const eventFired = new Promise((y, n) => {
65
+ resolve = y;
66
+ reject = n;
67
+ });
68
+ __classPrivateFieldGet(this, _getConnection).call(this).eventFired = eventFired;
69
+ const listener = async (e) => {
70
+ try {
71
+ if (e.channelName === channelName) {
72
+ resolve();
73
+ await this.fin.InterApplicationBus.Channel.removeListener('connected', listener);
74
+ }
75
+ }
76
+ catch (err) {
77
+ reject(err);
78
+ }
79
+ };
80
+ await this.fin.InterApplicationBus.Channel.on('connected', listener);
81
+ });
82
+ __classPrivateFieldSet(this, _identity, id);
83
+ }
84
+ get identity() {
85
+ return __classPrivateFieldGet(this, _identity);
86
+ }
87
+ /**
88
+ * Method to determine if the SnapshotSource has been initialized.
89
+ *
90
+ * Use when the parent application is starting up to ensure the SnapshotSource is able to accept and
91
+ * apply a snapshot using the {@link SnapshotSource#applySnapshot applySnapshot} method.
92
+ * @return { Promise<void> }
93
+ * @tutorial SnapshotSource.ready
94
+ */
95
+ async ready() {
96
+ this.wire.sendAction('snapshot-source-ready').catch((e) => {
97
+ // don't expose, analytics-only call
98
+ });
99
+ // eslint-disable-next-line no-async-promise-executor
100
+ try {
101
+ // If getClient was already called before this, do we have a timing issue where the channel might have been created but we missed the event but this still fails?
102
+ await __classPrivateFieldGet(this, _getClient).call(this);
103
+ }
104
+ catch (e) {
105
+ // it was not running.
106
+ await __classPrivateFieldGet(this, _getConnection).call(this).eventFired;
107
+ }
108
+ }
109
+ /**
110
+ * Call the SnapshotSource's getSnapshot method defined by {@link SnapshotSource#init init}.
111
+ * @return { Promise<any> }
112
+ */
113
+ async getSnapshot() {
114
+ this.wire.sendAction('snapshot-source-get-snapshot').catch((e) => {
115
+ // don't expose, analytics-only call
116
+ });
117
+ const client = await __classPrivateFieldGet(this, _getClient).call(this);
118
+ const response = (await client.dispatch('get-snapshot'));
119
+ return (await response).snapshot;
120
+ }
121
+ /**
122
+ * Call the SnapshotSource's applySnapshot method defined by {@link SnapshotSource#init init}.
123
+ * @return { Promise<void> }
124
+ */
125
+ async applySnapshot(snapshot) {
126
+ this.wire.sendAction('snapshot-source-apply-snapshot').catch((e) => {
127
+ // don't expose, analytics-only call
128
+ });
129
+ const client = await __classPrivateFieldGet(this, _getClient).call(this);
130
+ return client.dispatch('apply-snapshot', { snapshot });
131
+ }
132
+ }
133
+ exports.SnapshotSource = SnapshotSource;
134
+ _identity = new WeakMap(), _getConnection = new WeakMap(), _getClient = new WeakMap(), _startConnection = new WeakMap(), _setUpConnectionListener = new WeakMap();
@@ -0,0 +1,3 @@
1
+ import SnapshotModule from './Factory';
2
+ export default SnapshotModule;
3
+ export * from './Instance';
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
+ }
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ const Factory_1 = require("./Factory");
14
+ exports.default = Factory_1.default;
15
+ __exportStar(require("./Instance"), exports);
@@ -0,0 +1 @@
1
+ export declare const getSnapshotSourceChannelName: (id: OpenFin.ApplicationIdentity) => string;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSnapshotSourceChannelName = void 0;
4
+ const channelPrefix = 'snapshot-source-provider-';
5
+ exports.getSnapshotSourceChannelName = (id) => `${channelPrefix}${id.uuid}`;
@@ -0,0 +1,6 @@
1
+ export interface ApplicationInfo {
2
+ isPlatform: boolean;
3
+ isRunning: boolean;
4
+ uuid: string;
5
+ parentUuid?: string;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import Identity = OpenFin.Identity;
2
+ export interface Entity {
3
+ type: string;
4
+ uuid: string;
5
+ }
6
+ export interface EntityInfo {
7
+ name: string;
8
+ uuid: string;
9
+ parent: Identity;
10
+ entityType: string;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });