@openfin/core 31.75.1 → 32.75.2

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 (37) hide show
  1. package/package.json +1 -1
  2. package/src/OpenFin.d.ts +4 -2
  3. package/src/api/application/Instance.d.ts +13 -1
  4. package/src/api/application/Instance.js +21 -7
  5. package/src/api/events/application.d.ts +4 -1
  6. package/src/api/events/webcontents.d.ts +54 -5
  7. package/src/api/interappbus/channel/client.d.ts +2 -2
  8. package/src/api/interappbus/channel/index.d.ts +4 -4
  9. package/src/api/interappbus/channel/index.js +94 -57
  10. package/src/api/interappbus/channel/provider.d.ts +2 -3
  11. package/src/api/me.d.ts +1 -1
  12. package/src/api/me.js +2 -1
  13. package/src/api/platform/Factory.d.ts +1 -2
  14. package/src/api/platform/Factory.js +2 -11
  15. package/src/api/platform/layout/Factory.d.ts +1 -1
  16. package/src/api/platform/layout/Factory.js +4 -38
  17. package/src/api/view/Instance.js +1 -2
  18. package/src/environment/browser.d.ts +4 -2
  19. package/src/environment/browser.js +5 -2
  20. package/src/environment/environment.d.ts +4 -2
  21. package/src/environment/mockEnvironment.d.ts +2 -2
  22. package/src/environment/mockEnvironment.js +2 -2
  23. package/src/environment/node-env.d.ts +3 -2
  24. package/src/environment/node-env.js +5 -2
  25. package/src/environment/openfin-env.d.ts +5 -3
  26. package/src/environment/openfin-env.js +12 -10
  27. package/src/shapes/protocol.d.ts +9 -9
  28. package/src/transport/transport.d.ts +3 -2
  29. package/src/transport/transport.js +2 -2
  30. package/src/api/platform/layout/controllers/splitter-controller.d.ts +0 -30
  31. package/src/api/platform/layout/controllers/splitter-controller.js +0 -83
  32. package/src/api/platform/layout/controllers/tab-drag-controller.d.ts +0 -59
  33. package/src/api/platform/layout/controllers/tab-drag-controller.js +0 -124
  34. package/src/api/platform/layout/utils/bounds-observer.d.ts +0 -19
  35. package/src/api/platform/layout/utils/bounds-observer.js +0 -52
  36. package/src/api/platform/layout/utils/view-overlay.d.ts +0 -35
  37. package/src/api/platform/layout/utils/view-overlay.js +0 -49
@@ -8,10 +8,13 @@ class BrowserEnvironment {
8
8
  return window.crypto.getRandomValues(intArray)[0].toString(32);
9
9
  };
10
10
  }
