@openfin/core 31.74.6 → 31.74.8
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 +68 -16
- 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 +1 -2
- package/src/api/application/Instance.js +23 -5
- package/src/api/base.d.ts +1 -2
- package/src/api/events/base.d.ts +0 -3
- package/src/api/events/system.d.ts +2 -2
- package/src/api/events/view.d.ts +6 -3
- package/src/api/events/webcontents.d.ts +2 -0
- package/src/api/events/window.d.ts +21 -13
- package/src/api/interappbus/channel/index.js +1 -1
- package/src/api/interappbus/channel/protocols/classic/strategy.js +24 -6
- package/src/api/interappbus/index.js +1 -1
- package/src/api/interop/InteropBroker.js +6 -2
- package/src/api/interop/fdc3/PrivateChannelClient.d.ts +1 -0
- package/src/api/interop/fdc3/PrivateChannelClient.js +15 -7
- package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +16 -2
- package/src/api/interop/fdc3/PrivateChannelProvider.js +80 -28
- package/src/api/interop/fdc3/fdc3-1.2.js +53 -5
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +11 -10
- package/src/api/interop/fdc3/fdc3-2.0.js +18 -19
- package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +1 -1
- package/src/api/interop/fdc3/utils.d.ts +17 -0
- package/src/api/interop/fdc3/utils.js +75 -21
- package/src/api/interop/utils.d.ts +0 -1
- package/src/api/interop/utils.js +1 -9
- package/src/api/platform/Factory.d.ts +2 -1
- package/src/api/platform/Factory.js +5 -9
- package/src/api/platform/Instance.d.ts +6 -5
- package/src/api/platform/Instance.js +1 -0
- package/src/api/platform/layout/Factory.js +16 -6
- package/src/api/platform/layout/Instance.d.ts +6 -0
- package/src/api/platform/layout/Instance.js +26 -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 +117 -0
- package/src/api/platform/layout/controllers/layout-entities-controller.js +270 -0
- package/src/api/platform/layout/controllers/tab-drag-controller.d.ts +2 -1
- package/src/api/platform/layout/entities/layout-entities.d.ts +144 -0
- package/src/api/platform/layout/entities/layout-entities.js +216 -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/view/Instance.d.ts +13 -3
- package/src/api/view/Instance.js +41 -4
- package/src/api/webcontents/main.d.ts +1 -22
- package/src/mock.d.ts +1 -1
- package/src/mock.js +5 -2
- package/src/transport/transport.d.ts +7 -3
- package/src/transport/transport.js +10 -11
- package/src/transport/wire.d.ts +1 -0
- package/src/util/channel-api-relay.d.ts +13 -0
- package/src/util/channel-api-relay.js +47 -0
- package/src/util/lazy.d.ts +16 -0
- package/src/util/lazy.js +26 -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
|
@@ -6,7 +6,6 @@ const InteropClient_1 = require("../InteropClient");
|
|
|
6
6
|
const utils_2 = require("./utils");
|
|
7
7
|
const fdc3_1_2_1 = require("./fdc3-1.2");
|
|
8
8
|
const PrivateChannelClient_1 = require("./PrivateChannelClient");
|
|
9
|
-
const PrivateChannelProvider_1 = require("./PrivateChannelProvider");
|
|
10
9
|
/**
|
|
11
10
|
* @typedef { object } AppIdentifier
|
|
12
11
|
* @summary Identifies an application, or instance of an application, and is used to target FDC3 API calls at specific applications.
|
|
@@ -181,7 +180,7 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
181
180
|
* Find all the available instances for a particular application.
|
|
182
181
|
* @param { AppIdentifier } app
|
|
183
182
|
* @returns { Promise<Array<AppIdentifier>> }
|
|
184
|
-
* @tutorial findInstances
|
|
183
|
+
* @tutorial fdc3v2.findInstances
|
|
185
184
|
*/
|
|
186
185
|
async findInstances(app) {
|
|
187
186
|
this.wire.sendAction('fdc3-find-instances').catch((e) => {
|
|
@@ -199,7 +198,7 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
199
198
|
* Retrieves the AppMetadata for an AppIdentifier, which provides additional metadata (such as icons, a title and description) from the App Directory record for the application, that may be used for display purposes.
|
|
200
199
|
* @param { AppIdentifier } app
|
|
201
200
|
* @returns { Promise<AppMetadata(2)> }
|
|
202
|
-
* @tutorial getAppMetadata
|
|
201
|
+
* @tutorial fdc3v2.getAppMetadata
|
|
203
202
|
*/
|
|
204
203
|
async getAppMetadata(app) {
|
|
205
204
|
this.wire.sendAction('fdc3-get-app-metadata').catch((e) => {
|
|
@@ -277,7 +276,7 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
277
276
|
* @param { Context } context
|
|
278
277
|
* @param { string } [resultType] The type of result returned for any intent specified during resolution.
|
|
279
278
|
* @returns { Promise<Array<AppIntent(2)>> }
|
|
280
|
-
* @tutorial findIntentsByContext
|
|
279
|
+
* @tutorial fdc3v2.findIntentsByContext
|
|
281
280
|
*/
|
|
282
281
|
async findIntentsByContext(context, resultType) {
|
|
283
282
|
this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
|
|
@@ -298,7 +297,7 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
298
297
|
* @param { Context } context Context associated with the Intent
|
|
299
298
|
* @param { AppIdentifier | TargetApp } [app]
|
|
300
299
|
* @returns { Promise<IntentResolution(2)> }
|
|
301
|
-
* @tutorial raiseIntent
|
|
300
|
+
* @tutorial fdc3v2.raiseIntent
|
|
302
301
|
*/
|
|
303
302
|
async raiseIntent(intent, context, app) {
|
|
304
303
|
this.wire.sendAction('fdc3-raise-intent').catch((e) => {
|
|
@@ -317,7 +316,7 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
317
316
|
* @param { Context } context Context associated with the Intent
|
|
318
317
|
* @param { AppIdentifier | TargetApp } [app]
|
|
319
318
|
* @returns { Promise<IntentResolution(2)> }
|
|
320
|
-
* @tutorial raiseIntentForContext
|
|
319
|
+
* @tutorial fdc3v2.raiseIntentForContext
|
|
321
320
|
*/
|
|
322
321
|
async raiseIntentForContext(context, app) {
|
|
323
322
|
// TODO: We have to do the same thing we do for raiseIntent here as well.
|
|
@@ -349,27 +348,27 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
349
348
|
// The FDC3 Intenter handler only expects the context and contextMetadata to be passed to the handler,
|
|
350
349
|
// so we wrap it here and only pass those paramaters.
|
|
351
350
|
const contextHandler = async (raisedIntent) => {
|
|
351
|
+
let intentResult;
|
|
352
|
+
let intentResultToSend;
|
|
352
353
|
const { context, metadata: intentMetadata } = raisedIntent;
|
|
353
354
|
const { contextMetadata, metadata, ...rest } = context;
|
|
354
|
-
|
|
355
|
+
const intentResolutionResultId = (intentMetadata === null || intentMetadata === void 0 ? void 0 : intentMetadata.intentResolutionResultId) || (metadata === null || metadata === void 0 ? void 0 : metadata.intentResolutionResultId);
|
|
355
356
|
try {
|
|
356
357
|
const newContext = metadata ? { metadata, ...rest } : { ...rest };
|
|
357
358
|
intentResult = await handler(newContext, contextMetadata);
|
|
359
|
+
intentResultToSend = intentResult;
|
|
358
360
|
}
|
|
359
361
|
catch (error) {
|
|
360
362
|
intentResult = error;
|
|
363
|
+
intentResultToSend = { error: true };
|
|
361
364
|
}
|
|
362
|
-
const intentResolutionResultId = (intentMetadata === null || intentMetadata === void 0 ? void 0 : intentMetadata.intentResolutionResultId) || (metadata === null || metadata === void 0 ? void 0 : metadata.intentResolutionResultId);
|
|
363
365
|
if (intentResolutionResultId) {
|
|
364
|
-
|
|
365
|
-
this.fin.InterApplicationBus.publish(intentResolutionResultId, intentResult);
|
|
366
|
+
this.fin.InterApplicationBus.publish(intentResolutionResultId, intentResultToSend);
|
|
366
367
|
}
|
|
367
368
|
if (intentResult instanceof Error) {
|
|
368
369
|
throw new Error(intentResult.message);
|
|
369
370
|
}
|
|
370
|
-
|
|
371
|
-
return intentResult;
|
|
372
|
-
}
|
|
371
|
+
return intentResult;
|
|
373
372
|
};
|
|
374
373
|
return this.fin.me.interop.registerIntentHandler(contextHandler, intent, { fdc3Version: '2.0' });
|
|
375
374
|
}
|
|
@@ -385,12 +384,11 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
385
384
|
/**
|
|
386
385
|
* Returns a Channel with an auto-generated identity that is intended for private communication between applications. Primarily used to create channels that will be returned to other applications via an IntentResolution for a raised intent.
|
|
387
386
|
* @returns { Promise<PrivateChannel> }
|
|
388
|
-
* @tutorial createPrivateChannel
|
|
387
|
+
* @tutorial fdc3v2.createPrivateChannel
|
|
389
388
|
*/
|
|
390
389
|
async createPrivateChannel() {
|
|
391
390
|
const channelId = (0, utils_1.generateId)();
|
|
392
|
-
|
|
393
|
-
const newPrivateChannelProvider = new PrivateChannelProvider_1.PrivateChannelProvider(channelProvider, channelId);
|
|
391
|
+
await InteropClient_1.InteropClient.ferryFdc3Call(this.fin.me.interop, 'createPrivateChannelProvider', { channelId });
|
|
394
392
|
const channelClient = await this.fin.InterApplicationBus.Channel.connect(channelId);
|
|
395
393
|
const newPrivateChannelClient = new PrivateChannelClient_1.PrivateChannelClient(channelClient, channelId);
|
|
396
394
|
return (0, utils_2.buildPrivateChannelObject)(newPrivateChannelClient);
|
|
@@ -398,7 +396,7 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
398
396
|
/**
|
|
399
397
|
* Retrieves a list of the User Channels available for the app to join.
|
|
400
398
|
* @returns { Promise<Channel[]>}
|
|
401
|
-
* @tutorial getUserChannels
|
|
399
|
+
* @tutorial fdc3v2.getUserChannels
|
|
402
400
|
*/
|
|
403
401
|
async getUserChannels() {
|
|
404
402
|
const channels = await this.fin.me.interop.getContextGroups();
|
|
@@ -422,7 +420,7 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
422
420
|
* Join an app to a specified User channel.
|
|
423
421
|
* @param { string } channelId Channel name
|
|
424
422
|
* @returns { Promise<void> }
|
|
425
|
-
* @tutorial joinUserChannel
|
|
423
|
+
* @tutorial fdc3v2.joinUserChannel
|
|
426
424
|
*/
|
|
427
425
|
async joinUserChannel(channelId) {
|
|
428
426
|
return this.fdc3Module.joinChannel(channelId);
|
|
@@ -441,6 +439,7 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
441
439
|
/**
|
|
442
440
|
* Returns the Channel object for the current User channel membership
|
|
443
441
|
* @returns { Promise<FDC3.Channel | null> }
|
|
442
|
+
* @tutorial fdc3.getCurrentChannel
|
|
444
443
|
*/
|
|
445
444
|
async getCurrentChannel() {
|
|
446
445
|
const currentChannel = await this.fdc3Module.getCurrentChannel();
|
|
@@ -465,7 +464,7 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
465
464
|
* Retrieves information about the FDC3 implementation, including the supported version of the FDC3 specification, the name of the provider of the implementation, its own version number, details of whether optional API features are implemented and the metadata of the calling application according to the desktop agent.
|
|
466
465
|
* fdc3HandleGetInfo must be overridden in the InteropBroker so that the ImplementationMetadata will have the appMetadata info.
|
|
467
466
|
* @returns { Promise<ImplementationMetadata(2)> }
|
|
468
|
-
* @tutorial getInfo
|
|
467
|
+
* @tutorial fdc3v2.getInfo
|
|
469
468
|
*/
|
|
470
469
|
async getInfo() {
|
|
471
470
|
return InteropClient_1.InteropClient.ferryFdc3Call(this.fin.me.interop, 'fdc3v2GetInfo', { fdc3Version: '2.0' });
|
|
@@ -64,7 +64,7 @@ export interface DesktopAgent {
|
|
|
64
64
|
addContextListener(contextType: string | null, handler: ContextHandler): Promise<Listener>;
|
|
65
65
|
getUserChannels(): Promise<Array<SystemChannel>>;
|
|
66
66
|
joinUserChannel(channelId: string): Promise<void>;
|
|
67
|
-
getOrCreateChannel(channelId: string): Promise<
|
|
67
|
+
getOrCreateChannel(channelId: string): Promise<Channel>;
|
|
68
68
|
createPrivateChannel(): Promise<PrivateChannel>;
|
|
69
69
|
getCurrentChannel(): Promise<ChannelV1 | null>;
|
|
70
70
|
leaveCurrentChannel(): Promise<void>;
|
|
@@ -21,8 +21,25 @@ export declare enum ResultError {
|
|
|
21
21
|
*/
|
|
22
22
|
IntentHandlerRejected = "IntentHandlerRejected"
|
|
23
23
|
}
|
|
24
|
+
export declare enum ChannelError {
|
|
25
|
+
/** Returned if the specified channel is not found when attempting to join a
|
|
26
|
+
* channel via the `joinUserChannel` function of the DesktopAgent (`fdc3`).
|
|
27
|
+
*/
|
|
28
|
+
NoChannelFound = "NoChannelFound",
|
|
29
|
+
/** SHOULD be returned when a request to join a user channel or to a retrieve
|
|
30
|
+
* a Channel object via the `joinUserChannel` or `getOrCreateChannel` methods
|
|
31
|
+
* of the DesktopAgent (`fdc3`) object is denied.
|
|
32
|
+
*/
|
|
33
|
+
AccessDenied = "AccessDenied",
|
|
34
|
+
/** SHOULD be returned when a channel cannot be created or retrieved via the
|
|
35
|
+
* `getOrCreateChannel` method of the DesktopAgent (`fdc3`).
|
|
36
|
+
*/
|
|
37
|
+
CreationFailed = "CreationFailed"
|
|
38
|
+
}
|
|
24
39
|
export declare const buildPrivateChannelObject: (privateChannelClient: PrivateChannelClient) => PrivateChannel;
|
|
25
40
|
export declare const buildAppChannelObject: (sessionContextGroup: OpenFin.SessionContextGroup) => Channel;
|
|
26
41
|
export declare const connectPrivateChannel: (channelId: string) => Promise<PrivateChannel>;
|
|
42
|
+
export declare const isContext: (context: unknown) => context is Context;
|
|
43
|
+
export declare const isChannel: (channel: unknown) => channel is Channel;
|
|
27
44
|
export declare const getIntentResolution: (interopModule: OpenFin.InteropClient, context: Context, app?: AppIdentifier | TargetApp, intent?: string) => Promise<IntentResolution>;
|
|
28
45
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getIntentResolution = exports.connectPrivateChannel = exports.buildAppChannelObject = exports.buildPrivateChannelObject = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
|
|
3
|
+
exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildAppChannelObject = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const PrivateChannelClient_1 = require("./PrivateChannelClient");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
6
7
|
const getUnsupportedChannelApis = (channelType) => {
|
|
7
8
|
return {
|
|
8
9
|
addContextListener: () => {
|
|
@@ -35,6 +36,22 @@ var ResultError;
|
|
|
35
36
|
*/
|
|
36
37
|
ResultError["IntentHandlerRejected"] = "IntentHandlerRejected";
|
|
37
38
|
})(ResultError = exports.ResultError || (exports.ResultError = {}));
|
|
39
|
+
var ChannelError;
|
|
40
|
+
(function (ChannelError) {
|
|
41
|
+
/** Returned if the specified channel is not found when attempting to join a
|
|
42
|
+
* channel via the `joinUserChannel` function of the DesktopAgent (`fdc3`).
|
|
43
|
+
*/
|
|
44
|
+
ChannelError["NoChannelFound"] = "NoChannelFound";
|
|
45
|
+
/** SHOULD be returned when a request to join a user channel or to a retrieve
|
|
46
|
+
* a Channel object via the `joinUserChannel` or `getOrCreateChannel` methods
|
|
47
|
+
* of the DesktopAgent (`fdc3`) object is denied.
|
|
48
|
+
*/
|
|
49
|
+
ChannelError["AccessDenied"] = "AccessDenied";
|
|
50
|
+
/** SHOULD be returned when a channel cannot be created or retrieved via the
|
|
51
|
+
* `getOrCreateChannel` method of the DesktopAgent (`fdc3`).
|
|
52
|
+
*/
|
|
53
|
+
ChannelError["CreationFailed"] = "CreationFailed";
|
|
54
|
+
})(ChannelError = exports.ChannelError || (exports.ChannelError = {}));
|
|
38
55
|
const buildPrivateChannelObject = (privateChannelClient) => {
|
|
39
56
|
let clientDisconnected = false;
|
|
40
57
|
const checkIfClientDisconnected = () => {
|
|
@@ -95,14 +112,33 @@ const buildAppChannelObject = (sessionContextGroup) => {
|
|
|
95
112
|
return context === undefined ? null : context;
|
|
96
113
|
},
|
|
97
114
|
addContextListener: (contextType, handler) => {
|
|
98
|
-
let
|
|
115
|
+
let realHandler;
|
|
116
|
+
let realType;
|
|
99
117
|
if (typeof contextType === 'function') {
|
|
100
118
|
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
101
|
-
|
|
119
|
+
realHandler = contextType;
|
|
102
120
|
}
|
|
103
121
|
else {
|
|
104
|
-
|
|
122
|
+
realHandler = handler;
|
|
123
|
+
if (typeof contextType === 'string') {
|
|
124
|
+
realType = contextType;
|
|
125
|
+
}
|
|
105
126
|
}
|
|
127
|
+
const listener = (async () => {
|
|
128
|
+
let first = true;
|
|
129
|
+
const currentContext = await sessionContextGroup.getCurrentContext(realType);
|
|
130
|
+
const wrappedHandler = (context, contextMetadata) => {
|
|
131
|
+
if (first) {
|
|
132
|
+
first = false;
|
|
133
|
+
if ((0, lodash_1.isEqual)(currentContext, context)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// eslint-disable-next-line consistent-return
|
|
138
|
+
return realHandler(context, contextMetadata);
|
|
139
|
+
};
|
|
140
|
+
return sessionContextGroup.addContextHandler(wrappedHandler, realType);
|
|
141
|
+
})();
|
|
106
142
|
return {
|
|
107
143
|
...listener,
|
|
108
144
|
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
@@ -122,6 +158,22 @@ const connectPrivateChannel = async (channelId) => {
|
|
|
122
158
|
}
|
|
123
159
|
};
|
|
124
160
|
exports.connectPrivateChannel = connectPrivateChannel;
|
|
161
|
+
const isContext = (context) => {
|
|
162
|
+
if (context && typeof context === 'object' && 'type' in context) {
|
|
163
|
+
const { type } = context;
|
|
164
|
+
return typeof type === 'string';
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
};
|
|
168
|
+
exports.isContext = isContext;
|
|
169
|
+
const isChannel = (channel) => {
|
|
170
|
+
if (channel && typeof channel === 'object' && 'type' in channel && 'id' in channel) {
|
|
171
|
+
const { type, id } = channel;
|
|
172
|
+
return typeof type === 'string' && typeof id === 'string' && (type === 'app' || type === 'private');
|
|
173
|
+
}
|
|
174
|
+
return false;
|
|
175
|
+
};
|
|
176
|
+
exports.isChannel = isChannel;
|
|
125
177
|
const getIntentResolution = async (interopModule, context, app, intent) => {
|
|
126
178
|
// Generate an ID to make a session context group with. We will pass that ID to the Broker.
|
|
127
179
|
// The broker will then setContext on that session context group later with our Intent Result,
|
|
@@ -138,31 +190,33 @@ const getIntentResolution = async (interopModule, context, app, intent) => {
|
|
|
138
190
|
// Set up the getResult call.
|
|
139
191
|
const getResult = async () => {
|
|
140
192
|
let intentResult = await getResultPromise;
|
|
141
|
-
if (!intentResult) {
|
|
193
|
+
if (!intentResult || typeof intentResult !== 'object') {
|
|
142
194
|
throw new Error(ResultError.NoResultReturned);
|
|
143
195
|
}
|
|
144
|
-
|
|
196
|
+
const { error } = intentResult;
|
|
197
|
+
if (error) {
|
|
145
198
|
throw new Error(ResultError.IntentHandlerRejected);
|
|
146
199
|
}
|
|
147
|
-
if (
|
|
200
|
+
if ((0, exports.isChannel)(intentResult)) {
|
|
148
201
|
const { id, type } = intentResult;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
202
|
+
switch (type) {
|
|
203
|
+
case 'private': {
|
|
204
|
+
intentResult = await (0, exports.connectPrivateChannel)(id);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
case 'app': {
|
|
208
|
+
const sessionContextGroup = await interopModule.joinSessionContextGroup(id);
|
|
209
|
+
intentResult = (0, exports.buildAppChannelObject)(sessionContextGroup);
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
default: {
|
|
213
|
+
break;
|
|
163
214
|
}
|
|
164
215
|
}
|
|
165
216
|
}
|
|
217
|
+
else if (!(0, exports.isContext)(intentResult)) {
|
|
218
|
+
throw new Error(ResultError.NoResultReturned);
|
|
219
|
+
}
|
|
166
220
|
return intentResult;
|
|
167
221
|
};
|
|
168
222
|
// Finally fire the intent.
|
|
@@ -16,4 +16,3 @@ export declare const BROKER_ERRORS: {
|
|
|
16
16
|
fdc3GetInfo: string;
|
|
17
17
|
};
|
|
18
18
|
export declare const wrapIntentHandler: (handler: OpenFin.IntentHandler, handlerId: string) => (intent: OpenFin.Intent) => Promise<void>;
|
|
19
|
-
export declare const generateDefaultLoggingOptions: () => OpenFin.InteropLoggingOptions;
|
package/src/api/interop/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.wrapIntentHandler = exports.BROKER_ERRORS = exports.generateOverrideWarning = exports.generateOverrideError = exports.wrapContextHandler = exports.wrapInTryCatch = exports.generateId = void 0;
|
|
4
4
|
const generateId = () => `${Math.random()}${Date.now()}`;
|
|
5
5
|
exports.generateId = generateId;
|
|
6
6
|
const wrapInTryCatch = (f, prefix) => (...args) => {
|
|
@@ -59,11 +59,3 @@ const wrapIntentHandler = (handler, handlerId) => {
|
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
61
|
exports.wrapIntentHandler = wrapIntentHandler;
|
|
62
|
-
const generateDefaultLoggingOptions = () => {
|
|
63
|
-
const loggingActions = ['beforeAction', 'afterAction'];
|
|
64
|
-
const options = loggingActions.reduce((accumulator, loggingOption) => {
|
|
65
|
-
return { ...accumulator, [loggingOption]: { enabled: true } };
|
|
66
|
-
}, {});
|
|
67
|
-
return options;
|
|
68
|
-
};
|
|
69
|
-
exports.generateDefaultLoggingOptions = generateDefaultLoggingOptions;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type * as OpenFin from '../../OpenFin';
|
|
2
2
|
import { Base } from '../base';
|
|
3
|
-
import { Channel } from '../interappbus/channel/index';
|
|
4
3
|
import { Transport } from '../../transport/transport';
|
|
5
4
|
import { LayoutModule } from './layout/index';
|
|
5
|
+
type Channel = OpenFin.Fin['InterApplicationBus']['Channel'];
|
|
6
6
|
/**
|
|
7
7
|
* @PORTED
|
|
8
8
|
* InitPlatformOptions interface
|
|
@@ -113,3 +113,4 @@ export default class PlatformModule extends Base {
|
|
|
113
113
|
*/
|
|
114
114
|
startFromManifest(manifestUrl: string, opts?: OpenFin.RvmLaunchOptions): Promise<OpenFin.Platform>;
|
|
115
115
|
}
|
|
116
|
+
export {};
|
|
@@ -77,7 +77,7 @@ class PlatformModule extends base_1.Base {
|
|
|
77
77
|
const overrideCallback = options === null || options === void 0 ? void 0 : options.overrideCallback;
|
|
78
78
|
const interopBroker = await this.fin.Interop.init(this.fin.me.uuid, options === null || options === void 0 ? void 0 : options.interopOverride);
|
|
79
79
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
80
|
-
// @ts-
|
|
80
|
+
// @ts-expect-error debugging purposes
|
|
81
81
|
window.interopBroker = interopBroker;
|
|
82
82
|
return this._initializer(overrideCallback, interopBroker);
|
|
83
83
|
}
|
|
@@ -147,14 +147,12 @@ class PlatformModule extends base_1.Base {
|
|
|
147
147
|
return new Promise(async (resolve, reject) => {
|
|
148
148
|
try {
|
|
149
149
|
const { uuid } = platformOptions;
|
|
150
|
-
//
|
|
151
|
-
// @ts-ignore using private variable.
|
|
150
|
+
// @ts-expect-error using private variable.
|
|
152
151
|
const app = await this.fin.Application._create({ ...platformOptions, isPlatformController: true });
|
|
153
152
|
// TODO: fix typing (internal)
|
|
154
153
|
// @ts-expect-error
|
|
155
154
|
app.once('platform-api-ready', () => resolve(this.wrapSync({ uuid })));
|
|
156
|
-
//
|
|
157
|
-
// @ts-ignore using private variable.
|
|
155
|
+
// @ts-expect-error using private variable.
|
|
158
156
|
app._run({ uuid });
|
|
159
157
|
}
|
|
160
158
|
catch (e) {
|
|
@@ -178,14 +176,12 @@ class PlatformModule extends base_1.Base {
|
|
|
178
176
|
// eslint-disable-next-line no-async-promise-executor
|
|
179
177
|
return new Promise(async (resolve, reject) => {
|
|
180
178
|
try {
|
|
181
|
-
//
|
|
182
|
-
// @ts-ignore using private variable.
|
|
179
|
+
// @ts-expect-error using private variable.
|
|
183
180
|
const app = await this.fin.Application._createFromManifest(manifestUrl);
|
|
184
181
|
// TODO: fix typing (internal)
|
|
185
182
|
// @ts-expect-error
|
|
186
183
|
app.once('platform-api-ready', () => resolve(this.wrapSync({ uuid: app.identity.uuid })));
|
|
187
|
-
//
|
|
188
|
-
// @ts-ignore using private method without warning.
|
|
184
|
+
// @ts-expect-error using private method without warning.
|
|
189
185
|
app._run(opts);
|
|
190
186
|
}
|
|
191
187
|
catch (e) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type * as OpenFin from '../../OpenFin';
|
|
2
|
-
import { View } from '../view';
|
|
3
2
|
import { EmitterBase } from '../base';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
type View = OpenFin.View;
|
|
4
|
+
type Channel = OpenFin.Fin['InterApplicationBus']['Channel'];
|
|
5
|
+
type ChannelClient = OpenFin.ChannelClient;
|
|
6
|
+
type LayoutModule = OpenFin.Fin['Platform']['Layout'];
|
|
7
7
|
/** Manages the life cycle of windows and views in the application.
|
|
8
8
|
*
|
|
9
9
|
* Enables taking snapshots of itself and applyi
|
|
@@ -27,7 +27,7 @@ export declare class Platform extends EmitterBase<OpenFin.PlatformEvent> {
|
|
|
27
27
|
* @return { Promise<View> }
|
|
28
28
|
* @tutorial Platform.createView
|
|
29
29
|
*/
|
|
30
|
-
createView(viewOptions: OpenFin.PlatformViewCreationOptions, target?: OpenFin.
|
|
30
|
+
createView(viewOptions: OpenFin.PlatformViewCreationOptions, target?: OpenFin.CreateViewTarget, targetView?: OpenFin.Identity): Promise<View>;
|
|
31
31
|
/**
|
|
32
32
|
* Creates a new Window.
|
|
33
33
|
* @param { Window~options } options Window creation options
|
|
@@ -147,3 +147,4 @@ export declare class Platform extends EmitterBase<OpenFin.PlatformEvent> {
|
|
|
147
147
|
skipBeforeUnload: boolean;
|
|
148
148
|
}): Promise<void>;
|
|
149
149
|
}
|
|
150
|
+
export {};
|
|
@@ -7,6 +7,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
7
7
|
var _Platform_connectToProvider;
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.Platform = void 0;
|
|
10
|
+
/* eslint-disable import/prefer-default-export, no-undef */
|
|
10
11
|
const base_1 = require("../base");
|
|
11
12
|
const validate_1 = require("../../util/validate");
|
|
12
13
|
// Reuse clients to avoid overwriting already-registered client in provider
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
11
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
12
|
};
|
|
13
|
-
var _LayoutModule_layoutManager;
|
|
13
|
+
var _LayoutModule_layoutManager, _LayoutModule_layoutInitializationAttempted;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.LayoutModule = void 0;
|
|
16
16
|
/* eslint-disable no-undef, import/prefer-default-export */
|
|
@@ -19,6 +19,10 @@ const Instance_1 = require("./Instance");
|
|
|
19
19
|
const base_1 = require("../../base");
|
|
20
20
|
const splitter_controller_1 = require("./controllers/splitter-controller");
|
|
21
21
|
const view_overlay_1 = require("./utils/view-overlay");
|
|
22
|
+
const api_exposer_1 = require("../../api-exposer");
|
|
23
|
+
const layout_entities_controller_1 = require("./controllers/layout-entities-controller");
|
|
24
|
+
const layout_constants_1 = require("./layout.constants");
|
|
25
|
+
const layout_content_cache_1 = require("./controllers/layout-content-cache");
|
|
22
26
|
/**
|
|
23
27
|
* @PORTED
|
|
24
28
|
* InitLayoutOptions interface
|
|
@@ -87,6 +91,7 @@ class LayoutModule extends base_1.Base {
|
|
|
87
91
|
constructor() {
|
|
88
92
|
super(...arguments);
|
|
89
93
|
_LayoutModule_layoutManager.set(this, void 0);
|
|
94
|
+
_LayoutModule_layoutInitializationAttempted.set(this, false);
|
|
90
95
|
/**
|
|
91
96
|
* Initialize the window's Layout. Must be called from a custom window that has a 'layout' option set upon creation of that window.
|
|
92
97
|
* If a containerId is not provided, this method attempts to find an element with the id `layout-container`.
|
|
@@ -105,17 +110,18 @@ class LayoutModule extends base_1.Base {
|
|
|
105
110
|
if (!this.fin.me.isWindow) {
|
|
106
111
|
throw new Error('Layout.init can only be called from a Window context.');
|
|
107
112
|
}
|
|
108
|
-
else if (__classPrivateFieldGet(this,
|
|
113
|
+
else if (__classPrivateFieldGet(this, _LayoutModule_layoutInitializationAttempted, "f")) {
|
|
109
114
|
throw new Error('Layout for this window already initialized, please use Layout.replace call to replace the layout.');
|
|
110
115
|
}
|
|
116
|
+
__classPrivateFieldSet(this, _LayoutModule_layoutInitializationAttempted, true, "f");
|
|
111
117
|
// We need to go through environment to make sure it is only imported/bundled in OpenFin.
|
|
112
118
|
const ManagerConstructor = await this.wire.environment.getManagerConstructor();
|
|
113
119
|
const viewOverlay = new view_overlay_1.ViewOverlay(this.wire);
|
|
114
120
|
const splitterController = new splitter_controller_1.SplitterController(viewOverlay);
|
|
115
121
|
const tabDragController = new tab_drag_controller_1.TabDragController(viewOverlay);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
// @ts-
|
|
122
|
+
const contentItemCache = new layout_content_cache_1.LayoutContentCache();
|
|
123
|
+
__classPrivateFieldSet(this, _LayoutModule_layoutManager, new ManagerConstructor(splitterController, tabDragController, contentItemCache), "f");
|
|
124
|
+
// @ts-expect-error - layout warning here for backwards compatibility, can remove layout check in .52
|
|
119
125
|
let { layout, containerId } = options;
|
|
120
126
|
if (layout) {
|
|
121
127
|
console.warn(`We recommend using a layout in window options.
|
|
@@ -129,6 +135,10 @@ class LayoutModule extends base_1.Base {
|
|
|
129
135
|
// pull createChannelConnection out of LayoutManager and setup channel connections here using layoutmanager instance methods?
|
|
130
136
|
await __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f").initManager();
|
|
131
137
|
await __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f").createLayout(layout, container);
|
|
138
|
+
const { client, ofWindow } = ManagerConstructor.getClientAndWindow(__classPrivateFieldGet(this, _LayoutModule_layoutManager, "f"));
|
|
139
|
+
// expose LayoutEntitiesController instance for API consumption
|
|
140
|
+
const channelStrategy = new api_exposer_1.ChannelsExposer(client);
|
|
141
|
+
await new api_exposer_1.ApiExposer(channelStrategy).exposeInstance(new layout_entities_controller_1.LayoutEntitiesController(__classPrivateFieldGet(this, _LayoutModule_layoutManager, "f"), contentItemCache), { id: layout_constants_1.LAYOUT_CONTROLLER_ID });
|
|
132
142
|
// Adding this to the returned instance undocumented/typed for Browser.
|
|
133
143
|
return Object.assign(this.getCurrentSync(), { layoutManager: __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f") });
|
|
134
144
|
};
|
|
@@ -195,4 +205,4 @@ class LayoutModule extends base_1.Base {
|
|
|
195
205
|
}
|
|
196
206
|
}
|
|
197
207
|
exports.LayoutModule = LayoutModule;
|
|
198
|
-
_LayoutModule_layoutManager = new WeakMap();
|
|
208
|
+
_LayoutModule_layoutManager = new WeakMap(), _LayoutModule_layoutInitializationAttempted = new WeakMap();
|
|
@@ -8,6 +8,7 @@ type PresetLayoutOptions = OpenFin.PresetLayoutOptions;
|
|
|
8
8
|
* @lends Platform#Layout
|
|
9
9
|
*/
|
|
10
10
|
export declare class Layout extends Base {
|
|
11
|
+
#private;
|
|
11
12
|
init: (options?: InitLayoutOptions) => Promise<Layout>;
|
|
12
13
|
identity: Identity;
|
|
13
14
|
private platform;
|
|
@@ -19,6 +20,11 @@ export declare class Layout extends Base {
|
|
|
19
20
|
* @tutorial Layout.getConfig
|
|
20
21
|
*/
|
|
21
22
|
getConfig(): Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves the top level content item of the layout.
|
|
25
|
+
* @return {Promise<TabStack | ColumnOrRow>}
|
|
26
|
+
*/
|
|
27
|
+
getRootItem(): Promise<OpenFin.ColumnOrRow | OpenFin.TabStack>;
|
|
22
28
|
/**
|
|
23
29
|
* Replaces a Platform window's layout with a new layout. Any views that were in the old layout but not the new layout
|
|
24
30
|
* will be destroyed.
|
|
@@ -1,9 +1,18 @@
|
|
|
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 _Layout_layoutClient;
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.Layout = void 0;
|
|
10
|
+
const lazy_1 = require("../../../util/lazy");
|
|
4
11
|
const validate_1 = require("../../../util/validate");
|
|
5
|
-
const common_utils_1 = require("../common-utils");
|
|
6
12
|
const base_1 = require("../../base");
|
|
13
|
+
const common_utils_1 = require("../common-utils");
|
|
14
|
+
const layout_entities_1 = require("./entities/layout-entities");
|
|
15
|
+
const layout_constants_1 = require("./layout.constants");
|
|
7
16
|
/**
|
|
8
17
|
* @lends Platform#Layout
|
|
9
18
|
*/
|
|
@@ -11,6 +20,12 @@ class Layout extends base_1.Base {
|
|
|
11
20
|
// eslint-disable-next-line no-shadow
|
|
12
21
|
constructor(identity, wire) {
|
|
13
22
|
super(wire);
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
* Lazily constructed {@link LayoutEntitiesClient} bound to this platform's client and identity
|
|
26
|
+
* The client is for {@link LayoutEntitiesController}
|
|
27
|
+
*/
|
|
28
|
+
_Layout_layoutClient.set(this, new lazy_1.Lazy(async () => layout_entities_1.LayoutNode.newLayoutEntitiesClient(await this.platform.getClient(), layout_constants_1.LAYOUT_CONTROLLER_ID, this.identity)));
|
|
14
29
|
/**
|
|
15
30
|
* Replaces a Platform window's layout with a new layout. Any views that were in the old layout but not the new layout
|
|
16
31
|
* will be destroyed.
|
|
@@ -94,5 +109,15 @@ class Layout extends base_1.Base {
|
|
|
94
109
|
target: this.identity
|
|
95
110
|
});
|
|
96
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Retrieves the top level content item of the layout.
|
|
114
|
+
* @return {Promise<TabStack | ColumnOrRow>}
|
|
115
|
+
*/
|
|
116
|
+
async getRootItem() {
|
|
117
|
+
const client = await __classPrivateFieldGet(this, _Layout_layoutClient, "f").getValue();
|
|
118
|
+
const root = await client.getRoot();
|
|
119
|
+
return layout_entities_1.LayoutNode.getEntity(root, client);
|
|
120
|
+
}
|
|
97
121
|
}
|
|
98
122
|
exports.Layout = Layout;
|
|
123
|
+
_Layout_layoutClient = new WeakMap();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class LayoutContentCache {
|
|
2
|
+
private contentItemCache;
|
|
3
|
+
private contentItemCacheId;
|
|
4
|
+
private createCacheKey;
|
|
5
|
+
hasKey: (id: string) => boolean;
|
|
6
|
+
getItemOrUndefined: (id: string) => GoldenLayout.ContentItem | undefined;
|
|
7
|
+
getContentItemOrThrow: (id: string, expectedType?: string[]) => GoldenLayout.ContentItem;
|
|
8
|
+
getOrCreateEntityId: (contentItem: GoldenLayout.ContentItem) => string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LayoutContentCache = void 0;
|
|
4
|
+
const reversible_map_1 = require("../../../../util/reversible-map");
|
|
5
|
+
class LayoutContentCache {
|
|
6
|
+
constructor() {
|
|
7
|
+
// ContentItems currently do not have a unique id, this helps us to lookup items by value
|
|
8
|
+
this.contentItemCache = new reversible_map_1.ReversibleMap();
|
|
9
|
+
this.contentItemCacheId = 0;
|
|
10
|
+
this.createCacheKey = () => {
|
|
11
|
+
const key = `entity-${this.contentItemCacheId.toString()}`;
|
|
12
|
+
this.contentItemCacheId += 1;
|
|
13
|
+
return key;
|
|
14
|
+
};
|
|
15
|
+
this.hasKey = (id) => {
|
|
16
|
+
return this.contentItemCache.hasKey(id);
|
|
17
|
+
};
|
|
18
|
+
this.getItemOrUndefined = (id) => {
|
|
19
|
+
try {
|
|
20
|
+
return this.getContentItemOrThrow(id);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
this.getContentItemOrThrow = (id, expectedType) => {
|
|
27
|
+
if (!this.contentItemCache.hasKey(id)) {
|
|
28
|
+
throw new Error('Layout component has been destroyed or detached from the current layout.');
|
|
29
|
+
}
|
|
30
|
+
const contentItem = this.contentItemCache.getValue(id);
|
|
31
|
+
if (expectedType && !expectedType.includes(contentItem.type)) {
|
|
32
|
+
throw new Error(`Layout item is not the expected type. Expected ${expectedType.join(', ')}, got ${contentItem.type}.`);
|
|
33
|
+
}
|
|
34
|
+
return contentItem;
|
|
35
|
+
};
|
|
36
|
+
this.getOrCreateEntityId = (contentItem) => {
|
|
37
|
+
if (this.contentItemCache.hasValue(contentItem)) {
|
|
38
|
+
return this.contentItemCache.getKey(contentItem);
|
|
39
|
+
}
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
41
|
+
const onItemDestroyed = ({ origin, ...rest }) => {
|
|
42
|
+
if (origin === contentItem) {
|
|
43
|
+
this.contentItemCache.deleteValue(contentItem);
|
|
44
|
+
contentItem.unbind('itemDestroyed', onItemDestroyed);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
contentItem.on('itemDestroyed', onItemDestroyed);
|
|
48
|
+
const key = this.createCacheKey();
|
|
49
|
+
this.contentItemCache.setUnique(key, contentItem);
|
|
50
|
+
return key;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.LayoutContentCache = LayoutContentCache;
|