@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.
- package/package.json +1 -1
- package/src/OpenFin.d.ts +77 -18
- package/src/api/application/Factory.js +0 -1
- package/src/api/application/Instance.js +23 -5
- package/src/api/base.d.ts +1 -2
- package/src/api/base.js +1 -2
- package/src/api/events/system.d.ts +6 -3
- package/src/api/fin.js +1 -2
- package/src/api/interappbus/channel/index.d.ts +1 -0
- package/src/api/interappbus/channel/index.js +47 -47
- package/src/api/interappbus/channel/protocols/classic/strategy.js +24 -6
- package/src/api/interappbus/index.js +1 -1
- package/src/api/interop/InteropClient.d.ts +1 -1
- package/src/api/interop/InteropClient.js +1 -1
- package/src/api/interop/SessionContextGroupBroker.d.ts +1 -1
- package/src/api/interop/SessionContextGroupBroker.js +5 -4
- package/src/api/interop/SessionContextGroupClient.js +1 -1
- package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +1 -1
- package/src/api/interop/fdc3/PrivateChannelProvider.js +1 -8
- package/src/api/interop/fdc3/fdc3-1.2.js +34 -1
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +11 -10
- package/src/api/interop/fdc3/fdc3-2.0.js +10 -9
- package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +1 -1
- package/src/api/interop/fdc3/utils.js +24 -4
- package/src/api/platform/Factory.d.ts +2 -1
- package/src/api/platform/Factory.js +1 -4
- package/src/api/platform/Instance.d.ts +6 -5
- package/src/api/platform/Instance.js +1 -0
- package/src/api/platform/layout/Factory.js +15 -4
- package/src/api/platform/layout/Instance.d.ts +6 -0
- package/src/api/platform/layout/Instance.js +29 -1
- package/src/api/platform/layout/controllers/layout-content-cache.d.ts +9 -0
- package/src/api/platform/layout/controllers/layout-content-cache.js +54 -0
- package/src/api/platform/layout/controllers/layout-entities-controller.d.ts +119 -0
- package/src/api/platform/layout/controllers/layout-entities-controller.js +287 -0
- package/src/api/platform/layout/controllers/tab-drag-controller.d.ts +2 -1
- package/src/api/platform/layout/entities/layout-entities.d.ts +235 -0
- package/src/api/platform/layout/entities/layout-entities.js +312 -0
- package/src/api/platform/layout/entities/shapes.d.ts +6 -0
- package/src/api/platform/layout/entities/shapes.js +2 -0
- package/src/api/platform/layout/layout.constants.d.ts +1 -0
- package/src/api/platform/layout/layout.constants.js +4 -0
- package/src/api/platform/layout/shapes.d.ts +3 -0
- package/src/api/platform/layout/utils/layout-traversal.d.ts +4 -0
- package/src/api/platform/layout/utils/layout-traversal.js +65 -0
- package/src/api/platform/provider.d.ts +2 -1
- package/src/api/system/index.d.ts +9 -0
- package/src/api/system/index.js +78 -40
- package/src/api/view/Instance.d.ts +12 -3
- package/src/api/view/Instance.js +39 -4
- package/src/api/webcontents/main.d.ts +2 -22
- package/src/api/webcontents/main.js +2 -1
- package/src/api/window/Instance.d.ts +10 -0
- package/src/api/window/Instance.js +22 -0
- package/src/environment/mockEnvironment.d.ts +27 -0
- package/src/environment/mockEnvironment.js +61 -0
- package/src/mock.js +4 -83
- package/src/shapes/protocol.d.ts +17 -0
- package/src/transport/mockWire.d.ts +11 -0
- package/src/transport/mockWire.js +26 -0
- package/src/transport/transport-errors.d.ts +9 -1
- package/src/transport/transport-errors.js +45 -2
- package/src/transport/transport.d.ts +15 -5
- package/src/transport/transport.js +48 -20
- package/src/util/channel-api-relay.d.ts +13 -0
- package/src/util/channel-api-relay.js +47 -0
- package/src/util/errors.d.ts +1 -0
- package/src/util/errors.js +1 -0
- package/src/util/lazy.d.ts +34 -0
- package/src/util/lazy.js +54 -0
- package/src/util/ref-counter.d.ts +1 -1
- package/src/util/ref-counter.js +3 -2
- package/src/util/reversible-map.d.ts +11 -0
- package/src/util/reversible-map.js +49 -0
- package/src/transport/fin_store.d.ts +0 -4
- package/src/transport/fin_store.js +0 -16
package/package.json
CHANGED
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
|
|
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
|
*
|
|
@@ -1898,6 +1923,7 @@ export type Margins = {
|
|
|
1898
1923
|
* Options for printing a webpage in OpenFin.
|
|
1899
1924
|
*/
|
|
1900
1925
|
export type PrintOptions = {
|
|
1926
|
+
content?: 'self';
|
|
1901
1927
|
/**
|
|
1902
1928
|
* Disables prompting the user for print settings.
|
|
1903
1929
|
*/
|
|
@@ -1941,7 +1967,7 @@ export type PrintOptions = {
|
|
|
1941
1967
|
/**
|
|
1942
1968
|
* Page range to print.
|
|
1943
1969
|
*/
|
|
1944
|
-
pageRanges?: Record<'from' | 'to', number
|
|
1970
|
+
pageRanges?: Array<Record<'from' | 'to', number>>;
|
|
1945
1971
|
/**
|
|
1946
1972
|
* Duplex mode of the printed webpage.
|
|
1947
1973
|
*/
|
|
@@ -1951,6 +1977,14 @@ export type PrintOptions = {
|
|
|
1951
1977
|
*/
|
|
1952
1978
|
dpi?: Dpi;
|
|
1953
1979
|
};
|
|
1980
|
+
export type ScreenshotPrintOptions = {
|
|
1981
|
+
content: 'screenshot';
|
|
1982
|
+
};
|
|
1983
|
+
export type WindowViewsPrintOptions = {
|
|
1984
|
+
content: 'views';
|
|
1985
|
+
includeSelf?: boolean;
|
|
1986
|
+
};
|
|
1987
|
+
export type WindowPrintOptions = PrintOptions | ScreenshotPrintOptions | WindowViewsPrintOptions;
|
|
1954
1988
|
/**
|
|
1955
1989
|
* A request to write data to the clipboard.
|
|
1956
1990
|
*/
|
|
@@ -2218,6 +2252,7 @@ export type FindInPageResult = {
|
|
|
2218
2252
|
export type FrameInfo = {
|
|
2219
2253
|
name: string;
|
|
2220
2254
|
uuid: string;
|
|
2255
|
+
url: string;
|
|
2221
2256
|
entityType: EntityType;
|
|
2222
2257
|
parent: Identity;
|
|
2223
2258
|
};
|
|
@@ -2894,6 +2929,9 @@ export interface PopupResult<T = any> {
|
|
|
2894
2929
|
data?: T;
|
|
2895
2930
|
lastDispatchResult?: PopupResult;
|
|
2896
2931
|
}
|
|
2932
|
+
export type SystemShutdownHandler = (shutdownEvent: {
|
|
2933
|
+
proceed: () => void;
|
|
2934
|
+
}) => void;
|
|
2897
2935
|
export type AppVersionProgressEvent = {
|
|
2898
2936
|
type: 'app-version-progress';
|
|
2899
2937
|
} & AppVersionProgress;
|
|
@@ -2956,3 +2994,24 @@ export interface InteropActionLoggingOption {
|
|
|
2956
2994
|
export type InteropLoggingActions = 'beforeAction' | 'afterAction';
|
|
2957
2995
|
export type InteropLoggingOptions = Record<InteropLoggingActions, InteropActionLoggingOption>;
|
|
2958
2996
|
export type { Me } from './api/me';
|
|
2997
|
+
/**
|
|
2998
|
+
* Configuration for page capture.
|
|
2999
|
+
*/
|
|
3000
|
+
export interface CapturePageOptions {
|
|
3001
|
+
/**
|
|
3002
|
+
* The area of the window to be captured.
|
|
3003
|
+
*/
|
|
3004
|
+
area?: Rectangle;
|
|
3005
|
+
/**
|
|
3006
|
+
* @defaultValue 'png'
|
|
3007
|
+
*
|
|
3008
|
+
* The format of the captured image. Can be 'png', 'jpg', or 'bmp'.
|
|
3009
|
+
*/
|
|
3010
|
+
format?: 'bmp' | 'jpg' | 'png';
|
|
3011
|
+
/**
|
|
3012
|
+
* @defaultValue 100
|
|
3013
|
+
*
|
|
3014
|
+
* Quality of JPEG image. Between 0 - 100.
|
|
3015
|
+
*/
|
|
3016
|
+
quality?: number;
|
|
3017
|
+
}
|
|
@@ -203,7 +203,6 @@ 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
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;
|
|
@@ -141,11 +141,29 @@ class Application extends base_1.EmitterBase {
|
|
|
141
141
|
* @tutorial Application.quit
|
|
142
142
|
*/
|
|
143
143
|
async quit(force = false) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
|
31
|
+
return this.wire.getFin();
|
|
33
32
|
}
|
|
34
33
|
get me() {
|
|
35
34
|
return this.wire.me;
|
|
@@ -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,13 +38,16 @@ 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 =
|
|
41
|
+
export type ApplicationCreatedEvent = IdentityEvent & {
|
|
42
42
|
type: 'application-created';
|
|
43
43
|
};
|
|
44
44
|
export type DesktopIconClickedEvent = BaseEvent & {
|
|
45
45
|
type: 'desktop-icon-clicked';
|
|
46
46
|
};
|
|
47
|
+
export type SystemShutdownEvent = BaseEvent & {
|
|
48
|
+
type: 'system-shutdown';
|
|
49
|
+
};
|
|
47
50
|
export type SystemEvent = {
|
|
48
51
|
topic: 'system';
|
|
49
|
-
} & (ExcludeRequested<PropagatedWindowEvent> | PropagatedViewEvent | PropagatedApplicationEvent | ApplicationCreatedEvent | DesktopIconClickedEvent | IdleEvent | MonitorEvent | SessionChangedEvent | AppVersionEventWithId);
|
|
52
|
+
} & (ExcludeRequested<PropagatedWindowEvent> | PropagatedViewEvent | PropagatedApplicationEvent | ApplicationCreatedEvent | DesktopIconClickedEvent | IdleEvent | MonitorEvent | SessionChangedEvent | AppVersionEventWithId | SystemShutdownEvent);
|
|
50
53
|
export type SystemEventType = SystemEvent['type'];
|
package/src/api/fin.js
CHANGED
|
@@ -13,13 +13,11 @@ const index_8 = require("./global-hotkey/index");
|
|
|
13
13
|
const index_9 = require("./view/index");
|
|
14
14
|
const index_10 = require("./platform/index");
|
|
15
15
|
const me_1 = require("./me");
|
|
16
|
-
const fin_store_1 = require("../transport/fin_store");
|
|
17
16
|
const interop_1 = require("./interop");
|
|
18
17
|
const snapshot_source_1 = require("./snapshot-source");
|
|
19
18
|
class Fin extends events_1.EventEmitter {
|
|
20
19
|
constructor(wire) {
|
|
21
20
|
super();
|
|
22
|
-
(0, fin_store_1.registerFin)(wire, this);
|
|
23
21
|
this.wire = wire;
|
|
24
22
|
this.System = new index_1.default(wire);
|
|
25
23
|
this.Window = new index_2.default(wire);
|
|
@@ -33,6 +31,7 @@ class Fin extends events_1.EventEmitter {
|
|
|
33
31
|
this.View = new index_9.default(wire);
|
|
34
32
|
this.Interop = new interop_1.default(wire);
|
|
35
33
|
this.SnapshotSource = new snapshot_source_1.default(wire);
|
|
34
|
+
wire.registerFin(this);
|
|
36
35
|
this.me = (0, me_1.getMe)(wire);
|
|
37
36
|
// Handle disconnect events
|
|
38
37
|
wire.on('disconnected', () => {
|
|
@@ -15,6 +15,7 @@ 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;
|
|
18
19
|
getAllChannels(): Promise<ProviderIdentity[]>;
|
|
19
20
|
onChannelConnect(listener: (...args: any[]) => void): Promise<void>;
|
|
20
21
|
onChannelDisconnect(listener: (...args: any[]) => void): Promise<void>;
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _Channel_connectionManager;
|
|
13
|
+
var _Channel_connectionManager, _Channel_internalEmitter, _Channel_readyToConnect;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.Channel = void 0;
|
|
16
16
|
/* eslint-disable no-console */
|
|
@@ -18,16 +18,29 @@ const client_1 = require("./client");
|
|
|
18
18
|
const provider_1 = require("./provider");
|
|
19
19
|
const base_1 = require("../../base");
|
|
20
20
|
const connection_manager_1 = require("./connection-manager");
|
|
21
|
-
|
|
22
|
-
const
|
|
21
|
+
const events_1 = require("events");
|
|
22
|
+
const lazy_1 = require("../../../util/lazy");
|
|
23
23
|
class Channel extends base_1.EmitterBase {
|
|
24
24
|
constructor(wire) {
|
|
25
25
|
super(wire, 'channel');
|
|
26
26
|
_Channel_connectionManager.set(this, void 0);
|
|
27
|
+
_Channel_internalEmitter.set(this, new events_1.EventEmitter());
|
|
28
|
+
// OpenFin API has not been injected at construction time, *must* wait for API to be ready.
|
|
29
|
+
_Channel_readyToConnect.set(this, new lazy_1.AsyncRetryableLazy(async () => {
|
|
30
|
+
await Promise.all([
|
|
31
|
+
this.on('disconnected', (eventPayload) => {
|
|
32
|
+
client_1.default.handleProviderDisconnect(eventPayload);
|
|
33
|
+
}),
|
|
34
|
+
this.on('connected', (...args) => {
|
|
35
|
+
__classPrivateFieldGet(this, _Channel_internalEmitter, "f").emit('connected', ...args);
|
|
36
|
+
})
|
|
37
|
+
]).catch(() => new Error('error setting up channel connection listeners'));
|
|
38
|
+
}));
|
|
27
39
|
__classPrivateFieldSet(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
}
|
|
41
|
+
async channelExists(channelName) {
|
|
42
|
+
const channels = await this.getAllChannels();
|
|
43
|
+
return channels.some((providerIdentity) => providerIdentity.channelName === channelName);
|
|
31
44
|
}
|
|
32
45
|
async getAllChannels() {
|
|
33
46
|
return this.wire.sendAction('get-all-channels').then(({ payload }) => payload.data);
|
|
@@ -38,47 +51,39 @@ class Channel extends base_1.EmitterBase {
|
|
|
38
51
|
async onChannelDisconnect(listener) {
|
|
39
52
|
await this.on('disconnected', listener);
|
|
40
53
|
}
|
|
41
|
-
async connect(channelName, options) {
|
|
54
|
+
async connect(channelName, options = {}) {
|
|
55
|
+
// Make sure we don't connect before listeners are set up
|
|
56
|
+
// This also errors if we're not in OpenFin, ensuring we don't run unnecessary code
|
|
57
|
+
await __classPrivateFieldGet(this, _Channel_readyToConnect, "f").getValue();
|
|
42
58
|
if (!channelName || typeof channelName !== 'string') {
|
|
43
59
|
throw new Error('Please provide a channelName string to connect to a channel.');
|
|
44
60
|
}
|
|
45
|
-
const opts =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
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
|
+
}
|
|
58
78
|
try {
|
|
59
79
|
const { offer, rtc: rtcPacket } = await __classPrivateFieldGet(this, _Channel_connectionManager, "f").createClientOffer(opts);
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
if (entityType === 'iframe') {
|
|
63
|
-
// @ts-expect-error
|
|
64
|
-
// TODO: type this correctly (frame types are broken)
|
|
65
|
-
connectionUrl = (await this.fin.me.getInfo()).url;
|
|
66
|
-
}
|
|
67
|
-
else if (entityType === 'window' || entityType === 'view') {
|
|
68
|
-
connectionUrl = (await this.fin.me.getInfo()).url;
|
|
69
|
-
}
|
|
70
|
-
const res = await this.wire.sendAction('connect-to-channel', {
|
|
80
|
+
const connectionUrl = (await this.fin.me.getInfo()).url;
|
|
81
|
+
const { payload: { data: routingInfo } } = await this.wire.sendAction('connect-to-channel', {
|
|
71
82
|
channelName,
|
|
72
83
|
...opts,
|
|
73
84
|
offer,
|
|
74
85
|
connectionUrl
|
|
75
86
|
});
|
|
76
|
-
const { payload: { data: routingInfo } } = res;
|
|
77
|
-
// If there isn't a matching channel, the above sendAction call will error out and go to catch, skipping the logic below.
|
|
78
|
-
if (resolver) {
|
|
79
|
-
resolver();
|
|
80
|
-
}
|
|
81
|
-
this.removeListener('connected', listener);
|
|
82
87
|
const strategy = await __classPrivateFieldGet(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
|
|
83
88
|
const channel = new client_1.default(routingInfo, this.wire, strategy);
|
|
84
89
|
// It is the client's responsibility to handle endpoint disconnection to the provider.
|
|
@@ -97,18 +102,13 @@ class Channel extends base_1.EmitterBase {
|
|
|
97
102
|
});
|
|
98
103
|
return channel;
|
|
99
104
|
}
|
|
100
|
-
catch (
|
|
101
|
-
const shouldWait = { wait: true, ...opts }.wait;
|
|
105
|
+
catch (error) {
|
|
102
106
|
const internalNackMessage = 'internal-nack';
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
return waitResponse;
|
|
106
|
-
}
|
|
107
|
-
if (e.message === internalNackMessage) {
|
|
108
|
-
throw new Error(`No channel found for channelName: ${channelName}`);
|
|
107
|
+
if (error.message.includes(internalNackMessage)) {
|
|
108
|
+
throw new Error(`No channel found for channelName: ${channelName}.`);
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
|
-
throw new Error(
|
|
111
|
+
throw new Error(error);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
}
|
|
@@ -129,4 +129,4 @@ class Channel extends base_1.EmitterBase {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
exports.Channel = Channel;
|
|
132
|
-
_Channel_connectionManager = new WeakMap();
|
|
132
|
+
_Channel_connectionManager = new WeakMap(), _Channel_internalEmitter = new WeakMap(), _Channel_readyToConnect = new WeakMap();
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _ClassicStrategy_wire, _ClassicStrategy_endpointIdentityMap;
|
|
13
|
+
var _ClassicStrategy_wire, _ClassicStrategy_endpointIdentityMap, _ClassicStrategy_pendingMessagesByEndpointId;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ClassicInfo = exports.ClassicStrategy = void 0;
|
|
16
16
|
/*
|
|
@@ -26,7 +26,11 @@ class ClassicStrategy {
|
|
|
26
26
|
// Store full endpointIdentity by endpointId of all known endpoints for this strategy instance.
|
|
27
27
|
// (clients will only have 1: the provider, the provider will have all clients)
|
|
28
28
|
_ClassicStrategy_endpointIdentityMap.set(this, new Map());
|
|
29
|
+
// Store a set of cancellable promises to be able to reject them when client
|
|
30
|
+
// connection problems occur
|
|
31
|
+
_ClassicStrategy_pendingMessagesByEndpointId.set(this, new Map);
|
|
29
32
|
this.send = async (endpointId, action, payload) => {
|
|
33
|
+
var _a;
|
|
30
34
|
const to = __classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
|
|
31
35
|
if (!to) {
|
|
32
36
|
throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
|
|
@@ -38,20 +42,27 @@ class ClassicStrategy {
|
|
|
38
42
|
delete cleanId.endpointId;
|
|
39
43
|
}
|
|
40
44
|
delete cleanId.isLocalEndpointId;
|
|
41
|
-
|
|
45
|
+
// grab the promise before awaiting it to save in our pending messages map
|
|
46
|
+
const p = __classPrivateFieldGet(this, _ClassicStrategy_wire, "f")
|
|
42
47
|
.sendAction('send-channel-message', {
|
|
43
48
|
...cleanId,
|
|
44
49
|
providerIdentity: this.providerIdentity,
|
|
45
50
|
action,
|
|
46
51
|
payload
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
});
|
|
53
|
+
(_a = __classPrivateFieldGet(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)) === null || _a === void 0 ? void 0 : _a.add(p);
|
|
54
|
+
const raw = await p.catch((error) => {
|
|
55
|
+
throw new Error(error.message);
|
|
56
|
+
}).finally(() => {
|
|
57
|
+
var _a;
|
|
58
|
+
// clean up the pending promise
|
|
59
|
+
(_a = __classPrivateFieldGet(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)) === null || _a === void 0 ? void 0 : _a.delete(p);
|
|
50
60
|
});
|
|
51
61
|
return raw.payload.data.result;
|
|
52
62
|
};
|
|
53
63
|
this.close = async () => {
|
|
54
64
|
this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
|
|
65
|
+
[...__classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
|
|
55
66
|
__classPrivateFieldSet(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
|
|
56
67
|
};
|
|
57
68
|
__classPrivateFieldSet(this, _ClassicStrategy_wire, wire, "f");
|
|
@@ -63,13 +74,20 @@ class ClassicStrategy {
|
|
|
63
74
|
this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
|
|
64
75
|
}
|
|
65
76
|
async closeEndpoint(endpointId) {
|
|
77
|
+
const id = __classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
|
|
66
78
|
__classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
|
|
79
|
+
const pendingSet = __classPrivateFieldGet(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
|
|
80
|
+
pendingSet === null || pendingSet === void 0 ? void 0 : pendingSet.forEach((p) => {
|
|
81
|
+
const errorMsg = `Channel connection with identity uuid: ${id === null || id === void 0 ? void 0 : id.uuid} / name: ${id === null || id === void 0 ? void 0 : id.name} / endpointId: ${endpointId} no longer connected.`;
|
|
82
|
+
p.cancel(new Error(errorMsg));
|
|
83
|
+
});
|
|
67
84
|
}
|
|
68
85
|
isEndpointConnected(endpointId) {
|
|
69
86
|
return __classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
|
|
70
87
|
}
|
|
71
88
|
addEndpoint(endpointId, payload) {
|
|
72
89
|
__classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
|
|
90
|
+
__classPrivateFieldGet(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
|
|
73
91
|
}
|
|
74
92
|
isValidEndpointPayload(payload) {
|
|
75
93
|
var _a, _b;
|
|
@@ -78,6 +96,6 @@ class ClassicStrategy {
|
|
|
78
96
|
}
|
|
79
97
|
}
|
|
80
98
|
exports.ClassicStrategy = ClassicStrategy;
|
|
81
|
-
_ClassicStrategy_wire = new WeakMap(), _ClassicStrategy_endpointIdentityMap = new WeakMap();
|
|
99
|
+
_ClassicStrategy_wire = new WeakMap(), _ClassicStrategy_endpointIdentityMap = new WeakMap(), _ClassicStrategy_pendingMessagesByEndpointId = new WeakMap();
|
|
82
100
|
// Arbitrarily starting at 5 to leave the door open to backfilling pre endpointId etc.
|
|
83
101
|
exports.ClassicInfo = { version: 5, minimumVersion: 0, type: 'classic' };
|
|
@@ -17,7 +17,7 @@ class InterApplicationBus extends base_1.Base {
|
|
|
17
17
|
subscriberAdded: 'subscriber-added',
|
|
18
18
|
subscriberRemoved: 'subscriber-removed'
|
|
19
19
|
};
|
|
20
|
-
this.refCounter = new ref_counter_1.
|
|
20
|
+
this.refCounter = new ref_counter_1.RefCounter();
|
|
21
21
|
this.Channel = new index_1.Channel(wire);
|
|
22
22
|
this.emitter = new events_1.EventEmitter();
|
|
23
23
|
wire.registerMessageHandler(this.onmessage.bind(this));
|
|
@@ -88,7 +88,7 @@ import { Base } from '../base';
|
|
|
88
88
|
* @summary A SessionContextGroup instance method for adding a handler for context change.
|
|
89
89
|
* @param {ContextHandler} contextHandler The callback to be invoked. Is invoked when (a) the context changes or (b) immediately after getting created if the context is already set.
|
|
90
90
|
* @param {string} [contextType] The context type this handler should listen to. If not specified, a global handler for all context types will get created. Only one global handler is allowed per SessionContextGroup.
|
|
91
|
-
* @return {Promise<
|
|
91
|
+
* @return {Promise<Subscription>}
|
|
92
92
|
*/
|
|
93
93
|
/**
|
|
94
94
|
* {@link https://developers.openfin.co/of-docs/docs/enable-color-linking}
|
|
@@ -103,7 +103,7 @@ const utils_1 = require("./utils");
|
|
|
103
103
|
* @summary A SessionContextGroup instance method for adding a handler for context change.
|
|
104
104
|
* @param {ContextHandler} contextHandler The callback to be invoked. Is invoked when (a) the context changes or (b) immediately after getting created if the context is already set.
|
|
105
105
|
* @param {string} [contextType] The context type this handler should listen to. If not specified, a global handler for all context types will get created. Only one global handler is allowed per SessionContextGroup.
|
|
106
|
-
* @return {Promise<
|
|
106
|
+
* @return {Promise<Subscription>}
|
|
107
107
|
*/
|
|
108
108
|
/**
|
|
109
109
|
* {@link https://developers.openfin.co/of-docs/docs/enable-color-linking}
|
|
@@ -18,7 +18,7 @@ export default class SessionContextGroupBroker {
|
|
|
18
18
|
handlerAdded(payload: {
|
|
19
19
|
handlerId: string;
|
|
20
20
|
contextType?: string;
|
|
21
|
-
}, clientIdentity: OpenFin.ClientIdentity): void
|
|
21
|
+
}, clientIdentity: OpenFin.ClientIdentity): Promise<void>;
|
|
22
22
|
handlerRemoved(payload: {
|
|
23
23
|
handlerId: string;
|
|
24
24
|
}, clientIdentity: OpenFin.ClientIdentity): void;
|
|
@@ -48,7 +48,7 @@ class SessionContextGroupBroker {
|
|
|
48
48
|
getClientState(id) {
|
|
49
49
|
return this.clients.get(id.endpointId);
|
|
50
50
|
}
|
|
51
|
-
handlerAdded(payload, clientIdentity) {
|
|
51
|
+
async handlerAdded(payload, clientIdentity) {
|
|
52
52
|
const { handlerId, contextType } = payload;
|
|
53
53
|
const clientSubscriptionState = this.getClientState(clientIdentity);
|
|
54
54
|
if (!clientSubscriptionState) {
|
|
@@ -59,17 +59,18 @@ class SessionContextGroupBroker {
|
|
|
59
59
|
clientSubscriptionState.contextHandlers.set(contextType, [...currentHandlerList, handlerId]);
|
|
60
60
|
const currentContext = this.contextGroupMap.get(contextType);
|
|
61
61
|
if (currentContext) {
|
|
62
|
-
this.provider.dispatch(clientIdentity, handlerId, currentContext);
|
|
62
|
+
await this.provider.dispatch(clientIdentity, handlerId, currentContext);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
66
|
clientSubscriptionState.globalHandler = handlerId;
|
|
67
|
-
[...this.contextGroupMap.keys()].
|
|
67
|
+
const globalDispatchPromises = [...this.contextGroupMap.keys()].map(async (currentContextType) => {
|
|
68
68
|
const currentContext = this.contextGroupMap.get(currentContextType);
|
|
69
69
|
if (currentContext) {
|
|
70
|
-
this.provider.dispatch(clientIdentity, handlerId, currentContext);
|
|
70
|
+
await this.provider.dispatch(clientIdentity, handlerId, currentContext);
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
|
+
await Promise.all(globalDispatchPromises);
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
handlerRemoved(payload, clientIdentity) {
|
|
@@ -63,7 +63,7 @@ class SessionContextGroupClient extends base_1.Base {
|
|
|
63
63
|
handlerId = `sessionContextHandler:invoke-${this.id}`;
|
|
64
64
|
}
|
|
65
65
|
client.register(handlerId, (0, utils_1.wrapContextHandler)(contextHandler, handlerId));
|
|
66
|
-
client.dispatch(`sessionContextGroup:handlerAdded-${this.id}`, { handlerId, contextType });
|
|
66
|
+
await client.dispatch(`sessionContextGroup:handlerAdded-${this.id}`, { handlerId, contextType });
|
|
67
67
|
return { unsubscribe: await this.createUnsubscribeCb(handlerId) };
|
|
68
68
|
}
|
|
69
69
|
async createUnsubscribeCb(handlerId) {
|