@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
@@ -8,32 +8,350 @@ class WebContents extends base_1.EmitterBase {
8
8
  this.identity = identity;
9
9
  this.entityType = entityType;
10
10
  }
11
+ /**
12
+ * Gets a base64 encoded image of all or part of the WebContents.
13
+ * @function capturePage
14
+ * @param options Options for the capturePage call.
15
+ * @memberOf View
16
+ * @instance
17
+ *
18
+ * @example
19
+ *
20
+ * View:
21
+ * ```js
22
+ * const view = fin.View.getCurrentSync();
23
+ *
24
+ * // PNG image of a full visible View
25
+ * console.log(await view.capturePage());
26
+ *
27
+ * // Low-quality JPEG image of a defined visible area of the view
28
+ * const options = {
29
+ * area: {
30
+ * height: 100,
31
+ * width: 100,
32
+ * x: 10,
33
+ * y: 10,
34
+ * },
35
+ * format: 'jpg',
36
+ * quality: 20
37
+ * }
38
+ * console.log(await view.capturePage(options));
39
+ * ```
40
+ *
41
+ * Window:
42
+ * ```js
43
+ * const wnd = await fin.Window.getCurrent();
44
+ *
45
+ * // PNG image of a full visible window
46
+ * console.log(await wnd.capturePage());
47
+ *
48
+ * // Low-quality JPEG image of a defined visible area of the window
49
+ * const options = {
50
+ * area: {
51
+ * height: 100,
52
+ * width: 100,
53
+ * x: 10,
54
+ * y: 10,
55
+ * },
56
+ * format: 'jpg',
57
+ * quality: 20
58
+ * }
59
+ * console.log(await wnd.capturePage(options));
60
+ * ```
61
+ */
11
62
  capturePage(options) {
12
63
  return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
13
64
  }
65
+ /**
66
+ * Executes Javascript on the WebContents, restricted to contents you own or contents owned by
67
+ * applications you have created.
68
+ * @param code JavaScript code to be executed on the view.
69
+ * @function executeJavaScript
70
+ * @memberOf View
71
+ * @instance
72
+ *
73
+ * @example
74
+ * View:
75
+ * ```js
76
+ * async function executeJavaScript(code) {
77
+ * const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
78
+ * return await view.executeJavaScript(code);
79
+ * }
80
+ *
81
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
82
+ * ```
83
+ *
84
+ * Window:
85
+ * ```js
86
+ * async function executeJavaScript(code) {
87
+ * const app = await fin.Application.start({
88
+ * name: 'myApp',
89
+ * uuid: 'app-1',
90
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
91
+ * autoShow: true
92
+ * });
93
+ * const win = await app.getWindow();
94
+ * return await win.executeJavaScript(code);
95
+ * }
96
+ *
97
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
98
+ * ```
99
+ */
14
100
  executeJavaScript(code) {
15
101
  return this.wire
16
102
  .sendAction('execute-javascript-in-window', { ...this.identity, code })
17
103
  .then(({ payload }) => payload.data);
18
104
  }
105
+ /**
106
+ * Returns the zoom level of the WebContents.
107
+ * @function getZoomLevel
108
+ * @memberOf View
109
+ * @instance
110
+ *
111
+ * @example
112
+ * View:
113
+ * ```js
114
+ * async function getZoomLevel() {
115
+ * const view = await fin.View.getCurrent();
116
+ * return await view.getZoomLevel();
117
+ * }
118
+ *
119
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
120
+ * ```
121
+ *
122
+ * Window:
123
+ * ```js
124
+ * async function createWin() {
125
+ * const app = await fin.Application.start({
126
+ * name: 'myApp',
127
+ * uuid: 'app-1',
128
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getZoomLevel.html',
129
+ * autoShow: true
130
+ * });
131
+ * return await app.getWindow();
132
+ * }
133
+ *
134
+ * async function getZoomLevel() {
135
+ * const win = await createWin();
136
+ * return await win.getZoomLevel();
137
+ * }
138
+ *
139
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
140
+ * ```
141
+ */
19
142
  getZoomLevel() {
20
143
  return this.wire.sendAction('get-zoom-level', this.identity).then(({ payload }) => payload.data);
21
144
  }
