@openfin/core 33.76.36 → 33.76.38
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/OpenFin.d.ts +1 -1
- package/README.md +29 -4
- package/fin.d.ts +2 -2
- package/{src → out}/GlobalOpenFin.d.ts +1 -1
- package/out/mock-alpha.d.ts +16112 -0
- package/out/mock-beta.d.ts +16112 -0
- package/out/mock-public.d.ts +16112 -0
- package/out/mock.d.ts +16797 -0
- package/out/mock.js +17104 -0
- package/package.json +30 -23
- package/LICENSE +0 -13
- package/NOTICE +0 -16
- package/openfin-core-33.76.36.tgz +0 -0
- package/src/OpenFin.d.ts +0 -3091
- package/src/OpenFin.js +0 -2
- package/src/api/api-exposer/api-consumer.d.ts +0 -28
- package/src/api/api-exposer/api-consumer.js +0 -28
- package/src/api/api-exposer/api-exposer.d.ts +0 -35
- package/src/api/api-exposer/api-exposer.js +0 -38
- package/src/api/api-exposer/decorators.d.ts +0 -10
- package/src/api/api-exposer/decorators.js +0 -18
- package/src/api/api-exposer/index.d.ts +0 -4
- package/src/api/api-exposer/index.js +0 -20
- package/src/api/api-exposer/strategies/index.d.ts +0 -1
- package/src/api/api-exposer/strategies/index.js +0 -17
- package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.d.ts +0 -14
- package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.js +0 -20
- package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.d.ts +0 -20
- package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.js +0 -23
- package/src/api/api-exposer/strategies/openfin-channels/index.d.ts +0 -2
- package/src/api/api-exposer/strategies/openfin-channels/index.js +0 -18
- package/src/api/application/Factory.d.ts +0 -196
- package/src/api/application/Factory.js +0 -278
- package/src/api/application/Instance.d.ts +0 -692
- package/src/api/application/Instance.js +0 -821
- package/src/api/application/index.d.ts +0 -12
- package/src/api/application/index.js +0 -28
- package/src/api/base.d.ts +0 -117
- package/src/api/base.js +0 -246
- package/src/api/clipboard/index.d.ts +0 -172
- package/src/api/clipboard/index.js +0 -200
- package/src/api/events/application.d.ts +0 -158
- package/src/api/events/application.js +0 -14
- package/src/api/events/base.d.ts +0 -42
- package/src/api/events/base.js +0 -2
- package/src/api/events/channel.d.ts +0 -35
- package/src/api/events/channel.js +0 -7
- package/src/api/events/emitterMap.d.ts +0 -11
- package/src/api/events/emitterMap.js +0 -35
- package/src/api/events/eventAggregator.d.ts +0 -5
- package/src/api/events/eventAggregator.js +0 -35
- package/src/api/events/externalApplication.d.ts +0 -24
- package/src/api/events/externalApplication.js +0 -7
- package/src/api/events/frame.d.ts +0 -35
- package/src/api/events/frame.js +0 -2
- package/src/api/events/globalHotkey.d.ts +0 -25
- package/src/api/events/globalHotkey.js +0 -2
- package/src/api/events/platform.d.ts +0 -34
- package/src/api/events/platform.js +0 -10
- package/src/api/events/system.d.ts +0 -126
- package/src/api/events/system.js +0 -15
- package/src/api/events/typedEventEmitter.d.ts +0 -20
- package/src/api/events/typedEventEmitter.js +0 -2
- package/src/api/events/view.d.ts +0 -92
- package/src/api/events/view.js +0 -12
- package/src/api/events/webcontents.d.ts +0 -277
- package/src/api/events/webcontents.js +0 -13
- package/src/api/events/window.d.ts +0 -421
- package/src/api/events/window.js +0 -12
- package/src/api/external-application/Factory.d.ts +0 -34
- package/src/api/external-application/Factory.js +0 -47
- package/src/api/external-application/Instance.d.ts +0 -110
- package/src/api/external-application/Instance.js +0 -117
- package/src/api/external-application/index.d.ts +0 -12
- package/src/api/external-application/index.js +0 -28
- package/src/api/fin.d.ts +0 -54
- package/src/api/fin.js +0 -45
- package/src/api/frame/Factory.d.ts +0 -54
- package/src/api/frame/Factory.js +0 -86
- package/src/api/frame/Instance.d.ts +0 -136
- package/src/api/frame/Instance.js +0 -143
- package/src/api/frame/index.d.ts +0 -14
- package/src/api/frame/index.js +0 -30
- package/src/api/global-hotkey/index.d.ts +0 -106
- package/src/api/global-hotkey/index.js +0 -132
- package/src/api/interappbus/channel/channel.d.ts +0 -285
- package/src/api/interappbus/channel/channel.js +0 -334
- package/src/api/interappbus/channel/channels-docs.d.ts +0 -342
- package/src/api/interappbus/channel/channels-docs.js +0 -401
- package/src/api/interappbus/channel/client.d.ts +0 -117
- package/src/api/interappbus/channel/client.js +0 -181
- package/src/api/interappbus/channel/connection-manager.d.ts +0 -29
- package/src/api/interappbus/channel/connection-manager.js +0 -246
- package/src/api/interappbus/channel/index.d.ts +0 -189
- package/src/api/interappbus/channel/index.js +0 -333
- package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +0 -13
- package/src/api/interappbus/channel/protocols/classic/message-receiver.js +0 -73
- package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +0 -24
- package/src/api/interappbus/channel/protocols/classic/strategy.js +0 -101
- package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +0 -20
- package/src/api/interappbus/channel/protocols/combined/strategy.js +0 -58
- package/src/api/interappbus/channel/protocols/index.d.ts +0 -47
- package/src/api/interappbus/channel/protocols/index.js +0 -2
- package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +0 -10
- package/src/api/interappbus/channel/protocols/protocol-manager.js +0 -43
- package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +0 -25
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +0 -141
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +0 -30
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +0 -130
- package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +0 -24
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +0 -85
- package/src/api/interappbus/channel/protocols/strategy-types.d.ts +0 -13
- package/src/api/interappbus/channel/protocols/strategy-types.js +0 -2
- package/src/api/interappbus/channel/protocols/strategy.d.ts +0 -17
- package/src/api/interappbus/channel/protocols/strategy.js +0 -2
- package/src/api/interappbus/channel/provider.d.ts +0 -206
- package/src/api/interappbus/channel/provider.js +0 -338
- package/src/api/interappbus/index.d.ts +0 -120
- package/src/api/interappbus/index.js +0 -210
- package/src/api/interop/Factory.d.ts +0 -57
- package/src/api/interop/Factory.js +0 -96
- package/src/api/interop/InteropBroker.d.ts +0 -665
- package/src/api/interop/InteropBroker.js +0 -1313
- package/src/api/interop/InteropClient.d.ts +0 -502
- package/src/api/interop/InteropClient.js +0 -683
- package/src/api/interop/SessionContextGroupBroker.d.ts +0 -27
- package/src/api/interop/SessionContextGroupBroker.js +0 -108
- package/src/api/interop/SessionContextGroupClient.d.ts +0 -21
- package/src/api/interop/SessionContextGroupClient.js +0 -86
- package/src/api/interop/fdc3/PrivateChannelClient.d.ts +0 -20
- package/src/api/interop/fdc3/PrivateChannelClient.js +0 -90
- package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +0 -55
- package/src/api/interop/fdc3/PrivateChannelProvider.js +0 -276
- package/src/api/interop/fdc3/documentationStub.d.ts +0 -14
- package/src/api/interop/fdc3/documentationStub.js +0 -17
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +0 -205
- package/src/api/interop/fdc3/fdc3-1.2.js +0 -435
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +0 -298
- package/src/api/interop/fdc3/fdc3-2.0.js +0 -479
- package/src/api/interop/fdc3/fdc3.d.ts +0 -12
- package/src/api/interop/fdc3/fdc3.js +0 -35
- package/src/api/interop/fdc3/overrideCheck.d.ts +0 -4
- package/src/api/interop/fdc3/overrideCheck.js +0 -32
- package/src/api/interop/fdc3/shapes/fdc3v1.d.ts +0 -53
- package/src/api/interop/fdc3/shapes/fdc3v1.js +0 -4
- package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +0 -75
- package/src/api/interop/fdc3/shapes/fdc3v2.js +0 -2
- package/src/api/interop/fdc3/utils.d.ts +0 -45
- package/src/api/interop/fdc3/utils.js +0 -239
- package/src/api/interop/fdc3/versions.d.ts +0 -1
- package/src/api/interop/fdc3/versions.js +0 -2
- package/src/api/interop/index.d.ts +0 -12
- package/src/api/interop/index.js +0 -28
- package/src/api/interop/utils.d.ts +0 -18
- package/src/api/interop/utils.js +0 -61
- package/src/api/me.d.ts +0 -40
- package/src/api/me.js +0 -134
- package/src/api/platform/Factory.d.ts +0 -171
- package/src/api/platform/Factory.js +0 -240
- package/src/api/platform/Instance.d.ts +0 -653
- package/src/api/platform/Instance.js +0 -834
- package/src/api/platform/common-utils.d.ts +0 -7
- package/src/api/platform/common-utils.js +0 -16
- package/src/api/platform/index.d.ts +0 -12
- package/src/api/platform/index.js +0 -28
- package/src/api/platform/layout/Factory.d.ts +0 -91
- package/src/api/platform/layout/Factory.js +0 -151
- package/src/api/platform/layout/Instance.d.ts +0 -192
- package/src/api/platform/layout/Instance.js +0 -224
- package/src/api/platform/layout/controllers/layout-content-cache.d.ts +0 -9
- package/src/api/platform/layout/controllers/layout-content-cache.js +0 -54
- package/src/api/platform/layout/controllers/layout-entities-controller.d.ts +0 -119
- package/src/api/platform/layout/controllers/layout-entities-controller.js +0 -287
- package/src/api/platform/layout/entities/layout-entities.d.ts +0 -427
- package/src/api/platform/layout/entities/layout-entities.js +0 -504
- package/src/api/platform/layout/entities/shapes.d.ts +0 -6
- package/src/api/platform/layout/entities/shapes.js +0 -2
- package/src/api/platform/layout/index.d.ts +0 -11
- package/src/api/platform/layout/index.js +0 -27
- package/src/api/platform/layout/layout.constants.d.ts +0 -1
- package/src/api/platform/layout/layout.constants.js +0 -4
- package/src/api/platform/layout/shapes.d.ts +0 -16
- package/src/api/platform/layout/shapes.js +0 -2
- package/src/api/platform/layout/utils/layout-traversal.d.ts +0 -4
- package/src/api/platform/layout/utils/layout-traversal.js +0 -65
- package/src/api/platform/provider.d.ts +0 -510
- package/src/api/platform/provider.js +0 -2
- package/src/api/snapshot-source/Factory.d.ts +0 -53
- package/src/api/snapshot-source/Factory.js +0 -81
- package/src/api/snapshot-source/Instance.d.ts +0 -53
- package/src/api/snapshot-source/Instance.js +0 -154
- package/src/api/snapshot-source/index.d.ts +0 -12
- package/src/api/snapshot-source/index.js +0 -28
- package/src/api/snapshot-source/utils.d.ts +0 -2
- package/src/api/snapshot-source/utils.js +0 -6
- package/src/api/system/index.d.ts +0 -1468
- package/src/api/system/index.js +0 -1851
- package/src/api/view/Factory.d.ts +0 -88
- package/src/api/view/Factory.js +0 -141
- package/src/api/view/Instance.d.ts +0 -601
- package/src/api/view/Instance.js +0 -671
- package/src/api/view/index.d.ts +0 -12
- package/src/api/view/index.js +0 -28
- package/src/api/webcontents/main.d.ts +0 -922
- package/src/api/webcontents/main.js +0 -1046
- package/src/api/window/Factory.d.ts +0 -96
- package/src/api/window/Factory.js +0 -142
- package/src/api/window/Instance.d.ts +0 -1598
- package/src/api/window/Instance.js +0 -1851
- package/src/api/window/index.d.ts +0 -14
- package/src/api/window/index.js +0 -30
- package/src/browser.d.ts +0 -10
- package/src/browser.js +0 -36
- package/src/environment/browser.d.ts +0 -29
- package/src/environment/browser.js +0 -60
- package/src/environment/environment.d.ts +0 -33
- package/src/environment/environment.js +0 -4
- package/src/environment/mockEnvironment.d.ts +0 -27
- package/src/environment/mockEnvironment.js +0 -61
- package/src/environment/node-env.d.ts +0 -29
- package/src/environment/node-env.js +0 -72
- package/src/fdc3.d.ts +0 -3
- package/src/fdc3.js +0 -9
- package/src/mock.d.ts +0 -3
- package/src/mock.js +0 -18
- package/src/namespaces.d.ts +0 -22
- package/src/namespaces.js +0 -26
- package/src/shapes/ERROR_BOX_TYPES.d.ts +0 -1
- package/src/shapes/ERROR_BOX_TYPES.js +0 -2
- package/src/shapes/WebOptions.d.ts +0 -13
- package/src/shapes/WebOptions.js +0 -2
- package/src/shapes/WindowOptions.d.ts +0 -43
- package/src/shapes/WindowOptions.js +0 -2
- package/src/shapes/protocol.d.ts +0 -204
- package/src/shapes/protocol.js +0 -2
- package/src/transport/mockWire.d.ts +0 -11
- package/src/transport/mockWire.js +0 -26
- package/src/transport/transport-errors.d.ts +0 -31
- package/src/transport/transport-errors.js +0 -79
- package/src/transport/transport.d.ts +0 -73
- package/src/transport/transport.js +0 -219
- package/src/transport/wire.d.ts +0 -77
- package/src/transport/wire.js +0 -36
- package/src/util/asyncFilter.d.ts +0 -1
- package/src/util/asyncFilter.js +0 -7
- package/src/util/channel-api-relay.d.ts +0 -13
- package/src/util/channel-api-relay.js +0 -47
- package/src/util/errors.d.ts +0 -10
- package/src/util/errors.js +0 -12
- package/src/util/exhaustive.d.ts +0 -1
- package/src/util/exhaustive.js +0 -7
- package/src/util/http.d.ts +0 -11
- package/src/util/http.js +0 -90
- package/src/util/inaccessibleObject.d.ts +0 -2
- package/src/util/inaccessibleObject.js +0 -49
- package/src/util/lazy.d.ts +0 -34
- package/src/util/lazy.js +0 -54
- package/src/util/normalize-config.d.ts +0 -3
- package/src/util/normalize-config.js +0 -52
- package/src/util/promises.d.ts +0 -5
- package/src/util/promises.js +0 -27
- package/src/util/ref-counter.d.ts +0 -7
- package/src/util/ref-counter.js +0 -52
- package/src/util/reversible-map.d.ts +0 -11
- package/src/util/reversible-map.js +0 -49
- package/src/util/runtimeVersioning.d.ts +0 -3
- package/src/util/runtimeVersioning.js +0 -25
- package/src/util/utilTypes.d.ts +0 -8
- package/src/util/utilTypes.js +0 -2
- package/src/util/validate.d.ts +0 -3
- package/src/util/validate.js +0 -11
|
@@ -1,834 +0,0 @@
|
|
|
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 _Platform_connectToProvider;
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.Platform = void 0;
|
|
10
|
-
/* eslint-disable import/prefer-default-export, no-undef */
|
|
11
|
-
const base_1 = require("../base");
|
|
12
|
-
const validate_1 = require("../../util/validate");
|
|
13
|
-
// Reuse clients to avoid overwriting already-registered client in provider
|
|
14
|
-
const clientMap = new Map();
|
|
15
|
-
/** Manages the life cycle of windows and views in the application.
|
|
16
|
-
*
|
|
17
|
-
* Enables taking snapshots of itself and applyi
|
|
18
|
-
* ng them to restore a previous configuration
|
|
19
|
-
* as well as listen to {@link OpenFin.PlatformEvents platform events}.
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
class Platform extends base_1.EmitterBase {
|
|
23
|
-
/**
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
// eslint-disable-next-line no-shadow
|
|
27
|
-
constructor(identity, channel) {
|
|
28
|
-
// we piggyback off of application event emitter because from the core's perspective platform is just an app.
|
|
29
|
-
super(channel.wire, 'application', identity.uuid);
|
|
30
|
-
this.getClient = (identity) => {
|
|
31
|
-
this.wire.sendAction('platform-get-client', this.identity).catch((e) => {
|
|
32
|
-
// don't expose
|
|
33
|
-
});
|
|
34
|
-
const target = identity || this.identity;
|
|
35
|
-
const { uuid } = target;
|
|
36
|
-
if (!clientMap.has(uuid)) {
|
|
37
|
-
const clientPromise = __classPrivateFieldGet(this, _Platform_connectToProvider, "f").call(this, uuid);
|
|
38
|
-
clientMap.set(uuid, clientPromise);
|
|
39
|
-
}
|
|
40
|
-
// we set it above
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
42
|
-
return clientMap.get(uuid);
|
|
43
|
-
};
|
|
44
|
-
_Platform_connectToProvider.set(this, async (uuid) => {
|
|
45
|
-
try {
|
|
46
|
-
const channelName = `custom-frame-${uuid}`;
|
|
47
|
-
const client = await this._channel.connect(channelName, { wait: false });
|
|
48
|
-
client.onDisconnection(() => {
|
|
49
|
-
clientMap.delete(uuid);
|
|
50
|
-
});
|
|
51
|
-
return client;
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
clientMap.delete(uuid);
|
|
55
|
-
throw new Error('The targeted Platform is not currently running. Listen for application-started event for the given Uuid.');
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
/**
|
|
59
|
-
* @deprecated (renamed)
|
|
60
|
-
* @ignore
|
|
61
|
-
*/
|
|
62
|
-
this.launchLegacyManifest = this.launchContentManifest;
|
|
63
|
-
const errorMsg = (0, validate_1.validateIdentity)(identity);
|
|
64
|
-
if (errorMsg) {
|
|
65
|
-
throw new Error(errorMsg);
|
|
66
|
-
}
|
|
67
|
-
this._channel = channel;
|
|
68
|
-
this.identity = { uuid: identity.uuid };
|
|
69
|
-
this.Layout = this.fin.Platform.Layout;
|
|
70
|
-
this.Application = this.fin.Application.wrapSync(this.identity);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Creates a new view and attaches it to a specified target window.
|
|
74
|
-
* @param viewOptions View creation options
|
|
75
|
-
* @param target The window to which the new view is to be attached. If no target, create a view in a new window.
|
|
76
|
-
* @param targetView If provided, the new view will be added to the same tabstrip as targetView.
|
|
77
|
-
*
|
|
78
|
-
* @remarks If the view already exists, will reparent the view to the new target. You do not need to set a name for a View.
|
|
79
|
-
* Views that are not passed a name get a randomly generated one.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```js
|
|
83
|
-
* let windowIdentity;
|
|
84
|
-
* if (fin.me.isWindow) {
|
|
85
|
-
* windowIdentity = fin.me.identity;
|
|
86
|
-
* } else if (fin.me.isView) {
|
|
87
|
-
* windowIdentity = (await fin.me.getCurrentWindow()).identity;
|
|
88
|
-
* } else {
|
|
89
|
-
* throw new Error('Not running in a platform View or Window');
|
|
90
|
-
* }
|
|
91
|
-
*
|
|
92
|
-
* const platform = fin.Platform.getCurrentSync();
|
|
93
|
-
*
|
|
94
|
-
* platform.createView({
|
|
95
|
-
* name: 'test_view',
|
|
96
|
-
* url: 'https://developers.openfin.co/docs/platform-api'
|
|
97
|
-
* }, windowIdentity).then(console.log);
|
|
98
|
-
* ```
|
|
99
|
-
*
|
|
100
|
-
* Reparenting a view:
|
|
101
|
-
* ```js
|
|
102
|
-
* let windowIdentity;
|
|
103
|
-
* if (fin.me.isWindow) {
|
|
104
|
-
* windowIdentity = fin.me.identity;
|
|
105
|
-
* } else if (fin.me.isView) {
|
|
106
|
-
* windowIdentity = (await fin.me.getCurrentWindow()).identity;
|
|
107
|
-
* } else {
|
|
108
|
-
* throw new Error('Not running in a platform View or Window');
|
|
109
|
-
* }
|
|
110
|
-
*
|
|
111
|
-
* let platform = fin.Platform.getCurrentSync();
|
|
112
|
-
* let viewOptions = {
|
|
113
|
-
* name: 'example_view',
|
|
114
|
-
* url: 'https://example.com'
|
|
115
|
-
* };
|
|
116
|
-
* // a new view will now show in the current window
|
|
117
|
-
* await platform.createView(viewOptions, windowIdentity);
|
|
118
|
-
*
|
|
119
|
-
* const view = fin.View.wrapSync({ uuid: windowIdentity.uuid, name: 'yahoo_view' });
|
|
120
|
-
* // reparent `example_view` when a view in the new window is shown
|
|
121
|
-
* view.on('shown', async () => {
|
|
122
|
-
* let viewIdentity = { uuid: windowIdentity.uuid, name: 'example_view'};
|
|
123
|
-
* let target = {uuid: windowIdentity.uuid, name: 'test_win'};
|
|
124
|
-
* platform.createView(viewOptions, target);
|
|
125
|
-
* });
|
|
126
|
-
*
|
|
127
|
-
* // create a new window
|
|
128
|
-
* await platform.createWindow({
|
|
129
|
-
* name: "test_win",
|
|
130
|
-
* layout: {
|
|
131
|
-
* content: [
|
|
132
|
-
* {
|
|
133
|
-
* type: 'stack',
|
|
134
|
-
* content: [
|
|
135
|
-
* {
|
|
136
|
-
* type: 'component',
|
|
137
|
-
* componentName: 'view',
|
|
138
|
-
* componentState: {
|
|
139
|
-
* name: 'yahoo_view',
|
|
140
|
-
* url: 'https://yahoo.com'
|
|
141
|
-
* }
|
|
142
|
-
* }
|
|
143
|
-
* ]
|
|
144
|
-
* }
|
|
145
|
-
* ]
|
|
146
|
-
* }
|
|
147
|
-
* }).then(console.log);
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
async createView(viewOptions, target, targetView) {
|
|
151
|
-
this.wire.sendAction('platform-create-view', this.identity).catch((e) => {
|
|
152
|
-
// don't expose
|
|
153
|
-
});
|
|
154
|
-
const client = await this.getClient();
|
|
155
|
-
const response = await client.dispatch('create-view', {
|
|
156
|
-
target,
|
|
157
|
-
opts: viewOptions,
|
|
158
|
-
targetView
|
|
159
|
-
});
|
|
160
|
-
if (!response || (0, validate_1.validateIdentity)(response.identity)) {
|
|
161
|
-
throw new Error(`When overwriting the createView call, please return an object that has a valid 'identity' property: ${JSON.stringify(response)}`);
|
|
162
|
-
}
|
|
163
|
-
return this.fin.View.wrapSync(response.identity);
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Creates a new Window.
|
|
167
|
-
* @param options Window creation options
|
|
168
|
-
*
|
|
169
|
-
* @remarks There are two Window types at your disposal while using OpenFin Platforms - Default Window and Custom Window.
|
|
170
|
-
*
|
|
171
|
-
* The Default Window uses the standard OpenFin Window UI. It contains the standard close, maximize and minimize buttons,
|
|
172
|
-
* and will automatically render the Window's layout if one is specified.
|
|
173
|
-
*
|
|
174
|
-
* For deeper customization, you can bring your own Window code into a Platform. This is called a Custom Window.
|
|
175
|
-
*
|
|
176
|
-
* @example
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* The example below will create a Default Window which uses OpenFin default Window UI.<br>
|
|
180
|
-
* The Window contains two Views in a stack Layout:
|
|
181
|
-
*
|
|
182
|
-
* ```js
|
|
183
|
-
* const platform = fin.Platform.getCurrentSync();
|
|
184
|
-
* platform.createWindow({
|
|
185
|
-
* layout: {
|
|
186
|
-
* content: [
|
|
187
|
-
* {
|
|
188
|
-
* type: 'stack',
|
|
189
|
-
* content: [
|
|
190
|
-
* {
|
|
191
|
-
* type: 'component',
|
|
192
|
-
* componentName: 'view',
|
|
193
|
-
* componentState: {
|
|
194
|
-
* name: 'test_view_1',
|
|
195
|
-
* url: 'https://cdn.openfin.co/docs/javascript/canary/Platform.html'
|
|
196
|
-
* }
|
|
197
|
-
* },
|
|
198
|
-
* {
|
|
199
|
-
* type: 'component',
|
|
200
|
-
* componentName: 'view',
|
|
201
|
-
* componentState: {
|
|
202
|
-
* name: 'test_view_2',
|
|
203
|
-
* url: 'https://cdn.openfin.co/docs/javascript/canary/Platform.html'
|
|
204
|
-
* }
|
|
205
|
-
* }
|
|
206
|
-
* ]
|
|
207
|
-
* }
|
|
208
|
-
* ]
|
|
209
|
-
* }
|
|
210
|
-
* }).then(console.log);
|
|
211
|
-
* ```
|
|
212
|
-
* The Default Window's design can be customized by specifying the `stylesheetUrl` property in the manifest:
|
|
213
|
-
*
|
|
214
|
-
* ```json
|
|
215
|
-
* {
|
|
216
|
-
* platform: {
|
|
217
|
-
* defaultWindowOptions: {
|
|
218
|
-
* stylesheetUrl: 'some-url.css',
|
|
219
|
-
* ...
|
|
220
|
-
* }
|
|
221
|
-
* }
|
|
222
|
-
* }
|
|
223
|
-
* ```
|
|
224
|
-
* For a list of common Layout CSS classes you can override in your custom stylesheet, see <a href="tutorial-layoutStyles.html">Useful Layout CSS Classes</a>
|
|
225
|
-
**
|
|
226
|
-
* To specify a Platform Custom Window, provide a `url` property when creating a Window.
|
|
227
|
-
* If you intend to render a Layout in your Custom Window, you must also specify an `HTMLElement` that the Layout will inject into and set its `id` property to `"layout-container"`.
|
|
228
|
-
*
|
|
229
|
-
* The example below will create a Platform Custom Window:
|
|
230
|
-
*
|
|
231
|
-
* ```js
|
|
232
|
-
* // in an OpenFin app:
|
|
233
|
-
* const platform = fin.Platform.getCurrentSync();
|
|
234
|
-
* const windowConfig =
|
|
235
|
-
* {
|
|
236
|
-
* url: "https://www.my-domain.com/my-custom-window.html", // here we point to where the Custom Frame is hosted.
|
|
237
|
-
* layout: {
|
|
238
|
-
* content: [
|
|
239
|
-
* {
|
|
240
|
-
* type: "stack",
|
|
241
|
-
* content: [
|
|
242
|
-
* {
|
|
243
|
-
* type: "component",
|
|
244
|
-
* componentName: "view",
|
|
245
|
-
* componentState: {
|
|
246
|
-
* name: "app #1",
|
|
247
|
-
* url: "https://cdn.openfin.co/docs/javascript/canary/Platform.html"
|
|
248
|
-
* }
|
|
249
|
-
* },
|
|
250
|
-
* {
|
|
251
|
-
* type: "component",
|
|
252
|
-
* componentName: "view",
|
|
253
|
-
* componentState: {
|
|
254
|
-
* name: "app #2",
|
|
255
|
-
* url: "https://cdn.openfin.co/docs/javascript/canary/Platform.html"
|
|
256
|
-
* }
|
|
257
|
-
* }
|
|
258
|
-
* ]
|
|
259
|
-
* }
|
|
260
|
-
* ]
|
|
261
|
-
* }
|
|
262
|
-
* };
|
|
263
|
-
* platform.createWindow(windowConfig);
|
|
264
|
-
* ```
|
|
265
|
-
*
|
|
266
|
-
* Here's an example of a minimalist Custom Platform Window implementation:
|
|
267
|
-
* ```html
|
|
268
|
-
* <html>
|
|
269
|
-
* <head>
|
|
270
|
-
* <meta charset="utf-8">
|
|
271
|
-
* <meta name="viewport" content="width=device-width, initial-scale=1">
|
|
272
|
-
* <link rel="stylesheet" type="text/css" href="./styles.css">
|
|
273
|
-
* </head>
|
|
274
|
-
* <body>
|
|
275
|
-
* <div id="of-frame-main">
|
|
276
|
-
* <div id="title-bar">
|
|
277
|
-
* <div class="title-bar-draggable">
|
|
278
|
-
* <div id="title"> This is a custom frame! </div>
|
|
279
|
-
* </div>
|
|
280
|
-
* <div id="buttons-wrapper">
|
|
281
|
-
* <div class="button" id="minimize-button"></div>
|
|
282
|
-
* <div class="button" id="expand-button"></div>
|
|
283
|
-
* <div class="button" id="close-button"></div>
|
|
284
|
-
* </div>
|
|
285
|
-
* </div>
|
|
286
|
-
* <div id="layout-container"></div> <!-- OpenFin layout would be injected here -->
|
|
287
|
-
* <script src="./custom-frame.js"></script>
|
|
288
|
-
* </div>
|
|
289
|
-
* </body>
|
|
290
|
-
* </html>
|
|
291
|
-
* ```
|
|
292
|
-
* Your Custom Window can use in-domain resources for further customization (such as CSS, scripts, etc.).<br>
|
|
293
|
-
* For a list of common Layout CSS classes you can override in your stylesheet, see <a href="tutorial-layoutStyles.html">Useful Layout CSS Classes</a>
|
|
294
|
-
*
|
|
295
|
-
* The example above will require the `body` element to have `height: 100%;` set in order to render the layout correctly.
|
|
296
|
-
*/
|
|
297
|
-
async createWindow(options) {
|
|
298
|
-
this.wire.sendAction('platform-create-window', this.identity).catch((e) => {
|
|
299
|
-
// don't expose
|
|
300
|
-
});
|
|
301
|
-
const client = await this.getClient();
|
|
302
|
-
if (!options.reason) {
|
|
303
|
-
options.reason = 'api-call';
|
|
304
|
-
}
|
|
305
|
-
const response = await client.dispatch('create-view-container', options);
|
|
306
|
-
if (!response || (0, validate_1.validateIdentity)(response.identity)) {
|
|
307
|
-
throw new Error(`When overwriting the createWindow call, please return an object that has a valid 'identity' property: ${JSON.stringify(response)}`);
|
|
308
|
-
}
|
|
309
|
-
const { identity } = response;
|
|
310
|
-
const res = this.fin.Window.wrapSync(identity);
|
|
311
|
-
// we add the identity at the top level for backwards compatibility.
|
|
312
|
-
res.name = identity.name;
|
|
313
|
-
res.uuid = identity.uuid;
|
|
314
|
-
return res;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Closes current platform, all its windows, and their views.
|
|
318
|
-
*
|
|
319
|
-
* @example
|
|
320
|
-
* ```js
|
|
321
|
-
* const platform = await fin.Platform.getCurrent();
|
|
322
|
-
* platform.quit();
|
|
323
|
-
* // All windows/views in current layout platform will close and platform will shut down
|
|
324
|
-
* ```
|
|
325
|
-
*/
|
|
326
|
-
async quit() {
|
|
327
|
-
this.wire.sendAction('platform-quit', this.identity).catch((e) => {
|
|
328
|
-
// don't expose
|
|
329
|
-
});
|
|
330
|
-
const client = await this.getClient();
|
|
331
|
-
return client.dispatch('quit');
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Closes a specified view in a target window.
|
|
335
|
-
* @param viewIdentity View identity
|
|
336
|
-
*
|
|
337
|
-
* @example
|
|
338
|
-
* ```js
|
|
339
|
-
* let windowIdentity;
|
|
340
|
-
* if (fin.me.isWindow) {
|
|
341
|
-
* windowIdentity = fin.me.identity;
|
|
342
|
-
* } else if (fin.me.isView) {
|
|
343
|
-
* windowIdentity = (await fin.me.getCurrentWindow()).identity;
|
|
344
|
-
* } else {
|
|
345
|
-
* throw new Error('Not running in a platform View or Window');
|
|
346
|
-
* }
|
|
347
|
-
*
|
|
348
|
-
* const viewOptions = {
|
|
349
|
-
* name: 'test_view',
|
|
350
|
-
* url: 'https://example.com'
|
|
351
|
-
* };
|
|
352
|
-
*
|
|
353
|
-
* function sleep(ms) {
|
|
354
|
-
* return new Promise(resolve => setTimeout(resolve, ms));
|
|
355
|
-
* }
|
|
356
|
-
*
|
|
357
|
-
* const platform = await fin.Platform.getCurrent();
|
|
358
|
-
*
|
|
359
|
-
* await platform.createView(viewOptions, windowIdentity);
|
|
360
|
-
* // a new view will now show in the current window
|
|
361
|
-
*
|
|
362
|
-
* await sleep(5000);
|
|
363
|
-
*
|
|
364
|
-
* const viewIdentity = { uuid: windowIdentity.uuid, name: 'test_view'};
|
|
365
|
-
* platform.closeView(viewIdentity);
|
|
366
|
-
* // the view will now close
|
|
367
|
-
* ```
|
|
368
|
-
*/
|
|
369
|
-
async closeView(viewIdentity) {
|
|
370
|
-
this.wire.sendAction('platform-close-view', this.identity).catch((e) => {
|
|
371
|
-
// don't expose
|
|
372
|
-
});
|
|
373
|
-
const client = await this.getClient();
|
|
374
|
-
await client.dispatch('close-view', {
|
|
375
|
-
view: viewIdentity
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* ***DEPRECATED - please use Platform.createView.***
|
|
380
|
-
* Reparents a specified view in a new target window.
|
|
381
|
-
* @param viewIdentity View identity
|
|
382
|
-
* @param target new owner window identity
|
|
383
|
-
*
|
|
384
|
-
* @tutorial Platform.createView
|
|
385
|
-
*/
|
|
386
|
-
async reparentView(viewIdentity, target) {
|
|
387
|
-
var _a;
|
|
388
|
-
// eslint-disable-next-line no-console
|
|
389
|
-
console.warn('Platform.reparentView has been deprecated, please use Platform.createView');
|
|
390
|
-
this.wire.sendAction('platform-reparent-view', this.identity).catch((e) => {
|
|
391
|
-
// don't expose
|
|
392
|
-
});
|
|
393
|
-
const normalizedViewIdentity = {
|
|
394
|
-
...viewIdentity,
|
|
395
|
-
uuid: (_a = viewIdentity.uuid) !== null && _a !== void 0 ? _a : this.identity.uuid
|
|
396
|
-
};
|
|
397
|
-
const view = await this.fin.View.wrap(normalizedViewIdentity);
|
|
398
|
-
const viewOptions = await view.getOptions();
|
|
399
|
-
return this.createView(viewOptions, target);
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Returns a snapshot of the platform in its current state. You can pass the returning object to
|
|
403
|
-
* [Platform.applySnapshot]{@link Platform#applySnapshot} to launch it.
|
|
404
|
-
*
|
|
405
|
-
* @remarks The snapshot will include details such as an [ISO format](https://en.wikipedia.org/wiki/ISO_8601)
|
|
406
|
-
* timestamp of when the snapshot was taken, OpenFin runtime version the platform is running on, monitor information
|
|
407
|
-
* and the list of currently running windows.
|
|
408
|
-
*
|
|
409
|
-
* @example
|
|
410
|
-
* ```js
|
|
411
|
-
* const platform = await fin.Platform.getCurrent();
|
|
412
|
-
* const snapshot = await platform.getSnapshot();
|
|
413
|
-
* ```
|
|
414
|
-
*/
|
|
415
|
-
async getSnapshot() {
|
|
416
|
-
this.wire.sendAction('platform-get-snapshot', this.identity).catch((e) => {
|
|
417
|
-
// don't expose
|
|
418
|
-
});
|
|
419
|
-
const client = await this.getClient();
|
|
420
|
-
return client.dispatch('get-snapshot');
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* **NOTE**: Internal use only. It is not recommended to manage the state of individual views.
|
|
424
|
-
*
|
|
425
|
-
* Returns a snapshot of a single view's options in its current state.
|
|
426
|
-
*
|
|
427
|
-
* Can be used to restore a view to a previous state.
|
|
428
|
-
*
|
|
429
|
-
* @param viewIdentity View identity
|
|
430
|
-
*
|
|
431
|
-
* @internal
|
|
432
|
-
* @experimental
|
|
433
|
-
* @remarks This slice of snapshot state is equivalent to what is stored as `componentState` for views
|
|
434
|
-
* when capturing platform state using [Platform.getSnapshot]{@link Platform#getSnapshot}.
|
|
435
|
-
*
|
|
436
|
-
* @example
|
|
437
|
-
* ```js
|
|
438
|
-
* const platform = await fin.Platform.getCurrent();
|
|
439
|
-
* const url = 'https://google.com';
|
|
440
|
-
* const view = await fin.View.create({ name: 'my-view', target: fin.me.identity, url });
|
|
441
|
-
*
|
|
442
|
-
* await view.navigate(url);
|
|
443
|
-
*
|
|
444
|
-
* const viewState = await platform.getViewSnapshot(view.identity);
|
|
445
|
-
*
|
|
446
|
-
* console.log(viewState);
|
|
447
|
-
* ```
|
|
448
|
-
*/
|
|
449
|
-
async getViewSnapshot(viewIdentity) {
|
|
450
|
-
const client = await this.getClient();
|
|
451
|
-
return client.dispatch('get-view-snapshot', { viewIdentity });
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Adds a snapshot to a running Platform.
|
|
455
|
-
* Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.
|
|
456
|
-
*
|
|
457
|
-
* Can optionally close existing windows and overwrite current platform state with that of a snapshot.
|
|
458
|
-
*
|
|
459
|
-
* The function accepts either a snapshot taken using {@link Platform#getSnapshot getSnapshot},
|
|
460
|
-
* or a url or filepath to a snapshot JSON object.
|
|
461
|
-
* @param requestedSnapshot Snapshot to apply, or a url or filepath.
|
|
462
|
-
* @param options Optional parameters to specify whether existing windows should be closed.
|
|
463
|
-
*
|
|
464
|
-
* @remarks Will create any windows and views that are not running but are passed in the snapshot object. Any View
|
|
465
|
-
* specified in the snapshot is assigned a randomly generated name to avoid collisions.
|
|
466
|
-
*
|
|
467
|
-
* @example
|
|
468
|
-
* ```js
|
|
469
|
-
* // Get a wrapped layout platform instance
|
|
470
|
-
* const platform = await fin.Platform.getCurrent();
|
|
471
|
-
*
|
|
472
|
-
* const snapshot = {
|
|
473
|
-
* windows: [
|
|
474
|
-
* {
|
|
475
|
-
* layout: {
|
|
476
|
-
* content: [
|
|
477
|
-
* {
|
|
478
|
-
* type: 'stack',
|
|
479
|
-
* content: [
|
|
480
|
-
* {
|
|
481
|
-
* type: 'component',
|
|
482
|
-
* componentName: 'view',
|
|
483
|
-
* componentState: {
|
|
484
|
-
* name: 'component_X',
|
|
485
|
-
* url: 'https://www.openfin.co'
|
|
486
|
-
* }
|
|
487
|
-
* },
|
|
488
|
-
* {
|
|
489
|
-
* type: 'component',
|
|
490
|
-
* componentName: 'view',
|
|
491
|
-
* componentState: {
|
|
492
|
-
* name: 'component_Y',
|
|
493
|
-
* url: 'https://cdn.openfin.co/embed-web/chart.html'
|
|
494
|
-
* }
|
|
495
|
-
* }
|
|
496
|
-
* ]
|
|
497
|
-
* }
|
|
498
|
-
* ]
|
|
499
|
-
* }
|
|
500
|
-
* }
|
|
501
|
-
* ]
|
|
502
|
-
* }
|
|
503
|
-
*
|
|
504
|
-
* platform.applySnapshot(snapshot);
|
|
505
|
-
* ```
|
|
506
|
-
*
|
|
507
|
-
* In place of a snapshot object, `applySnapshot` can take a url or filepath and to retrieve a JSON snapshot.
|
|
508
|
-
*
|
|
509
|
-
* ```js
|
|
510
|
-
* const platform = await fin.Platform.getCurrent();
|
|
511
|
-
* platform.applySnapshot('https://api.jsonbin.io/b/5e6f903ef4331e681fc1231d/1');
|
|
512
|
-
* ```
|
|
513
|
-
*
|
|
514
|
-
* Optionally, `applySnapshot` can close existing windows and restore a Platform to a previously saved state.
|
|
515
|
-
* This is accomplished by providing `{ closeExistingWindows: true }` as an option.
|
|
516
|
-
*
|
|
517
|
-
* ```js
|
|
518
|
-
* // Get a wrapped layout platform instance
|
|
519
|
-
* const platform = await fin.Platform.getCurrent();
|
|
520
|
-
*
|
|
521
|
-
* async function addViewToWindow(winId) {
|
|
522
|
-
* return await platform.createView({
|
|
523
|
-
* name: 'test_view_3',
|
|
524
|
-
* url: 'https://openfin.co'
|
|
525
|
-
* }, winId);
|
|
526
|
-
* }
|
|
527
|
-
*
|
|
528
|
-
* async function createWindowWithTwoViews() {
|
|
529
|
-
* const platform = await fin.Platform.getCurrent();
|
|
530
|
-
*
|
|
531
|
-
* return platform.createWindow({
|
|
532
|
-
* layout: {
|
|
533
|
-
* content: [
|
|
534
|
-
* {
|
|
535
|
-
* type: 'stack',
|
|
536
|
-
* content: [
|
|
537
|
-
* {
|
|
538
|
-
* type: 'component',
|
|
539
|
-
* componentName: 'view',
|
|
540
|
-
* componentState: {
|
|
541
|
-
* name: 'test_view_1',
|
|
542
|
-
* url: 'https://example.com'
|
|
543
|
-
* }
|
|
544
|
-
* },
|
|
545
|
-
* {
|
|
546
|
-
* type: 'component',
|
|
547
|
-
* componentName: 'view',
|
|
548
|
-
* componentState: {
|
|
549
|
-
* name: 'test_view_2',
|
|
550
|
-
* url: 'https://yahoo.com'
|
|
551
|
-
* }
|
|
552
|
-
* }
|
|
553
|
-
* ]
|
|
554
|
-
* }
|
|
555
|
-
* ]
|
|
556
|
-
* }
|
|
557
|
-
* });
|
|
558
|
-
* }
|
|
559
|
-
*
|
|
560
|
-
* const win = await createWindowWithTwoViews();
|
|
561
|
-
* // ... you will now see a new window with two views in it
|
|
562
|
-
*
|
|
563
|
-
* // we take a snapshot of the current state of the app, before changing it
|
|
564
|
-
* const snapshotOfInitialAppState = await platform.getSnapshot();
|
|
565
|
-
*
|
|
566
|
-
* // now let's change the state of the app:
|
|
567
|
-
* await addViewToWindow(win.identity);
|
|
568
|
-
* // ... the window now has three views in it
|
|
569
|
-
*
|
|
570
|
-
* await platform.applySnapshot(snapshotOfInitialAppState, { closeExistingWindows: true });
|
|
571
|
-
* // ... the window will revert to previous state, with just two views
|
|
572
|
-
*
|
|
573
|
-
* ```
|
|
574
|
-
*/
|
|
575
|
-
async applySnapshot(requestedSnapshot, options) {
|
|
576
|
-
this.wire.sendAction('platform-apply-snapshot', this.identity).catch((e) => {
|
|
577
|
-
// don't expose
|
|
578
|
-
});
|
|
579
|
-
const errMsg = 'Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.';
|
|
580
|
-
let snapshot;
|
|
581
|
-
if (typeof requestedSnapshot === 'string') {
|
|
582
|
-
// Fetch and parse snapshot
|
|
583
|
-
try {
|
|
584
|
-
const response = await this._channel.wire.sendAction('get-application-manifest', {
|
|
585
|
-
manifestUrl: requestedSnapshot
|
|
586
|
-
});
|
|
587
|
-
snapshot = response.payload.data;
|
|
588
|
-
}
|
|
589
|
-
catch (err) {
|
|
590
|
-
throw new Error(`${errMsg}: ${err}`);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
else {
|
|
594
|
-
snapshot = requestedSnapshot;
|
|
595
|
-
}
|
|
596
|
-
if (!snapshot.windows) {
|
|
597
|
-
throw new Error(errMsg);
|
|
598
|
-
}
|
|
599
|
-
const client = await this.getClient();
|
|
600
|
-
await client.dispatch('apply-snapshot', {
|
|
601
|
-
snapshot,
|
|
602
|
-
options
|
|
603
|
-
});
|
|
604
|
-
return this;
|
|
605
|
-
}
|
|
606
|
-
/**
|
|
607
|
-
* Fetches a JSON manifest using the browser process and returns a Javascript object.
|
|
608
|
-
* Can be overwritten using {@link Platform.PlatformModule.init Platform.init}.
|
|
609
|
-
* @param manifestUrl The URL of the manifest to fetch.
|
|
610
|
-
*
|
|
611
|
-
* @remarks Can be overwritten using {@link Platform#init Platform.init}.
|
|
612
|
-
*
|
|
613
|
-
* @example
|
|
614
|
-
*
|
|
615
|
-
* ```js
|
|
616
|
-
* const platform = fin.Platform.getCurrentSync();
|
|
617
|
-
* const manifest = await platform.fetchManifest('https://www.path-to-manifest.com/app.json');
|
|
618
|
-
* console.log(manifest);
|
|
619
|
-
* ```
|
|
620
|
-
*/
|
|
621
|
-
async fetchManifest(manifestUrl) {
|
|
622
|
-
const client = await this.getClient();
|
|
623
|
-
return client.dispatch('platform-fetch-manifest', { manifestUrl });
|
|
624
|
-
}
|
|
625
|
-
/**
|
|
626
|
-
* Retrieves a manifest by url and launches a legacy application manifest or snapshot into the platform. Returns a promise that
|
|
627
|
-
* resolves to the wrapped Platform.
|
|
628
|
-
* @param manifestUrl - The URL of the manifest that will be launched into the platform. If this app manifest
|
|
629
|
-
* contains a snapshot, that will be launched into the platform. If not, the application described in startup_app options
|
|
630
|
-
* will be launched into the platform. The applicable startup_app options will become {@link OpenFin.ViewCreationOptions View Options}.
|
|
631
|
-
*
|
|
632
|
-
* @remarks If the app manifest contains a snapshot, that will be launched into the platform. If not, the
|
|
633
|
-
* application described in startup_app options will be launched into the platform as a window with a single view.
|
|
634
|
-
* The applicable startup_app options will become View Options.
|
|
635
|
-
*
|
|
636
|
-
* @example
|
|
637
|
-
* ```js
|
|
638
|
-
* try {
|
|
639
|
-
* const platform = fin.Platform.getCurrentSync();
|
|
640
|
-
* await platform.launchContentManifest('http://localhost:5555/app.json');
|
|
641
|
-
* console.log(`content launched successfully into platform`);
|
|
642
|
-
* } catch(e) {
|
|
643
|
-
* console.error(e);
|
|
644
|
-
* }
|
|
645
|
-
* // For a local manifest file:
|
|
646
|
-
* try {
|
|
647
|
-
* const platform = fin.Platform.getCurrentSync();
|
|
648
|
-
* platform.launchContentManifest('file:///C:/somefolder/app.json');
|
|
649
|
-
* console.log(`content launched successfully into platform`);
|
|
650
|
-
* } catch(e) {
|
|
651
|
-
* console.error(e);
|
|
652
|
-
* }
|
|
653
|
-
* ```
|
|
654
|
-
* @experimental
|
|
655
|
-
*/
|
|
656
|
-
async launchContentManifest(manifestUrl) {
|
|
657
|
-
this.wire.sendAction('platform-launch-content-manifest', this.identity).catch((e) => {
|
|
658
|
-
// don't expose
|
|
659
|
-
});
|
|
660
|
-
const client = await this.getClient();
|
|
661
|
-
const manifest = await this.fetchManifest(manifestUrl);
|
|
662
|
-
client.dispatch('launch-into-platform', { manifest });
|
|
663
|
-
return this;
|
|
664
|
-
}
|
|
665
|
-
/**
|
|
666
|
-
* Set the context of a host window. The context will be available to the window itself, and to its child Views. It will be saved in any platform snapshots.
|
|
667
|
-
* It can be retrieved using {@link Platform#getWindowContext getWindowContext}.
|
|
668
|
-
* @param context - A field where serializable context data can be stored to be saved in platform snapshots.
|
|
669
|
-
* @param target - A target window or view may optionally be provided. If no target is provided, the update will be applied
|
|
670
|
-
* to the current window (if called from a Window) or the current host window (if called from a View).
|
|
671
|
-
*
|
|
672
|
-
* @remarks The context data must be serializable. This can only be called from a window or view that has been launched into a
|
|
673
|
-
* platform.
|
|
674
|
-
* This method can be called from the window itself, or from any child view. Context data is shared by all
|
|
675
|
-
* entities within a window.
|
|
676
|
-
*
|
|
677
|
-
* @example
|
|
678
|
-
* Setting own context:
|
|
679
|
-
* ```js
|
|
680
|
-
* const platform = fin.Platform.getCurrentSync();
|
|
681
|
-
* const contextData = {
|
|
682
|
-
* security: 'STOCK',
|
|
683
|
-
* currentView: 'detailed'
|
|
684
|
-
* }
|
|
685
|
-
*
|
|
686
|
-
* await platform.setWindowContext(contextData);
|
|
687
|
-
* // Context of current window is now set to `contextData`
|
|
688
|
-
* ```
|
|
689
|
-
*
|
|
690
|
-
* Setting the context of another window or view:
|
|
691
|
-
* ```js
|
|
692
|
-
* const platform = fin.Platform.getCurrentSync();
|
|
693
|
-
* const contextData = {
|
|
694
|
-
* security: 'STOCK',
|
|
695
|
-
* currentView: 'detailed'
|
|
696
|
-
* }
|
|
697
|
-
*
|
|
698
|
-
* const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
|
|
699
|
-
* await platform.setWindowContext(contextData, windowOrViewIdentity);
|
|
700
|
-
* // Context of the target window or view is now set to `contextData`
|
|
701
|
-
* ```
|
|
702
|
-
*
|
|
703
|
-
* A view can listen to changes to its host window's context by listening to the `host-context-changed` event.
|
|
704
|
-
* This event will fire when a host window's context is updated or when the view is reparented to a new window:
|
|
705
|
-
*
|
|
706
|
-
* ```js
|
|
707
|
-
* // From a view
|
|
708
|
-
* const contextChangeHandler = ({ context }) => {
|
|
709
|
-
* console.log('Host window\'s context has changed. New context data:', context);
|
|
710
|
-
* // react to new context data here
|
|
711
|
-
* }
|
|
712
|
-
* await fin.me.on('host-context-changed', contextChangeHandler);
|
|
713
|
-
*
|
|
714
|
-
* const platform = await fin.Platform.getCurrentSync();
|
|
715
|
-
* const contextData = {
|
|
716
|
-
* security: 'STOCK',
|
|
717
|
-
* currentView: 'detailed'
|
|
718
|
-
* }
|
|
719
|
-
* platform.setWindowContext(contextData) // contextChangeHandler will log the new context
|
|
720
|
-
* ```
|
|
721
|
-
*
|
|
722
|
-
* To listen to a window's context updates, use the `context-changed` event:
|
|
723
|
-
* ```js
|
|
724
|
-
* // From a window
|
|
725
|
-
* const contextChangeHandler = ({ context }) => {
|
|
726
|
-
* console.log('This window\'s context has changed. New context data:', context);
|
|
727
|
-
* // react to new context data here
|
|
728
|
-
* }
|
|
729
|
-
* await fin.me.on('context-changed', contextChangeHandler);
|
|
730
|
-
*
|
|
731
|
-
* const platform = await fin.Platform.getCurrentSync();
|
|
732
|
-
* const contextData = {
|
|
733
|
-
* security: 'STOCK',
|
|
734
|
-
* currentView: 'detailed'
|
|
735
|
-
* }
|
|
736
|
-
* platform.setWindowContext(contextData) // contextChangeHandler will log the new context
|
|
737
|
-
* ```
|
|
738
|
-
* @experimental
|
|
739
|
-
*/
|
|
740
|
-
async setWindowContext(context = {}, target) {
|
|
741
|
-
this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
|
|
742
|
-
// don't expose
|
|
743
|
-
});
|
|
744
|
-
if (!context) {
|
|
745
|
-
throw new Error('Please provide a serializable object or string to set the context.');
|
|
746
|
-
}
|
|
747
|
-
const client = await this.getClient();
|
|
748
|
-
const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
|
|
749
|
-
await client.dispatch('set-window-context', {
|
|
750
|
-
context,
|
|
751
|
-
entityType,
|
|
752
|
-
target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
/**
|
|
756
|
-
* Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
|
|
757
|
-
* The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
|
|
758
|
-
* @param target - A target window or view may optionally be provided. If no target is provided, target will be
|
|
759
|
-
* the current window (if called from a Window) or the current host window (if called from a View).
|
|
760
|
-
*
|
|
761
|
-
* @remarks This method can be called from the window itself, or from any child view. Context data is shared
|
|
762
|
-
* by all entities within a window.
|
|
763
|
-
*
|
|
764
|
-
* @example
|
|
765
|
-
*
|
|
766
|
-
* Retrieving context from current window:
|
|
767
|
-
* ```js
|
|
768
|
-
* const platform = fin.Platform.getCurrentSync();
|
|
769
|
-
* const customContext = { answer: 42 };
|
|
770
|
-
* await platform.setWindowContext(customContext);
|
|
771
|
-
*
|
|
772
|
-
* const myContext = await platform.getWindowContext();
|
|
773
|
-
* console.log(myContext); // { answer: 42 }
|
|
774
|
-
* ```
|
|
775
|
-
*
|
|
776
|
-
* Retrieving the context of another window or view:
|
|
777
|
-
* ```js
|
|
778
|
-
* const platform = fin.Platform.getCurrentSync();
|
|
779
|
-
*
|
|
780
|
-
* const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
|
|
781
|
-
*
|
|
782
|
-
* const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
|
|
783
|
-
* console.log(targetWindowContext); // context of target window
|
|
784
|
-
* ```
|
|
785
|
-
* @experimental
|
|
786
|
-
*/
|
|
787
|
-
async getWindowContext(target) {
|
|
788
|
-
this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
|
|
789
|
-
// don't expose
|
|
790
|
-
});
|
|
791
|
-
const client = await this.getClient();
|
|
792
|
-
const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
|
|
793
|
-
return client.dispatch('get-window-context', {
|
|
794
|
-
target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
|
|
795
|
-
entityType
|
|
796
|
-
});
|
|
797
|
-
}
|
|
798
|
-
/**
|
|
799
|
-
* Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
|
|
800
|
-
* This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
|
|
801
|
-
* @param winId
|
|
802
|
-
* @param options
|
|
803
|
-
*
|
|
804
|
-
* @remarks This method works by setting a `close-requested` handler on the Platform Window. If you have your own `close-requested` handler set on the Platform Window as well,
|
|
805
|
-
* it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
|
|
806
|
-
*
|
|
807
|
-
* @example
|
|
808
|
-
*
|
|
809
|
-
* ```js
|
|
810
|
-
* // Close the current Window inside a Window context
|
|
811
|
-
* const platform = await fin.Platform.getCurrent();
|
|
812
|
-
* platform.closeWindow(fin.me.identity);
|
|
813
|
-
*
|
|
814
|
-
* // Close the Window from inside a View context
|
|
815
|
-
* const platform = await fin.Platform.getCurrent();
|
|
816
|
-
* const parentWindow = await fin.me.getCurrentWindow();
|
|
817
|
-
* platform.closeWindow(parentWindow.identity);
|
|
818
|
-
*
|
|
819
|
-
* // Close the Window and do not fire the before unload handler on Views
|
|
820
|
-
* const platform = await fin.Platform.getCurrent();
|
|
821
|
-
* platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
|
|
822
|
-
* ```
|
|
823
|
-
* @experimental
|
|
824
|
-
*/
|
|
825
|
-
async closeWindow(windowId, options = { skipBeforeUnload: false }) {
|
|
826
|
-
this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
|
|
827
|
-
// don't expose
|
|
828
|
-
});
|
|
829
|
-
const client = await this.getClient();
|
|
830
|
-
return client.dispatch('close-window', { windowId, options });
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
exports.Platform = Platform;
|
|
834
|
-
_Platform_connectToProvider = new WeakMap();
|