@openfin/workspace-platform 5.3.1 → 5.6.3

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.
@@ -1,12 +1,15 @@
1
1
  /// <reference types="openfin-adapter/fin" />
2
2
  import type { InteropBroker } from 'openfin-adapter/src/api/interop';
3
+ import { NamedIdentity } from 'openfin-adapter/src/identity';
3
4
  import type { AttachedPage, Page, PageWithUpdatableRuntimeAttribs } from '../../common/src/api/pages/shapes';
4
5
  import type { CustomThemes } from '../../common/src/api/theming';
5
6
  import type { App } from '../../client-api/src/shapes';
7
+ import { MenuData } from './api/context-menu/browser-logo-handler';
6
8
  export type { CustomThemes } from '../../common/src/api/theming';
7
9
  export type { App, Image, AppIntent } from '../../client-api/src/shapes';
8
10
  export { AppManifestType } from '../../client-api/src/shapes';
9
11
  export type { AttachedPage, Page, PageWithUpdatableRuntimeAttribs, PageLayout, PageLayoutDetails } from '../../common/src/api/pages/shapes';
12
+ import type { IconProps } from '@openfin/ui-library';
10
13
  /**
11
14
  * Request for creating a saved page in persistent storage.
12
15
  */
@@ -30,6 +33,28 @@ export interface ReorderPagesRequest {
30
33
  /** An array of page ids that specify the order of the pages attached to the window. */
31
34
  pageIds: string[];
32
35
  }
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
+ };
33
58
  /**
34
59
  * Request to update the attributes of a page in which is attached to a running browser window.
35
60
  */
@@ -39,6 +64,50 @@ export interface UpdateAttachedPageRequest {
39
64
  /** The updated page. */
40
65
  page: Partial<PageWithUpdatableRuntimeAttribs>;
41
66
  }
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
+ }
42
111
  /**
43
112
  * Request for creating a browser window.
44
113
  */
@@ -61,6 +130,14 @@ export interface BrowserCreateWindowRequest extends Omit<OpenFin.PlatformWindowC
61
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.
62
131
  */
63
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;
64
141
  };
65
142
  }
66
143
  /**
@@ -110,7 +187,7 @@ export interface BrowserWindowModule {
110
187
  */
111
188
  getPages(): Promise<AttachedPage[]>;
112
189
  /**
113
- * Set the active page for the browser window.
190
+ * Set the active page for the browser window. If `multiplePagesDisabled` is `true` an error will be thrown.
114
191
  *
115
192
  * ```ts
116
193
  * import * as WorkspacePlatform from '@openfin/workspace-platform';
@@ -125,7 +202,7 @@ export interface BrowserWindowModule {
125
202
  setActivePage(id: string): Promise<void>;
126
203
  /**
127
204
  * Attach a page to a browser window.
128
- * 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.
129
206
  *
130
207
  * ```ts
131
208
  * import * as WorkspacePlatform from '@openfin/workspace-platform';
@@ -156,6 +233,10 @@ export interface BrowserWindowModule {
156
233
  * // assume a browser window already exists
157
234
  * const windows = await workspacePlatform.Browser.getAllWindows();
158
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();
159
240
  * ```
160
241
  * @param page the attach page to a browser window.
161
242
  */
@@ -215,7 +296,7 @@ export interface BrowserWindowModule {
215
296
  */
216
297
  updatePage(req: UpdateAttachedPageRequest): Promise<void>;
217
298
  /**
218
- * Reorder pages attached to the browser window.
299
+ * Reorder pages attached to the browser window. If `multiplePagesDisabled` is `true` an error will be thrown.
219
300
  *
220
301
  * ```ts
221
302
  * import * as WorkspacePlatform from '@openfin/workspace-platform';
@@ -570,14 +651,83 @@ export interface WorkspacePlatformProvider extends OpenFin.PlatformProvider {
570
651
  * @param id of the id of the page to delete.
571
652
  */
572
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;
680
+ }
681
+ export interface CustomActionsMap {
682
+ [x: string]: (payload: CustomActionPayload) => any;
573
683
  }
574
684
  /**
575
685
  * Configuration for initializing a Workspace platform.
576
686
  */
577
687
  export interface WorkspacePlatformInitConfig {
688
+ customActions?: CustomActionsMap;
578
689
  /** Config for overriding browser options and behavior. */
579
690
  browser?: BrowserInitConfig;
580
- /** Custom Themes object */
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
+ */
581
731
  theme?: CustomThemes;
582
732
  }