145
+ /**
146
+ * Sets the zoom level of the WebContents.
147
+ * @param level The zoom level
148
+ * @function setZoomLevel
149
+ * @memberOf View
150
+ * @instance
151
+ *
152
+ * @example
153
+ * View:
154
+ * ```js
155
+ * async function setZoomLevel(number) {
156
+ * const view = await fin.View.getCurrent();
157
+ * return await view.setZoomLevel(number);
158
+ * }
159
+ *
160
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
161
+ * ```
162
+ *
163
+ * Window:
164
+ * ```js
165
+ * async function createWin() {
166
+ * const app = await fin.Application.start({
167
+ * name: 'myApp',
168
+ * uuid: 'app-1',
169
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setZoomLevel.html',
170
+ * autoShow: true
171
+ * });
172
+ * return await app.getWindow();
173
+ * }
174
+ *
175
+ * async function setZoomLevel(number) {
176
+ * const win = await createWin();
177
+ * return await win.setZoomLevel(number);
178
+ * }
179
+ *
180
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
181
+ * ```
182
+ */
22
183
  setZoomLevel(level) {
23
184
  return this.wire.sendAction('set-zoom-level', { ...this.identity, level }).then(() => undefined);
24
185
  }
186
+ /**
187
+ * Navigates the WebContents to a specified URL.
188
+ *
189
+ * @remarks The url must contain the protocol prefix such as http:// or https://.
190
+ * @param url - The URL to navigate the WebContents to.
191
+ *
192
+ * @function navigate
193
+ * @memberof View
194
+ * @instance
195
+ * @example
196
+ * View:
197
+ * ```js
198
+ * async function createView() {
199
+ * const me = await fin.Window.getCurrent();
200
+ * return fin.View.create({
201
+ * name: 'viewName',
202
+ * target: me.identity,
203
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
204
+ * });
205
+ * }
206
+ *
207
+ * createView()
208
+ * .then(view => view.navigate('https://example.com'))
209
+ * .then(() => console.log('navigation complete'))
210
+ * .catch(err => console.log(err));
211
+ * ```
212
+ *
213
+ * Window:
214
+ * ```js
215
+ * async function navigate() {
216
+ * const win = await fin.Window.getCurrent();
217
+ * return await win.navigate('https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.navigate.html');
218
+ * }
219
+ * navigate().then(() => console.log('Navigate to tutorial')).catch(err => console.log(err));
220
+ * ```
221
+ * @experimental
222
+ */
25
223
  navigate(url) {
26
224
  return this.wire.sendAction('navigate-window', { ...this.identity, url }).then(() => undefined);
27
225
  }
226
+ /**
227
+ * Navigates the WebContents back one page.
228
+ * @function navigateBack
229
+ * @memberOf View
230
+ * @instance
231
+ *
232
+ * @example
233
+ * View:
234
+ * ```js
235
+ * async function navigateBack() {
236
+ * const view = await fin.View.wrap({ name: 'testapp-view', uuid: 'testapp' });
237
+ * await view.navigate('https://www.google.com');
238
+ * return await view.navigateBack();
239
+ * }
240
+ * navigateBack().then(() => console.log('Navigated back')).catch(err => console.log(err));
241
+ * ```
242
+ *
243
+ * Window:
244
+ * ```js
245
+ * async function navigateBack() {
246
+ * const win = await fin.Window.wrap({ name: 'testapp', uuid: 'testapp' });
247
+ * await win.navigate('https://www.google.com');
248
+ * return await win.navigateBack();
249
+ * }
250
+ * navigateBack().then(() => console.log('Navigated back')).catch(err => console.log(err));
251
+ * ```
252
+ */
28
253
  navigateBack() {
29
254
  return this.wire.sendAction('navigate-window-back', { ...this.identity }).then(() => undefined);
30
255
  }
