@openfin/core 33.76.27 → 33.76.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/openfin-core-33.76.36.tgz +0 -0
  2. package/package.json +1 -1
  3. package/src/OpenFin.d.ts +27 -16
  4. package/src/api/application/Factory.d.ts +148 -100
  5. package/src/api/application/Factory.js +148 -100
  6. package/src/api/application/Instance.d.ts +477 -106
  7. package/src/api/application/Instance.js +474 -106
  8. package/src/api/application/index.d.ts +9 -0
  9. package/src/api/application/index.js +9 -0
  10. package/src/api/base.d.ts +69 -0
  11. package/src/api/base.js +69 -0
  12. package/src/api/clipboard/index.d.ts +111 -31
  13. package/src/api/clipboard/index.js +111 -31
  14. package/src/api/events/application.d.ts +12 -0
  15. package/src/api/events/application.js +12 -0
  16. package/src/api/events/channel.d.ts +5 -0
  17. package/src/api/events/channel.js +5 -0
  18. package/src/api/events/externalApplication.d.ts +5 -0
  19. package/src/api/events/externalApplication.js +5 -0
  20. package/src/api/events/frame.d.ts +5 -0
  21. package/src/api/events/globalHotkey.d.ts +5 -0
  22. package/src/api/events/platform.d.ts +9 -1
  23. package/src/api/events/platform.js +8 -0
  24. package/src/api/events/system.d.ts +13 -0
  25. package/src/api/events/system.js +13 -0
  26. package/src/api/events/view.d.ts +19 -9
  27. package/src/api/events/view.js +10 -0
  28. package/src/api/events/webcontents.d.ts +21 -10
  29. package/src/api/events/webcontents.js +11 -0
  30. package/src/api/events/window.d.ts +70 -1
  31. package/src/api/events/window.js +10 -0
  32. package/src/api/external-application/Factory.d.ts +16 -9
  33. package/src/api/external-application/Factory.js +16 -9
  34. package/src/api/external-application/Instance.d.ts +40 -32
  35. package/src/api/external-application/Instance.js +40 -32
  36. package/src/api/external-application/index.d.ts +9 -0
  37. package/src/api/external-application/index.js +9 -0
  38. package/src/api/fin.d.ts +3 -0
  39. package/src/api/fin.js +3 -0
  40. package/src/api/frame/Factory.d.ts +30 -13
  41. package/src/api/frame/Factory.js +30 -13
  42. package/src/api/frame/Instance.d.ts +51 -38
  43. package/src/api/frame/Instance.js +51 -38
  44. package/src/api/frame/index.d.ts +11 -0
  45. package/src/api/frame/index.js +11 -0
  46. package/src/api/global-hotkey/index.d.ts +81 -13
  47. package/src/api/global-hotkey/index.js +81 -13
  48. package/src/api/interappbus/channel/channel.d.ts +257 -0
  49. package/src/api/interappbus/channel/channel.js +257 -0
  50. package/src/api/interappbus/channel/channels-docs.d.ts +59 -57
  51. package/src/api/interappbus/channel/channels-docs.js +71 -68
  52. package/src/api/interappbus/channel/client.d.ts +93 -0
  53. package/src/api/interappbus/channel/client.js +93 -1
  54. package/src/api/interappbus/channel/index.d.ts +164 -0
  55. package/src/api/interappbus/channel/index.js +165 -1
  56. package/src/api/interappbus/channel/provider.d.ts +172 -0
  57. package/src/api/interappbus/channel/provider.js +172 -0
  58. package/src/api/interappbus/index.d.ts +55 -20
  59. package/src/api/interappbus/index.js +55 -20
  60. package/src/api/interop/Factory.d.ts +30 -10
  61. package/src/api/interop/Factory.js +30 -10
  62. package/src/api/interop/InteropBroker.d.ts +298 -70
  63. package/src/api/interop/InteropBroker.js +298 -70
  64. package/src/api/interop/InteropClient.d.ts +286 -62
  65. package/src/api/interop/InteropClient.js +286 -62
  66. package/src/api/interop/SessionContextGroupClient.d.ts +2 -2
  67. package/src/api/interop/SessionContextGroupClient.js +2 -2
  68. package/src/api/interop/fdc3/documentationStub.d.ts +14 -0
  69. package/src/api/interop/fdc3/documentationStub.js +17 -0
  70. package/src/api/interop/fdc3/fdc3-1.2.d.ts +31 -34
  71. package/src/api/interop/fdc3/fdc3-1.2.js +31 -34
  72. package/src/api/interop/fdc3/fdc3-2.0.d.ts +48 -51
  73. package/src/api/interop/fdc3/fdc3-2.0.js +48 -51
  74. package/src/api/interop/index.d.ts +8 -0
  75. package/src/api/interop/index.js +8 -0
  76. package/src/api/platform/Factory.d.ts +121 -65
  77. package/src/api/platform/Factory.js +122 -66
  78. package/src/api/platform/Instance.d.ts +551 -48
  79. package/src/api/platform/Instance.js +551 -49
  80. package/src/api/platform/index.d.ts +9 -0
  81. package/src/api/platform/index.js +9 -0
  82. package/src/api/platform/layout/Factory.d.ts +53 -76
  83. package/src/api/platform/layout/Factory.js +53 -76
  84. package/src/api/platform/layout/Instance.d.ts +158 -23
  85. package/src/api/platform/layout/Instance.js +118 -20
  86. package/src/api/platform/layout/entities/layout-entities.d.ts +222 -30
  87. package/src/api/platform/layout/entities/layout-entities.js +222 -30
  88. package/src/api/platform/layout/index.d.ts +9 -0
  89. package/src/api/platform/layout/index.js +9 -0
  90. package/src/api/platform/provider.d.ts +398 -51
  91. package/src/api/snapshot-source/Factory.d.ts +33 -18
  92. package/src/api/snapshot-source/Factory.js +33 -18
  93. package/src/api/snapshot-source/Instance.d.ts +30 -8
  94. package/src/api/snapshot-source/Instance.js +30 -8
  95. package/src/api/snapshot-source/index.d.ts +9 -0
  96. package/src/api/snapshot-source/index.js +9 -0
  97. package/src/api/system/index.d.ts +1137 -186
  98. package/src/api/system/index.js +1142 -186
  99. package/src/api/view/Factory.d.ts +54 -16
  100. package/src/api/view/Factory.js +54 -16
  101. package/src/api/view/Instance.d.ts +330 -216
  102. package/src/api/view/Instance.js +331 -217
  103. package/src/api/view/index.d.ts +9 -0
  104. package/src/api/view/index.js +9 -0
  105. package/src/api/webcontents/main.d.ts +890 -0
  106. package/src/api/webcontents/main.js +890 -0
  107. package/src/api/window/Factory.d.ts +67 -16
  108. package/src/api/window/Factory.js +67 -16
  109. package/src/api/window/Instance.d.ts +824 -316
  110. package/src/api/window/Instance.js +822 -320
  111. package/src/api/window/index.d.ts +11 -0
  112. package/src/api/window/index.js +11 -0
  113. package/src/namespaces.d.ts +1 -0
  114. package/src/namespaces.js +3 -1
  115. package/src/shapes/protocol.d.ts +4 -0
  116. package/openfin-core-33.76.27.tgz +0 -0
