@openfin/core 31.75.1 → 32.75.2

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 (37) hide show
  1. package/package.json +1 -1
  2. package/src/OpenFin.d.ts +4 -2
  3. package/src/api/application/Instance.d.ts +13 -1
  4. package/src/api/application/Instance.js +21 -7
  5. package/src/api/events/application.d.ts +4 -1
  6. package/src/api/events/webcontents.d.ts +54 -5
  7. package/src/api/interappbus/channel/client.d.ts +2 -2
  8. package/src/api/interappbus/channel/index.d.ts +4 -4
  9. package/src/api/interappbus/channel/index.js +94 -57
  10. package/src/api/interappbus/channel/provider.d.ts +2 -3
  11. package/src/api/me.d.ts +1 -1
  12. package/src/api/me.js +2 -1
  13. package/src/api/platform/Factory.d.ts +1 -2
  14. package/src/api/platform/Factory.js +2 -11
  15. package/src/api/platform/layout/Factory.d.ts +1 -1
  16. package/src/api/platform/layout/Factory.js +4 -38
  17. package/src/api/view/Instance.js +1 -2
  18. package/src/environment/browser.d.ts +4 -2
  19. package/src/environment/browser.js +5 -2
  20. package/src/environment/environment.d.ts +4 -2
  21. package/src/environment/mockEnvironment.d.ts +2 -2
  22. package/src/environment/mockEnvironment.js +2 -2
  23. package/src/environment/node-env.d.ts +3 -2
  24. package/src/environment/node-env.js +5 -2
  25. package/src/environment/openfin-env.d.ts +5 -3
  26. package/src/environment/openfin-env.js +12 -10
  27. package/src/shapes/protocol.d.ts +9 -9
  28. package/src/transport/transport.d.ts +3 -2
  29. package/src/transport/transport.js +2 -2
  30. package/src/api/platform/layout/controllers/splitter-controller.d.ts +0 -30
  31. package/src/api/platform/layout/controllers/splitter-controller.js +0 -83
  32. package/src/api/platform/layout/controllers/tab-drag-controller.d.ts +0 -59
  33. package/src/api/platform/layout/controllers/tab-drag-controller.js +0 -124
  34. package/src/api/platform/layout/utils/bounds-observer.d.ts +0 -19
  35. package/src/api/platform/layout/utils/bounds-observer.js +0 -52
  36. package/src/api/platform/layout/utils/view-overlay.d.ts +0 -35
  37. package/src/api/platform/layout/utils/view-overlay.js +0 -49
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "31.75.1",
3
+ "version": "32.75.2",
4
4
  "license": "SEE LICENSE IN LICENSE.MD",
5
5
  "main": "./src/mock.js",
6
6
  "types": "./src/mock.d.ts",
