@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "31.74.9",
3
+ "version": "31.74.11",
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
@@ -1,21 +1,23 @@
1
- import type { Application } from './api/application';
1
+ import type { Application } from './api/application/index';
2
2
  import { AppVersionEvent } from './api/events/system';
3
3
  import { TypedEventEmitter } from './api/events/typedEventEmitter';
4
- import type { ExternalApplication } from './api/external-application';
4
+ import type { ExternalApplication } from './api/external-application/index';
5
5
  import { FinApi } from './api/fin';
6
- import type { _Frame } from './api/frame';
6
+ import type { _Frame } from './api/frame/index';
7
7
  import type ChannelClient from './api/interappbus/channel/client';
8
- import { MessagingProtocols } from './api/interappbus/channel/protocols';
8
+ import { MessagingProtocols } from './api/interappbus/channel/protocols/index';
9
9
  import type { ChannelProvider } from './api/interappbus/channel/provider';
10
- import type { InteropBroker, InteropClient } from './api/interop';
11
- import type { Platform } from './api/platform';
12
- import type { Layout } from './api/platform/layout';
10
+ import type { InteropBroker, InteropClient } from './api/interop/index';
11
+ import type { Platform } from './api/platform/index';
12
+ import type { Layout } from './api/platform/layout/index';
13
13
  import { PlatformProvider } from './api/platform/provider';
14
- import { SnapshotSource } from './api/snapshot-source';
15
- import type { View } from './api/view';
16
- import { _Window } from './api/window';
14
+ import { SnapshotSource } from './api/snapshot-source/index';
15
+ import type { View } from './api/view/index';
16
+ import { _Window } from './api/window/index';
17
+ import { ColumnOrRow, TabStack } from './api/platform/layout/entities/layout-entities';
17
18
  export type Fin<MeType extends EntityType = 'window' | 'view'> = FinApi<MeType>;
18
- export type { Application, ExternalApplication, _Frame as Frame, ChannelClient, ChannelProvider, Platform, Layout, View, _Window as Window, InteropClient, InteropBroker, SnapshotSource };
19
+ export type { Application, ExternalApplication, _Frame as Frame, ChannelClient, ChannelProvider, Platform, Layout, View, ColumnOrRow, TabStack, _Window as Window, InteropClient, InteropBroker, SnapshotSource };
20
+ export type { LayoutEntityDefinition, LayoutEntityTypes, LayoutPosition } from './api/platform/layout/entities/shapes';
19
21
  export type WebContent = View | _Window;
20
22
  export type { PlatformProvider };