583
733
  /**
@@ -0,0 +1,14 @@
1
+ /// <reference types="openfin-adapter/fin" />
2
+ export declare const getWindowChannelId: (identity: OpenFin.Identity) => string;
3
+ export declare const getChannelClient: (identity: OpenFin.Identity) => Promise<import("openfin-adapter").ChannelClient>;
4
+ /**
5
+ * If the browser window is reloaded too quickly, runtime will
6
+ * respond that the channel provider has already been created.
7
+ * Hence, we retry a couple of times to make sure this does not occur.
8
+ * (Should only happen in local development)
9
+ */
10
+ export declare const createChannel: () => Promise<import("openfin-adapter").ChannelProvider>;
11
+ export declare enum ChannelAction {
12
+ CloseBrowserWindow = "close-browser-window",
13
+ QuitPlatform = "quit-platform"
14
+ }
@@ -21,7 +21,6 @@ export declare enum EventType {
21
21
  AttachedPagesToWindow = "attached-pages-to-window",
22
22
  DetachedPagesFromWindow = "detached-pages-from-window"
23
23
  }
24
- export declare const getWindowChannelId: (identity: OpenFin.Identity) => string;
25
24
  export declare const getEventEmitter: (identity: OpenFin.Identity) => {
26
25
  emit: (event: string | number, ...payload: any[]) => Promise<void>;
27
26
  addListener: (event: string | number, listener: import("@common/utils/shared-emitter").Listener) => void;
@@ -6,7 +6,7 @@ interface Workstack {
6
6
  layout: PageLayout;
7
7
  isActive: boolean;
8
8
  }
9
- export declare function convertWorkstackToAttachedPage(workstack: Workstack & AttachedPage): AttachedPage;
9
+ export declare function convertWorkstackToAttachedPage({ id, name, ...rest }: Workstack & AttachedPage): AttachedPage;
10
10
  /**
11
11
  * Attempts to fix any misconfigurations in a list of attached pages.
12
12
  * @param pages the pages to fix.
@@ -20,8 +20,17 @@ export interface Page {
20
20
  tooltip?: string;
21
21
  /** True if the page is read only. In this state, the page is locked and cannot be unlocked. */
22
22
  isReadOnly?: boolean;
23
+ /** Icon that appears on a page tab if there are unsaved changes (dirty state). If 'undefined', default icon will appear. */
24
+ unsavedIconUrl?: string;
25
+ /** Icon that appears on a page tab if there are no unsaved changes. If 'undefined', default icon will appear. */
26
+ iconUrl?: string;
23
27
  /** The layout of the page. */
24
28
  layout: PageLayout;
29
+ /** Used to manipulate behaviour of a close button on a page tab. If `undefined`, then close button is visible and actionable. */
30
+ closeButton?: {
31
+ hidden?: boolean;
32
+ disabled?: boolean;
33
+ };
25
34
  }
