@openfin/workspace 1.8.0 → 4.0.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.
Files changed (62) hide show
  1. package/README.md +121 -4
  2. package/client-api/src/common.d.ts +6 -0
  3. package/{index.test.d.ts → client-api/src/common.test.d.ts} +0 -0
  4. package/client-api/src/home.d.ts +19 -0
  5. package/{umd.d.ts → client-api/src/home.test.d.ts} +0 -0
  6. package/client-api/src/index.d.ts +11 -0
  7. package/client-api/src/index.test.d.ts +1 -0
  8. package/{logger.d.ts → client-api/src/logger.d.ts} +0 -0
  9. package/client-api/src/shapes.d.ts +573 -0
  10. package/client-api/src/storefront.d.ts +18 -0
  11. package/client-api/src/storefront.test.d.ts +1 -0
  12. package/client-api/src/umd.d.ts +1 -0
  13. package/common/src/api/home.d.ts +27 -0
  14. package/common/src/api/protocol.d.ts +88 -0
  15. package/common/src/api/search.d.ts +7 -0
  16. package/common/src/api/shapes.d.ts +20 -0
  17. package/common/src/api/storefront.d.ts +70 -0
  18. package/common/src/utils/application.d.ts +41 -0
  19. package/common/src/utils/channels.d.ts +8 -0
  20. package/common/src/utils/env.d.ts +27 -0
  21. package/common/src/utils/logger/index.d.ts +26 -0
  22. package/common/src/utils/logger/manager.d.ts +35 -0
  23. package/common/src/utils/logger/shapes.d.ts +27 -0
  24. package/common/src/utils/window.d.ts +145 -0
  25. package/index.d.ts +2 -6
  26. package/index.js +1 -1
  27. package/index.js.map +1 -1
  28. package/package.json +1 -1
  29. package/search-api/src/client/index.d.ts +6 -0
  30. package/search-api/src/client/internal.d.ts +38 -0
  31. package/search-api/src/client/remote/channel-client-factory.d.ts +2 -0
  32. package/search-api/src/client/remote/channel-client.d.ts +9 -0
  33. package/search-api/src/client/remote/data.d.ts +16 -0
  34. package/search-api/src/client/remote/disconnect.d.ts +7 -0
  35. package/search-api/src/client/remote/dispatch.d.ts +9 -0
  36. package/search-api/src/client/remote/requests.d.ts +5 -0
  37. package/search-api/src/client/remote/search-close.d.ts +14 -0
  38. package/search-api/src/common.d.ts +104 -0
  39. package/search-api/src/errors.d.ts +5 -0
  40. package/search-api/src/fin/index.d.ts +6 -0
  41. package/search-api/src/fin/shapes.d.ts +23 -0
  42. package/search-api/src/index.d.ts +7 -0
  43. package/search-api/src/internal-shapes.d.ts +134 -0
  44. package/search-api/src/logger.d.ts +1 -0
  45. package/search-api/src/provider/index.d.ts +8 -0
  46. package/search-api/src/provider/internal.d.ts +33 -0
  47. package/search-api/src/provider/remote/channel-factory.d.ts +6 -0
  48. package/search-api/src/provider/remote/channel.d.ts +23 -0
  49. package/search-api/src/provider/remote/connection.d.ts +20 -0
  50. package/search-api/src/provider/remote/data.d.ts +23 -0
  51. package/search-api/src/provider/remote/deregistration.d.ts +5 -0
  52. package/search-api/src/provider/remote/disconnect.d.ts +1 -0
  53. package/search-api/src/provider/remote/disconnection.d.ts +9 -0
  54. package/search-api/src/provider/remote/dispatch.d.ts +7 -0
  55. package/search-api/src/provider/remote/info.d.ts +5 -0
  56. package/search-api/src/provider/remote/registration.d.ts +23 -0
  57. package/search-api/src/provider/remote/search-close.d.ts +14 -0
  58. package/search-api/src/provider/remote/search.d.ts +8 -0
  59. package/search-api/src/shapes.d.ts +541 -0
  60. package/common.d.ts +0 -6
  61. package/content-store.d.ts +0 -14
  62. package/shapes.d.ts +0 -272
