@openfin/core 25.68.30 → 25.70.2

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 (199) hide show
  1. package/OpenFin.d.ts +30 -826
  2. package/README.md +12 -2
  3. package/package.json +1 -1
  4. package/src/api/application/Factory.d.ts +145 -145
  5. package/src/api/application/Factory.js +229 -229
  6. package/src/api/application/Instance.d.ts +301 -302
  7. package/src/api/application/Instance.js +412 -412
  8. package/src/api/application/index.d.ts +3 -3
  9. package/src/api/application/index.js +15 -15
  10. package/src/api/base.d.ts +43 -43
  11. package/src/api/base.js +177 -177
  12. package/src/api/clipboard/index.d.ts +69 -69
  13. package/src/api/clipboard/index.js +88 -88
  14. package/src/api/events/application.d.ts +69 -0
  15. package/src/api/events/application.js +2 -0
  16. package/src/api/events/base.d.ts +17 -0
  17. package/src/api/events/base.js +2 -0
  18. package/src/api/events/channel.d.ts +10 -11
  19. package/src/api/events/channel.js +2 -2
  20. package/src/api/events/emitterMap.d.ts +11 -11
  21. package/src/api/events/emitterMap.js +35 -35
  22. package/src/api/events/eventAggregator.d.ts +5 -5
  23. package/src/api/events/eventAggregator.js +43 -43
  24. package/src/api/events/externalApplication.d.ts +5 -0
  25. package/src/api/events/externalApplication.js +2 -0
  26. package/src/api/events/frame.d.ts +9 -0
  27. package/src/api/events/frame.js +2 -0
  28. package/src/api/events/globalHotkey.d.ts +10 -0
  29. package/src/api/events/globalHotkey.js +2 -0
  30. package/src/api/events/platform.d.ts +18 -0
  31. package/src/api/events/platform.js +2 -0
  32. package/src/api/events/system.d.ts +22 -0
  33. package/src/api/events/system.js +2 -0
  34. package/src/api/events/view.d.ts +56 -0
  35. package/src/api/events/view.js +2 -0
  36. package/src/api/events/webcontents.d.ts +48 -0
  37. package/src/api/events/webcontents.js +2 -0
  38. package/src/api/events/window.d.ts +176 -0
  39. package/src/api/events/window.js +2 -0
  40. package/src/api/external-application/Factory.d.ts +26 -26
  41. package/src/api/external-application/Factory.js +40 -40
  42. package/src/api/external-application/Instance.d.ts +101 -102
  43. package/src/api/external-application/Instance.js +109 -109
  44. package/src/api/external-application/index.d.ts +3 -3
  45. package/src/api/external-application/index.js +15 -15
  46. package/src/api/fin.d.ts +49 -49
  47. package/src/api/fin.js +43 -43
  48. package/src/api/frame/Factory.d.ts +36 -36
  49. package/src/api/frame/Factory.js +69 -69
  50. package/src/api/frame/Instance.d.ts +121 -121
  51. package/src/api/frame/Instance.js +130 -130
  52. package/src/api/frame/index.d.ts +3 -3
  53. package/src/api/frame/index.js +15 -15
  54. package/src/api/global-hotkey/index.d.ts +38 -38
  55. package/src/api/global-hotkey/index.js +58 -58
  56. package/src/api/interappbus/channel/channel.d.ts +26 -26
  57. package/src/api/interappbus/channel/channel.js +77 -77
  58. package/src/api/interappbus/channel/channels-docs.d.ts +318 -318
  59. package/src/api/interappbus/channel/channels-docs.js +376 -376
  60. package/src/api/interappbus/channel/client.d.ts +22 -22
  61. package/src/api/interappbus/channel/client.js +84 -84
  62. package/src/api/interappbus/channel/connection-manager.d.ts +28 -28
  63. package/src/api/interappbus/channel/connection-manager.js +244 -244
  64. package/src/api/interappbus/channel/index.d.ts +22 -23
  65. package/src/api/interappbus/channel/index.js +121 -121
  66. package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +13 -13
  67. package/src/api/interappbus/channel/protocols/classic/message-receiver.js +73 -73
  68. package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +22 -22
  69. package/src/api/interappbus/channel/protocols/classic/strategy.js +84 -84
  70. package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +20 -20
  71. package/src/api/interappbus/channel/protocols/combined/strategy.js +58 -58
  72. package/src/api/interappbus/channel/protocols/index.d.ts +44 -44
  73. package/src/api/interappbus/channel/protocols/index.js +2 -2
  74. package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +10 -10
  75. package/src/api/interappbus/channel/protocols/protocol-manager.js +43 -43
  76. package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +23 -23
  77. package/src/api/interappbus/channel/protocols/rtc/endpoint.js +135 -135
  78. package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +30 -30
  79. package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +131 -131
  80. package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +22 -22
  81. package/src/api/interappbus/channel/protocols/rtc/strategy.js +87 -87
  82. package/src/api/interappbus/channel/protocols/strategy-types.d.ts +13 -13
  83. package/src/api/interappbus/channel/protocols/strategy-types.js +2 -2
  84. package/src/api/interappbus/channel/protocols/strategy.d.ts +15 -15
  85. package/src/api/interappbus/channel/protocols/strategy.js +2 -2
  86. package/src/api/interappbus/channel/provider.d.ts +31 -31
  87. package/src/api/interappbus/channel/provider.js +160 -160
  88. package/src/api/interappbus/index.d.ts +85 -86
  89. package/src/api/interappbus/index.js +175 -175
  90. package/src/api/interop/Factory.d.ts +37 -37
  91. package/src/api/interop/Factory.js +54 -54
  92. package/src/api/interop/InteropBroker.d.ts +363 -363
  93. package/src/api/interop/InteropBroker.js +914 -914
  94. package/src/api/interop/InteropClient.d.ts +268 -268
  95. package/src/api/interop/InteropClient.js +450 -450
  96. package/src/api/interop/SessionContextGroupBroker.d.ts +26 -26
  97. package/src/api/interop/SessionContextGroupBroker.js +107 -107
  98. package/src/api/interop/SessionContextGroupClient.d.ts +20 -20
  99. package/src/api/interop/SessionContextGroupClient.js +85 -85
  100. package/src/api/interop/fdc3/fdc3-1.2.d.ts +187 -187
  101. package/src/api/interop/fdc3/fdc3-1.2.js +385 -385
  102. package/src/api/interop/fdc3/fdc3.js +17 -17
  103. package/src/api/interop/fdc3/utils.d.ts +6 -6
  104. package/src/api/interop/fdc3/utils.js +17 -17
  105. package/src/api/interop/index.d.ts +4 -4
  106. package/src/api/interop/index.js +16 -16
  107. package/src/api/interop/utils.d.ts +11 -11
  108. package/src/api/interop/utils.js +36 -36
  109. package/src/api/me.d.ts +38 -35
  110. package/src/api/me.js +128 -60
  111. package/src/api/platform/Factory.d.ts +109 -109
  112. package/src/api/platform/Factory.js +188 -188
  113. package/src/api/platform/Instance.d.ts +122 -122
  114. package/src/api/platform/Instance.js +298 -298
  115. package/src/api/platform/common-utils.d.ts +6 -6
  116. package/src/api/platform/common-utils.js +16 -16
  117. package/src/api/platform/index.d.ts +3 -3
  118. package/src/api/platform/index.js +15 -15
  119. package/src/api/platform/layout/Factory.d.ts +108 -108
  120. package/src/api/platform/layout/Factory.js +189 -189
  121. package/src/api/platform/layout/Instance.d.ts +49 -49
  122. package/src/api/platform/layout/Instance.js +99 -99
  123. package/src/api/platform/layout/index.d.ts +2 -2
  124. package/src/api/platform/layout/index.js +14 -14
  125. package/src/api/platform/layout/shapes.d.ts +11 -0
  126. package/src/api/{window → platform/layout}/shapes.js +2 -2
  127. package/src/api/snapshot-source/Factory.d.ts +36 -36
  128. package/src/api/snapshot-source/Factory.js +65 -65
  129. package/src/api/snapshot-source/Instance.d.ts +30 -30
  130. package/src/api/snapshot-source/Instance.js +134 -134
  131. package/src/api/snapshot-source/index.d.ts +3 -3
  132. package/src/api/snapshot-source/index.js +15 -15
  133. package/src/api/snapshot-source/utils.d.ts +1 -1
  134. package/src/api/snapshot-source/utils.js +5 -5
  135. package/src/api/system/index.d.ts +960 -961
  136. package/src/api/system/index.js +1241 -1241
  137. package/src/api/view/Factory.d.ts +49 -49
  138. package/src/api/view/Factory.js +103 -103
  139. package/src/api/view/Instance.d.ts +387 -380
  140. package/src/api/view/Instance.js +422 -415
  141. package/src/api/view/index.d.ts +3 -3
  142. package/src/api/view/index.js +15 -15
  143. package/src/api/webcontents/main.d.ts +36 -36
  144. package/src/api/webcontents/main.js +82 -82
  145. package/src/api/window/Factory.d.ts +44 -44
  146. package/src/api/window/Factory.js +91 -91
  147. package/src/api/window/Instance.d.ts +972 -966
  148. package/src/api/window/Instance.js +1209 -1202
  149. package/src/api/window/index.d.ts +3 -5
  150. package/src/api/window/index.js +15 -17
  151. package/src/environment/environment.d.ts +28 -25
  152. package/src/environment/environment.js +4 -4
  153. package/src/environment/node-env.d.ts +25 -26
  154. package/src/environment/node-env.js +64 -64
  155. package/src/environment/openfin-env.d.ts +29 -30
  156. package/src/environment/openfin-env.js +107 -107
  157. package/src/mock.d.ts +3 -3
  158. package/src/mock.js +91 -90
  159. package/src/shapes/ERROR_BOX_TYPES.d.ts +1 -0
  160. package/src/shapes/ERROR_BOX_TYPES.js +2 -0
  161. package/src/shapes/WebOptions.d.ts +12 -0
  162. package/src/shapes/WebOptions.js +2 -0
  163. package/src/shapes/WindowOptions.d.ts +42 -0
  164. package/src/shapes/WindowOptions.js +2 -0
  165. package/src/shapes/protocol.d.ts +178 -0
  166. package/src/shapes/protocol.js +2 -0
  167. package/src/transport/fin_store.d.ts +4 -4
  168. package/src/transport/fin_store.js +16 -16
  169. package/src/transport/transport-errors.d.ts +18 -18
  170. package/src/transport/transport-errors.js +37 -37
  171. package/src/transport/transport.d.ts +56 -43
  172. package/src/transport/transport.js +181 -181
  173. package/src/transport/wire.d.ts +71 -11
  174. package/src/transport/wire.js +32 -32
  175. package/src/util/asyncFilter.d.ts +1 -1
  176. package/src/util/asyncFilter.js +7 -7
  177. package/src/util/errors.d.ts +9 -5
  178. package/src/util/errors.js +11 -11
  179. package/src/util/exhaustive.d.ts +1 -1
  180. package/src/util/exhaustive.js +7 -7
  181. package/src/util/http.d.ts +11 -11
  182. package/src/util/http.js +83 -83
  183. package/src/util/normalize-config.d.ts +3 -5
  184. package/src/util/normalize-config.js +47 -47
  185. package/src/util/promises.d.ts +5 -5
  186. package/src/util/promises.js +27 -27
  187. package/src/util/ref-counter.d.ts +7 -7
  188. package/src/util/ref-counter.js +51 -51
  189. package/src/util/runtimeVersioning.d.ts +3 -3
  190. package/src/util/runtimeVersioning.js +25 -25
  191. package/src/util/utilTypes.d.ts +8 -8
  192. package/src/util/utilTypes.js +2 -2
  193. package/src/util/validate.d.ts +3 -3
  194. package/src/util/validate.js +11 -11
  195. package/docs.README(OLD).md +0 -82
  196. package/resources/win/OpenFinRVM.exe +0 -0
  197. package/src/api/window/bounds-changed.d.ts +0 -10
  198. package/src/api/window/bounds-changed.js +0 -6
  199. package/src/api/window/shapes.d.ts +0 -13
