@openfin/core 29.73.5 → 29.73.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "29.73.5",
3
+ "version": "29.73.8",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./src/mock.js",
6
6
  "types": "./src/mock.d.ts",
package/src/OpenFin.d.ts CHANGED
@@ -660,8 +660,8 @@ export declare type LayoutOptions = {
660
660
  headerHeight?: number;
661
661
  };
662
662
  };
663
- export declare type OverrideCallback<T extends any = PlatformProvider, U extends T = T> = (arg: Constructor<T>, ...args: ConstructorParameters<Constructor<T>>) => U | Promise<U>;
664
- export declare type Constructor<T = {}> = new (...args: any[]) => T;
663
+ export declare type OverrideCallback<T extends any = PlatformProvider, U extends T = T> = (arg: Constructor<T>) => U | Promise<U>;
664
+ export declare type Constructor<T = {}> = new () => T;
665
665
  export declare type HostContextChangedReasons = 'updated' | 'reparented';
666
666
  export declare type WindowCreationReason = 'tearout' | 'create-view-without-target' | 'api-call' | 'app-creation' | 'restore' | 'apply-snapshot';
667
667
  export declare type PlatformProvider = {
@@ -680,9 +680,12 @@ export declare type PlatformProvider = {
680
680
  */
681
681
  getSnapshot(payload: undefined, identity: Identity): Promise<Snapshot>;
682
682
  /**
683
+ * **NOTE**: Internal use only. It is not recommended to manage the state of individual views.
683
684
  * Gets the current state of a single view and returns an object with the options needed to restore that view as part of a snapshot.
684
685
  * @param { Identity } payload Identity of the view.
685
686
  * @return { Promise<ViewState> }
687
+ * @internal
688
+ * @experimental
686
689
  */
687
690
  getViewSnapshot(payload: {
688
691
  viewIdentity: Identity;
@@ -1,3 +1,4 @@
1
+ import type * as OpenFin from '../../OpenFin';
1
2
  import { Base } from '../base';
2
3
  import { InteropBroker } from './InteropBroker';
3
4
  import { InteropClient } from './InteropClient';
@@ -1,9 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const lodash_1 = require("lodash");
4
+ const inaccessibleObject_1 = require("../../util/inaccessibleObject");
3
5
  const base_1 = require("../base");
4
6
  const InteropBroker_1 = require("./InteropBroker");
5
7
  const InteropClient_1 = require("./InteropClient");
6
- const defaultOverride = (Class, ...args) => new Class(...args);
8
+ const overrideCheck_1 = require("./fdc3/overrideCheck");
9
+ const defaultOverride = (Class) => new Class();
10
+ const BrokerParamAccessError = 'You have attempted to use or modify InteropBroker parameters, which is not allowed. You are likely using an older InteropBroker override scheme. Please consult our Interop docs for guidance on migrating to the new override scheme.';
7
11
  /**
8
12
  * @typedef { object } InteropConfig
9
13
  * @summary Information relevant to the Interop Broker.
@@ -26,11 +30,15 @@ class InteropModule extends base_1.Base {
26
30
  * @static
27
31
  */
28
32
  async init(name, override = defaultOverride) {
33
+ var _a;
29
34
  this.wire.sendAction('interop-init').catch((e) => {
30
35
  // don't expose, analytics-only call
31
36
  });
32
37
  // Allows for manifest-level configuration, without having to override. (e.g. specifying custom context groups)
33
38
  const options = await this.fin.Application.getCurrentSync().getInfo();
39
+ const opts = (_a = options.initialOptions.interopBrokerConfiguration) !== null && _a !== void 0 ? _a : {};
40
+ const objectThatThrows = (0, inaccessibleObject_1.createUnusableObject)(BrokerParamAccessError);
41
+ const warningOptsClone = (0, inaccessibleObject_1.createWarningObject)(BrokerParamAccessError, (0, lodash_1.cloneDeep)(opts));
34
42
  let provider;
35
43
  const getProvider = () => {
36
44
  if (!provider) {
@@ -38,7 +46,16 @@ class InteropModule extends base_1.Base {
38
46
  }
39
47
  return provider;
40
48
  };
41
- return override(InteropBroker_1.InteropBroker, this.wire, getProvider, options.initialOptions.interopBrokerConfiguration);
49
+ const throwingGetProvider = async () => {
50
+ // eslint-disable-next-line no-console
51
+ throw new Error(BrokerParamAccessError);
52
+ };
53
+ const OverrideableBroker = InteropBroker_1.InteropBroker.createClosedConstructor(this.wire, getProvider, opts);
54
+ // We need to use these objects because removing them entirely would be a breaking change and we want an informative error
55
+ // @ts-expect-error
56
+ const broker = await override(OverrideableBroker, objectThatThrows, throwingGetProvider, warningOptsClone);
57
+ (0, overrideCheck_1.overrideCheck)(broker, (0, overrideCheck_1.getDefaultViewFdc3VersionFromAppInfo)(options));
58
+ return broker;
42
59
  }
43
60
  /**
44
61
  * Connects a client to an Interop broker. This is called under-the-hood for Views in a Platform.
@@ -2,7 +2,7 @@ import { TargetApp } from './fdc3/shapes/fdc3v1';
2
2
  import { AppIdentifier } from './fdc3/shapes/fdc3v2';
3
3
  import { Base } from '../base';
4
4
  import type Transport from '../../transport/transport';
5
- import Identity = OpenFin.Identity;
5
+ declare type Identity = OpenFin.Identity;
6
6
  /**
7
7
  * {@link https://developers.openfin.co/of-docs/docs/enable-color-linking **THE INTEROP API IS EXPERIMENTAL. IF YOU WOULD LIKE TO USE IT, PLEASE USE OUR DEFAULT IMPLEMENTATION IN BROWSER**}
8
8
  *
@@ -102,7 +102,7 @@ import Identity = OpenFin.Identity;
102
102
  * };
103
103
  * return new Override();
104
104
  * },
105
- * interopOverride: async (InteropBroker, provider, options, ...args) => {
105
+ * interopOverride: async (InteropBroker) => {
106
106
  * class Override extends InteropBroker {
107
107
  * async joinContextGroup(channelName = 'default', target) {
108
108
  * console.log('before super joinContextGroup')
@@ -111,37 +111,7 @@ import Identity = OpenFin.Identity;
111
111
  * }
112
112
  * }
113
113
  *
114
- * options.contextGroups = [
115
- * {
116
- * id: 'green',
117
- * displayMetadata: {
118
- * color: '#00CC88',
119
- * name: 'green'
120
- * }
121
- * },
122
- * {
123
- * id: 'purple',
124
- * displayMetadata: {
125
- * color: '#8C61FF',
126
- * name: 'purple'
127
- * }
128
- * },
129
- * {
130
- * id: 'orange',
131
- * displayMetadata: {
132
- * color: '#FF8C4C',
133
- * name: 'orange'
134
- * }
135
- * },
136
- * {
137
- * id: 'red',
138
- * displayMetadata: {
139
- * color: '#FF5E60',
140
- * name: 'red'
141
- * }
142
- * }
143
- * ];
144
- * return new Override(provider, options, ...args);
114
+ * return new Override();
145
115
  * }
146
116
  * });
147
117
  * ```
@@ -161,6 +131,9 @@ export declare class InteropBroker extends Base {
161
131
  private channel;
162
132
  private logging;
163
133
  constructor(wire: Transport, getProvider: () => Promise<OpenFin.ChannelProvider>, options?: any);
134
+ static createClosedConstructor(...args: ConstructorParameters<typeof InteropBroker>): {
135
+ new (): InteropBroker;
136
+ };
164
137
  /**
165
138
  * SetContextOptions interface
166
139
  * @typedef { object } SetContextOptions
@@ -415,7 +388,7 @@ export declare class InteropBroker extends Base {
415
388
  * FDC3 2.0: Use the endpointId in the ClientInfo as the instanceId when generating
416
389
  * an AppIdentifier.
417
390
  * @return { Promise<Array<ClientInfo>> }
418
- * @tutorial interop.getAllClientInfo()
391
+ * @tutorial interop.getAllClientInfo
419
392
  */
420
393
  getAllClientInfo(): Promise<Array<OpenFin.ClientInfo>>;
421
394
  decorateSnapshot(snapshot: OpenFin.Snapshot): OpenFin.Snapshot;
@@ -465,3 +438,4 @@ export declare class InteropBroker extends Base {
465
438
  */
466
439
  isActionAuthorized(_action: string, _payload: any, _identity: OpenFin.ClientIdentity): Promise<boolean> | boolean;
467
440
  }
441
+ export {};
@@ -4,6 +4,7 @@ exports.InteropBroker = void 0;
4
4
  const base_1 = require("../base");
5
5
  const SessionContextGroupBroker_1 = require("./SessionContextGroupBroker");
6
6
  const utils_1 = require("./utils");
7
+ const lodash_1 = require("lodash");
7
8
  let contextGroups = [
8
9
  {
9
10
  id: 'green',
@@ -147,7 +148,7 @@ let contextGroups = [
147
148
  * };
148
149
  * return new Override();
149
150
  * },
150
- * interopOverride: async (InteropBroker, provider, options, ...args) => {
151
+ * interopOverride: async (InteropBroker) => {
151
152
  * class Override extends InteropBroker {
152
153
  * async joinContextGroup(channelName = 'default', target) {
153
154
  * console.log('before super joinContextGroup')
@@ -156,37 +157,7 @@ let contextGroups = [
156
157
  * }
157
158
  * }
158
159
  *
159
- * options.contextGroups = [
160
- * {
161
- * id: 'green',
162
- * displayMetadata: {
163
- * color: '#00CC88',
164
- * name: 'green'
165
- * }
166
- * },
167
- * {
168
- * id: 'purple',
169
- * displayMetadata: {
170
- * color: '#8C61FF',
171
- * name: 'purple'
172
- * }
173
- * },
174
- * {
175
- * id: 'orange',
176
- * displayMetadata: {
177
- * color: '#FF8C4C',
178
- * name: 'orange'
179
- * }
180
- * },
181
- * {
182
- * id: 'red',
183
- * displayMetadata: {
184
- * color: '#FF5E60',
185
- * name: 'red'
186
- * }
187
- * }
188
- * ];
189
- * return new Override(provider, options, ...args);
160
+ * return new Override();
190
161
  * }
191
162
  * });
192
163
  * ```
@@ -198,6 +169,7 @@ let contextGroups = [
198
169
  */
199
170
  class InteropBroker extends base_1.Base {
200
171
  constructor(wire, getProvider, options) {
172
+ // Tip from Pierre and Michael from the overrideCheck work: Don't use bound methods for overrideable InteropBroker functions.
201
173
  super(wire);
202
174
  this.getProvider = getProvider;
203
175
  this.interopClients = new Map();
@@ -214,6 +186,24 @@ class InteropBroker extends base_1.Base {
214
186
  this.setContextGroupMap();
215
187
  this.setupChannelProvider();
216
188
  }
189
+ static createClosedConstructor(...args) {
190
+ return class OverrideableBroker extends InteropBroker {
191
+ constructor(...unused) {
192
+ if (unused.length) {
193
+ const [_ignore1, ignore2, opts] = unused;
194
+ if (opts && typeof opts === 'object' && !(0, lodash_1.isEqual)(opts, args[2])) {
195
+ // eslint-disable-next-line no-console
196
+ console.warn('You have modified the parameters of the InteropOverride constructor. This behavior is deprecated and will be removed in a future version. You can modify these options in your manifest. Please consult our Interop docs for guidance on migrating to the new override scheme.');
197
+ super(args[0], args[1], opts);
198
+ return;
199
+ }
200
+ // eslint-disable-next-line no-console
201
+ console.warn('You are attempting to pass arguments to the InteropOverride constructor. This is not necessary, and these passed arguments will be ignored. You are likely using an older InteropBroker override scheme. Please consult our Interop docs for guidance on migrating to the new override scheme.');
202
+ }
203
+ super(...args);
204
+ }
205
+ };
206
+ }
217
207
  /*
218
208
  Client API
219
209
  */
@@ -746,7 +736,7 @@ class InteropBroker extends base_1.Base {
746
736
  * FDC3 2.0: Use the endpointId in the ClientInfo as the instanceId when generating
747
737
  * an AppIdentifier.
748
738
  * @return { Promise<Array<ClientInfo>> }
749
- * @tutorial interop.getAllClientInfo()
739
+ * @tutorial interop.getAllClientInfo
750
740
  */
751
741
  async getAllClientInfo() {
752
742
  const provider = await this.getProvider();
@@ -1,13 +1,12 @@
1
1
  import Fdc3Module from './fdc3-1.2';
2
2
  import Fdc3Module2 from './fdc3-2.0';
3
3
  import type Transport from '../../../transport/transport';
4
+ import { Fdc3Version } from './versions';
4
5
  declare global {
5
6
  interface Window {
6
7
  fdc3: Fdc3Module | Fdc3Module2;
7
8
  }
8
9
  }
9
- declare type Fdc3Versions = '1.2' | '2.0';
10
- export declare const versionMap: Record<Fdc3Versions, typeof Fdc3Module | typeof Fdc3Module2>;
10
+ export declare const versionMap: Record<Fdc3Version, typeof Fdc3Module | typeof Fdc3Module2>;
11
11
  export declare function registerFdc3Shim(version: string, transport: Transport): void;
12
- export declare function getFdc3(transport: Transport, version?: Fdc3Versions): Fdc3Module | Fdc3Module2;
13
- export {};
12
+ export declare function getFdc3(transport: Transport, version?: Fdc3Version): Fdc3Module | Fdc3Module2;
@@ -0,0 +1,4 @@
1
+ import * as OpenFin from '../../../OpenFin';
2
+ import { Fdc3Version } from './versions';
3
+ export declare function getDefaultViewFdc3VersionFromAppInfo({ manifest, initialOptions }: Awaited<ReturnType<OpenFin.Application['getInfo']>>): Fdc3Version | undefined;
4
+ export declare function overrideCheck(overriddenBroker: OpenFin.InteropBroker, fdc3InteropApi?: Fdc3Version): void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.overrideCheck = exports.getDefaultViewFdc3VersionFromAppInfo = void 0;
4
+ const InteropBroker_1 = require("../InteropBroker");
5
+ function getDefaultViewFdc3VersionFromAppInfo({ manifest, initialOptions }) {
6
+ var _a, _b, _c, _d;
7
+ const setVersion = (_c = (_b = (_a = manifest.platform) === null || _a === void 0 ? void 0 : _a.defaultViewOptions) === null || _b === void 0 ? void 0 : _b.fdc3InteropApi) !== null && _c !== void 0 ? _c : (_d = initialOptions.defaultViewOptions) === null || _d === void 0 ? void 0 : _d.fdc3InteropApi;
8
+ return ['1.2', '2.0'].includes(setVersion !== null && setVersion !== void 0 ? setVersion : '') ? setVersion : undefined;
9
+ }
10
+ exports.getDefaultViewFdc3VersionFromAppInfo = getDefaultViewFdc3VersionFromAppInfo;
11
+ // TODO: Unit test this
12
+ function overrideCheck(overriddenBroker, fdc3InteropApi) {
13
+ if (fdc3InteropApi && fdc3InteropApi === '2.0') {
14
+ const mustOverrideAPIs = [
15
+ 'fdc3HandleFindInstances',
16
+ 'handleInfoForIntent',
17
+ 'handleInfoForIntentsByContext',
18
+ 'fdc3HandleGetAppMetadata',
19
+ 'fdc3HandleGetInfo',
20
+ 'fdc3HandleOpen',
21
+ 'handleFiredIntent',
22
+ 'handleFiredIntentForContext'
23
+ ];
24
+ const notOverridden = mustOverrideAPIs.filter((api) => {
25
+ return overriddenBroker[api] === InteropBroker_1.InteropBroker.prototype[api];
26
+ });
27
+ if (notOverridden.length > 0) {
28
+ console.warn(`WARNING: FDC3 2.0 has been set as a default option for Views in this Platform, but the required InteropBroker APIs for FDC3 2.0 compliance have not all been overridden.\nThe following APIs need to be overridden:\n${notOverridden.join('\n')}`);
29
+ }
30
+ }
31
+ }
32
+ exports.overrideCheck = overrideCheck;
@@ -0,0 +1 @@
1
+ export declare type Fdc3Version = '1.2' | '2.0';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -65,14 +65,16 @@ export declare class Platform extends EmitterBase<PlatformEvents> {
65
65
  */
66
66
  getSnapshot(): Promise<OpenFin.Snapshot>;
67
67
  /**
68
+ * **NOTE**: Internal use only. It is not recommended to manage the state of individual views.
69
+ *
68
70
  * Returns a snapshot of a single view's options in its current state.
69
71
  *
70
72
  * Can be used to restore a view to a previous state.
71
73
  *
72
- * NOTE: this method is meant for advanced usage only, it is not recommended to manage the state of individual views.
73
- *
74
74
  * @param { Identity } viewIdentity View identity
75
75
  * @returns { Promise<ViewState> }
76
+ * @internal
77
+ * @experimental
76
78
  * @tutorial Platform.getViewSnapshot
77
79
  */
78
80
  getViewSnapshot(viewIdentity: OpenFin.Identity): Promise<OpenFin.ViewState>;
@@ -174,14 +174,16 @@ class Platform extends base_1.EmitterBase {
174
174
  return client.dispatch('get-snapshot');
175
175
  }
176
176
  /**
177
+ * **NOTE**: Internal use only. It is not recommended to manage the state of individual views.
178
+ *
177
179
  * Returns a snapshot of a single view's options in its current state.
178
180
  *
179
181
  * Can be used to restore a view to a previous state.
180
182
  *
181
- * NOTE: this method is meant for advanced usage only, it is not recommended to manage the state of individual views.
182
- *
183
183
  * @param { Identity } viewIdentity View identity
184
184
  * @returns { Promise<ViewState> }
185
+ * @internal
186
+ * @experimental
185
187
  * @tutorial Platform.getViewSnapshot
186
188
  */
187
189
  async getViewSnapshot(viewIdentity) {
@@ -452,9 +452,12 @@ export declare class View extends WebContents<ViewEvents> {
452
452
  */
453
453
  triggerBeforeUnload: () => Promise<boolean>;
454
454
  /**
455
+ * **NOTE**: Internal use only.
455
456
  * Attaches this view to an HTML element in the current context. The view will resize responsively when the element bounds change.
457
+ *
456
458
  * @param { string } elementId - id of the HTML element to attach the view to.
457
459
  * @return {Function} - Cleanup function that will disconnect the element resize observer.
460
+ * @internal
458
461
  * @experimental
459
462
  * @tutorial View.bindToElement
460
463
  */
@@ -457,9 +457,12 @@ class View extends main_1.WebContents {
457
457
  return message.payload.data;
458
458
  };
459
459
  /**
460
+ * **NOTE**: Internal use only.
460
461
  * Attaches this view to an HTML element in the current context. The view will resize responsively when the element bounds change.
462
+ *
461
463
  * @param { string } elementId - id of the HTML element to attach the view to.
462
464
  * @return {Function} - Cleanup function that will disconnect the element resize observer.
465
+ * @internal
463
466
  * @experimental
464
467
  * @tutorial View.bindToElement
465
468
  */
@@ -0,0 +1,2 @@
1
+ export declare function createUnusableObject(message: string): Record<any, never>;
2
+ export declare function createWarningObject<T extends {}>(message: string, obj: T): T;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createWarningObject = exports.createUnusableObject = void 0;
4
+ function createUnusableObject(message) {
5
+ const handle = () => {
6
+ throw new Error(message);
7
+ };
8
+ return new Proxy({}, {
9
+ apply: handle,
10
+ construct: handle,
11
+ defineProperty: handle,
12
+ deleteProperty: handle,
13
+ get: handle,
14
+ getOwnPropertyDescriptor: handle,
15
+ getPrototypeOf: handle,
16
+ has: handle,
17
+ isExtensible: handle,
18
+ ownKeys: handle,
19
+ preventExtensions: handle,
20
+ set: handle,
21
+ setPrototypeOf: handle
22
+ });
23
+ }
24
+ exports.createUnusableObject = createUnusableObject;
25
+ function createWarningObject(message, obj) {
26
+ return new Proxy(obj, {
27
+ get: (...args) => {
28
+ // eslint-disable-next-line no-console
29
+ console.warn(message);
30
+ return Reflect.get(...args);
31
+ },
32
+ set: (...args) => {
33
+ // eslint-disable-next-line no-console
34
+ console.warn(message);
35
+ return Reflect.set(...args);
36
+ },
37
+ getOwnPropertyDescriptor: (...args) => {
38
+ // eslint-disable-next-line no-console
39
+ console.warn(message);
40
+ return Reflect.getOwnPropertyDescriptor(...args);
41
+ },
42
+ ownKeys: (...args) => {
43
+ // eslint-disable-next-line no-console
44
+ console.warn(message);
45
+ return Reflect.ownKeys(...args);
46
+ }
47
+ });
48
+ }
49
+ exports.createWarningObject = createWarningObject;