@openfin/core 31.74.22 → 31.74.23

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 (76) hide show
  1. package/package.json +1 -1
  2. package/src/OpenFin.d.ts +77 -18
  3. package/src/api/application/Factory.js +0 -1
  4. package/src/api/application/Instance.js +23 -5
  5. package/src/api/base.d.ts +1 -2
  6. package/src/api/base.js +1 -2
  7. package/src/api/events/system.d.ts +6 -3
  8. package/src/api/fin.js +1 -2
  9. package/src/api/interappbus/channel/index.d.ts +1 -0
  10. package/src/api/interappbus/channel/index.js +47 -47
  11. package/src/api/interappbus/channel/protocols/classic/strategy.js +24 -6
  12. package/src/api/interappbus/index.js +1 -1
  13. package/src/api/interop/InteropClient.d.ts +1 -1
  14. package/src/api/interop/InteropClient.js +1 -1
  15. package/src/api/interop/SessionContextGroupBroker.d.ts +1 -1
  16. package/src/api/interop/SessionContextGroupBroker.js +5 -4
  17. package/src/api/interop/SessionContextGroupClient.js +1 -1
  18. package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +1 -1
  19. package/src/api/interop/fdc3/PrivateChannelProvider.js +1 -8
  20. package/src/api/interop/fdc3/fdc3-1.2.js +34 -1
  21. package/src/api/interop/fdc3/fdc3-2.0.d.ts +11 -10
  22. package/src/api/interop/fdc3/fdc3-2.0.js +10 -9
  23. package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +1 -1
  24. package/src/api/interop/fdc3/utils.js +24 -4
  25. package/src/api/platform/Factory.d.ts +2 -1
  26. package/src/api/platform/Factory.js +1 -4
  27. package/src/api/platform/Instance.d.ts +6 -5
  28. package/src/api/platform/Instance.js +1 -0
  29. package/src/api/platform/layout/Factory.js +15 -4
  30. package/src/api/platform/layout/Instance.d.ts +6 -0
  31. package/src/api/platform/layout/Instance.js +29 -1
  32. package/src/api/platform/layout/controllers/layout-content-cache.d.ts +9 -0
  33. package/src/api/platform/layout/controllers/layout-content-cache.js +54 -0
  34. package/src/api/platform/layout/controllers/layout-entities-controller.d.ts +119 -0
  35. package/src/api/platform/layout/controllers/layout-entities-controller.js +287 -0
  36. package/src/api/platform/layout/controllers/tab-drag-controller.d.ts +2 -1
  37. package/src/api/platform/layout/entities/layout-entities.d.ts +235 -0
  38. package/src/api/platform/layout/entities/layout-entities.js +312 -0
  39. package/src/api/platform/layout/entities/shapes.d.ts +6 -0
  40. package/src/api/platform/layout/entities/shapes.js +2 -0
  41. package/src/api/platform/layout/layout.constants.d.ts +1 -0
  42. package/src/api/platform/layout/layout.constants.js +4 -0
  43. package/src/api/platform/layout/shapes.d.ts +3 -0
  44. package/src/api/platform/layout/utils/layout-traversal.d.ts +4 -0
  45. package/src/api/platform/layout/utils/layout-traversal.js +65 -0
  46. package/src/api/platform/provider.d.ts +2 -1
  47. package/src/api/system/index.d.ts +9 -0
  48. package/src/api/system/index.js +78 -40
  49. package/src/api/view/Instance.d.ts +12 -3
  50. package/src/api/view/Instance.js +39 -4
  51. package/src/api/webcontents/main.d.ts +2 -22
  52. package/src/api/webcontents/main.js +2 -1
  53. package/src/api/window/Instance.d.ts +10 -0
  54. package/src/api/window/Instance.js +22 -0
  55. package/src/environment/mockEnvironment.d.ts +27 -0
  56. package/src/environment/mockEnvironment.js +61 -0
  57. package/src/mock.js +4 -83
  58. package/src/shapes/protocol.d.ts +17 -0
  59. package/src/transport/mockWire.d.ts +11 -0
  60. package/src/transport/mockWire.js +26 -0
  61. package/src/transport/transport-errors.d.ts +9 -1
  62. package/src/transport/transport-errors.js +45 -2
  63. package/src/transport/transport.d.ts +15 -5
  64. package/src/transport/transport.js +48 -20
  65. package/src/util/channel-api-relay.d.ts +13 -0
  66. package/src/util/channel-api-relay.js +47 -0
  67. package/src/util/errors.d.ts +1 -0
  68. package/src/util/errors.js +1 -0
  69. package/src/util/lazy.d.ts +34 -0
  70. package/src/util/lazy.js +54 -0
  71. package/src/util/ref-counter.d.ts +1 -1
  72. package/src/util/ref-counter.js +3 -2
  73. package/src/util/reversible-map.d.ts +11 -0
  74. package/src/util/reversible-map.js +49 -0
  75. package/src/transport/fin_store.d.ts +0 -4
  76. package/src/transport/fin_store.js +0 -16
