@openfin/workspace-platform 4.3.0 → 4.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.
Files changed (97) hide show
  1. package/client-api/src/shapes.d.ts +596 -0
  2. package/{index.ts → client-api-platform/index.d.ts} +0 -0
  3. package/client-api-platform/src/api/app-directory.d.ts +7 -0
  4. package/client-api-platform/src/api/browser/browser-module.d.ts +13 -0
  5. package/client-api-platform/src/api/browser/index.d.ts +22 -0
  6. package/client-api-platform/src/api/pages/helper.d.ts +22 -0
  7. package/client-api-platform/src/api/pages/index.d.ts +30 -0
  8. package/client-api-platform/src/api/protocol.d.ts +47 -0
  9. package/client-api-platform/src/api/storage.d.ts +10 -0
  10. package/client-api-platform/src/api/workspace-module.d.ts +3 -0
  11. package/client-api-platform/src/index.d.ts +6 -0
  12. package/client-api-platform/src/init/browser-window-focus.d.ts +19 -0
  13. package/client-api-platform/src/init/cleanup.d.ts +1 -0
  14. package/client-api-platform/src/init/index.d.ts +5 -0
  15. package/client-api-platform/src/init/override-callback.d.ts +3 -0
  16. package/client-api-platform/src/init/utils.d.ts +39 -0
  17. package/{src/shapes.ts → client-api-platform/src/shapes.d.ts} +2 -29
  18. package/client-api-platform/src/umd.d.ts +1 -0
  19. package/common/src/api/pages/attached.d.ts +101 -0
  20. package/common/src/api/pages/idb.d.ts +12 -0
  21. package/common/src/api/pages/index.d.ts +16 -0
  22. package/common/src/api/pages/legacy.d.ts +16 -0
  23. package/common/src/api/pages/shapes.d.ts +77 -0
  24. package/common/src/api/protocol.d.ts +63 -0
  25. package/common/src/api/workspaces/index.d.ts +7 -0
  26. package/common/src/utils/application.d.ts +38 -0
  27. package/common/src/utils/channels.d.ts +8 -0
  28. package/common/src/utils/debounce.d.ts +16 -0
  29. package/common/src/utils/env.d.ts +30 -0
  30. package/common/src/utils/layout.d.ts +52 -0
  31. package/common/src/utils/local-storage-key.d.ts +8 -0
  32. package/common/src/utils/logger/index.d.ts +26 -0
  33. package/common/src/utils/logger/manager.d.ts +35 -0
  34. package/common/src/utils/logger/shapes.d.ts +27 -0
  35. package/common/src/utils/route.d.ts +55 -0
  36. package/common/src/utils/shared-emitter.d.ts +10 -0
  37. package/common/src/utils/snapshot.d.ts +33 -0
  38. package/common/src/utils/strings.d.ts +5 -0
  39. package/common/src/utils/umd.d.ts +2 -0
  40. package/common/src/utils/window.d.ts +146 -0
  41. package/index.d.ts +1 -0
  42. package/index.js +2 -0
  43. package/index.js.map +1 -0
  44. package/package.json +1 -34
  45. package/search-api/src/client/index.d.ts +6 -0
  46. package/search-api/src/client/internal.d.ts +38 -0
  47. package/search-api/src/client/remote/channel-client-factory.d.ts +2 -0
  48. package/search-api/src/client/remote/channel-client.d.ts +9 -0
  49. package/search-api/src/client/remote/data.d.ts +16 -0
  50. package/search-api/src/client/remote/disconnect.d.ts +7 -0
  51. package/search-api/src/client/remote/dispatch.d.ts +9 -0
  52. package/search-api/src/client/remote/requests.d.ts +5 -0
  53. package/search-api/src/client/remote/search-close.d.ts +14 -0
  54. package/search-api/src/common.d.ts +104 -0
  55. package/search-api/src/errors.d.ts +5 -0
  56. package/search-api/src/fin/index.d.ts +6 -0
  57. package/search-api/src/fin/shapes.d.ts +23 -0
  58. package/search-api/src/index.d.ts +7 -0
  59. package/search-api/src/internal-shapes.d.ts +134 -0
  60. package/search-api/src/logger.d.ts +1 -0
  61. package/search-api/src/provider/index.d.ts +8 -0
  62. package/search-api/src/provider/internal.d.ts +33 -0
  63. package/search-api/src/provider/remote/channel-factory.d.ts +6 -0
  64. package/search-api/src/provider/remote/channel.d.ts +23 -0
  65. package/search-api/src/provider/remote/connection.d.ts +20 -0
  66. package/search-api/src/provider/remote/data.d.ts +23 -0
  67. package/search-api/src/provider/remote/deregistration.d.ts +5 -0
  68. package/search-api/src/provider/remote/disconnect.d.ts +1 -0
  69. package/search-api/src/provider/remote/disconnection.d.ts +9 -0
  70. package/search-api/src/provider/remote/dispatch.d.ts +7 -0
  71. package/search-api/src/provider/remote/info.d.ts +5 -0
  72. package/search-api/src/provider/remote/registration.d.ts +23 -0
  73. package/search-api/src/provider/remote/search-close.d.ts +14 -0
  74. package/search-api/src/provider/remote/search.d.ts +8 -0
  75. package/search-api/src/shapes.d.ts +541 -0
  76. package/.eslintignore +0 -1
  77. package/.eslintrc.js +0 -2
  78. package/.prettierrc.js +0 -2
  79. package/babel.config.js +0 -2
  80. package/jest.config.js +0 -2
  81. package/src/api/app-directory.ts +0 -45
  82. package/src/api/browser/browser-module.ts +0 -65
  83. package/src/api/browser/index.ts +0 -46
  84. package/src/api/pages/helper.ts +0 -113
  85. package/src/api/pages/index.ts +0 -164
  86. package/src/api/protocol.ts +0 -60
  87. package/src/api/storage.ts +0 -32
  88. package/src/api/workspace-module.ts +0 -36
  89. package/src/index.ts +0 -35
  90. package/src/init/browser-window-focus.ts +0 -59
  91. package/src/init/cleanup.ts +0 -87
  92. package/src/init/index.ts +0 -42
  93. package/src/init/override-callback.ts +0 -159
  94. package/src/init/utils.ts +0 -164
  95. package/src/umd.ts +0 -5
  96. package/tsconfig.json +0 -13
  97. package/webpack.common.config.js +0 -1
