Skip to main content

Module: LauncherClient

The Launcher Client handles spawning windows of all kinds. Finsemble provides the architecture to launch, resize, and reposition any component, whether native, modern, or third-party.

The Launcher API has capabilities to customize your end user's experience. This includes CSS-like positioning and a fully display-aware positioning that deals with idiosyncrasies such as monitors with different scaling resolutions.

CSS provides higher level abstractions that aid in laying out an application that is composed of constituent parts. Finsemble has borrowed CSS’s positioning paradigm and applied it to the task of laying out windows on the desktop. This CSS-style positioning allows windows to be positioned on the left, right, top, or bottom of the end user’s screen for instance; we also developed new positions, such as adjacent, which allows a child window to spawn adjacent to their parent. Components can be positioned and sized by percentage, relative to the monitor or to each other (nested windows).

The Launcher Client frequently uses the parameters windowName and componentType. Learn more about them here.

Type Aliases

ComponentDescriptor

Ƭ ComponentDescriptor: Record<string, any>


ComponentList

Ƭ ComponentList: Record<string, ComponentDescriptor>


MonitorInfo

Ƭ MonitorInfo: any


SpawnResponse

Ƭ SpawnResponse: Object

Type declaration

NameType
finWindowFinsembleWindow
launchGroupWindows?string[]
windowDescriptorWindowDescriptor
windowIdentifierWindowIdentifier

Functions

getActiveDescriptors

getActiveDescriptors(cb?): StandardPromise<Record<string, WindowDescriptor>>

Gets the windowDescriptor for all open windows.

Note: This returns descriptors even if the window is not part of the workspace.

FSBL.Clients.LauncherClient.getActiveDescriptors(function (error, response) {
if (error) {
Logger.system.error("Error getting active descriptors: ", + JSON.stringify(error));
} else {
const activeDescriptors = response;
//{
// ...
// Toolbar-1-Finsemble: {...},
// Welcome-Component-80-6453-Finsemble: {...},
// ...
//}
}
});

Parameters

NameTypeDescription
cb?StandardErrorCallback<Record<string, WindowDescriptor>>Callback returns an object containing windowDescriptors keyed by name.

Returns

StandardPromise<Record<string, WindowDescriptor>>


getComponentDefaultConfig

getComponentDefaultConfig(componentType, cb?): StandardPromise<ComponentDescriptor>

Get the component config (from components.json) for a specific component.

Parameters

NameTypeDescription
componentTypestringThe type of the component.
cb?StandardErrorCallback<ComponentDescriptor>Callback returns the default config (windowDescriptor) for the requested componentType.

Returns

StandardPromise<ComponentDescriptor>


getComponentList

getComponentList(cb?): StandardPromise<ComponentList>

Get a list of registered components (those that were entered into components.json).

Parameters

NameTypeDescription
cb?StandardErrorCallback<ComponentList>Callback returns an object map of components. Each component object contains the default config for that component.

Returns

StandardPromise<ComponentList>


getMonitorInfo

getMonitorInfo(params?, cb?): StandardPromise<MonitorInfoDetail>

Gets monitor information for a given windowIdentifier or for a specific monitor. If neither the identifier or monitor are provided then the monitorInfo for the current window is returned.

The information returned contains:

monitorRect - The full dimensions for the monitor.
availableRect - The dimensions for the available space on the monitor (less the Windows task bar).
position - The position of the monitor, numerically from zero to X. Primary monitor is zero.
whichMonitor - Contains the string "primary" if it is the primary monitor.

The dimensions are supplemented with the following additional members:

width - The width as calculated (right - left).
height - The height as calculated (bottom - top).

Parameters

NameTypeDescription
paramsObject
params.monitor?MonitorCommandIf passed then a specific monitor is identified. Valid values include: "mine" - Place the window on the same monitor as the calling window. Integer value from 0-n (0 being the primary monitor). "primary" indicates the user's primary monitor. "all" - Put a copy of the component on all monitors.
params.windowIdentifier?WindowIdentifierThe windowIdentifier to get the monitorInfo. If undefined, then the current window.
cb?StandardErrorCallback<MonitorInfoDetail>Returns a monitorInfo object containing the monitorRect and availableRect.

Returns

StandardPromise<MonitorInfoDetail>

A promise that resolves to a monitorInfo


getMonitorInfoAll

getMonitorInfoAll(cb?): StandardPromise<MonitorInfoDetail[]>