@@ -0,0 +1,312 @@
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
+ * @ignore
25
+ * @internal
26
+ * Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
27
+ * for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
28
+ */
29
+ class LayoutNode {
30
+ /**
31
+ * @internal
32
+ * @ignore
33
+ */
34
+ constructor(client, entityId) {
35
+ /**
36
+ * @ignore
37
+ * @internal
38
+ * ApiClient for {@link LayoutEntitiesController}
39
+ */
40
+ _LayoutNode_client.set(this, void 0);
41
+ this.isRoot = () => __classPrivateFieldGet(this, _LayoutNode_client, "f").isRoot(this.entityId);
42
+ this.exists = () => __classPrivateFieldGet(this, _LayoutNode_client, "f").exists(this.entityId);
43
+ this.getParent = async () => {
44
+ const parent = await __classPrivateFieldGet(this, _LayoutNode_client, "f").getParent(this.entityId);
45
+ if (!parent) {
46
+ return undefined;
47
+ }
48
+ return LayoutNode.getEntity(parent, __classPrivateFieldGet(this, _LayoutNode_client, "f"));
49
+ };
50
+ this.createAdjacentStack = async (views, options) => {
51
+ const entityId = await __classPrivateFieldGet(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
52
+ return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet(this, _LayoutNode_client, "f"));
53
+ };
54
+ this.getAdjacentStacks = async (edge) => {
55
+ const adjacentStacks = await __classPrivateFieldGet(this, _LayoutNode_client, "f").getAdjacentStacks({
56
+ targetId: this.entityId,
57
+ edge
58
+ });
59
+ return adjacentStacks.map((stack) => LayoutNode.getEntity({
60
+ type: 'stack',
61
+ entityId: stack.entityId
62
+ }, __classPrivateFieldGet(this, _LayoutNode_client, "f")));
63
+ };
64
+ __classPrivateFieldSet(this, _LayoutNode_client, client, "f");
65
+ this.entityId = entityId;
66
+ }
67
+ }
68
+ exports.LayoutNode = LayoutNode;
69
+ _a = LayoutNode, _LayoutNode_client = new WeakMap();
70
+ /**
71
+ * @ignore
72
+ * @internal
73
+ * Encapsulates Api consumption of {@link LayoutEntitiesController} with a relayed dispatch
74
+ * @param client
75
+ * @param controllerId
76
+ * @param identity
77
+ * @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
78
+ */
79
+ LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
80
+ 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.');
81
+ const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
82
+ return consumer.consume({ id: controllerId });
83
+ };
84
+ LayoutNode.getEntity = (definition, client) => {
85
+ const { entityId, type } = definition;
86
+ switch (type) {
87
+ case 'column':
88
+ case 'row':
89
+ return new ColumnOrRow(client, entityId, type);
90
+ case 'stack':
91
+ return new TabStack(client, entityId);
92
+ default:
93
+ throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
94
+ }
95
+ };
96
+ /**
97
+ * @typedef {string} LayoutPosition
98
+ * @summary Represents the position of an item in a layout relative to another. Possible values are 'top', 'bottom', 'left' and 'right'.
99
+ */
100
+ /**
101
+ * @typedef {object} StackCreationOptions
102
+ * @summary Stack creation options.
103
+ * @property {LayoutPosition} [position] - The position to create the new {@link TabStack} in, relative to the given adjacent {@link TabStack}. Defaults to 'right'.
104
+ */
105
+ /**
106
+ * @typedef {object} TabStack~AddViewOptions
107
+ * @summary Options to use when adding a view to a {@link TabStack}
108
+ * @property {number} [index] - Insertion index when adding the view. Defaults to 0.
109
+ */
110
+ /**
111
+ * A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
112
+ */
113
+ class TabStack extends LayoutNode {
114
+ /**
115
+ * Determines if this {@link TabStack} is the top level content item in the current layout.
116
+ * @function isRoot
117
+ * @memberof TabStack
118
+ * @instance
119
+ * @tutorial TabStack.isRoot
120
+ * @return {Promise<boolean>} Resolves true if this TabStack is the top level content item, or false if it is not.
121
+ */
122
+ /**
123
+ * Determines if this {@link TabStack} exists.
124
+ * @function exists
125
+ * @instance
126
+ * @memberof TabStack
127
+ * @tutorial TabStack.exists
128
+ * @return {Promise<boolean>} Resolves true if this is the TabStack exists, or false if it has been destroyed.
129
+ */
130
+ /**
131
+ * Retrieves the parent {@link ColumnOrRow} of this {@link TabStack}, if one exists.
132
+ * @function getParent
133
+ * @instance
134
+ * @memberof TabStack
135
+ * @tutorial TabStack.getParent
136
+ * @return {Promise<ColumnOrRow | TabStack | undefined>} Promise resolving with the {@link ColumnOrRow} that contains this item, or undefined if this {@link TabStack} is the root content item or does not exist.
137
+ */
138
+ /**
139
+ * Returns all the adjacent stacks that share an edge with the given {@link TabStack}.
140
+ * @function getAdjacentStacks
141
+ * @instance
142
+ * @memberof TabStack
143
+ * @param {LayoutPosition} edge - Edge to check for any adjacent stacks.
144
+ * @returns {Promise<TabStack[]>}
145
+ * @tutorial TabStack.getAdjacentStacks
146
+ */
147
+ /**
148
+ * Given a list of view creation options or references and a layout position, creates a {@link TabStack} adjacent to the current {@link TabStack}
149
+ *
150
+ * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
151
+ * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
152
+ * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
153
+ * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
154
+ *
155
+ * @function createAdjacentStack
156
+ * @instance
157
+ * @memberof TabStack
158
+ * @param {View~options} views - List of identities or view creation options of the views to include in the stack
159
+ * @param {StackCreationOptions} options - Creation options.
160
+ * @returns {Promise<TabStack>} The created TabStack.
161
+ * @tutorial TabStack.createAdjacentStack
162
+ * @experimental
163
+ */
164
+ /** @internal */
165
+ constructor(client, entityId) {
166
+ super(client, entityId);
167
+ /**
168
+ * @internal
169
+ * ApiClient for {@link LayoutEntitiesController}
170
+ */
171
+ _TabStack_client.set(this, void 0);
172
+ /**
173
+ * Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
174
+ */
175
+ this.type = 'stack';
176
+ /**
177
+ * Retrieves a list of all views belonging to this {@link TabStack}.
178
+ *
179
+ * Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
180
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
181
+ * If that happens and then getViews() is called, it will return the identities in a different order than
182
+ * than the currently rendered tab order.
183
+ *
184
+ * @returns {Promise<Identity[]>} Resolves with a list containing the {@link OpenFin.Identity identities} of each view belonging to the {@link TabStack}.
185
+ * @throws If the {@link TabStack} has been destroyed.
186
+ * @tutorial TabStack.getViews
187
+ * @experimental
188
+ */
189
+ this.getViews = () => __classPrivateFieldGet(this, _TabStack_client, "f").getStackViews(this.entityId);
190
+ /**
191
+ * Adds or creates a view in this {@link TabStack}.
192
+ *
193
+ * Known Issue: If adding a view overflows the tab-container, the added view will be set as active
194
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
195
+ *
196
+ * @param {View~options} view The identity of an existing view to add, or options to create a view.
197
+ * @param {TabStack~AddViewOptions} options Optional view options: index number used to insert the view into the stack at that index. Defaults to 0 (front of the stack)
198
+ * @returns {Promise<identity>} Resolves with the {@link OpenFin.Identity identity} of the added view.
199
+ * @throws If the view does not exist or fails to create.
200
+ * @throws If the {@link TabStack} has been destroyed.
201
+ * @tutorial TabStack.addView
202
+ * @experimental
203
+ */
204
+ this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
205
+ /**
206
+ * Removes a view from this {@link TabStack}.
207
+ * @param {Identity} view - Identity of the view to remove.
208
+ * @throws If the view does not exist or does not belong to the stack.
209
+ * @throws If the {@link TabStack} has been destroyed.
210
+ * @return {Promise<void>}
211
+ * @tutorial TabStack.removeView
212
+ */
213
+ this.removeView = async (view) => {
214
+ await __classPrivateFieldGet(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
215
+ };
216
+ /**
217
+ * Sets the active view of the {@link TabStack} without focusing it.
218
+ * @param {Identity} view - Identity of the view to activate.
219
+ * @returns {Promise<void>} Promise which resolves with void once the view has been activated.
220
+ * @throws If the {@link TabStack} has been destroyed.
221
+ * @throws If the view does not exist.
222
+ * @tutorial TabStack.setActiveView
223
+ * @experimental
224
+ */
225
+ this.setActiveView = async (view) => {
226
+ await __classPrivateFieldGet(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
227
+ };
228
+ __classPrivateFieldSet(this, _TabStack_client, client, "f");
229
+ }
230
+ }
231
+ exports.TabStack = TabStack;
232
+ _TabStack_client = new WeakMap();
233
+ /**
234
+ * A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
235
+ */
236
+ class ColumnOrRow extends LayoutNode {
237
+ /**
238
+ * Determines if this {@link ColumnOrRow} is the top level content item in the current layout.
239
+ * @function isRoot
240
+ * @memberof ColumnOrRow
241
+ * @instance
242
+ * @tutorial ColumnOrRow.isRoot
243
+ * @return {Promise<boolean>} Resolves true if this TabStack is the top level content item, or false if it is not.
244
+ */
245
+ /**
246
+ * Determines if this {@link ColumnOrRow} exists.
247
+ * @function exists
248
+ * @instance
249
+ * @memberof ColumnOrRow
250
+ * @tutorial ColumnOrRow.exists
251
+ * @return {Promise<boolean>} Resolves true if the TabStack exists, or false if it has been destroyed.
252
+ */
253
+ /**
254
+ * Retrieves the parent {@link ColumnOrRow} of this {@link ColumnOrRow}, if one exists.
255
+ * @function getParent
256
+ * @instance
257
+ * @memberof ColumnOrRow
258
+ * @tutorial ColumnOrRow.getParent
259
+ * @return {Promise<ColumnOrRow | undefined>} Promise resolving with the {@link ColumnOrRow} that contains this item, or undefined if this {@link ColumnOrRow} does not exist or is the root content item.
260
+ */
261
+ /**
262
+ * Returns all the adjacent stacks that share an edge with the given {@link ColumnOrRow}.
263
+ * @function getAdjacentStacks
264
+ * @instance
265
+ * @memberof ColumnOrRow
266
+ * @param {LayoutPosition} edge - Edge to check for any adjacent stacks.
267
+ * @returns {Promise<TabStack[]>}
268
+ * @tutorial ColumnOrRow.getAdjacentStacks
269
+ */
270
+ /**
271
+ * Given a list of view creation options or references and a layout position, creates a {@link TabStack} adjacent to the given {@link ColumnOrRow}
272
+ *
273
+ * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
274
+ * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
275
+ * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
276
+ * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
277
+ *
278
+ * @function createAdjacentStack
279
+ * @instance
280
+ * @memberof ColumnOrRow
281
+ * @param {View~options} views - List of identities or view creation options of the views to include in the stack
282
+ * @param {StackCreationOptions} options - Creation options.
283
+ * @returns {Promise<TabStack>} The created TabStack
284
+ * @tutorial ColumnOrRow.createAdjacentStack
285
+ * @experimental
286
+ */
287
+ /**
288
+ * @internal
289
+ */
290
+ constructor(client, entityId, type) {
291
+ super(client, entityId);
292
+ /**
293
+ * @ignore
294
+ * @internal
295
+ * ApiClient for {@link LayoutEntitiesController}
296
+ */
297
+ _ColumnOrRow_client.set(this, void 0);
298
+ /**
299
+ * Retrieves a list of all content items belonging to this {@link ColumnOrRow} in order of appearance.
300
+ * @returns {Promise<Array<ColumnOrRow | TabStack>>} Resolves with a list containing {@link ColumnOrRow} and {@link TabStack} items belonging to this {@link ColumnOrRow}.
301
+ * @tutorial ColumnOrRow.getContent
302
+ */
303
+ this.getContent = async () => {
304
+ const contentItemEntities = await __classPrivateFieldGet(this, _ColumnOrRow_client, "f").getContent(this.entityId);
305
+ return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet(this, _ColumnOrRow_client, "f")));
306
+ };
307
+ __classPrivateFieldSet(this, _ColumnOrRow_client, client, "f");
308
+ this.type = type;
309
+ }
310
+ }
311
+ exports.ColumnOrRow = ColumnOrRow;
312
+ _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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export declare const LAYOUT_CONTROLLER_ID = "layout-entities";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LAYOUT_CONTROLLER_ID = void 0;
4
+ exports.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,4 @@
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 doShareEdge: (from: GoldenLayout.ContentItem, to: GoldenLayout.ContentItem, edge: OpenFin.LayoutPosition) => boolean;
4
+ 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.doShareEdge = exports.getAdjacentItem = void 0;
4
+ const getAdjacentItem = (component, edge) => {
5
+ const { parent } = component;
6
+ if (parent.isRoot) {
7
+ return undefined;
8
+ }
9
+ const targetType = ['top', 'bottom'].includes(edge) ? 'column' : 'row';
10
+ const edgeSiblingOffset = ['top', 'left'].includes(edge) ? -1 : 1;
11
+ if (parent.type === targetType) {
12
+ const componentIndex = parent.contentItems.indexOf(component);
13
+ const targetIndex = componentIndex + edgeSiblingOffset;
14
+ if (targetIndex >= 0 && targetIndex < parent.contentItems.length) {
15
+ return parent.contentItems[targetIndex];
16
+ }
17
+ }
18
+ return (0, exports.getAdjacentItem)(parent, edge);
19
+ };
20
+ exports.getAdjacentItem = getAdjacentItem;
21
+ const doShareEdge = (from, to, edge) => {
22
+ var _a, _b;
23
+ const boundsFrom = (_a = from.element.get(0)) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
24
+ const boundsTo = (_b = to.element.get(0)) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
25
+ if (!boundsFrom || !boundsTo) {
26
+ return false;
27
+ }
28
+ if (['top', 'bottom'].includes(edge)) {
29
+ const horizontallyOutOfBounds = boundsFrom.right < boundsTo.left || boundsFrom.left > boundsTo.right;
30
+ return !horizontallyOutOfBounds;
31
+ }
32
+ const verticallyOutOfBounds = boundsFrom.bottom < boundsTo.top || boundsFrom.top > boundsTo.bottom;
33
+ return !verticallyOutOfBounds;
34
+ };
35
+ exports.doShareEdge = doShareEdge;
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 ((0, exports.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,5 +1,5 @@
1
- import { WindowOptionsChangedEvent } from '../events/window';
2
1
  import * as OpenFin from '../../OpenFin';
2
+ type WindowOptionsChangedEvent = OpenFin.WindowEvents.WindowOptionsChangedEvent;
3
3
  /**
4
4
  * This class handles Platform actions. It does not need to be used directly by developers.
5
5
  * However, its methods can be overriden by passing an `overrideCallback` to {@link Platform#init Platform.init}
@@ -160,3 +160,4 @@ export interface PlatformProvider {
160
160
  */
161
161
  handleViewsAndWindowClose(windowId: OpenFin.Identity, userDecision: OpenFin.BeforeUnloadUserDecision): Promise<void>;
162
162
  }
163
+ export {};
@@ -460,6 +460,15 @@ export default class System extends EmitterBase<OpenFin.SystemEvent> {
460
460
  */
461
461
  getServiceConfiguration(serviceIdentifier: OpenFin.ServiceIdentifier): Promise<OpenFin.ServiceConfiguration>;
462
462
  protected getSystemAppConfig(name: string): Promise<any>;
463
+ /**
464
+ * Registers a system shutdown handler so user can do some cleanup before system is shutting down.
465
+ * Note: Once system shutdown starts, you are unable to cancel it.
466
+ * @param { SystemShutdownHandler } handler system shutdown handler
467
+ * @return {Promise.<void>}
468
+ * @tutorial System.registerShutdownHandler
469
+ * @experimental
470
+ */
471
+ registerShutdownHandler(handler: OpenFin.SystemShutdownHandler): Promise<void>;
463
472
  /**
464
473
  * Signals the RVM to perform a health check and returns the results as json.
465
474
  * @return {Promise.<string[]>}
@@ -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 }));
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.
@@ -568,6 +577,7 @@ class System extends base_1.EmitterBase {
568
577
  * @tutorial System.downloadRuntime
569
578
  */
570
579
  downloadRuntime(options, progressListener) {
580
+ const callsites = transport_errors_1.RuntimeError.getCallSite();
571
581
  return new Promise((resolve, reject) => {
572
582
  // node.js environment not supported
573
583
  if (this.wire.environment.constructor.name === 'NodeEnvironment') {
@@ -593,7 +603,7 @@ class System extends base_1.EmitterBase {
593
603
  const dlError = (payload) => {
594
604
  cleanListeners();
595
605
  const { reason, err: error } = payload;
596
- reject(new transport_errors_1.RuntimeError({ reason, error }));
606
+ reject(new transport_errors_1.RuntimeError({ reason, error }, callsites));
597
607
  };
598
608
  const dlComplete = () => {
599
609
  cleanListeners();
@@ -735,6 +745,34 @@ class System extends base_1.EmitterBase {
735
745
  }
736
746
  return this.wire.sendAction('get-system-app-configuration', { name }).then(({ payload }) => payload.data);
737
747
  }
748
+ /**
749
+ * Registers a system shutdown handler so user can do some cleanup before system is shutting down.
750
+ * Note: Once system shutdown starts, you are unable to cancel it.
751
+ * @param { SystemShutdownHandler } handler system shutdown handler
752
+ * @return {Promise.<void>}
753
+ * @tutorial System.registerShutdownHandler
754
+ * @experimental
755
+ */
756
+ async registerShutdownHandler(handler) {
757
+ this.wire.sendAction('system-register-shutdown-handler').catch((e) => {
758
+ // don't expose, analytics-only call
759
+ });
760
+ const SystemShutdownEventName = 'system-shutdown';
761
+ const SystemShutdownHandledEventName = 'system-shutdown-handled';
762
+ const { uuid, name } = this.wire.me;
763
+ const shutdownHandler = (payload) => {
764
+ const proceed = () => {
765
+ // notify core that the app is ready for shutdown
766
+ this.wire.environment.raiseEvent(`application/${SystemShutdownHandledEventName}`, {
767
+ uuid,
768
+ name,
769
+ topic: 'application'
770
+ });
771
+ };
772
+ handler({ proceed });
773
+ };
774
+ this.on(SystemShutdownEventName, shutdownHandler);
775
+ }
738
776
  /**
739
777
  * Signals the RVM to perform a health check and returns the results as json.
740
778
  * @return {Promise.<string[]>}
@@ -1,9 +1,8 @@
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
- import { ViewEvent } from '../events/view';
3
+ import { WebContents } from '../webcontents/main';
6
4
  type UpdatableViewOptions = OpenFin.UpdatableViewOptions;
5
+ type ViewEvent = OpenFin.ViewEvent;
7
6
  /**
8
7
  * @PORTED
9
8
  * @typedef {object} View~options
@@ -145,6 +144,9 @@ type UpdatableViewOptions = OpenFin.UpdatableViewOptions;
145
144
  * @property {string} [processAffinity=<application uuid>]
146
145
  * A string to attempt to group renderers together. Will only be used if pages are on the same origin.
147
146
  *
147
+ * @property {boolean} [spellCheck=false]
148
+ * Enable spell check in input text fields for the view.
149
+ *
148
150
  * @property {Identity} [target]
149
151
  * The identity of the window this view should be attached to.
150
152
  *
@@ -172,6 +174,7 @@ type UpdatableViewOptions = OpenFin.UpdatableViewOptions;
172
174
  * @hideconstructor
173
175
  */
174
176
  export declare class View extends WebContents<ViewEvent> {
177
+ #private;
175
178
  identity: OpenFin.Identity;
176
179
  constructor(wire: Transport, identity: OpenFin.Identity);
177
180
  /**
@@ -445,6 +448,12 @@ export declare class View extends WebContents<ViewEvent> {
445
448
  * @experimental
446
449
  */
447
450
  getCurrentWindow: () => Promise<OpenFin.Window>;
451
+ /**
452
+ * Retrieves the current {@link TabStack} of the view if it belongs to one.
453
+ * @return {Promise<TabStack>} The {@link TabStack} this view belongs to.
454
+ * @throws if this view does not belong to a TabStack or if the window has been destroyed.
455
+ */
456
+ getCurrentStack: () => Promise<OpenFin.TabStack>;
448
457
  /**
449
458
  * 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
459
  * Only enabled when setting enableBeforeUnload: true in your View options. If this option is not enabled it will always return false.