@openfin/core 25.68.26

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 (227) hide show
  1. package/LICENSE +13 -0
  2. package/NOTICE +16 -0
  3. package/OpenFin.d.ts +1340 -0
  4. package/README.md +41 -0
  5. package/docs.README(OLD).md +82 -0
  6. package/fin.d.ts +4 -0
  7. package/package.json +33 -0
  8. package/resources/win/OpenFinRVM.exe +0 -0
  9. package/src/api/application/Factory.d.ts +145 -0
  10. package/src/api/application/Factory.js +229 -0
  11. package/src/api/application/Instance.d.ts +302 -0
  12. package/src/api/application/Instance.js +412 -0
  13. package/src/api/application/index.d.ts +3 -0
  14. package/src/api/application/index.js +15 -0
  15. package/src/api/base.d.ts +43 -0
  16. package/src/api/base.js +177 -0
  17. package/src/api/clipboard/index.d.ts +69 -0
  18. package/src/api/clipboard/index.js +88 -0
  19. package/src/api/events/application.d.ts +69 -0
  20. package/src/api/events/application.js +2 -0
  21. package/src/api/events/base.d.ts +17 -0
  22. package/src/api/events/base.js +2 -0
  23. package/src/api/events/channel.d.ts +10 -0
  24. package/src/api/events/channel.js +2 -0
  25. package/src/api/events/emitterMap.d.ts +11 -0
  26. package/src/api/events/emitterMap.js +35 -0
  27. package/src/api/events/eventAggregator.d.ts +5 -0
  28. package/src/api/events/eventAggregator.js +43 -0
  29. package/src/api/events/externalApplication.d.ts +5 -0
  30. package/src/api/events/externalApplication.js +2 -0
  31. package/src/api/events/frame.d.ts +9 -0
  32. package/src/api/events/frame.js +2 -0
  33. package/src/api/events/globalHotkey.d.ts +10 -0
  34. package/src/api/events/globalHotkey.js +2 -0
  35. package/src/api/events/platform.d.ts +18 -0
  36. package/src/api/events/platform.js +2 -0
  37. package/src/api/events/system.d.ts +22 -0
  38. package/src/api/events/system.js +2 -0
  39. package/src/api/events/view.d.ts +56 -0
  40. package/src/api/events/view.js +2 -0
  41. package/src/api/events/webcontents.d.ts +48 -0
  42. package/src/api/events/webcontents.js +2 -0
  43. package/src/api/events/window.d.ts +169 -0
  44. package/src/api/events/window.js +2 -0
  45. package/src/api/external-application/Factory.d.ts +26 -0
  46. package/src/api/external-application/Factory.js +40 -0
  47. package/src/api/external-application/Instance.d.ts +102 -0
  48. package/src/api/external-application/Instance.js +109 -0
  49. package/src/api/external-application/index.d.ts +3 -0
  50. package/src/api/external-application/index.js +15 -0
  51. package/src/api/fin.d.ts +49 -0
  52. package/src/api/fin.js +43 -0
  53. package/src/api/frame/Factory.d.ts +36 -0
  54. package/src/api/frame/Factory.js +69 -0
  55. package/src/api/frame/Instance.d.ts +121 -0
  56. package/src/api/frame/Instance.js +130 -0
  57. package/src/api/frame/index.d.ts +3 -0
  58. package/src/api/frame/index.js +15 -0
  59. package/src/api/global-hotkey/index.d.ts +38 -0
  60. package/src/api/global-hotkey/index.js +58 -0
  61. package/src/api/interappbus/channel/channel.d.ts +26 -0
  62. package/src/api/interappbus/channel/channel.js +77 -0
  63. package/src/api/interappbus/channel/channels-docs.d.ts +318 -0
  64. package/src/api/interappbus/channel/channels-docs.js +376 -0
  65. package/src/api/interappbus/channel/client.d.ts +22 -0
  66. package/src/api/interappbus/channel/client.js +84 -0
  67. package/src/api/interappbus/channel/connection-manager.d.ts +28 -0
  68. package/src/api/interappbus/channel/connection-manager.js +244 -0
  69. package/src/api/interappbus/channel/index.d.ts +22 -0
  70. package/src/api/interappbus/channel/index.js +121 -0
  71. package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +13 -0
  72. package/src/api/interappbus/channel/protocols/classic/message-receiver.js +73 -0
  73. package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +22 -0
  74. package/src/api/interappbus/channel/protocols/classic/strategy.js +84 -0
  75. package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +20 -0
  76. package/src/api/interappbus/channel/protocols/combined/strategy.js +58 -0
  77. package/src/api/interappbus/channel/protocols/index.d.ts +44 -0
  78. package/src/api/interappbus/channel/protocols/index.js +2 -0
  79. package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +10 -0
  80. package/src/api/interappbus/channel/protocols/protocol-manager.js +43 -0
  81. package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +23 -0
  82. package/src/api/interappbus/channel/protocols/rtc/endpoint.js +135 -0
  83. package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +30 -0
  84. package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +131 -0
  85. package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +22 -0
  86. package/src/api/interappbus/channel/protocols/rtc/strategy.js +87 -0
  87. package/src/api/interappbus/channel/protocols/strategy-types.d.ts +13 -0
  88. package/src/api/interappbus/channel/protocols/strategy-types.js +2 -0
  89. package/src/api/interappbus/channel/protocols/strategy.d.ts +15 -0
  90. package/src/api/interappbus/channel/protocols/strategy.js +2 -0
  91. package/src/api/interappbus/channel/provider.d.ts +31 -0
  92. package/src/api/interappbus/channel/provider.js +165 -0
  93. package/src/api/interappbus/index.d.ts +85 -0
  94. package/src/api/interappbus/index.js +175 -0
  95. package/src/api/interop/Factory.d.ts +37 -0
  96. package/src/api/interop/Factory.js +54 -0
  97. package/src/api/interop/InteropBroker.d.ts +363 -0
  98. package/src/api/interop/InteropBroker.js +914 -0
  99. package/src/api/interop/InteropClient.d.ts +268 -0
  100. package/src/api/interop/InteropClient.js +450 -0
  101. package/src/api/interop/SessionContextGroupBroker.d.ts +26 -0
  102. package/src/api/interop/SessionContextGroupBroker.js +107 -0
  103. package/src/api/interop/SessionContextGroupClient.d.ts +20 -0
  104. package/src/api/interop/SessionContextGroupClient.js +85 -0
  105. package/src/api/interop/fdc3/fdc3-1.2.d.ts +187 -0
  106. package/src/api/interop/fdc3/fdc3-1.2.js +385 -0
  107. package/src/api/interop/fdc3/fdc3.js +17 -0
  108. package/src/api/interop/fdc3/utils.d.ts +6 -0
  109. package/src/api/interop/fdc3/utils.js +17 -0
  110. package/src/api/interop/index.d.ts +4 -0
  111. package/src/api/interop/index.js +16 -0
  112. package/src/api/interop/utils.d.ts +11 -0
  113. package/src/api/interop/utils.js +36 -0
  114. package/src/api/me.d.ts +35 -0
  115. package/src/api/me.js +60 -0
  116. package/src/api/platform/Factory.d.ts +109 -0
  117. package/src/api/platform/Factory.js +188 -0
  118. package/src/api/platform/Instance.d.ts +122 -0
  119. package/src/api/platform/Instance.js +299 -0
  120. package/src/api/platform/common-utils.d.ts +6 -0
  121. package/src/api/platform/common-utils.js +16 -0
  122. package/src/api/platform/index.d.ts +3 -0
  123. package/src/api/platform/index.js +15 -0
  124. package/src/api/platform/layout/Factory.d.ts +108 -0
  125. package/src/api/platform/layout/Factory.js +189 -0
  126. package/src/api/platform/layout/Instance.d.ts +48 -0
  127. package/src/api/platform/layout/Instance.js +99 -0
  128. package/src/api/platform/layout/index.d.ts +3 -0
  129. package/src/api/platform/layout/index.js +15 -0
  130. package/src/api/platform/layout/shapes.d.ts +11 -0
  131. package/src/api/platform/layout/shapes.js +2 -0
  132. package/src/api/snapshot-source/Factory.d.ts +36 -0
  133. package/src/api/snapshot-source/Factory.js +65 -0
  134. package/src/api/snapshot-source/Instance.d.ts +30 -0
  135. package/src/api/snapshot-source/Instance.js +134 -0
  136. package/src/api/snapshot-source/index.d.ts +3 -0
  137. package/src/api/snapshot-source/index.js +15 -0
  138. package/src/api/snapshot-source/utils.d.ts +1 -0
  139. package/src/api/snapshot-source/utils.js +5 -0
  140. package/src/api/system/application.d.ts +6 -0
  141. package/src/api/system/application.js +2 -0
  142. package/src/api/system/entity.d.ts +11 -0
  143. package/src/api/system/entity.js +2 -0
  144. package/src/api/system/index.d.ts +957 -0
  145. package/src/api/system/index.js +1241 -0
  146. package/src/api/system/installedApps.d.ts +6 -0
  147. package/src/api/system/installedApps.js +2 -0
  148. package/src/api/system/log.d.ts +11 -0
  149. package/src/api/system/log.js +2 -0
  150. package/src/api/system/process.d.ts +15 -0
  151. package/src/api/system/process.js +2 -0
  152. package/src/api/system/proxy.d.ts +15 -0
  153. package/src/api/system/proxy.js +2 -0
  154. package/src/api/system/queryPermissionTypes.d.ts +1 -0
  155. package/src/api/system/queryPermissionTypes.js +2 -0
  156. package/src/api/system/registry-info.d.ts +7 -0
  157. package/src/api/system/registry-info.js +2 -0
  158. package/src/api/system/window.d.ts +16 -0
  159. package/src/api/system/window.js +2 -0
  160. package/src/api/view/Factory.d.ts +49 -0
  161. package/src/api/view/Factory.js +103 -0
  162. package/src/api/view/Instance.d.ts +379 -0
  163. package/src/api/view/Instance.js +415 -0
  164. package/src/api/view/index.d.ts +3 -0
  165. package/src/api/view/index.js +15 -0
  166. package/src/api/webcontents/main.d.ts +36 -0
  167. package/src/api/webcontents/main.js +82 -0
  168. package/src/api/window/Factory.d.ts +44 -0
  169. package/src/api/window/Factory.js +91 -0
  170. package/src/api/window/Instance.d.ts +966 -0
  171. package/src/api/window/Instance.js +1202 -0
  172. package/src/api/window/bounds-changed.d.ts +10 -0
  173. package/src/api/window/bounds-changed.js +6 -0
  174. package/src/api/window/index.d.ts +5 -0
  175. package/src/api/window/index.js +17 -0
  176. package/src/api/window/shapes.d.ts +13 -0
  177. package/src/api/window/shapes.js +2 -0
  178. package/src/environment/environment.d.ts +28 -0
  179. package/src/environment/environment.js +4 -0
  180. package/src/environment/node-env.d.ts +25 -0
  181. package/src/environment/node-env.js +64 -0
  182. package/src/environment/openfin-env.d.ts +29 -0
  183. package/src/environment/openfin-env.js +105 -0
  184. package/src/mock.d.ts +4 -0
  185. package/src/mock.js +91 -0
  186. package/src/shapes/ERROR_BOX_TYPES.d.ts +6 -0
  187. package/src/shapes/ERROR_BOX_TYPES.js +10 -0
  188. package/src/shapes/EntityType.d.ts +1 -0
  189. package/src/shapes/EntityType.js +2 -0
  190. package/src/shapes/LayoutPresetType.d.ts +1 -0
  191. package/src/shapes/LayoutPresetType.js +2 -0
  192. package/src/shapes/Platform.d.ts +112 -0
  193. package/src/shapes/Platform.js +16 -0
  194. package/src/shapes/WebOptions.d.ts +12 -0
  195. package/src/shapes/WebOptions.js +2 -0
  196. package/src/shapes/WindowOptions.d.ts +42 -0
  197. package/src/shapes/WindowOptions.js +2 -0
  198. package/src/shapes/protocol.d.ts +178 -0
  199. package/src/shapes/protocol.js +2 -0
  200. package/src/transport/fin_store.d.ts +4 -0
  201. package/src/transport/fin_store.js +16 -0
  202. package/src/transport/transport-errors.d.ts +17 -0
  203. package/src/transport/transport-errors.js +39 -0
  204. package/src/transport/transport.d.ts +57 -0
  205. package/src/transport/transport.js +195 -0
  206. package/src/transport/wire.d.ts +76 -0
  207. package/src/transport/wire.js +39 -0
  208. package/src/util/asyncFilter.d.ts +1 -0
  209. package/src/util/asyncFilter.js +7 -0
  210. package/src/util/errors.d.ts +9 -0
  211. package/src/util/errors.js +14 -0
  212. package/src/util/exhaustive.d.ts +1 -0
  213. package/src/util/exhaustive.js +7 -0
  214. package/src/util/http.d.ts +11 -0
  215. package/src/util/http.js +83 -0
  216. package/src/util/normalize-config.d.ts +3 -0
  217. package/src/util/normalize-config.js +47 -0
  218. package/src/util/promises.d.ts +5 -0
  219. package/src/util/promises.js +27 -0
  220. package/src/util/ref-counter.d.ts +7 -0
  221. package/src/util/ref-counter.js +51 -0
  222. package/src/util/runtimeVersioning.d.ts +3 -0
  223. package/src/util/runtimeVersioning.js +25 -0
  224. package/src/util/utilTypes.d.ts +8 -0
  225. package/src/util/utilTypes.js +2 -0
  226. package/src/util/validate.d.ts +3 -0
  227. package/src/util/validate.js +11 -0