Gets monitorInfo (dimensions and position) for all monitors. Returns an array of monitorInfo objects. See LauncherClient#getMonitorInfo for the format of a monitorInfo object.

Parameters

NameTypeDescription
cb?StandardErrorCallback<MonitorInfoDetail[]>Returns an array of monitorInfo objects.

Returns

StandardPromise<MonitorInfoDetail[]>


getMyWindowIdentifier

getMyWindowIdentifier(cb?): Promise<WindowIdentifier>

Returns a windowIdentifier for the current window.

Parameters

NameTypeDescription
cb?(windowIdentifier: WindowIdentifier) => voidCallback function returns windowIdentifier for this window (optional or use the returned Promise)

Returns

Promise<WindowIdentifier>

A promise that resolves to a windowIdentifier


showWindow

showWindow(windowLocator, params, cb?): StandardPromise<SpawnResponse>

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 will be unsnapped/ungrouped/untabbed from the other windows. If invoked on a tabbed window or a window in a group, the window will be removed from the tab/group.

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.

FSBL.Clients.LauncherClient.showWindow({windowName: "Welcome Component-86-3416-Finsemble", componentType: "Welcome Component"}, {spawnIfNotFound: true}, (err, data)=> {});

Parameters

NameTypeDescription
windowLocatorWindowLocator-
paramsanyConfiguration settings from the finsemble.appd[].manifest.window section of the application manifest may be used as parameters to this function, except for the options element. These are the same as LauncherClient.spawn() with the following exceptions:
  • monitor - Same as spawn() except that null or undefined means don't move the window to a different monitor.
  • left - Same as spawn() except that null or undefined means don't move the window from current horizontal location.
  • top - Same as spawn() except that null or undefined means don't move the window from current vertical location.
  • slave - Cannot be set for an existing window. Will only go into effect if the window is spawned. (In other words, only use this in conjunction with spawnIfNotFound).
  • spawnIfNotFound - If true, then spawns a new window if the requested one cannot be found. Note: only works if the windowIdentifier contains a componentType.
  • autoFocus - Whether or not the window should be focused when shown.
cb?StandardErrorCallback<SpawnResponse>Callback to be invoked after the function is completed regardless if the call fails or succeeds. Callback contains two arguments in the following order.
  1. error: an object containing details related to the reason the call failed and where the exception occurred. This object will be null if the call has succeeded.
  2. data: an object with the following information:
    • windowIdentifier - The WindowIdentifier for the new window.
    • windowDescriptor - The WindowDescriptor of the new window.
    • finWindow - A finWindow object referencing the new window.

Returns

StandardPromise<SpawnResponse>


spawn

spawn(component, params, cb?): Promise<{ error?: StandardError ; response?: SpawnResponse }>

Asks the Launcher service to spawn a new component. Any parameter below can also be specified in public/config/components.json, which will then operate as the default for that value.

The launcher parameters mimic CSS window positioning. For instance, to set a full screen window use {left: 0, top: 0, right: 0, bottom: 0}. This is functionally equivalent to: {left: 0, top: 0, width: "100%", height: "100%"}.

You can also spawn more than one component at a time by using a single action, such as clicking a button on a menu. See https://github.com/ChartIQ/finsemble-seed/tree/recipes/SpawnComponentGroup for an example of spawning a component group.

FSBL.Clients.LauncherClient.spawn("Welcome Component", {left: 0, top: 0, position: "relative"}, (err, data)=> {});

Parameters

NameTypeDescription
componentstringThe application or component to spawn.
paramsSpawnParamsConfiguration settings from the finsemble.appd[].manifest.window section of the application manifest may be used as parameters to this function, except for the options element.
cb?StandardErrorCallback<SpawnResponse>Function invoked after the window is created

Returns

Promise<{ error?: StandardError ; response?: SpawnResponse }>


toggleWindowOnClick

toggleWindowOnClick(element, windowLocator, params): void

A convenient method for dealing with a common use-case, which is toggling the appearance and disappearance of a child window when a button is pressed, aka drop down menus. Call this method from the click handler for your element. Your child window will need to close itself on blur events. 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.

Parameters

NameTypeDescription
elementHTMLElementThe DOM element, or selector, clicked by the end user.
windowLocatorWindowLocator-
paramsanyParameters to be passed to LauncherClient.showWindow() if the child window is allowed to open

Returns

void