@@ -2,8 +2,8 @@ import * as OpenFin from '../../OpenFin';
2
2
  type WindowOptionsChangedEvent = OpenFin.WindowEvents.WindowOptionsChangedEvent;
3
3
  /**
4
4
  * This class handles Platform actions. It does not need to be used directly by developers.
5
- * However, its methods can be overriden by passing an `overrideCallback` to {@link Platform#init Platform.init}
6
- * in order to implement custom Platform behavior. (See {@tutorial Platform.init})
5
+ * However, its methods can be overriden by passing an `overrideCallback` to {@link Platform.PlatformModule.init Platform.init}
6
+ * in order to implement custom Platform behavior. (See {@link Platform.PlatformModule.init Platform.init})
7
7
  *
8
8
  * For an overview of Provider customization, see
9
9
  * {@link https://developers.openfin.co/docs/platform-customization#section-customizing-platform-behavior}.
@@ -11,25 +11,103 @@ type WindowOptionsChangedEvent = OpenFin.WindowEvents.WindowOptionsChangedEvent;
11
11
  export interface PlatformProvider {
12
12
  /**
13
13
  * Handles requests to create a window in the current platform.
14
- * @param { WindowOption } payload Window options for the window to be created.
15
- * @param { Identity } [identity] If {@link Platform#createWindow Platform.createWindow} was called, the identity of the caller will be here.
16
- * If `createWindow` was called as part of applying a snapshot or creating a view without a target window, `identity` will be undefined.
14
+ * @param payload Window options for the window to be created.
15
+ * @param identity If {@link Platform.Platform#createWindow Platform.createWindow} was called, the identity of the caller will be here.
16
+ *
17
+ * @remarks If `createWindow` was called as part of applying a snapshot or creating a view without a target window,
18
+ * `identity` will be undefined.
19
+ *
20
+ * Allows overriding a platform's default window creation behavior. All calls to {@link Platform#createWindow Platform.createWindow}
21
+ * will pass through the override.
22
+ *
23
+ * @example
24
+ * ```js
25
+ * const overrideCallback = (PlatformProvider) => {
26
+ * class Override extends PlatformProvider {
27
+ * async createWindow(options, callerIdentity) {
28
+ * if (options.reason === 'tearout') {
29
+ * // Perhaps in our platform, we want tearout windows to have a certain initial context value
30
+ * const customContext = {
31
+ * security: 'STOCK',
32
+ * currentView: 'detailed'
33
+ * }
34
+ * return super.createWindow({ ...options, customContext }, callerIdentity);
35
+ * }
36
+ * // default behavior for all other creation reasons
37
+ * return super.createWindow(options, callerIdentity);
38
+ * }
39
+ * }
40
+ * return new Override();
41
+ * }
42
+ *
43
+ * fin.Platform.init({ overrideCallback });
44
+ * ```
17
45
  */
