@openfin/workspace-platform 12.1.3 → 12.4.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.
@@ -1,6 +1,5 @@
1
1
  export type { Action, DispatchedAction, DispatchedSearchResult, SearchListenerRequest, SearchListenerResponse, SearchProviderInfo, SearchResult, ScoreOrder, SearchTag, SearchProvider, UserInputListener, ResultDispatchListener, SearchResponse } from '../../../search-api/src/index';
2
2
  export type { Workspace } from '../../../common/src/api/workspaces';
3
- export type { LayoutExtended, LayoutContentExtended, LayoutSettingsExtended, LayoutContentItemExtended, LayoutComponentExtended, LayoutComponentStateExtended, LayoutStack } from '../../../common/src/utils/layout';
4
3
  export type { Page, PageLayout, PageLayoutDetails, PanelConfig, PanelConfigHorizontal, PanelConfigVertical, PanelPosition } from '../../../common/src/api/pages/shapes';
5
4
  export { SearchTagBackground, ActionTrigger } from '../../../search-api/src/shapes';
6
5
  export type { ProviderInfo } from './provider';
@@ -8,10 +7,8 @@ export type { BaseCustomButtonConfig, BaseCustomDropdownConfig, BaseCustomDropdo
8
7
  /**
9
8
  * return by component.register function
10
9
  */
11
- export interface RegisterMetaInfo {
12
- workspaceVersion: string;
13
- }
14
10
  export interface RegistrationMetaInfo {
15
11
  clientAPIVersion: string;
16
12
  workspaceVersion: string;
17
13
  }
14
+ export declare type RegisterMetaInfoInternal = Pick<RegistrationMetaInfo, 'workspaceVersion'>;
@@ -237,17 +237,54 @@ export interface StoreRegistration extends RegistrationMetaInfo {
237
237
  * used to update button configuration returned by provider for an app.
238
238
  *
239
239
  * ```ts
240
- * registration = await Store.register(provider);
241
- * registration.updateAppCardButtons({
242
- * appId: request.payload.appId,
243
- * primaryButton: {
244
- * ...request.payload.sourcePrimaryButton,
245
- * title: "Primary button is now disabled",
246
- * disabled: true
247
- * },
248
- * secondaryButtons: request.payload.sourceSecondaryButtons
240
+ * let storeRegistration: StoreRegistration | undefined;
241
+ *
242
+ * await WorkspacePlatform.init({
243
+ * customActions: {
244
+ * storeButtonCustomActionHandler: async (payload: StoreCustomButtonActionPayload) => {
245
+ * if (storeRegistration) {
246
+ * await storeRegistration.updateAppCardButtons({
247
+ * appId: payload.appId,
248
+ * primaryButton: {
249
+ * ...payload.primaryButton,
250
+ * title: 'Disabled Button',
251
+ * disabled: true,
252
+ * },
253
+ * secondaryButtons: payload.secondaryButtons
254
+ * });
255
+ * }
256
+ * }
257
+ * }
249
258
  * });
250
- * ```
259
+ *
260
+ * const sampleApp: App = {
261
+ * title: 'Sample Application',
262
+ * addId: 'sampleAppId',
263
+ * icons: [],
264
+ * publisher: 'Sample',
265
+ * primaryButton: {
266
+ * title: 'Sample Button',
267
+ * action: {
268
+ * id: 'storeButtonCustomActionHandler',
269
+ * }
270
+ * }
271
+ * },
272
+ *
273
+ * const storefrontProvider: StorefrontProvider = {
274
+ * title: 'Sample Store',
275
+ * id: 'sampleStoreId',
276
+ * icon: {...},
277
+ * getApps: () => Promise.resolve([sampleApp]),
278
+ * getLandingPage: {...},
279
+ * getNavigation: {...},
280
+ * getFooter: {...},
281
+ * launchApp: (app: App) => WR.getCurrentSync().launchApp({app})
282
+ * };
283
+ *
284
+ * storeRegistration = await Store.register(storefrontProvider);
285
+ * await Store.show();
286
+ *
287
+ * ```
251
288
  */
252
289
  updateAppCardButtons: (request: UpdateButtonConfigRequest) => Promise<void>;
253
290
  }
@@ -1,8 +1,11 @@
1
- import type { CreateSavedWorkspaceRequest, Workspace } from '../../../../client-api-platform/src/shapes';
1
+ import type { ApplyWorkspacePayload, CreateSavedWorkspaceRequest, Workspace } from '../../../../client-api-platform/src/shapes';
2
2
  /**
3
3
  * Apply the given workspace and set it as active.
4
+ * @param payload, the workspace to apply and the options to apply it with.
5
+ *
6
+ * @returns true if the workspace was applied, false if the user cancelled the switch or an error occurred.
4
7
  */
5
- export declare function applyWorkspace(workspace: Workspace): Promise<void>;
8
+ export declare function applyWorkspace({ options, ...workspace }: ApplyWorkspacePayload): Promise<boolean>;
6
9
  /**
7
10
  * Set the current active workspace.
8
11
  */
@@ -1094,6 +1094,8 @@ export interface WorkspacePlatformModule extends OpenFin.Platform {
1094
1094
  /**
1095
1095
  * Launch an application.
1096
1096
  *
1097
+ * @deprecated This method is deprecated. It is recommended to use [createView](https://developers.openfin.co/of-docs/docs/platform-getting-started#add-a-view-to-an-existing-window) or [createWindow](https://developers.openfin.co/of-docs/docs/platform-getting-started#create-a-platform-window) instead.
1098
+ *
1097
1099
  * ```ts
1098
1100
  * import * as WorkspacePlatform from '@openfin/workspace-platform';
1099
1101
  *
@@ -1132,8 +1134,11 @@ export interface WorkspacePlatformModule extends OpenFin.Platform {
1132
1134
  * Closes content from the current workspace and applies the given workspace to the user's desktop. Makes that
1133
1135
  * workspace the active workspace.
1134
1136
  * @param workspace the workspace to apply to the desktop and set as the current active workspace.
1137
+ * @param options see {@link ApplyWorkspaceOptions}.
1138
+ *
1139
+ * @returns true if the workspace was applied, false if the workspace was not applied.
1135
1140
  */
1136
- applyWorkspace(workspace: Workspace): Promise<void>;
1141
+ applyWorkspace(workspace: Workspace, options?: ApplyWorkspaceOptions): Promise<boolean>;
1137
1142
  /**
1138
1143
  * The browser window factory for the Workspace Platform.
1139
1144
  */
@@ -1199,6 +1204,13 @@ export interface WorkspacePlatformProvider extends OpenFin.PlatformProvider {
1199
1204
  * @param id of the id of the workspace to delete.
1200
1205
  */
1201
1206
  deleteSavedWorkspace(id: string): Promise<void>;
1207
+ /**
1208
+ * Applies a workspace to the user's desktop. Makes that workspace the active workspace.
1209
+ * @param applyWorkspacePayload {@link ApplyWorkspacePayload}
1210
+ *
1211
+ * @returns true if the workspace was applied, false if the workspace was not applied.
1212
+ */
1213
+ applyWorkspace(payload: ApplyWorkspacePayload): Promise<boolean>;
1202
1214
  /**
1203
1215
  * Implementation for showing a global context menu given a menu template,
1204
1216
  * handler callback, and screen coordinates. For an example of overriding, see {@link WorkspacePlatformOverrideCallback}.
@@ -1261,6 +1273,40 @@ export declare enum CustomActionCallerType {
1261
1273
  export declare type CustomActionPayload = {
1262
1274
  callerType: CustomActionCallerType.API;
1263
1275
  } | CustomButtonActionPayload | StoreCustomButtonActionPayload | CustomDropdownItemActionPayload | GlobalContextMenuOptionActionPayload | ViewTabCustomActionPayload | PageTabContextMenuOptionActionPayload | OpenSaveContextMenuOptionActionPayload;
1276
+ /**
1277
+ * Options for the {@link WorkspacePlatformModule.applyWorkspace applyWorkspace} method.
1278
+ *
1279
+ */
1280
+ export interface ApplyWorkspaceOptions {
1281
+ /**
1282
+ * If true, the workspace will be applied without prompting the user to confirm.
1283
+ * If false, the user will be prompted to confirm the workspace application.
1284
+ * @default false
1285
+ */
1286
+ skipPrompt?: boolean;
1287
+ /**
1288
+ * The window to use as the parent for the workspace switch confirmation dialog.
1289
+ */
1290
+ promptContainerWindowIdentity?: OpenFin.Identity;
1291
+ /**
1292
+ * @inheritdoc OpenFin.ApplySnapshotOptions
1293
+ */
1294
+ applySnapshotOptions?: OpenFin.ApplySnapshotOptions & {
1295
+ /**
1296
+ * When true, applyWorkspace will close all existing windows,
1297
+ * replacing current Platform state with the given snapshot.
1298
+ *
1299
+ * @default true
1300
+ */
1301
+ closeExistingWindows?: boolean;
1302
+ };
1303
+ }
1304
+ /**
1305
+ * Payload received by applyWorkspace platform provider method
1306
+ */
1307
+ export declare type ApplyWorkspacePayload = Workspace & {
1308
+ options?: ApplyWorkspaceOptions;
1309
+ };
1264
1310
  /**
1265
1311
  * Defines custom action map where the key is the custom action ID and value is the action handler
1266
1312
  */
@@ -1271,7 +1317,7 @@ export interface AnalyticsConfig {
1271
1317
  /**
1272
1318
  * Enable sending of Analytics data to OpenFin
1273
1319
  */
1274
- enableOpenFinAnalytics: boolean;
1320
+ sendToOpenFin: boolean;
1275
1321
  }
1276
1322
  /**
1277
1323
  * Configuration for initializing a Workspace platform.
@@ -1336,6 +1382,10 @@ export interface WorkspacePlatformInitConfig {
1336
1382
  * https://cdn.openfin.co/docs/javascript/stable/InteropBroker.html
1337
1383
  */
1338
1384
  interopOverride?: OpenFin.OverrideCallback<OpenFin.InteropBroker, OpenFin.InteropBroker>;
1385
+ /**
1386
+ * Config for Workspace Platform analytics
1387
+ */
1388
+ analytics?: AnalyticsConfig;
1339
1389
  }
1340
1390
  /**
1341
1391
  * Extend or replace default functionality in order to customize behavior of a Workspace Platform Provider.
@@ -14,7 +14,7 @@ export interface Overrides {
14
14
  [key: string]: boolean;
15
15
  };
16
16
  disableRuntimeValidation: boolean;
17
- enableOpenFinAnalytics: boolean;
17
+ disableOpenFinAnalytics: boolean;
18
18
  }
19
19
  export declare function getOverrides(): Promise<Partial<Overrides>>;
20
20
  export declare const useOverrides: () => Partial<Overrides>;
@@ -1,4 +1,4 @@
1
- import { LayoutExtended } from '../../../../common/src/utils/layout';
1
+ import type OpenFin from '@openfin/core';
2
2
  import type { AttachedPage, Page, PageLayout, PageWithUpdatableRuntimeAttribs } from './shapes';
3
3
  export declare function getLegacyPages(): Promise<Page[]>;
4
4
  export declare function cleanPage<T extends AttachedPage | Page>(page: T): T;
@@ -13,7 +13,7 @@ export declare const getPageLayout: (layout: PageLayout) => Promise<PageLayout>;
13
13
  * @param title the title for the page.
14
14
  * @param layout the layout for the page.
15
15
  */
16
- export declare const makePage: (title: string, layout: LayoutExtended) => Promise<PageWithUpdatableRuntimeAttribs>;
16
+ export declare const makePage: (title: string, layout: OpenFin.LayoutOptions) => Promise<PageWithUpdatableRuntimeAttribs>;
17
17
  /**
18
18
  * Clone a page.
19
19
  * @param page the page to clone.
@@ -1,14 +1,44 @@
1
1
  import type OpenFin from '@openfin/core';
2
- import type { LayoutExtended } from '../../utils/layout';
3
2
  export interface PageLayoutDetails {
4
- /** The id of the machine that created the page. */
3
+ /**
4
+ * The id of the machine that created the page.
5
+ */
5
6
  machineId: string;
6
- /** The name of the machine that created the page. */
7
+ /**
8
+ * The name of the machine that created the page.
9
+ */
7
10
  machineName?: string;
8
11
  }
9
- export declare type PageLayout = LayoutExtended & {
12
+ export declare type PageLayout = OpenFin.LayoutOptions & {
10
13
  layoutDetails?: PageLayoutDetails;
11
14
  };
15
+ /**
16
+ * Provides configuration options for a set of Workspace Views. An array of Page objects is a required option of the {@link workspacePlatform}
17
+ * property of the {@link BrowserCreateWindowRequest} interface.
18
+ *```ts
19
+ * const page: Page = {
20
+ * title: 'myPageTitle',
21
+ * pageId: 'myPageID',
22
+ * layout: {
23
+ * content: [
24
+ * {
25
+ * type: 'stack',
26
+ * content: [
27
+ * {
28
+ * type: 'component',
29
+ * componentName: 'view',
30
+ * componentState: {
31
+ * name: 'myViewName',
32
+ * url: 'http://google.com'
33
+ * }
34
+ * }
35
+ * ]
36
+ * }
37
+ * ]
38
+ * }
39
+ * };
40
+ * ```
41
+ */
12
42
  export interface Page {
13
43
  /** A UI friendly title for the page. */
14
44
  title: string;
@@ -1,26 +1,6 @@
1
1
  import type OpenFin from '@openfin/core';
2
2
  import { AttachedPage, PageLayout } from '../../../client-api-platform/src/shapes';
3
3
  import { WindowIdentity } from './window';
4
- export declare type LayoutComponentStateExtended = OpenFin.LayoutComponent['componentState'] & {
5
- name: string;
6
- uuid: string;
7
- };
8
- export declare type LayoutComponentExtended = Omit<OpenFin.LayoutComponent, 'componentState'> & {
9
- componentState: LayoutComponentStateExtended;
10
- };
11
- export declare type LayoutStack = {
12
- type: 'stack';
13
- content: OpenFin.LayoutContent;
14
- };
15
- export declare type LayoutContentItemExtended = OpenFin.LayoutRow | OpenFin.LayoutColumn | LayoutStack | LayoutComponentExtended | OpenFin.LayoutItemConfig;
16
- export declare type LayoutContentExtended = LayoutContentItemExtended[];
17
- export declare type LayoutSettingsExtended = OpenFin.LayoutOptions['settings'] & {
18
- reorderEnabled?: boolean;
19
- };
20
- export declare type LayoutExtended = {
21
- settings?: LayoutSettingsExtended;
22
- content: LayoutContentExtended;
23
- };
24
4
  export declare enum LayoutDOMEventType {
25
5
  TabCreated = "tab-created",
26
6
  ContainerCreated = "container-created",
@@ -66,11 +46,11 @@ export declare const cloneViewComponentWithoutName: (componentState: any) => any
66
46
  * @returns A copy of the layout with names removed
67
47
  */
68
48
  export declare const cloneLayoutAndRemoveNames: (layout: PageLayout) => any;
69
- export declare const mapContentComponentState: (content: OpenFin.LayoutContent | LayoutContentExtended) => LayoutComponentStateExtended[];
49
+ export declare const mapContentComponentState: (content: OpenFin.LayoutContent) => OpenFin.LayoutComponent['componentState'][];
70
50
  export declare const getLayoutWithSingleView: (title: string, url: string, winIdentity?: OpenFin.Identity) => Promise<any>;
71
51
  export declare const isLayoutTabActive: (tabSelector: string) => boolean;
72
52
  export declare const containerId = "layout_container";
73
- export declare const getViewComponents: () => LayoutContentExtended;
53
+ export declare const getViewComponents: () => OpenFin.LayoutContent;
74
54
  export declare const removeLayoutView: (name: string) => Promise<void>;
75
55
  export declare const addLayoutEventListener: (event: LayoutDOMEventType, listener: LayoutDOMEventListener) => void;
76
56
  /**
@@ -23,7 +23,7 @@ declare type WindowOptionsWithBounds = OptionalExceptFor<OpenFin.WindowOptions,
23
23
  top: number;
24
24
  left: number;
25
25
  };
26
- export declare function createChildWindow(opts: OptionalExceptFor<OpenFin.WindowOptions, 'name' | 'url'>, route?: string, bounds?: OpenFin.Bounds): Promise<OpenFin.Window | null>;
26
+ export declare function createChildWindow(opts: OptionalExceptFor<OpenFin.WindowOptions, 'name' | 'url'>, route?: string, bounds?: Partial<OpenFin.Bounds>): Promise<OpenFin.Window>;
27
27
  export interface ShowChildOptions {
28
28
  options: WindowOptionsWithBounds;
29
29
  parameters?: URLSearchParams;
@@ -5,7 +5,7 @@ import { ResponseModalConfig } from './menu-config';
5
5
  * this will return the correct bounds regardless of whether the window is maximized
6
6
  *
7
7
  * @param modalOptions window options including height/width so that we can calculate the correct bounds
8
- * @param parentWindowIdentity the window to get the bounds from
8
+ * @param parentWindowIdentity the window to get the bounds from. If this is undefined, the primary monitor will be used
9
9
  * @param centerOnMonitor whether the modal should be centered on the monitor
10
10
  * @returns a point (top/left) as to where the window should be placed
11
11
  */
@@ -27,10 +27,18 @@ interface Size {
27
27
  }
28
28
  /**
29
29
  * Gets the center point of a window given its bounds
30
- * @param bounds OpenFin bounds - left, top, height, width
31
- * @returns coords representing the center - left, top
30
+ *
31
+ * @param bounds OpenFin WindowBounds - left, top, height, width
32
+ * @returns A {@link OpenFin.Point} representing the center of the monitor
32
33
  */
33
34
  export declare const getCenterFromBounds: (bounds: OpenFin.WindowBounds) => Point;
35
+ /**
36
+ * Gets the center point of a monitor given its bounds
37
+ *
38
+ * @param bounds RectangleByEdgePositions - left, top, right, bottom. The bounds of the monitor
39
+ * @returns A {@link OpenFin.Point} representing the center of the monitor
40
+ */
41
+ export declare const getCenterFromMonitorBounds: (bounds: OpenFin.RectangleByEdgePositions) => Point;
34
42
  /**
35
43
  * Gets the top and left coords of a window given its size and center point
36
44
  * @param center point representing the desired center coords
@@ -1,7 +1,7 @@
1
1
  import type OpenFin from '@openfin/core';
2
2
  import { ResponseModalConfig } from '../../../common/src/utils/menu-config';
3
3
  export declare const restoreChangesMenu: (windowIdentity: OpenFin.Identity) => Promise<ResponseModalConfig>;
4
- export declare const showSwitchWorkspaceModal: (windowIdentity: OpenFin.Identity, workspaceTitle: string) => Promise<boolean>;
4
+ export declare const showSwitchWorkspaceModal: (targetWindowIdentity: OpenFin.Identity | undefined, workspaceTitle: string) => Promise<boolean>;
5
5
  export declare const showDeleteWorkspaceModal: (windowIdentity: OpenFin.Identity, workspaceTitle: string) => Promise<boolean>;
6
6
  /**
7
7
  *