@openfin/core 31.74.9 → 31.74.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.
Files changed (90) hide show
  1. package/package.json +1 -1
  2. package/src/OpenFin.d.ts +79 -17
  3. package/src/api/api-exposer/api-consumer.d.ts +28 -0
  4. package/src/api/api-exposer/api-consumer.js +28 -0
  5. package/src/api/api-exposer/api-exposer.d.ts +35 -0
  6. package/src/api/api-exposer/api-exposer.js +38 -0
  7. package/src/api/api-exposer/decorators.d.ts +10 -0
  8. package/src/api/api-exposer/decorators.js +18 -0
  9. package/src/api/api-exposer/index.d.ts +4 -0
  10. package/src/api/api-exposer/index.js +20 -0
  11. package/src/api/api-exposer/strategies/index.d.ts +1 -0
  12. package/src/api/api-exposer/strategies/index.js +17 -0
  13. package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.d.ts +14 -0
  14. package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.js +20 -0
  15. package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.d.ts +20 -0
  16. package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.js +23 -0
  17. package/src/api/api-exposer/strategies/openfin-channels/index.d.ts +2 -0
  18. package/src/api/api-exposer/strategies/openfin-channels/index.js +18 -0
  19. package/src/api/application/Factory.js +1 -2
  20. package/src/api/application/Instance.js +23 -5
  21. package/src/api/base.d.ts +1 -2
  22. package/src/api/base.js +1 -2
  23. package/src/api/events/base.d.ts +0 -3
  24. package/src/api/events/system.d.ts +2 -2
  25. package/src/api/events/view.d.ts +6 -3
  26. package/src/api/events/webcontents.d.ts +2 -0
  27. package/src/api/events/window.d.ts +21 -13
  28. package/src/api/fin.js +1 -2
  29. package/src/api/interappbus/channel/protocols/classic/strategy.js +24 -6
  30. package/src/api/interappbus/index.js +1 -1
  31. package/src/api/interop/InteropBroker.js +6 -2
  32. package/src/api/interop/SessionContextGroupBroker.d.ts +1 -1
  33. package/src/api/interop/SessionContextGroupBroker.js +5 -4
  34. package/src/api/interop/SessionContextGroupClient.js +1 -1
  35. package/src/api/interop/fdc3/PrivateChannelClient.d.ts +1 -0
  36. package/src/api/interop/fdc3/PrivateChannelClient.js +15 -7
  37. package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +16 -2
  38. package/src/api/interop/fdc3/PrivateChannelProvider.js +80 -28
  39. package/src/api/interop/fdc3/fdc3-1.2.js +53 -5
  40. package/src/api/interop/fdc3/fdc3-2.0.d.ts +11 -10
  41. package/src/api/interop/fdc3/fdc3-2.0.js +18 -19
  42. package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +1 -1
  43. package/src/api/interop/fdc3/utils.d.ts +17 -0
  44. package/src/api/interop/fdc3/utils.js +75 -21
  45. package/src/api/platform/Factory.d.ts +2 -1
  46. package/src/api/platform/Factory.js +5 -9
  47. package/src/api/platform/Instance.d.ts +6 -5
  48. package/src/api/platform/Instance.js +1 -0
  49. package/src/api/platform/layout/Factory.js +16 -6
  50. package/src/api/platform/layout/Instance.d.ts +6 -0
  51. package/src/api/platform/layout/Instance.js +29 -1
  52. package/src/api/platform/layout/controllers/layout-content-cache.d.ts +9 -0
  53. package/src/api/platform/layout/controllers/layout-content-cache.js +54 -0
  54. package/src/api/platform/layout/controllers/layout-entities-controller.d.ts +119 -0
  55. package/src/api/platform/layout/controllers/layout-entities-controller.js +287 -0
  56. package/src/api/platform/layout/controllers/tab-drag-controller.d.ts +2 -1
  57. package/src/api/platform/layout/entities/layout-entities.d.ts +144 -0
  58. package/src/api/platform/layout/entities/layout-entities.js +216 -0
  59. package/src/api/platform/layout/entities/shapes.d.ts +6 -0
  60. package/src/api/platform/layout/entities/shapes.js +2 -0
  61. package/src/api/platform/layout/layout.constants.d.ts +1 -0
  62. package/src/api/platform/layout/layout.constants.js +4 -0
  63. package/src/api/platform/layout/shapes.d.ts +3 -0
  64. package/src/api/platform/layout/utils/layout-traversal.d.ts +4 -0
  65. package/src/api/platform/layout/utils/layout-traversal.js +65 -0
  66. package/src/api/platform/provider.d.ts +2 -1
  67. package/src/api/system/index.js +3 -2
  68. package/src/api/view/Instance.d.ts +16 -3
  69. package/src/api/view/Instance.js +47 -4
  70. package/src/api/webcontents/main.d.ts +1 -22
  71. package/src/api/window/Instance.d.ts +3 -0
  72. package/src/api/window/Instance.js +3 -0
  73. package/src/mock.d.ts +1 -1
  74. package/src/mock.js +2 -2
  75. package/src/transport/transport-errors.d.ts +9 -1
  76. package/src/transport/transport-errors.js +45 -2
  77. package/src/transport/transport.d.ts +13 -5
  78. package/src/transport/transport.js +38 -19
  79. package/src/util/channel-api-relay.d.ts +13 -0
  80. package/src/util/channel-api-relay.js +47 -0
  81. package/src/util/errors.d.ts +1 -0
  82. package/src/util/errors.js +1 -0
  83. package/src/util/lazy.d.ts +16 -0
  84. package/src/util/lazy.js +26 -0
  85. package/src/util/ref-counter.d.ts +1 -1
  86. package/src/util/ref-counter.js +3 -2
  87. package/src/util/reversible-map.d.ts +11 -0
  88. package/src/util/reversible-map.js +49 -0
  89. package/src/transport/fin_store.d.ts +0 -4
  90. package/src/transport/fin_store.js +0 -16
