@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
@@ -6,12 +6,13 @@ const base_1 = require("../base");
6
6
  const window_1 = require("../window");
7
7
  const view_1 = require("../view");
8
8
  /**
9
- * @classdesc An object representing an application. Allows the developer to create,
10
- * execute, show/close an application as well as listen to <a href="tutorial-Application.EventEmitter.html">application events</a>.
11
- * @class
12
- * @hideconstructor
9
+ * An object representing an application. Allows the developer to create,
10
+ * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
13
11
  */
14
12
  class Application extends base_1.EmitterBase {
13
+ /**
14
+ * @internal
15
+ */
15
16
  constructor(wire, identity) {
16
17
  super(wire, 'application', identity.uuid);
17
18
  this.identity = identity;
@@ -32,10 +33,10 @@ class Application extends base_1.EmitterBase {
32
33
  }
33
34
  /**
34
35
  * Adds a listener to the end of the listeners array for the specified event.
35
- * @param { string | symbol } eventType - The type of the event.
36
- * @param { Function } listener - Called whenever an event of the specified type occurs.
37
- * @param { SubOptions } [options] - Option to support event timestamps.
38
- * @return {Promise.<this>}
36
+ * @param eventType - The type of the event.
37
+ * @param listener - Called whenever an event of the specified type occurs.
38
+ * @param options - Option to support event timestamps.
39
+ *
39
40
  * @function addListener
40
41
  * @memberof Application
41
42
  * @instance
@@ -43,10 +44,10 @@ class Application extends base_1.EmitterBase {
43
44
  */
44
45
  /**
45
46
  * Adds a listener to the end of the listeners array for the specified event.
46
- * @param { string | symbol } eventType - The type of the event.
47
- * @param { Function } listener - Called whenever an event of the specified type occurs.
48
- * @param { SubOptions } [options] - Option to support event timestamps.
49
- * @return {Promise.<this>}
47
+ * @param eventType - The type of the event.
48
+ * @param listener - Called whenever an event of the specified type occurs.
49
+ * @param options - Option to support event timestamps.
50
+ *
50
51
  * @function on
51
52
  * @memberof Application
52
53
  * @instance
@@ -54,10 +55,10 @@ class Application extends base_1.EmitterBase {
54
55
  */
55
56
  /**
56
57
  * Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.
57
- * @param { string | symbol } eventType - The type of the event.
58
- * @param { Function } listener - The callback function.
59
- * @param { SubOptions } [options] - Option to support event timestamps.
60
- * @return {Promise.<this>}
58
+ * @param eventType - The type of the event.
59
+ * @param listener - The callback function.
60
+ * @param options - Option to support event timestamps.
61
+ *
61
62
  * @function once
62
63
  * @memberof Application
63
64
  * @instance
@@ -65,10 +66,10 @@ class Application extends base_1.EmitterBase {
65
66
  */
66
67
  /**
67
68
  * Adds a listener to the beginning of the listeners array for the specified event.
68
- * @param { string | symbol } eventType - The type of the event.
69
- * @param { Function } listener - The callback function.
70
- * @param { SubOptions } [options] - Option to support event timestamps.
71
- * @return {Promise.<this>}
69
+ * @param eventType - The type of the event.
70
+ * @param listener - The callback function.
71
+ * @param options - Option to support event timestamps.
72
+ *
72
73
  * @function prependListener
73
74
  * @memberof Application
74
75
  * @instance
@@ -77,10 +78,10 @@ class Application extends base_1.EmitterBase {
77
78
  /**
78
79
  * Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.
79
80
  * The listener is added to the beginning of the listeners array.
80
- * @param { string | symbol } eventType - The type of the event.
81
- * @param { Function } listener - The callback function.
82
- * @param { SubOptions } [options] - Option to support event timestamps.
83
- * @return {Promise.<this>}
81
+ * @param eventType - The type of the event.
82
+ * @param listener - The callback function.
83
+ * @param options - Option to support event timestamps.
84
+ *
84
85
  * @function prependOnceListener
85
86
  * @memberof Application
86
87
  * @instance
@@ -89,10 +90,10 @@ class Application extends base_1.EmitterBase {
89
90
  /**
90
91
  * Remove a listener from the listener array for the specified event.
91
92
  * Caution: Calling this method changes the array indices in the listener array behind the listener.
92
- * @param { string | symbol } eventType - The type of the event.
93
- * @param { Function } listener - The callback function.
94
- * @param { SubOptions } [options] - Option to support event timestamps.
95
- * @return {Promise.<this>}
93
+ * @param eventType - The type of the event.
94
+ * @param listener - The callback function.
95
+ * @param options - Option to support event timestamps.
96
+ *
96
97
  * @function removeListener
97
98
  * @memberof Application
98
99
  * @instance
@@ -100,18 +101,13 @@ class Application extends base_1.EmitterBase {
100
101
  */
101
102
  /**
102
103
  * Removes all listeners, or those of the specified event.
103
- * @param { string | symbol } [eventType] - The type of the event.
104
- * @return {Promise.<this>}
104
+ * @param eventType - The type of the event.
105
+ *
105
106
  * @function removeAllListeners
106
107
  * @memberof Application
107
108
  * @instance
108
109
  * @tutorial Application.EventEmitter
109
110
  */
110
- /**
111
- * Determines if the application is currently running.
112
- * @return {Promise.<boolean>}
113
- * @tutorial Application.isRunning
114
- */
115
111
  /**
116
112
  * JumpListCategory interface
117
113
  * @typedef { object } JumpListCategory
@@ -129,16 +125,40 @@ class Application extends base_1.EmitterBase {
129
125
  * @property { string } iconPath The absolute path to an icon to be displayed for the item, which can be an arbitrary resource file that contains an icon (e.g. .ico, .exe, .dll).
130
126
  * @property { number } iconIndex The index of the icon in the resource file. If a resource file contains multiple icons this value can be used to specify the zero-based index of the icon that should be displayed for this task. If a resource file contains only one icon, this property should be set to zero.
131
127
  */
128
+ /**
129
+ * Determines if the application is currently running.
130
+ *
131
+ * @example
132
+ *
133
+ * ```js
134
+ * async function isAppRunning() {
135
+ * const app = await fin.Application.getCurrent();
136
+ * return await app.isRunning();
137
+ * }
138
+ * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
139
+ * ```
140
+ */
132
141
  isRunning() {
133
142
  return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
134
143
  }
135
144
  /**
136
145
  * Closes the application and any child windows created by the application.
137
146
  * Cleans the application from state so it is no longer found in getAllApplications.
138
- * @param { boolean } [force = false] Close will be prevented from closing when force is false and
147
+ * @param force Close will be prevented from closing when force is false and
139
148
  * ‘close-requested’ has been subscribed to for application’s main window.
140
- * @return {Promise.<boolean>}
141
- * @tutorial Application.quit
149
+ *
150
+ * @example
151
+ *
152
+ * ```js
153
+ * async function closeApp() {
154
+ * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
155
+ * const app = await fin.Application.wrap({uuid: 'app2'});
156
+ * await app.quit();
157
+ * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
158
+ *
159
+ * }
160
+ * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
161
+ * ```
142
162
  */
143
163
  async quit(force = false) {
144
164
  try {
@@ -162,6 +182,23 @@ class Application extends base_1.EmitterBase {
162
182
  }
163
183
  }
164
184
  }
185
+ /**
186
+ * @deprecated use Application.quit instead
187
+ * Closes the application and any child windows created by the application.
188
+ * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
189
+ * @param callback - called if the method succeeds.
190
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
191
+ *
192
+ * @example
193
+ *
194
+ * ```js
195
+ * async function closeApp() {
196
+ * const app = await fin.Application.getCurrent();
197
+ * return await app.close();
198
+ * }
199
+ * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
200
+ * ```
201
+ */
165
202
  close(force = false) {
166
203
  console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
167
204
  this.wire.sendAction('application-close', this.identity).catch((e) => {
@@ -171,8 +208,17 @@ class Application extends base_1.EmitterBase {
171
208
  }
172
209
  /**
173
210
  * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
174
- * @return {Promise.Array.<_Window>}
175
- * @tutorial Application.getChildWindows
211
+ *
212
+ * @example
213
+ *
214
+ * ```js
215
+ * async function getChildWindows() {
216
+ * const app = await fin.Application.getCurrent();
217
+ * return await app.getChildWindows();
218
+ * }
219
+ *
220
+ * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
221
+ * ```
176
222
  */
177
223
  getChildWindows() {
178
224
  return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
@@ -186,8 +232,17 @@ class Application extends base_1.EmitterBase {
186
232
  /**
187
233
  * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
188
234
  * if the application was not created from a manifest.
189
- * @return {Promise.<Manifest>}
190
- * @tutorial Application.getManifest
235
+ *
236
+ * @example
237
+ *
238
+ * ```js
239
+ * async function getManifest() {
240
+ * const app = await fin.Application.getCurrent();
241
+ * return await app.getManifest();
242
+ * }
243
+ *
244
+ * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
245
+ * ```
191
246
  */
192
247
  getManifest() {
193
248
  return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
@@ -195,16 +250,38 @@ class Application extends base_1.EmitterBase {
195
250
  /**
196
251
  * Retrieves UUID of the application that launches this application. Invokes the error callback
197
252
  * if the application was created from a manifest.
198
- * @return {Promise.<string>}
199
- * @tutorial Application.getParentUuid
253
+ *
254
+ * @example
255
+ *
256
+ * ```js
257
+ * async function getParentUuid() {
258
+ * const app = await fin.Application.start({
259
+ * uuid: 'app-1',
260
+ * name: 'myApp',
261
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
262
+ * autoShow: true
263
+ * });
264
+ * return await app.getParentUuid();
265
+ * }
266
+ *
267
+ * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
268
+ * ```
200
269
  */
201
270
  getParentUuid() {
202
271
  return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
203
272
  }
204
273
  /**
205
274
  * Retrieves current application's shortcut configuration.
206
- * @return {Promise.<ShortCutConfig>}
207
- * @tutorial Application.getShortcuts
275
+ *
276
+ * @example
277
+ *
278
+ * ```js
279
+ * async function getShortcuts() {
280
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
281
+ * return await app.getShortcuts();
282
+ * }
283
+ * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
284
+ * ```
208
285
  */
209
286
  getShortcuts() {
210
287
  return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
@@ -212,8 +289,16 @@ class Application extends base_1.EmitterBase {
212
289
  /**
213
290
  * Retrieves current application's views.
214
291
  * @experimental
215
- * @return {Promise.Array.<View>}
216
- * @tutorial Application.getViews
292
+ *
293
+ * @example
294
+ *
295
+ * ```js
296
+ * async function getViews() {
297
+ * const app = await fin.Application.getCurrent();
298
+ * return await app.getViews();
299
+ * }
300
+ * getViews().then(views => console.log(views)).catch(err => console.log(err));
301
+ * ```
217
302
  */
218
303
  async getViews() {
219
304
  const { payload } = await this.wire.sendAction('application-get-views', this.identity);
@@ -221,16 +306,42 @@ class Application extends base_1.EmitterBase {
221
306
  }
222
307
  /**
223
308
  * Returns the current zoom level of the application.
224
- * @return {Promise.<number>}
225
- * @tutorial Application.getZoomLevel
309
+ *
310
+ * @example
311
+ *
312
+ * ```js
313
+ * async function getZoomLevel() {
314
+ * const app = await fin.Application.getCurrent();
315
+ * return await app.getZoomLevel();
316
+ * }
317
+ *
318
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
319
+ * ```
226
320
  */
227
321
  getZoomLevel() {
228
322
  return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
229
323
  }
230
324
  /**
231
325
  * Returns an instance of the main Window of the application
232
- * @return {Promise.<_Window>}
233
- * @tutorial Application.getWindow
326
+ *
327
+ * @example
328
+ *
329
+ * ```js
330
+ * async function getWindow() {
331
+ * const app = await fin.Application.start({
332
+ * uuid: 'app-1',
333
+ * name: 'myApp',
334
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
335
+ * autoShow: true
336
+ * });
337
+ * return await app.getWindow();
338
+ * }
339
+ *
340
+ * getWindow().then(win => {
341
+ * win.showAt(0, 400);
342
+ * win.flash();
343
+ * }).catch(err => console.log(err));
344
+ * ```
234
345
  */
235
346
  getWindow() {
236
347
  this.wire.sendAction('application-get-window', this.identity).catch((e) => {
@@ -240,26 +351,52 @@ class Application extends base_1.EmitterBase {
240
351
  }
241
352
  /**
242
353
  * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
243
- * @param { string } userName - username to be passed to the RVM.
244
- * @param { string } appName - app name to be passed to the RVM.
245
- * @return {Promise.<void>}
246
- * @tutorial Application.registerUser
354
+ * @param userName - username to be passed to the RVM.
355
+ * @param appName - app name to be passed to the RVM.
356
+ *
357
+ * @example
358
+ *
359
+ * ```js
360
+ * async function registerUser() {
361
+ * const app = await fin.Application.getCurrent();
362
+ * return await app.registerUser('user', 'myApp');
363
+ * }
364
+ *
365
+ * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
366
+ * ```
247
367
  */
248
368
  registerUser(userName, appName) {
249
369
  return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
250
370
  }
251
371
  /**
252
372
  * Removes the application’s icon from the tray.
253
- * @return {Promise.<void>}
254
- * @tutorial Application.removeTrayIcon
373
+ *
374
+ * @example
375
+ *
376
+ * ```js
377
+ * async function removeTrayIcon() {
378
+ * const app = await fin.Application.getCurrent();
379
+ * return await app.removeTrayIcon();
380
+ * }
381
+ *
382
+ * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
383
+ * ```
255
384
  */
256
385
  removeTrayIcon() {
257
386
  return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
258
387
  }
259
388
  /**
260
389
  * Restarts the application.
261
- * @return {Promise.<void>}
262
- * @tutorial Application.restart
390
+ *
391
+ * @example
392
+ *
393
+ * ```js
394
+ * async function restartApp() {
395
+ * const app = await fin.Application.getCurrent();
396
+ * return await app.restart();
397
+ * }
398
+ * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
399
+ * ```
263
400
  */
264
401
  restart() {
265
402
  return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
@@ -267,8 +404,22 @@ class Application extends base_1.EmitterBase {
267
404
  /**
268
405
  * DEPRECATED method to run the application.
269
406
  * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
270
- * @return {Promise.<void>}
271
- * @tutorial Application.run
407
+ *
408
+ * @example
409
+ *
410
+ * ```js
411
+ * async function run() {
412
+ * const app = await fin.Application.create({
413
+ * name: 'myApp',
414
+ * uuid: 'app-1',
415
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
416
+ * autoShow: true
417
+ * });
418
+ * await app.run();
419
+ * }
420
+ * run().then(() => console.log('Application is running')).catch(err => console.log(err));
421
+ * ```
422
+ *
272
423
  * @ignore
273
424
  */
274
425
  run() {
@@ -289,8 +440,17 @@ class Application extends base_1.EmitterBase {
289
440
  }
290
441
  /**
291
442
  * Instructs the RVM to schedule one restart of the application.
292
- * @return {Promise.<void>}
293
- * @tutorial Application.scheduleRestart
443
+ *
444
+ * @example
445
+ *
446
+ * ```js
447
+ * async function scheduleRestart() {
448
+ * const app = await fin.Application.getCurrent();
449
+ * return await app.scheduleRestart();
450
+ * }
451
+ *
452
+ * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
453
+ * ```
294
454
  */
295
455
  scheduleRestart() {
296
456
  return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
@@ -298,8 +458,17 @@ class Application extends base_1.EmitterBase {
298
458
  /**
299
459
  * Sends a message to the RVM to upload the application's logs. On success,
300
460
  * an object containing logId is returned.
301
- * @return {Promise.<SendApplicationLogResponse>}
302
- * @tutorial Application.sendApplicationLog
461
+ *
462
+ * @example
463
+ *
464
+ * ```js
465
+ * async function sendLog() {
466
+ * const app = await fin.Application.getCurrent();
467
+ * return await app.sendApplicationLog();
468
+ * }
469
+ *
470
+ * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
471
+ * ```
303
472
  */
304
473
  async sendApplicationLog() {
305
474
  const { payload } = await this.wire.sendAction('send-application-log', this.identity);
@@ -309,18 +478,120 @@ class Application extends base_1.EmitterBase {
309
478
  * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
310
479
  * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
311
480
  * Note: If the "name" property is omitted it defaults to "tasks".
312
- * @param { Array.<JumpListCategory> | null } jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
313
- * @return { Promise.<void> }
314
- * @tutorial Application.setJumpList
481
+ * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
482
+ *
483
+ *
484
+ * @remarks If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
485
+ *
486
+ * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
487
+ * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
488
+ *
489
+ * Note: If the "name" property is omitted it defaults to "tasks".
490
+ *
491
+ * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
492
+ * uuid or shortcut.name is changed.
493
+ *
494
+ * @example
495
+ *
496
+ * ```js
497
+ * const app = fin.Application.getCurrentSync();
498
+ * const appName = 'My App';
499
+ * const jumpListConfig = [ // array of JumpList categories
500
+ * {
501
+ * // has no name and no type so `type` is assumed to be "tasks"
502
+ * items: [ // array of JumpList items
503
+ * {
504
+ * type: 'task',
505
+ * title: `Launch ${appName}`,
506
+ * description: `Runs ${appName} with the default configuration`,
507
+ * deepLink: 'fins://path.to/app/manifest.json',
508
+ * iconPath: 'https://path.to/app/icon.ico',
509
+ * iconIndex: 0
510
+ * },
511
+ * { type: 'separator' },
512
+ * {
513
+ * type: 'task',
514
+ * title: `Restore ${appName}`,
515
+ * description: 'Restore to last configuration',
516
+ * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
517
+ * iconPath: 'https://path.to/app/icon.ico',
518
+ * iconIndex: 0
519
+ * },
520
+ * ]
521
+ * },
522
+ * {
523
+ * name: 'Tools',
524
+ * items: [ // array of JumpList items
525
+ * {
526
+ * type: 'task',
527
+ * title: 'Tool A',
528
+ * description: 'Runs Tool A',
529
+ * deepLink: 'fins://path.to/tool-a/manifest.json',
530
+ * iconPath: 'https://path.to/tool-a/icon.ico',
531
+ * iconIndex: 0
532
+ * },
533
+ * {
534
+ * type: 'task',
535
+ * title: 'Tool B',
536
+ * description: 'Runs Tool B',
537
+ * deepLink: 'fins://path.to/tool-b/manifest.json',
538
+ * iconPath: 'https://path.to/tool-b/icon.ico',
539
+ * iconIndex: 0
540
+ * }]
541
+ * }
542
+ * ];
543
+ *
544
+ * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
545
+ * ```
546
+ *
547
+ * To handle deeplink args:
548
+ * ```js
549
+ * function handleUseLastConfiguration() {
550
+ * // this handler is called when the app is being launched
551
+ * app.on('run-requested', event => {
552
+ * if(event.userAppConfigArgs['use-last-configuration']) {
553
+ * // your logic here
554
+ * }
555
+ * });
556
+ * // this handler is called when the app was already running when the launch was requested
557
+ * fin.desktop.main(function(args) {
558
+ * if(args && args['use-last-configuration']) {
559
+ * // your logic here
560
+ * }
561
+ * });
562
+ * }
563
+ * ```
315
564
  */
316
565
  async setJumpList(jumpListCategories) {
317
566
  await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
318
567
  }
319
568
  /**
320
569
  * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
321
- * @param { string } icon Image URL or base64 encoded string to be used as the icon
322
- * @return {Promise.<void>}
323
- * @tutorial Application.setTrayIcon
570
+ * @param icon Image URL or base64 encoded string to be used as the icon
571
+ *
572
+ * @example
573
+ *
574
+ * ```js
575
+ * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
576
+ * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
577
+ * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
578
+ * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
579
+ * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
580
+ *
581
+ * async function setTrayIcon(icon) {
582
+ * const app = await fin.Application.getCurrent();
583
+ * return await app.setTrayIcon(icon);
584
+ * }
585
+ *
586
+ * // use image url to set tray icon
587
+ * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
588
+ *
589
+ * // use base64 encoded string to set tray icon
590
+ * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
591
+ *
592
+ * // use a dataURL to set tray icon
593
+ * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
594
+ * ```
324
595
  */
325
596
  setTrayIcon(icon) {
326
597
  return this.wire
@@ -332,21 +603,44 @@ class Application extends base_1.EmitterBase {
332
603
  }
333
604
  /**
334
605
  * Sets new application's shortcut configuration. Windows only.
335
- * @param { ShortCutConfig } config New application's shortcut configuration.
336
- * @param { boolean } [config.desktop] - Enable/disable desktop shortcut.
337
- * @param { boolean } [config.startMenu] - Enable/disable start menu shortcut.
338
- * @param { boolean } [config.systemStartup] - Enable/disable system startup shortcut.
339
- * @return {Promise.<void>}
340
- * @tutorial Application.setShortcuts
606
+ * @param config New application's shortcut configuration.
607
+ *
608
+ * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
609
+ * to be able to change shortcut states.
610
+ *
611
+ * @example
612
+ *
613
+ * ```js
614
+ * async function setShortcuts(config) {
615
+ * const app = await fin.Application.getCurrent();
616
+ * return app.setShortcuts(config);
617
+ * }
618
+ *
619
+ * setShortcuts({
620
+ * desktop: true,
621
+ * startMenu: false,
622
+ * systemStartup: true
623
+ * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
624
+ * ```
341
625
  */
342
626
  setShortcuts(config) {
343
627
  return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
344
628
  }
345
629
  /**
346
630
  * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
347
- * @param { string } queryString The new query string for this app's shortcuts.
348
- * @return {Promise.<void>}
349
- * @tutorial Application.setShortcutQueryParams
631
+ * @param queryString The new query string for this app's shortcuts.
632
+ *
633
+ * @example
634
+ *
635
+ * ```js
636
+ * const newQueryArgs = 'arg=true&arg2=false';
637
+ * const app = await fin.Application.getCurrent();
638
+ * try {
639
+ * await app.setShortcutQueryParams(newQueryArgs);
640
+ * } catch(err) {
641
+ * console.error(err)
642
+ * }
643
+ * ```
350
644
  */
351
645
  async setShortcutQueryParams(queryString) {
352
646
  await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
@@ -354,43 +648,84 @@ class Application extends base_1.EmitterBase {
354
648
  /**
355
649
  * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
356
650
  * larger or smaller to default limits of 300% and 50% of original size, respectively.
357
- * @param { number } level The zoom level
358
- * @return {Promise.<void>}
359
- * @tutorial Application.setZoomLevel
651
+ * @param level The zoom level
652
+ *
653
+ * @example
654
+ *
655
+ * ```js
656
+ * async function setZoomLevel(number) {
657
+ * const app = await fin.Application.getCurrent();
658
+ * return await app.setZoomLevel(number);
659
+ * }
660
+ *
661
+ * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
662
+ * ```
360
663
  */
361
664
  setZoomLevel(level) {
362
665
  return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
363
666
  }
364
667
  /**
365
668
  * Sets a username to correlate with App Log Management.
366
- * @param { string } username Username to correlate with App's Log.
367
- * @return {Promise.<void>}
368
- * @tutorial Application.setAppLogUsername
669
+ * @param username Username to correlate with App's Log.
670
+ *
671
+ * @example
672
+ *
673
+ * ```js
674
+ * async function setAppLogUser() {
675
+ * const app = await fin.Application.getCurrent();
676
+ * return await app.setAppLogUsername('username');
677
+ * }
678
+ *
679
+ * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
680
+ *
681
+ * ```
369
682
  */
370
683
  async setAppLogUsername(username) {
371
684
  await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
372
685
  }
373
686
  /**
374
- * @summary Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
375
- * @desc The only information currently returned is the position and dimensions.
376
- * @return {Promise.<TrayInfo>}
377
- * @tutorial Application.getTrayIconInfo
687
+ * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
688
+ * @remarks The only information currently returned is the position and dimensions.
689
+ *
690
+ * @example
691
+ *
692
+ * ```js
693
+ * async function getTrayIconInfo() {
694
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
695
+ * return await app.getTrayIconInfo();
696
+ * }
697
+ * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
698
+ * ```
378
699
  */
379
700
  getTrayIconInfo() {
380
701
  return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
381
702
  }
382
703
  /**
383
- * @summary Checks if the application has an associated tray icon.
384
- * @return {Promise.<boolean>}
385
- * @tutorial Application.hasTrayIcon
704
+ * Checks if the application has an associated tray icon.
705
+ *
706
+ * @example
707
+ *
708
+ * ```js
709
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
710
+ * const hasTrayIcon = await app.hasTrayIcon();
711
+ * console.log(hasTrayIcon);
712
+ * ```
386
713
  */
387
714
  hasTrayIcon() {
388
715
  return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
389
716
  }
390
717
  /**
391
718
  * Closes the application by terminating its process.
392
- * @return {Promise.<void>}
393
- * @tutorial Application.terminate
719
+ *
720
+ * @example
721
+ *
722
+ * ```js
723
+ * async function terminateApp() {
724
+ * const app = await fin.Application.getCurrent();
725
+ * return await app.terminate();
726
+ * }
727
+ * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
728
+ * ```
394
729
  */
395
730
  terminate() {
396
731
  return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
@@ -399,7 +734,7 @@ class Application extends base_1.EmitterBase {
399
734
  * Waits for a hanging application. This method can be called in response to an application
400
735
  * "not-responding" to allow the application to continue and to generate another "not-responding"
401
736
  * message after a certain period of time.
402
- * @return {Promise.<void>}
737
+ *
403
738
  * @ignore
404
739
  */
405
740
  wait() {
@@ -407,16 +742,33 @@ class Application extends base_1.EmitterBase {
407
742
  }
408
743
  /**
409
744
  * Retrieves information about the application.
410
- * @return {Promise.<ApplicationInfo>}
411
- * @tutorial Application.getInfo
745
+ *
746
+ * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
747
+ * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
748
+ * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
749
+ *
750
+ * @example
751
+ *
752
+ * ```js
753
+ * async function getInfo() {
754
+ * const app = await fin.Application.getCurrent();
755
+ * return await app.getInfo();
756
+ * }
757
+ *
758
+ * getInfo().then(info => console.log(info)).catch(err => console.log(err));
759
+ * ```
412
760
  */
413
761
  getInfo() {
414
762
  return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
415
763
  }
416
764
  /**
417
765
  * Retrieves all process information for entities (windows and views) associated with an application.
418
- * @return {Promise.<AppProcessInfo>}
419
- * @tutorial Application.getProcessInfo
766
+ *
767
+ * @example
768
+ * ```js
769
+ * const app = await fin.Application.getCurrent();
770
+ * const processInfo = await app.getProcessInfo();
771
+ * ```
420
772
  * @experimental
421
773
  */
422
774
  async getProcessInfo() {
@@ -427,10 +779,21 @@ class Application extends base_1.EmitterBase {
427
779
  * Sets file auto download location. It's only allowed in the same application.
428
780
  * Note: This method is restricted by default and must be enabled via
429
781
  * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
430
- * @param { string } downloadLocation file auto download location
431
- * @return {Promise.<void>}
782
+ * @param downloadLocation file auto download location
783
+ *
432
784
  * @throws if setting file auto download location on different applications.
433
- * @tutorial Application.setFileDownloadLocation
785
+ * @example
786
+ *
787
+ * ```js
788
+ * const downloadLocation = 'C:\\dev\\temp';
789
+ * const app = await fin.Application.getCurrent();
790
+ * try {
791
+ * await app.setFileDownloadLocation(downloadLocation);
792
+ * console.log('File download location is set');
793
+ * } catch(err) {
794
+ * console.error(err)
795
+ * }
796
+ * ```
434
797
  */
435
798
  async setFileDownloadLocation(downloadLocation) {
436
799
  const { name } = this.wire.me;
@@ -441,9 +804,14 @@ class Application extends base_1.EmitterBase {
441
804
  * Gets file auto download location. It's only allowed in the same application. If file auto download location is not set, it will return the default location.
442
805
  * Note: This method is restricted by default and must be enabled via
443
806
  * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
444
- * @return {Promise.<string>}
807
+ *
445
808
  * @throws if getting file auto download location on different applications.
446
- * @tutorial Application.getFileDownloadLocation
809
+ * @example
810
+ *
811
+ * ```js
812
+ * const app = await fin.Application.getCurrent();
813
+ * const fileDownloadDir = await app.getFileDownloadLocation();
814
+ * ```
447
815
  */
448
816
  async getFileDownloadLocation() {
449
817
  const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);