@openfin/core 31.74.31 → 32.75.1
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 +58 -13
- package/src/api/application/Instance.d.ts +13 -1
- package/src/api/application/Instance.js +39 -7
- package/src/api/base.d.ts +1 -2
- package/src/api/base.js +1 -2
- package/src/api/events/application.d.ts +4 -1
- package/src/api/events/system.d.ts +6 -3
- package/src/api/events/webcontents.d.ts +54 -5
- package/src/api/fin.js +1 -2
- package/src/api/interappbus/channel/client.d.ts +2 -2
- package/src/api/interappbus/channel/index.d.ts +4 -3
- package/src/api/interappbus/channel/index.js +111 -74
- 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/utils.js +24 -4
- package/src/api/me.d.ts +1 -1
- package/src/api/me.js +2 -1
- package/src/api/platform/Factory.d.ts +3 -3
- package/src/api/platform/Factory.js +2 -11
- package/src/api/platform/Instance.d.ts +5 -4
- package/src/api/platform/Instance.js +2 -1
- package/src/api/platform/layout/Factory.d.ts +1 -1
- package/src/api/platform/layout/Factory.js +7 -39
- package/src/api/platform/layout/Instance.js +3 -0
- package/src/api/platform/layout/controllers/layout-entities-controller.d.ts +6 -2
- package/src/api/platform/layout/controllers/layout-entities-controller.js +40 -8
- package/src/api/platform/layout/entities/layout-entities.d.ts +143 -42
- package/src/api/platform/layout/entities/layout-entities.js +151 -43
- package/src/api/platform/layout/utils/layout-traversal.d.ts +1 -0
- package/src/api/platform/layout/utils/layout-traversal.js +11 -11
- 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 +6 -3
- package/src/api/view/Instance.js +10 -9
- 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/browser.d.ts +4 -2
- package/src/environment/browser.js +5 -2
- package/src/environment/environment.d.ts +4 -2
- package/src/environment/mockEnvironment.d.ts +27 -0
- package/src/environment/mockEnvironment.js +61 -0
- package/src/environment/node-env.d.ts +3 -2
- package/src/environment/node-env.js +5 -2
- package/src/environment/openfin-env.d.ts +5 -3
- package/src/environment/openfin-env.js +12 -10
- package/src/mock.js +4 -83
- package/src/shapes/protocol.d.ts +26 -9
- 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 +16 -5
- package/src/transport/transport.js +48 -20
- package/src/util/channel-api-relay.js +11 -1
- package/src/util/errors.d.ts +1 -0
- package/src/util/errors.js +1 -0
- package/src/util/lazy.d.ts +18 -0
- package/src/util/lazy.js +29 -1
- package/src/util/ref-counter.d.ts +1 -1
- package/src/util/ref-counter.js +3 -2
- package/src/api/platform/layout/controllers/splitter-controller.d.ts +0 -30
- package/src/api/platform/layout/controllers/splitter-controller.js +0 -83
- package/src/api/platform/layout/controllers/tab-drag-controller.d.ts +0 -58
- package/src/api/platform/layout/controllers/tab-drag-controller.js +0 -124
- package/src/api/platform/layout/utils/bounds-observer.d.ts +0 -19
- package/src/api/platform/layout/utils/bounds-observer.js +0 -52
- package/src/api/platform/layout/utils/view-overlay.d.ts +0 -35
- package/src/api/platform/layout/utils/view-overlay.js +0 -49
- package/src/transport/fin_store.d.ts +0 -4
- package/src/transport/fin_store.js +0 -16
|
@@ -5,6 +5,7 @@ const base_1 = require("../base");
|
|
|
5
5
|
class WebContents extends base_1.EmitterBase {
|
|
6
6
|
constructor(wire, identity, entityType) {
|
|
7
7
|
super(wire, entityType, identity.uuid, identity.name);
|
|
8
|
+
this.identity = identity;
|
|
8
9
|
this.entityType = entityType;
|
|
9
10
|
}
|
|
10
11
|
capturePage(options) {
|
|
@@ -41,7 +42,7 @@ class WebContents extends base_1.EmitterBase {
|
|
|
41
42
|
})
|
|
42
43
|
.then(() => undefined);
|
|
43
44
|
}
|
|
44
|
-
print(options) {
|
|
45
|
+
print(options = {}) {
|
|
45
46
|
return this.wire.sendAction('print', { ...this.identity, options }).then(() => undefined);
|
|
46
47
|
}
|
|
47
48
|
findInPage(searchTerm, options) {
|
|
@@ -334,6 +334,9 @@ import { WebContents } from '../webcontents/main';
|
|
|
334
334
|
* _Note: Caveats of small windows are no Aero Snap and drag to/from maximize._
|
|
335
335
|
* _Windows 10: Requires `maximizable` to be false. Resizing with the mouse is only possible down to 38x39 px._
|
|
336
336
|
*
|
|
337
|
+
* @property {boolean} [spellCheck=false]
|
|
338
|
+
* Enable spell check in input text fields for the window.
|
|
339
|
+
*
|
|
337
340
|
* @property {string} [state="normal"]
|
|
338
341
|
* The visible state of the window on creation.
|
|
339
342
|
* One of:
|
|
@@ -1071,4 +1074,11 @@ export declare class _Window extends WebContents<OpenFin.WindowEvent> {
|
|
|
1071
1074
|
* @tutorial Window.dispatchPopupResult
|
|
1072
1075
|
*/
|
|
1073
1076
|
dispatchPopupResult(data: any): Promise<void>;
|
|
1077
|
+
/**
|
|
1078
|
+
* Prints the contents of the window.
|
|
1079
|
+
*
|
|
1080
|
+
* @param options Configuration for the print task.
|
|
1081
|
+
* @tutorial Window.print
|
|
1082
|
+
*/
|
|
1083
|
+
print(options?: OpenFin.WindowPrintOptions): Promise<void>;
|
|
1074
1084
|
}
|
|
@@ -341,6 +341,9 @@ const view_1 = require("../view");
|
|
|
341
341
|
* _Note: Caveats of small windows are no Aero Snap and drag to/from maximize._
|
|
342
342
|
* _Windows 10: Requires `maximizable` to be false. Resizing with the mouse is only possible down to 38x39 px._
|
|
343
343
|
*
|
|
344
|
+
* @property {boolean} [spellCheck=false]
|
|
345
|
+
* Enable spell check in input text fields for the window.
|
|
346
|
+
*
|
|
344
347
|
* @property {string} [state="normal"]
|
|
345
348
|
* The visible state of the window on creation.
|
|
346
349
|
* One of:
|
|
@@ -1317,5 +1320,24 @@ class _Window extends main_1.WebContents {
|
|
|
1317
1320
|
});
|
|
1318
1321
|
await this.wire.sendAction('dispatch-popup-result', { data, ...this.identity });
|
|
1319
1322
|
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Prints the contents of the window.
|
|
1325
|
+
*
|
|
1326
|
+
* @param options Configuration for the print task.
|
|
1327
|
+
* @tutorial Window.print
|
|
1328
|
+
*/
|
|
1329
|
+
async print(options = { content: 'self' }) {
|
|
1330
|
+
switch (options.content) {
|
|
1331
|
+
case undefined:
|
|
1332
|
+
case 'self':
|
|
1333
|
+
return super.print(options);
|
|
1334
|
+
case 'screenshot':
|
|
1335
|
+
return this.wire.sendAction('print-screenshot', this.identity).then(() => undefined);
|
|
1336
|
+
case 'views':
|
|
1337
|
+
return this.wire.sendAction('print-views', { ...this.identity, options }).then(() => undefined);
|
|
1338
|
+
default:
|
|
1339
|
+
return undefined;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1320
1342
|
}
|
|
1321
1343
|
exports._Window = _Window;
|
|
@@ -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
|
-
|
|
7
|
-
|
|
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;
|
|
@@ -8,10 +8,13 @@ class BrowserEnvironment {
|
|
|
8
8
|
return window.crypto.getRandomValues(intArray)[0].toString(32);
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
observeBounds(element, onChange) {
|
|
12
12
|
throw new Error('Method not implemented.');
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
initLayout(_fin, wire, options) {
|
|
15
|
+
throw new Error('Method not implemented.');
|
|
16
|
+
}
|
|
17
|
+
initPlatform(...args) {
|
|
15
18
|
throw new Error('Method not implemented.');
|
|
16
19
|
}
|
|
17
20
|
writeToken(path, token) {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type * as OpenFin from '../OpenFin';
|
|
2
|
+
import { Transport } from '../transport/transport';
|
|
2
3
|
import { NewConnectConfig } from '../transport/wire';
|
|
3
4
|
type EntityType = OpenFin.EntityType;
|
|
4
5
|
export interface Environment {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
initLayout(fin: OpenFin.Fin<OpenFin.EntityType>, wire: Transport, ...args: Parameters<OpenFin.Fin['Platform']['Layout']['init']>): ReturnType<OpenFin.Fin['Platform']['Layout']['init']>;
|
|
7
|
+
initPlatform(fin: OpenFin.Fin<OpenFin.EntityType>, ...args: Parameters<OpenFin.Fin['Platform']['init']>): ReturnType<OpenFin.Fin['Platform']['init']>;
|
|
8
|
+
observeBounds(element: Element, onChange: (bounds: DOMRect) => Promise<void> | void): (() => void);
|
|
7
9
|
writeToken(path: string, token: string): Promise<string>;
|
|
8
10
|
retrievePort(config: NewConnectConfig): Promise<number>;
|
|
9
11
|
getNextMessageId(): any;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Environment } from './environment';
|
|
2
|
+
import type * as OpenFin from '../OpenFin';
|
|
3
|
+
import { NewConnectConfig } from '../transport/wire';
|
|
4
|
+
import { EntityType } from '../OpenFin';
|
|
5
|
+
export declare class MockEnvironment implements Environment {
|
|
6
|
+
getDefaultChannelOptions(): {
|
|
7
|
+
create: OpenFin.ChannelCreateOptions;
|
|
8
|
+
connect: OpenFin.ChannelConnectOptions;
|
|
9
|
+
};
|
|
10
|
+
getRtcPeer(): RTCPeerConnection;
|
|
11
|
+
initLayout(): Promise<never>;
|
|
12
|
+
initPlatform(): Promise<never>;
|
|
13
|
+
observeBounds(): never;
|
|
14
|
+
writeToken(path: string, token: string): Promise<string>;
|
|
15
|
+
retrievePort(config: NewConnectConfig): Promise<number>;
|
|
16
|
+
getNextMessageId(): string;
|
|
17
|
+
getRandomId(): string;
|
|
18
|
+
createChildContent(options: any): Promise<any>;
|
|
19
|
+
getWebWindow(identity: OpenFin.Identity): globalThis.Window;
|
|
20
|
+
getCurrentEntityIdentity(): OpenFin.EntityInfo;
|
|
21
|
+
getCurrentEntityType(): EntityType;
|
|
22
|
+
raiseEvent(eventName: string, eventArgs: any): void;
|
|
23
|
+
getUrl(): string;
|
|
24
|
+
whenReady(): Promise<void>;
|
|
25
|
+
childViews: boolean;
|
|
26
|
+
getWsConstructor(): any;
|
|
27
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockEnvironment = void 0;
|
|
4
|
+
const me_1 = require("../api/me");
|
|
5
|
+
class MockEnvironment {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.childViews = true;
|
|
8
|
+
}
|
|
9
|
+
getDefaultChannelOptions() {
|
|
10
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
11
|
+
}
|
|
12
|
+
getRtcPeer() {
|
|
13
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
14
|
+
}
|
|
15
|
+
initLayout() {
|
|
16
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
17
|
+
}
|
|
18
|
+
initPlatform() {
|
|
19
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
20
|
+
}
|
|
21
|
+
observeBounds() {
|
|
22
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
23
|
+
}
|
|
24
|
+
writeToken(path, token) {
|
|
25
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
26
|
+
}
|
|
27
|
+
retrievePort(config) {
|
|
28
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
29
|
+
}
|
|
30
|
+
getNextMessageId() {
|
|
31
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
32
|
+
}
|
|
33
|
+
getRandomId() {
|
|
34
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
35
|
+
}
|
|
36
|
+
createChildContent(options) {
|
|
37
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
38
|
+
}
|
|
39
|
+
getWebWindow(identity) {
|
|
40
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
41
|
+
}
|
|
42
|
+
getCurrentEntityIdentity() {
|
|
43
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
44
|
+
}
|
|
45
|
+
getCurrentEntityType() {
|
|
46
|
+
return 'unknown';
|
|
47
|
+
}
|
|
48
|
+
raiseEvent(eventName, eventArgs) {
|
|
49
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
50
|
+
}
|
|
51
|
+
getUrl() {
|
|
52
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
53
|
+
}
|
|
54
|
+
whenReady() {
|
|
55
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
56
|
+
}
|
|
57
|
+
getWsConstructor() {
|
|
58
|
+
throw new Error('Method not implemented.');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.MockEnvironment = MockEnvironment;
|
|
@@ -3,6 +3,7 @@ import { Environment } from './environment';
|
|
|
3
3
|
import { NewConnectConfig } from '../transport/wire';
|
|
4
4
|
type EntityType = OpenFin.EntityType;
|
|
5
5
|
export default class NodeEnvironment implements Environment {
|
|
6
|
+
observeBounds(element: Element, onChange: (bounds: DOMRect) => void | Promise<void>): () => void;
|
|
6
7
|
getDefaultChannelOptions(): {
|
|
7
8
|
create: OpenFin.ChannelCreateOptions;
|
|
8
9
|
connect: OpenFin.ChannelConnectOptions;
|
|
@@ -10,8 +11,8 @@ export default class NodeEnvironment implements Environment {
|
|
|
10
11
|
getRtcPeer(): RTCPeerConnection;
|
|
11
12
|
private messageCounter;
|
|
12
13
|
childViews: boolean;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
initLayout(): Promise<never>;
|
|
15
|
+
initPlatform(): Promise<never>;
|
|
15
16
|
whenReady(): Promise<void>;
|
|
16
17
|
writeToken: (path: string, token: string) => Promise<string>;
|
|
17
18
|
retrievePort: (config: NewConnectConfig) => Promise<number>;
|
|
@@ -43,16 +43,19 @@ class NodeEnvironment {
|
|
|
43
43
|
throw new transport_errors_1.NotImplementedError('Not Implemented');
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
+
observeBounds(element, onChange) {
|
|
47
|
+
throw new Error('Method not implemented.');
|
|
48
|
+
}
|
|
46
49
|
getDefaultChannelOptions() {
|
|
47
50
|
return { create: {}, connect: {} };
|
|
48
51
|
}
|
|
49
52
|
getRtcPeer() {
|
|
50
53
|
throw new Error('Method not implemented.');
|
|
51
54
|
}
|
|
52
|
-
async
|
|
55
|
+
async initLayout() {
|
|
53
56
|
throw new Error('Method not implemented.');
|
|
54
57
|
}
|
|
55
|
-
async
|
|
58
|
+
async initPlatform() {
|
|
56
59
|
throw new Error('Method not implemented.');
|
|
57
60
|
}
|
|
58
61
|
whenReady() {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type * as OpenFin from '../OpenFin';
|
|
2
|
-
import {
|
|
2
|
+
import { Transport } from '../transport/transport';
|
|
3
3
|
import { NewConnectConfig } from '../transport/wire';
|
|
4
4
|
import { BrowserEnvironment } from './browser';
|
|
5
|
+
import { ChildContentOptions, Environment } from './environment';
|
|
5
6
|
type EntityType = OpenFin.EntityType;
|
|
6
7
|
export default class OpenFinEnvironment extends BrowserEnvironment implements Environment {
|
|
7
8
|
#private;
|
|
@@ -12,8 +13,9 @@ export default class OpenFinEnvironment extends BrowserEnvironment implements En
|
|
|
12
13
|
create: OpenFin.ChannelCreateOptions;
|
|
13
14
|
connect: OpenFin.ChannelConnectOptions;
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
initLayout(_fin: OpenFin.Fin<OpenFin.EntityType>, wire: Transport, options: OpenFin.InitLayoutOptions): Promise<OpenFin.Layout>;
|
|
17
|
+
initPlatform(_fin: OpenFin.Fin<OpenFin.EntityType>, options?: OpenFin.InitPlatformOptions): ReturnType<OpenFin.Fin['Platform']['init']>;
|
|
18
|
+
observeBounds(element: Element, onChange: (bounds: DOMRect) => void | Promise<void>): () => void;
|
|
17
19
|
writeToken: (path: string, token: string) => Promise<string>;
|
|
18
20
|
retrievePort: (config: NewConnectConfig) => Promise<number>;
|
|
19
21
|
getNextMessageId: () => any;
|
|
@@ -12,10 +12,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
12
12
|
};
|
|
13
13
|
var _OpenFinEnvironment_ready;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
/* global window, location */
|
|
16
|
-
/* eslint-disable class-methods-use-this */
|
|
17
15
|
const transport_errors_1 = require("../transport/transport-errors");
|
|
18
16
|
const browser_1 = require("./browser");
|
|
17
|
+
const bounds_observer_1 = require("../api/platform/renderer/utils/bounds-observer");
|
|
19
18
|
// Inherits the following BrowserEnvironment methods: getRtcPeer, getRandomId, getUrl, getWsConstructor.
|
|
20
19
|
class OpenFinEnvironment extends browser_1.BrowserEnvironment {
|
|
21
20
|
constructor() {
|
|
@@ -73,17 +72,20 @@ class OpenFinEnvironment extends browser_1.BrowserEnvironment {
|
|
|
73
72
|
...((_b = (_a = fin.__internal_.initialOptions.experimental) === null || _a === void 0 ? void 0 : _a.defaultChannelOptions) !== null && _b !== void 0 ? _b : {})
|
|
74
73
|
};
|
|
75
74
|
}
|
|
76
|
-
async
|
|
77
|
-
const
|
|
75
|
+
async initLayout(_fin, wire, options) {
|
|
76
|
+
const { initLayout } = await Promise.resolve().then(() => require(
|
|
78
77
|
/* webpackChunkName: 'layout' */
|
|
79
|
-
'../api/platform/renderer/
|
|
80
|
-
return
|
|
78
|
+
'../api/platform/renderer/init-layout'));
|
|
79
|
+
return initLayout(_fin, wire, options);
|
|
81
80
|
}
|
|
82
|
-
async
|
|
83
|
-
const
|
|
81
|
+
async initPlatform(_fin, options) {
|
|
82
|
+
const { initPlatformProvider } = await Promise.resolve().then(() => require(
|
|
84
83
|
/* webpackChunkName: 'provider' */
|
|
85
|
-
'../api/platform/renderer/platform-provider'))
|
|
86
|
-
return
|
|
84
|
+
'../api/platform/renderer/init-platform-provider'));
|
|
85
|
+
return initPlatformProvider(this, _fin, options);
|
|
86
|
+
}
|
|
87
|
+
observeBounds(element, onChange) {
|
|
88
|
+
return (0, bounds_observer_1.observeBounds)(element, onChange);
|
|
87
89
|
}
|
|
88
90
|
// eslint-disable-next-line class-methods-use-this
|
|
89
91
|
resolveUrl(url) {
|
package/src/mock.js
CHANGED
|
@@ -1,94 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fin = void 0;
|
|
4
|
-
/* eslint-disable import/prefer-default-export */
|
|
5
|
-
/* eslint-disable spaced-comment */
|
|
6
|
-
/* eslint-disable @typescript-eslint/triple-slash-reference */
|
|
7
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
8
|
-
/* eslint-disable class-methods-use-this */
|
|
9
|
-
const events_1 = require("events");
|
|
10
4
|
const OpenFin = require("./OpenFin");
|
|
11
5
|
const fin_1 = require("./api/fin");
|
|
12
6
|
const transport_1 = require("./transport/transport");
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
connect(address) {
|
|
16
|
-
throw new Error('You are not running in OpenFin.');
|
|
17
|
-
}
|
|
18
|
-
connectSync() {
|
|
19
|
-
throw new Error('You are not running in OpenFin.');
|
|
20
|
-
}
|
|
21
|
-
send(data) {
|
|
22
|
-
throw new Error('You are not running in OpenFin.');
|
|
23
|
-
}
|
|
24
|
-
shutdown() {
|
|
25
|
-
throw new Error('You are not running in OpenFin.');
|
|
26
|
-
}
|
|
27
|
-
getPort() {
|
|
28
|
-
throw new Error('This transport has no port');
|
|
29
|
-
}
|
|
30
|
-
// eslint-disable-next-line no-useless-constructor
|
|
31
|
-
constructor() {
|
|
32
|
-
super();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
class MockEnvironment {
|
|
36
|
-
constructor() {
|
|
37
|
-
this.childViews = true;
|
|
38
|
-
}
|
|
39
|
-
getDefaultChannelOptions() {
|
|
40
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
41
|
-
}
|
|
42
|
-
getRtcPeer() {
|
|
43
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
44
|
-
}
|
|
45
|
-
getManagerConstructor() {
|
|
46
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
47
|
-
}
|
|
48
|
-
getProviderInitializer() {
|
|
49
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
50
|
-
}
|
|
51
|
-
writeToken(path, token) {
|
|
52
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
53
|
-
}
|
|
54
|
-
retrievePort(config) {
|
|
55
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
56
|
-
}
|
|
57
|
-
getNextMessageId() {
|
|
58
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
59
|
-
}
|
|
60
|
-
getRandomId() {
|
|
61
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
62
|
-
}
|
|
63
|
-
createChildContent(options) {
|
|
64
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
65
|
-
}
|
|
66
|
-
getWebWindow(identity) {
|
|
67
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
68
|
-
}
|
|
69
|
-
getCurrentEntityIdentity() {
|
|
70
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
71
|
-
}
|
|
72
|
-
getCurrentEntityType() {
|
|
73
|
-
return 'unknown';
|
|
74
|
-
}
|
|
75
|
-
raiseEvent(eventName, eventArgs) {
|
|
76
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
77
|
-
}
|
|
78
|
-
getUrl() {
|
|
79
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
80
|
-
}
|
|
81
|
-
whenReady() {
|
|
82
|
-
throw new Error(me_1.environmentUnsupportedMessage);
|
|
83
|
-
}
|
|
84
|
-
getWsConstructor() {
|
|
85
|
-
throw new Error('Method not implemented.');
|
|
86
|
-
}
|
|
87
|
-
}
|
|
7
|
+
const mockEnvironment_1 = require("./environment/mockEnvironment");
|
|
8
|
+
const mockWire_1 = require("./transport/mockWire");
|
|
88
9
|
exports.fin = ((typeof window !== 'undefined' && (window === null || window === void 0 ? void 0 : window.fin)) ||
|
|
89
10
|
(() => {
|
|
90
|
-
const environment = new MockEnvironment();
|
|
91
|
-
const transport = new transport_1.Transport(MockWire, environment, {
|
|
11
|
+
const environment = new mockEnvironment_1.MockEnvironment();
|
|
12
|
+
const transport = new transport_1.Transport(mockWire_1.MockWire, environment, {
|
|
92
13
|
uuid: '',
|
|
93
14
|
name: ''
|
|
94
15
|
});
|
package/src/shapes/protocol.d.ts
CHANGED
|
@@ -37,6 +37,22 @@ export interface ProtocolMap extends ProtocolMapBase {
|
|
|
37
37
|
}>;
|
|
38
38
|
'trigger-before-unload': IdentityCall<{}, boolean>;
|
|
39
39
|
'window-get-views': IdentityCall<{}, OpenFin.Identity[]>;
|
|
40
|
+
'print': {
|
|
41
|
+
request: OpenFin.Identity & {
|
|
42
|
+
options: OpenFin.PrintOptions;
|
|
43
|
+
};
|
|
44
|
+
response: void;
|
|
45
|
+
};
|
|
46
|
+
'print-screenshot': {
|
|
47
|
+
request: OpenFin.Identity;
|
|
48
|
+
response: void;
|
|
49
|
+
};
|
|
50
|
+
'print-views': {
|
|
51
|
+
request: OpenFin.Identity & {
|
|
52
|
+
options: OpenFin.WindowViewsPrintOptions;
|
|
53
|
+
};
|
|
54
|
+
response: void;
|
|
55
|
+
};
|
|
40
56
|
'launch-manifest': {
|
|
41
57
|
request: {
|
|
42
58
|
manifestUrl: string;
|
|
@@ -66,16 +82,18 @@ export interface ProtocolMap extends ProtocolMapBase {
|
|
|
66
82
|
};
|
|
67
83
|
response: OpenFin.NativeWindowIntegrationProviderAuthorization;
|
|
68
84
|
};
|
|
69
|
-
'get-permissions':
|
|
70
|
-
|
|
71
|
-
response: any;
|
|
72
|
-
};
|
|
85
|
+
'get-permissions': GetterCall<any>;
|
|
86
|
+
'get-all-channels': GetterCall<OpenFin.ProviderIdentity[]>;
|
|
73
87
|
'set-file-download-location': {
|
|
74
|
-
request: OpenFin.
|
|
88
|
+
request: OpenFin.Identity & {
|
|
75
89
|
downloadLocation: string;
|
|
76
90
|
};
|
|
77
91
|
response: void;
|
|
78
92
|
};
|
|
93
|
+
'get-file-download-location': {
|
|
94
|
+
request: OpenFin.ApplicationIdentity;
|
|
95
|
+
response: string;
|
|
96
|
+
};
|
|
79
97
|
'close-popup-menu': IdentityCall;
|
|
80
98
|
'fdc3-add-context-listener': VoidCall;
|
|
81
99
|
'fdc3-broadcast': VoidCall;
|
|
@@ -144,16 +162,15 @@ export interface ProtocolMap extends ProtocolMapBase {
|
|
|
144
162
|
};
|
|
145
163
|
response: void;
|
|
146
164
|
};
|
|
147
|
-
'system-get-printers':
|
|
148
|
-
|
|
149
|
-
response: OpenFin.PrinterInfo[];
|
|
150
|
-
};
|
|
165
|
+
'system-get-printers': GetterCall<OpenFin.PrinterInfo[]>;
|
|
166
|
+
'system-register-shutdown-handler': VoidCall;
|
|
151
167
|
}
|
|
152
168
|
type ApiCall<Request, Response> = {
|
|
153
169
|
request: Request;
|
|
154
170
|
response: Response;
|
|
155
171
|
};
|
|
156
172
|
type VoidCall = ApiCall<void, void>;
|
|
173
|
+
type GetterCall<T> = ApiCall<void, T>;
|
|
157
174
|
type IdentityCall<AdditionalPayload = {}, Response = void> = ApiCall<AdditionalPayload & OpenFin.Identity, Response>;
|
|
158
175
|
interface ProtocolMapBase {
|
|
159
176
|
[action: string]: {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { Wire } from './wire';
|
|
4
|
+
export declare class MockWire extends EventEmitter implements Wire {
|
|
5
|
+
connect(address: string): Promise<any>;
|
|
6
|
+
connectSync(): any;
|
|
7
|
+
send(data: any): Promise<any>;
|
|
8
|
+
shutdown(): Promise<void>;
|
|
9
|
+
getPort(): string;
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockWire = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
class MockWire extends events_1.EventEmitter {
|
|
6
|
+
connect(address) {
|
|
7
|
+
throw new Error('You are not running in OpenFin.');
|
|
8
|
+
}
|
|
9
|
+
connectSync() {
|
|
10
|
+
throw new Error('You are not running in OpenFin.');
|
|
11
|
+
}
|
|
12
|
+
send(data) {
|
|
13
|
+
throw new Error('You are not running in OpenFin.');
|
|
14
|
+
}
|
|
15
|
+
shutdown() {
|
|
16
|
+
throw new Error('You are not running in OpenFin.');
|
|
17
|
+
}
|
|
18
|
+
getPort() {
|
|
19
|
+
throw new Error('This transport has no port');
|
|
20
|
+
}
|
|
21
|
+
// eslint-disable-next-line no-useless-constructor
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.MockWire = MockWire;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { ErrorPlainObject } from '../util/errors';
|
|
2
3
|
export type ReadyState = 'CONNECTING' | 'OPEN' | 'CLOSING' | 'CLOSED';
|
|
3
4
|
export declare class DisconnectedError extends Error {
|
|
@@ -18,6 +19,13 @@ export type RuntimeErrorPayload = {
|
|
|
18
19
|
reason: string;
|
|
19
20
|
error?: ErrorPlainObject;
|
|
20
21
|
};
|
|
22
|
+
declare class InternalError<T extends ErrorPlainObject = ErrorPlainObject> extends Error {
|
|
23
|
+
constructor(err: T);
|
|
24
|
+
}
|
|
21
25
|
export declare class RuntimeError extends Error {
|
|
22
|
-
|
|
26
|
+
cause?: InternalError;
|
|
27
|
+
static getCallSite(callsToRemove?: number): NodeJS.CallSite[];
|
|
28
|
+
static prepareStackTrace(err: Error, callSites: NodeJS.CallSite[]): string;
|
|
29
|
+
constructor(payload: RuntimeErrorPayload, callSites?: NodeJS.CallSite[]);
|
|
23
30
|
}
|
|
31
|
+
export {};
|
|
@@ -23,13 +23,56 @@ exports.NotImplementedError = NotImplementedError;
|
|
|
23
23
|
class NotSupportedError extends Error {
|
|
24
24
|
}
|
|
25
25
|
exports.NotSupportedError = NotSupportedError;
|
|
26
|
+
class InternalError extends Error {
|
|
27
|
+
constructor(err) {
|
|
28
|
+
const { message, name, stack, ...rest } = err;
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = name || 'Error';
|
|
31
|
+
this.stack = stack !== null && stack !== void 0 ? stack : this.toString();
|
|
32
|
+
Object.keys(rest).forEach(key => {
|
|
33
|
+
this[key] = rest[key];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// For documentation of the error methods being used see here: https://v8.dev/docs/stack-trace-api
|
|
26
38
|
class RuntimeError extends Error {
|
|
27
|
-
|
|
39
|
+
static getCallSite(callsToRemove = 0) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const length = Error.stackTraceLimit;
|
|
42
|
+
const realCallsToRemove = callsToRemove + 1; // remove this call;
|
|
43
|
+
Error.stackTraceLimit = length + realCallsToRemove;
|
|
44
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
45
|
+
const _prepareStackTrace = Error.prepareStackTrace;
|
|
46
|
+
// This will be called when we access the `stack` property
|
|
47
|
+
Error.prepareStackTrace = (_, stack) => stack;
|
|
48
|
+
// stack is optional in non chromium contexts
|
|
49
|
+
const stack = (_b = (_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.slice(realCallsToRemove)) !== null && _b !== void 0 ? _b : [];
|
|
50
|
+
Error.prepareStackTrace = _prepareStackTrace;
|
|
51
|
+
Error.stackTraceLimit = length;
|
|
52
|
+
return stack;
|
|
53
|
+
}
|
|
54
|
+
static prepareStackTrace(err, callSites) {
|
|
55
|
+
if (typeof Error.prepareStackTrace === 'function') {
|
|
56
|
+
return Error.prepareStackTrace(err, callSites);
|
|
57
|
+
}
|
|
58
|
+
let string = "";
|
|
59
|
+
string += err.name || "Error";
|
|
60
|
+
string += `: ${err.message || ""}`;
|
|
61
|
+
for (const callSite of callSites) {
|
|
62
|
+
string += `\n at ${callSite.toString()}`;
|
|
63
|
+
}
|
|
64
|
+
return string;
|
|
65
|
+
}
|
|
66
|
+
;
|
|
67
|
+
constructor(payload, callSites) {
|
|
28
68
|
const { reason, error } = payload;
|
|
29
69
|
super(reason);
|
|
30
70
|
this.name = 'RuntimeError';
|
|
31
71
|
if (error === null || error === void 0 ? void 0 : error.stack) {
|
|
32
|
-
this.
|
|
72
|
+
this.cause = new InternalError(error);
|
|
73
|
+
}
|
|
74
|
+
if (callSites) {
|
|
75
|
+
this.stack = RuntimeError.prepareStackTrace(this, callSites);
|
|
33
76
|
}
|
|
34
77
|
}
|
|
35
78
|
}
|
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { EventEmitter } from 'events';
|
|
3
4
|
import type * as OpenFin from '../OpenFin';
|
|
4
5
|
import { ExistingConnectConfig, InternalConnectConfig, RemoteConfig, Wire, WireConstructor } from './wire';
|
|
5
6
|
import { Environment } from '../environment/environment';
|
|
7
|
+
import { RuntimeErrorPayload } from './transport-errors';
|
|
6
8
|
import EventAggregator from '../api/events/eventAggregator';
|
|
7
9
|
import { EntityTypeHelpers } from '../api/me';
|
|
8
10
|
import { ProtocolMap } from '../shapes/protocol';
|
|
9
11
|
import { NamedEvent } from '../api/events/base';
|
|
10
12
|
import { ErrorPlainObject } from '../util/errors';
|
|
11
13
|
type EntityType = OpenFin.EntityType;
|
|
14
|
+
type SendActionResponse<T extends keyof ProtocolMap> = Message<{
|
|
15
|
+
data: ProtocolMap[T]['response'];
|
|
16
|
+
} & ProtocolMap[T]['specialResponse']>;
|
|
12
17
|
export type MessageHandler = (data: any) => boolean;
|
|
18
|
+
export type SentMessage<Value> = Promise<Value> & {
|
|
19
|
+
cancel: (reason?: any) => void;
|
|
20
|
+
messageId: ReturnType<Environment['getNextMessageId']>;
|
|
21
|
+
};
|
|
22
|
+
type NackHandler = (payloadOrMessage: RuntimeErrorPayload | string) => void;
|
|
13
23
|
export declare class Transport<MeType extends EntityType = EntityType> extends EventEmitter {
|
|
14
24
|
#private;
|
|
15
25
|
protected wireListeners: Map<number, {
|
|
16
26
|
resolve: Function;
|
|
17
|
-
|
|
27
|
+
handleNack: (payload: RuntimeErrorPayload) => void;
|
|
18
28
|
}>;
|
|
19
29
|
protected uncorrelatedListener: Function;
|
|
20
30
|
me: OpenFin.EntityInfo & EntityTypeHelpers<MeType>;
|
|
@@ -24,6 +34,8 @@ export declare class Transport<MeType extends EntityType = EntityType> extends E
|
|
|
24
34
|
eventAggregator: EventAggregator;
|
|
25
35
|
protected messageHandlers: MessageHandler[];
|
|
26
36
|
constructor(WireType: WireConstructor, environment: Environment, config: OpenFin.Identity);
|
|
37
|
+
getFin(): OpenFin.Fin<MeType>;
|
|
38
|
+
registerFin(_fin: OpenFin.Fin<MeType>): void;
|
|
27
39
|
connectSync: () => void;
|
|
28
40
|
getPort: () => string;
|
|
29
41
|
shutdown(): Promise<void>;
|
|
@@ -31,12 +43,11 @@ export declare class Transport<MeType extends EntityType = EntityType> extends E
|
|
|
31
43
|
private connectRemote;
|
|
32
44
|
connectByPort(config: ExistingConnectConfig): Promise<void>;
|
|
33
45
|
private authorize;
|
|
34
|
-
sendAction<T extends keyof ProtocolMap = string>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean):
|
|
35
|
-
|
|
36
|
-
} & ProtocolMap[T]['specialResponse']>>;
|
|
46
|
+
sendAction<T extends keyof ProtocolMap = string>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): SentMessage<SendActionResponse<T>>;
|
|
47
|
+
protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: NodeJS.CallSite[]): void;
|
|
37
48
|
ferryAction(origData: any): Promise<Message<any>>;
|
|
38
49
|
registerMessageHandler(handler: MessageHandler): void;
|
|
39
|
-
protected addWireListener(id: number, resolve: Function,
|
|
50
|
+
protected addWireListener(id: number, resolve: Function, handleNack: NackHandler, uncorrelated: boolean): void;
|
|
40
51
|
protected onmessage(data: Message<Payload>): void;
|
|
41
52
|
protected handleMessage(data: Message<Payload>): boolean;
|
|
42
53
|
}
|