26
35
  declare type AttachedPageMetadata = {
27
36
  /** The window the page is currently attached to. */
@@ -0,0 +1,12 @@
1
+ /// <reference types="openfin-adapter/fin" />
2
+ import { _Window } from 'openfin-adapter/src/api/window';
3
+ export declare enum MenuItemType {
4
+ Label = "normal",
5
+ Separator = "separator",
6
+ Submenu = "submenu",
7
+ Checkbox = "checkbox"
8
+ }
9
+ export declare type ShowContextMenuResponse = OpenFin.MenuResult & {
10
+ data: string;
11
+ };
12
+ export default function showContextMenu(opts: OpenFin.ShowPopupMenuOptions, win?: _Window): Promise<ShowContextMenuResponse>;
@@ -0,0 +1,18 @@
1
+ /// <reference types="openfin-adapter/fin" />
2
+ interface InternalWindowOptions extends OpenFin.PlatformWindowCreationOptions {
3
+ workspacePlatform: OpenFin.WindowOptions['workspacePlatform'] & {
4
+ _internalAutoShow: boolean;
5
+ };
6
+ }
7
+ /**
8
+ * Apply options to a window's options that will disallow the Core from auto showing the window.
9
+ * Instead, a script within the window itself must handle showing the window if deferred auto showing is enabled.
10
+ * When it comes time to show the window, the script can auto show if deferred by simply calling the `autoShowIfDeferred` function.
11
+ * @param opts the window options to apply deferred auto show to.
12
+ */
13
+ export declare function applyDeferAutoShowOptions(opts: OpenFin.PlatformWindowCreationOptions): InternalWindowOptions;
14
+ /**
15
+ * Will show the current window if deferred auto show is enabled.
16
+ */
17
+ export declare function autoShowIfDeferred(): Promise<void>;
18
+ export {};
@@ -12,19 +12,18 @@ export declare const isWindowDefinedWithIndexDB: boolean;
12
12
  export declare const finUUID: string;
13
13
  export declare const finName: string;
14
14
  export declare const finEntityType: "" | import("openfin-adapter/src/shapes/EntityType").EntityType;
15
- export declare const env: Env;
16
15
  export declare const isEnvLocal: boolean;
17
16
  export declare const isEnvDev: boolean;
18
17
  export declare const isEnvStaging: boolean;
19
18
  export declare const isEnvProd: boolean;
20
- export declare const isLibrary: boolean;
21
19
  export declare const workspaceProviderFinsLink: string;
22
20
  export declare const workspaceProviderFallbackUrl: string;
23
- export declare const workspaceAppsUrl: string;
24
- export declare const workspaceStorefrontFooterUrl: string;
25
- export declare const workspaceStorefrontLandingPageUrl: string;
26
- export declare const workspaceStorefrontNavigationUrl: string;
27
- export declare const workspaceShareUrl: string;
28
21
  export declare const workspaceCdnUrl: string;
29
22
  export declare const workspaceCdnEnvUrl: string;
30
23
  export declare const workspaceRuntimeVersion: string;
24
+ /**
25
+ * A promise that resolves when:
26
+ * - The window 'load' event is fired.
27
+ * - The window first paint occurs.
28
+ */
29
+ export declare const firstPaint: Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { NamedIdentity } from 'openfin-adapter/src/identity';
2
+ export declare const getGlobalContextMenuTemplate: (winIdentity: NamedIdentity) => Promise<any[]>;
@@ -0,0 +1,11 @@
1
+ /// <reference types="openfin-adapter/fin" />
2
+ import { NamedIdentity } from 'openfin-adapter/src/identity';
3
+ interface LandingPageUrls {
4
+ newPageUrl: string | false;
5
+ newTabUrl: string | false;
6
+ }
7
+ export declare const getLandingPageUrls: (winIdentity?: NamedIdentity) => Promise<LandingPageUrls>;
8
+ export declare const checkHasNewTabUrl: () => Promise<boolean>;
9
+ export declare const getNewLandingTabViewOptions: (target: OpenFin.Identity) => Promise<OpenFin.PlatformViewCreationOptions>;
10
+ export declare const makeNewLandingPage: (winIdentity?: NamedIdentity) => Promise<import("@client-platform/index").PageWithUpdatableRuntimeAttribs>;
11
+ export {};
@@ -1,4 +1,5 @@
1
1
  /// <reference types="openfin-adapter/fin" />
2
+ import { NamedIdentity } from 'openfin-adapter/src/identity';
2
3
  export declare type LayoutComponentStateExtended = OpenFin.LayoutComponent['componentState'] & {
3
4
  name: string;
4
5
  uuid: string;
@@ -40,7 +41,7 @@ export declare type LayoutDOMEventListener = (ev: LayoutDOMEvent) => void;
40
41
  */
41
42
  export declare const cloneLayoutAndRemoveNames: (layout: any) => any;
42
43
  export declare const mapContentComponentState: (content: OpenFin.LayoutContent | LayoutContentExtended) => LayoutComponentStateExtended[];
43
- export declare const getLayoutWithSingleView: (title: string, url: string) => Promise<any>;
44
+ export declare const getLayoutWithSingleView: (title: string, url: string, winIdentity?: NamedIdentity) => Promise<any>;
44
45
  export declare const isLayoutTabActive: (tabSelector: string) => boolean;
45
46
  export declare const containerId = "layout_container";
46
47
  export declare const getViewComponents: () => LayoutContentExtended;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Deep merge a set of source objects into a single target object.
3
+ * @param target the target object to merge sources into.
4
+ * @param sources the source objects to merge into the target. (FIFO)
5
+ */
6
+ export declare function mergeDeep(target: any, ...sources: any[]): any;
@@ -1,5 +1,3 @@
1
1
  export declare const capitalize: (s: string) => string;
2
- export declare const titleize: (s: string) => string;
3
2
  export declare const pascalize: (s: string) => string;
4
- export declare const slugify: (s: string) => string;
5
3
  export declare const isStringMatchesQuery: (title: string, query?: string) => boolean;
@@ -31,6 +31,9 @@ export interface WindowIdentity {
31
31
  uuid: ApplicationUUID | string;
32
32
  name: WindowName | string;
33
33
  }
34
+ export interface WindowCreationOptionsExtended extends OpenFin.PlatformWindowCreationOptions {
35
+ backgroundThrottling?: boolean;
36
+ }
34
37
  interface Point {
35
38
  left: number;
36
39
  top: number;
@@ -144,4 +147,5 @@ export declare const isStorefrontWindowRunning: () => Promise<boolean>;
144
147
  export declare const isHomeWindowRunning: () => Promise<boolean>;
145
148
  export declare const showAndFocusStorefront: () => Promise<void>;
146
149
  export declare const centerWindowIfOffScreen: (windowIdentity?: WindowIdentity) => Promise<void>;
150
+ export declare const getDisableMultiplePagesOption: (identity: WindowIdentity) => Promise<any>;
147
151
  export {};