18
46
  createWindow(options: OpenFin.PlatformWindowCreationOptions, identity?: OpenFin.Identity): Promise<OpenFin.Window>;
19
47
  /**
20
48
  * Gets the current state of windows and their views and returns a snapshot object containing that info.
21
- * @param { undefined } payload Undefined unless you've defined a custom `getSnapshot` protocol.
22
- * @param { Identity } identity Identity of the entity that called {@link Platform#getSnapshot Platform.getSnapshot}.
23
- * @return { Promise<Snapshot> } Snapshot of current platform state.
49
+ * @param payload Undefined unless you've defined a custom `getSnapshot` protocol.
50
+ * @param identity Identity of the entity that called {@link Platform.Platform#getSnapshot Platform.getSnapshot}.
51
+ * @returns Snapshot of current platform state.
52
+ *
53
+ * @remarks Allows overriding a platform's default snapshot behavior. All calls to
54
+ * {@link Platform#getSnapshot Platform.getSnapshot} will pass through the override.
55
+ *
56
+ * @example
57
+ * ```js
58
+ * const overrideCallback = (PlatformProvider) => {
59
+ * // Extend default behavior
60
+ * class MyOverride extends PlatformProvider {
61
+ * async getSnapshot(payload, callerIdentity) {
62
+ * // Call super to access vanilla platform behavior
63
+ * const snapshot = await super.getSnapshot();
64
+ * // Perform any additional logic needed
65
+ * const modifiedSnapshot = { ...snapshot, answer: 42 }
66
+ * await saveSnapshotToServer(modifiedSnapshot);
67
+ * return modifiedSnapshot;
68
+ * }
69
+ * }
70
+ * // Return instance with methods to be consumed by Platform
71
+ * return new MyOverride();
72
+ * };
73
+ * fin.Platform.init({ overrideCallback });
74
+ *
75
+ * async function saveSnapshotToServer(snapshot) {
76
+ * // Send a snapshot to the server, store it locally somewhere, etc.
77
+ * }
78
+ * ```
24
79
  */
25
80
  getSnapshot(payload: undefined, identity: OpenFin.Identity): Promise<OpenFin.Snapshot>;
26
81
  /**
27
82
  * **NOTE**: Internal use only. It is not recommended to manage the state of individual views.
28
83
  * Gets the current state of a single view and returns an object with the options needed to restore that view as part of a snapshot.
29
- * @param { Identity } payload Identity of the view.
30
- * @return { Promise<ViewState> }
84
+ * @param payload Identity of the view.
85
+ *
31
86
  * @internal
32
87
  * @experimental
88
+ *
89
+ * @remarks Allows overriding a platform's default `getViewSnapshot` behavior. All calls to
90
+ * {@link Platform#getViewSnapshot Platform.getViewSnapshot} will pass through the override.
91
+ *
92
+ * @example
93
+ * ```js
94
+ * const overrideCallback = (PlatformProvider) => {
95
+ * // Extend default behavior
96
+ * class MyOverride extends PlatformProvider {
97
+ * async getViewSnapshot(payload) {
98
+ * // Call super to access vanilla platform behavior
99
+ * const defaultViewSnapshot = await super.getViewSnapshot(payload);
100
+ * // Perform any additional logic needed
101
+ * const modifiedSnapshot = { ...defaultViewSnapshot, answer: 42 }
102
+ * return modifiedSnapshot;
103
+ * }
104
+ * }
105
+ * // Return instance with methods to be consumed by Platform
106
+ * return new MyOverride();
107
+ * };
108
+ *
109
+ * fin.Platform.init({ overrideCallback });
110
+ * ```
33
111
  */
