@openfin/core 29.72.17 → 29.73.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OpenFin.d.ts +45 -27
- package/package.json +1 -1
- package/src/api/application/Factory.js +3 -3
- package/src/api/application/index.js +7 -3
- package/src/api/base.js +18 -20
- package/src/api/external-application/index.js +7 -3
- package/src/api/fin.js +2 -2
- package/src/api/frame/Factory.js +2 -2
- package/src/api/frame/index.js +7 -3
- package/src/api/interappbus/channel/client.js +24 -26
- package/src/api/interappbus/channel/connection-manager.js +24 -26
- package/src/api/interappbus/channel/index.js +16 -18
- package/src/api/interappbus/channel/protocols/classic/strategy.js +21 -22
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +24 -26
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +29 -31
- package/src/api/interappbus/channel/provider.js +134 -139
- package/src/api/interappbus/index.js +1 -1
- package/src/api/interop/InteropBroker.js +9 -9
- package/src/api/interop/InteropClient.js +38 -40
- package/src/api/interop/SessionContextGroupClient.js +22 -24
- package/src/api/interop/fdc3/PrivateChannelClient.d.ts +17 -0
- package/src/api/interop/fdc3/PrivateChannelClient.js +82 -0
- package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +40 -0
- package/src/api/interop/fdc3/PrivateChannelProvider.js +224 -0
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +0 -1
- package/src/api/interop/fdc3/fdc3-1.2.js +1 -27
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +22 -3
- package/src/api/interop/fdc3/fdc3-2.0.js +76 -11
- package/src/api/interop/fdc3/utils.d.ts +15 -0
- package/src/api/interop/fdc3/utils.js +162 -1
- package/src/api/interop/index.js +7 -3
- package/src/api/interop/utils.js +21 -15
- package/src/api/platform/Factory.js +5 -5
- package/src/api/platform/Instance.js +11 -12
- package/src/api/platform/index.js +7 -3
- package/src/api/platform/layout/Factory.js +18 -20
- package/src/api/platform/layout/Instance.d.ts +1 -1
- package/src/api/platform/layout/Instance.js +2 -2
- package/src/api/platform/layout/controllers/splitter-controller.js +1 -1
- package/src/api/platform/layout/controllers/tab-drag-controller.d.ts +17 -8
- package/src/api/platform/layout/controllers/tab-drag-controller.js +44 -22
- package/src/api/platform/layout/index.js +7 -3
- package/src/api/platform/layout/utils/bounds-observer.js +5 -3
- package/src/api/snapshot-source/Factory.js +1 -1
- package/src/api/snapshot-source/Instance.js +33 -35
- package/src/api/snapshot-source/index.js +7 -3
- package/src/api/snapshot-source/utils.js +2 -1
- package/src/api/view/Factory.js +2 -2
- package/src/api/view/Instance.d.ts +31 -1
- package/src/api/view/Instance.js +31 -1
- package/src/api/view/index.js +7 -3
- package/src/api/window/Factory.js +2 -2
- package/src/api/window/Instance.d.ts +3 -0
- package/src/api/window/Instance.js +3 -0
- package/src/api/window/index.js +7 -3
- package/src/environment/node-env.js +2 -2
- package/src/environment/openfin-env.js +15 -17
- package/src/fdc3.js +1 -1
- package/src/mock.js +1 -2
- package/src/transport/transport.js +26 -28
- package/src/transport/wire.d.ts +9 -7
- package/src/util/http.d.ts +1 -1
- package/src/util/http.js +16 -11
- package/src/util/normalize-config.js +5 -5
|
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const base_1 = require("../../base");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const InteropClient_1 = require("../InteropClient");
|
|
6
|
+
const utils_2 = require("./utils");
|
|
6
7
|
const fdc3_1_2_1 = require("./fdc3-1.2");
|
|
8
|
+
const PrivateChannelClient_1 = require("./PrivateChannelClient");
|
|
9
|
+
const PrivateChannelProvider_1 = require("./PrivateChannelProvider");
|
|
7
10
|
/**
|
|
8
11
|
* @typedef { object } AppIdentifier
|
|
9
12
|
* @summary Identifies an application, or instance of an application, and is used to target FDC3 API calls at specific applications.
|
|
@@ -106,6 +109,20 @@ const fdc3_1_2_1 = require("./fdc3-1.2");
|
|
|
106
109
|
* @property { string } [version] The version number of the Intents schema being used.
|
|
107
110
|
* @property { Function } getResult {@link getResult Function} that returns a promise that will resolve to either `Context` data returned by the application that resolves the raised intent or a `Channel` established and returned by the app resolving the intent.
|
|
108
111
|
*/
|
|
112
|
+
/**
|
|
113
|
+
* @typedef { object } PrivateChannel
|
|
114
|
+
* @summary Object representing a private context channel, which is intended to support secure communication between applications, and extends the Channel interface with event handlers which provide information on the connection state of both parties, ensuring that desktop agents do not need to queue or retain messages that are broadcast before a context listener is added and that applications are able to stop broadcasting messages when the other party has disconnected.
|
|
115
|
+
* @property { string } id Private Channel Id
|
|
116
|
+
* @property { string } type Channel Type
|
|
117
|
+
* @property { DisplayMetadata } [displayMetadata]
|
|
118
|
+
* @property { function } broadcast
|
|
119
|
+
* @property { function } getCurrentContext
|
|
120
|
+
* @property { function } addContextListener
|
|
121
|
+
* @property { function } onAddContextListener
|
|
122
|
+
* @property { function } onUnsubscribe
|
|
123
|
+
* @property { function } onDisconnect
|
|
124
|
+
* @property { function } disconnect
|
|
125
|
+
*/
|
|
109
126
|
/**
|
|
110
127
|
* @class
|
|
111
128
|
* @alias fdc3v2
|
|
@@ -281,20 +298,39 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
281
298
|
* @param { Context } context Context associated with the Intent
|
|
282
299
|
* @param { AppIdentifier | TargetApp } [app]
|
|
283
300
|
* @returns { Promise<IntentResolution(2)> }
|
|
284
|
-
* @tutorial
|
|
301
|
+
* @tutorial fdc3v2.raiseIntent
|
|
285
302
|
*/
|
|
286
303
|
async raiseIntent(intent, context, app) {
|
|
287
|
-
|
|
304
|
+
this.wire.sendAction('fdc3-raise-intent').catch((e) => {
|
|
305
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
306
|
+
});
|
|
307
|
+
try {
|
|
308
|
+
return (0, utils_2.getIntentResolution)(this.fin.me.interop, context, app, intent);
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error;
|
|
312
|
+
throw new Error(errorToThrow);
|
|
313
|
+
}
|
|
288
314
|
}
|
|
289
315
|
/**
|
|
290
316
|
* Finds and raises an intent against apps registered with the desktop agent based purely on the type of the context data.
|
|
291
317
|
* @param { Context } context Context associated with the Intent
|
|
292
318
|
* @param { AppIdentifier | TargetApp } [app]
|
|
293
319
|
* @returns { Promise<IntentResolution(2)> }
|
|
294
|
-
* @tutorial
|
|
320
|
+
* @tutorial fdc3v2.raiseIntentForContext
|
|
295
321
|
*/
|
|
296
322
|
async raiseIntentForContext(context, app) {
|
|
297
|
-
|
|
323
|
+
// TODO: We have to do the same thing we do for raiseIntent here as well.
|
|
324
|
+
this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
|
|
325
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
326
|
+
});
|
|
327
|
+
try {
|
|
328
|
+
return (0, utils_2.getIntentResolution)(this.fin.me.interop, context, app);
|
|
329
|
+
}
|
|
330
|
+
catch (error) {
|
|
331
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error;
|
|
332
|
+
throw new Error(errorToThrow);
|
|
333
|
+
}
|
|
298
334
|
}
|
|
299
335
|
/**
|
|
300
336
|
* Adds a listener for incoming intents.
|
|
@@ -307,13 +343,33 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
307
343
|
this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
|
|
308
344
|
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
309
345
|
});
|
|
346
|
+
if (typeof intent !== 'string') {
|
|
347
|
+
throw new Error('First argument must be an Intent name');
|
|
348
|
+
}
|
|
310
349
|
// The FDC3 Intenter handler only expects the context and contextMetadata to be passed to the handler,
|
|
311
350
|
// so we wrap it here and only pass those paramaters.
|
|
312
|
-
const contextHandler = (raisedIntent) => {
|
|
313
|
-
const { context } = raisedIntent;
|
|
314
|
-
const { contextMetadata, ...rest } = context;
|
|
315
|
-
|
|
316
|
-
|
|
351
|
+
const contextHandler = async (raisedIntent) => {
|
|
352
|
+
const { context, metadata: intentMetadata } = raisedIntent;
|
|
353
|
+
const { contextMetadata, metadata, ...rest } = context;
|
|
354
|
+
let intentResult;
|
|
355
|
+
try {
|
|
356
|
+
const newContext = metadata ? { metadata, ...rest } : { ...rest };
|
|
357
|
+
intentResult = await handler(newContext, contextMetadata);
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
intentResult = error;
|
|
361
|
+
}
|
|
362
|
+
const intentResolutionResultId = (intentMetadata === null || intentMetadata === void 0 ? void 0 : intentMetadata.intentResolutionResultId) || (metadata === null || metadata === void 0 ? void 0 : metadata.intentResolutionResultId);
|
|
363
|
+
if (intentResolutionResultId) {
|
|
364
|
+
// Send whatever the result is.
|
|
365
|
+
fin.InterApplicationBus.publish(intentResolutionResultId, intentResult);
|
|
366
|
+
}
|
|
367
|
+
if (intentResult instanceof Error) {
|
|
368
|
+
throw new Error(intentResult.message);
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
return intentResult;
|
|
372
|
+
}
|
|
317
373
|
};
|
|
318
374
|
return this.fin.me.interop.registerIntentHandler(contextHandler, intent, { fdc3Version: '2.0' });
|
|
319
375
|
}
|
|
@@ -326,9 +382,18 @@ class Fdc3Module2 extends base_1.Base {
|
|
|
326
382
|
async getOrCreateChannel(channelId) {
|
|
327
383
|
return this.fdc3Module.getOrCreateChannel(channelId);
|
|
328
384
|
}
|
|
329
|
-
|
|
385
|
+
/**
|
|
386
|
+
* 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
|
+
* @returns { Promise<PrivateChannel> }
|
|
388
|
+
* @tutorial fdc3v2.createPrivateChannel
|
|
389
|
+
*/
|
|
330
390
|
async createPrivateChannel() {
|
|
331
|
-
|
|
391
|
+
const channelId = (0, utils_1.generateId)();
|
|
392
|
+
const channelProvider = await this.fin.InterApplicationBus.Channel.create(channelId);
|
|
393
|
+
const newPrivateChannelProvider = new PrivateChannelProvider_1.PrivateChannelProvider(channelProvider, channelId);
|
|
394
|
+
const channelClient = await this.fin.InterApplicationBus.Channel.connect(channelId);
|
|
395
|
+
const newPrivateChannelClient = new PrivateChannelClient_1.PrivateChannelClient(channelClient, channelId);
|
|
396
|
+
return (0, utils_2.buildPrivateChannelObject)(newPrivateChannelClient);
|
|
332
397
|
}
|
|
333
398
|
/**
|
|
334
399
|
* Retrieves a list of the User Channels available for the app to join.
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
import { PrivateChannelClient } from './PrivateChannelClient';
|
|
1
2
|
export declare class UnsupportedChannelApiError extends Error {
|
|
2
3
|
constructor(apiName: string);
|
|
3
4
|
}
|
|
5
|
+
export declare enum ResultError {
|
|
6
|
+
/** Returned if the `IntentHandler` exited without returning a Promise or that
|
|
7
|
+
* Promise was not resolved with a Context or Channel object.
|
|
8
|
+
*/
|
|
9
|
+
NoResultReturned = "NoResultReturned",
|
|
10
|
+
/** Returned if the `IntentHandler` function processing the raised intent
|
|
11
|
+
* throws an error or rejects the Promise it returned.
|
|
12
|
+
*/
|
|
13
|
+
IntentHandlerRejected = "IntentHandlerRejected"
|
|
14
|
+
}
|
|
15
|
+
export declare const buildPrivateChannelObject: (privateChannelClient: PrivateChannelClient) => FDC3v2.PrivateChannel;
|
|
16
|
+
export declare const buildAppChannelObject: (sessionContextGroup: OpenFin.SessionContextGroup) => FDC3.Channel;
|
|
17
|
+
export declare const connectPrivateChannel: (channelId: string) => Promise<FDC3v2.PrivateChannel>;
|
|
18
|
+
export declare const getIntentResolution: (interopModule: OpenFin.InteropClient, context: OpenFin.Context, app?: FDC3v2.AppIdentifier | FDC3.TargetApp, intent?: string) => Promise<FDC3v2.IntentResolution>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnsupportedChannelApiError = void 0;
|
|
3
|
+
exports.getIntentResolution = exports.connectPrivateChannel = exports.buildAppChannelObject = exports.buildPrivateChannelObject = exports.ResultError = exports.UnsupportedChannelApiError = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const PrivateChannelClient_1 = require("./PrivateChannelClient");
|
|
4
6
|
class UnsupportedChannelApiError extends Error {
|
|
5
7
|
constructor(apiName) {
|
|
6
8
|
super(apiName);
|
|
@@ -8,3 +10,162 @@ class UnsupportedChannelApiError extends Error {
|
|
|
8
10
|
}
|
|
9
11
|
}
|
|
10
12
|
exports.UnsupportedChannelApiError = UnsupportedChannelApiError;
|
|
13
|
+
var ResultError;
|
|
14
|
+
(function (ResultError) {
|
|
15
|
+
/** Returned if the `IntentHandler` exited without returning a Promise or that
|
|
16
|
+
* Promise was not resolved with a Context or Channel object.
|
|
17
|
+
*/
|
|
18
|
+
ResultError["NoResultReturned"] = "NoResultReturned";
|
|
19
|
+
/** Returned if the `IntentHandler` function processing the raised intent
|
|
20
|
+
* throws an error or rejects the Promise it returned.
|
|
21
|
+
*/
|
|
22
|
+
ResultError["IntentHandlerRejected"] = "IntentHandlerRejected";
|
|
23
|
+
})(ResultError = exports.ResultError || (exports.ResultError = {}));
|
|
24
|
+
const buildPrivateChannelObject = (privateChannelClient) => {
|
|
25
|
+
let clientDisconnected = false;
|
|
26
|
+
const checkIfClientDisconnected = () => {
|
|
27
|
+
if (clientDisconnected) {
|
|
28
|
+
throw new Error('Private Channel Client has been disconnected from the Private Channel');
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
id: privateChannelClient.id,
|
|
33
|
+
type: 'private',
|
|
34
|
+
broadcast: async (context) => {
|
|
35
|
+
checkIfClientDisconnected();
|
|
36
|
+
return privateChannelClient.broadcast(context);
|
|
37
|
+
},
|
|
38
|
+
getCurrentContext: async (contextType) => {
|
|
39
|
+
checkIfClientDisconnected();
|
|
40
|
+
return privateChannelClient.getCurrentContext(contextType);
|
|
41
|
+
},
|
|
42
|
+
addContextListener: async (contextType, handler) => {
|
|
43
|
+
checkIfClientDisconnected();
|
|
44
|
+
let handlerInUse = handler;
|
|
45
|
+
let contextTypeInUse = contextType;
|
|
46
|
+
if (typeof contextType === 'function') {
|
|
47
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
48
|
+
handlerInUse = contextType;
|
|
49
|
+
contextTypeInUse = null;
|
|
50
|
+
}
|
|
51
|
+
const listener = privateChannelClient.addContextListener(contextTypeInUse, handlerInUse);
|
|
52
|
+
return listener;
|
|
53
|
+
},
|
|
54
|
+
onAddContextListener: (handler) => {
|
|
55
|
+
checkIfClientDisconnected();
|
|
56
|
+
return privateChannelClient.onAddContextListener(handler);
|
|
57
|
+
},
|
|
58
|
+
disconnect: async () => {
|
|
59
|
+
checkIfClientDisconnected();
|
|
60
|
+
clientDisconnected = true;
|
|
61
|
+
return privateChannelClient.disconnect();
|
|
62
|
+
},
|
|
63
|
+
onDisconnect: (handler) => {
|
|
64
|
+
checkIfClientDisconnected();
|
|
65
|
+
return privateChannelClient.onDisconnect(handler);
|
|
66
|
+
},
|
|
67
|
+
onUnsubscribe: (handler) => {
|
|
68
|
+
checkIfClientDisconnected();
|
|
69
|
+
return privateChannelClient.onUnsubscribe(handler);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
exports.buildPrivateChannelObject = buildPrivateChannelObject;
|
|
74
|
+
const buildAppChannelObject = (sessionContextGroup) => {
|
|
75
|
+
return {
|
|
76
|
+
id: sessionContextGroup.id,
|
|
77
|
+
type: 'app',
|
|
78
|
+
broadcast: sessionContextGroup.setContext,
|
|
79
|
+
getCurrentContext: async (contextType) => {
|
|
80
|
+
const context = await sessionContextGroup.getCurrentContext(contextType);
|
|
81
|
+
return context === undefined ? null : context;
|
|
82
|
+
},
|
|
83
|
+
addContextListener: (contextType, handler) => {
|
|
84
|
+
let listener;
|
|
85
|
+
if (typeof contextType === 'function') {
|
|
86
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
87
|
+
listener = sessionContextGroup.addContextHandler(contextType);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
listener = sessionContextGroup.addContextHandler(handler, contextType === null ? undefined : contextType);
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
...listener,
|
|
94
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
exports.buildAppChannelObject = buildAppChannelObject;
|
|
100
|
+
const connectPrivateChannel = async (channelId) => {
|
|
101
|
+
try {
|
|
102
|
+
const channelClient = await fin.InterApplicationBus.Channel.connect(channelId);
|
|
103
|
+
const privateChannelClient = new PrivateChannelClient_1.PrivateChannelClient(channelClient, channelId);
|
|
104
|
+
return (0, exports.buildPrivateChannelObject)(privateChannelClient);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
throw new Error(`Private Channel with id: ${channelId} doesn't exist`);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
exports.connectPrivateChannel = connectPrivateChannel;
|
|
111
|
+
const getIntentResolution = async (interopModule, context, app, intent) => {
|
|
112
|
+
// Generate an ID to make a session context group with. We will pass that ID to the Broker.
|
|
113
|
+
// The broker will then setContext on that session context group later with our Intent Result,
|
|
114
|
+
const guid = (0, utils_1.generateId)();
|
|
115
|
+
// Promise we'll use in getResult
|
|
116
|
+
const getResultPromise = new Promise((resolve) => {
|
|
117
|
+
fin.InterApplicationBus.subscribe({ uuid: '*' }, guid, (intentResult) => {
|
|
118
|
+
resolve(intentResult);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
// Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
|
|
122
|
+
const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
|
|
123
|
+
const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
|
|
124
|
+
// Set up the getResult call.
|
|
125
|
+
const getResult = async () => {
|
|
126
|
+
let intentResult = await getResultPromise;
|
|
127
|
+
if (!intentResult) {
|
|
128
|
+
throw new Error(ResultError.NoResultReturned);
|
|
129
|
+
}
|
|
130
|
+
if (intentResult instanceof Error) {
|
|
131
|
+
throw new Error(ResultError.IntentHandlerRejected);
|
|
132
|
+
}
|
|
133
|
+
if (typeof intentResult === 'object') {
|
|
134
|
+
const { id, type } = intentResult;
|
|
135
|
+
if (type && id && typeof id === 'string') {
|
|
136
|
+
switch (type) {
|
|
137
|
+
case 'private': {
|
|
138
|
+
intentResult = await (0, exports.connectPrivateChannel)(id);
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
case 'app': {
|
|
142
|
+
const sessionContextGroup = await interopModule.joinSessionContextGroup(id);
|
|
143
|
+
intentResult = (0, exports.buildAppChannelObject)(sessionContextGroup);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
default: {
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return intentResult;
|
|
153
|
+
};
|
|
154
|
+
// Finally fire the intent.
|
|
155
|
+
const intentResolutionInfoFromBroker = intent
|
|
156
|
+
? await interopModule.fireIntent(intentObj)
|
|
157
|
+
: await interopModule.fireIntentForContext(intentObj);
|
|
158
|
+
if (typeof intentResolutionInfoFromBroker !== 'object') {
|
|
159
|
+
return {
|
|
160
|
+
source: {
|
|
161
|
+
appId: '',
|
|
162
|
+
instanceId: ''
|
|
163
|
+
},
|
|
164
|
+
intent: '',
|
|
165
|
+
version: '2.0',
|
|
166
|
+
getResult
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return { ...intentResolutionInfoFromBroker, getResult };
|
|
170
|
+
};
|
|
171
|
+
exports.getIntentResolution = getIntentResolution;
|
package/src/api/interop/index.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
8
12
|
}));
|
|
9
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
11
|
-
}
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
const Factory_1 = require("./Factory");
|
|
14
18
|
exports.default = Factory_1.default;
|
package/src/api/interop/utils.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.wrapIntentHandler = exports.BROKER_ERRORS = exports.generateOverrideWarning = exports.generateOverrideError = exports.wrapContextHandler = exports.wrapInTryCatch = exports.generateId = void 0;
|
|
4
|
-
|
|
5
|
-
exports.
|
|
4
|
+
const generateId = () => `${Math.random()}${Date.now()}`;
|
|
5
|
+
exports.generateId = generateId;
|
|
6
|
+
const wrapInTryCatch = (f, prefix) => (...args) => {
|
|
6
7
|
try {
|
|
7
8
|
return f(...args);
|
|
8
9
|
}
|
|
@@ -10,7 +11,8 @@ exports.wrapInTryCatch = (f, prefix) => (...args) => {
|
|
|
10
11
|
throw new Error((prefix || '') + e);
|
|
11
12
|
}
|
|
12
13
|
};
|
|
13
|
-
exports.
|
|
14
|
+
exports.wrapInTryCatch = wrapInTryCatch;
|
|
15
|
+
const wrapContextHandler = (handler, handlerId) => {
|
|
14
16
|
return async (context) => {
|
|
15
17
|
try {
|
|
16
18
|
await handler(context);
|
|
@@ -21,31 +23,34 @@ exports.wrapContextHandler = (handler, handlerId) => {
|
|
|
21
23
|
}
|
|
22
24
|
};
|
|
23
25
|
};
|
|
24
|
-
exports.
|
|
26
|
+
exports.wrapContextHandler = wrapContextHandler;
|
|
27
|
+
const generateOverrideError = (clientApi, brokerApi) => {
|
|
25
28
|
return `You have tried to to use ${clientApi} but ${brokerApi} has not been overridden in the Interop Broker. Please override this function. Refer to our documentation for more info.`;
|
|
26
29
|
};
|
|
27
|
-
exports.
|
|
30
|
+
exports.generateOverrideError = generateOverrideError;
|
|
31
|
+
const generateOverrideWarning = (fdc3ClientApi, brokerApi, identity, interopClientApi) => {
|
|
28
32
|
const { uuid, name } = identity;
|
|
29
33
|
const message = interopClientApi
|
|
30
34
|
? `Entity with identity: ${uuid}/${name} has called ${interopClientApi} or ${fdc3ClientApi} but ${brokerApi} has not been overridden.`
|
|
31
35
|
: `Entity with identity: ${uuid}/${name} has called ${fdc3ClientApi} but ${brokerApi} has not been overridden.`;
|
|
32
36
|
return message;
|
|
33
37
|
};
|
|
38
|
+
exports.generateOverrideWarning = generateOverrideWarning;
|
|
34
39
|
exports.BROKER_ERRORS = {
|
|
35
|
-
fireIntent: exports.generateOverrideError('fireIntent', 'handleFiredIntent'),
|
|
36
|
-
fireIntentForContext: exports.generateOverrideError('fireIntentForContext', 'handleFiredIntentForContext'),
|
|
37
|
-
getInfoForIntent: exports.generateOverrideError('getInfoForIntent', 'handleInfoForIntent'),
|
|
38
|
-
getInfoForIntentsByContext: exports.generateOverrideError('getInfoForIntentsByContext', 'handleInfoForIntentsByContext'),
|
|
40
|
+
fireIntent: (0, exports.generateOverrideError)('fireIntent', 'handleFiredIntent'),
|
|
41
|
+
fireIntentForContext: (0, exports.generateOverrideError)('fireIntentForContext', 'handleFiredIntentForContext'),
|
|
42
|
+
getInfoForIntent: (0, exports.generateOverrideError)('getInfoForIntent', 'handleInfoForIntent'),
|
|
43
|
+
getInfoForIntentsByContext: (0, exports.generateOverrideError)('getInfoForIntentsByContext', 'handleInfoForIntentsByContext'),
|
|
39
44
|
joinSessionContextGroupWithJoinContextGroup: 'The Context Group you have tried to join is a Session Context Group. Custom Context Groups can only be defined by the Interop Broker through code or manifest configuration. Please use joinSessionContextGroup.',
|
|
40
|
-
fdc3Open: exports.generateOverrideError('fdc3.open', 'fdc3HandleOpen'),
|
|
41
|
-
fdc3FindInstances: exports.generateOverrideError('fdc3.findInstances', 'fdc3HandleFindInstances'),
|
|
42
|
-
fdc3GetAppMetadata: exports.generateOverrideError('fdc3.getAppMetadata', 'fdc3HandleGetAppMetadata'),
|
|
43
|
-
fdc3GetInfo: exports.generateOverrideError('fdc3.getInfo', 'fdc3HandleGetInfo')
|
|
45
|
+
fdc3Open: (0, exports.generateOverrideError)('fdc3.open', 'fdc3HandleOpen'),
|
|
46
|
+
fdc3FindInstances: (0, exports.generateOverrideError)('fdc3.findInstances', 'fdc3HandleFindInstances'),
|
|
47
|
+
fdc3GetAppMetadata: (0, exports.generateOverrideError)('fdc3.getAppMetadata', 'fdc3HandleGetAppMetadata'),
|
|
48
|
+
fdc3GetInfo: (0, exports.generateOverrideError)('fdc3.getInfo', 'fdc3HandleGetInfo')
|
|
44
49
|
};
|
|
45
|
-
|
|
50
|
+
const wrapIntentHandler = (handler, handlerId) => {
|
|
46
51
|
return async (intent) => {
|
|
47
52
|
try {
|
|
48
|
-
|
|
53
|
+
return handler(intent);
|
|
49
54
|
}
|
|
50
55
|
catch (error) {
|
|
51
56
|
console.error(`Error thrown by handler ${handlerId}: ${error}`);
|
|
@@ -53,3 +58,4 @@ exports.wrapIntentHandler = (handler, handlerId) => {
|
|
|
53
58
|
}
|
|
54
59
|
};
|
|
55
60
|
};
|
|
61
|
+
exports.wrapIntentHandler = wrapIntentHandler;
|
|
@@ -71,7 +71,7 @@ class PlatformModule extends base_1.Base {
|
|
|
71
71
|
async init(options) {
|
|
72
72
|
const overrideCallback = options === null || options === void 0 ? void 0 : options.overrideCallback;
|
|
73
73
|
const interopBroker = await this.fin.Interop.init(this.fin.me.uuid, options === null || options === void 0 ? void 0 : options.interopOverride);
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
75
75
|
// @ts-ignore debugging purposes
|
|
76
76
|
window.interopBroker = interopBroker;
|
|
77
77
|
return this._initializer(overrideCallback, interopBroker);
|
|
@@ -142,11 +142,11 @@ class PlatformModule extends base_1.Base {
|
|
|
142
142
|
return new Promise(async (resolve, reject) => {
|
|
143
143
|
try {
|
|
144
144
|
const { uuid } = platformOptions;
|
|
145
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
146
146
|
// @ts-ignore using private variable.
|
|
147
147
|
const app = await this.fin.Application._create({ ...platformOptions, isPlatformController: true });
|
|
148
148
|
app.once('platform-api-ready', () => resolve(this.wrapSync({ uuid })));
|
|
149
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
150
150
|
// @ts-ignore using private variable.
|
|
151
151
|
app._run({ uuid });
|
|
152
152
|
}
|
|
@@ -171,11 +171,11 @@ class PlatformModule extends base_1.Base {
|
|
|
171
171
|
// eslint-disable-next-line no-async-promise-executor
|
|
172
172
|
return new Promise(async (resolve, reject) => {
|
|
173
173
|
try {
|
|
174
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
175
175
|
// @ts-ignore using private variable.
|
|
176
176
|
const app = await this.fin.Application._createFromManifest(manifestUrl);
|
|
177
177
|
app.once('platform-api-ready', () => resolve(this.wrapSync({ uuid: app.identity.uuid })));
|
|
178
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
179
179
|
// @ts-ignore using private method without warning.
|
|
180
180
|
app._run(opts);
|
|
181
181
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver,
|
|
3
|
-
if (!
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return privateMap.get(receiver);
|
|
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);
|
|
7
6
|
};
|
|
8
|
-
var
|
|
7
|
+
var _Platform_connectToProvider;
|
|
9
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
9
|
exports.Platform = void 0;
|
|
11
10
|
const base_1 = require("../base");
|
|
@@ -30,14 +29,14 @@ class Platform extends base_1.EmitterBase {
|
|
|
30
29
|
const target = identity || this.identity;
|
|
31
30
|
const { uuid } = target;
|
|
32
31
|
if (!clientMap.has(uuid)) {
|
|
33
|
-
const clientPromise = __classPrivateFieldGet(this,
|
|
32
|
+
const clientPromise = __classPrivateFieldGet(this, _Platform_connectToProvider, "f").call(this, uuid);
|
|
34
33
|
clientMap.set(uuid, clientPromise);
|
|
35
34
|
}
|
|
36
35
|
// we set it above
|
|
37
36
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
38
37
|
return clientMap.get(uuid);
|
|
39
38
|
};
|
|
40
|
-
|
|
39
|
+
_Platform_connectToProvider.set(this, async (uuid) => {
|
|
41
40
|
try {
|
|
42
41
|
const channelName = `custom-frame-${uuid}`;
|
|
43
42
|
const client = await this._channel.connect(channelName, { wait: false });
|
|
@@ -53,7 +52,7 @@ class Platform extends base_1.EmitterBase {
|
|
|
53
52
|
});
|
|
54
53
|
// Deprecated (renamed)
|
|
55
54
|
this.launchLegacyManifest = this.launchContentManifest;
|
|
56
|
-
const errorMsg = validate_1.validateIdentity(identity);
|
|
55
|
+
const errorMsg = (0, validate_1.validateIdentity)(identity);
|
|
57
56
|
if (errorMsg) {
|
|
58
57
|
throw new Error(errorMsg);
|
|
59
58
|
}
|
|
@@ -80,7 +79,7 @@ class Platform extends base_1.EmitterBase {
|
|
|
80
79
|
opts: viewOptions,
|
|
81
80
|
targetView
|
|
82
81
|
});
|
|
83
|
-
if (!response || validate_1.validateIdentity(response.identity)) {
|
|
82
|
+
if (!response || (0, validate_1.validateIdentity)(response.identity)) {
|
|
84
83
|
throw new Error(`When overwriting the createView call, please return an object that has a valid 'identity' property: ${JSON.stringify(response)}`);
|
|
85
84
|
}
|
|
86
85
|
return this.fin.View.wrapSync(response.identity);
|
|
@@ -100,7 +99,7 @@ class Platform extends base_1.EmitterBase {
|
|
|
100
99
|
options.reason = 'api-call';
|
|
101
100
|
}
|
|
102
101
|
const response = await client.dispatch('create-view-container', options);
|
|
103
|
-
if (!response || validate_1.validateIdentity(response.identity)) {
|
|
102
|
+
if (!response || (0, validate_1.validateIdentity)(response.identity)) {
|
|
104
103
|
throw new Error(`When overwriting the createWindow call, please return an object that has a valid 'identity' property: ${JSON.stringify(response)}`);
|
|
105
104
|
}
|
|
106
105
|
const { identity } = response;
|
|
@@ -311,4 +310,4 @@ class Platform extends base_1.EmitterBase {
|
|
|
311
310
|
}
|
|
312
311
|
}
|
|
313
312
|
exports.Platform = Platform;
|
|
314
|
-
|
|
313
|
+
_Platform_connectToProvider = new WeakMap();
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
8
12
|
}));
|
|
9
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
11
|
-
}
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
const Factory_1 = require("./Factory");
|
|
14
18
|
exports.default = Factory_1.default;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver,
|
|
3
|
-
if (!
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return privateMap.get(receiver);
|
|
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);
|
|
7
6
|
};
|
|
8
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver,
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return value;
|
|
7
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
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
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
14
12
|
};
|
|
15
|
-
var
|
|
13
|
+
var _LayoutModule_layoutManager;
|
|
16
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
15
|
exports.LayoutModule = void 0;
|
|
18
16
|
/* eslint-disable no-undef, import/prefer-default-export */
|
|
@@ -84,7 +82,7 @@ const view_overlay_1 = require("./utils/view-overlay");
|
|
|
84
82
|
class LayoutModule extends base_1.Base {
|
|
85
83
|
constructor() {
|
|
86
84
|
super(...arguments);
|
|
87
|
-
|
|
85
|
+
_LayoutModule_layoutManager.set(this, void 0);
|
|
88
86
|
/**
|
|
89
87
|
* Initialize the window's Layout. Must be called from a custom window that has a 'layout' option set upon creation of that window.
|
|
90
88
|
* If a containerId is not provided, this method attempts to find an element with the id `layout-container`.
|
|
@@ -103,7 +101,7 @@ class LayoutModule extends base_1.Base {
|
|
|
103
101
|
if (!this.fin.me.isWindow) {
|
|
104
102
|
throw new Error('Layout.init can only be called from a Window context.');
|
|
105
103
|
}
|
|
106
|
-
else if (__classPrivateFieldGet(this,
|
|
104
|
+
else if (__classPrivateFieldGet(this, _LayoutModule_layoutManager, "f")) {
|
|
107
105
|
throw new Error('Layout for this window already initialized, please use Layout.replace call to replace the layout.');
|
|
108
106
|
}
|
|
109
107
|
// We need to go through environment to make sure it is only imported/bundled in OpenFin.
|
|
@@ -111,8 +109,8 @@ class LayoutModule extends base_1.Base {
|
|
|
111
109
|
const viewOverlay = new view_overlay_1.ViewOverlay(this.wire);
|
|
112
110
|
const splitterController = new splitter_controller_1.SplitterController(viewOverlay);
|
|
113
111
|
const tabDragController = new tab_drag_controller_1.TabDragController(viewOverlay);
|
|
114
|
-
__classPrivateFieldSet(this,
|
|
115
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-
|
|
112
|
+
__classPrivateFieldSet(this, _LayoutModule_layoutManager, new ManagerConstructor(splitterController, tabDragController), "f");
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
116
114
|
// @ts-ignore - layout warning here for backwards compatibility, can remove layout check in .52
|
|
117
115
|
let { layout, containerId } = options;
|
|
118
116
|
if (layout) {
|
|
@@ -125,10 +123,10 @@ class LayoutModule extends base_1.Base {
|
|
|
125
123
|
// Should we error here if there is no container? Getting a typescript complaint on createLayout
|
|
126
124
|
// override here
|
|
127
125
|
// pull createChannelConnection out of LayoutManager and setup channel connections here using layoutmanager instance methods?
|
|
128
|
-
await __classPrivateFieldGet(this,
|
|
129
|
-
await __classPrivateFieldGet(this,
|
|
126
|
+
await __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f").initManager();
|
|
127
|
+
await __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f").createLayout(layout, container);
|
|
130
128
|
// Adding this to the returned instance undocumented/typed for Browser.
|
|
131
|
-
return Object.assign(this.getCurrentSync(), { layoutManager: __classPrivateFieldGet(this,
|
|
129
|
+
return Object.assign(this.getCurrentSync(), { layoutManager: __classPrivateFieldGet(this, _LayoutModule_layoutManager, "f") });
|
|
132
130
|
};
|
|
133
131
|
}
|
|
134
132
|
/**
|
|
@@ -193,4 +191,4 @@ class LayoutModule extends base_1.Base {
|
|
|
193
191
|
}
|
|
194
192
|
}
|
|
195
193
|
exports.LayoutModule = LayoutModule;
|
|
196
|
-
|
|
194
|
+
_LayoutModule_layoutManager = new WeakMap();
|
|
@@ -26,7 +26,7 @@ export declare class Layout extends Base {
|
|
|
26
26
|
* @return { Promise<void> }
|
|
27
27
|
* @tutorial Layout.replace
|
|
28
28
|
*/
|
|
29
|
-
replace: (layout:
|
|
29
|
+
replace: (layout: OpenFin.LayoutOptions) => Promise<void>;
|
|
30
30
|
/**
|
|
31
31
|
* Replaces the specified view with a view with the provided configuration.
|
|
32
32
|
* The old view is stripped of its listeners and either closed or attached to the provider window
|