@openfin/core 32.75.9 → 32.75.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "32.75.9",
3
+ "version": "32.75.11",
4
4
  "license": "SEE LICENSE IN LICENSE.MD",
5
5
  "main": "./src/mock.js",
6
6
  "types": "./src/mock.d.ts",
@@ -1,6 +1,6 @@
1
1
  import type * as OpenFin from '../../OpenFin';
2
- import { Base } from '../base';
3
2
  import { Transport } from '../../transport/transport';
3
+ import { Base } from '../base';
4
4
  import { LayoutModule } from './layout/index';
5
5
  type Channel = OpenFin.Fin['InterApplicationBus']['Channel'];
6
6
  /**
@@ -51,7 +51,6 @@ type Channel = OpenFin.Fin['InterApplicationBus']['Channel'];
51
51
  export default class PlatformModule extends Base {
52
52
  private _channel;
53
53
  Layout: LayoutModule;
54
- private _initializer;
55
54
  constructor(wire: Transport, channel: Channel);
56
55
  /**
57
56
  * Initializes a Platform. Must be called from the Provider when using a custom provider.
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable no-undef, no-underscore-dangle */
4
3
  const base_1 = require("../base");
5
- const index_1 = require("./layout/index");
6
4
  const Instance_1 = require("./Instance");
5
+ const index_1 = require("./layout/index");
7
6
  /**
8
7
  * @PORTED
9
8
  * InitPlatformOptions interface
@@ -53,9 +52,6 @@ class PlatformModule extends base_1.Base {
53
52
  constructor(wire, channel) {
54
53
  super(wire);
55
54
  this._channel = channel;
56
- this._initializer = (...args) => this.wire.environment
57
- .getProviderInitializer()
58
- .then((initConstructor) => initConstructor(this.wire.environment)(...args));
59
55
  /**
60
56
  * @namespace
61
57
  * @desc Layouts give app providers the ability to embed multiple views in a single window. The Layout namespace
@@ -74,12 +70,7 @@ class PlatformModule extends base_1.Base {
74
70
  * @static
75
71
  */
76
72
  async init(options) {
77
- const overrideCallback = options === null || options === void 0 ? void 0 : options.overrideCallback;
78
- const interopBroker = await this.fin.Interop.init(this.fin.me.uuid, options === null || options === void 0 ? void 0 : options.interopOverride);
79
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
80
- // @ts-expect-error debugging purposes
81
- window.interopBroker = interopBroker;
82
- return this._initializer(overrideCallback, interopBroker);
73
+ return this.wire.environment.initPlatform(this.fin, options);
83
74
  }
84
75
  /**
85
76
  * Asynchronously returns a Platform object that represents an existing platform.
@@ -1,6 +1,6 @@
1
1
  import type * as OpenFin from '../../../OpenFin';
2
- import { Layout } from './Instance';
3
2
  import { Base } from '../../base';
3
+ import { Layout } from './Instance';
4
4
  type InitLayoutOptions = OpenFin.InitLayoutOptions;
5
5
  /**
6
6
  * @PORTED
@@ -10,19 +10,12 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
11
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
12
  };
13
- var _LayoutModule_layoutManager, _LayoutModule_layoutInitializationAttempted;
13
+ var _LayoutModule_layoutInitializationAttempted;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.LayoutModule = void 0;
16
16
  /* eslint-disable no-undef, import/prefer-default-export */
17
- const tab_drag_controller_1 = require("./controllers/tab-drag-controller");
18
- const Instance_1 = require("./Instance");
19
17
  const base_1 = require("../../base");