256
+ /**
257
+ * Navigates the WebContents forward one page.
258
+ * @function navigateForward
259
+ * @memberOf View
260
+ * @instance
261
+ *
262
+ * @example
263
+ * View:
264
+ * ```js
265
+ * async function navigateForward() {
266
+ * const view = await fin.View.getCurrent();
267
+ * await view.navigate('https://www.google.com');
268
+ * await view.navigateBack();
269
+ * return await view.navigateForward();
270
+ * }
271
+ * navigateForward().then(() => console.log('Navigated forward')).catch(err => console.log(err));
272
+ * ```
273
+ *
274
+ * Window:
275
+ * ```js
276
+ * async function navigateForward() {
277
+ * const win = await fin.Window.getCurrent();
278
+ * await win.navigate('https://www.google.com');
279
+ * await win.navigateBack();
280
+ * return await win.navigateForward();
281
+ * }
282
+ * navigateForward().then(() => console.log('Navigated forward')).catch(err => console.log(err));
283
+ * ```
284
+ */
31
285
  async navigateForward() {
32
286
  await this.wire.sendAction('navigate-window-forward', { ...this.identity });
33
287
  }
288
+ /**
289
+ * Stops any current navigation the WebContents is performing.
290
+ * @function stopNavigation
291
+ * @memberOf View
292
+ * @instance
293
+ *
294
+ * @example
295
+ * View:
296
+ * ```js
297
+ * async function stopNavigation() {
298
+ * const view = await fin.View.wrap({ name: 'testapp-view', uuid: 'testapp' });
299
+ * await view.navigate('https://www.google.com');
300
+ * return await view.stopNavigation();
301
+ * }
302
+ * stopNavigation().then(() => console.log('you shall not navigate')).catch(err => console.log(err));
303
+ * ```
304
+ *
305
+ * Window:
306
+ * ```js
307
+ * async function stopNavigation() {
308
+ * const win = await fin.Window.wrap({ name: 'testapp', uuid: 'testapp' });
309
+ * await win.navigate('https://www.google.com');
310
+ * return await win.stopNavigation();
311
+ * }
312
+ * stopNavigation().then(() => console.log('you shall not navigate')).catch(err => console.log(err));
313
+ * ```
314
+ */
34
315
  stopNavigation() {
35
316
  return this.wire.sendAction('stop-window-navigation', { ...this.identity }).then(() => undefined);
36
317
  }