@@ -1,159 +0,0 @@
1
- import { getSnapshotExtended } from '@common/utils/snapshot';
2
- import { closeBrowserWindows } from '@common/utils/window';
3
-
4
- import * as defaultPagesProvider from '@common/api/pages/idb';
5
-
6
- import type { BrowserInitConfig } from '@client-platform/shapes';
7
-
8
- import { launchApp } from '../api/app-directory';
9
- import {
10
- attachPagesToWindow,
11
- createSavedPageInternal,
12
- deleteSavedPageInternal,
13
- detachPagesFromWindow,
14
- getOpenPages,
15
- getPageForWindow,
16
- getPagesForWindow,
17
- getUniquePageTitle,
18
- reorderPagesForWindow,
19
- savePage,
20
- setActivePageForWindow,
21
- updatePageForWindow,
22
- updateSavedPageInternal
23
- } from '../api/pages';
24
- import { applySnapshotWithPages, getSnapshotWithPages } from '../api/pages/helper';
25
-
26
- import { getLastFocusedBrowserWindow } from './browser-window-focus';
27
- import {
28
- applyBrowserDefaults,
29
- filterSnapshotWindows,
30
- fitToMonitor,
31
- initWorkspacePlatformOptions,
32
- overrideViewOptions
33
- } from './utils';
34
-
35
- export const getOverrideCallback = (
36
- initOptions: BrowserInitConfig
37
- ): OpenFin.OverrideCallback<OpenFin.PlatformProvider> => async (Provider) => {
38
- class Override extends Provider {
39
- async getSnapshot() {
40
- const originalSnap = await getSnapshotWithPages(async () =>
41
- getSnapshotExtended(await super.getSnapshot(undefined, fin.me.identity))
42
- );
43
- const finalSnapshot = {
44
- ...originalSnap,
45
- windows: originalSnap.windows.filter(filterSnapshotWindows)
46
- };
47
- return finalSnapshot;
48
- }
49
-
50
- async applySnapshot({ snapshot, options }) {
51
- const superApplySnapshot = (superSnapshot) =>
52
- super.applySnapshot({
53
- snapshot: superSnapshot,
54
- options: { ...options, closeExistingWindows: false }
55
- });
56
-
57
- if (options?.closeExistingWindows) {
58
- await closeBrowserWindows();
59
- }
60
- let targetSnapshot = snapshot;
61
-
62
- if (typeof targetSnapshot === 'string') {
63
- targetSnapshot = await super.fetchManifest({ manifestUrl: targetSnapshot }, fin.me.identity);
64
- }
65
-
66
- return applySnapshotWithPages(targetSnapshot, superApplySnapshot);
67
- }
68
-
69
- async createWindow(options: OpenFin.PlatformWindowCreationOptions, callerIdentity) {
70
- let overrideOptions = initWorkspacePlatformOptions(options);
71
-
72
- // override options if layout exists
73
- overrideOptions = applyBrowserDefaults(overrideOptions);
74
-
75
- // Fixes height issue on mac for workspaces loading on small monitors
76
- // override default value sizes to fit available rectangle
77
- overrideOptions = await fitToMonitor(overrideOptions);
78
-
79
- return super.createWindow(overrideOptions, callerIdentity);
80
- }
81
-
82
- async createView(payload: OpenFin.CreateViewPayload, callerIdentity) {
83
- overrideViewOptions(payload.opts);
84
- return super.createView(payload, callerIdentity);
85
- }
86
-
87
- async replaceView(payload: OpenFin.ReplaceViewPayload, callerIdentity) {
88
- overrideViewOptions(payload.opts.newView);
89
- return super.replaceView(payload, callerIdentity);
90
- }
91
-
92
- async replaceLayout(payload, caller) {
93
- // force our dimensions as well (particularly headerHeight)
94
- delete payload.opts.layout?.dimensions;
95
- return super.replaceLayout(payload, caller);
96
- }
97
-
98
- async closeView(payload: OpenFin.CloseViewPayload, callerIdentity) {
99
- const view = fin.View.wrapSync(payload.view);
100
- await super.closeView(payload, callerIdentity);
101
- await view.destroy().catch((e) => e); // do nothing, view destroyed by super
102
- }
103
-
104
- isWorkspacePlatform = () => true;
105
-
106
- // *****STORAGE APIs - SHOULD NOT USE INDEXEDDB STORAGE BY DEFAULT
107
- getSavedPage = defaultPagesProvider.getPage;
108
-
109
- getSavedPages = defaultPagesProvider.getPageList;
110
-
111
- createSavedPage = defaultPagesProvider.createPage;
112
-
113
- deleteSavedPage = defaultPagesProvider.deletePage;
114
-
115
- updateSavedPage = defaultPagesProvider.updatePage;
116
- // *****END STORAGE APIs
117
-
118
- // *****EXECUTION APIs
119
- // ***EXPOSE TO API
120
- attachPagesToWindow = attachPagesToWindow;
121
-
122
- addPage = attachPagesToWindow;
123
-
124
- detachPagesFromWindow = detachPagesFromWindow;
125
-
126
- getOpenPages = getOpenPages;
127
-
128
- getPagesForWindow = getPagesForWindow;
129
-
130
- getPageForWindow = getPageForWindow;
131
-
132
- setActivePageForWindow = setActivePageForWindow;
133
-
134
- launchApp = launchApp;
135
-
136
- // INTERNAL ONLY EXECUTION APIs
137
- savePage = savePage;
138
-
139
- createSavedPageInternal = createSavedPageInternal;
140
-
141
- updateSavedPageInternal = updateSavedPageInternal;
142
-
143
- deleteSavedPageInternal = deleteSavedPageInternal;
144
-
145
- reorderPagesForWindow = reorderPagesForWindow;
146
-
147
- getUniquePageTitle = getUniquePageTitle;
148
-
149
- updatePageForWindow = updatePageForWindow;
150
-
151
- getLastFocusedBrowserWindow = getLastFocusedBrowserWindow;
152
- }
153
-
154
- // Client API Overrides our overrides
155
- if (typeof initOptions?.overrideCallback === 'function') {
156
- return initOptions.overrideCallback(Override);
157
- }
158
- return new Override();
159
- };
package/src/init/utils.ts DELETED
@@ -1,164 +0,0 @@
1
- import { workspaceCdnEnvUrl } from '@common/utils/env';
2
- import Route from '@common/utils/route';
3
- import { WindowName } from '@common/utils/window';
4
-
5
- import type { AttachedPage } from '@common/api/pages/shapes';
6
-
7
- const defaultBrowserUrl = workspaceCdnEnvUrl + Route.Browser;
8
-
9
- export function overrideViewOptions(options: Partial<OpenFin.ViewOptions>) {
10
- options.detachOnClose = true;
11
- }
12
-
13
- export const filterSnapshotWindows = (win: OpenFin.WindowOptions) => {
14
- const isHome = win.name === WindowName.Home;
15
- const isHomeInternal = win.name?.startsWith(WindowName.HomeInternal);
16
- const isInternalMenu = win.name?.startsWith(WindowName.BrowserMenu);
17
- return !isHome && !isHomeInternal && !isInternalMenu;
18
- };
19
-
20
- /**
21
- * fitToMonitor()
22
- * Function to determine if window size is too large
23
- * for available rectangle area.
24
- *
25
- * - Checks monitor data for available rectangle coords
26
- * - Defines max width/height for current monitor
27
- * - Defines default width/height if property is not set
28
- * - Updates options object default width/height if they exceed max values
29
- *
30
- * Ticket: WRK-1084
31
- *
32
- * @param options - Object passed into createWindow -> contains height and width
33
- * @returns unprocessed or processed options object
34
- */
35
- export const fitToMonitor = async (options) => {
36
- // get monitor dimensions
37
- const monitor = await fin.System.getMonitorInfo();
38
-
39
- // Extract the max height from the available area between top and bottom
40
- const maxHeight = monitor.primaryMonitor.availableRect.bottom - monitor.primaryMonitor.availableRect.top;
41
- const maxWidth = monitor.primaryMonitor.availableRect.right - monitor.primaryMonitor.availableRect.left;
42
-
43
- /**
44
- * Q?: Should these default values be somewhere global?
45
- * I know that we have values set somewhere, probably in
46
- * a database or backend, but I don't see anything
47
- * defined in the workspace code.
48
- */
49
- // createView doesn't pass default size properties, so defaults added here
50
- options.defaultHeight = options.defaultHeight || '800';
51
- options.defaultWidth = options.defaultWidth || '800';
52
-
53
- // if max height is less than default height set default height to max height
54
- if (maxHeight < options.defaultHeight) {
55
- options.defaultHeight = maxHeight;
56
- }
57
- // if max width is less than default width set default width to max width
58
- if (maxWidth < options.defaultWidth) {
59
- options.defaultWidth = maxWidth;
60
- }
61
-
62
- return options;
63
- };
64
-
65
- type LegacyWindowOptions = Omit<OpenFin.PlatformWindowCreationOptions, 'workspacePlatform'> & {
66
- pages?: OpenFin.Page[];
67
- workstacks?: OpenFin.Page[];
68
- };
69
-
70
- const migrateLegacyOptions = ({
71
- workstacks,
72
- pages,
73
- ...rest
74
- }: LegacyWindowOptions): OpenFin.PlatformWindowCreationOptions => {
75
- return { ...rest, workspacePlatform: { pages: pages || workstacks || null } };
76
- };
77
-
78
- export const initWorkspacePlatformOptions = (
79
- options: LegacyWindowOptions | OpenFin.PlatformWindowCreationOptions
80
- ): OpenFin.PlatformWindowCreationOptions => {
81
- if ('workspacePlatform' in options) return options;
82
-
83
- return migrateLegacyOptions(options);
84
- };
85
-
86
- const defaultWindowOptions = {
87
- contextMenuSettings: {
88
- reload: false
89
- },
90
- url: defaultBrowserUrl,
91
- contextMenu: true,
92
- waitForPageLoad: true,
93
- cornerRounding: {
94
- height: 8,
95
- width: 8
96
- },
97
- closeOnLastViewRemoved: false,
98
- experimental: {
99
- showFavicons: true,
100
- defaultFaviconUrl: `${workspaceCdnEnvUrl}/icons/defaultFavicon.svg`
101
- },
102
- permissions: {
103
- System: {
104
- openUrlWithBrowser: {
105
- enabled: true,
106
- protocols: ['mailto']
107
- }
108
- }
109
- }
110
- };
111
-
112
- const defaultLayout = {
113
- dimensions: {
114
- borderWidth: 3,
115
- headerHeight: 30
116
- }
117
- };
118
-
119
- /**
120
- * hasLayout()
121
- * Function to force layout settings
122
- * - Check if layout property exists if so process data, else return as is
123
- * - Define behavior settings
124
- * - Force dimension options
125
- * - Validate icon
126
- *
127
- * Ticket: WRK-???
128
- *
129
- * @param options - options used to handle layout settings
130
- * @returns processed or unprocesseed options
131
- */
132
-
133
- export const applyBrowserDefaults = (options: OpenFin.PlatformWindowCreationOptions) => {
134
- const pages: AttachedPage[] = options?.workspacePlatform?.pages;
135
- if (pages) {
136
- const activePage = pages.find((page) => page.isActive);
137
- if (activePage) {
138
- options.layout = activePage.layout;
139
- } else {
140
- pages[0].isActive = true;
141
- options.layout = pages[0].layout;
142
- }
143
- }
144
- if (options.layout) {
145
- // If the window has a layout it should always be opened in our default browser window
146
- // TODO: Would need to alter this to allow for non-Browser layout windows
147
- Object.assign(options, defaultWindowOptions);
148
- options.layout = Object.assign(options.layout, defaultLayout);
149
-
150
- // just use the normal OpenFin icon and taskbarIcon options
151
- if (options.icon || (options as any).taskbarIcon) {
152
- options.taskbarIconGroup = options.taskbarIconGroup || fin.me.identity.uuid;
153
- }
154
-
155
- const newTabUrl = options.workspacePlatform.newTabUrl;
156
- if (newTabUrl) {
157
- if (!options.layout.settings) {
158
- options.layout.settings = {};
159
- }
160
- options.layout.settings.newTabButton = { url: newTabUrl };
161
- }
162
- }
163
- return options;
164
- };
package/src/umd.ts DELETED
@@ -1,5 +0,0 @@
1
- import injectAPI from '@common/utils/umd';
2
-
3
- import * as WorkspacePlatform from '../index';
4
-
5
- injectAPI('Workspace.WorkspacePlatform', WorkspacePlatform);
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "@openfin/common/tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "out",
5
- "noUnusedLocals": true,
6
- "downlevelIteration": true,
7
- "declaration": true,
8
- "removeComments": false,
9
- "noEmit": false
10
- },
11
- "include": ["./src/**/*.ts", "./src/**/*.tsx", "../common/common.d.ts"],
12
- "exclude": ["node_modules"]
13
- }
@@ -1 +0,0 @@
1
- module.exports = require('@openfin/common/webpack.common.config');