20
- const splitter_controller_1 = require("./controllers/splitter-controller");
21
- const view_overlay_1 = require("./utils/view-overlay");
22
- const api_exposer_1 = require("../../api-exposer");
23
- const layout_entities_controller_1 = require("./controllers/layout-entities-controller");
24
- const layout_constants_1 = require("./layout.constants");
25
- const layout_content_cache_1 = require("./controllers/layout-content-cache");
18
+ const Instance_1 = require("./Instance");
26
19
  /**
27
20
  * @PORTED
28
21
  * InitLayoutOptions interface
@@ -90,7 +83,6 @@ const layout_content_cache_1 = require("./controllers/layout-content-cache");
90
83
  class LayoutModule extends base_1.Base {
91
84
  constructor() {
92
85
  super(...arguments);
93
- _LayoutModule_layoutManager.set(this, void 0);
94
86
  _LayoutModule_layoutInitializationAttempted.set(this, false);
95
87
  /**
96
88
  * Initialize the window's Layout. Must be called from a custom window that has a 'layout' option set upon creation of that window.
@@ -114,33 +106,7 @@ class LayoutModule extends base_1.Base {
114
106
  throw new Error('Layout for this window already initialized, please use Layout.replace call to replace the layout.');
115
107
  }
116
108
  __classPrivateFieldSet(this, _LayoutModule_layoutInitializationAttempted, true, "f");
117
- // We need to go through environment to make sure it is only imported/bundled in OpenFin.
118
- const ManagerConstructor = await this.wire.environment.getManagerConstructor();
119
- const viewOverlay = new view_overlay_1.ViewOverlay(this.wire);
120
- const splitterController = new splitter_controller_1.SplitterController(viewOverlay);
121
- const tabDragController = new tab_drag_controller_1.TabDragController(viewOverlay);
122
- const contentItemCache = new layout_content_cache_1.LayoutContentCache();
123
- __classPrivateFieldSet(this, _LayoutModule_layoutManager, new ManagerConstructor(splitterController, tabDragController, contentItemCache), "f");
124
- // @ts-expect-error - layout warning here for backwards compatibility, can remove layout check in .52
125
- let { layout, containerId } = options;
126
- if (layout) {
127
- console.warn(`We recommend using a layout in window options.
128
- This layout has not been sanitized and unexpected behavior can occur.`);
129
- }
130
- layout = layout || (await this.fin.Window.getCurrentSync().getOptions()).layout;
131
- containerId = containerId || 'layout-container';
132
- const container = document.getElementById(containerId);
133
- // Should we error here if there is no container? Getting a typescript complaint on createLayout
134
- // override here
135
- // pull createChannelConnection out of LayoutManager and setup channel connections here using layoutmanager instance methods?
136
- await __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f").initManager();
137
- await __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f").createLayout(layout, container);
138
- const { client, ofWindow } = ManagerConstructor.getClientAndWindow(__classPrivateFieldGet(this, _LayoutModule_layoutManager, "f"));
139
- // expose LayoutEntitiesController instance for API consumption
140
- const channelStrategy = new api_exposer_1.ChannelsExposer(client);
141
- await new api_exposer_1.ApiExposer(channelStrategy).exposeInstance(new layout_entities_controller_1.LayoutEntitiesController(__classPrivateFieldGet(this, _LayoutModule_layoutManager, "f"), contentItemCache), { id: layout_constants_1.LAYOUT_CONTROLLER_ID });
142
- // Adding this to the returned instance undocumented/typed for Browser.
143
- return Object.assign(this.getCurrentSync(), { layoutManager: __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f") });
109
+ return this.wire.environment.initLayout(this.fin, this.wire, options);
144
110
  };
145
111
  }
146
112
  /**
@@ -205,4 +171,4 @@ class LayoutModule extends base_1.Base {
205
171
  }
206
172
  }
207
173
  exports.LayoutModule = LayoutModule;
208
- _LayoutModule_layoutManager = new WeakMap(), _LayoutModule_layoutInitializationAttempted = new WeakMap();
174
+ _LayoutModule_layoutInitializationAttempted = new WeakMap();
@@ -512,53 +512,62 @@ class System extends base_1.EmitterBase {
512
512
  * @tutorial System.downloadAsset
513
513
  */
514
514
  // incompatible with standalone node process.