318
+ /**
319
+ * Reloads the WebContents
320
+ * @function reload
321
+ * @memberOf View
322
+ * @instance
323
+ *
324
+ * @example
325
+ * View:
326
+ * ```js
327
+ * async function reload() {
328
+ * const view = await fin.View.getCurrent();
329
+ * return await view.reload();
330
+ * }
331
+ *
332
+ * reload().then(() => {
333
+ * console.log('Reloaded view')
334
+ * }).catch(err => console.log(err));
335
+ * ```
336
+ *
337
+ * Window:
338
+ * ```js
339
+ * async function reloadWindow() {
340
+ * const app = await fin.Application.start({
341
+ * name: 'myApp',
342
+ * uuid: 'app-1',
343
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.reload.html',
344
+ * autoShow: true
345
+ * });
346
+ * const win = await app.getWindow();
347
+ * return await win.reload();
348
+ * }
349
+ *
350
+ * reloadWindow().then(() => {
351
+ * console.log('Reloaded window')
352
+ * }).catch(err => console.log(err));
353
+ * ```
354
+ */
37
355
  reload(ignoreCache = false) {
38
356
  return this.wire
39
357
  .sendAction('reload-window', {
@@ -42,43 +360,615 @@ class WebContents extends base_1.EmitterBase {
42
360
  })
43
361
  .then(() => undefined);
44
362
  }
363
+ /**
364
+ * Prints the WebContents.
365
+ * @param options Printer Options
366
+ * @function print
367
+ * @memberOf View
368
+ * @instance
369
+ *
370
+ * @remarks When `silent` is set to `true`, the API will pick the system's default printer if deviceName
371
+ * is empty and the default settings for printing.
372
+ *
373
+ * Use the CSS style `page-break-before: always;` to force print to a new page.
374
+ *
375
+ * @example
376
+ * ```js
377
+ * const view = fin.View.getCurrentSync();
378
+ *
379
+ * view.print({ silent: false, deviceName: 'system-printer-name' }).then(() => {
380
+ * console.log('print call has been sent to the system');
381
+ * });
382
+ * ```
383
+ */
45
384
  print(options = {}) {
46
385
  return this.wire.sendAction('print', { ...this.identity, options }).then(() => undefined);
47
386
  }
387
+ /**
388
+ * Find and highlight text on a page.
389
+ * @param searchTerm Term to find in page
390
+ * @param options Search options
391
+ * @function findInPage
392
+ * @memberOf View
393
+ * @instance
394
+ *
395
+ * @remarks By default, each subsequent call will highlight the next text that matches the search term.
396
+ *
397
+ * Returns a promise with the results for the request. By subscribing to the
398
+ * found-in-page event, you can get the results of this call as well.
399
+ *
400
+ * @example
401
+ * View:
402
+ * ```js
403
+ * const view = fin.View.getCurrentSync();
404
+ *
405
+ * //By subscribing to the 'found in page' event we can get the results of each findInPage call made.
406
+ * view.addListener('found-in-page', (event) => {
407
+ * console.log(event);
408
+ * });
409
+ *
410
+ * // The promise also returns the results for the request
411
+ * view.findInPage('a').then((result) => {
412
+ * console.log(result)
413
+ * });
414
+ * ```
415
+ *
416
+ * Window:
417
+ * ```js
418
+ * const win = fin.Window.getCurrentSync();
419
+ *
420
+ * //By subscribing to the 'found in page' event we can get the results of each findInPage call made.
421
+ * win.addListener('found-in-page', (event) => {
422
+ * console.log(event);
423
+ * });
424
+ *
425
+ * // The promise also returns the results for the request
426
+ * win.findInPage('a').then((result) => {
427
+ * console.log(result)
428
+ * });
429
+ * ```
430
+ */
48
431
  findInPage(searchTerm, options) {
49
432
  return this.wire
50
433
  .sendAction('find-in-page', { ...this.identity, searchTerm, options })
51
434
  .then(({ payload }) => payload.data);
52
435
  }
436
+ /**
437
+ * Stop a {@link View#findInPage findInPage} call by specifying any of these actions:
438
+ *
439
+ * * clearSelection - Clear the selection.
440
+ * * keepSelection - Translate the selection into a normal selection.
441
+ * * activateSelection - Focus and click the selection node.
442
+ *
443
+ * @example
444
+ * View:
445
+ * ```js
446
+ * const view = fin.View.getCurrentSync();
447
+ *
448
+ * view.addListener('found-in-page', (event) => {
449
+ * setTimeout(() => {
450
+ * view.stopFindInPage('clearSelection');
451
+ * }, 5000);
452
+ * });
453
+ *
454
+ * view.findInPage('a').then(results => {
455
+ * console.log(results);
456
+ * });
457
+ * ```
458
+ *
459
+ * Window:
460
+ * ```js
461
+ * const win = fin.Window.getCurrentSync();
462
+ *
463
+ * win.addListener('found-in-page', (event) => {
464
+ * setTimeout(() => {
465
+ * win.stopFindInPage('clearSelection');
466
+ * }, 5000);
467
+ * });
468
+ *
469
+ * win.findInPage('a').then(results => {
470
+ * console.log(results);
471
+ * });
472
+ * ```
473
+ */
53
474
  stopFindInPage(action) {
54
475
  return this.wire.sendAction('stop-find-in-page', { ...this.identity, action }).then(() => undefined);
55
476
  }
477
+ /**
478
+ * Returns an array with all system printers
479
+ * @deprecated use System.getPrinters instead
480
+ * @function getPrinters
481
+ * @memberOf View
482
+ * @instance
483
+ *
484
+ * @example
485
+ * View:
486
+ * ```js
487
+ * const view = fin.View.getCurrentSync();
488
+ *
489
+ * view.getPrinters()
490
+ * .then((printers) => {
491
+ * printers.forEach((printer) => {
492
+ * if (printer.isDefault) {
493
+ * console.log(printer);
494
+ * }
495
+ * });
496
+ * })
497
+ * .catch((err) => {
498
+ * console.log(err);
499
+ * });
500
+ * ```
501
+ *
502
+ * Window:
503
+ * ```js
504
+ * const win = fin.Window.getCurrentSync();
505
+ *
506
+ * win.getPrinters()
507
+ * .then((printers) => {
508
+ * printers.forEach((printer) => {
509
+ * if (printer.isDefault) {
510
+ * console.log(printer);
511
+ * }
512
+ * });
513
+ * })
514
+ * .catch((err) => {
515
+ * console.log(err);
516
+ * });
517
+ * ```
518
+ */
56
519
  getPrinters() {
57
520
  return this.wire.sendAction('get-printers', { ...this.identity }).then(({ payload }) => payload.data);
58
521
  }
522
+ /**
523
+ * Gives focus to the WebContents.
524
+ *
525
+ * @function focus
526
+ * @emits focused
527
+ * @memberOf Window
528
+ * @instance
529
+ * @example
530
+ * ```js
531
+ * async function focusWindow() {
532
+ * const app = await fin.Application.start({
533
+ * name: 'myApp',
534
+ * uuid: 'app-1',
535
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.focus.html',
536
+ * autoShow: true
537
+ * });
538
+ * const win = await app.getWindow();
539
+ * return await win.focus();
540
+ * }
541
+ *
542
+ * focusWindow().then(() => console.log('Window focused')).catch(err => console.log(err));
543
+ * ```
544
+ */
59
545
  async focus({ emitSynthFocused } = { emitSynthFocused: true }) {
60
546
  await this.wire.sendAction('focus-window', { emitSynthFocused, ...this.identity });
61
547
  }
548
+ /**
549
+ * Shows the Chromium Developer Tools
550
+ * @function showDeveloperTools
551
+ * @memberOf View
552
+ * @instance
553
+ *
554
+ * @example
555
+ * View:
556
+ * ```js
557
+ * async function showDeveloperTools() {
558
+ * const view = await fin.View.getCurrent();
559
+ * return view.showDeveloperTools();
560
+ * }
561
+ *
562
+ * showDevelopertools()
563
+ * .then(() => console.log('Showing dev tools'))
564
+ * .catch(err => console.error(err));
565
+ * ```
566
+ *
567
+ * Window:
568
+ * ```js
569
+ * async function showDeveloperTools() {
570
+ * const win = await fin.Window.getCurrent();
571
+ * return win.showDeveloperTools();
572
+ * }
573
+ *
574
+ * showDevelopertools()
575
+ * .then(() => console.log('Showing dev tools'))
576
+ * .catch(err => console.error(err));
577
+ * ```
578
+ */
62
579
  async showDeveloperTools() {
63
580
  // Note this hits the system action map in core state for legacy reasons.
64
581
  await this.wire.sendAction('show-developer-tools', this.identity);
65
582
  }
583
+ /**
584
+ * Retrieves the process information associated with a WebContents.
585
+ *
586
+ * @remarks This includes any iframes associated with the WebContents
587
+ *
588
+ * @function getProcessInfo
589
+ * @memberOf View
590
+ * @instance
591
+ *
592
+ * @example
593
+ * View:
594
+ * ```js
595
+ * const view = await fin.View.getCurrent();
596
+ * const processInfo = await view.getProcessInfo();
597
+ * ```
598
+ *
599
+ * Window:
600
+ * ```js
601
+ * const win = await fin.Window.getCurrent();
602
+ * const processInfo = await win.getProcessInfo();
603
+ * ```
604
+ */
66
605
  async getProcessInfo() {
67
606
  const { payload: { data } } = await this.wire.sendAction('get-process-info', this.identity);
68
607
  return data;
69
608
  }
609
+ /**
610
+ * Retrieves information on all Shared Workers.
611
+ * @function getSharedWorkers
612
+ * @memberOf View
613
+ * @instance
614
+ *
615
+ * @example
616
+ * View:
617
+ * ```js
618
+ * const view = await fin.View.create({
619
+ * name: 'viewName',
620
+ * target: fin.me.identity,
621
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
622
+ * });
623
+ *
624
+ * await view.navigate('http://mdn.github.io/simple-shared-worker/index2.html');
625
+ *
626
+ * const sharedWorkers = await view.getSharedWorkers();
627
+ * ```
628
+ *
629
+ * Window:
630
+ * ```js
631
+ * const winOption = {
632
+ * name:'child',
633
+ * defaultWidth: 300,
634
+ * defaultHeight: 300,
635
+ * url: 'http://mdn.github.io/simple-shared-worker/index2.html',
636
+ * frame: true,
637
+ * autoShow: true
638
+ * };
639
+ * const win = await fin.Window.create(winOption);
640
+ * const sharedWorkers = await win.getSharedWorkers();
641
+ * ```
642
+ */
70
643
  async getSharedWorkers() {
71
644
  return this.wire.sendAction('get-shared-workers', this.identity).then(({ payload }) => payload.data);
72
645
  }
646
+ /**
647
+ * Opens the developer tools for the shared worker context.
648
+ * @function inspectSharedWorker
649
+ * @memberOf View
650
+ * @instance
651
+ *
652
+ * @example
653
+ * View:
654
+ * ```js
655
+ * const view = await fin.View.create({
656
+ * name: 'viewName',
657
+ * target: fin.me.identity,
658
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
659
+ * });
660
+ *
661
+ * await view.navigate('http://mdn.github.io/simple-shared-worker/index2.html');
662
+ *
663
+ * await view.inspectSharedWorker();
664
+ * ```
665
+ *
666
+ * Example:
667
+ * ```js
668
+ * const winOption = {
669
+ * name:'child',
670
+ * defaultWidth: 300,
671
+ * defaultHeight: 300,
672
+ * url: 'http://mdn.github.io/simple-shared-worker/index2.html',
673
+ * frame: true,
674
+ * autoShow: true
675
+ * };
676
+ * const win = await fin.Window.create(winOption);
677
+ * await win.inspectSharedWorker();
678
+ * ```
679
+ */
73
680
  async inspectSharedWorker() {
74
681
  await this.wire.sendAction('inspect-shared-worker', { ...this.identity });
75
682
  }
683
+ /**
684
+ * Inspects the shared worker based on its ID.
685
+ * @param workerId - The id of the shared worker.
686
+ * @function inspectSharedWorkerById
687
+ * @memberOf View
688
+ * @instance
689
+ *
690
+ * @example
691
+ * View:
692
+ * ```js
693
+ * const view = await fin.View.create({
694
+ * name: 'viewName',
695
+ * target: fin.me.identity,
696
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
697
+ * });
698
+ *
699
+ * await view.navigate('http://mdn.github.io/simple-shared-worker/index2.html');
700
+ *
701
+ * const sharedWorkers = await view.getSharedWorkers();
702
+ * await view.inspectSharedWorkerById(sharedWorkers[0].id);
703
+ * ```
704
+ *
705
+ * Window:
706
+ * ```js
707
+ * const winOption = {
708
+ * name:'child',
709
+ * defaultWidth: 300,
710
+ * defaultHeight: 300,
711
+ * url: 'http://mdn.github.io/simple-shared-worker/index2.html',
712
+ * frame: true,
713
+ * autoShow: true
714
+ * };
715
+ * const win = await fin.Window.create(winOption);
716
+ * const sharedWorkers = await win.getSharedWorkers();
717
+ * await win.inspectSharedWorkerById(sharedWorkers[0].id);
718
+ * ```
719
+ */
76
720
  async inspectSharedWorkerById(workerId) {
77
721
  await this.wire.sendAction('inspect-shared-worker-by-id', { ...this.identity, workerId });
78
722
  }
723
+ /**
724
+ * Opens the developer tools for the service worker context.
725
+ * @function inspectServiceWorker
726
+ * @memberOf View
727
+ * @instance
728
+ *
729
+ * @example
730
+ * View:
731
+ * ```js
732
+ * const view = await fin.View.create({
733
+ * name: 'viewName',
734
+ * target: fin.me.identity,
735
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
736
+ * });
737
+ *
738
+ * await view.navigate('http://googlechrome.github.io/samples/service-worker/basic/index.html');
739
+ *
740
+ * await view.inspectServiceWorker();
741
+ * ```
742
+ *
743
+ * Window:
744
+ * ```js
745
+ * const winOption = {
746
+ * name:'child',
747
+ * defaultWidth: 300,
748
+ * defaultHeight: 300,
749
+ * url: 'http://googlechrome.github.io/samples/service-worker/basic/index.html',
750
+ * frame: true,
751
+ * autoShow: true
752
+ * };
753
+ * const win = await fin.Window.create(winOption);
754
+ * await win.inspectServiceWorker();
755
+ * ```
756
+ */
79
757
  async inspectServiceWorker() {
80
758
  await this.wire.sendAction('inspect-service-worker', { ...this.identity });
81
759
  }
760
+ /**
761
+ * Shows a popup window.
762
+ *
763
+ * @remarks If this WebContents is a view and its attached window has a popup open, this will close it.
764
+ *
765
+ * Shows a popup window. Including a `name` in `options` will attempt to show an existing window as a popup, if
766
+ * that window doesn't exist or no `name` is included a window will be created. If the caller view or the caller
767
+ * view's parent window currently has a popup window open, calling `showPopupWindow` again will dismiss the currently
768
+ * open popup window before showing the new popup window. Also, if the caller view is destroyed or detached, the popup
769
+ * will be dismissed.
770
+ *
771
+ * NOTE: in the case where the window being shown as a popup needs to be created, it is a child of the caller view's parent window.
772
+ *
773
+ * @example
774
+ *
775
+ * Create and show a single-use popup window that returns a single result to the caller. `initialOptions` allows
776
+ * us to pass window options to the popup window that will be created. `resultDispatchBehavior: 'close'` ensures
777
+ * that once the popup window calls `dispatchPopupResult` it is closed. `blurBehavior: 'close'` will yield a dismissed
778
+ * result should the popup window lose focus.
779
+ *
780
+ * ```js
781
+ * const result = await fin.me.showPopupWindow({
782
+ * initialOptions: {
783
+ * frame: false
784
+ * },
785
+ * url: '<my_popup_url>',
786
+ * resultDispatchBehavior: 'close',
787
+ * blurBehavior: 'close',
788
+ * focus: true,
789
+ * height: 300,
790
+ * width: 300,
791
+ * x: 0,
792
+ * y: 0
793
+ * });
794
+ * ```
795
+ *
796
+ * Same as above but using an existing window as a popup by referencing its `name`:
797
+ *
798
+ * Note: if a window with the `name` provided doesn't exist, it will be created.
799
+ *
800
+ * ```js
801
+ * const result = await fin.me.showPopupWindow({
802
+ * initialOptions: {
803
+ * frame: true
804
+ * },
805
+ * name: 'my-popup', // shows the 'my-popup' window if it exists, otherwise creates it
806
+ * url: '<my_popup_url>', // navigates to this url if it doesn't match the location.href of the 'my-popup' window
807
+ * resultDispatchBehavior: 'close',
808
+ * blurBehavior: 'close',
809
+ * focus: true,
810
+ * hideOnClose: true, // persist window on 'dismissed' result, alternatively change onResultDispatch and blurBehavior to 'hide'
811
+ * height: 300,
812
+ * width: 300,
813
+ * x: 0,
814
+ * y: 0
815
+ * });
816
+ * ```
817
+ *
818
+ * Create and show a popup window that is able to return multiple results to the caller via an `onPopupResult` callback. Each
819
+ * time the popup window calls `dispatchPopupResult`, the callback will be executed on the result. Once the popup window is
820
+ * closed or hidden, the `showPopupWindow` promise will resolve with a `dismissed` result that will include the most recently
821
+ * dispatched result as `lastDispatchResult`:
822
+ *
823
+ * ```js
824
+ * const popupResultCallback = (payload) => {
825
+ * if (payload.result === 'clicked') {
826
+ * if (payload.data.topic === 'color-changed') {
827
+ * // do something like
828
+ * // setColor(payload.data.value);
829
+ * }
830
+ * }
831
+ * };
832
+ *
833
+ * await fin.me.showPopupWindow({
834
+ * initialOptions: {
835
+ * frame: false
836
+ * },
837
+ * url: '<my_popup_url>',
838
+ * resultDispatchBehavior: 'none',
839
+ * blurBehavior: 'close',
840
+ * focus: true,
841
+ * height: 300,
842
+ * width: 300,
843
+ * x: 0,
844
+ * y: 0,
845
+ * onPopupResult: popupResultCallback
846
+ * });
847
+ * ```
848
+ *
849
+ * Same as above but using an existing window as a popup:
850
+ *
851
+ * ```js
852
+ * const popupResultCallback = (payload) => {
853
+ * if (payload.result === 'clicked') {
854
+ * if (payload.data.topic === 'color-changed') {
855
+ * // do something like
856
+ * // setColor(payload.data.value);
857
+ * }
858
+ * }
859
+ * };
860
+ *
861
+ * await fin.me.showPopupWindow({
862
+ * initialOptions: {
863
+ * frame: false
864
+ * },
865
+ * name: 'my-popup', // shows the 'my-popup' window if it exists, otherwise creates it
866
+ * url: '<my_popup_url>', // navigates to this url if it doesn't match the location.href of the 'my-popup' window
867
+ * resultDispatchBehavior: 'none',
868
+ * blurBehavior: 'hide',
869
+ * focus: true,
870
+ * hideOnClose: true, // we can just use this or we can change blurBehavior to 'hide'
871
+ * height: 300,
872
+ * width: 300,
873
+ * x: 0,
874
+ * y: 0,
875
+ * onPopupResult: popupResultCallback
876
+ * });
877
+ * ```
878
+ *
879
+ * Create or show a popup window that disables user movement (positioning and resizing) in the caller
880
+ * view's parent window by using `blurBehavior: 'modal'`:
881
+ *
882
+ * ```js
883
+ * const result = await fin.me.showPopupWindow({
884
+ * initialOptions: {
885
+ * frame: false
886
+ * },
887
+ * url: '<my_popup_url>',
888
+ * resultDispatchBehavior: 'close',
889
+ * blurBehavior: 'modal',
890
+ * focus: true,
891
+ * height: 300,
892
+ * width: 300,
893
+ * x: 0,
894
+ * y: 0
895
+ * });
896
+ * ```
897
+ *
898
+ * Create a popup window as a modal:
899
+ *
900
+ * Note: The only way to ensure true modal behavior is to create the window being shown as a popup with a
901
+ * `modalParentIdentity` that uses the caller view's parent window identity.
902
+ *
903
+ * ```js
904
+ * const result = await fin.me.showPopupWindow({
905
+ * initialOptions: {
906
+ * frame: false,
907
+ * modalParentIdentity: fin.me.identity
908
+ * },
909
+ * url: '<my_popup_url>',
910
+ * resultDispatchBehavior: 'close',
911
+ * blurBehavior: 'modal',
912
+ * focus: true,
913
+ * height: 300,
914
+ * width: 300,
915
+ * x: 0,
916
+ * y: 0
917
+ * });
918
+ * ```
919
+ *
920
+ * Pass data to a popup window that is available when the popup is shown.
921
+ *
922
+ * Note: this is just one example for a use of `additionalOptions`, it can be used to update any updatable
923
+ * window options when creating or showing an existing window as a popup.
924
+ *
925
+ * ```js
926
+ * const result = await fin.me.showPopupWindow({
927
+ * additionalOptions: {
928
+ * customData: {
929
+ * foo: 'bar'
930
+ * }
931
+ * },
932
+ * url: '<my_popup_url>',
933
+ * resultDispatchBehavior: 'close',
934
+ * blurBehavior: 'close',
935
+ * focus: true,
936
+ * height: 300,
937
+ * width: 300,
938
+ * x: 0,
939
+ * y: 0
940
+ * });
941
+ *
942
+ * // Access from the popup window context like so:
943
+ * const { customData } = await fin.me.getOptions();
944
+ * const { foo } = customData;
945
+ * ```
946
+ *
947
+ * Execute a callback on the popup's OpenFin window when the popup is shown:
948
+ *
949
+ * ```js
950
+ * const popupWindowCallback = async (win) => {
951
+ * await win.flash();
952
+ * };
953
+ *
954
+ * const result = await fin.me.showPopupWindow({
955
+ * url: '<my_popup_url>',
956
+ * resultDispatchBehavior: 'close',
957
+ * blurBehavior: 'close',
958
+ * focus: true,
959
+ * height: 300,
960
+ * width: 300,
961
+ * x: 0,
962
+ * y: 0,
963
+ * onPopupReady: popupWindowCallback;
964
+ * });
965
+ * ```
966
+ * @function showPopupWindow
967
+ * @memberOf View
968
+ * @instance
969
+ * @param options
970
+ *
971
+ */
82
972
  async showPopupWindow(options) {
83
973
  this.wire.sendAction(`${this.entityType}-show-popup-window`, this.identity).catch(() => {
84
974
  // we do not want to expose this error, just continue if this analytics-only call fails