21
23
  export type ApplicationIdentity = {
@@ -244,7 +246,7 @@ export type DisplayMetadata = {
244
246
  */
245
247
  readonly glyph?: string;
246
248
  };
247
- export type LegacyWinOptionsInAppOptions = Pick<WindowCreationOptions, 'accelerator' | 'alwaysOnTop' | 'api' | 'aspectRatio' | 'autoplayPolicy' | 'autoShow' | 'backgroundColor' | 'contentNavigation' | 'contextMenu' | 'cornerRounding' | 'customData' | 'customRequestHeaders' | 'defaultCentered' | 'defaultHeight' | 'defaultLeft' | 'defaultTop' | 'defaultWidth' | 'frame' | 'hideOnClose' | 'icon' | 'maxHeight' | 'maximizable' | 'maxWidth' | 'minHeight' | 'minimizable' | 'minWidth' | 'opacity' | 'preloadScripts' | 'resizable' | 'resizeRegion' | 'saveWindowState' | 'ignoreSavedWindowState' | 'shadow' | 'showTaskbarIcon' | 'smallWindow' | 'state' | 'taskbarIconGroup' | 'waitForPageLoad'>;
249
+ export type LegacyWinOptionsInAppOptions = Pick<WindowCreationOptions, 'accelerator' | 'alwaysOnTop' | 'api' | 'aspectRatio' | 'autoplayPolicy' | 'autoShow' | 'backgroundColor' | 'contentNavigation' | 'contextMenu' | 'cornerRounding' | 'customData' | 'customRequestHeaders' | 'defaultCentered' | 'defaultHeight' | 'defaultLeft' | 'defaultTop' | 'defaultWidth' | 'frame' | 'hideOnClose' | 'icon' | 'maxHeight' | 'maximizable' | 'maxWidth' | 'minHeight' | 'minimizable' | 'minWidth' | 'opacity' | 'preloadScripts' | 'resizable' | 'resizeRegion' | 'saveWindowState' | 'ignoreSavedWindowState' | 'shadow' | 'showTaskbarIcon' | 'smallWindow' | 'state' | 'taskbarIconGroup' | 'waitForPageLoad' | '_internalWorkspaceData'>;
248
250
  export type Snapshot = {
249
251
  windows: WindowCreationOptions[];
250
252
  snapshotDetails?: {
@@ -792,6 +794,11 @@ export type MutableWindowOptions = {
792
794
  */
793
795
  showTaskbarIcon: boolean;
794
796
  interop: InteropConfig;
797
+ /**
798
+ * @internal
799
+ * Used by Workspace to store custom data. Overwriting or modifying this field may impact the functionality of Workspace
800
+ */
801
+ _internalWorkspaceData: any;
795
802
  workspacePlatform: WorkspacePlatformOptions;
796
803
  };
797
804
  export type WorkspacePlatformOptions = {
@@ -1191,6 +1198,11 @@ export type MutableViewOptions = {
1191
1198
  */
1192
1199
  preventDragOut: boolean;
1193
1200
  interop?: InteropConfig;
1201
+ /**
1202
+ * @internal
1203
+ * Used by Workspace to store custom data. Overwriting or modifying this field may impact the functionality of Workspace
1204
+ */
1205
+ _internalWorkspaceData: any;
1194
1206
  };
1195
1207
  /**
1196
1208
  * User-facing options for a view.
@@ -1330,6 +1342,22 @@ export type ApplySnapshotPayload = {
1330
1342
  */
1331
1343
  options?: ApplySnapshotOptions;
1332
1344
  };
1345
+ export type AddViewToStackOptions = {
1346
+ /**
1347
+ * Optional index within the stack to insert the view. Defaults to 0
1348
+ */
1349
+ index?: number;
1350
+ };
1351
+ export type CreateViewTarget = Identity & {
1352
+ /**
1353
+ * If specified, view creation will not attach to a window and caller must
1354
+ * insert the view into the layout explicitly
1355
+ */
1356
+ location?: {
1357
+ id: string;
1358
+ index?: number;
1359
+ };
1360
+ };
1333
1361
  export type CreateViewPayload = {
1334
1362
  /**
1335
1363
  * Options for the view to be added.
@@ -1338,7 +1366,7 @@ export type CreateViewPayload = {
1338
1366
  /**
1339
1367
  * Window the view will be added to. If no target is provided, a new window will be created.
1340
1368
  */
1341
- target: Identity;
1369
+ target?: CreateViewTarget;
1342
1370
  targetView?: Identity;
1343
1371
  };
1344
1372
  export type ReplaceViewPayload = {
@@ -1460,10 +1488,7 @@ export type PlatformWindowOptions = WindowCreationOptions & {
1460
1488
  */
1461
1489
  stylesheetUrl: string;
1462
1490
  };
1463
- export type PlatformViewCreationOptions = Partial<ViewOptions> & {
1464
- url: string;
1465
- target: Identity;
1466
- };
1491
+ export type PlatformViewCreationOptions = Partial<ViewOptions>;
1467
1492
  /**
1468
1493
  * Strategy to assign views to process affinity by domain.
1469
1494
  *
@@ -2199,6 +2224,22 @@ export type FindInPageOptions = {
2199
2224
  */
2200
2225
  medialCapitalAsWordStart?: boolean;
2201
2226
  };
2227
+ export type FindInPageResult = {
2228
+ requestId: number;
2229
+ /**
2230
+ * Position of the active match.
2231
+ */
2232
+ activeMatchOrdinal: number;
2233
+ /**
2234
+ * Number of Matches.
2235
+ */
2236
+ matches: number;
2237
+ /**
2238
+ * Coordinates of first match region.
2239
+ */
2240
+ selectionArea: Rectangle;
2241
+ finalUpdate: boolean;
2242
+ };
2202
2243
  export type FrameInfo = {
2203
2244
  name: string;
2204
2245
  uuid: string;
@@ -2940,3 +2981,24 @@ export interface InteropActionLoggingOption {
2940
2981
  export type InteropLoggingActions = 'beforeAction' | 'afterAction';
2941
2982
  export type InteropLoggingOptions = Record<InteropLoggingActions, InteropActionLoggingOption>;
2942
2983
  export type { Me } from './api/me';
2984
+ /**
2985
+ * Configuration for page capture.
2986
+ */
2987
+ export interface CapturePageOptions {
2988
+ /**
2989
+ * The area of the window to be captured.
2990
+ */
2991
+ area?: Rectangle;
2992
+ /**
2993
+ * @defaultValue 'png'
2994
+ *
2995
+ * The format of the captured image. Can be 'png', 'jpg', or 'bmp'.
2996
+ */
2997
+ format?: 'bmp' | 'jpg' | 'png';
2998
+ /**
2999
+ * @defaultValue 100
3000
+ *
3001
+ * Quality of JPEG image. Between 0 - 100.
3002
+ */
3003
+ quality?: number;
3004
+ }
@@ -0,0 +1,28 @@
1
+ import { ExposedProp } from "./decorators";
2
+ export type ConsumeStrategy<TMetaConsumeOptions, TPropConsumeDefinition> = {
3
+ getExposedFunctions: (options: TMetaConsumeOptions) => Promise<ExposedProp<TPropConsumeDefinition>[]>;
4
+ createFunction: (options: ExposedProp<TPropConsumeDefinition>, meta: TMetaConsumeOptions) => Function;
5
+ };
6
+ type PickOfType<T extends Record<any, any>, TTarget> = {
7
+ [key in keyof T as T[key] extends TTarget | undefined ? key : never]: T[key];
8
+ };
9
+ export type ApiClient<T extends Record<any, any>> = {
10
+ [key in keyof PickOfType<T, Function>]: (...args: Parameters<T[key]>) => ReturnType<T[key]> extends Promise<any> ? ReturnType<T[key]> : Promise<ReturnType<T[key]>>;
11
+ };
12
+ /**
13
+ * Consumer for apis exposed with {@see ApiExposer}.
14
+ *
15
+ * A strategy that matches the strategy used to expose a target API must be provided.
16
+ */
17
+ export declare class ApiConsumer<TMetaConsumeOptions = any, TPropConsumptionOptions = any> {
18
+ private strategy;
19
+ constructor(strategy: ConsumeStrategy<TMetaConsumeOptions, TPropConsumptionOptions>);
20
+ /**
21
+ * Consumes an api exposed using a given transport strategy, and generates a client
22
+ * for easy, type safe consumption of that client.
23
+ * @param options Strategy specific consumption options.
24
+ * @returns An api client matching the given type.
25
+ */
26
+ consume: <T extends Record<any, any>>(options: TMetaConsumeOptions) => Promise<ApiClient<T>>;
27
+ }
28
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiConsumer = void 0;
4
+ /**
5
+ * Consumer for apis exposed with {@see ApiExposer}.
6
+ *
7
+ * A strategy that matches the strategy used to expose a target API must be provided.
8
+ */
9
+ class ApiConsumer {
10
+ // eslint-disable-next-line
11
+ constructor(strategy) {
12
+ this.strategy = strategy;
13
+ /**
14
+ * Consumes an api exposed using a given transport strategy, and generates a client
15
+ * for easy, type safe consumption of that client.
16
+ * @param options Strategy specific consumption options.
17
+ * @returns An api client matching the given type.
18
+ */
19
+ this.consume = async (options) => {
20
+ const exposedProperties = await this.strategy.getExposedFunctions(options);
21
+ return exposedProperties.reduce((client, prop) => ({
22
+ ...client,
23
+ [prop.key]: this.strategy.createFunction(prop, options)
24
+ }), {});
25
+ };
26
+ }
27
+ }
28
+ exports.ApiConsumer = ApiConsumer;
@@ -0,0 +1,35 @@
1
+ import { ExposedProp } from './decorators';
2
+ export type ConsumptionConfig<T> = {
3
+ key: string;
4
+ options: T;
5
+ };
6
+ export type ExposeStrategy<TInstanceExposeOptions, TPropExposeOptions, TPropConsumeOptions> = {
7
+ /**
8
+ * Exposes the given function on the strategy.
9
+ */
10
+ exposeFunction: (target: Function, config: {
11
+ key: string;
12
+ options: TPropExposeOptions;
13
+ meta: TInstanceExposeOptions;
14
+ }) => Promise<TPropConsumeOptions>;
15
+ /**
16
+ * Exposes metadata to enable creation of client objects.
17
+ */
18
+ exposeMeta: (instanceOptions: TInstanceExposeOptions, props: ExposedProp<TPropConsumeOptions>[]) => Promise<void>;
19
+ };
20
+ /**
21
+ * Exposes api services on the transport of choice.
22
+ */
23
+ export declare class ApiExposer<TInstanceExposeOptions = any, TPropExposeOptions = any, TPropConsumptionOptions = any> {
24
+ private strategy;
25
+ /**
26
+ * @param strategy The expose strategy to use to expose instances.
27
+ */
28
+ constructor(strategy: ExposeStrategy<TInstanceExposeOptions, TPropExposeOptions, TPropConsumptionOptions>);
29
+ /**
30
+ * Exposes an instance of a given api on
31
+ * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
32
+ * @param instanceOptions Transport strategy specific options to use when exposing.
33
+ */
34
+ exposeInstance: (instance: Record<any, any>, instanceOptions: TInstanceExposeOptions) => Promise<void>;
35
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiExposer = void 0;
4
+ const decorators_1 = require("./decorators");
5
+ /**
6
+ * Exposes api services on the transport of choice.
7
+ */
8
+ class ApiExposer {
9
+ /**
10
+ * @param strategy The expose strategy to use to expose instances.
11
+ */
12
+ // eslint-disable-next-line
13
+ constructor(strategy) {
14
+ this.strategy = strategy;
15
+ /**
16
+ * Exposes an instance of a given api on
17
+ * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
18
+ * @param instanceOptions Transport strategy specific options to use when exposing.
19
+ */
20
+ this.exposeInstance = async (instance, instanceOptions) => {
21
+ const exposableProps = (0, decorators_1.getExposedProperties)(instance);
22
+ const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
23
+ const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
24
+ key,
25
+ options,
26
+ meta: instanceOptions
27
+ });
28
+ return {
29
+ key,
30
+ options: customConsumptionOptions
31
+ };
32
+ }));
33
+ await this.strategy.exposeMeta(instanceOptions, exposedProps);
34
+ };
35
+ }
36
+ ;
37
+ }
38
+ exports.ApiExposer = ApiExposer;
@@ -0,0 +1,10 @@
1
+ export type ExposedProp<T> = {
2
+ key: string;
3
+ options: T;
4
+ };
5
+ export declare const getExposedProperties: <T>(target: Record<any, any>) => ExposedProp<T>[];
6
+ /**
7
+ * Indicates that a class member function can be exposed using {@link ApiExposer}.
8
+ * @param options Options specific to the strategy used in {@link ApiExposer}
9
+ */
10
+ export declare const expose: <T = undefined>(options?: T) => any;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expose = exports.getExposedProperties = void 0;
4
+ const exposedProperties = Symbol('exposedProperties');
5
+ const getExposedProperties = (target) => {
6
+ return target[exposedProperties] || target.prototype[exposedProperties] || [];
7
+ };
8
+ exports.getExposedProperties = getExposedProperties;
9
+ /**
10
+ * Indicates that a class member function can be exposed using {@link ApiExposer}.
11
+ * @param options Options specific to the strategy used in {@link ApiExposer}
12
+ */
13
+ // Returns any as decorator typing is weird.
14
+ const expose = (options) => (target, key, descriptor) => {
15
+ target[exposedProperties] = target[exposedProperties] || [];
16
+ target[exposedProperties].push({ key, descriptor, options });
17
+ };
18
+ exports.expose = expose;
@@ -0,0 +1,4 @@
1
+ export * from './api-consumer';
2
+ export * from './api-exposer';
3
+ export * from './strategies';
4
+ export * from './decorators';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./api-consumer"), exports);
18
+ __exportStar(require("./api-exposer"), exports);
19
+ __exportStar(require("./strategies"), exports);
20
+ __exportStar(require("./decorators"), exports);
@@ -0,0 +1 @@
1
+ export * from './openfin-channels';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./openfin-channels"), exports);
@@ -0,0 +1,14 @@
1
+ import { ConsumeStrategy } from "../../api-consumer";
2
+ import { ExposedProp } from "../../decorators";
3
+ export type ChannelConsumeOptions = {
4
+ id: string;
5
+ };
6
+ export type ChannelsPropConfig = {
7
+ action: string;
8
+ };
9
+ export declare class ChannelsConsumer implements ConsumeStrategy<ChannelConsumeOptions, ChannelsPropConfig> {
10
+ private channel;
11
+ constructor(channel: any);
12
+ getExposedFunctions: (options: ChannelConsumeOptions) => Promise<ExposedProp<ChannelsPropConfig>[]>;
13
+ createFunction: (prop: ExposedProp<ChannelsPropConfig>) => Function;
14
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChannelsConsumer = void 0;
4
+ class ChannelsConsumer {
5
+ // eslint-disable-next-line
6
+ constructor(channel) {
7
+ this.channel = channel;
8
+ this.getExposedFunctions = async (options) => {
9
+ const { id } = options;
10
+ const { props } = await this.channel.dispatch(`api-meta:${id}`);
11
+ return props;
12
+ };
13
+ this.createFunction = (prop) => (...args) => {
14
+ const { action } = prop.options;
15
+ return this.channel.dispatch(action, { args });
16
+ };
17
+ }
18
+ ;
19
+ }
20
+ exports.ChannelsConsumer = ChannelsConsumer;
@@ -0,0 +1,20 @@
1
+ import { ExposeStrategy } from '../../api-exposer';
2
+ import { ExposedProp } from '../../decorators';
3
+ import { ChannelsPropConfig } from './channels-consumer';
4
+ type ChannelInstanceExposeOptions = {
5
+ id: string;
6
+ };
7
+ export type ChannelsPropOptions = {
8
+ action?: string;
9
+ } | undefined;
10
+ export declare class ChannelsExposer implements ExposeStrategy<ChannelInstanceExposeOptions, ChannelsPropOptions, ChannelsPropConfig> {
11
+ private channelProviderOrClient;
12
+ constructor(channelProviderOrClient: any);
13
+ exposeFunction: (target: Function, config: {
14
+ key: string;
15
+ options: ChannelsPropOptions;
16
+ meta: ChannelInstanceExposeOptions;
17
+ }) => Promise<ChannelsPropConfig>;
18
+ exposeMeta: ({ id }: ChannelInstanceExposeOptions, props: ExposedProp<ChannelsPropOptions>[]) => Promise<void>;
19
+ }
20
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChannelsExposer = void 0;
4
+ class ChannelsExposer {
5
+ // eslint-disable-next-line
6
+ constructor(channelProviderOrClient) {
7
+ this.channelProviderOrClient = channelProviderOrClient;
8
+ this.exposeFunction = async (target, config) => {
9
+ const { key, options, meta } = config;
10
+ const { id } = meta;
11
+ const action = `${id}.${(options === null || options === void 0 ? void 0 : options.action) || key}`;
12
+ await this.channelProviderOrClient.register(action, async ({ args }) => {
13
+ return target(...args);
14
+ });
15
+ return { action };
16
+ };
17
+ this.exposeMeta = async ({ id }, props) => {
18
+ const action = `api-meta:${id}`;
19
+ await this.channelProviderOrClient.register(action, () => ({ props }));
20
+ };
21
+ }
22
+ }
23
+ exports.ChannelsExposer = ChannelsExposer;
@@ -0,0 +1,2 @@
1
+ export * from './channels-consumer';
2
+ export * from './channels-exposer';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./channels-consumer"), exports);
18
+ __exportStar(require("./channels-exposer"), exports);
@@ -203,8 +203,7 @@ class ApplicationModule extends base_1.Base {
203
203
  // we do not want to expose this error, just continue if this analytics-only call fails
204
204
  });
205
205
  const app = await this._createFromManifest(manifestUrl);
206
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
207
- // @ts-ignore using private method without warning.
206
+ // @ts-expect-error using private method without warning.
208
207
  await app._run(opts); // eslint-disable-line no-underscore-dangle
209
208
  return app;
210
209
  }
