@openfin/core 31.74.25 → 31.74.28
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 +1 -1
- package/src/OpenFin.d.ts +20 -2
- package/src/api/application/Factory.js +0 -1
- package/src/api/platform/Factory.js +1 -4
- package/src/api/platform/Instance.d.ts +1 -1
- package/src/api/platform/Instance.js +1 -1
- package/src/api/platform/layout/Factory.js +10 -1
- package/src/api/platform/layout/Instance.d.ts +6 -0
- package/src/api/platform/layout/Instance.js +26 -1
- package/src/api/platform/layout/controllers/layout-content-cache.d.ts +9 -0
- package/src/api/platform/layout/controllers/layout-content-cache.js +54 -0
- package/src/api/platform/layout/controllers/layout-entities-controller.d.ts +116 -0
- package/src/api/platform/layout/controllers/layout-entities-controller.js +256 -0
- package/src/api/platform/layout/entities/layout-entities.d.ts +134 -0
- package/src/api/platform/layout/entities/layout-entities.js +204 -0
- package/src/api/platform/layout/entities/shapes.d.ts +6 -0
- package/src/api/platform/layout/entities/shapes.js +2 -0
- package/src/api/platform/layout/layout.constants.d.ts +1 -0
- package/src/api/platform/layout/layout.constants.js +4 -0
- package/src/api/platform/layout/shapes.d.ts +3 -0
- package/src/api/platform/layout/utils/layout-traversal.d.ts +3 -0
- package/src/api/platform/layout/utils/layout-traversal.js +65 -0
- package/src/api/view/Instance.d.ts +8 -2
- package/src/api/view/Instance.js +37 -4
- package/src/util/channel-api-relay.d.ts +13 -0
- package/src/util/channel-api-relay.js +37 -0
- package/src/util/lazy.d.ts +16 -0
- package/src/util/lazy.js +26 -0
- package/src/util/reversible-map.d.ts +11 -0
- package/src/util/reversible-map.js +49 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type * as OpenFin from '../../../../OpenFin';
|
|
2
|
+
import { LayoutEntitiesClient } from '../shapes';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
|
|
6
|
+
* for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class LayoutNode {
|
|
9
|
+
#private;
|
|
10
|
+
/** @internal */
|
|
11
|
+
protected constructor(client: LayoutEntitiesClient, entityId: string);
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
* The type of this node, one of: 'row' | 'column' | 'stack';
|
|
15
|
+
*/
|
|
16
|
+
readonly abstract type: OpenFin.LayoutEntityTypes;
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
* This instance's unique id used when calling the layout-entities-controller api client
|
|
20
|
+
*/
|
|
21
|
+
protected readonly entityId: string;
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
* Encapsulates Api consumption of {@link LayoutEntitiesController} with a relayed dispatch
|
|
25
|
+
* @param client
|
|
26
|
+
* @param controllerId
|
|
27
|
+
* @param identity
|
|
28
|
+
* @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
|
|
29
|
+
*/
|
|
30
|
+
static newLayoutEntitiesClient: (client: OpenFin.ChannelClient, controllerId: string, identity: OpenFin.Identity) => Promise<LayoutEntitiesClient>;
|
|
31
|
+
static getEntity: (definition: OpenFin.LayoutEntityDefinition, client: LayoutEntitiesClient) => ColumnOrRow | TabStack;
|
|
32
|
+
/**
|
|
33
|
+
* Determines if this {@link ColumnOrRow} or {@link TabStack} is the top level content item in the current layout.
|
|
34
|
+
* @returns Promise resolving true if this is the root, or false otherwise.
|
|
35
|
+
*/
|
|
36
|
+
isRoot: () => Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Determines if this {@link ColumnOrRow} or {@link TabStack} is the top level
|
|
39
|
+
* content item in the current layout.
|
|
40
|
+
* @returns Promise resolving true if this is the root, or false otherwise.
|
|
41
|
+
*/
|
|
42
|
+
exists: () => Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves the parent {@link ColumnOrRow} or {@link TabStack} of this item, if one exists.
|
|
45
|
+
* @returns Promise resolving with the {@link ColumnOrRow} or {@link TabStack} that contains this item, or undefined if this is the root content item.
|
|
46
|
+
*/
|
|
47
|
+
getParent: () => Promise<ColumnOrRow | TabStack | undefined>;
|
|
48
|
+
/**
|
|
49
|
+
* Given a list of view creation options or references and a layout position, creates an adjacent {@link TabStack}
|
|
50
|
+
*
|
|
51
|
+
* Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
|
|
52
|
+
* during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
|
|
53
|
+
* This means the views you pass to createAdjacentStack() may not render in the order given by the array.
|
|
54
|
+
* Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
|
|
55
|
+
*
|
|
56
|
+
* @param views List of identities or view creation options of the views to include in the stack
|
|
57
|
+
* @param options Creation options, defaults to position: 'right'
|
|
58
|
+
* @returns an instance of {@link TabStack} containing the given views
|
|
59
|
+
* @experimental
|
|
60
|
+
*/
|
|
61
|
+
createAdjacentStack: (views: OpenFin.PlatformViewCreationOptions[], options: {
|
|
62
|
+
position?: OpenFin.LayoutPosition;
|
|
63
|
+
}) => Promise<TabStack>;
|
|
64
|
+
/**
|
|
65
|
+
* Finds the immediate adjacent layout item given an edge Position
|
|
66
|
+
* @param edgePosition
|
|
67
|
+
* @returns either {@link TabStack} or {@link ColumnOrRow} that was found, or `undefined` if there is no item with that edgePosition
|
|
68
|
+
*/
|
|
69
|
+
getAdjacentStacks: (edge: OpenFin.LayoutPosition) => Promise<TabStack[]>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A {@link TabStack} is used to manage the state of a TabStack within an OpenFin Layout and
|
|
73
|
+
* traverse to its parent Content Item.
|
|
74
|
+
*/
|
|
75
|
+
export declare class TabStack extends LayoutNode {
|
|
76
|
+
#private;
|
|
77
|
+
/** @internal */
|
|
78
|
+
constructor(client: LayoutEntitiesClient, entityId: string);
|
|
79
|
+
/**
|
|
80
|
+
* Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
|
|
81
|
+
*/
|
|
82
|
+
readonly type = "stack";
|
|
83
|
+
/**
|
|
84
|
+
* Retrieves a list of all views belonging to this {@link TabStack}.
|
|
85
|
+
*
|
|
86
|
+
* Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
|
|
87
|
+
* and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
|
|
88
|
+
* If that happens and then getViews() is called, it will return the identities in a different order than
|
|
89
|
+
* than the currently rendered tab order.
|
|
90
|
+
*
|
|
91
|
+
* @returns Resolves with a list containing the {@link OpenFin.Identity identities} of each view belonging to the {@link TabStack}.
|
|
92
|
+
* @throws If the {@link TabStack} has been destroyed.
|
|
93
|
+
* @experimental
|
|
94
|
+
*/
|
|
95
|
+
getViews: () => Promise<OpenFin.Identity[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Adds or creates a view in this {@link TabStack}.
|
|
98
|
+
*
|
|
99
|
+
* Known Issue: If adding a view overflows the tab-container, the added view will be set as active
|
|
100
|
+
* and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
|
|
101
|
+
*
|
|
102
|
+
* @param view The identity of an existing view to add, or options to create a view.
|
|
103
|
+
* @param options Optional view options: index number used to insert the view into the stack at that index. Defaults to 0 (front of the stack)
|
|
104
|
+
* @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
|
|
105
|
+
* @throws If the view does not exist or fails to create.
|
|
106
|
+
* @throws If the {@link TabStack} has been destroyed.
|
|
107
|
+
* @experimental
|
|
108
|
+
*/
|
|
109
|
+
addView: (view: OpenFin.Identity | OpenFin.PlatformViewCreationOptions, options?: OpenFin.AddViewToStackOptions) => Promise<OpenFin.Identity>;
|
|
110
|
+
/**
|
|
111
|
+
* Removes a view from this {@link TabStack}.
|
|
112
|
+
* @param view {@link OpenFin.Identiy Identity} of the view to remove.
|
|
113
|
+
* @throws If the view does not exist or does not belong to the stack.
|
|
114
|
+
* @throws If the {@link TabStack} has been destroyed.
|
|
115
|
+
*/
|
|
116
|
+
removeView: (view: OpenFin.Identity) => Promise<void>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A {@link ColumnOrRow} is used to manage the state of a ColumnOrRow within an OpenFin Layout.
|
|
120
|
+
*/
|
|
121
|
+
export declare class ColumnOrRow extends LayoutNode {
|
|
122
|
+
#private;
|
|
123
|
+
/** @internal */
|
|
124
|
+
constructor(client: LayoutEntitiesClient, entityId: string, type: 'row' | 'column');
|
|
125
|
+
/**
|
|
126
|
+
* The type of this {@link ColumnOrRow}. Either 'row' or 'column'.
|
|
127
|
+
*/
|
|
128
|
+
readonly type: 'column' | 'row';
|
|
129
|
+
/**
|
|
130
|
+
* Retrieves a list of all content items belonging to this {@link ColumnOrRow} in order of appearance.
|
|
131
|
+
* @returns Resolves with a list containing {@link ColumnOrRow} and {@link TabStack} items belonging to this {@link ColumnOrRow}.
|
|
132
|
+
*/
|
|
133
|
+
getContent: () => Promise<(ColumnOrRow | TabStack)[]>;
|
|
134
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
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");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _a, _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ColumnOrRow = exports.TabStack = exports.LayoutNode = void 0;
|
|
16
|
+
const api_exposer_1 = require("../../../api-exposer");
|
|
17
|
+
const channel_api_relay_1 = require("../../../../util/channel-api-relay");
|
|
18
|
+
/*
|
|
19
|
+
This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
|
|
20
|
+
intertwined, and share members via parent abstract class LayoutNode. To prevent circular
|
|
21
|
+
refs, we define and export all the classes here.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
* Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
|
|
26
|
+
* for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
|
|
27
|
+
*/
|
|
28
|
+
class LayoutNode {
|
|
29
|
+
/** @internal */
|
|
30
|
+
constructor(client, entityId) {
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
* ApiClient for {@link LayoutEntitiesController}
|
|
34
|
+
*/
|
|
35
|
+
_LayoutNode_client.set(this, void 0);
|
|
36
|
+
/**
|
|
37
|
+
* Determines if this {@link ColumnOrRow} or {@link TabStack} is the top level content item in the current layout.
|
|
38
|
+
* @returns Promise resolving true if this is the root, or false otherwise.
|
|
39
|
+
*/
|
|
40
|
+
this.isRoot = () => __classPrivateFieldGet(this, _LayoutNode_client, "f").isRoot(this.entityId);
|
|
41
|
+
/**
|
|
42
|
+
* Determines if this {@link ColumnOrRow} or {@link TabStack} is the top level
|
|
43
|
+
* content item in the current layout.
|
|
44
|
+
* @returns Promise resolving true if this is the root, or false otherwise.
|
|
45
|
+
*/
|
|
46
|
+
this.exists = () => __classPrivateFieldGet(this, _LayoutNode_client, "f").exists(this.entityId);
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the parent {@link ColumnOrRow} or {@link TabStack} of this item, if one exists.
|
|
49
|
+
* @returns Promise resolving with the {@link ColumnOrRow} or {@link TabStack} that contains this item, or undefined if this is the root content item.
|
|
50
|
+
*/
|
|
51
|
+
this.getParent = async () => {
|
|
52
|
+
const parent = await __classPrivateFieldGet(this, _LayoutNode_client, "f").getParent(this.entityId);
|
|
53
|
+
if (!parent) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
return LayoutNode.getEntity(parent, __classPrivateFieldGet(this, _LayoutNode_client, "f"));
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Given a list of view creation options or references and a layout position, creates an adjacent {@link TabStack}
|
|
60
|
+
*
|
|
61
|
+
* Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
|
|
62
|
+
* during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
|
|
63
|
+
* This means the views you pass to createAdjacentStack() may not render in the order given by the array.
|
|
64
|
+
* Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
|
|
65
|
+
*
|
|
66
|
+
* @param views List of identities or view creation options of the views to include in the stack
|
|
67
|
+
* @param options Creation options, defaults to position: 'right'
|
|
68
|
+
* @returns an instance of {@link TabStack} containing the given views
|
|
69
|
+
* @experimental
|
|
70
|
+
*/
|
|
71
|
+
this.createAdjacentStack = async (views, options) => {
|
|
72
|
+
const entityId = await __classPrivateFieldGet(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
|
|
73
|
+
return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet(this, _LayoutNode_client, "f"));
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Finds the immediate adjacent layout item given an edge Position
|
|
77
|
+
* @param edgePosition
|
|
78
|
+
* @returns either {@link TabStack} or {@link ColumnOrRow} that was found, or `undefined` if there is no item with that edgePosition
|
|
79
|
+
*/
|
|
80
|
+
this.getAdjacentStacks = async (edge) => {
|
|
81
|
+
const adjacentStacks = await __classPrivateFieldGet(this, _LayoutNode_client, "f").getAdjacentStacks({
|
|
82
|
+
targetId: this.entityId,
|
|
83
|
+
edge
|
|
84
|
+
});
|
|
85
|
+
return adjacentStacks.map(stack => LayoutNode.getEntity({
|
|
86
|
+
type: 'stack',
|
|
87
|
+
entityId: stack.entityId
|
|
88
|
+
}, __classPrivateFieldGet(this, _LayoutNode_client, "f")));
|
|
89
|
+
};
|
|
90
|
+
__classPrivateFieldSet(this, _LayoutNode_client, client, "f");
|
|
91
|
+
this.entityId = entityId;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.LayoutNode = LayoutNode;
|
|
95
|
+
_a = LayoutNode, _LayoutNode_client = new WeakMap();
|
|
96
|
+
/**
|
|
97
|
+
* @internal
|
|
98
|
+
* Encapsulates Api consumption of {@link LayoutEntitiesController} with a relayed dispatch
|
|
99
|
+
* @param client
|
|
100
|
+
* @param controllerId
|
|
101
|
+
* @param identity
|
|
102
|
+
* @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
|
|
103
|
+
*/
|
|
104
|
+
LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
|
|
105
|
+
const dispatch = (0, channel_api_relay_1.createRelayedDispatch)(client, identity, 'layout-relay', 'You are trying to interact with a layout component on a window that has been destroyed.');
|
|
106
|
+
const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
|
|
107
|
+
return consumer.consume({ id: controllerId });
|
|
108
|
+
};
|
|
109
|
+
LayoutNode.getEntity = (definition, client) => {
|
|
110
|
+
const { entityId, type } = definition;
|
|
111
|
+
switch (type) {
|
|
112
|
+
case 'column':
|
|
113
|
+
case 'row':
|
|
114
|
+
return new ColumnOrRow(client, entityId, type);
|
|
115
|
+
case 'stack':
|
|
116
|
+
return new TabStack(client, entityId);
|
|
117
|
+
default:
|
|
118
|
+
throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* A {@link TabStack} is used to manage the state of a TabStack within an OpenFin Layout and
|
|
123
|
+
* traverse to its parent Content Item.
|
|
124
|
+
*/
|
|
125
|
+
class TabStack extends LayoutNode {
|
|
126
|
+
/** @internal */
|
|
127
|
+
constructor(client, entityId) {
|
|
128
|
+
super(client, entityId);
|
|
129
|
+
/**
|
|
130
|
+
* @internal
|
|
131
|
+
* ApiClient for {@link LayoutEntitiesController}
|
|
132
|
+
*/
|
|
133
|
+
_TabStack_client.set(this, void 0);
|
|
134
|
+
/**
|
|
135
|
+
* Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
|
|
136
|
+
*/
|
|
137
|
+
this.type = 'stack';
|
|
138
|
+
/**
|
|
139
|
+
* Retrieves a list of all views belonging to this {@link TabStack}.
|
|
140
|
+
*
|
|
141
|
+
* Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
|
|
142
|
+
* and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
|
|
143
|
+
* If that happens and then getViews() is called, it will return the identities in a different order than
|
|
144
|
+
* than the currently rendered tab order.
|
|
145
|
+
*
|
|
146
|
+
* @returns Resolves with a list containing the {@link OpenFin.Identity identities} of each view belonging to the {@link TabStack}.
|
|
147
|
+
* @throws If the {@link TabStack} has been destroyed.
|
|
148
|
+
* @experimental
|
|
149
|
+
*/
|
|
150
|
+
this.getViews = () => __classPrivateFieldGet(this, _TabStack_client, "f").getStackViews(this.entityId);
|
|
151
|
+
/**
|
|
152
|
+
* Adds or creates a view in this {@link TabStack}.
|
|
153
|
+
*
|
|
154
|
+
* Known Issue: If adding a view overflows the tab-container, the added view will be set as active
|
|
155
|
+
* and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
|
|
156
|
+
*
|
|
157
|
+
* @param view The identity of an existing view to add, or options to create a view.
|
|
158
|
+
* @param options Optional view options: index number used to insert the view into the stack at that index. Defaults to 0 (front of the stack)
|
|
159
|
+
* @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
|
|
160
|
+
* @throws If the view does not exist or fails to create.
|
|
161
|
+
* @throws If the {@link TabStack} has been destroyed.
|
|
162
|
+
* @experimental
|
|
163
|
+
*/
|
|
164
|
+
this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
|
|
165
|
+
/**
|
|
166
|
+
* Removes a view from this {@link TabStack}.
|
|
167
|
+
* @param view {@link OpenFin.Identiy Identity} of the view to remove.
|
|
168
|
+
* @throws If the view does not exist or does not belong to the stack.
|
|
169
|
+
* @throws If the {@link TabStack} has been destroyed.
|
|
170
|
+
*/
|
|
171
|
+
this.removeView = async (view) => {
|
|
172
|
+
await __classPrivateFieldGet(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
|
|
173
|
+
};
|
|
174
|
+
__classPrivateFieldSet(this, _TabStack_client, client, "f");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.TabStack = TabStack;
|
|
178
|
+
_TabStack_client = new WeakMap();
|
|
179
|
+
/**
|
|
180
|
+
* A {@link ColumnOrRow} is used to manage the state of a ColumnOrRow within an OpenFin Layout.
|
|
181
|
+
*/
|
|
182
|
+
class ColumnOrRow extends LayoutNode {
|
|
183
|
+
/** @internal */
|
|
184
|
+
constructor(client, entityId, type) {
|
|
185
|
+
super(client, entityId);
|
|
186
|
+
/**
|
|
187
|
+
* @internal
|
|
188
|
+
* ApiClient for {@link LayoutEntitiesController}
|
|
189
|
+
*/
|
|
190
|
+
_ColumnOrRow_client.set(this, void 0);
|
|
191
|
+
/**
|
|
192
|
+
* Retrieves a list of all content items belonging to this {@link ColumnOrRow} in order of appearance.
|
|
193
|
+
* @returns Resolves with a list containing {@link ColumnOrRow} and {@link TabStack} items belonging to this {@link ColumnOrRow}.
|
|
194
|
+
*/
|
|
195
|
+
this.getContent = async () => {
|
|
196
|
+
const contentItemEntities = await __classPrivateFieldGet(this, _ColumnOrRow_client, "f").getContent(this.entityId);
|
|
197
|
+
return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet(this, _ColumnOrRow_client, "f")));
|
|
198
|
+
};
|
|
199
|
+
__classPrivateFieldSet(this, _ColumnOrRow_client, client, "f");
|
|
200
|
+
this.type = type;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
exports.ColumnOrRow = ColumnOrRow;
|
|
204
|
+
_ColumnOrRow_client = new WeakMap();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type LayoutEntityTypes = Exclude<GoldenLayout.ItemType, 'component' | 'root'>;
|
|
2
|
+
export type LayoutPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
export type LayoutEntityDefinition<TLayoutEntityType extends LayoutEntityTypes = LayoutEntityTypes> = {
|
|
4
|
+
type: TLayoutEntityType;
|
|
5
|
+
entityId: string;
|
|
6
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LAYOUT_CONTROLLER_ID = "layout-entities";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { ApiClient } from '../../api-exposer';
|
|
1
2
|
import type * as OpenFin from '../../../OpenFin';
|
|
3
|
+
import { LayoutEntitiesController } from './controllers/layout-entities-controller';
|
|
2
4
|
type LayoutPresetType = OpenFin.LayoutPresetType;
|
|
3
5
|
export interface InitLayoutOptions {
|
|
4
6
|
containerId?: string;
|
|
@@ -10,4 +12,5 @@ export interface DragPayload {
|
|
|
10
12
|
'view-config': OpenFin.ViewCreationOptions;
|
|
11
13
|
'view-identity': [string, string, string];
|
|
12
14
|
}
|
|
15
|
+
export type LayoutEntitiesClient = ApiClient<LayoutEntitiesController>;
|
|
13
16
|
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type * as OpenFin from '../../../../OpenFin';
|
|
2
|
+
export declare const getAdjacentItem: (component: GoldenLayout.ContentItem, edge: OpenFin.LayoutPosition) => GoldenLayout.ContentItem | undefined;
|
|
3
|
+
export declare const getAdjacentStacks: (item: GoldenLayout.ContentItem, edge: OpenFin.LayoutPosition) => GoldenLayout.ContentItem[];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAdjacentStacks = exports.getAdjacentItem = void 0;
|
|
4
|
+
const getAdjacentItem = (component, edge) => {
|
|
5
|
+
const { parent } = component;
|
|
6
|
+
// need to handle the case where a stack is the parent content item
|
|
7
|
+
if (parent.isRoot) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const targetType = ['top', 'bottom'].includes(edge) ? 'column' : 'row';
|
|
11
|
+
const edgeSiblingOffset = ['top', 'left'].includes(edge) ? -1 : 1;
|
|
12
|
+
if (parent.type === targetType) {
|
|
13
|
+
const componentIndex = parent.contentItems.indexOf(component);
|
|
14
|
+
const targetIndex = componentIndex + edgeSiblingOffset;
|
|
15
|
+
if (targetIndex >= 0 && targetIndex < parent.contentItems.length) {
|
|
16
|
+
return parent.contentItems[targetIndex];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return (0, exports.getAdjacentItem)(parent, edge);
|
|
20
|
+
};
|
|
21
|
+
exports.getAdjacentItem = getAdjacentItem;
|
|
22
|
+
const doShareEdge = (a, b, edge) => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
const boundsA = (_a = a.element.get(0)) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
25
|
+
const boundsB = (_b = b.element.get(0)) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
|
|
26
|
+
if (!boundsA || !boundsB) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
if (['top', 'bottom'].includes(edge)) {
|
|
30
|
+
return ((boundsB.left >= boundsA.left && boundsB.left < boundsA.right) ||
|
|
31
|
+
(boundsB.right > boundsA.left && boundsB.right <= boundsA.right));
|
|
32
|
+
}
|
|
33
|
+
return ((boundsB.top >= boundsA.top && boundsB.top < boundsA.bottom) ||
|
|
34
|
+
(boundsB.bottom > boundsA.top && boundsB.bottom <= boundsA.bottom));
|
|
35
|
+
};
|
|
36
|
+
const getAdjacentStacks = (item, edge) => {
|
|
37
|
+
const targetContainer = ['top', 'bottom'].includes(edge) ? 'row' : 'column';
|
|
38
|
+
const findEdgeStacks = (component) => {
|
|
39
|
+
if (component.type === 'stack') {
|
|
40
|
+
if (doShareEdge(item, component, edge)) {
|
|
41
|
+
return [component];
|
|
42
|
+
}
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
if (component.type === 'root') {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
if (component.type === targetContainer) {
|
|
49
|
+
return component.contentItems.map((contentItem) => findEdgeStacks(contentItem)).flat();
|
|
50
|
+
}
|
|
51
|
+
if (component.type !== targetContainer) {
|
|
52
|
+
if (['top', 'right'].includes(edge)) {
|
|
53
|
+
return findEdgeStacks(component.contentItems[component.contentItems.length - 1]);
|
|
54
|
+
}
|
|
55
|
+
return findEdgeStacks(component.contentItems[0]);
|
|
56
|
+
}
|
|
57
|
+
return [];
|
|
58
|
+
};
|
|
59
|
+
const edgeItem = (0, exports.getAdjacentItem)(item, edge);
|
|
60
|
+
if (edgeItem) {
|
|
61
|
+
return findEdgeStacks(edgeItem);
|
|
62
|
+
}
|
|
63
|
+
return [];
|
|
64
|
+
};
|
|
65
|
+
exports.getAdjacentStacks = getAdjacentStacks;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type * as OpenFin from '../../OpenFin';
|
|
2
|
-
import { WebContents } from '../webcontents/main';
|
|
3
2
|
import { Transport } from '../../transport/transport';
|
|
4
|
-
import { Layout } from '../platform/layout';
|
|
5
3
|
import { ViewEvent } from '../events/view';
|
|
4
|
+
import { WebContents } from '../webcontents/main';
|
|
6
5
|
type UpdatableViewOptions = OpenFin.UpdatableViewOptions;
|
|
7
6
|
/**
|
|
8
7
|
* @PORTED
|
|
@@ -172,6 +171,7 @@ type UpdatableViewOptions = OpenFin.UpdatableViewOptions;
|
|
|
172
171
|
* @hideconstructor
|
|
173
172
|
*/
|
|
174
173
|
export declare class View extends WebContents<ViewEvent> {
|
|
174
|
+
#private;
|
|
175
175
|
identity: OpenFin.Identity;
|
|
176
176
|
constructor(wire: Transport, identity: OpenFin.Identity);
|
|
177
177
|
/**
|
|
@@ -445,6 +445,12 @@ export declare class View extends WebContents<ViewEvent> {
|
|
|
445
445
|
* @experimental
|
|
446
446
|
*/
|
|
447
447
|
getCurrentWindow: () => Promise<OpenFin.Window>;
|
|
448
|
+
/**
|
|
449
|
+
* Retrieves the current {@link TabStack} of the view if it belongs to one.
|
|
450
|
+
* @return {Promise<TabStack | undefined>} The {@link TabStack} this view belongs to.
|
|
451
|
+
* @throws if this view does not belong to a TabStack or if the window has been destroyed.
|
|
452
|
+
*/
|
|
453
|
+
getCurrentStack: () => Promise<OpenFin.TabStack | undefined>;
|
|
448
454
|
/**
|
|
449
455
|
* Triggers the before-unload handler for the View, if one is set. Returns `true` if the handler is trying to prevent the View from unloading, and `false` if it isn't.
|
|
450
456
|
* Only enabled when setting enableBeforeUnload: true in your View options. If this option is not enabled it will always return false.
|
package/src/api/view/Instance.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _View_providerChannelClient;
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.View = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
const transport_errors_1 = require("../../transport/transport-errors");
|
|
11
|
+
const lazy_1 = require("../../util/lazy");
|
|
12
|
+
const layout_entities_1 = require("../platform/layout/entities/layout-entities");
|
|
13
|
+
const layout_constants_1 = require("../platform/layout/layout.constants");
|
|
14
|
+
const bounds_observer_1 = require("../platform/layout/utils/bounds-observer");
|
|
7
15
|
const main_1 = require("../webcontents/main");
|
|
8
16
|
const window_1 = require("../window");
|
|
9
|
-
const bounds_observer_1 = require("../platform/layout/utils/bounds-observer");
|
|
10
17
|
/**
|
|
11
18
|
* @PORTED
|
|
12
19
|
* @typedef {object} View~options
|
|
@@ -178,6 +185,10 @@ class View extends main_1.WebContents {
|
|
|
178
185
|
constructor(wire, identity) {
|
|
179
186
|
super(wire, identity, 'view');
|
|
180
187
|
this.identity = identity;
|
|
188
|
+
_View_providerChannelClient.set(this, new lazy_1.Lazy(() => {
|
|
189
|
+
const platform = this.fin.Platform.wrapSync(this.identity);
|
|
190
|
+
return platform.getClient();
|
|
191
|
+
}));
|
|
181
192
|
/**
|
|
182
193
|
* Returns the zoom level of the view.
|
|
183
194
|
* @function getZoomLevel
|
|
@@ -446,6 +457,27 @@ class View extends main_1.WebContents {
|
|
|
446
457
|
const { payload: { data } } = await this.wire.sendAction('get-view-window', { ...this.identity });
|
|
447
458
|
return new window_1._Window(this.wire, data);
|
|
448
459
|
};
|
|
460
|
+
/**
|
|
461
|
+
* Retrieves the current {@link TabStack} of the view if it belongs to one.
|
|
462
|
+
* @return {Promise<TabStack | undefined>} The {@link TabStack} this view belongs to.
|
|
463
|
+
* @throws if this view does not belong to a TabStack or if the window has been destroyed.
|
|
464
|
+
*/
|
|
465
|
+
this.getCurrentStack = async () => {
|
|
466
|
+
try {
|
|
467
|
+
const layoutWindow = await this.getCurrentWindow();
|
|
468
|
+
const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
|
|
469
|
+
const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindow.identity);
|
|
470
|
+
const stackDefinition = await client.getStackByView(this.identity);
|
|
471
|
+
return layout_entities_1.LayoutNode.getEntity(stackDefinition, client);
|
|
472
|
+
}
|
|
473
|
+
catch (error) {
|
|
474
|
+
const e = new transport_errors_1.RuntimeError({ reason: 'This view does not belong to a stack.' });
|
|
475
|
+
// TODO: @pierre to fix
|
|
476
|
+
// @ts-expect-error pending PR !3459 to fix runtime errors
|
|
477
|
+
e.cause = error;
|
|
478
|
+
throw e;
|
|
479
|
+
}
|
|
480
|
+
};
|
|
449
481
|
/**
|
|
450
482
|
* Triggers the before-unload handler for the View, if one is set. Returns `true` if the handler is trying to prevent the View from unloading, and `false` if it isn't.
|
|
451
483
|
* Only enabled when setting enableBeforeUnload: true in your View options. If this option is not enabled it will always return false.
|
|
@@ -515,3 +547,4 @@ class View extends main_1.WebContents {
|
|
|
515
547
|
}
|
|
516
548
|
}
|
|
517
549
|
exports.View = View;
|
|
550
|
+
_View_providerChannelClient = new WeakMap();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as OpenFin from '../OpenFin';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Create a channel relay for a given channel exposition, allowing a single provider to route
|
|
5
|
+
* actions to the designated clients.
|
|
6
|
+
*
|
|
7
|
+
* Designed to be used in conjunction with @expose
|
|
8
|
+
*
|
|
9
|
+
* @param channelProvider The channel provider to relay the actions on.
|
|
10
|
+
* @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
|
|
11
|
+
*/
|
|
12
|
+
export declare const relayChannelClientApi: (channelProvider: OpenFin.ChannelProvider, relayId: string) => Promise<void>;
|
|
13
|
+
export declare const createRelayedDispatch: (client: OpenFin.ChannelClient, target: OpenFin.Identity, relayId: string, relayErrorMsg?: string) => OpenFin.ChannelClient['dispatch'];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRelayedDispatch = exports.relayChannelClientApi = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Create a channel relay for a given channel exposition, allowing a single provider to route
|
|
7
|
+
* actions to the designated clients.
|
|
8
|
+
*
|
|
9
|
+
* Designed to be used in conjunction with @expose
|
|
10
|
+
*
|
|
11
|
+
* @param channelProvider The channel provider to relay the actions on.
|
|
12
|
+
* @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
|
|
13
|
+
*/
|
|
14
|
+
const relayChannelClientApi = async (channelProvider, relayId) => {
|
|
15
|
+
channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
|
|
16
|
+
return channelProvider.dispatch(target, action, payload);
|
|
17
|
+
});
|
|
18
|
+
await Promise.resolve();
|
|
19
|
+
};
|
|
20
|
+
exports.relayChannelClientApi = relayChannelClientApi;
|
|
21
|
+
const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
|
|
22
|
+
try {
|
|
23
|
+
return await client.dispatch(`relay:${relayId}`, {
|
|
24
|
+
action,
|
|
25
|
+
payload,
|
|
26
|
+
target
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
if (e.message.includes('no longer connected') && relayErrorMsg) {
|
|
31
|
+
throw new Error(relayErrorMsg);
|
|
32
|
+
}
|
|
33
|
+
;
|
|
34
|
+
throw e;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.createRelayedDispatch = createRelayedDispatch;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handy class for managing asynchronous dependencies of classes.
|
|
3
|
+
*
|
|
4
|
+
* Will call the producer function once and only once when getValue is called,
|
|
5
|
+
* returning the resultant value for every subsequent call.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Lazy<T> {
|
|
8
|
+
private producerFn;
|
|
9
|
+
constructor(producerFn: () => T);
|
|
10
|
+
private value;
|
|
11
|
+
/**
|
|
12
|
+
* Lazily get the value returned by the producer.
|
|
13
|
+
* @returns The value returned from the producer function
|
|
14
|
+
*/
|
|
15
|
+
getValue(): T;
|
|
16
|
+
}
|
package/src/util/lazy.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Lazy = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Handy class for managing asynchronous dependencies of classes.
|
|
6
|
+
*
|
|
7
|
+
* Will call the producer function once and only once when getValue is called,
|
|
8
|
+
* returning the resultant value for every subsequent call.
|
|
9
|
+
*/
|
|
10
|
+
class Lazy {
|
|
11
|
+
// eslint-disable-next-line
|
|
12
|
+
constructor(producerFn) {
|
|
13
|
+
this.producerFn = producerFn;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Lazily get the value returned by the producer.
|
|
17
|
+
* @returns The value returned from the producer function
|
|
18
|
+
*/
|
|
19
|
+
getValue() {
|
|
20
|
+
if (!this.value) {
|
|
21
|
+
this.value = this.producerFn();
|
|
22
|
+
}
|
|
23
|
+
return this.value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.Lazy = Lazy;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class ReversibleMap<TKey extends string | number | symbol, TValue extends Object | string | number> {
|
|
2
|
+
private readonly valueToKey;
|
|
3
|
+
private readonly keyToValue;
|
|
4
|
+
setUnique: (key: TKey, value: TValue) => void;
|
|
5
|
+
getKey: (value: TValue) => TKey;
|
|
6
|
+
getValue(key: TKey): TValue;
|
|
7
|
+
deleteKey: (key: TKey) => TValue | undefined;
|
|
8
|
+
deleteValue: (value: TValue) => TKey | undefined;
|
|
9
|
+
hasKey: (key: TKey) => boolean;
|
|
10
|
+
hasValue: (value: TValue) => boolean;
|
|
11
|
+
}
|