@@ -0,0 +1,1202 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._Window = void 0;
4
+ /* eslint-disable import/prefer-default-export */
5
+ const application_1 = require("../application");
6
+ const main_1 = require("../webcontents/main");
7
+ const view_1 = require("../view");
8
+ /**
9
+ * @typedef { object } Margins
10
+ * @property { string } [marginType]
11
+ * Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen,
12
+ * you will also need to specify `top`, `bottom`, `left`, and `right`.
13
+ *
14
+ * @property { number } [top] The top margin of the printed web page, in pixels.
15
+ * @property { number } [bottom] The bottom margin of the printed web page, in pixels.
16
+ * @property { number } [left] The left margin of the printed web page, in pixels.
17
+ * @property { number } [right] The right margin of the printed web page, in pixels.
18
+ */
19
+ /**
20
+ * @typedef { object } Dpi
21
+ * @property { number } [horizontal] The horizontal dpi
22
+ * @property { number } [vertical] The vertical dpi
23
+ */
24
+ /**
25
+ * @typedef { object } PrintOptions
26
+ * @property { boolean } [silent=false] Don't ask user for print settings.
27
+ * @property { boolean } [printBackground=false] Prints the background color and image of the web page.
28
+ * @property { string } [deviceName=''] Set the printer device name to use.
29
+ * @property { boolean } [color=true] Set whether the printed web page will be in color or grayscale.
30
+ * @property { Margins } [margins] Set margins for the printed web page
31
+ * @property { boolean } [landscape=false] Whether the web page should be printed in landscape mode.
32
+ * @property { number } [scaleFactor] The scale factor of the web page.
33
+ * @property { number } [pagesPerSheet] The number of pages to print per page sheet.
34
+ * @property { boolean } [collate] Whether the web page should be collated.
35
+ * @property { number } [copies] The number of copies of the web page to print.
36
+ * @property { Record<string, number> } [pageRanges] The page range to print. Should have two keys: from and to.
37
+ * @property { string } [duplexMode] Set the duplex mode of the printed web page. Can be simplex, shortEdge, or longEdge.
38
+ * @property { Dpi } [dpi] Set dpi for the printed web page
39
+ */
40
+ /**
41
+ * PrinterInfo interface
42
+ * @typedef { object } PrinterInfo
43
+ * @property { string } name Printer Name
44
+ * @property { string } description Printer Description
45
+ * @property { number } status Printer Status
46
+ * @property { boolean } isDefault Indicates that system's default printer
47
+ */
48
+ /**
49
+ * SharedWorkerInfo interface
50
+ * @typedef { object } SharedWorkerInfo
51
+ * @property { string } id The unique id of the shared worker.
52
+ * @property { string } url The url of the shared worker.
53
+ */
54
+ /**
55
+ * ContentCreationRule interface
56
+ * @typedef { object } ContentCreationRule
57
+ * @property { string } behavior 'view' | 'window' | 'browser' | 'block'
58
+ * @property { string[] } match List of [match patterns](https://developer.chrome.com/extensions/match_patterns).
59
+ * @property { object } options Window creation options or View creation options.
60
+ */
61
+ /**
62
+ * @typedef {object} Window~options
63
+ * @summary Window creation options.
64
+ * @desc This is the options object required by {@link Window.create Window.create}.
65
+ *
66
+ * Note that `name` is the only required property — albeit the `url` property is usually provided as well
67
+ * (defaults to `"about:blank"` when omitted).
68
+ *
69
+ * _This jsdoc typedef mirrors the `WindowOptions` TypeScript interface in `@types/openfin`._
70
+ *
71
+ * @property {object} [accelerator]
72
+ * Enable keyboard shortcuts for devtools, zoom, reload, and reload ignoring cache.
73
+ *
74
+ * @property {boolean} [accelerator.devtools=false]
75
+ * If `true`, enables the devtools keyboard shortcut:<br>
76
+ * `Ctrl` + `Shift` + `I` _(Toggles Devtools)_
77
+ *
78
+ * @property {boolean} [accelerator.reload=false]
79
+ * If `true`, enables the reload keyboard shortcuts:<br>
80
+ * `Ctrl` + `R` _(Windows)_<br>
81
+ * `F5` _(Windows)_<br>
82
+ * `Command` + `R` _(Mac)_
83
+ *
84
+ * @property {boolean} [accelerator.reloadIgnoringCache=false]
85
+ * If `true`, enables the reload-from-source keyboard shortcuts:<br>
86
+ * `Ctrl` + `Shift` + `R` _(Windows)_<br>
87
+ * `Shift` + `F5` _(Windows)_<br>
88
+ * `Command` + `Shift` + `R` _(Mac)_
89
+ *
90
+ * @property {boolean} [accelerator.zoom=false]
91
+ * If `true`, enables the zoom keyboard shortcuts:<br>
92
+ * `Ctrl` + `+` _(Zoom In)_<br>
93
+ * `Ctrl` + `Shift` + `+` _(Zoom In)_<br>
94
+ * `Ctrl` + `NumPad+` _(Zoom In)_<br>
95
+ * `Ctrl` + `-` _(Zoom Out)_<br>
96
+ * `Ctrl` + `Shift` + `-` _(Zoom Out)_<br>
97
+ * `Ctrl` + `NumPad-` _(Zoom Out)_<br>
98
+ * `Ctrl` + `Scroll` _(Zoom In & Out)_<br>
99
+ * `Ctrl` + `0` _(Restore to 100%)_
100
+ *
101
+ * @property {object} [alphaMask] - _Experimental._ _Updatable._
102
+ * <br>
103
+ * alphaMask turns anything of matching RGB value transparent.
104
+ * <br>
105
+ * Caveats:
106
+ * * runtime key --disable-gpu is required. Note: Unclear behavior on remote Desktop support
107
+ * * User cannot click-through transparent regions
108
+ * * Not supported on Mac
109
+ * * Windows Aero must be enabled
110
+ * * Won't make visual sense on Pixel-pushed environments such as Citrix
111
+ * * Not supported on rounded corner windows
112
+ * @property {number} [alphaMask.red=-1] 0-255
113
+ * @property {number} [alphaMask.green=-1] 0-255
114
+ * @property {number} [alphaMask.blue=-1] 0-255
115
+ *
116
+ * @property {boolean} [alwaysOnTop=false] - _Updatable._
117
+ * A flag to always position the window at the top of the window stack.
118
+ *
119
+ * @property {object} [api]
120
+ * Configurations for API injection.
121
+ *
122
+ * @property {object} [api.iframe] Configure if the the API should be injected into iframes based on domain.
123
+ *
124
+ * @property {boolean} [api.iframe.crossOriginInjection=false] Controls if the `fin` API object is present for cross origin iframes.
125
+ * @property {boolean} [api.iframe.sameOriginInjection=true] Controls if the `fin` API object is present for same origin iframes.
126
+ *
127
+ * @property {string} [applicationIcon = ""] - _Deprecated_ - use `icon` instead.
128
+ *
129
+ * @property {number} [aspectRatio=0] - _Updatable._
130
+ * The aspect ratio of width to height to enforce for the window. If this value is equal to or less than zero,
131
+ * an aspect ratio will not be enforced.
132
+ *
133
+ * @property {boolean} [autoShow=true]
134
+ * A flag to automatically show the window when it is created.
135
+ *
136
+ * @property {string} [backgroundColor="#FFF"]
137
+ * The window’s _backfill_ color as a hexadecimal value. Not to be confused with the content background color
138
+ * (`document.body.style.backgroundColor`),
139
+ * this color briefly fills a window’s (a) content area before its content is loaded as well as (b) newly exposed
140
+ * areas when growing a window. Setting
141
+ * this value to the anticipated content background color can help improve user experience.
142
+ * Default is white.
143
+ *
144
+ * @property {object} [contentCreation]
145
+ * Apply rules that determine how user interaction (`window.open` and links) creates content.
146
+ * @property {ContentCreationRule[]} [contentCreation.rules = []] List of content creation rules.
147
+ *
148
+ * @property {object} [contentNavigation]
149
+ * Restrict navigation to URLs that match a whitelisted pattern.
150
+ * In the lack of a whitelist, navigation to URLs that match a blacklisted pattern would be prohibited.
151
+ * See [here](https://developer.chrome.com/extensions/match_patterns) for more details.
152
+ * @property {string[]} [contentNavigation.whitelist=[]] List of whitelisted URLs.
153
+ * @property {string[]} [contentNavigation.blacklist=[]] List of blacklisted URLs.
154
+
155
+ * @property {boolean} [contextMenu=true] - _Updatable._
156
+ * A flag to show the context menu when right-clicking on a window.
157
+ * Gives access to the devtools for the window.
158
+ *
159
+ * @property {object} [contextMenuSettings] - _Updatable._
160
+ * Configure the context menu when right-clicking on a window.
161
+ * @property {boolean} [contextMenuSettings.enable=true] Should the context menu display on right click.
162
+ * @property {boolean} [contextMenuSettings.devtools=true] Should the context menu contain a button for opening devtools.
163
+ * @property {boolean} [contextMenuSettings.reload=true] Should the context menu contain a button for reloading the page.
164
+ *
165
+ * @property {object} [cornerRounding] - _Updatable._
166
+ * Defines and applies rounded corners for a frameless window. **NOTE:** On macOS corner is not ellipse but circle rounded by the
167
+ * average of _height_ and _width_.
168
+ * @property {number} [cornerRounding.height=0] The height in pixels.
169
+ * @property {number} [cornerRounding.width=0] The width in pixels.
170
+ *
171
+ * @property {any} [customContext=""] - _Updatable._
172
+ * A field that the user can use to attach serializable data that will be saved when {@link Platform#getSnapshot Platform.getSnapshot}
173
+ * is called. If a window in a Platform is trying to update or retrieve its own context, it can use the
174
+ * {@link Platform#setWindowContext Platform.setWindowContext} and {@link Platform#getWindowContext Platform.getWindowContext} calls.
175
+ * When omitted, the default value of this property is the empty string (`""`).
176
+ * As opposed to customData this is meant for frequent updates and sharing with other contexts. [Example]{@tutorial customContext}
177
+ *
178
+ * @property {any} [customData=""] - _Updatable._
179
+ * A field that the user can attach serializable data to to be ferried around with the window options.
180
+ * _When omitted, the default value of this property is the empty string (`""`)._
181
+ *
182
+ * @property {object[]} [customRequestHeaders]
183
+ * Defines list of custom headers for requests sent by the window.
184
+ * @property {string[]} [customRequestHeaders.urlPatterns=[]] The URL patterns for which the headers will be applied
185
+ * @property {object[]} [customRequestHeaders.headers=[]] Objects representing headers and their values,
186
+ * where the object key is the name of header and value at key is the value of the header
187
+ *
188
+ * @property {boolean} [closeOnLastViewRemoved=true] - _Experimental._ _Updatable._
189
+ * Toggling off would keep the Window alive even if all its Views were closed.
190
+ * This is meant for advanced users and should be used with caution.
191
+ * Limitations - Once a Layout has been emptied out of all views it's not usable anymore, and certain API calls will fail.
192
+ * Use `layout.replace` to create a fresh Layout instance in case you want to populate it with Views again.
193
+ * ** note ** - This option is ignored in non-Platforms apps.
194
+ *
195
+ * @property {boolean} [defaultCentered=false]
196
+ * Centers the window in the primary monitor. This option overrides `defaultLeft` and `defaultTop`. When `saveWindowState` is `true`,
197
+ * this value will be ignored for subsequent launches in favor of the cached value. **NOTE:** On macOS _defaultCenter_ is
198
+ * somewhat above center vertically.
199
+ *
200
+ * @property {number} [defaultHeight=500]
201
+ * The default height of the window. When `saveWindowState` is `true`, this value will be ignored for subsequent launches
202
+ * in favor of the cached value.
203
+ *
204
+ * @property {number} [defaultLeft=100]
205
+ * The default left position of the window. When `saveWindowState` is `true`, this value will be ignored for subsequent
206
+ * launches in favor of the cached value.
207
+ *
208
+ * @property {number} [defaultTop=100]
209
+ * The default top position of the window. When `saveWindowState` is `true`, this value will be ignored for subsequent
210
+ * launches in favor of the cached value.
211
+ *
212
+ * @property {number} [defaultWidth=800]
213
+ * The default width of the window. When `saveWindowState` is `true`, this value will be ignored for subsequent
214
+ * launches in favor of the cached value.
215
+ *
216
+ * @property {boolean} [includeInSnapshots=true] - _Updatable._
217
+ * When true, the window will be be included in snapshots returned by Platform.getSnapshot(). Turning this off may be desirable when dealing with
218
+ * inherently temporary windows whose state shouldn't be preserved, such as modals, menus, or popups.
219
+ *
220
+ * @property {boolean} [frame=true] - _Updatable._
221
+ * A flag to show the frame.
222
+ *
223
+ * @hidden-property {boolean} [hideOnClose=false] - A flag to allow a window to be hidden when the close button is clicked.
224
+ *
225
+ * @property {object[]} [hotkeys=[]] - _Updatable._
226
+ * Defines the list of hotkeys that will be emitted as a `hotkey` event on the window. For usage example see [example]{@tutorial hotkeys}.
227
+ * Within Platform, OpenFin also implements a set of pre-defined actions called
228
+ * [keyboard commands]{@link https://developers.openfin.co/docs/platform-api#section-5-3-using-keyboard-commands}
229
+ * that can be assigned to a specific hotkey in the platform manifest.
230
+ * @property {string} hotkeys.keys The key combination of the hotkey, i.e. "Ctrl+T"
231
+ * @property {boolean} [hotkeys.preventDefault=false] Whether or not to prevent default key handling before emitting the event
232
+ *
233
+ * @property {string} [icon] - _Updatable. Inheritable._
234
+ * A URL for the icon to be shown in the window title bar and the taskbar.
235
+ * _When omitted, inherits from the parent application._
236
+ * note: Window OS caches taskbar icons, therefore an icon change might only be visible after the cache is removed or the uuid is changed.
237
+ *
238
+ * @property {number} [maxHeight=-1] - _Updatable._
239
+ * The maximum height of a window. Will default to the OS defined value if set to -1.
240
+ *
241
+ * @property {boolean} [maximizable=true] - _Updatable._
242
+ * A flag that lets the window be maximized.
243
+ *
244
+ * @property {number} [maxWidth=-1] - _Updatable._
245
+ * The maximum width of a window. Will default to the OS defined value if set to -1.
246
+ *
247
+ * @property {number} [minHeight=0] - _Updatable._
248
+ * The minimum height of a window.
249
+ *
250
+ * @property {boolean} [minimizable=true] - _Updatable._
251
+ * A flag that lets the window be minimized.
252
+ *
253
+ * @property {number} [minWidth=0] - _Updatable._
254
+ * The minimum width of a window.
255
+ *
256
+ * @property {Identity} [modalParentIdentity]
257
+ * Parent identity of a modal window. It will create a modal child window when this option is set.
258
+ *
259
+ * @property {string} name
260
+ * The name of the window.
261
+ *
262
+ * @property {number} [opacity=1.0] - _Updatable._
263
+ * A flag that specifies how transparent the window will be.
264
+ * Changing opacity doesn't work on Windows 7 without Aero so setting this value will have no effect there.
265
+ * This value is clamped between `0.0` and `1.0`.
266
+ *
267
+ * @property {preloadScript[]} [preloadScripts] - _Inheritable_
268
+ * A list of scripts that are eval'ed before other scripts in the page. When omitted, _inherits_
269
+ * from the parent application.
270
+ *
271
+ * @property {string} [processAffinity]
272
+ * A string to attempt to group renderers together. Will only be used if pages are on the same origin.
273
+ *
274
+ * @property {boolean} [resizable=true] - _Updatable._
275
+ * A flag to allow the user to resize the window.
276
+ *
277
+ * @property {object} [resizeRegion] - _Updatable._
278
+ * Defines a region in pixels that will respond to user mouse interaction for resizing a frameless window.
279
+ * @property {number} [resizeRegion.bottomRightCorner=9]
280
+ * The size in pixels of an additional square resizable region located at the bottom right corner of a frameless window.
281
+ * @property {number} [resizeRegion.size=7]
282
+ * The size in pixels.
283
+ * @property {object} [resizeRegion.sides={top:true,right:true,bottom:true,left:true}]
284
+ * Sides that a window can be resized from.
285
+ *
286
+ * @property {boolean} [saveWindowState=true]
287
+ * A flag to cache the location of the window.
288
+ * ** note ** - This option is ignored in Platforms as it would cause inconsistent {@link Platform#applySnapshot applySnapshot} behavior.
289
+ *
290
+ * @property {boolean} [shadow=false]
291
+ * A flag to display a shadow on frameless windows.
292
+ * `shadow` and `cornerRounding` are mutually exclusive.
293
+ * On Windows 7, Aero theme is required.
294
+ *
295
+ * @property {boolean} [showBackgroundImages=false] - _Updatable._
296
+ * Platforms Only. If true, will show background images in the layout when the Views are hidden.
297
+ * This occurs when the window is resizing or a tab is being dragged within the layout.
298
+ *
299
+ * @property {boolean} [showTaskbarIcon=true] - _Updatable._ _Windows_.
300
+ * A flag to show the window's icon in the taskbar.
301
+ *
302
+ * @property {boolean} [smallWindow=false]
303
+ * A flag to specify a frameless window that can be be created and resized to less than 41x36 px (width x height).
304
+ * _Note: Caveats of small windows are no Aero Snap and drag to/from maximize._
305
+ * _Windows 10: Requires `maximizable` to be false. Resizing with the mouse is only possible down to 38x39 px._
306
+ *
307
+ * @property {string} [state="normal"]
308
+ * The visible state of the window on creation.
309
+ * One of:
310
+ * * `"maximized"`
311
+ * * `"minimized"`
312
+ * * `"normal"`
313
+ *
314
+ * @property {string} [taskbarIcon=string] - Deprecated - use `icon` instead._Windows_.
315
+ *
316
+ * @property {string} [taskbarIconGroup=<application uuid>] - _Windows_.
317
+ * Specify a taskbar group for the window.
318
+ * _If omitted, defaults to app's uuid (`fin.Application.getCurrentSync().identity.uuid`)._
319
+ *
320
+ * @property {string} [url="about:blank"]
321
+ * The URL of the window.
322
+ *
323
+ * @property {string} [uuid=<application uuid>]
324
+ * The `uuid` of the application, unique within the set of all `Application`s running in OpenFin Runtime.
325
+ * If omitted, defaults to the `uuid` of the application spawning the window.
326
+ * If given, must match the `uuid` of the application spawning the window.
327
+ * In other words, the application's `uuid` is the only acceptable value, but is the default, so there's
328
+ * really no need to provide it.
329
+ *
330
+ * @property {boolean} [waitForPageLoad=false]
331
+ * When set to `true`, the window will not appear until the `window` object's `load` event fires.
332
+ * When set to `false`, the window will appear immediately without waiting for content to be loaded.
333
+ */
334
+ /**
335
+ * @typedef {object} CapturePageOptions
336
+ * @property { Area } [area] The area of the window to be captured.
337
+ * @property { string } [format='png'] The format of the captured image. Can be 'png', 'jpg', or 'bmp'.
338
+ * @property { number } [quality=100] Number representing quality of JPEG image only. Between 0 - 100.
339
+ */
340
+ /**
341
+ * @typedef { object } Area
342
+ * @property { number } height Area's height
343
+ * @property { number } width Area's width
344
+ * @property { number } x X coordinate of area's starting point
345
+ * @property { number } y Y coordinate of area's starting point
346
+ */
347
+ /**
348
+ * @typedef {object} FindInPageOptions
349
+ * @property {boolean} [forward=true] Whether to search forward or backward.
350
+ * @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.
351
+ * @property {boolean} [matchCase=false] Whether search should be case-sensitive.
352
+ * @property {boolean} [wordStart=false] Whether to look only at the start of words.
353
+ * @property {boolean} [medialCapitalAsWordStart=false]
354
+ * 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>
355
+ * lowercase or non-letter. Accepts several other intra-word matches.
356
+ */
357
+ /**
358
+ * @typedef {object} Transition
359
+ * @property {Opacity} opacity - The Opacity transition
360
+ * @property {Position} position - The Position transition
361
+ * @property {Size} size - The Size transition
362
+ */
363
+ /**
364
+ * @typedef {object} TransitionOptions
365
+ * @property {boolean} interrupt - This option interrupts the current animation. When false it pushes
366
+ this animation onto the end of the animation queue.
367
+ * @property {boolean} relative - Treat 'opacity' as absolute or as a delta. Defaults to false.
368
+ */
369
+ /**
370
+ * @typedef {object} Size
371
+ * @property {number} duration - The total time in milliseconds this transition should take.
372
+ * @property {boolean} relative - Treat 'opacity' as absolute or as a delta. Defaults to false.
373
+ * @property {number} width - Optional if height is present. Defaults to the window's current width.
374
+ * @property {number} height - Optional if width is present. Defaults to the window's current height.
375
+ */
376
+ /**
377
+ * @typedef {object} Position
378
+ * @property {number} duration - The total time in milliseconds this transition should take.
379
+ * @property {boolean} relative - Treat 'opacity' as absolute or as a delta. Defaults to false.
380
+ * @property {number} left - Defaults to the window's current left position in virtual screen coordinates.
381
+ * @property {number} top - Defaults to the window's current top position in virtual screen coordinates.
382
+ */
383
+ /**
384
+ * @typedef {object} Opacity
385
+ * @property {number} duration - The total time in milliseconds this transition should take.
386
+ * @property {boolean} relative - Treat 'opacity' as absolute or as a delta. Defaults to false.
387
+ * @property {number} opacity - This value is clamped from 0.0 to 1.0.
388
+ */
389
+ /**
390
+ * Bounds is a interface that has the properties of height,
391
+ * width, left, top which are all numbers
392
+ * @typedef { object } Bounds
393
+ * @property { number } height Get the application height bound
394
+ * @property { number } width Get the application width bound
395
+ * @property { number } top Get the application top bound
396
+ * @property { number } left Get the application left bound
397
+ * @property { number } right Get the application right bound
398
+ * @property { number } bottom Get the application bottom bound
399
+ */
400
+ /**
401
+ * @classdesc A basic window that wraps a native HTML window. Provides more fine-grained
402
+ * control over the window state such as the ability to minimize, maximize, restore, etc.
403
+ * By default a window does not show upon instantiation; instead the window's show() method
404
+ * must be invoked manually. The new window appears in the same process as the parent window.
405
+ * It has the ability to listen for <a href="tutorial-Window.EventEmitter.html">window specific events</a>.
406
+ * @class
407
+ * @alias Window
408
+ * @hideconstructor
409
+ */
410
+ // The window.Window name is taken
411
+ class _Window extends main_1.WebContents {
412
+ constructor(wire, identity) {
413
+ super(wire, identity, 'window');
414
+ this.identity = identity;
415
+ }
416
+ /**
417
+ * Adds a listener to the end of the listeners array for the specified event.
418
+ * @param { string | symbol } eventType - The type of the event.
419
+ * @param { Function } listener - Called whenever an event of the specified type occurs.
420
+ * @param { SubOptions } [options] - Option to support event timestamps.
421
+ * @return {Promise.<this>}
422
+ * @function addListener
423
+ * @memberof Window
424
+ * @instance
425
+ * @tutorial Window.EventEmitter
426
+ */
427
+ /**
428
+ * Adds a listener to the end of the listeners array for the specified event.
429
+ * @param { string | symbol } eventType - The type of the event.
430
+ * @param { Function } listener - Called whenever an event of the specified type occurs.
431
+ * @param { SubOptions } [options] - Option to support event timestamps.
432
+ * @return {Promise.<this>}
433
+ * @function on
434
+ * @memberof Window
435
+ * @instance
436
+ * @tutorial Window.EventEmitter
437
+ */
438
+ /**
439
+ * 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.
440
+ * @param { string | symbol } eventType - The type of the event.
441
+ * @param { Function } listener - The callback function.
442
+ * @param { SubOptions } [options] - Option to support event timestamps.
443
+ * @return {Promise.<this>}
444
+ * @function once
445
+ * @memberof Window
446
+ * @instance
447
+ * @tutorial Window.EventEmitter
448
+ */
449
+ /**
450
+ * Adds a listener to the beginning of the listeners array for the specified event.
451
+ * @param { string | symbol } eventType - The type of the event.
452
+ * @param { Function } listener - The callback function.
453
+ * @param { SubOptions } [options] - Option to support event timestamps.
454
+ * @return {Promise.<this>}
455
+ * @function prependListener
456
+ * @memberof Window
457
+ * @instance
458
+ * @tutorial Window.EventEmitter
459
+ */
460
+ /**
461
+ * 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.
462
+ * The listener is added to the beginning of the listeners array.
463
+ * @param { string | symbol } eventType - The type of the event.
464
+ * @param { Function } listener - The callback function.
465
+ * @param { SubOptions } [options] - Option to support event timestamps.
466
+ * @return {Promise.<this>}
467
+ * @function prependOnceListener
468
+ * @memberof Window
469
+ * @instance
470
+ * @tutorial Window.EventEmitter
471
+ */
472
+ /**
473
+ * Remove a listener from the listener array for the specified event.
474
+ * Caution: Calling this method changes the array indices in the listener array behind the listener.
475
+ * @param { string | symbol } eventType - The type of the event.
476
+ * @param { Function } listener - The callback function.
477
+ * @param { SubOptions } [options] - Option to support event timestamps.
478
+ * @return {Promise.<this>}
479
+ * @function removeListener
480
+ * @memberof Window
481
+ * @instance
482
+ * @tutorial Window.EventEmitter
483
+ */
484
+ /**
485
+ * Removes all listeners, or those of the specified event.
486
+ * @param { string | symbol } [eventType] - The type of the event.
487
+ * @return {Promise.<this>}
488
+ * @function removeAllListeners
489
+ * @memberof Window
490
+ * @instance
491
+ * @tutorial Window.EventEmitter
492
+ */
493
+ /**
494
+ * Gets a base64 encoded image of the window or a part of it.
495
+ * @function capturePage
496
+ * @param { CapturePageOptions } [options] options for capturePage call.
497
+ * @return {Promise.<string>}
498
+ * @memberof Window
499
+ * @instance
500
+ * @tutorial Window.capturePage
501
+ */
502
+ /**
503
+ * Executes Javascript on the window, restricted to windows you own or windows owned by
504
+ * applications you have created.
505
+ * @param { string } code JavaScript code to be executed on the window.
506
+ * @function executeJavaScript
507
+ * @memberOf Window
508
+ * @instance
509
+ * @return {Promise.<void>}
510
+ * @tutorial Window.executeJavaScript
511
+ */
512
+ /**
513
+ * Gives focus to the window.
514
+ * @return {Promise.<void>}
515
+ * @function focus
516
+ * @emits focused
517
+ * @memberOf Window
518
+ * @instance
519
+ * @tutorial Window.focus
520
+ */
521
+ /**
522
+ * Returns the zoom level of the window.
523
+ * @function getZoomLevel
524
+ * @memberOf Window
525
+ * @instance
526
+ * @return {Promise.<number>}
527
+ * @tutorial Window.getZoomLevel
528
+ */
529
+ /**
530
+ * Sets the zoom level of the window.
531
+ * @param { number } level The zoom level
532
+ * @function setZoomLevel
533
+ * @memberOf Window
534
+ * @instance
535
+ * @return {Promise.<void>}
536
+ * @tutorial Window.setZoomLevel
537
+ */
538
+ /**
539
+ * Find and highlight text on a page.
540
+ * @param { string } searchTerm Term to find in page
541
+ * @param { FindInPageOptions } options Search options
542
+ * @function findInPage
543
+ * @memberOf Window
544
+ * @instance
545
+ * @return {Promise.<number>}
546
+ * @tutorial Window.findInPage
547
+ */
548
+ /**
549
+ * Stops any findInPage call with the provided action.
550
+ * @param {string} action
551
+ * Action to execute when stopping a find in page:<br>
552
+ * "clearSelection" - Clear the selection.<br>
553
+ * "keepSelection" - Translate the selection into a normal selection.<br>
554
+ * "activateSelection" - Focus and click the selection node.<br>
555
+ * @function stopFindInPage
556
+ * @memberOf Window
557
+ * @instance
558
+ * @return {Promise.<void>}
559
+ * @tutorial Window.stopFindInPage
560
+ */
561
+ /**
562
+ * Navigates the window to a specified URL. The url must contain the protocol prefix such as http:// or https://.
563
+ * @param {string} url - The URL to navigate the window to.
564
+ * @function navigate
565
+ * @memberOf Window
566
+ * @instance
567
+ * @return {Promise.<void>}
568
+ * @tutorial Window.navigate
569
+ */
570
+ /**
571
+ * Navigates the window back one page.
572
+ * @function navigateBack
573
+ * @memberOf Window
574
+ * @instance
575
+ * @return {Promise.<void>}
576
+ * @tutorial Window.navigateBack
577
+ */
578
+ /**
579
+ * Navigates the window forward one page.
580
+ * @function navigateForward
581
+ * @memberOf Window
582
+ * @instance
583
+ * @return {Promise.<void>}
584
+ * @tutorial Window.navigateForward
585
+ */
586
+ /**
587
+ * Stops any current navigation the window is performing.
588
+ * @function stopNavigation
589
+ * @memberOf Window
590
+ * @instance
591
+ * @return {Promise.<void>}
592
+ * @tutorial Window.stopNavigation
593
+ */
594
+ /**
595
+ * Reloads the window current page
596
+ * @function reload
597
+ * @memberOf Window
598
+ * @instance
599
+ * @return {Promise.<void>}
600
+ * @tutorial Window.reload
601
+ */
602
+ /**
603
+ * Prints the window's web page
604
+ * @param { PrintOptions } [options] Printer Options
605
+ * @function print
606
+ * @memberOf Window
607
+ * @instance
608
+ * @return {Promise.<void>}
609
+ * @tutorial Window.print
610
+ */
611
+ /**
612
+ * Returns an array with all system printers
613
+ * @function getPrinters
614
+ * @memberOf Window
615
+ * @instance
616
+ * @return { Promise.Array.<PrinterInfo> }
617
+ * @tutorial Window.getPrinters
618
+ */
619
+ /**
620
+ * Retrieves the process information associated with a window.
621
+ * @function getProcessInfo
622
+ * @memberOf Window
623
+ * @instance
624
+ * @return {Promise.<EntityProcessDetails>}
625
+ * @tutorial Window.getProcessInfo
626
+ */
627
+ /**
628
+ * Retrieves information on all Shared Workers.
629
+ * @function getSharedWorkers
630
+ * @memberOf Window
631
+ * @instance
632
+ * @return {Promise.Array.<SharedWorkerInfo>}
633
+ * @tutorial Window.getSharedWorkers
634
+ */
635
+ /**
636
+ * Opens the developer tools for the shared worker context.
637
+ * @function inspectSharedWorker
638
+ * @memberOf Window
639
+ * @instance
640
+ * @return {Promise.<void>}
641
+ * @tutorial Window.inspectSharedWorker
642
+ */
643
+ /**
644
+ * Inspects the shared worker based on its ID.
645
+ * @param { string } workerId - The id of the shared worker.
646
+ * @function inspectSharedWorkerById
647
+ * @memberOf Window
648
+ * @instance
649
+ * @return {Promise.<void>}
650
+ * @tutorial Window.inspectSharedWorkerById
651
+ */
652
+ /**
653
+ * Opens the developer tools for the service worker context.
654
+ * @function inspectServiceWorker
655
+ * @memberOf Window
656
+ * @instance
657
+ * @return {Promise.<void>}
658
+ * @tutorial Window.inspectServiceWorker
659
+ */
660
+ // create a new window
661
+ createWindow(options) {
662
+ this.wire.sendAction('window-create-window', this.identity).catch((e) => {
663
+ // we do not want to expose this error, just continue if this analytics-only call fails
664
+ });
665
+ return new Promise((resolve, reject) => {
666
+ const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
667
+ // need to call pageResponse, otherwise when a child window is created, page is not loaded
668
+ const pageResponse = new Promise((resolve) => {
669
+ this.on(CONSTRUCTOR_CB_TOPIC, function fireConstructor(response) {
670
+ let cbPayload;
671
+ const { success } = response;
672
+ const responseData = response.data;
673
+ const { message } = responseData;
674
+ if (success) {
675
+ cbPayload = {
676
+ httpResponseCode: responseData.httpResponseCode,
677
+ apiInjected: responseData.apiInjected
678
+ };
679
+ }
680
+ else {
681
+ cbPayload = {
682
+ message: responseData.message,
683
+ networkErrorCode: responseData.networkErrorCode,
684
+ stack: responseData.stack
685
+ };
686
+ }
687
+ this.removeListener(CONSTRUCTOR_CB_TOPIC, fireConstructor);
688
+ resolve({
689
+ message,
690
+ cbPayload,
691
+ success
692
+ });
693
+ });
694
+ });
695
+ // set defaults:
696
+ if (options.waitForPageLoad === undefined) {
697
+ options.waitForPageLoad = false;
698
+ }
699
+ if (options.autoShow === undefined) {
700
+ options.autoShow = true;
701
+ }
702
+ const windowCreation = this.wire.environment.createChildContent({ entityType: 'window', options });
703
+ Promise.all([pageResponse, windowCreation])
704
+ .then((resolvedArr) => {
705
+ const pageResolve = resolvedArr[0];
706
+ if (pageResolve.success) {
707
+ resolve(this);
708
+ }
709
+ else {
710
+ reject(pageResolve);
711
+ }
712
+ try {
713
+ // this is to enforce a 5.0 contract that the child's main function
714
+ // will not fire before the parent's success callback on creation.
715
+ // if the child window is not accessible (CORS) this contract does
716
+ // not hold.
717
+ const webWindow = this.getWebWindow();
718
+ webWindow.fin.__internal_.openerSuccessCBCalled();
719
+ }
720
+ catch (e) {
721
+ // common for main windows, we do not want to expose this error. here just to have a debug target.
722
+ // console.error(e);
723
+ }
724
+ })
725
+ .catch(reject);
726
+ });
727
+ }
728
+ /**
729
+ * Retrieves an array of frame info objects representing the main frame and any
730
+ * iframes that are currently on the page.
731
+ * @return {Promise.<Array<FrameInfo>>}
732
+ * @tutorial Window.getAllFrames
733
+ */
734
+ getAllFrames() {
735
+ return this.wire.sendAction('get-all-frames', this.identity).then(({ payload }) => payload.data);
736
+ }
737
+ /**
738
+ * Gets the current bounds (top, bottom, right, left, width, height) of the window.
739
+ * @return {Promise.<Bounds>}
740
+ * @tutorial Window.getBounds
741
+ */
742
+ getBounds() {
743
+ return this.wire
744
+ .sendAction('get-window-bounds', this.identity)
745
+ .then(({ payload }) => payload.data);
746
+ }
747
+ /**
748
+ * Centers the window on its current screen.
749
+ * @return {Promise.<void>}
750
+ * @tutorial Window.center
751
+ */
752
+ center() {
753
+ return this.wire.sendAction('center-window', this.identity).then(() => undefined);
754
+ }
755
+ /**
756
+ * Removes focus from the window.
757
+ * @return {Promise.<void>}
758
+ * @tutorial Window.blur
759
+ */
760
+ blur() {
761
+ return this.wire.sendAction('blur-window', this.identity).then(() => undefined);
762
+ }
763
+ /**
764
+ * Brings the window to the front of the window stack.
765
+ * @return {Promise.<void>}
766
+ * @tutorial Window.bringToFront
767
+ */
768
+ bringToFront() {
769
+ return this.wire.sendAction('bring-window-to-front', this.identity).then(() => undefined);
770
+ }
771
+ /**
772
+ * Performs the specified window transitions.
773
+ * @param {Transition} transitions - Describes the animations to perform. See the tutorial.
774
+ * @param {TransitionOptions} options - Options for the animation. See the tutorial.
775
+ * @return {Promise.<void>}
776
+ * @tutorial Window.animate
777
+ */
778
+ animate(transitions, options) {
779
+ return this.wire
780
+ .sendAction('animate-window', {
781
+ transitions,
782
+ options,
783
+ ...this.identity
784
+ })
785
+ .then(() => undefined);
786
+ }
787
+ /**
788
+ * Hides the window.
789
+ * @return {Promise.<void>}
790
+ * @tutorial Window.hide
791
+ */
792
+ hide() {
793
+ return this.wire.sendAction('hide-window', this.identity).then(() => undefined);
794
+ }
795
+ /**
796
+ * closes the window application
797
+ * @param { boolean } [force = false] Close will be prevented from closing when force is false and
798
+ * ‘close-requested’ has been subscribed to for application’s main window.
799
+ * @return {Promise.<void>}
800
+ * @tutorial Window.close
801
+ */
802
+ close(force = false) {
803
+ return this.wire.sendAction('close-window', { force, ...this.identity }).then(() => {
804
+ Object.setPrototypeOf(this, null);
805
+ return undefined;
806
+ });
807
+ }
808
+ focusedWebViewWasChanged() {
809
+ return this.wire.sendAction('focused-webview-changed', this.identity).then(() => undefined);
810
+ }
811
+ /**
812
+ * Returns the native OS level Id.
813
+ * In Windows, it will return the Windows [handle](https://docs.microsoft.com/en-us/windows/desktop/WinProg/windows-data-types#HWND).
814
+ * @return {Promise.<string>}
815
+ * @tutorial Window.getNativeId
816
+ */
817
+ getNativeId() {
818
+ return this.wire.sendAction('get-window-native-id', this.identity).then(({ payload }) => payload.data);
819
+ }
820
+ /**
821
+ * Retrieves window's attached views.
822
+ * @experimental
823
+ * @return {Promise.Array.<View>}
824
+ * @tutorial Window.getCurrentViews
825
+ */
826
+ async getCurrentViews() {
827
+ const { payload } = await this.wire.sendAction('window-get-views', this.identity);
828
+ return payload.data.map((id) => new view_1.View(this.wire, id));
829
+ }
830
+ /*
831
+ * @deprecated Use {@link Window.disableUserMovement} instead.
832
+ */
833
+ disableFrame() {
834
+ console.warn('Function is deprecated; use disableUserMovement instead.');
835
+ return this.wire.sendAction('disable-window-frame', this.identity).then(() => undefined);
836
+ }
837
+ /**
838
+ * Prevents a user from changing a window's size/position when using the window's frame.
839
+ * @return {Promise.<void>}
840
+ * @tutorial Window.disableUserMovement
841
+ */
842
+ disableUserMovement() {
843
+ return this.wire.sendAction('disable-window-frame', this.identity).then(() => undefined);
844
+ }
845
+ /*
846
+ * @deprecated Use {@link Window.enableUserMovement} instead.
847
+ */
848
+ enableFrame() {
849
+ console.warn('Function is deprecated; use enableUserMovement instead.');
850
+ return this.wire.sendAction('enable-window-frame', this.identity).then(() => undefined);
851
+ }
852
+ /**
853
+ * Re-enables user changes to a window's size/position when using the window's frame.
854
+ * @return {Promise.<void>}
855
+ * @tutorial Window.enableUserMovement
856
+ */
857
+ enableUserMovement() {
858
+ return this.wire.sendAction('enable-window-frame', this.identity).then(() => undefined);
859
+ }
860
+ /**
861
+ * Flashes the window’s frame and taskbar icon until stopFlashing is called or until a focus event is fired.
862
+ * @return {Promise.<void>}
863
+ * @tutorial Window.flash
864
+ */
865
+ flash() {
866
+ return this.wire.sendAction('flash-window', this.identity).then(() => undefined);
867
+ }
868
+ /**
869
+ * Stops the taskbar icon from flashing.
870
+ * @return {Promise.<void>}
871
+ * @tutorial Window.stopFlashing
872
+ */
873
+ stopFlashing() {
874
+ return this.wire.sendAction('stop-flash-window', this.identity).then(() => undefined);
875
+ }
876
+ /**
877
+ * Gets an information object for the window.
878
+ * @return {Promise.<WindowInfo>}
879
+ * @tutorial Window.getInfo
880
+ */
881
+ getInfo() {
882
+ return this.wire.sendAction('get-window-info', this.identity).then(({ payload }) => payload.data);
883
+ }
884
+ /**
885
+ * Retrieves the window's Layout
886
+ * @return {Promise.<Layout>}
887
+ * @tutorial Window.getLayout
888
+ * @experimental
889
+ */
890
+ async getLayout() {
891
+ this.wire.sendAction('window-get-layout', this.identity).catch((e) => {
892
+ // don't expose
893
+ });
894
+ const opts = await this.getOptions();
895
+ if (!opts.layout) {
896
+ throw new Error('Window does not have a Layout');
897
+ }
898
+ return this.fin.Platform.Layout.wrap(this.identity);
899
+ }
900
+ /**
901
+ * Gets the current settings of the window.
902
+ * @return {Promise.<any>}
903
+ * @tutorial Window.getOptions
904
+ */
905
+ getOptions() {
906
+ return this.wire.sendAction('get-window-options', this.identity).then(({ payload }) => payload.data);
907
+ }
908
+ /**
909
+ * Gets the parent application.
910
+ * @return {Promise.<Application>}
911
+ * @tutorial Window.getParentApplication
912
+ */
913
+ getParentApplication() {
914
+ this.wire.sendAction('window-get-parent-application', this.identity).catch((e) => {
915
+ // we do not want to expose this error, just continue if this analytics-only call fails
916
+ });
917
+ return Promise.resolve(new application_1.Application(this.wire, this.identity));
918
+ }
919
+ /**
920
+ * Gets the parent window.
921
+ * @return {Promise.<_Window>}
922
+ * @tutorial Window.getParentWindow
923
+ */
924
+ getParentWindow() {
925
+ this.wire.sendAction('window-get-parent-window', this.identity).catch((e) => {
926
+ // we do not want to expose this error, just continue if this analytics-only call fails
927
+ });
928
+ return Promise.resolve(new application_1.Application(this.wire, this.identity)).then((app) => app.getWindow());
929
+ }
930
+ /**
931
+ * ***DEPRECATED - please use Window.capturePage.***
932
+ * Gets a base64 encoded PNG image of the window or just part a of it.
933
+ * @param { Area } [area] The area of the window to be captured.
934
+ * Omitting it will capture the whole visible window.
935
+ * @return {Promise.<string>}
936
+ * @tutorial Window.capturePage
937
+ */
938
+ async getSnapshot(area) {
939
+ const req = { area, ...this.identity };
940
+ console.warn('Window.getSnapshot has been deprecated, please use Window.capturePage');
941
+ const res = await this.wire.sendAction('get-window-snapshot', req);
942
+ return res.payload.data;
943
+ }
944
+ /**
945
+ * Gets the current state ("minimized", "maximized", or "restored") of the window.
946
+ * @return {Promise.<string>}
947
+ * @tutorial Window.getState
948
+ */
949
+ getState() {
950
+ return this.wire.sendAction('get-window-state', this.identity).then(({ payload }) => payload.data);
951
+ }
952
+ /**
953
+ * Previously called getNativeWindow.
954
+ * Returns the [Window Object](https://developer.mozilla.org/en-US/docs/Web/API/Window)
955
+ * that represents the web context of the target window. This is the same object that
956
+ * you would get from calling [window.open()](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) in a standard web context.
957
+ * The target window needs to be in the same application as the requesting window
958
+ * as well as comply with [same-origin](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) policy requirements.
959
+ * @return {object}
960
+ * @tutorial Window.getWebWindow
961
+ */
962
+ getWebWindow() {
963
+ this.wire.sendAction('window-get-web-window', this.identity).catch((e) => {
964
+ // we do not want to expose this error, just continue if this analytics-only call fails
965
+ });
966
+ return this.wire.environment.getWebWindow(this.identity);
967
+ }
968
+ /**
969
+ * Determines if the window is a main window.
970
+ * @return {boolean}
971
+ * @tutorial Window.isMainWindow
972
+ */
973
+ isMainWindow() {
974
+ this.wire.sendAction('window-is-main-window', this.identity).catch((e) => {
975
+ // we do not want to expose this error, just continue if this analytics-only call fails
976
+ });
977
+ return this.me.uuid === this.me.name;
978
+ }
979
+ /**
980
+ * Determines if the window is currently showing.
981
+ * @return {Promise.<boolean>}
982
+ * @tutorial Window.isShowing
983
+ */
984
+ isShowing() {
985
+ return this.wire.sendAction('is-window-showing', this.identity).then(({ payload }) => payload.data);
986
+ }
987
+ /**
988
+ * Maximizes the window
989
+ * @return {Promise.<void>}
990
+ * @tutorial Window.maximize
991
+ */
992
+ maximize() {
993
+ return this.wire.sendAction('maximize-window', this.identity).then(() => undefined);
994
+ }
995
+ /**
996
+ * Minimizes the window.
997
+ * @return {Promise.<void>}
998
+ * @tutorial Window.minimize
999
+ */
1000
+ minimize() {
1001
+ return this.wire.sendAction('minimize-window', this.identity).then(() => undefined);
1002
+ }
1003
+ /**
1004
+ * Moves the window by a specified amount.
1005
+ * @param { number } deltaLeft The change in the left position of the window
1006
+ * @param { number } deltaTop The change in the top position of the window
1007
+ * @return {Promise.<void>}
1008
+ * @tutorial Window.moveBy
1009
+ */
1010
+ moveBy(deltaLeft, deltaTop) {
1011
+ return this.wire
1012
+ .sendAction('move-window-by', {
1013
+ deltaLeft,
1014
+ deltaTop,
1015
+ ...this.identity
1016
+ })
1017
+ .then(() => undefined);
1018
+ }
1019
+ /**
1020
+ * Moves the window to a specified location.
1021
+ * @param { number } left The left position of the window
1022
+ * @param { number } top The top position of the window
1023
+ * @return {Promise.<void>}
1024
+ * @tutorial Window.moveTo
1025
+ */
1026
+ moveTo(left, top) {
1027
+ return this.wire
1028
+ .sendAction('move-window', {
1029
+ left,
1030
+ top,
1031
+ ...this.identity
1032
+ })
1033
+ .then(() => undefined);
1034
+ }
1035
+ /**
1036
+ * Resizes the window by a specified amount.
1037
+ * @param { number } deltaWidth The change in the width of the window
1038
+ * @param { number } deltaHeight The change in the height of the window
1039
+ * @param { AnchorType } anchor Specifies a corner to remain fixed during the resize.
1040
+ * Can take the values: "top-left", "top-right", "bottom-left", or "bottom-right".
1041
+ * If undefined, the default is "top-left"
1042
+ * @return {Promise.<void>}
1043
+ * @tutorial Window.resizeBy
1044
+ */
1045
+ resizeBy(deltaWidth, deltaHeight, anchor) {
1046
+ return this.wire
1047
+ .sendAction('resize-window-by', {
1048
+ deltaWidth: Math.floor(deltaWidth),
1049
+ deltaHeight: Math.floor(deltaHeight),
1050
+ anchor,
1051
+ ...this.identity
1052
+ })
1053
+ .then(() => undefined);
1054
+ }
1055
+ /**
1056
+ * Resizes the window to the specified dimensions.
1057
+ * @param { number } width The change in the width of the window
1058
+ * @param { number } height The change in the height of the window
1059
+ * @param { AnchorType } anchor Specifies a corner to remain fixed during the resize.
1060
+ * Can take the values: "top-left", "top-right", "bottom-left", or "bottom-right".
1061
+ * If undefined, the default is "top-left"
1062
+ * @return {Promise.<void>}
1063
+ * @tutorial Window.resizeTo
1064
+ */
1065
+ resizeTo(width, height, anchor) {
1066
+ return this.wire
1067
+ .sendAction('resize-window', {
1068
+ width: Math.floor(width),
1069
+ height: Math.floor(height),
1070
+ anchor,
1071
+ ...this.identity
1072
+ })
1073
+ .then(() => undefined);
1074
+ }
1075
+ /**
1076
+ * Restores the window to its normal state (i.e., unminimized, unmaximized).
1077
+ * @return {Promise.<void>}
1078
+ * @tutorial Window.restore
1079
+ */
1080
+ restore() {
1081
+ return this.wire.sendAction('restore-window', this.identity).then(() => undefined);
1082
+ }
1083
+ /**
1084
+ * Will bring the window to the front of the entire stack and give it focus.
1085
+ * @return {Promise.<void>}
1086
+ * @tutorial Window.setAsForeground
1087
+ */
1088
+ setAsForeground() {
1089
+ return this.wire.sendAction('set-foreground-window', this.identity).then(() => undefined);
1090
+ }
1091
+ /**
1092
+ * Sets the window's size and position.
1093
+ * @property { Bounds } bounds This is a * @type {string} name - name of the window.object that holds the propertys of
1094
+ * @return {Promise.<void>}
1095
+ * @tutorial Window.setBounds
1096
+ */
1097
+ setBounds(bounds) {
1098
+ return this.wire.sendAction('set-window-bounds', { ...bounds, ...this.identity }).then(() => undefined);
1099
+ }
1100
+ /**
1101
+ * Shows the window if it is hidden.
1102
+ * @param { boolean } [force = false] Show will be prevented from showing when force is false and
1103
+ * ‘show-requested’ has been subscribed to for application’s main window.
1104
+ * @return {Promise.<void>}
1105
+ * @tutorial Window.show
1106
+ */
1107
+ show(force = false) {
1108
+ return this.wire.sendAction('show-window', { force, ...this.identity }).then(() => undefined);
1109
+ }
1110
+ /**
1111
+ * Shows the window if it is hidden at the specified location.
1112
+ * If the toggle parameter is set to true, the window will
1113
+ * alternate between showing and hiding.
1114
+ * @param { number } left The left position of the window
1115
+ * @param { number } top The right position of the window
1116
+ * @param { boolean } force Show will be prevented from closing when force is false and
1117
+ * ‘show-requested’ has been subscribed to for application’s main window
1118
+ * @return {Promise.<void>}
1119
+ * @tutorial Window.showAt
1120
+ */
1121
+ showAt(left, top, force = false) {
1122
+ return this.wire
1123
+ .sendAction('show-at-window', {
1124
+ force,
1125
+ left: Math.floor(left),
1126
+ top: Math.floor(top),
1127
+ ...this.identity
1128
+ })
1129
+ .then(() => undefined);
1130
+ }
1131
+ /**
1132
+ * Shows the Chromium Developer Tools
1133
+ * @return {Promise.<void>}
1134
+ * @tutorial Window.showDeveloperTools
1135
+ */
1136
+ /**
1137
+ * Updates the window using the passed options.
1138
+ * Values that are objects are deep-merged, overwriting only the values that are provided.
1139
+ * @param {*} options Changes a window's options that were defined upon creation. See tutorial
1140
+ * @return {Promise.<void>}
1141
+ * @tutorial Window.updateOptions
1142
+ */
1143
+ updateOptions(options) {
1144
+ return this.wire.sendAction('update-window-options', { options, ...this.identity }).then(() => undefined);
1145
+ }
1146
+ /**
1147
+ * Provides credentials to authentication requests
1148
+ * @param { string } userName userName to provide to the authentication challenge
1149
+ * @param { string } password password to provide to the authentication challenge
1150
+ * @return {Promise.<void>}
1151
+ * @tutorial Window.authenticate
1152
+ */
1153
+ authenticate(userName, password) {
1154
+ return this.wire
1155
+ .sendAction('window-authenticate', { userName, password, ...this.identity })
1156
+ .then(() => undefined);
1157
+ }
1158
+ /**
1159
+ * @typedef {object} ShowPopupMenuOptions
1160
+ * @property {Array<MenuItemTemplate>} template - An array describing the menu to show.
1161
+ * @property {number} [x] - The window x coordinate where to show the menu. Defaults to mouse position. If using must also use `y`.
1162
+ * @property {number} [y] - The window y coordinate where to show the menu. Defaults to mouse position. If using must also use `x`
1163
+ */
1164
+ /**
1165
+ * @typedef {object} MenuItemTemplate
1166
+ * @property {*} data Data to be returned if the user selects the element. Must be serializable. Large objects can have a performance impact.
1167
+ * @property {'normal' | 'separator' | 'submenu' | 'checkbox'} [type] - Defaults to 'normal' unless a 'submenu' key exists
1168
+ * @property {string} [label] - The text to show on the menu item. Should be left undefined for `type: 'separator'`
1169
+ * @property {boolean} [enabled] - If false, the menu item will be greyed out and unclickable.
1170
+ * @property {boolean} [visible] - If false, the menu item will be entirely hidden.
1171
+ * @property {boolean} [checked] - Should only be specified for `checkbox` type menu items.
1172
+ * @property {Array<MenuItemTemplate>} [submenu] Should be specified for `submenu` type menu items. If `submenu` is specified, the `type: 'submenu'` can be omitted.
1173
+ */
1174
+ /**
1175
+ * @typedef {object} MenuResult
1176
+ * @property {'clicked' | 'closed'} result - Whether the user clicked on a menu item or the menu was closed (user clicked elsewhere).
1177
+ * @property {* | undefined} [data] - The data property of the menu item clicked by the user. Only defined if result was `clicked`.
1178
+ */
1179
+ /**
1180
+ * Shows a menu on the window. Returns a promise that resolves when the user has either selected an item or closed the menu. (This may take longer than other apis).
1181
+ * 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.
1182
+ * Calling this method will close previously opened menus.
1183
+ * @experimental
1184
+ * @param {ShowPopupMenuOptions} options
1185
+ * @return {Promise<MenuResult>}
1186
+ * @tutorial Window.showPopupMenu
1187
+ */
1188
+ async showPopupMenu(options) {
1189
+ const { payload } = await this.wire.sendAction('show-popup-menu', { options, ...this.identity });
1190
+ return payload.data;
1191
+ }
1192
+ /**
1193
+ * Closes the window's popup menu, if one exists.
1194
+ * @experimental
1195
+ * @return {Promise<void>}
1196
+ * @tutorial Window.closePopupMenu
1197
+ */
1198
+ async closePopupMenu() {
1199
+ return this.wire.sendAction('close-popup-menu', { ...this.identity }).then(() => undefined);
1200
+ }
1201
+ }
1202
+ exports._Window = _Window;