@openfin/core 33.76.36 → 33.77.1

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