@openfin/core 33.76.31 → 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.31.tgz +0 -0
@@ -16,10 +16,13 @@ const clientMap = new Map();
16
16
  *
17
17
  * Enables taking snapshots of itself and applyi
18
18
  * ng them to restore a previous configuration
19
- * as well as listen to <a href="tutorial-Platform.EventEmitter.html">platform events</a>.
20
- * @namespace
19
+ * as well as listen to {@link OpenFin.PlatformEvents platform events}.
20
+ *
21
21
  */
22
22
  class Platform extends base_1.EmitterBase {
23
+ /**
24
+ * @internal
25
+ */
23
26
  // eslint-disable-next-line no-shadow
24
27
  constructor(identity, channel) {
25
28
  // we piggyback off of application event emitter because from the core's perspective platform is just an app.
@@ -52,7 +55,10 @@ class Platform extends base_1.EmitterBase {
52
55
  throw new Error('The targeted Platform is not currently running. Listen for application-started event for the given Uuid.');
53
56
  }
54
57
  });
55
- // Deprecated (renamed)
58
+ /**
59
+ * @deprecated (renamed)
60
+ * @ignore
61
+ */
56
62
  this.launchLegacyManifest = this.launchContentManifest;
57
63
  const errorMsg = (0, validate_1.validateIdentity)(identity);
