@openfin/core 33.76.36 → 33.76.38

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 (271) hide show
  1. package/OpenFin.d.ts +1 -1
  2. package/README.md +29 -4
  3. package/fin.d.ts +2 -2
  4. package/{src → out}/GlobalOpenFin.d.ts +1 -1
  5. package/out/mock-alpha.d.ts +16112 -0
  6. package/out/mock-beta.d.ts +16112 -0
  7. package/out/mock-public.d.ts +16112 -0
  8. package/out/mock.d.ts +16797 -0
  9. package/out/mock.js +17104 -0
  10. package/package.json +30 -23
  11. package/LICENSE +0 -13
  12. package/NOTICE +0 -16
  13. package/openfin-core-33.76.36.tgz +0 -0
  14. package/src/OpenFin.d.ts +0 -3091
  15. package/src/OpenFin.js +0 -2
  16. package/src/api/api-exposer/api-consumer.d.ts +0 -28
  17. package/src/api/api-exposer/api-consumer.js +0 -28
  18. package/src/api/api-exposer/api-exposer.d.ts +0 -35
  19. package/src/api/api-exposer/api-exposer.js +0 -38
  20. package/src/api/api-exposer/decorators.d.ts +0 -10
  21. package/src/api/api-exposer/decorators.js +0 -18
  22. package/src/api/api-exposer/index.d.ts +0 -4
  23. package/src/api/api-exposer/index.js +0 -20
  24. package/src/api/api-exposer/strategies/index.d.ts +0 -1
  25. package/src/api/api-exposer/strategies/index.js +0 -17
  26. package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.d.ts +0 -14
  27. package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.js +0 -20
  28. package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.d.ts +0 -20
  29. package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.js +0 -23
  30. package/src/api/api-exposer/strategies/openfin-channels/index.d.ts +0 -2
  31. package/src/api/api-exposer/strategies/openfin-channels/index.js +0 -18
  32. package/src/api/application/Factory.d.ts +0 -196
  33. package/src/api/application/Factory.js +0 -278
  34. package/src/api/application/Instance.d.ts +0 -692
  35. package/src/api/application/Instance.js +0 -821
  36. package/src/api/application/index.d.ts +0 -12
  37. package/src/api/application/index.js +0 -28
  38. package/src/api/base.d.ts +0 -117
  39. package/src/api/base.js +0 -246
  40. package/src/api/clipboard/index.d.ts +0 -172
  41. package/src/api/clipboard/index.js +0 -200
  42. package/src/api/events/application.d.ts +0 -158
  43. package/src/api/events/application.js +0 -14
  44. package/src/api/events/base.d.ts +0 -42
  45. package/src/api/events/base.js +0 -2
  46. package/src/api/events/channel.d.ts +0 -35
  47. package/src/api/events/channel.js +0 -7
  48. package/src/api/events/emitterMap.d.ts +0 -11
  49. package/src/api/events/emitterMap.js +0 -35
  50. package/src/api/events/eventAggregator.d.ts +0 -5
  51. package/src/api/events/eventAggregator.js +0 -35
  52. package/src/api/events/externalApplication.d.ts +0 -24
  53. package/src/api/events/externalApplication.js +0 -7
  54. package/src/api/events/frame.d.ts +0 -35
  55. package/src/api/events/frame.js +0 -2
  56. package/src/api/events/globalHotkey.d.ts +0 -25
  57. package/src/api/events/globalHotkey.js +0 -2
  58. package/src/api/events/platform.d.ts +0 -34
  59. package/src/api/events/platform.js +0 -10
  60. package/src/api/events/system.d.ts +0 -126
  61. package/src/api/events/system.js +0 -15
  62. package/src/api/events/typedEventEmitter.d.ts +0 -20
  63. package/src/api/events/typedEventEmitter.js +0 -2
  64. package/src/api/events/view.d.ts +0 -92
  65. package/src/api/events/view.js +0 -12
  66. package/src/api/events/webcontents.d.ts +0 -277
  67. package/src/api/events/webcontents.js +0 -13
  68. package/src/api/events/window.d.ts +0 -421
  69. package/src/api/events/window.js +0 -12
  70. package/src/api/external-application/Factory.d.ts +0 -34
  71. package/src/api/external-application/Factory.js +0 -47
  72. package/src/api/external-application/Instance.d.ts +0 -110
  73. package/src/api/external-application/Instance.js +0 -117
  74. package/src/api/external-application/index.d.ts +0 -12
  75. package/src/api/external-application/index.js +0 -28
  76. package/src/api/fin.d.ts +0 -54
  77. package/src/api/fin.js +0 -45
  78. package/src/api/frame/Factory.d.ts +0 -54
  79. package/src/api/frame/Factory.js +0 -86
  80. package/src/api/frame/Instance.d.ts +0 -136
  81. package/src/api/frame/Instance.js +0 -143
  82. package/src/api/frame/index.d.ts +0 -14
  83. package/src/api/frame/index.js +0 -30
  84. package/src/api/global-hotkey/index.d.ts +0 -106
  85. package/src/api/global-hotkey/index.js +0 -132
  86. package/src/api/interappbus/channel/channel.d.ts +0 -285
  87. package/src/api/interappbus/channel/channel.js +0 -334
  88. package/src/api/interappbus/channel/channels-docs.d.ts +0 -342
  89. package/src/api/interappbus/channel/channels-docs.js +0 -401
  90. package/src/api/interappbus/channel/client.d.ts +0 -117
  91. package/src/api/interappbus/channel/client.js +0 -181
  92. package/src/api/interappbus/channel/connection-manager.d.ts +0 -29
  93. package/src/api/interappbus/channel/connection-manager.js +0 -246
  94. package/src/api/interappbus/channel/index.d.ts +0 -189
  95. package/src/api/interappbus/channel/index.js +0 -333
  96. package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +0 -13
  97. package/src/api/interappbus/channel/protocols/classic/message-receiver.js +0 -73
  98. package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +0 -24
  99. package/src/api/interappbus/channel/protocols/classic/strategy.js +0 -101
  100. package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +0 -20
  101. package/src/api/interappbus/channel/protocols/combined/strategy.js +0 -58
  102. package/src/api/interappbus/channel/protocols/index.d.ts +0 -47
  103. package/src/api/interappbus/channel/protocols/index.js +0 -2
  104. package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +0 -10
  105. package/src/api/interappbus/channel/protocols/protocol-manager.js +0 -43
  106. package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +0 -25
  107. package/src/api/interappbus/channel/protocols/rtc/endpoint.js +0 -141
  108. package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +0 -30
  109. package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +0 -130
  110. package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +0 -24
  111. package/src/api/interappbus/channel/protocols/rtc/strategy.js +0 -85
  112. package/src/api/interappbus/channel/protocols/strategy-types.d.ts +0 -13
  113. package/src/api/interappbus/channel/protocols/strategy-types.js +0 -2
  114. package/src/api/interappbus/channel/protocols/strategy.d.ts +0 -17
  115. package/src/api/interappbus/channel/protocols/strategy.js +0 -2
  116. package/src/api/interappbus/channel/provider.d.ts +0 -206
  117. package/src/api/interappbus/channel/provider.js +0 -338
  118. package/src/api/interappbus/index.d.ts +0 -120
  119. package/src/api/interappbus/index.js +0 -210
  120. package/src/api/interop/Factory.d.ts +0 -57
  121. package/src/api/interop/Factory.js +0 -96
  122. package/src/api/interop/InteropBroker.d.ts +0 -665
  123. package/src/api/interop/InteropBroker.js +0 -1313
  124. package/src/api/interop/InteropClient.d.ts +0 -502
  125. package/src/api/interop/InteropClient.js +0 -683
  126. package/src/api/interop/SessionContextGroupBroker.d.ts +0 -27
  127. package/src/api/interop/SessionContextGroupBroker.js +0 -108
  128. package/src/api/interop/SessionContextGroupClient.d.ts +0 -21
  129. package/src/api/interop/SessionContextGroupClient.js +0 -86
  130. package/src/api/interop/fdc3/PrivateChannelClient.d.ts +0 -20
  131. package/src/api/interop/fdc3/PrivateChannelClient.js +0 -90
  132. package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +0 -55
  133. package/src/api/interop/fdc3/PrivateChannelProvider.js +0 -276
  134. package/src/api/interop/fdc3/documentationStub.d.ts +0 -14
  135. package/src/api/interop/fdc3/documentationStub.js +0 -17
  136. package/src/api/interop/fdc3/fdc3-1.2.d.ts +0 -205
  137. package/src/api/interop/fdc3/fdc3-1.2.js +0 -435
  138. package/src/api/interop/fdc3/fdc3-2.0.d.ts +0 -298
  139. package/src/api/interop/fdc3/fdc3-2.0.js +0 -479
  140. package/src/api/interop/fdc3/fdc3.d.ts +0 -12
  141. package/src/api/interop/fdc3/fdc3.js +0 -35
  142. package/src/api/interop/fdc3/overrideCheck.d.ts +0 -4
  143. package/src/api/interop/fdc3/overrideCheck.js +0 -32
  144. package/src/api/interop/fdc3/shapes/fdc3v1.d.ts +0 -53
  145. package/src/api/interop/fdc3/shapes/fdc3v1.js +0 -4
  146. package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +0 -75
  147. package/src/api/interop/fdc3/shapes/fdc3v2.js +0 -2
  148. package/src/api/interop/fdc3/utils.d.ts +0 -45
  149. package/src/api/interop/fdc3/utils.js +0 -239
  150. package/src/api/interop/fdc3/versions.d.ts +0 -1
  151. package/src/api/interop/fdc3/versions.js +0 -2
  152. package/src/api/interop/index.d.ts +0 -12
  153. package/src/api/interop/index.js +0 -28
  154. package/src/api/interop/utils.d.ts +0 -18
  155. package/src/api/interop/utils.js +0 -61
  156. package/src/api/me.d.ts +0 -40
  157. package/src/api/me.js +0 -134
  158. package/src/api/platform/Factory.d.ts +0 -171
  159. package/src/api/platform/Factory.js +0 -240
  160. package/src/api/platform/Instance.d.ts +0 -653
  161. package/src/api/platform/Instance.js +0 -834
  162. package/src/api/platform/common-utils.d.ts +0 -7
  163. package/src/api/platform/common-utils.js +0 -16
  164. package/src/api/platform/index.d.ts +0 -12
  165. package/src/api/platform/index.js +0 -28
  166. package/src/api/platform/layout/Factory.d.ts +0 -91
  167. package/src/api/platform/layout/Factory.js +0 -151
  168. package/src/api/platform/layout/Instance.d.ts +0 -192
  169. package/src/api/platform/layout/Instance.js +0 -224
  170. package/src/api/platform/layout/controllers/layout-content-cache.d.ts +0 -9
  171. package/src/api/platform/layout/controllers/layout-content-cache.js +0 -54
  172. package/src/api/platform/layout/controllers/layout-entities-controller.d.ts +0 -119
  173. package/src/api/platform/layout/controllers/layout-entities-controller.js +0 -287
  174. package/src/api/platform/layout/entities/layout-entities.d.ts +0 -427
  175. package/src/api/platform/layout/entities/layout-entities.js +0 -504
  176. package/src/api/platform/layout/entities/shapes.d.ts +0 -6
  177. package/src/api/platform/layout/entities/shapes.js +0 -2
  178. package/src/api/platform/layout/index.d.ts +0 -11
  179. package/src/api/platform/layout/index.js +0 -27
  180. package/src/api/platform/layout/layout.constants.d.ts +0 -1
  181. package/src/api/platform/layout/layout.constants.js +0 -4
  182. package/src/api/platform/layout/shapes.d.ts +0 -16
  183. package/src/api/platform/layout/shapes.js +0 -2
  184. package/src/api/platform/layout/utils/layout-traversal.d.ts +0 -4
  185. package/src/api/platform/layout/utils/layout-traversal.js +0 -65
  186. package/src/api/platform/provider.d.ts +0 -510
  187. package/src/api/platform/provider.js +0 -2
  188. package/src/api/snapshot-source/Factory.d.ts +0 -53
  189. package/src/api/snapshot-source/Factory.js +0 -81
  190. package/src/api/snapshot-source/Instance.d.ts +0 -53
  191. package/src/api/snapshot-source/Instance.js +0 -154
  192. package/src/api/snapshot-source/index.d.ts +0 -12
  193. package/src/api/snapshot-source/index.js +0 -28
  194. package/src/api/snapshot-source/utils.d.ts +0 -2
  195. package/src/api/snapshot-source/utils.js +0 -6
  196. package/src/api/system/index.d.ts +0 -1468
  197. package/src/api/system/index.js +0 -1851
  198. package/src/api/view/Factory.d.ts +0 -88
  199. package/src/api/view/Factory.js +0 -141
  200. package/src/api/view/Instance.d.ts +0 -601
  201. package/src/api/view/Instance.js +0 -671
  202. package/src/api/view/index.d.ts +0 -12
  203. package/src/api/view/index.js +0 -28
  204. package/src/api/webcontents/main.d.ts +0 -922
  205. package/src/api/webcontents/main.js +0 -1046
  206. package/src/api/window/Factory.d.ts +0 -96
  207. package/src/api/window/Factory.js +0 -142
  208. package/src/api/window/Instance.d.ts +0 -1598
  209. package/src/api/window/Instance.js +0 -1851
  210. package/src/api/window/index.d.ts +0 -14
  211. package/src/api/window/index.js +0 -30
  212. package/src/browser.d.ts +0 -10
  213. package/src/browser.js +0 -36
  214. package/src/environment/browser.d.ts +0 -29
  215. package/src/environment/browser.js +0 -60
  216. package/src/environment/environment.d.ts +0 -33
  217. package/src/environment/environment.js +0 -4
  218. package/src/environment/mockEnvironment.d.ts +0 -27
  219. package/src/environment/mockEnvironment.js +0 -61
  220. package/src/environment/node-env.d.ts +0 -29
  221. package/src/environment/node-env.js +0 -72
  222. package/src/fdc3.d.ts +0 -3
  223. package/src/fdc3.js +0 -9
  224. package/src/mock.d.ts +0 -3
  225. package/src/mock.js +0 -18
  226. package/src/namespaces.d.ts +0 -22
  227. package/src/namespaces.js +0 -26
  228. package/src/shapes/ERROR_BOX_TYPES.d.ts +0 -1
  229. package/src/shapes/ERROR_BOX_TYPES.js +0 -2
  230. package/src/shapes/WebOptions.d.ts +0 -13
  231. package/src/shapes/WebOptions.js +0 -2
  232. package/src/shapes/WindowOptions.d.ts +0 -43
  233. package/src/shapes/WindowOptions.js +0 -2
  234. package/src/shapes/protocol.d.ts +0 -204
  235. package/src/shapes/protocol.js +0 -2
  236. package/src/transport/mockWire.d.ts +0 -11
  237. package/src/transport/mockWire.js +0 -26
  238. package/src/transport/transport-errors.d.ts +0 -31
  239. package/src/transport/transport-errors.js +0 -79
  240. package/src/transport/transport.d.ts +0 -73
  241. package/src/transport/transport.js +0 -219
  242. package/src/transport/wire.d.ts +0 -77
  243. package/src/transport/wire.js +0 -36
  244. package/src/util/asyncFilter.d.ts +0 -1
  245. package/src/util/asyncFilter.js +0 -7
  246. package/src/util/channel-api-relay.d.ts +0 -13
  247. package/src/util/channel-api-relay.js +0 -47
  248. package/src/util/errors.d.ts +0 -10
  249. package/src/util/errors.js +0 -12
  250. package/src/util/exhaustive.d.ts +0 -1
  251. package/src/util/exhaustive.js +0 -7
  252. package/src/util/http.d.ts +0 -11
  253. package/src/util/http.js +0 -90
  254. package/src/util/inaccessibleObject.d.ts +0 -2
  255. package/src/util/inaccessibleObject.js +0 -49
  256. package/src/util/lazy.d.ts +0 -34
  257. package/src/util/lazy.js +0 -54
  258. package/src/util/normalize-config.d.ts +0 -3
  259. package/src/util/normalize-config.js +0 -52
  260. package/src/util/promises.d.ts +0 -5
  261. package/src/util/promises.js +0 -27
  262. package/src/util/ref-counter.d.ts +0 -7
  263. package/src/util/ref-counter.js +0 -52
  264. package/src/util/reversible-map.d.ts +0 -11
  265. package/src/util/reversible-map.js +0 -49
  266. package/src/util/runtimeVersioning.d.ts +0 -3
  267. package/src/util/runtimeVersioning.js +0 -25
  268. package/src/util/utilTypes.d.ts +0 -8
  269. package/src/util/utilTypes.js +0 -2
  270. package/src/util/validate.d.ts +0 -3
  271. package/src/util/validate.js +0 -11
