@openfin/core 31.74.21 → 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/api-exposer/api-consumer.d.ts +28 -0
- package/src/api/api-exposer/api-consumer.js +28 -0
- package/src/api/api-exposer/api-exposer.d.ts +35 -0
- package/src/api/api-exposer/api-exposer.js +38 -0
- package/src/api/api-exposer/decorators.d.ts +10 -0
- package/src/api/api-exposer/decorators.js +18 -0
- package/src/api/api-exposer/index.d.ts +4 -0
- package/src/api/api-exposer/index.js +20 -0
- package/src/api/api-exposer/strategies/index.d.ts +1 -0
- package/src/api/api-exposer/strategies/index.js +17 -0
- package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.d.ts +14 -0
- package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.js +20 -0
- package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.d.ts +20 -0
- package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.js +23 -0
- package/src/api/api-exposer/strategies/openfin-channels/index.d.ts +2 -0
- package/src/api/api-exposer/strategies/openfin-channels/index.js +18 -0
- 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/src/api/view/Instance.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
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");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _View_providerChannelClient;
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.View = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
const transport_errors_1 = require("../../transport/transport-errors");
|
|
11
|
+
const lazy_1 = require("../../util/lazy");
|
|
12
|
+
const layout_entities_1 = require("../platform/layout/entities/layout-entities");
|
|
13
|
+
const layout_constants_1 = require("../platform/layout/layout.constants");
|
|
14
|
+
const bounds_observer_1 = require("../platform/layout/utils/bounds-observer");
|
|
7
15
|
const main_1 = require("../webcontents/main");
|
|
8
16
|
const window_1 = require("../window");
|
|
9
|
-
const bounds_observer_1 = require("../platform/layout/utils/bounds-observer");
|
|
10
17
|
/**
|
|
11
18
|
* @PORTED
|
|
12
19
|
* @typedef {object} View~options
|
|
@@ -148,6 +155,9 @@ const bounds_observer_1 = require("../platform/layout/utils/bounds-observer");
|
|
|
148
155
|
* @property {string} [processAffinity=<application uuid>]
|
|
149
156
|
* A string to attempt to group renderers together. Will only be used if pages are on the same origin.
|
|
150
157
|
*
|
|
158
|
+
* @property {boolean} [spellCheck=false]
|
|
159
|
+
* Enable spell check in input text fields for the view.
|
|
160
|
+
*
|
|
151
161
|
* @property {Identity} [target]
|
|
152
162
|
* The identity of the window this view should be attached to.
|
|
153
163
|
*
|
|
@@ -178,6 +188,10 @@ class View extends main_1.WebContents {
|
|
|
178
188
|
constructor(wire, identity) {
|
|
179
189
|
super(wire, identity, 'view');
|
|
180
190
|
this.identity = identity;
|
|
191
|
+
_View_providerChannelClient.set(this, new lazy_1.Lazy(() => {
|
|
192
|
+
const platform = this.fin.Platform.wrapSync(this.identity);
|
|
193
|
+
return platform.getClient();
|
|
194
|
+
}));
|
|
181
195
|
/**
|
|
182
196
|
* Returns the zoom level of the view.
|
|
183
197
|
* @function getZoomLevel
|
|
@@ -446,6 +460,26 @@ class View extends main_1.WebContents {
|
|
|
446
460
|
const { payload: { data } } = await this.wire.sendAction('get-view-window', { ...this.identity });
|
|
447
461
|
return new window_1._Window(this.wire, data);
|
|
448
462
|
};
|
|
463
|
+
/**
|
|
464
|
+
* Retrieves the current {@link TabStack} of the view if it belongs to one.
|
|
465
|
+
* @return {Promise<TabStack>} The {@link TabStack} this view belongs to.
|
|
466
|
+
* @throws if this view does not belong to a TabStack or if the window has been destroyed.
|
|
467
|
+
*/
|
|
468
|
+
this.getCurrentStack = async () => {
|
|
469
|
+
this.wire.sendAction('view-get-current-stack').catch(() => {
|
|
470
|
+
// don't expose
|
|
471
|
+
});
|
|
472
|
+
try {
|
|
473
|
+
const layoutWindow = await this.getCurrentWindow();
|
|
474
|
+
const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
|
|
475
|
+
const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindow.identity);
|
|
476
|
+
const stackDefinition = (await client.getStackByView(this.identity));
|
|
477
|
+
return layout_entities_1.LayoutNode.getEntity(stackDefinition, client);
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
throw new transport_errors_1.RuntimeError({ reason: 'This view does not belong to a stack.', error });
|
|
481
|
+
}
|
|
482
|
+
};
|
|
449
483
|
/**
|
|
450
484
|
* Triggers the before-unload handler for the View, if one is set. Returns `true` if the handler is trying to prevent the View from unloading, and `false` if it isn't.
|
|
451
485
|
* Only enabled when setting enableBeforeUnload: true in your View options. If this option is not enabled it will always return false.
|
|
@@ -515,3 +549,4 @@ class View extends main_1.WebContents {
|
|
|
515
549
|
}
|
|
516
550
|
}
|
|
517
551
|
exports.View = View;
|
|
552
|
+
_View_providerChannelClient = new WeakMap();
|
|
@@ -2,31 +2,11 @@ import type * as OpenFin from '../../OpenFin';
|
|
|
2
2
|
import { EmitterBase } from '../base';
|
|
3
3
|
import { Transport } from '../../transport/transport';
|
|
4
4
|
import { BaseEvent } from '../events/base';
|
|
5
|
-
/**
|
|
6
|
-
* Configuration for page capture.
|
|
7
|
-
*/
|
|
8
|
-
export interface CapturePageOptions {
|
|
9
|
-
/**
|
|
10
|
-
* The area of the window to be captured.
|
|
11
|
-
*/
|
|
12
|
-
area?: OpenFin.Rectangle;
|
|
13
|
-
/**
|
|
14
|
-
* @defaultValue 'png'
|
|
15
|
-
*
|
|
16
|
-
* The format of the captured image. Can be 'png', 'jpg', or 'bmp'.
|
|
17
|
-
*/
|
|
18
|
-
format?: 'bmp' | 'jpg' | 'png';
|
|
19
|
-
/**
|
|
20
|
-
* @defaultValue 100
|
|
21
|
-
*
|
|
22
|
-
* Quality of JPEG image. Between 0 - 100.
|
|
23
|
-
*/
|
|
24
|
-
quality?: number;
|
|
25
|
-
}
|
|
26
5
|
export declare class WebContents<T extends BaseEvent> extends EmitterBase<T> {
|
|
6
|
+
identity: OpenFin.Identity;
|
|
27
7
|
entityType: string;
|
|
28
8
|
constructor(wire: Transport, identity: OpenFin.Identity, entityType: string);
|
|
29
|
-
capturePage(options?: CapturePageOptions): Promise<string>;
|
|
9
|
+
capturePage(options?: OpenFin.CapturePageOptions): Promise<string>;
|
|
30
10
|
executeJavaScript(code: string): Promise<void>;
|
|
31
11
|
getZoomLevel(): Promise<number>;
|
|
32
12
|
setZoomLevel(level: number): Promise<void>;
|
|
@@ -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;
|
|
@@ -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
|
+
getManagerConstructor(): Promise<any>;
|
|
12
|
+
getProviderInitializer(): Promise<any>;
|
|
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
|
+
async getManagerConstructor() {
|
|
16
|
+
throw new Error(me_1.environmentUnsupportedMessage);
|
|
17
|
+
}
|
|
18
|
+
async getProviderInitializer() {
|
|
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;
|
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;
|
|
@@ -148,6 +164,7 @@ export interface ProtocolMap extends ProtocolMapBase {
|
|
|
148
164
|
request: void;
|
|
149
165
|
response: OpenFin.PrinterInfo[];
|
|
150
166
|
};
|
|
167
|
+
'system-register-shutdown-handler': VoidCall;
|
|
151
168
|
}
|
|
152
169
|
type ApiCall<Request, Response> = {
|
|
153
170
|
request: Request;
|
|
@@ -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,29 @@
|
|
|
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 CancellablePromise<T> = Promise<T> & {
|
|
19
|
+
cancel: (reason?: any) => void;
|
|
20
|
+
};
|
|
21
|
+
type NackHandler = (payloadOrMessage: RuntimeErrorPayload | string) => void;
|
|
13
22
|
export declare class Transport<MeType extends EntityType = EntityType> extends EventEmitter {
|
|
14
23
|
#private;
|
|
15
24
|
protected wireListeners: Map<number, {
|
|
16
25
|
resolve: Function;
|
|
17
|
-
|
|
26
|
+
handleNack: (payload: RuntimeErrorPayload) => void;
|
|
18
27
|
}>;
|
|
19
28
|
protected uncorrelatedListener: Function;
|
|
20
29
|
me: OpenFin.EntityInfo & EntityTypeHelpers<MeType>;
|
|
@@ -24,6 +33,8 @@ export declare class Transport<MeType extends EntityType = EntityType> extends E
|
|
|
24
33
|
eventAggregator: EventAggregator;
|
|
25
34
|
protected messageHandlers: MessageHandler[];
|
|
26
35
|
constructor(WireType: WireConstructor, environment: Environment, config: OpenFin.Identity);
|
|
36
|
+
getFin(): OpenFin.Fin<MeType>;
|
|
37
|
+
registerFin(_fin: OpenFin.Fin<MeType>): void;
|
|
27
38
|
connectSync: () => void;
|
|
28
39
|
getPort: () => string;
|
|
29
40
|
shutdown(): Promise<void>;
|
|
@@ -31,12 +42,11 @@ export declare class Transport<MeType extends EntityType = EntityType> extends E
|
|
|
31
42
|
private connectRemote;
|
|
32
43
|
connectByPort(config: ExistingConnectConfig): Promise<void>;
|
|
33
44
|
private authorize;
|
|
34
|
-
sendAction<T extends keyof ProtocolMap = string>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean):
|
|
35
|
-
|
|
36
|
-
} & ProtocolMap[T]['specialResponse']>>;
|
|
45
|
+
sendAction<T extends keyof ProtocolMap = string>(action: T, payload?: ProtocolMap[T]['request'], uncorrelated?: boolean): CancellablePromise<SendActionResponse<T>>;
|
|
46
|
+
protected nackHandler(payloadOrMessage: RuntimeErrorPayload | string, reject: Function, callSites?: NodeJS.CallSite[]): void;
|
|
37
47
|
ferryAction(origData: any): Promise<Message<any>>;
|
|
38
48
|
registerMessageHandler(handler: MessageHandler): void;
|
|
39
|
-
protected addWireListener(id: number, resolve: Function,
|
|
49
|
+
protected addWireListener(id: number, resolve: Function, handleNack: NackHandler, uncorrelated: boolean): void;
|
|
40
50
|
protected onmessage(data: Message<Payload>): void;
|
|
41
51
|
protected handleMessage(data: Message<Payload>): boolean;
|
|
42
52
|
}
|