34
112
  getViewSnapshot(payload: {
35
113
  viewIdentity: OpenFin.Identity;
@@ -38,107 +116,350 @@ export interface PlatformProvider {
38
116
  * Called when a snapshot is being applied and some windows in that snapshot would be fully or partially off-screen.
39
117
  * Returns an array of windows with modified positions, such that any off-screen windows are positioned in the top left
40
118
  * corner of the main monitor.
41
- * @param { Snapshot } snapshot The snapshot to be applied.
42
- * @param { WindowOptions[] } outOfBoundsWindows An array of WindowOptions for any windows that would be off-screen.
43
- * @return { Promise<WindowOptions[]> } An array of WindowOptions with their position modified to fit on screen.
119
+ * @param snapshot The snapshot to be applied.
120
+ * @param outOfBoundsWindows An array of WindowOptions for any windows that would be off-screen.
121
+ * @returns An array of WindowOptions with their position modified to fit on screen.
122
+ *
123
+ * @example
124
+ * ```js
125
+ * const overrideCallback = (PlatformProvider) => {
126
+ * class Override extends PlatformProvider {
127
+ * async positionOutOfBoundsWindows(
128
+ * snapshot, // The snapshot currently being applied
129
+ * outOfBoundsWindows // An array of options for all windows that would be fully or partially off-screen.
130
+ * ) {
131
+ * // By default, this function cascades out-of-bounds windows from the top left of the main monitor.
132
+ * // Perhaps we wish to instead position all such windows on the bottom right.
133
+ *
134
+ * // First, find the coordinates of the bottom right of the primary monitor
135
+ * const {
136
+ * primaryMonitor: {
137
+ * availableRect: { right, bottom }
138
+ * }
139
+ * } = await fin.System.getMonitorInfo();
140
+ *
141
+ * // Update the coordinates of each out-of-bounds window to be bottom right
142
+ * const newWindows = snapshot.windows.map((windowOptions) => {
143
+ * if (outOfBoundsWindows.find(w => w.name === windowOptions.name)) {
144
+ * // If the window is out of bounds, set a new initial top and left
145
+ * const { defaultHeight, defaultWidth } = windowOptions;
146
+ * return {
147
+ * ...windowOptions,
148
+ * defaultTop: bottom - defaultHeight,
149
+ * defaultLeft: right - defaultWidth
150
+ * }
151
+ * } else {
152
+ * return windowOptions;
153
+ * }
154
+ * })
155
+ *
156
+ * // Return all windows with desired bounds
157
+ * return newWindows;
158
+ * }
159
+ * }
160
+ * return new Override();
161
+ * }
162
+ *
163
+ * fin.Platform.init({ overrideCallback });
164
+ * ```
44
165
  */
45
166
  positionOutOfBoundsWindows(snapshot: OpenFin.Snapshot, outOfBoundsWindows: OpenFin.WindowCreationOptions[]): Promise<OpenFin.WindowCreationOptions[]>;
46
167
  /**
47
168
  * Handles requests to apply a snapshot to the current Platform.
48
- * @param { ApplySnapshotPayload } payload Payload containing the snapshot to be applied, as well as any options.
49
- * @param { Identity } [identity] Identity of the entity that called {@link Platform#applySnapshot Platform.applySnapshot}.
169
+ * @param payload Payload containing the snapshot to be applied, as well as any options.
170
+ * @param identity Identity of the entity that called {@link Platform.Platform#applySnapshot Platform.applySnapshot}.
50
171
  * Undefined if called internally (e.g. when opening the initial snapshot).
51
- * @return { Promise<void> }
172
+ *
173
+ *
174
+ * @remarks Allows overriding a platform's default snapshot behavior. All calls to
175
+ * {@link Platform#applySnapshot Platform.applySnapshot} will pass through the override.
176
+ *
177
+ * @example
178
+ * ```js
179
+ * const overrideCallback = (Provider) => {
180
+ * class Override extends Provider {
181
+ * async applySnapshot(payload, callerIdentity) {
182
+ * const { snapshot, options } = payload;
183
+ * // Perhaps in our platform, we wish to always use the closeExistingWindows option
184
+ * return super.applySnapshot(
185
+ * { snapshot, options: { ...options, closeExistingWindows: true }},
186
+ * callerIdentity
187
+ * );
188
+ * }
189
+ * return new Override();
190
+ * }
191
+ *
192
+ * fin.Platform.init({ overrideCallback });
193
+ * ```
52
194
  */
53
195
  applySnapshot(payload: OpenFin.ApplySnapshotPayload, identity?: OpenFin.Identity): Promise<void>;
54
196
  /**
55
197
  * Closes the current Platform and all child windows and views.
56
- * @param { undefined } payload Undefined unless you have implemented a custom quite protocol.
57
- * @param { Identity } identity Identity of the entity that called {@link Platform#quit Platform.quit}.
58
- * @return { Promise<void> }
198
+ * @param payload Undefined unless you have implemented a custom quite protocol.
199
+ * @param identity Identity of the entity that called {@link Platform.Platform#quit Platform.quit}.
200
+ *
201
+ *
202
+ * @remarks Allows overriding a platform's default shutdown behavior. All calls to {@link Platform#quit Platform.quit} will
203
+ * pass through the override.
204
+ *
205
+ * @example
206
+ * ```js
207
+ * const overrideCallback = (PlatformProvider) => {
208
+ * class Override extends PlatformProvider {
209
+ * async quit(payload, callerIdentity) {
210
+ * // Perhaps in our platform, we wish to take a snapshot and save it somewhere before shutting down
211
+ * const snapshot = await this.getSnapshot();
212
+ * await saveSnapshot(snapshot);
213
+ * return super.quit(payload, callerIdentity);
214
+ * }
215
+ * }
216
+ * return new Override();
217
+ * }
218
+ *
219
+ * fin.Platform.init({ overrideCallback });
220
+ *
221
+ * async function saveSnapshot(snapshot) {
222
+ * // Save the snapshot in localstorage, send to a server, etc.
223
+ * }
224
+ * ```
59
225
  */
60
226
  quit(payload: undefined, identity: OpenFin.Identity): Promise<void>;
61
227
  /**
62
228
  * Closes a view
63
- * @param { CloseViewPayload } payload Specifies the `target` view to be closed.
64
- * @param { Identity } identity Identity of the entity that called {@link Platform#closeView Platform.closeView}.
229
+ * @param payload Specifies the `target` view to be closed.
230
+ * @param identity Identity of the entity that called {@link Platform.Platform#closeView Platform.closeView}.
231
+ *
232
+ * @remarks Allows overriding a platform's default view closing behavior. All calls to
233
+ * {@link Platform#closeView Platform.closeView} will pass through the override.
234
+ *
235
+ * @example
236
+ * ```js
237
+ * const overrideCallback = (PlatformProvider) => {
238
+ * class Override extends PlatformProvider {
239
+ * async closeView(payload, callerIdentity) {
240
+ * const { view } = payload;
241
+ * // Perhaps in our platform, we want to take a snapshot and save it somewhere before closing certain views.
242
+ * if (view.name === 'my-special-view') {
243
+ * const snapshot = await fin.Platform.getCurrentSync().getSnapshot();
244
+ * await saveSnapshot(snapshot);
245
+ * }
246
+ * return super.closeView(options, callerIdentity);
247
+ * }
248
+ * }
249
+ * return new Override();
250
+ * }
251
+ *
252
+ * fin.Platform.init({ overrideCallback });
253
+ *
254
+ * async function saveSnapshot(snapshot) {
255
+ * // Save the snapshot in localstorage, send to a server, etc.
256
+ * }
257
+ * ```
65
258
  */
66
259
  closeView(payload: OpenFin.CloseViewPayload, identity?: OpenFin.Identity): Promise<any>;
67
260
  /**
68
261
  * Creates a new view and attaches it to a specified target window.
69
- * @param { CreateViewPayload } payload Creation options for the new view.
70
- * @param { Identity } identity Identity of the entity that called {@link Platform#createView Platform.createView}.
71
- * @return { Promise<void> }
262
+ * @param payload Creation options for the new view.
263
+ * @param identity Identity of the entity that called {@link Platform.Platform#createView Platform.createView}.
264
+ *
72
265
  */
73
266
  createView(payload: OpenFin.CreateViewPayload, identity: OpenFin.Identity): Promise<OpenFin.View>;
74
267
  /** Handles requests to fetch manifests in the current platform.
75
- * @param { FetchManifestPayload } payload Payload containing the manifestUrl to be fetched.
76
- * @param { Identity } callerIdentity If {@link Platform#fetchManifest Platform.fetchManifest}
268
+ * @param payload Payload containing the manifestUrl to be fetched.
269
+ * @param callerIdentity If {@link Platform.Platform#fetchManifest Platform.fetchManifest}
77
270
  * was called, the identity of the caller will be here.
78
- * If `fetchManifest` was called internally, `callerIdentity` will be the provider's identity.
271
+ *
272
+ * @remarks If `fetchManifest` was called internally, `callerIdentity` will be the provider's identity.
273
+ *
274
+ * Allows overriding a platform's default behavior when fetching manifests. Overwriting this call will change how
275
+ * {@link Platform#launchContentManifest Platform.launchContentManifest} and
276
+ * {@link https://developers.openfin.co/docs/starting-the-platform-and-launching-content#section-deep-linking-fin-or-fins-link fins links}
277
+ * fetch manifests. All calls to {@link Platform#fetchManifest Platform.fetchManifest} will also pass through the override.
278
+ *
279
+ * @example
280
+ * ```js
281
+ * const overrideCallback = (Provider) => {
282
+ * class Override extends Provider {
283
+ * async fetchManifest(payload, callerIdentity) {
284
+ * const { manifestUrl } = payload;
285
+ *
286
+ * // I want to fetch certain URLs from the platform provider so that renderer-side cookies will be sent
287
+ * if (manifestUrl === 'https://www.my-internal-manifest.com') {
288
+ * const manifest = await fetch(manifestUrl);
289
+ * return manifest.json();
290
+ * }
291
+ *
292
+ * // Any requests that might be cross-origin should still be sent from the browser process
293
+ * return super.fetchManifest(payload);
294
+ * }
295
+ * }
296
+ * return new Override();
297
+ * }
298
+ *
299
+ * fin.Platform.init({ overrideCallback });
300
+ * ```
79
301
  */
80
302
  fetchManifest(payload: OpenFin.FetchManifestPayload, callerIdentity: OpenFin.Identity): Promise<any>;
81
303
  /**
82
304
  * Replaces a Platform window's layout with a new layout. Any views that were in the old layout but not the new layout will be destroyed.
83
- * @param { ReplaceLayoutPayload } payload Contains the `target` window and an `opts` object with a `layout` property to apply.
84
- * @param { Identity } [identity] Identity of the entity that called {@link Platform#replaceLayout Platform.replaceLayout}.
305
+ * @param payload Contains the `target` window and an `opts` object with a `layout` property to apply.
306
+ * @param identity Identity of the entity that called {@link PlatformProvider#replaceLayout Platform.replaceLayout}.
85
307
  * Undefined if `replaceLayout` is called internally (e.g. while applying a snapshot).
86
- * @return { Promise<void> }
308
+ *
309
+ *
310
+ * @remarks Allows overriding a platform's default replaceLayout behavior. All calls to
311
+ * {@link Platform#replaceLayout Platform.replaceLayout} will pass through the override.
312
+ *
313
+ * @example
314
+ * ```js
315
+ * const overrideCallback = (PlatformProvider) => {
316
+ * class Override extends PlatformProvider {
317
+ * async replaceLayout(payload, callerIdentity) {
318
+ * // Perhaps in our platform, we wish to save an updated snapshot each time a layout is replaced
319
+ * await super.replaceLayout(payload, callerIdentity);
320
+ * const updatedSnapshot = await fin.Platform.getCurrentSync().getSnapshot();
321
+ * await saveSnapshot(updatedSnapshot);
322
+ * }
323
+ * }
324
+ * return new Override();
325
+ * }
326
+ *
327
+ * fin.Platform.init({ overrideCallback });
328
+ *
329
+ * async function saveSnapshot(snapshot) {
330
+ * // Save the snapshot in localstorage, send to a server, etc.
331
+ * }
332
+ * ```
87
333
  */
88
334
  replaceLayout(payload: OpenFin.ReplaceLayoutPayload, identity?: OpenFin.Identity): Promise<void>;
89
335
  replaceView(payload: OpenFin.ReplaceViewPayload, identity?: OpenFin.Identity): Promise<void>;
336
+ /**
337
+ * @internal
338
+ */
90
339
  launchIntoPlatform(payload: OpenFin.LaunchIntoPlatformPayload): Promise<void>;
91
340
  /**
92
341
  * Handles requests to set a window's context. `target` may be a window or a view.
93
342
  * If it is a window, that window's `customContext` will be updated.
94
343
  * If it is a view, the `customContext` of that view's current host window will be updated.
95
- * @param { SetWindowContextPayload } payload Object containing the requested `context` update,
344
+ * @param payload Object containing the requested `context` update,
96
345
  * the `target`'s identity, and the target's `entityType`.
97
- * @param { Identity } [identity] Identity of the entity that called {@link Platform#setWindowContext Platform.setWindowContext}.
346
+ * @param identity Identity of the entity that called {@link Platform.Platform#setWindowContext Platform.setWindowContext}.
98
347
  * Undefined if `setWindowContext` is called internally (e.g. while applying a snapshot).
99
- * @return { Promise<any> } The new context.
348
+ * @returns The new context.
349
+ *
350
+ * @remarks Allows overriding a platform's default setWindowContext behavior.
351
+ * All calls to {@link Platform#setWindowContext Platform.setWindowContext} will pass through the override.
352
+ *
353
+ * @example
354
+ * ```js
355
+ * const overrideCallback = (PlatformProvider) => {
356
+ * class Override extends PlatformProvider {
357
+ * async setWindowContext(payload, callerIdentity) {
358
+ * // Perhaps in our platform, we wish to only take context updates from windows
359
+ * // and ignore updates sent from views.
360
+ * if (payload.entityType === 'view') {
361
+ * throw new Error('Updating window context from a view is not permitted in this platform.');
362
+ * }
363
+ * return super.setWindowContext(payload, callerIdentity);
364
+ * }
365
+ * }
366
+ * return new Override();
367
+ * }
368
+ *
369
+ * fin.Platform.init({ overrideCallback });
370
+ * ```
100
371
  */
101
372
  setWindowContext(payload: OpenFin.SetWindowContextPayload, identity?: OpenFin.Identity): Promise<any>;
102
373
  /**
103
374
  * Handles requests to get a window's context. `target` may be a window or a view.
104
375
  * If it is a window, that window's `customContext` will be returned.
105
376
  * If it is a view, the `customContext` of that view's current host window will be returned.
106
- * @param { GetWindowContextPayload } payload Object containing the requested `context` update,
377
+ * @param payload Object containing the requested `context` update,
107
378
  * the `target`'s identity, and the target's `entityType`.
108
- * @param { Identity } [identity] Identity of the entity that called {@link Platform#getWindowContext Platform.getWindowContext}.
379
+ * @param identity Identity of the entity that called {@link Platform.Platform#getWindowContext Platform.getWindowContext}.
109
380
  * Undefined when `getWindowContext` is called internally
110
381
  * (e.g. when getting a window's context for the purpose of raising a "host-context-changed" event on a reparented view).
111
- * @return { Promise<any> } The new context.
382
+ * @returns The new context.
383
+ *
384
+ * @remarks Allows overriding a platform's default getWindowContext behavior. All calls to
385
+ * {@link Platform#getWindowContext Platform.getWindowContext} will pass through the override.
386
+ *
387
+ * @example
388
+ * ```js
389
+ * const overrideCallback = (PlatformProvider) => {
390
+ * class Override extends PlatformProvider {
391
+ * async getWindowContext(payload, callerIdentity) {
392
+ * // Perhaps in our platform, we wish to make window context available only to views from a given domain.
393
+ * const { entityType } = callerIdentity;
394
+ * if (entityType === 'view') {
395
+ * const { url } = await fin.View.wrapSync(callerIdentity).getInfo();
396
+ * if (!url.startsWith('https://my.trusted-domain.com')) {
397
+ * throw new Error('Only apps from trusted domains may use window context in this platform.');
398
+ * }
399
+ * }
400
+ * return super.getWindowContext(payload, callerIdentity);
401
+ * }
402
+ * }
403
+ * return new Override();
404
+ * }
405
+ *
406
+ * fin.Platform.init({ overrideCallback });
407
+ * ```
112
408
  */
113
409
  getWindowContext(payload: OpenFin.GetWindowContextPayload, identity?: OpenFin.Identity): Promise<any>;
114
410
  /**
115
411
  * Called when a window's `customContext` is updated. Responsible for raising the `host-context-updated` event on that window's child views.
116
- * @param { WindowOptionsChangedEvent<'window', 'options-changed'> } payload The event payload for the window whose context has changed.
412
+ * @param payload The event payload for the window whose context has changed.
117
413
  * The new context will be contained as `payload.diff.customContext.newVal`.
118
- * @return { Promise<HostContextChangedPayload> } The event that it raised.
414
+ * @returns The event that it raised.
119
415
  */
120
416
  onWindowContextUpdated(payload: WindowOptionsChangedEvent): Promise<OpenFin.HostContextChangedPayload | undefined>;
121
417
  /**
122
418
  * Closes a Window.
123
419
  * By default it will fire any before unload handler set by a View in the Window.
124
420
  * This can be disabled by setting skipBeforeUnload in the options object of the payload.
125
- * This method is called by {@link Platform#closeWindow Platform.closeWindow}.
126
- * @param {CloseWindowPayload} payload Object that contains the Window Identity and related options.
127
- * @param {Identity} callerIdentity
128
- * @returns {Promise<void>}
421
+ * This method is called by {@link Platform.Platform#closeWindow Platform.closeWindow}.
422
+ * @param payload Object that contains the Window Identity and related options.
423
+ * @param callerIdentity
424
+ *
425
+ *
426
+ * @remarks This method calls a number of Platform Provider methods:
427
+ *
428
+ * * {@link PlatformProvider#getViewsForWindowClose}
429
+ * * {@link PlatformProvider#checkViewsForPreventUnload}
430
+ * * {@link PlatformProvider#getUserDecisionForBeforeUnload}
431
+ * * {@link PlatformProvider#handleViewsAndWindowClose}
432
+ *
433
+ *
434
+ * @example
435
+ *
436
+ * ```js
437
+ * const overrideCallback = (PlatformProvider) => {
438
+ * class Override extends PlatformProvider {
439
+ * async closeWindow(payload, callerIdentity) {
440
+ * const { windowId: { uuid, name }, options: { skipBeforeUnload } } = payload;
441
+ * console.log(`${uuid}/${name} is closing and skipBeforeUnload is set to: ${skipBeforeUnload}`);
442
+ * return super.closeWindow(payload, callerIdentity);
443
+ * }
444
+ * }
445
+ * return new Override();
446
+ * }
447
+ *
448
+ * fin.Platform.init({ overrideCallback });
449
+ * ```
129
450
  */
130
451
  closeWindow(payload: OpenFin.CloseWindowPayload, callerIdentity: OpenFin.Identity): Promise<void>;
131
452
  /**
132
453
  * Gets all the Views attached to a Window that should close along with it. This is meant to be overridable
133
454
  * in the case where you want to return other Views that may not be attached to the Window that is closing.
134
455
  * @param winId Identity of the Window that is closing
135
- * @returns { Promise<View> }
456
+ *
136
457
  */
137
458
  getViewsForWindowClose(windowId: OpenFin.Identity): Promise<OpenFin.View[]>;
138
459
  /**
139
460
  * It takes in an array of Views and returns an object specifying which of them are trying to prevent an unload and which are not.
140
- * @param {View[]} views Array of Views
141
- * @returns { Promise<ViewStatuses> }
461
+ * @param views Array of Views
462
+ *
142
463
  */
143
464
  checkViewsForPreventUnload(views: OpenFin.View[]): Promise<OpenFin.ViewStatuses>;
144
465
  /**
@@ -146,17 +467,43 @@ export interface PlatformProvider {
146
467
  * Called in {@link PlatformProvider#closeWindow PlatformProvider.closeWindow}.
147
468
  * Normally you would use this method to show a dialog indicating that there are Views that are trying to prevent an unload.
148
469
  * By default it will always return all Views passed into it as meaning to close.
149
- * @param {ViewsPreventingUnloadPayload} payload
150
- * @tutorial PlatformProvider.getUserDecisionForBeforeUnload
151
- * @returns {Promise<BeforeUnloadUserDecision>}
470
+ * @param payload
471
+ * @example
472
+ *
473
+ * ```js
474
+ * const overrideCallback = (PlatformProvider) => {
475
+ * class Override extends PlatformProvider {
476
+ * async getUserDecisionForBeforeUnload(payload, callerIdentity) {
477
+ * const { windowShouldClose, viewsPreventingUnload, viewsNotPreventingUnload, windowId, closeType } = payload;
478
+ *
479
+ * // launch dialog and wait for user response
480
+ * const continueWithClose = await showDialog(viewsPreventingUnload, windowId, closeType);
481
+ *
482
+ * if (continueWithClose) {
483
+ * return { windowShouldClose, viewsToClose: [...viewsNotPreventingUnload, ...viewsPreventingUnload] };
484
+ * } else {
485
+ * return { windowShouldClose: false, viewsToClose: [] };
486
+ * }
487
+ * }
488
+ * }
489
+ * return new Override();
490
+ * }
491
+ *
492
+ * fin.Platform.init({ overrideCallback });
493
+ *
494
+ * async function showDialog(viewsPreventingUnload, windowId, closeType) {
495
+ * // Show a dialog and await for user response
496
+ * }
497
+ * ```
498
+ *
152
499
  */
153
500
  getUserDecisionForBeforeUnload(payload: OpenFin.ViewsPreventingUnloadPayload): Promise<OpenFin.BeforeUnloadUserDecision>;
154
501
  /**
155
502
  * Handles the closing of a Window and/or its Views. Called in {@link PlatformProvider#closeWindow PlatformProvider.closeWindow}.
156
503
  * The return of {@link PlatformProvider#getUserDecisionForBeforeUnload PlatformProvider.getUserDecisionForBeforeUnload} is passed into this method.
157
- * @param {Identity} winId Identity of the Window
158
- * @param {BeforeUnloadUserDecision} userDecision Decision object
159
- * @returns {Promise<void>}
504
+ * @param winId Identity of the Window
505
+ * @param userDecision Decision object
506
+ *
160
507
  */
161
508
  handleViewsAndWindowClose(windowId: OpenFin.Identity, userDecision: OpenFin.BeforeUnloadUserDecision): Promise<void>;
162
509
  }
@@ -1,37 +1,52 @@
1
1
  import type * as OpenFin from '../../OpenFin';
2
2
  import { Base } from '../base';
3
3
  import { SnapshotSource } from './Instance';
4
- /**
5
- * @REMOVED
6
- * @typedef { object } SnapshotProvider
7
- * @property {getSnapshot} [getSnapshot]
8
- * @property {applySnapshot} [applySnapshot]
9
- */
10
- /**
11
- * @lends SnapshotSource
12
- */
13
4
  export default class SnapshotSourceModule extends Base {
14
5
  /**
15
6
  * Initializes a SnapshotSource with the getSnapshot and applySnapshot methods defined.
16
- * @param { SnapshotProvider } provider
17
- * @return { Promise<void> }
18
- * @tutorial SnapshotSource.init
7
+ * @param provider
8
+ *
9
+ * @example
10
+ * ```js
11
+ * const snapshotProvider = {
12
+ * async getSnapshot() {
13
+ * const bounds = await fin.me.getBounds();
14
+ * return bounds;
15
+ * },
16
+ * async applySnapshot(snapshot) {
17
+ * await fin.me.setBounds(snapshot);
18
+ * return undefined;
19
+ * }
20
+ * }
21
+ *
22
+ * await fin.SnapshotSource.init(snapshotProvider);
23
+ * ```
19
24
  * @static
20
25
  */
21
26
  init<T = any>(provider: OpenFin.SnapshotProvider<T>): Promise<void>;
22
27
  /**
23
28
  * Synchronously returns a SnapshotSource object that represents the current SnapshotSource.
24
- * @param { Identity } identity
25
- * @return { SnapshotSource }
26
- * @tutorial SnapshotSource.wrapSync
29
+ * @param identity
30
+ *
31
+ * @example
32
+ * ```js
33
+ * const snapshotSource = fin.SnapshotSource.wrapSync(fin.me);
34
+ * // Use wrapped instance's getSnapshot method, e.g.:
35
+ * const snapshot = await snapshotSource.getSnapshot();
36
+ * ```
27
37
  * @static
28
38
  */
29
39
  wrapSync(identity: OpenFin.ApplicationIdentity): SnapshotSource;
30
40
  /**
31
41
  * Asynchronously returns a SnapshotSource object that represents the current SnapshotSource.
32
- * @param { Identity } identity
33
- * @return { Promise.<SnapshotSource> }
34
- * @tutorial SnapshotSource.wrap
42
+ * @param identity
43
+ *
44
+ * @example
45
+ * ```js
46
+ * const snapshotSource = await fin.SnapshotSource.wrap(fin.me);
47
+ * // Use wrapped instance's getSnapshot method, e.g.:
48
+ * const snapshot = await snapshotSource.getSnapshot();
49
+ * ```
35
50
  * @static
36
51
  */
37
52
  wrap(identity: OpenFin.ApplicationIdentity): Promise<SnapshotSource>;