@finsemble/finsemble-ui 8.4.0-beta.1 → 8.4.0

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 (72) hide show
  1. package/clients/Interop/FinsembleDesktopAgent.d.ts.map +1 -1
  2. package/clients/Interop/FinsembleDesktopAgent.js +5 -8
  3. package/clients/Interop/FinsembleDesktopAgent.js.map +1 -1
  4. package/clients/Startup/FSBLDesktop.d.ts +1 -1
  5. package/clients/Startup/FSBLDesktop.d.ts.map +1 -1
  6. package/clients/Startup/FSBLDesktop.js +1 -1
  7. package/clients/Startup/FSBLDesktop.js.map +1 -1
  8. package/clients/Startup/windowStartup.d.ts.map +1 -1
  9. package/clients/Startup/windowStartup.js +54 -2
  10. package/clients/Startup/windowStartup.js.map +1 -1
  11. package/clients/appsClient.d.ts +394 -55
  12. package/clients/appsClient.d.ts.map +1 -1
  13. package/clients/appsClient.js +628 -30
  14. package/clients/appsClient.js.map +1 -1
  15. package/clients/configClient.d.ts +16 -3
  16. package/clients/configClient.d.ts.map +1 -1
  17. package/clients/configClient.js +17 -4
  18. package/clients/configClient.js.map +1 -1
  19. package/clients/launcherClient.d.ts +65 -334
  20. package/clients/launcherClient.d.ts.map +1 -1
  21. package/clients/launcherClient.js +35 -601
  22. package/clients/launcherClient.js.map +1 -1
  23. package/clients/notificationClient.d.ts +13 -6
  24. package/clients/notificationClient.d.ts.map +1 -1
  25. package/clients/notificationClient.js +13 -6
  26. package/clients/notificationClient.js.map +1 -1
  27. package/deprecated/deprecatedFunctions.js +2 -2
  28. package/deprecated/deprecatedFunctions.js.map +1 -1
  29. package/deprecated/deprecatedlauncherClient.d.ts +1 -1
  30. package/deprecated/deprecatedlauncherClient.d.ts.map +1 -1
  31. package/deprecated/deprecatedlauncherClient.js.map +1 -1
  32. package/deprecated/dragAndDropClient.d.ts.map +1 -1
  33. package/deprecated/dragAndDropClient.js +14 -4
  34. package/deprecated/dragAndDropClient.js.map +1 -1
  35. package/main.d.ts +113 -106
  36. package/main.d.ts.map +1 -1
  37. package/main.js +1 -1
  38. package/main.js.map +1 -1
  39. package/package.json +2 -2
  40. package/platform/services/Interop/types.d.ts +6 -0
  41. package/platform/services/Interop/types.d.ts.map +1 -1
  42. package/platform/services/Interop/types.js.map +1 -1
  43. package/platform/services/systemManager/_constants.d.ts.map +1 -1
  44. package/platform/services/systemManager/_constants.js +1 -0
  45. package/platform/services/systemManager/_constants.js.map +1 -1
  46. package/platform/services/systemManager/types.d.ts +1 -1
  47. package/platform/services/systemManager/types.d.ts.map +1 -1
  48. package/platform/services/systemManager/types.js.map +1 -1
  49. package/platform/services/window/modules/actions.d.ts +4 -0
  50. package/platform/services/window/modules/actions.d.ts.map +1 -1
  51. package/platform/services/window/modules/actions.js +1 -0
  52. package/platform/services/window/modules/actions.js.map +1 -1
  53. package/react/assets/css/fonts/icons-reference.html +1 -1
  54. package/react/assets/css/windowTitleBar.css +4 -1
  55. package/react/components/search/SearchResults.d.ts.map +1 -1
  56. package/react/components/search/SearchResults.js +6 -6
  57. package/react/components/search/SearchResults.js.map +1 -1
  58. package/react/components/singleInputDialog/SingleInputDialog.d.ts.map +1 -1
  59. package/react/components/singleInputDialog/SingleInputDialog.js +5 -3
  60. package/react/components/singleInputDialog/SingleInputDialog.js.map +1 -1
  61. package/react/components/toolbar/DragHandle.d.ts.map +1 -1
  62. package/react/components/toolbar/DragHandle.js +8 -5
  63. package/react/components/toolbar/DragHandle.js.map +1 -1
  64. package/react/components/userPreferences/components/content/Workspaces.d.ts +5 -0
  65. package/react/components/userPreferences/components/content/Workspaces.d.ts.map +1 -1
  66. package/react/components/userPreferences/components/content/Workspaces.js +14 -1
  67. package/react/components/userPreferences/components/content/Workspaces.js.map +1 -1
  68. package/react/hooks/useInjectedTitleBar.d.ts.map +1 -1
  69. package/react/hooks/useInjectedTitleBar.js +92 -20
  70. package/react/hooks/useInjectedTitleBar.js.map +1 -1
  71. package/typedefs/FDC3/api/AppMetadata.d.ts +1 -0
  72. package/typedefs/FDC3/api/AppMetadata.d.ts.map +1 -1
