API: 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
Name | Type |
---|---|
finWindow | FinsembleWindow |
launchGroupWindows? | string [] |
windowDescriptor | WindowDescriptor |
windowIdentifier | WindowIdentifier |
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
componentType | string | The 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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
params | Object | |
params.monitor? | MonitorCommand | If 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? | WindowIdentifier | The 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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
cb? | (windowIdentifier : WindowIdentifier ) => void | Callback 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
Name | Type | Description |
---|---|---|
windowLocator | WindowLocator | - |
params | any | Configuration 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:
|
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.
|
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
Name | Type | Description |
---|---|---|
component | string | The application or component to spawn. |
params | SpawnParams | Configuration 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
Name | Type | Description |
---|---|---|
element | HTMLElement | The DOM element, or selector, clicked by the end user. |
windowLocator | WindowLocator | - |
params | any | Parameters to be passed to LauncherClient.showWindow() if the child window is allowed to open |
Returns
void