@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
@@ -1,5 +1,5 @@
1
1
  import type * as OpenFin from '../../../OpenFin';
2
- import { ChannelProvider } from '../../interappbus/channel/provider';
2
+ type ChannelProvider = OpenFin.ChannelProvider;
3
3
  type HandlerId = string;
4
4
  type ContextType = string;
5
5
  interface PrivateChannelClientState {
@@ -84,16 +84,9 @@ class PrivateChannelProvider {
84
84
  if (contextType) {
85
85
  const currentHandlersList = senderClientState.handlerIdsByContextTypes.get(contextType) || [];
86
86
  senderClientState.handlerIdsByContextTypes.set(contextType, [...currentHandlersList, handlerId]);
87
- const currContext = this.contextByContextType.get(contextType);
88
- if (currContext) {
89
- this.provider.dispatch(senderClientIdentity, handlerId, currContext);
90
- }
91
87
  }
92
88
  else {
93
89
  senderClientState.globalHandler = handlerId;
94
- if (this.lastContext) {
95
- this.provider.dispatch(senderClientIdentity, handlerId, this.lastContext);
96
- }
97
90
  }
98
91
  Array.from(this.clients.values()).forEach((currClientState) => {
99
92
  if (currClientState.clientIdentity.endpointId !== senderClientIdentity.endpointId &&
@@ -271,7 +264,7 @@ class PrivateChannelProvider {
271
264
  const allClientInfo = await this.provider.getAllClientInfo();
272
265
  return Array.from(this.clients.values()).filter((clientState) => {
273
266
  const { uuid, name } = clientState.clientIdentity;
274
- return allClientInfo.some(clientInfo => {
267
+ return allClientInfo.some((clientInfo) => {
275
268
  return name === clientInfo.name && uuid === clientInfo.uuid;
276
269
  });
277
270
  });
@@ -4,6 +4,7 @@ const base_1 = require("../../base");
4
4
  const utils_1 = require("./utils");
5
5
  const utils_2 = require("../utils");
6
6
  const InteropClient_1 = require("../InteropClient");
7
+ const lodash_1 = require("lodash");
7
8
  /**
8
9
  * @typedef { object } Listener
9
10
  * @summary Listener object returned by addContextListener and addIntentListener
@@ -393,7 +394,39 @@ class Fdc3Module extends base_1.Base {
393
394
  return {
394
395
  ...currentContextGroupInfo,
395
396
  type: 'system',
396
- addContextListener: this.addContextListener.bind(this),
397
+ addContextListener: (contextType, handler) => {
398
+ let realHandler;
399
+ let realType;
400
+ if (typeof contextType === 'function') {
401
+ console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
402
+ realHandler = contextType;
403
+ }
404
+ else {
405
+ realHandler = handler;
406
+ if (typeof contextType === 'string') {
407
+ realType = contextType;
408
+ }
409
+ }
410
+ const listener = (async () => {
411
+ let first = true;
412
+ const currentContext = await this.fin.me.interop.getCurrentContext(realType);
413
+ const wrappedHandler = (context, contextMetadata) => {
414
+ if (first) {
415
+ first = false;
416
+ if ((0, lodash_1.isEqual)(currentContext, context)) {
417
+ return;
418
+ }
419
+ }
420
+ // eslint-disable-next-line consistent-return
421
+ return realHandler(context, contextMetadata);
422
+ };
423
+ return this.fin.me.interop.addContextHandler(wrappedHandler, realType);
424
+ })();
425
+ return {
426
+ ...listener,
427
+ unsubscribe: () => listener.then((l) => l.unsubscribe())
428
+ };
429
+ },
397
430
  broadcast: this.broadcast.bind(this),
398
431
  getCurrentContext: async (contextType) => {
399
432
  const context = await this.fin.me.interop.getCurrentContext(contextType);
@@ -171,14 +171,14 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
171
171
  * Find all the available instances for a particular application.
172
172
  * @param { AppIdentifier } app
173
173
  * @returns { Promise<Array<AppIdentifier>> }
174
- * @tutorial findInstances
174
+ * @tutorial fdc3v2.findInstances
175
175
  */
176
176
  findInstances(app: FDC3v2.AppIdentifier): Promise<Array<FDC3v2.AppIdentifier>>;
177
177
  /**
178
178
  * Retrieves the AppMetadata for an AppIdentifier, which provides additional metadata (such as icons, a title and description) from the App Directory record for the application, that may be used for display purposes.
179
179
  * @param { AppIdentifier } app
180
180
  * @returns { Promise<AppMetadata(2)> }
181
- * @tutorial getAppMetadata
181
+ * @tutorial fdc3v2.getAppMetadata
182
182
  */
183
183
  getAppMetadata(app: FDC3v2.AppIdentifier): Promise<FDC3v2.AppMetadata>;
184
184
  /**
@@ -210,7 +210,7 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
210
210
  * @param { Context } context
211
211
  * @param { string } [resultType] The type of result returned for any intent specified during resolution.
212
212
  * @returns { Promise<Array<AppIntent(2)>> }
213
- * @tutorial findIntentsByContext
213
+ * @tutorial fdc3v2.findIntentsByContext
214
214
  */
215
215
  findIntentsByContext(context: FDC3v2.Context, resultType?: string): Promise<Array<FDC3v2.AppIntent>>;
216
216
  /**
@@ -219,7 +219,7 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
219
219
  * @param { Context } context Context associated with the Intent
220
220
  * @param { AppIdentifier | TargetApp } [app]
221
221
  * @returns { Promise<IntentResolution(2)> }
222
- * @tutorial raiseIntent
222
+ * @tutorial fdc3v2.raiseIntent
223
223
  */
224
224
  raiseIntent(intent: string, context: FDC3v2.Context, app?: FDC3v2.AppIdentifier | FDC3v1.TargetApp): Promise<FDC3v2.IntentResolution>;
225
225
  /**
@@ -227,7 +227,7 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
227
227
  * @param { Context } context Context associated with the Intent
228
228
  * @param { AppIdentifier | TargetApp } [app]
229
229
  * @returns { Promise<IntentResolution(2)> }
230
- * @tutorial raiseIntentForContext
230
+ * @tutorial fdc3v2.raiseIntentForContext
231
231
  */
232
232
  raiseIntentForContext(context: FDC3v2.Context, app?: FDC3v2.AppIdentifier | FDC3v1.TargetApp): Promise<FDC3v2.IntentResolution>;
233
233
  /**
@@ -244,17 +244,17 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
244
244
  * @returns { Promise<Channel> }
245
245
  * @tutorial fdc3.getOrCreateChannel
246
246
  */
247
- getOrCreateChannel(channelId: string): Promise<FDC3v1.Channel>;
247
+ getOrCreateChannel(channelId: string): Promise<FDC3v2.Channel>;
248
248
  /**
249
249
  * Returns a Channel with an auto-generated identity that is intended for private communication between applications. Primarily used to create channels that will be returned to other applications via an IntentResolution for a raised intent.
250
250
  * @returns { Promise<PrivateChannel> }
251
- * @tutorial createPrivateChannel
251
+ * @tutorial fdc3v2.createPrivateChannel
252
252
  */
253
253
  createPrivateChannel(): Promise<FDC3v2.PrivateChannel>;
254
254
  /**
255
255
  * Retrieves a list of the User Channels available for the app to join.
256
256
  * @returns { Promise<Channel[]>}
257
- * @tutorial getUserChannels
257
+ * @tutorial fdc3v2.getUserChannels
258
258
  */
259
259
  getUserChannels(): Promise<Array<FDC3v1.SystemChannel>>;
260
260
  /**
@@ -268,7 +268,7 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
268
268
  * Join an app to a specified User channel.
269
269
  * @param { string } channelId Channel name
270
270
  * @returns { Promise<void> }
271
- * @tutorial joinUserChannel
271
+ * @tutorial fdc3v2.joinUserChannel
272
272
  */
273
273
  joinUserChannel(channelId: string): Promise<void>;
274
274
  /**
@@ -282,6 +282,7 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
282
282
  /**
283
283
  * Returns the Channel object for the current User channel membership
284
284
  * @returns { Promise<FDC3.Channel | null> }
285
+ * @tutorial fdc3.getCurrentChannel
285
286
  */
286
287
  getCurrentChannel(): Promise<FDC3v2.Channel | null>;
287
288
  /**
@@ -294,7 +295,7 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
294
295
  * Retrieves information about the FDC3 implementation, including the supported version of the FDC3 specification, the name of the provider of the implementation, its own version number, details of whether optional API features are implemented and the metadata of the calling application according to the desktop agent.
295
296
  * fdc3HandleGetInfo must be overridden in the InteropBroker so that the ImplementationMetadata will have the appMetadata info.
296
297
  * @returns { Promise<ImplementationMetadata(2)> }
297
- * @tutorial getInfo
298
+ * @tutorial fdc3v2.getInfo
298
299
  */
299
300
  getInfo(): Promise<FDC3v2.ImplementationMetadata>;
300
301
  }
@@ -180,7 +180,7 @@ class Fdc3Module2 extends base_1.Base {
180
180
  * Find all the available instances for a particular application.
181
181
  * @param { AppIdentifier } app
182
182
  * @returns { Promise<Array<AppIdentifier>> }
183
- * @tutorial findInstances
183
+ * @tutorial fdc3v2.findInstances
184
184
  */
185
185
  async findInstances(app) {
186
186
  this.wire.sendAction('fdc3-find-instances').catch((e) => {
@@ -198,7 +198,7 @@ class Fdc3Module2 extends base_1.Base {
198
198
  * Retrieves the AppMetadata for an AppIdentifier, which provides additional metadata (such as icons, a title and description) from the App Directory record for the application, that may be used for display purposes.
199
199
  * @param { AppIdentifier } app
200
200
  * @returns { Promise<AppMetadata(2)> }
201
- * @tutorial getAppMetadata
201
+ * @tutorial fdc3v2.getAppMetadata
202
202
  */
203
203
  async getAppMetadata(app) {
204
204
  this.wire.sendAction('fdc3-get-app-metadata').catch((e) => {
@@ -276,7 +276,7 @@ class Fdc3Module2 extends base_1.Base {
276
276
  * @param { Context } context
277
277
  * @param { string } [resultType] The type of result returned for any intent specified during resolution.
278
278
  * @returns { Promise<Array<AppIntent(2)>> }
279
- * @tutorial findIntentsByContext
279
+ * @tutorial fdc3v2.findIntentsByContext
280
280
  */
281
281
  async findIntentsByContext(context, resultType) {
282
282
  this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
@@ -297,7 +297,7 @@ class Fdc3Module2 extends base_1.Base {
297
297
  * @param { Context } context Context associated with the Intent
298
298
  * @param { AppIdentifier | TargetApp } [app]
299
299
  * @returns { Promise<IntentResolution(2)> }
300
- * @tutorial raiseIntent
300
+ * @tutorial fdc3v2.raiseIntent
301
301
  */
302
302
  async raiseIntent(intent, context, app) {
303
303
  this.wire.sendAction('fdc3-raise-intent').catch((e) => {
@@ -316,7 +316,7 @@ class Fdc3Module2 extends base_1.Base {
316
316
  * @param { Context } context Context associated with the Intent
317
317
  * @param { AppIdentifier | TargetApp } [app]
318
318
  * @returns { Promise<IntentResolution(2)> }
319
- * @tutorial raiseIntentForContext
319
+ * @tutorial fdc3v2.raiseIntentForContext
320
320
  */
321
321
  async raiseIntentForContext(context, app) {
322
322
  // TODO: We have to do the same thing we do for raiseIntent here as well.
@@ -384,7 +384,7 @@ class Fdc3Module2 extends base_1.Base {
384
384
  /**
385
385
  * Returns a Channel with an auto-generated identity that is intended for private communication between applications. Primarily used to create channels that will be returned to other applications via an IntentResolution for a raised intent.
386
386
  * @returns { Promise<PrivateChannel> }
387
- * @tutorial createPrivateChannel
387
+ * @tutorial fdc3v2.createPrivateChannel
388
388
  */
389
389
  async createPrivateChannel() {
390
390
  const channelId = (0, utils_1.generateId)();
@@ -396,7 +396,7 @@ class Fdc3Module2 extends base_1.Base {
396
396
  /**
397
397
  * Retrieves a list of the User Channels available for the app to join.
398
398
  * @returns { Promise<Channel[]>}
399
- * @tutorial getUserChannels
399
+ * @tutorial fdc3v2.getUserChannels
400
400
  */
401
401
  async getUserChannels() {
402
402
  const channels = await this.fin.me.interop.getContextGroups();
@@ -420,7 +420,7 @@ class Fdc3Module2 extends base_1.Base {
420
420
  * Join an app to a specified User channel.
421
421
  * @param { string } channelId Channel name
422
422
  * @returns { Promise<void> }
423
- * @tutorial joinUserChannel
423
+ * @tutorial fdc3v2.joinUserChannel
424
424
  */
425
425
  async joinUserChannel(channelId) {
426
426
  return this.fdc3Module.joinChannel(channelId);
@@ -439,6 +439,7 @@ class Fdc3Module2 extends base_1.Base {
439
439
  /**
440
440
  * Returns the Channel object for the current User channel membership
441
441
  * @returns { Promise<FDC3.Channel | null> }
442
+ * @tutorial fdc3.getCurrentChannel
442
443
  */
443
444
  async getCurrentChannel() {
444
445
  const currentChannel = await this.fdc3Module.getCurrentChannel();
@@ -463,7 +464,7 @@ class Fdc3Module2 extends base_1.Base {
463
464
  * Retrieves information about the FDC3 implementation, including the supported version of the FDC3 specification, the name of the provider of the implementation, its own version number, details of whether optional API features are implemented and the metadata of the calling application according to the desktop agent.
464
465
  * fdc3HandleGetInfo must be overridden in the InteropBroker so that the ImplementationMetadata will have the appMetadata info.
465
466
  * @returns { Promise<ImplementationMetadata(2)> }
466
- * @tutorial getInfo
467
+ * @tutorial fdc3v2.getInfo
467
468
  */
468
469
  async getInfo() {
469
470
  return InteropClient_1.InteropClient.ferryFdc3Call(this.fin.me.interop, 'fdc3v2GetInfo', { fdc3Version: '2.0' });
@@ -64,7 +64,7 @@ export interface DesktopAgent {
64
64
  addContextListener(contextType: string | null, handler: ContextHandler): Promise<Listener>;
65
65
  getUserChannels(): Promise<Array<SystemChannel>>;
66
66
  joinUserChannel(channelId: string): Promise<void>;
67
- getOrCreateChannel(channelId: string): Promise<ChannelV1>;
67
+ getOrCreateChannel(channelId: string): Promise<Channel>;
68
68
  createPrivateChannel(): Promise<PrivateChannel>;
69
69
  getCurrentChannel(): Promise<ChannelV1 | null>;
70
70
  leaveCurrentChannel(): Promise<void>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildAppChannelObject = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  const PrivateChannelClient_1 = require("./PrivateChannelClient");
6
+ const lodash_1 = require("lodash");
6
7
  const getUnsupportedChannelApis = (channelType) => {
7
8
  return {
8
9
  addContextListener: () => {
@@ -111,14 +112,33 @@ const buildAppChannelObject = (sessionContextGroup) => {
111
112
  return context === undefined ? null : context;
112
113
  },
113
114
  addContextListener: (contextType, handler) => {
114
- let listener;
115
+ let realHandler;
116
+ let realType;
115
117
  if (typeof contextType === 'function') {
116
118
  console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
117
- listener = sessionContextGroup.addContextHandler(contextType);
119
+ realHandler = contextType;
118
120
  }
119
121
  else {
120
- listener = sessionContextGroup.addContextHandler(handler, contextType === null ? undefined : contextType);
122
+ realHandler = handler;
123
+ if (typeof contextType === 'string') {
124
+ realType = contextType;
125
+ }
121
126
  }
127
+ const listener = (async () => {
128
+ let first = true;
129
+ const currentContext = await sessionContextGroup.getCurrentContext(realType);
130
+ const wrappedHandler = (context, contextMetadata) => {
131
+ if (first) {
132
+ first = false;
133
+ if ((0, lodash_1.isEqual)(currentContext, context)) {
134
+ return;
135
+ }
136
+ }
137
+ // eslint-disable-next-line consistent-return
138
+ return realHandler(context, contextMetadata);
139
+ };
140
+ return sessionContextGroup.addContextHandler(wrappedHandler, realType);
141
+ })();
122
142
  return {
123
143
  ...listener,
124
144
  unsubscribe: () => listener.then((l) => l.unsubscribe())
@@ -149,7 +169,7 @@ exports.isContext = isContext;
149
169
  const isChannel = (channel) => {
150
170
  if (channel && typeof channel === 'object' && 'type' in channel && 'id' in channel) {
151
171
  const { type, id } = channel;
152
- return (typeof type === 'string' && typeof id === 'string' && (type === 'app' || type === 'private'));
172
+ return typeof type === 'string' && typeof id === 'string' && (type === 'app' || type === 'private');
153
173
  }
154
174
  return false;
155
175
  };
@@ -1,8 +1,8 @@
1
1
  import type * as OpenFin from '../../OpenFin';
2
2
  import { Base } from '../base';
3
- import { Channel } from '../interappbus/channel/index';
4
3
  import { Transport } from '../../transport/transport';
5
4
  import { LayoutModule } from './layout/index';
5
+ type Channel = OpenFin.Fin['InterApplicationBus']['Channel'];
6
6
  /**
7
7
  * @PORTED
8
8
  * InitPlatformOptions interface
@@ -113,3 +113,4 @@ export default class PlatformModule extends Base {
113
113
  */
114
114
  startFromManifest(manifestUrl: string, opts?: OpenFin.RvmLaunchOptions): Promise<OpenFin.Platform>;
115
115
  }
116
+ export {};
@@ -152,8 +152,7 @@ class PlatformModule extends base_1.Base {
152
152
  // TODO: fix typing (internal)
153
153
  // @ts-expect-error
154
154
  app.once('platform-api-ready', () => resolve(this.wrapSync({ uuid })));
155
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
156
- // @ts-ignore using private variable.
155
+ // @ts-expect-error using private variable.
157
156
  app._run({ uuid });
158
157
  }
159
158
  catch (e) {
@@ -177,13 +176,11 @@ class PlatformModule extends base_1.Base {
177
176
  // eslint-disable-next-line no-async-promise-executor
178
177
  return new Promise(async (resolve, reject) => {
179
178
  try {
180
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
181
179
  // @ts-expect-error using private variable.
182
180
  const app = await this.fin.Application._createFromManifest(manifestUrl);
183
181
  // TODO: fix typing (internal)
184
182
  // @ts-expect-error
185
183
  app.once('platform-api-ready', () => resolve(this.wrapSync({ uuid: app.identity.uuid })));
186
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
187
184
  // @ts-expect-error using private method without warning.
188
185
  app._run(opts);
189
186
  }
@@ -1,9 +1,9 @@
1
1
  import type * as OpenFin from '../../OpenFin';
2
- import { View } from '../view';
3
2
  import { EmitterBase } from '../base';
4
- import { Channel } from '../interappbus/channel/index';
5
- import ChannelClient from '../interappbus/channel/client';
6
- import { LayoutModule } from './layout';
3
+ type View = OpenFin.View;
4
+ type Channel = OpenFin.Fin['InterApplicationBus']['Channel'];
5
+ type ChannelClient = OpenFin.ChannelClient;
6
+ type LayoutModule = OpenFin.Fin['Platform']['Layout'];
7
7
  /** Manages the life cycle of windows and views in the application.
8
8
  *
9
9
  * Enables taking snapshots of itself and applyi
@@ -27,7 +27,7 @@ export declare class Platform extends EmitterBase<OpenFin.PlatformEvent> {
27
27
  * @return { Promise<View> }
28
28
  * @tutorial Platform.createView
29
29
  */
30
- createView(viewOptions: OpenFin.PlatformViewCreationOptions, target?: OpenFin.Identity, targetView?: OpenFin.Identity): Promise<View>;
30
+ createView(viewOptions: OpenFin.PlatformViewCreationOptions, target?: OpenFin.CreateViewTarget, targetView?: OpenFin.Identity): Promise<View>;
31
31
  /**
32
32
  * Creates a new Window.
33
33
  * @param { Window~options } options Window creation options
@@ -147,3 +147,4 @@ export declare class Platform extends EmitterBase<OpenFin.PlatformEvent> {
147
147
  skipBeforeUnload: boolean;
148
148
  }): Promise<void>;
149
149
  }
150
+ export {};
@@ -7,6 +7,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
7
7
  var _Platform_connectToProvider;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.Platform = void 0;
10
+ /* eslint-disable import/prefer-default-export, no-undef */
10
11
  const base_1 = require("../base");
11
12
  const validate_1 = require("../../util/validate");
12
13
  // Reuse clients to avoid overwriting already-registered client in provider
@@ -10,7 +10,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
11
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
12
  };
13
- var _LayoutModule_layoutManager;
13
+ var _LayoutModule_layoutManager, _LayoutModule_layoutInitializationAttempted;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.LayoutModule = void 0;
16
16
  /* eslint-disable no-undef, import/prefer-default-export */
@@ -19,6 +19,10 @@ const Instance_1 = require("./Instance");
19
19
  const base_1 = require("../../base");
20
20
  const splitter_controller_1 = require("./controllers/splitter-controller");
21
21
  const view_overlay_1 = require("./utils/view-overlay");
22
+ const api_exposer_1 = require("../../api-exposer");
23
+ const layout_entities_controller_1 = require("./controllers/layout-entities-controller");
24
+ const layout_constants_1 = require("./layout.constants");
25
+ const layout_content_cache_1 = require("./controllers/layout-content-cache");
22
26
  /**
23
27
  * @PORTED
24
28
  * InitLayoutOptions interface
@@ -87,6 +91,7 @@ class LayoutModule extends base_1.Base {
87
91
  constructor() {
88
92
  super(...arguments);
89
93
  _LayoutModule_layoutManager.set(this, void 0);
94
+ _LayoutModule_layoutInitializationAttempted.set(this, false);
90
95
  /**
91
96
  * Initialize the window's Layout. Must be called from a custom window that has a 'layout' option set upon creation of that window.
92
97
  * If a containerId is not provided, this method attempts to find an element with the id `layout-container`.
@@ -105,15 +110,17 @@ class LayoutModule extends base_1.Base {
105
110
  if (!this.fin.me.isWindow) {
106
111
  throw new Error('Layout.init can only be called from a Window context.');
107
112
  }
108
- else if (__classPrivateFieldGet(this, _LayoutModule_layoutManager, "f")) {
113
+ else if (__classPrivateFieldGet(this, _LayoutModule_layoutInitializationAttempted, "f")) {
109
114
  throw new Error('Layout for this window already initialized, please use Layout.replace call to replace the layout.');
110
115
  }
116
+ __classPrivateFieldSet(this, _LayoutModule_layoutInitializationAttempted, true, "f");
111
117
  // We need to go through environment to make sure it is only imported/bundled in OpenFin.
112
118
  const ManagerConstructor = await this.wire.environment.getManagerConstructor();
113
119
  const viewOverlay = new view_overlay_1.ViewOverlay(this.wire);
114
120
  const splitterController = new splitter_controller_1.SplitterController(viewOverlay);
115
121
  const tabDragController = new tab_drag_controller_1.TabDragController(viewOverlay);
116
- __classPrivateFieldSet(this, _LayoutModule_layoutManager, new ManagerConstructor(splitterController, tabDragController), "f");
122
+ const contentItemCache = new layout_content_cache_1.LayoutContentCache();
123
+ __classPrivateFieldSet(this, _LayoutModule_layoutManager, new ManagerConstructor(splitterController, tabDragController, contentItemCache), "f");
117
124
  // @ts-expect-error - layout warning here for backwards compatibility, can remove layout check in .52
118
125
  let { layout, containerId } = options;
119
126
  if (layout) {
@@ -128,6 +135,10 @@ class LayoutModule extends base_1.Base {
128
135
  // pull createChannelConnection out of LayoutManager and setup channel connections here using layoutmanager instance methods?
129
136
  await __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f").initManager();
130
137
  await __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f").createLayout(layout, container);
138
+ const { client, ofWindow } = ManagerConstructor.getClientAndWindow(__classPrivateFieldGet(this, _LayoutModule_layoutManager, "f"));
139
+ // expose LayoutEntitiesController instance for API consumption
140
+ const channelStrategy = new api_exposer_1.ChannelsExposer(client);
141
+ await new api_exposer_1.ApiExposer(channelStrategy).exposeInstance(new layout_entities_controller_1.LayoutEntitiesController(__classPrivateFieldGet(this, _LayoutModule_layoutManager, "f"), contentItemCache), { id: layout_constants_1.LAYOUT_CONTROLLER_ID });
131
142
  // Adding this to the returned instance undocumented/typed for Browser.
132
143
  return Object.assign(this.getCurrentSync(), { layoutManager: __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f") });
133
144
  };
@@ -194,4 +205,4 @@ class LayoutModule extends base_1.Base {
194
205
  }
195
206
  }
196
207
  exports.LayoutModule = LayoutModule;
197
- _LayoutModule_layoutManager = new WeakMap();
208
+ _LayoutModule_layoutManager = new WeakMap(), _LayoutModule_layoutInitializationAttempted = new WeakMap();
@@ -8,6 +8,7 @@ type PresetLayoutOptions = OpenFin.PresetLayoutOptions;
8
8
  * @lends Platform#Layout
9
9
  */
10
10
  export declare class Layout extends Base {
11
+ #private;
11
12
  init: (options?: InitLayoutOptions) => Promise<Layout>;
12
13
  identity: Identity;
13
14
  private platform;
@@ -19,6 +20,11 @@ export declare class Layout extends Base {
19
20
  * @tutorial Layout.getConfig
20
21
  */
21
22
  getConfig(): Promise<any>;
23
+ /**
24
+ * Retrieves the top level content item of the layout.
25
+ * @return {Promise<TabStack | ColumnOrRow>}
26
+ */
27
+ getRootItem(): Promise<OpenFin.ColumnOrRow | OpenFin.TabStack>;
22
28
  /**
23
29
  * Replaces a Platform window's layout with a new layout. Any views that were in the old layout but not the new layout
24
30
  * will be destroyed.
@@ -1,9 +1,18 @@
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 _Layout_layoutClient;
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.Layout = void 0;
10
+ const lazy_1 = require("../../../util/lazy");
4
11
  const validate_1 = require("../../../util/validate");
5
- const common_utils_1 = require("../common-utils");
6
12
  const base_1 = require("../../base");
13
+ const common_utils_1 = require("../common-utils");
14
+ const layout_entities_1 = require("./entities/layout-entities");
15
+ const layout_constants_1 = require("./layout.constants");
7
16
  /**
8
17
  * @lends Platform#Layout
9
18
  */
@@ -11,6 +20,12 @@ class Layout extends base_1.Base {
11
20
  // eslint-disable-next-line no-shadow
12
21
  constructor(identity, wire) {
13
22
  super(wire);
23
+ /**
24
+ * @internal
25
+ * Lazily constructed {@link LayoutEntitiesClient} bound to this platform's client and identity
26
+ * The client is for {@link LayoutEntitiesController}
27
+ */
28
+ _Layout_layoutClient.set(this, new lazy_1.Lazy(async () => layout_entities_1.LayoutNode.newLayoutEntitiesClient(await this.platform.getClient(), layout_constants_1.LAYOUT_CONTROLLER_ID, this.identity)));
14
29
  /**
15
30
  * Replaces a Platform window's layout with a new layout. Any views that were in the old layout but not the new layout
16
31
  * will be destroyed.
@@ -94,5 +109,18 @@ class Layout extends base_1.Base {
94
109
  target: this.identity
95
110
  });
96
111
  }
112
+ /**
113
+ * Retrieves the top level content item of the layout.
114
+ * @return {Promise<TabStack | ColumnOrRow>}
115
+ */
116
+ async getRootItem() {
117
+ this.wire.sendAction('layout-get-root-item').catch(() => {
118
+ // don't expose
119
+ });
120
+ const client = await __classPrivateFieldGet(this, _Layout_layoutClient, "f").getValue();
121
+ const root = await client.getRoot();
122
+ return layout_entities_1.LayoutNode.getEntity(root, client);
123
+ }
97
124
  }
98
125
  exports.Layout = Layout;
126
+ _Layout_layoutClient = new WeakMap();
@@ -0,0 +1,9 @@
1
+ export declare class LayoutContentCache {
2
+ private contentItemCache;
3
+ private contentItemCacheId;
4
+ private createCacheKey;
5
+ hasKey: (id: string) => boolean;
6
+ getItemOrUndefined: (id: string) => GoldenLayout.ContentItem | undefined;
7
+ getContentItemOrThrow: (id: string, expectedType?: string[]) => GoldenLayout.ContentItem;
8
+ getOrCreateEntityId: (contentItem: GoldenLayout.ContentItem) => string;
9
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LayoutContentCache = void 0;
4
+ const reversible_map_1 = require("../../../../util/reversible-map");
5
+ class LayoutContentCache {
6
+ constructor() {
7
+ // ContentItems currently do not have a unique id, this helps us to lookup items by value
8
+ this.contentItemCache = new reversible_map_1.ReversibleMap();
9
+ this.contentItemCacheId = 0;
10
+ this.createCacheKey = () => {
11
+ const key = `entity-${this.contentItemCacheId.toString()}`;
12
+ this.contentItemCacheId += 1;
13
+ return key;
14
+ };
15
+ this.hasKey = (id) => {
16
+ return this.contentItemCache.hasKey(id);
17
+ };
18
+ this.getItemOrUndefined = (id) => {
19
+ try {
20
+ return this.getContentItemOrThrow(id);
21
+ }
22
+ catch (error) {
23
+ return undefined;
24
+ }
25
+ };
26
+ this.getContentItemOrThrow = (id, expectedType) => {
27
+ if (!this.contentItemCache.hasKey(id)) {
28
+ throw new Error('Layout component has been destroyed or detached from the current layout.');
29
+ }
30
+ const contentItem = this.contentItemCache.getValue(id);
31
+ if (expectedType && !expectedType.includes(contentItem.type)) {
32
+ throw new Error(`Layout item is not the expected type. Expected ${expectedType.join(', ')}, got ${contentItem.type}.`);
33
+ }
34
+ return contentItem;
35
+ };
36
+ this.getOrCreateEntityId = (contentItem) => {
37
+ if (this.contentItemCache.hasValue(contentItem)) {
38
+ return this.contentItemCache.getKey(contentItem);
39
+ }
40
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41
+ const onItemDestroyed = ({ origin, ...rest }) => {
42
+ if (origin === contentItem) {
43
+ this.contentItemCache.deleteValue(contentItem);
44
+ contentItem.unbind('itemDestroyed', onItemDestroyed);
45
+ }
46
+ };
47
+ contentItem.on('itemDestroyed', onItemDestroyed);
48
+ const key = this.createCacheKey();
49
+ this.contentItemCache.setUnique(key, contentItem);
50
+ return key;
51
+ };
52
+ }
53
+ }
54
+ exports.LayoutContentCache = LayoutContentCache;