@@ -0,0 +1,88 @@
1
+ /// <reference types="openfin-adapter/fin" />
2
+ /** The name of the channel for the centralized workspace protocol. */
3
+ export declare const channelName = "__of_workspace_protocol__";
4
+ /**
5
+ * All of the remote procedures that can be called in the
6
+ * Workspace Provider's address space.
7
+ *
8
+ * When adding a new channel action make sure to register a
9
+ * handler for the remote procedure in the Workspace Provider.
10
+ * All of the registered channel action handlers can be found here:
11
+ * @see link: [Provider Protocol Handlers](https://github.com/openfin/workspace/provider/src/api/protocol.ts)
12
+ */
13
+ export declare enum ChannelAction {
14
+ LaunchApp = "launch-app",
15
+ CreateWorkspace = "create-workspace",
16
+ UpdateWorkspace = "update-workspace",
17
+ DeleteWorkspace = "delete-workspace",
18
+ LaunchWorkspace = "launch-workspace",
19
+ ShareWorkspace = "share-workspace",
20
+ GetWorkspace = "get-workspace",
21
+ GetWorkspaceList = "get-workspace-list",
22
+ GetActiveWorkspace = "get-active-workspace",
23
+ GetPage = "get-page",
24
+ CreatePage = "create-page",
25
+ UpdatePage = "update-page",
26
+ RenamePage = "rename-page",
27
+ DeletePage = "delete-page",
28
+ SharePage = "share-page",
29
+ LaunchPage = "launch-page",
30
+ AttachPagesToWindow = "attach-pages-to-window",
31
+ DetachPagesFromWindow = "detach-pages-from-window",
32
+ ReorderPagesForWindow = "reorder-pages-for-window",
33
+ SetActivePageForWindow = "set-active-page-for-window",
34
+ GetSavedPageList = "get-saved-page-list",
35
+ GetAttachedPageList = "get-running-page-list",
36
+ GetAllPageList = "get-all-page-list",
37
+ GetActivePageIdForWindow = "get-active-page-id-for-window",
38
+ GetPagesForWindow = "get-pages-for-window",
39
+ GetSavedPageMetadata = "get-saved-page-metadata",
40
+ RegisterStorefrontProvider = "register-storefront-provider",
41
+ DeregisterStorefrontProvider = "deregister-storefront-provider",
42
+ GetStorefrontProviders = "get-storefront-providers",
43
+ HideStorefront = "hide-storefront",
44
+ GetStorefrontProviderApps = "get-storefront-provider-apps",
45
+ GetStorefrontProviderLandingPage = "get-storefront-provider-landing-page",
46
+ GetStorefrontProviderFooter = "get-storefront-provider-footer",
47
+ GetStorefrontProviderNavigation = "get-storefront-provider-navigation",
48
+ LaunchStorefrontProviderApp = "launch-storefront-provider-app",
49
+ ShowStorefront = "show-storefront",
50
+ CreateStorefrontWindow = "create-storefront-window",
51
+ CreateBrowserWindow = "create-browser-window",
52
+ ShowHome = "show-home",
53
+ HideHome = "hide-home",
54
+ AssignHomeSearchContext = "assign-home-search-context"
55
+ }
56
+ export interface ChannelClient extends OpenFin.ChannelClient {
57
+ dispatch: (action: ChannelAction, payload: any) => Promise<any>;
58
+ }
59
+ /**
60
+ * Get a channel client for the centralized Workspace protocol.
61
+ *
62
+ * The channel client is automatically connected to the Workspace Provider,
63
+ * in which acts as a centralized location for executing Workspace API logic.
64
+ *
65
+ * The channel client can execute remote procedures on the provider via its `dispatch` function.
66
+ * A call to the `dispatch` function will block until the channel action has concluded execution
67
+ * in the Workspace Provider's address space.
68
+ * For a list of supported procedures, see the `ChannelAction` enum.
69
+ *
70
+ * @returns the channel client for the centralized workspace protocol.
71
+ */
72
+ export declare const getChannelClient: () => Promise<ChannelClient>;
73
+ /**
74
+ * Returns true if the current application was launched via a library (such as the Client APIs).
75
+ * Otherwise, returns false.
76
+ */
77
+ export declare const isLaunchedViaLib: () => Promise<boolean>;
78
+ /**
79
+ * Launches the Workspace Provider.
80
+ * If the Workspace Provider is already running, does nothing.
81
+ */
82
+ export declare const launchProvider: () => Promise<void>;
83
+ /**
84
+ * Launches the Workspace provider if it is not running.
85
+ * Then gets a Channel Client that is connected to the Workspace Provider.
86
+ * @returns the Channel Client that is connected to the Workspace Provider.
87
+ */
88
+ export declare const getChannelClientAndLaunchProvider: () => Promise<ChannelClient>;
@@ -0,0 +1,7 @@
1
+ import { searchTopic as homeSearchTopic } from '@common/api/home';
2
+ import type { SearchProviderResponse, SearchTopicClient } from '@search/shapes';
3
+ import type { SearchItem } from './shapes';
4
+ export declare type Topic = typeof homeSearchTopic;
5
+ export declare function waitForSearchRegistration(): Promise<void>;
6
+ export declare function getTopic(topic: Topic): Promise<SearchTopicClient>;
7
+ export declare function mapSearchResponsesToItems(topic: Topic, responses: SearchProviderResponse[]): SearchItem[];
@@ -0,0 +1,20 @@
1
+ /// <reference types="openfin-adapter/fin" />
2
+ import { CLISearchResultWithTemplate, StorefrontProviderInfo } from '@client/shapes';
3
+ import { Action as BaseAction, SearchProviderInfo } from '@search/shapes';
4
+ export interface Action extends BaseAction {
5
+ isHidden: boolean;
6
+ dispatch: () => any;
7
+ }
8
+ export interface SearchItem {
9
+ providerInfo: SearchProviderInfo;
10
+ result: CLISearchResultWithTemplate<any, any, Action>;
11
+ actions: Action[];
12
+ key: string;
13
+ }
14
+ export declare enum SearchProviderName {
15
+ Pages = "home-pages",
16
+ Workspaces = "home-workspaces"
17
+ }
18
+ export interface StorefrontProviderInfoWithIdentity extends StorefrontProviderInfo {
19
+ platformIdentity: OpenFin.Identity;
20
+ }
@@ -0,0 +1,70 @@
1
+ /// <reference types="openfin-adapter/fin" />
2
+ import type { StorefrontProviderInfoWithIdentity } from '@common/api/shapes';
3
+ import { App, StorefrontFooter, StorefrontLandingPage, StorefrontNavigationItemAppGrid, StorefrontNavigationSection } from '@client/shapes';
4
+ export interface LaunchStorefrontAppRequest {
5
+ app: App;
6
+ platformIdentity?: OpenFin.Identity;
7
+ }
8
+ export interface StorefrontProviderIdentity {
9
+ /**
10
+ * The ID of the Storefront Provider.
11
+ */
12
+ id: string;
13
+ /**
14
+ * The platform identity that registered the Storefront Provider.
15
+ */
16
+ platformIdentity: OpenFin.Identity;
17
+ }
18
+ export interface LaunchStorefrontProviderAppRequest extends StorefrontProviderIdentity {
19
+ app: App;
20
+ }
21
+ /**
22
+ * Launch a Storefront app.
23
+ * @param platformIdentity the identity of the platform that provided the app.
24
+ */
25
+ export declare const launchStorefrontApp: (req: LaunchStorefrontProviderAppRequest) => Promise<void>;
26
+ /**
27
+ * Get a list of applications for Storefront.
28
+ * @param platformIdentity the identity of the platform to get the apps from.
29
+ * @returns the list of Storefront apps for the platform.
30
+ */
31
+ export declare const getStorefrontApps: (identity: StorefrontProviderIdentity) => Promise<App[]>;
32
+ /**
33
+ * Get a list of all providers that have registered with the Storefront API.
34
+ */
35
+ export declare const getStorefrontProviders: () => Promise<StorefrontProviderInfoWithIdentity[]>;
36
+ export declare const showStorefront: () => Promise<any>;
37
+ /**
38
+ * Get the platform's landing page for Storefront.
39
+ * @param platformIdentity the identity of the platform to get the landing page of.
40
+ * @returns the platform's landing page.
41
+ */
42
+ export declare const getStorefrontLandingPage: (identity: StorefrontProviderIdentity) => Promise<StorefrontLandingPage | undefined>;
43
+ /**
44
+ * Get the platform's footer for Storefront.
45
+ * @param platformIdentity the identity of the platform to get the footer of.
46
+ * @returns the platform's footer.
47
+ */
48
+ export declare const getStorefrontFooter: (identity: StorefrontProviderIdentity) => Promise<StorefrontFooter>;
49
+ /**
50
+ * Get the platform's navigation for Storefront.
51
+ * @param platformIdentity the identity of the platform to get the navigation of.
52
+ * @returns the platform's navigation.
53
+ */
54
+ export declare const getStorefrontNavigation: (identity: StorefrontProviderIdentity) => Promise<[StorefrontNavigationSection?, StorefrontNavigationSection?]>;
55
+ /**
56
+ * A helper method that gets a Storefront navigation item by ID.
57
+ * @param navigationItemId the id of the Storefront navigation item.
58
+ * @param platformIdentity the platform identity.
59
+ * @returns the navigation item with the ID.
60
+ */
61
+ export declare const getStorefrontNavigationItemAppGrid: (navigationItemId: string, identity: StorefrontProviderIdentity) => Promise<StorefrontNavigationItemAppGrid | undefined>;
62
+ /**
63
+ * A function to dispatch hiding the Storefront of current OF identity
64
+ * @returns action to hide Storefront
65
+ */
66
+ export declare const hideStorefront: () => Promise<void>;
67
+ /**
68
+ * Create the Storefront main window.
69
+ */
70
+ export declare function createStorefrontWindow(): Promise<any>;
@@ -0,0 +1,41 @@
1
+ /// <reference types="openfin-adapter/fin" />
2
+ export declare enum ApplicationUUID {
3
+ /**
4
+ * The UUID of workspace.
5
+ * Home is a part of this application.
6
+ */
7
+ Workspace = "openfin-browser"
8
+ }
9
+ export interface ApplicationEvent {
10
+ viewIdentity?: OpenFin.Identity;
11
+ name?: string;
12
+ uuid?: string;
13
+ }
14
+ export declare type ApplicationListener = (ev: ApplicationEvent) => void;
15
+ export declare enum ApplicationEventType {
16
+ ViewPageTitleUpdated = "view-page-title-updated",
17
+ ViewDestroyed = "view-destroyed",
18
+ ViewAttached = "view-attached",
19
+ RunRequested = "run-requested",
20
+ WindowOptionsChanged = "window-options-changed",
21
+ WindowClosed = "window-closed",
22
+ WindowCreated = "window-created"
23
+ }
24
+ export declare enum LaunchModeType {
25
+ FinProtocol = "fin-protocol"
26
+ }
27
+ export declare type ApplicationInfoExtended = OpenFin.ApplicationInfo & {
28
+ initialOptions: OpenFin.ApplicationInfo['initialOptions'] & {
29
+ userAppConfigArgs: any;
30
+ };
31
+ };
32
+ export declare const currentOFAppIdentity: {
33
+ uuid: string;
34
+ name: string;
35
+ };
36
+ export declare const workspaceOFAppIdentity: {
37
+ name: ApplicationUUID;
38
+ uuid: ApplicationUUID;
39
+ };
40
+ export declare const getCurrentOFApplication: () => import("openfin-adapter").Application;
41
+ export declare const getWorkspaceOFApplication: () => import("openfin-adapter").Application;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Make a function that connects to a channel.
3
+ * If already connected to the channel, will return the channel connection.
4
+ * If disconnected from the channel, will automatically reconnect.
5
+ * @param channelName the name of the channel to connect to.
6
+ * @returns the function to connect to the channel.
7
+ */
8
+ export default function makeGetChannelClient(channelName: string): () => Promise<import("openfin-adapter").ChannelClient>;
@@ -0,0 +1,27 @@
1
+ export declare enum Env {
2
+ Local = "local",
3
+ Dev = "dev",
4
+ Staging = "staging",
5
+ Prod = "prod"
6
+ }
7
+ export declare const isFin: boolean;
8
+ export declare const isJest: boolean;
9
+ export declare const isWindowDefined: boolean;
10
+ export declare const isDocumentDefined: boolean;
11
+ export declare const isWindowDefinedWithIndexDB: boolean;
12
+ export declare const finUUID: string;
13
+ export declare const finName: string;
14
+ export declare const finEntityType: import("openfin-adapter/src/shapes/EntityType").default;
15
+ export declare const env: Env;
16
+ export declare const isEnvLocal: boolean;
17
+ export declare const isEnvDev: boolean;
18
+ export declare const isEnvStaging: boolean;
19
+ export declare const isEnvProd: boolean;
20
+ export declare const isLibrary: boolean;
21
+ export declare const workspaceProviderFinsLink: string;
22
+ 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;
@@ -0,0 +1,26 @@
1
+ import { LogLocal } from './shapes';
2
+ /**
3
+ * Responsible of capturing log information locally and centrally alongside the logs of other windows/views.
4
+ *
5
+ * **Warning: if you don't specify a name then it will still log out your messages but it becomes harder to distinguish where the log entry came from**
6
+ *
7
+ * Basic usage example:
8
+ *
9
+ * ```ts
10
+ * import logger from '../utils/logger';
11
+ * const log = logger("My Component");
12
+ *
13
+ * log.info("Initialised.");
14
+ * ```
15
+ * More information can be found [here](https://github.com/openfin/browser/blob/main/docs/Logging.md)
16
+ * @param name Specify a name for this logger that will be the prefix of all log messages.
17
+ * @param logLocal Specify an object to say what loglevel should be logged to the local window console e.g. { info: true }.
18
+ */
19
+ export default function logger(name?: string, logLocal?: LogLocal): {
20
+ trace: (message: string, ...args: any[]) => void;
21
+ debug: (message: string, ...args: any[]) => void;
22
+ info: (message: string, ...args: any[]) => void;
23
+ warn: (message: string, ...args: any[]) => void;
24
+ error: (message: string, error?: any, ...args: any[]) => void;
25
+ fatal: (message: string, error?: any, ...args: any[]) => void;
26
+ };
@@ -0,0 +1,35 @@
1
+ import { LogEntry, LogOptions } from './shapes';
2
+ declare class LogInterface {
3
+ private worker;
4
+ private name;
5
+ private requestResponseHandler;
6
+ private errorListeners;
7
+ constructor();
8
+ getLogs(fromId?: number): Promise<LogEntry[]>;
9
+ trace(message: string, sourceName?: string, args?: any[]): void;
10
+ debug(message: string, sourceName?: string, args?: any[]): void;
11
+ info(message: string, sourceName?: string, args?: any[]): void;
12
+ warn(message: string, sourceName?: string, args?: any[]): void;
13
+ error(message: string, error?: any, sourceName?: string, args?: any[]): void;
14
+ fatal(message: string, error?: any, sourceName?: string, args?: any[]): void;
15
+ configure(options: LogOptions): void;
16
+ onLogError(listener: (error: Error) => void): void;
17
+ removeListener(listener: (...args: unknown[]) => void): void;
18
+ private log;
19
+ private listener;
20
+ }
21
+ /**
22
+ * Responsible for managing the way logging behaves and retrieving logs. Additionally exposes logging functions but logger should be used for logging.
23
+ *
24
+ * Basic usage example:
25
+ *
26
+ * ```ts
27
+ * import logManager from '../utils/log-manager';
28
+ *
29
+ * const logs = await logManager.getLogs();
30
+ *
31
+ * ```
32
+ * More information can be found [here](https://github.com/openfin/browser/blob/main/docs/Logging.md)
33
+ */
34
+ declare let instance: LogInterface | undefined;
35
+ export default instance;
@@ -0,0 +1,27 @@
1
+ export declare type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
2
+ export interface LogOptions {
3
+ instanceId?: string;
4
+ auditLimit?: number;
5
+ auditLevel?: LogLevel;
6
+ logLevel?: LogLevel;
7
+ }
8
+ export declare type LogLocal = {
9
+ [key in LogLevel]?: boolean;
10
+ };
11
+ export interface LogEntry {
12
+ id?: number;
13
+ level: LogLevel;
14
+ name: string;
15
+ source?: string;
16
+ message: string;
17
+ error?: string;
18
+ ts?: number;
19
+ data?: any[];
20
+ }
21
+ export interface GetLogOptions {
22
+ from?: number;
23
+ responseId: number;
24
+ }
25
+ export declare const LogColors: {
26
+ [key in LogLevel]: string;
27
+ };
@@ -0,0 +1,145 @@
1
+ /// <reference types="openfin-adapter/fin" />
2
+ import type { Fin } from 'openfin-adapter';
3
+ import type { _Window } from 'openfin-adapter/src/api/window';
4
+ import type EntityType from 'openfin-adapter/src/shapes/EntityType';
5
+ import { ApplicationUUID } from './application';
6
+ export declare type WindowFin = Fin<EntityType.WINDOW>;
7
+ export declare enum WindowName {
8
+ Home = "openfin-home",
9
+ Dock = "openfin-dock",
10
+ Storefront = "openfin-storefront",
11
+ HomeInternal = "openfin-home-internal",
12
+ BrowserMenu = "openfin-browser-menu",
13
+ BrowserIndicator = "openfin-browser-indicator",
14
+ BrowserWindow = "internal-generated-window"
15
+ }
16
+ export declare enum WindowEvent {
17
+ Shown = "shown",
18
+ BoundsChanged = "bounds-changed",
19
+ LayoutReady = "layout-ready",
20
+ EndUserBoundsChanging = "end-user-bounds-changing",
21
+ Blurred = "blurred",
22
+ CloseRequested = "close-requested",
23
+ Focused = "focused",
24
+ ShowRequested = "show-requested",
25
+ ViewCrashed = "view-crashed",
26
+ ViewAttached = "view-attached",
27
+ ViewDetached = "view-detached"
28
+ }
29
+ export interface WindowIdentity {
30
+ uuid: ApplicationUUID | string;
31
+ name: WindowName | string;
32
+ }
33
+ interface Point {
34
+ left: number;
35
+ top: number;
36
+ }
37
+ interface Size {
38
+ height: number;
39
+ width: number;
40
+ }
41
+ /**
42
+ * Gets the center point of a window given its bounds
43
+ * @param bounds OpenFin bounds - left, top, height, width
44
+ * @returns coords representing the center - left, top
45
+ */
46
+ export declare const getCenterFromBounds: (bounds: OpenFin.WindowBounds) => Point;
47
+ /**
48
+ * Gets the top and left coords of a window given its size and center point
49
+ * @param center point representing the desired center coords
50
+ * @param size height and width of the window
51
+ * @returns coords representing the left, top of window given the center point
52
+ */
53
+ export declare const getBoundsFromCenter: (center: Point, size: Size) => Point;
54
+ /**
55
+ * Get a wrapped OpenFin window.
56
+ *
57
+ * This method can only be used in an OF env.
58
+ * If used outside of OF, such as in a pre-rendering context, will throw a clear and traceable error.
59
+ *
60
+ * @param identity the window identity.
61
+ * @returns the wrapped OpenFin window identity.
62
+ */
63
+ export declare function getOFWindow(identity: WindowIdentity): _Window;
64
+ /**
65
+ * The OpenFin identity for the current window.
66
+ */
67
+ export declare const currentOFIdentity: WindowIdentity;
68
+ /**
69
+ * Get the current OpenFin window.
70
+ */
71
+ export declare function getCurrentOFWindow(): _Window;
72
+ /**
73
+ * The OpenFin identity for Home.
74
+ */
75
+ export declare const homeOFIdentity: WindowIdentity;
76
+ export declare const dockOFIdentity: WindowIdentity;
77
+ export declare const StorefrontOFIdentity: WindowIdentity;
78
+ export declare const providerOFIdentity: WindowIdentity;
79
+ /**
80
+ * Get the Home OpenFin window.
81
+ */
82
+ export declare function getHomeOFWindow(): _Window;
83
+ export declare function getDockOFWindow(): _Window;
84
+ /**
85
+ * Helper for max and restoring a window.
86
+ * @param identity the identity of the window to maximize or restore.
87
+ */
88
+ export declare function maxOrRestore(identity: WindowIdentity): Promise<void>;
89
+ /**
90
+ * Helper for showing a window.
91
+ * This method ensures the window is shown, brought to front and focused.
92
+ * @param identity the identity of the window to show.
93
+ */
94
+ export declare function showAndFocus(identity: WindowIdentity): Promise<void>;
95
+ /**
96
+ * Helper for hiding a window.
97
+ * This method ensures the window is hidden and blurred.
98
+ * @param identity the identity of the window to hide.
99
+ */
100
+ export declare function hideAndBlur(identity: WindowIdentity): Promise<void>;
101
+ /**
102
+ * Helper for showing / hiding a window.
103
+ * This method calls showAndFocus / hideAndBlur
104
+ * @param identity the identity of the window to hide.
105
+ */
106
+ export declare function toggleVisibility(identity: WindowIdentity): Promise<void>;
107
+ export declare const toggleDock: () => Promise<void>;
108
+ export declare const showAndFocusDock: () => Promise<void>;
109
+ export declare function isAnimatingSize(): boolean;
110
+ /**
111
+ * Resizes a window to width and height saved in the store
112
+ * if they differ from current window size.
113
+ */
114
+ export declare function restoreWindowSize(): Promise<void>;
115
+ export declare function animateSize(width: number, height: number): Promise<void>;
116
+ /**
117
+ * Returns true if the window name is that of a browser window.
118
+ * @param name the window name.
119
+ * @returns true if the name is that of a browser window's.
120
+ */
121
+ export declare const isBrowserWindow: (name: string) => boolean;
122
+ /**
123
+ * Force document body size. Called when resizing or on scaling changes.
124
+ */
125
+ export declare function forceBodySize(): void;
126
+ /**
127
+ * Gets all currently open browser windows.
128
+ */
129
+ export declare function getBrowserWindows(): Promise<_Window[]>;
130
+ /**
131
+ * Closes all currently open Browser windows.
132
+ */
133
+ export declare function closeBrowserWindows(): Promise<void>;
134
+ /**
135
+ * Returns true if the OpenFin window for the provided identity is running.
136
+ * */
137
+ export declare const isWindowRunning: (identity: WindowIdentity) => Promise<boolean>;
138
+ /**
139
+ * Check if Storefront window is running.
140
+ * @returns true if the Storefront window is running.
141
+ */
142
+ export declare const isStorefrontWindowRunning: () => Promise<boolean>;
143
+ export declare const isHomeWindowRunning: () => Promise<boolean>;
144
+ export declare const showAndFocusStorefront: () => Promise<void>;
145
+ export {};
package/index.d.ts CHANGED
@@ -1,6 +1,2 @@
1
- import * as contentStoreAPI from './content-store';
2
- export * from './common';
3
- /**
4
- * Namespace for Content Store integrations.
5
- */
6
- export declare const ContentStore: typeof contentStoreAPI;
1
+
2
+ export * from './client-api/src';
package/index.js CHANGED
@@ -1,2 +1,2 @@
1
- (()=>{"use strict";var e={d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ContentStore:()=>$,launchApp:()=>N});var o,n,r={};e.r(r),e.d(r,{hide:()=>T,register:()=>k,show:()=>b}),function(e){e.Local="local",e.Dev="dev",e.Staging="staging",e.Prod="prod"}(n||(n={}));const a="undefined"!=typeof window&&"undefined"!=typeof fin,i=("undefined"==typeof process||null===(o=process.env)||void 0===o||o.JEST_WORKER_ID,"undefined"!=typeof window),d=(i?window.origin:n.Local,a&&fin.me.uuid,a&&fin.me.name,"undefined"!=typeof ENV?ENV:n.Local,n.Local,n.Dev,n.Staging,n.Prod,!0),c=("undefined"!=typeof WORKSPACE_API_URL&&WORKSPACE_API_URL,"undefined"!=typeof WORKSPACE_APPS_URL&&WORKSPACE_APPS_URL,"undefined"!=typeof WORKSPACE_CONTENT_STORE_FOOTER_URL&&WORKSPACE_CONTENT_STORE_FOOTER_URL,"undefined"!=typeof WORKSPACE_CONTENT_STORE_LANDING_PAGE_URL&&WORKSPACE_CONTENT_STORE_LANDING_PAGE_URL,"undefined"!=typeof WORKSPACE_CONTENT_STORE_NAVIGATION_URL&&WORKSPACE_CONTENT_STORE_NAVIGATION_URL,"#7795f7"),s={trace:!0,debug:"undefined"!=typeof LOG_DEBUG&&LOG_DEBUG,info:!1,warn:!0,error:!0,fatal:!0};const p=function(e,t){const o=`${e} : `,n=`color:${c}`;return{trace:s.trace?(e,...t)=>{console.trace(`%c${o}${e}`,n,...t)}:(e,...t)=>{},debug:s.debug?(e,...t)=>{console.info(`%c${o}${e}`,"color:#86db94",...t)}:(e,...t)=>{},info:s.info?(e,...t)=>{console.debug(`%c${o}${e}`,"color:#ffffff",...t)}:(e,...t)=>{},warn:s.warn?(e,...t)=>{console.warn(`%c${o}${e}`,"color:#edad68",...t)}:(e,...t)=>{},error:s.error?(e,t,...n)=>{console.error(`%c${o}${e}`,"color:#f55d67",...n,t)}:(e,t,...o)=>{},fatal:s.fatal?(e,t,...n)=>{console.error(`%c${o}${e}`,"color:#f70723",...n,t)}:(e,t,...o)=>{}}}("utils.channels"),g=i&&"complete"!==document.readyState&&new Promise((e=>document.addEventListener("readystatechange",(()=>{"complete"===document.readyState&&e()}))));var w,u,l,f,h;!function(e){e.Workspace="openfin-browser"}(w||(w={})),function(e){e.ViewPageTitleUpdated="view-page-title-updated",e.ViewDestroyed="view-destroyed",e.RunRequested="run-requested",e.WindowOptionsChanged="window-options-changed",e.WindowClosed="window-closed",e.WindowCreated="window-created"}(u||(u={})),function(e){e.FinProtocol="fin-protocol"}(l||(l={})),w.Workspace,w.Workspace,function(e){e.Home="openfin-home",e.Dock="openfin-dock",e.ContentStore="openfin-content-store",e.HomeInternal="openfin-home-internal",e.BrowserMenu="openfin-browser-menu",e.BrowserIndicator="openfin-browser-indicator",e.BrowserWindow="internal-generated-window"}(f||(f={})),function(e){e.Shown="shown",e.BoundsChanged="bounds-changed",e.LayoutReady="layout-ready",e.EndUserBoundsChanging="end-user-bounds-changing",e.Blurred="blurred",e.CloseRequested="close-requested",e.Focused="focused",e.ShowRequested="show-requested",e.ViewCrashed="view-crashed",e.ViewAttached="view-attached",e.ViewDetached="view-detached"}(h||(h={})),f.Home,w.Workspace,f.Dock,w.Workspace,f.ContentStore,w.Workspace;const v={name:w.Workspace,uuid:w.Workspace},P=e=>function(e){if(!a)throw new Error("getOFWindow can only be used in an OpenFin env. Avoid calling this method during pre-rendering.");return fin.Window.wrapSync(e)}(e).getOptions().then((()=>!0)).catch((()=>!1));var S,C;(C=S||(S={})).LaunchApp="launch-app",C.CreateWorkspace="create-workspace",C.UpdateWorkspace="update-workspace",C.DeleteWorkspace="delete-workspace",C.LaunchWorkspace="launch-workspace",C.ShareWorkspace="share-workspace",C.GetWorkspace="get-workspace",C.GetWorkspaceList="get-workspace-list",C.GetActiveWorkspace="get-active-workspace",C.GetPage="get-page",C.CreatePage="create-page",C.UpdatePage="update-page",C.RenamePage="rename-page",C.DeletePage="delete-page",C.SharePage="share-page",C.LaunchPage="launch-page",C.AttachPagesToWindow="attach-pages-to-window",C.DetachPagesFromWindow="detach-pages-from-window",C.ReorderPagesForWindow="reorder-pages-for-window",C.SetActivePageForWindow="set-active-page-for-window",C.GetSavedPageList="get-saved-page-list",C.GetAttachedPageList="get-running-page-list",C.GetAllPageList="get-all-page-list",C.GetActivePageIdForWindow="get-active-page-id-for-window",C.GetPagesForWindow="get-pages-for-window",C.GetSavedPageMetadata="get-saved-page-metadata",C.RegisterContentStoreProvider="register-content-store-provider",C.GetContentStoreProviders="get-content-store-providers",C.HideContentStore="hide-content-store",C.GetContentStoreProviderApps="get-content-store-provider-apps",C.GetContentStoreProviderLandingPage="get-content-store-provider-landing-page",C.GetContentStoreProviderFooter="get-content-store-provider-footer",C.GetContentStoreProviderNavigation="get-content-store-provider-navigation",C.LaunchContentStoreProviderApp="launch-content-store-provider-app",C.ShowContentStore="show-content-store",C.CreateContentStoreWindow="create-content-store-window",C.CreateBrowserWindow="create-browser-window";const _=function(e){let t;return()=>{if(!a)throw new Error("getChannelClient cannot be used outside an OpenFin env. Avoid using this method during pre-rendering.");return t||(p.debug(`connecting to channel provider ${e}`),t=(async()=>{await g;const o=await fin.InterApplicationBus.Channel.connect(e);return o.onDisconnection((async()=>{p.warn(`disconnected from channel provider ${e}`),t=void 0})),o})().then((t=>(p.debug(`connected to channel provider ${e}`),t))).catch((t=>{p.error(`failed to connect to channel provider ${e}`,t)}))),t}}("__of_workspace_protocol__"),y=async()=>{if(!await P(v))return fin.System.openUrlWithBrowser((()=>{const e=new URL("fins://cdn.openfin.co/workspace/dev/app.json");return e.searchParams.append("isLaunchedViaLib",d.toString()),e.toString()})())},A=async()=>(await y(),_());var W,O,R;let E;!function(e){e.Snapshot="snapshot",e.Manifest="manifest",e.View="view",e.External="external"}(W||(W={})),(R=O||(O={})).LandingPage="landingPage",R.AppGrid="appGrid";const L=new Map;let m=!1;const G=e=>{if(!L.has(e))throw new Error(`Content Store Provider with id ${e} is not registered`);return L.get(e)},k=e=>(E=(async e=>{const t=await A();if(L.has(e.id))throw new Error(`Content store provider with id ${e.id} already registered`);return L.set(e.id,e),(e=>{m||(m=!0,e.register(S.GetContentStoreProviderApps,(e=>G(e).getApps())),e.register(S.GetContentStoreProviderFooter,(e=>G(e).getFooter())),e.register(S.GetContentStoreProviderLandingPage,(e=>G(e).getLandingPage())),e.register(S.GetContentStoreProviderNavigation,(e=>G(e).getNavigation())),e.register(S.LaunchContentStoreProviderApp,(({id:e,app:t})=>G(e).launchApp(t))))})(t),t.dispatch(S.RegisterContentStoreProvider,e)})(e),E),T=async()=>{await E,await y(),await(async()=>(await _()).dispatch(S.HideContentStore,void 0))()},b=async()=>{await E,await y(),await(async()=>(await _()).dispatch(S.ShowContentStore,null))()},N=async e=>(await A()).dispatch(S.LaunchApp,e),$=r;module.exports=t})();
1
+ (()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{AppManifestType:()=>vt,CLIAction:()=>mt,CLIFilterOptionType:()=>Rt,CLITemplate:()=>St,Home:()=>_t,SearchTagBackground:()=>$e,Storefront:()=>Tt,StorefrontTemplate:()=>yt,launchApp:()=>Wt});var n={};e.r(n),e.d(n,{subscribe:()=>Ae});var o={};e.r(o),e.d(o,{create:()=>rt});var r={};e.r(r),e.d(r,{deregister:()=>gt,hide:()=>ht,register:()=>pt,show:()=>wt});var i,s,a={};e.r(a),e.d(a,{deregister:()=>Et,hide:()=>Lt,register:()=>kt,show:()=>It}),function(e){e.Local="local",e.Dev="dev",e.Staging="staging",e.Prod="prod"}(s||(s={}));const c="undefined"!=typeof window&&"undefined"!=typeof fin,d=("undefined"==typeof process||null===(i=process.env)||void 0===i||i.JEST_WORKER_ID,"undefined"!=typeof window),u=d?window.origin:s.Local,l=(c&&fin.me.uuid,c&&fin.me.name,c&&fin.me.entityType,"undefined"!=typeof ENV?ENV:s.Local,s.Local,s.Dev,s.Staging,s.Prod,!0),f=e=>e.startsWith("http://")||e.startsWith("https://")?e:u+e,p=("undefined"!=typeof WORKSPACE_APPS_URL&&f(WORKSPACE_APPS_URL),"undefined"!=typeof WORKSPACE_STOREFRONT_FOOTER_URL&&f(WORKSPACE_STOREFRONT_FOOTER_URL),"undefined"!=typeof WORKSPACE_STOREFRONT_LANDING_PAGE_URL&&f(WORKSPACE_STOREFRONT_LANDING_PAGE_URL),"undefined"!=typeof WORKSPACE_STOREFRONT_NAVIGATION_URL&&f(WORKSPACE_STOREFRONT_NAVIGATION_URL),"undefined"!=typeof WORKSPACE_SHARE_URL&&f(WORKSPACE_SHARE_URL),"#7795f7"),g={trace:!0,debug:"undefined"!=typeof LOG_DEBUG&&LOG_DEBUG,info:!1,warn:!0,error:!0,fatal:!0};function w(e,t){const n=void 0===t?g:{...g,...t},o=e?`${e} : `:"",r=`color:${p}`;return{trace:n.trace?(e,...t)=>{console.trace(`%c${o}${e}`,r,...t)}:(e,...t)=>{},debug:n.debug?(e,...t)=>{console.info(`%c${o}${e}`,"color:#86db94",...t)}:(e,...t)=>{},info:n.info?(e,...t)=>{console.debug(`%c${o}${e}`,"color:#ffffff",...t)}:(e,...t)=>{},warn:n.warn?(e,...t)=>{console.warn(`%c${o}${e}`,"color:#edad68",...t)}:(e,...t)=>{},error:n.error?(e,t,...n)=>{console.error(`%c${o}${e}`,"color:#f55d67",...n,t)}:(e,t,...n)=>{},fatal:n.fatal?(e,t,...n)=>{console.error(`%c${o}${e}`,"color:#f70723",...n,t)}:(e,t,...n)=>{}}}const h=w("utils.channels"),v=d&&"complete"!==document.readyState&&new Promise((e=>document.addEventListener("readystatechange",(()=>{"complete"===document.readyState&&e()}))));var y,m,S,R,P;!function(e){e.Workspace="openfin-browser"}(y||(y={})),function(e){e.ViewPageTitleUpdated="view-page-title-updated",e.ViewDestroyed="view-destroyed",e.ViewAttached="view-attached",e.RunRequested="run-requested",e.WindowOptionsChanged="window-options-changed",e.WindowClosed="window-closed",e.WindowCreated="window-created"}(m||(m={})),function(e){e.FinProtocol="fin-protocol"}(S||(S={})),y.Workspace,y.Workspace,function(e){e.Home="openfin-home",e.Dock="openfin-dock",e.Storefront="openfin-storefront",e.HomeInternal="openfin-home-internal",e.BrowserMenu="openfin-browser-menu",e.BrowserIndicator="openfin-browser-indicator",e.BrowserWindow="internal-generated-window"}(R||(R={})),function(e){e.Shown="shown",e.BoundsChanged="bounds-changed",e.LayoutReady="layout-ready",e.EndUserBoundsChanging="end-user-bounds-changing",e.Blurred="blurred",e.CloseRequested="close-requested",e.Focused="focused",e.ShowRequested="show-requested",e.ViewCrashed="view-crashed",e.ViewAttached="view-attached",e.ViewDetached="view-detached"}(P||(P={})),R.Home,y.Workspace,R.Dock,y.Workspace,R.Storefront,y.Workspace;const b={name:y.Workspace,uuid:y.Workspace},C=e=>function(e){if(!c)throw new Error("getOFWindow can only be used in an OpenFin env. Avoid calling this method during pre-rendering.");return fin.Window.wrapSync(e)}(e).getOptions().then((()=>!0)).catch((()=>!1));var O,A;(A=O||(O={})).LaunchApp="launch-app",A.CreateWorkspace="create-workspace",A.UpdateWorkspace="update-workspace",A.DeleteWorkspace="delete-workspace",A.LaunchWorkspace="launch-workspace",A.ShareWorkspace="share-workspace",A.GetWorkspace="get-workspace",A.GetWorkspaceList="get-workspace-list",A.GetActiveWorkspace="get-active-workspace",A.GetPage="get-page",A.CreatePage="create-page",A.UpdatePage="update-page",A.RenamePage="rename-page",A.DeletePage="delete-page",A.SharePage="share-page",A.LaunchPage="launch-page",A.AttachPagesToWindow="attach-pages-to-window",A.DetachPagesFromWindow="detach-pages-from-window",A.ReorderPagesForWindow="reorder-pages-for-window",A.SetActivePageForWindow="set-active-page-for-window",A.GetSavedPageList="get-saved-page-list",A.GetAttachedPageList="get-running-page-list",A.GetAllPageList="get-all-page-list",A.GetActivePageIdForWindow="get-active-page-id-for-window",A.GetPagesForWindow="get-pages-for-window",A.GetSavedPageMetadata="get-saved-page-metadata",A.RegisterStorefrontProvider="register-storefront-provider",A.DeregisterStorefrontProvider="deregister-storefront-provider",A.GetStorefrontProviders="get-storefront-providers",A.HideStorefront="hide-storefront",A.GetStorefrontProviderApps="get-storefront-provider-apps",A.GetStorefrontProviderLandingPage="get-storefront-provider-landing-page",A.GetStorefrontProviderFooter="get-storefront-provider-footer",A.GetStorefrontProviderNavigation="get-storefront-provider-navigation",A.LaunchStorefrontProviderApp="launch-storefront-provider-app",A.ShowStorefront="show-storefront",A.CreateStorefrontWindow="create-storefront-window",A.CreateBrowserWindow="create-browser-window",A.ShowHome="show-home",A.HideHome="hide-home",A.AssignHomeSearchContext="assign-home-search-context";const k=function(e){let t;return()=>{if(!c)throw new Error("getChannelClient cannot be used outside an OpenFin env. Avoid using this method during pre-rendering.");return t||(h.debug(`connecting to channel provider ${e}`),t=(async()=>{await v;const n=await fin.InterApplicationBus.Channel.connect(e);return n.onDisconnection((async()=>{h.warn(`disconnected from channel provider ${e}`),t=void 0})),n})().then((t=>(h.debug(`connected to channel provider ${e}`),t))).catch((t=>{h.error(`failed to connect to channel provider ${e}`,t)}))),t}}("__of_workspace_protocol__"),E=e=>{const t=new URL(e);return t.searchParams.append("isLaunchedViaLib",l.toString()),t.toString()},L=async()=>{if(!await C(b))return-1===navigator.userAgent.indexOf("Win")&&await fin.Application.startFromManifest(E("https://cdn.openfin.co/workspace/app.json")),fin.System.openUrlWithBrowser(E("fins://system-apps/workspace"))},I=async()=>(await L(),k()),W="home";var T,_;!function(e){e.Commands="home-commands",e.Workspaces="home-workspaces",e.Pages="home-pages"}(T||(T={})),function(e){e[e.Initial=0]="Initial",e[e.Open=1]="Open",e[e.Close=2]="Close"}(_||(_={}));const $="0",F="5",B="6",G=()=>{};function D(e,t){return e?`${e}-${t}`:t}function M(e){return`__search-${e}-topic__`}const x=new Map;function U(e,t){x.has(e)||x.set(e,new Set),x.get(e).add(t)}function N(e,t){const n=x.get(e);n&&n.delete(t)}const q=new Map;function H(e,t){q.has(e)||q.set(e,new Set),q.get(e).add(t)}function V(e,t){const n=q.get(e);n&&n.delete(t)}const K=new Map;function j(e,t){K.has(e)||K.set(e,new Map),K.get(e).set(t.id,t);const n=x.get(e);n&&n.forEach((e=>e()))}function z(e,t){const n=K.get(e);if(!n)return;n.delete(t);const o=q.get(e);o&&o.forEach((e=>e()))}function J(e){return K.get(e)?[...K.get(e).values()]:[]}function Q(e){const t=K.get(e);t&&t.clear()}function X(e,t){const n=K.get(e);return n?n.get(t):null}function Y(e,t,n){return{...e,action:n||e.actions[0],dispatcherIdentity:t}}function Z(e,t,n="ascending"){const o=e||[];if(!(null==t?void 0:t.length))return o;const r=[],i=new Map;t.forEach((e=>{if(e.key)return i.set(e.key,e);r.push(e)}));let s=o.map((e=>{const{key:t}=e;if(t&&i.has(t)){const e=i.get(t);return i.delete(t),e}return e}));return s.push(...i.values(),...r),s="ascending"===n?s.sort(((e,t)=>(null!==e.score&&void 0!==e.score?e.score:1/0)-(null!==t.score&&void 0!==t.score?t.score:1/0))):s.sort(((e,t)=>(null!==t.score&&void 0!==t.score?t.score:1/0)-(null!==e.score&&void 0!==e.score?e.score:1/0))),s}function ee(e){const t={};let n=[],o=[],r=_.Initial;t.getStatus=()=>r,t.getResultBuffer=()=>n,t.setResultBuffer=e=>{n=e,(null==n?void 0:n.length)&&t.onChange()},t.getRevokedBuffer=()=>o,t.setRevokedBuffer=e=>{o=e,(null==o?void 0:o.length)&&t.onChange()},t.onChange=G;const i={};return t.res=i,i.close=()=>{r!==_.Close&&(r=_.Close,t.onChange())},i.open=()=>{r!==_.Open&&(r=_.Open,t.onChange())},i.respond=n=>{const o=Z(t.getResultBuffer(),n,e);t.setResultBuffer(o)},i.revoke=(...e)=>{const n=new Set(e),o=t.getResultBuffer().filter((({key:e})=>{const t=n.has(e);return t&&n.delete(e),!t}));t.setResultBuffer(o),n.size&&(t.getRevokedBuffer().forEach((e=>n.add(e))),t.setRevokedBuffer([...n]))},t}function te(e,t,n){const o=new Set;let r=!1;return{close:()=>{r=!0;for(const e of o)e()},req:{id:t,topic:e,...n,context:(null==n?void 0:n.context)||{},onClose:e=>{o.add(e),r&&e()},removeListener:e=>{o.delete(e)}}}}function ne(){return{name:fin.me.name,uuid:fin.me.uuid}}function oe(){let e;try{const t=fin.Platform.getCurrentSync();if(!(null==t?void 0:t.identity))return;e=t.identity.uuid}catch(e){}return e}const re="deregistered or does not exist",ie=new Error(`provider ${re}`),se=new Error("provider with name already exists"),ae=new Error("bad payload"),ce=new Error("subscription rejected"),de=new Error(`channel ${re}`),ue=new Map;function le(e){const t=fe(e);if(t)return t;throw de}function fe(e){const t=ue.get(e);if(t)return t}function pe(e,t){ue.set(e,t)}function ge(e){console.error("OpenFin Search API: ",e)}const we=new Map;function he(e){we.has(e)||we.set(e,new Map);const t=we.get(e);return{getRequestsForIdentity:e=>{const n=function(e){return`${e.uuid}:${e.name}`}(e);return t.has(n)||t.set(n,new Map),t.get(n)}}}async function ve(e,t){return(await le(e)).dispatch($,t)}function ye({namespacedTopic:e,topic:t}){const n=X.bind(null,e),o=he(e),r=ve.bind(null,e);return async(e,i)=>{if(!e||!e.id||!e.providerId){const e=ae;return ge(e),{error:e.message}}const{id:s,providerId:a}=e,c=n(a);if(!c){const e=ie;return ge(e),{error:e.message}}const d=o.getRequestsForIdentity(i);let u=d.get(e.id);u||(u=te(t,s,e),d.set(e.id,u));const l=ee(),f=()=>{const e=l.getResultBuffer();l.setResultBuffer([]);const t=l.getRevokedBuffer();l.setRevokedBuffer([]);const n=l.getStatus();r({id:s,providerId:a,results:e,revoked:t,status:n})};let p=!0,g=!1;l.onChange=()=>{if(p)return p=!1,void f();g||(g=!0,setTimeout((()=>{g=!1,f()}),100))};try{const{results:e,context:t}=await c.onUserInput(u.req,l.res),n=l.getStatus();return{id:s,providerId:a,status:n,results:e,context:t}}catch(e){return ge(e),{id:s,providerId:a,error:e.message}}}}async function me(e,t,n){const o=n||await le(e),r=ne(),i={identity:r,...t,onUserInput:void 0,onResultDispatch:void 0};await o.dispatch("2",i),j(e,{identity:r,...t})}async function Se(e,t){const n=await le(e);return await n.dispatch("3",t),z(e,t)}async function Re(e,t,n,o){const r=Y(n,ne(),o),i=X(e,t);if(i){const{onResultDispatch:e}=i;if(!e)return;return e(r)}const s={providerId:t,result:r};return(await le(e)).dispatch(F,s)}async function Pe(e,t){const n={...t,context:(null==t?void 0:t.context)||{}},o={},r=async function*(e,t,{setState:n}){const o=await le(e);for(;;){const e=await o.dispatch("1",t),r=e.error;if(r)throw new Error(r);const i=e;if(t.id=i.id,n(i.state),i.done)return i.value;yield i.value}}(e,n,{setState:e=>{o.state=e}});let i=await r.next();return o.id=n.id,o.close=()=>{!async function(e,t){(await le(e)).dispatch(B,{id:t})}(e,o.id)},o.next=()=>{if(i){const e=i;return i=void 0,e}return r.next()},o}async function be(e){return(await le(e)).dispatch("4",null)}async function Ce(e){const t=await le(e);var n;n=e,ue.delete(n),Q(e),await t.disconnect()}async function Oe(e){const{namespacedTopic:t}=e,n=M(t),o=await async function(e){for(let t=0;t<50;t++)try{return await fin.InterApplicationBus.Channel.connect(e,{wait:!1})}catch(e){if(49===t)throw e;await new Promise((e=>setTimeout(e,1e3)))}}(n);return o.register($,ye(e)),o.register(B,function(e){const t=he(e);return(e,n)=>{const o=t.getRequestsForIdentity(n),r=o.get(e.id);r&&(r.close(),o.delete(e.id))}}(t)),o.register(F,function(e){return async(t,n)=>{if(!t||!t.providerId||!t.result)return void ge(ae);const o=X(e,t.providerId);if(!o)return void ge(ie);const{onResultDispatch:r}=o;return r?(t.result.dispatcherIdentity=n,r(t.result)):void 0}}(t)),o.onDisconnection(function(e){const{namespacedTopic:t}=e,n=he(t);return async o=>{if(!fe(t))return;const r=n.getRequestsForIdentity(o);for(const{req:e,close:t}of r.values())t(),r.delete(e.id);pe(t,(async e=>{const{namespacedTopic:t}=e,n=await Oe(e);for(const e of J(t))await me(t,e,n);return n})(e))}}(e)),o}async function Ae(e){const t=("string"==typeof e?e:null==e?void 0:e.topic)||"all",n=("string"==typeof e?null:null==e?void 0:e.uuid)||oe(),o=D(n,t),r={topic:t,namespace:n,namespacedTopic:o};let i=fe(o);return i||(i=Oe(r),pe(o,i),await i),{getAllProviders:be.bind(null,o),register:me.bind(null,o),search:Pe.bind(null,o),deregister:Se.bind(null,o),dispatch:Re.bind(null,o),disconnect:Ce.bind(null,o)}}const ke=new Map;function Ee(e){const t=Le(e);if(t)return t;throw de}function Le(e){const t=ke.get(e);if(t)return t}const Ie=new Map;function We(e,t){Ie.has(e)||Ie.set(e,new Set),Ie.get(e).add(t)}function Te(e,t){const n=Ie.get(e);n&&n.delete(t)}var _e,$e;function Fe(e){return[...J(e)].map((e=>({...e,onUserInput:void 0,onResultDispatch:void 0})))}function Be(e,t){if(X(e,t.id))throw new Error("provider with name already exists");j(e,{identity:ne(),...t})}function Ge(e,t){z(e,t)}async function De(e,t,n,o){const r=X(e,t);if(!r)throw ie;const{onResultDispatch:i}=r;if(i)return i(Y(n,ne(),o))}!function(e){e.Fetching="fetching",e.Fetched="fetched",e.Complete="complete"}(_e||(_e={})),function(e){e.Active="active",e.Default="default"}($e||($e={}));let Me=0;function xe({namespacedTopic:e,topic:t},n){Me+=1;const o=te(t,Me.toString(),n);let r;return r=async function*(e,t,n){const o=function(e,t){const n=[],o=[],r=[],i=[];for(const s of e){const e=ee(s.scoreOrder),a={results:[],provider:{id:s.id,identity:s.identity,title:s.title,scoreOrder:s.scoreOrder,icon:s.icon}};n.push(a),o.push(e);const c=(async()=>{try{const{results:n,context:o}=await s.onUserInput(t,e.res);a.results=Z(a.results,n),a.context={...a.context,...o}}catch(e){a.error=e}c.done=!0})();i.push(c),r.push(r.length)}return{providerResponses:n,listenerResponses:o,openListenerResponses:r,initialResponsePromises:i}}(t.targets?t.targets.map((t=>X(e,t))).filter((e=>!!e)):[...J(e).filter((e=>!e.hidden))],t),{providerResponses:r,listenerResponses:i}=o;let{openListenerResponses:s,initialResponsePromises:a}=o,c=_e.Fetching;const d=e=>{c=e,n.setState(c)};let u,l=!1;t.onClose((()=>{l=!0,u&&u()}));do{let e=!1;if(a.length){const t=[];for(const n of a)n.done?e=!0:t.push(n);a=t,a.length||(d(_e.Fetched),e=!0)}let t,n=!1;const o=()=>{n=!0,t&&t()},f=[];for(const t of s){const n=i[t],s=r[t],a=n.getStatus();(a===_.Open||c===_e.Fetching&&a===_.Initial)&&(f.push(t),n.onChange=o);const d=n.getResultBuffer();d.length&&(n.setResultBuffer([]),s.results=Z(s.results,d),e=!0);const u=n.getRevokedBuffer();if(u.length){n.setRevokedBuffer([]);const t=new Set(u);s.results=s.results.filter((({key:e})=>!t.has(e))),e=!0}}if(s=f,e&&(yield r),l)break;n||(s.length||a.length)&&await Promise.race([...a,new Promise((e=>{t=e})),new Promise((e=>{u=e}))])}while(s.length||a.length);return d(_e.Complete),r}(e,o.req,{setState:e=>{r.state=e}}),r.id=Me.toString(),r.close=o.close,r.state=_e.Fetching,r}const Ue=new Map;function Ne(e,t){return`${e}:${t}`}function qe(e,t,n){return Ee(e).dispatch(t,B,{id:n})}async function He(e,t,{id:n,query:o,context:r,targets:i}){const s=Ee(e),a={id:n,query:o,context:r,targets:i,providerId:t.id},c=await s.dispatch(t.identity,$,a),d=c.error;if(d)throw new Error(d);return c}const Ve=new Map;function Ke(e,t,n){return`${e}:${t.name}:${t.uuid}:${n}`}const je=new Map;function ze(e,t,n){return`${e}:${t}:${n}`}function Je(e,t){const n=Ke.bind(null,e,t.identity),o=qe.bind(null,e,t.identity),r=He.bind(null,e,t);return async(i,s)=>{const a=n(i.id);if(!Ve.has(a)){const e=()=>{o(i.id),Ve.delete(a)};Ve.set(a,e),i.onClose(e)}const c=ze(e,t.id,i.id),d=()=>{je.delete(c),s.close()};i.onClose(d),je.set(c,(e=>{var t,n;(null===(t=e.results)||void 0===t?void 0:t.length)&&s.respond(e.results),(null===(n=e.revoked)||void 0===n?void 0:n.length)&&s.revoke(...e.revoked),e.status===_.Open&&s.open(),e.status===_.Close&&d()}));const u=await r(i);return u.status===_.Open&&s.open(),u.status!==_.Close&&u.status!==_.Initial||d(),u}}function Qe(e,t){return async n=>{const o=Ee(e),r={providerId:t.id,result:n};return o.dispatch(t.identity,F,r)}}const Xe=new Map;function Ye(e,t){return`${e}-${t.name}-${t.uuid}`}const Ze=new Map;function et(e,t){Ze.has(e)||Ze.set(e,new Set),Ze.get(e).add(t)}function tt(e,t){const n=Ze.get(e);n&&n.delete(t)}async function nt(e){const{namespacedTopic:t}=e,n=M(e.namespacedTopic),o=await(r=n,fin.InterApplicationBus.Channel.create(r));var r;return o.onConnection(function({namespacedTopic:e}){return async t=>{const n=Ie.get(e);if(n)for(const e of n)if(!await e(t))throw ce}}(e)),o.onDisconnection(function(e){return async t=>{!function(e,t){const n=Ye(e,t),o=Xe.get(n);if(o){for(const t of o)z(e,t);Xe.delete(n)}}(e,t);const n=Ze.get(e);n&&n.forEach((e=>e(t)))}}(t)),o.register(B,function(e){return t=>function(e,t){const n=Ne(e,t),o=Ue.get(n);o&&o.generator.close()}(e,t.id)}(t)),o.register($,function(e){return t=>{const n=ze(e,t.providerId,t.id),o=je.get(n);o&&o(t)}}(t)),o.register("2",function(e){return(t,n)=>{if(t&&t.id){if(X(e,t.id))throw se;t.identity=n,function(e,t){const n=Ye(e,t.identity);Xe.has(n)||Xe.set(n,[]),Xe.get(n).push(t.id),j(e,{...t,onUserInput:Je(e,t),onResultDispatch:Qe(e,t)})}(e,t)}else ge(ae)}}(t)),o.register("3",function(e){return t=>{t?function(e,t){const n=X(e,t);if(!n)return;const o=Ye(e,n.identity),r=Xe.get(o);if(r){const n=r.findIndex((e=>e===t));-1!==n&&(r.splice(n,1),z(e,t))}}(e,t):ge(ae)}}(t)),o.register("4",function(e){return async()=>Fe(e)}(t)),o.register("1",function(e){return async t=>{if(!t)return ge(ae),{error:ae.message};let n;if(t.id)n=Ne(e.namespacedTopic,t.id);else{const o=xe(e,t);n=Ne(e.namespacedTopic,o.id),t.id=o.id,Ue.set(n,{generator:o})}const o=Ue.get(n);clearTimeout(o.timeout);const r=await o.generator.next();return o.timeout=function(e){return window.setTimeout((()=>{Ue.delete(e)}),1e4)}(n),{...r,id:t.id,state:o.generator.state}}}(e)),o.register(F,function(e){return async(t,n)=>{if(!t||!t.providerId||!t.result)return void ge(ae);const o=X(e,t.providerId);if(!o)throw ie;const{onResultDispatch:r}=o;return r?(t.result.dispatcherIdentity=n,r(t.result)):void 0}}(t)),o}async function ot(e){const t=Ee(e);var n;n=e,ke.delete(n),await t.destroy(),Q(e)}async function rt(e){const t=("string"==typeof e?e:null==e?void 0:e.topic)||"all",n=oe(),o=D(n,t),r={topic:t,namespace:n,namespacedTopic:o};let i=Le(o);i||(i=await nt(r),function(e,t){ke.set(e,t)}(o,i));const s=Te.bind(null,o),a=tt.bind(null,o),c=N.bind(null,o),d=V.bind(null,o);return{getAllProviders:Fe.bind(null,o),search:xe.bind(null,r),register:Be.bind(null,o),deregister:Ge.bind(null,o),onSubscription:We.bind(null,o),onDisconnect:et.bind(null,o),onRegister:U.bind(null,o),onDeregister:H.bind(null,o),dispatch:De.bind(null,r),disconnect:ot.bind(null,o),removeListener:e=>{s(e),a(e),c(e),d(e)}}}const{create:it}=o,{subscribe:st}=n,at={create:it,subscribe:st,defaultTopic:"all"},ct=()=>{const e=window;e.search=at,e.fin&&(e.fin.Search=at)},dt=e=>{const t=()=>{ct(),window.removeEventListener(e,t)};return t};if("undefined"!=typeof window){ct();const e="load",t=dt(e);window.addEventListener(e,t);const n="DOMContentLoaded",o=dt(n);window.addEventListener(n,o)}w("api.common.search");const ut=new Map;let lt;async function ft(e){return await async function(){return lt||(lt=async function(){await async function(e){ut.set(e,await st({topic:e,uuid:y.Workspace}))}(W)}()),lt}(),ut.get(e)}const pt=async e=>{if(!e.icon)throw new Error(`${e.id} provider needs to have icon property defined.`);return await L(),(await ft(W)).register(e)},gt=async e=>(await L(),(await ft(W)).deregister(e));async function wt(){return(await I()).dispatch(O.ShowHome,void 0)}async function ht(){return(await I()).dispatch(O.HideHome,void 0)}var vt,yt,mt,St,Rt,Pt;let bt;!function(e){e.Snapshot="snapshot",e.Manifest="manifest",e.View="view",e.External="external"}(vt||(vt={})),(Pt=yt||(yt={})).LandingPage="landingPage",Pt.AppGrid="appGrid",function(e){e.Suggestion="suggestion"}(mt||(mt={})),function(e){e.Contact="Contact",e.List="List",e.Plain="Plain",e.SimpleText="SimpleText"}(St||(St={})),function(e){e.MultiSelect="MultiSelect"}(Rt||(Rt={}));const Ct=new Map;let Ot=!1;const At=e=>{if(!Ct.has(e))throw new Error(`Storefront Provider with id ${e} is not registered`);return Ct.get(e)},kt=e=>(bt=(async e=>{const t=await I();if(Ct.has(e.id))throw new Error(`Storefront provider with id ${e.id} already registered`);return Ct.set(e.id,e),(e=>{Ot||(Ot=!0,e.register(O.GetStorefrontProviderApps,(e=>At(e).getApps())),e.register(O.GetStorefrontProviderFooter,(e=>At(e).getFooter())),e.register(O.GetStorefrontProviderLandingPage,(e=>At(e).getLandingPage())),e.register(O.GetStorefrontProviderNavigation,(e=>At(e).getNavigation())),e.register(O.LaunchStorefrontProviderApp,(({id:e,app:t})=>At(e).launchApp(t))))})(t),t.dispatch(O.RegisterStorefrontProvider,e)})(e),bt),Et=async e=>(await bt,Ct.delete(e),(await I()).dispatch(O.DeregisterStorefrontProvider,e)),Lt=async()=>{await bt,await L(),await(async()=>(await k()).dispatch(O.HideStorefront,void 0))()},It=async()=>{await bt,await L(),await(async()=>(await k()).dispatch(O.ShowStorefront,null))()},Wt=async e=>(await I()).dispatch(O.LaunchApp,{app:e}),Tt=a,_t=r;module.exports=t})();
2
2
  //# sourceMappingURL=index.js.map