@openfin/workspace-platform 5.3.0 → 5.6.2
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/README.md +31 -4
- package/client-api/src/shapes.d.ts +283 -6
- package/client-api-platform/src/api/app-directory.d.ts +2 -2
- package/client-api-platform/src/api/browser/browser-module.d.ts +4 -2
- package/client-api-platform/src/api/browser/index.d.ts +5 -4
- package/client-api-platform/src/api/context-menu/browser-logo-handler.d.ts +10 -0
- package/client-api-platform/src/api/context-menu/index.d.ts +6 -0
- package/client-api-platform/src/api/pages/helper.d.ts +1 -1
- package/client-api-platform/src/api/pages/index.d.ts +6 -6
- package/client-api-platform/src/api/protocol.d.ts +8 -5
- package/client-api-platform/src/api/storage.d.ts +1 -1
- package/client-api-platform/src/api/theming.d.ts +5 -0
- package/client-api-platform/src/api/workspace-module.d.ts +2 -2
- package/client-api-platform/src/index.d.ts +36 -1
- package/client-api-platform/src/init/custom-actions.d.ts +3 -0
- package/client-api-platform/src/init/override-callback.d.ts +3 -2
- package/client-api-platform/src/init/theming.d.ts +9 -0
- package/client-api-platform/src/init/utils.d.ts +8 -2
- package/client-api-platform/src/shapes.d.ts +667 -20
- package/common/src/api/browser-protocol.d.ts +14 -0
- package/common/src/api/pages/attached.d.ts +0 -1
- package/common/src/api/pages/idb.d.ts +2 -2
- package/common/src/api/pages/index.d.ts +7 -1
- package/common/src/api/pages/legacy.d.ts +2 -2
- package/common/src/api/pages/shapes.d.ts +9 -0
- package/common/src/api/protocol.d.ts +2 -1
- package/common/src/api/theming.d.ts +62 -0
- package/common/src/utils/context-menu.d.ts +12 -0
- package/common/src/utils/defer-auto-show.d.ts +18 -0
- package/common/src/utils/env.d.ts +6 -7
- package/common/src/utils/global-context-menu.d.ts +2 -0
- package/common/src/utils/landing-page.d.ts +11 -0
- package/common/src/utils/layout.d.ts +2 -1
- package/common/src/utils/merge-deep.d.ts +6 -0
- package/common/src/utils/strings.d.ts +0 -2
- package/common/src/utils/theming.d.ts +57 -0
- package/common/src/utils/window.d.ts +5 -0
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/search-api/src/client/internal.d.ts +1 -1
- package/search-api/src/shapes.d.ts +45 -2
|
@@ -1,59 +1,318 @@
|
|
|
1
1
|
/// <reference types="openfin-adapter/fin" />
|
|
2
2
|
import type { InteropBroker } from 'openfin-adapter/src/api/interop';
|
|
3
|
-
import
|
|
3
|
+
import { NamedIdentity } from 'openfin-adapter/src/identity';
|
|
4
4
|
import type { AttachedPage, Page, PageWithUpdatableRuntimeAttribs } from '../../common/src/api/pages/shapes';
|
|
5
|
+
import type { CustomThemes } from '../../common/src/api/theming';
|
|
6
|
+
import type { App } from '../../client-api/src/shapes';
|
|
7
|
+
import { MenuData } from './api/context-menu/browser-logo-handler';
|
|
8
|
+
export type { CustomThemes } from '../../common/src/api/theming';
|
|
5
9
|
export type { App, Image, AppIntent } from '../../client-api/src/shapes';
|
|
6
10
|
export { AppManifestType } from '../../client-api/src/shapes';
|
|
11
|
+
export type { AttachedPage, Page, PageWithUpdatableRuntimeAttribs, PageLayout, PageLayoutDetails } from '../../common/src/api/pages/shapes';
|
|
12
|
+
import type { IconProps } from '@openfin/ui-library';
|
|
13
|
+
/**
|
|
14
|
+
* Request for creating a saved page in persistent storage.
|
|
15
|
+
*/
|
|
7
16
|
export interface CreateSavedPageRequest {
|
|
17
|
+
/** The page to create. */
|
|
8
18
|
page: Page;
|
|
9
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Request for updating a saved page in persistent storage.
|
|
22
|
+
*/
|
|
10
23
|
export interface UpdateSavedPageRequest {
|
|
11
24
|
/** The ID of the page to update. */
|
|
12
25
|
pageId: string;
|
|
13
26
|
/** The updated page. */
|
|
14
27
|
page: Page;
|
|
15
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Request for reordering the pages attached to a window.
|
|
31
|
+
*/
|
|
16
32
|
export interface ReorderPagesRequest {
|
|
17
|
-
/**
|
|
33
|
+
/** An array of page ids that specify the order of the pages attached to the window. */
|
|
18
34
|
pageIds: string[];
|
|
19
35
|
}
|
|
20
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Request for opening a logo context menu in Browser.
|
|
38
|
+
*/
|
|
39
|
+
export interface OpenGlobalContextMenuRequest {
|
|
40
|
+
/** Screen x-coordinate where context menu should be shown. */
|
|
41
|
+
x: number;
|
|
42
|
+
/** Screen y-coordinate where context menu should be shown. */
|
|
43
|
+
y: number;
|
|
44
|
+
/** Miscelaneous options necessary for implementing custom logic in the provider override. */
|
|
45
|
+
customData?: any;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Payload received by the openGlobalContextMenu provider override.
|
|
49
|
+
*/
|
|
50
|
+
export declare type OpenGlobalContextMenuPayload = OpenGlobalContextMenuRequest & {
|
|
51
|
+
/** Template defining the options to show in the context menu. */
|
|
52
|
+
template: OpenFin.MenuItemTemplate[];
|
|
53
|
+
/** Identity of the Browser window where context menu should be shown. */
|
|
54
|
+
identity: NamedIdentity;
|
|
55
|
+
/** Default function that handles stock context menu options. */
|
|
56
|
+
callback: (data: MenuData) => any;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Request to update the attributes of a page in which is attached to a running browser window.
|
|
60
|
+
*/
|
|
61
|
+
export interface UpdateAttachedPageRequest {
|
|
21
62
|
/** The ID of the page to update. */
|
|
22
63
|
pageId: string;
|
|
23
64
|
/** The updated page. */
|
|
24
65
|
page: Partial<PageWithUpdatableRuntimeAttribs>;
|
|
25
66
|
}
|
|
26
|
-
export
|
|
27
|
-
|
|
67
|
+
export declare enum BrowserButtonType {
|
|
68
|
+
ShowHideTabs = "ShowHideTabs",
|
|
69
|
+
ColorLinking = "ColorLinking",
|
|
70
|
+
PresetLayouts = "PresetLayouts",
|
|
71
|
+
SavePage = "SavePage",
|
|
72
|
+
Minimise = "Minimise",
|
|
73
|
+
Maximise = "Maximise",
|
|
74
|
+
Close = "Close",
|
|
75
|
+
Custom = "Custom"
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The shape of the payload sent by a custom button click to a custom action handler
|
|
79
|
+
*/
|
|
80
|
+
export interface CustomButtonActionPayload {
|
|
81
|
+
callerType: CustomActionCallerType.CustomButton;
|
|
82
|
+
windowIdentity: OpenFin.Identity;
|
|
83
|
+
customData: any;
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
}
|
|
87
|
+
export interface CustomBrowserButtonConfig {
|
|
88
|
+
type: BrowserButtonType.Custom;
|
|
89
|
+
tooltip: string;
|
|
90
|
+
disabled?: boolean;
|
|
91
|
+
iconUrl: string;
|
|
92
|
+
action: CustomActionSpecifier;
|
|
93
|
+
}
|
|
94
|
+
export interface PreDefinedButtonConfig {
|
|
95
|
+
type: BrowserButtonType;
|
|
96
|
+
tooltip?: string;
|
|
97
|
+
iconUrl?: string;
|
|
98
|
+
iconProps?: IconProps;
|
|
99
|
+
}
|
|
100
|
+
declare type ShowHideTabsConfig = {
|
|
101
|
+
type: BrowserButtonType.ShowHideTabs;
|
|
102
|
+
};
|
|
103
|
+
export declare type IconTrayButton = ShowHideTabsConfig | CustomBrowserButtonConfig | PreDefinedButtonConfig;
|
|
104
|
+
export interface IconTrayOptions {
|
|
105
|
+
buttons: IconTrayButton[];
|
|
106
|
+
}
|
|
107
|
+
export declare type WindowStateButton = CustomBrowserButtonConfig | PreDefinedButtonConfig;
|
|
108
|
+
export interface WindowStateButtonOptions {
|
|
109
|
+
buttons: WindowStateButton[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Request for creating a browser window.
|
|
113
|
+
*/
|
|
28
114
|
export interface BrowserCreateWindowRequest extends Omit<OpenFin.PlatformWindowCreationOptions, 'workspacePlatform'> {
|
|
115
|
+
/** WorkspacePlatform specific window options. These options will not work unless a workspace platform has been initialized. */
|
|
29
116
|
workspacePlatform: {
|
|
117
|
+
/** The initial set of pages to add to the created browser window. */
|
|
30
118
|
pages: Page[];
|
|
119
|
+
/** The favicon to display on the top left of the created browser window. */
|
|
31
120
|
favicon?: string;
|
|
121
|
+
/** A UI friendly title for the created browser window. */
|
|
32
122
|
title?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Landing page that shows up when you add a new tab from the plus button that exists in the tabstrip.
|
|
125
|
+
* 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.
|
|
126
|
+
*/
|
|
33
127
|
newTabUrl?: string;
|
|
128
|
+
/**
|
|
129
|
+
* 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.
|
|
130
|
+
* 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.
|
|
131
|
+
*/
|
|
34
132
|
newPageUrl?: string;
|
|
133
|
+
iconTrayOptions?: IconTrayOptions;
|
|
134
|
+
windowStateButtonOptions?: WindowStateButtonOptions;
|
|
135
|
+
/**
|
|
136
|
+
* Remove the Page UI and only allow a single page in the browser window.
|
|
137
|
+
* Must be set to true for this behavior. If this is not set to false,
|
|
138
|
+
* then an empty `pages` option will be populated with a single page.
|
|
139
|
+
*/
|
|
140
|
+
disableMultiplePages?: boolean;
|
|
35
141
|
};
|
|
36
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* A window that is part of a browser snapshot.
|
|
145
|
+
*/
|
|
146
|
+
export declare type BrowserSnapshotWindow = OpenFin.WindowCreationOptions & BrowserCreateWindowRequest;
|
|
147
|
+
/**
|
|
148
|
+
* A browser snapshot.
|
|
149
|
+
*/
|
|
150
|
+
export interface BrowserSnapshot {
|
|
151
|
+
/** The state of the windows that were running at the time the snapshot was taken. */
|
|
152
|
+
windows: BrowserSnapshotWindow[];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Controller for interacting with a browser window.
|
|
156
|
+
*/
|
|
37
157
|
export interface BrowserWindowModule {
|
|
158
|
+
/** The identity of the browser window. */
|
|
38
159
|
identity: OpenFin.Identity;
|
|
160
|
+
/** Underlying OpenFin window Controller. */
|
|
39
161
|
openfinWindow: OpenFin.Window;
|
|
162
|
+
/**
|
|
163
|
+
* Get a page that is attached to the browser window.
|
|
164
|
+
*
|
|
165
|
+
* ```ts
|
|
166
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
167
|
+
*
|
|
168
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
169
|
+
* // assume a browser window already exists
|
|
170
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
171
|
+
* const page = await windows[0].getPage('MyPageId');
|
|
172
|
+
* ```
|
|
173
|
+
* @param id the id of the page to get.
|
|
174
|
+
*/
|
|
40
175
|
getPage(id: string): Promise<AttachedPage>;
|
|
41
176
|
/**
|
|
42
177
|
* Return all the pages that are attached to a browser window.
|
|
178
|
+
*
|
|
179
|
+
* ```ts
|
|
180
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
181
|
+
*
|
|
182
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
183
|
+
* // assume a browser window already exists
|
|
184
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
185
|
+
* const pages = await windows[0].getPages();
|
|
186
|
+
* ```
|
|
43
187
|
*/
|
|
44
188
|
getPages(): Promise<AttachedPage[]>;
|
|
189
|
+
/**
|
|
190
|
+
* Set the active page for the browser window. If `multiplePagesDisabled` is `true` an error will be thrown.
|
|
191
|
+
*
|
|
192
|
+
* ```ts
|
|
193
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
194
|
+
*
|
|
195
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
196
|
+
* // assume a browser window already exists
|
|
197
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
198
|
+
* await windows[0].setActivePage('MyPageId');
|
|
199
|
+
* ```
|
|
200
|
+
* @param id the id of the attached page to set as active.
|
|
201
|
+
*/
|
|
45
202
|
setActivePage(id: string): Promise<void>;
|
|
46
203
|
/**
|
|
47
204
|
* Attach a page to a browser window.
|
|
48
|
-
* If a page with same id or title is attached to an existing browser window, an error will be thrown.
|
|
205
|
+
* If `multiplePagesDisabled` is `true` or a page with same id or title is attached to an existing browser window, an error will be thrown.
|
|
206
|
+
*
|
|
207
|
+
* ```ts
|
|
208
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
49
209
|
*
|
|
210
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
211
|
+
* const layout = {
|
|
212
|
+
* content: [
|
|
213
|
+
* {
|
|
214
|
+
* type: 'stack',
|
|
215
|
+
* content: [
|
|
216
|
+
* {
|
|
217
|
+
* type: 'component',
|
|
218
|
+
* componentName: 'view',
|
|
219
|
+
* componentState: {
|
|
220
|
+
* name: 'myViewName',
|
|
221
|
+
* url: 'http://google.com'
|
|
222
|
+
* }
|
|
223
|
+
* }
|
|
224
|
+
* ]
|
|
225
|
+
* }
|
|
226
|
+
* ]
|
|
227
|
+
* };
|
|
228
|
+
* const page = {
|
|
229
|
+
* title: 'myPageTitle',
|
|
230
|
+
* pageId: 'myPageId',
|
|
231
|
+
* layout
|
|
232
|
+
* };
|
|
233
|
+
* // assume a browser window already exists
|
|
234
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
235
|
+
* await windows[0].addPage(page);
|
|
236
|
+
* // focus window
|
|
237
|
+
* await windows[0].openfinWindow.focus();
|
|
238
|
+
* // restore window if minimized
|
|
239
|
+
* await windows[0].openfinWindow.restore();
|
|
240
|
+
* ```
|
|
50
241
|
* @param page the attach page to a browser window.
|
|
51
242
|
*/
|
|
52
243
|
addPage(page: PageWithUpdatableRuntimeAttribs): Promise<void>;
|
|
244
|
+
/**
|
|
245
|
+
* Remove an attached page from the browser window.
|
|
246
|
+
*
|
|
247
|
+
* ```ts
|
|
248
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
249
|
+
*
|
|
250
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
251
|
+
* // assume a browser window already exists
|
|
252
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
253
|
+
* await windows[0].removePage('myPageId');
|
|
254
|
+
* ```
|
|
255
|
+
* @param id the id of the attached page to remove from the browser window.
|
|
256
|
+
*/
|
|
53
257
|
removePage(id: string): Promise<void>;
|
|
54
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Update a page in which is attached to the browser window.
|
|
260
|
+
*
|
|
261
|
+
* ```ts
|
|
262
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
263
|
+
*
|
|
264
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
265
|
+
* const layout = {
|
|
266
|
+
* content: [
|
|
267
|
+
* {
|
|
268
|
+
* type: 'stack',
|
|
269
|
+
* content: [
|
|
270
|
+
* {
|
|
271
|
+
* type: 'component',
|
|
272
|
+
* componentName: 'view',
|
|
273
|
+
* componentState: {
|
|
274
|
+
* name: 'myViewName',
|
|
275
|
+
* url: 'http://google.com'
|
|
276
|
+
* }
|
|
277
|
+
* }
|
|
278
|
+
* ]
|
|
279
|
+
* }
|
|
280
|
+
* ]
|
|
281
|
+
* };
|
|
282
|
+
* const page = {
|
|
283
|
+
* title: 'myPageTitle',
|
|
284
|
+
* pageId: 'myPageId',
|
|
285
|
+
* layout
|
|
286
|
+
* };
|
|
287
|
+
* // assume a browser window already exists
|
|
288
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
289
|
+
* const req = {
|
|
290
|
+
* pageId: 'myPageId',
|
|
291
|
+
* page
|
|
292
|
+
* };
|
|
293
|
+
* await windows[0].updatePage(req);
|
|
294
|
+
* ```
|
|
295
|
+
* @param req the update request.
|
|
296
|
+
*/
|
|
297
|
+
updatePage(req: UpdateAttachedPageRequest): Promise<void>;
|
|
298
|
+
/**
|
|
299
|
+
* Reorder pages attached to the browser window. If `multiplePagesDisabled` is `true` an error will be thrown.
|
|
300
|
+
*
|
|
301
|
+
* ```ts
|
|
302
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
303
|
+
*
|
|
304
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
305
|
+
* // assume a browser window already exists and has three pages in it
|
|
306
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
307
|
+
* await windows[0].reorderPages(['myPageId2', 'myPageId1', 'myPageId3']);
|
|
308
|
+
* ```
|
|
309
|
+
* @param req the reorder pages request.
|
|
310
|
+
*/
|
|
55
311
|
reorderPages(req: ReorderPagesRequest): Promise<void>;
|
|
56
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* Factory for wrapping browser windows and global operations.
|
|
315
|
+
*/
|
|
57
316
|
export interface BrowserWindowFactory {
|
|
58
317
|
/**
|
|
59
318
|
* Synchronously returns a Browser Window object that represents an existing window
|
|
@@ -62,42 +321,259 @@ export interface BrowserWindowFactory {
|
|
|
62
321
|
*/
|
|
63
322
|
wrapSync: (identity: OpenFin.Identity) => BrowserWindowModule;
|
|
64
323
|
/**
|
|
65
|
-
* Get a list of pages that are
|
|
324
|
+
* Get a list of all pages that are attached to any running browser window.
|
|
325
|
+
*
|
|
326
|
+
* ```ts
|
|
327
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
328
|
+
*
|
|
329
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
330
|
+
* const attachedPages = await workspacePlatform.Browser.getAllAttachedPages();
|
|
331
|
+
* ```
|
|
66
332
|
*/
|
|
67
|
-
|
|
333
|
+
getAllAttachedPages(): Promise<AttachedPage[]>;
|
|
68
334
|
/**
|
|
69
|
-
* Get all the Browser Windows that are
|
|
335
|
+
* Get all the Browser Windows that are running in the Workspace Platform.
|
|
70
336
|
*
|
|
337
|
+
* ```ts
|
|
338
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
339
|
+
*
|
|
340
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
341
|
+
* const windows = await workspacePlatform.Browser.getAllWindows();
|
|
342
|
+
* ```
|
|
71
343
|
*/
|
|
72
344
|
getAllWindows(): Promise<BrowserWindowModule[]>;
|
|
73
345
|
/**
|
|
74
346
|
* Create a new browser window.
|
|
75
347
|
*
|
|
348
|
+
* ```ts
|
|
349
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
350
|
+
*
|
|
351
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
352
|
+
* const layout = {
|
|
353
|
+
* content: [
|
|
354
|
+
* {
|
|
355
|
+
* type: 'stack',
|
|
356
|
+
* content: [
|
|
357
|
+
* {
|
|
358
|
+
* type: 'component',
|
|
359
|
+
* componentName: 'view',
|
|
360
|
+
* componentState: {
|
|
361
|
+
* name: 'myViewName',
|
|
362
|
+
* url: 'http://google.com'
|
|
363
|
+
* }
|
|
364
|
+
* }
|
|
365
|
+
* ]
|
|
366
|
+
* }
|
|
367
|
+
* ]
|
|
368
|
+
* };
|
|
369
|
+
* const page = {
|
|
370
|
+
* title: 'myPageTitle',
|
|
371
|
+
* pageId: 'myPageId',
|
|
372
|
+
* layout
|
|
373
|
+
* };
|
|
374
|
+
* const options: BrowserCreateWindowRequest = {
|
|
375
|
+
* workspacePlatform {
|
|
376
|
+
* pages: [page],
|
|
377
|
+
* title: 'My Window Title',
|
|
378
|
+
* favicon: 'https://google.com/favicon.ico'
|
|
379
|
+
* }
|
|
380
|
+
* };
|
|
381
|
+
* const window = await workspacePlatform.Browser.createWindow(options);
|
|
382
|
+
* ```
|
|
383
|
+
*
|
|
76
384
|
* @param options the browser window creation options
|
|
77
385
|
*/
|
|
78
|
-
createWindow
|
|
386
|
+
createWindow(options: BrowserCreateWindowRequest): Promise<BrowserWindowModule>;
|
|
79
387
|
/**
|
|
80
388
|
* Get a unique title for a page.
|
|
389
|
+
*
|
|
390
|
+
* ```ts
|
|
391
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
392
|
+
*
|
|
393
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
394
|
+
* const uniqueTitle = await workspacePlatform.Browser.getUniquePageTitle('myTitle');
|
|
395
|
+
* ```
|
|
81
396
|
* @param title a prefix for the title.
|
|
82
397
|
*/
|
|
83
398
|
getUniquePageTitle(title?: string): Promise<string>;
|
|
84
399
|
/**
|
|
85
400
|
* Get the identity of the last focused Browser window.
|
|
401
|
+
*
|
|
402
|
+
* ```ts
|
|
403
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
404
|
+
*
|
|
405
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
406
|
+
* const windowIdentity = await workspacePlatform.Browser.getLastFocusedWindow();
|
|
407
|
+
* ```
|
|
86
408
|
*/
|
|
87
409
|
getLastFocusedWindow(): Promise<OpenFin.Identity>;
|
|
88
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* API for interacting with persistent storage.
|
|
413
|
+
*/
|
|
89
414
|
export interface WorkspacePlatformStorage {
|
|
415
|
+
/**
|
|
416
|
+
* Get all pages that are saved in persistent storage.
|
|
417
|
+
*
|
|
418
|
+
* ```ts
|
|
419
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
420
|
+
*
|
|
421
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
422
|
+
* const pages = await workspacePlatform.Storage.getPages();
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
90
425
|
getPages(): Promise<Page[]>;
|
|
426
|
+
/**
|
|
427
|
+
* Get a specific page in persistent storage.
|
|
428
|
+
*
|
|
429
|
+
* ```ts
|
|
430
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
431
|
+
*
|
|
432
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
433
|
+
* const myPage = await workspacePlatform.Storage.getPage('myPageId');
|
|
434
|
+
* ```
|
|
435
|
+
* @param id the id of the page to get.
|
|
436
|
+
*/
|
|
91
437
|
getPage(id: string): Promise<Page>;
|
|
438
|
+
/**
|
|
439
|
+
* Create a page in persistent storage.
|
|
440
|
+
*
|
|
441
|
+
* ```ts
|
|
442
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
443
|
+
*
|
|
444
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
445
|
+
* const layout = {
|
|
446
|
+
* content: [
|
|
447
|
+
* {
|
|
448
|
+
* type: 'stack',
|
|
449
|
+
* content: [
|
|
450
|
+
* {
|
|
451
|
+
* type: 'component',
|
|
452
|
+
* componentName: 'view',
|
|
453
|
+
* componentState: {
|
|
454
|
+
* name: 'myViewName',
|
|
455
|
+
* url: 'http://google.com'
|
|
456
|
+
* }
|
|
457
|
+
* }
|
|
458
|
+
* ]
|
|
459
|
+
* }
|
|
460
|
+
* ]
|
|
461
|
+
* };
|
|
462
|
+
* const page = {
|
|
463
|
+
* title: 'myPageTitle',
|
|
464
|
+
* pageId: 'myPageId',
|
|
465
|
+
* layout
|
|
466
|
+
* };
|
|
467
|
+
* await workspacePlatform.Storage.createPage({page});
|
|
468
|
+
* ```
|
|
469
|
+
* @param page the page to create in persistent storage.
|
|
470
|
+
*/
|
|
92
471
|
createPage(page: CreateSavedPageRequest): Promise<void>;
|
|
472
|
+
/**
|
|
473
|
+
* Update a page in persistent storage.
|
|
474
|
+
*
|
|
475
|
+
* ```ts
|
|
476
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
477
|
+
*
|
|
478
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
479
|
+
* const layout = {
|
|
480
|
+
* content: [
|
|
481
|
+
* {
|
|
482
|
+
* type: 'stack',
|
|
483
|
+
* content: [
|
|
484
|
+
* {
|
|
485
|
+
* type: 'component',
|
|
486
|
+
* componentName: 'view',
|
|
487
|
+
* componentState: {
|
|
488
|
+
* name: 'myViewName',
|
|
489
|
+
* url: 'http://google.com'
|
|
490
|
+
* }
|
|
491
|
+
* }
|
|
492
|
+
* ]
|
|
493
|
+
* }
|
|
494
|
+
* ]
|
|
495
|
+
* };
|
|
496
|
+
* const page = {
|
|
497
|
+
* title: 'myPageTitle',
|
|
498
|
+
* pageId: 'myPageId',
|
|
499
|
+
* layout
|
|
500
|
+
* };
|
|
501
|
+
* const req = {
|
|
502
|
+
* pageId: 'myPageId',
|
|
503
|
+
* page
|
|
504
|
+
* };
|
|
505
|
+
* await workspacePlatform.Storage.updatePage(req);
|
|
506
|
+
* ```
|
|
507
|
+
* @param req the update saved page request.
|
|
508
|
+
*/
|
|
93
509
|
updatePage(req: UpdateSavedPageRequest): Promise<void>;
|
|
510
|
+
/**
|
|
511
|
+
* Delete a page from persistent storage.
|
|
512
|
+
*
|
|
513
|
+
* ```ts
|
|
514
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
515
|
+
*
|
|
516
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
517
|
+
* await workspacePlatform.Storage.deletePage('myPageId');
|
|
518
|
+
* ```
|
|
519
|
+
* @param id the id of the page to delete.
|
|
520
|
+
*/
|
|
94
521
|
deletePage(id: string): Promise<void>;
|
|
522
|
+
/**
|
|
523
|
+
* Save a page in persistent storage.
|
|
524
|
+
*
|
|
525
|
+
* This is a helper function that will call `getPage` to determine if a page is already in storage.
|
|
526
|
+
* If the page is already in storage, it will call `updatePage`.
|
|
527
|
+
* If it does not exist in storage, the function will call `createPage` instead.
|
|
528
|
+
*
|
|
529
|
+
* ```ts
|
|
530
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
531
|
+
*
|
|
532
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
533
|
+
* const layout = {
|
|
534
|
+
* content: [
|
|
535
|
+
* {
|
|
536
|
+
* type: 'stack',
|
|
537
|
+
* content: [
|
|
538
|
+
* {
|
|
539
|
+
* type: 'component',
|
|
540
|
+
* componentName: 'view',
|
|
541
|
+
* componentState: {
|
|
542
|
+
* name: 'myViewName',
|
|
543
|
+
* url: 'http://google.com'
|
|
544
|
+
* }
|
|
545
|
+
* }
|
|
546
|
+
* ]
|
|
547
|
+
* }
|
|
548
|
+
* ]
|
|
549
|
+
* };
|
|
550
|
+
* const page = {
|
|
551
|
+
* title: 'myPageTitle',
|
|
552
|
+
* pageId: 'myPageId',
|
|
553
|
+
* layout
|
|
554
|
+
* };
|
|
555
|
+
* await workspacePlatform.Storage.savePage(page);
|
|
556
|
+
* ```
|
|
557
|
+
* @param page the page to save.
|
|
558
|
+
*/
|
|
95
559
|
savePage(page: Page): Promise<void>;
|
|
96
560
|
}
|
|
97
|
-
|
|
561
|
+
/**
|
|
562
|
+
* Request for launching an application.
|
|
563
|
+
*/
|
|
564
|
+
export interface LaunchAppRequest {
|
|
98
565
|
target?: OpenFin.EntityInfo;
|
|
99
566
|
app: App;
|
|
100
567
|
}
|
|
568
|
+
/**
|
|
569
|
+
* Get Themes from API
|
|
570
|
+
*/
|
|
571
|
+
export interface ThemeApi {
|
|
572
|
+
getThemes(): Promise<CustomThemes>;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Controller for a Workspace Platform.
|
|
576
|
+
*/
|
|
101
577
|
export interface WorkspacePlatformModule extends OpenFin.Platform {
|
|
102
578
|
/**
|
|
103
579
|
* Launch a browser snapshot that contains windows with pages.
|
|
@@ -105,29 +581,200 @@ export interface WorkspacePlatformModule extends OpenFin.Platform {
|
|
|
105
581
|
* @param snapshot the browser snapshot to launch or a url or filepath to retrieve a JSON snapshot.
|
|
106
582
|
*/
|
|
107
583
|
applySnapshot(snapshot: BrowserSnapshot | string): Promise<OpenFin.Platform>;
|
|
584
|
+
/**
|
|
585
|
+
* Get a snapshot that contains browser windows with pages.
|
|
586
|
+
*/
|
|
108
587
|
getSnapshot(): Promise<BrowserSnapshot>;
|
|
109
|
-
|
|
588
|
+
/**
|
|
589
|
+
* Launch an application.
|
|
590
|
+
* ```ts
|
|
591
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
592
|
+
*
|
|
593
|
+
* const workspacePlatform = WorkspacePlatform.getCurrentSync();
|
|
594
|
+
* const req = {
|
|
595
|
+
* app: {
|
|
596
|
+
* appId: 'myAppId',
|
|
597
|
+
* title: 'appTitle',
|
|
598
|
+
* manifest: 'http://localhost/app.json',
|
|
599
|
+
* manifestType: AppManifestType.Manifest,
|
|
600
|
+
* icons:[
|
|
601
|
+
* {
|
|
602
|
+
* icon: "https://cdn.openfin.co/demos/notifications/generator/images/icon-blue.png",
|
|
603
|
+
* src: "https://cdn.openfin.co/demos/notifications/generator/images/icon-blue.png",
|
|
604
|
+
* type: "ico",
|
|
605
|
+
* },
|
|
606
|
+
* ]
|
|
607
|
+
* }
|
|
608
|
+
* }
|
|
609
|
+
* workspacePlatform.launchApp(req);
|
|
610
|
+
*
|
|
611
|
+
* ```
|
|
612
|
+
* @param req the launch app request.
|
|
613
|
+
*/
|
|
614
|
+
launchApp(req: LaunchAppRequest): Promise<void>;
|
|
615
|
+
/**
|
|
616
|
+
* The browser window factory for the Workspace Platform.
|
|
617
|
+
*/
|
|
110
618
|
Browser: BrowserWindowFactory;
|
|
619
|
+
/**
|
|
620
|
+
* The storage API for the Workspace Platform.
|
|
621
|
+
*/
|
|
111
622
|
Storage: WorkspacePlatformStorage;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
623
|
+
/**
|
|
624
|
+
* Theme API for the Workspace Platform.
|
|
625
|
+
*/
|
|
626
|
+
Theme: ThemeApi;
|
|
115
627
|
}
|
|
116
628
|
export interface WorkspacePlatformProvider extends OpenFin.PlatformProvider {
|
|
629
|
+
/**
|
|
630
|
+
* Implementation for getting a list of saved pages from persistent storage.
|
|
631
|
+
* @param query an optional query.
|
|
632
|
+
*/
|
|
117
633
|
getSavedPages(query?: string): Promise<Page[]>;
|
|
634
|
+
/**
|
|
635
|
+
* Implementation for getting a single page in persistent storage.
|
|
636
|
+
* @param id
|
|
637
|
+
*/
|
|
118
638
|
getSavedPage(id: string): Promise<Page>;
|
|
639
|
+
/**
|
|
640
|
+
* Implementation for creating a saved page in persistent storage.
|
|
641
|
+
* @param req the create saved page request.
|
|
642
|
+
*/
|
|
119
643
|
createSavedPage(req: CreateSavedPageRequest): Promise<void>;
|
|
644
|
+
/**
|
|
645
|
+
* Implementation for updating a saved page in persistent storage.
|
|
646
|
+
* @param req the update saved page request.
|
|
647
|
+
*/
|
|
120
648
|
updateSavedPage(req: UpdateSavedPageRequest): Promise<void>;
|
|
649
|
+
/**
|
|
650
|
+
* Implementation for deleting a saved page in persistent storage.
|
|
651
|
+
* @param id of the id of the page to delete.
|
|
652
|
+
*/
|
|
121
653
|
deleteSavedPage(id: string): Promise<void>;
|
|
654
|
+
/**
|
|
655
|
+
* Implementation for showing a global context menu given a menu template,
|
|
656
|
+
* handler callback, and screen coordinates
|
|
657
|
+
* @param req the payload received by the provider call
|
|
658
|
+
* @param callerIdentity OF identity of the entity from which the request originated
|
|
659
|
+
*/
|
|
660
|
+
openGlobalContextMenu(req: OpenGlobalContextMenuPayload, callerIdentity: any): any;
|
|
661
|
+
}
|
|
662
|
+
export declare enum CustomActionCallerType {
|
|
663
|
+
CustomButton = "CustomButton",
|
|
664
|
+
ContextMenu = "ContextMenu",
|
|
665
|
+
API = "API"
|
|
666
|
+
}
|
|
667
|
+
export interface CustomActionPayload {
|
|
668
|
+
callerType: CustomActionCallerType;
|
|
669
|
+
[x: string]: any;
|
|
670
|
+
}
|
|
671
|
+
export interface CustomActionSpecifier {
|
|
672
|
+
/** Identifier of a custom action defined at platform initialization*/
|
|
673
|
+
id: string;
|
|
674
|
+
/** Any data necessary for the functioning of specified custom action*/
|
|
675
|
+
customData: any;
|
|
676
|
+
}
|
|
677
|
+
export interface InvokeCustomActionRequest {
|
|
678
|
+
actionId: string;
|
|
679
|
+
payload: CustomActionPayload;
|
|
122
680
|
}
|
|
681
|
+
export interface CustomActionsMap {
|
|
682
|
+
[x: string]: (payload: CustomActionPayload) => any;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Configuration for initializing a Workspace platform.
|
|
686
|
+
*/
|
|
123
687
|
export interface WorkspacePlatformInitConfig {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
688
|
+
customActions?: CustomActionsMap;
|
|
689
|
+
/** Config for overriding browser options and behavior. */
|
|
690
|
+
browser?: BrowserInitConfig;
|
|
691
|
+
/** Custom Themes object
|
|
692
|
+
*
|
|
693
|
+
* ```ts
|
|
694
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
695
|
+
*
|
|
696
|
+
* // This is the palette used to create the OpenFin dark theme
|
|
697
|
+
* const customPalette: WorkspacePlatform.CustomPaletteSet = {
|
|
698
|
+
* brandPrimary: '#504CFF',
|
|
699
|
+
* brandSecondary: '#383A40',
|
|
700
|
+
* backgroundPrimary: '#000',
|
|
701
|
+
* background1: '#111214',
|
|
702
|
+
* background2: '#1E1F23',
|
|
703
|
+
* background3: '#24262B',
|
|
704
|
+
* background4: '#2F3136',
|
|
705
|
+
* background5: '#383A40',
|
|
706
|
+
* background6: '#53565F',
|
|
707
|
+
* statusSuccess: '#35C759',
|
|
708
|
+
* statusWarning: '#C93400',
|
|
709
|
+
* statusCritical: '#000',
|
|
710
|
+
* statusActive: '#0879C4',
|
|
711
|
+
* inputBackground: '#53565F',
|
|
712
|
+
* inputColor: '#FFFFFF',
|
|
713
|
+
* inputPlaceholder: '#C9CBD2',
|
|
714
|
+
* inputDisabled: '#7D808A',
|
|
715
|
+
* inputFocused: '#C9CBD2',
|
|
716
|
+
* textDefault: '#FFFFFF',
|
|
717
|
+
* textHelp: '#C9CBD2',
|
|
718
|
+
* textInactive: '#7D808A',
|
|
719
|
+
* };
|
|
720
|
+
*
|
|
721
|
+
* const customTheme: WorkspacePlatform.CustomThemes = [{
|
|
722
|
+
* label: "My Custom Theme",
|
|
723
|
+
* palette: customPalette
|
|
724
|
+
* }];
|
|
725
|
+
*
|
|
726
|
+
* await WorkspacePlatform.init({
|
|
727
|
+
* browser: { overrideCallback },
|
|
728
|
+
* theme: customThemes
|
|
729
|
+
* });
|
|
730
|
+
*/
|
|
731
|
+
theme?: CustomThemes;
|
|
127
732
|
}
|
|
733
|
+
/**
|
|
734
|
+
* Extend or replace default functionality in order to customize behavior of a Workspace Platform Provider.
|
|
735
|
+
*
|
|
736
|
+
* To implement your own handlers for Workspace Platform behavior, extend the provided class and override any methods you'd like to alter.
|
|
737
|
+
*
|
|
738
|
+
* ```ts
|
|
739
|
+
* import * as WorkspacePlatform from '@openfin/workspace-platform';
|
|
740
|
+
* import { UpdateSavedPageRequest } from '../../client-api-platform/src/shapes';
|
|
741
|
+
*
|
|
742
|
+
* const overrideCallback: WorkspacePlatform.BrowserOverrideCallback = async (
|
|
743
|
+
* WorkspacePlatformProvider
|
|
744
|
+
* ) => {
|
|
745
|
+
* class Override extends WorkspacePlatformProvider {
|
|
746
|
+
* updateSavedPage = async (req: UpdateSavedPageRequest): Promise<void> => {
|
|
747
|
+
* console.log(`saving page ${req.page.pageId}`);
|
|
748
|
+
* // calling custom function to the save page here
|
|
749
|
+
* };
|
|
750
|
+
* }
|
|
751
|
+
* return new Override();
|
|
752
|
+
* };
|
|
753
|
+
*
|
|
754
|
+
* await WorkspacePlatform.init({
|
|
755
|
+
* browser: { overrideCallback },
|
|
756
|
+
* });
|
|
757
|
+
*/
|
|
758
|
+
export declare type BrowserOverrideCallback = OpenFin.OverrideCallback<WorkspacePlatformProvider>;
|
|
759
|
+
/**
|
|
760
|
+
* Configuration for initializing a Browser.
|
|
761
|
+
*/
|
|
128
762
|
export interface BrowserInitConfig {
|
|
763
|
+
/**
|
|
764
|
+
* 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.
|
|
765
|
+
*/
|
|
129
766
|
defaultWindowOptions?: BrowserCreateWindowRequest;
|
|
767
|
+
/**
|
|
768
|
+
* 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.
|
|
769
|
+
*/
|
|
130
770
|
defaultViewOptions?: OpenFin.ViewOptions;
|
|
131
|
-
|
|
771
|
+
/**
|
|
772
|
+
* Override workspace platform behavior
|
|
773
|
+
*/
|
|
774
|
+
overrideCallback?: BrowserOverrideCallback;
|
|
775
|
+
/**
|
|
776
|
+
* Override workspace platform interop behavior
|
|
777
|
+
* https://cdn.openfin.co/docs/javascript/stable/InteropBroker.html
|
|
778
|
+
*/
|
|
132
779
|
interopOverride?: OpenFin.OverrideCallback<InteropBroker, InteropBroker>;
|
|
133
780
|
}
|