@openfin/core 29.72.1 → 29.72.5

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/OpenFin.d.ts CHANGED
@@ -250,17 +250,18 @@ declare namespace OpenFin {
250
250
 
251
251
  export type WindowOptions = MutableWindowOptions & ConstWindowOptions;
252
252
 
253
- export interface ShowViewOnWindowResizeOptions {
253
+ export type ViewVisibilityOption = {
254
254
  enabled?: boolean;
255
- paintIntervalMs?: number;
256
255
  }
257
256
 
258
- export interface ShowViewOnSplitterDragOptions {
259
- enabled?: boolean;
257
+ export type ShowViewOnWindowResizeOptions = ViewVisibilityOption & {
258
+ paintIntervalMs?: number;
260
259
  }
260
+
261
261
  export type ViewVisibilityOptions = {
262
262
  showViewsOnWindowResize?: ShowViewOnWindowResizeOptions;
263
- showViewsOnSplitterDrag?: ShowViewOnSplitterDragOptions;
263
+ showViewsOnSplitterDrag?: ViewVisibilityOption;
264
+ showViewsOnTabDrag?: ViewVisibilityOption;
264
265
  };
265
266
 
266
267
  export type WindowState = 'maximized' | 'minimized' | 'normal';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "29.72.1",
3
+ "version": "29.72.5",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./src/mock.js",
6
6
  "types": "./src/mock.d.ts",
@@ -16,10 +16,11 @@ var _layoutManager;
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.LayoutModule = void 0;
18
18
  /* eslint-disable no-undef, import/prefer-default-export */
19
+ const tab_drag_controller_1 = require("./controllers/tab-drag-controller");
19
20
  const Instance_1 = require("./Instance");
20
21
  const base_1 = require("../../base");
21
- const SplitterController_1 = require("./SplitterController");
22
- const view_overlay_1 = require("./SplitterController/view-overlay");
22
+ const splitter_controller_1 = require("./controllers/splitter-controller");
23
+ const view_overlay_1 = require("./utils/view-overlay");
23
24
  /**
24
25
  * InitLayoutOptions interface
25
26
  * @typedef { object } InitLayoutOptions
@@ -108,8 +109,9 @@ class LayoutModule extends base_1.Base {
108
109
  // We need to go through environment to make sure it is only imported/bundled in OpenFin.
109
110
  const ManagerConstructor = await this.wire.environment.getManagerConstructor();
110
111
  const viewOverlay = new view_overlay_1.ViewOverlay(this.wire);
111
- const splitterController = new SplitterController_1.SplitterController(viewOverlay);
112
- __classPrivateFieldSet(this, _layoutManager, new ManagerConstructor(splitterController));
112
+ const splitterController = new splitter_controller_1.SplitterController(viewOverlay);
113
+ const tabDragController = new tab_drag_controller_1.TabDragController(viewOverlay);
114
+ __classPrivateFieldSet(this, _layoutManager, new ManagerConstructor(splitterController, tabDragController));
113
115
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
114
116
  // @ts-ignore - layout warning here for backwards compatibility, can remove layout check in .52
115
117
  let { layout, containerId } = options;
@@ -1,11 +1,11 @@
1
- import { ViewOverlay } from './view-overlay';
1
+ import { ViewOverlay } from '../utils/view-overlay';
2
2
  export declare type SplitterItem = GoldenLayout.ContentItem & {
3
3
  viewEventsAdded: boolean;
4
4
  isVertical: boolean;
5
5
  };
6
6
  /**
7
- * @ignore
8
7
  * Utility class for managing Golden Layout splitter drag interactions.
8
+ * @ignore
9
9
  */
10
10
  export declare class SplitterController {
11
11
  private readonly viewOverlay;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SplitterController = void 0;
4
- const bounds_observer_1 = require("./bounds-observer");
4
+ const bounds_observer_1 = require("../utils/bounds-observer");
5
5
  const applyBoundsOffset = (bounds, offsets = {}) => {
6
6
  const sum = (bound, offset) => {
7
7
  return bound + (offset || 0);
@@ -14,8 +14,8 @@ const applyBoundsOffset = (bounds, offsets = {}) => {
14
14
  };
15
15
  };
16
16
  /**
17
- * @ignore
18
17
  * Utility class for managing Golden Layout splitter drag interactions.
18
+ * @ignore
19
19
  */
20
20
  class SplitterController {
21
21
  // eslint-disable-next-line
@@ -65,8 +65,9 @@ class SplitterController {
65
65
  splitterDiv.style.visibility = 'hidden';
66
66
  const onBoundsChange = (bounds) => {
67
67
  const offsetBounds = applyBoundsOffset(bounds, { height: splitterItem.isVertical ? 0 : 2 });
68
- this.viewOverlay.renderOverlay({ bounds: offsetBounds, backgroundColor });
68
+ this.viewOverlay.renderOverlay(offsetBounds);
69
69
  };
70
+ await this.viewOverlay.setStyle({ backgroundColor });
70
71
  const teardownBoundsObserver = bounds_observer_1.observeBounds(splitterDiv, onBoundsChange);
71
72
  this.teardown = () => {
72
73
  teardownBoundsObserver();
@@ -0,0 +1,48 @@
1
+ import { ViewOverlay } from '../utils/view-overlay';
2
+ import { View } from '../../../view';
3
+ /**
4
+ * Set of apis used to facilitate tab drag interactions without needing to hide views.
5
+ * @ignore
6
+ */
7
+ export declare class TabDragController {
8
+ private readonly viewOverlay;
9
+ constructor(viewOverlay: ViewOverlay);
10
+ private dropZonePreview?;
11
+ /**
12
+ * When a tab is dragged from a stack greater than one, it's view will need to be hidden and the
13
+ * view next in the stack shown.
14
+ *
15
+ * Conversely, when a view is the last view in a window, it will need to remain visible.
16
+ *
17
+ * This function implements this logic accordingly
18
+ * @param movingView The view which is currently being dragged
19
+ * @param currentView The current active view of the tabstack
20
+ * @param isOnlyViewInWindow Indicates whether the moving view is the only in the platform window.
21
+ */
22
+ handleTabStackActiveView: (movingView: View, currentView: View, isOnlyViewInWindow: boolean) => Promise<void>;
23
+ /**
24
+ * Extracts the border and backgroundColor css values from the drop zone preview,
25
+ * and sets the viewOverlay to match them.
26
+ */
27
+ inheritStyles: () => Promise<void>;
28
+ /**
29
+ * Called when a tab drag interaction is started from the current window (not when it enters the window).
30
+ *
31
+ * Sets all views in the platform to ignore mouse events so that they can pass through to the golden-layout
32
+ * document whilst remaining visible.
33
+ */
34
+ startDrag: () => Promise<void>;
35
+ /**
36
+ * Called when a tab drag interaction which was started from the current window ends.
37
+ *
38
+ * Disables the click through setting on every view in the platform.
39
+ */
40
+ endDrag: () => Promise<void>;
41
+ /**
42
+ * Observes a golden-layout drop zone preview in order to render a BrowserView
43
+ * overlay whenever a tab is dragged over a droppable region.
44
+ * @param dropZonePreview The drop zone preview element created by Golden Layout in order to highlight
45
+ * droppable regions of the UI.
46
+ */
47
+ observeOverlay: (dropZonePreview: HTMLElement) => Promise<void>;
48
+ }
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TabDragController = void 0;
4
+ const bounds_observer_1 = require("../utils/bounds-observer");
5
+ /**
6
+ * Set of apis used to facilitate tab drag interactions without needing to hide views.
7
+ * @ignore
8
+ */
9
+ class TabDragController {
10
+ // eslint-disable-next-line
11
+ constructor(viewOverlay) {
12
+ this.viewOverlay = viewOverlay;
13
+ /**
14
+ * When a tab is dragged from a stack greater than one, it's view will need to be hidden and the
15
+ * view next in the stack shown.
16
+ *
17
+ * Conversely, when a view is the last view in a window, it will need to remain visible.
18
+ *
19
+ * This function implements this logic accordingly
20
+ * @param movingView The view which is currently being dragged
21
+ * @param currentView The current active view of the tabstack
22
+ * @param isOnlyViewInWindow Indicates whether the moving view is the only in the platform window.
23
+ */
24
+ this.handleTabStackActiveView = async (movingView, currentView, isOnlyViewInWindow) => {
25
+ if (this.dropZonePreview) {
26
+ const hideMovingViewIfPossible = async () => {
27
+ if (!isOnlyViewInWindow) {
28
+ await movingView.hide();
29
+ }
30
+ };
31
+ const showCurrentView = async () => {
32
+ if (currentView.identity.name !== movingView.identity.name) {
33
+ await currentView.show();
34
+ }
35
+ };
36
+ await Promise.all([hideMovingViewIfPossible(), showCurrentView()]);
37
+ }
38
+ };
39
+ /**
40
+ * Extracts the border and backgroundColor css values from the drop zone preview,
41
+ * and sets the viewOverlay to match them.
42
+ */
43
+ this.inheritStyles = async () => {
44
+ if (this.dropZonePreview) {
45
+ const { border, backgroundColor } = getComputedStyle(this.dropZonePreview);
46
+ await this.viewOverlay.setStyle({ border, backgroundColor });
47
+ }
48
+ };
49
+ /**
50
+ * Called when a tab drag interaction is started from the current window (not when it enters the window).
51
+ *
52
+ * Sets all views in the platform to ignore mouse events so that they can pass through to the golden-layout
53
+ * document whilst remaining visible.
54
+ */
55
+ this.startDrag = async () => {
56
+ await this.viewOverlay.setIgnoreViewMouseEvents(true);
57
+ };
58
+ /**
59
+ * Called when a tab drag interaction which was started from the current window ends.
60
+ *
61
+ * Disables the click through setting on every view in the platform.
62
+ */
63
+ this.endDrag = async () => {
64
+ await this.viewOverlay.setIgnoreViewMouseEvents(false);
65
+ };
66
+ /**
67
+ * Observes a golden-layout drop zone preview in order to render a BrowserView
68
+ * overlay whenever a tab is dragged over a droppable region.
69
+ * @param dropZonePreview The drop zone preview element created by Golden Layout in order to highlight
70
+ * droppable regions of the UI.
71
+ */
72
+ this.observeOverlay = async (dropZonePreview) => {
73
+ if (!this.dropZonePreview) {
74
+ this.dropZonePreview = dropZonePreview;
75
+ let lastBounds;
76
+ dropZonePreview.style.visibility = 'hidden';
77
+ dropZonePreview.addEventListener('drop-area-highlighted', async (e) => {
78
+ try {
79
+ const { bounds } = e.detail;
80
+ if (!lastBounds || !bounds_observer_1.isDomRectEqual(lastBounds, bounds)) {
81
+ lastBounds = bounds;
82
+ await this.viewOverlay.renderOverlay(bounds);
83
+ }
84
+ }
85
+ catch (error) {
86
+ console.warn('Unexpected error encountered rendering tab drag preview.', error);
87
+ }
88
+ });
89
+ dropZonePreview.addEventListener('drop-area-hidden', async () => {
90
+ try {
91
+ lastBounds = undefined;
92
+ await this.viewOverlay.detachOverlay();
93
+ }
94
+ catch (error) {
95
+ console.warn('Unexpected error encountered hiding tab drag preview.', error);
96
+ }
97
+ });
98
+ }
99
+ };
100
+ }
101
+ }
102
+ exports.TabDragController = TabDragController;
@@ -1,5 +1,5 @@
1
+ export declare const isDomRectEqual: (a: DOMRect, b: DOMRect) => boolean;
1
2
  /**
2
- * @ignore
3
3
  * Observes the bounding client box rectangle of the given element for changes.
4
4
  *
5
5
  * This solution only works for 2 scenarios, though could be updated to support more
@@ -14,5 +14,6 @@
14
14
  * @param element The element to observe the bounding box for (i.e. position, width, height)
15
15
  * @param onChange Called every time the bounding box changes.
16
16
  * @returns Function which disposes the observers when invoked.
17
+ * @ignore
17
18
  */
18
19
  export declare const observeBounds: (element: Element, onChange: (bounds: DOMRect) => void) => () => void;
@@ -1,8 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.observeBounds = void 0;
3
+ exports.observeBounds = exports.isDomRectEqual = void 0;
4
+ exports.isDomRectEqual = (a, b) => {
5
+ if (a.top !== b.top ||
6
+ a.left !== b.left ||
7
+ a.width !== b.width ||
8
+ a.height !== b.height ||
9
+ a.x !== b.x ||
10
+ a.y !== b.y) {
11
+ return false;
12
+ }
13
+ return true;
14
+ };
4
15
  /**
5
- * @ignore
6
16
  * Observes the bounding client box rectangle of the given element for changes.
7
17
  *
8
18
  * This solution only works for 2 scenarios, though could be updated to support more
@@ -17,23 +27,13 @@ exports.observeBounds = void 0;
17
27
  * @param element The element to observe the bounding box for (i.e. position, width, height)
18
28
  * @param onChange Called every time the bounding box changes.
19
29
  * @returns Function which disposes the observers when invoked.
30
+ * @ignore
20
31
  */
21
32
  exports.observeBounds = (element, onChange) => {
22
33
  let lastBounds;
23
- const isDomRectEqual = (a, b) => {
24
- if (a.top !== b.top
25
- || a.left !== b.left
26
- || a.width !== b.width
27
- || a.height !== b.height
28
- || a.x !== b.x
29
- || a.y !== b.y) {
30
- return false;
31
- }
32
- return true;
33
- };
34
34
  const checkBounds = () => {
35
35
  const currentBounds = element.getBoundingClientRect();
36
- if (!lastBounds || !isDomRectEqual(lastBounds, currentBounds)) {
36
+ if (!lastBounds || !exports.isDomRectEqual(lastBounds, currentBounds)) {
37
37
  lastBounds = currentBounds;
38
38
  onChange(element.getBoundingClientRect());
39
39
  }
@@ -0,0 +1,34 @@
1
+ import Transport from '../../../../transport/transport';
2
+ /**
3
+ * Api client allowing an empty electron BrowserView to be rendered
4
+ * in the current window with the specified bounds.
5
+ *
6
+ * Please note, only one view based overlay can be rendered at a time per runtime.
7
+ * @ignore
8
+ */
9
+ export declare class ViewOverlay {
10
+ private wire;
11
+ constructor(wire: Transport);
12
+ /**
13
+ * Sets the style of the root <html> element of the view overlay webcontent.
14
+ * @param style A partial collection of Css style declarations to set.
15
+ */
16
+ setStyle: (style: Partial<CSSStyleDeclaration>) => Promise<void>;
17
+ /**
18
+ * Renders the overlay at the specified position relative to the calling window.
19
+ * @param options Bounds and background color to display in the overlay.
20
+ */
21
+ renderOverlay: (bounds: OpenFin.Bounds) => Promise<void>;
22
+ /**
23
+ * Removes the overlay from the current window.
24
+ */
25
+ detachOverlay: () => Promise<void>;
26
+ /**
27
+ * Allows setting all OpenFin views to ignore or consume mouse events.
28
+ *
29
+ * This can help with the rendering of view overlays that depend on OpenFin views not consuming mouse events.
30
+ *
31
+ * @param enabled If true, all mouse events are ignored by openfin views. If false, all OpenFin views will consume mouse events.
32
+ */
33
+ setIgnoreViewMouseEvents(enabled: boolean): Promise<void>;
34
+ }
@@ -2,23 +2,29 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ViewOverlay = void 0;
4
4
  /**
5
- * @ignore
6
5
  * Api client allowing an empty electron BrowserView to be rendered
7
6
  * in the current window with the specified bounds.
8
7
  *
9
8
  * Please note, only one view based overlay can be rendered at a time per runtime.
9
+ * @ignore
10
10
  */
11
11
  class ViewOverlay {
12
12
  // eslint-disable-next-line
13
13
  constructor(wire) {
14
14
  this.wire = wire;
15
+ /**
16
+ * Sets the style of the root <html> element of the view overlay webcontent.
17
+ * @param style A partial collection of Css style declarations to set.
18
+ */
19
+ this.setStyle = async (style) => {
20
+ await this.wire.sendAction('set-overlay-style', { style });
21
+ };
15
22
  /**
16
23
  * Renders the overlay at the specified position relative to the calling window.
17
24
  * @param options Bounds and background color to display in the overlay.
18
25
  */
19
- this.renderOverlay = async (options) => {
20
- const { bounds, backgroundColor } = options;
21
- await this.wire.sendAction('render-overlay', { bounds, backgroundColor });
26
+ this.renderOverlay = async (bounds) => {
27
+ await this.wire.sendAction('render-overlay', { bounds });
22
28
  };
23
29
  /**
24
30
  * Removes the overlay from the current window.
@@ -27,5 +33,17 @@ class ViewOverlay {
27
33
  await this.wire.sendAction('detach-overlay');
28
34
  };
29
35
  }
36
+ /**
37
+ * Allows setting all OpenFin views to ignore or consume mouse events.
38
+ *
39
+ * This can help with the rendering of view overlays that depend on OpenFin views not consuming mouse events.
40
+ *
41
+ * @param enabled If true, all mouse events are ignored by openfin views. If false, all OpenFin views will consume mouse events.
42
+ */
43
+ async setIgnoreViewMouseEvents(enabled) {
44
+ await this.wire.sendAction('set-ignore-all-view-mouse-events', {
45
+ enabled
46
+ });
47
+ }
30
48
  }
31
49
  exports.ViewOverlay = ViewOverlay;
@@ -358,7 +358,8 @@ import WindowEvents = OpenFin.WindowEvents;
358
358
  * @typedef {Object} ViewVisibility _Platform Windows Only_. Controls behavior for showing views when they are being resized by the user.
359
359
  * @property {ShowViewsOnWindowResize} [showViewsOnWindowResize] Enables views to be shown when a Platform Window is being resized by the user.
360
360
  * @property {ShowViewsOnSplitterDrag} [showViewsOnSplitterDrag] Allows views to be shown when they are resized by the user dragging the splitter between layout stacks.
361
- */
361
+ * @property {ShowViewsOnTabDrag} [showViewsOnTabDrag] _Supported on Windows Operating Systems only_. Allows views to be shown when the user is dragging a tab around a layout.
362
+ */
362
363
  /**
363
364
  * @typedef {Object} ShowViewsOnWindowResize _Platform Windows Only_. Enables views to be shown when a Platform Window is being resized by the user.
364
365
  * @property {boolean} [enabled=false] Enables or disables showing Views when a Platform Window is being resized.
@@ -368,6 +369,10 @@ import WindowEvents = OpenFin.WindowEvents;
368
369
  * @typedef {Object} ShowViewsOnSplitterDrag _Platform Windows Only_. Allows views to be shown when they are resized by the user dragging the splitter between layout stacks.
369
370
  * @property {boolean} [enabled=false] Enables or disables showing views when the layout splitter is being dragged.
370
371
  */
372
+ /**
373
+ * @typedef {Object} ShowViewsOnTabDrag _Platform Windows Only_. Allows views to be shown when the user is manipulating the layout by repositioning a tab.
374
+ * @property {boolean} [enabled=false] Enables or disables showing views when a tab is being dragged.
375
+ */
371
376
  /**
372
377
  * @typedef {object} CapturePageOptions
373
378
  * @property { Area } [area] The area of the window to be captured.
@@ -365,7 +365,8 @@ const view_1 = require("../view");
365
365
  * @typedef {Object} ViewVisibility _Platform Windows Only_. Controls behavior for showing views when they are being resized by the user.
366
366
  * @property {ShowViewsOnWindowResize} [showViewsOnWindowResize] Enables views to be shown when a Platform Window is being resized by the user.
367
367
  * @property {ShowViewsOnSplitterDrag} [showViewsOnSplitterDrag] Allows views to be shown when they are resized by the user dragging the splitter between layout stacks.
368
- */
368
+ * @property {ShowViewsOnTabDrag} [showViewsOnTabDrag] _Supported on Windows Operating Systems only_. Allows views to be shown when the user is dragging a tab around a layout.
369
+ */
369
370
  /**
370
371
  * @typedef {Object} ShowViewsOnWindowResize _Platform Windows Only_. Enables views to be shown when a Platform Window is being resized by the user.
371
372
  * @property {boolean} [enabled=false] Enables or disables showing Views when a Platform Window is being resized.
@@ -375,6 +376,10 @@ const view_1 = require("../view");
375
376
  * @typedef {Object} ShowViewsOnSplitterDrag _Platform Windows Only_. Allows views to be shown when they are resized by the user dragging the splitter between layout stacks.
376
377
  * @property {boolean} [enabled=false] Enables or disables showing views when the layout splitter is being dragged.
377
378
  */
379
+ /**
380
+ * @typedef {Object} ShowViewsOnTabDrag _Platform Windows Only_. Allows views to be shown when the user is manipulating the layout by repositioning a tab.
381
+ * @property {boolean} [enabled=false] Enables or disables showing views when a tab is being dragged.
382
+ */
378
383
  /**
379
384
  * @typedef {object} CapturePageOptions
380
385
  * @property { Area } [area] The area of the window to be captured.
@@ -122,11 +122,22 @@ export interface ProtocolMap extends ProtocolMapBase {
122
122
  'render-overlay': {
123
123
  request: {
124
124
  bounds: OpenFin.Bounds;
125
- backgroundColor: string;
125
+ };
126
+ response: void;
127
+ };
128
+ 'set-overlay-style': {
129
+ request: {
130
+ style: Partial<CSSStyleDeclaration>;
126
131
  };
127
132
  response: void;
128
133
  };
129
134
  'detach-overlay': VoidCall;
135
+ 'set-ignore-all-view-mouse-events': {
136
+ request: {
137
+ enabled: boolean;
138
+ };
139
+ response: void;
140
+ };
130
141
  'system-get-printers': {
131
142
  request: void;
132
143
  response: OpenFin.PrinterInfo[];
@@ -1,24 +0,0 @@
1
- import Transport from "../../../../transport/transport";
2
- /**
3
- * @ignore
4
- * Api client allowing an empty electron BrowserView to be rendered
5
- * in the current window with the specified bounds.
6
- *
7
- * Please note, only one view based overlay can be rendered at a time per runtime.
8
- */
9
- export declare class ViewOverlay {
10
- private wire;
11
- constructor(wire: Transport);
12
- /**
13
- * Renders the overlay at the specified position relative to the calling window.
14
- * @param options Bounds and background color to display in the overlay.
15
- */
16
- renderOverlay: (options: {
17
- bounds: OpenFin.Bounds;
18
- backgroundColor: string;
19
- }) => Promise<void>;
20
- /**
21
- * Removes the overlay from the current window.
22
- */
23
- detachOverlay: () => Promise<void>;
24
- }