@openfin/workspace-platform 11.0.6 → 12.1.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/README.md CHANGED
@@ -9,7 +9,7 @@ Run `npm i -E @openfin/workspace-platform`.
9
9
  ## Workspace Platform API documentation
10
10
 
11
11
  - [Overview](https://developers.openfin.co/of-docs/docs/workspace-sdk)
12
- - [API Reference](https://cdn.openfin.co/workspace/docs/platform/latest/index.html)
12
+ - [API Reference](https://workspace.openfin.co/workspace/docs/platform/latest/index.html)
13
13
  - [Example projects using Workspace Platform](https://github.com/built-on-openfin/workspace-starter)
14
14
 
15
15
  ## Code examples
@@ -5,6 +5,21 @@ export * from './shapes/dock';
5
5
  * Registers a Dock provider
6
6
  * @returns promise - invokes action
7
7
  * ```ts
8
+ * const provider: DockProvider = {
9
+ * id: 'provider-id',
10
+ * title: 'Sample Dock',
11
+ * icon: 'https://www.openfin.co/favicon-32x32.png',
12
+ * buttons: [
13
+ * {
14
+ * tooltip: 'Sample Button 1',
15
+ * iconUrl: 'https://www.openfin.co/favicon-32x32.png',
16
+ * action: {
17
+ * id: 'sampleButton1'
18
+ * }
19
+ * }
20
+ * ]
21
+ * };
22
+ *
8
23
  * await Dock.register(provider)
9
24
  * ```
10
25
  */
@@ -39,7 +39,7 @@ export interface WorkspaceComponentButtonOptions {
39
39
  * A dropdown button presents a list of options the user can choose from.
40
40
  * An action button initiates a single task or action only.
41
41
  */
42
- export declare enum DockButtonNames {
42
+ export declare const enum DockButtonNames {
43
43
  ActionButton = "ActionButton",
44
44
  DropdownButton = "DropdownButton"
45
45
  }
@@ -315,6 +315,35 @@ export interface CLIProvider extends SearchProvider {
315
315
  /**
316
316
  * A CLI provider responds to search requests from Home UI.
317
317
  * Exposes search features that are specifically supported by Home.
318
+ *
319
+ * <h3>Sample HomeProvider definition.</h3>
320
+ *
321
+ * Import required dependencies.
322
+ * ```ts
323
+ * import { Home, HomeProvider } from '@openfin/workspace';
324
+ * ```
325
+ *
326
+ * Create provider object to configure `Home`.
327
+ *
328
+ * ```ts
329
+ * const provider: HomeProvider = {
330
+ * id: 'provider-id',
331
+ * title: 'Sample Home',
332
+ * icon: 'https://www.openfin.co/favicon-32x32.png',
333
+ * description: 'A short description of the Search Provider.',
334
+ * onResultDispatch: () => { } // Handle Result Dispatch
335
+ * onUserInput: () => { } // Handle User Input
336
+ * };
337
+ * ```
338
+ *
339
+ * Register home ``provider`` object.
340
+ * ```ts
341
+ * await Home.register(provider);
342
+ * ```
343
+ * Show Home.
344
+ * ```ts
345
+ * await Home.show();
346
+ * ```
318
347
  */
319
348
  export interface HomeProvider extends CLIProvider {
320
349
  onUserInput(req: HomeSearchListenerRequest, res: HomeSearchListenerResponse): Promise<HomeSearchResponse>;
@@ -328,7 +357,7 @@ export interface SearchQueryWithProviderID {
328
357
  query: string;
329
358
  }
330
359
  /**
331
- * Reponse from home registration which includes metadata and a function to inject search string into home search
360
+ * Response from home registration which includes metadata and a function to inject search string into home search
332
361
  */
333
362
  export interface HomeRegistration extends RegistrationMetaInfo {
334
363
  /**
@@ -3,6 +3,7 @@
3
3
  * up the packaged typing files. When writing code examples,
4
4
  * for documentation, please use async/await syntax over .then()!
5
5
  */
6
+ import { UpdateButtonConfigRequest } from '../../../client-api/src/store';
6
7
  import { CustomButtonConfig, RegistrationMetaInfo } from './common';
7
8
  import { ProviderInfo } from './provider';
8
9
  /**
@@ -225,6 +226,31 @@ export interface StorefrontNavigationItemAppGrid extends StorefrontNavigationIte
225
226
  */
226
227
  templateData: StorefrontAppGrid;
227
228
  }
229
+ /**
230
+ * Response from store registration which includes metadata and a function to update app cards buttons.
231
+ */
232
+ export interface StoreRegistration extends RegistrationMetaInfo {
233
+ /**
234
+ * Function to updates app card button config.
235
+ * @example Updating primary button title and disabled flag.
236
+ * @param request object that contains primary button and secondary buttons configs that will be
237
+ * used to update button configuration returned by provider for an app.
238
+ *
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
249
+ * });
250
+ * ```
251
+ */
252
+ updateAppCardButtons: (request: UpdateButtonConfigRequest) => Promise<void>;
253
+ }
228
254
  /**
229
255
  * Template for rendering a navigation item that renders another landing page when clicked.
230
256
  */
@@ -248,6 +274,33 @@ export interface StorefrontProviderInfo extends ProviderInfo {
248
274
  /**
249
275
  * Describes a Storefront provided by a platform.
250
276
  * A platform must provide an object that satisfies this interface in order to register with the Storefront.
277
+ *
278
+ * <h3>Sample StorefrontProvider definition.</h3>
279
+ *
280
+ * Import required dependencies.
281
+ * ```ts
282
+ * import { Storefront, StorefrontProvider } from '@openfin/workspace';
283
+ * ```
284
+ *
285
+ * Create provider object to configure `Storefront`.
286
+ *
287
+ * ```ts
288
+ * const provider: StorefrontProvider = {
289
+ * id: 'provider-id',
290
+ * title: 'Sample Storefront',
291
+ * icon: 'https://www.openfin.co/favicon-32x32.png',
292
+ * getApps: () => { }, // Get apps to populate the platform's storefront
293
+ * getNavigation: () => {...}, // Get navigation selections for the left nav bar
294
+ * getLandingPage: () => {...}, // Get main landing page for platform's storefront
295
+ * getFooter: () => {...}, // Get footer for the platform's storefront
296
+ * launchApp: () => {...}, // Launch an app provided by the platform's storefront
297
+ * };
298
+ * ```
299
+ *
300
+ * Register storefront ``provider`` object.
301
+ * ```ts
302
+ * await Storefront.register(provider);
303
+ * ```
251
304
  */
252
305
  export interface StorefrontProvider extends StorefrontProviderInfo {
253
306
  /**
@@ -314,6 +367,7 @@ export interface StorefrontProvider extends StorefrontProviderInfo {
314
367
  getLandingPage(): Promise<StorefrontLandingPage>;
315
368
  /**
316
369
  * Get the Storefront navigation sections for the left nav bar.
370
+ *
317
371
  * ```ts
318
372
  * const navigationSections: [StorefrontNavigationSection, StorefrontNavigationSection] = [
319
373
  * {
@@ -426,7 +480,7 @@ export interface StorefrontAPI {
426
480
  */
427
481
  register(provider: StorefrontProvider): Promise<RegistrationMetaInfo>;
428
482
  /**
429
- * Deregister a provider.
483
+ * Deregister a [[StorefrontProvider]].
430
484
  *
431
485
  * ```ts
432
486
  * import { Storefront, StorefrontProvider } from "@openfin/workspace";
@@ -1,10 +1,15 @@
1
- import type { StorefrontProvider } from './shapes/store';
1
+ import type { StorefrontProvider, StoreRegistration } from './shapes/store';
2
2
  export * from './shapes/store';
3
- import type { RegistrationMetaInfo } from '../../client-api/src/shapes';
3
+ import { StoreButtonConfig } from './shapes/store';
4
4
  /**
5
5
  * Registers a Storefront provider
6
6
  */
7
- export declare const register: (provider: StorefrontProvider) => Promise<RegistrationMetaInfo>;
7
+ export declare const register: (provider: StorefrontProvider) => Promise<StoreRegistration>;
8
+ export interface UpdateButtonConfigRequest {
9
+ appId: string;
10
+ primaryButton: StoreButtonConfig;
11
+ secondaryButtons: StoreButtonConfig[];
12
+ }
8
13
  /**
9
14
  * Deregister a Storefront provider
10
15
  */
@@ -1,4 +1,47 @@
1
1
  import type OpenFin from '@openfin/core';
2
2
  import { WorkspacePlatformModule } from '../shapes';
3
+ /**
4
+ * Synchronously returns a Platform object that represents an existing platform.
5
+ *
6
+ * ```ts
7
+ * import * as WorkspacePlatform from '@openfin/workspace-platform';
8
+ *
9
+ * // declare platform identity
10
+ * const myPlatformIdentity: OpenFin.ApplicationIdentity = {
11
+ * uuid: 'testPlatform',
12
+ * name: 'Test Platform'
13
+ * };
14
+ *
15
+ * // get the platform representing myPlatformIdentity
16
+ * const platform = WorkspacePlatform.wrapSync(myPlatformIdentity);
17
+ *
18
+ * // do something with platform. e.g. create a window
19
+ * platform.createWindow({
20
+ * layout: {
21
+ * content: [
22
+ * {
23
+ * type: 'component',
24
+ * componentName: 'Example View',
25
+ * componentState: {
26
+ * name: 'example_view_1'
27
+ * url: 'https://cdn.openfin.co/docs/javascript/canary/Platform.html'
28
+ * }
29
+ * }
30
+ * ]
31
+ * }
32
+ * });
33
+ * ```
34
+ */
3
35
  export declare const wrapSync: (identity: OpenFin.ApplicationIdentity) => WorkspacePlatformModule;
36
+ /**
37
+ * Synchronously returns a Platform object that represents the current platform.
38
+ *
39
+ * ```ts
40
+ * import * as WorkspacePlatform from '@openfin/workspace-platform';
41
+ * // get current Workspace Platform
42
+ * const workspacePlatform = WorkspacePlatform.getCurrentSync();
43
+ * // do something with workspacePlatform. e.g. get snapshot of browser window with pages
44
+ * const snapshot = await workspacePlatform.getSnapshot();
45
+ * ```
46
+ */
4
47
  export declare const getCurrentSync: () => WorkspacePlatformModule;
@@ -1,3 +1,3 @@
1
1
  import { CustomActionsMap, InvokeCustomActionRequest } from '..';
2
2
  export declare const initCustomActions: (actions: CustomActionsMap) => void;
3
- export declare const makeInvokeCustomActionInternal: ({ actionId, payload }: InvokeCustomActionRequest) => Promise<any>;
3
+ export declare const invokeCustomActionInternal: ({ actionId, payload }: InvokeCustomActionRequest) => Promise<any>;
@@ -13,7 +13,7 @@ import type { WorkspacePlatformInitConfig } from '../shapes';
13
13
  * brandSecondary: '#1FF58A',
14
14
  * backgroundPrimary: '#F8E71C', // hex, rgb/rgba, hsl/hsla only - no string colors: 'red'
15
15
  * }
16
- * }
16
+ * }];
17
17
  *
18
18
  * const overrideCallback: WorkspacePlatform.WorkspacePlatformOverrideCallback = async (
19
19
  * WorkspacePlatformProvider
@@ -4,7 +4,7 @@ import type { AnalyticsEvent } from '../../common/src/utils/usage-register';
4
4
  import { CustomActionSpecifier, CustomButtonConfig } from '../../common/src/api/action';
5
5
  import type { AttachedPage, Page, PageWithUpdatableRuntimeAttribs } from '../../common/src/api/pages/shapes';
6
6
  import type { CustomThemes } from '../../common/src/api/theming';
7
- import type { App } from '../../client-api/src/shapes';
7
+ import type { App, StoreButtonConfig } from '../../client-api/src/shapes';
8
8
  export { AppManifestType } from '../../client-api/src/shapes';
9
9
  export type { App, AppIntent, Image } from '../../client-api/src/shapes';
10
10
  export type { CustomActionSpecifier, CustomButtonConfig } from '../../common/src/api/action';
@@ -73,7 +73,7 @@ export declare enum GlobalContextMenuOptionType {
73
73
  /**
74
74
  * Types of color scheme.
75
75
  */
76
- export declare enum ColorSchemeOptionType {
76
+ export declare const enum ColorSchemeOptionType {
77
77
  Light = "light",
78
78
  Dark = "dark",
79
79
  System = "system"
@@ -298,9 +298,9 @@ export interface StoreCustomButtonActionPayload extends Omit<CustomButtonActionP
298
298
  * Invoking application id.
299
299
  */
300
300
  appId: string;
301
- /**
302
- * callerType - StoreCustomButton type.
303
- */
301
+ sourceButtonConfig: StoreButtonConfig;
302
+ secondaryButtons: StoreButtonConfig[];
303
+ primaryButton: StoreButtonConfig;
304
304
  callerType: CustomActionCallerType.StoreCustomButton;
305
305
  storeFrontProviderId: string;
306
306
  }
@@ -1093,6 +1093,7 @@ export interface WorkspacePlatformModule extends OpenFin.Platform {
1093
1093
  getSnapshot(): Promise<BrowserSnapshot>;
1094
1094
  /**
1095
1095
  * Launch an application.
1096
+ *
1096
1097
  * ```ts
1097
1098
  * import * as WorkspacePlatform from '@openfin/workspace-platform';
1098
1099
  *
@@ -1380,6 +1381,11 @@ export interface WorkspacePlatformInitConfig {
1380
1381
  *
1381
1382
  * // add a custom menu item in View Tab Context Menu
1382
1383
  * openViewTabContextMenu = async (payload: OpenViewTabContextMenuPayload, callerIdentity) => {
1384
+ * const viewsInfo = await Promise.all(payload.selectedViews.map(async (v) => fin.View.wrapSync(v).getInfo()));
1385
+ *
1386
+ * const enableBack = viewsInfo.every((viewInfo) => viewInfo.canNavigateBack === true);
1387
+ * const enableForward = viewsInfo.every((viewInfo) => viewInfo.canNavigateForward === true);
1388
+ *
1383
1389
  * return super.openViewTabContextMenu({
1384
1390
  * ...payload,
1385
1391
  * template: [
@@ -1394,68 +1400,51 @@ export interface WorkspacePlatformInitConfig {
1394
1400
  * }
1395
1401
  * }
1396
1402
  * },
1397
- * ...payload.template
1398
- * ]
1399
- * }, callerIdentity);
1400
- * };
1401
- *
1402
- * // add a custom menu item (forward/back) in View Tab Context Menu
1403
- * openViewTabContextMenu = async (payload: OpenViewTabContextMenuPayload, callerIdentity) => {
1404
- * const viewsInfo = await Promise.all(payload.selectedViews.map(async (v) => fin.View.wrapSync(v).getInfo()));
1405
- *
1406
- * const enableBack = viewsInfo.every((viewInfo) => viewInfo.canNavigateBack === true);
1407
- * const enableForward = viewsInfo.every((viewInfo) => viewInfo.canNavigateForward === true);
1408
- *
1409
- *
1410
- * return super.openViewTabContextMenu({
1411
- * ...payload,
1412
- * template: [
1413
- * {
1403
+ * {
1414
1404
  * type: 'normal',
1415
1405
  * label: 'Back',
1416
1406
  * data: {
1417
1407
  * type: ViewTabMenuOptionType.Back
1418
1408
  * },
1419
1409
  * enabled: enableBack
1420
- * },
1421
- * {
1410
+ * },
1411
+ * {
1422
1412
  * type: 'normal',
1423
1413
  * label: 'Forward',
1424
1414
  * data: {
1425
1415
  * type: ViewTabMenuOptionType.Forward
1426
1416
  * },
1427
1417
  * enabled: enableForward
1428
- * },
1429
- * ...payload.template
1418
+ * },
1419
+ * ...payload.template
1430
1420
  * ]
1431
1421
  * }, callerIdentity);
1432
1422
  * };
1433
1423
  *
1434
1424
  * // add a custom menu item in Save Context Menu
1435
- * openSaveButtonContextMenu = (req: WorkspacePlatform.OpenSaveButtonContextMenuPayload, callerIdentity: OpenFin.Identity) => {
1436
- * return super.openSaveButtonContextMenu(
1437
- * {
1438
- * ...req,
1439
- * template: [
1440
- * ...req.template,
1441
- * {
1442
- * label: 'Save custom option',
1443
- * data: {
1444
- * type: SaveButtonContextMenuOptionType.Custom,
1445
- * action: {
1446
- * id: 'sample-custom-action-name',
1447
- * customData: {
1448
- * someProp: 'Save Button task'
1449
- * }
1450
- * }
1451
- * }
1452
- * }
1453
- * ]
1454
- * },
1455
- * callerIdentity
1456
- * );
1457
- * }
1458
- * }
1425
+ * openSaveButtonContextMenu = (req: WorkspacePlatform.OpenSaveButtonContextMenuPayload, callerIdentity: OpenFin.Identity) => {
1426
+ * return super.openSaveButtonContextMenu(
1427
+ * {
1428
+ * ...req,
1429
+ * template: [
1430
+ * ...req.template,
1431
+ * {
1432
+ * label: 'Save custom option',
1433
+ * data: {
1434
+ * type: SaveButtonContextMenuOptionType.Custom,
1435
+ * action: {
1436
+ * id: 'sample-custom-action-name',
1437
+ * customData: {
1438
+ * someProp: 'Save Button task'
1439
+ * }
1440
+ * }
1441
+ * }
1442
+ * }
1443
+ * ]
1444
+ * },
1445
+ * callerIdentity
1446
+ * );
1447
+ * }
1459
1448
  * }
1460
1449
  * return new Override();
1461
1450
  * };
@@ -1483,7 +1472,7 @@ export declare type WorkspacePlatformOverrideCallback = OpenFin.OverrideCallback
1483
1472
  * @deprecated
1484
1473
  */
1485
1474
  export declare type BrowserOverrideCallback = WorkspacePlatformOverrideCallback;
1486
- /**`
1475
+ /**
1487
1476
  * Configuration for initializing a Browser.
1488
1477
  */
1489
1478
  export interface BrowserInitConfig {
@@ -22,12 +22,12 @@ export declare enum WorkspaceChannelAction {
22
22
  GetStorefrontProviderFooter = "get-storefront-provider-footer",
23
23
  GetStorefrontProviderNavigation = "get-storefront-provider-navigation",
24
24
  LaunchStorefrontProviderApp = "launch-storefront-provider-app",
25
+ UpdateAppCardButtonConfig = "update-app-card-button-config",
25
26
  ShowHome = "show-home",
26
27
  HideHome = "hide-home",
27
28
  AssignHomeSearchContext = "assign-home-search-context",
28
29
  SetSearchQuery = "set-search-query",
29
30
  OpenHomeAndSetSearchQuery = "open-home-and-set-search-query",
30
- SetStoreButtonState = "set-store-button-state",
31
31
  GetLegacyPages = "get-legacy-pages",
32
32
  GetLegacyWorkspaces = "get-legacy-workspaces",
33
33
  GetComputedPlatformTheme = "get-computed-platform-theme",
@@ -16,6 +16,5 @@ export interface SearchItem {
16
16
  requestReload?: () => any;
17
17
  }
18
18
  export declare type Topic = typeof homeSearchTopic;
19
- export declare function waitForSearchRegistration(): Promise<void>;
20
19
  export declare function getTopic(topic: Topic): Promise<SearchTopicClient>;
21
20
  export declare function mapSearchResponsesToItems(topic: Topic, responses: SearchProviderResponse[]): SearchItem[];
@@ -4,7 +4,8 @@ export declare enum ApplicationUUID {
4
4
  * The UUID of workspace.
5
5
  * Home is a part of this application.
6
6
  */
7
- Workspace = "openfin-browser"
7
+ Workspace = "openfin-workspace",
8
+ OldWorkspace = "openfin-browser"
8
9
  }
9
10
  export interface ApplicationEvent {
10
11
  viewIdentity?: OpenFin.Identity;
@@ -12,12 +13,6 @@ export interface ApplicationEvent {
12
13
  uuid?: string;
13
14
  }
14
15
  export declare type ApplicationListener = (ev: ApplicationEvent) => void;
15
- export declare enum ApplicationEventType {
16
- RunRequested = "run-requested",
17
- WindowOptionsChanged = "window-options-changed",
18
- WindowClosed = "window-closed",
19
- WindowCreated = "window-created"
20
- }
21
16
  export declare enum LaunchModeType {
22
17
  FinProtocol = "fin-protocol"
23
18
  }
@@ -10,26 +10,6 @@ export declare enum WindowName {
10
10
  BrowserWindow = "internal-generated-window",
11
11
  ClassicWindow = "internal-generated-classic-window"
12
12
  }
13
- export declare enum WindowEvent {
14
- Shown = "shown",
15
- BoundsChanged = "bounds-changed",
16
- LayoutReady = "layout-ready",
17
- EndUserBoundsChanging = "end-user-bounds-changing",
18
- Blurred = "blurred",
19
- Closed = "closed",
20
- CloseRequested = "close-requested",
21
- Focused = "focused",
22
- ShowRequested = "show-requested",
23
- ViewCrashed = "view-crashed",
24
- ViewAttached = "view-attached",
25
- ViewDetached = "view-detached",
26
- ViewPageTitleUpdated = "view-page-title-updated",
27
- ViewDestroyed = "view-destroyed",
28
- OptionsChanged = "options-changed"
29
- }
30
- export declare enum WebWindowEvent {
31
- BeforeUnload = "beforeunload"
32
- }
33
13
  export interface WindowIdentity {
34
14
  uuid: ApplicationUUID | string;
35
15
  name: WindowName | string;