package/src/OpenFin.d.ts CHANGED
@@ -48,17 +48,18 @@ export type ClientIdentity = Identity & {
48
48
  */
49
49
  export type ClientInfo = Omit<ClientIdentity, 'isLocalEndpointId'> & {
50
50
  /**
51
- * Indicates if the client belongs to a Window or View
51
+ * Indicates if the client belongs to a Window, View or IFrame
52
52
  */
53
53
  entityType: EntityType;
54
54
  /**
55
- * URL of the View or Window at the time of connection to the Channel Provider.
55
+ * URL of the Window, View or IFrame at the time of connection to the Channel Provider.
56
56
  */
57
57
  connectionUrl: string;
58
58
  };
59
59
  export type ClientIdentityMultiRuntime = ClientIdentity & {
60
60
  runtimeUuid: string;
61
61
  };
62
+ export type ClientConnectionPayload = ClientIdentity & ClientInfo;
62
63
  export type EntityInfo = {
63
64
  uuid: string;
64
65
  name: string;
@@ -1433,6 +1434,7 @@ export type GetWindowContextPayload = {
1433
1434
  };
1434
1435
  export type ApplicationPermissions = {
1435
1436
  setFileDownloadLocation: boolean;
1437
+ getFileDownloadLocation: boolean;
1436
1438
  };
1437
1439
  export type LaunchExternalProcessRule = {
1438
1440
  behavior: 'allow' | 'block';
@@ -300,10 +300,22 @@ export declare class Application extends EmitterBase<OpenFin.ApplicationEvent> {
300
300
  */
301
301
  getProcessInfo(): Promise<OpenFin.AppProcessInfo>;
302
302
  /**
303
- * Sets file auto download location.
303
+ * Sets file auto download location. It's only allowed in the same application.
304
+ * Note: This method is restricted by default and must be enabled via
305
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
304
306
  * @param { string } downloadLocation file auto download location
305
307
  * @return {Promise.<void>}
308
+ * @throws if setting file auto download location on different applications.
306
309
  * @tutorial Application.setFileDownloadLocation
307
310
  */
308
311
  setFileDownloadLocation(downloadLocation: string): Promise<void>;
312
+ /**
313
+ * Gets file auto download location. It's only allowed in the same application. If file auto download location is not set, it will return the default location.
314
+ * Note: This method is restricted by default and must be enabled via
315
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
316
+ * @return {Promise.<string>}
317
+ * @throws if getting file auto download location on different applications.
318
+ * @tutorial Application.getFileDownloadLocation
319
+ */
320
+ getFileDownloadLocation(): Promise<string>;
309
321
  }
@@ -146,11 +146,8 @@ class Application extends base_1.EmitterBase {
146
146
  await this.wire.sendAction('destroy-application', { force, ...this.identity });
147
147
  }
148
148
  catch (error) {
149
- const acceptableErrors = [
150
- 'Remote connection has closed',
151
- 'Could not locate the requested application'
152
- ];
153
- if (!acceptableErrors.some(msg => error.message.includes(msg))) {
149
+ const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
150
+ if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
154
151
  throw error;
155
152
  }
156
153
  }
@@ -427,13 +424,30 @@ class Application extends base_1.EmitterBase {
427
424
  return data;
428
425
  }
429
426
  /**
430
- * Sets file auto download location.
427
+ * Sets file auto download location. It's only allowed in the same application.
428
+ * Note: This method is restricted by default and must be enabled via
429
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
431
430
  * @param { string } downloadLocation file auto download location
432
431
  * @return {Promise.<void>}
432
+ * @throws if setting file auto download location on different applications.
433
433
  * @tutorial Application.setFileDownloadLocation
434
434
  */
435
435
  async setFileDownloadLocation(downloadLocation) {
436
- await this.wire.sendAction('set-file-download-location', { downloadLocation, ...this.identity });
436
+ const { name } = this.wire.me;
437
+ const entityIdentity = { uuid: this.identity.uuid, name };
438
+ await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
439
+ }
440
+ /**
441
+ * Gets file auto download location. It's only allowed in the same application. If file auto download location is not set, it will return the default location.
442
+ * Note: This method is restricted by default and must be enabled via
443
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
444
+ * @return {Promise.<string>}
445
+ * @throws if getting file auto download location on different applications.
446
+ * @tutorial Application.getFileDownloadLocation
447
+ */
448
+ async getFileDownloadLocation() {
449
+ const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
450
+ return data;
437
451
  }
438
452
  }
439
453
  exports.Application = Application;
@@ -11,6 +11,9 @@ export type CrashedEvent = NamedEvent & {
11
11
  exitCode: number;
12
12
  };
13
13
  };
14
+ export type FileDownloadLocationChangedEvent = NamedEvent & {
15
+ type: 'file-download-location-changed';
16
+ };
14
17
  export type RunRequestedEvent = IdentityEvent & {
15
18
  type: 'run-requested';
16
19
  userAppConfigArgs: Record<string, any>;
@@ -70,7 +73,7 @@ export type StartedEvent = IdentityEvent & {
70
73
  /**
71
74
  * An Application event that does propagate to (republish on) parent topics.
72
75
  */
73
- export type WillPropagateApplicationEvent = ClosedEvent | ApplicationConnectedEvent | CrashedEvent | InitializedEvent | ManifestChangedEvent | NotRespondingEvent | RespondingEvent | RunRequestedEvent | StartedEvent | TrayIconClickedEvent;
76
+ export type WillPropagateApplicationEvent = ClosedEvent | ApplicationConnectedEvent | CrashedEvent | InitializedEvent | ManifestChangedEvent | NotRespondingEvent | RespondingEvent | RunRequestedEvent | StartedEvent | TrayIconClickedEvent | FileDownloadLocationChangedEvent;
74
77
  export type ApplicationEvent = {
75
78
  topic: 'application';
76
79
  } & (PropagatedViewEvent | PropagatedWindowEvent | ApplicationWindowEvent | WillPropagateApplicationEvent);
@@ -67,10 +67,6 @@ export type FoundInPageEvent = NamedEvent & {
67
67
  } & {
68
68
  result: OpenFin.FindInPageResult;
69
69
  };
70
- /**
71
- * A WebContents event that does not propagate to (republish on) parent topics.
72
- */
73
- export type NonPropagatedWebContentsEvent = FoundInPageEvent | CertificateErrorEvent;
74
70
  export type BlurredEvent = NamedEvent & {
75
71
  type: 'blurred';
76
72
  };
@@ -89,9 +85,62 @@ export type ChildContentOpenedInBrowserEvent = NamedEvent & {
89
85
  export type ChildViewCreatedEvent = NamedEvent & {
90
86
  type: 'child-view-created';
91
87
  };
88
+ export type FileDownloadEvent = NamedEvent & {
89
+ state: 'started' | 'progressing' | 'cancelled' | 'interrupted' | 'completed';
90
+ /**
91
+ * The url from which the file is being downloaded.
92
+ */
93
+ url: string;
94
+ mimeType: string;
95
+ /**
96
+ * Name used to save the file locally.
97
+ */
98
+ fileName: string;
99
+ /**
100
+ * Original name of the file.
101
+ */
102
+ originalFileName: string;
103
+ totalBytes: number;
104
+ /**
105
+ * The number of seconds since the UNIX epoch when the download was started.
106
+ */
107
+ startTime: number;
108
+ /**
109
+ * The value of the Content-Disposition field from the response header.
110
+ */
111
+ contentDisposition: string;
112
+ /**
113
+ * The value of the Last-Modified header.
114
+ */
115
+ lastModifiedTime: Date;
116
+ /**
117
+ * The value of the ETag header.
118
+ */
119
+ eTag: string;
120
+ /**
121
+ * The number of bytes of the item that have already been downloaded.
122
+ */
123
+ downloadedBytes: number;
124
+ };
125
+ export type FileDownloadStartedEvent = FileDownloadEvent & {
126
+ type: 'file-download-started';
127
+ state: 'started';
128
+ };
129
+ export type FileDownloadProgressEvent = FileDownloadEvent & {
130
+ type: 'file-download-progress';
131
+ state: 'progressing' | 'interrupted';
132
+ };
133
+ export type FileDownloadCompletedEvent = FileDownloadEvent & {
134
+ type: 'file-download-completed';
135
+ state: 'completed' | 'interrupted' | 'cancelled';
136
+ };
92
137
  /**
93
138
  * A WebContents event that does propagate to (republish on) parent topics.
94
139
  */
95
- export type WillPropagateWebContentsEvent = BlurredEvent | CertificateSelectionShownEvent | CrashedEvent | DidChangeThemeColorEvent | FocusedEvent | NavigationRejectedEvent | UrlChangedEvent | DidFailLoadEvent | DidFinishLoadEvent | FaviconUpdatedEvent | PageTitleUpdatedEvent | ResourceLoadFailedEvent | ResourceResponseReceivedEvent | ChildContentBlockedEvent | ChildContentOpenedInBrowserEvent | ChildViewCreatedEvent;
140
+ export type WillPropagateWebContentsEvent = BlurredEvent | CertificateSelectionShownEvent | CrashedEvent | DidChangeThemeColorEvent | FocusedEvent | NavigationRejectedEvent | UrlChangedEvent | DidFailLoadEvent | DidFinishLoadEvent | FaviconUpdatedEvent | PageTitleUpdatedEvent | ResourceLoadFailedEvent | ResourceResponseReceivedEvent | ChildContentBlockedEvent | ChildContentOpenedInBrowserEvent | ChildViewCreatedEvent | FileDownloadStartedEvent | FileDownloadProgressEvent | FileDownloadCompletedEvent;
141
+ /**
142
+ * A WebContents event that does not propagate to (republish on) parent topics.
143
+ */
144
+ export type NonPropagatedWebContentsEvent = FoundInPageEvent | CertificateErrorEvent;
96
145
  export type WebContentsEvent = NonPropagatedWebContentsEvent | WillPropagateWebContentsEvent;
97
146
  export {};
@@ -4,9 +4,9 @@ import { Transport } from '../../../transport/transport';
4
4
  import { AnyStrategy } from './protocols/strategy-types';
5
5
  type ProviderIdentity = OpenFin.ProviderIdentity;
6
6
  type DisconnectionListener = (providerIdentity: ProviderIdentity) => any;
7
- interface RoutingInfo extends ProviderIdentity {
7
+ export type RoutingInfo = ProviderIdentity & {
8
8
  endpointId: string;
9
- }
9
+ };
10
10
  export default class ChannelClient extends ChannelBase {
11
11
  #private;
12
12
  private disconnectListener;
@@ -1,9 +1,9 @@
1
1
  import type * as OpenFin from '../../../OpenFin';
2
- import ChannelClient from './client';
3
- import { ChannelProvider } from './provider';
2
+ import { Message, Transport } from '../../../transport/transport';
4
3
  import { EmitterBase } from '../../base';
5
- import { Transport, Message } from '../../../transport/transport';
6
4
  import { ChannelEvent } from '../../events/channel';
5
+ import ChannelClient from './client';
6
+ import { ChannelProvider } from './provider';
7
7
  type ProviderIdentity = OpenFin.ProviderIdentity;
8
8
  type Identity = OpenFin.Identity;
9
9
  export interface ChannelMessage extends Message<any> {
@@ -15,10 +15,10 @@ export interface ChannelMessage extends Message<any> {
15
15
  export declare class Channel extends EmitterBase<ChannelEvent> {
16
16
  #private;
17
17
  constructor(wire: Transport);
18
- private channelExists;
19
18
  getAllChannels(): Promise<ProviderIdentity[]>;
20
19
  onChannelConnect(listener: (...args: any[]) => void): Promise<void>;
21
20
  onChannelDisconnect(listener: (...args: any[]) => void): Promise<void>;
21
+ private safeConnect;
22
22
  connect(channelName: string, options?: OpenFin.ChannelConnectOptions): Promise<ChannelClient>;
23
23
  create(channelName: string, options?: OpenFin.ChannelCreateOptions): Promise<ChannelProvider>;
24
24
  }
@@ -14,12 +14,25 @@ var _Channel_connectionManager, _Channel_internalEmitter, _Channel_readyToConnec
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Channel = void 0;
16
16
  /* eslint-disable no-console */
17
- const client_1 = require("./client");
18
- const provider_1 = require("./provider");
19
- const base_1 = require("../../base");
20
- const connection_manager_1 = require("./connection-manager");
21
17
  const events_1 = require("events");
22
18
  const lazy_1 = require("../../../util/lazy");
19
+ const base_1 = require("../../base");
20
+ const client_1 = require("./client");
21
+ const connection_manager_1 = require("./connection-manager");
22
+ const provider_1 = require("./provider");
23
+ function retryDelay(count) {
24
+ const interval = 500; // base delay
25
+ const steps = 10; // How many retries to do before incrementing the delay
26
+ const base = 2; // How much to multiply the previous delay by
27
+ const max = 30000; // max delay
28
+ const step = Math.floor(count / steps);
29
+ const delay = Math.min(max, interval * base ** step);
30
+ return new Promise(resolve => {
31
+ setTimeout(() => {
32
+ resolve(false);
33
+ }, delay);
34
+ });
35
+ }
23
36
  class Channel extends base_1.EmitterBase {
24
37
  constructor(wire) {
25
38
  super(wire, 'channel');
@@ -38,10 +51,6 @@ class Channel extends base_1.EmitterBase {
38
51
  }));
39
52
  __classPrivateFieldSet(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
40
53
  }
41
- async channelExists(channelName) {
42
- const channels = await this.getAllChannels();
43
- return channels.some((providerIdentity) => providerIdentity.channelName === channelName);
44
- }
45
54
  async getAllChannels() {
46
55
  return this.wire.sendAction('get-all-channels').then(({ payload }) => payload.data);
47
56
  }
@@ -51,6 +60,57 @@ class Channel extends base_1.EmitterBase {
51
60
  async onChannelDisconnect(listener) {
52
61
  await this.on('disconnected', listener);
53
62
  }
63
+ async safeConnect(channelName, shouldWait, connectPayload) {
64
+ const retryInfo = { count: 0 };
65
+ /* eslint-disable no-await-in-loop, no-constant-condition */
66
+ do {
67
+ // setup a listener and a connected promise to await in case we connect before the channel is ready
68
+ let connectedListener = () => undefined;
69
+ const connectedPromise = new Promise((resolve) => {
70
+ connectedListener = (payload) => {
71
+ if (channelName === payload.channelName) {
72
+ resolve(true);
73
+ }
74
+ };
75
+ __classPrivateFieldGet(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
76
+ });
77
+ try {
78
+ if (retryInfo.count > 0) {
79
+ // Wait before retrying
80
+ // Delay returns false connectedPromise returns true so we can know if a retry is due to connected event
81
+ retryInfo.gotConnectedEvent = await Promise.race([retryDelay(retryInfo.count), connectedPromise]);
82
+ const result = await this.wire.sendAction('connect-to-channel', { ...connectPayload, retryInfo });
83
+ // log only if there was a retry
84
+ console.log(`Successfully connected to channelName: ${channelName}`);
85
+ return result.payload.data;
86
+ }
87
+ // Send retryInfo to the core for debug log inclusion
88
+ const sentMessagePromise = this.wire.sendAction('connect-to-channel', connectPayload);
89
+ // Save messageId from the first connection attempt
90
+ retryInfo.originalMessageId = sentMessagePromise.messageId;
91
+ const result = await sentMessagePromise;
92
+ return result.payload.data;
93
+ }
94
+ catch (error) {
95
+ if (!error.message.includes('internal-nack')) {
96
+ // Not an internal nack, break the loop
97
+ throw error;
98
+ }
99
+ if (shouldWait && retryInfo.count === 0) {
100
+ // start waiting on the next iteration, warn the user
101
+ console.warn(`No channel found for channelName: ${channelName}. Waiting for connection...`);
102
+ }
103
+ }
104
+ finally {
105
+ retryInfo.count += 1;
106
+ // in case of other errors, remove our listener
107
+ __classPrivateFieldGet(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
108
+ }
109
+ } while (shouldWait); // If we're waiting we retry the above loop
110
+ // Should wait was false, no channel was found.
111
+ throw new Error(`No channel found for channelName: ${channelName}.`);
112
+ /* eslint-enable no-await-in-loop, no-constant-condition */
113
+ }
54
114
  async connect(channelName, options = {}) {
55
115
  // Make sure we don't connect before listeners are set up
56
116
  // This also errors if we're not in OpenFin, ensuring we don't run unnecessary code
@@ -59,58 +119,35 @@ class Channel extends base_1.EmitterBase {
59
119
  throw new Error('Please provide a channelName string to connect to a channel.');
60
120
  }
61
121
  const opts = { wait: true, ...this.wire.environment.getDefaultChannelOptions().connect, ...options };
62
- const shouldWait = opts.wait;
63
- if (shouldWait) {
64
- const channelExists = await this.channelExists(channelName);
65
- if (!channelExists) {
66
- console.warn(`Channel not found for channelName: ${channelName}, waiting for channel connection.`);
67
- await new Promise((resolve) => {
68
- const connectedListener = (payload) => {
69
- if (channelName === payload.channelName) {
70
- __classPrivateFieldGet(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
71
- resolve();
72
- }
73
- };
74
- __classPrivateFieldGet(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
75
- });
76
- }
77
- }
78
- try {
79
- const { offer, rtc: rtcPacket } = await __classPrivateFieldGet(this, _Channel_connectionManager, "f").createClientOffer(opts);
80
- const connectionUrl = (await this.fin.me.getInfo()).url;
81
- const { payload: { data: routingInfo } } = await this.wire.sendAction('connect-to-channel', {
82
- channelName,
83
- ...opts,
84
- offer,
85
- connectionUrl
86
- });
87
- const strategy = await __classPrivateFieldGet(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
88
- const channel = new client_1.default(routingInfo, this.wire, strategy);
89
- // It is the client's responsibility to handle endpoint disconnection to the provider.
90
- // If the endpoint dies, the client will force a disconnection through the core.
91
- // The provider does not care about endpoint disconnection.
92
- strategy.onEndpointDisconnect(routingInfo.channelId, async () => {
93
- try {
94
- await channel.sendDisconnectAction();
95
- }
96
- catch (error) {
97
- console.warn(`Something went wrong during disconnect for client with uuid: ${routingInfo.uuid} / name: ${routingInfo.name} / endpointId: ${routingInfo.endpointId}.`);
98
- }
99
- finally {
100
- client_1.default.handleProviderDisconnect(routingInfo);
101
- }
102
- });
103
- return channel;
122
+ const { offer, rtc: rtcPacket } = await __classPrivateFieldGet(this, _Channel_connectionManager, "f").createClientOffer(opts);
123
+ let connectionUrl;
124
+ if (this.fin.me.isFrame || this.fin.me.isView || this.fin.me.isWindow) {
125
+ connectionUrl = (await this.fin.me.getInfo()).url;
104
126
  }
105
- catch (error) {
106
- const internalNackMessage = 'internal-nack';
107
- if (error.message.includes(internalNackMessage)) {
108
- throw new Error(`No channel found for channelName: ${channelName}.`);
127
+ const connectPayload = {
128
+ channelName,
129
+ ...opts,
130
+ offer,
131
+ connectionUrl
132
+ };
133
+ const routingInfo = await this.safeConnect(channelName, opts.wait, connectPayload);
134
+ const strategy = await __classPrivateFieldGet(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
135
+ const channel = new client_1.default(routingInfo, this.wire, strategy);
136
+ // It is the client's responsibility to handle endpoint disconnection to the provider.
137
+ // If the endpoint dies, the client will force a disconnection through the core.
138
+ // The provider does not care about endpoint disconnection.
139
+ strategy.onEndpointDisconnect(routingInfo.channelId, async () => {
140
+ try {
141
+ await channel.sendDisconnectAction();
109
142
  }
110
- else {
111
- throw new Error(error);
143
+ catch (error) {
144
+ console.warn(`Something went wrong during disconnect for client with uuid: ${routingInfo.uuid} / name: ${routingInfo.name} / endpointId: ${routingInfo.endpointId}.`);
112
145
  }
113
- }
146
+ finally {
147
+ client_1.default.handleProviderDisconnect(routingInfo);
148
+ }
149
+ });
150
+ return channel;
114
151
  }
115
152
  async create(channelName, options) {
116
153
  if (!channelName) {
@@ -6,19 +6,18 @@ type ProviderIdentity = OpenFin.ProviderIdentity;
6
6
  type ClientIdentity = OpenFin.ClientIdentity;
7
7
  export type ConnectionListener = (identity: ClientIdentity, connectionMessage?: any) => Promise<any> | any;
8
8
  export type DisconnectionListener = (identity: ClientIdentity) => any;
9
- type ClientConnectionPayload = OpenFin.ClientIdentity & OpenFin.ClientInfo;
10
9
  export declare class ChannelProvider extends ChannelBase {
11
10
  #private;
12
11
  private static removalMap;
13
12
  private connectListener;
14
13
  private disconnectListener;
15
- get connections(): ClientConnectionPayload[];
14
+ get connections(): OpenFin.ClientConnectionPayload[];
16
15
  static handleClientDisconnection(channel: ChannelProvider, payload: any): void;
17
16
  static setProviderRemoval(provider: ChannelProvider, remove: Function): void;
18
17
  constructor(providerIdentity: ProviderIdentity, wire: Transport, strategy: AnyStrategy);
19
18
  dispatch(to: OpenFin.ClientIdentity | OpenFin.Identity, action: string, payload?: any): Promise<any>;
20
19
  protected processAction: (action: string, payload: any, senderIdentity: OpenFin.ClientIdentity | OpenFin.ClientIdentityMultiRuntime) => Promise<any>;
21
- processConnection(senderId: ClientConnectionPayload, payload: any): Promise<any>;
20
+ processConnection(senderId: OpenFin.ClientConnectionPayload, payload: any): Promise<any>;
22
21
  publish(action: string, payload: any): Promise<any>[];
23
22
  onConnection(listener: ConnectionListener): void;
24
23
  onDisconnection(listener: DisconnectionListener): void;
package/src/api/me.d.ts CHANGED
@@ -33,7 +33,7 @@ export declare function getBaseMe<T extends EntityType = EntityType>(entityType:
33
33
  export interface WithInterop {
34
34
  interop: InteropClient;
35
35
  }
36
- export type Me<MeType extends EntityType> = OpenFin.EntityInfo & (MeType extends 'view' ? EntityTypeHelpers<'view'> & OpenFin.View & WithInterop : MeType extends 'window' ? EntityTypeHelpers<'window'> & OpenFin.Window & WithInterop : MeType extends 'iframe' ? EntityTypeHelpers<'iframe'> & OpenFin.Frame & WithInterop : EntityTypeHelpers<MeType> & WithInterop) & {
36
+ export type Me<MeType extends EntityType> = OpenFin.EntityInfo & (MeType extends 'view' ? EntityTypeHelpers<'view'> & OpenFin.View & WithInterop : MeType extends 'window' ? EntityTypeHelpers<'window'> & OpenFin.Window & WithInterop : MeType extends 'iframe' ? EntityTypeHelpers<'iframe'> & OpenFin.Frame & WithInterop : MeType extends 'external connection' ? EntityTypeHelpers<'external connection'> & OpenFin.ExternalApplication & WithInterop : EntityTypeHelpers<MeType> & WithInterop) & {
37
37
  isOpenFin: boolean;
38
38
  };
39
39
  export declare function getMe<MeType extends EntityType>(wire: Transport<MeType>): Me<MeType>;
package/src/api/me.js CHANGED
@@ -4,6 +4,7 @@ exports.getMe = exports.getBaseMe = exports.environmentUnsupportedMessage = void
4
4
  const view_1 = require("./view");
5
5
  const frame_1 = require("./frame");
6
6
  const window_1 = require("./window");
7
+ const external_application_1 = require("./external-application");
7
8
  exports.environmentUnsupportedMessage = 'You are not running in OpenFin.';
8
9
  function getBaseMe(entityType, uuid, name) {
9
10
  const entityTypeHelpers = {
@@ -117,7 +118,7 @@ function getMe(wire) {
117
118
  isOpenFin: true
118
119
  });
119
120
  case 'external connection':
120
- return Object.assign(new window_1._Window(wire, { uuid, name }), getBaseMe(entityType, uuid, name), {
121
+ return Object.assign(new external_application_1.ExternalApplication(wire, { uuid }), getBaseMe(entityType, uuid, name), {
121
122
  interop: fallbackInterop,
122
123
  isOpenFin: false
123
124
  });
@@ -1,6 +1,6 @@
1
1
  import type * as OpenFin from '../../OpenFin';
2
- import { Base } from '../base';
3
2
  import { Transport } from '../../transport/transport';
3
+ import { Base } from '../base';
4
4
  import { LayoutModule } from './layout/index';
5
5
  type Channel = OpenFin.Fin['InterApplicationBus']['Channel'];
6
6
  /**
@@ -51,7 +51,6 @@ type Channel = OpenFin.Fin['InterApplicationBus']['Channel'];
51
51
  export default class PlatformModule extends Base {
52
52
  private _channel;
53
53
  Layout: LayoutModule;
54
- private _initializer;
55
54
  constructor(wire: Transport, channel: Channel);
56
55
  /**
57
56
  * Initializes a Platform. Must be called from the Provider when using a custom provider.
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable no-undef, no-underscore-dangle */
4
3
  const base_1 = require("../base");
5
- const index_1 = require("./layout/index");
6
4
  const Instance_1 = require("./Instance");
5
+ const index_1 = require("./layout/index");
7
6
  /**
8
7
  * @PORTED
9
8
  * InitPlatformOptions interface
@@ -53,9 +52,6 @@ class PlatformModule extends base_1.Base {
53
52
  constructor(wire, channel) {
54
53
  super(wire);
55
54
  this._channel = channel;
56
- this._initializer = (...args) => this.wire.environment
57
- .getProviderInitializer()
58
- .then((initConstructor) => initConstructor(this.wire.environment)(...args));
59
55
  /**
60
56
  * @namespace
61
57
  * @desc Layouts give app providers the ability to embed multiple views in a single window. The Layout namespace
@@ -74,12 +70,7 @@ class PlatformModule extends base_1.Base {
74
70
  * @static
75
71
  */
76
72
  async init(options) {
77
- const overrideCallback = options === null || options === void 0 ? void 0 : options.overrideCallback;
78
- const interopBroker = await this.fin.Interop.init(this.fin.me.uuid, options === null || options === void 0 ? void 0 : options.interopOverride);
79
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
80
- // @ts-expect-error debugging purposes
81
- window.interopBroker = interopBroker;
82
- return this._initializer(overrideCallback, interopBroker);
73
+ return this.wire.environment.initPlatform(this.fin, options);
83
74
  }
84
75
  /**
85
76
  * Asynchronously returns a Platform object that represents an existing platform.
@@ -1,6 +1,6 @@
1
1
  import type * as OpenFin from '../../../OpenFin';
2
- import { Layout } from './Instance';
3
2
  import { Base } from '../../base';
3
+ import { Layout } from './Instance';
4
4
  type InitLayoutOptions = OpenFin.InitLayoutOptions;
5
5
  /**
6
6
  * @PORTED
@@ -10,19 +10,12 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
11
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
12
  };
13
- var _LayoutModule_layoutManager, _LayoutModule_layoutInitializationAttempted;
13
+ var _LayoutModule_layoutInitializationAttempted;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.LayoutModule = void 0;
16
16
  /* eslint-disable no-undef, import/prefer-default-export */
17
- const tab_drag_controller_1 = require("./controllers/tab-drag-controller");
18
- const Instance_1 = require("./Instance");
19
17
  const base_1 = require("../../base");
20
- const splitter_controller_1 = require("./controllers/splitter-controller");
21
- const view_overlay_1 = require("./utils/view-overlay");
22
- const api_exposer_1 = require("../../api-exposer");
23
- const layout_entities_controller_1 = require("./controllers/layout-entities-controller");
24
- const layout_constants_1 = require("./layout.constants");
25
- const layout_content_cache_1 = require("./controllers/layout-content-cache");
18
+ const Instance_1 = require("./Instance");
26
19
  /**
27
20
  * @PORTED
28
21
  * InitLayoutOptions interface
@@ -90,7 +83,6 @@ const layout_content_cache_1 = require("./controllers/layout-content-cache");
90
83
  class LayoutModule extends base_1.Base {
91
84
  constructor() {
92
85
  super(...arguments);
93
- _LayoutModule_layoutManager.set(this, void 0);
94
86
  _LayoutModule_layoutInitializationAttempted.set(this, false);
95
87
  /**
96
88
  * Initialize the window's Layout. Must be called from a custom window that has a 'layout' option set upon creation of that window.
@@ -114,33 +106,7 @@ class LayoutModule extends base_1.Base {
114
106
  throw new Error('Layout for this window already initialized, please use Layout.replace call to replace the layout.');
115
107
  }
116
108
  __classPrivateFieldSet(this, _LayoutModule_layoutInitializationAttempted, true, "f");
117
- // We need to go through environment to make sure it is only imported/bundled in OpenFin.
118
- const ManagerConstructor = await this.wire.environment.getManagerConstructor();
119
- const viewOverlay = new view_overlay_1.ViewOverlay(this.wire);
120
- const splitterController = new splitter_controller_1.SplitterController(viewOverlay);
121
- const tabDragController = new tab_drag_controller_1.TabDragController(viewOverlay);
122
- const contentItemCache = new layout_content_cache_1.LayoutContentCache();
123
- __classPrivateFieldSet(this, _LayoutModule_layoutManager, new ManagerConstructor(splitterController, tabDragController, contentItemCache), "f");
124
- // @ts-expect-error - layout warning here for backwards compatibility, can remove layout check in .52
125
- let { layout, containerId } = options;
126
- if (layout) {
127
- console.warn(`We recommend using a layout in window options.
128
- This layout has not been sanitized and unexpected behavior can occur.`);
129
- }
130
- layout = layout || (await this.fin.Window.getCurrentSync().getOptions()).layout;
131
- containerId = containerId || 'layout-container';
132
- const container = document.getElementById(containerId);
133
- // Should we error here if there is no container? Getting a typescript complaint on createLayout
134
- // override here
135
- // pull createChannelConnection out of LayoutManager and setup channel connections here using layoutmanager instance methods?
136
- await __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f").initManager();
137
- await __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f").createLayout(layout, container);
138
- const { client, ofWindow } = ManagerConstructor.getClientAndWindow(__classPrivateFieldGet(this, _LayoutModule_layoutManager, "f"));
139
- // expose LayoutEntitiesController instance for API consumption
140
- const channelStrategy = new api_exposer_1.ChannelsExposer(client);
141
- await new api_exposer_1.ApiExposer(channelStrategy).exposeInstance(new layout_entities_controller_1.LayoutEntitiesController(__classPrivateFieldGet(this, _LayoutModule_layoutManager, "f"), contentItemCache), { id: layout_constants_1.LAYOUT_CONTROLLER_ID });
142
- // Adding this to the returned instance undocumented/typed for Browser.
143
- return Object.assign(this.getCurrentSync(), { layoutManager: __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f") });
109
+ return this.wire.environment.initLayout(this.fin, this.wire, options);
144
110
  };
145
111
  }
146
112
  /**
@@ -205,4 +171,4 @@ class LayoutModule extends base_1.Base {
205
171
  }
206
172
  }
207
173
  exports.LayoutModule = LayoutModule;
208
- _LayoutModule_layoutManager = new WeakMap(), _LayoutModule_layoutInitializationAttempted = new WeakMap();
174
+ _LayoutModule_layoutInitializationAttempted = new WeakMap();
@@ -11,7 +11,6 @@ const transport_errors_1 = require("../../transport/transport-errors");
11
11
  const lazy_1 = require("../../util/lazy");
12
12
  const layout_entities_1 = require("../platform/layout/entities/layout-entities");
13
13
  const layout_constants_1 = require("../platform/layout/layout.constants");
14
- const bounds_observer_1 = require("../platform/layout/utils/bounds-observer");
15
14
  const main_1 = require("../webcontents/main");
16
15
  const window_1 = require("../window");
17
16
  /**
@@ -510,7 +509,7 @@ class View extends main_1.WebContents {
510
509
  throw new Error('Element not found.');
511
510
  }
512
511
  const onChange = async (bounds) => this.setBounds(bounds);
513
- return (0, bounds_observer_1.observeBounds)(element, onChange);
512
+ return this.wire.environment.observeBounds(element, onChange);
514
513
  };
515
514
  }
516
515
  /**
@@ -1,10 +1,12 @@
1
1
  import type * as OpenFin from '../OpenFin';
2
+ import { Transport } from '../transport/transport';
2
3
  import { NewConnectConfig } from '../transport/wire';
3
4
  import { ChildContentOptions, Environment } from './environment';
4
5
  type EntityType = OpenFin.EntityType;
5
6
  export declare class BrowserEnvironment implements Environment {
6
- getManagerConstructor(): Promise<any>;
7
- getProviderInitializer(): Promise<any>;
7
+ observeBounds(element: Element, onChange: (bounds: DOMRect) => void | Promise<void>): () => void;
8
+ initLayout(_fin: OpenFin.Fin<OpenFin.EntityType>, wire: Transport, options: OpenFin.InitLayoutOptions): Promise<OpenFin.Layout>;
9
+ initPlatform(...args: any[]): Promise<any>;
8
10
  writeToken(path: string, token: string): Promise<string>;
9
11
  retrievePort(config: NewConnectConfig): Promise<number>;
10
12
  getNextMessageId(): string;