@openfin/core 25.68.30 → 26.69.32

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