58
64
  if (errorMsg) {
@@ -65,11 +71,81 @@ class Platform extends base_1.EmitterBase {
65
71
  }
66
72
  /**
67
73
  * Creates a new view and attaches it to a specified target window.
68
- * @param { View~options } viewOptions View creation options
69
- * @param { Identity } [target] The window to which the new view is to be attached. If no target, create a view in a new window.
70
- * @param { Identity } [targetView] If provided, the new view will be added to the same tabstrip as targetView.
71
- * @return { Promise<View> }
72
- * @tutorial Platform.createView
74
+ * @param viewOptions View creation options
75
+ * @param target The window to which the new view is to be attached. If no target, create a view in a new window.
76
+ * @param targetView If provided, the new view will be added to the same tabstrip as targetView.
77
+ *
78
+ * @remarks If the view already exists, will reparent the view to the new target. You do not need to set a name for a View.
79
+ * Views that are not passed a name get a randomly generated one.
80
+ *
81
+ * @example
82
+ * ```js
83
+ * let windowIdentity;
84
+ * if (fin.me.isWindow) {
85
+ * windowIdentity = fin.me.identity;
86
+ * } else if (fin.me.isView) {
87
+ * windowIdentity = (await fin.me.getCurrentWindow()).identity;
88
+ * } else {
89
+ * throw new Error('Not running in a platform View or Window');
90
+ * }
91
+ *
92
+ * const platform = fin.Platform.getCurrentSync();
93
+ *
94
+ * platform.createView({
95
+ * name: 'test_view',
96
+ * url: 'https://developers.openfin.co/docs/platform-api'
97
+ * }, windowIdentity).then(console.log);
98
+ * ```
99
+ *
100
+ * Reparenting a view:
101
+ * ```js
102
+ * let windowIdentity;
103
+ * if (fin.me.isWindow) {
104
+ * windowIdentity = fin.me.identity;
105
+ * } else if (fin.me.isView) {
106
+ * windowIdentity = (await fin.me.getCurrentWindow()).identity;
107
+ * } else {
108
+ * throw new Error('Not running in a platform View or Window');
109
+ * }
110
+ *
111
+ * let platform = fin.Platform.getCurrentSync();
112
+ * let viewOptions = {
113
+ * name: 'example_view',
114
+ * url: 'https://example.com'
115
+ * };
116
+ * // a new view will now show in the current window
117
+ * await platform.createView(viewOptions, windowIdentity);
118
+ *
119
+ * const view = fin.View.wrapSync({ uuid: windowIdentity.uuid, name: 'yahoo_view' });
120
+ * // reparent `example_view` when a view in the new window is shown
121
+ * view.on('shown', async () => {
122
+ * let viewIdentity = { uuid: windowIdentity.uuid, name: 'example_view'};
123
+ * let target = {uuid: windowIdentity.uuid, name: 'test_win'};
124
+ * platform.createView(viewOptions, target);
125
+ * });
126
+ *
127
+ * // create a new window
128
+ * await platform.createWindow({
129
+ * name: "test_win",
130
+ * layout: {
131
+ * content: [
132
+ * {
133
+ * type: 'stack',
134
+ * content: [
135
+ * {
136
+ * type: 'component',
137
+ * componentName: 'view',
138
+ * componentState: {
139
+ * name: 'yahoo_view',
140
+ * url: 'https://yahoo.com'
141
+ * }
142
+ * }
143
+ * ]
144
+ * }
145
+ * ]
146
+ * }
147
+ * }).then(console.log);
148
+ * ```
73
149
  */
74
150
  async createView(viewOptions, target, targetView) {
75
151
  this.wire.sendAction('platform-create-view', this.identity).catch((e) => {
@@ -88,9 +164,135 @@ class Platform extends base_1.EmitterBase {
88
164
  }
89
165
  /**
90
166
  * Creates a new Window.
91
- * @param { Window~options } options Window creation options
92
- * @return { Promise<_Window> }
93
- * @tutorial Platform.createWindow
167
+ * @param options Window creation options
168
+ *
169
+ * @remarks There are two Window types at your disposal while using OpenFin Platforms - Default Window and Custom Window.
170
+ *
171
+ * The Default Window uses the standard OpenFin Window UI. It contains the standard close, maximize and minimize buttons,
172
+ * and will automatically render the Window's layout if one is specified.
173
+ *
174
+ * For deeper customization, you can bring your own Window code into a Platform. This is called a Custom Window.
175
+ *
176
+ * @example
177
+ *
178
+ *
179
+ * The example below will create a Default Window which uses OpenFin default Window UI.<br>
180
+ * The Window contains two Views in a stack Layout:
181
+ *
182
+ * ```js
183
+ * const platform = fin.Platform.getCurrentSync();
184
+ * platform.createWindow({
185
+ * layout: {
186
+ * content: [
187
+ * {
188
+ * type: 'stack',
189
+ * content: [
190
+ * {
191
+ * type: 'component',
192
+ * componentName: 'view',
193
+ * componentState: {
194
+ * name: 'test_view_1',
195
+ * url: 'https://cdn.openfin.co/docs/javascript/canary/Platform.html'
196
+ * }
197
+ * },
198
+ * {
199
+ * type: 'component',
200
+ * componentName: 'view',
201
+ * componentState: {
202
+ * name: 'test_view_2',
203
+ * url: 'https://cdn.openfin.co/docs/javascript/canary/Platform.html'
204
+ * }
205
+ * }
206
+ * ]
207
+ * }
208
+ * ]
209
+ * }
210
+ * }).then(console.log);
211
+ * ```
212
+ * The Default Window's design can be customized by specifying the `stylesheetUrl` property in the manifest:
213
+ *
214
+ * ```json
215
+ * {
216
+ * platform: {
217
+ * defaultWindowOptions: {
218
+ * stylesheetUrl: 'some-url.css',
219
+ * ...
220
+ * }
221
+ * }
222
+ * }
223
+ * ```
224
+ * For a list of common Layout CSS classes you can override in your custom stylesheet, see <a href="tutorial-layoutStyles.html">Useful Layout CSS Classes</a>
225
+ **
226
+ * To specify a Platform Custom Window, provide a `url` property when creating a Window.
227
+ * If you intend to render a Layout in your Custom Window, you must also specify an `HTMLElement` that the Layout will inject into and set its `id` property to `"layout-container"`.
228
+ *
229
+ * The example below will create a Platform Custom Window:
230
+ *
231
+ * ```js
232
+ * // in an OpenFin app:
233
+ * const platform = fin.Platform.getCurrentSync();
234
+ * const windowConfig =
235
+ * {
236
+ * url: "https://www.my-domain.com/my-custom-window.html", // here we point to where the Custom Frame is hosted.
237
+ * layout: {
238
+ * content: [
239
+ * {
240
+ * type: "stack",
241
+ * content: [
242
+ * {
243
+ * type: "component",
244
+ * componentName: "view",
245
+ * componentState: {
246
+ * name: "app #1",
247
+ * url: "https://cdn.openfin.co/docs/javascript/canary/Platform.html"
248
+ * }
249
+ * },
250
+ * {
251
+ * type: "component",
252
+ * componentName: "view",
253
+ * componentState: {
254
+ * name: "app #2",
255
+ * url: "https://cdn.openfin.co/docs/javascript/canary/Platform.html"
256
+ * }
257
+ * }
258
+ * ]
259
+ * }
260
+ * ]
261
+ * }
262
+ * };
263
+ * platform.createWindow(windowConfig);
264
+ * ```
265
+ *
266
+ * Here's an example of a minimalist Custom Platform Window implementation:
267
+ * ```html
268
+ * <html>
269
+ * <head>
270
+ * <meta charset="utf-8">
271
+ * <meta name="viewport" content="width=device-width, initial-scale=1">
272
+ * <link rel="stylesheet" type="text/css" href="./styles.css">
273
+ * </head>
274
+ * <body>
275
+ * <div id="of-frame-main">
276
+ * <div id="title-bar">
277
+ * <div class="title-bar-draggable">
278
+ * <div id="title"> This is a custom frame! </div>
279
+ * </div>
280
+ * <div id="buttons-wrapper">
281
+ * <div class="button" id="minimize-button"></div>
282
+ * <div class="button" id="expand-button"></div>
283
+ * <div class="button" id="close-button"></div>
284
+ * </div>
285
+ * </div>
286
+ * <div id="layout-container"></div> <!-- OpenFin layout would be injected here -->
287
+ * <script src="./custom-frame.js"></script>
288
+ * </div>
289
+ * </body>
290
+ * </html>
291
+ * ```
292
+ * Your Custom Window can use in-domain resources for further customization (such as CSS, scripts, etc.).<br>
293
+ * For a list of common Layout CSS classes you can override in your stylesheet, see <a href="tutorial-layoutStyles.html">Useful Layout CSS Classes</a>
294
+ *
295
+ * The example above will require the `body` element to have `height: 100%;` set in order to render the layout correctly.
94
296
  */
95
297
  async createWindow(options) {
96
298
  this.wire.sendAction('platform-create-window', this.identity).catch((e) => {
@@ -113,8 +315,13 @@ class Platform extends base_1.EmitterBase {
113
315
  }
114
316
  /**
115
317
  * Closes current platform, all its windows, and their views.
116
- * @return { Promise<void> }
117
- * @tutorial Platform.quit
318
+ *
319
+ * @example
320
+ * ```js
321
+ * const platform = await fin.Platform.getCurrent();
322
+ * platform.quit();
323
+ * // All windows/views in current layout platform will close and platform will shut down
324
+ * ```
118
325
  */
119
326
  async quit() {
120
327
  this.wire.sendAction('platform-quit', this.identity).catch((e) => {
@@ -125,9 +332,39 @@ class Platform extends base_1.EmitterBase {
125
332
  }
126
333
  /**
127
334
  * Closes a specified view in a target window.
128
- * @param { Identity } viewIdentity View identity
129
- * @return { Promise<void> }
130
- * @tutorial Platform.closeView
335
+ * @param viewIdentity View identity
336
+ *
337
+ * @example
338
+ * ```js
339
+ * let windowIdentity;
340
+ * if (fin.me.isWindow) {
341
+ * windowIdentity = fin.me.identity;
342
+ * } else if (fin.me.isView) {
343
+ * windowIdentity = (await fin.me.getCurrentWindow()).identity;
344
+ * } else {
345
+ * throw new Error('Not running in a platform View or Window');
346
+ * }
347
+ *
348
+ * const viewOptions = {
349
+ * name: 'test_view',
350
+ * url: 'https://example.com'
351
+ * };
352
+ *
353
+ * function sleep(ms) {
354
+ * return new Promise(resolve => setTimeout(resolve, ms));
355
+ * }
356
+ *
357
+ * const platform = await fin.Platform.getCurrent();
358
+ *
359
+ * await platform.createView(viewOptions, windowIdentity);
360
+ * // a new view will now show in the current window
361
+ *
362
+ * await sleep(5000);
363
+ *
364
+ * const viewIdentity = { uuid: windowIdentity.uuid, name: 'test_view'};
365
+ * platform.closeView(viewIdentity);
366
+ * // the view will now close
367
+ * ```
131
368
  */
132
369
  async closeView(viewIdentity) {
133
370
  this.wire.sendAction('platform-close-view', this.identity).catch((e) => {
@@ -141,9 +378,9 @@ class Platform extends base_1.EmitterBase {
141
378
  /**
142
379
  * ***DEPRECATED - please use Platform.createView.***
143
380
  * Reparents a specified view in a new target window.
144
- * @param { Identity } viewIdentity View identity
145
- * @param { Identity } target new owner window identity
146
- * @return { Promise<View> }
381
+ * @param viewIdentity View identity
382
+ * @param target new owner window identity
383
+ *
147
384
  * @tutorial Platform.createView
148
385
  */
149
386
  async reparentView(viewIdentity, target) {
@@ -162,11 +399,18 @@ class Platform extends base_1.EmitterBase {
162
399
  return this.createView(viewOptions, target);
163
400
  }
164
401
  /**
165
- * Returns a snapshot of the platform in its current state.
402
+ * Returns a snapshot of the platform in its current state. You can pass the returning object to
403
+ * [Platform.applySnapshot]{@link Platform#applySnapshot} to launch it.
404
+ *
405
+ * @remarks The snapshot will include details such as an [ISO format](https://en.wikipedia.org/wiki/ISO_8601)
406
+ * timestamp of when the snapshot was taken, OpenFin runtime version the platform is running on, monitor information
407
+ * and the list of currently running windows.
166
408
  *
167
- * Can be used to restore an application to a previous state.
168
- * @return { Promise<Snapshot> }
169
- * @tutorial Platform.getSnapshot
409
+ * @example
410
+ * ```js
411
+ * const platform = await fin.Platform.getCurrent();
412
+ * const snapshot = await platform.getSnapshot();
413
+ * ```
170
414
  */
171
415
  async getSnapshot() {
172
416
  this.wire.sendAction('platform-get-snapshot', this.identity).catch((e) => {
@@ -182,11 +426,25 @@ class Platform extends base_1.EmitterBase {
182
426
  *
183
427
  * Can be used to restore a view to a previous state.
184
428
  *
185
- * @param { Identity } viewIdentity View identity
186
- * @returns { Promise<ViewState> }
429
+ * @param viewIdentity View identity
430
+ *
187
431
  * @internal
188
432
  * @experimental
189
- * @tutorial Platform.getViewSnapshot
433
+ * @remarks This slice of snapshot state is equivalent to what is stored as `componentState` for views
434
+ * when capturing platform state using [Platform.getSnapshot]{@link Platform#getSnapshot}.
435
+ *
436
+ * @example
437
+ * ```js
438
+ * const platform = await fin.Platform.getCurrent();
439
+ * const url = 'https://google.com';
440
+ * const view = await fin.View.create({ name: 'my-view', target: fin.me.identity, url });
441
+ *
442
+ * await view.navigate(url);
443
+ *
444
+ * const viewState = await platform.getViewSnapshot(view.identity);
445
+ *
446
+ * console.log(viewState);
447
+ * ```
190
448
  */
191
449
  async getViewSnapshot(viewIdentity) {
192
450
  const client = await this.getClient();
@@ -200,10 +458,119 @@ class Platform extends base_1.EmitterBase {
200
458
  *
201
459
  * The function accepts either a snapshot taken using {@link Platform#getSnapshot getSnapshot},
202
460
  * or a url or filepath to a snapshot JSON object.
203
- * @param { Snapshot | string } requestedSnapshot Snapshot to apply, or a url or filepath.
204
- * @param { ApplySnapshotOptions } [options] Optional parameters to specify whether existing windows should be closed.
205
- * @return { Promise<Platform> }
206
- * @tutorial Platform.applySnapshot
461
+ * @param requestedSnapshot Snapshot to apply, or a url or filepath.
462
+ * @param options Optional parameters to specify whether existing windows should be closed.
463
+ *
464
+ * @remarks Will create any windows and views that are not running but are passed in the snapshot object. Any View
465
+ * specified in the snapshot is assigned a randomly generated name to avoid collisions.
466
+ *
467
+ * @example
468
+ * ```js
469
+ * // Get a wrapped layout platform instance
470
+ * const platform = await fin.Platform.getCurrent();
471
+ *
472
+ * const snapshot = {
473
+ * windows: [
474
+ * {
475
+ * layout: {
476
+ * content: [
477
+ * {
478
+ * type: 'stack',
479
+ * content: [
480
+ * {
481
+ * type: 'component',
482
+ * componentName: 'view',
483
+ * componentState: {
484
+ * name: 'component_X',
485
+ * url: 'https://www.openfin.co'
486
+ * }
487
+ * },
488
+ * {
489
+ * type: 'component',
490
+ * componentName: 'view',
491
+ * componentState: {
492
+ * name: 'component_Y',
493
+ * url: 'https://cdn.openfin.co/embed-web/chart.html'
494
+ * }
495
+ * }
496
+ * ]
497
+ * }
498
+ * ]
499
+ * }
500
+ * }
501
+ * ]
502
+ * }
503
+ *
504
+ * platform.applySnapshot(snapshot);
505
+ * ```
506
+ *
507
+ * In place of a snapshot object, `applySnapshot` can take a url or filepath and to retrieve a JSON snapshot.
508
+ *
509
+ * ```js
510
+ * const platform = await fin.Platform.getCurrent();
511
+ * platform.applySnapshot('https://api.jsonbin.io/b/5e6f903ef4331e681fc1231d/1');
512
+ * ```
513
+ *
514
+ * Optionally, `applySnapshot` can close existing windows and restore a Platform to a previously saved state.
515
+ * This is accomplished by providing `{ closeExistingWindows: true }` as an option.
516
+ *
517
+ * ```js
518
+ * // Get a wrapped layout platform instance
519
+ * const platform = await fin.Platform.getCurrent();
520
+ *
521
+ * async function addViewToWindow(winId) {
522
+ * return await platform.createView({
523
+ * name: 'test_view_3',
524
+ * url: 'https://openfin.co'
525
+ * }, winId);
526
+ * }
527
+ *
528
+ * async function createWindowWithTwoViews() {
529
+ * const platform = await fin.Platform.getCurrent();
530
+ *
531
+ * return platform.createWindow({
532
+ * layout: {
533
+ * content: [
534
+ * {
535
+ * type: 'stack',
536
+ * content: [
537
+ * {
538
+ * type: 'component',
539
+ * componentName: 'view',
540
+ * componentState: {
541
+ * name: 'test_view_1',
542
+ * url: 'https://example.com'
543
+ * }
544
+ * },
545
+ * {
546
+ * type: 'component',
547
+ * componentName: 'view',
548
+ * componentState: {
549
+ * name: 'test_view_2',
550
+ * url: 'https://yahoo.com'
551
+ * }
552
+ * }
553
+ * ]
554
+ * }
555
+ * ]
556
+ * }
557
+ * });
558
+ * }
559
+ *
560
+ * const win = await createWindowWithTwoViews();
561
+ * // ... you will now see a new window with two views in it
562
+ *
563
+ * // we take a snapshot of the current state of the app, before changing it
564
+ * const snapshotOfInitialAppState = await platform.getSnapshot();
565
+ *
566
+ * // now let's change the state of the app:
567
+ * await addViewToWindow(win.identity);
568
+ * // ... the window now has three views in it
569
+ *
570
+ * await platform.applySnapshot(snapshotOfInitialAppState, { closeExistingWindows: true });
571
+ * // ... the window will revert to previous state, with just two views
572
+ *
573
+ * ```
207
574
  */
208
575
  async applySnapshot(requestedSnapshot, options) {
209
576
  this.wire.sendAction('platform-apply-snapshot', this.identity).catch((e) => {
@@ -238,10 +605,18 @@ class Platform extends base_1.EmitterBase {
238
605
  }
239
606
  /**
240
607
  * Fetches a JSON manifest using the browser process and returns a Javascript object.
241
- * Can be overwritten using {@link Platform#init Platform.init}.
242
- * @param { string } manifestUrl The URL of the manifest to fetch.
243
- * @return { Promise<any> }
244
- * @tutorial Platform.fetchManifest
608
+ * Can be overwritten using {@link Platform.PlatformModule.init Platform.init}.
609
+ * @param manifestUrl The URL of the manifest to fetch.
610
+ *
611
+ * @remarks Can be overwritten using {@link Platform#init Platform.init}.
612
+ *
613
+ * @example
614
+ *
615
+ * ```js
616
+ * const platform = fin.Platform.getCurrentSync();
617
+ * const manifest = await platform.fetchManifest('https://www.path-to-manifest.com/app.json');
618
+ * console.log(manifest);
619
+ * ```
245
620
  */
246
621
  async fetchManifest(manifestUrl) {
247
622
  const client = await this.getClient();
@@ -250,11 +625,32 @@ class Platform extends base_1.EmitterBase {
250
625
  /**
251
626
  * Retrieves a manifest by url and launches a legacy application manifest or snapshot into the platform. Returns a promise that
252
627
  * resolves to the wrapped Platform.
253
- * @param {string} manifestUrl - The URL of the manifest that will be launched into the platform. If this app manifest
628
+ * @param manifestUrl - The URL of the manifest that will be launched into the platform. If this app manifest
254
629
  * contains a snapshot, that will be launched into the platform. If not, the application described in startup_app options
255
- * will be launched into the platform. The applicable startup_app options will become {@link View~options View Options}.
256
- * @return {Promise<Platform>}
257
- * @tutorial Platform.launchContentManifest
630
+ * will be launched into the platform. The applicable startup_app options will become {@link OpenFin.ViewCreationOptions View Options}.
631
+ *
632
+ * @remarks If the app manifest contains a snapshot, that will be launched into the platform. If not, the
633
+ * application described in startup_app options will be launched into the platform as a window with a single view.
634
+ * The applicable startup_app options will become View Options.
635
+ *
636
+ * @example
637
+ * ```js
638
+ * try {
639
+ * const platform = fin.Platform.getCurrentSync();
640
+ * await platform.launchContentManifest('http://localhost:5555/app.json');
641
+ * console.log(`content launched successfully into platform`);
642
+ * } catch(e) {
643
+ * console.error(e);
644
+ * }
645
+ * // For a local manifest file:
646
+ * try {
647
+ * const platform = fin.Platform.getCurrentSync();
648
+ * platform.launchContentManifest('file:///C:/somefolder/app.json');
649
+ * console.log(`content launched successfully into platform`);
650
+ * } catch(e) {
651
+ * console.error(e);
652
+ * }
653
+ * ```
258
654
  * @experimental
259
655
  */
260
656
  async launchContentManifest(manifestUrl) {
@@ -269,11 +665,76 @@ class Platform extends base_1.EmitterBase {
269
665
  /**
270
666
  * 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.
271
667
  * It can be retrieved using {@link Platform#getWindowContext getWindowContext}.
272
- * @param {any} context - A field where serializable context data can be stored to be saved in platform snapshots.
273
- * @param {Identity} [target] - A target window or view may optionally be provided. If no target is provided, the update will be applied
668
+ * @param context - A field where serializable context data can be stored to be saved in platform snapshots.
669
+ * @param target - A target window or view may optionally be provided. If no target is provided, the update will be applied
274
670
  * to the current window (if called from a Window) or the current host window (if called from a View).
275
- * @return {Promise<void>}
276
- * @tutorial Platform.setWindowContext
671
+ *
672
+ * @remarks The context data must be serializable. This can only be called from a window or view that has been launched into a
673
+ * platform.
674
+ * This method can be called from the window itself, or from any child view. Context data is shared by all
675
+ * entities within a window.
676
+ *
677
+ * @example
678
+ * Setting own context:
679
+ * ```js
680
+ * const platform = fin.Platform.getCurrentSync();
681
+ * const contextData = {
682
+ * security: 'STOCK',
683
+ * currentView: 'detailed'
684
+ * }
685
+ *
686
+ * await platform.setWindowContext(contextData);
687
+ * // Context of current window is now set to `contextData`
688
+ * ```
689
+ *
690
+ * Setting the context of another window or view:
691
+ * ```js
692
+ * const platform = fin.Platform.getCurrentSync();
693
+ * const contextData = {
694
+ * security: 'STOCK',
695
+ * currentView: 'detailed'
696
+ * }
697
+ *
698
+ * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
699
+ * await platform.setWindowContext(contextData, windowOrViewIdentity);
700
+ * // Context of the target window or view is now set to `contextData`
701
+ * ```
702
+ *
703
+ * A view can listen to changes to its host window's context by listening to the `host-context-changed` event.
704
+ * This event will fire when a host window's context is updated or when the view is reparented to a new window:
705
+ *
706
+ * ```js
707
+ * // From a view
708
+ * const contextChangeHandler = ({ context }) => {
709
+ * console.log('Host window\'s context has changed. New context data:', context);
710
+ * // react to new context data here
711
+ * }
712
+ * await fin.me.on('host-context-changed', contextChangeHandler);
713
+ *
714
+ * const platform = await fin.Platform.getCurrentSync();
715
+ * const contextData = {
716
+ * security: 'STOCK',
717
+ * currentView: 'detailed'
718
+ * }
719
+ * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
720
+ * ```
721
+ *
722
+ * To listen to a window's context updates, use the `context-changed` event:
723
+ * ```js
724
+ * // From a window
725
+ * const contextChangeHandler = ({ context }) => {
726
+ * console.log('This window\'s context has changed. New context data:', context);
727
+ * // react to new context data here
728
+ * }
729
+ * await fin.me.on('context-changed', contextChangeHandler);
730
+ *
731
+ * const platform = await fin.Platform.getCurrentSync();
732
+ * const contextData = {
733
+ * security: 'STOCK',
734
+ * currentView: 'detailed'
735
+ * }
736
+ * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
737
+ * ```
277
738
  * @experimental
278
739
  */
279
740
  async setWindowContext(context = {}, target) {
@@ -294,10 +755,33 @@ class Platform extends base_1.EmitterBase {
294
755
  /**
295
756
  * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
296
757
  * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
297
- * @param {Identity} [target] - A target window or view may optionally be provided. If no target is provided, target will be
758
+ * @param target - A target window or view may optionally be provided. If no target is provided, target will be
298
759
  * the current window (if called from a Window) or the current host window (if called from a View).
299
- * @return {Promise<any>}
300
- * @tutorial Platform.getWindowContext
760
+ *
761
+ * @remarks This method can be called from the window itself, or from any child view. Context data is shared
762
+ * by all entities within a window.
763
+ *
764
+ * @example
765
+ *
766
+ * Retrieving context from current window:
767
+ * ```js
768
+ * const platform = fin.Platform.getCurrentSync();
769
+ * const customContext = { answer: 42 };
770
+ * await platform.setWindowContext(customContext);
771
+ *
772
+ * const myContext = await platform.getWindowContext();
773
+ * console.log(myContext); // { answer: 42 }
774
+ * ```
775
+ *
776
+ * Retrieving the context of another window or view:
777
+ * ```js
778
+ * const platform = fin.Platform.getCurrentSync();
779
+ *
780
+ * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
781
+ *
782
+ * const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
783
+ * console.log(targetWindowContext); // context of target window
784
+ * ```
301
785
  * @experimental
302
786
  */
303
787
  async getWindowContext(target) {
@@ -314,10 +798,28 @@ class Platform extends base_1.EmitterBase {
314
798
  /**
315
799
  * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
316
800
  * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
317
- * @param {Identity} winId
318
- * @param {closeWindowoptions} [options]
319
- * @returns {Promise<void>}
320
- * @tutorial Platform.closeWindow
801
+ * @param winId
802
+ * @param options
803
+ *
804
+ * @remarks This method works by setting a `close-requested` handler on the Platform Window. If you have your own `close-requested` handler set on the Platform Window as well,
805
+ * it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
806
+ *
807
+ * @example
808
+ *
809
+ * ```js
810
+ * // Close the current Window inside a Window context
811
+ * const platform = await fin.Platform.getCurrent();
812
+ * platform.closeWindow(fin.me.identity);
813
+ *
814
+ * // Close the Window from inside a View context
815
+ * const platform = await fin.Platform.getCurrent();
816
+ * const parentWindow = await fin.me.getCurrentWindow();
817
+ * platform.closeWindow(parentWindow.identity);
818
+ *
819
+ * // Close the Window and do not fire the before unload handler on Views
820
+ * const platform = await fin.Platform.getCurrent();
821
+ * platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
822
+ * ```
321
823
  * @experimental
322
824
  */
323
825
  async closeWindow(windowId, options = { skipBeforeUnload: false }) {