@openfin/core 25.68.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/LICENSE +13 -0
  2. package/NOTICE +16 -0
  3. package/OpenFin.d.ts +1340 -0
  4. package/README.md +41 -0
  5. package/docs.README(OLD).md +82 -0
  6. package/fin.d.ts +4 -0
  7. package/package.json +33 -0
  8. package/resources/win/OpenFinRVM.exe +0 -0
  9. package/src/api/application/Factory.d.ts +145 -0
  10. package/src/api/application/Factory.js +229 -0
  11. package/src/api/application/Instance.d.ts +302 -0
  12. package/src/api/application/Instance.js +412 -0
  13. package/src/api/application/index.d.ts +3 -0
  14. package/src/api/application/index.js +15 -0
  15. package/src/api/base.d.ts +43 -0
  16. package/src/api/base.js +177 -0
  17. package/src/api/clipboard/index.d.ts +69 -0
  18. package/src/api/clipboard/index.js +88 -0
  19. package/src/api/events/application.d.ts +69 -0
  20. package/src/api/events/application.js +2 -0
  21. package/src/api/events/base.d.ts +17 -0
  22. package/src/api/events/base.js +2 -0
  23. package/src/api/events/channel.d.ts +10 -0
  24. package/src/api/events/channel.js +2 -0
  25. package/src/api/events/emitterMap.d.ts +11 -0
  26. package/src/api/events/emitterMap.js +35 -0
  27. package/src/api/events/eventAggregator.d.ts +5 -0
  28. package/src/api/events/eventAggregator.js +43 -0
  29. package/src/api/events/externalApplication.d.ts +5 -0
  30. package/src/api/events/externalApplication.js +2 -0
  31. package/src/api/events/frame.d.ts +9 -0
  32. package/src/api/events/frame.js +2 -0
  33. package/src/api/events/globalHotkey.d.ts +10 -0
  34. package/src/api/events/globalHotkey.js +2 -0
  35. package/src/api/events/platform.d.ts +18 -0
  36. package/src/api/events/platform.js +2 -0
  37. package/src/api/events/system.d.ts +22 -0
  38. package/src/api/events/system.js +2 -0
  39. package/src/api/events/view.d.ts +56 -0
  40. package/src/api/events/view.js +2 -0
  41. package/src/api/events/webcontents.d.ts +48 -0
  42. package/src/api/events/webcontents.js +2 -0
  43. package/src/api/events/window.d.ts +169 -0
  44. package/src/api/events/window.js +2 -0
  45. package/src/api/external-application/Factory.d.ts +26 -0
  46. package/src/api/external-application/Factory.js +40 -0
  47. package/src/api/external-application/Instance.d.ts +102 -0
  48. package/src/api/external-application/Instance.js +109 -0
  49. package/src/api/external-application/index.d.ts +3 -0
  50. package/src/api/external-application/index.js +15 -0
  51. package/src/api/fin.d.ts +49 -0
  52. package/src/api/fin.js +43 -0
  53. package/src/api/frame/Factory.d.ts +36 -0
  54. package/src/api/frame/Factory.js +69 -0
  55. package/src/api/frame/Instance.d.ts +121 -0
  56. package/src/api/frame/Instance.js +130 -0
  57. package/src/api/frame/index.d.ts +3 -0
  58. package/src/api/frame/index.js +15 -0
  59. package/src/api/global-hotkey/index.d.ts +38 -0
  60. package/src/api/global-hotkey/index.js +58 -0
  61. package/src/api/interappbus/channel/channel.d.ts +26 -0
  62. package/src/api/interappbus/channel/channel.js +77 -0
  63. package/src/api/interappbus/channel/channels-docs.d.ts +318 -0
  64. package/src/api/interappbus/channel/channels-docs.js +376 -0
  65. package/src/api/interappbus/channel/client.d.ts +22 -0
  66. package/src/api/interappbus/channel/client.js +84 -0
  67. package/src/api/interappbus/channel/connection-manager.d.ts +28 -0
  68. package/src/api/interappbus/channel/connection-manager.js +244 -0
  69. package/src/api/interappbus/channel/index.d.ts +22 -0
  70. package/src/api/interappbus/channel/index.js +121 -0
  71. package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +13 -0
  72. package/src/api/interappbus/channel/protocols/classic/message-receiver.js +73 -0
  73. package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +22 -0
  74. package/src/api/interappbus/channel/protocols/classic/strategy.js +84 -0
  75. package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +20 -0
  76. package/src/api/interappbus/channel/protocols/combined/strategy.js +58 -0
  77. package/src/api/interappbus/channel/protocols/index.d.ts +44 -0
  78. package/src/api/interappbus/channel/protocols/index.js +2 -0
  79. package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +10 -0
  80. package/src/api/interappbus/channel/protocols/protocol-manager.js +43 -0
  81. package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +23 -0
  82. package/src/api/interappbus/channel/protocols/rtc/endpoint.js +135 -0
  83. package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +30 -0
  84. package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +131 -0
  85. package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +22 -0
  86. package/src/api/interappbus/channel/protocols/rtc/strategy.js +87 -0
  87. package/src/api/interappbus/channel/protocols/strategy-types.d.ts +13 -0
  88. package/src/api/interappbus/channel/protocols/strategy-types.js +2 -0
  89. package/src/api/interappbus/channel/protocols/strategy.d.ts +15 -0
  90. package/src/api/interappbus/channel/protocols/strategy.js +2 -0
  91. package/src/api/interappbus/channel/provider.d.ts +31 -0
  92. package/src/api/interappbus/channel/provider.js +165 -0
  93. package/src/api/interappbus/index.d.ts +85 -0
  94. package/src/api/interappbus/index.js +175 -0
  95. package/src/api/interop/Factory.d.ts +37 -0
  96. package/src/api/interop/Factory.js +54 -0
  97. package/src/api/interop/InteropBroker.d.ts +363 -0
  98. package/src/api/interop/InteropBroker.js +914 -0
  99. package/src/api/interop/InteropClient.d.ts +268 -0
  100. package/src/api/interop/InteropClient.js +450 -0
  101. package/src/api/interop/SessionContextGroupBroker.d.ts +26 -0
  102. package/src/api/interop/SessionContextGroupBroker.js +107 -0
  103. package/src/api/interop/SessionContextGroupClient.d.ts +20 -0
  104. package/src/api/interop/SessionContextGroupClient.js +85 -0
  105. package/src/api/interop/fdc3/fdc3-1.2.d.ts +187 -0
  106. package/src/api/interop/fdc3/fdc3-1.2.js +385 -0
  107. package/src/api/interop/fdc3/fdc3.js +17 -0
  108. package/src/api/interop/fdc3/utils.d.ts +6 -0
  109. package/src/api/interop/fdc3/utils.js +17 -0
  110. package/src/api/interop/index.d.ts +4 -0
  111. package/src/api/interop/index.js +16 -0
  112. package/src/api/interop/utils.d.ts +11 -0
  113. package/src/api/interop/utils.js +36 -0
  114. package/src/api/me.d.ts +35 -0
  115. package/src/api/me.js +60 -0
  116. package/src/api/platform/Factory.d.ts +109 -0
  117. package/src/api/platform/Factory.js +188 -0
  118. package/src/api/platform/Instance.d.ts +122 -0
  119. package/src/api/platform/Instance.js +299 -0
  120. package/src/api/platform/common-utils.d.ts +6 -0
  121. package/src/api/platform/common-utils.js +16 -0
  122. package/src/api/platform/index.d.ts +3 -0
  123. package/src/api/platform/index.js +15 -0
  124. package/src/api/platform/layout/Factory.d.ts +108 -0
  125. package/src/api/platform/layout/Factory.js +189 -0
  126. package/src/api/platform/layout/Instance.d.ts +48 -0
  127. package/src/api/platform/layout/Instance.js +99 -0
  128. package/src/api/platform/layout/index.d.ts +3 -0
  129. package/src/api/platform/layout/index.js +15 -0
  130. package/src/api/platform/layout/shapes.d.ts +11 -0
  131. package/src/api/platform/layout/shapes.js +2 -0
  132. package/src/api/snapshot-source/Factory.d.ts +36 -0
  133. package/src/api/snapshot-source/Factory.js +65 -0
  134. package/src/api/snapshot-source/Instance.d.ts +30 -0
  135. package/src/api/snapshot-source/Instance.js +134 -0
  136. package/src/api/snapshot-source/index.d.ts +3 -0
  137. package/src/api/snapshot-source/index.js +15 -0
  138. package/src/api/snapshot-source/utils.d.ts +1 -0
  139. package/src/api/snapshot-source/utils.js +5 -0
  140. package/src/api/system/application.d.ts +6 -0
  141. package/src/api/system/application.js +2 -0
  142. package/src/api/system/entity.d.ts +11 -0
  143. package/src/api/system/entity.js +2 -0
  144. package/src/api/system/index.d.ts +957 -0
  145. package/src/api/system/index.js +1241 -0
  146. package/src/api/system/installedApps.d.ts +6 -0
  147. package/src/api/system/installedApps.js +2 -0
  148. package/src/api/system/log.d.ts +11 -0
  149. package/src/api/system/log.js +2 -0
  150. package/src/api/system/process.d.ts +15 -0
  151. package/src/api/system/process.js +2 -0
  152. package/src/api/system/proxy.d.ts +15 -0
  153. package/src/api/system/proxy.js +2 -0
  154. package/src/api/system/queryPermissionTypes.d.ts +1 -0
  155. package/src/api/system/queryPermissionTypes.js +2 -0
  156. package/src/api/system/registry-info.d.ts +7 -0
  157. package/src/api/system/registry-info.js +2 -0
  158. package/src/api/system/window.d.ts +16 -0
  159. package/src/api/system/window.js +2 -0
  160. package/src/api/view/Factory.d.ts +49 -0
  161. package/src/api/view/Factory.js +103 -0
  162. package/src/api/view/Instance.d.ts +379 -0
  163. package/src/api/view/Instance.js +415 -0
  164. package/src/api/view/index.d.ts +3 -0
  165. package/src/api/view/index.js +15 -0
  166. package/src/api/webcontents/main.d.ts +36 -0
  167. package/src/api/webcontents/main.js +82 -0
  168. package/src/api/window/Factory.d.ts +44 -0
  169. package/src/api/window/Factory.js +91 -0
  170. package/src/api/window/Instance.d.ts +966 -0
  171. package/src/api/window/Instance.js +1202 -0
  172. package/src/api/window/bounds-changed.d.ts +10 -0
  173. package/src/api/window/bounds-changed.js +6 -0
  174. package/src/api/window/index.d.ts +5 -0
  175. package/src/api/window/index.js +17 -0
  176. package/src/api/window/shapes.d.ts +13 -0
  177. package/src/api/window/shapes.js +2 -0
  178. package/src/environment/environment.d.ts +28 -0
  179. package/src/environment/environment.js +4 -0
  180. package/src/environment/node-env.d.ts +25 -0
  181. package/src/environment/node-env.js +64 -0
  182. package/src/environment/openfin-env.d.ts +29 -0
  183. package/src/environment/openfin-env.js +105 -0
  184. package/src/mock.d.ts +4 -0
  185. package/src/mock.js +91 -0
  186. package/src/shapes/ERROR_BOX_TYPES.d.ts +6 -0
  187. package/src/shapes/ERROR_BOX_TYPES.js +10 -0
  188. package/src/shapes/EntityType.d.ts +1 -0
  189. package/src/shapes/EntityType.js +2 -0
  190. package/src/shapes/LayoutPresetType.d.ts +1 -0
  191. package/src/shapes/LayoutPresetType.js +2 -0
  192. package/src/shapes/Platform.d.ts +112 -0
  193. package/src/shapes/Platform.js +16 -0
  194. package/src/shapes/WebOptions.d.ts +12 -0
  195. package/src/shapes/WebOptions.js +2 -0
  196. package/src/shapes/WindowOptions.d.ts +42 -0
  197. package/src/shapes/WindowOptions.js +2 -0
  198. package/src/shapes/protocol.d.ts +178 -0
  199. package/src/shapes/protocol.js +2 -0
  200. package/src/transport/fin_store.d.ts +4 -0
  201. package/src/transport/fin_store.js +16 -0
  202. package/src/transport/transport-errors.d.ts +17 -0
  203. package/src/transport/transport-errors.js +39 -0
  204. package/src/transport/transport.d.ts +57 -0
  205. package/src/transport/transport.js +195 -0
  206. package/src/transport/wire.d.ts +76 -0
  207. package/src/transport/wire.js +39 -0
  208. package/src/util/asyncFilter.d.ts +1 -0
  209. package/src/util/asyncFilter.js +7 -0
  210. package/src/util/errors.d.ts +9 -0
  211. package/src/util/errors.js +14 -0
  212. package/src/util/exhaustive.d.ts +1 -0
  213. package/src/util/exhaustive.js +7 -0
  214. package/src/util/http.d.ts +11 -0
  215. package/src/util/http.js +83 -0
  216. package/src/util/normalize-config.d.ts +3 -0
  217. package/src/util/normalize-config.js +47 -0
  218. package/src/util/promises.d.ts +5 -0
  219. package/src/util/promises.js +27 -0
  220. package/src/util/ref-counter.d.ts +7 -0
  221. package/src/util/ref-counter.js +51 -0
  222. package/src/util/runtimeVersioning.d.ts +3 -0
  223. package/src/util/runtimeVersioning.js +25 -0
  224. package/src/util/utilTypes.d.ts +8 -0
  225. package/src/util/utilTypes.js +2 -0
  226. package/src/util/validate.d.ts +3 -0
  227. package/src/util/validate.js +11 -0
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
3
+ if (!privateMap.has(receiver)) {
4
+ throw new TypeError("attempted to get private field on non-instance");
5
+ }
6
+ return privateMap.get(receiver);
7
+ };
8
+ var _connectToProvider;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.Platform = void 0;
11
+ const base_1 = require("../base");
12
+ const validate_1 = require("../../util/validate");
13
+ const Platform_1 = require("../../shapes/Platform");
14
+ // Reuse clients to avoid overwriting already-registered client in provider
15
+ const clientMap = new Map();
16
+ /** Manages the life cycle of windows and views in the application.
17
+ *
18
+ * Enables taking snapshots of itself and applying them to restore a previous configuration
19
+ * as well as listen to <a href="tutorial-Platform.EventEmitter.html">platform events</a>.
20
+ * @namespace
21
+ */
22
+ class Platform extends base_1.EmitterBase {
23
+ // eslint-disable-next-line no-shadow
24
+ constructor(identity, channel) {
25
+ // we piggyback off of application event emitter because from the core's perspective platform is just an app.
26
+ super(channel.wire, 'application', identity.uuid);
27
+ this.getClient = (identity) => {
28
+ this.wire.sendAction('platform-get-client', this.identity).catch((e) => {
29
+ // don't expose
30
+ });
31
+ const target = identity || this.identity;
32
+ const { uuid } = target;
33
+ if (!clientMap.has(uuid)) {
34
+ const clientPromise = __classPrivateFieldGet(this, _connectToProvider).call(this, uuid);
35
+ clientMap.set(uuid, clientPromise);
36
+ }
37
+ // we set it above
38
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
39
+ return clientMap.get(uuid);
40
+ };
41
+ _connectToProvider.set(this, async (uuid) => {
42
+ try {
43
+ const channelName = `custom-frame-${uuid}`;
44
+ const client = await this._channel.connect(channelName, { wait: false });
45
+ client.onDisconnection(() => {
46
+ clientMap.delete(uuid);
47
+ });
48
+ return client;
49
+ }
50
+ catch (e) {
51
+ clientMap.delete(uuid);
52
+ throw new Error('The targeted Platform is not currently running. Listen for application-started event for the given Uuid.');
53
+ }
54
+ });
55
+ // Deprecated (renamed)
56
+ this.launchLegacyManifest = this.launchContentManifest;
57
+ const errorMsg = validate_1.validateIdentity(identity);
58
+ if (errorMsg) {
59
+ throw new Error(errorMsg);
60
+ }
61
+ this._channel = channel;
62
+ this.identity = { uuid: identity.uuid };
63
+ this.Layout = this.fin.Platform.Layout;
64
+ this.Application = this.fin.Application.wrapSync(this.identity);
65
+ }
66
+ /**
67
+ * Creates a new view and attaches it to a specified target window.
68
+ * @param { View~options } viewOptions View creation options
69
+ * @param { Identity } [target] The window to which the new view is to be attached. If no target, create a view in a new window.
70
+ * @param { Identity } [targetView] If provided, the new view will be added to the same tabstrip as targetView.
71
+ * @return { Promise<View> }
72
+ * @tutorial Platform.createView
73
+ */
74
+ async createView(viewOptions, target, targetView) {
75
+ this.wire.sendAction('platform-create-view', this.identity).catch((e) => {
76
+ // don't expose
77
+ });
78
+ const client = await this.getClient();
79
+ const response = await client.dispatch('create-view', {
80
+ target,
81
+ opts: viewOptions,
82
+ targetView
83
+ });
84
+ if (!response || validate_1.validateIdentity(response.identity)) {
85
+ throw new Error(`When overwriting the createView call, please return an object that has a valid 'identity' property: ${JSON.stringify(response)}`);
86
+ }
87
+ return this.fin.View.wrapSync(response.identity);
88
+ }
89
+ /**
90
+ * Creates a new Window.
91
+ * @param { Window~options } options Window creation options
92
+ * @return { Promise<_Window> }
93
+ * @tutorial Platform.createWindow
94
+ */
95
+ async createWindow(options) {
96
+ this.wire.sendAction('platform-create-window', this.identity).catch((e) => {
97
+ // don't expose
98
+ });
99
+ const client = await this.getClient();
100
+ if (!options.reason) {
101
+ options.reason = Platform_1.WindowCreationReason.APICall;
102
+ }
103
+ const response = await client.dispatch('create-view-container', options);
104
+ if (!response || validate_1.validateIdentity(response.identity)) {
105
+ throw new Error(`When overwriting the createWindow call, please return an object that has a valid 'identity' property: ${JSON.stringify(response)}`);
106
+ }
107
+ const { identity } = response;
108
+ const res = this.fin.Window.wrapSync(identity);
109
+ // we add the identity at the top level for backwards compatibility.
110
+ res.name = identity.name;
111
+ res.uuid = identity.uuid;
112
+ return res;
113
+ }
114
+ /**
115
+ * Closes current platform, all its windows, and their views.
116
+ * @return { Promise<void> }
117
+ * @tutorial Platform.quit
118
+ */
119
+ async quit() {
120
+ this.wire.sendAction('platform-quit', this.identity).catch((e) => {
121
+ // don't expose
122
+ });
123
+ const client = await this.getClient();
124
+ return client.dispatch('quit');
125
+ }
126
+ /**
127
+ * Closes a specified view in a target window.
128
+ * @param { Identity } viewIdentity View identity
129
+ * @return { Promise<void> }
130
+ * @tutorial Platform.closeView
131
+ */
132
+ async closeView(viewIdentity) {
133
+ this.wire.sendAction('platform-close-view', this.identity).catch((e) => {
134
+ // don't expose
135
+ });
136
+ const client = await this.getClient();
137
+ await client.dispatch('close-view', {
138
+ view: viewIdentity
139
+ });
140
+ }
141
+ /**
142
+ * ***DEPRECATED - please use Platform.createView.***
143
+ * Reparents a specified view in a new target window.
144
+ * @param { Identity } viewIdentity View identity
145
+ * @param { Identity } target new owner window identity
146
+ * @return { Promise<View> }
147
+ * @tutorial Platform.createView
148
+ */
149
+ async reparentView(viewIdentity, target) {
150
+ var _a;
151
+ // eslint-disable-next-line no-console
152
+ console.warn('Platform.reparentView has been deprecated, please use Platform.createView');
153
+ this.wire.sendAction('platform-reparent-view', this.identity).catch((e) => {
154
+ // don't expose
155
+ });
156
+ const normalizedViewIdentity = {
157
+ ...viewIdentity,
158
+ uuid: (_a = viewIdentity.uuid) !== null && _a !== void 0 ? _a : this.identity.uuid
159
+ };
160
+ const view = await this.fin.View.wrap(normalizedViewIdentity);
161
+ const viewOptions = await view.getOptions();
162
+ return this.createView(viewOptions, target);
163
+ }
164
+ /**
165
+ * Returns a snapshot of the platform in its current state.
166
+ *
167
+ * Can be used to restore an application to a previous state.
168
+ * @return { Promise<Snapshot> }
169
+ * @tutorial Platform.getSnapshot
170
+ */
171
+ async getSnapshot() {
172
+ this.wire.sendAction('platform-get-snapshot', this.identity).catch((e) => {
173
+ // don't expose
174
+ });
175
+ const client = await this.getClient();
176
+ return client.dispatch('get-snapshot');
177
+ }
178
+ /**
179
+ * Adds a snapshot to a running Platform.
180
+ * Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.
181
+ *
182
+ * Can optionally close existing windows and overwrite current platform state with that of a snapshot.
183
+ *
184
+ * The function accepts either a snapshot taken using {@link Platform#getSnapshot getSnapshot},
185
+ * or a url or filepath to a snapshot JSON object.
186
+ * @param { Snapshot | string } requestedSnapshot Snapshot to apply, or a url or filepath.
187
+ * @param { ApplySnapshotOptions } [options] Optional parameters to specify whether existing windows should be closed.
188
+ * @return { Promise<Platform> }
189
+ * @tutorial Platform.applySnapshot
190
+ */
191
+ async applySnapshot(requestedSnapshot, options) {
192
+ this.wire.sendAction('platform-apply-snapshot', this.identity).catch((e) => {
193
+ // don't expose
194
+ });
195
+ const errMsg = 'Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.';
196
+ let snapshot;
197
+ if (typeof requestedSnapshot === 'string') {
198
+ // Fetch and parse snapshot
199
+ try {
200
+ const response = await this._channel.wire.sendAction('get-application-manifest', {
201
+ manifestUrl: requestedSnapshot
202
+ });
203
+ snapshot = response.payload.data;
204
+ }
205
+ catch (err) {
206
+ throw new Error(`${errMsg}: ${err}`);
207
+ }
208
+ }
209
+ else {
210
+ snapshot = requestedSnapshot;
211
+ }
212
+ if (!snapshot.windows) {
213
+ throw new Error(errMsg);
214
+ }
215
+ const client = await this.getClient();
216
+ await client.dispatch('apply-snapshot', {
217
+ snapshot,
218
+ options
219
+ });
220
+ return this;
221
+ }
222
+ /**
223
+ * Fetches a JSON manifest using the browser process and returns a Javascript object.
224
+ * Can be overwritten using {@link Platform#init Platform.init}.
225
+ * @param { string } manifestUrl The URL of the manifest to fetch.
226
+ * @return { Promise<any> }
227
+ * @tutorial Platform.fetchManifest
228
+ */
229
+ async fetchManifest(manifestUrl) {
230
+ const client = await this.getClient();
231
+ return client.dispatch('platform-fetch-manifest', { manifestUrl });
232
+ }
233
+ /**
234
+ * Retrieves a manifest by url and launches a legacy application manifest or snapshot into the platform. Returns a promise that
235
+ * resolves to the wrapped Platform.
236
+ * @param {string} manifestUrl - The URL of the manifest that will be launched into the platform. If this app manifest
237
+ * contains a snapshot, that will be launched into the platform. If not, the application described in startup_app options
238
+ * will be launched into the platform. The applicable startup_app options will become {@link View~options View Options}.
239
+ * @return {Promise<Platform>}
240
+ * @tutorial Platform.launchContentManifest
241
+ * @experimental
242
+ */
243
+ async launchContentManifest(manifestUrl) {
244
+ this.wire.sendAction('platform-launch-content-manifest', this.identity).catch((e) => {
245
+ // don't expose
246
+ });
247
+ const client = await this.getClient();
248
+ const manifest = await this.fetchManifest(manifestUrl);
249
+ client.dispatch('launch-into-platform', { manifest });
250
+ return this;
251
+ }
252
+ /**
253
+ * Set the context of a host window. The context will be available to the window itself, and to its child Views. It will be saved in any platform snapshots.
254
+ * It can be retrieved using {@link Platform#getWindowContext getWindowContext}.
255
+ * @param {any} context - A field where serializable context data can be stored to be saved in platform snapshots.
256
+ * @param {Identity} [target] - A target window or view may optionally be provided. If no target is provided, the update will be applied
257
+ * to the current window (if called from a Window) or the current host window (if called from a View).
258
+ * @return {Promise<void>}
259
+ * @tutorial Platform.setWindowContext
260
+ * @experimental
261
+ */
262
+ async setWindowContext(context = {}, target) {
263
+ this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
264
+ // don't expose
265
+ });
266
+ if (!context) {
267
+ throw new Error('Please provide a serializable object or string to set the context.');
268
+ }
269
+ const client = await this.getClient();
270
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
271
+ await client.dispatch('set-window-context', {
272
+ context,
273
+ entityType,
274
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
275
+ });
276
+ }
277
+ /**
278
+ * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
279
+ * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
280
+ * @param {Identity} [target] - A target window or view may optionally be provided. If no target is provided, target will be
281
+ * the current window (if called from a Window) or the current host window (if called from a View).
282
+ * @return {Promise<any>}
283
+ * @tutorial Platform.getWindowContext
284
+ * @experimental
285
+ */
286
+ async getWindowContext(target) {
287
+ this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
288
+ // don't expose
289
+ });
290
+ const client = await this.getClient();
291
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
292
+ return client.dispatch('get-window-context', {
293
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
294
+ entityType
295
+ });
296
+ }
297
+ }
298
+ exports.Platform = Platform;
299
+ _connectToProvider = new WeakMap();
@@ -0,0 +1,6 @@
1
+ import { LayoutPresetType } from '../../shapes/LayoutPresetType';
2
+ export declare function isValidPresetType(type: LayoutPresetType): type is LayoutPresetType;
3
+ declare const _default: {
4
+ isValidPresetType: typeof isValidPresetType;
5
+ };
6
+ export default _default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidPresetType = void 0;
4
+ function isValidPresetType(type) {
5
+ switch (type) {
6
+ case 'columns':
7
+ case 'grid':
8
+ case 'rows':
9
+ case 'tabs':
10
+ return true;
11
+ default:
12
+ return false;
13
+ }
14
+ }
15
+ exports.isValidPresetType = isValidPresetType;
16
+ exports.default = { isValidPresetType };
@@ -0,0 +1,3 @@
1
+ import PlatformModule from './Factory';
2
+ export default PlatformModule;
3
+ export * from './Instance';
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
+ }
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ const Factory_1 = require("./Factory");
14
+ exports.default = Factory_1.default;
15
+ __exportStar(require("./Instance"), exports);
@@ -0,0 +1,108 @@
1
+ import { InitLayoutOptions } from './shapes';
2
+ import { Layout } from './Instance';
3
+ import { Base } from '../../base';
4
+ /**
5
+ * InitLayoutOptions interface
6
+ * @typedef { object } InitLayoutOptions
7
+ * @property { string } [containerId] The id attribute of the container where the window's Layout should be initialized. If not provided
8
+ * then an element with id `layout-container` is used. We recommend using a div element.
9
+ */
10
+ /**
11
+ * PresetLayoutOptions interface
12
+ * @typedef { object } PresetLayoutOptions
13
+ * @property { LayoutPresetTypes } presetType Which preset layout arrangement to use.
14
+ * The preset options are `columns`, `grid`, `rows`, and `tabs`.
15
+ */
16
+ /**
17
+ * LayoutConfig interface
18
+ * @typedef { object } LayoutConfig
19
+ * @property { Array<LayoutItem> } content Content of the layout. There can only be one top-level LayoutItem in the content array.
20
+ * We do not recommend trying to build Layouts or LayoutItems by hand and instead use calls such as {@link Platform#getSnapshot getSnapshot}
21
+ * or our {@link https://openfin.github.io/golden-prototype/config-gen Layout Config Generation Tool }.
22
+ * @property { LayoutSettings } settings Configuration for certain Layout behaviors. See the LayoutSettings interface.
23
+ */
24
+ /**
25
+ * LayoutItem Interface
26
+ * @typedef { object } LayoutItem Represents the arrangement of Views within a Platform window's Layout. We do not recommend trying
27
+ * to build Layouts or LayoutItems by hand and instead use calls such as {@link Platform#getSnapshot getSnapshot} or our
28
+ * {@link https://openfin.github.io/golden-prototype/config-gen Layout Config Generation Tool }.
29
+ * @property { string } type The type of the item. Possible values are 'row', 'column', 'stack', and 'component'.
30
+ * @property { Array<LayoutItem> } [content] An array of configurations for items that will be created as children of this item.
31
+ * @property { string } [componentName] Only a `component` type will have this property and it should be set to `view`.
32
+ * @property { View~options } [componentState] Only a `component` type will have this property and it represents the view
33
+ * options of a given component.
34
+ */
35
+ /**
36
+ * LayoutSettings Interface
37
+ * @typedef { object } LayoutSettings Represents a potential ways to customize behavior of your Layout
38
+ * @property { boolean } [constrainDragToHeaders=false] Limits the area to which tabs can be dragged.
39
+ * If true, stack headers are the only areas where tabs can be dropped.
40
+ * @property { boolean } [hasHeaders=true] Turns tab headers on or off.
41
+ * If false, the layout will be displayed with splitters only.
42
+ * @property {object} [newTabButton]
43
+ * Configuration of the Plus button that appears on each tabstrip. Upon pressing, a new tab
44
+ * will be added to the tabstrip with the specified url.
45
+ * @property {string} [newTabButton.url] Specifies the url that opens in the tab created upon pressing the button.
46
+ * @property { boolean } [popoutWholeStack=false] Whether the popout button will only act on the entire stack,
47
+ * as opposed to only the active tab.
48
+ * @property { boolean } [preventDragIn=false] If true, tabs can't be dragged into the window.
49
+ * @property { boolean } [preventDragOut=false] If true, tabs can't be dragged out of the window.
50
+ * @property { boolean } [preventSplitterResize=false] If true, tab contents can't be resized by the user.
51
+ * @property { boolean } [reorderEnabled=true] If true, the user can re-arrange the layout by
52
+ * dragging items by their tabs to the desired location.
53
+ * @property { boolean } [showCloseIcon=false] Whether to show the close button on stack header
54
+ * (not to be confused with close button on every tab).
55
+ * @property { boolean } [showMaximiseIcon=false] Whether to show the maximize button on stack header.
56
+ * The button will maximize the current tab to fill the entire window.
57
+ * @property { boolean } [showPopoutIcon=false] Whether to show the popout button on stack header.
58
+ * The button will create a new window with current tab as its content.
59
+ * In case `popoutWholeStack` is set to true, all tabs in the stack will be in the new window.
60
+ */
61
+ /**
62
+ * @lends Platform#Layout
63
+ */
64
+ export declare class LayoutModule extends Base {
65
+ #private;
66
+ /**
67
+ * Asynchronously returns a Layout object that represents a Window's layout.
68
+ * @param { Identity } identity
69
+ * @return {Promise.<Layout>}
70
+ * @tutorial Layout.wrap
71
+ * @static
72
+ */
73
+ wrap(identity: OpenFin.Identity): Promise<OpenFin.Layout>;
74
+ /**
75
+ * Synchronously returns a Layout object that represents a Window's layout.
76
+ * @param { Identity } identity
77
+ * @return {Layout}
78
+ * @tutorial Layout.wrapSync
79
+ * @static
80
+ */
81
+ wrapSync(identity: OpenFin.Identity): OpenFin.Layout;
82
+ /**
83
+ * Asynchronously returns a Layout object that represents a Window's layout.
84
+ * @return {Promise.<Layout>}
85
+ * @tutorial Layout.getCurrent
86
+ * @static
87
+ */
88
+ getCurrent(): Promise<OpenFin.Layout>;
89
+ /**
90
+ * Synchronously returns a Layout object that represents a Window's layout.
91
+ * @return {Layout}
92
+ * @tutorial Layout.getCurrentSync
93
+ * @static
94
+ */
95
+ getCurrentSync(): OpenFin.Layout;
96
+ /**
97
+ * Initialize the window's Layout. Must be called from a custom window that has a 'layout' option set upon creation of that window.
98
+ * If a containerId is not provided, this method attempts to find an element with the id `layout-container`.
99
+ * A Layout will <a href="tutorial-Layout.DOMEvents.html">emit events locally</a> on the DOM element representing the layout-container.
100
+ * In order to capture the relevant events during Layout initiation, set up the listeners on the DOM element prior to calling `init`.
101
+ * @param { InitLayoutOptions } [options] - Layout init options.
102
+ * @return { Promise<Layout> }
103
+ * @static
104
+ * @experimental
105
+ * @tutorial Layout.init
106
+ */
107
+ init: (options?: InitLayoutOptions) => Promise<OpenFin.Layout>;
108
+ }
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
3
+ if (!privateMap.has(receiver)) {
4
+ throw new TypeError("attempted to get private field on non-instance");
5
+ }
6
+ return privateMap.get(receiver);
7
+ };
8
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
9
+ if (!privateMap.has(receiver)) {
10
+ throw new TypeError("attempted to set private field on non-instance");
11
+ }
12
+ privateMap.set(receiver, value);
13
+ return value;
14
+ };
15
+ var _layoutManager;
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.LayoutModule = void 0;
18
+ const Instance_1 = require("./Instance");
19
+ const base_1 = require("../../base");
20
+ /**
21
+ * InitLayoutOptions interface
22
+ * @typedef { object } InitLayoutOptions
23
+ * @property { string } [containerId] The id attribute of the container where the window's Layout should be initialized. If not provided
24
+ * then an element with id `layout-container` is used. We recommend using a div element.
25
+ */
26
+ /**
27
+ * PresetLayoutOptions interface
28
+ * @typedef { object } PresetLayoutOptions
29
+ * @property { LayoutPresetTypes } presetType Which preset layout arrangement to use.
30
+ * The preset options are `columns`, `grid`, `rows`, and `tabs`.
31
+ */
32
+ /**
33
+ * LayoutConfig interface
34
+ * @typedef { object } LayoutConfig
35
+ * @property { Array<LayoutItem> } content Content of the layout. There can only be one top-level LayoutItem in the content array.
36
+ * We do not recommend trying to build Layouts or LayoutItems by hand and instead use calls such as {@link Platform#getSnapshot getSnapshot}
37
+ * or our {@link https://openfin.github.io/golden-prototype/config-gen Layout Config Generation Tool }.
38
+ * @property { LayoutSettings } settings Configuration for certain Layout behaviors. See the LayoutSettings interface.
39
+ */
40
+ /**
41
+ * LayoutItem Interface
42
+ * @typedef { object } LayoutItem Represents the arrangement of Views within a Platform window's Layout. We do not recommend trying
43
+ * to build Layouts or LayoutItems by hand and instead use calls such as {@link Platform#getSnapshot getSnapshot} or our
44
+ * {@link https://openfin.github.io/golden-prototype/config-gen Layout Config Generation Tool }.
45
+ * @property { string } type The type of the item. Possible values are 'row', 'column', 'stack', and 'component'.
46
+ * @property { Array<LayoutItem> } [content] An array of configurations for items that will be created as children of this item.
47
+ * @property { string } [componentName] Only a `component` type will have this property and it should be set to `view`.
48
+ * @property { View~options } [componentState] Only a `component` type will have this property and it represents the view
49
+ * options of a given component.
50
+ */
51
+ /**
52
+ * LayoutSettings Interface
53
+ * @typedef { object } LayoutSettings Represents a potential ways to customize behavior of your Layout
54
+ * @property { boolean } [constrainDragToHeaders=false] Limits the area to which tabs can be dragged.
55
+ * If true, stack headers are the only areas where tabs can be dropped.
56
+ * @property { boolean } [hasHeaders=true] Turns tab headers on or off.
57
+ * If false, the layout will be displayed with splitters only.
58
+ * @property {object} [newTabButton]
59
+ * Configuration of the Plus button that appears on each tabstrip. Upon pressing, a new tab
60
+ * will be added to the tabstrip with the specified url.
61
+ * @property {string} [newTabButton.url] Specifies the url that opens in the tab created upon pressing the button.
62
+ * @property { boolean } [popoutWholeStack=false] Whether the popout button will only act on the entire stack,
63
+ * as opposed to only the active tab.
64
+ * @property { boolean } [preventDragIn=false] If true, tabs can't be dragged into the window.
65
+ * @property { boolean } [preventDragOut=false] If true, tabs can't be dragged out of the window.
66
+ * @property { boolean } [preventSplitterResize=false] If true, tab contents can't be resized by the user.
67
+ * @property { boolean } [reorderEnabled=true] If true, the user can re-arrange the layout by
68
+ * dragging items by their tabs to the desired location.
69
+ * @property { boolean } [showCloseIcon=false] Whether to show the close button on stack header
70
+ * (not to be confused with close button on every tab).
71
+ * @property { boolean } [showMaximiseIcon=false] Whether to show the maximize button on stack header.
72
+ * The button will maximize the current tab to fill the entire window.
73
+ * @property { boolean } [showPopoutIcon=false] Whether to show the popout button on stack header.
74
+ * The button will create a new window with current tab as its content.
75
+ * In case `popoutWholeStack` is set to true, all tabs in the stack will be in the new window.
76
+ */
77
+ /**
78
+ * @lends Platform#Layout
79
+ */
80
+ class LayoutModule extends base_1.Base {
81
+ constructor() {
82
+ super(...arguments);
83
+ _layoutManager.set(this, void 0);
84
+ /**
85
+ * Initialize the window's Layout. Must be called from a custom window that has a 'layout' option set upon creation of that window.
86
+ * If a containerId is not provided, this method attempts to find an element with the id `layout-container`.
87
+ * A Layout will <a href="tutorial-Layout.DOMEvents.html">emit events locally</a> on the DOM element representing the layout-container.
88
+ * In order to capture the relevant events during Layout initiation, set up the listeners on the DOM element prior to calling `init`.
89
+ * @param { InitLayoutOptions } [options] - Layout init options.
90
+ * @return { Promise<Layout> }
91
+ * @static
92
+ * @experimental
93
+ * @tutorial Layout.init
94
+ */
95
+ this.init = async (options = {}) => {
96
+ this.wire.sendAction('layout-init').catch((e) => {
97
+ // don't expose
98
+ });
99
+ if (!this.fin.me.isWindow) {
100
+ throw new Error('Layout.init can only be called from a Window context.');
101
+ }
102
+ else if (__classPrivateFieldGet(this, _layoutManager)) {
103
+ throw new Error('Layout for this window already initialized, please use Layout.replace call to replace the layout.');
104
+ }
105
+ // We need to go through environment to make sure it is only imported/bundled in OpenFin.
106
+ const ManagerConstructor = await this.wire.environment.getManagerConstructor();
107
+ __classPrivateFieldSet(this, _layoutManager, new ManagerConstructor());
108
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
109
+ // @ts-ignore - layout warning here for backwards compatibility, can remove layout check in .52
110
+ let { layout, containerId } = options;
111
+ if (layout) {
112
+ console.warn(`We recommend using a layout in window options.
113
+ This layout has not been sanitized and unexpected behavior can occur.`);
114
+ }
115
+ layout = layout || (await this.fin.Window.getCurrentSync().getOptions()).layout;
116
+ containerId = containerId || 'layout-container';
117
+ const container = document.getElementById(containerId);
118
+ // Should we error here if there is no container? Getting a typescript complaint on createLayout
119
+ // override here
120
+ // pull createChannelConnection out of LayoutManager and setup channel connections here using layoutmanager instance methods?
121
+ await __classPrivateFieldGet(this, _layoutManager).initManager();
122
+ await __classPrivateFieldGet(this, _layoutManager).createLayout(layout, container);
123
+ // Adding this to the returned instance undocumented/typed for Browser.
124
+ return Object.assign(this.getCurrentSync(), { layoutManager: __classPrivateFieldGet(this, _layoutManager) });
125
+ };
126
+ }
127
+ /**
128
+ * Asynchronously returns a Layout object that represents a Window's layout.
129
+ * @param { Identity } identity
130
+ * @return {Promise.<Layout>}
131
+ * @tutorial Layout.wrap
132
+ * @static
133
+ */
134
+ // eslint-disable-next-line class-methods-use-this
135
+ async wrap(identity) {
136
+ this.wire.sendAction('layout-wrap').catch((e) => {
137
+ // don't expose
138
+ });
139
+ return new Instance_1.Layout(identity, this.wire);
140
+ }
141
+ /**
142
+ * Synchronously returns a Layout object that represents a Window's layout.
143
+ * @param { Identity } identity
144
+ * @return {Layout}
145
+ * @tutorial Layout.wrapSync
146
+ * @static
147
+ */
148
+ // eslint-disable-next-line class-methods-use-this
149
+ wrapSync(identity) {
150
+ this.wire.sendAction('layout-wrap-sync').catch((e) => {
151
+ // don't expose
152
+ });
153
+ return new Instance_1.Layout(identity, this.wire);
154
+ }
155
+ /**
156
+ * Asynchronously returns a Layout object that represents a Window's layout.
157
+ * @return {Promise.<Layout>}
158
+ * @tutorial Layout.getCurrent
159
+ * @static
160
+ */
161
+ async getCurrent() {
162
+ this.wire.sendAction('layout-get-current').catch((e) => {
163
+ // don't expose
164
+ });
165
+ if (!this.fin.me.isWindow) {
166
+ throw new Error('You are not in a Window context. Only Windows can have a Layout.');
167
+ }
168
+ const { uuid, name } = this.fin.me;
169
+ return this.wrap({ uuid, name });
170
+ }
171
+ /**
172
+ * Synchronously returns a Layout object that represents a Window's layout.
173
+ * @return {Layout}
174
+ * @tutorial Layout.getCurrentSync
175
+ * @static
176
+ */
177
+ getCurrentSync() {
178
+ this.wire.sendAction('layout-get-current-sync').catch((e) => {
179
+ // don't expose
180
+ });
181
+ if (!this.fin.me.isWindow) {
182
+ throw new Error('You are not in a Window context. Only Windows can have a Layout.');
183
+ }
184
+ const { uuid, name } = this.fin.me;
185
+ return this.wrapSync({ uuid, name });
186
+ }
187
+ }
188
+ exports.LayoutModule = LayoutModule;
189
+ _layoutManager = new WeakMap();