@@ -1,298 +1,298 @@
1
- "use strict";
2
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
3
- if (!privateMap.has(receiver)) {
4
- throw new TypeError("attempted to get private field on non-instance");
5
- }
6
- return privateMap.get(receiver);
7
- };
8
- var _connectToProvider;
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.Platform = void 0;
11
- const base_1 = require("../base");
12
- const validate_1 = require("../../util/validate");
13
- // Reuse clients to avoid overwriting already-registered client in provider
14
- const clientMap = new Map();
15
- /** Manages the life cycle of windows and views in the application.
16
- *
17
- * Enables taking snapshots of itself and applying them to restore a previous configuration
18
- * as well as listen to <a href="tutorial-Platform.EventEmitter.html">platform events</a>.
19
- * @namespace
20
- */
21
- class Platform extends base_1.EmitterBase {
22
- // eslint-disable-next-line no-shadow
23
- constructor(identity, channel) {
24
- // we piggyback off of application event emitter because from the core's perspective platform is just an app.
25
- super(channel.wire, 'application', identity.uuid);
26
- this.getClient = (identity) => {
27
- this.wire.sendAction('platform-get-client', this.identity).catch((e) => {
28
- // don't expose
29
- });
30
- const target = identity || this.identity;
31
- const { uuid } = target;
32
- if (!clientMap.has(uuid)) {
33
- const clientPromise = __classPrivateFieldGet(this, _connectToProvider).call(this, uuid);
34
- clientMap.set(uuid, clientPromise);
35
- }
36
- // we set it above
37
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
38
- return clientMap.get(uuid);
39
- };
40
- _connectToProvider.set(this, async (uuid) => {
41
- try {
42
- const channelName = `custom-frame-${uuid}`;
43
- const client = await this._channel.connect(channelName, { wait: false });
44
- client.onDisconnection(() => {
45
- clientMap.delete(uuid);
46
- });
47
- return client;
48
- }
49
- catch (e) {
50
- clientMap.delete(uuid);
51
- throw new Error('The targeted Platform is not currently running. Listen for application-started event for the given Uuid.');
52
- }
53
- });
54
- // Deprecated (renamed)
55
- this.launchLegacyManifest = this.launchContentManifest;
56
- const errorMsg = validate_1.validateIdentity(identity);
57
- if (errorMsg) {
58
- throw new Error(errorMsg);
59
- }
60
- this._channel = channel;
61
- this.identity = { uuid: identity.uuid };
62
- this.Layout = this.fin.Platform.Layout;
63
- this.Application = this.fin.Application.wrapSync(this.identity);
64
- }
65
- /**
66
- * Creates a new view and attaches it to a specified target window.
67
- * @param { View~options } viewOptions View creation options
68
- * @param { Identity } [target] The window to which the new view is to be attached. If no target, create a view in a new window.
69
- * @param { Identity } [targetView] If provided, the new view will be added to the same tabstrip as targetView.
70
- * @return { Promise<View> }
71
- * @tutorial Platform.createView
72
- */
73
- async createView(viewOptions, target, targetView) {
74
- this.wire.sendAction('platform-create-view', this.identity).catch((e) => {
75
- // don't expose
76
- });
77
- const client = await this.getClient();
78
- const response = await client.dispatch('create-view', {
79
- target,
80
- opts: viewOptions,
81
- targetView
82
- });
83
- if (!response || validate_1.validateIdentity(response.identity)) {
84
- throw new Error(`When overwriting the createView call, please return an object that has a valid 'identity' property: ${JSON.stringify(response)}`);
85
- }
86
- return this.fin.View.wrapSync(response.identity);
87
- }
88
- /**
89
- * Creates a new Window.
90
- * @param { Window~options } options Window creation options
91
- * @return { Promise<_Window> }
92
- * @tutorial Platform.createWindow
93
- */
94
- async createWindow(options) {
95
- this.wire.sendAction('platform-create-window', this.identity).catch((e) => {
96
- // don't expose
97
- });
98
- const client = await this.getClient();
99
- if (!options.reason) {
100
- options.reason = 'api-call';
101
- }
102
- const response = await client.dispatch('create-view-container', options);
103
- if (!response || validate_1.validateIdentity(response.identity)) {
104
- throw new Error(`When overwriting the createWindow call, please return an object that has a valid 'identity' property: ${JSON.stringify(response)}`);
105
- }
106
- const { identity } = response;
107
- const res = this.fin.Window.wrapSync(identity);
108
- // we add the identity at the top level for backwards compatibility.
109
- res.name = identity.name;
110
- res.uuid = identity.uuid;
111
- return res;
112
- }
113
- /**
114
- * Closes current platform, all its windows, and their views.
115
- * @return { Promise<void> }
116
- * @tutorial Platform.quit
117
- */
118
- async quit() {
119
- this.wire.sendAction('platform-quit', this.identity).catch((e) => {
120
- // don't expose
121
- });
122
- const client = await this.getClient();
123
- return client.dispatch('quit');
124
- }
125
- /**
126
- * Closes a specified view in a target window.
127
- * @param { Identity } viewIdentity View identity
128
- * @return { Promise<void> }
129
- * @tutorial Platform.closeView
130
- */
131
- async closeView(viewIdentity) {
132
- this.wire.sendAction('platform-close-view', this.identity).catch((e) => {
133
- // don't expose
134
- });
135
- const client = await this.getClient();
136
- await client.dispatch('close-view', {
137
- view: viewIdentity
138
- });
139
- }
140
- /**
141
- * ***DEPRECATED - please use Platform.createView.***
142
- * Reparents a specified view in a new target window.
143
- * @param { Identity } viewIdentity View identity
144
- * @param { Identity } target new owner window identity
145
- * @return { Promise<View> }
146
- * @tutorial Platform.createView
147
- */
148
- async reparentView(viewIdentity, target) {
149
- var _a;
150
- // eslint-disable-next-line no-console
151
- console.warn('Platform.reparentView has been deprecated, please use Platform.createView');
152
- this.wire.sendAction('platform-reparent-view', this.identity).catch((e) => {
153
- // don't expose
154
- });
155
- const normalizedViewIdentity = {
156
- ...viewIdentity,
157
- uuid: (_a = viewIdentity.uuid) !== null && _a !== void 0 ? _a : this.identity.uuid
158
- };
159
- const view = await this.fin.View.wrap(normalizedViewIdentity);
160
- const viewOptions = await view.getOptions();
161
- return this.createView(viewOptions, target);
162
- }
163
- /**
164
- * Returns a snapshot of the platform in its current state.
165
- *
166
- * Can be used to restore an application to a previous state.
167
- * @return { Promise<Snapshot> }
168
- * @tutorial Platform.getSnapshot
169
- */
170
- async getSnapshot() {
171
- this.wire.sendAction('platform-get-snapshot', this.identity).catch((e) => {
172
- // don't expose
173
- });
174
- const client = await this.getClient();
175
- return client.dispatch('get-snapshot');
176
- }
177
- /**
178
- * Adds a snapshot to a running Platform.
179
- * Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.
180
- *
181
- * Can optionally close existing windows and overwrite current platform state with that of a snapshot.
182
- *
183
- * The function accepts either a snapshot taken using {@link Platform#getSnapshot getSnapshot},
184
- * or a url or filepath to a snapshot JSON object.
185
- * @param { Snapshot | string } requestedSnapshot Snapshot to apply, or a url or filepath.
186
- * @param { ApplySnapshotOptions } [options] Optional parameters to specify whether existing windows should be closed.
187
- * @return { Promise<Platform> }
188
- * @tutorial Platform.applySnapshot
189
- */
190
- async applySnapshot(requestedSnapshot, options) {
191
- this.wire.sendAction('platform-apply-snapshot', this.identity).catch((e) => {
192
- // don't expose
193
- });
194
- const errMsg = 'Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.';
195
- let snapshot;
196
- if (typeof requestedSnapshot === 'string') {
197
- // Fetch and parse snapshot
198
- try {
199
- const response = await this._channel.wire.sendAction('get-application-manifest', {
200
- manifestUrl: requestedSnapshot
201
- });
202
- snapshot = response.payload.data;
203
- }
204
- catch (err) {
205
- throw new Error(`${errMsg}: ${err}`);
206
- }
207
- }
208
- else {
209
- snapshot = requestedSnapshot;
210
- }
211
- if (!snapshot.windows) {
212
- throw new Error(errMsg);
213
- }
214
- const client = await this.getClient();
215
- await client.dispatch('apply-snapshot', {
216
- snapshot,
217
- options
218
- });
219
- return this;
220
- }
221
- /**
222
- * Fetches a JSON manifest using the browser process and returns a Javascript object.
223
- * Can be overwritten using {@link Platform#init Platform.init}.
224
- * @param { string } manifestUrl The URL of the manifest to fetch.
225
- * @return { Promise<any> }
226
- * @tutorial Platform.fetchManifest
227
- */
228
- async fetchManifest(manifestUrl) {
229
- const client = await this.getClient();
230
- return client.dispatch('platform-fetch-manifest', { manifestUrl });
231
- }
232
- /**
233
- * Retrieves a manifest by url and launches a legacy application manifest or snapshot into the platform. Returns a promise that
234
- * resolves to the wrapped Platform.
235
- * @param {string} manifestUrl - The URL of the manifest that will be launched into the platform. If this app manifest
236
- * contains a snapshot, that will be launched into the platform. If not, the application described in startup_app options
237
- * will be launched into the platform. The applicable startup_app options will become {@link View~options View Options}.
238
- * @return {Promise<Platform>}
239
- * @tutorial Platform.launchContentManifest
240
- * @experimental
241
- */
242
- async launchContentManifest(manifestUrl) {
243
- this.wire.sendAction('platform-launch-content-manifest', this.identity).catch((e) => {
244
- // don't expose
245
- });
246
- const client = await this.getClient();
247
- const manifest = await this.fetchManifest(manifestUrl);
248
- client.dispatch('launch-into-platform', { manifest });
249
- return this;
250
- }
251
- /**
252
- * Set the context of a host window. The context will be available to the window itself, and to its child Views. It will be saved in any platform snapshots.
253
- * It can be retrieved using {@link Platform#getWindowContext getWindowContext}.
254
- * @param {any} context - A field where serializable context data can be stored to be saved in platform snapshots.
255
- * @param {Identity} [target] - A target window or view may optionally be provided. If no target is provided, the update will be applied
256
- * to the current window (if called from a Window) or the current host window (if called from a View).
257
- * @return {Promise<void>}
258
- * @tutorial Platform.setWindowContext
259
- * @experimental
260
- */
261
- async setWindowContext(context = {}, target) {
262
- this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
263
- // don't expose
264
- });
265
- if (!context) {
266
- throw new Error('Please provide a serializable object or string to set the context.');
267
- }
268
- const client = await this.getClient();
269
- const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
270
- await client.dispatch('set-window-context', {
271
- context,
272
- entityType,
273
- target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
274
- });
275
- }
276
- /**
277
- * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
278
- * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
279
- * @param {Identity} [target] - A target window or view may optionally be provided. If no target is provided, target will be
280
- * the current window (if called from a Window) or the current host window (if called from a View).
281
- * @return {Promise<any>}
282
- * @tutorial Platform.getWindowContext
283
- * @experimental
284
- */
285
- async getWindowContext(target) {
286
- this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
287
- // don't expose
288
- });
289
- const client = await this.getClient();
290
- const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
291
- return client.dispatch('get-window-context', {
292
- target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
293
- entityType
294
- });
295
- }
296
- }
297
- exports.Platform = Platform;
298
- _connectToProvider = new WeakMap();
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
3
+ if (!privateMap.has(receiver)) {
4
+ throw new TypeError("attempted to get private field on non-instance");
5
+ }
6
+ return privateMap.get(receiver);
7
+ };
8
+ var _connectToProvider;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.Platform = void 0;
11
+ const base_1 = require("../base");
12
+ const validate_1 = require("../../util/validate");
13
+ // Reuse clients to avoid overwriting already-registered client in provider
14
+ const clientMap = new Map();
15
+ /** Manages the life cycle of windows and views in the application.
16
+ *
17
+ * Enables taking snapshots of itself and applying them to restore a previous configuration
18
+ * as well as listen to <a href="tutorial-Platform.EventEmitter.html">platform events</a>.
19
+ * @namespace
20
+ */
21
+ class Platform extends base_1.EmitterBase {
22
+ // eslint-disable-next-line no-shadow
23
+ constructor(identity, channel) {
24
+ // we piggyback off of application event emitter because from the core's perspective platform is just an app.
25
+ super(channel.wire, 'application', identity.uuid);
26
+ this.getClient = (identity) => {
27
+ this.wire.sendAction('platform-get-client', this.identity).catch((e) => {
28
+ // don't expose
29
+ });
30
+ const target = identity || this.identity;
31
+ const { uuid } = target;
32
+ if (!clientMap.has(uuid)) {
33
+ const clientPromise = __classPrivateFieldGet(this, _connectToProvider).call(this, uuid);
34
+ clientMap.set(uuid, clientPromise);
35
+ }
36
+ // we set it above
37
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
38
+ return clientMap.get(uuid);
39
+ };
40
+ _connectToProvider.set(this, async (uuid) => {
41
+ try {
42
+ const channelName = `custom-frame-${uuid}`;
43
+ const client = await this._channel.connect(channelName, { wait: false });
44
+ client.onDisconnection(() => {
45
+ clientMap.delete(uuid);
46
+ });
47
+ return client;
48
+ }
49
+ catch (e) {
50
+ clientMap.delete(uuid);
51
+ throw new Error('The targeted Platform is not currently running. Listen for application-started event for the given Uuid.');
52
+ }
53
+ });
54
+ // Deprecated (renamed)
55
+ this.launchLegacyManifest = this.launchContentManifest;
56
+ const errorMsg = validate_1.validateIdentity(identity);
57
+ if (errorMsg) {
58
+ throw new Error(errorMsg);
59
+ }
60
+ this._channel = channel;
61
+ this.identity = { uuid: identity.uuid };
62
+ this.Layout = this.fin.Platform.Layout;
63
+ this.Application = this.fin.Application.wrapSync(this.identity);
64
+ }
65
+ /**
66
+ * Creates a new view and attaches it to a specified target window.
67
+ * @param { View~options } viewOptions View creation options
68
+ * @param { Identity } [target] The window to which the new view is to be attached. If no target, create a view in a new window.
69
+ * @param { Identity } [targetView] If provided, the new view will be added to the same tabstrip as targetView.
70
+ * @return { Promise<View> }
71
+ * @tutorial Platform.createView
72
+ */
73
+ async createView(viewOptions, target, targetView) {
74
+ this.wire.sendAction('platform-create-view', this.identity).catch((e) => {
75
+ // don't expose
76
+ });
77
+ const client = await this.getClient();
78
+ const response = await client.dispatch('create-view', {
79
+ target,
80
+ opts: viewOptions,
81
+ targetView
82
+ });
83
+ if (!response || validate_1.validateIdentity(response.identity)) {
84
+ throw new Error(`When overwriting the createView call, please return an object that has a valid 'identity' property: ${JSON.stringify(response)}`);
85
+ }
86
+ return this.fin.View.wrapSync(response.identity);
87
+ }
88
+ /**
89
+ * Creates a new Window.
90
+ * @param { Window~options } options Window creation options
91
+ * @return { Promise<_Window> }
92
+ * @tutorial Platform.createWindow
93
+ */
94
+ async createWindow(options) {
95
+ this.wire.sendAction('platform-create-window', this.identity).catch((e) => {
96
+ // don't expose
97
+ });
98
+ const client = await this.getClient();
99
+ if (!options.reason) {
100
+ options.reason = 'api-call';
101
+ }
102
+ const response = await client.dispatch('create-view-container', options);
103
+ if (!response || validate_1.validateIdentity(response.identity)) {
104
+ throw new Error(`When overwriting the createWindow call, please return an object that has a valid 'identity' property: ${JSON.stringify(response)}`);
105
+ }
106
+ const { identity } = response;
107
+ const res = this.fin.Window.wrapSync(identity);
108
+ // we add the identity at the top level for backwards compatibility.
109
+ res.name = identity.name;
110
+ res.uuid = identity.uuid;
111
+ return res;
112
+ }
113
+ /**
114
+ * Closes current platform, all its windows, and their views.
115
+ * @return { Promise<void> }
116
+ * @tutorial Platform.quit
117
+ */
118
+ async quit() {
119
+ this.wire.sendAction('platform-quit', this.identity).catch((e) => {
120
+ // don't expose
121
+ });
122
+ const client = await this.getClient();
123
+ return client.dispatch('quit');
124
+ }
125
+ /**
126
+ * Closes a specified view in a target window.
127
+ * @param { Identity } viewIdentity View identity
128
+ * @return { Promise<void> }
129
+ * @tutorial Platform.closeView
130
+ */
131
+ async closeView(viewIdentity) {
132
+ this.wire.sendAction('platform-close-view', this.identity).catch((e) => {
133
+ // don't expose
134
+ });
135
+ const client = await this.getClient();
136
+ await client.dispatch('close-view', {
137
+ view: viewIdentity
138
+ });
139
+ }
140
+ /**
141
+ * ***DEPRECATED - please use Platform.createView.***
142
+ * Reparents a specified view in a new target window.
143
+ * @param { Identity } viewIdentity View identity
144
+ * @param { Identity } target new owner window identity
145
+ * @return { Promise<View> }
146
+ * @tutorial Platform.createView
147
+ */
148
+ async reparentView(viewIdentity, target) {
149
+ var _a;
150
+ // eslint-disable-next-line no-console
151
+ console.warn('Platform.reparentView has been deprecated, please use Platform.createView');
152
+ this.wire.sendAction('platform-reparent-view', this.identity).catch((e) => {
153
+ // don't expose
154
+ });
155
+ const normalizedViewIdentity = {
156
+ ...viewIdentity,
157
+ uuid: (_a = viewIdentity.uuid) !== null && _a !== void 0 ? _a : this.identity.uuid
158
+ };
159
+ const view = await this.fin.View.wrap(normalizedViewIdentity);
160
+ const viewOptions = await view.getOptions();
161
+ return this.createView(viewOptions, target);
162
+ }
163
+ /**
164
+ * Returns a snapshot of the platform in its current state.
165
+ *
166
+ * Can be used to restore an application to a previous state.
167
+ * @return { Promise<Snapshot> }
168
+ * @tutorial Platform.getSnapshot
169
+ */
170
+ async getSnapshot() {
171
+ this.wire.sendAction('platform-get-snapshot', this.identity).catch((e) => {
172
+ // don't expose
173
+ });
174
+ const client = await this.getClient();
175
+ return client.dispatch('get-snapshot');
176
+ }
177
+ /**
178
+ * Adds a snapshot to a running Platform.
179
+ * Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.
180
+ *
181
+ * Can optionally close existing windows and overwrite current platform state with that of a snapshot.
182
+ *
183
+ * The function accepts either a snapshot taken using {@link Platform#getSnapshot getSnapshot},
184
+ * or a url or filepath to a snapshot JSON object.
185
+ * @param { Snapshot | string } requestedSnapshot Snapshot to apply, or a url or filepath.
186
+ * @param { ApplySnapshotOptions } [options] Optional parameters to specify whether existing windows should be closed.
187
+ * @return { Promise<Platform> }
188
+ * @tutorial Platform.applySnapshot
189
+ */
190
+ async applySnapshot(requestedSnapshot, options) {
191
+ this.wire.sendAction('platform-apply-snapshot', this.identity).catch((e) => {
192
+ // don't expose
193
+ });
194
+ const errMsg = 'Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.';
195
+ let snapshot;
196
+ if (typeof requestedSnapshot === 'string') {
197
+ // Fetch and parse snapshot
198
+ try {
199
+ const response = await this._channel.wire.sendAction('get-application-manifest', {
200
+ manifestUrl: requestedSnapshot
201
+ });
202
+ snapshot = response.payload.data;
203
+ }
204
+ catch (err) {
205
+ throw new Error(`${errMsg}: ${err}`);
206
+ }
207
+ }
208
+ else {
209
+ snapshot = requestedSnapshot;
210
+ }
211
+ if (!snapshot.windows) {
212
+ throw new Error(errMsg);
213
+ }
214
+ const client = await this.getClient();
215
+ await client.dispatch('apply-snapshot', {
216
+ snapshot,
217
+ options
218
+ });
219
+ return this;
220
+ }
221
+ /**
222
+ * Fetches a JSON manifest using the browser process and returns a Javascript object.
223
+ * Can be overwritten using {@link Platform#init Platform.init}.
224
+ * @param { string } manifestUrl The URL of the manifest to fetch.
225
+ * @return { Promise<any> }
226
+ * @tutorial Platform.fetchManifest
227
+ */
228
+ async fetchManifest(manifestUrl) {
229
+ const client = await this.getClient();
230
+ return client.dispatch('platform-fetch-manifest', { manifestUrl });
231
+ }
232
+ /**
233
+ * Retrieves a manifest by url and launches a legacy application manifest or snapshot into the platform. Returns a promise that
234
+ * resolves to the wrapped Platform.
235
+ * @param {string} manifestUrl - The URL of the manifest that will be launched into the platform. If this app manifest
236
+ * contains a snapshot, that will be launched into the platform. If not, the application described in startup_app options
237
+ * will be launched into the platform. The applicable startup_app options will become {@link View~options View Options}.
238
+ * @return {Promise<Platform>}
239
+ * @tutorial Platform.launchContentManifest
240
+ * @experimental
241
+ */
242
+ async launchContentManifest(manifestUrl) {
243
+ this.wire.sendAction('platform-launch-content-manifest', this.identity).catch((e) => {
244
+ // don't expose
245
+ });
246
+ const client = await this.getClient();
247
+ const manifest = await this.fetchManifest(manifestUrl);
248
+ client.dispatch('launch-into-platform', { manifest });
249
+ return this;
250
+ }
251
+ /**
252
+ * Set the context of a host window. The context will be available to the window itself, and to its child Views. It will be saved in any platform snapshots.
253
+ * It can be retrieved using {@link Platform#getWindowContext getWindowContext}.
254
+ * @param {any} context - A field where serializable context data can be stored to be saved in platform snapshots.
255
+ * @param {Identity} [target] - A target window or view may optionally be provided. If no target is provided, the update will be applied
256
+ * to the current window (if called from a Window) or the current host window (if called from a View).
257
+ * @return {Promise<void>}
258
+ * @tutorial Platform.setWindowContext
259
+ * @experimental
260
+ */
261
+ async setWindowContext(context = {}, target) {
262
+ this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
263
+ // don't expose
264
+ });
265
+ if (!context) {
266
+ throw new Error('Please provide a serializable object or string to set the context.');
267
+ }
268
+ const client = await this.getClient();
269
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
270
+ await client.dispatch('set-window-context', {
271
+ context,
272
+ entityType,
273
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
274
+ });
275
+ }
276
+ /**
277
+ * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
278
+ * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
279
+ * @param {Identity} [target] - A target window or view may optionally be provided. If no target is provided, target will be
280
+ * the current window (if called from a Window) or the current host window (if called from a View).
281
+ * @return {Promise<any>}
282
+ * @tutorial Platform.getWindowContext
283
+ * @experimental
284
+ */
285
+ async getWindowContext(target) {
286
+ this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
287
+ // don't expose
288
+ });
289
+ const client = await this.getClient();
290
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
291
+ return client.dispatch('get-window-context', {
292
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
293
+ entityType
294
+ });
295
+ }
296
+ }
297
+ exports.Platform = Platform;
298
+ _connectToProvider = new WeakMap();
@@ -1,6 +1,6 @@
1
- import LayoutPresetType = OpenFin.LayoutPresetType;
2
- export declare function isValidPresetType(type: LayoutPresetType): type is LayoutPresetType;
3
- declare const _default: {
4
- isValidPresetType: typeof isValidPresetType;
5
- };
6
- export default _default;
1
+ import LayoutPresetType = OpenFin.LayoutPresetType;
2
+ export declare function isValidPresetType(type: LayoutPresetType): type is LayoutPresetType;
3
+ declare const _default: {
4
+ isValidPresetType: typeof isValidPresetType;
5
+ };
6
+ export default _default;
@@ -1,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isValidPresetType = void 0;
4
- function isValidPresetType(type) {
5
- switch (type) {
6
- case 'columns':
7
- case 'grid':
8
- case 'rows':
9
- case 'tabs':
10
- return true;
11
- default:
12
- return false;
13
- }
14
- }
15
- exports.isValidPresetType = isValidPresetType;
16
- exports.default = { isValidPresetType };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidPresetType = void 0;
4
+ function isValidPresetType(type) {
5
+ switch (type) {
6
+ case 'columns':
7
+ case 'grid':
8
+ case 'rows':
9
+ case 'tabs':
10
+ return true;
11
+ default:
12
+ return false;
13
+ }
14
+ }
15
+ exports.isValidPresetType = isValidPresetType;
16
+ exports.default = { isValidPresetType };
@@ -1,3 +1,3 @@
1
- import PlatformModule from './Factory';
2
- export default PlatformModule;
3
- export * from './Instance';
1
+ import PlatformModule from './Factory';
2
+ export default PlatformModule;
3
+ export * from './Instance';