515
- downloadAsset(appAsset, progressListener) {
516
- return new Promise((resolve, reject) => {
517
- // node.js environment not supported
518
- if (this.wire.environment.constructor.name === 'NodeEnvironment') {
519
- reject(new transport_errors_1.NotSupportedError('downloadAsset only supported in an OpenFin Render process'));
520
- return;
521
- }
522
- const downloadId = this.wire.environment.getNextMessageId().toString();
523
- const dlProgressKey = `asset-download-progress-${downloadId}`;
524
- const dlErrorKey = `asset-download-error-${downloadId}`;
525
- const dlCompleteKey = `asset-download-complete-${downloadId}`;
526
- const dlProgress = (progress) => {
527
- const p = {
528
- downloadedBytes: progress.downloadedBytes,
529
- totalBytes: progress.totalBytes
530
- };
531
- progressListener(p);
532
- };
533
- const cleanListeners = () => {
534
- // TODO: fix internal types
535
- // @ts-expect-error
536
- this.removeListener(dlProgressKey, dlProgress);
537
- };
538
- const dlError = (payload) => {
539
- cleanListeners();
540
- const { reason, err: error } = payload;
541
- reject(new transport_errors_1.RuntimeError({ reason, error }, transport_errors_1.RuntimeError.getCallSite(3)));
542
- };
543
- const dlComplete = () => {
544
- cleanListeners();
545
- resolve();
515
+ async downloadAsset(appAsset, progressListener) {
516
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-empty-function
517
+ const noop = () => { };
518
+ let resolve = noop;
519
+ let reject = noop;
520
+ const downloadCompletePromise = new Promise((y, n) => {
521
+ resolve = y;
522
+ reject = n;
523
+ });
524
+ // node.js environment not supported
525
+ if (this.wire.environment.constructor.name === 'NodeEnvironment') {
526
+ throw new transport_errors_1.NotSupportedError('downloadAsset only supported in an OpenFin Render process');
527
+ }
528
+ const callSite = transport_errors_1.RuntimeError.getCallSite();
529
+ const downloadId = this.wire.environment.getNextMessageId().toString();
530
+ const dlProgressKey = `asset-download-progress-${downloadId}`;
531
+ const dlErrorKey = `asset-download-error-${downloadId}`;
532
+ const dlCompleteKey = `asset-download-complete-${downloadId}`;
533
+ const dlProgress = (progress) => {
534
+ const p = {
535
+ downloadedBytes: progress.downloadedBytes,
536
+ totalBytes: progress.totalBytes
546
537
  };
538
+ progressListener(p);
539
+ };
540
+ const cleanListeners = () => {
547
541
  // TODO: fix internal types
548
542
  // @ts-expect-error
549
- this.on(dlProgressKey, dlProgress);
543
+ this.removeListener(dlProgressKey, dlProgress);
544
+ };
545
+ const dlError = (payload) => {
546
+ cleanListeners();
547
+ const { reason, err: error } = payload;
548
+ reject(new transport_errors_1.RuntimeError({ reason, error }, callSite));
549
+ };
550
+ const dlComplete = () => {
551
+ cleanListeners();
552
+ resolve();
553
+ };
554
+ await Promise.all([
550
555
  // TODO: fix internal types
551
556
  // @ts-expect-error
552
- this.once(dlErrorKey, dlError);
557
+ this.on(dlProgressKey, dlProgress),
553
558
  // TODO: fix internal types
554
559
  // @ts-expect-error
555
- this.once(dlCompleteKey, dlComplete);
556
- const downloadOptions = Object.assign(appAsset, { downloadId });
557
- this.wire.sendAction('download-asset', downloadOptions).catch((err) => {
558
- cleanListeners();
559
- reject(err);
560
- });
560
+ this.once(dlErrorKey, dlError),
561
+ // TODO: fix internal types
562
+ // @ts-expect-error
563
+ this.once(dlCompleteKey, dlComplete)
564
+ ]);
565
+ const downloadOptions = Object.assign(appAsset, { downloadId });
566
+ await this.wire.sendAction('download-asset', downloadOptions).catch((err) => {
567
+ cleanListeners();
568
+ throw err;
561
569
  });
570
+ return downloadCompletePromise;
562
571
  }
563
572
  /**
564
573
  * Downloads a version of the runtime.
@@ -11,7 +11,6 @@ const transport_errors_1 = require("../../transport/transport-errors");
11
11
  const lazy_1 = require("../../util/lazy");
12
12
  const layout_entities_1 = require("../platform/layout/entities/layout-entities");
13
13
  const layout_constants_1 = require("../platform/layout/layout.constants");
14
- const bounds_observer_1 = require("../platform/layout/utils/bounds-observer");
15
14
  const main_1 = require("../webcontents/main");
16
15
  const window_1 = require("../window");
17
16
  /**
@@ -510,7 +509,7 @@ class View extends main_1.WebContents {
510
509
  throw new Error('Element not found.');
511
510
  }
512
511
  const onChange = async (bounds) => this.setBounds(bounds);
513
- return (0, bounds_observer_1.observeBounds)(element, onChange);
512
+ return this.wire.environment.observeBounds(element, onChange);
514
513
  };
515
514
  }
516
515
  /**
@@ -1,10 +1,12 @@
1
1
  import type * as OpenFin from '../OpenFin';
2
+ import { Transport } from '../transport/transport';
2
3
  import { NewConnectConfig } from '../transport/wire';
3
4
  import { ChildContentOptions, Environment } from './environment';
4
5
  type EntityType = OpenFin.EntityType;
5
6
  export declare class BrowserEnvironment implements Environment {
6
- getManagerConstructor(): Promise<any>;
7
- getProviderInitializer(): Promise<any>;
7
+ observeBounds(element: Element, onChange: (bounds: DOMRect) => void | Promise<void>): () => void;
8
+ initLayout(_fin: OpenFin.Fin<OpenFin.EntityType>, wire: Transport, options: OpenFin.InitLayoutOptions): Promise<OpenFin.Layout>;
9
+ initPlatform(...args: any[]): Promise<any>;
8
10
  writeToken(path: string, token: string): Promise<string>;
9
11
  retrievePort(config: NewConnectConfig): Promise<number>;
10
12
  getNextMessageId(): string;
@@ -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;
@@ -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) {
package/src/mock.js CHANGED
@@ -42,10 +42,13 @@ class MockEnvironment {
42
42
  getRtcPeer() {
43
43
  throw new Error(me_1.environmentUnsupportedMessage);
44
44
  }
45
- getManagerConstructor() {
45
+ initLayout() {
46
46
  throw new Error(me_1.environmentUnsupportedMessage);
47
47
  }
48
- getProviderInitializer() {
48
+ initPlatform() {
49
+ throw new Error(me_1.environmentUnsupportedMessage);
50
+ }
51
+ observeBounds() {
49
52
  throw new Error(me_1.environmentUnsupportedMessage);
50
53
  }
51
54
  writeToken(path, token) {
@@ -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
- }
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ViewOverlay = void 0;
4
- /**
5
- * Api client allowing an empty electron BrowserView to be rendered
6
- * in the current window with the specified bounds.
7
- *
8
- * Please note, only one view based overlay can be rendered at a time per runtime.
9
- * @ignore
10
- */
11
- class ViewOverlay {
12
- // eslint-disable-next-line
13
- constructor(wire) {
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
- };
22
- /**
23
- * Renders the overlay at the specified position relative to the calling window.
24
- * @param options Bounds and background color to display in the overlay.
25
- */
26
- this.renderOverlay = async (bounds) => {
27
- await this.wire.sendAction('render-overlay', { bounds });
28
- };
29
- /**
30
- * Removes the overlay from the current window.
31
- */
32
- this.detachOverlay = async () => {
33
- await this.wire.sendAction('detach-overlay');
34
- };
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
- }
48
- }
49
- exports.ViewOverlay = ViewOverlay;