@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,1851 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const base_1 = require("../base");
4
- const transport_errors_1 = require("../../transport/transport-errors");
5
- const window_1 = require("../window");
6
- const events_1 = require("events");
7
- /**
8
- * An object representing the core of OpenFin Runtime. Allows the developer
9
- * to perform system-level actions, such as accessing logs, viewing processes,
10
- * clearing the cache and exiting the runtime as well as listen to {@link OpenFin.SystemEvents system events}.
11
- *
12
- */
13
- class System extends base_1.EmitterBase {
14
- /**
15
- * @internal
16
- */
17
- constructor(wire) {
18
- super(wire, 'system');
19
- }
20
- sendExternalProcessRequest(action, options) {
21
- return new Promise((resolve, reject) => {
22
- const exitEventKey = 'external-process-exited';
23
- let processUuid;
24
- let exitPayload;
25
- let externalProcessExitHandler;
26
- let ofWindow;
27
- if (typeof options.listener === 'function') {
28
- externalProcessExitHandler = (payload) => {
29
- const data = payload || {};
30
- exitPayload = {
31
- topic: 'exited',
32
- uuid: data.processUuid || '',
33
- exitCode: data.exitCode || 0
34
- };
35
- if (processUuid === payload.processUuid) {
36
- options.listener(exitPayload);
37
- ofWindow.removeListener(exitEventKey, externalProcessExitHandler);
38
- }
39
- };
40
- // window constructor expects the name is not undefined
41
- if (!this.wire.me.name) {
42
- this.wire.me.name = this.wire.me.uuid;
43
- }
44
- ofWindow = new window_1._Window(this.wire, this.wire.me);
45
- ofWindow.on(exitEventKey, externalProcessExitHandler);
46
- }
47
- this.wire
48
- .sendAction(action, options)
49
- .then(({ payload }) => {
50
- processUuid = payload.data.uuid;
51
- resolve(payload.data);
52
- if (exitPayload && processUuid === exitPayload.uuid) {
53
- options.listener(exitPayload);
54
- ofWindow.removeListener(exitEventKey, externalProcessExitHandler);
55
- }
56
- })
57
- .catch((err) => {
58
- if (ofWindow) {
59
- ofWindow.removeListener(exitEventKey, externalProcessExitHandler);
60
- }
61
- reject(err);
62
- });
63
- });
64
- }
65
- /**
66
- * Adds a listener to the end of the listeners array for the specified event.
67
- * @param eventType - The type of the event.
68
- * @param listener - Called whenever an event of the specified type occurs.
69
- * @param options - Option to support event timestamps.
70
- *
71
- * @function addListener
72
- * @memberof System
73
- * @instance
74
- * @tutorial System.EventEmitter
75
- */
76
- /**
77
- * Adds a listener to the end of the listeners array for the specified event.
78
- * @param eventType - The type of the event.
79
- * @param listener - Called whenever an event of the specified type occurs.
80
- * @param options - Option to support event timestamps.
81
- *
82
- * @function on
83
- * @memberof System
84
- * @instance
85
- * @tutorial System.EventEmitter
86
- */
87
- /**
88
- * 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.
89
- * @param eventType - The type of the event.
90
- * @param listener - The callback function.
91
- * @param options - Option to support event timestamps.
92
- *
93
- * @function once
94
- * @memberof System
95
- * @instance
96
- * @tutorial System.EventEmitter
97
- */
98
- /**
99
- * Adds a listener to the beginning of the listeners array for the specified event.
100
- * @param eventType - The type of the event.
101
- * @param listener - The callback function.
102
- * @param options - Option to support event timestamps.
103
- *
104
- * @function prependListener
105
- * @memberof System
106
- * @instance
107
- * @tutorial System.EventEmitter
108
- */
109
- /**
110
- * 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.
111
- * The listener is added to the beginning of the listeners array.
112
- * @param eventType - The type of the event.
113
- * @param listener - The callback function.
114
- * @param options - Option to support event timestamps.
115
- *
116
- * @function prependOnceListener
117
- * @memberof System
118
- * @instance
119
- * @tutorial System.EventEmitter
120
- */
121
- /**
122
- * Remove a listener from the listener array for the specified event.
123
- * Caution: Calling this method changes the array indices in the listener array behind the listener.
124
- * @param eventType - The type of the event.
125
- * @param listener - The callback function.
126
- * @param options - Option to support event timestamps.
127
- *
128
- * @function removeListener
129
- * @memberof System
130
- * @instance
131
- * @tutorial System.EventEmitter
132
- */
133
- /**
134
- * Removes all listeners, or those of the specified event.
135
- * @param eventType - The type of the event.
136
- *
137
- * @function removeAllListeners
138
- * @memberof System
139
- * @instance
140
- * @tutorial System.EventEmitter
141
- */
142
- /**
143
- * Returns the version of the runtime. The version contains the major, minor,
144
- * build and revision numbers.
145
- *
146
- * @example
147
- * ```js
148
- * fin.System.getVersion().then(v => console.log(v)).catch(err => console.log(err));
149
- * ```
150
- */
151
- getVersion() {
152
- return this.wire.sendAction('get-version').then(({ payload }) => payload.data);
153
- }
154
- /**
155
- * Clears cached data containing application resource
156
- * files (images, HTML, JavaScript files), cookies, and items stored in the
157
- * Local Storage.
158
- * @param options - See below for details.
159
- *
160
- * @remarks For more information on the accepted options, see the following pages:
161
- * * cache: browsing data cache for html files and images ([caching](https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching))
162
- * * cookies: browser [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies)
163
- * * localStorage: browser data that can be used across sessions ([local storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage))
164
- * * appcache: html5 [application cache](https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache)
165
- * @example
166
- * ```js
167
- * const clearCacheOptions = {
168
- * appcache: true,
169
- * cache: true,
170
- * cookies: true,
171
- * localStorage: true
172
- * };
173
- * fin.System.clearCache(clearCacheOptions).then(() => console.log('Cache cleared')).catch(err => console.log(err));
174
- * ```
175
- *
176
- */
177
- clearCache(options) {
178
- return this.wire.sendAction('clear-cache', options).then(() => undefined);
179
- }
180
- /**
181
- * Clears all cached data when OpenFin Runtime exits.
182
- *
183
- * @example
184
- * ```js
185
- * fin.System.deleteCacheOnExit().then(() => console.log('Deleted Cache')).catch(err => console.log(err));
186
- * ```
187
- */
188
- deleteCacheOnExit() {
189
- return this.wire.sendAction('delete-cache-request').then(() => undefined);
190
- }
191
- /**
192
- * Exits the Runtime.
193
- *
194
- * @example
195
- * ```js
196
- * fin.System.exit().then(() => console.log('exit')).catch(err => console.log(err));
197
- * ```
198
- */
199
- exit() {
200
- return this.wire.sendAction('exit-desktop').then(() => undefined);
201
- }
202
- /**
203
- * Fetches a JSON manifest using the browser process and returns a Javascript object.
204
- * @param manifestUrl The URL of the manifest to fetch.
205
- *
206
- * @example
207
- * ```js
208
- * const manifest = await fin.System.fetchManifest('https://www.path-to-manifest.com');
209
- * console.log(manifest);
210
- * ```
211
- */
212
- async fetchManifest(manifestUrl) {
213
- const { payload: { data } } = await this.wire.sendAction('fetch-manifest', { manifestUrl });
214
- return data;
215
- }
216
- /**
217
- * Writes any unwritten cookies data to disk.
218
- *
219
- * @example
220
- * ```js
221
- * fin.System.flushCookieStore()
222
- * .then(() => console.log('success'))
223
- * .catch(err => console.error(err));
224
- * ```
225
- */
226
- flushCookieStore() {
227
- return this.wire.sendAction('flush-cookie-store').then(() => undefined);
228
- }
229
- /**
230
- * Retrieves an array of data (name, ids, bounds) for all application windows.
231
- *
232
- * @example
233
- * ```js
234
- * fin.System.getAllWindows().then(wins => console.log(wins)).catch(err => console.log(err));
235
- * ```
236
- */
237
- getAllWindows() {
238
- return this.wire.sendAction('get-all-windows').then(({ payload }) => payload.data);
239
- }
240
- /**
241
- * Retrieves an array of data for all applications.
242
- *
243
- * @example
244
- * ```js
245
- * fin.System.getAllApplications().then(apps => console.log(apps)).catch(err => console.log(err));
246
- * ```
247
- */
248
- getAllApplications() {
249
- return this.wire.sendAction('get-all-applications').then(({ payload }) => payload.data);
250
- }
251
- /**
252
- * Retrieves the command line argument string that started OpenFin Runtime.
253
- *
254
- * @example
255
- * ```js
256
- * fin.System.getCommandLineArguments().then(args => console.log(args)).catch(err => console.log(err));
257
- * ```
258
- */
259
- getCommandLineArguments() {
260
- return this.wire.sendAction('get-command-line-arguments').then(({ payload }) => payload.data);
261
- }
262
- /**
263
- * Get the current state of the crash reporter.
264
- *
265
- * @example
266
- * ```js
267
- * fin.System.getCrashReporterState().then(state => console.log(state)).catch(err => console.log(err));
268
- * ```
269
- */
270
- async getCrashReporterState() {
271
- const { payload: { data: { diagnosticMode, isRunning } } } = await this.wire.sendAction('get-crash-reporter-state');
272
- console.warn('diagnosticMode property is deprecated. It will be removed in a future version');
273
- return {
274
- // diagnosticMode will be removed in a future version
275
- diagnosticMode,
276
- diagnosticsMode: diagnosticMode,
277
- isRunning
278
- };
279
- }
280
- /**
281
- * Start the crash reporter if not already running.
282
- * @param options - configure crash reporter
283
- *
284
- * @remarks You can optionally specify `diagnosticsMode` to have the logs sent to
285
- * OpenFin on runtime close. (NOTE: `diagnosticsMode` will turn on verbose logging and disable the sandbox
286
- * for newly launched renderer processes. See https://developers.openfin.co/of-docs/docs/debugging#diagnostics-mode for
287
- * more details.)
288
- *
289
- * @example
290
- * ```js
291
- * fin.System.startCrashReporter({diagnosticsMode: true}).then(reporter => console.log(reporter)).catch(err => console.log(err));
292
- * ```
293
- */
294
- async startCrashReporter(options) {
295
- const opts = options;
296
- const newOpts = { ...opts, diagnosticMode: opts.diagnosticsMode || opts.diagnosticMode };
297
- const { payload: { data: { diagnosticMode, isRunning } } } = await this.wire.sendAction('start-crash-reporter', newOpts);
298
- return {
299
- // diagnosticMode will be removed in a future version
300
- diagnosticMode,
301
- diagnosticsMode: diagnosticMode,
302
- isRunning
303
- };
304
- }
305
- /**
306
- * Returns a hex encoded hash of the machine id and the currently logged in user name.
307
- * This is the recommended way to uniquely identify a user / machine combination.
308
- *
309
- * @remarks For Windows systems this is a sha256 hash of the machine ID set in the registry key:
310
- * `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\MachineGuid` and `USERNAME`.
311
- *
312
- * For OSX systems, a native-level call is used to get the machine ID.
313
- *
314
- * @example
315
- * ```js
316
- * fin.System.getUniqueUserId().then(id => console.log(id)).catch(err => console.log(err));
317
- * ```
318
- * @static
319
- */
320
- getUniqueUserId() {
321
- return this.wire.sendAction('get-unique-user-id').then(({ payload }) => payload.data);
322
- }
323
- /**
324
- * Retrieves a frame info object for the uuid and name passed in
325
- * @param uuid - The UUID of the target.
326
- * @param name - The name of the target.
327
- *
328
- * @remarks The possible types are 'window', 'iframe', 'external connection' or 'unknown'.
329
- * @example
330
- * ```js
331
- * const entityUuid = 'OpenfinPOC';
332
- * const entityName = '40c74b5d-ed98-40f7-853f-e3d3c2699175';
333
- * fin.System.getEntityInfo(entityUuid, entityName).then(info => console.log(info)).catch(err => console.log(err));
334
- *
335
- * // example info shape
336
- * {
337
- * "uuid": "OpenfinPOC",
338
- * "name": "40c74b5d-ed98-40f7-853f-e3d3c2699175",
339
- * "parent": {
340
- * "uuid": "OpenfinPOC",
341
- * "name": "OpenfinPOC"
342
- * },
343
- * "entityType": "iframe"
344
- * }
345
- * ```
346
- */
347
- getEntityInfo(uuid, name) {
348
- return this.wire.sendAction('get-entity-info', { uuid, name }).then(({ payload }) => payload.data);
349
- }
350
- /**
351
- * Gets the value of a given environment variable on the computer on which the runtime is installed
352
- *
353
- * @example
354
- * ```js
355
- * fin.System.getEnvironmentVariable('HOME').then(env => console.log(env)).catch(err => console.log(err));
356
- * ```
357
- */
358
- getEnvironmentVariable(envName) {
359
- return this.wire
360
- .sendAction('get-environment-variable', {
361
- environmentVariables: envName
362
- })
363
- .then(({ payload }) => payload.data);
364
- }
365
- /**
366
- * Get current focused window.
367
- *
368
- * @example
369
- * ```js
370
- * fin.System.getFocusedWindow().then(winInfo => console.log(winInfo)).catch(err => console.log(err));
371
- * ```
372
- */
373
- getFocusedWindow() {
374
- return this.wire.sendAction('get-focused-window').then(({ payload }) => payload.data);
375
- }
376
- /**
377
- * Returns information about the given app's certification status
378
- *
379
- * @example
380
- * ```js
381
- * const manifestUrl = "http://localhost:1234/app.json"
382
- * try {
383
- * const certificationInfo = await fin.System.isAppCertified(manifestUrl);
384
- * } catch(err) {
385
- * console.error(err)
386
- * }
387
- * ```
388
- */
389
- async isAppCertified(manifestUrl) {
390
- const { payload: { data: { certifiedInfo } } } = await this.wire.sendAction('is-app-certified', { manifestUrl });
391
- return certifiedInfo;
392
- }
393
- /**
394
- * Returns an array of all the installed runtime versions in an object.
395
- *
396
- * @example
397
- * ```js
398
- * fin.System.getInstalledRuntimes().then(runtimes => console.log(runtimes)).catch(err => console.log(err));
399
- * ```
400
- */
401
- // incompatible with standalone node process.
402
- getInstalledRuntimes() {
403
- return this.wire.sendAction('get-installed-runtimes').then(({ payload }) => payload.data.runtimes);
404
- }
405
- // incompatible with standalone node process.
406
- async getInstalledApps() {
407
- const { payload: { data: { installedApps } } } = await this.wire.sendAction('get-installed-apps');
408
- return installedApps;
409
- }
410
- /**
411
- * Retrieves the contents of the log with the specified filename.
412
- * @param options A object that id defined by the GetLogRequestType interface
413
- *
414
- * @example
415
- * ```js
416
- * async function getLog() {
417
- * const logs = await fin.System.getLogList();
418
- * return await fin.System.getLog(logs[0]);
419
- * }
420
- *
421
- * getLog().then(log => console.log(log)).catch(err => console.log(err));
422
- * ```
423
- */
424
- getLog(options) {
425
- return this.wire.sendAction('view-log', options).then(({ payload }) => payload.data);
426
- }
427
- /**
428
- * Returns a unique identifier (UUID) provided by the machine.
429
- *
430
- * @example
431
- * ```js
432
- * fin.System.getMachineId().then(id => console.log(id)).catch(err => console.log(err));
433
- * ```
434
- */
435
- getMachineId() {
436
- return this.wire.sendAction('get-machine-id').then(({ payload }) => payload.data);
437
- }
438
- /**
439
- * Returns the minimum (inclusive) logging level that is currently being written to the log.
440
- *
441
- * @example
442
- * ```js
443
- * fin.System.getMinLogLevel().then(level => console.log(level)).catch(err => console.log(err));
444
- * ```
445
- */
446
- getMinLogLevel() {
447
- return this.wire.sendAction('get-min-log-level').then(({ payload }) => payload.data);
448
- }
449
- /**
450
- * Retrieves an array containing information for each log file.
451
- *
452
- * @example
453
- * ```js
454
- * fin.System.getLogList().then(logList => console.log(logList)).catch(err => console.log(err));
455
- * ```
456
- */
457
- getLogList() {
458
- return this.wire.sendAction('list-logs').then(({ payload }) => payload.data);
459
- }
460
- /**
461
- * Retrieves an object that contains data about the monitor setup of the
462
- * computer that the runtime is running on.
463
- *
464
- * @example
465
- * ```js
466
- * fin.System.getMonitorInfo().then(monitorInfo => console.log(monitorInfo)).catch(err => console.log(err));
467
- * ```
468
- */
469
- getMonitorInfo() {
470
- return this.wire.sendAction('get-monitor-info').then(({ payload }) => payload.data);
471
- }
472
- /**
473
- * Returns the mouse in virtual screen coordinates (left, top).
474
- *
475
- * @example
476
- * ```js
477
- * fin.System.getMousePosition().then(mousePosition => console.log(mousePosition)).catch(err => console.log(err));
478
- * ```
479
- */
480
- getMousePosition() {
481
- return this.wire.sendAction('get-mouse-position').then(({ payload }) => payload.data);
482
- }
483
- /**
484
- * Retrieves an array of all of the runtime processes that are currently
485
- * running. Each element in the array is an object containing the uuid
486
- * and the name of the application to which the process belongs.
487
- * @deprecated Please use our new set of process APIs:
488
- * {@link Window._Window#getProcessInfo Window.getProcessInfo}
489
- * {@link View.View#getProcessInfo View.getProcessInfo}
490
- * {@link Application.Application#getProcessInfo Application.getProcessInfo}
491
- * {@link System#getAllProcessInfo System.getAllProcessInfo}
492
- *
493
- * @example
494
- * ```js
495
- * fin.System.getProcessList().then(ProcessList => console.log(ProcessList)).catch(err => console.log(err));
496
- * ```
497
- */
498
- getProcessList() {
499
- // eslint-disable-next-line no-console
500
- console.warn('System.getProcessList has been deprecated. Please consider using our new process APIs: Window.getProcessInfo, View.getProcessInfo, Application.getProcessInfo, System.getAllProcessInfo');
501
- return this.wire.sendAction('process-snapshot').then(({ payload }) => payload.data);
502
- }
503
- /**
504
- * Retrieves all process information.
505
- *
506
- * @remarks This includes the browser process and every process associated to all entities (windows and views).
507
- *
508
- * @example
509
- * ```js
510
- * const allProcessInfo = await fin.System.getAllProcessInfo();
511
- * ```
512
- * @experimental
513
- */
514
- async getAllProcessInfo() {
515
- const { payload: { data } } = await this.wire.sendAction('get-all-process-info', this.identity);
516
- return data;
517
- }
518
- /**
519
- * Retrieves the Proxy settings.
520
- *
521
- * @example
522
- * ```js
523
- * fin.System.getProxySettings().then(ProxySetting => console.log(ProxySetting)).catch(err => console.log(err));
524
- *
525
- * //This response has the following shape:
526
- * {
527
- * config: {
528
- * proxyAddress: "proxyAddress", //the configured Proxy Address
529
- * proxyPort: 0, //the configured Proxy port
530
- * type: "system" //Proxy Type
531
- * },
532
- * system: {
533
- * autoConfigUrl: "",
534
- * bypass: "",
535
- * enabled: false,
536
- * proxy: ""
537
- * }
538
- * }
539
- * ```
540
- */
541
- getProxySettings() {
542
- return this.wire.sendAction('get-proxy-settings').then(({ payload }) => payload.data);
543
- }
544
- /**
545
- * Returns information about the running Runtime in an object.
546
- *
547
- * @example
548
- * ```js
549
- * fin.System.getRuntimeInfo().then(RuntimeInfo => console.log(RuntimeInfo)).catch(err => console.log(err));
550
- * ```
551
- */
552
- getRuntimeInfo() {
553
- return this.wire.sendAction('get-runtime-info').then(({ payload }) => payload.data);
554
- }
555
- /**
556
- * Returns information about the running RVM in an object.
557
- *
558
- * @example
559
- * ```js
560
- * fin.System.getRvmInfo().then(RvmInfo => console.log(RvmInfo)).catch(err => console.log(err));
561
- * ```
562
- */
563
- // incompatible with standalone node process.
564
- getRvmInfo() {
565
- return this.wire.sendAction('get-rvm-info').then(({ payload }) => payload.data);
566
- }
567
- /**
568
- * Retrieves system information.
569
- *
570
- * @example
571
- * ```js
572
- * fin.System.getHostSpecs().then(specs => console.log(specs)).catch(err => console.log(err));
573
- * ```
574
- */
575
- getHostSpecs() {
576
- return this.wire.sendAction('get-host-specs').then(({ payload }) => payload.data);
577
- }
578
- /**
579
- * Runs an executable or batch file. A path to the file must be included in options.
580
- * <br> A uuid may be optionally provided. If not provided, OpenFin will create a uuid for the new process.
581
- * <br> Note: This method is restricted by default and must be enabled via
582
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>. Also, this api has an enhanced permission set to make it less dangerous. So application owners can only allow to launch the assets owned by the application, the enabled downloaded files or the restricted executables.
583
- * @param options A object that is defined in the ExternalProcessRequestType interface
584
- *
585
- * @remarks If an unused UUID is provided in options, it will be used. If no UUID is provided, OpenFin will assign one.
586
- * This api has an enhanced permission set to make it less dangerous. So application owners can only allow to launch the
587
- * assets owned by the application, the enabled downloaded files or the restricted executables.
588
- *
589
- * **Note:** Since _appAssets_ relies on the RVM, which is missing on MAC_OS, 'alias' is not available. Instead provide
590
- * the full path e.g. _/Applications/Calculator.app/Contents/MacOS/Calculator_.
591
- *
592
- * @example
593
- * Basic Example:
594
- * ```js
595
- * fin.System.launchExternalProcess({
596
- * path: 'notepad',
597
- * arguments: '',
598
- * listener: function (result) {
599
- * console.log('the exit code', result.exitCode);
600
- * }
601
- * }).then(processIdentity => {
602
- * console.log(processIdentity);
603
- * }).catch(error => {
604
- * console.log(error);
605
- * });
606
- * ```
607
- *
608
- * Promise resolution:
609
- *
610
- * ```js
611
- * //This response has the following shape:
612
- * {
613
- * uuid: "FB3E6E36-0976-4C2B-9A09-FB2E54D2F1BB" // The mapped UUID which identifies the launched process
614
- * }
615
- * ```
616
- *
617
- * Listener callback:
618
- * ```js
619
- * //This response has the following shape:
620
- * {
621
- * topic: "exited", // Or "released" on a call to releaseExternalProcess
622
- * uuid: "FB3E6E36-0976-4C2B-9A09-FB2E54D2F1BB", // The mapped UUID which identifies the launched process
623
- * exitCode: 0 // Process exit code
624
- * }
625
- * ```
626
- *
627
- * By specifying a lifetime, an external process can live as long the window/application that launched it or
628
- * persist after the application exits. The default value is null, which is equivalent to 'persist', meaning
629
- * the process lives on after the application exits:
630
- *
631
- * ```js
632
- * fin.System.launchExternalProcess({
633
- * path: 'notepad',
634
- * arguments: '',
635
- * listener: (result) => {
636
- * console.log('the exit code', result.exitCode);
637
- * },
638
- * lifetime: 'window'
639
- * }).then(processIdentity => {
640
- * console.log(processIdentity);
641
- * }).catch(error => {
642
- * console.log(error);
643
- * });
644
- * ```
645
- *
646
- * Note: A process that exits when the window/application exits cannot be released via fin.desktop.System.releaseExternalProcess.
647
- *
648
- * By specifying a cwd, it will set current working directory when launching an external process:
649
- *
650
- * ```js
651
- * fin.System.launchExternalProcess({
652
- * path: 'cmd.exe',
653
- * cwd: 'c:\\temp',
654
- * arguments: '',
655
- * listener: (result) => {
656
- * console.log('the exit code', result.exitCode);
657
- * }
658
- * }).then(processIdentity => {
659
- * console.log(processIdentity);
660
- * }).catch(error => {
661
- * console.log(error);
662
- * });
663
- * ```
664
- *
665
- * Example using an alias from app.json appAssets property:
666
- *
667
- * ```json
668
- * "appAssets": [
669
- * {
670
- * "src": "exe.zip",
671
- * "alias": "myApp",
672
- * "version": "4.12.8",
673
- * "target": "myApp.exe",
674
- * "args": "a b c d"
675
- * },
676
- * ]
677
- * ```
678
- *
679
- * ```js
680
- * // When called, if no arguments are passed then the arguments (if any)
681
- * // are taken from the 'app.json' file, from the 'args' parameter
682
- * // of the 'appAssets' Object with the relevant 'alias'.
683
- * fin.System.launchExternalProcess({
684
- * //Additionally note that the executable found in the zip file specified in appAssets
685
- * //will default to the one mentioned by appAssets.target
686
- * //If the the path below refers to a specific path it will override this default
687
- * alias: 'myApp',
688
- * listener: (result) => {
689
- * console.log('the exit code', result.exitCode);
690
- * }
691
- * }).then(processIdentity => {
692
- * console.log(processIdentity);
693
- * }).catch(error => {
694
- * console.log(error);
695
- * });
696
- * ```
697
- *
698
- * Example using an alias but overriding the arguments:
699
- *
700
- * ```json
701
- * "appAssets": [
702
- * {
703
- * "src": "exe.zip",
704
- * "alias": "myApp",
705
- * "version": "4.12.8",
706
- * "target": "myApp.exe",
707
- * "args": "a b c d"
708
- * },
709
- * ]
710
- * ```
711
- *
712
- * ```js
713
- * // If 'arguments' is passed as a parameter it takes precedence
714
- * // over any 'args' set in the 'app.json'.
715
- * fin.System.launchExternalProcess({
716
- * alias: 'myApp',
717
- * arguments: 'e f g',
718
- * listener: (result) => {
719
- * console.log('the exit code', result.exitCode);
720
- * }
721
- * }).then(processIdentity => {
722
- * console.log(processIdentity);
723
- * }).catch(error => {
724
- * console.log(error);
725
- * });
726
- * ```
727
- *
728
- * It is now possible to optionally perform any combination of the following certificate checks
729
- * against an absolute target via `fin.desktop.System.launchExternalProcess()`:
730
- *
731
- * ```js
732
- * "certificate": {
733
- * "serial": "3c a5 ...", // A hex string with or without spaces
734
- * "subject": "O=OpenFin INC., L=New York, ...", // An internally tokenized and comma delimited string allowing partial or full checks of the subject fields
735
- * "publickey": "3c a5 ...", // A hex string with or without spaces
736
- * "thumbprint": "3c a5 ...", // A hex string with or without spaces
737
- * "trusted": true // A boolean indicating that the certificate is trusted and not revoked
738
- * }
739
- * ```
740
- *
741
- * Providing this information as part of the default configurations for assets in an application's manifest
742
- * will be added in a future RVM update:
743
- *
744
- * ```js
745
- * fin.System.launchExternalProcess({
746
- * path: 'C:\\Users\\ExampleUser\\AppData\\Local\\OpenFin\\OpenFinRVM.exe',
747
- * arguments: '--version',
748
- * certificate: {
749
- * trusted: true,
750
- * subject: 'O=OpenFin INC., L=New York, S=NY, C=US',
751
- * thumbprint: '‎3c a5 28 19 83 05 fe 69 88 e6 8f 4b 3a af c5 c5 1b 07 80 5b'
752
- * },
753
- * listener: (result) => {
754
- * console.log('the exit code', result.exitCode);
755
- * }
756
- * }).then(processIdentity => {
757
- * console.log(processIdentity);
758
- * }).catch(error => {
759
- * console.log(error);
760
- * });
761
- * ```
762
- *
763
- * It is possible to launch files that have been downloaded by the user by listening to the window
764
- * `file-download-completed` event and using the `fileUuid` provided by the event:
765
- *
766
- * ```js
767
- * const win = fin.Window.getCurrentSync();
768
- * win.addListener('file-download-completed', (evt) => {
769
- * if (evt.state === 'completed') {
770
- * fin.System.launchExternalProcess({
771
- * fileUuid: evt.fileUuid,
772
- * arguments: '',
773
- * listener: (result) => {
774
- * console.log('the exit code', result.exitCode);
775
- * }
776
- * }).then(processIdentity => {
777
- * console.log(processIdentity);
778
- * }).catch(error => {
779
- * console.log(error);
780
- * });
781
- * }
782
- * });
783
- * ```
784
- *
785
- * Launching assets specified in the app manifest:
786
- *
787
- * Sample appAssets section in app.json
788
- * ```js
789
- * "appAssets": [
790
- * {
791
- * "src": "http://filesamples.com/exe.zip",
792
- * "alias": "myApp",
793
- * "version": "4.12.8",
794
- * "target": "myApp.exe",
795
- * "args": "a b c d"
796
- * },
797
- * {
798
- * "src": "http://examples.com/exe.zip",
799
- * "alias": "myApp2",
800
- * "version": "5.12.8",
801
- * "target": "myApp2.exe",
802
- * "args": "a b c"
803
- * }
804
- * ]
805
- * ```
806
- *
807
- * This permission allows for launching of all assets specified in the above appAssets section. ("myApp" and "myApp2"):
808
- *
809
- * ```js
810
- * "permissions": {
811
- * "System": {
812
- * "launchExternalProcess": {
813
- * "enabled": true,
814
- * "assets": {
815
- * "enabled": true
816
- * }
817
- * }
818
- * }
819
- * }
820
- * ```
821
- *
822
- * This permission allows for launching of _only_ the "myApp" asset in the above appAssets section, as defined in `srcRules`:
823
- * ```js
824
- * "permissions": {
825
- * "System": {
826
- * "launchExternalProcess": {
827
- * "enabled": true,
828
- * "assets": {
829
- * "enabled": true
830
- * "srcRules": [
831
- * {
832
- * "match": [
833
- * "*://filesamples.com/*"
834
- * ],
835
- * "behavior": "allow"
836
- * },
837
- * {
838
- * "match": [
839
- * "<all_urls>"
840
- * ],
841
- * "behavior": "block"
842
- * }
843
- * ]
844
- * }
845
- * }
846
- * }
847
- * }
848
- * ```
849
- *
850
- * Launching downloaded files:
851
- * ```js
852
- * "permissions": {
853
- * "System": {
854
- * "launchExternalProcess": {
855
- * "enabled": true,
856
- * "downloads": {
857
- * "enabled": true
858
- * }
859
- * }
860
- * }
861
- * }
862
- * ```
863
- *
864
- * This permission allows to launch all the executables:
865
- * ```js
866
- * "permissions": {
867
- * "System": {
868
- * "launchExternalProcess": {
869
- * "enabled": true,
870
- * "executables": {
871
- * "enabled": true
872
- * }
873
- * }
874
- * }
875
- * }
876
- * ```
877
- *
878
- *
879
- * This permission only allows launching of executables whose file paths match the corresponding `pathRules`:
880
- * ```js
881
- * "permissions": {
882
- * "System": {
883
- * "launchExternalProcess": {
884
- * "enabled": true,
885
- * "executables": {
886
- * "enabled": true
887
- * "pathRules": [
888
- * {
889
- * "match": [
890
- * "/Windows/System32/*.exe"
891
- * ],
892
- * "behavior": "allow"
893
- * },
894
- * {
895
- * "match": [
896
- * "*.exe"
897
- * ],
898
- * "behavior": "block"
899
- * }
900
- * ]
901
- * }
902
- * }
903
- * }
904
- * }
905
- * ```
906
- */
907
- launchExternalProcess(options) {
908
- return this.sendExternalProcessRequest('launch-external-process', options);
909
- }
910
- /**
911
- * Monitors a running process. A pid for the process must be included in options.
912
- * <br> A uuid may be optionally provided. If not provided, OpenFin will create a uuid for the new process.
913
- * @param options See tutorial for more details
914
- *
915
- * @remarks If an unused uuid is provided in options, it will be used. If no uuid is provided, OpefinFin will assign a uuid.
916
- * @example
917
- * ```js
918
- * fin.System.monitorExternalProcess({
919
- * pid: 10208,
920
- * uuid: 'my-external-process', // optional
921
- * listener: function (result) {
922
- * console.log('the exit code', result.exitCode);
923
- * }
924
- * }).then(processIdentity => console.log(processIdentity)).catch(err => console.log(err));
925
- * ```
926
- */
927
- monitorExternalProcess(options) {
928
- return this.sendExternalProcessRequest('monitor-external-process', options);
929
- }
930
- /**
931
- * Writes the passed message into both the log file and the console.
932
- * @param level The log level for the entry. Can be either "info", "warning" or "error"
933
- * @param message The log message text
934
- *
935
- * @example
936
- * ```js
937
- * fin.System.log("info", "An example log message").then(() => console.log('Log info message')).catch(err => console.log(err));
938
- * ```
939
- */
940
- log(level, message) {
941
- return this.wire.sendAction('write-to-log', { level, message }).then(() => undefined);
942
- }
943
- /**
944
- * Opens the passed URL in the default web browser.
945
- *
946
- * @remarks It only supports http(s) and fin(s) protocols by default.
947
- * In order to use other custom protocols, they have to be enabled via
948
- * [API security settings](https://developers.openfin.co/docs/api-security).
949
- * File protocol and file path are not supported.
950
- * @param url The URL to open
951
- *
952
- * @example
953
- * ```js
954
- * fin.System.openUrlWithBrowser('https://cdn.openfin.co/docs/javascript/stable/tutorial-System.openUrlWithBrowser.html')
955
- * .then(() => console.log('Opened URL'))
956
- * .catch(err => console.log(err));
957
- * ```
958
- *
959
- * Example of permission definition to enable non-default protocols:
960
- *
961
- * Note: permission definition should be specified in an app manifest file if there is no DOS settings.
962
- * Otherwise it has to be specified in both DOS and app manifest files.
963
- *
964
- * ```js
965
- * "permissions": {
966
- * "System": {
967
- * "openUrlWithBrowser": {
968
- * "enabled": true,
969
- * "protocols": [ "msteams", "slack"]
970
- * }
971
- * }
972
- * }
973
- * ```
974
- */
975
- openUrlWithBrowser(url) {
976
- return this.wire.sendAction('open-url-with-browser', { url }).then(() => undefined);
977
- }
978
- /**
979
- * Removes the process entry for the passed UUID obtained from a prior call
980
- * of fin.System.launchExternalProcess().
981
- * @param uuid The UUID for a process obtained from a prior call to fin.desktop.System.launchExternalProcess()
982
- *
983
- * @example
984
- * ```js
985
- * fin.System.launchExternalProcess({
986
- * path: "notepad",
987
- * listener: function (result) {
988
- * console.log("The exit code", result.exitCode);
989
- * }
990
- * })
991
- * .then(identity => fin.System.releaseExternalProcess(identity.uuid))
992
- * .then(() => console.log('Process has been unmapped!'))
993
- * .catch(err => console.log(err));
994
- * ```
995
- */
996
- releaseExternalProcess(uuid) {
997
- return this.wire.sendAction('release-external-process', { uuid }).then(() => undefined);
998
- }
999
- /**
1000
- * Shows the Chromium Developer Tools for the specified window
1001
- * @param identity This is a object that is defined by the Identity interface
1002
- *
1003
- * @tutorial System.showDeveloperTools
1004
- */
1005
- showDeveloperTools(identity) {
1006
- return this.wire.sendAction('show-developer-tools', identity).then(() => undefined);
1007
- }
1008
- /**
1009
- * Attempt to close an external process. The process will be terminated if it
1010
- * has not closed after the elapsed timeout in milliseconds.<br>
1011
- * Note: This method is restricted by default and must be enabled via
1012
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
1013
- * @param options A object defined in the TerminateExternalRequestType interface
1014
- *
1015
- * @example
1016
- * ```js
1017
- * fin.System.launchExternalProcess({
1018
- * path: "notepad",
1019
- * listener: function (result) {
1020
- * console.log("The exit code", result.exitCode);
1021
- * }
1022
- * })
1023
- * .then(identity => fin.System.terminateExternalProcess({uuid: identity.uuid, timeout:2000, killTree: false}))
1024
- * .then(() => console.log('Terminate the process'))
1025
- * .catch(err => console.log(err));
1026
- * ```
1027
- */
1028
- terminateExternalProcess(options) {
1029
- return this.wire.sendAction('terminate-external-process', options).then(() => undefined);
1030
- }
1031
- /**
1032
- * Update the OpenFin Runtime Proxy settings.
1033
- * @param options A config object defined in the ProxyConfig interface
1034
- *
1035
- * @example
1036
- * ```js
1037
- * fin.System.updateProxySettings({proxyAddress:'127.0.0.1', proxyPort:8080, type:'http'})
1038
- * .then(() => console.log('Update proxy successfully'))
1039
- * .catch(err => console.error(err));
1040
- * ```
1041
- */
1042
- updateProxySettings(options) {
1043
- return this.wire.sendAction('update-proxy', options).then(() => undefined);
1044
- }
1045
- /**
1046
- * Downloads the given application asset<br>
1047
- * Note: This method is restricted by default and must be enabled via
1048
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
1049
- * @param appAsset App asset object
1050
- *
1051
- * @example
1052
- * ```js
1053
- * async function downloadAsset() {
1054
- * const appAsset = {
1055
- * src: `${ location.origin }/assets.zip`,
1056
- * alias: 'dirApp',
1057
- * version: '1.23.24',
1058
- * target: 'assets/run.bat'
1059
- * };
1060
- *
1061
- * return fin.System.downloadAsset(appAsset, (progress => {
1062
- * //Print progress as we download the asset.
1063
- * const downloadedPercent = Math.floor((progress.downloadedBytes / progress.totalBytes) * 100);
1064
- * console.log(`Downloaded ${downloadedPercent}%`);
1065
- * }));
1066
- * }
1067
- *
1068
- * downloadAsset()
1069
- * .then(() => console.log('Success'))
1070
- * .catch(err => console.error(err));
1071
- *
1072
- * ```
1073
- */
1074
- // incompatible with standalone node process.
1075
- async downloadAsset(appAsset, progressListener) {
1076
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-empty-function
1077
- const noop = () => { };
1078
- let resolve = noop;
1079
- let reject = noop;
1080
- const downloadCompletePromise = new Promise((y, n) => {
1081
- resolve = y;
1082
- reject = n;
1083
- });
1084
- // node.js environment not supported
1085
- if (this.wire.environment.constructor.name === 'NodeEnvironment') {
1086
- throw new transport_errors_1.NotSupportedError('downloadAsset only supported in an OpenFin Render process');
1087
- }
1088
- const callSite = transport_errors_1.RuntimeError.getCallSite();
1089
- const downloadId = this.wire.environment.getNextMessageId().toString();
1090
- const dlProgressKey = `asset-download-progress-${downloadId}`;
1091
- const dlErrorKey = `asset-download-error-${downloadId}`;
1092
- const dlCompleteKey = `asset-download-complete-${downloadId}`;
1093
- const dlProgress = (progress) => {
1094
- const p = {
1095
- downloadedBytes: progress.downloadedBytes,
1096
- totalBytes: progress.totalBytes
1097
- };
1098
- progressListener(p);
1099
- };
1100
- const cleanListeners = () => {
1101
- // TODO: fix internal types
1102
- // @ts-expect-error
1103
- this.removeListener(dlProgressKey, dlProgress);
1104
- };
1105
- const dlError = (payload) => {
1106
- cleanListeners();
1107
- const { reason, err: error } = payload;
1108
- reject(new transport_errors_1.RuntimeError({ reason, error }, callSite));
1109
- };
1110
- const dlComplete = () => {
1111
- cleanListeners();
1112
- resolve();
1113
- };
1114
- await Promise.all([
1115
- // TODO: fix internal types
1116
- // @ts-expect-error
1117
- this.on(dlProgressKey, dlProgress),
1118
- // TODO: fix internal types
1119
- // @ts-expect-error
1120
- this.once(dlErrorKey, dlError),
1121
- // TODO: fix internal types
1122
- // @ts-expect-error
1123
- this.once(dlCompleteKey, dlComplete)
1124
- ]);
1125
- const downloadOptions = Object.assign(appAsset, { downloadId });
1126
- await this.wire.sendAction('download-asset', downloadOptions).catch((err) => {
1127
- cleanListeners();
1128
- throw err;
1129
- });
1130
- return downloadCompletePromise;
1131
- }
1132
- /**
1133
- * Downloads a version of the runtime.
1134
- * @param options - Download options.
1135
- * @param progressListener - called as the runtime is downloaded with progress information.
1136
- *
1137
- * @remarks Only supported in an OpenFin Render process.
1138
- *
1139
- * @example
1140
- * ```js
1141
- * var downloadOptions = {
1142
- * //Specific version number required, if given a release channel the call will produce an error.
1143
- * version: '9.61.30.1'
1144
- * };
1145
- *
1146
- * function onProgress(progress) {
1147
- * console.log(`${Math.floor((progress.downloadedBytes / progress.totalBytes) * 100)}%`);
1148
- * }
1149
- *
1150
- * fin.System.downloadRuntime(downloadOptions, onProgress).then(() => {
1151
- * console.log('Download complete');
1152
- * }).catch(err => {
1153
- * console.log(`Download Failed, we could retry: ${err.message}`);
1154
- * console.log(err);
1155
- * });
1156
- * ```
1157
- */
1158
- downloadRuntime(options, progressListener) {
1159
- const callsites = transport_errors_1.RuntimeError.getCallSite();
1160
- return new Promise((resolve, reject) => {
1161
- // node.js environment not supported
1162
- if (this.wire.environment.constructor.name === 'NodeEnvironment') {
1163
- reject(new transport_errors_1.NotSupportedError('downloadRuntime only supported in an OpenFin Render process'));
1164
- return;
1165
- }
1166
- const downloadId = this.wire.environment.getNextMessageId().toString();
1167
- const dlProgressKey = `runtime-download-progress-${downloadId}`;
1168
- const dlErrorKey = `runtime-download-error-${downloadId}`;
1169
- const dlCompleteKey = `runtime-download-complete-${downloadId}`;
1170
- const dlProgress = (progress) => {
1171
- const p = {
1172
- downloadedBytes: progress.downloadedBytes,
1173
- totalBytes: progress.totalBytes
1174
- };
1175
- progressListener(p);
1176
- };
1177
- const cleanListeners = () => {
1178
- // TODO: fix internal types
1179
- // @ts-expect-error
1180
- this.removeListener(dlProgressKey, dlProgress);
1181
- };
1182
- const dlError = (payload) => {
1183
- cleanListeners();
1184
- const { reason, err: error } = payload;
1185
- reject(new transport_errors_1.RuntimeError({ reason, error }, callsites));
1186
- };
1187
- const dlComplete = () => {
1188
- cleanListeners();
1189
- resolve();
1190
- };
1191
- // TODO: fix internal types
1192
- // @ts-expect-error
1193
- this.on(dlProgressKey, dlProgress);
1194
- // TODO: fix internal types
1195
- // @ts-expect-error
1196
- this.once(dlErrorKey, dlError);
1197
- // TODO: fix internal types
1198
- // @ts-expect-error
1199
- this.once(dlCompleteKey, dlComplete);
1200
- const downloadOptions = Object.assign(options, { downloadId });
1201
- this.wire.sendAction('download-runtime', downloadOptions).catch((err) => {
1202
- cleanListeners();
1203
- reject(err);
1204
- });
1205
- });
1206
- }
1207
- /**
1208
- * Download preload scripts from given URLs
1209
- * @param scripts - URLs of preload scripts. See tutorial for more details.
1210
- *
1211
- * @example
1212
- * ```js
1213
- * const scripts = [
1214
- * { url: 'http://.../preload.js' },
1215
- * { url: 'http://.../preload2.js' }
1216
- * ];
1217
- *
1218
- * fin.System.downloadPreloadScripts(scripts).then(results => {
1219
- * results.forEach(({url, success, error}) => {
1220
- * console.log(`URL: ${url}`);
1221
- * console.log(`Success: ${success}`);
1222
- * if (error) {
1223
- * console.log(`Error: ${error}`);
1224
- * }
1225
- * });
1226
- * });
1227
- * ```
1228
- */
1229
- downloadPreloadScripts(scripts) {
1230
- return this.wire.sendAction('download-preload-scripts', { scripts }).then(({ payload }) => payload.data);
1231
- }
1232
- /**
1233
- * Retrieves an array of data (name, ids, bounds) for all application windows.
1234
- *
1235
- * @example
1236
- * ```js
1237
- * fin.System.getAllExternalApplications()
1238
- * .then(externalApps => console.log('Total external apps: ' + externalApps.length))
1239
- * .catch(err => console.log(err));
1240
- * ```
1241
- */
1242
- getAllExternalApplications() {
1243
- return this.wire.sendAction('get-all-external-applications').then(({ payload }) => payload.data);
1244
- }
1245
- /**
1246
- * Retrieves app asset information.
1247
- * @param options
1248
- *
1249
- * @example
1250
- * ```js
1251
- * fin.System.getAppAssetInfo({alias:'procexp'}).then(assetInfo => console.log(assetInfo)).catch(err => console.log(err));
1252
- * ```
1253
- */
1254
- getAppAssetInfo(options) {
1255
- return this.wire.sendAction('get-app-asset-info', options).then(({ payload }) => payload.data);
1256
- }
1257
- /**
1258
- * Get additional info of cookies.
1259
- * @param options - See tutorial for more details.
1260
- *
1261
- * @example
1262
- * ```js
1263
- * fin.System.getCookies({name: 'myCookie'}).then(cookies => console.log(cookies)).catch(err => console.log(err));
1264
- * ```
1265
- */
1266
- getCookies(options) {
1267
- const url = this.wire.environment.getUrl();
1268
- const newOptions = Object.assign(options, { url });
1269
- return this.wire.sendAction('get-cookies', newOptions).then(({ payload }) => payload.data);
1270
- }
1271
- /**
1272
- * Set the minimum log level above which logs will be written to the OpenFin log
1273
- * @param The minimum level (inclusive) above which all calls to log will be written
1274
- *
1275
- * @example
1276
- * ```js
1277
- * fin.System.setMinLogLevel("verbose").then(() => console.log("log level is set to verbose")).catch(err => console.log(err));
1278
- * ```
1279
- */
1280
- setMinLogLevel(level) {
1281
- return this.wire.sendAction('set-min-log-level', { level }).then(() => undefined);
1282
- }
1283
- /**
1284
- * Retrieves the UUID of the computer on which the runtime is installed
1285
- * @param uuid The uuid of the running application
1286
- *
1287
- * @example
1288
- * ```js
1289
- * fin.System.resolveUuid('OpenfinPOC').then(entity => console.log(entity)).catch(err => console.log(err));
1290
- * ```
1291
- */
1292
- resolveUuid(uuid) {
1293
- return this.wire
1294
- .sendAction('resolve-uuid', {
1295
- entityKey: uuid
1296
- })
1297
- .then(({ payload }) => payload.data);
1298
- }
1299
- /**
1300
- * Retrieves an array of data for all external applications
1301
- * @param requestingIdentity This object is described in the Identity typedef
1302
- * @param data Any data type to pass to the method
1303
- *
1304
- * @ignore
1305
- */
1306
- executeOnRemote(requestingIdentity, data) {
1307
- data.requestingIdentity = requestingIdentity;
1308
- return this.wire.ferryAction(data);
1309
- }
1310
- /**
1311
- * Reads the specifed value from the registry.
1312
- * @remarks This method is restricted by default and must be enabled via
1313
- * [API security settings](https://developers.openfin.co/docs/api-security).
1314
- * @param rootKey - The registry root key.
1315
- * @param subkey - The registry key.
1316
- * @param value - The registry value name.
1317
- *
1318
- * @example
1319
- * ```js
1320
- * fin.System.readRegistryValue("HKEY_LOCAL_MACHINE", "HARDWARE\\DESCRIPTION\\System", "BootArchitecture").then(val => console.log(val)).catch(err => console.log(err));
1321
- * ```
1322
- *
1323
- * See {@link https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx here} for Window's error code definitions.
1324
- *
1325
- * Example payloads of different registry types:
1326
- *
1327
- * See list of types {@link https://msdn.microsoft.com/en-us/library/windows/desktop/ms724884(v=vs.85).aspx here}.
1328
- *
1329
- * ```js
1330
- * // REG_DWORD
1331
- * {
1332
- * data: 1,
1333
- * rootKey: "HKEY_LOCAL_MACHINE",
1334
- * subkey: "Foo\Bar",
1335
- * type: "REG_DWORD",
1336
- * value: "Baz"
1337
- * }
1338
- *
1339
- * // REG_QWORD
1340
- * {
1341
- * data: 13108146671334112,
1342
- * rootKey: "HKEY_LOCAL_MACHINE",
1343
- * subkey: "Foo\Bar",
1344
- * type: "REG_QWORD",
1345
- * value: "Baz"
1346
- * }
1347
- *
1348
- * // REG_SZ
1349
- * {
1350
- * data: "FooBarBaz",
1351
- * rootKey: "HKEY_LOCAL_MACHINE",
1352
- * subkey: "Foo\Bar",
1353
- * type: "REG_SZ",
1354
- * value: "Baz"
1355
- * }
1356
- *
1357
- * // REG_EXPAND_SZ
1358
- * {
1359
- * data: "C:\User\JohnDoe\AppData\Local",
1360
- * rootKey: "HKEY_CURRENT_USER",
1361
- * subkey: "Foo\Bar",
1362
- * type: "REG_EXPAND_SZ",
1363
- * value: "Baz"
1364
- * }
1365
- *
1366
- * // REG_MULTI_SZ
1367
- * {
1368
- * data: [
1369
- * "Foo",
1370
- * "Bar",
1371
- * "Baz"
1372
- * ],
1373
- * rootKey: "HKEY_CURRENT_USER",
1374
- * subkey: "Foo\Bar",
1375
- * type: "REG_MULTI_SZ",
1376
- * value: "Baz"
1377
- * }
1378
- *
1379
- * // REG_BINARY
1380
- * {
1381
- * data: {
1382
- * data: [
1383
- * 255,
1384
- * 255,
1385
- * 0,
1386
- * 43,
1387
- * 55,
1388
- * 0,
1389
- * 0,
1390
- * 255,
1391
- * 255
1392
- * ],
1393
- * type: "Buffer"
1394
- * },
1395
- * rootKey: "HKEY_CURRENT_USER",
1396
- * subkey: "Foo\Bar",
1397
- * type: "REG_BINARY",
1398
- * value: "Baz"
1399
- * }
1400
- * ```
1401
- */
1402
- readRegistryValue(rootKey, subkey, value) {
1403
- return this.wire
1404
- .sendAction('read-registry-value', {
1405
- rootKey,
1406
- subkey,
1407
- value
1408
- })
1409
- .then(({ payload }) => payload.data);
1410
- }
1411
- /**
1412
- * This function call will register a unique id and produce a token.
1413
- * The token can be used to broker an external connection.
1414
- * @param uuid - A UUID for the remote connection.
1415
- *
1416
- * @example
1417
- * ```js
1418
- * fin.System.registerExternalConnection("remote-connection-uuid").then(conn => console.log(conn)).catch(err => console.log(err));
1419
- *
1420
- *
1421
- * // object comes back with
1422
- * // token: "0489EAC5-6404-4F0D-993B-92BB8EAB445D", // this will be unique each time
1423
- * // uuid: "remote-connection-uuid"
1424
- *
1425
- * ```
1426
- */
1427
- registerExternalConnection(uuid) {
1428
- return this.wire.sendAction('register-external-connection', { uuid }).then(({ payload }) => payload.data);
1429
- }
1430
- /**
1431
- * Returns the json blob found in the [desktop owner settings](https://openfin.co/documentation/desktop-owner-settings/)
1432
- * for the specified service.
1433
- * @param serviceIdentifier An object containing a name key that identifies the service.
1434
- *
1435
- * @remarks More information about desktop services can be found [here](https://developers.openfin.co/docs/desktop-services).
1436
- * This call will reject if the desktop owner settings file is not present, not correctly formatted, or if the service requested is not configured or configured incorrectly.
1437
- *
1438
- * @example
1439
- * ```js
1440
- * // Here we are using the [layouts](https://github.com/HadoukenIO/layouts-service) service.
1441
- * fin.System.getServiceConfiguration({name:'layouts'}).then(console.log).catch(console.error);
1442
- * ```
1443
- */
1444
- async getServiceConfiguration(serviceIdentifier) {
1445
- if (typeof serviceIdentifier.name !== 'string') {
1446
- throw new Error('Must provide an object with a `name` property having a string value');
1447
- }
1448
- const { name } = serviceIdentifier;
1449
- return this.wire.sendAction('get-service-configuration', { name }).then(({ payload }) => payload.data);
1450
- }
1451
- async getSystemAppConfig(name) {
1452
- if (typeof name !== 'string') {
1453
- throw new Error('Must provide a string value for name of system app');
1454
- }
1455
- return this.wire.sendAction('get-system-app-configuration', { name }).then(({ payload }) => payload.data);
1456
- }
1457
- /**
1458
- * Registers a system shutdown handler so user can do some cleanup before system is shutting down.
1459
- * @remarks Once system shutdown starts, you are unable to cancel it.
1460
- * @param handler system shutdown handler
1461
- *
1462
- * @example
1463
- * ```js
1464
- * fin.System.registerShutdownHandler((shutdownEvent) => {
1465
- * // save state or cleanup
1466
- * console.log('do some cleanup before shutdown');
1467
- * // Notify app is ready for termination.
1468
- * shutdownEvent.proceed();
1469
- * })
1470
- * .then(() => console.log('Shutdown handler registered!'))
1471
- * .catch(err => console.log(err));
1472
- * ```
1473
- * @experimental
1474
- */
1475
- async registerShutdownHandler(handler) {
1476
- this.wire.sendAction('system-register-shutdown-handler').catch((e) => {
1477
- // don't expose, analytics-only call
1478
- });
1479
- const SystemShutdownEventName = 'system-shutdown';
1480
- const SystemShutdownHandledEventName = 'system-shutdown-handled';
1481
- const { uuid, name } = this.wire.me;
1482
- const shutdownHandler = (payload) => {
1483
- const proceed = () => {
1484
- // notify core that the app is ready for shutdown
1485
- this.wire.environment.raiseEvent(`application/${SystemShutdownHandledEventName}`, {
1486
- uuid,
1487
- name,
1488
- topic: 'application'
1489
- });
1490
- };
1491
- handler({ proceed });
1492
- };
1493
- this.on(SystemShutdownEventName, shutdownHandler);
1494
- }
1495
- /**
1496
- * Signals the RVM to perform a health check and returns the results as json.
1497
- *
1498
- * @remarks Requires RVM 5.5+
1499
- *
1500
- * @example
1501
- * ```js
1502
- * try {
1503
- * const results = await fin.System.runRvmHealthCheck();
1504
- * console.log(results);
1505
- * } catch(e) {
1506
- * console.error(e);
1507
- * }
1508
- * ```
1509
- */
1510
- runRvmHealthCheck() {
1511
- return this.wire.sendAction('run-rvm-health-check').then(({ payload }) => payload.data);
1512
- }
1513
- /**
1514
- * Launch application using a manifest URL/path. It differs from Application.startFromManifest in that this API can accept a manifest using the fin protocol.
1515
- * @param manifestUrl - The manifest's URL or path.
1516
- * @param opts - Parameters that the RVM will use.
1517
- *
1518
- * @experimental
1519
- * @remarks Supports protocols http/s and fin/s, and also a local path.
1520
- *
1521
- * Note: This API is Windows only.
1522
- *
1523
- * @example
1524
- *
1525
- * This API can handle most manifest types. Some examples below.
1526
- *
1527
- * Traditional:
1528
- * ```js
1529
- * const manifest = await fin.System.launchManifest(
1530
- * 'https://demoappdirectory.openf.in/desktop/config/apps/OpenFin/HelloOpenFin/app.json');
1531
- * console.log(manifest);
1532
- * ```
1533
- *
1534
- * Platform:
1535
- * ```js
1536
- * const manifest = await fin.System.launchManifest('https://openfin.github.io/platform-api-project-seed/public.json');
1537
- * console.log(manifest);
1538
- * ```
1539
- *
1540
- * Launching traditional manifest into a platform:
1541
- * ```js
1542
- * const manifest = await fin.System.launchManifest(
1543
- * 'https://openfin.github.io/platform-api-project-seed/public.json?\
1544
- * $$appManifestUrl=https://demoappdirectory.openf.in/desktop/config/\
1545
- * apps/OpenFin/HelloOpenFin/app.json');
1546
- * console.log(manifest);
1547
- * ```
1548
- *
1549
- * Launching with RVM options:
1550
- * ```js
1551
- * const manifest = await fin.System.launchManifest('https://openfin.github.io/platform-api-project-seed/public.json',
1552
- * { noUi: true, userAppConfigArgs: { abc: '123', xyz: '789' } });
1553
- * console.log(manifest);
1554
- * ```
1555
- *
1556
- * Local Path:
1557
- * ```js
1558
- * const manifest = await fin.System.launchManifest('file://c:\\path\\to\\manifest\\file.json');
1559
- * console.log(manifest);
1560
- * ```
1561
- *
1562
- * Launching with RVM 'subscribe' option:
1563
- *
1564
- * This option allows users to subscribe to app version resolver events when
1565
- * calling launchManifest with fallbackManifests specified.
1566
- *
1567
- * ```js
1568
- * fin.System.launchManifest('fins://system-apps/notifications/app.json', { subscribe: (launch) => {
1569
- * launch.on('app-version-progress', (progress) => {
1570
- * console.log("Trying manifest " + progress.manifest)
1571
- * });
1572
- *
1573
- * launch.on('runtime-status', (status) => {
1574
- * console.log("Runtime status: " + JSON.stringify(status));
1575
- * });
1576
- *
1577
- * // RVM has successfully found the target runtime version
1578
- * launch.on('app-version-complete', (complete) => {
1579
- * console.log("Parent app " + complete.srcManifest + " resolved to " + complete.manifest);
1580
- * launch.removeAllListeners();
1581
- * });
1582
- *
1583
- * // RVM failed to find an available runtime version
1584
- * launch.on('app-version-error', (error) => {
1585
- * console.log("Failed to resolve " + error.srcManifest + " from the fallbackManifests");
1586
- * launch.removeAllListeners();
1587
- * });
1588
- * }
1589
- * });
1590
- * ```
1591
- * @static
1592
- */
1593
- async launchManifest(manifestUrl, opts = {}) {
1594
- const { subscribe, ..._sendOpts } = opts;
1595
- const sendOpts = _sendOpts;
1596
- if (subscribe) {
1597
- const launchEmitter = new events_1.EventEmitter();
1598
- subscribe(launchEmitter);
1599
- const AppVersionProgressEventName = 'app-version-progress';
1600
- const RuntimeStatusEventName = 'runtime-status';
1601
- const AppVersionCompleteEventName = 'app-version-complete';
1602
- const AppVersionErrorEventName = 'app-version-error';
1603
- // add id to avoid multiple api calls getting duplicated events
1604
- const id = this.wire.environment.getNextMessageId().toString();
1605
- sendOpts.appVersionId = id;
1606
- const supportedEvents = [
1607
- AppVersionCompleteEventName,
1608
- AppVersionProgressEventName,
1609
- RuntimeStatusEventName,
1610
- AppVersionErrorEventName
1611
- ];
1612
- const cleanEventPayload = (payload) => {
1613
- // We need to do type castings below to make sure the return type is correct.
1614
- const { appVersionId, topic, type: typeWithId, ...rest } = payload;
1615
- const type = supportedEvents.find((x) => typeWithId.includes(x));
1616
- return {
1617
- ...rest,
1618
- type
1619
- };
1620
- };
1621
- const appVersionListener = (payload) => {
1622
- const cleanPayload = cleanEventPayload(payload);
1623
- launchEmitter.emit(cleanPayload.type, cleanPayload);
1624
- };
1625
- const removeAllListeners = () => {
1626
- this.removeListener(`${AppVersionProgressEventName}.${id}`, appVersionListener);
1627
- this.removeListener(`${RuntimeStatusEventName}.${id}`, appVersionListener);
1628
- this.removeListener(`${AppVersionCompleteEventName}.${id}`, appVersionListener);
1629
- this.removeListener(`${AppVersionErrorEventName}.${id}`, appVersionListener);
1630
- this.removeListener(`${AppVersionCompleteEventName}.${id}`, removeAllListeners);
1631
- this.removeListener(`${AppVersionErrorEventName}.${id}`, removeAllListeners);
1632
- };
1633
- await Promise.all([
1634
- this.on(`${AppVersionProgressEventName}.${id}`, appVersionListener),
1635
- this.on(`${RuntimeStatusEventName}.${id}`, appVersionListener),
1636
- this.once(`${AppVersionCompleteEventName}.${id}`, appVersionListener),
1637
- this.once(`${AppVersionErrorEventName}.${id}`, appVersionListener),
1638
- this.once(`${AppVersionCompleteEventName}.${id}`, removeAllListeners),
1639
- this.once(`${AppVersionErrorEventName}.${id}`, removeAllListeners)
1640
- ]);
1641
- }
1642
- const response = await this.wire.sendAction('launch-manifest', {
1643
- manifestUrl,
1644
- opts: sendOpts
1645
- });
1646
- return response.payload.data.manifest;
1647
- }
1648
- /**
1649
- * Query permission of a secured api in current context.
1650
- * @param apiName - The full name of a secured API.
1651
- *
1652
- * @example
1653
- * ```js
1654
- * fin.System.queryPermissionForCurrentContext('System.launchExternalProcess').then(result => console.log(result)).catch(err => console.log(err));
1655
- *
1656
- * //This response has the following shape:
1657
- * {
1658
- * permission: 'System.launchExternalProcess', // api full name
1659
- * state: 'granted', // state of permission
1660
- * granted: true
1661
- * }
1662
- * ```
1663
- */
1664
- async queryPermissionForCurrentContext(apiName) {
1665
- const identity = { uuid: this.wire.me.uuid, name: this.wire.me.name };
1666
- const response = await this.wire.sendAction('query-permission-for-current-context', {
1667
- apiName,
1668
- identity
1669
- });
1670
- return response.payload.data;
1671
- }
1672
- // Not documenting, internal use only.
1673
- async enableNativeWindowIntegrationProvider(permissions) {
1674
- const { payload } = await this.wire.sendAction('enable-native-window-integration-provider', { permissions });
1675
- return payload.data;
1676
- }
1677
- /**
1678
- * (Internal) Register the usage of a component with a platform
1679
- * @param options - Object with data and type
1680
- *
1681
- * @example
1682
- * ```js
1683
- * async function registerUsage() {
1684
- * const app = await fin.System.getCurrent();
1685
- * return await fin.System.registerUsage({
1686
- * type: 'workspace-licensing',
1687
- * // example values for the following data object
1688
- * data: {
1689
- * apiVersion: '1.0',
1690
- * componentName: 'home',
1691
- * componentVersion: '1.0',
1692
- * allowed: true,
1693
- * rejectionCode: ''
1694
- * }
1695
- * });
1696
- * }
1697
- *
1698
- * registerUsage().then(() => console.log('Successfully registered component application')).catch(err => console.log(err));
1699
- * ```
1700
- */
1701
- async registerUsage({ data, type }) {
1702
- await this.wire.sendAction('register-usage', { data, type });
1703
- }
1704
- /**
1705
- * Returns an array with all printers of the caller and not all the printers on the desktop.
1706
- *
1707
- * @example
1708
- * ```js
1709
- * fin.System.getPrinters()
1710
- * .then((printers) => {
1711
- * printers.forEach((printer) => {
1712
- * if (printer.isDefault) {
1713
- * console.log(printer);
1714
- * }
1715
- * });
1716
- * })
1717
- * .catch((err) => {
1718
- * console.log(err);
1719
- * });
1720
- * ```
1721
- */
1722
- async getPrinters() {
1723
- const { payload } = await this.wire.sendAction('system-get-printers');
1724
- return payload.data;
1725
- }
1726
- /**
1727
- * Updates Process Logging values: periodic interval and outlier detection entries and interval.
1728
- * @param options Process Logging updatable options.
1729
- *
1730
- * @remarks When enabling verbose mode, additional process information is logged to the debug.log:
1731
- *
1732
- * 1. Periodically process usage (memory, cpu, etc) will be logged for each PID along with the windows, views and
1733
- * iframes that belong to them. The default is every 30 seconds. Updatable by passing the interval option.
1734
- * 2. When Windows and Views are created or navigated the PID they belong to and their options will be logged.
1735
- * 3. When Windows and Views are destroyed their last known process usage will be logged.
1736
- * 4. Whenever an outlier memory usage is detected it will be logged. By default, on an interval of 5 seconds we will
1737
- * collect process usage for all PIDs and when 144 such entries are collected, we will start analyzing the data for any
1738
- * possible outliers in the following entries. The interval and maximum number of entries stored in the running buffer
1739
- * can be updatable by passing the outlierDetection.interval and outlierDetection.entries options.
1740
- *
1741
- * @example
1742
- *
1743
- * ```js
1744
- * await fin.System.updateProcessLoggingOptions({
1745
- * interval: 10,
1746
- * outlierDetection: {
1747
- * interval: 15,
1748
- * entries: 200
1749
- * }
1750
- * });
1751
- * ```
1752
- */
1753
- async updateProcessLoggingOptions(options) {
1754
- await this.wire.sendAction('system-update-process-logging-options', { options });
1755
- }
1756
- /**
1757
- * Returns domain settings for the current application.
1758
- * Initial settings are configured with the defaultDomainSettings application option via manifest.
1759
- * Domain settings can be overwritten during runtime with System.setDomainSettings.
1760
- * @example
1761
- * ```js
1762
- * const domainSettings = await fin.System.getDomainSettings();
1763
- * // {
1764
- * // "rules": [
1765
- * // {
1766
- * // "match": [
1767
- * // "https://openfin.co"
1768
- * // ],
1769
- * // "options": {
1770
- * // "downloadSettings": {
1771
- * // "rules": [
1772
- * // {
1773
- * // "match": [
1774
- * // "<all_urls>"
1775
- * // ],
1776
- * // "behavior": "prompt"
1777
- * // }
1778
- * // ]
1779
- * // }
1780
- * // }
1781
- * // }
1782
- * // ]
1783
- * // }
1784
- * ```
1785
- */
1786
- async getDomainSettings() {
1787
- const { payload: { data } } = await this.wire.sendAction('get-domain-settings', this.identity);
1788
- return data;
1789
- }
1790
- /**
1791
- * Sets the domain settings for the current application.
1792
- * @param domainSettings - domain settings object
1793
- * @example
1794
- * ```js
1795
- * const domainSettings = await fin.System.getDomainSettings();
1796
- * // {
1797
- * // "rules": [
1798
- * // {
1799
- * // "match": [
1800
- * // "https://openfin.co"
1801
- * // ],
1802
- * // "options": {
1803
- * // "downloadSettings": {
1804
- * // "rules": [
1805
- * // {
1806
- * // "match": [
1807
- * // "<all_urls>"
1808
- * // ],
1809
- * // "behavior": "prompt"
1810
- * // }
1811
- * // ]
1812
- * // }
1813
- * // }
1814
- * // }
1815
- * // ]
1816
- * // }
1817
- *
1818
- * // Valid rule behaviors are 'prompt' and 'no-prompt'
1819
- * domainSettings.rules[0].options.downloadSettings.rules[0].behavior = 'no-prompt';
1820
- *
1821
- * await fin.System.setDomainSettings(domainSettings);
1822
- *
1823
- * const newDomainSettings = await fin.System.getDomainSettings();
1824
- * // {
1825
- * // "rules": [
1826
- * // {
1827
- * // "match": [
1828
- * // "https://openfin.co"
1829
- * // ],
1830
- * // "options": {
1831
- * // "downloadSettings": {
1832
- * // "rules": [
1833
- * // {
1834
- * // "match": [
1835
- * // "<all_urls>"
1836
- * // ],
1837
- * // "behavior": "no-prompt"
1838
- * // }
1839
- * // ]
1840
- * // }
1841
- * // }
1842
- * // }
1843
- * // ]
1844
- * // }
1845
- * ```
1846
- */
1847
- async setDomainSettings(domainSettings) {
1848
- await this.wire.sendAction('set-domain-settings', { domainSettings, ...this.identity });
1849
- }
1850
- }
1851
- exports.default = System;