11
- getManagerConstructor() {
11
+ observeBounds(element, onChange) {
12
12
  throw new Error('Method not implemented.');
13
13
  }
14
- getProviderInitializer() {
14
+ initLayout(_fin, wire, options) {
15
+ throw new Error('Method not implemented.');
16
+ }
17
+ initPlatform(...args) {
15
18
  throw new Error('Method not implemented.');
16
19
  }
17
20
  writeToken(path, token) {
@@ -1,9 +1,11 @@
1
1
  import type * as OpenFin from '../OpenFin';
2
+ import { Transport } from '../transport/transport';
2
3
  import { NewConnectConfig } from '../transport/wire';
3
4
  type EntityType = OpenFin.EntityType;
4
5
  export interface Environment {
5
- getManagerConstructor(): Promise<any>;
6
- getProviderInitializer(): Promise<any>;
6
+ initLayout(fin: OpenFin.Fin<OpenFin.EntityType>, wire: Transport, ...args: Parameters<OpenFin.Fin['Platform']['Layout']['init']>): ReturnType<OpenFin.Fin['Platform']['Layout']['init']>;
7
+ initPlatform(fin: OpenFin.Fin<OpenFin.EntityType>, ...args: Parameters<OpenFin.Fin['Platform']['init']>): ReturnType<OpenFin.Fin['Platform']['init']>;
8
+ observeBounds(element: Element, onChange: (bounds: DOMRect) => Promise<void> | void): (() => void);
7
9
  writeToken(path: string, token: string): Promise<string>;
8
10
  retrievePort(config: NewConnectConfig): Promise<number>;
9
11
  getNextMessageId(): any;
@@ -8,8 +8,8 @@ export declare class MockEnvironment implements Environment {
8
8
  connect: OpenFin.ChannelConnectOptions;
9
9
  };
10
10
  getRtcPeer(): RTCPeerConnection;
11
- getManagerConstructor(): Promise<any>;
12
- getProviderInitializer(): Promise<any>;
11
+ initLayout(): Promise<never>;
12
+ initPlatform(): Promise<never>;
13
13
  observeBounds(): never;
14
14
  writeToken(path: string, token: string): Promise<string>;
15
15
  retrievePort(config: NewConnectConfig): Promise<number>;
@@ -12,10 +12,10 @@ class MockEnvironment {
12
12
  getRtcPeer() {
13
13
  throw new Error(me_1.environmentUnsupportedMessage);
14
14
  }
15
- async getManagerConstructor() {
15
+ initLayout() {
16
16
  throw new Error(me_1.environmentUnsupportedMessage);
17
17
  }
18
- async getProviderInitializer() {
18
+ initPlatform() {
19
19
  throw new Error(me_1.environmentUnsupportedMessage);
20
20
  }
21
21
  observeBounds() {
@@ -3,6 +3,7 @@ import { Environment } from './environment';
3
3
  import { NewConnectConfig } from '../transport/wire';
4
4
  type EntityType = OpenFin.EntityType;
5
5
  export default class NodeEnvironment implements Environment {
6
+ observeBounds(element: Element, onChange: (bounds: DOMRect) => void | Promise<void>): () => void;
6
7
  getDefaultChannelOptions(): {
7
8
  create: OpenFin.ChannelCreateOptions;
8
9
  connect: OpenFin.ChannelConnectOptions;
@@ -10,8 +11,8 @@ export default class NodeEnvironment implements Environment {
10
11
  getRtcPeer(): RTCPeerConnection;
11
12
  private messageCounter;
12
13
  childViews: boolean;
13
- getManagerConstructor(): Promise<any>;
14
- getProviderInitializer(): Promise<any>;
14
+ initLayout(): Promise<never>;
15
+ initPlatform(): Promise<never>;
15
16
  whenReady(): Promise<void>;
16
17
  writeToken: (path: string, token: string) => Promise<string>;
17
18
  retrievePort: (config: NewConnectConfig) => Promise<number>;
@@ -43,16 +43,19 @@ class NodeEnvironment {
43
43
  throw new transport_errors_1.NotImplementedError('Not Implemented');
44
44
  };
45
45
  }
46
+ observeBounds(element, onChange) {
47
+ throw new Error('Method not implemented.');
48
+ }
46
49
  getDefaultChannelOptions() {
47
50
  return { create: {}, connect: {} };
48
51
  }
49
52
  getRtcPeer() {
50
53
  throw new Error('Method not implemented.');
51
54
  }
52
- async getManagerConstructor() {
55
+ async initLayout() {
53
56
  throw new Error('Method not implemented.');
54
57
  }
55
- async getProviderInitializer() {
58
+ async initPlatform() {
56
59
  throw new Error('Method not implemented.');
57
60
  }
58
61
  whenReady() {
@@ -1,7 +1,8 @@
1
1
  import type * as OpenFin from '../OpenFin';
2
- import { ChildContentOptions, Environment } from './environment';
2
+ import { Transport } from '../transport/transport';
3
3
  import { NewConnectConfig } from '../transport/wire';
4
4
  import { BrowserEnvironment } from './browser';
5
+ import { ChildContentOptions, Environment } from './environment';
5
6
  type EntityType = OpenFin.EntityType;
6
7
  export default class OpenFinEnvironment extends BrowserEnvironment implements Environment {
7
8
  #private;
@@ -12,8 +13,9 @@ export default class OpenFinEnvironment extends BrowserEnvironment implements En
12
13
  create: OpenFin.ChannelCreateOptions;
13
14
  connect: OpenFin.ChannelConnectOptions;
14
15
  };
15
- getManagerConstructor(): Promise<any>;
16
- getProviderInitializer(): Promise<any>;
16
+ initLayout(_fin: OpenFin.Fin<OpenFin.EntityType>, wire: Transport, options: OpenFin.InitLayoutOptions): Promise<OpenFin.Layout>;
17
+ initPlatform(_fin: OpenFin.Fin<OpenFin.EntityType>, options?: OpenFin.InitPlatformOptions): ReturnType<OpenFin.Fin['Platform']['init']>;
18
+ observeBounds(element: Element, onChange: (bounds: DOMRect) => void | Promise<void>): () => void;
17
19
  writeToken: (path: string, token: string) => Promise<string>;
18
20
  retrievePort: (config: NewConnectConfig) => Promise<number>;
19
21
  getNextMessageId: () => any;
@@ -12,10 +12,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
12
12
  };
13
13
  var _OpenFinEnvironment_ready;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- /* global window, location */
16
- /* eslint-disable class-methods-use-this */
17
15
  const transport_errors_1 = require("../transport/transport-errors");
18
16
  const browser_1 = require("./browser");
17
+ const bounds_observer_1 = require("../api/platform/renderer/utils/bounds-observer");
19
18
  // Inherits the following BrowserEnvironment methods: getRtcPeer, getRandomId, getUrl, getWsConstructor.
20
19
  class OpenFinEnvironment extends browser_1.BrowserEnvironment {
21
20
  constructor() {
@@ -73,17 +72,20 @@ class OpenFinEnvironment extends browser_1.BrowserEnvironment {
73
72
  ...((_b = (_a = fin.__internal_.initialOptions.experimental) === null || _a === void 0 ? void 0 : _a.defaultChannelOptions) !== null && _b !== void 0 ? _b : {})
74
73
  };
75
74
  }
76
- async getManagerConstructor() {
77
- const ManagerConstructor = (await Promise.resolve().then(() => require(
75
+ async initLayout(_fin, wire, options) {
76
+ const { initLayout } = await Promise.resolve().then(() => require(
78
77
  /* webpackChunkName: 'layout' */
79
- '../api/platform/renderer/openfin-layout'))).default;
80
- return ManagerConstructor;
78
+ '../api/platform/renderer/init-layout'));
79
+ return initLayout(_fin, wire, options);
81
80
  }
82
- async getProviderInitializer() {
83
- const providerInitializer = (await Promise.resolve().then(() => require(
81
+ async initPlatform(_fin, options) {
82
+ const { initPlatformProvider } = await Promise.resolve().then(() => require(
84
83
  /* webpackChunkName: 'provider' */
85
- '../api/platform/renderer/platform-provider'))).default;
86
- return providerInitializer;
84
+ '../api/platform/renderer/init-platform-provider'));
85
+ return initPlatformProvider(this, _fin, options);
86
+ }
87
+ observeBounds(element, onChange) {
88
+ return (0, bounds_observer_1.observeBounds)(element, onChange);
87
89
  }
88
90
  // eslint-disable-next-line class-methods-use-this
89
91
  resolveUrl(url) {
@@ -82,16 +82,18 @@ export interface ProtocolMap extends ProtocolMapBase {
82
82
  };
83
83
  response: OpenFin.NativeWindowIntegrationProviderAuthorization;
84
84
  };
85
- 'get-permissions': {
86
- request: void;
87
- response: any;
88
- };
85
+ 'get-permissions': GetterCall<any>;
86
+ 'get-all-channels': GetterCall<OpenFin.ProviderIdentity[]>;
89
87
  'set-file-download-location': {
90
- request: OpenFin.ApplicationIdentity & {
88
+ request: OpenFin.Identity & {
91
89
  downloadLocation: string;
92
90
  };
93
91
  response: void;
94
92
  };
93
+ 'get-file-download-location': {
94
+ request: OpenFin.ApplicationIdentity;
95
+ response: string;
96
+ };
95
97
  'close-popup-menu': IdentityCall;
96
98
  'fdc3-add-context-listener': VoidCall;
97
99
  'fdc3-broadcast': VoidCall;
@@ -160,10 +162,7 @@ export interface ProtocolMap extends ProtocolMapBase {
160
162
  };
161
163
  response: void;
162
164
  };
163
- 'system-get-printers': {
164
- request: void;
165
- response: OpenFin.PrinterInfo[];
166
- };
165
+ 'system-get-printers': GetterCall<OpenFin.PrinterInfo[]>;
167
166
  'system-register-shutdown-handler': VoidCall;
168
167
  }
169
168
  type ApiCall<Request, Response> = {
@@ -171,6 +170,7 @@ type ApiCall<Request, Response> = {
171
170
  response: Response;
172
171
  };
173
172
  type VoidCall = ApiCall<void, void>;
173
+ type GetterCall<T> = ApiCall<void, T>;
174
174
  type IdentityCall<AdditionalPayload = {}, Response = void> = ApiCall<AdditionalPayload & OpenFin.Identity, Response>;
175
175
  interface ProtocolMapBase {
176
176
  [action: string]: {
@@ -15,8 +15,9 @@ type SendActionResponse<T extends keyof ProtocolMap> = Message<{
15
15
  data: ProtocolMap[T]['response'];
16
16
  } & ProtocolMap[T]['specialResponse']>;
17
17
  export type MessageHandler = (data: any) => boolean;
18
- export type CancellablePromise<T> = Promise<T> & {
18
+ export type SentMessage<Value> = Promise<Value> & {
19
19
  cancel: (reason?: any) => void;
20
+ messageId: ReturnType<Environment['getNextMessageId']>;
20
21
  };
21
22
  type NackHandler = (payloadOrMessage: RuntimeErrorPayload | string) => void;
22
23
  export declare class Transport<MeType extends EntityType = EntityType> extends EventEmitter {
@@ -42,7 +43,7 @@ export declare class Transport<MeType extends EntityType = EntityType> extends E
42
43
  private connectRemote;
43
44
  connectByPort(config: ExistingConnectConfig): Promise<void>;
44
45
  private authorize;
45
- sendAction<T extends keyof ProtocolMap = string>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): CancellablePromise<SendActionResponse<T>>;
46
+ sendAction<T extends keyof ProtocolMap = string>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): SentMessage<SendActionResponse<T>>;
46
47
  protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: NodeJS.CallSite[]): void;
47
48
  ferryAction(origData: any): Promise<Message<any>>;
48
49
  registerMessageHandler(handler: MessageHandler): void;
@@ -115,9 +115,9 @@ class Transport extends events_1.EventEmitter {
115
115
  let cancel = () => { };
116
116
  // We want the callsite from the caller of this function, not from here.
117
117
  const callSites = transport_errors_1.RuntimeError.getCallSite(1);
118
+ const messageId = this.environment.getNextMessageId();
118
119
  const prom = new Promise((resolve, reject) => {
119
120
  cancel = reject;
120
- const messageId = this.environment.getNextMessageId();
121
121
  const msg = {
122
122
  action,
123
123
  payload,
@@ -127,7 +127,7 @@ class Transport extends events_1.EventEmitter {
127
127
  this.addWireListener(messageId, resolve, (payload) => this.nackHandler(payload, reject, callSites), uncorrelated);
128
128
  return wire.send(msg).catch(reject);
129
129
  });
130
- return Object.assign(prom, { cancel });
130
+ return Object.assign(prom, { cancel, messageId });
131
131
  }
132
132
  nackHandler(payloadOrMessage, reject, callSites) {
133
133
  if (typeof payloadOrMessage === 'string') {
@@ -1,30 +0,0 @@
1
- import { ViewOverlay } from '../utils/view-overlay';
2
- export type SplitterItem = GoldenLayout.ContentItem & {
3
- viewEventsAdded: boolean;
4
- isVertical: boolean;
5
- };
6
- /**
7
- * Utility class for managing Golden Layout splitter drag interactions.
8
- * @ignore
9
- */
10
- export declare class SplitterController {
11
- private readonly viewOverlay;
12
- constructor(viewOverlay: ViewOverlay);
13
- private teardown?;
14
- private tryTeardown;
15
- /**
16
- * Disables the pointer events on the splitters, preventing them from being dragged.
17
- */
18
- preventSplitterResize: () => void;
19
- /**
20
- * Ends a splitter drag move, if one is in progress.
21
- */
22
- endMove: () => Promise<void>;
23
- /**
24
- * Initialises a splitter drag move, rendering a view on top of the splitter
25
- * to allow it to render on top of the views within a layout (as they will always
26
- * have a higher z-index to the platform window itself).
27
- * @param splitterItem The Golden Layout splitter item that is currently being dragged.
28
- */
29
- startMove: (splitterItem: SplitterItem) => Promise<void>;
30
- }
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SplitterController = void 0;
4
- const bounds_observer_1 = require("../utils/bounds-observer");
5
- const applyBoundsOffset = (bounds, offsets = {}) => {
6
- const sum = (bound, offset) => {
7
- return bound + (offset || 0);
8
- };
9
- return {
10
- left: sum(bounds.left, offsets.left),
11
- top: sum(bounds.top, offsets.top),
12
- width: sum(bounds.width, offsets.width),
13
- height: sum(bounds.height, offsets.height)
14
- };
15
- };
16
- /**
17
- * Utility class for managing Golden Layout splitter drag interactions.
18
- * @ignore
19
- */
20
- class SplitterController {
21
- // eslint-disable-next-line
22
- constructor(viewOverlay) {
23
- this.viewOverlay = viewOverlay;
24
- this.tryTeardown = () => {
25
- if (this.teardown) {
26
- this.teardown();
27
- this.teardown = undefined;
28
- }
29
- };
30
- /**
31
- * Disables the pointer events on the splitters, preventing them from being dragged.
32
- */
33
- this.preventSplitterResize = () => {
34
- document.querySelectorAll('.lm_splitter').forEach((splitter) => {
35
- splitter.style.pointerEvents = 'none';
36
- });
37
- };
38
- /**
39
- * Ends a splitter drag move, if one is in progress.
40
- */
41
- this.endMove = async () => {
42
- try {
43
- this.viewOverlay.detachOverlay();
44
- this.tryTeardown();
45
- }
46
- catch (error) {
47
- throw new Error(`Failed to end splitter move: ${error.stack}`);
48
- }
49
- };
50
- /**
51
- * Initialises a splitter drag move, rendering a view on top of the splitter
52
- * to allow it to render on top of the views within a layout (as they will always
53
- * have a higher z-index to the platform window itself).
54
- * @param splitterItem The Golden Layout splitter item that is currently being dragged.
55
- */
56
- this.startMove = async (splitterItem) => {
57
- try {
58
- if (this.teardown) {
59
- console.warn('Splitter move started before other move has been torn down.');
60
- this.tryTeardown();
61
- }
62
- const splitterDiv = splitterItem.element.get(0);
63
- const { backgroundColor } = getComputedStyle(splitterDiv);
64
- const initialVisibility = splitterDiv.style.visibility;
65
- splitterDiv.style.visibility = 'hidden';
66
- const onBoundsChange = (bounds) => {
67
- const offsetBounds = applyBoundsOffset(bounds, { height: splitterItem.isVertical ? 0 : 2 });
68
- this.viewOverlay.renderOverlay(offsetBounds);
69
- };
70
- await this.viewOverlay.setStyle({ backgroundColor });
71
- const teardownBoundsObserver = (0, bounds_observer_1.observeBounds)(splitterDiv, onBoundsChange);
72
- this.teardown = () => {
73
- teardownBoundsObserver();
74
- splitterDiv.style.visibility = initialVisibility;
75
- };
76
- }
77
- catch (error) {
78
- throw new Error(`Failed to start splitter move: ${error.stack}`);
79
- }
80
- };
81
- }
82
- }
83
- exports.SplitterController = SplitterController;
@@ -1,59 +0,0 @@
1
- import type * as OpenFin from '../../../../OpenFin';
2
- import { ViewOverlay } from '../utils/view-overlay';
3
- type View = OpenFin.View;
4
- /**
5
- * Set of apis used to facilitate tab drag interactions without needing to hide views.
6
- * @ignore
7
- */
8
- export declare class TabDragController {
9
- private readonly viewOverlay;
10
- constructor(viewOverlay: ViewOverlay);
11
- private dropZonePreview?;
12
- /**
13
- *
14
- * When a tab is dragged out of a stack, it will need to be hidden from the stack.
15
- *
16
- * Additionally, if there is a new view to show in the stack, it will be shown at the position specified by
17
- * containerBounds
18
- *
19
- * As drag interactions can under extreme circumstances complete before this chain of promises has completed,
20
- * we need to pass in a isDragging() function which returns whether the drag is in progress.
21
- * This allows us to cancel any layout affecting operations.
22
- *
23
- * @param draggingView The view which is currently being dragged
24
- * @param isLastViewInWindow Whether the draggin view is the last view in a window or not. If false, the dragging view will not hide.
25
- * @param isDragging A function which returns true if the drag is still in progress. As we chain some async calls here, we want to avoid
26
- * modifying any views if the drag has completed (as the post drag procedure will have taken care of it.)
27
- * @param containerBounds The bounds of the container of the view to be shown in the stack
28
- * @param nextView The view which has become active after dragging the draggingView out.
29
- */
30
- handleTabStackActiveView: (draggingView: View, isLastViewInWindow: boolean, isDragging: () => boolean, containerBounds?: OpenFin.Bounds, nextView?: View) => Promise<void>;
31
- /**
32
- * Extracts the border and backgroundColor css values from the drop zone preview,
33
- * and sets the viewOverlay to match them.
34
- */
35
- inheritStyles: () => Promise<void>;
36
- /**
37
- * Called when a tab drag interaction is started from the current window (not when it enters the window).
38
- *
39
- * Sets all views in the platform to ignore mouse events so that they can pass through to the golden-layout
40
- * document whilst remaining visible.
41
- */
42
- startDrag: () => Promise<void>;
43
- /**
44
- * Called when a tab drag interaction which was started from the current window ends.
45
- *
46
- * Disables the click through setting on every view in the platform.
47
- */
48
- endDrag: () => Promise<void>;
49
- private disposeObserve?;
50
- disposeOverlayObserver: () => void;
51
- /**
52
- * Observes a golden-layout drop zone preview in order to render a BrowserView
53
- * overlay whenever a tab is dragged over a droppable region.
54
- * @param dropZonePreview The drop zone preview element created by Golden Layout in order to highlight
55
- * droppable regions of the UI.
56
- */
57
- observeOverlay: (dropZonePreview: HTMLElement) => Promise<void>;
58
- }
59
- export {};
@@ -1,124 +0,0 @@
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
- *
15
- * When a tab is dragged out of a stack, it will need to be hidden from the stack.
16
- *
17
- * Additionally, if there is a new view to show in the stack, it will be shown at the position specified by
18
- * containerBounds
19
- *
20
- * As drag interactions can under extreme circumstances complete before this chain of promises has completed,
21
- * we need to pass in a isDragging() function which returns whether the drag is in progress.
22
- * This allows us to cancel any layout affecting operations.
23
- *
24
- * @param draggingView The view which is currently being dragged
25
- * @param isLastViewInWindow Whether the draggin view is the last view in a window or not. If false, the dragging view will not hide.
26
- * @param isDragging A function which returns true if the drag is still in progress. As we chain some async calls here, we want to avoid
27
- * modifying any views if the drag has completed (as the post drag procedure will have taken care of it.)
28
- * @param containerBounds The bounds of the container of the view to be shown in the stack
29
- * @param nextView The view which has become active after dragging the draggingView out.
30
- */
31
- this.handleTabStackActiveView = async (draggingView, isLastViewInWindow, isDragging, containerBounds, nextView) => {
32
- if (this.dropZonePreview) {
33
- if (nextView && containerBounds) {
34
- if (isDragging()) {
35
- await (nextView === null || nextView === void 0 ? void 0 : nextView.show());
36
- }
37
- if (isDragging()) {
38
- await (nextView === null || nextView === void 0 ? void 0 : nextView.setBounds(containerBounds));
39
- }
40
- }
41
- if (isDragging() && !isLastViewInWindow) {
42
- await draggingView.hide();
43
- }
44
- }
45
- };
46
- /**
47
- * Extracts the border and backgroundColor css values from the drop zone preview,
48
- * and sets the viewOverlay to match them.
49
- */
50
- this.inheritStyles = async () => {
51
- if (this.dropZonePreview) {
52
- const { border, backgroundColor } = getComputedStyle(this.dropZonePreview);
53
- await this.viewOverlay.setStyle({ border, backgroundColor });
54
- }
55
- };
56
- /**
57
- * Called when a tab drag interaction is started from the current window (not when it enters the window).
58
- *
59
- * Sets all views in the platform to ignore mouse events so that they can pass through to the golden-layout
60
- * document whilst remaining visible.
61
- */
62
- this.startDrag = async () => {
63
- await this.viewOverlay.setIgnoreViewMouseEvents(true);
64
- };
65
- /**
66
- * Called when a tab drag interaction which was started from the current window ends.
67
- *
68
- * Disables the click through setting on every view in the platform.
69
- */
70
- this.endDrag = async () => {
71
- await this.viewOverlay.setIgnoreViewMouseEvents(false);
72
- };
73
- this.disposeOverlayObserver = () => {
74
- if (this.disposeObserve) {
75
- this.disposeObserve();
76
- }
77
- this.dropZonePreview = undefined;
78
- };
79
- /**
80
- * Observes a golden-layout drop zone preview in order to render a BrowserView
81
- * overlay whenever a tab is dragged over a droppable region.
82
- * @param dropZonePreview The drop zone preview element created by Golden Layout in order to highlight
83
- * droppable regions of the UI.
84
- */
85
- this.observeOverlay = async (dropZonePreview) => {
86
- if (!this.dropZonePreview) {
87
- this.dropZonePreview = dropZonePreview;
88
- let lastBounds;
89
- dropZonePreview.style.visibility = 'hidden';
90
- const onDropAreaHighlighted = async (e) => {
91
- try {
92
- const { bounds } = e.detail;
93
- if (!lastBounds || !(0, bounds_observer_1.isDomRectEqual)(lastBounds, bounds)) {
94
- lastBounds = bounds;
95
- await this.viewOverlay.renderOverlay(bounds);
96
- }
97
- }
98
- catch (error) {
99
- console.warn('Unexpected error encountered rendering tab drag preview.', error);
100
- }
101
- };
102
- const onDropAreaHidden = async () => {
103
- try {
104
- lastBounds = undefined;
105
- await this.viewOverlay.detachOverlay();
106
- }
107
- catch (error) {
108
- console.warn('Unexpected error encountered hiding tab drag preview.', error);
109
- }
110
- };
111
- dropZonePreview.addEventListener('drop-area-highlighted', onDropAreaHighlighted);
112
- dropZonePreview.addEventListener('drop-area-hidden', onDropAreaHidden);
113
- this.disposeObserve = () => {
114
- dropZonePreview.removeEventListener('drop-area-highlighted', onDropAreaHighlighted);
115
- dropZonePreview.removeEventListener('drop-area-hidden', onDropAreaHidden);
116
- };
117
- }
118
- else {
119
- console.warn('Tried to observe a drop zone overlay without disposing the previous.');
120
- }
121
- };
122
- }
123
- }
124
- exports.TabDragController = TabDragController;
@@ -1,19 +0,0 @@
1
- export declare const isDomRectEqual: (a: DOMRect, b: DOMRect) => boolean;
2
- /**
3
- * Observes the bounding client box rectangle of the given element for changes.
4
- *
5
- * This solution only works for 2 scenarios, though could be updated to support more
6
- * (e.g. via polling).
7
- *
8
- * MutationObserver will only pick up changes to bounds if they are specified via fixed
9
- * style rules in the element's attribtues.
10
- *
11
- * ResizeObserver will pick up all changes to an element's width and height but will not capture
12
- * any changes to position.
13
- *
14
- * @param element The element to observe the bounding box for (i.e. position, width, height)
15
- * @param onChange Called every time the bounding box changes.
16
- * @returns Function which disposes the observers when invoked.
17
- * @ignore
18
- */
19
- export declare const observeBounds: (element: Element, onChange: (bounds: DOMRect) => Promise<void> | void) => (() => void);
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.observeBounds = exports.isDomRectEqual = void 0;
4
- const 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
- };
15
- exports.isDomRectEqual = isDomRectEqual;
16
- /**
17
- * Observes the bounding client box rectangle of the given element for changes.
18
- *
19
- * This solution only works for 2 scenarios, though could be updated to support more
20
- * (e.g. via polling).
21
- *
22
- * MutationObserver will only pick up changes to bounds if they are specified via fixed
23
- * style rules in the element's attribtues.
24
- *
25
- * ResizeObserver will pick up all changes to an element's width and height but will not capture
26
- * any changes to position.
27
- *
28
- * @param element The element to observe the bounding box for (i.e. position, width, height)
29
- * @param onChange Called every time the bounding box changes.
30
- * @returns Function which disposes the observers when invoked.
31
- * @ignore
32
- */
33
- const observeBounds = (element, onChange) => {
34
- let lastBounds;
35
- const checkBounds = async () => {
36
- const currentBounds = element.getBoundingClientRect();
37
- if (!lastBounds || !(0, exports.isDomRectEqual)(lastBounds, currentBounds)) {
38
- lastBounds = currentBounds;
39
- await onChange(element.getBoundingClientRect());
40
- }
41
- };
42
- const resizeObserver = new ResizeObserver(() => checkBounds());
43
- const mutationObserver = new MutationObserver(() => checkBounds());
44
- resizeObserver.observe(element, { box: 'content-box' });
45
- mutationObserver.observe(element, { attributes: true, attributeFilter: ['style'] });
46
- checkBounds();
47
- return () => {
48
- resizeObserver.disconnect();
49
- mutationObserver.disconnect();
50
- };
51
- };
52
- exports.observeBounds = observeBounds;
@@ -1,35 +0,0 @@
1
- import type * as OpenFin from '../../../../OpenFin';
2
- import { Transport } from '../../../../transport/transport';
3
- /**
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
- * @ignore
9
- */
10
- export declare class ViewOverlay {
11
- private wire;
12
- constructor(wire: Transport);
13
- /**
14
- * Sets the style of the root <html> element of the view overlay webcontent.
15
- * @param style A partial collection of Css style declarations to set.
16
- */
17
- setStyle: (style: Partial<CSSStyleDeclaration>) => Promise<void>;
18
- /**
19
- * Renders the overlay at the specified position relative to the calling window.
20
- * @param options Bounds and background color to display in the overlay.
21
- */
22
- renderOverlay: (bounds: OpenFin.Bounds) => Promise<void>;
23
- /**
24
- * Removes the overlay from the current window.
25
- */
26
- detachOverlay: () => Promise<void>;
27
- /**
28
- * Allows setting all OpenFin views to ignore or consume mouse events.
29
- *
30
- * This can help with the rendering of view overlays that depend on OpenFin views not consuming mouse events.
31
- *
32
- * @param enabled If true, all mouse events are ignored by openfin views. If false, all OpenFin views will consume mouse events.
33
- */
34
- setIgnoreViewMouseEvents(enabled: boolean): Promise<void>;
35
- }