@openfin/workspace 6.2.2 → 6.3.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.
- package/client-api/src/home.d.ts +2 -1
- package/client-api/src/index.d.ts +8 -5
- package/client-api/src/notifications.d.ts +13 -0
- package/client-api/src/shapes/common.d.ts +5 -0
- package/client-api/src/shapes/home.d.ts +415 -0
- package/client-api/src/shapes/index.d.ts +7 -0
- package/client-api/src/shapes/notifications.d.ts +20 -0
- package/client-api/src/shapes/store.d.ts +467 -0
- package/client-api/src/{templates.d.ts → shapes/templates.d.ts} +0 -0
- package/client-api/src/storefront.d.ts +2 -1
- package/client-api-platform/src/api/app-directory.d.ts +7 -0
- package/client-api-platform/src/api/browser/browser-module.d.ts +20 -0
- package/client-api-platform/src/api/browser/index.d.ts +26 -0
- package/client-api-platform/src/api/context-menu/browser-logo-handler.d.ts +3 -0
- package/client-api-platform/src/api/context-menu/browser-pagetab-handler.d.ts +3 -0
- package/client-api-platform/src/api/context-menu/browser-viewtab-handler.d.ts +3 -0
- package/client-api-platform/src/api/context-menu/index.d.ts +13 -0
- package/client-api-platform/src/api/index.d.ts +4 -0
- package/client-api-platform/src/api/pages/helper.d.ts +22 -0
- package/client-api-platform/src/api/pages/index.d.ts +30 -0
- package/client-api-platform/src/api/protocol.d.ts +51 -0
- package/client-api-platform/src/api/storage.d.ts +10 -0
- package/client-api-platform/src/api/theming.d.ts +5 -0
- package/client-api-platform/src/index.d.ts +3 -0
- package/client-api-platform/src/init/browser-window-focus.d.ts +19 -0
- package/client-api-platform/src/init/cleanup.d.ts +1 -0
- package/client-api-platform/src/init/custom-actions.d.ts +3 -0
- package/client-api-platform/src/init/index.d.ts +37 -0
- package/client-api-platform/src/init/override-callback.d.ts +4 -0
- package/client-api-platform/src/init/theming.d.ts +9 -0
- package/client-api-platform/src/init/utils.d.ts +33 -0
- package/client-api-platform/src/shapes.d.ts +1177 -0
- package/common/src/api/browser-protocol.d.ts +23 -0
- package/common/src/api/pages/attached.d.ts +100 -0
- package/common/src/api/pages/idb.d.ts +12 -0
- package/common/src/api/pages/legacy.d.ts +16 -0
- package/common/src/api/theming.d.ts +62 -0
- package/common/src/utils/context-menu.d.ts +12 -0
- package/common/src/utils/debounce.d.ts +16 -0
- package/common/src/utils/defer-show.d.ts +46 -0
- package/common/src/utils/global-context-menu.d.ts +3 -0
- package/common/src/utils/landing-page.d.ts +11 -0
- package/common/src/utils/merge-deep.d.ts +6 -0
- package/common/src/utils/page-tab-context-menu.d.ts +2 -0
- package/common/src/utils/route.d.ts +55 -0
- package/common/src/utils/shared-emitter.d.ts +10 -0
- package/common/src/utils/strings.d.ts +3 -0
- package/common/src/utils/theming.d.ts +57 -0
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/client-api/src/logger.d.ts +0 -1
- package/client-api/src/shapes.d.ts +0 -883
|
@@ -0,0 +1,1177 @@
|
|
|
1
|
+
/// <reference types="openfin-adapter/fin" />
|
|
2
|
+
import type { InteropBroker } from 'openfin-adapter/src/api/interop';
|
|
3
|
+
import { NamedIdentity } from 'openfin-adapter/src/identity';
|
|
4
|
+
import { IconProps } from '@openfin/ui-library';
|
|
5
|
+
import type { AttachedPage, Page, PageWithUpdatableRuntimeAttribs } from '../../common/src/api/pages/shapes';
|
|
6
|
+
import type { CustomThemes } from '../../common/src/api/theming';
|
|
7
|
+
import type { App } from '../../client-api/src/shapes';
|
|
8
|
+
export type { CustomThemes } from '../../common/src/api/theming';
|
|
9
|
+
export type { App, Image, AppIntent } from '../../client-api/src/shapes';
|
|
10
|
+
export { AppManifestType } from '../../client-api/src/shapes';
|
|
11
|
+
export type { AttachedPage, Page, PageWithUpdatableRuntimeAttribs, PageLayout, PageLayoutDetails } from '../../common/src/api/pages/shapes';
|
|
12
|
+
/**
|
|
13
|
+
* Request for creating a saved page in persistent storage.
|
|
14
|
+
*/
|
|
15
|
+
export interface CreateSavedPageRequest {
|
|
16
|
+
/** The page to create. */
|
|
17
|
+
page: Page;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Request for updating a saved page in persistent storage.
|
|
21
|
+
*/
|
|
22
|
+
export interface UpdateSavedPageRequest {
|
|
23
|
+
/** The ID of the page to update. */
|
|
24
|
+
pageId: string;
|
|
25
|
+
/** The updated page. */
|
|
26
|
+
page: Page;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Request for reordering the pages attached to a window.
|
|
30
|
+
*/
|
|
31
|
+
export interface ReorderPagesRequest {
|
|
32
|
+
/** An array of page ids that specify the order of the pages attached to the window. */
|
|
33
|
+
pageIds: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Request for opening a logo context menu in Browser.
|
|
37
|
+
*/
|
|
38
|
+
export interface OpenGlobalContextMenuRequest {
|
|
39
|
+
/** Screen x-coordinate where context menu should be shown. */
|
|
40
|
+
x: number;
|
|
41
|
+
/** Screen y-coordinate where context menu should be shown. */
|
|
42
|
+
y: number;
|
|
43
|
+
/** Miscellaneous options necessary for implementing custom logic in the provider override. */
|
|
44
|
+
customData?: any;
|
|
45
|
+
}
|
|
46
|
+
/**Shape of the data property of a context menu template item */
|
|
47
|
+
export interface ContextMenuItemData {
|
|
48
|
+
type: string;
|
|
49
|
+
action?: CustomActionSpecifier;
|
|
50
|
+
}
|
|
51
|
+
/**Types of global context menu options, including pre-defined ones.
|
|
52
|
+
* User-defined context menu items should use the value `Custom` */
|
|
53
|
+
export declare enum GlobalContextMenuOptionType {
|
|
54
|
+
NewWindow = "NewWindow",
|
|
55
|
+
NewPage = "NewPage",
|
|
56
|
+
CloseWindow = "CloseWindow",
|
|
57
|
+
OpenStorefront = "OpenStorefront",
|
|
58
|
+
Quit = "Quit",
|
|
59
|
+
Custom = "Custom"
|
|
60
|
+
}
|
|
61
|
+
/**Types of page tab context menu options, including pre-defined ones.
|
|
62
|
+
* User-defined context menu items should use the value `Custom` */
|
|
63
|
+
export declare enum PageTabContextMenuOptionType {
|
|
64
|
+
Close = "Close",
|
|
65
|
+
Duplicate = "Duplicate",
|
|
66
|
+
Rename = "Rename",
|
|
67
|
+
Save = "Save",
|
|
68
|
+
Custom = "Custom"
|
|
69
|
+
}
|
|
70
|
+
/**Shape of the data property of a global context menu template item */
|
|
71
|
+
export interface GlobalContextMenuItemData extends ContextMenuItemData {
|
|
72
|
+
type: GlobalContextMenuOptionType;
|
|
73
|
+
}
|
|
74
|
+
/**Configuration of an option in the global context menu */
|
|
75
|
+
export interface GlobalContextMenuItemTemplate extends OpenFin.MenuItemTemplate {
|
|
76
|
+
data: GlobalContextMenuItemData;
|
|
77
|
+
}
|
|
78
|
+
/**Shape of the data property of a page tab context menu template item */
|
|
79
|
+
export interface PageTabContextMenuItemData extends ContextMenuItemData {
|
|
80
|
+
type: PageTabContextMenuOptionType;
|
|
81
|
+
}
|
|
82
|
+
/**Configuration of an option in the page tab context menu */
|
|
83
|
+
export interface PageTabContextMenuItemTemplate extends OpenFin.MenuItemTemplate {
|
|
84
|
+
data: PageTabContextMenuItemData;
|
|
85
|
+
}
|
|
86
|
+
/**Payload received by a Custom Action that is invoked by a custom global context menu option */
|
|
87
|
+
export interface GlobalContextMenuOptionActionPayload {
|
|
88
|
+
callerType: CustomActionCallerType.GlobalContextMenu;
|
|
89
|
+
/** Identity of the browser window where the context menu is invoked */
|
|
90
|
+
windowIdentity: OpenFin.Identity;
|
|
91
|
+
/** Any data necessary for the functioning of specified custom action*/
|
|
92
|
+
customData?: any;
|
|
93
|
+
}
|
|
94
|
+
/**Payload received by a Custom Action that is invoked by a custom page tab context menu option */
|
|
95
|
+
export interface PageTabContextMenuOptionActionPayload {
|
|
96
|
+
callerType: CustomActionCallerType.PageTabContextMenu;
|
|
97
|
+
/** Identity of the browser window where the context menu is invoked */
|
|
98
|
+
windowIdentity: OpenFin.Identity;
|
|
99
|
+
/** Any data necessary for the functioning of specified custom action*/
|
|
100
|
+
customData?: any;
|
|
101
|
+
/** Id of the page on which the context menu is invoked */
|
|
102
|
+
pageId: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Payload received by the openGlobalContextMenu provider override.
|
|
106
|
+
*/
|
|
107
|
+
export declare type OpenGlobalContextMenuPayload = OpenGlobalContextMenuRequest & {
|
|
108
|
+
/** Template defining the options to show in the context menu. */
|
|
109
|
+
template: GlobalContextMenuItemTemplate[];
|
|
110
|
+
/** Identity of the Browser window where context menu should be shown. */
|
|
111
|
+
identity: NamedIdentity;
|
|
112
|
+
/** Default function that handles stock context menu options. */
|
|
113
|
+
callback: (data: GlobalContextMenuItemData, payload: OpenGlobalContextMenuPayload) => any;
|
|
114
|
+
};
|
|
115
|
+
export interface ViewTabContextMenuTemplate extends OpenFin.MenuItemTemplate {
|
|
116
|
+
data: ViewTabMenuData;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Request for opening a view tab context menu in Browser.
|
|
120
|
+
*/
|
|
121
|
+
export interface OpenViewTabContextMenuRequest {
|
|
122
|
+
/** Screen x-coordinate where context menu should be shown. */
|
|
123
|
+
x: number;
|
|
124
|
+
/** Screen y-coordinate where context menu should be shown. */
|
|
125
|
+
y: number;
|
|
126
|
+
/** Miscellaneous options necessary for implementing custom logic in the provider override. */
|
|
127
|
+
customData?: any;
|
|
128
|
+
/** Template defining the options to show in the context menu. */
|
|
129
|
+
template: ViewTabContextMenuTemplate[];
|
|
130
|
+
selectedViews: OpenFin.Identity[];
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Request for opening a page tab context menu in Browser.
|
|
134
|
+
*/
|
|
135
|
+
export interface OpenPageTabContextMenuRequest {
|
|
136
|
+
/** Screen x-coordinate where context menu should be shown. */
|
|
137
|
+
x: number;
|
|
138
|
+
/** Screen y-coordinate where context menu should be shown. */
|
|
139
|
+
y: number;
|
|
140
|
+
/** Miscellaneous options necessary for implementing custom logic in the provider override. */
|
|
141
|
+
customData?: any;
|
|
142
|
+
/** Id of the page on which the context menu is invoked */
|
|
143
|
+
pageId: string;
|
|
144
|
+
}
|
|
145
|
+
export declare enum ViewTabMenuOptionType {
|
|
146
|
+
NewView = "NewView",
|
|
147
|
+
DuplicateViews = "DuplicateView",
|
|
148
|
+
OpenWithDefaultBrowser = "OpenWithDefaultBrowser",
|
|
149
|
+
ReloadViews = "ReloadTab",
|
|
150
|
+
CloseViews = "CloseTab",
|
|
151
|
+
AddToChannel = "AddToChannel",
|
|
152
|
+
RemoveFromChannel = "RemoveFromChannel",
|
|
153
|
+
Custom = "Custom"
|
|
154
|
+
}
|
|
155
|
+
export interface ViewTabMenuData {
|
|
156
|
+
type: ViewTabMenuOptionType;
|
|
157
|
+
action?: CustomActionSpecifier;
|
|
158
|
+
option?: string;
|
|
159
|
+
}
|
|
160
|
+
export interface ViewTabCustomActionPayload {
|
|
161
|
+
callerType: CustomActionCallerType.ViewTabContextMenu;
|
|
162
|
+
/** Any data necessary for the functioning of specified custom action*/
|
|
163
|
+
customData: any;
|
|
164
|
+
/** Identity of the Browser window where context menu should be shown. */
|
|
165
|
+
windowIdentity: NamedIdentity;
|
|
166
|
+
selectedViews: OpenFin.Identity[];
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Payload received by the openViewTabContextMenu provider override.
|
|
170
|
+
*/
|
|
171
|
+
export declare type OpenViewTabContextMenuPayload = OpenViewTabContextMenuRequest & {
|
|
172
|
+
/** Identity of the Browser window where context menu should be shown. */
|
|
173
|
+
identity: NamedIdentity;
|
|
174
|
+
/** Default function that handles stock context menu options. */
|
|
175
|
+
callback: (data: ViewTabMenuData, req: OpenViewTabContextMenuPayload) => any;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Payload received by the openViewTabContextMenu provider override.
|
|
179
|
+
*/
|
|
180
|
+
export declare type OpenPageTabContextMenuPayload = OpenPageTabContextMenuRequest & {
|
|
181
|
+
/** Identity of the Browser window where context menu should be shown. */
|
|
182
|
+
identity: NamedIdentity;
|
|
183
|
+
/** Template defining the options to show in the context menu. */
|
|
184
|
+
template: PageTabContextMenuItemTemplate[];
|
|
185
|
+
/** Default function that handles stock context menu options. */
|
|
186
|
+
callback: (data: PageTabContextMenuItemData, req: OpenPageTabContextMenuPayload) => any;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Request to update the attributes of a page in which is attached to a running browser window.
|
|
190
|
+
*/
|
|
191
|
+
export interface UpdateAttachedPageRequest {
|
|
192
|
+
/** The ID of the page to update. */
|
|
193
|
+
pageId: string;
|
|
194
|
+
/** The updated page. */
|
|
195
|
+
page: Partial<PageWithUpdatableRuntimeAttribs>;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Types of buttons on browser windows
|
|
199
|
+
*/
|
|
200
|
+
export declare enum BrowserButtonType {
|
|
201
|
+
ShowHideTabs = "ShowHideTabs",
|
|
202
|
+
ColorLinking = "ColorLinking",
|
|
203
|
+
PresetLayouts = "PresetLayouts",
|
|
204
|
+
SavePage = "SavePage",
|
|
205
|
+
Minimise = "Minimise",
|
|
206
|
+
Maximise = "Maximise",
|
|
207
|
+
Close = "Close",
|
|
208
|
+
Custom = "Custom"
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The shape of the payload sent by a custom button click to a custom action handler
|
|
212
|
+
*/
|
|
213
|
+
export interface CustomButtonActionPayload {
|
|
214
|
+
/** Calling the CustomButton type */
|
|
215
|
+
callerType: CustomActionCallerType.CustomButton;
|
|
216
|
+
/** Identity for the current window. */
|
|
217
|
+
windowIdentity: OpenFin.Identity;
|
|
218
|
+
/** Any data necessary for the functioning of specified custom action*/
|
|
219
|
+
customData: any;
|
|
220
|
+
/** Screen x-coordinate where custom button should be shown. */
|
|
221
|
+
x: number;
|
|
222
|
+
/** Screen y-coordinate where custom button should be shown. */
|
|
223
|
+
y: number;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Custom browser buttons
|
|
227
|
+
*/
|
|
228
|
+
export interface CustomBrowserButtonConfig {
|
|
229
|
+
/** Type of cutom browser button */
|
|
230
|
+
type: BrowserButtonType.Custom;
|
|
231
|
+
/** Button name text when hovered over */
|
|
232
|
+
tooltip: string;
|
|
233
|
+
/** Disable custom button true or false */
|
|
234
|
+
disabled?: boolean;
|
|
235
|
+
/** icon URL for icon image */
|
|
236
|
+
iconUrl: string;
|
|
237
|
+
/** Custom action once the button is clicked */
|
|
238
|
+
action: CustomActionSpecifier;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Default Browser Button types
|
|
242
|
+
*/
|
|
243
|
+
export interface PreDefinedButtonConfig {
|
|
244
|
+
/** Type of default browser button */
|
|
245
|
+
type: BrowserButtonType;
|
|
246
|
+
/** Button name text when hovered over */
|
|
247
|
+
tooltip?: string;
|
|
248
|
+
/** icon URL for icon image */
|
|
249
|
+
iconUrl?: string;
|
|
250
|
+
iconProps?: IconProps;
|
|
251
|
+
disabled?: boolean;
|
|
252
|
+
}
|
|
253
|
+
declare type ShowHideTabsConfig = {
|
|
254
|
+
type: BrowserButtonType.ShowHideTabs;
|
|
255
|
+
disabled?: boolean;
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Buttons on the left of WindowStateButtonOptions
|
|
259
|
+
*/
|
|
260
|
+
export declare type ToolbarButton = ShowHideTabsConfig | CustomBrowserButtonConfig | PreDefinedButtonConfig;
|
|
261
|
+
export interface ToolbarOptions {
|
|
262
|
+
buttons: ToolbarButton[];
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Buttons to the top far right of Browser
|
|
266
|
+
*/
|
|
267
|
+
export declare type WindowStateButton = CustomBrowserButtonConfig | PreDefinedButtonConfig;
|
|
268
|
+
export interface WindowStateButtonOptions {
|
|
269
|
+
buttons: WindowStateButton[];
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Request for creating a browser window.
|
|
273
|
+
*/
|
|
274
|
+
export interface BrowserCreateWindowRequest extends Omit<OpenFin.PlatformWindowCreationOptions, 'workspacePlatform'> {
|
|
275
|
+
/** WorkspacePlatform specific window options. These options will not work unless a workspace platform has been initialized. */
|
|
276
|
+
workspacePlatform: {
|
|
277
|
+
/** The initial set of pages to add to the created browser window. */
|
|
278
|
+
pages: Page[];
|
|
279
|
+
/** The favicon to display on the top left of the created browser window. */
|
|
280
|
+
favicon?: string;
|
|
281
|
+
/** A UI friendly title for the created browser window. */
|
|
282
|
+
title?: string;
|
|
283
|
+
/**
|
|
284
|
+
* Landing page that shows up when you add a new tab from the plus button that exists in the tabstrip.
|
|
285
|
+
* If you do not provide a newTabUrl, then the plus button in the tabstrip will not be shown and users cannot create a new empty tab.
|
|
286
|
+
*/
|
|
287
|
+
newTabUrl?: string;
|
|
288
|
+
/**
|
|
289
|
+
* Landing page that shows up when you add a new page from the plus button that exists in the window frame where the page selector is shown.
|
|
290
|
+
* If you do not provide a newPageUrl, then the new Page plus button will not be shown and you cannot create a new empty Page or Window.
|
|
291
|
+
*/
|
|
292
|
+
newPageUrl?: string;
|
|
293
|
+
toolbarOptions?: ToolbarOptions;
|
|
294
|
+
windowStateButtonOptions?: WindowStateButtonOptions;
|
|
295
|
+
/**
|
|
296
|
+
* Remove the Page UI and only allow a single page in the browser window.
|
|
297
|
+
* Must be set to true for this behavior. If this is not set to false,
|
|
298
|
+
* then an empty `pages` option will be populated with a single page.
|
|
299
|
+
*/
|
|
300
|
+
disableMultiplePages?: boolean;
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* A window that is part of a browser snapshot.
|
|
305
|
+
*/
|
|
306
|
+
export declare type BrowserSnapshotWindow = OpenFin.WindowCreationOptions & BrowserCreateWindowRequest;
|
|
307
|
+
/**
|
|
308
|
+
* A browser snapshot.
|
|
309
|
+
*/
|
|
310
|
+
export interface BrowserSnapshot {
|
|
311
|
+
/** The state of the windows that were running at the time the snapshot was taken. */
|
|
312
|
+
windows: BrowserSnapshotWindow[];
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Controller for interacting with a browser window.
|
|
316
|
+
*/
|
|
317
|
+
export interface BrowserWindowModule {
|
|
318
|
+
/** The identity of the browser window. */
|
|
319
|
+
identity: OpenFin.Identity;
|
|
320
|
+
/** Underlying OpenFin window Controller. */
|
|
321
|
+
openfinWindow: OpenFin.Window;
|
|
322
|
+
/**
|
|
323
|
+
* Get a page that is attached to the browser window.
|
|
324
|
+
*
|
|
325
|
+
* ```ts
|
|
326
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
327
|
+
*
|
|
328
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
329
|
+
* // assume a browser window already exists
|
|
330
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
331
|
+
* const page = await windows[0].getPage('MyPageId');
|
|
332
|
+
* ```
|
|
333
|
+
* @param id the id of the page to get.
|
|
334
|
+
*/
|
|
335
|
+
getPage(id: string): Promise<AttachedPage>;
|
|
336
|
+
/**
|
|
337
|
+
* Return all the pages that are attached to a browser window.
|
|
338
|
+
*
|
|
339
|
+
* ```ts
|
|
340
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
341
|
+
*
|
|
342
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
343
|
+
* // assume a browser window already exists
|
|
344
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
345
|
+
* const pages = await windows[0].getPages();
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
getPages(): Promise<AttachedPage[]>;
|
|
349
|
+
/**
|
|
350
|
+
* Set the active page for the browser window. If `multiplePagesDisabled` is `true` an error will be thrown.
|
|
351
|
+
*
|
|
352
|
+
* ```ts
|
|
353
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
354
|
+
*
|
|
355
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
356
|
+
* // assume a browser window already exists
|
|
357
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
358
|
+
* await windows[0].setActivePage('MyPageId');
|
|
359
|
+
* ```
|
|
360
|
+
* @param id the id of the attached page to set as active.
|
|
361
|
+
*/
|
|
362
|
+
setActivePage(id: string): Promise<void>;
|
|
363
|
+
/**
|
|
364
|
+
* Attach a page to a browser window.
|
|
365
|
+
* If `multiplePagesDisabled` is `true` or a page with same id or title is attached to an existing browser window, an error will be thrown.
|
|
366
|
+
*
|
|
367
|
+
* ```ts
|
|
368
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
369
|
+
*
|
|
370
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
371
|
+
* const layout = {
|
|
372
|
+
* content: [
|
|
373
|
+
* {
|
|
374
|
+
* type: 'stack',
|
|
375
|
+
* content: [
|
|
376
|
+
* {
|
|
377
|
+
* type: 'component',
|
|
378
|
+
* componentName: 'view',
|
|
379
|
+
* componentState: {
|
|
380
|
+
* name: 'myViewName',
|
|
381
|
+
* url: 'http://google.com'
|
|
382
|
+
* }
|
|
383
|
+
* }
|
|
384
|
+
* ]
|
|
385
|
+
* }
|
|
386
|
+
* ]
|
|
387
|
+
* };
|
|
388
|
+
* const page = {
|
|
389
|
+
* title: 'myPageTitle',
|
|
390
|
+
* pageId: 'myPageId',
|
|
391
|
+
* layout
|
|
392
|
+
* };
|
|
393
|
+
* // assume a browser window already exists
|
|
394
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
395
|
+
* await windows[0].addPage(page);
|
|
396
|
+
* // focus window
|
|
397
|
+
* await windows[0].openfinWindow.focus();
|
|
398
|
+
* // restore window if minimized
|
|
399
|
+
* await windows[0].openfinWindow.restore();
|
|
400
|
+
* ```
|
|
401
|
+
* @param page the attach page to a browser window.
|
|
402
|
+
*/
|
|
403
|
+
addPage(page: PageWithUpdatableRuntimeAttribs): Promise<void>;
|
|
404
|
+
/**
|
|
405
|
+
* Remove an attached page from the browser window.
|
|
406
|
+
*
|
|
407
|
+
* ```ts
|
|
408
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
409
|
+
*
|
|
410
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
411
|
+
* // assume a browser window already exists
|
|
412
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
413
|
+
* await windows[0].removePage('myPageId');
|
|
414
|
+
* ```
|
|
415
|
+
* @param id the id of the attached page to remove from the browser window.
|
|
416
|
+
*/
|
|
417
|
+
removePage(id: string): Promise<void>;
|
|
418
|
+
/**
|
|
419
|
+
* Update a page in which is attached to the browser window.
|
|
420
|
+
*
|
|
421
|
+
* ```ts
|
|
422
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
423
|
+
*
|
|
424
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
425
|
+
* const layout = {
|
|
426
|
+
* content: [
|
|
427
|
+
* {
|
|
428
|
+
* type: 'stack',
|
|
429
|
+
* content: [
|
|
430
|
+
* {
|
|
431
|
+
* type: 'component',
|
|
432
|
+
* componentName: 'view',
|
|
433
|
+
* componentState: {
|
|
434
|
+
* name: 'myViewName',
|
|
435
|
+
* url: 'http://google.com'
|
|
436
|
+
* }
|
|
437
|
+
* }
|
|
438
|
+
* ]
|
|
439
|
+
* }
|
|
440
|
+
* ]
|
|
441
|
+
* };
|
|
442
|
+
* const page = {
|
|
443
|
+
* title: 'myPageTitle',
|
|
444
|
+
* pageId: 'myPageId',
|
|
445
|
+
* layout
|
|
446
|
+
* };
|
|
447
|
+
* // assume a browser window already exists
|
|
448
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
449
|
+
* const req = {
|
|
450
|
+
* pageId: 'myPageId',
|
|
451
|
+
* page
|
|
452
|
+
* };
|
|
453
|
+
* await windows[0].updatePage(req);
|
|
454
|
+
* ```
|
|
455
|
+
* @param req the update request.
|
|
456
|
+
*/
|
|
457
|
+
updatePage(req: UpdateAttachedPageRequest): Promise<void>;
|
|
458
|
+
/**
|
|
459
|
+
* Reorder pages attached to the browser window. If `multiplePagesDisabled` is `true` an error will be thrown.
|
|
460
|
+
*
|
|
461
|
+
* ```ts
|
|
462
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
463
|
+
*
|
|
464
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
465
|
+
* // assume a browser window already exists and has three pages in it
|
|
466
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
467
|
+
* await windows[0].reorderPages(['myPageId2', 'myPageId1', 'myPageId3']);
|
|
468
|
+
* ```
|
|
469
|
+
* @param req the reorder pages request.
|
|
470
|
+
*/
|
|
471
|
+
reorderPages(req: ReorderPagesRequest): Promise<void>;
|
|
472
|
+
/**
|
|
473
|
+
* Replace toolbar options with custom toolbar options
|
|
474
|
+
*
|
|
475
|
+
* ```ts
|
|
476
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
477
|
+
*
|
|
478
|
+
* // to set the array to our default buttons, pass in null
|
|
479
|
+
*
|
|
480
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
481
|
+
* workspacePlatform.Browser.wrapSync(identity).replaceToolbarOptions({buttons:[{
|
|
482
|
+
* type: 'Custom',
|
|
483
|
+
* tooltip: 'Custom Tooltip',
|
|
484
|
+
* disabled: false,
|
|
485
|
+
* iconUrl: 'https://www.openfin.co/favicon.ico',
|
|
486
|
+
* action: {
|
|
487
|
+
* id: 'sample-custom-action-name',
|
|
488
|
+
* customData: {
|
|
489
|
+
* message: 'Clicked on custom Toolbar button'
|
|
490
|
+
* }
|
|
491
|
+
* }
|
|
492
|
+
* }]})
|
|
493
|
+
*
|
|
494
|
+
* const openFinWindow = fin.Window.wrapSync(identity);
|
|
495
|
+
* // call getOptions() to view updated toolbarOptions under workspacePlatform
|
|
496
|
+
* await openFinWindow.getOptions()
|
|
497
|
+
* ```
|
|
498
|
+
* @param options new toolbar options.
|
|
499
|
+
*/
|
|
500
|
+
replaceToolbarOptions(options: ToolbarOptions): Promise<void>;
|
|
501
|
+
/**
|
|
502
|
+
* Replace window state button options with custom window state button options
|
|
503
|
+
*
|
|
504
|
+
* ```ts
|
|
505
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
506
|
+
*
|
|
507
|
+
* // to set the array to our default buttons, pass in null
|
|
508
|
+
*
|
|
509
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
510
|
+
* workspacePlatform.Browser.wrapSync(identity).replaceWindowStateButtonOptions({buttons:[{
|
|
511
|
+
* type: 'Custom',
|
|
512
|
+
* tooltip: 'Custom tooltip',
|
|
513
|
+
* disabled: false,
|
|
514
|
+
* iconUrl: 'https://www.openfin.co/favicon.ico',
|
|
515
|
+
* action: {
|
|
516
|
+
* id: 'sample-custom-action-name',
|
|
517
|
+
* customData: {
|
|
518
|
+
* message: 'Clicked on custom window state button'
|
|
519
|
+
* }
|
|
520
|
+
* }
|
|
521
|
+
* }]})
|
|
522
|
+
*
|
|
523
|
+
* const openFinWindow = fin.Window.wrapSync(identity);
|
|
524
|
+
* // call getOptions() to view updated windowStateButtonOptions under workspacePlatform
|
|
525
|
+
* await openFinWindow.getOptions()
|
|
526
|
+
* ```
|
|
527
|
+
* @param options new window state options.
|
|
528
|
+
*/
|
|
529
|
+
replaceWindowStateButtonOptions(options: WindowStateButtonOptions): Promise<void>;
|
|
530
|
+
/**
|
|
531
|
+
* Open global context menu in the browser window. By default, this context menu appears
|
|
532
|
+
* when clicking on the logo in the upper-left corner of the window.
|
|
533
|
+
*
|
|
534
|
+
* ```ts
|
|
535
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
536
|
+
*
|
|
537
|
+
* const browserIdentity = {
|
|
538
|
+
* name: 'example-browser-window-name',
|
|
539
|
+
* uuid: 'my-application'
|
|
540
|
+
* };
|
|
541
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
542
|
+
* workspacePlatform.Browser.wrapSync(browserIdentity)._openGlobalContextMenu({
|
|
543
|
+
* x: 100,
|
|
544
|
+
* y: 150
|
|
545
|
+
* });
|
|
546
|
+
* ```
|
|
547
|
+
* @param req the global context menu request.
|
|
548
|
+
* @internal
|
|
549
|
+
*/
|
|
550
|
+
_openGlobalContextMenu(req: OpenGlobalContextMenuRequest): Promise<void>;
|
|
551
|
+
_openViewTabContextMenu(req: OpenViewTabContextMenuRequest): Promise<void>;
|
|
552
|
+
_openPageTabContextMenu(req: OpenPageTabContextMenuRequest): Promise<void>;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Factory for wrapping browser windows and global operations.
|
|
556
|
+
*/
|
|
557
|
+
export interface BrowserWindowFactory {
|
|
558
|
+
/**
|
|
559
|
+
* Synchronously returns a Browser Window object that represents an existing window
|
|
560
|
+
*
|
|
561
|
+
* @param identity of the window
|
|
562
|
+
*/
|
|
563
|
+
wrapSync: (identity: OpenFin.Identity) => BrowserWindowModule;
|
|
564
|
+
/**
|
|
565
|
+
* Get a list of all pages that are attached to any running browser window.
|
|
566
|
+
*
|
|
567
|
+
* ```ts
|
|
568
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
569
|
+
*
|
|
570
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
571
|
+
* const attachedPages = await workspacePlatform.Browser.getAllAttachedPages();
|
|
572
|
+
* ```
|
|
573
|
+
*/
|
|
574
|
+
getAllAttachedPages(): Promise<AttachedPage[]>;
|
|
575
|
+
/**
|
|
576
|
+
* Get all the Browser Windows that are running in the Workspace Platform.
|
|
577
|
+
*
|
|
578
|
+
* ```ts
|
|
579
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
580
|
+
*
|
|
581
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
582
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
583
|
+
* ```
|
|
584
|
+
*/
|
|
585
|
+
getAllWindows(): Promise<BrowserWindowModule[]>;
|
|
586
|
+
/**
|
|
587
|
+
* Create a new browser window.
|
|
588
|
+
*
|
|
589
|
+
* ```ts
|
|
590
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
591
|
+
*
|
|
592
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
593
|
+
* const layout = {
|
|
594
|
+
* content: [
|
|
595
|
+
* {
|
|
596
|
+
* type: 'stack',
|
|
597
|
+
* content: [
|
|
598
|
+
* {
|
|
599
|
+
* type: 'component',
|
|
600
|
+
* componentName: 'view',
|
|
601
|
+
* componentState: {
|
|
602
|
+
* name: 'myViewName',
|
|
603
|
+
* url: 'http://google.com'
|
|
604
|
+
* }
|
|
605
|
+
* }
|
|
606
|
+
* ]
|
|
607
|
+
* }
|
|
608
|
+
* ]
|
|
609
|
+
* };
|
|
610
|
+
* const page = {
|
|
611
|
+
* title: 'myPageTitle',
|
|
612
|
+
* pageId: 'myPageId',
|
|
613
|
+
* layout
|
|
614
|
+
* };
|
|
615
|
+
* const options: BrowserCreateWindowRequest = {
|
|
616
|
+
* workspacePlatform {
|
|
617
|
+
* pages: [page],
|
|
618
|
+
* title: 'My Window Title',
|
|
619
|
+
* favicon: 'https://google.com/favicon.ico',
|
|
620
|
+
* disableMultiplePages: true, // disable page functonality for the window
|
|
621
|
+
* toolbarOptions: { // configure the set of tray icons for the window
|
|
622
|
+
* buttons: [
|
|
623
|
+
* { // adding a custom tray icon for the window
|
|
624
|
+
* type: BrowserButtonType.Custom,
|
|
625
|
+
* tooltip: 'Sample Tray Icon',
|
|
626
|
+
* disabled: false,
|
|
627
|
+
* iconUrl: 'https://www.openfin.co/favicon.ico',
|
|
628
|
+
* action: {
|
|
629
|
+
* // This action needs to be registed in customActions property in the call WorkspacePlatform.init
|
|
630
|
+
* id: 'sample-trayicon-custom-action',
|
|
631
|
+
* customData: {
|
|
632
|
+
* message: 'Clicked on custom Toolbar button'
|
|
633
|
+
* }
|
|
634
|
+
* }
|
|
635
|
+
* },
|
|
636
|
+
* {
|
|
637
|
+
* type: BrowserButtonType.ShowHideTabs
|
|
638
|
+
* },
|
|
639
|
+
* {
|
|
640
|
+
* type: BrowserButtonType.ColorLinking
|
|
641
|
+
* },
|
|
642
|
+
* {
|
|
643
|
+
* type: BrowserButtonType.PresetLayouts
|
|
644
|
+
* },
|
|
645
|
+
* {
|
|
646
|
+
* type: BrowserButtonType.SavePage
|
|
647
|
+
* }
|
|
648
|
+
* ]
|
|
649
|
+
* }
|
|
650
|
+
* windowStateButtonOptions: { configure the set of icons for setting window states
|
|
651
|
+
* buttons: [
|
|
652
|
+
* { // adding a custom window state icon for the window
|
|
653
|
+
* id: 'windowState123',
|
|
654
|
+
* type: BrowserButtonType.Custom,
|
|
655
|
+
* tooltip: 'Sample Window State button',
|
|
656
|
+
* disabled: false,
|
|
657
|
+
* iconUrl: 'https://www.openfin.co/favicon.ico',
|
|
658
|
+
* action: {
|
|
659
|
+
* // This action needs to be registed in customActions property in the call WorkspacePlatform.init
|
|
660
|
+
* id: 'sample-window-state-custom-action',
|
|
661
|
+
* customData: {
|
|
662
|
+
* message: 'Clicked on custom Window State button'
|
|
663
|
+
* }
|
|
664
|
+
* }
|
|
665
|
+
* },
|
|
666
|
+
* { // override tooltip and icon URL for standard Maximise button
|
|
667
|
+
* type: BrowserButtonType.Maximise,
|
|
668
|
+
* tooltip: overrideWindowStateIcons ? 'Studio Maximise' : undefined,
|
|
669
|
+
* iconUrl: overrideWindowStateIcons ? 'https://www.openfin.co/favicon.ico' : undefined
|
|
670
|
+
* },
|
|
671
|
+
* {
|
|
672
|
+
* type: BrowserButtonType.Minimise
|
|
673
|
+
* },
|
|
674
|
+
* {
|
|
675
|
+
* type: BrowserButtonType.Close
|
|
676
|
+
* }
|
|
677
|
+
* ]
|
|
678
|
+
* }
|
|
679
|
+
* }
|
|
680
|
+
* };
|
|
681
|
+
* const window = await workspacePlatform.Browser.createWindow(options);
|
|
682
|
+
* ```
|
|
683
|
+
*
|
|
684
|
+
* @param options the browser window creation options
|
|
685
|
+
*/
|
|
686
|
+
createWindow(options: BrowserCreateWindowRequest): Promise<BrowserWindowModule>;
|
|
687
|
+
/**
|
|
688
|
+
* Get a unique title for a page.
|
|
689
|
+
*
|
|
690
|
+
* ```ts
|
|
691
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
692
|
+
*
|
|
693
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
694
|
+
* const uniqueTitle = await workspacePlatform.Browser.getUniquePageTitle('myTitle');
|
|
695
|
+
* ```
|
|
696
|
+
* @param title a prefix for the title.
|
|
697
|
+
*/
|
|
698
|
+
getUniquePageTitle(title?: string): Promise<string>;
|
|
699
|
+
/**
|
|
700
|
+
* Get the identity of the last focused Browser window.
|
|
701
|
+
*
|
|
702
|
+
* ```ts
|
|
703
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
704
|
+
*
|
|
705
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
706
|
+
* const windowIdentity = await workspacePlatform.Browser.getLastFocusedWindow();
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
709
|
+
getLastFocusedWindow(): Promise<OpenFin.Identity>;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* API for interacting with persistent storage.
|
|
713
|
+
*/
|
|
714
|
+
export interface WorkspacePlatformStorage {
|
|
715
|
+
/**
|
|
716
|
+
* Get all pages that are saved in persistent storage.
|
|
717
|
+
*
|
|
718
|
+
* ```ts
|
|
719
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
720
|
+
*
|
|
721
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
722
|
+
* const pages = await workspacePlatform.Storage.getPages();
|
|
723
|
+
* ```
|
|
724
|
+
*/
|
|
725
|
+
getPages(): Promise<Page[]>;
|
|
726
|
+
/**
|
|
727
|
+
* Get a specific page in persistent storage.
|
|
728
|
+
*
|
|
729
|
+
* ```ts
|
|
730
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
731
|
+
*
|
|
732
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
733
|
+
* const myPage = await workspacePlatform.Storage.getPage('myPageId');
|
|
734
|
+
* ```
|
|
735
|
+
* @param id the id of the page to get.
|
|
736
|
+
*/
|
|
737
|
+
getPage(id: string): Promise<Page>;
|
|
738
|
+
/**
|
|
739
|
+
* Create a page in persistent storage.
|
|
740
|
+
*
|
|
741
|
+
* ```ts
|
|
742
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
743
|
+
*
|
|
744
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
745
|
+
* const layout = {
|
|
746
|
+
* content: [
|
|
747
|
+
* {
|
|
748
|
+
* type: 'stack',
|
|
749
|
+
* content: [
|
|
750
|
+
* {
|
|
751
|
+
* type: 'component',
|
|
752
|
+
* componentName: 'view',
|
|
753
|
+
* componentState: {
|
|
754
|
+
* name: 'myViewName',
|
|
755
|
+
* url: 'http://google.com'
|
|
756
|
+
* }
|
|
757
|
+
* }
|
|
758
|
+
* ]
|
|
759
|
+
* }
|
|
760
|
+
* ]
|
|
761
|
+
* };
|
|
762
|
+
* const page = {
|
|
763
|
+
* title: 'myPageTitle',
|
|
764
|
+
* pageId: 'myPageId',
|
|
765
|
+
* layout
|
|
766
|
+
* };
|
|
767
|
+
* await workspacePlatform.Storage.createPage({page});
|
|
768
|
+
* ```
|
|
769
|
+
* @param page the page to create in persistent storage.
|
|
770
|
+
*/
|
|
771
|
+
createPage(page: CreateSavedPageRequest): Promise<void>;
|
|
772
|
+
/**
|
|
773
|
+
* Update a page in persistent storage.
|
|
774
|
+
*
|
|
775
|
+
* ```ts
|
|
776
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
777
|
+
*
|
|
778
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
779
|
+
* const layout = {
|
|
780
|
+
* content: [
|
|
781
|
+
* {
|
|
782
|
+
* type: 'stack',
|
|
783
|
+
* content: [
|
|
784
|
+
* {
|
|
785
|
+
* type: 'component',
|
|
786
|
+
* componentName: 'view',
|
|
787
|
+
* componentState: {
|
|
788
|
+
* name: 'myViewName',
|
|
789
|
+
* url: 'http://google.com'
|
|
790
|
+
* }
|
|
791
|
+
* }
|
|
792
|
+
* ]
|
|
793
|
+
* }
|
|
794
|
+
* ]
|
|
795
|
+
* };
|
|
796
|
+
* const page = {
|
|
797
|
+
* title: 'myPageTitle',
|
|
798
|
+
* pageId: 'myPageId',
|
|
799
|
+
* layout
|
|
800
|
+
* };
|
|
801
|
+
* const req = {
|
|
802
|
+
* pageId: 'myPageId',
|
|
803
|
+
* page
|
|
804
|
+
* };
|
|
805
|
+
* await workspacePlatform.Storage.updatePage(req);
|
|
806
|
+
* ```
|
|
807
|
+
* @param req the update saved page request.
|
|
808
|
+
*/
|
|
809
|
+
updatePage(req: UpdateSavedPageRequest): Promise<void>;
|
|
810
|
+
/**
|
|
811
|
+
* Delete a page from persistent storage.
|
|
812
|
+
*
|
|
813
|
+
* ```ts
|
|
814
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
815
|
+
*
|
|
816
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
817
|
+
* await workspacePlatform.Storage.deletePage('myPageId');
|
|
818
|
+
* ```
|
|
819
|
+
* @param id the id of the page to delete.
|
|
820
|
+
*/
|
|
821
|
+
deletePage(id: string): Promise<void>;
|
|
822
|
+
/**
|
|
823
|
+
* Save a page in persistent storage.
|
|
824
|
+
*
|
|
825
|
+
* This is a helper function that will call `getPage` to determine if a page is already in storage.
|
|
826
|
+
* If the page is already in storage, it will call `updatePage`.
|
|
827
|
+
* If it does not exist in storage, the function will call `createPage` instead.
|
|
828
|
+
*
|
|
829
|
+
* ```ts
|
|
830
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
831
|
+
*
|
|
832
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
833
|
+
* const layout = {
|
|
834
|
+
* content: [
|
|
835
|
+
* {
|
|
836
|
+
* type: 'stack',
|
|
837
|
+
* content: [
|
|
838
|
+
* {
|
|
839
|
+
* type: 'component',
|
|
840
|
+
* componentName: 'view',
|
|
841
|
+
* componentState: {
|
|
842
|
+
* name: 'myViewName',
|
|
843
|
+
* url: 'http://google.com'
|
|
844
|
+
* }
|
|
845
|
+
* }
|
|
846
|
+
* ]
|
|
847
|
+
* }
|
|
848
|
+
* ]
|
|
849
|
+
* };
|
|
850
|
+
* const page = {
|
|
851
|
+
* title: 'myPageTitle',
|
|
852
|
+
* pageId: 'myPageId',
|
|
853
|
+
* layout
|
|
854
|
+
* };
|
|
855
|
+
* await workspacePlatform.Storage.savePage(page);
|
|
856
|
+
* ```
|
|
857
|
+
* @param page the page to save.
|
|
858
|
+
*/
|
|
859
|
+
savePage(page: Page): Promise<void>;
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Request for launching an application.
|
|
863
|
+
*/
|
|
864
|
+
export interface LaunchAppRequest {
|
|
865
|
+
target?: OpenFin.EntityInfo;
|
|
866
|
+
app: App;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Get Themes from API
|
|
870
|
+
*/
|
|
871
|
+
export interface ThemeApi {
|
|
872
|
+
getThemes(): Promise<CustomThemes>;
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* Controller for a Workspace Platform.
|
|
876
|
+
*/
|
|
877
|
+
export interface WorkspacePlatformModule extends OpenFin.Platform {
|
|
878
|
+
/**
|
|
879
|
+
* Launch a browser snapshot that contains windows with pages.
|
|
880
|
+
*
|
|
881
|
+
* @param snapshot the browser snapshot to launch or a url or filepath to retrieve a JSON snapshot.
|
|
882
|
+
*/
|
|
883
|
+
applySnapshot(snapshot: BrowserSnapshot | string): Promise<OpenFin.Platform>;
|
|
884
|
+
/**
|
|
885
|
+
* Get a snapshot that contains browser windows with pages.
|
|
886
|
+
*/
|
|
887
|
+
getSnapshot(): Promise<BrowserSnapshot>;
|
|
888
|
+
/**
|
|
889
|
+
* Invokes a custom action defined by platform provider
|
|
890
|
+
* @internal
|
|
891
|
+
*/
|
|
892
|
+
_invokeCustomAction(actionId: string, payload: CustomActionPayload): Promise<any>;
|
|
893
|
+
/**
|
|
894
|
+
* Launch an application.
|
|
895
|
+
* ```ts
|
|
896
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
897
|
+
*
|
|
898
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
899
|
+
* const req = {
|
|
900
|
+
* app: {
|
|
901
|
+
* appId: 'myAppId',
|
|
902
|
+
* title: 'appTitle',
|
|
903
|
+
* manifest: 'http://localhost/app.json',
|
|
904
|
+
* manifestType: AppManifestType.Manifest,
|
|
905
|
+
* icons:[
|
|
906
|
+
* {
|
|
907
|
+
* icon: "https://cdn.openfin.co/demos/notifications/generator/images/icon-blue.png",
|
|
908
|
+
* src: "https://cdn.openfin.co/demos/notifications/generator/images/icon-blue.png",
|
|
909
|
+
* type: "ico",
|
|
910
|
+
* },
|
|
911
|
+
* ]
|
|
912
|
+
* }
|
|
913
|
+
* }
|
|
914
|
+
* workspacePlatform.launchApp(req);
|
|
915
|
+
*
|
|
916
|
+
* ```
|
|
917
|
+
* @param req the launch app request.
|
|
918
|
+
*/
|
|
919
|
+
launchApp(req: LaunchAppRequest): Promise<void>;
|
|
920
|
+
/**
|
|
921
|
+
* The browser window factory for the Workspace Platform.
|
|
922
|
+
*/
|
|
923
|
+
Browser: BrowserWindowFactory;
|
|
924
|
+
/**
|
|
925
|
+
* The storage API for the Workspace Platform.
|
|
926
|
+
*/
|
|
927
|
+
Storage: WorkspacePlatformStorage;
|
|
928
|
+
/**
|
|
929
|
+
* Theme API for the Workspace Platform.
|
|
930
|
+
*/
|
|
931
|
+
Theme: ThemeApi;
|
|
932
|
+
}
|
|
933
|
+
export interface WorkspacePlatformProvider extends OpenFin.PlatformProvider {
|
|
934
|
+
/**
|
|
935
|
+
* Implementation for getting a list of saved pages from persistent storage.
|
|
936
|
+
* @param query an optional query.
|
|
937
|
+
*/
|
|
938
|
+
getSavedPages(query?: string): Promise<Page[]>;
|
|
939
|
+
/**
|
|
940
|
+
* Implementation for getting a single page in persistent storage.
|
|
941
|
+
* @param id
|
|
942
|
+
*/
|
|
943
|
+
getSavedPage(id: string): Promise<Page>;
|
|
944
|
+
/**
|
|
945
|
+
* Implementation for creating a saved page in persistent storage.
|
|
946
|
+
* @param req the create saved page request.
|
|
947
|
+
*/
|
|
948
|
+
createSavedPage(req: CreateSavedPageRequest): Promise<void>;
|
|
949
|
+
/**
|
|
950
|
+
* Implementation for updating a saved page in persistent storage.
|
|
951
|
+
* @param req the update saved page request.
|
|
952
|
+
*/
|
|
953
|
+
updateSavedPage(req: UpdateSavedPageRequest): Promise<void>;
|
|
954
|
+
/**
|
|
955
|
+
* Implementation for deleting a saved page in persistent storage.
|
|
956
|
+
* @param id of the id of the page to delete.
|
|
957
|
+
*/
|
|
958
|
+
deleteSavedPage(id: string): Promise<void>;
|
|
959
|
+
/**
|
|
960
|
+
* Implementation for showing a global context menu given a menu template,
|
|
961
|
+
* handler callback, and screen coordinates. For an example of overriding, see {@link BrowserOverrideCallback}.
|
|
962
|
+
* @param req the payload received by the provider call
|
|
963
|
+
* @param callerIdentity OF identity of the entity from which the request originated
|
|
964
|
+
*/
|
|
965
|
+
openGlobalContextMenu(req: OpenGlobalContextMenuPayload, callerIdentity: OpenFin.Identity): any;
|
|
966
|
+
/**
|
|
967
|
+
* Implementation for showing a view tab context menu given a menu template,
|
|
968
|
+
* handler callback, and screen coordinates. For an example of overriding, see {@link BrowserOverrideCallback}.
|
|
969
|
+
* @param req the payload received by the provider call
|
|
970
|
+
* @param callerIdentity OF identity of the entity from which the request originated
|
|
971
|
+
*/
|
|
972
|
+
openViewTabContextMenu(req: OpenViewTabContextMenuPayload, callerIdentity: OpenFin.Identity): any;
|
|
973
|
+
/**
|
|
974
|
+
* Implementation for showing a page tab context menu given a menu template,
|
|
975
|
+
* handler callback, and screen coordinates. For an example of overriding, see {@link BrowserOverrideCallback}.
|
|
976
|
+
* @param req the payload received by the provider call
|
|
977
|
+
* @param callerIdentity OF identity of the entity from which the request originated
|
|
978
|
+
*/
|
|
979
|
+
openPageTabContextMenu(req: OpenPageTabContextMenuPayload, callerIdentity: OpenFin.Identity): any;
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* The origins from which a custom action can be invoked
|
|
983
|
+
*/
|
|
984
|
+
export declare enum CustomActionCallerType {
|
|
985
|
+
CustomButton = "CustomButton",
|
|
986
|
+
GlobalContextMenu = "GlobalContextMenu",
|
|
987
|
+
ViewTabContextMenu = "ViewTabContextMenu",
|
|
988
|
+
PageTabContextMenu = "PageTabContextMenu",
|
|
989
|
+
API = "API"
|
|
990
|
+
}
|
|
991
|
+
/**The payload received by a Custom Action.
|
|
992
|
+
* The `callerType` property can be used to determine what data is available in the payload and cast accordingly.
|
|
993
|
+
* When `callerType == CustomActionCallerType.API`, the payload is defined by the code directly invoking the action.*/
|
|
994
|
+
export declare type CustomActionPayload = {
|
|
995
|
+
callerType: CustomActionCallerType.API;
|
|
996
|
+
} | CustomButtonActionPayload | GlobalContextMenuOptionActionPayload | ViewTabCustomActionPayload | PageTabContextMenuOptionActionPayload;
|
|
997
|
+
/**
|
|
998
|
+
* Configures a custom action when the control is invoked
|
|
999
|
+
*/
|
|
1000
|
+
export interface CustomActionSpecifier {
|
|
1001
|
+
/** Identifier of a custom action defined at platform initialization*/
|
|
1002
|
+
id: string;
|
|
1003
|
+
/** Any data necessary for the functioning of specified custom action*/
|
|
1004
|
+
customData?: any;
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Payload received by invokeCustomActionInternal platform provider method
|
|
1008
|
+
* @internal
|
|
1009
|
+
*/
|
|
1010
|
+
export interface InvokeCustomActionRequest {
|
|
1011
|
+
actionId: string;
|
|
1012
|
+
payload: CustomActionPayload;
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Defines custom action map where the key is the custom action ID and value is the action handler
|
|
1016
|
+
*/
|
|
1017
|
+
export interface CustomActionsMap {
|
|
1018
|
+
[actionId: string]: (payload: CustomActionPayload) => any;
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Configuration for initializing a Workspace platform.
|
|
1022
|
+
*/
|
|
1023
|
+
export interface WorkspacePlatformInitConfig {
|
|
1024
|
+
customActions?: CustomActionsMap;
|
|
1025
|
+
/** Config for overriding browser options and behavior. */
|
|
1026
|
+
browser?: BrowserInitConfig;
|
|
1027
|
+
/** Custom Themes object
|
|
1028
|
+
*
|
|
1029
|
+
* ```ts
|
|
1030
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
1031
|
+
*
|
|
1032
|
+
* // This is the palette used to create the OpenFin dark theme
|
|
1033
|
+
* const customPalette: WorkspacePlatform.CustomPaletteSet = {
|
|
1034
|
+
* brandPrimary: '#504CFF',
|
|
1035
|
+
* brandSecondary: '#383A40',
|
|
1036
|
+
* backgroundPrimary: '#000',
|
|
1037
|
+
* background1: '#111214',
|
|
1038
|
+
* background2: '#1E1F23',
|
|
1039
|
+
* background3: '#24262B',
|
|
1040
|
+
* background4: '#2F3136',
|
|
1041
|
+
* background5: '#383A40',
|
|
1042
|
+
* background6: '#53565F',
|
|
1043
|
+
* statusSuccess: '#35C759',
|
|
1044
|
+
* statusWarning: '#C93400',
|
|
1045
|
+
* statusCritical: '#000',
|
|
1046
|
+
* statusActive: '#0879C4',
|
|
1047
|
+
* inputBackground: '#53565F',
|
|
1048
|
+
* inputColor: '#FFFFFF',
|
|
1049
|
+
* inputPlaceholder: '#C9CBD2',
|
|
1050
|
+
* inputDisabled: '#7D808A',
|
|
1051
|
+
* inputFocused: '#C9CBD2',
|
|
1052
|
+
* textDefault: '#FFFFFF',
|
|
1053
|
+
* textHelp: '#C9CBD2',
|
|
1054
|
+
* textInactive: '#7D808A',
|
|
1055
|
+
* };
|
|
1056
|
+
*
|
|
1057
|
+
* const customTheme: WorkspacePlatform.CustomThemes = [{
|
|
1058
|
+
* label: "My Custom Theme",
|
|
1059
|
+
* palette: customPalette
|
|
1060
|
+
* }];
|
|
1061
|
+
*
|
|
1062
|
+
* await WorkspacePlatform.init({
|
|
1063
|
+
* browser: { overrideCallback },
|
|
1064
|
+
* theme: customThemes
|
|
1065
|
+
* });
|
|
1066
|
+
*/
|
|
1067
|
+
theme?: CustomThemes;
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Extend or replace default functionality in order to customize behavior of a Workspace Platform Provider.
|
|
1071
|
+
*
|
|
1072
|
+
* To implement your own handlers for Workspace Platform behavior, extend the provided class and override any methods you'd like to alter.
|
|
1073
|
+
*
|
|
1074
|
+
* ```ts
|
|
1075
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
1076
|
+
* import { UpdateSavedPageRequest } from '../../client-api-platform/src/shapes';
|
|
1077
|
+
*
|
|
1078
|
+
* const overrideCallback: WorkspacePlatform.BrowserOverrideCallback = async (
|
|
1079
|
+
* WorkspacePlatformProvider
|
|
1080
|
+
* ) => {
|
|
1081
|
+
* class Override extends WorkspacePlatformProvider {
|
|
1082
|
+
* // ovrride default behavior of updateSavedPage
|
|
1083
|
+
* updateSavedPage = async (req: UpdateSavedPageRequest): Promise<void> => {
|
|
1084
|
+
* console.log(`saving page ${req.page.pageId}`);
|
|
1085
|
+
* // calling custom function to the save page here
|
|
1086
|
+
* };
|
|
1087
|
+
*
|
|
1088
|
+
* // add a custom menu item in Global Context Menu
|
|
1089
|
+
* openGlobalContextMenu(req: WorkspacePlatform.OpenGlobalContextMenuPayload, callerIdentity: any) {
|
|
1090
|
+
* return super.openGlobalContextMenu(
|
|
1091
|
+
* {
|
|
1092
|
+
* ...req,
|
|
1093
|
+
* template: [
|
|
1094
|
+
* ...req.template,
|
|
1095
|
+
* {
|
|
1096
|
+
* label: 'Sample custom global option',
|
|
1097
|
+
* data: {
|
|
1098
|
+
* type: GlobalContextMenuOptionType.Custom,
|
|
1099
|
+
* action: {
|
|
1100
|
+
* // This action needs to be registed in customActions property in the call WorkspacePlatform.init
|
|
1101
|
+
* id: 'sample-custom-global-menu-action'
|
|
1102
|
+
* }
|
|
1103
|
+
* }
|
|
1104
|
+
* }
|
|
1105
|
+
* ]
|
|
1106
|
+
* },
|
|
1107
|
+
* callerIdentity
|
|
1108
|
+
* );
|
|
1109
|
+
* }
|
|
1110
|
+
*
|
|
1111
|
+
* // add a custom menu item in View Tab Context Menu
|
|
1112
|
+
* openViewTabContextMenu = async (payload: OpenViewTabContextMenuPayload, callerIdentity) => {
|
|
1113
|
+
* return super.openViewTabContextMenu({
|
|
1114
|
+
* ...payload,
|
|
1115
|
+
* template: [
|
|
1116
|
+
* {
|
|
1117
|
+
* label: 'Sample View Tab Context Menu',
|
|
1118
|
+
* data: {
|
|
1119
|
+
* type: ViewTabMenuOptionType.Custom,
|
|
1120
|
+
* action: {
|
|
1121
|
+
* // This action needs to be registed in customActions property in the call WorkspacePlatform.init
|
|
1122
|
+
* id: 'sample-viewtab-action',
|
|
1123
|
+
* customData: 'Custom View Tab Action'
|
|
1124
|
+
* }
|
|
1125
|
+
* }
|
|
1126
|
+
* },
|
|
1127
|
+
* ...payload.template
|
|
1128
|
+
* ]
|
|
1129
|
+
* }, callerIdentity);
|
|
1130
|
+
* };
|
|
1131
|
+
*
|
|
1132
|
+
*
|
|
1133
|
+
* }
|
|
1134
|
+
* return new Override();
|
|
1135
|
+
* };
|
|
1136
|
+
*
|
|
1137
|
+
* await WorkspacePlatform.init({
|
|
1138
|
+
* browser: { overrideCallback },
|
|
1139
|
+
* customActions: {
|
|
1140
|
+
* 'sample-custom-global-menu-action': (payload: CustomActionPayload) => {
|
|
1141
|
+
* alert('This custom action works ' + JSON.stringify(payload));
|
|
1142
|
+
* return 'someresponse';
|
|
1143
|
+
* },
|
|
1144
|
+
* 'sample-viewtab-action': (payload: ViewTabCustomActionPayload) => {
|
|
1145
|
+
* alert('This custom action works ' + JSON.stringify(payload));
|
|
1146
|
+
* return 'someresponse';
|
|
1147
|
+
* }
|
|
1148
|
+
* }
|
|
1149
|
+
*
|
|
1150
|
+
*
|
|
1151
|
+
* });
|
|
1152
|
+
*/
|
|
1153
|
+
export declare type BrowserOverrideCallback = OpenFin.OverrideCallback<WorkspacePlatformProvider>;
|
|
1154
|
+
/**
|
|
1155
|
+
* Configuration for initializing a Browser.
|
|
1156
|
+
*/
|
|
1157
|
+
export interface BrowserInitConfig {
|
|
1158
|
+
/**
|
|
1159
|
+
* Default options for creating a new browser window. Any option not included in WorkspacePlatform.getCurrentSync().Browser.createWindow(options) call will default to the value provided in this field.
|
|
1160
|
+
*/
|
|
1161
|
+
defaultWindowOptions?: BrowserCreateWindowRequest;
|
|
1162
|
+
/** Default options when creating a new page. If `iconUrl`, `unsavedIconUrl` or `closeButton` are not defined when creating a page, setting will default to `defaultPageOptions`. */
|
|
1163
|
+
defaultPageOptions?: Pick<Page, 'iconUrl' | 'unsavedIconUrl' | 'closeButton'>;
|
|
1164
|
+
/**
|
|
1165
|
+
* The default options when creating a new browser window. Any option not included in WorkspacePlatform.getCurrentSync().Browser.createView(options) call will default to the value provided in this field.
|
|
1166
|
+
*/
|
|
1167
|
+
defaultViewOptions?: OpenFin.ViewOptions;
|
|
1168
|
+
/**
|
|
1169
|
+
* Override workspace platform behavior
|
|
1170
|
+
*/
|
|
1171
|
+
overrideCallback?: BrowserOverrideCallback;
|
|
1172
|
+
/**
|
|
1173
|
+
* Override workspace platform interop behavior
|
|
1174
|
+
* https://cdn.openfin.co/docs/javascript/stable/InteropBroker.html
|
|
1175
|
+
*/
|
|
1176
|
+
interopOverride?: OpenFin.OverrideCallback<InteropBroker, InteropBroker>;
|
|
1177
|
+
}
|