@@ -1,5 +1,599 @@
1
- import LauncherClient from "./launcherClient";
2
- import { Logger } from "./logger";
1
+ /*!
2
+ * Copyright 2017 - 2023 by Finsemble, Inc.
3
+ * All rights reserved.
4
+ */
5
+ /**
6
+ * The Apps Client (formerly known as the Launcher Client) handles spawning
7
+ * apps and app services, and auxiliary functions such as adding or removing
8
+ * them from config dynamically or retrieving details of running instances
9
+ * (active descriptors).
10
+ *
11
+ * The AppsClient API has capabilities to customize your end user's experience,
12
+ * by altering the apps available to them or customizing them at launch. For
13
+ * example, it can apply custom CSS-like positioning and fully display-aware
14
+ * positioning that deals with idiosyncrasies such as monitors with different
15
+ * scaling resolutions.
16
+ *
17
+ * CSS provides higher level abstractions that help lay out an application
18
+ * that consists of constituent parts.
19
+ * Finsemble has borrowed CSS’s positioning paradigm and applied it to the task
20
+ * of laying out windows on the desktop.
21
+ * For example, this CSS-style positioning allows windows to be positioned on the `left`,
22
+ * `right`, `top`, or `bottom` of the end user’s screen. We've
23
+ * also developed new positions, such as `adjacent`, which allows a child
24
+ * window to spawn adjacent to their parent or another application.
25
+ *
26
+ * Application windows can also be positioned and sized by percentage, relative
27
+ * to the monitor or to each other.
28
+ *
29
+ * The Apps Client frequently uses the parameters <code>windowName</code> and <code>componentType</code>. [Learn more about them here](/docs/productivity/componentTypesAndWindowNames).
30
+ * @module AppsClient
31
+ */
32
+ import { getMyWindowIdentifier as getMyWindowIdentifierUtil, clone } from "../common/util";
33
+ import Logger from "./logger";
34
+ import { FinsembleWindow } from "../common/FinsembleWindow";
35
+ import { RouterClient } from "./routerClient";
36
+ import SystemManagerClient from "../common/systemManagerClient";
37
+ import { getAllMonitorsClientSide, getWhichMonitorClientSide, } from "../common/Monitors";
38
+ import { registerComponent, unRegisterComponent, getMonitor, getActiveAndPendingWindowNames, getPendingWindows, getComponentsThatCanReceiveDataTypes, hyperFocus, createWindowGroup, addWindowsToGroup, removeWindowsFromGroup, getGroupsForWindow, addToGroups, } from "../deprecated/deprecatedlauncherClient";
39
+ import { bringWindowsToFront, minimizeWindows } from "../common/Desktop";
40
+ import { isMouseOverDOMElement } from "../common/util";
41
+ // A map of related menus that is kept by handleToggle.
42
+ const okayToOpenMenu = {};
43
+ /**
44
+ * Utility function that converts a WindowLocator into a WindowIdentifier.
45
+ * @param locator The window locator Object to convert
46
+ * @returns WindowIdentifier
47
+ */
48
+ const locatorToIdentifier = (locator) => {
49
+ let windowIdentifier = {};
50
+ if ("windowName" in locator) {
51
+ windowIdentifier.windowName = locator.windowName;
52
+ }
53
+ else {
54
+ windowIdentifier.windowName = "";
55
+ }
56
+ if ("componentType" in locator) {
57
+ windowIdentifier.componentType = locator.componentType;
58
+ }
59
+ if ("uuid" in locator) {
60
+ windowIdentifier.uuid = locator.uuid;
61
+ }
62
+ return windowIdentifier;
63
+ };
64
+ /**
65
+ * Get a list of registered components from <i>components.json</i>.
66
+ *
67
+ * ```javascript
68
+ * const {err, data} = await FSBL.Clients.AppsClient.getComponentList();
69
+ * if(!err){
70
+ * console.log(data);
71
+ * // {
72
+ * // "Toolbar": { ... },
73
+ * // "Tour": { ... },
74
+ * // ...
75
+ * // }
76
+ * }
77
+ * ```
78
+ *
79
+ * @param cb Callback returns an object map of components. Each component object
80
+ * contains the default config for that component.
81
+ */
82
+ export const getComponentList = async (cb) => {
83
+ await SystemManagerClient.waitForStartup("windowService");
84
+ const { err, response } = await RouterClient.query("Launcher.componentList", {});
85
+ cb === null || cb === void 0 ? void 0 : cb(err, response.data);
86
+ return { err, data: response.data };
87
+ };
88
+ /**
89
+ * Get the component config for a specific component from <i>components.json</i>.
90
+ *
91
+ * ```javascript
92
+ * const {err, data} = await FSBL.Clients.AppsClient.getComponentDefaultConfig("ChartIQ Example App");
93
+ * ```
94
+ *
95
+ * @param componentType The type of the component.
96
+ * @param cb Callback returns the default config (windowDescriptor) for the requested componentType.
97
+ */
98
+ export const getComponentDefaultConfig = async (componentType, cb) => {
99
+ const { err, data } = await getComponentList();
100
+ const componentDescriptor = data === null || data === void 0 ? void 0 : data[componentType];
101
+ cb === null || cb === void 0 ? void 0 : cb(err, componentDescriptor);
102
+ return { err, data: componentDescriptor };
103
+ };
104
+ /**
105
+ * Get monitorInfo (dimensions and position) for all monitors. Returns an array of monitorInfo objects. See <a href="/docs/reference/typedocs/modules/AppsClient#getMonitorInfo">AppsClient#getMonitorInfo</a> for the format of a monitorInfo object.
106
+ *
107
+ * ```javascript
108
+ * const {err, data} = await FSBL.Clients.AppsClient.getMonitorInfoAll();
109
+ * if(!err){
110
+ * console.log(`There are ${data.length} monitors.`);
111
+ * }
112
+ * ```
113
+ *
114
+ * @param cb Returns an array of monitorInfo objects.
115
+ */
116
+ export const getMonitorInfoAll = async (cb) => {
117
+ Logger.system.debug("AppsClient.getMonitorInfoAll()");
118
+ return getAllMonitorsClientSide(RouterClient, cb);
119
+ };
120
+ /**
121
+ * Get monitor information for a given windowIdentifier or for a specific monitor.
122
+ * If neither the identifier nor monitor are provided, returns the monitorInfo for the current window.
123
+ *
124
+ *
125
+ * The information returned contains:
126
+ *
127
+ * **monitorRect** - The full dimensions for the monitor. <br/>
128
+ * **availableRect** - The dimensions for the available space on the monitor (not including the Windows task bar). <br/>
129
+ * **position** - A number that represents the position of the monitor. The primary monitor is zero. <br/>
130
+ * **whichMonitor** - Contains the string "primary" if it is the primary monitor. <br/>
131
+ *
132
+ * The dimensions are supplemented with the following additional members:
133
+ *
134
+ * **width** - The width calculated as right - left. <br/>
135
+ * **height** - The height calculated as bottom - top. <br/>
136
+ *
137
+ * ```javascript
138
+ * // Get the info for the monitor that the calling app is on
139
+ * const {err, data} = await FSBL.Clients.AppsClient.getMonitorInfo();
140
+ * if(!err){
141
+ * console.log(data);
142
+ * // Example results:
143
+ * // {
144
+ * // availableRect: {width, height, bottom, left, ...},
145
+ * // deviceId: "123456",
146
+ * // deviceScaleFactor: 2,
147
+ * // displayDeviceActive: true,
148
+ * // monitor: {dipRect, scaledRect},
149
+ * // monitorRect: {width, height, bottom, left, right, ...}
150
+ * // name: "device0",
151
+ * // position: 0,
152
+ * // taskbar: {top, left, right, bottom, width, ...}
153
+ * // whichMonitor: "primary"
154
+ * // }
155
+ * }
156
+ *
157
+ * // Get monitor info for a given window
158
+ * const {err, data} = await FSBL.Clients.AppsClient.getMonitorInfo({
159
+ * windowIdentifier: {
160
+ * windowName: "ABC-uuid"
161
+ * }
162
+ * });
163
+ * if(!err){
164
+ * console.log(`App ABC-uuid is currently on the monitor with index ${data.position}`);
165
+ * }
166
+ *
167
+ * // Get the dimensions of the first non-primary monitor
168
+ * const {err, data} = await FSBL.Clients.AppsClient.getMonitorInfo({monitor: 1});
169
+ * if(!err){
170
+ * console.log("Available dimensions for monitor[1]: ", data.monitorRect);
171
+ * console.log("Available dimensions, minus claimed space, for monitor[1]: ", data.availableRect);
172
+ * }
173
+ * ```
174
+ *
175
+ * @param params
176
+ * @param params.windowIdentifier The windowIdentifier to get the monitorInfo. If undefined, this points to the current window.
177
+ * @param params.monitor If passed then a specific monitor is identified. Valid values include:
178
+ *
179
+ * <b>"mine"</b> - Place the window on the same monitor as the calling window.
180
+ *
181
+ * Integer value from 0-n (0 being the primary monitor).
182
+ *
183
+ * <b>"primary"</b> indicates the user's primary monitor.
184
+ *
185
+ * <b>"all"</b> - Put a copy of the component on each monitor.
186
+ * @param cb Returns a monitorInfo object containing the monitorRect and availableRect.
187
+ *
188
+ * @returns A promise that resolves to a monitorInfo.
189
+ */
190
+ export const getMonitorInfo = async (params = {}, cb) => {
191
+ Logger.system.debug("AppsClient.getMonitorInfo()");
192
+ if (params.monitor === "all") {
193
+ Logger.deprecated(`Use of type "all" in AppsClient.getMonitorInfo() is deprecated. Please use AppsClient.getMonitorInfoAll()`);
194
+ return getMonitorInfoAll(cb);
195
+ }
196
+ return getWhichMonitorClientSide(RouterClient, params, cb);
197
+ };
198
+ /**
199
+ * Displays a window and relocates/resizes it according to the values contained in parameters. If the specified window is in a group or tabbed, it is unsnapped/ungrouped/untabbed from the other windows.
200
+ * If invoked on a tabbed window or a window in a group, the window is removed from the tab/group.
201
+ *
202
+ * Caution: A window can inherit parameters only once, at the time when it’s spawned. When the component already exists, changing parameters other than positioning arguments (monitor, relativeWindow, top, bottom, left, right, width, height) has no effect.
203
+ *
204
+ * ```javascript
205
+ * FSBL.Clients.AppsClient.showWindow({windowName: "Welcome Component-86-3416-Finsemble", componentType: "Welcome Component"}, {spawnIfNotFound: true}, (err, data)=> {});
206
+ * ```
207
+ * @param windowIdentifier A windowIdentifier. This is an object containing windowName and componentType. If you dont' speciry windowName, Finsemble tries to find it by componentType.
208
+ * @param params Configuration settings from the <i><a href="/docs/reference/ConfigReference#finsemble-appd---manifest-window">finsemble.appd[].manifest.window</a></i> section of the application manifest may be used as parameters to this function, except for the `options` element.
209
+ * These are the same as <a href="/docs/reference/typedocs/modules/AppsClient#spawn">AppsClient.spawn()</a> with the following exceptions:
210
+ * <ul>
211
+ * <li><b>monitor</b> - Same as spawn() except that null or undefined means don't move the window to a different monitor.</li>
212
+ * <li><b>left</b> - Same as spawn() except that null or undefined means don't move the window from current horizontal location.</li>
213
+ * <li><b>top</b> - Same as spawn() except that null or undefined means don't move the window from current vertical location.</li>
214
+ * <li><b>slave</b> - Cannot be set for an existing window. Goes into effect only if the window is spawned. In other words, use this only in conjunction with spawnIfNotFound.</li>
215
+ * <li><b>spawnIfNotFound</b> - If true, spawns a new window if the requested one cannot be found. Note: only works if the windowIdentifier contains a componentType.</li>
216
+ * <li><b>autoFocus</b> - Whether or not the window should be in focus when shown.</li>
217
+ * </ul>
218
+ * @param cb Callback to be invoked after the function is completed regardless of whether the call fails or succeeds.
219
+ * Callback contains two arguments in the following order:
220
+ * <ol>
221
+ * <li><b>error</b>: an object containing details related to the reason the call failed and where the exception occurred. This object is null if the call has succeeded.</li>
222
+ * <li><b>data</b>: an object with the following information:
223
+ * <ul>
224
+ * <li><b>windowIdentifier</b> - The <a href="/docs/productivity/componentTypesAndWindowNames">WindowIdentifier</a> for the new window.</li>
225
+ * <li><b>windowDescriptor</b> - The <a href="/docs/productivity/componentTypesAndWindowNames">WindowDescriptor</a> of the new window.</li>
226
+ * <li><b>finWindow</b> - A <code>finWindow</code> object referencing the new window.</li>
227
+ * </ul>
228
+ * </li>
229
+ * </ol>
230
+ */
231
+ export const showWindow = async (windowLocator, params, cb) => {
232
+ if (!params) {
233
+ params = {};
234
+ }
235
+ params = clone(params);
236
+ if (!params.staggerPixels && params.staggerPixels !== 0) {
237
+ params.staggerPixels = 100;
238
+ }
239
+ params.windowIdentifier = locatorToIdentifier(windowLocator);
240
+ const myWindowIdentifier = await getMyWindowIdentifierUtil();
241
+ if (!params.relativeWindow) {
242
+ params.relativeWindow = myWindowIdentifier;
243
+ }
244
+ await SystemManagerClient.waitForStartup("windowService");
245
+ const { err, response } = await RouterClient.query("Launcher.showWindow", params);
246
+ if (err) {
247
+ cb === null || cb === void 0 ? void 0 : cb(err);
248
+ return { err };
249
+ }
250
+ else {
251
+ const name = response.data.windowIdentifier.windowName;
252
+ const { wrap: finWindow } = await FinsembleWindow.getInstance({
253
+ name,
254
+ });
255
+ const data = Object.assign(Object.assign({}, response.data), { windowIdentifier: Object.assign(Object.assign({}, response.data.windowIdentifier), { name }), finWindow });
256
+ cb === null || cb === void 0 ? void 0 : cb(err, data);
257
+ return { err, data: data };
258
+ }
259
+ };
260
+ /**
261
+ * A convenient method for dealing with a common use case of toggling the appearance and disappearance of a child window when a user presses a button of a dropdown menus.
262
+ * Call this method from the click handler for your element. Your child window needs to close itself on blur events.
263
+ * Caution: A window can inherit parameters only once, at the time when it’s spawned. When the component already exists, changing parameters other than positioning arguments (monitor, relativeWindow, top, bottom, left, right, width, height) has no effect.
264
+ * @param element The DOM element, or selector, clicked by the end user.
265
+ * @param windowIdentifier Identifies the child window
266
+ * @param params Parameters to be passed to <a href="/docs/reference/typedocs/modules/AppsClient#showWindow">AppsClient.showWindow()</a> if the child window is allowed to open
267
+ */
268
+ export const toggleWindowOnClick = (element, windowLocator, params) => {
269
+ var _a, _b;
270
+ const windowIdentifier = locatorToIdentifier(windowLocator);
271
+ const key = (_b = (_a = windowIdentifier.windowName) !== null && _a !== void 0 ? _a : windowIdentifier.componentType) !== null && _b !== void 0 ? _b : "";
272
+ // If the element was clicked while the menu was open, return right away. The menu window receives a blur event and closes.
273
+ // This method is dependent on the fact that blur events are processed before click events.
274
+ // If this turns out to be a problem, put this call inside of a setTimeout().
275
+ if (okayToOpenMenu[key] === false) {
276
+ okayToOpenMenu[key] = true;
277
+ return;
278
+ }
279
+ const onDisplayed = (showError, showResponse) => {
280
+ if (!showResponse)
281
+ return;
282
+ const { finWindow } = showResponse;
283
+ const onBlur = () => {
284
+ okayToOpenMenu[key] = true;
285
+ isMouseOverDOMElement(element, (mouseIsOverElement) => {
286
+ okayToOpenMenu[key] = !mouseIsOverElement;
287
+ });
288
+ finWindow.removeEventListener("blurred", onBlur);
289
+ };
290
+ finWindow.addEventListener("blurred", onBlur);
291
+ };
292
+ if (!params.position)
293
+ params.position = "absolute";
294
+ showWindow(windowLocator, params, onDisplayed);
295
+ };
296
+ const waitForReadySignal = (name) => new Promise((resolve) => {
297
+ // Wait for a definite message that the component is ready (that FSBL has been initialized in the spawned app).
298
+ const subscriberID = RouterClient.subscribe(`Finsemble.${name}.componentReady`, (error, response) => {
299
+ if (error || !response.data) {
300
+ Logger.system.error(`RouterClient.waitForReadySignal() Error subscribing for component ready state ${error}`);
301
+ resolve(error);
302
+ // Ignore the initial "uninitialized" state message delivered by subscribe (the one with an empty string).
303
+ }
304
+ else if (Object.keys(response.data).length) {
305
+ // A second message will arrive with the actual data. Now we know that the client has initialized and signaled its readiness.
306
+ RouterClient.unsubscribe(subscriberID);
307
+ resolve(null);
308
+ }
309
+ });
310
+ });
311
+ const callSpawn = async (params) => {
312
+ const { err, response } = await RouterClient.query("Launcher.spawn", params);
313
+ Logger.system.debug("CallSpawn", "Initial launcher callback params", err, response);
314
+ if (err || !response) {
315
+ const error = err !== null && err !== void 0 ? err : `Internal error: callSpawn(): No data returned from service for "Launcher.spawn"`;
316
+ return { err: error };
317
+ }
318
+ else {
319
+ const { data: spawnResponseData } = response;
320
+ if (spawnResponseData.stackedWindow) {
321
+ return { err: "Legacy stacked window spawn" };
322
+ }
323
+ let spawnedWindowNames = [];
324
+ let spawnResponse;
325
+ // If we receive an array of spawn response, it means we've spawned a launch group.
326
+ // We select the first spawn response as the result so that a finWindow is available.
327
+ // Additionally, we put all the window names in an array and assign it to a launchGroupWindows
328
+ // property to be placed in the result object so that we have all available window names for the
329
+ // launch group.
330
+ if (Array.isArray(spawnResponseData)) {
331
+ spawnedWindowNames = spawnResponseData.reduce((acc, curr) => {
332
+ acc.push(curr.windowIdentifier.windowName);
333
+ return acc;
334
+ }, []);
335
+ spawnResponse = spawnResponseData[0];
336
+ }
337
+ else {
338
+ spawnResponse = spawnResponseData;
339
+ }
340
+ const name = spawnResponse.windowIdentifier.windowName;
341
+ const { wrap: finWindow } = await FinsembleWindow.getInstance({
342
+ name,
343
+ });
344
+ const result = Object.assign(Object.assign({}, spawnResponse), { windowIdentifier: Object.assign(Object.assign({}, spawnResponse.windowIdentifier), { name }),
345
+ // Add a wrapped finWindow to the response. You can do this only on the client side.
346
+ finWindow });
347
+ // if we have an array of window names, it means spawn of launchGroup
348
+ // so lets add it to the result.
349
+ if (spawnedWindowNames.length > 0) {
350
+ result.launchGroupWindows = spawnedWindowNames;
351
+ }
352
+ Logger.system.debug("CallSpawn", "Waiting for ready signal", name);
353
+ const waitError = await waitForReadySignal(name);
354
+ Logger.system.debug("CallSpawn", "Got ready signal", name);
355
+ return { err: waitError, result };
356
+ }
357
+ };
358
+ /**
359
+ * Asks the Launcher service to spawn a new component. You can also specify any of the following parameters in <i>public/config/components.json</i>, which will
360
+ * then operate as the default for that value.
361
+ *
362
+ * The launcher parameters mimic CSS window positioning.
363
+ * For example, to set a full screen window, use `{left: 0, top: 0, right: 0, bottom: 0}`.
364
+ * This is functionally equivalent to `{left: 0, top: 0, width: "100%", height: "100%"}`.
365
+ *
366
+ * You can also spawn more than one component at a time by using a single action, such as clicking a button on a menu.
367
+ * See https://github.com/ChartIQ/finsemble-seed/tree/recipes/SpawnComponentGroup for an example of spawning a component group.
368
+ *
369
+ * ```javascript
370
+ * FSBL.Clients.AppsClient.spawn("Welcome Component", {left: 0, top: 0, position: "relative"}, (err, data)=> {});
371
+ * ```
372
+ * @param component The application or component to spawn.
373
+ * @param params Configuration settings from the <i><a href="/docs/reference/ConfigReference#finsemble-appd---manifest-window">finsemble.appd[].manifest.window</a></i> section of the application manifest may be used as parameters to this function, except for the `options` element.
374
+ * @param cb Function invoked after the window is created
375
+ */
376
+ export const spawn = async (component, params, cb) => {
377
+ if (!params) {
378
+ params = {};
379
+ }
380
+ params = clone(params);
381
+ params.component = component;
382
+ if (!params.options) {
383
+ params.options = {};
384
+ }
385
+ if (!params.options.customData) {
386
+ params.options.customData = {};
387
+ }
388
+ if (!params.staggerPixels && params.staggerPixels !== 0) {
389
+ params.staggerPixels = 50;
390
+ }
391
+ Logger.system.debug(`AppsClient.spawn starting for componentType:${component}`);
392
+ await SystemManagerClient.waitForStartup("windowService");
393
+ const windowIdentifier = await getMyWindowIdentifierUtil();
394
+ params.launchingWindow = windowIdentifier;
395
+ const { err, result: response } = await callSpawn(params);
396
+ Logger.system.debug(`AppsClient.spawn completing for componentType:${component}`, err);
397
+ cb === null || cb === void 0 ? void 0 : cb(err, response);
398
+ return { error: err, response: response };
399
+ };
400
+ /**
401
+ * Spawns a set of apps and assembles them into a tab collection. you can specify spawn parameters for the entire collection
402
+ * or for individual apps. However, positioning parameters (e.g. `left` or `top`) are disregarded when set on individual apps.
403
+ *
404
+ * ```javascript
405
+ * await FSBL.Clients.AppsClient.spawnTabCollection({
406
+ * componentList: [{appID: "Welcome Component", individualParams: { alwaysOnTop : true } }],
407
+ * globalParams: { left: 100, top: 100}
408
+ * });
409
+ * ```
410
+ * @param __namedParameters.componentList - The apps to open. Each should be an object that contains the appID (from AppD) and an optional set of SpawnParams.
411
+ * @param __namedParameters.globalParams - Positioning parameters for the collection. If omitted, the collection is spawned in a default location.
412
+ * @returns - Resolves to an object that contains the ID of the tab collection and the list of window names for the spawned apps
413
+ */
414
+ export const spawnTabCollection = async ({ componentList, globalParams, }, cb) => {
415
+ Logger.system.debug(`AppsClient.spawn starting for componentType: tabCollection`);
416
+ await SystemManagerClient.waitForStartup("windowService");
417
+ const windowIdentifier = await getMyWindowIdentifierUtil();
418
+ globalParams = globalParams !== null && globalParams !== void 0 ? globalParams : {};
419
+ globalParams.launchingWindow = windowIdentifier;
420
+ const { err, response } = await RouterClient.query("Launcher.spawnTabCollection", {
421
+ componentList,
422
+ globalParams,
423
+ });
424
+ const { id, windows } = response.data;
425
+ let result = {
426
+ id: id,
427
+ windows: [],
428
+ };
429
+ for (const res of windows) {
430
+ const name = res.windowIdentifier.windowName;
431
+ const { wrap: finWindow } = await FinsembleWindow.getInstance({
432
+ name,
433
+ });
434
+ result.windows.push(Object.assign(Object.assign({}, res), { windowIdentifier: Object.assign(Object.assign({}, res.windowIdentifier), { name }),
435
+ // Add a wrapped finWindow to the response (this can only be done client side)
436
+ finWindow }));
437
+ }
438
+ Logger.system.debug(`AppsClient.spawn completing for tabCollection`, err);
439
+ cb === null || cb === void 0 ? void 0 : cb(err, result);
440
+ return { err: err, data: result };
441
+ };
442
+ /**
443
+ * Returns a windowIdentifier for the current window.
444
+ *
445
+ * ```javascript
446
+ * const myWindowIdentifier = await FSBL.Clients.AppsClient.getMyWindowIdentifier();
447
+ * console.log(myWindowIdentifier);
448
+ * // {
449
+ * // windowName: "ABC-uuid",
450
+ * // componentType: "ABC"
451
+ * // }
452
+ * ```
453
+ *
454
+ * @param cb Callback function returns windowIdentifier for this window. (Optional or use the returned Promise)
455
+ * @returns A promise that resolves to a windowIdentifier.
456
+ */
457
+ export const getMyWindowIdentifier = async (cb) => {
458
+ const wi = await getMyWindowIdentifierUtil();
459
+ cb === null || cb === void 0 ? void 0 : cb(wi);
460
+ return wi;
461
+ };
462
+ /**
463
+ * Gets the windowDescriptor for all open windows.
464
+ *
465
+ * :::note
466
+ * This returns descriptors even if the window is not part of the workspace.
467
+ * :::
468
+ *
469
+ * ```javascript
470
+ * FSBL.Clients.AppsClient.getActiveDescriptors(function (error, response) {
471
+ * if (error) {
472
+ * Logger.system.error("Error getting active descriptors: ", + JSON.stringify(error));
473
+ * } else {
474
+ * const activeDescriptors = response;
475
+ * //{
476
+ * // ...
477
+ * // Toolbar-1-Finsemble: {...},
478
+ * // Welcome-Component-80-6453-Finsemble: {...},
479
+ * // ...
480
+ * //}
481
+ * }
482
+ * });
483
+ * ```
484
+ * @param cb Callback returns an object containing windowDescriptors keyed by name.
485
+ */
486
+ export const getActiveDescriptors = async (cb) => {
487
+ await SystemManagerClient.waitForStartup("windowService");
488
+ const { err, response } = await RouterClient.query("Launcher.getActiveDescriptors", {});
489
+ if (err)
490
+ Logger.system.error(err);
491
+ cb === null || cb === void 0 ? void 0 : cb(err, response.data);
492
+ return { err, data: response.data };
493
+ };
494
+ /**
495
+ * @private Adds a custom component.
496
+ * @ignore
497
+ */
498
+ export const addUserDefinedComponent = async (params, cb) => {
499
+ await SystemManagerClient.waitForStartup("windowService");
500
+ const { err } = await RouterClient.query("Launcher.userDefinedComponentUpdate", {
501
+ type: "add",
502
+ name: params.name,
503
+ url: params.url,
504
+ });
505
+ if (err)
506
+ Logger.system.error(err);
507
+ cb === null || cb === void 0 ? void 0 : cb(err);
508
+ return { err };
509
+ };
510
+ /**
511
+ * @private Adds a custom component.
512
+ * @ignore
513
+ */
514
+ export const removeUserDefinedComponent = async (params, cb) => {
515
+ await SystemManagerClient.waitForStartup("windowService");
516
+ const { err } = await RouterClient.query("Launcher.userDefinedComponentUpdate", {
517
+ type: "remove",
518
+ name: params.name,
519
+ url: params.url,
520
+ });
521
+ if (err)
522
+ Logger.system.error(err);
523
+ cb === null || cb === void 0 ? void 0 : cb(err);
524
+ return { err };
525
+ };
526
+ /**
527
+ * Adds to Finsemble new FDC3 App definition(s), in the form of an array of FDC3 2.0 AppD
528
+ * records. After the apps are added, a user can launch them via the Apps
529
+ * Client, `fdc3.open`, `fdc3.raiseIntent` or Toolbar launcher menus.
530
+ *
531
+ * ```javascript
532
+ * const {err, data} = await FSBL.Clients.AppsClient.addApps([anFDC3App]);
533
+ * ```
534
+ *
535
+ * @param apps he array of FDC3 2.0 AppD records (`FDC3AppDefinition`) to add to Finsemble.
536
+ * @param cb The callback to be invoked after the apps are set or on error.
537
+ */
538
+ export const addApps = async (apps, cb) => {
539
+ if (!Array.isArray(apps)) {
540
+ const err = "The input was not an array. Pass an array of type: FDC3AppDefinition[] (including if only adding a single app)";
541
+ cb === null || cb === void 0 ? void 0 : cb(err);
542
+ return { err };
543
+ }
544
+ const { err, response } = await RouterClient.query("configService.addApps", apps);
545
+ cb === null || cb === void 0 ? void 0 : cb(err, response.data);
546
+ return { err, data: response.data };
547
+ };
548
+ /**
549
+ * Removes from Finsemble one or more apps,specified via an array of `appId` values.
550
+ * After an app is removed, it can no longer be launched via the
551
+ * AppsClient, `fdc3.open`, `fdc3.raiseIntent` or launcher menus. Removed
552
+ * applications are automatically removed from launcher menus.
553
+ *
554
+ * Existing instances of the apps are NOT closed automatically when removed,
555
+ * either from the current workspace or saved workspaces. However, saved
556
+ * workspaces containing them are unable to launch them when the workspace
557
+ * is loaded.
558
+ *
559
+ * ```javascript
560
+ * const {err, data} = await FSBL.Clients.AppsClient.removeApps(["fdc3AppId"]);
561
+ * ```
562
+ *
563
+ * @param apps The array of appIds to remove
564
+ * @param cb The callback to be invoked after the apps are removed or on error.
565
+ *
566
+ */
567
+ export const removeApps = async (appIds, cb) => {
568
+ if (!Array.isArray(appIds)) {
569
+ const err = "The input was not an array. Pass an array of string appIds to remove (including if only removing a single app)";
570
+ cb === null || cb === void 0 ? void 0 : cb(err);
571
+ return { err };
572
+ }
573
+ const { err, response } = await RouterClient.query("configService.removeApps", appIds);
574
+ cb === null || cb === void 0 ? void 0 : cb(err, response.data);
575
+ return { err, data: response.data };
576
+ };
577
+ /**
578
+ * Retrieves the AppD records for a specified list `appIds` known to Finsemble.
579
+ *
580
+ * @param appIds an array of app IDs to retrieve. If not provided, Finsemble retrieves all apps.
581
+ * @param cb The callback to be invoked after the apps are retrieved or on error.
582
+ * @returns A promise that resolves to an array of app objects.
583
+ */
584
+ export const getApps = async (appIds, cb) => {
585
+ if (appIds && !Array.isArray(appIds)) {
586
+ const err = "The input was not an array. Pass an array of string appIds to fetch (including if only retrieving a single app)";
587
+ cb === null || cb === void 0 ? void 0 : cb(err);
588
+ return { err };
589
+ }
590
+ const { err, response } = await RouterClient.query("configService.getApps", appIds);
591
+ cb === null || cb === void 0 ? void 0 : cb(err, response.data);
592
+ return { err, data: response.data };
593
+ };
594
+ /**
595
+ * @ignore
596
+ */
3
597
  export const AppsClient = {
4
598
  /**
5
599
  * For backward compatibility
@@ -18,34 +612,38 @@ export const AppsClient = {
18
612
  Logger.system.deprecated("It is no longer necessary to call AppsClient.onReady()");
19
613
  cb === null || cb === void 0 ? void 0 : cb();
20
614
  },
21
- addToGroups: LauncherClient.addToGroups,
22
- getGroupsForWindow: LauncherClient.getGroupsForWindow,
23
- removeWindowsFromGroup: LauncherClient.removeWindowsFromGroup,
24
- addWindowsToGroup: LauncherClient.addWindowsToGroup,
25
- createWindowGroup: LauncherClient.createWindowGroup,
26
- minimizeWindows: LauncherClient.minimizeWindows,
27
- hyperFocus: LauncherClient.hyperFocus,
28
- bringWindowsToFront: LauncherClient.bringWindowsToFront,
29
- getComponentsThatCanReceiveDataTypes: LauncherClient.getComponentsThatCanReceiveDataTypes,
30
- removeUserDefinedComponent: LauncherClient.removeUserDefinedComponent,
31
- addUserDefinedComponent: LauncherClient.addUserDefinedComponent,
32
- getPendingWindows: LauncherClient.getPendingWindows,
33
- getActiveAndPendingWindowNames: LauncherClient.getActiveAndPendingWindowNames,
34
- getActiveDescriptors: LauncherClient.getActiveDescriptors,
35
- getMyWindowIdentifier: LauncherClient.getMyWindowIdentifier,
36
- getMonitor: LauncherClient.getMonitor,
37
- spawn: LauncherClient.spawn,
38
- toggleWindowOnClick: LauncherClient.toggleWindowOnClick,
39
- showWindow: LauncherClient.showWindow,
40
- unRegisterComponent: LauncherClient.unRegisterComponent,
41
- registerComponent: LauncherClient.registerComponent,
42
- getMonitorInfo: LauncherClient.getMonitorInfo,
43
- getMonitorInfoAll: LauncherClient.getMonitorInfoAll,
44
- getComponentDefaultConfig: LauncherClient.getComponentDefaultConfig,
45
- getComponentList: LauncherClient.getComponentList,
46
- addApps: LauncherClient.addApps,
47
- removeApps: LauncherClient.removeApps,
48
- getApps: LauncherClient.getApps,
615
+ addToGroups,
616
+ addUserDefinedComponent,
617
+ addWindowsToGroup,
618
+ bringWindowsToFront,
619
+ createWindowGroup,
620
+ getActiveAndPendingWindowNames,
621
+ getActiveDescriptors,
622
+ getComponentDefaultConfig,
623
+ getComponentList,
624
+ getComponentsThatCanReceiveDataTypes,
625
+ getGroupsForWindow,
626
+ getMonitor,
627
+ getMonitorInfo,
628
+ getMonitorInfoAll,
629
+ getMyWindowIdentifier,
630
+ getPendingWindows,
631
+ hyperFocus,
632
+ minimizeWindows,
633
+ registerComponent,
634
+ removeUserDefinedComponent,
635
+ removeWindowsFromGroup,
636
+ showWindow,
637
+ spawn,
638
+ spawnTabCollection,
639
+ toggleWindowOnClick,
640
+ unRegisterComponent,
641
+ addApps,
642
+ removeApps,
643
+ getApps,
49
644
  };
645
+ /**
646
+ * @ignore
647
+ */
50
648
  export default AppsClient;
51
649
  //# sourceMappingURL=appsClient.js.map