@@ -0,0 +1,216 @@
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 edge
78
+ * @returns an array of {@link TabStack} found, if none found returns an empty array.
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
+ /**
175
+ * Sets the active view of the {@link TabStack} without focusing it.
176
+ * @param view {@link OpenFin.Identity Identity} of the view to activate.
177
+ * @returns Promise which resolves with void once the view has been activated.
178
+ * @throws If the {@link TabStack} has been destroyed.
179
+ * @throws If the view does not exist.
180
+ * @tutorial TabStack.setActiveView
181
+ * @experimental
182
+ */
183
+ this.setActiveView = async (view) => {
184
+ await __classPrivateFieldGet(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
185
+ };
186
+ __classPrivateFieldSet(this, _TabStack_client, client, "f");
187
+ }
188
+ }
189
+ exports.TabStack = TabStack;
190
+ _TabStack_client = new WeakMap();
191
+ /**
192
+ * A {@link ColumnOrRow} is used to manage the state of a ColumnOrRow within an OpenFin Layout.
193
+ */
194
+ class ColumnOrRow extends LayoutNode {
195
+ /** @internal */
196
+ constructor(client, entityId, type) {
197
+ super(client, entityId);
198
+ /**
199
+ * @internal
200
+ * ApiClient for {@link LayoutEntitiesController}
201
+ */
202
+ _ColumnOrRow_client.set(this, void 0);
203
+ /**
204
+ * Retrieves a list of all content items belonging to this {@link ColumnOrRow} in order of appearance.
205
+ * @returns Resolves with a list containing {@link ColumnOrRow} and {@link TabStack} items belonging to this {@link ColumnOrRow}.
206
+ */
207
+ this.getContent = async () => {
208
+ const contentItemEntities = await __classPrivateFieldGet(this, _ColumnOrRow_client, "f").getContent(this.entityId);
209
+ return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet(this, _ColumnOrRow_client, "f")));
210
+ };
211
+ __classPrivateFieldSet(this, _ColumnOrRow_client, client, "f");
212
+ this.type = type;
213
+ }
214
+ }
215
+ exports.ColumnOrRow = ColumnOrRow;
216
+ _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: (a: GoldenLayout.ContentItem, b: 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 = (a, b, edge) => {
22
+ var _a, _b;
23
+ const boundsA = (_a = a.element.get(0)) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
24
+ const boundsB = (_b = b.element.get(0)) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
25
+ if (!boundsA || !boundsB) {
26
+ return false;
27
+ }
28
+ if (['top', 'bottom'].includes(edge)) {
29
+ return ((boundsB.left >= boundsA.left && boundsB.left < boundsA.right) ||
30
+ (boundsB.right > boundsA.left && boundsB.right <= boundsA.right));
31
+ }
32
+ return ((boundsB.top >= boundsA.top && boundsB.top < boundsA.bottom) ||
33
+ (boundsB.bottom > boundsA.top && boundsB.bottom <= boundsA.bottom));
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 {};
@@ -538,7 +538,7 @@ class System extends base_1.EmitterBase {
538
538
  const dlError = (payload) => {
539
539
  cleanListeners();
540
540
  const { reason, err: error } = payload;
541
- reject(new transport_errors_1.RuntimeError({ reason, error }));
541
+ reject(new transport_errors_1.RuntimeError({ reason, error }, transport_errors_1.RuntimeError.getCallSite(3)));
542
542
  };
543
543
  const dlComplete = () => {
544
544
  cleanListeners();
@@ -568,6 +568,7 @@ class System extends base_1.EmitterBase {
568
568
  * @tutorial System.downloadRuntime
569
569
  */
570
570
  downloadRuntime(options, progressListener) {
571
+ const callsites = transport_errors_1.RuntimeError.getCallSite();
571
572
  return new Promise((resolve, reject) => {
572
573
  // node.js environment not supported
573
574
  if (this.wire.environment.constructor.name === 'NodeEnvironment') {
@@ -593,7 +594,7 @@ class System extends base_1.EmitterBase {
593
594
  const dlError = (payload) => {
594
595
  cleanListeners();
595
596
  const { reason, err: error } = payload;
596
- reject(new transport_errors_1.RuntimeError({ reason, error }));
597
+ reject(new transport_errors_1.RuntimeError({ reason, error }, callsites));
597
598
  };
598
599
  const dlComplete = () => {
599
600
  cleanListeners();
@@ -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.
@@ -457,6 +466,10 @@ export declare class View extends WebContents<ViewEvent> {
457
466
  * **NOTE**: Internal use only.
458
467
  * Attaches this view to an HTML element in the current context. The view will resize responsively when the element bounds change.
459
468
  *
469
+ * **Known issue**: View.bindToElement does not track position changes, if the element has fixed px width and height values it is possible for the view to not update responsively.
470
+ *
471
+ * **Known issue**: When View.bindToElement is used on a element that takes up the entire page in a platform window, the bound view will not respond responsively when the window is resized to be smaller.
472
+ *
460
473
  * @param {HTMLElement} element - HTML element to attach the view to.
461
474
  * @return {Function} - Cleanup function that will disconnect the element resize observer.
462
475
  * @internal
@@ -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
- /* eslint-disable import/prefer-default-export */
5
- /* eslint-disable consistent-return */
6
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
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
@@ -148,6 +155,9 @@ const bounds_observer_1 = require("../platform/layout/utils/bounds-observer");
148
155
  * @property {string} [processAffinity=<application uuid>]
149
156
  * A string to attempt to group renderers together. Will only be used if pages are on the same origin.
150
157
  *
158
+ * @property {boolean} [spellCheck=false]
159
+ * Enable spell check in input text fields for the view.
160
+ *
151
161
  * @property {Identity} [target]
152
162
  * The identity of the window this view should be attached to.
153
163
  *
@@ -178,6 +188,10 @@ class View extends main_1.WebContents {
178
188
  constructor(wire, identity) {
179
189
  super(wire, identity, 'view');
180
190
  this.identity = identity;
191
+ _View_providerChannelClient.set(this, new lazy_1.Lazy(() => {
192
+ const platform = this.fin.Platform.wrapSync(this.identity);
193
+ return platform.getClient();
194
+ }));
181
195
  /**
182
196
  * Returns the zoom level of the view.
183
197
  * @function getZoomLevel
@@ -446,6 +460,30 @@ class View extends main_1.WebContents {
446
460
  const { payload: { data } } = await this.wire.sendAction('get-view-window', { ...this.identity });
447
461
  return new window_1._Window(this.wire, data);
448
462
  };
463
+ /**
464
+ * Retrieves the current {@link TabStack} of the view if it belongs to one.
465
+ * @return {Promise<TabStack>} The {@link TabStack} this view belongs to.
466
+ * @throws if this view does not belong to a TabStack or if the window has been destroyed.
467
+ */
468
+ this.getCurrentStack = async () => {
469
+ this.wire.sendAction('view-get-current-stack').catch(() => {
470
+ // don't expose
471
+ });
472
+ try {
473
+ const layoutWindow = await this.getCurrentWindow();
474
+ const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
475
+ const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindow.identity);
476
+ const stackDefinition = (await client.getStackByView(this.identity));
477
+ return layout_entities_1.LayoutNode.getEntity(stackDefinition, client);
478
+ }
479
+ catch (error) {
480
+ const e = new transport_errors_1.RuntimeError({ reason: 'This view does not belong to a stack.' });
481
+ // TODO: @pierre to fix
482
+ // @ts-expect-error pending PR !3459 to fix runtime errors
483
+ e.cause = error;
484
+ throw e;
485
+ }
486
+ };
449
487
  /**
450
488
  * 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
489
  * Only enabled when setting enableBeforeUnload: true in your View options. If this option is not enabled it will always return false.
@@ -461,6 +499,10 @@ class View extends main_1.WebContents {
461
499
  * **NOTE**: Internal use only.
462
500
  * Attaches this view to an HTML element in the current context. The view will resize responsively when the element bounds change.
463
501
  *
502
+ * **Known issue**: View.bindToElement does not track position changes, if the element has fixed px width and height values it is possible for the view to not update responsively.
503
+ *
504
+ * **Known issue**: When View.bindToElement is used on a element that takes up the entire page in a platform window, the bound view will not respond responsively when the window is resized to be smaller.
505
+ *
464
506
  * @param {HTMLElement} element - HTML element to attach the view to.
465
507
  * @return {Function} - Cleanup function that will disconnect the element resize observer.
466
508
  * @internal
@@ -511,3 +553,4 @@ class View extends main_1.WebContents {
511
553
  }
512
554
  }
513
555
  exports.View = View;
556
+ _View_providerChannelClient = new WeakMap();
@@ -2,31 +2,10 @@ import type * as OpenFin from '../../OpenFin';
2
2
  import { EmitterBase } from '../base';
3
3
  import { Transport } from '../../transport/transport';
4
4
  import { BaseEvent } from '../events/base';
5
- /**
6
- * Configuration for page capture.
7
- */
8
- export interface CapturePageOptions {
9
- /**
10
- * The area of the window to be captured.
11
- */
12
- area?: OpenFin.Rectangle;
13
- /**
14
- * @defaultValue 'png'
15
- *
16
- * The format of the captured image. Can be 'png', 'jpg', or 'bmp'.
17
- */
18
- format?: 'bmp' | 'jpg' | 'png';
19
- /**
20
- * @defaultValue 100
21
- *
22
- * Quality of JPEG image. Between 0 - 100.
23
- */
24
- quality?: number;
25
- }
26
5
  export declare class WebContents<T extends BaseEvent> extends EmitterBase<T> {
27
6
  entityType: string;
28
7
  constructor(wire: Transport, identity: OpenFin.Identity, entityType: string);
29
- capturePage(options?: CapturePageOptions): Promise<string>;
8
+ capturePage(options?: OpenFin.CapturePageOptions): Promise<string>;
30
9
  executeJavaScript(code: string): Promise<void>;
31
10
  getZoomLevel(): Promise<number>;
32
11
  setZoomLevel(level: number): Promise<void>;
@@ -334,6 +334,9 @@ import { WebContents } from '../webcontents/main';
334
334
  * _Note: Caveats of small windows are no Aero Snap and drag to/from maximize._
335
335
  * _Windows 10: Requires `maximizable` to be false. Resizing with the mouse is only possible down to 38x39 px._
336
336
  *
337
+ * @property {boolean} [spellCheck=false]
338
+ * Enable spell check in input text fields for the window.
339
+ *
337
340
  * @property {string} [state="normal"]
338
341
  * The visible state of the window on creation.
339
342
  * One of:
@@ -341,6 +341,9 @@ const view_1 = require("../view");
341
341
  * _Note: Caveats of small windows are no Aero Snap and drag to/from maximize._
342
342
  * _Windows 10: Requires `maximizable` to be false. Resizing with the mouse is only possible down to 38x39 px._
343
343
  *
344
+ * @property {boolean} [spellCheck=false]
345
+ * Enable spell check in input text fields for the window.
346
+ *
344
347
  * @property {string} [state="normal"]
345
348
  * The visible state of the window on creation.
346
349
  * One of:
package/src/mock.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type * as OpenFin from './OpenFin';
1
+ import * as OpenFin from './OpenFin';
2
2
  export declare const fin: OpenFin.Fin<"window" | "view">;
3
3
  export default OpenFin;
package/src/mock.js CHANGED
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fin = void 0;
4
- const events_1 = require("events");
5
4
  /* eslint-disable import/prefer-default-export */
6
5
  /* eslint-disable spaced-comment */
7
6
  /* eslint-disable @typescript-eslint/triple-slash-reference */
8
7
  /* eslint-disable @typescript-eslint/explicit-function-return-type */
9
8
  /* eslint-disable class-methods-use-this */
10
- /// <reference path="../OpenFin.d.ts"/>
9
+ const events_1 = require("events");
10
+ const OpenFin = require("./OpenFin");
11
11
  const fin_1 = require("./api/fin");
12
12
  const transport_1 = require("./transport/transport");
13
13
  const me_1 = require("./api/me");
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { ErrorPlainObject } from '../util/errors';
2
3
  export type ReadyState = 'CONNECTING' | 'OPEN' | 'CLOSING' | 'CLOSED';
3
4
  export declare class DisconnectedError extends Error {
@@ -18,6 +19,13 @@ export type RuntimeErrorPayload = {
18
19
  reason: string;
19
20
  error?: ErrorPlainObject;
20
21
  };
22
+ declare class InternalError<T extends ErrorPlainObject = ErrorPlainObject> extends Error {
23
+ constructor(err: T);
24
+ }
21
25
  export declare class RuntimeError extends Error {
22
- constructor(payload: RuntimeErrorPayload);
26
+ internalError?: InternalError;
27
+ static getCallSite(callsToRemove?: number): NodeJS.CallSite[];
28
+ static prepareStackTrace(err: Error, callSites: NodeJS.CallSite[]): string;
29
+ constructor(payload: RuntimeErrorPayload, callSites?: NodeJS.CallSite[]);
23
30
  }
31
+ export {};