@@ -141,11 +141,29 @@ class Application extends base_1.EmitterBase {
141
141
  * @tutorial Application.quit
142
142
  */
143
143
  async quit(force = false) {
144
- await this._close(force);
145
- await this.wire.sendAction('destroy-application', { force, ...this.identity });
146
- }
147
- _close(force = false) {
148
- return this.wire.sendAction('close-application', { force, ...this.identity }).then(() => undefined);
144
+ try {
145
+ await this._close(force);
146
+ await this.wire.sendAction('destroy-application', { force, ...this.identity });
147
+ }
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))) {
154
+ throw error;
155
+ }
156
+ }
157
+ }
158
+ async _close(force = false) {
159
+ try {
160
+ await this.wire.sendAction('close-application', { force, ...this.identity });
161
+ }
162
+ catch (error) {
163
+ if (!error.message.includes('Remote connection has closed')) {
164
+ throw error;
165
+ }
166
+ }
149
167
  }
150
168
  close(force = false) {
151
169
  console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
package/src/api/base.d.ts CHANGED
@@ -2,14 +2,13 @@
2
2
  import { EventEmitter } from 'events';
3
3
  import { Transport } from '../transport/transport';
4
4
  import type * as OpenFin from '../OpenFin';
5
- import Fin from './fin';
6
5
  import { BaseEvent, EventHandler } from './events/base';
7
6
  type ApplicationIdentity = OpenFin.ApplicationIdentity;
8
7
  type Identity = OpenFin.Identity;
9
8
  export declare class Base {
10
9
  wire: Transport;
11
10
  constructor(wire: Transport);
12
- protected get fin(): Fin;
11
+ protected get fin(): OpenFin.Fin<OpenFin.EntityType>;
13
12
  get me(): Identity;
14
13
  protected isNodeEnvironment: () => boolean;
15
14
  protected isOpenFinEnvironment: () => boolean;
package/src/api/base.js CHANGED
@@ -14,7 +14,6 @@ var _EmitterBase_emitterAccessor;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Reply = exports.EmitterBase = exports.Base = void 0;
16
16
  const promises_1 = require("../util/promises");
17
- const fin_store_1 = require("../transport/fin_store");
18
17
  class Base {
19
18
  constructor(wire) {
20
19
  this.isNodeEnvironment = () => {
@@ -29,7 +28,7 @@ class Base {
29
28
  this.wire = wire;
30
29
  }
31
30
  get fin() {
32
- return (0, fin_store_1.getFin)(this.wire);
31
+ return this.wire.getFin();
33
32
  }
34
33
  get me() {
35
34
  return this.wire.me;
@@ -1,4 +1,3 @@
1
- import type * as OpenFin from '../../OpenFin';
2
1
  /**
3
2
  * Modifies an event key to reflect propagation by prefixing with the topic.
4
3
  */
@@ -13,8 +12,6 @@ export type PropagatedEvent<Topic extends string, Event extends {
13
12
  type: string;
14
13
  } ? Omit<E, 'type'> & {
15
14
  type: PropagatedEventType<Topic, E['type']>;
16
- } & {
17
- [topic in `${Topic}Identity`]: OpenFin.Identity;
18
15
  } : never;
19
16
  /**
20
17
  * Handler for an event on an EventEmitter; selects the correct type for the event
@@ -1,6 +1,6 @@
1
1
  import type * as OpenFin from '../../OpenFin';
2
2
  import { PropagatedApplicationEvent } from './application';
3
- import { BaseEvent } from './base';
3
+ import { BaseEvent, IdentityEvent } from './base';
4
4
  import { PropagatedViewEvent } from './view';
5
5
  import { PropagatedWindowEvent } from './window';
6
6
  import { AppVersionCompleteEvent, AppVersionErrorEvent, AppVersionProgressEvent, AppVersionRuntimeStatusEvent } from '../../OpenFin';
@@ -38,7 +38,7 @@ export type EventWithId<Event extends AppVersionEvent> = Event extends infer E e
38
38
  appVersionId: string;
39
39
  } : never;
40
40
  export type AppVersionEventWithId = EventWithId<AppVersionEvent>;
41
- export type ApplicationCreatedEvent = BaseEvent & {
41
+ export type ApplicationCreatedEvent = IdentityEvent & {
42
42
  type: 'application-created';
43
43
  };
44
44
  export type DesktopIconClickedEvent = BaseEvent & {
@@ -1,15 +1,18 @@
1
1
  import type * as OpenFin from '../../OpenFin';
2
2
  import { NonPropagatedWebContentsEvent, WillPropagateWebContentsEvent } from './webcontents';
3
3
  import { NamedEvent, PropagatedEvent } from './base';
4
+ export type BaseViewEvent = {
5
+ target: OpenFin.Identity;
6
+ viewIdentity: OpenFin.Identity;
7
+ };
4
8
  export type TargetChangedEvent = NamedEvent & {
5
9
  type: 'target-changed';
6
10
  previousTarget: OpenFin.Identity;
7
- target: OpenFin.Identity;
8
11
  };
9
12
  /**
10
13
  * A View event that does not propagate to (republish on) parent topics.
11
14
  */
12
- export type NonPropagatedViewEvent = NonPropagatedWebContentsEvent;
15
+ export type NonPropagatedViewEvent = BaseViewEvent & NonPropagatedWebContentsEvent;
13
16
  export type AttachedEvent = NamedEvent & {
14
17
  type: 'attached';
15
18
  };
@@ -31,7 +34,7 @@ export type ShownEvent = NamedEvent & {
31
34
  /**
32
35
  * A View event that does propagate to (republish on) parent topics.
33
36
  */
34
- export type WillPropagateViewEvent = WillPropagateWebContentsEvent | AttachedEvent | CreatedEvent | DestroyedEvent | HiddenEvent | HotkeyEvent | ShownEvent | TargetChangedEvent;
37
+ export type WillPropagateViewEvent = BaseViewEvent & (WillPropagateWebContentsEvent | AttachedEvent | CreatedEvent | DestroyedEvent | HiddenEvent | HotkeyEvent | ShownEvent | TargetChangedEvent);
35
38
  export type ViewEvent = {
36
39
  topic: 'view';
37
40
  } & (NonPropagatedViewEvent | WillPropagateViewEvent);
@@ -64,6 +64,8 @@ export type DidFailLoadEvent = BaseLoadFailedEvent & {
64
64
  };
65
65
  export type FoundInPageEvent = NamedEvent & {
66
66
  type: 'found-in-page';
67
+ } & {
68
+ result: OpenFin.FindInPageResult;
67
69
  };
68
70
  /**
69
71
  * A WebContents event that does not propagate to (republish on) parent topics.