@@ -1,1851 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._Window = void 0;
4
- /* eslint-disable import/prefer-default-export */
5
- /* eslint-disable @typescript-eslint/no-unused-vars */
6
- /* eslint-disable no-console */
7
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
8
- const application_1 = require("../application");
9
- const main_1 = require("../webcontents/main");
10
- const view_1 = require("../view");
11
- /**
12
- * @PORTED
13
- * @typedef { object } Margins
14
- * @property { string } [marginType]
15
- * Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen,
16
- * you will also need to specify `top`, `bottom`, `left`, and `right`.
17
- *
18
- * @property { number } [top] The top margin of the printed web page, in pixels.
19
- * @property { number } [bottom] The bottom margin of the printed web page, in pixels.
20
- * @property { number } [left] The left margin of the printed web page, in pixels.
21
- * @property { number } [right] The right margin of the printed web page, in pixels.
22
- */
23
- /**
24
- * @PORTED
25
- * @typedef { object } Dpi
26
- * @property { number } [horizontal] The horizontal dpi
27
- * @property { number } [vertical] The vertical dpi
28
- */
29
- /**
30
- * @PORTED
31
- * @typedef { object } PrintOptions
32
- * @property { boolean } [silent=false] Don't ask user for print settings.
33
- * @property { boolean } [printBackground=false] Prints the background color and image of the web page.
34
- * @property { string } [deviceName=''] Set the printer device name to use.
35
- * @property { boolean } [color=true] Set whether the printed web page will be in color or grayscale.
36
- * @property { Margins } [margins] Set margins for the printed web page
37
- * @property { boolean } [landscape=false] Whether the web page should be printed in landscape mode.
38
- * @property { number } [scaleFactor] The scale factor of the web page.
39
- * @property { number } [pagesPerSheet] The number of pages to print per page sheet.
40
- * @property { boolean } [collate] Whether the web page should be collated.
41
- * @property { number } [copies] The number of copies of the web page to print.
42
- * @property { Record<string, number> } [pageRanges] The page range to print. Should have two keys: from and to.
43
- * @property { string } [duplexMode] Set the duplex mode of the printed web page. Can be simplex, shortEdge, or longEdge.
44
- * @property { Dpi } [dpi] Set dpi for the printed web page
45
- */
46
- /**
47
- * @REMOVED
48
- * PrinterInfo interface
49
- * @typedef { object } PrinterInfo
50
- * @property { string } name Printer Name
51
- * @property { string } description Printer Description
52
- * @property { number } status Printer Status
53
- * @property { boolean } isDefault Indicates that system's default printer
54
- */
55
- /**
56
- * @REMOVED
57
- * SharedWorkerInfo interface
58
- * @typedef { object } SharedWorkerInfo
59
- * @property { string } id The unique id of the shared worker.
60
- * @property { string } url The url of the shared worker.
61
- */
62
- /**
63
- * @PORTED
64
- * ContentCreationRule interface
65
- * @typedef { object } ContentCreationRule
66
- * @property { string } behavior 'view' | 'window' | 'browser' | 'block'
67
- * @property { string[] } match List of [match patterns](https://developer.chrome.com/extensions/match_patterns).
68
- * @property { object } options Window creation options or View creation options.
69
- */
70
- /**
71
- * @PORTED
72
- * @typedef {object} Window~options
73
- * @summary Window creation options.
74
- * @desc This is the options object required by {@link Window.create Window.create}.
75
- *
76
- * Note that `name` is the only required property — albeit the `url` property is usually provided as well
77
- * (defaults to `"about:blank"` when omitted).
78
- *
79
- * _This jsdoc typedef mirrors the `WindowOptions` TypeScript interface in `@types/openfin`._
80
- *
81
- * @property {object} [accelerator]
82
- * Enable keyboard shortcuts for devtools, zoom, reload, and reload ignoring cache.
83
- *
84
- * @property {boolean} [accelerator.devtools=false]
85
- * If `true`, enables the devtools keyboard shortcut:<br>
86
- * `Ctrl` + `Shift` + `I` _(Toggles Devtools)_
87
- *
88
- * @property {boolean} [accelerator.reload=false]
89
- * If `true`, enables the reload keyboard shortcuts:<br>
90
- * `Ctrl` + `R` _(Windows)_<br>
91
- * `F5` _(Windows)_<br>
92
- * `Command` + `R` _(Mac)_
93
- *
94
- * @property {boolean} [accelerator.reloadIgnoringCache=false]
95
- * If `true`, enables the reload-from-source keyboard shortcuts:<br>
96
- * `Ctrl` + `Shift` + `R` _(Windows)_<br>
97
- * `Shift` + `F5` _(Windows)_<br>
98
- * `Command` + `Shift` + `R` _(Mac)_
99
- *
100
- * @property {boolean} [accelerator.zoom=false]
101
- * NOTE: It is not recommended to set this value to true for Windows in Platforms as that may lead to unexpected visual shifts in layout.
102
- * If `true`, enables the zoom keyboard shortcuts:<br>
103
- * `Ctrl` + `+` _(Zoom In)_<br>
104
- * `Ctrl` + `Shift` + `+` _(Zoom In)_<br>
105
- * `Ctrl` + `NumPad+` _(Zoom In)_<br>
106
- * `Ctrl` + `-` _(Zoom Out)_<br>
107
- * `Ctrl` + `Shift` + `-` _(Zoom Out)_<br>
108
- * `Ctrl` + `NumPad-` _(Zoom Out)_<br>
109
- * `Ctrl` + `Scroll` _(Zoom In & Out)_<br>
110
- * `Ctrl` + `0` _(Restore to 100%)_
111
- *
112
- * @property {object} [alphaMask] - _Experimental._ _Updatable._
113
- * <br>
114
- * alphaMask turns anything of matching RGB value transparent.
115
- * <br>
116
- * Caveats:
117
- * * runtime key --disable-gpu is required. Note: Unclear behavior on remote Desktop support
118
- * * User cannot click-through transparent regions
119
- * * Not supported on Mac
120
- * * Windows Aero must be enabled
121
- * * Won't make visual sense on Pixel-pushed environments such as Citrix
122
- * * Not supported on rounded corner windows
123
- * @property {number} [alphaMask.red=-1] 0-255
124
- * @property {number} [alphaMask.green=-1] 0-255
125
- * @property {number} [alphaMask.blue=-1] 0-255
126
- *
127
- * @property {boolean} [alwaysOnTop=false] - _Updatable._
128
- * A flag to always position the window at the top of the window stack.
129
- *
130
- * @property {object} [api]
131
- * Configurations for API injection.
132
- *
133
- * @property {object} [api.iframe] Configure if the the API should be injected into iframes based on domain.
134
- *
135
- * @property {boolean} [api.iframe.crossOriginInjection=false] Controls if the `fin` API object is present for cross origin iframes.
136
- * @property {boolean} [api.iframe.sameOriginInjection=true] Controls if the `fin` API object is present for same origin iframes.
137
- *
138
- * @property {string} [applicationIcon = ""] - _Deprecated_ - use `icon` instead.
139
- *
140
- * @property {number} [aspectRatio=0] - _Updatable._
141
- * The aspect ratio of width to height to enforce for the window. If this value is equal to or less than zero,
142
- * an aspect ratio will not be enforced.
143
- *
144
- * @property {string} [autoplayPolicy="no-user-gesture-required"]
145
- * Autoplay policy to apply to content in the window, can be
146
- * `no-user-gesture-required`, `user-gesture-required`,
147
- * `document-user-activation-required`. Defaults to `no-user-gesture-required`.
148
- *
149
- * @property {boolean} [autoShow=true]
150
- * A flag to automatically show the window when it is created.
151
- *
152
- * @property {string} [backgroundColor="#FFF"]
153
- * The window’s _backfill_ color as a hexadecimal value. Not to be confused with the content background color
154
- * (`document.body.style.backgroundColor`),
155
- * this color briefly fills a window’s (a) content area before its content is loaded as well as (b) newly exposed
156
- * areas when growing a window. Setting
157
- * this value to the anticipated content background color can help improve user experience.
158
- * Default is white.
159
- *
160
- * @property {object} [contentCreation]
161
- * Apply rules that determine how user interaction (`window.open` and links) creates content.
162
- * @property {ContentCreationRule[]} [contentCreation.rules = []] List of content creation rules.
163
- *
164
- * @property {object} [contentNavigation]
165
- * Restrict navigation to URLs that match an allowed pattern.
166
- * In the lack of an allowlist, navigation to URLs that match a denied pattern would be prohibited.
167
- * See [here](https://developer.chrome.com/extensions/match_patterns) for more details.
168
- * @property {string[]} [contentNavigation.allowlist=[]] List of allowed URLs.
169
- * @property {string[]} [contentNavigation.denylist=[]] List of denied URLs.
170
- *
171
- * @property {object} [contentRedirect]
172
- * Restrict redirects to URLs that match an allowed pattern.
173
- * In the lack of an allowlist, redirects to URLs that match a denied pattern would be prohibited.
174
- * See [here](https://developer.chrome.com/extensions/match_patterns) for more details.
175
- * @property {string[]} [contentRedirect.allowlist=[]] List of allowed URLs.
176
- * @property {string[]} [contentRedirect.denylist=[]] List of denied URLs.
177
- *
178
- * @property {boolean} [contextMenu=true] - _Updatable._
179
- * A flag to show the context menu when right-clicking on a window.
180
- * Gives access to the devtools for the window.
181
- *
182
- * @property {object} [contextMenuSettings] - _Updatable._
183
- * Deprecated - superseded by {@link contextMenuOptions}, which offers a larger feature-set and cleaner syntax.
184
- * Configure the context menu when right-clicking on a window.
185
- * @property {boolean} [contextMenuSettings.enable=true] Should the context menu display on right click.
186
- * @property {boolean} [contextMenuSettings.devtools=true] Should the context menu contain a button for opening devtools.
187
- * @property {boolean} [contextMenuSettings.reload=true] Should the context menu contain a button for reloading the page.
188
- *
189
- * @property {object} [contextMenuOptions] - _Updatable._
190
- * Configure the context menu when right-clicking on a window. Supported menu items:
191
- * 'separator'
192
- * 'cut'
193
- * 'copy'
194
- * 'paste'
195
- * 'spellCheck'
196
- * 'inspect'
197
- * 'reload'
198
- * 'navigateForward'
199
- * 'navigateBack'
200
- * 'print'
201
- * @property {boolean} [contextMenuOptions.enabled = true] Should the context menu display on right click.
202
- * @property {string[]} [contextMenuSettings.template=[]] List of context menu items to display on right-click.
203
- *
204
- * @property {object} [cornerRounding] - _Updatable._
205
- * Defines and applies rounded corners for a frameless window. **NOTE:** On macOS corner is not ellipse but circle rounded by the
206
- * average of _height_ and _width_.
207
- * @property {number} [cornerRounding.height=0] The height in pixels.
208
- * @property {number} [cornerRounding.width=0] The width in pixels.
209
- *
210
- * @property {any} [customContext=""] - _Updatable. Inheritable._
211
- * A field that the user can use to attach serializable data that will be saved when {@link Platform#getSnapshot Platform.getSnapshot}
212
- * is called. If a window in a Platform is trying to update or retrieve its own context, it can use the
213
- * {@link Platform#setWindowContext Platform.setWindowContext} and {@link Platform#getWindowContext Platform.getWindowContext} calls.
214
- * _When omitted, _inherits_ from the parent application._
215
- * As opposed to customData, this is meant for frequent updates and sharing with other contexts. [Example]{@tutorial customContext}
216
- *
217
- * @property {any} [customData=""] - _Updatable. Inheritable._
218
- * A field that the user can attach serializable data to be ferried around with the window options.
219
- * _When omitted, _inherits_ from the parent application._
220
- *
221
- * @property {object[]} [customRequestHeaders]
222
- * Defines list of custom headers for requests sent by the window.
223
- * @property {string[]} [customRequestHeaders.urlPatterns=[]] The URL patterns for which the headers will be applied
224
- * @property {object[]} [customRequestHeaders.headers=[]] Objects representing headers and their values,
225
- * where the object key is the name of header and value at key is the value of the header
226
- *
227
- * @property {boolean} [closeOnLastViewRemoved=true] - _Experimental._ _Updatable._
228
- * Toggling off would keep the Window alive even if all its Views were closed.
229
- * This is meant for advanced users and should be used with caution.
230
- * Limitations - Once a Layout has been emptied out of all views it's not usable anymore, and certain API calls will fail.
231
- * Use `layout.replace` to create a fresh Layout instance in case you want to populate it with Views again.
232
- * ** note ** - This option is ignored in non-Platforms apps.
233
- *
234
- * @property {boolean} [defaultCentered=false]
235
- * Centers the window in the primary monitor. This option overrides `defaultLeft` and `defaultTop`. When `saveWindowState` is `true`,
236
- * this value will be ignored for subsequent launches in favor of the cached value. **NOTE:** On macOS _defaultCenter_ is
237
- * somewhat above center vertically.
238
- *
239
- * @property {number} [defaultHeight=500]
240
- * The default height of the window. When `saveWindowState` is `true`, this value will be ignored for subsequent launches
241
- * in favor of the cached value.
242
- *
243
- * @property {number} [defaultLeft=100]
244
- * The default left position of the window. When `saveWindowState` is `true`, this value will be ignored for subsequent
245
- * launches in favor of the cached value.
246
- *
247
- * @property {number} [defaultTop=100]
248
- * The default top position of the window. When `saveWindowState` is `true`, this value will be ignored for subsequent
249
- * launches in favor of the cached value.
250
- *
251
- * @property {number} [defaultWidth=800]
252
- * The default width of the window. When `saveWindowState` is `true`, this value will be ignored for subsequent
253
- * launches in favor of the cached value.
254
- *
255
- * @property {boolean} [includeInSnapshots=true] - _Updatable._
256
- * When true, the window will be be included in snapshots returned by Platform.getSnapshot(). Turning this off may be desirable when dealing with
257
- * inherently temporary windows whose state shouldn't be preserved, such as modals, menus, or popups.
258
- *
259
- * @property {boolean} [frame=true] - _Updatable._
260
- * A flag to show the frame.
261
- *
262
- * @hidden-property {boolean} [hideOnClose=false] - A flag to allow a window to be hidden when the close button is clicked.
263
- *
264
- * @property {object[]} [hotkeys=[]] - _Updatable._
265
- * Defines the list of hotkeys that will be emitted as a `hotkey` event on the window. For usage example see [example]{@tutorial hotkeys}.
266
- * Within Platform, OpenFin also implements a set of pre-defined actions called
267
- * [keyboard commands]{@link https://developers.openfin.co/docs/platform-api#section-5-3-using-keyboard-commands}
268
- * that can be assigned to a specific hotkey in the platform manifest.
269
- * @property {string} hotkeys.keys The key combination of the hotkey, i.e. "Ctrl+T"
270
- * @property {boolean} [hotkeys.preventDefault=false] Whether or not to prevent default key handling before emitting the event
271
- *
272
- * @property {string} [icon] - _Updatable. Inheritable._
273
- * A URL for the icon to be shown in the window title bar and the taskbar.
274
- * When omitted, inherits from the parent application._
275
- * note: Window OS caches taskbar icons, therefore an icon change might only be visible after the cache is removed or the uuid is changed.
276
- *
277
- * @property {number} [maxHeight=-1] - _Updatable._
278
- * The maximum height of a window. Will default to the OS defined value if set to -1.
279
- *
280
- * @property {boolean} [maximizable=true] - _Updatable._
281
- * A flag that lets the window be maximized.
282
- *
283
- * @property {number} [maxWidth=-1] - _Updatable._
284
- * The maximum width of a window. Will default to the OS defined value if set to -1.
285
- *
286
- * @property {number} [minHeight=0] - _Updatable._
287
- * The minimum height of a window.
288
- *
289
- * @property {boolean} [minimizable=true] - _Updatable._
290
- * A flag that lets the window be minimized.
291
- *
292
- * @property {number} [minWidth=0] - _Updatable._
293
- * The minimum width of a window.
294
- *
295
- * @property {Identity} [modalParentIdentity]
296
- * Parent identity of a modal window. It will create a modal child window when this option is set.
297
- *
298
- * @property {string} name
299
- * The name of the window.
300
- *
301
- * @property {number} [opacity=1.0] - _Updatable._
302
- * A flag that specifies how transparent the window will be.
303
- * Changing opacity doesn't work on Windows 7 without Aero so setting this value will have no effect there.
304
- * This value is clamped between `0.0` and `1.0`.
305
- *
306
- * @property {preloadScript[]} [preloadScripts] - _Inheritable_
307
- * A list of scripts that are eval'ed before other scripts in the page. When omitted, _inherits_
308
- * from the parent application.
309
- *
310
- * @property {string} [processAffinity]
311
- * A string to attempt to group renderers together. Will only be used if pages are on the same origin.
312
- *
313
- * @property {boolean} [resizable=true] - _Updatable._
314
- * A flag to allow the user to resize the window.
315
- *
316
- * @property {object} [resizeRegion] - _Updatable._
317
- * Defines a region in pixels that will respond to user mouse interaction for resizing a frameless window.
318
- * @property {number} [resizeRegion.bottomRightCorner=9]
319
- * The size in pixels of an additional square resizable region located at the bottom right corner of a frameless window.
320
- * @property {number} [resizeRegion.size=7]
321
- * The size in pixels.
322
- * @property {object} [resizeRegion.sides={top:true,right:true,bottom:true,left:true}]
323
- * Sides that a window can be resized from.
324
- *
325
- * @property {boolean} [saveWindowState=true]
326
- * A flag to cache the location of the window.
327
- * ** note ** - This option is ignored in Platforms as it would cause inconsistent {@link Platform#applySnapshot applySnapshot} behavior.
328
- *
329
- * @property {boolean} [ignoreSavedWindowState]
330
- * A flag to ignore previously cached state of the window. It defaults the opposite value of `saveWindowState` to maintain backwards compatibility.
331
- *
332
- * @property {boolean} [shadow=false]
333
- * A flag to display a shadow on frameless windows.
334
- * `shadow` and `cornerRounding` are mutually exclusive.
335
- * On Windows 7, Aero theme is required.
336
- *
337
- * @property {boolean} [showBackgroundImages=false] - _Updatable._
338
- * Platforms Only. If true, will show background images in the layout when the Views are hidden.
339
- * This occurs when the window is resizing or a tab is being dragged within the layout.
340
- *
341
- * @property {boolean} [showTaskbarIcon=true] - _Updatable._ _Windows_.
342
- * A flag to show the window's icon in the taskbar.
343
- *
344
- * @property {boolean} [smallWindow=false]
345
- * A flag to specify a frameless window that can be be created and resized to less than 41x36 px (width x height).
346
- * _Note: Caveats of small windows are no Aero Snap and drag to/from maximize._
347
- * _Windows 10: Requires `maximizable` to be false. Resizing with the mouse is only possible down to 38x39 px._
348
- *
349
- * @property {boolean} [spellCheck=false]
350
- * Enable spell check in input text fields for the window.
351
- *
352
- * @property {string} [state="normal"]
353
- * The visible state of the window on creation.
354
- * One of:
355
- * * `"maximized"`
356
- * * `"minimized"`
357
- * * `"normal"`
358
- *
359
- * @property {string} [taskbarIcon=string] - Deprecated - use `icon` instead._Windows_.
360
- *
361
- * @property {string} [taskbarIconGroup=<application uuid>] - _Windows_.
362
- * Specify a taskbar group for the window.
363
- * _If omitted, defaults to app's uuid (`fin.Application.getCurrentSync().identity.uuid`)._
364
- *
365
- * @property {string} [url="about:blank"]
366
- * The URL of the window.
367
- *
368
- * @property {string} [uuid=<application uuid>]
369
- * The `uuid` of the application, unique within the set of all `Application`s running in OpenFin Runtime.
370
- * If omitted, defaults to the `uuid` of the application spawning the window.
371
- * If given, must match the `uuid` of the application spawning the window.
372
- * In other words, the application's `uuid` is the only acceptable value, but is the default, so there's
373
- * really no need to provide it.
374
- *
375
- * @property {boolean} [waitForPageLoad=false]
376
- * When set to `true`, the window will not appear until the `window` object's `load` event fires.
377
- * When set to `false`, the window will appear immediately without waiting for content to be loaded.
378
- *
379
- * @property {ViewVisibility} [viewVisibility]
380
- * _Platform Windows Only_. Controls behavior for showing views when they are being resized by the user.
381
- */
382
- /**
383
- * @PORTED
384
- * @typedef {Object} ViewVisibility _Platform Windows Only_. Controls behavior for showing views when they are being resized by the user.
385
- * @property {ShowViewsOnWindowResize} [showViewsOnWindowResize] Enables views to be shown when a Platform Window is being resized by the user.
386
- * @property {ShowViewsOnSplitterDrag} [showViewsOnSplitterDrag] Allows views to be shown when they are resized by the user dragging the splitter between layout stacks.
387
- * @property {ShowViewsOnTabDrag} [showViewsOnTabDrag] _Supported on Windows Operating Systems only_. Allows views to be shown when the user is dragging a tab around a layout.
388
- */
389
- /**
390
- * @PORTED
391
- * @typedef {Object} ShowViewsOnWindowResize _Platform Windows Only_. Enables views to be shown when a Platform Window is being resized by the user.
392
- * @property {boolean} [enabled=false] Enables or disables showing Views when a Platform Window is being resized.
393
- * @property {number} [paintIntervalMs=0] Number of miliseconds to wait between view repaints.
394
- */
395
- /**
396
- * @REMOVED
397
- * @typedef {Object} ShowViewsOnSplitterDrag _Platform Windows Only_. Allows views to be shown when they are resized by the user dragging the splitter between layout stacks.
398
- * @property {boolean} [enabled=false] Enables or disables showing views when the layout splitter is being dragged.
399
- */
400
- /**
401
- * @REMOVED
402
- * @typedef {Object} ShowViewsOnTabDrag _Platform Windows Only_. Allows views to be shown when the user is manipulating the layout by repositioning a tab.
403
- * @property {boolean} [enabled=false] Enables or disables showing views when a tab is being dragged.
404
- */
405
- /**
406
- * @PORTED
407
- * @typedef {object} CapturePageOptions
408
- * @property { Area } [area] The area of the window to be captured.
409
- * @property { string } [format='png'] The format of the captured image. Can be 'png', 'jpg', or 'bmp'.
410
- * @property { number } [quality=100] Number representing quality of JPEG image only. Between 0 - 100.
411
- */
412
- /**
413
- * @PORTED
414
- * @typedef { object } Area
415
- * @property { number } height Area's height
416
- * @property { number } width Area's width
417
- * @property { number } x X coordinate of area's starting point
418
- * @property { number } y Y coordinate of area's starting point
419
- */
420
- /**
421
- * @PORTED
422
- * @typedef {object} FindInPageOptions
423
- * @property {boolean} [forward=true] Whether to search forward or backward.
424
- * @property {boolean} [findNext=false] Whether to begin a new text finding session. Should be true for first requests, and false for subsequent requests. Defaults to false.
425
- * @property {boolean} [matchCase=false] Whether search should be case-sensitive.
426
- * @property {boolean} [wordStart=false] Whether to look only at the start of words.
427
- * @property {boolean} [medialCapitalAsWordStart=false]
428
- * When combined with wordStart, accepts a match in the middle of a word if the match begins with an uppercase letter followed by a<br>
429
- * lowercase or non-letter. Accepts several other intra-word matches.
430
- */
431
- /**
432
- * @REMOVED
433
- * @typedef {object} Transition
434
- * @property {Opacity} opacity - The Opacity transition
435
- * @property {Position} position - The Position transition
436
- * @property {Size} size - The Size transition
437
- */
438
- /**
439
- * @PORTED
440
- * @typedef {object} TransitionOptions
441
- * @property {boolean} interrupt - This option interrupts the current animation. When false it pushes
442
- this animation onto the end of the animation queue.
443
- * @property {boolean} relative - Treat 'opacity' as absolute or as a delta. Defaults to false.
444
- */
445
- /**
446
- * @PORTED
447
- * @typedef {object} Size
448
- * @property {number} duration - The total time in milliseconds this transition should take.
449
- * @property {boolean} relative - Treat 'opacity' as absolute or as a delta. Defaults to false.
450
- * @property {number} width - Optional if height is present. Defaults to the window's current width.
451
- * @property {number} height - Optional if width is present. Defaults to the window's current height.
452
- */
453
- /**
454
- * @PORTED
455
- * @typedef {object} Position
456
- * @property {number} duration - The total time in milliseconds this transition should take.
457
- * @property {boolean} relative - Treat 'opacity' as absolute or as a delta. Defaults to false.
458
- * @property {number} left - Defaults to the window's current left position in virtual screen coordinates.
459
- * @property {number} top - Defaults to the window's current top position in virtual screen coordinates.
460
- */
461
- /**
462
- * @PORTED
463
- * @typedef {object} Opacity
464
- * @property {number} duration - The total time in milliseconds this transition should take.
465
- * @property {boolean} relative - Treat 'opacity' as absolute or as a delta. Defaults to false.
466
- * @property {number} opacity - This value is clamped from 0.0 to 1.0.
467
- */
468
- /**
469
- * @REMOVED
470
- * Bounds is a interface that has the properties of height,
471
- * width, left, top which are all numbers
472
- * @typedef { object } Bounds
473
- * @property { number } height Get the application height bound
474
- * @property { number } width Get the application width bound
475
- * @property { number } top Get the application top bound
476
- * @property { number } left Get the application left bound
477
- * @property { number } right Get the application right bound
478
- * @property { number } bottom Get the application bottom bound
479
- */
480
- /**
481
- * A basic window that wraps a native HTML window. Provides more fine-grained
482
- * control over the window state such as the ability to minimize, maximize, restore, etc.
483
- * By default a window does not show upon instantiation; instead the window's show() method
484
- * must be invoked manually. The new window appears in the same process as the parent window.
485
- * It has the ability to listen for {@link OpenFin.WindowEvents window specific events}.
486
- */
487
- // The window.Window name is taken
488
- class _Window extends main_1.WebContents {
489
- /**
490
- * @internal
491
- */
492
- constructor(wire, identity) {
493
- super(wire, identity, 'window');
494
- this.identity = identity;
495
- }
496
- /**
497
- * Adds a listener to the end of the listeners array for the specified event.
498
- * @param eventType - The type of the event.
499
- * @param listener - Called whenever an event of the specified type occurs.
500
- * @param options - Option to support event timestamps.
501
- *
502
- * @function addListener
503
- * @memberof Window
504
- * @instance
505
- * @tutorial Window.EventEmitter
506
- */
507
- /**
508
- * Adds a listener to the end of the listeners array for the specified event.
509
- * @param eventType - The type of the event.
510
- * @param listener - Called whenever an event of the specified type occurs.
511
- * @param options - Option to support event timestamps.
512
- *
513
- * @function on
514
- * @memberof Window
515
- * @instance
516
- * @tutorial Window.EventEmitter
517
- */
518
- /**
519
- * 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.
520
- * @param eventType - The type of the event.
521
- * @param listener - The callback function.
522
- * @param options - Option to support event timestamps.
523
- *
524
- * @function once
525
- * @memberof Window
526
- * @instance
527
- * @tutorial Window.EventEmitter
528
- */
529
- /**
530
- * Adds a listener to the beginning of the listeners array for the specified event.
531
- * @param eventType - The type of the event.
532
- * @param listener - The callback function.
533
- * @param options - Option to support event timestamps.
534
- *
535
- * @function prependListener
536
- * @memberof Window
537
- * @instance
538
- * @tutorial Window.EventEmitter
539
- */
540
- /**
541
- * 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.
542
- * The listener is added to the beginning of the listeners array.
543
- * @param eventType - The type of the event.
544
- * @param listener - The callback function.
545
- * @param options - Option to support event timestamps.
546
- *
547
- * @function prependOnceListener
548
- * @memberof Window
549
- * @instance
550
- * @tutorial Window.EventEmitter
551
- */
552
- /**
553
- * Remove a listener from the listener array for the specified event.
554
- * Caution: Calling this method changes the array indices in the listener array behind the listener.
555
- * @param eventType - The type of the event.
556
- * @param listener - The callback function.
557
- * @param options - Option to support event timestamps.
558
- *
559
- * @function removeListener
560
- * @memberof Window
561
- * @instance
562
- * @tutorial Window.EventEmitter
563
- */
564
- /**
565
- * Removes all listeners, or those of the specified event.
566
- * @param eventType - The type of the event.
567
- *
568
- * @function removeAllListeners
569
- * @memberof Window
570
- * @instance
571
- * @tutorial Window.EventEmitter
572
- */
573
- // create a new window
574
- createWindow(options) {
575
- this.wire.sendAction('window-create-window', this.identity).catch((e) => {
576
- // we do not want to expose this error, just continue if this analytics-only call fails
577
- });
578
- return new Promise((resolve, reject) => {
579
- const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
580
- // need to call pageResponse, otherwise when a child window is created, page is not loaded
581
- const pageResponse = new Promise((resolve) => {
582
- // TODO: fix typing (internal)
583
- // @ts-expect-error
584
- this.on(CONSTRUCTOR_CB_TOPIC, function fireConstructor(response) {
585
- let cbPayload;
586
- const { success } = response;
587
- const responseData = response.data;
588
- const { message } = responseData;
589
- if (success) {
590
- cbPayload = {
591
- httpResponseCode: responseData.httpResponseCode,
592
- apiInjected: responseData.apiInjected
593
- };
594
- }
595
- else {
596
- cbPayload = {
597
- message: responseData.message,
598
- networkErrorCode: responseData.networkErrorCode,
599
- stack: responseData.stack
600
- };
601
- }
602
- this.removeListener(CONSTRUCTOR_CB_TOPIC, fireConstructor);
603
- resolve({
604
- message,
605
- cbPayload,
606
- success
607
- });
608
- });
609
- });
610
- // set defaults:
611
- if (options.waitForPageLoad === undefined) {
612
- options.waitForPageLoad = false;
613
- }
614
- if (options.autoShow === undefined) {
615
- options.autoShow = true;
616
- }
617
- const windowCreation = this.wire.environment.createChildContent({ entityType: 'window', options });
618
- Promise.all([pageResponse, windowCreation])
619
- .then((resolvedArr) => {
620
- const pageResolve = resolvedArr[0];
621
- if (pageResolve.success) {
622
- resolve(this);
623
- }
624
- else {
625
- reject(pageResolve);
626
- }
627
- try {
628
- // this is to enforce a 5.0 contract that the child's main function
629
- // will not fire before the parent's success callback on creation.
630
- // if the child window is not accessible (CORS) this contract does
631
- // not hold.
632
- const webWindow = this.getWebWindow();
633
- webWindow.fin.__internal_.openerSuccessCBCalled();
634
- }
635
- catch (e) {
636
- // common for main windows, we do not want to expose this error. here just to have a debug target.
637
- // console.error(e);
638
- }
639
- })
640
- .catch(reject);
641
- });
642
- }
643
- /**
644
- * Retrieves an array of frame info objects representing the main frame and any
645
- * iframes that are currently on the page.
646
- *
647
- * @example
648
- * ```js
649
- * async function getAllFrames() {
650
- * const app = await fin.Application.start({
651
- * name: 'myApp',
652
- * uuid: 'app-1',
653
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getAllFrames.html',
654
- * autoShow: true
655
- * });
656
- * const win = await app.getWindow();
657
- * return await win.getAllFrames();
658
- * }
659
- *
660
- * getAllFrames().then(framesInfo => console.log(framesInfo)).catch(err => console.log(err));
661
- * ```
662
- */
663
- getAllFrames() {
664
- return this.wire.sendAction('get-all-frames', this.identity).then(({ payload }) => payload.data);
665
- }
666
- /**
667
- * Gets the current bounds (top, bottom, right, left, width, height) of the window.
668
- *
669
- * @example
670
- * ```js
671
- * async function getBounds() {
672
- * const app = await fin.Application.start({
673
- * name: 'myApp',
674
- * uuid: 'app-3',
675
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getBounds.html',
676
- * autoShow: true
677
- * });
678
- * const win = await app.getWindow();
679
- * return await win.getBounds();
680
- * }
681
- *
682
- * getBounds().then(bounds => console.log(bounds)).catch(err => console.log(err));
683
- * ```
684
- */
685
- getBounds() {
686
- return this.wire
687
- .sendAction('get-window-bounds', this.identity)
688
- .then(({ payload }) => payload.data);
689
- }
690
- /**
691
- * Centers the window on its current screen.
692
- *
693
- * @remarks Does not have an effect on minimized or maximized windows.
694
- *
695
- * @example
696
- * ```js
697
- * async function centerWindow() {
698
- * const app = await fin.Application.start({
699
- * name: 'myApp',
700
- * uuid: 'app-1',
701
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.center.html',
702
- * autoShow: true
703
- * });
704
- * const win = await app.getWindow();
705
- * return await win.center();
706
- * }
707
- *
708
- * centerWindow().then(() => console.log('Window centered')).catch(err => console.log(err));
709
- * ```
710
- *
711
- */
712
- center() {
713
- return this.wire.sendAction('center-window', this.identity).then(() => undefined);
714
- }
715
- /**
716
- * Removes focus from the window.
717
- *
718
- * @example
719
- * ```js
720
- * async function blurWindow() {
721
- * const app = await fin.Application.start({
722
- * name: 'myApp',
723
- * uuid: 'app-1',
724
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.blur.html',
725
- * autoShow: true
726
- * });
727
- * const win = await app.getWindow();
728
- * return await win.blur();
729
- * }
730
- *
731
- * blurWindow().then(() => console.log('Blured Window')).catch(err => console.log(err));
732
- * ```
733
- */
734
- blur() {
735
- return this.wire.sendAction('blur-window', this.identity).then(() => undefined);
736
- }
737
- /**
738
- * Brings the window to the front of the window stack.
739
- *
740
- * @example
741
- * ```js
742
- * async function BringWindowToFront() {
743
- * const app = await fin.Application.start({
744
- * name: 'myApp',
745
- * uuid: 'app-1',
746
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.bringToFront.html',
747
- * autoShow: true
748
- * });
749
- * const win = await app.getWindow();
750
- * return await win.bringToFront();
751
- * }
752
- *
753
- * BringWindowToFront().then(() => console.log('Window is in the front')).catch(err => console.log(err));
754
- * ```
755
- */
756
- bringToFront() {
757
- return this.wire.sendAction('bring-window-to-front', this.identity).then(() => undefined);
758
- }
759
- /**
760
- * Performs the specified window transitions.
761
- * @param transitions - Describes the animations to perform. See the tutorial.
762
- * @param options - Options for the animation. See the tutorial.
763
- *
764
- * @example
765
- * ```
766
- * async function animateWindow() {
767
- * const transitions = {
768
- * opacity: {
769
- * opacity: 0.7,
770
- * duration: 500
771
- * },
772
- * position: {
773
- * top: 100,
774
- * left: 100,
775
- * duration: 500,
776
- * relative: true
777
- * }
778
- * };
779
- * const options = {
780
- * interrupt: true,
781
- * tween: 'ease-in'
782
- * };
783
- *
784
- * const win = await fin.Window.getCurrent();
785
- * return win.animate(transitions, options);
786
- * }
787
- *
788
- * animateWindow()
789
- * .then(() => console.log('Animation done'))
790
- * .catch(err => console.error(err));
791
- * ```
792
- */
793
- animate(transitions, options) {
794
- return this.wire
795
- .sendAction('animate-window', {
796
- transitions,
797
- options,
798
- ...this.identity
799
- })
800
- .then(() => undefined);
801
- }
802
- /**
803
- * Hides the window.
804
- *
805
- * @example
806
- * ```js
807
- * async function hideWindow() {
808
- * const app = await fin.Application.start({
809
- * name: 'myApp',
810
- * uuid: 'app-1',
811
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.hide.html',
812
- * autoShow: true
813
- * });
814
- * const win = await app.getWindow();
815
- * return await win.hide();
816
- * }
817
- *
818
- * hideWindow().then(() => console.log('Window is hidden')).catch(err => console.log(err));
819
- * ```
820
- */
821
- hide() {
822
- return this.wire.sendAction('hide-window', this.identity).then(() => undefined);
823
- }
824
- /**
825
- * closes the window application
826
- * @param force Close will be prevented from closing when force is false and
827
- * ‘close-requested’ has been subscribed to for application’s main window.
828
- *
829
- * @example
830
- * ```js
831
- * async function closeWindow() {
832
- * const app = await fin.Application.start({
833
- * name: 'myApp',
834
- * uuid: 'app-3',
835
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.close.html',
836
- * autoShow: true
837
- * });
838
- * const win = await app.getWindow();
839
- * return await win.close();
840
- * }
841
- *
842
- * closeWindow().then(() => console.log('Window closed')).catch(err => console.log(err));
843
- * ```
844
- */
845
- close(force = false) {
846
- return this.wire.sendAction('close-window', { force, ...this.identity }).then(() => {
847
- Object.setPrototypeOf(this, null);
848
- return undefined;
849
- });
850
- }
851
- focusedWebViewWasChanged() {
852
- return this.wire.sendAction('focused-webview-changed', this.identity).then(() => undefined);
853
- }
854
- /**
855
- * Returns the native OS level Id.
856
- *
857
- * @remarks In Windows, it will return the Windows [handle](https://docs.microsoft.com/en-us/windows/desktop/WinProg/windows-data-types#HWND).
858
- *
859
- * @example
860
- * ```js
861
- * async function getWindowNativeId() {
862
- * const app = await fin.Application.start({
863
- * name: 'myApp',
864
- * uuid: 'app-3',
865
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getNativeId.html',
866
- * autoShow: true
867
- * });
868
- * const win = await app.getWindow();
869
- * return await win.getNativeId();
870
- * }
871
- *
872
- * getWindowNativeId().then(nativeId => console.log(nativeId)).catch(err => console.log(err));
873
- * ```
874
- */
875
- getNativeId() {
876
- return this.wire.sendAction('get-window-native-id', this.identity).then(({ payload }) => payload.data);
877
- }
878
- /**
879
- * Retrieves window's attached views.
880
- * @experimental
881
- *
882
- * @example
883
- * ```js
884
- * const win = fin.Window.getCurrentSync();
885
- *
886
- * win.getCurrentViews()
887
- * .then(views => console.log(views))
888
- * .catch(console.error);
889
- * ```
890
- */
891
- async getCurrentViews() {
892
- const { payload } = await this.wire.sendAction('window-get-views', this.identity);
893
- return payload.data.map((id) => new view_1.View(this.wire, id));
894
- }
895
- /**
896
- * @deprecated Use {@link Window._Window.disableUserMovement} instead.
897
- */
898
- disableFrame() {
899
- console.warn('Function is deprecated; use disableUserMovement instead.');
900
- return this.wire.sendAction('disable-window-frame', this.identity).then(() => undefined);
901
- }
902
- /**
903
- * Prevents a user from changing a window's size/position when using the window's frame.
904
- *
905
- * @example
906
- * ```js
907
- * async function disableUserMovement() {
908
- * const app = await fin.Application.start({
909
- * name: 'myApp',
910
- * uuid: 'app-3',
911
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.disableFrame.html',
912
- * autoShow: true
913
- * });
914
- * const win = await app.getWindow();
915
- * return await win.disableUserMovement();
916
- * }
917
- *
918
- * disableUserMovement().then(() => console.log('Window is disabled')).catch(err => console.log(err));
919
- * ```
920
- */
921
- disableUserMovement() {
922
- return this.wire.sendAction('disable-window-frame', this.identity).then(() => undefined);
923
- }
924
- /**
925
- * @deprecated Use {@link Window._Window.enableUserMovement} instead.
926
- */
927
- enableFrame() {
928
- console.warn('Function is deprecated; use enableUserMovement instead.');
929
- return this.wire.sendAction('enable-window-frame', this.identity).then(() => undefined);
930
- }
931
- /**
932
- * Re-enables user changes to a window's size/position when using the window's frame.
933
- *
934
- * @example
935
- * ```js
936
- * async function enableUserMovement() {
937
- * const app = await fin.Application.start({
938
- * name: 'myApp',
939
- * uuid: 'app-3',
940
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.enableFrame.html',
941
- * autoShow: true
942
- * });
943
- * const win = await app.getWindow();
944
- * return await win.enableUserMovement();
945
- * }
946
- *
947
- * enableUserMovement().then(() => console.log('Window is enabled')).catch(err => console.log(err));
948
- * ```
949
- */
950
- enableUserMovement() {
951
- return this.wire.sendAction('enable-window-frame', this.identity).then(() => undefined);
952
- }
953
- /**
954
- * Flashes the window’s frame and taskbar icon until stopFlashing is called or until a focus event is fired.
955
- *
956
- * @remarks On macOS flash only works on inactive windows.
957
- * @example
958
- * ```js
959
- * async function windowFlash() {
960
- * const app = await fin.Application.start({
961
- * name: 'myApp',
962
- * uuid: 'app-1',
963
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.flash.html',
964
- * autoShow: true
965
- * });
966
- * const win = await app.getWindow();
967
- * return await win.flash();
968
- * }
969
- *
970
- * windowFlash().then(() => console.log('Window flashing')).catch(err => console.log(err));
971
- * ```
972
- */
973
- flash() {
974
- return this.wire.sendAction('flash-window', this.identity).then(() => undefined);
975
- }
976
- /**
977
- * Stops the taskbar icon from flashing.
978
- *
979
- * @example
980
- * ```js
981
- * async function stopWindowFlashing() {
982
- * const app = await fin.Application.start({
983
- * name: 'myApp',
984
- * uuid: 'app-1',
985
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.stopFlashing.html',
986
- * autoShow: true
987
- * });
988
- * const win = await app.getWindow();
989
- * return await win.stopFlashing();
990
- * }
991
- *
992
- * stopWindowFlashing().then(() => console.log('Application window flashing')).catch(err => console.log(err));
993
- * ```
994
- */
995
- stopFlashing() {
996
- return this.wire.sendAction('stop-flash-window', this.identity).then(() => undefined);
997
- }
998
- /**
999
- * Gets an information object for the window.
1000
- *
1001
- * @example
1002
- * ```js
1003
- * async function getInfo() {
1004
- * const app = await fin.Application.start({
1005
- * name: 'myApp',
1006
- * uuid: 'app-1',
1007
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getInfo.html',
1008
- * autoShow: true
1009
- * });
1010
- * const win = await app.getWindow();
1011
- * return await win.getInfo();
1012
- * }
1013
- *
1014
- * getInfo().then(info => console.log(info)).catch(err => console.log(err));
1015
- * ```
1016
- */
1017
- getInfo() {
1018
- return this.wire.sendAction('get-window-info', this.identity).then(({ payload }) => payload.data);
1019
- }
1020
- /**
1021
- * Retrieves the window's Layout
1022
- *
1023
- * @example
1024
- * ```js
1025
- * //get the current window
1026
- * const window = await fin.Window.getCurrent();
1027
- *
1028
- * //get the layout for the window
1029
- * const layout = await window.getLayout();
1030
- * ```
1031
- * @experimental
1032
- */
1033
- async getLayout() {
1034
- this.wire.sendAction('window-get-layout', this.identity).catch((e) => {
1035
- // don't expose
1036
- });
1037
- const opts = await this.getOptions();
1038
- if (!opts.layout) {
1039
- throw new Error('Window does not have a Layout');
1040
- }
1041
- return this.fin.Platform.Layout.wrap(this.identity);
1042
- }
1043
- /**
1044
- * Gets the current settings of the window.
1045
- *
1046
- * @example
1047
- * ```js
1048
- * async function getWindowOptions() {
1049
- * const app = await fin.Application.start({
1050
- * name: 'myApp',
1051
- * uuid: 'app-1',
1052
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getOptions.html',
1053
- * autoShow: true
1054
- * });
1055
- * const win = await app.getWindow();
1056
- * return await win.getOptions();
1057
- * }
1058
- *
1059
- * getWindowOptions().then(opts => console.log(opts)).catch(err => console.log(err));
1060
- * ```
1061
- */
1062
- getOptions() {
1063
- return this.wire.sendAction('get-window-options', this.identity).then(({ payload }) => payload.data);
1064
- }
1065
- /**
1066
- * Gets the parent application.
1067
- *
1068
- * @example
1069
- * ```js
1070
- * async function getParentApplication() {
1071
- * const app = await fin.Application.start({
1072
- * name: 'myApp',
1073
- * uuid: 'app-1',
1074
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getParentApplication.html',
1075
- * autoShow: true
1076
- * });
1077
- * const win = await app.getWindow();
1078
- * return await win.getParentApplication();
1079
- * }
1080
- *
1081
- * getParentApplication().then(parentApplication => console.log(parentApplication)).catch(err => console.log(err));
1082
- * ```
1083
- */
1084
- getParentApplication() {
1085
- this.wire.sendAction('window-get-parent-application', this.identity).catch((e) => {
1086
- // we do not want to expose this error, just continue if this analytics-only call fails
1087
- });
1088
- return Promise.resolve(new application_1.Application(this.wire, this.identity));
1089
- }
1090
- /**
1091
- * Gets the parent window.
1092
- *
1093
- * @example
1094
- * ```js
1095
- * async function getParentWindow() {
1096
- * const app = await fin.Application.start({
1097
- * name: 'myApp',
1098
- * uuid: 'app-1',
1099
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getParentWindow.html',
1100
- * autoShow: true
1101
- * });
1102
- * const win = await app.getWindow();
1103
- * return await win.getParentWindow();
1104
- * }
1105
- *
1106
- * getParentWindow().then(parentWindow => console.log(parentWindow)).catch(err => console.log(err));
1107
- * ```
1108
- */
1109
- getParentWindow() {
1110
- this.wire.sendAction('window-get-parent-window', this.identity).catch((e) => {
1111
- // we do not want to expose this error, just continue if this analytics-only call fails
1112
- });
1113
- return Promise.resolve(new application_1.Application(this.wire, this.identity)).then((app) => app.getWindow());
1114
- }
1115
- /**
1116
- * ***DEPRECATED - please use Window.capturePage.***
1117
- * Gets a base64 encoded PNG image of the window or just part a of it.
1118
- * @param area The area of the window to be captured.
1119
- * Omitting it will capture the whole visible window.
1120
- *
1121
- * @tutorial Window.capturePage
1122
- */
1123
- async getSnapshot(area) {
1124
- const req = { area, ...this.identity };
1125
- console.warn('Window.getSnapshot has been deprecated, please use Window.capturePage');
1126
- const res = await this.wire.sendAction('get-window-snapshot', req);
1127
- return res.payload.data;
1128
- }
1129
- /**
1130
- * Gets the current state ("minimized", "maximized", or "normal") of the window.
1131
- *
1132
- * @example
1133
- * ```js
1134
- * async function getWindowState() {
1135
- * const app = await fin.Application.start({
1136
- * name: 'myApp',
1137
- * uuid: 'app-1',
1138
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getState.html',
1139
- * autoShow: true
1140
- * });
1141
- * const win = await app.getWindow();
1142
- * return await win.getState();
1143
- * }
1144
- *
1145
- * getWindowState().then(winState => console.log(winState)).catch(err => console.log(err));
1146
- * ```
1147
- */
1148
- getState() {
1149
- return this.wire.sendAction('get-window-state', this.identity).then(({ payload }) => payload.data);
1150
- }
1151
- /**
1152
- * Previously called getNativeWindow.
1153
- * Returns the [Window Object](https://developer.mozilla.org/en-US/docs/Web/API/Window)
1154
- * that represents the web context of the target window. This is the same object that
1155
- * you would get from calling [window.open()](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) in a standard web context.
1156
- * The target window needs to be in the same application as the requesting window
1157
- * as well as comply with [same-origin](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) policy requirements.
1158
- *
1159
- * @example
1160
- * Injecting content into an empty window:
1161
- *
1162
- * ```js
1163
- * (async ()=> {
1164
- * try {
1165
- * const winName = `child-window-${Date.now()}`;
1166
- * const win = await fin.Window.create({
1167
- * name: winName,
1168
- * url: 'about:blank'
1169
- * });
1170
- * win.getWebWindow().document.write('<h1>Hello World</h1>');
1171
- * } catch (err) {
1172
- * console.error(err);
1173
- * }
1174
- * })();
1175
- * ```
1176
- *
1177
- * Cloning DOM elements from the parent window (in this example we clone an `h3` element from the parent window):
1178
- * ```js
1179
- * (async ()=> {
1180
- * try {
1181
- * const currentWindow = await fin.Window.getCurrent();
1182
- * const parentWindow = await currentWindow.getParentWindow();
1183
- * const clonedH3 = parentWindow.getWebWindow().document.querySelector('h3').cloneNode(true);
1184
- * document.body.append(clonedH3);
1185
- *
1186
- * } catch (err) {
1187
- * console.error(err);
1188
- * }
1189
- * })();
1190
- * ```
1191
- *
1192
- * Rendering on a child window via a library (in this example we are using the [lit-html](https://lit-html.polymer-project.org/)
1193
- * template library to render content on a blank child window. You are not going to be able to copy paste this example without
1194
- * configuring the project correctly but this would demonstrate some templating options available):
1195
- * ```js
1196
- * (async ()=> {
1197
- * try {
1198
- * const win = await fin.Window.create({
1199
- * name: `child-window-${Date.now()}`,
1200
- * url: 'about:blank'
1201
- * });
1202
- * const template = html`
1203
- * <div>
1204
- * <span>Click here: </span>
1205
- * <button @click=${()=> console.log('Hello World!')}>log to the console</button>
1206
- * </div>`;
1207
- * render(template, win.getWebWindow().document.body);
1208
- *
1209
- * } catch (err) {
1210
- * console.error(err);
1211
- * }
1212
- * })();
1213
- * ```
1214
- */
1215
- getWebWindow() {
1216
- this.wire.sendAction('window-get-web-window', this.identity).catch((e) => {
1217
- // we do not want to expose this error, just continue if this analytics-only call fails
1218
- });
1219
- return this.wire.environment.getWebWindow(this.identity);
1220
- }
1221
- /**
1222
- * Determines if the window is a main window.
1223
- *
1224
- * @example
1225
- * ```js
1226
- * const wnd = fin.Window.getCurrentSync();
1227
- * const isMainWnd = wnd.isMainWindow();
1228
- * console.log('Is this a main window? ' + isMainWnd);
1229
- * ```
1230
- */
1231
- isMainWindow() {
1232
- this.wire.sendAction('window-is-main-window', this.identity).catch((e) => {
1233
- // we do not want to expose this error, just continue if this analytics-only call fails
1234
- });
1235
- return this.me.uuid === this.me.name;
1236
- }
1237
- /**
1238
- * Determines if the window is currently showing.
1239
- *
1240
- * @example
1241
- * ```js
1242
- * async function isWindowShowing() {
1243
- * const app = await fin.Application.start({
1244
- * name: 'myApp',
1245
- * uuid: 'app-1',
1246
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.isShowing.html',
1247
- * autoShow: true
1248
- * });
1249
- * const win = await app.getWindow();
1250
- * return await win.isShowing();
1251
- * }
1252
- *
1253
- * isWindowShowing().then(bool => console.log(bool)).catch(err => console.log(err));
1254
- * ```
1255
- */
1256
- isShowing() {
1257
- return this.wire.sendAction('is-window-showing', this.identity).then(({ payload }) => payload.data);
1258
- }
1259
- /**
1260
- * Maximizes the window
1261
- *
1262
- * @example
1263
- * ```js
1264
- * async function maxWindow() {
1265
- * const app = await fin.Application.start({
1266
- * name: 'myApp',
1267
- * uuid: 'app-1',
1268
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.maximize.html',
1269
- * autoShow: true
1270
- * });
1271
- * const win = await app.getWindow();
1272
- * return await win.maximize();
1273
- * }
1274
- *
1275
- * maxWindow().then(() => console.log('Maximized window')).catch(err => console.log(err));
1276
- * ```
1277
- */
1278
- maximize() {
1279
- return this.wire.sendAction('maximize-window', this.identity).then(() => undefined);
1280
- }
1281
- /**
1282
- * Minimizes the window.
1283
- *
1284
- * @example
1285
- * ```js
1286
- * async function minWindow() {
1287
- * const win = await fin.Window.getCurrent();
1288
- * return await win.minimize();
1289
- * }
1290
- *
1291
- * minWindow().then(() => console.log('Minimized window')).catch(err => console.log(err));
1292
- * ```
1293
- */
1294
- minimize() {
1295
- return this.wire.sendAction('minimize-window', this.identity).then(() => undefined);
1296
- }
1297
- /**
1298
- * Moves the window by a specified amount.
1299
- * @param deltaLeft The change in the left position of the window
1300
- * @param deltaTop The change in the top position of the window
1301
- *
1302
- * @example
1303
- * ```js
1304
- * async function createWin() {
1305
- * const app = await fin.Application.start({
1306
- * name: 'myApp',
1307
- * uuid: 'app-1',
1308
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.moveBy.html',
1309
- * autoShow: true
1310
- * });
1311
- * return await app.getWindow();
1312
- * }
1313
- *
1314
- * async function moveBy(left, top) {
1315
- * const win = await createWin();
1316
- * return await win.moveBy(left, top);
1317
- * }
1318
- *
1319
- * moveBy(580, 300).then(() => console.log('Moved')).catch(err => console.log(err));
1320
- * ```
1321
- */
1322
- moveBy(deltaLeft, deltaTop) {
1323
- return this.wire
1324
- .sendAction('move-window-by', {
1325
- deltaLeft,
1326
- deltaTop,
1327
- ...this.identity
1328
- })
1329
- .then(() => undefined);
1330
- }
1331
- /**
1332
- * Moves the window to a specified location.
1333
- * @param left The left position of the window
1334
- * @param top The top position of the window
1335
- *
1336
- * @example
1337
- * ```js
1338
- * async function createWin() {
1339
- * const app = await fin.Application.start({
1340
- * name: 'myApp',
1341
- * uuid: 'app-1',
1342
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.moveTo.html',
1343
- * autoShow: true
1344
- * });
1345
- * return await app.getWindow();
1346
- * }
1347
- *
1348
- * async function moveTo(left, top) {
1349
- * const win = await createWin();
1350
- * return await win.moveTo(left, top)
1351
- * }
1352
- *
1353
- * moveTo(580, 300).then(() => console.log('Moved')).catch(err => console.log(err))
1354
- * ```
1355
- */
1356
- moveTo(left, top) {
1357
- return this.wire
1358
- .sendAction('move-window', {
1359
- left,
1360
- top,
1361
- ...this.identity
1362
- })
1363
- .then(() => undefined);
1364
- }
1365
- /**
1366
- * Resizes the window by a specified amount.
1367
- * @param deltaWidth The change in the width of the window
1368
- * @param deltaHeight The change in the height of the window
1369
- * @param anchor Specifies a corner to remain fixed during the resize.
1370
- * Can take the values: "top-left", "top-right", "bottom-left", or "bottom-right".
1371
- * If undefined, the default is "top-left"
1372
- *
1373
- * @example
1374
- * ```js
1375
- * async function createWin() {
1376
- * const app = await fin.Application.start({
1377
- * name: 'myApp',
1378
- * uuid: 'app-1',
1379
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.resizeBy.html',
1380
- * autoShow: true
1381
- * });
1382
- * return await app.getWindow();
1383
- * }
1384
- *
1385
- * async function resizeBy(left, top, anchor) {
1386
- * const win = await createWin();
1387
- * return await win.resizeBy(left, top, anchor)
1388
- * }
1389
- *
1390
- * resizeBy(580, 300, 'top-right').then(() => console.log('Resized')).catch(err => console.log(err));
1391
- * ```
1392
- */
1393
- resizeBy(deltaWidth, deltaHeight, anchor) {
1394
- return this.wire
1395
- .sendAction('resize-window-by', {
1396
- deltaWidth: Math.floor(deltaWidth),
1397
- deltaHeight: Math.floor(deltaHeight),
1398
- anchor,
1399
- ...this.identity
1400
- })
1401
- .then(() => undefined);
1402
- }
1403
- /**
1404
- * Resizes the window to the specified dimensions.
1405
- * @param width The change in the width of the window
1406
- * @param height The change in the height of the window
1407
- * @param anchor Specifies a corner to remain fixed during the resize.
1408
- * Can take the values: "top-left", "top-right", "bottom-left", or "bottom-right".
1409
- * If undefined, the default is "top-left"
1410
- *
1411
- * @example
1412
- * ```js
1413
- * async function createWin() {
1414
- * const app = await fin.Application.start({
1415
- * name: 'myApp',
1416
- * uuid: 'app-1',
1417
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.resizeTo.html',
1418
- * autoShow: true
1419
- * });
1420
- * return await app.getWindow();
1421
- * }
1422
- *
1423
- * async function resizeTo(left, top, anchor) {
1424
- * const win = await createWin();
1425
- * return await win.resizeTo(left, top, anchor);
1426
- * }
1427
- *
1428
- * resizeTo(580, 300, 'top-left').then(() => console.log('Resized')).catch(err => console.log(err));
1429
- * ```
1430
- */
1431
- resizeTo(width, height, anchor) {
1432
- return this.wire
1433
- .sendAction('resize-window', {
1434
- width: Math.floor(width),
1435
- height: Math.floor(height),
1436
- anchor,
1437
- ...this.identity
1438
- })
1439
- .then(() => undefined);
1440
- }
1441
- /**
1442
- * Restores the window to its normal state (i.e., unminimized, unmaximized).
1443
- *
1444
- * @example
1445
- * ```js
1446
- * async function createWin() {
1447
- * const app = await fin.Application.start({
1448
- * name: 'myApp',
1449
- * uuid: 'app-1',
1450
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.restore.html',
1451
- * autoShow: true
1452
- * });
1453
- * return await app.getWindow();
1454
- * }
1455
- *
1456
- * async function restore() {
1457
- * const win = await createWin();
1458
- * return await win.restore();
1459
- * }
1460
- *
1461
- * restore().then(() => console.log('Restored')).catch(err => console.log(err));
1462
- * ```
1463
- */
1464
- restore() {
1465
- return this.wire.sendAction('restore-window', this.identity).then(() => undefined);
1466
- }
1467
- /**
1468
- * Will bring the window to the front of the entire stack and give it focus.
1469
- *
1470
- * @example
1471
- * ```js
1472
- * async function createWin() {
1473
- * const app = await fin.Application.start({
1474
- * name: 'myApp',
1475
- * uuid: 'app-1',
1476
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setAsForeground.html',
1477
- * autoShow: true
1478
- * });
1479
- * return await app.getWindow();
1480
- * }
1481
- *
1482
- * async function setAsForeground() {
1483
- * const win = await createWin();
1484
- * return await win.setAsForeground()
1485
- * }
1486
- *
1487
- * setAsForeground().then(() => console.log('In the foreground')).catch(err => console.log(err));
1488
- * ```
1489
- */
1490
- setAsForeground() {
1491
- return this.wire.sendAction('set-foreground-window', this.identity).then(() => undefined);
1492
- }
1493
- /**
1494
- * Sets the window's size and position.
1495
- * @property { Bounds } bounds This is a * @type {string} name - name of the window.object that holds the propertys of
1496
- *
1497
- * @example
1498
- * ```js
1499
- * async function createWin() {
1500
- * const app = await fin.Application.start({
1501
- * name: 'myApp',
1502
- * uuid: 'app-1',
1503
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setBounds.html',
1504
- * autoShow: true
1505
- * });
1506
- * return await app.getWindow();
1507
- * }
1508
- *
1509
- * async function setBounds(bounds) {
1510
- * const win = await createWin();
1511
- * return await win.setBounds(bounds);
1512
- * }
1513
- *
1514
- * setBounds({
1515
- * height: 100,
1516
- * width: 200,
1517
- * top: 400,
1518
- * left: 400
1519
- * }).then(() => console.log('Bounds set to window')).catch(err => console.log(err));
1520
- * ```
1521
- */
1522
- setBounds(bounds) {
1523
- return this.wire.sendAction('set-window-bounds', { ...bounds, ...this.identity }).then(() => undefined);
1524
- }
1525
- /**
1526
- * Shows the window if it is hidden.
1527
- * @param force Show will be prevented from showing when force is false and
1528
- * ‘show-requested’ has been subscribed to for application’s main window.
1529
- *
1530
- * @example
1531
- * ```js
1532
- * async function createWin() {
1533
- * const app = await fin.Application.start({
1534
- * name: 'myApp',
1535
- * uuid: 'app-1',
1536
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.show.html',
1537
- * autoShow: false
1538
- * });
1539
- * return await app.getWindow();
1540
- * }
1541
- *
1542
- * async function show() {
1543
- * const win = await createWin();
1544
- * return await win.show()
1545
- * }
1546
- *
1547
- * show().then(() => console.log('Showing')).catch(err => console.log(err));
1548
- * ```
1549
- */
1550
- show(force = false) {
1551
- return this.wire.sendAction('show-window', { force, ...this.identity }).then(() => undefined);
1552
- }
1553
- /**
1554
- * Shows the window if it is hidden at the specified location.
1555
- * If the toggle parameter is set to true, the window will
1556
- * alternate between showing and hiding.
1557
- * @param left The left position of the window
1558
- * @param top The right position of the window
1559
- * @param force Show will be prevented from closing when force is false and
1560
- * ‘show-requested’ has been subscribed to for application’s main window
1561
- *
1562
- * @example
1563
- * ```js
1564
- * async function createWin() {
1565
- * const app = await fin.Application.start({
1566
- * name: 'myApp',
1567
- * uuid: 'app-1',
1568
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.showAt.html',
1569
- * autoShow: true
1570
- * });
1571
- * return await app.getWindow();
1572
- * }
1573
- *
1574
- * async function showAt(left, top) {
1575
- * const win = await createWin();
1576
- * return await win.showAt(left, top)
1577
- * }
1578
- *
1579
- * showAt(580, 300).then(() => console.log('Showing at')).catch(err => console.log(err));
1580
- * ```
1581
- */
1582
- showAt(left, top, force = false) {
1583
- return this.wire
1584
- .sendAction('show-at-window', {
1585
- force,
1586
- left: Math.floor(left),
1587
- top: Math.floor(top),
1588
- ...this.identity
1589
- })
1590
- .then(() => undefined);
1591
- }
1592
- /**
1593
- * Shows the Chromium Developer Tools
1594
- *
1595
- * @tutorial Window.showDeveloperTools
1596
- */
1597
- /**
1598
- * Updates the window using the passed options.
1599
- *
1600
- * @remarks Values that are objects are deep-merged, overwriting only the values that are provided.
1601
- * @param options Changes a window's options that were defined upon creation. See tutorial
1602
- *
1603
- * @example
1604
- * ```js
1605
- * async function updateOptions() {
1606
- * const win = await fin.Window.getCurrent();
1607
- * return win.updateOptions({maxWidth: 100});
1608
- * }
1609
- * updateOptions().then(() => console.log('options is updated')).catch(err => console.error(err));
1610
- * ```
1611
- */
1612
- updateOptions(options) {
1613
- return this.wire.sendAction('update-window-options', { options, ...this.identity }).then(() => undefined);
1614
- }
1615
- /**
1616
- * Provides credentials to authentication requests
1617
- * @param userName userName to provide to the authentication challenge
1618
- * @param password password to provide to the authentication challenge
1619
- *
1620
- * @example
1621
- * ```js
1622
- * fin.Application.wrap({uuid: 'OpenfinPOC'}).then(app => {
1623
- * app.on('window-auth-requested', evt => {
1624
- * let win = fin.Window.wrap({ uuid: evt.uuid, name: evt.name});
1625
- * win.authenticate('userName', 'P@assw0rd').then(()=> console.log('authenticated')).catch(err => console.log(err));
1626
- * });
1627
- * });
1628
- * ```
1629
- */
1630
- authenticate(userName, password) {
1631
- return this.wire
1632
- .sendAction('window-authenticate', { userName, password, ...this.identity })
1633
- .then(() => undefined);
1634
- }
1635
- /**
1636
- * @typedef {object} ShowPopupMenuOptions
1637
- * @property {Array<MenuItemTemplate>} template - An array describing the menu to show.
1638
- * @property {number} [x] - The window x coordinate where to show the menu. Defaults to mouse position. If using must also use `y`.
1639
- * @property {number} [y] - The window y coordinate where to show the menu. Defaults to mouse position. If using must also use `x`
1640
- */
1641
- /**
1642
- * @typedef {object} MenuItemTemplate
1643
- * @property {*} data - Data to be returned if the user selects the element. Must be serializable. Large objects can have a performance impact.
1644
- * @property {'normal' | 'separator' | 'submenu' | 'checkbox'} [type] - Defaults to 'normal' unless a 'submenu' key exists
1645
- * @property {string} [label] - The text to show on the menu item. Should be left undefined for `type: 'separator'`
1646
- * @property {boolean} [enabled] - If false, the menu item will be greyed out and unclickable.
1647
- * @property {boolean} [visible] - If false, the menu item will be entirely hidden.
1648
- * @property {boolean} [checked] - Should only be specified for `checkbox` type menu items.
1649
- * @property {string} [icon] - Image Data URI with image dimensions inferred from the encoded string
1650
- * @property {Array<MenuItemTemplate>} [submenu] Should be specified for `submenu` type menu items. If `submenu` is specified, the `type: 'submenu'` can be omitted.
1651
- */
1652
- /**
1653
- * @typedef {object} MenuResult
1654
- * @property {'clicked' | 'closed'} result - Whether the user clicked on a menu item or the menu was closed (user clicked elsewhere).
1655
- * @property {* | undefined} [data] - The data property of the menu item clicked by the user. Only defined if result was `clicked`.
1656
- */
1657
- /**
1658
- * Shows a menu on the window.
1659
- *
1660
- * @remarks Returns a promise that resolves when the user has either selected an item or closed the menu. (This may take longer than other apis).
1661
- * Resolves to an object with `{result: 'clicked', data }` where data is the data field on the menu item clicked, or `{result 'closed'}` when the user doesn't select anything.
1662
- * Calling this method will close previously opened menus.
1663
- * @experimental
1664
- * @param options
1665
- *
1666
- * @example
1667
- * This could be used to show a drop down menu over views in a platform window:
1668
- * ```js
1669
- * const template = [
1670
- * {
1671
- * label: 'Menu Item 1',
1672
- * data: 'hello from item 1'
1673
- * },
1674
- * { type: 'separator' },
1675
- * {
1676
- * label: 'Menu Item 2',
1677
- * type: 'checkbox',
1678
- * checked: true,
1679
- * data: 'The user clicked the checkbox'
1680
- * },
1681
- * {
1682
- * label: 'see more',
1683
- * enabled: false,
1684
- * submenu: [
1685
- * { label: 'submenu 1', data: 'hello from submenu' }
1686
- * ]
1687
- * }
1688
- * ]
1689
- * fin.me.showPopupMenu({ template }).then(r => {
1690
- * if (r.result === 'closed') {
1691
- * console.log('nothing happened');
1692
- * } else {
1693
- * console.log(r.data)
1694
- * }
1695
- * })
1696
- * ```
1697
- *
1698
- * Overriding the built in context menu (ote that this can be done per element or document wide):
1699
- * ```js
1700
- * document.addEventListener('contextmenu', e => {
1701
- * e.preventDefault();
1702
- * const template = [
1703
- * {
1704
- * label: 'Menu Item 1',
1705
- * data: 'hello from item 1'
1706
- * },
1707
- * { type: 'separator' },
1708
- * {
1709
- * label: 'Menu Item 2',
1710
- * type: 'checkbox',
1711
- * checked: true,
1712
- * data: 'The user clicked the checkbox'
1713
- * },
1714
- * {
1715
- * label: 'see more',
1716
- * enabled: false,
1717
- * submenu: [
1718
- * { label: 'submenu 1', data: 'hello from submenu' }
1719
- * ]
1720
- * }
1721
- * ]
1722
- * fin.me.showPopupMenu({ template, x: e.x, y: e.y }).then(r => {
1723
- * if (r.result === 'closed') {
1724
- * console.log('nothing happened');
1725
- * } else {
1726
- * console.log(r.data)
1727
- * }
1728
- * })
1729
- * })
1730
- * ```
1731
- */
1732
- async showPopupMenu(options) {
1733
- const { payload } = await this.wire.sendAction('show-popup-menu', { options, ...this.identity });
1734
- return payload.data;
1735
- }
1736
- /**
1737
- * Closes the window's popup menu, if one exists.
1738
- * @experimental
1739
- *
1740
- * @remarks Only one popup menu will ever be showing at a time. Calling `showPopupMenu` will automatically close
1741
- * any existing popup menu.
1742
- *
1743
- *
1744
- * @example
1745
- * This could be used to close a popup menu if the user's mouse leaves an element for example.
1746
- *
1747
- * ```js
1748
- * await fin.me.closePopupMenu();
1749
- * ```
1750
- */
1751
- async closePopupMenu() {
1752
- return this.wire.sendAction('close-popup-menu', { ...this.identity }).then(() => undefined);
1753
- }
1754
- /**
1755
- * @typedef {object} PopupOptions
1756
- * @property {string} [name] - If a window with this `name` exists, it will be shown as a popup. Otherwise, a new window with this `name` will be created. If this `name` is undefined, `initialOptions.name` will be used. If this `name` and `intialOptions.name` are both undefined, a `name` will be generated.
1757
- * @property {string} [url] - Navigates to this `url` if showing an existing window as a popup, otherwise the newly created window will load this `url`.
1758
- * @property {Window~options} [initialOptions] - Window creation options when using `showPopupWindow` to create a new window.
1759
- * @property {Window~options} [additionalOptions] - Updatable window options applied to new and existing windows when shown as popups.
1760
- * @property {function} [onPopupResult] - Executed when this window's popup calls `dispatchPopupResult`. Note: if this is defined, `showPopupWindow` will not return a `PopupResult`.
1761
- * @property {function} [onPopupReady] - Executed when the popup window is shown. Provides the popup window to the provided function, and allows for easy access the popup window for additional behavior customization.
1762
- * @property {number} [height] - Height of the popup window (takes priority over `intialOptions` size properties).
1763
- * @property {number} [width] - Width of the popup window (takes priority over `intialOptions` size properties).
1764
- * @property {number} [x] - Left position where the popup window will be shown (relative to the window calling `showPopupWindow`).
1765
- * @property {number} [y] - Top position where the popup window will be shown (relative to the window calling `showPopupWindow`).
1766
- * @property {'modal' | 'hide' | 'close'} [blurBehavior] - Determines what happens if the popup window is blurred. 'modal' restricts resizing and positioning in the caller, 'hide' hides the popup window on blur and 'close' closes the popup window on blur.
1767
- * @property {'none' | 'hide' | 'close'} [resultDispatchBehavior] - Determines what happens when the popup window calls `dispatchPopupResult`. 'none' will do nothing, 'hide' hides the popup window on `dispatchPopupResult` and 'close' closes the popup window on `dispatchPopupResult`.
1768
- * @property {boolean} [focus] - Determines if the popup window should or should not be focused when it is shown.
1769
- * @property {boolean} [hideOnClose] - Hide the popup window instead of closing whenever `close` is called on it. Note: if this is `true` and `blurBehavior` and/or `resultDispatchBehavior` are set to `close`, the window will be hidden.
1770
- */
1771
- /**
1772
- * @typedef {object} PopupResult
1773
- * @property {Identity} identity - `name` and `uuid` of the popup window that called dispatched this result.
1774
- * @property {'clicked' | 'dismissed'} result - Result of the user interaction with the popup window.
1775
- * @property {* | undefined} [data] - Data passed to `dispatchPopupResult`.
1776
- */
1777
- /**
1778
- * Dispatch a result to the caller of `showPopupWindow`.
1779
- *
1780
- * @remarks If this window isn't currently being shown as a popup, this call will silently fail.
1781
- * @param data Serializable data to send to the caller window.
1782
- *
1783
- * @example
1784
- * ```js
1785
- * await fin.me.dispatchPopupResult({
1786
- * foo: 'bar'
1787
- * });
1788
- * ```
1789
- */
1790
- async dispatchPopupResult(data) {
1791
- this.wire.sendAction('window-dispatch-popup-result', this.identity).catch((e) => {
1792
- // we do not want to expose this error, just continue if this analytics-only call fails
1793
- });
1794
- await this.wire.sendAction('dispatch-popup-result', { data, ...this.identity });
1795
- }
1796
- /**
1797
- * Prints the contents of the window.
1798
- *
1799
- * @param options Configuration for the print task.
1800
- * @remarks When `silent` is set to `true`, the API will pick the system's default printer if deviceName is empty
1801
- * and the default settings for printing.
1802
- *
1803
- * Use the CSS style `page-break-before: always;` to force print to a new page.
1804
- *
1805
- * @example
1806
- * ```js
1807
- * const win = fin.Window.getCurrentSync();
1808
- *
1809
- * win.print({ silent: false, deviceName: 'system-printer-name' }).then(() => {
1810
- * console.log('print call has been sent to the system');
1811
- * });
1812
- * ```
1813
- *
1814
- * If a window has embedded views, those views will not print by default. To print a window's contents including embedded views,
1815
- * use the `content` option:
1816
- *
1817
- * ```js
1818
- * const win = fin.Window.getCurrentSync();
1819
- *
1820
- * // Print embedded views
1821
- * win.print({ content: 'views' });
1822
- *
1823
- * // Print screenshot of current window
1824
- * win.print({ content: 'screenshot' })
1825
- * ```
1826
- *
1827
- * When `content` is set to `views`, the embedded views in the platform window will be concatenated and printed as
1828
- * individual pages. If `includeSelf` is set to `true`, the platform window itself will be printed as the first
1829
- * page - be aware that this page will *not* include the embedded views - it will only include the contents of
1830
- * the platform window itself (e.g. tab stacks), with blank spaces where the view contents would be embedded.
1831
- *
1832
- * Due to a known issue, view contents that are not visible at the time `print` is called will not appear when
1833
- * printing `contents: views`. This includes views that are obscured behind other active UI elements.
1834
- *
1835
- * To print the views embedded in their page context, set `content` to `screenshot`.
1836
- */
1837
- async print(options = { content: 'self' }) {
1838
- switch (options.content) {
1839
- case undefined:
1840
- case 'self':
1841
- return super.print(options);
1842
- case 'screenshot':
1843
- return this.wire.sendAction('print-screenshot', this.identity).then(() => undefined);
1844
- case 'views':
1845
- return this.wire.sendAction('print-views', { ...this.identity, options }).then(() => undefined);
1846
- default:
1847
- return undefined;
1848
- }
1849
- }
1850
- }
1851
- exports._Window = _Window;