@openfin/remote-adapter 37.80.39 → 37.81.20
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/README.md +2 -3
- package/out/remote-adapter-alpha.d.ts +337 -471
- package/out/remote-adapter-beta.d.ts +337 -471
- package/out/remote-adapter-public.d.ts +337 -471
- package/out/remote-adapter.d.ts +345 -479
- package/out/remote-adapter.js +1951 -762
- package/package.json +7 -18
package/out/remote-adapter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var require$$
|
|
4
|
-
var require$$0
|
|
3
|
+
var require$$3 = require('lodash');
|
|
4
|
+
var require$$0 = require('events');
|
|
5
5
|
var bridge = require('./bridge-ef11968f.js');
|
|
6
6
|
var crypto = require('crypto');
|
|
7
7
|
var backchannel = require('./backchannel.js');
|
|
@@ -48,13 +48,13 @@ async function promiseMapSerial(arr, func) {
|
|
|
48
48
|
}
|
|
49
49
|
promises.promiseMapSerial = promiseMapSerial;
|
|
50
50
|
|
|
51
|
-
var __classPrivateFieldSet$
|
|
51
|
+
var __classPrivateFieldSet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
52
52
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
53
53
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
54
54
|
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");
|
|
55
55
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
56
56
|
};
|
|
57
|
-
var __classPrivateFieldGet$
|
|
57
|
+
var __classPrivateFieldGet$e = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
58
58
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
59
59
|
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");
|
|
60
60
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -141,8 +141,8 @@ class EmitterBase extends Base {
|
|
|
141
141
|
this.emit = (eventType, payload, ...args) => {
|
|
142
142
|
return this.hasEmitter() ? this.getOrCreateEmitter().emit(eventType, payload, ...args) : false;
|
|
143
143
|
};
|
|
144
|
-
this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$
|
|
145
|
-
this.getOrCreateEmitter = () => this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$
|
|
144
|
+
this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$e(this, _EmitterBase_emitterAccessor, "f"));
|
|
145
|
+
this.getOrCreateEmitter = () => this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$e(this, _EmitterBase_emitterAccessor, "f"));
|
|
146
146
|
this.listeners = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(type) : [];
|
|
147
147
|
this.listenerCount = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listenerCount(type) : 0;
|
|
148
148
|
this.registerEventListener = async (eventType, options = {}, applySubscription, undoSubscription) => {
|
|
@@ -180,7 +180,7 @@ class EmitterBase extends Base {
|
|
|
180
180
|
// This will only be reached if unsubscribe from event that does not exist but do not want to error here
|
|
181
181
|
return Promise.resolve();
|
|
182
182
|
};
|
|
183
|
-
__classPrivateFieldSet$
|
|
183
|
+
__classPrivateFieldSet$c(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
|
|
184
184
|
this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
@@ -298,7 +298,7 @@ class EmitterBase extends Base {
|
|
|
298
298
|
}
|
|
299
299
|
deleteEmitterIfNothingRegistered(emitter) {
|
|
300
300
|
if (emitter.eventNames().length === 0) {
|
|
301
|
-
this.wire.eventAggregator.delete(__classPrivateFieldGet$
|
|
301
|
+
this.wire.eventAggregator.delete(__classPrivateFieldGet$e(this, _EmitterBase_emitterAccessor, "f"));
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
}
|
|
@@ -365,11 +365,11 @@ function createWarningObject(message, obj) {
|
|
|
365
365
|
}
|
|
366
366
|
inaccessibleObject.createWarningObject = createWarningObject;
|
|
367
367
|
|
|
368
|
-
var InteropClient
|
|
368
|
+
var InteropClient = {};
|
|
369
369
|
|
|
370
370
|
var SessionContextGroupClient$1 = {};
|
|
371
371
|
|
|
372
|
-
var utils$
|
|
372
|
+
var utils$3 = {};
|
|
373
373
|
|
|
374
374
|
(function (exports) {
|
|
375
375
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -432,29 +432,29 @@ var utils$1 = {};
|
|
|
432
432
|
};
|
|
433
433
|
};
|
|
434
434
|
exports.wrapIntentHandler = wrapIntentHandler;
|
|
435
|
-
} (utils$
|
|
435
|
+
} (utils$3));
|
|
436
436
|
|
|
437
|
-
var __classPrivateFieldSet$
|
|
437
|
+
var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
438
438
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
439
439
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
440
440
|
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");
|
|
441
441
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
442
442
|
};
|
|
443
|
-
var __classPrivateFieldGet$
|
|
443
|
+
var __classPrivateFieldGet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
444
444
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
445
445
|
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");
|
|
446
446
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
447
447
|
};
|
|
448
448
|
var _SessionContextGroupClient_clientPromise;
|
|
449
449
|
Object.defineProperty(SessionContextGroupClient$1, "__esModule", { value: true });
|
|
450
|
-
const base_1$
|
|
451
|
-
const utils_1$
|
|
452
|
-
class SessionContextGroupClient extends base_1$
|
|
450
|
+
const base_1$j = base;
|
|
451
|
+
const utils_1$2 = utils$3;
|
|
452
|
+
class SessionContextGroupClient extends base_1$j.Base {
|
|
453
453
|
constructor(wire, client, id) {
|
|
454
454
|
super(wire);
|
|
455
455
|
_SessionContextGroupClient_clientPromise.set(this, void 0);
|
|
456
456
|
this.id = id;
|
|
457
|
-
__classPrivateFieldSet$
|
|
457
|
+
__classPrivateFieldSet$b(this, _SessionContextGroupClient_clientPromise, client, "f");
|
|
458
458
|
}
|
|
459
459
|
/**
|
|
460
460
|
* Sets a context for the session context group.
|
|
@@ -466,7 +466,7 @@ class SessionContextGroupClient extends base_1$k.Base {
|
|
|
466
466
|
this.wire.sendAction('interop-session-context-group-set-context').catch((e) => {
|
|
467
467
|
// don't expose, analytics-only call
|
|
468
468
|
});
|
|
469
|
-
const client = await __classPrivateFieldGet$
|
|
469
|
+
const client = await __classPrivateFieldGet$d(this, _SessionContextGroupClient_clientPromise, "f");
|
|
470
470
|
return client.dispatch(`sessionContextGroup:setContext-${this.id}`, {
|
|
471
471
|
sessionContextGroupId: this.id,
|
|
472
472
|
context
|
|
@@ -476,7 +476,7 @@ class SessionContextGroupClient extends base_1$k.Base {
|
|
|
476
476
|
this.wire.sendAction('interop-session-context-group-get-context').catch((e) => {
|
|
477
477
|
// don't expose, analytics-only call
|
|
478
478
|
});
|
|
479
|
-
const client = await __classPrivateFieldGet$
|
|
479
|
+
const client = await __classPrivateFieldGet$d(this, _SessionContextGroupClient_clientPromise, "f");
|
|
480
480
|
return client.dispatch(`sessionContextGroup:getContext-${this.id}`, {
|
|
481
481
|
sessionContextGroupId: this.id,
|
|
482
482
|
type
|
|
@@ -489,20 +489,20 @@ class SessionContextGroupClient extends base_1$k.Base {
|
|
|
489
489
|
if (typeof contextHandler !== 'function') {
|
|
490
490
|
throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
|
|
491
491
|
}
|
|
492
|
-
const client = await __classPrivateFieldGet$
|
|
492
|
+
const client = await __classPrivateFieldGet$d(this, _SessionContextGroupClient_clientPromise, "f");
|
|
493
493
|
let handlerId;
|
|
494
494
|
if (contextType) {
|
|
495
|
-
handlerId = `sessionContextHandler:invoke-${this.id}-${contextType}-${(0, utils_1$
|
|
495
|
+
handlerId = `sessionContextHandler:invoke-${this.id}-${contextType}-${(0, utils_1$2.generateId)()}`;
|
|
496
496
|
}
|
|
497
497
|
else {
|
|
498
498
|
handlerId = `sessionContextHandler:invoke-${this.id}`;
|
|
499
499
|
}
|
|
500
|
-
client.register(handlerId, (0, utils_1$
|
|
500
|
+
client.register(handlerId, (0, utils_1$2.wrapContextHandler)(contextHandler, handlerId));
|
|
501
501
|
await client.dispatch(`sessionContextGroup:handlerAdded-${this.id}`, { handlerId, contextType });
|
|
502
502
|
return { unsubscribe: await this.createUnsubscribeCb(handlerId) };
|
|
503
503
|
}
|
|
504
504
|
async createUnsubscribeCb(handlerId) {
|
|
505
|
-
const client = await __classPrivateFieldGet$
|
|
505
|
+
const client = await __classPrivateFieldGet$d(this, _SessionContextGroupClient_clientPromise, "f");
|
|
506
506
|
return async () => {
|
|
507
507
|
client.remove(handlerId);
|
|
508
508
|
await client.dispatch(`sessionContextGroup:handlerRemoved-${this.id}`, { handlerId });
|
|
@@ -511,610 +511,1770 @@ class SessionContextGroupClient extends base_1$k.Base {
|
|
|
511
511
|
getUserInstance() {
|
|
512
512
|
return {
|
|
513
513
|
id: this.id,
|
|
514
|
-
setContext: (0, utils_1$
|
|
515
|
-
getCurrentContext: (0, utils_1$
|
|
516
|
-
addContextHandler: (0, utils_1$
|
|
514
|
+
setContext: (0, utils_1$2.wrapInTryCatch)(this.setContext.bind(this), 'Failed to set context: '),
|
|
515
|
+
getCurrentContext: (0, utils_1$2.wrapInTryCatch)(this.getCurrentContext.bind(this), 'Failed to get context: '),
|
|
516
|
+
addContextHandler: (0, utils_1$2.wrapInTryCatch)(this.addContextHandler.bind(this), 'Failed to add context handler: ')
|
|
517
517
|
};
|
|
518
518
|
}
|
|
519
519
|
}
|
|
520
520
|
SessionContextGroupClient$1.default = SessionContextGroupClient;
|
|
521
521
|
_SessionContextGroupClient_clientPromise = new WeakMap();
|
|
522
522
|
|
|
523
|
-
var
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
var
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
const utils_1$2 = utils$1;
|
|
540
|
-
/**
|
|
541
|
-
* The Interop Client API is broken up into two groups:
|
|
542
|
-
*
|
|
543
|
-
* **Content Facing APIs** - For Application Developers putting Views into a Platform Window, who care about Context. These are APIs that send out and receive the Context data that flows between applications. Think of this as the Water in the Interop Pipes.
|
|
544
|
-
*
|
|
545
|
-
* **Context Grouping APIs** - For Platform Developers, to add and remove Views to and from Context Groups. These APIs are utilized under-the-hood in Platforms, so they don't need to be used to participate in Interop. These are the APIs that decide which entities the context data flows between. Think of these as the valves or pipes that control the flow of Context Data for Interop.
|
|
546
|
-
*
|
|
547
|
-
* ---
|
|
548
|
-
*
|
|
549
|
-
* All APIs are available at the `fin.me.interop` namespace.
|
|
550
|
-
*
|
|
551
|
-
* ---
|
|
552
|
-
*
|
|
553
|
-
* **You only need 2 things to participate in Interop Context Grouping:**
|
|
554
|
-
* * A Context Handler for incoming context: {@link InteropClient#addContextHandler addContextHandler(handler, contextType?)}
|
|
555
|
-
* * Call setContext on your context group when you want to share context with other group members: {@link InteropClient#setContext setContext(context)}
|
|
556
|
-
*
|
|
557
|
-
* ---
|
|
558
|
-
*
|
|
559
|
-
* ##### Constructor
|
|
560
|
-
* Returned by {@link Interop.connectSync Interop.connectSync}.
|
|
561
|
-
*
|
|
562
|
-
* ---
|
|
563
|
-
*
|
|
564
|
-
* ##### Interop methods intended for Views
|
|
565
|
-
*
|
|
566
|
-
*
|
|
567
|
-
* **Context Groups API**
|
|
568
|
-
* * {@link InteropClient#addContextHandler addContextHandler(handler, contextType?)}
|
|
569
|
-
* * {@link InteropClient#setContext setContext(context)}
|
|
570
|
-
* * {@link InteropClient#getCurrentContext getCurrentContext(contextType?)}
|
|
571
|
-
* * {@link InteropClient#joinSessionContextGroup joinSessionContextGroup(sessionContextGroupId)}
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
* **Intents API**
|
|
575
|
-
* * {@link InteropClient#fireIntent fireIntent(intent)}
|
|
576
|
-
* * {@link InteropClient#registerIntentHandler registerIntentHandler(intentHandler, intentName)}
|
|
577
|
-
* * {@link InteropClient#getInfoForIntent getInfoForIntent(infoForIntentOptions)}
|
|
578
|
-
* * {@link InteropClient#getInfoForIntentsByContext getInfoForIntentsByContext(context)}
|
|
579
|
-
* * {@link InteropClient#fireIntentForContext fireIntentForContext(contextForIntent)}
|
|
580
|
-
*
|
|
581
|
-
* ##### Interop methods intended for Windows
|
|
582
|
-
* * {@link InteropClient#getContextGroups getContextGroups()}
|
|
583
|
-
* * {@link InteropClient#joinContextGroup joinContextGroup(contextGroupId, target?)}
|
|
584
|
-
* * {@link InteropClient#removeFromContextGroup removeFromContextGroup(target?)}
|
|
585
|
-
* * {@link InteropClient#getInfoForContextGroup getInfoForContextGroup(contextGroupId)}
|
|
586
|
-
* * {@link InteropClient#getAllClientsInContextGroup getAllClientsInContextGroup(contextGroupId)}
|
|
587
|
-
*
|
|
588
|
-
*/
|
|
589
|
-
class InteropClient extends base_1$j.Base {
|
|
590
|
-
/**
|
|
591
|
-
* @internal
|
|
592
|
-
*/
|
|
593
|
-
constructor(wire, name, interopConfig = {}) {
|
|
594
|
-
super(wire);
|
|
595
|
-
_InteropClient_clientPromise.set(this, void 0);
|
|
596
|
-
_InteropClient_sessionContextGroups.set(this, void 0);
|
|
597
|
-
__classPrivateFieldSet$b(this, _InteropClient_sessionContextGroups, new Map(), "f");
|
|
598
|
-
__classPrivateFieldSet$b(this, _InteropClient_clientPromise, this.wire.environment.whenReady().then(() => {
|
|
599
|
-
return this.fin.InterApplicationBus.Channel.connect(`interop-broker-${name}`, {
|
|
600
|
-
payload: interopConfig
|
|
601
|
-
});
|
|
602
|
-
}), "f");
|
|
523
|
+
var fdc31_2 = {};
|
|
524
|
+
|
|
525
|
+
var fdc3Common = {};
|
|
526
|
+
|
|
527
|
+
var utils$2 = {};
|
|
528
|
+
|
|
529
|
+
var PrivateChannelClient$1 = {};
|
|
530
|
+
|
|
531
|
+
Object.defineProperty(PrivateChannelClient$1, "__esModule", { value: true });
|
|
532
|
+
PrivateChannelClient$1.PrivateChannelClient = void 0;
|
|
533
|
+
const utils$1 = utils$3;
|
|
534
|
+
class PrivateChannelClient {
|
|
535
|
+
constructor(client, id) {
|
|
536
|
+
this.id = id;
|
|
537
|
+
this.client = client;
|
|
538
|
+
this.listeners = new Map();
|
|
603
539
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
*/
|
|
607
|
-
/**
|
|
608
|
-
* Sets a context for the context group of the current entity.
|
|
609
|
-
*
|
|
610
|
-
* @remarks The entity must be part of a context group in order set a context.
|
|
611
|
-
*
|
|
612
|
-
* @param context - New context to set.
|
|
613
|
-
*
|
|
614
|
-
* @example
|
|
615
|
-
* ```js
|
|
616
|
-
* setInstrumentContext = async (ticker) => {
|
|
617
|
-
* fin.me.interop.setContext({type: 'instrument', id: {ticker}})
|
|
618
|
-
* }
|
|
619
|
-
*
|
|
620
|
-
* // The user clicks an instrument of interest. We want to set that Instrument context so that the rest of our workflow updates with information for that instrument
|
|
621
|
-
* instrumentElement.on('click', (evt) => {
|
|
622
|
-
* setInstrumentContext(evt.ticker)
|
|
623
|
-
* })
|
|
624
|
-
* ```
|
|
625
|
-
*/
|
|
626
|
-
async setContext(context) {
|
|
627
|
-
this.wire.sendAction('interop-client-set-context').catch((e) => {
|
|
628
|
-
// don't expose, analytics-only call
|
|
629
|
-
});
|
|
630
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
631
|
-
return client.dispatch('setContext', { context });
|
|
540
|
+
async broadcast(context) {
|
|
541
|
+
return this.client.dispatch('broadcast', { context });
|
|
632
542
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
* @param handler - Handler for incoming context.
|
|
638
|
-
* @param contextType - The type of context you wish to handle.
|
|
639
|
-
*
|
|
640
|
-
* @example
|
|
641
|
-
* ```js
|
|
642
|
-
* function handleIncomingContext(contextInfo) {
|
|
643
|
-
* const { type, id } = contextInfo;
|
|
644
|
-
* switch (type) {
|
|
645
|
-
* case 'instrument':
|
|
646
|
-
* handleInstrumentContext(contextInfo);
|
|
647
|
-
* break;
|
|
648
|
-
* case 'country':
|
|
649
|
-
* handleCountryContext(contextInfo);
|
|
650
|
-
* break;
|
|
651
|
-
*
|
|
652
|
-
* default:
|
|
653
|
-
* break;
|
|
654
|
-
* }
|
|
655
|
-
* }
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
* function handleInstrumentContext(contextInfo) {
|
|
659
|
-
* const { type, id } = contextInfo;
|
|
660
|
-
* console.log('contextInfo for instrument', contextInfo)
|
|
661
|
-
* }
|
|
662
|
-
*
|
|
663
|
-
* function handleCountryContext(contextInfo) {
|
|
664
|
-
* const { type, id } = contextInfo;
|
|
665
|
-
* console.log('contextInfo for country', contextInfo)
|
|
666
|
-
* }
|
|
667
|
-
*
|
|
668
|
-
* fin.me.interop.addContextHandler(handleIncomingContext);
|
|
669
|
-
* ```
|
|
670
|
-
*
|
|
671
|
-
*
|
|
672
|
-
* We are also testing the ability to add a context handler for specific contexts. If you would like to use
|
|
673
|
-
* this, please make sure you add your context handlers at the top level of your application, on a page that
|
|
674
|
-
* does not navigate/reload/re-render, to avoid memory leaks. This feature is experimental:
|
|
675
|
-
*
|
|
676
|
-
* ```js
|
|
677
|
-
* function handleInstrumentContext(contextInfo) {
|
|
678
|
-
* const { type, id } = contextInfo;
|
|
679
|
-
* console.log('contextInfo for instrument', contextInfo)
|
|
680
|
-
* }
|
|
681
|
-
*
|
|
682
|
-
* function handleCountryContext(contextInfo) {
|
|
683
|
-
* const { type, id } = contextInfo;
|
|
684
|
-
* console.log('contextInfo for country', contextInfo)
|
|
685
|
-
* }
|
|
686
|
-
*
|
|
687
|
-
*
|
|
688
|
-
* fin.me.interop.addContextHandler(handleInstrumentContext, 'instrument')
|
|
689
|
-
* fin.me.interop.addContextHandler(handleCountryContext, 'country')
|
|
690
|
-
* ```
|
|
691
|
-
*/
|
|
692
|
-
async addContextHandler(handler, contextType) {
|
|
693
|
-
this.wire.sendAction('interop-client-add-context-handler').catch((e) => {
|
|
694
|
-
// don't expose, analytics-only call
|
|
695
|
-
});
|
|
543
|
+
async getCurrentContext(contextType) {
|
|
544
|
+
return this.client.dispatch('getCurrentContext', { contextType });
|
|
545
|
+
}
|
|
546
|
+
async addContextListener(contextType, handler) {
|
|
696
547
|
if (typeof handler !== 'function') {
|
|
697
|
-
throw new Error("Non-function argument passed to the
|
|
548
|
+
throw new Error("Non-function argument passed to the second parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
|
|
698
549
|
}
|
|
699
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
700
550
|
let handlerId;
|
|
701
551
|
if (contextType) {
|
|
702
|
-
handlerId = `
|
|
703
|
-
console.warn(`Warning: By providing a contextType (${contextType}), you are using the experimental addContextHandler. To avoid issues, make sure you are adding your context handlers at the top level in your application.`);
|
|
552
|
+
handlerId = `contextHandler:invoke-${this.id}-${contextType}-${utils$1.generateId()}`;
|
|
704
553
|
}
|
|
705
554
|
else {
|
|
706
|
-
handlerId =
|
|
707
|
-
}
|
|
708
|
-
const wrappedHandler = (0, utils_1$2.wrapContextHandler)(handler, handlerId);
|
|
709
|
-
client.register(handlerId, wrappedHandler);
|
|
710
|
-
await client.dispatch('contextHandlerRegistered', { handlerId, contextType });
|
|
711
|
-
return {
|
|
712
|
-
unsubscribe: async () => {
|
|
713
|
-
client.remove(handlerId);
|
|
714
|
-
await client.dispatch('removeContextHandler', { handlerId });
|
|
715
|
-
}
|
|
716
|
-
};
|
|
717
|
-
}
|
|
718
|
-
/*
|
|
719
|
-
Platform Window APIs
|
|
720
|
-
*/
|
|
721
|
-
/**
|
|
722
|
-
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
723
|
-
* Used by Platform Windows.
|
|
724
|
-
*
|
|
725
|
-
* @example
|
|
726
|
-
* ```js
|
|
727
|
-
* fin.me.interop.getContextGroups()
|
|
728
|
-
* .then(contextGroups => {
|
|
729
|
-
* contextGroups.forEach(contextGroup => {
|
|
730
|
-
* console.log(contextGroup.displayMetadata.name)
|
|
731
|
-
* console.log(contextGroup.displayMetadata.color)
|
|
732
|
-
* })
|
|
733
|
-
* })
|
|
734
|
-
* ```
|
|
735
|
-
*/
|
|
736
|
-
async getContextGroups() {
|
|
737
|
-
this.wire.sendAction('interop-client-get-context-groups').catch((e) => {
|
|
738
|
-
// don't expose, analytics-only call
|
|
739
|
-
});
|
|
740
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
741
|
-
return client.dispatch('getContextGroups');
|
|
742
|
-
}
|
|
743
|
-
/**
|
|
744
|
-
* Join all Interop Clients at the given identity to context group `contextGroupId`.
|
|
745
|
-
* If no target is specified, it adds the sender to the context group.
|
|
746
|
-
*
|
|
747
|
-
* @remarks Because multiple Channel connections/Interop Clients can potentially exist at a `uuid`/`name` combo, we currently join all Channel connections/Interop Clients at the given identity to the context group.
|
|
748
|
-
* If an `endpointId` is provided (which is unlikely, unless the call is coming from an external adapter), then we only join that single connection to the context group.
|
|
749
|
-
* For all intents and purposes, there will only be 1 connection present in Platform and Browser implmentations, so this point is more-or-less moot.
|
|
750
|
-
* Used by Platform Windows.
|
|
751
|
-
*
|
|
752
|
-
* @param contextGroupId - Id of the context group.
|
|
753
|
-
* @param target - Identity of the entity you wish to join to a context group.
|
|
754
|
-
*
|
|
755
|
-
* @example
|
|
756
|
-
* ```js
|
|
757
|
-
* joinViewToContextGroup = async (contextGroupId, view) => {
|
|
758
|
-
* await fin.me.interop.joinContextGroup(contextGroupId, view);
|
|
759
|
-
* }
|
|
760
|
-
*
|
|
761
|
-
* getLastFocusedView()
|
|
762
|
-
* .then(lastFocusedViewIdentity => {
|
|
763
|
-
* joinViewToContextGroup('red', lastFocusedViewIdentity)
|
|
764
|
-
* })
|
|
765
|
-
* ```
|
|
766
|
-
*/
|
|
767
|
-
async joinContextGroup(contextGroupId, target) {
|
|
768
|
-
this.wire.sendAction('interop-client-join-context-group').catch((e) => {
|
|
769
|
-
// don't expose, analytics-only call
|
|
770
|
-
});
|
|
771
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
772
|
-
if (!contextGroupId) {
|
|
773
|
-
throw new Error('No contextGroupId specified for joinContextGroup.');
|
|
555
|
+
handlerId = `contextHandler:invoke-${this.id}-${utils$1.generateId()}`;
|
|
774
556
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
* Used by Platform Windows.
|
|
781
|
-
*
|
|
782
|
-
* @param target - Identity of the entity you wish to join to a context group.
|
|
783
|
-
*
|
|
784
|
-
* @example
|
|
785
|
-
* ```js
|
|
786
|
-
* removeViewFromContextGroup = async (view) => {
|
|
787
|
-
* await fin.me.interop.removeFromContextGroup(view);
|
|
788
|
-
* }
|
|
789
|
-
*
|
|
790
|
-
* getLastFocusedView()
|
|
791
|
-
* .then(lastFocusedViewIdentity => {
|
|
792
|
-
* removeViewFromContextGroup(lastFocusedViewIdentity)
|
|
793
|
-
* })
|
|
794
|
-
* ```
|
|
795
|
-
*/
|
|
796
|
-
async removeFromContextGroup(target) {
|
|
797
|
-
this.wire.sendAction('interop-client-remove-from-context-group').catch((e) => {
|
|
798
|
-
// don't expose, analytics-only call
|
|
799
|
-
});
|
|
800
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
801
|
-
return client.dispatch('removeFromContextGroup', { target });
|
|
557
|
+
this.client.register(handlerId, utils$1.wrapContextHandler(handler, handlerId));
|
|
558
|
+
const listener = { unsubscribe: await this.createContextUnsubscribeCb(handlerId) };
|
|
559
|
+
this.listeners.set(handlerId, listener);
|
|
560
|
+
await this.client.dispatch(`contextHandlerAdded`, { handlerId, contextType });
|
|
561
|
+
return listener;
|
|
802
562
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
* @param contextGroupId - The id of context group you wish to get clients for.
|
|
810
|
-
*
|
|
811
|
-
* @example
|
|
812
|
-
* ```js
|
|
813
|
-
* fin.me.interop.getAllClientsInContextGroup('red')
|
|
814
|
-
* .then(clientsInContextGroup => {
|
|
815
|
-
* console.log(clientsInContextGroup)
|
|
816
|
-
* })
|
|
817
|
-
* ```
|
|
818
|
-
*/
|
|
819
|
-
async getAllClientsInContextGroup(contextGroupId) {
|
|
820
|
-
this.wire.sendAction('interop-client-get-all-clients-in-context-group').catch((e) => {
|
|
821
|
-
// don't expose, analytics-only call
|
|
822
|
-
});
|
|
823
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
824
|
-
if (!contextGroupId) {
|
|
825
|
-
throw new Error('No contextGroupId specified for getAllClientsInContextGroup.');
|
|
826
|
-
}
|
|
827
|
-
return client.dispatch('getAllClientsInContextGroup', { contextGroupId });
|
|
563
|
+
createNonStandardUnsubscribeCb(handlerId) {
|
|
564
|
+
return async () => {
|
|
565
|
+
this.client.remove(handlerId);
|
|
566
|
+
this.listeners.delete(handlerId);
|
|
567
|
+
await this.client.dispatch('nonStandardHandlerRemoved', { handlerId });
|
|
568
|
+
};
|
|
828
569
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
* @example
|
|
836
|
-
* ```js
|
|
837
|
-
* fin.me.interop.getInfoForContextGroup('red')
|
|
838
|
-
* .then(contextGroupInfo => {
|
|
839
|
-
* console.log(contextGroupInfo.displayMetadata.name)
|
|
840
|
-
* console.log(contextGroupInfo.displayMetadata.color)
|
|
841
|
-
* })
|
|
842
|
-
* ```
|
|
843
|
-
*/
|
|
844
|
-
async getInfoForContextGroup(contextGroupId) {
|
|
845
|
-
this.wire.sendAction('interop-client-get-info-for-context-group').catch((e) => {
|
|
846
|
-
// don't expose, analytics-only call
|
|
847
|
-
});
|
|
848
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
849
|
-
if (!contextGroupId) {
|
|
850
|
-
throw new Error('No contextGroupId specified for getInfoForContextGroup.');
|
|
851
|
-
}
|
|
852
|
-
return client.dispatch('getInfoForContextGroup', { contextGroupId });
|
|
570
|
+
createContextUnsubscribeCb(handlerId) {
|
|
571
|
+
return async () => {
|
|
572
|
+
this.client.remove(handlerId);
|
|
573
|
+
this.listeners.delete(handlerId);
|
|
574
|
+
await this.client.dispatch('contextHandlerRemoved', { handlerId });
|
|
575
|
+
};
|
|
853
576
|
}
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
this.
|
|
874
|
-
|
|
577
|
+
onAddContextListener(handler) {
|
|
578
|
+
const handlerId = `onContextHandlerAdded:invoke-${this.id}-${utils$1.generateId()}`;
|
|
579
|
+
this.client.register(handlerId, handler);
|
|
580
|
+
const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
|
|
581
|
+
this.listeners.set(handlerId, listener);
|
|
582
|
+
this.client.dispatch(`onAddContextHandlerAdded`, { handlerId });
|
|
583
|
+
return listener;
|
|
584
|
+
}
|
|
585
|
+
onDisconnect(handler) {
|
|
586
|
+
const handlerId = `onDisconnect:invoke-${this.id}-${utils$1.generateId()}`;
|
|
587
|
+
this.client.register(handlerId, handler);
|
|
588
|
+
const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
|
|
589
|
+
this.listeners.set(handlerId, listener);
|
|
590
|
+
this.client.dispatch(`onDisconnectHandlerAdded`, { handlerId });
|
|
591
|
+
return listener;
|
|
592
|
+
}
|
|
593
|
+
onUnsubscribe(handler) {
|
|
594
|
+
const handlerId = `onUnsubscribe:invoke-${this.id}-${utils$1.generateId()}`;
|
|
595
|
+
this.client.register(handlerId, handler);
|
|
596
|
+
const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
|
|
597
|
+
this.listeners.set(handlerId, listener);
|
|
598
|
+
this.client.dispatch(`onUnsubscribeHandlerAdded`, { handlerId });
|
|
599
|
+
return listener;
|
|
600
|
+
}
|
|
601
|
+
async cleanUpAllSubs() {
|
|
602
|
+
const listenerUnsubscribers = Array.from(this.listeners.keys());
|
|
603
|
+
listenerUnsubscribers.forEach((handlerId) => {
|
|
604
|
+
this.client.remove(handlerId);
|
|
605
|
+
this.listeners.delete(handlerId);
|
|
875
606
|
});
|
|
876
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
877
|
-
return client.dispatch('fireIntent', intent);
|
|
878
607
|
}
|
|
879
|
-
|
|
880
|
-
* Adds an intent handler for incoming intents. The last intent sent of the name subscribed to will be received.
|
|
881
|
-
* @param handler - Registered function meant to handle a specific intent type.
|
|
882
|
-
* @param intentName - The name of an intent.
|
|
883
|
-
*
|
|
884
|
-
* @example
|
|
885
|
-
* ```js
|
|
886
|
-
* const intentHandler = (intent) => {
|
|
887
|
-
* const { context } = intent;
|
|
888
|
-
* myViewChartHandler(context);
|
|
889
|
-
* };
|
|
890
|
-
*
|
|
891
|
-
* const subscription = await fin.me.interop.registerIntentHandler(intentHandler, 'ViewChart');
|
|
892
|
-
*
|
|
893
|
-
* function myAppCloseSequence() {
|
|
894
|
-
* // to unsubscribe the handler, simply call:
|
|
895
|
-
* subscription.unsubscribe();
|
|
896
|
-
* }
|
|
897
|
-
* ```
|
|
898
|
-
*/
|
|
899
|
-
async registerIntentHandler(handler, intentName, options) {
|
|
900
|
-
this.wire.sendAction('interop-client-register-intent-handler').catch((e) => {
|
|
901
|
-
// don't expose, this is only for api analytics purposes
|
|
902
|
-
});
|
|
903
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
904
|
-
const handlerId = `intent-handler-${intentName}`;
|
|
905
|
-
const wrappedHandler = (0, utils_1$2.wrapIntentHandler)(handler, handlerId);
|
|
608
|
+
async disconnect() {
|
|
906
609
|
try {
|
|
907
|
-
await client.
|
|
908
|
-
await
|
|
610
|
+
await this.client.dispatch('clientDisconnecting');
|
|
611
|
+
await this.cleanUpAllSubs();
|
|
612
|
+
await this.client.disconnect();
|
|
909
613
|
}
|
|
910
614
|
catch (error) {
|
|
911
|
-
throw new Error(
|
|
615
|
+
throw new Error(error.message);
|
|
912
616
|
}
|
|
913
|
-
return {
|
|
914
|
-
unsubscribe: async () => {
|
|
915
|
-
client.remove(handlerId);
|
|
916
|
-
}
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
/**
|
|
920
|
-
* Gets the last context of the Context Group currently subscribed to. It takes an optional Context Type and returns the
|
|
921
|
-
* last context of that type.
|
|
922
|
-
* @param contextType
|
|
923
|
-
*
|
|
924
|
-
* @example
|
|
925
|
-
* ```js
|
|
926
|
-
* await fin.me.interop.joinContextGroup('yellow');
|
|
927
|
-
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
|
928
|
-
* const currentContext = await fin.me.interop.getCurrentContext();
|
|
929
|
-
*
|
|
930
|
-
* // with a specific context
|
|
931
|
-
* await fin.me.interop.joinContextGroup('yellow');
|
|
932
|
-
* await fin.me.interop.setContext({ type: 'country', id: { ISOALPHA3: 'US' }});
|
|
933
|
-
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
|
934
|
-
* const currentContext = await fin.me.interop.getCurrentContext('country');
|
|
935
|
-
* ```
|
|
936
|
-
*/
|
|
937
|
-
async getCurrentContext(contextType) {
|
|
938
|
-
this.wire.sendAction('interop-client-get-current-context').catch((e) => {
|
|
939
|
-
// don't expose, analytics-only call
|
|
940
|
-
});
|
|
941
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
942
|
-
return client.dispatch('getCurrentContext', { contextType });
|
|
943
|
-
}
|
|
944
|
-
/**
|
|
945
|
-
* Get information for a particular Intent from the Interop Broker.
|
|
946
|
-
*
|
|
947
|
-
* @remarks To resolve this info, the function handleInfoForIntent is meant to be overridden in the Interop Broker.
|
|
948
|
-
* The format for the response will be determined by the App Provider overriding the function.
|
|
949
|
-
*
|
|
950
|
-
* @param options
|
|
951
|
-
*
|
|
952
|
-
* @example
|
|
953
|
-
* ```js
|
|
954
|
-
* const intentInfo = await fin.me.interop.getInfoForIntent('ViewChart');
|
|
955
|
-
* ```
|
|
956
|
-
*/
|
|
957
|
-
async getInfoForIntent(options) {
|
|
958
|
-
this.wire.sendAction('interop-client-get-info-for-intent').catch((e) => {
|
|
959
|
-
// don't expose, analytics-only call
|
|
960
|
-
});
|
|
961
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
962
|
-
return client.dispatch('getInfoForIntent', options);
|
|
963
|
-
}
|
|
964
|
-
/**
|
|
965
|
-
* Get information from the Interop Broker on all Intents that are meant to handle a particular context.
|
|
966
|
-
*
|
|
967
|
-
* @remarks To resolve this info, the function handleInfoForIntentsByContext is meant to be overridden in the Interop Broker.
|
|
968
|
-
* The format for the response will be determined by the App Provider overriding the function.
|
|
969
|
-
*
|
|
970
|
-
* @param context
|
|
971
|
-
*
|
|
972
|
-
* @example
|
|
973
|
-
* ```js
|
|
974
|
-
* tickerElement.on('click', (element) => {
|
|
975
|
-
* const ticker = element.innerText;
|
|
976
|
-
*
|
|
977
|
-
* const context = {
|
|
978
|
-
* type: 'fdc3.instrument',
|
|
979
|
-
* id: {
|
|
980
|
-
* ticker
|
|
981
|
-
* }
|
|
982
|
-
* }
|
|
983
|
-
*
|
|
984
|
-
* const intentsInfo = await fin.me.interop.getInfoForIntentByContext(context);
|
|
985
|
-
* })
|
|
986
|
-
* ```
|
|
987
|
-
*/
|
|
988
|
-
async getInfoForIntentsByContext(context) {
|
|
989
|
-
this.wire.sendAction('interop-client-get-info-for-intents-by-context').catch((e) => {
|
|
990
|
-
// don't expose, analytics-only call
|
|
991
|
-
});
|
|
992
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
993
|
-
return client.dispatch('getInfoForIntentsByContext', context);
|
|
994
|
-
}
|
|
995
|
-
/**
|
|
996
|
-
* Sends a Context that will be resolved to an Intent by the Interop Broker.
|
|
997
|
-
* This context accepts a metadata property.
|
|
998
|
-
*
|
|
999
|
-
* @remarks To resolve this info, the function handleFiredIntentByContext is meant to be overridden in the Interop Broker.
|
|
1000
|
-
* The format for the response will be determined by the App Provider overriding the function.
|
|
1001
|
-
*
|
|
1002
|
-
* @param context
|
|
1003
|
-
*
|
|
1004
|
-
* @example
|
|
1005
|
-
* ```js
|
|
1006
|
-
* tickerElement.on('click', (element) => {
|
|
1007
|
-
* const ticker = element.innerText;
|
|
1008
|
-
*
|
|
1009
|
-
* const context = {
|
|
1010
|
-
* type: 'fdc3.instrument',
|
|
1011
|
-
* id: {
|
|
1012
|
-
* ticker
|
|
1013
|
-
* }
|
|
1014
|
-
* }
|
|
1015
|
-
*
|
|
1016
|
-
* const intentResolution = await fin.me.interop.fireIntentForContext(context);
|
|
1017
|
-
* })
|
|
1018
|
-
* ```
|
|
1019
|
-
*/
|
|
1020
|
-
async fireIntentForContext(context) {
|
|
1021
|
-
this.wire.sendAction('interop-client-fire-intent-for-context').catch((e) => {
|
|
1022
|
-
// don't expose, analytics-only call
|
|
1023
|
-
});
|
|
1024
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
1025
|
-
return client.dispatch('fireIntentForContext', context);
|
|
1026
|
-
}
|
|
1027
|
-
/**
|
|
1028
|
-
* Join the current entity to session context group `sessionContextGroupId` and return a sessionContextGroup instance.
|
|
1029
|
-
* If the sessionContextGroup doesn't exist, one will get created.
|
|
1030
|
-
*
|
|
1031
|
-
* @remarks Session Context Groups do not persist between runs and aren't present on snapshots.
|
|
1032
|
-
* @param sessionContextGroupId - Id of the context group.
|
|
1033
|
-
*
|
|
1034
|
-
* @example
|
|
1035
|
-
* Say we want to have a Session Context Group that holds UI theme information for all apps to consume:
|
|
1036
|
-
*
|
|
1037
|
-
* My color-picker View:
|
|
1038
|
-
* ```js
|
|
1039
|
-
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
|
1040
|
-
*
|
|
1041
|
-
* const myColorPickerElement = document.getElementById('color-palette-picker');
|
|
1042
|
-
* myColorPickerElement.addEventListener('change', event => {
|
|
1043
|
-
* themeSessionContextGroup.setContext({ type: 'color-palette', selection: event.value });
|
|
1044
|
-
* });
|
|
1045
|
-
* ```
|
|
1046
|
-
*
|
|
1047
|
-
* In other views:
|
|
1048
|
-
* ```js
|
|
1049
|
-
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
|
1050
|
-
*
|
|
1051
|
-
* const changeColorPalette = ({ selection }) => {
|
|
1052
|
-
* // change the color palette to the selection
|
|
1053
|
-
* };
|
|
1054
|
-
*
|
|
1055
|
-
* // If the context is already set by the time the handler was set, the handler will get invoked immediately with the current context.
|
|
1056
|
-
* themeSessionContextGroup.addContextHandler(changeColorPalette, 'color-palette');
|
|
1057
|
-
* ```
|
|
1058
|
-
*/
|
|
1059
|
-
async joinSessionContextGroup(sessionContextGroupId) {
|
|
1060
|
-
try {
|
|
1061
|
-
const currentSessionContextGroup = __classPrivateFieldGet$d(this, _InteropClient_sessionContextGroups, "f").get(sessionContextGroupId);
|
|
1062
|
-
if (currentSessionContextGroup) {
|
|
1063
|
-
return currentSessionContextGroup.getUserInstance();
|
|
1064
|
-
}
|
|
1065
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
1066
|
-
const { hasConflict } = await client.dispatch('sessionContextGroup:createIfNeeded', {
|
|
1067
|
-
sessionContextGroupId
|
|
1068
|
-
});
|
|
1069
|
-
if (hasConflict) {
|
|
1070
|
-
console.warn(`A (non-session) context group with the name "${sessionContextGroupId}" already exists. If you are trying to join a Context Group, call joinContextGroup instead.`);
|
|
1071
|
-
}
|
|
1072
|
-
const newSessionContextGroup = new SessionContextGroupClient_1.default(this.wire, __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f"), sessionContextGroupId);
|
|
1073
|
-
__classPrivateFieldGet$d(this, _InteropClient_sessionContextGroups, "f").set(sessionContextGroupId, newSessionContextGroup);
|
|
1074
|
-
return newSessionContextGroup.getUserInstance();
|
|
1075
|
-
}
|
|
1076
|
-
catch (error) {
|
|
1077
|
-
console.error(`Error thrown trying to create Session Context Group with id "${sessionContextGroupId}": ${error}`);
|
|
1078
|
-
throw error;
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
/**
|
|
1082
|
-
* Register a listener that is called when the Interop Client has been disconnected from the Interop Broker.
|
|
1083
|
-
* Only one listener per Interop Client can be set.
|
|
1084
|
-
* @param listener
|
|
1085
|
-
*
|
|
1086
|
-
* @example
|
|
1087
|
-
* ```js
|
|
1088
|
-
* const listener = (event) => {
|
|
1089
|
-
* const { type, topic, brokerName} = event;
|
|
1090
|
-
* console.log(`Disconnected from Interop Broker ${brokerName} `);
|
|
1091
|
-
* }
|
|
1092
|
-
*
|
|
1093
|
-
* await fin.me.interop.onDisconnection(listener);
|
|
1094
|
-
* ```
|
|
1095
|
-
*/
|
|
1096
|
-
async onDisconnection(listener) {
|
|
1097
|
-
this.wire.sendAction('interop-client-add-ondisconnection-listener').catch((e) => {
|
|
1098
|
-
// don't expose, analytics-only call
|
|
1099
|
-
});
|
|
1100
|
-
const client = await __classPrivateFieldGet$d(this, _InteropClient_clientPromise, "f");
|
|
1101
|
-
return client.onDisconnection((event) => {
|
|
1102
|
-
const { uuid } = event;
|
|
1103
|
-
listener({ type: 'interop-broker', topic: 'disconnected', brokerName: uuid });
|
|
1104
|
-
});
|
|
1105
|
-
}
|
|
1106
|
-
/**
|
|
1107
|
-
* @internal
|
|
1108
|
-
*
|
|
1109
|
-
* Used to ferry fdc3-only calls from the fdc3 shim to the Interop Broker
|
|
1110
|
-
*/
|
|
1111
|
-
static async ferryFdc3Call(interopClient, action, payload) {
|
|
1112
|
-
const client = await __classPrivateFieldGet$d(interopClient, _InteropClient_clientPromise, "f");
|
|
1113
|
-
return client.dispatch(action, payload || null);
|
|
1114
617
|
}
|
|
1115
618
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
619
|
+
PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
|
|
620
|
+
|
|
621
|
+
(function (exports) {
|
|
622
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
623
|
+
exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildAppChannelObject = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
|
|
624
|
+
const utils_1 = utils$3;
|
|
625
|
+
const PrivateChannelClient_1 = PrivateChannelClient$1;
|
|
626
|
+
const lodash_1 = require$$3;
|
|
627
|
+
const getUnsupportedChannelApis = (channelType) => {
|
|
628
|
+
return {
|
|
629
|
+
addContextListener: () => {
|
|
630
|
+
throw new UnsupportedChannelApiError('Channel.addContextListener', channelType);
|
|
631
|
+
},
|
|
632
|
+
broadcast: () => {
|
|
633
|
+
throw new UnsupportedChannelApiError('Channel.broadcast', channelType);
|
|
634
|
+
},
|
|
635
|
+
getCurrentContext: () => {
|
|
636
|
+
throw new UnsupportedChannelApiError('Channel.getCurrentContext', channelType);
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
};
|
|
640
|
+
exports.getUnsupportedChannelApis = getUnsupportedChannelApis;
|
|
641
|
+
class UnsupportedChannelApiError extends Error {
|
|
642
|
+
constructor(apiName, channelType = 'System') {
|
|
643
|
+
super(apiName);
|
|
644
|
+
this.message = `Calling ${apiName} on an instance of a ${channelType} Channel returned by fdc3.get${channelType}Channels is not supported. If you would like to use a ${channelType} Channel, please use fdc3.joinChannel, fdc3.addContextListener, and fdc3.broadcast instead.`;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
exports.UnsupportedChannelApiError = UnsupportedChannelApiError;
|
|
648
|
+
var ResultError;
|
|
649
|
+
(function (ResultError) {
|
|
650
|
+
/** Returned if the `IntentHandler` exited without returning a Promise or that
|
|
651
|
+
* Promise was not resolved with a Context or Channel object.
|
|
652
|
+
*/
|
|
653
|
+
ResultError["NoResultReturned"] = "NoResultReturned";
|
|
654
|
+
/** Returned if the `IntentHandler` function processing the raised intent
|
|
655
|
+
* throws an error or rejects the Promise it returned.
|
|
656
|
+
*/
|
|
657
|
+
ResultError["IntentHandlerRejected"] = "IntentHandlerRejected";
|
|
658
|
+
})(ResultError = exports.ResultError || (exports.ResultError = {}));
|
|
659
|
+
(function (ChannelError) {
|
|
660
|
+
/** Returned if the specified channel is not found when attempting to join a
|
|
661
|
+
* channel via the `joinUserChannel` function of the DesktopAgent (`fdc3`).
|
|
662
|
+
*/
|
|
663
|
+
ChannelError["NoChannelFound"] = "NoChannelFound";
|
|
664
|
+
/** SHOULD be returned when a request to join a user channel or to a retrieve
|
|
665
|
+
* a Channel object via the `joinUserChannel` or `getOrCreateChannel` methods
|
|
666
|
+
* of the DesktopAgent (`fdc3`) object is denied.
|
|
667
|
+
*/
|
|
668
|
+
ChannelError["AccessDenied"] = "AccessDenied";
|
|
669
|
+
/** SHOULD be returned when a channel cannot be created or retrieved via the
|
|
670
|
+
* `getOrCreateChannel` method of the DesktopAgent (`fdc3`).
|
|
671
|
+
*/
|
|
672
|
+
ChannelError["CreationFailed"] = "CreationFailed";
|
|
673
|
+
})(exports.ChannelError || (exports.ChannelError = {}));
|
|
674
|
+
const buildPrivateChannelObject = (privateChannelClient) => {
|
|
675
|
+
let clientDisconnected = false;
|
|
676
|
+
const checkIfClientDisconnected = () => {
|
|
677
|
+
if (clientDisconnected) {
|
|
678
|
+
throw new Error('Private Channel Client has been disconnected from the Private Channel');
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
return {
|
|
682
|
+
id: privateChannelClient.id,
|
|
683
|
+
type: 'private',
|
|
684
|
+
broadcast: async (context) => {
|
|
685
|
+
checkIfClientDisconnected();
|
|
686
|
+
return privateChannelClient.broadcast(context);
|
|
687
|
+
},
|
|
688
|
+
getCurrentContext: async (contextType) => {
|
|
689
|
+
checkIfClientDisconnected();
|
|
690
|
+
return privateChannelClient.getCurrentContext(contextType);
|
|
691
|
+
},
|
|
692
|
+
// @ts-expect-error TODO [CORE-1524]
|
|
693
|
+
addContextListener: async (contextType, handler) => {
|
|
694
|
+
checkIfClientDisconnected();
|
|
695
|
+
let handlerInUse = handler;
|
|
696
|
+
let contextTypeInUse = contextType;
|
|
697
|
+
if (typeof contextType === 'function') {
|
|
698
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
699
|
+
handlerInUse = contextType;
|
|
700
|
+
contextTypeInUse = null;
|
|
701
|
+
}
|
|
702
|
+
const listener = privateChannelClient.addContextListener(contextTypeInUse, handlerInUse);
|
|
703
|
+
return listener;
|
|
704
|
+
},
|
|
705
|
+
onAddContextListener: (handler) => {
|
|
706
|
+
checkIfClientDisconnected();
|
|
707
|
+
return privateChannelClient.onAddContextListener(handler);
|
|
708
|
+
},
|
|
709
|
+
disconnect: async () => {
|
|
710
|
+
checkIfClientDisconnected();
|
|
711
|
+
clientDisconnected = true;
|
|
712
|
+
return privateChannelClient.disconnect();
|
|
713
|
+
},
|
|
714
|
+
onDisconnect: (handler) => {
|
|
715
|
+
checkIfClientDisconnected();
|
|
716
|
+
return privateChannelClient.onDisconnect(handler);
|
|
717
|
+
},
|
|
718
|
+
onUnsubscribe: (handler) => {
|
|
719
|
+
checkIfClientDisconnected();
|
|
720
|
+
return privateChannelClient.onUnsubscribe(handler);
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
};
|
|
724
|
+
exports.buildPrivateChannelObject = buildPrivateChannelObject;
|
|
725
|
+
const buildAppChannelObject = (sessionContextGroup) => {
|
|
726
|
+
return {
|
|
727
|
+
id: sessionContextGroup.id,
|
|
728
|
+
type: 'app',
|
|
729
|
+
broadcast: sessionContextGroup.setContext,
|
|
730
|
+
getCurrentContext: async (contextType) => {
|
|
731
|
+
const context = await sessionContextGroup.getCurrentContext(contextType);
|
|
732
|
+
return context === undefined ? null : context;
|
|
733
|
+
},
|
|
734
|
+
// @ts-expect-error TODO [CORE-1524]
|
|
735
|
+
addContextListener: (contextType, handler) => {
|
|
736
|
+
let realHandler;
|
|
737
|
+
let realType;
|
|
738
|
+
if (typeof contextType === 'function') {
|
|
739
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
740
|
+
realHandler = contextType;
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
realHandler = handler;
|
|
744
|
+
if (typeof contextType === 'string') {
|
|
745
|
+
realType = contextType;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
const listener = (async () => {
|
|
749
|
+
let first = true;
|
|
750
|
+
const currentContext = await sessionContextGroup.getCurrentContext(realType);
|
|
751
|
+
const wrappedHandler = (context, contextMetadata) => {
|
|
752
|
+
if (first) {
|
|
753
|
+
first = false;
|
|
754
|
+
if ((0, lodash_1.isEqual)(currentContext, context)) {
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
// eslint-disable-next-line consistent-return
|
|
759
|
+
return realHandler(context, contextMetadata);
|
|
760
|
+
};
|
|
761
|
+
return sessionContextGroup.addContextHandler(wrappedHandler, realType);
|
|
762
|
+
})();
|
|
763
|
+
return {
|
|
764
|
+
...listener,
|
|
765
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
};
|
|
770
|
+
exports.buildAppChannelObject = buildAppChannelObject;
|
|
771
|
+
const connectPrivateChannel = async (channelId) => {
|
|
772
|
+
try {
|
|
773
|
+
const channelClient = await fin.InterApplicationBus.Channel.connect(channelId);
|
|
774
|
+
const privateChannelClient = new PrivateChannelClient_1.PrivateChannelClient(channelClient, channelId);
|
|
775
|
+
return (0, exports.buildPrivateChannelObject)(privateChannelClient);
|
|
776
|
+
}
|
|
777
|
+
catch (error) {
|
|
778
|
+
throw new Error(`Private Channel with id: ${channelId} doesn't exist`);
|
|
779
|
+
}
|
|
780
|
+
};
|
|
781
|
+
exports.connectPrivateChannel = connectPrivateChannel;
|
|
782
|
+
const isContext = (context) => {
|
|
783
|
+
if (context && typeof context === 'object' && 'type' in context) {
|
|
784
|
+
const { type } = context;
|
|
785
|
+
return typeof type === 'string';
|
|
786
|
+
}
|
|
787
|
+
return false;
|
|
788
|
+
};
|
|
789
|
+
exports.isContext = isContext;
|
|
790
|
+
const isChannel = (channel) => {
|
|
791
|
+
if (channel && typeof channel === 'object' && 'type' in channel && 'id' in channel) {
|
|
792
|
+
const { type, id } = channel;
|
|
793
|
+
return typeof type === 'string' && typeof id === 'string' && (type === 'app' || type === 'private');
|
|
794
|
+
}
|
|
795
|
+
return false;
|
|
796
|
+
};
|
|
797
|
+
exports.isChannel = isChannel;
|
|
798
|
+
const getIntentResolution = async (interopModule, context, app, intent) => {
|
|
799
|
+
// Generate an ID to make a session context group with. We will pass that ID to the Broker.
|
|
800
|
+
// The broker will then setContext on that session context group later with our Intent Result,
|
|
801
|
+
const guid = (0, utils_1.generateId)(); // TODO make this undefined in web
|
|
802
|
+
// Promise we'll use in getResult
|
|
803
|
+
const getResultPromise = new Promise((resolve, reject) => {
|
|
804
|
+
fin.InterApplicationBus.subscribe({ uuid: '*' }, guid, (intentResult) => {
|
|
805
|
+
resolve(intentResult);
|
|
806
|
+
}).catch(() => reject(new Error('getResult is not supported in this environment')));
|
|
807
|
+
});
|
|
808
|
+
// Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
|
|
809
|
+
const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
|
|
810
|
+
const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
|
|
811
|
+
// Set up the getResult call.
|
|
812
|
+
const getResult = async () => {
|
|
813
|
+
let intentResult = await getResultPromise;
|
|
814
|
+
if (!intentResult || typeof intentResult !== 'object') {
|
|
815
|
+
throw new Error(ResultError.NoResultReturned);
|
|
816
|
+
}
|
|
817
|
+
const { error } = intentResult;
|
|
818
|
+
if (error) {
|
|
819
|
+
throw new Error(ResultError.IntentHandlerRejected);
|
|
820
|
+
}
|
|
821
|
+
if ((0, exports.isChannel)(intentResult)) {
|
|
822
|
+
const { id, type } = intentResult;
|
|
823
|
+
switch (type) {
|
|
824
|
+
case 'private': {
|
|
825
|
+
intentResult = await (0, exports.connectPrivateChannel)(id);
|
|
826
|
+
break;
|
|
827
|
+
}
|
|
828
|
+
case 'app': {
|
|
829
|
+
const sessionContextGroup = await interopModule.joinSessionContextGroup(id);
|
|
830
|
+
intentResult = (0, exports.buildAppChannelObject)(sessionContextGroup);
|
|
831
|
+
break;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
else if (!(0, exports.isContext)(intentResult)) {
|
|
836
|
+
throw new Error(ResultError.NoResultReturned);
|
|
837
|
+
}
|
|
838
|
+
return intentResult;
|
|
839
|
+
};
|
|
840
|
+
// Finally fire the intent.
|
|
841
|
+
const intentResolutionInfoFromBroker = intent
|
|
842
|
+
? await interopModule.fireIntent(intentObj)
|
|
843
|
+
: await interopModule.fireIntentForContext(intentObj);
|
|
844
|
+
if (typeof intentResolutionInfoFromBroker !== 'object') {
|
|
845
|
+
return {
|
|
846
|
+
source: {
|
|
847
|
+
appId: '',
|
|
848
|
+
instanceId: ''
|
|
849
|
+
},
|
|
850
|
+
intent: '',
|
|
851
|
+
version: '2.0',
|
|
852
|
+
getResult
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
return { ...intentResolutionInfoFromBroker, getResult };
|
|
856
|
+
};
|
|
857
|
+
exports.getIntentResolution = getIntentResolution;
|
|
858
|
+
} (utils$2));
|
|
859
|
+
|
|
860
|
+
var hasRequiredFdc3Common;
|
|
861
|
+
|
|
862
|
+
function requireFdc3Common () {
|
|
863
|
+
if (hasRequiredFdc3Common) return fdc3Common;
|
|
864
|
+
hasRequiredFdc3Common = 1;
|
|
865
|
+
var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
866
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
867
|
+
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");
|
|
868
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
869
|
+
};
|
|
870
|
+
var __classPrivateFieldSet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
871
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
872
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
873
|
+
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");
|
|
874
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
875
|
+
};
|
|
876
|
+
var _FDC3ModuleBase_producer;
|
|
877
|
+
Object.defineProperty(fdc3Common, "__esModule", { value: true });
|
|
878
|
+
fdc3Common.FDC3ModuleBase = void 0;
|
|
879
|
+
const utils_1 = utils$2;
|
|
880
|
+
const utils_2 = utils$3;
|
|
881
|
+
const InteropClient_1 = requireInteropClient();
|
|
882
|
+
const lodash_1 = require$$3;
|
|
883
|
+
class FDC3ModuleBase {
|
|
884
|
+
get client() {
|
|
885
|
+
return __classPrivateFieldGet(this, _FDC3ModuleBase_producer, "f").call(this);
|
|
886
|
+
}
|
|
887
|
+
get fin() {
|
|
888
|
+
return this.wire.getFin();
|
|
889
|
+
}
|
|
890
|
+
// eslint-disable-next-line no-useless-constructor
|
|
891
|
+
constructor(producer, wire) {
|
|
892
|
+
this.wire = wire;
|
|
893
|
+
_FDC3ModuleBase_producer.set(this, void 0);
|
|
894
|
+
__classPrivateFieldSet(this, _FDC3ModuleBase_producer, producer, "f");
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Broadcasts a context for the channel of the current entity.
|
|
898
|
+
* @param context - New context to set.
|
|
899
|
+
*
|
|
900
|
+
* @tutorial fdc3.broadcast
|
|
901
|
+
* @static
|
|
902
|
+
*/
|
|
903
|
+
async broadcast(context) {
|
|
904
|
+
this.wire.sendAction('fdc3-broadcast').catch((e) => {
|
|
905
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
906
|
+
});
|
|
907
|
+
return this.client.setContext(context);
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Launches an app with target information, which can either be a string or an AppMetadata object.
|
|
911
|
+
* @param app
|
|
912
|
+
* @param context
|
|
913
|
+
*
|
|
914
|
+
* @tutorial fdc3.open
|
|
915
|
+
*/
|
|
916
|
+
async _open(app, context) {
|
|
917
|
+
this.wire.sendAction('fdc3-open').catch((e) => {
|
|
918
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
919
|
+
});
|
|
920
|
+
try {
|
|
921
|
+
return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3Open', { app, context });
|
|
922
|
+
}
|
|
923
|
+
catch (error) {
|
|
924
|
+
const errorToThrow = error.message === utils_2.BROKER_ERRORS.fdc3Open ? 'ResolverUnavailable' : error.message;
|
|
925
|
+
throw new Error(errorToThrow);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Returns a Channel object for the specified channel, creating it as an App Channel if it does not exist.
|
|
930
|
+
* @param channelId
|
|
931
|
+
*
|
|
932
|
+
* @tutorial fdc3.getOrCreateChannel
|
|
933
|
+
*/
|
|
934
|
+
async getOrCreateChannel(channelId) {
|
|
935
|
+
this.wire.sendAction('fdc3-get-or-create-channel').catch((e) => {
|
|
936
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
937
|
+
});
|
|
938
|
+
const systemChannels = await this.getSystemChannels();
|
|
939
|
+
const userChannel = systemChannels.find((channel) => channel.id === channelId);
|
|
940
|
+
if (userChannel) {
|
|
941
|
+
return { ...userChannel, type: 'system', ...(0, utils_1.getUnsupportedChannelApis)() };
|
|
942
|
+
}
|
|
943
|
+
try {
|
|
944
|
+
const sessionContextGroup = await this.client.joinSessionContextGroup(channelId);
|
|
945
|
+
return (0, utils_1.buildAppChannelObject)(sessionContextGroup);
|
|
946
|
+
}
|
|
947
|
+
catch (error) {
|
|
948
|
+
console.error(error.message);
|
|
949
|
+
throw new Error(utils_1.ChannelError.CreationFailed);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
954
|
+
*
|
|
955
|
+
* @tutorial fdc3.getSystemChannels
|
|
956
|
+
* @static
|
|
957
|
+
*/
|
|
958
|
+
async getSystemChannels() {
|
|
959
|
+
this.wire.sendAction('fdc3-get-system-channels').catch((e) => {
|
|
960
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
961
|
+
});
|
|
962
|
+
const channels = await this.client.getContextGroups();
|
|
963
|
+
// fdc3 implementation of getSystemChannels returns on array of channels, have to decorate over
|
|
964
|
+
// this so people know that these APIs are not supported
|
|
965
|
+
return channels.map((channel) => {
|
|
966
|
+
return { ...channel, type: 'system', ...(0, utils_1.getUnsupportedChannelApis)() };
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Join all Interop Clients at the given identity to context group `contextGroupId`.
|
|
971
|
+
* If no target is specified, it adds the sender to the context group.
|
|
972
|
+
* Because multiple Channel connections/Interop Clients can potentially exist at a `uuid`/`name` combo, we currently join all Channel connections/Interop Clients at the given identity to the context group.
|
|
973
|
+
* If an `endpointId` is provided (which is unlikely, unless the call is coming from an external adapter), then we only join that single connection to the context group.
|
|
974
|
+
* For all intents and purposes, there will only be 1 connection present in Platform and Browser implementations, so this point is more-or-less moot.
|
|
975
|
+
* @param channelId - Id of the context group.
|
|
976
|
+
*
|
|
977
|
+
* @tutorial fdc3.joinChannel
|
|
978
|
+
* @static
|
|
979
|
+
*/
|
|
980
|
+
async joinChannel(channelId) {
|
|
981
|
+
this.wire.sendAction('fdc3-join-channel').catch((e) => {
|
|
982
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
983
|
+
});
|
|
984
|
+
try {
|
|
985
|
+
return await this.client.joinContextGroup(channelId);
|
|
986
|
+
}
|
|
987
|
+
catch (error) {
|
|
988
|
+
if (error.message === utils_2.BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup) {
|
|
989
|
+
console.error('The Channel you have tried to join is an App Channel. Custom Channels can only be defined by the Interop Broker through code or manifest configuration. Please use getOrCreateChannel.');
|
|
990
|
+
}
|
|
991
|
+
else {
|
|
992
|
+
console.error(error.message);
|
|
993
|
+
}
|
|
994
|
+
if (error.message.startsWith('Attempting to join a context group that does not exist')) {
|
|
995
|
+
throw new Error(utils_1.ChannelError.NoChannelFound);
|
|
996
|
+
}
|
|
997
|
+
throw new Error(utils_1.ChannelError.AccessDenied);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Returns the Channel that the entity is subscribed to. Returns null if not joined to a channel.
|
|
1002
|
+
*
|
|
1003
|
+
* @tutorial fdc3.getCurrentChannel
|
|
1004
|
+
*/
|
|
1005
|
+
async getCurrentChannel() {
|
|
1006
|
+
this.wire.sendAction('fdc3-get-current-channel').catch((e) => {
|
|
1007
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1008
|
+
});
|
|
1009
|
+
const currentContextGroupInfo = await this.getCurrentContextGroupInfo();
|
|
1010
|
+
if (!currentContextGroupInfo) {
|
|
1011
|
+
return null;
|
|
1012
|
+
}
|
|
1013
|
+
return this.buildChannelObject(currentContextGroupInfo);
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Removes the specified target from a context group.
|
|
1017
|
+
* If no target is specified, it removes the sender from their context group.
|
|
1018
|
+
*
|
|
1019
|
+
* @tutorial fdc3.leaveCurrentChannel
|
|
1020
|
+
* @static
|
|
1021
|
+
*/
|
|
1022
|
+
async leaveCurrentChannel() {
|
|
1023
|
+
this.wire.sendAction('fdc3-leave-current-channel').catch((e) => {
|
|
1024
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1025
|
+
});
|
|
1026
|
+
return this.client.removeFromContextGroup();
|
|
1027
|
+
}
|
|
1028
|
+
// utils
|
|
1029
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1030
|
+
async getCurrentContextGroupInfo() {
|
|
1031
|
+
const contextGroups = await this.client.getContextGroups();
|
|
1032
|
+
const clientsInCtxGroupsPromise = contextGroups.map(async (ctxGroup) => {
|
|
1033
|
+
return this.client.getAllClientsInContextGroup(ctxGroup.id);
|
|
1034
|
+
});
|
|
1035
|
+
const clientsInCtxGroups = await Promise.all(clientsInCtxGroupsPromise);
|
|
1036
|
+
const clientIdx = clientsInCtxGroups.findIndex((clientIdentityArr) => {
|
|
1037
|
+
return clientIdentityArr.some((clientIdentity) => {
|
|
1038
|
+
const { uuid, name } = clientIdentity;
|
|
1039
|
+
return this.wire.me.uuid === uuid && this.wire.me.name === name;
|
|
1040
|
+
});
|
|
1041
|
+
});
|
|
1042
|
+
return contextGroups[clientIdx];
|
|
1043
|
+
}
|
|
1044
|
+
async buildChannelObject(currentContextGroupInfo) {
|
|
1045
|
+
// @ts-expect-error
|
|
1046
|
+
return {
|
|
1047
|
+
...currentContextGroupInfo,
|
|
1048
|
+
type: 'system',
|
|
1049
|
+
addContextListener: (...[contextType, handler]) => {
|
|
1050
|
+
let realHandler;
|
|
1051
|
+
let realType;
|
|
1052
|
+
if (typeof contextType === 'function') {
|
|
1053
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
1054
|
+
realHandler = contextType;
|
|
1055
|
+
}
|
|
1056
|
+
else {
|
|
1057
|
+
realHandler = handler;
|
|
1058
|
+
if (typeof contextType === 'string') {
|
|
1059
|
+
realType = contextType;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
const listener = (async () => {
|
|
1063
|
+
let first = true;
|
|
1064
|
+
const currentContext = await this.client.getCurrentContext(realType);
|
|
1065
|
+
const wrappedHandler = (context, contextMetadata) => {
|
|
1066
|
+
if (first) {
|
|
1067
|
+
first = false;
|
|
1068
|
+
if ((0, lodash_1.isEqual)(currentContext, context)) {
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
// eslint-disable-next-line consistent-return
|
|
1073
|
+
return realHandler(context, contextMetadata);
|
|
1074
|
+
};
|
|
1075
|
+
return this.client.addContextHandler(wrappedHandler, realType);
|
|
1076
|
+
})();
|
|
1077
|
+
// @ts-expect-error TODO [CORE-1524]
|
|
1078
|
+
return {
|
|
1079
|
+
...listener,
|
|
1080
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
1081
|
+
};
|
|
1082
|
+
},
|
|
1083
|
+
broadcast: this.broadcast.bind(this),
|
|
1084
|
+
// @ts-expect-error Typescript fails to infer the returntype is a Promise
|
|
1085
|
+
getCurrentContext: async (contextType) => {
|
|
1086
|
+
const context = await this.client.getCurrentContext(contextType);
|
|
1087
|
+
// @ts-expect-error Typescript fails to infer the returntype is a Promise
|
|
1088
|
+
return context === undefined ? null : context;
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
fdc3Common.FDC3ModuleBase = FDC3ModuleBase;
|
|
1094
|
+
_FDC3ModuleBase_producer = new WeakMap();
|
|
1095
|
+
return fdc3Common;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
var hasRequiredFdc31_2;
|
|
1099
|
+
|
|
1100
|
+
function requireFdc31_2 () {
|
|
1101
|
+
if (hasRequiredFdc31_2) return fdc31_2;
|
|
1102
|
+
hasRequiredFdc31_2 = 1;
|
|
1103
|
+
Object.defineProperty(fdc31_2, "__esModule", { value: true });
|
|
1104
|
+
fdc31_2.Fdc3Module = void 0;
|
|
1105
|
+
const utils_1 = utils$3;
|
|
1106
|
+
const fdc3_common_1 = requireFdc3Common();
|
|
1107
|
+
/**
|
|
1108
|
+
* @version 1.2
|
|
1109
|
+
* The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
|
|
1110
|
+
* while using our Interop API under the hood. In order to use this set of APIs
|
|
1111
|
+
* you will need to set up your own {@link InteropBroker InteropBroker} or use a Platform application, which does the setup for you. Refer to our documentation on
|
|
1112
|
+
* our {@link https://developers.openfin.co/of-docs/docs/enable-color-linking Interop API}.
|
|
1113
|
+
*
|
|
1114
|
+
* To enable the FDC3 APIs in a {@link Window Window} or {@link View View}, add the fdc3InteropApi
|
|
1115
|
+
* property to its options:
|
|
1116
|
+
*
|
|
1117
|
+
* ```js
|
|
1118
|
+
* {
|
|
1119
|
+
* autoShow: false,
|
|
1120
|
+
* saveWindowState: true,
|
|
1121
|
+
* url: 'https://openfin.co',
|
|
1122
|
+
* fdc3InteropApi: '1.2'
|
|
1123
|
+
* }
|
|
1124
|
+
* ```
|
|
1125
|
+
*
|
|
1126
|
+
* If using a {@link Platform Platform } application, you can set this property in defaultWindowOptions and defaultViewOptions.
|
|
1127
|
+
*
|
|
1128
|
+
* In order to ensure that the FDC3 Api is ready before use, you can use the 'fdc3Ready' event fired on the DOM Window object:
|
|
1129
|
+
*
|
|
1130
|
+
* ```js
|
|
1131
|
+
* function fdc3Action() {
|
|
1132
|
+
* // Make some fdc3 API calls here
|
|
1133
|
+
* }
|
|
1134
|
+
*
|
|
1135
|
+
* if (window.fdc3) {
|
|
1136
|
+
* fdc3Action();
|
|
1137
|
+
* } else {
|
|
1138
|
+
* window.addEventListener('fdc3Ready', fdc3Action);
|
|
1139
|
+
* }
|
|
1140
|
+
* ```
|
|
1141
|
+
*/
|
|
1142
|
+
class Fdc3Module extends fdc3_common_1.FDC3ModuleBase {
|
|
1143
|
+
async open(app, context) {
|
|
1144
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
1145
|
+
await super._open(app, context);
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Add a context handler for incoming context. If an entity is part of a context group, and then sets its context handler, it will receive all of its declared contexts. If you wish to listen for all incoming contexts, pass `null` for the contextType argument.
|
|
1149
|
+
* @param contextType - The type of context you wish to handle.
|
|
1150
|
+
* @param handler - Handler for incoming context.
|
|
1151
|
+
*
|
|
1152
|
+
* @tutorial fdc3.addContextListener
|
|
1153
|
+
* @static
|
|
1154
|
+
*/
|
|
1155
|
+
// @ts-expect-error TODO [CORE-1524]
|
|
1156
|
+
addContextListener(contextType, handler) {
|
|
1157
|
+
this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
|
|
1158
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1159
|
+
});
|
|
1160
|
+
let listener;
|
|
1161
|
+
if (typeof contextType === 'function') {
|
|
1162
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
1163
|
+
listener = this.client.addContextHandler(contextType);
|
|
1164
|
+
}
|
|
1165
|
+
else {
|
|
1166
|
+
listener = this.client.addContextHandler(handler, contextType === null ? undefined : contextType);
|
|
1167
|
+
}
|
|
1168
|
+
return {
|
|
1169
|
+
...listener,
|
|
1170
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
/**
|
|
1174
|
+
* Adds a listener for incoming Intents.
|
|
1175
|
+
* @param intent - Name of the Intent
|
|
1176
|
+
* @param handler - Handler for incoming Intent
|
|
1177
|
+
*
|
|
1178
|
+
* @tutorial fdc3.addIntentListener
|
|
1179
|
+
* @static
|
|
1180
|
+
*/
|
|
1181
|
+
addIntentListener(intent, handler) {
|
|
1182
|
+
this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
|
|
1183
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1184
|
+
});
|
|
1185
|
+
const contextHandler = (raisedIntent) => {
|
|
1186
|
+
const { context, metadata: intentMetadata } = raisedIntent;
|
|
1187
|
+
const { metadata } = context;
|
|
1188
|
+
const intentResolutionResultId = intentMetadata?.intentResolutionResultId || metadata?.intentResolutionResultId;
|
|
1189
|
+
if (intentResolutionResultId) {
|
|
1190
|
+
this.fin.InterApplicationBus.publish(intentResolutionResultId, null).catch(() => null);
|
|
1191
|
+
}
|
|
1192
|
+
handler(raisedIntent.context);
|
|
1193
|
+
};
|
|
1194
|
+
const listener = this.client.registerIntentHandler(contextHandler, intent, {
|
|
1195
|
+
fdc3Version: '1.2'
|
|
1196
|
+
});
|
|
1197
|
+
return {
|
|
1198
|
+
...listener,
|
|
1199
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Raises a specific intent.
|
|
1204
|
+
* @param intent Name of the Intent.
|
|
1205
|
+
* @param context Context associated with the Intent.
|
|
1206
|
+
* @param app App that will resolve the Intent. This is added as metadata to the Intent. Can be accessed by the app provider in {@link InteropBroker#handleFiredIntent InteropBroker.handleFiredIntent}.
|
|
1207
|
+
*
|
|
1208
|
+
* @tutorial fdc3.raiseIntent
|
|
1209
|
+
* @static
|
|
1210
|
+
*/
|
|
1211
|
+
async raiseIntent(intent, context, app) {
|
|
1212
|
+
this.wire.sendAction('fdc3-raise-intent').catch((e) => {
|
|
1213
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1214
|
+
});
|
|
1215
|
+
const intentObj = app
|
|
1216
|
+
? { name: intent, context, metadata: { target: app } }
|
|
1217
|
+
: { name: intent, context };
|
|
1218
|
+
try {
|
|
1219
|
+
return await this.client.fireIntent(intentObj);
|
|
1220
|
+
}
|
|
1221
|
+
catch (error) {
|
|
1222
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error.message;
|
|
1223
|
+
throw new Error(errorToThrow);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Find out more information about a particular intent by passing its name, and optionally its context.
|
|
1228
|
+
* @param intent Name of the Intent
|
|
1229
|
+
* @param context
|
|
1230
|
+
*
|
|
1231
|
+
* @tutorial fdc3.findIntent
|
|
1232
|
+
*/
|
|
1233
|
+
async findIntent(intent, context) {
|
|
1234
|
+
this.wire.sendAction('fdc3-find-intent').catch((e) => {
|
|
1235
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1236
|
+
});
|
|
1237
|
+
try {
|
|
1238
|
+
return await this.client.getInfoForIntent({ name: intent, context });
|
|
1239
|
+
}
|
|
1240
|
+
catch (error) {
|
|
1241
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntent ? 'ResolverUnavailable' : error.message;
|
|
1242
|
+
throw new Error(errorToThrow);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* Find all the available intents for a particular context.
|
|
1247
|
+
* @param context
|
|
1248
|
+
*
|
|
1249
|
+
* @tutorial fdc3.findIntentsByContext
|
|
1250
|
+
*/
|
|
1251
|
+
async findIntentsByContext(context) {
|
|
1252
|
+
this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
|
|
1253
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1254
|
+
});
|
|
1255
|
+
try {
|
|
1256
|
+
return await this.client.getInfoForIntentsByContext(context);
|
|
1257
|
+
}
|
|
1258
|
+
catch (error) {
|
|
1259
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntentsByContext ? 'ResolverUnavailable' : error.message;
|
|
1260
|
+
throw new Error(errorToThrow);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Finds and raises an intent against a target app based purely on context data.
|
|
1265
|
+
* @param context
|
|
1266
|
+
* @param app
|
|
1267
|
+
*
|
|
1268
|
+
* @tutorial fdc3.raiseIntentForContext
|
|
1269
|
+
*/
|
|
1270
|
+
async raiseIntentForContext(context, app) {
|
|
1271
|
+
this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
|
|
1272
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1273
|
+
});
|
|
1274
|
+
try {
|
|
1275
|
+
return await this.client.fireIntentForContext({ ...context, metadata: { target: app } });
|
|
1276
|
+
}
|
|
1277
|
+
catch (error) {
|
|
1278
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntentForContext ? 'ResolverUnavailable' : error.message;
|
|
1279
|
+
throw new Error(errorToThrow);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Returns a Channel object for the specified channel, creating it as an App Channel if it does not exist.
|
|
1284
|
+
* @param channelId
|
|
1285
|
+
*
|
|
1286
|
+
* @tutorial fdc3.getOrCreateChannel
|
|
1287
|
+
*/
|
|
1288
|
+
async getOrCreateChannel(channelId) {
|
|
1289
|
+
return super.getOrCreateChannel(channelId);
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Returns metadata relating to the FDC3 object and its provider, including the supported version of the FDC3 specification and the name of the provider of the implementation.
|
|
1293
|
+
*
|
|
1294
|
+
* @tutorial fdc3.getInfo
|
|
1295
|
+
*/
|
|
1296
|
+
getInfo() {
|
|
1297
|
+
this.wire.sendAction('fdc3-get-info').catch((e) => {
|
|
1298
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1299
|
+
});
|
|
1300
|
+
// @ts-expect-error
|
|
1301
|
+
const { uuid, fdc3InteropApi } = fin.__internal_.initialOptions;
|
|
1302
|
+
// @ts-expect-error
|
|
1303
|
+
const runtimeVersion = fin.desktop.getVersion();
|
|
1304
|
+
return {
|
|
1305
|
+
fdc3Version: fdc3InteropApi,
|
|
1306
|
+
provider: `openfin-${uuid}`,
|
|
1307
|
+
providerVersion: runtimeVersion
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
fdc31_2.Fdc3Module = Fdc3Module;
|
|
1312
|
+
return fdc31_2;
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
var fdc32_0 = {};
|
|
1316
|
+
|
|
1317
|
+
var hasRequiredFdc32_0;
|
|
1318
|
+
|
|
1319
|
+
function requireFdc32_0 () {
|
|
1320
|
+
if (hasRequiredFdc32_0) return fdc32_0;
|
|
1321
|
+
hasRequiredFdc32_0 = 1;
|
|
1322
|
+
Object.defineProperty(fdc32_0, "__esModule", { value: true });
|
|
1323
|
+
fdc32_0.Fdc3Module2 = void 0;
|
|
1324
|
+
const fdc3_common_1 = requireFdc3Common();
|
|
1325
|
+
const utils_1 = utils$3;
|
|
1326
|
+
const InteropClient_1 = requireInteropClient();
|
|
1327
|
+
const utils_2 = utils$2;
|
|
1328
|
+
const PrivateChannelClient_1 = PrivateChannelClient$1;
|
|
1329
|
+
/**
|
|
1330
|
+
* @version 2.0
|
|
1331
|
+
* The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
|
|
1332
|
+
* while using our Interop API under the hood. In order to use this set of APIs
|
|
1333
|
+
* you will need to set up your own {@link InteropBroker InteropBroker} or use a Platform application, which does the setup for you. Refer to our documentation on
|
|
1334
|
+
* our {@link https://developers.openfin.co/of-docs/docs/enable-context-sharing Interop API}.
|
|
1335
|
+
*
|
|
1336
|
+
* To enable the FDC3 APIs in a {@link Window Window} or {@link View View}, add the fdc3InteropApi
|
|
1337
|
+
* property to its options:
|
|
1338
|
+
*
|
|
1339
|
+
* ```js
|
|
1340
|
+
* {
|
|
1341
|
+
* autoShow: false,
|
|
1342
|
+
* saveWindowState: true,
|
|
1343
|
+
* url: 'https://openfin.co',
|
|
1344
|
+
* fdc3InteropApi: '2.0'
|
|
1345
|
+
* }
|
|
1346
|
+
* ```
|
|
1347
|
+
*
|
|
1348
|
+
* If using a {@link Platform Platform } application, you can set this property in defaultWindowOptions and defaultViewOptions.
|
|
1349
|
+
*
|
|
1350
|
+
* In order to ensure that the FDC3 Api is ready before use, you can use the 'fdc3Ready' event fired on the DOM Window object:
|
|
1351
|
+
*
|
|
1352
|
+
* ```js
|
|
1353
|
+
* function fdc3Action() {
|
|
1354
|
+
* // Make some fdc3 API calls here
|
|
1355
|
+
* }
|
|
1356
|
+
*
|
|
1357
|
+
* if (window.fdc3) {
|
|
1358
|
+
* fdc3Action();
|
|
1359
|
+
* } else {
|
|
1360
|
+
* window.addEventListener('fdc3Ready', fdc3Action);
|
|
1361
|
+
* }
|
|
1362
|
+
* ```
|
|
1363
|
+
*/
|
|
1364
|
+
class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
1365
|
+
/**
|
|
1366
|
+
* Launches an app, specified via an AppIdentifier object.
|
|
1367
|
+
* @param app
|
|
1368
|
+
* @param context
|
|
1369
|
+
*
|
|
1370
|
+
* @tutorial fdc3.open
|
|
1371
|
+
*/
|
|
1372
|
+
async open(app, context) {
|
|
1373
|
+
if (typeof app === 'string') {
|
|
1374
|
+
console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
|
|
1375
|
+
}
|
|
1376
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
1377
|
+
return super._open(app, context);
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* Find all the available instances for a particular application.
|
|
1381
|
+
* @param app
|
|
1382
|
+
*
|
|
1383
|
+
* @tutorial fdc3v2.findInstances
|
|
1384
|
+
*/
|
|
1385
|
+
async findInstances(app) {
|
|
1386
|
+
this.wire.sendAction('fdc3-find-instances').catch((e) => {
|
|
1387
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1388
|
+
});
|
|
1389
|
+
try {
|
|
1390
|
+
return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3FindInstances', app);
|
|
1391
|
+
}
|
|
1392
|
+
catch (error) {
|
|
1393
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fdc3FindInstances ? 'ResolverUnavailable' : error.message;
|
|
1394
|
+
throw new Error(errorToThrow);
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* 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.
|
|
1399
|
+
* @param app
|
|
1400
|
+
*
|
|
1401
|
+
* @tutorial fdc3v2.getAppMetadata
|
|
1402
|
+
*/
|
|
1403
|
+
async getAppMetadata(app) {
|
|
1404
|
+
this.wire.sendAction('fdc3-get-app-metadata').catch((e) => {
|
|
1405
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1406
|
+
});
|
|
1407
|
+
try {
|
|
1408
|
+
return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3GetAppMetadata', app);
|
|
1409
|
+
}
|
|
1410
|
+
catch (error) {
|
|
1411
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fdc3GetAppMetadata ? 'ResolverUnavailable' : error.message;
|
|
1412
|
+
throw new Error(errorToThrow);
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* Add a context handler for incoming context. If an entity is part of a context group, and then sets its context handler, it will receive all of its declared contexts. If you wish to listen for all incoming contexts, pass `null` for the contextType argument.
|
|
1417
|
+
* @param contextType
|
|
1418
|
+
* @param handler
|
|
1419
|
+
*
|
|
1420
|
+
* @tutorial fdc3.addContextListener
|
|
1421
|
+
*/
|
|
1422
|
+
// @ts-expect-error TODO [CORE-1524]
|
|
1423
|
+
async addContextListener(contextType, handler) {
|
|
1424
|
+
this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
|
|
1425
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1426
|
+
});
|
|
1427
|
+
// The FDC3 ContextHandler only expects the context and optional ContextMetadata, so we wrap the handler
|
|
1428
|
+
// here so it only gets passed these parameters
|
|
1429
|
+
const getWrappedHandler = (handlerToWrap) => {
|
|
1430
|
+
return (context) => {
|
|
1431
|
+
const { contextMetadata, ...rest } = context;
|
|
1432
|
+
const args = contextMetadata ? [{ ...rest }, contextMetadata] : [context, null];
|
|
1433
|
+
handlerToWrap(...args);
|
|
1434
|
+
};
|
|
1435
|
+
};
|
|
1436
|
+
let actualHandler = handler;
|
|
1437
|
+
let wrappedHandler = getWrappedHandler(actualHandler);
|
|
1438
|
+
if (typeof contextType === 'function') {
|
|
1439
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
1440
|
+
actualHandler = contextType;
|
|
1441
|
+
wrappedHandler = getWrappedHandler(actualHandler);
|
|
1442
|
+
return this.client.addContextHandler(wrappedHandler);
|
|
1443
|
+
}
|
|
1444
|
+
return this.client.addContextHandler(wrappedHandler, contextType === null ? undefined : contextType);
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* Find out more information about a particular intent by passing its name, and optionally its context and resultType.
|
|
1448
|
+
* @param intent Name of the Intent
|
|
1449
|
+
* @param context Context
|
|
1450
|
+
* @param resultType The type of result returned for any intent specified during resolution.
|
|
1451
|
+
*
|
|
1452
|
+
* @tutorial fdc3.findIntent
|
|
1453
|
+
*/
|
|
1454
|
+
async findIntent(intent, context, resultType) {
|
|
1455
|
+
this.wire.sendAction('fdc3-find-intent').catch((e) => {
|
|
1456
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1457
|
+
});
|
|
1458
|
+
try {
|
|
1459
|
+
return await this.client.getInfoForIntent({ name: intent, context, metadata: { resultType } });
|
|
1460
|
+
}
|
|
1461
|
+
catch (error) {
|
|
1462
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntent ? 'ResolverUnavailable' : error.message;
|
|
1463
|
+
throw new Error(errorToThrow);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
/**
|
|
1467
|
+
* Find all the available intents for a particular context.
|
|
1468
|
+
* @param context
|
|
1469
|
+
* @param resultType The type of result returned for any intent specified during resolution.
|
|
1470
|
+
*
|
|
1471
|
+
* @tutorial fdc3v2.findIntentsByContext
|
|
1472
|
+
*/
|
|
1473
|
+
async findIntentsByContext(context, resultType) {
|
|
1474
|
+
this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
|
|
1475
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1476
|
+
});
|
|
1477
|
+
const payload = resultType ? { context, metadata: { resultType } } : context;
|
|
1478
|
+
try {
|
|
1479
|
+
return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3v2FindIntentsByContext', payload);
|
|
1480
|
+
}
|
|
1481
|
+
catch (error) {
|
|
1482
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntentsByContext ? 'ResolverUnavailable' : error.message;
|
|
1483
|
+
throw new Error(errorToThrow);
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* Raises a specific intent for resolution against apps registered with the desktop agent.
|
|
1488
|
+
* @param intent Name of the Intent
|
|
1489
|
+
* @param context Context associated with the Intent
|
|
1490
|
+
* @param app
|
|
1491
|
+
*
|
|
1492
|
+
* @tutorial fdc3v2.raiseIntent
|
|
1493
|
+
*/
|
|
1494
|
+
async raiseIntent(intent, context, app) {
|
|
1495
|
+
this.wire.sendAction('fdc3-raise-intent').catch((e) => {
|
|
1496
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1497
|
+
});
|
|
1498
|
+
try {
|
|
1499
|
+
if (typeof app === 'string') {
|
|
1500
|
+
console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
|
|
1501
|
+
}
|
|
1502
|
+
return (0, utils_2.getIntentResolution)(this.client, context, app, intent);
|
|
1503
|
+
}
|
|
1504
|
+
catch (error) {
|
|
1505
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error.message;
|
|
1506
|
+
throw new Error(errorToThrow);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Finds and raises an intent against apps registered with the desktop agent based purely on the type of the context data.
|
|
1511
|
+
* @param context Context associated with the Intent
|
|
1512
|
+
* @param app
|
|
1513
|
+
*
|
|
1514
|
+
* @tutorial fdc3v2.raiseIntentForContext
|
|
1515
|
+
*/
|
|
1516
|
+
async raiseIntentForContext(context, app) {
|
|
1517
|
+
// TODO: We have to do the same thing we do for raiseIntent here as well.
|
|
1518
|
+
this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
|
|
1519
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1520
|
+
});
|
|
1521
|
+
try {
|
|
1522
|
+
if (typeof app === 'string') {
|
|
1523
|
+
console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
|
|
1524
|
+
}
|
|
1525
|
+
return (0, utils_2.getIntentResolution)(this.client, context, app);
|
|
1526
|
+
}
|
|
1527
|
+
catch (error) {
|
|
1528
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error.message;
|
|
1529
|
+
throw new Error(errorToThrow);
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
/**
|
|
1533
|
+
* Adds a listener for incoming intents.
|
|
1534
|
+
* @param intent Name of the Intent
|
|
1535
|
+
* @param handler A callback that handles a context event and may return a promise of a Context or Channel object to be returned to the application that raised the intent.
|
|
1536
|
+
*
|
|
1537
|
+
* @tutorial fdc3.addIntentListener
|
|
1538
|
+
*/
|
|
1539
|
+
async addIntentListener(intent, handler) {
|
|
1540
|
+
this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
|
|
1541
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1542
|
+
});
|
|
1543
|
+
if (typeof intent !== 'string') {
|
|
1544
|
+
throw new Error('First argument must be an Intent name');
|
|
1545
|
+
}
|
|
1546
|
+
// The FDC3 Intenter handler only expects the context and contextMetadata to be passed to the handler,
|
|
1547
|
+
// so we wrap it here and only pass those paramaters.
|
|
1548
|
+
const contextHandler = async (raisedIntent) => {
|
|
1549
|
+
let intentResult;
|
|
1550
|
+
let intentResultToSend;
|
|
1551
|
+
const { context, metadata: intentMetadata } = raisedIntent;
|
|
1552
|
+
const { contextMetadata, metadata, ...rest } = context;
|
|
1553
|
+
const intentResolutionResultId = intentMetadata?.intentResolutionResultId || metadata?.intentResolutionResultId;
|
|
1554
|
+
try {
|
|
1555
|
+
const newContext = metadata ? { metadata, ...rest } : { ...rest };
|
|
1556
|
+
intentResult = await handler(newContext, contextMetadata);
|
|
1557
|
+
intentResultToSend = intentResult;
|
|
1558
|
+
}
|
|
1559
|
+
catch (error) {
|
|
1560
|
+
intentResult = error;
|
|
1561
|
+
intentResultToSend = { error: true };
|
|
1562
|
+
}
|
|
1563
|
+
if (intentResolutionResultId) {
|
|
1564
|
+
this.fin.InterApplicationBus.publish(intentResolutionResultId, intentResultToSend).catch(() => null);
|
|
1565
|
+
}
|
|
1566
|
+
if (intentResult instanceof Error) {
|
|
1567
|
+
throw new Error(intentResult.message);
|
|
1568
|
+
}
|
|
1569
|
+
return intentResult;
|
|
1570
|
+
};
|
|
1571
|
+
return this.client.registerIntentHandler(contextHandler, intent, { fdc3Version: '2.0' });
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* Returns a Channel object for the specified channel, creating it as an App Channel if it does not exist.
|
|
1575
|
+
* @param channelId
|
|
1576
|
+
*
|
|
1577
|
+
* @tutorial fdc3.getOrCreateChannel
|
|
1578
|
+
*/
|
|
1579
|
+
async getOrCreateChannel(channelId) {
|
|
1580
|
+
return super.getOrCreateChannel(channelId);
|
|
1581
|
+
}
|
|
1582
|
+
/**
|
|
1583
|
+
* 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.
|
|
1584
|
+
*
|
|
1585
|
+
* @tutorial fdc3v2.createPrivateChannel
|
|
1586
|
+
*/
|
|
1587
|
+
async createPrivateChannel() {
|
|
1588
|
+
const channelId = (0, utils_1.generateId)();
|
|
1589
|
+
await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'createPrivateChannelProvider', { channelId });
|
|
1590
|
+
const channelClient = await this.fin.InterApplicationBus.Channel.connect(channelId);
|
|
1591
|
+
const newPrivateChannelClient = new PrivateChannelClient_1.PrivateChannelClient(channelClient, channelId);
|
|
1592
|
+
return (0, utils_2.buildPrivateChannelObject)(newPrivateChannelClient);
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* Retrieves a list of the User Channels available for the app to join.
|
|
1596
|
+
*
|
|
1597
|
+
* @tutorial fdc3v2.getUserChannels
|
|
1598
|
+
*/
|
|
1599
|
+
async getUserChannels() {
|
|
1600
|
+
const channels = await this.client.getContextGroups();
|
|
1601
|
+
// fdc3 implementation of getUserChannels returns on array of channels, have to decorate over
|
|
1602
|
+
// this so people know that these APIs are not supported
|
|
1603
|
+
return channels.map((channel) => {
|
|
1604
|
+
// @ts-expect-error TODO [CORE-1524]
|
|
1605
|
+
return { ...channel, type: 'user', ...(0, utils_2.getUnsupportedChannelApis)('User') };
|
|
1606
|
+
});
|
|
1607
|
+
}
|
|
1608
|
+
/**
|
|
1609
|
+
* Retrieves a list of the User Channels available for the app to join.
|
|
1610
|
+
*
|
|
1611
|
+
* @deprecated Please use {@link fdc3.getUserChannels fdc3.getUserChannels} instead
|
|
1612
|
+
* @tutorial fdc3.getSystemChannels
|
|
1613
|
+
*/
|
|
1614
|
+
async getSystemChannels() {
|
|
1615
|
+
console.warn('This API has been deprecated. Please use fdc3.getUserChannels instead.');
|
|
1616
|
+
return super.getSystemChannels();
|
|
1617
|
+
}
|
|
1618
|
+
/**
|
|
1619
|
+
* Join an app to a specified User channel.
|
|
1620
|
+
* @param channelId Channel name
|
|
1621
|
+
*
|
|
1622
|
+
* @tutorial fdc3v2.joinUserChannel
|
|
1623
|
+
*/
|
|
1624
|
+
async joinUserChannel(channelId) {
|
|
1625
|
+
return super.joinChannel(channelId);
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Join an app to a specified User channel.
|
|
1629
|
+
* @param channelId Channel name
|
|
1630
|
+
* @deprecated Please use {@link fdc3.joinUserChannel fdc3.joinUserChannel} instead
|
|
1631
|
+
*
|
|
1632
|
+
* @tutorial fdc3.joinChannel
|
|
1633
|
+
*/
|
|
1634
|
+
async joinChannel(channelId) {
|
|
1635
|
+
console.warn('This API has been deprecated. Please use fdc3.joinUserChannel instead.');
|
|
1636
|
+
return super.joinChannel(channelId);
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Returns the Channel object for the current User channel membership
|
|
1640
|
+
*
|
|
1641
|
+
* @tutorial fdc3.getCurrentChannel
|
|
1642
|
+
*/
|
|
1643
|
+
async getCurrentChannel() {
|
|
1644
|
+
const currentChannel = await super.getCurrentChannel();
|
|
1645
|
+
if (!currentChannel) {
|
|
1646
|
+
return null;
|
|
1647
|
+
}
|
|
1648
|
+
return {
|
|
1649
|
+
...currentChannel,
|
|
1650
|
+
type: 'user',
|
|
1651
|
+
broadcast: this.broadcast.bind(this)
|
|
1652
|
+
};
|
|
1653
|
+
}
|
|
1654
|
+
/**
|
|
1655
|
+
* 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.
|
|
1656
|
+
* fdc3HandleGetInfo must be overridden in the InteropBroker so that the ImplementationMetadata will have the appMetadata info.
|
|
1657
|
+
*
|
|
1658
|
+
* @tutorial fdc3v2.getInfo
|
|
1659
|
+
*/
|
|
1660
|
+
async getInfo() {
|
|
1661
|
+
return InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3v2GetInfo', { fdc3Version: '2.0' });
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
fdc32_0.Fdc3Module2 = Fdc3Module2;
|
|
1665
|
+
return fdc32_0;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
var hasRequiredInteropClient;
|
|
1669
|
+
|
|
1670
|
+
function requireInteropClient () {
|
|
1671
|
+
if (hasRequiredInteropClient) return InteropClient;
|
|
1672
|
+
hasRequiredInteropClient = 1;
|
|
1673
|
+
var __classPrivateFieldSet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
1674
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
1675
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
1676
|
+
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");
|
|
1677
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
1678
|
+
};
|
|
1679
|
+
var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
1680
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1681
|
+
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");
|
|
1682
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1683
|
+
};
|
|
1684
|
+
var _InteropClient_clientPromise, _InteropClient_sessionContextGroups;
|
|
1685
|
+
Object.defineProperty(InteropClient, "__esModule", { value: true });
|
|
1686
|
+
InteropClient.InteropClient = void 0;
|
|
1687
|
+
const base_1 = base;
|
|
1688
|
+
const SessionContextGroupClient_1 = SessionContextGroupClient$1;
|
|
1689
|
+
const fdc3_1_2_1 = requireFdc31_2();
|
|
1690
|
+
const fdc3_2_0_1 = requireFdc32_0();
|
|
1691
|
+
const utils_1 = utils$3;
|
|
1692
|
+
/**
|
|
1693
|
+
* The Interop Client API is broken up into two groups:
|
|
1694
|
+
*
|
|
1695
|
+
* **Content Facing APIs** - For Application Developers putting Views into a Platform Window, who care about Context. These are APIs that send out and receive the Context data that flows between applications. Think of this as the Water in the Interop Pipes.
|
|
1696
|
+
*
|
|
1697
|
+
* **Context Grouping APIs** - For Platform Developers, to add and remove Views to and from Context Groups. These APIs are utilized under-the-hood in Platforms, so they don't need to be used to participate in Interop. These are the APIs that decide which entities the context data flows between. Think of these as the valves or pipes that control the flow of Context Data for Interop.
|
|
1698
|
+
*
|
|
1699
|
+
* ---
|
|
1700
|
+
*
|
|
1701
|
+
* All APIs are available at the `fin.me.interop` namespace.
|
|
1702
|
+
*
|
|
1703
|
+
* ---
|
|
1704
|
+
*
|
|
1705
|
+
* **You only need 2 things to participate in Interop Context Grouping:**
|
|
1706
|
+
* * A Context Handler for incoming context: {@link InteropClient#addContextHandler addContextHandler(handler, contextType?)}
|
|
1707
|
+
* * Call setContext on your context group when you want to share context with other group members: {@link InteropClient#setContext setContext(context)}
|
|
1708
|
+
*
|
|
1709
|
+
* ---
|
|
1710
|
+
*
|
|
1711
|
+
* ##### Constructor
|
|
1712
|
+
* Returned by {@link Interop.connectSync Interop.connectSync}.
|
|
1713
|
+
*
|
|
1714
|
+
* ---
|
|
1715
|
+
*
|
|
1716
|
+
* ##### Interop methods intended for Views
|
|
1717
|
+
*
|
|
1718
|
+
*
|
|
1719
|
+
* **Context Groups API**
|
|
1720
|
+
* * {@link InteropClient#addContextHandler addContextHandler(handler, contextType?)}
|
|
1721
|
+
* * {@link InteropClient#setContext setContext(context)}
|
|
1722
|
+
* * {@link InteropClient#getCurrentContext getCurrentContext(contextType?)}
|
|
1723
|
+
* * {@link InteropClient#joinSessionContextGroup joinSessionContextGroup(sessionContextGroupId)}
|
|
1724
|
+
*
|
|
1725
|
+
*
|
|
1726
|
+
* **Intents API**
|
|
1727
|
+
* * {@link InteropClient#fireIntent fireIntent(intent)}
|
|
1728
|
+
* * {@link InteropClient#registerIntentHandler registerIntentHandler(intentHandler, intentName)}
|
|
1729
|
+
* * {@link InteropClient#getInfoForIntent getInfoForIntent(infoForIntentOptions)}
|
|
1730
|
+
* * {@link InteropClient#getInfoForIntentsByContext getInfoForIntentsByContext(context)}
|
|
1731
|
+
* * {@link InteropClient#fireIntentForContext fireIntentForContext(contextForIntent)}
|
|
1732
|
+
*
|
|
1733
|
+
* ##### Interop methods intended for Windows
|
|
1734
|
+
* * {@link InteropClient#getContextGroups getContextGroups()}
|
|
1735
|
+
* * {@link InteropClient#joinContextGroup joinContextGroup(contextGroupId, target?)}
|
|
1736
|
+
* * {@link InteropClient#removeFromContextGroup removeFromContextGroup(target?)}
|
|
1737
|
+
* * {@link InteropClient#getInfoForContextGroup getInfoForContextGroup(contextGroupId)}
|
|
1738
|
+
* * {@link InteropClient#getAllClientsInContextGroup getAllClientsInContextGroup(contextGroupId)}
|
|
1739
|
+
*
|
|
1740
|
+
*/
|
|
1741
|
+
let InteropClient$1 = class InteropClient extends base_1.Base {
|
|
1742
|
+
/**
|
|
1743
|
+
* @internal
|
|
1744
|
+
*/
|
|
1745
|
+
constructor(wire, clientPromise) {
|
|
1746
|
+
super(wire);
|
|
1747
|
+
_InteropClient_clientPromise.set(this, void 0);
|
|
1748
|
+
_InteropClient_sessionContextGroups.set(this, void 0);
|
|
1749
|
+
__classPrivateFieldSet(this, _InteropClient_sessionContextGroups, new Map(), "f");
|
|
1750
|
+
__classPrivateFieldSet(this, _InteropClient_clientPromise, clientPromise, "f");
|
|
1751
|
+
}
|
|
1752
|
+
/*
|
|
1753
|
+
Client APIs
|
|
1754
|
+
*/
|
|
1755
|
+
/**
|
|
1756
|
+
* Sets a context for the context group of the current entity.
|
|
1757
|
+
*
|
|
1758
|
+
* @remarks The entity must be part of a context group in order set a context.
|
|
1759
|
+
*
|
|
1760
|
+
* @param context - New context to set.
|
|
1761
|
+
*
|
|
1762
|
+
* @example
|
|
1763
|
+
* ```js
|
|
1764
|
+
* setInstrumentContext = async (ticker) => {
|
|
1765
|
+
* fin.me.interop.setContext({type: 'instrument', id: {ticker}})
|
|
1766
|
+
* }
|
|
1767
|
+
*
|
|
1768
|
+
* // The user clicks an instrument of interest. We want to set that Instrument context so that the rest of our workflow updates with information for that instrument
|
|
1769
|
+
* instrumentElement.on('click', (evt) => {
|
|
1770
|
+
* setInstrumentContext(evt.ticker)
|
|
1771
|
+
* })
|
|
1772
|
+
* ```
|
|
1773
|
+
*/
|
|
1774
|
+
async setContext(context) {
|
|
1775
|
+
this.wire.sendAction('interop-client-set-context').catch((e) => {
|
|
1776
|
+
// don't expose, analytics-only call
|
|
1777
|
+
});
|
|
1778
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1779
|
+
return client.dispatch('setContext', { context });
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Add a context handler for incoming context. If an entity is part of a context group, and then sets its context handler,
|
|
1783
|
+
* it will receive all of its declared contexts.
|
|
1784
|
+
*
|
|
1785
|
+
* @param handler - Handler for incoming context.
|
|
1786
|
+
* @param contextType - The type of context you wish to handle.
|
|
1787
|
+
*
|
|
1788
|
+
* @example
|
|
1789
|
+
* ```js
|
|
1790
|
+
* function handleIncomingContext(contextInfo) {
|
|
1791
|
+
* const { type, id } = contextInfo;
|
|
1792
|
+
* switch (type) {
|
|
1793
|
+
* case 'instrument':
|
|
1794
|
+
* handleInstrumentContext(contextInfo);
|
|
1795
|
+
* break;
|
|
1796
|
+
* case 'country':
|
|
1797
|
+
* handleCountryContext(contextInfo);
|
|
1798
|
+
* break;
|
|
1799
|
+
*
|
|
1800
|
+
* default:
|
|
1801
|
+
* break;
|
|
1802
|
+
* }
|
|
1803
|
+
* }
|
|
1804
|
+
*
|
|
1805
|
+
*
|
|
1806
|
+
* function handleInstrumentContext(contextInfo) {
|
|
1807
|
+
* const { type, id } = contextInfo;
|
|
1808
|
+
* console.log('contextInfo for instrument', contextInfo)
|
|
1809
|
+
* }
|
|
1810
|
+
*
|
|
1811
|
+
* function handleCountryContext(contextInfo) {
|
|
1812
|
+
* const { type, id } = contextInfo;
|
|
1813
|
+
* console.log('contextInfo for country', contextInfo)
|
|
1814
|
+
* }
|
|
1815
|
+
*
|
|
1816
|
+
* fin.me.interop.addContextHandler(handleIncomingContext);
|
|
1817
|
+
* ```
|
|
1818
|
+
*
|
|
1819
|
+
*
|
|
1820
|
+
* Passing in a context type as the second parameter will cause the handler to only be invoked with that context type.
|
|
1821
|
+
*
|
|
1822
|
+
* ```js
|
|
1823
|
+
* function handleInstrumentContext(contextInfo) {
|
|
1824
|
+
* const { type, id } = contextInfo;
|
|
1825
|
+
* console.log('contextInfo for instrument', contextInfo)
|
|
1826
|
+
* }
|
|
1827
|
+
*
|
|
1828
|
+
* function handleCountryContext(contextInfo) {
|
|
1829
|
+
* const { type, id } = contextInfo;
|
|
1830
|
+
* console.log('contextInfo for country', contextInfo)
|
|
1831
|
+
* }
|
|
1832
|
+
*
|
|
1833
|
+
*
|
|
1834
|
+
* fin.me.interop.addContextHandler(handleInstrumentContext, 'instrument')
|
|
1835
|
+
* fin.me.interop.addContextHandler(handleCountryContext, 'country')
|
|
1836
|
+
* ```
|
|
1837
|
+
*/
|
|
1838
|
+
async addContextHandler(handler, contextType) {
|
|
1839
|
+
this.wire.sendAction('interop-client-add-context-handler').catch((e) => {
|
|
1840
|
+
// don't expose, analytics-only call
|
|
1841
|
+
});
|
|
1842
|
+
if (typeof handler !== 'function') {
|
|
1843
|
+
throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
|
|
1844
|
+
}
|
|
1845
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1846
|
+
let handlerId;
|
|
1847
|
+
if (contextType) {
|
|
1848
|
+
handlerId = `invokeContextHandler-${contextType}-${(0, utils_1.generateId)()}`;
|
|
1849
|
+
}
|
|
1850
|
+
else {
|
|
1851
|
+
handlerId = 'invokeContextHandler';
|
|
1852
|
+
}
|
|
1853
|
+
const wrappedHandler = (0, utils_1.wrapContextHandler)(handler, handlerId);
|
|
1854
|
+
client.register(handlerId, wrappedHandler);
|
|
1855
|
+
await client.dispatch('contextHandlerRegistered', { handlerId, contextType });
|
|
1856
|
+
return {
|
|
1857
|
+
unsubscribe: async () => {
|
|
1858
|
+
client.remove(handlerId);
|
|
1859
|
+
await client.dispatch('removeContextHandler', { handlerId });
|
|
1860
|
+
}
|
|
1861
|
+
};
|
|
1862
|
+
}
|
|
1863
|
+
/*
|
|
1864
|
+
Platform Window APIs
|
|
1865
|
+
*/
|
|
1866
|
+
/**
|
|
1867
|
+
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
1868
|
+
* Used by Platform Windows.
|
|
1869
|
+
*
|
|
1870
|
+
* @example
|
|
1871
|
+
* ```js
|
|
1872
|
+
* fin.me.interop.getContextGroups()
|
|
1873
|
+
* .then(contextGroups => {
|
|
1874
|
+
* contextGroups.forEach(contextGroup => {
|
|
1875
|
+
* console.log(contextGroup.displayMetadata.name)
|
|
1876
|
+
* console.log(contextGroup.displayMetadata.color)
|
|
1877
|
+
* })
|
|
1878
|
+
* })
|
|
1879
|
+
* ```
|
|
1880
|
+
*/
|
|
1881
|
+
async getContextGroups() {
|
|
1882
|
+
this.wire.sendAction('interop-client-get-context-groups').catch((e) => {
|
|
1883
|
+
// don't expose, analytics-only call
|
|
1884
|
+
});
|
|
1885
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1886
|
+
return client.dispatch('getContextGroups');
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* Join all Interop Clients at the given identity to context group `contextGroupId`.
|
|
1890
|
+
* If no target is specified, it adds the sender to the context group.
|
|
1891
|
+
*
|
|
1892
|
+
* @remarks Because multiple Channel connections/Interop Clients can potentially exist at a `uuid`/`name` combo, we currently join all Channel connections/Interop Clients at the given identity to the context group.
|
|
1893
|
+
* If an `endpointId` is provided (which is unlikely, unless the call is coming from an external adapter), then we only join that single connection to the context group.
|
|
1894
|
+
* For all intents and purposes, there will only be 1 connection present in Platform and Browser implmentations, so this point is more-or-less moot.
|
|
1895
|
+
* Used by Platform Windows.
|
|
1896
|
+
*
|
|
1897
|
+
* @param contextGroupId - Id of the context group.
|
|
1898
|
+
* @param target - Identity of the entity you wish to join to a context group.
|
|
1899
|
+
*
|
|
1900
|
+
* @example
|
|
1901
|
+
* ```js
|
|
1902
|
+
* joinViewToContextGroup = async (contextGroupId, view) => {
|
|
1903
|
+
* await fin.me.interop.joinContextGroup(contextGroupId, view);
|
|
1904
|
+
* }
|
|
1905
|
+
*
|
|
1906
|
+
* getLastFocusedView()
|
|
1907
|
+
* .then(lastFocusedViewIdentity => {
|
|
1908
|
+
* joinViewToContextGroup('red', lastFocusedViewIdentity)
|
|
1909
|
+
* })
|
|
1910
|
+
* ```
|
|
1911
|
+
*/
|
|
1912
|
+
async joinContextGroup(contextGroupId, target) {
|
|
1913
|
+
this.wire.sendAction('interop-client-join-context-group').catch((e) => {
|
|
1914
|
+
// don't expose, analytics-only call
|
|
1915
|
+
});
|
|
1916
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1917
|
+
if (!contextGroupId) {
|
|
1918
|
+
throw new Error('No contextGroupId specified for joinContextGroup.');
|
|
1919
|
+
}
|
|
1920
|
+
return client.dispatch('joinContextGroup', { contextGroupId, target });
|
|
1921
|
+
}
|
|
1922
|
+
/**
|
|
1923
|
+
* Removes the specified target from a context group.
|
|
1924
|
+
* If no target is specified, it removes the sender from their context group.
|
|
1925
|
+
* Used by Platform Windows.
|
|
1926
|
+
*
|
|
1927
|
+
* @param target - Identity of the entity you wish to join to a context group.
|
|
1928
|
+
*
|
|
1929
|
+
* @example
|
|
1930
|
+
* ```js
|
|
1931
|
+
* removeViewFromContextGroup = async (view) => {
|
|
1932
|
+
* await fin.me.interop.removeFromContextGroup(view);
|
|
1933
|
+
* }
|
|
1934
|
+
*
|
|
1935
|
+
* getLastFocusedView()
|
|
1936
|
+
* .then(lastFocusedViewIdentity => {
|
|
1937
|
+
* removeViewFromContextGroup(lastFocusedViewIdentity)
|
|
1938
|
+
* })
|
|
1939
|
+
* ```
|
|
1940
|
+
*/
|
|
1941
|
+
async removeFromContextGroup(target) {
|
|
1942
|
+
this.wire.sendAction('interop-client-remove-from-context-group').catch((e) => {
|
|
1943
|
+
// don't expose, analytics-only call
|
|
1944
|
+
});
|
|
1945
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1946
|
+
return client.dispatch('removeFromContextGroup', { target });
|
|
1947
|
+
}
|
|
1948
|
+
/**
|
|
1949
|
+
* Gets all clients for a context group.
|
|
1950
|
+
*
|
|
1951
|
+
* @remarks **This is primarily used for platform windows. Views within a platform should not have to use this API.**
|
|
1952
|
+
*
|
|
1953
|
+
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
1954
|
+
* @param contextGroupId - The id of context group you wish to get clients for.
|
|
1955
|
+
*
|
|
1956
|
+
* @example
|
|
1957
|
+
* ```js
|
|
1958
|
+
* fin.me.interop.getAllClientsInContextGroup('red')
|
|
1959
|
+
* .then(clientsInContextGroup => {
|
|
1960
|
+
* console.log(clientsInContextGroup)
|
|
1961
|
+
* })
|
|
1962
|
+
* ```
|
|
1963
|
+
*/
|
|
1964
|
+
async getAllClientsInContextGroup(contextGroupId) {
|
|
1965
|
+
this.wire.sendAction('interop-client-get-all-clients-in-context-group').catch((e) => {
|
|
1966
|
+
// don't expose, analytics-only call
|
|
1967
|
+
});
|
|
1968
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1969
|
+
if (!contextGroupId) {
|
|
1970
|
+
throw new Error('No contextGroupId specified for getAllClientsInContextGroup.');
|
|
1971
|
+
}
|
|
1972
|
+
return client.dispatch('getAllClientsInContextGroup', { contextGroupId });
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Gets display info for a context group
|
|
1976
|
+
*
|
|
1977
|
+
* @remarks Used by Platform Windows.
|
|
1978
|
+
* @param contextGroupId - The id of context group you wish to get display info for.
|
|
1979
|
+
*
|
|
1980
|
+
* @example
|
|
1981
|
+
* ```js
|
|
1982
|
+
* fin.me.interop.getInfoForContextGroup('red')
|
|
1983
|
+
* .then(contextGroupInfo => {
|
|
1984
|
+
* console.log(contextGroupInfo.displayMetadata.name)
|
|
1985
|
+
* console.log(contextGroupInfo.displayMetadata.color)
|
|
1986
|
+
* })
|
|
1987
|
+
* ```
|
|
1988
|
+
*/
|
|
1989
|
+
async getInfoForContextGroup(contextGroupId) {
|
|
1990
|
+
this.wire.sendAction('interop-client-get-info-for-context-group').catch((e) => {
|
|
1991
|
+
// don't expose, analytics-only call
|
|
1992
|
+
});
|
|
1993
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1994
|
+
if (!contextGroupId) {
|
|
1995
|
+
throw new Error('No contextGroupId specified for getInfoForContextGroup.');
|
|
1996
|
+
}
|
|
1997
|
+
return client.dispatch('getInfoForContextGroup', { contextGroupId });
|
|
1998
|
+
}
|
|
1999
|
+
/**
|
|
2000
|
+
* Sends an intent to the Interop Broker to resolve.
|
|
2001
|
+
* @param intent - The combination of an action and a context that is passed to an application for resolution.
|
|
2002
|
+
*
|
|
2003
|
+
* @example
|
|
2004
|
+
* ```js
|
|
2005
|
+
* // View wants to fire an Intent after a user clicks on a ticker
|
|
2006
|
+
* tickerElement.on('click', (element) => {
|
|
2007
|
+
* const ticker = element.innerText;
|
|
2008
|
+
* const intent = {
|
|
2009
|
+
* name: 'ViewChart',
|
|
2010
|
+
* context: {type: 'fdc3.instrument', id: { ticker }}
|
|
2011
|
+
* }
|
|
2012
|
+
*
|
|
2013
|
+
* fin.me.interop.fireIntent(intent);
|
|
2014
|
+
* })
|
|
2015
|
+
* ```
|
|
2016
|
+
*/
|
|
2017
|
+
async fireIntent(intent) {
|
|
2018
|
+
this.wire.sendAction('interop-client-fire-intent').catch((e) => {
|
|
2019
|
+
// don't expose, this is only for api analytics purposes
|
|
2020
|
+
});
|
|
2021
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2022
|
+
return client.dispatch('fireIntent', intent);
|
|
2023
|
+
}
|
|
2024
|
+
/**
|
|
2025
|
+
* Adds an intent handler for incoming intents. The last intent sent of the name subscribed to will be received.
|
|
2026
|
+
* @param handler - Registered function meant to handle a specific intent type.
|
|
2027
|
+
* @param intentName - The name of an intent.
|
|
2028
|
+
*
|
|
2029
|
+
* @example
|
|
2030
|
+
* ```js
|
|
2031
|
+
* const intentHandler = (intent) => {
|
|
2032
|
+
* const { context } = intent;
|
|
2033
|
+
* myViewChartHandler(context);
|
|
2034
|
+
* };
|
|
2035
|
+
*
|
|
2036
|
+
* const subscription = await fin.me.interop.registerIntentHandler(intentHandler, 'ViewChart');
|
|
2037
|
+
*
|
|
2038
|
+
* function myAppCloseSequence() {
|
|
2039
|
+
* // to unsubscribe the handler, simply call:
|
|
2040
|
+
* subscription.unsubscribe();
|
|
2041
|
+
* }
|
|
2042
|
+
* ```
|
|
2043
|
+
*/
|
|
2044
|
+
async registerIntentHandler(handler, intentName, options) {
|
|
2045
|
+
this.wire.sendAction('interop-client-register-intent-handler').catch((e) => {
|
|
2046
|
+
// don't expose, this is only for api analytics purposes
|
|
2047
|
+
});
|
|
2048
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2049
|
+
const handlerId = `intent-handler-${intentName}`;
|
|
2050
|
+
const wrappedHandler = (0, utils_1.wrapIntentHandler)(handler, handlerId);
|
|
2051
|
+
try {
|
|
2052
|
+
await client.register(handlerId, wrappedHandler);
|
|
2053
|
+
await client.dispatch('intentHandlerRegistered', { handlerId, ...options });
|
|
2054
|
+
}
|
|
2055
|
+
catch (error) {
|
|
2056
|
+
throw new Error('Unable to register intent handler');
|
|
2057
|
+
}
|
|
2058
|
+
return {
|
|
2059
|
+
unsubscribe: async () => {
|
|
2060
|
+
client.remove(handlerId);
|
|
2061
|
+
}
|
|
2062
|
+
};
|
|
2063
|
+
}
|
|
2064
|
+
/**
|
|
2065
|
+
* Gets the last context of the Context Group currently subscribed to. It takes an optional Context Type and returns the
|
|
2066
|
+
* last context of that type.
|
|
2067
|
+
* @param contextType
|
|
2068
|
+
*
|
|
2069
|
+
* @example
|
|
2070
|
+
* ```js
|
|
2071
|
+
* await fin.me.interop.joinContextGroup('yellow');
|
|
2072
|
+
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
|
2073
|
+
* const currentContext = await fin.me.interop.getCurrentContext();
|
|
2074
|
+
*
|
|
2075
|
+
* // with a specific context
|
|
2076
|
+
* await fin.me.interop.joinContextGroup('yellow');
|
|
2077
|
+
* await fin.me.interop.setContext({ type: 'country', id: { ISOALPHA3: 'US' }});
|
|
2078
|
+
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
|
2079
|
+
* const currentContext = await fin.me.interop.getCurrentContext('country');
|
|
2080
|
+
* ```
|
|
2081
|
+
*/
|
|
2082
|
+
async getCurrentContext(contextType) {
|
|
2083
|
+
this.wire.sendAction('interop-client-get-current-context').catch((e) => {
|
|
2084
|
+
// don't expose, analytics-only call
|
|
2085
|
+
});
|
|
2086
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2087
|
+
return client.dispatch('getCurrentContext', { contextType });
|
|
2088
|
+
}
|
|
2089
|
+
/**
|
|
2090
|
+
* Get information for a particular Intent from the Interop Broker.
|
|
2091
|
+
*
|
|
2092
|
+
* @remarks To resolve this info, the function handleInfoForIntent is meant to be overridden in the Interop Broker.
|
|
2093
|
+
* The format for the response will be determined by the App Provider overriding the function.
|
|
2094
|
+
*
|
|
2095
|
+
* @param options
|
|
2096
|
+
*
|
|
2097
|
+
* @example
|
|
2098
|
+
* ```js
|
|
2099
|
+
* const intentInfo = await fin.me.interop.getInfoForIntent('ViewChart');
|
|
2100
|
+
* ```
|
|
2101
|
+
*/
|
|
2102
|
+
async getInfoForIntent(options) {
|
|
2103
|
+
this.wire.sendAction('interop-client-get-info-for-intent').catch((e) => {
|
|
2104
|
+
// don't expose, analytics-only call
|
|
2105
|
+
});
|
|
2106
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2107
|
+
return client.dispatch('getInfoForIntent', options);
|
|
2108
|
+
}
|
|
2109
|
+
/**
|
|
2110
|
+
* Get information from the Interop Broker on all Intents that are meant to handle a particular context.
|
|
2111
|
+
*
|
|
2112
|
+
* @remarks To resolve this info, the function handleInfoForIntentsByContext is meant to be overridden in the Interop Broker.
|
|
2113
|
+
* The format for the response will be determined by the App Provider overriding the function.
|
|
2114
|
+
*
|
|
2115
|
+
* @param context
|
|
2116
|
+
*
|
|
2117
|
+
* @example
|
|
2118
|
+
* ```js
|
|
2119
|
+
* tickerElement.on('click', (element) => {
|
|
2120
|
+
* const ticker = element.innerText;
|
|
2121
|
+
*
|
|
2122
|
+
* const context = {
|
|
2123
|
+
* type: 'fdc3.instrument',
|
|
2124
|
+
* id: {
|
|
2125
|
+
* ticker
|
|
2126
|
+
* }
|
|
2127
|
+
* }
|
|
2128
|
+
*
|
|
2129
|
+
* const intentsInfo = await fin.me.interop.getInfoForIntentByContext(context);
|
|
2130
|
+
* })
|
|
2131
|
+
* ```
|
|
2132
|
+
*/
|
|
2133
|
+
async getInfoForIntentsByContext(context) {
|
|
2134
|
+
this.wire.sendAction('interop-client-get-info-for-intents-by-context').catch((e) => {
|
|
2135
|
+
// don't expose, analytics-only call
|
|
2136
|
+
});
|
|
2137
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2138
|
+
return client.dispatch('getInfoForIntentsByContext', context);
|
|
2139
|
+
}
|
|
2140
|
+
/**
|
|
2141
|
+
* Sends a Context that will be resolved to an Intent by the Interop Broker.
|
|
2142
|
+
* This context accepts a metadata property.
|
|
2143
|
+
*
|
|
2144
|
+
* @remarks To resolve this info, the function handleFiredIntentByContext is meant to be overridden in the Interop Broker.
|
|
2145
|
+
* The format for the response will be determined by the App Provider overriding the function.
|
|
2146
|
+
*
|
|
2147
|
+
* @param context
|
|
2148
|
+
*
|
|
2149
|
+
* @example
|
|
2150
|
+
* ```js
|
|
2151
|
+
* tickerElement.on('click', (element) => {
|
|
2152
|
+
* const ticker = element.innerText;
|
|
2153
|
+
*
|
|
2154
|
+
* const context = {
|
|
2155
|
+
* type: 'fdc3.instrument',
|
|
2156
|
+
* id: {
|
|
2157
|
+
* ticker
|
|
2158
|
+
* }
|
|
2159
|
+
* }
|
|
2160
|
+
*
|
|
2161
|
+
* const intentResolution = await fin.me.interop.fireIntentForContext(context);
|
|
2162
|
+
* })
|
|
2163
|
+
* ```
|
|
2164
|
+
*/
|
|
2165
|
+
async fireIntentForContext(context) {
|
|
2166
|
+
this.wire.sendAction('interop-client-fire-intent-for-context').catch((e) => {
|
|
2167
|
+
// don't expose, analytics-only call
|
|
2168
|
+
});
|
|
2169
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2170
|
+
return client.dispatch('fireIntentForContext', context);
|
|
2171
|
+
}
|
|
2172
|
+
/**
|
|
2173
|
+
* Join the current entity to session context group `sessionContextGroupId` and return a sessionContextGroup instance.
|
|
2174
|
+
* If the sessionContextGroup doesn't exist, one will get created.
|
|
2175
|
+
*
|
|
2176
|
+
* @remarks Session Context Groups do not persist between runs and aren't present on snapshots.
|
|
2177
|
+
* @param sessionContextGroupId - Id of the context group.
|
|
2178
|
+
*
|
|
2179
|
+
* @example
|
|
2180
|
+
* Say we want to have a Session Context Group that holds UI theme information for all apps to consume:
|
|
2181
|
+
*
|
|
2182
|
+
* My color-picker View:
|
|
2183
|
+
* ```js
|
|
2184
|
+
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
|
2185
|
+
*
|
|
2186
|
+
* const myColorPickerElement = document.getElementById('color-palette-picker');
|
|
2187
|
+
* myColorPickerElement.addEventListener('change', event => {
|
|
2188
|
+
* themeSessionContextGroup.setContext({ type: 'color-palette', selection: event.value });
|
|
2189
|
+
* });
|
|
2190
|
+
* ```
|
|
2191
|
+
*
|
|
2192
|
+
* In other views:
|
|
2193
|
+
* ```js
|
|
2194
|
+
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
|
2195
|
+
*
|
|
2196
|
+
* const changeColorPalette = ({ selection }) => {
|
|
2197
|
+
* // change the color palette to the selection
|
|
2198
|
+
* };
|
|
2199
|
+
*
|
|
2200
|
+
* // If the context is already set by the time the handler was set, the handler will get invoked immediately with the current context.
|
|
2201
|
+
* themeSessionContextGroup.addContextHandler(changeColorPalette, 'color-palette');
|
|
2202
|
+
* ```
|
|
2203
|
+
*/
|
|
2204
|
+
async joinSessionContextGroup(sessionContextGroupId) {
|
|
2205
|
+
try {
|
|
2206
|
+
const currentSessionContextGroup = __classPrivateFieldGet(this, _InteropClient_sessionContextGroups, "f").get(sessionContextGroupId);
|
|
2207
|
+
if (currentSessionContextGroup) {
|
|
2208
|
+
return currentSessionContextGroup.getUserInstance();
|
|
2209
|
+
}
|
|
2210
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2211
|
+
const { hasConflict } = await client.dispatch('sessionContextGroup:createIfNeeded', {
|
|
2212
|
+
sessionContextGroupId
|
|
2213
|
+
});
|
|
2214
|
+
if (hasConflict) {
|
|
2215
|
+
console.warn(`A (non-session) context group with the name "${sessionContextGroupId}" already exists. If you are trying to join a Context Group, call joinContextGroup instead.`);
|
|
2216
|
+
}
|
|
2217
|
+
const newSessionContextGroup = new SessionContextGroupClient_1.default(this.wire, __classPrivateFieldGet(this, _InteropClient_clientPromise, "f"), sessionContextGroupId);
|
|
2218
|
+
__classPrivateFieldGet(this, _InteropClient_sessionContextGroups, "f").set(sessionContextGroupId, newSessionContextGroup);
|
|
2219
|
+
return newSessionContextGroup.getUserInstance();
|
|
2220
|
+
}
|
|
2221
|
+
catch (error) {
|
|
2222
|
+
console.error(`Error thrown trying to create Session Context Group with id "${sessionContextGroupId}": ${error}`);
|
|
2223
|
+
throw error;
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
/**
|
|
2227
|
+
* Register a listener that is called when the Interop Client has been disconnected from the Interop Broker.
|
|
2228
|
+
* Only one listener per Interop Client can be set.
|
|
2229
|
+
* @param listener
|
|
2230
|
+
*
|
|
2231
|
+
* @example
|
|
2232
|
+
* ```js
|
|
2233
|
+
* const listener = (event) => {
|
|
2234
|
+
* const { type, topic, brokerName} = event;
|
|
2235
|
+
* console.log(`Disconnected from Interop Broker ${brokerName} `);
|
|
2236
|
+
* }
|
|
2237
|
+
*
|
|
2238
|
+
* await fin.me.interop.onDisconnection(listener);
|
|
2239
|
+
* ```
|
|
2240
|
+
*/
|
|
2241
|
+
async onDisconnection(listener) {
|
|
2242
|
+
this.wire.sendAction('interop-client-add-ondisconnection-listener').catch((e) => {
|
|
2243
|
+
// don't expose, analytics-only call
|
|
2244
|
+
});
|
|
2245
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2246
|
+
return client.onDisconnection((event) => {
|
|
2247
|
+
const { uuid } = event;
|
|
2248
|
+
listener({ type: 'interop-broker', topic: 'disconnected', brokerName: uuid });
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
getFDC3Sync(version) {
|
|
2252
|
+
switch (version) {
|
|
2253
|
+
case '1.2':
|
|
2254
|
+
return new fdc3_1_2_1.Fdc3Module(() => this, this.wire);
|
|
2255
|
+
case '2.0':
|
|
2256
|
+
return new fdc3_2_0_1.Fdc3Module2(() => this, this.wire);
|
|
2257
|
+
default:
|
|
2258
|
+
throw new Error(`Invalid FDC3 version provided: ${version}. Must be '1.2' or '2.0'`);
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
async getFDC3(version) {
|
|
2262
|
+
return this.getFDC3Sync(version);
|
|
2263
|
+
}
|
|
2264
|
+
/**
|
|
2265
|
+
* @internal
|
|
2266
|
+
*
|
|
2267
|
+
* Used to ferry fdc3-only calls from the fdc3 shim to the Interop Broker
|
|
2268
|
+
*/
|
|
2269
|
+
static async ferryFdc3Call(interopClient, action, payload) {
|
|
2270
|
+
const client = await __classPrivateFieldGet(interopClient, _InteropClient_clientPromise, "f");
|
|
2271
|
+
return client.dispatch(action, payload || null);
|
|
2272
|
+
}
|
|
2273
|
+
};
|
|
2274
|
+
InteropClient.InteropClient = InteropClient$1;
|
|
2275
|
+
_InteropClient_clientPromise = new WeakMap(), _InteropClient_sessionContextGroups = new WeakMap();
|
|
2276
|
+
return InteropClient;
|
|
2277
|
+
}
|
|
1118
2278
|
|
|
1119
2279
|
var commonUtils = {};
|
|
1120
2280
|
|
|
@@ -1145,11 +2305,11 @@ function requireFactory$3 () {
|
|
|
1145
2305
|
hasRequiredFactory$3 = 1;
|
|
1146
2306
|
Object.defineProperty(Factory$8, "__esModule", { value: true });
|
|
1147
2307
|
Factory$8.InteropModule = void 0;
|
|
1148
|
-
const lodash_1 = require$$
|
|
2308
|
+
const lodash_1 = require$$3;
|
|
1149
2309
|
const inaccessibleObject_1 = inaccessibleObject;
|
|
1150
2310
|
const base_1 = base;
|
|
1151
2311
|
const InteropBroker_1 = requireInteropBroker();
|
|
1152
|
-
const InteropClient_1 =
|
|
2312
|
+
const InteropClient_1 = requireInteropClient();
|
|
1153
2313
|
const overrideCheck_1 = requireOverrideCheck();
|
|
1154
2314
|
const common_utils_1 = commonUtils;
|
|
1155
2315
|
const defaultOverride = (Class) => new Class();
|
|
@@ -1183,12 +2343,8 @@ function requireFactory$3 () {
|
|
|
1183
2343
|
const options = await this.wire.environment.getInteropInfo(this.wire.getFin());
|
|
1184
2344
|
const objectThatThrows = (0, inaccessibleObject_1.createUnusableObject)(BrokerParamAccessError);
|
|
1185
2345
|
const warningOptsClone = (0, inaccessibleObject_1.createWarningObject)(BrokerParamAccessError, (0, lodash_1.cloneDeep)(options));
|
|
1186
|
-
let provider;
|
|
1187
2346
|
const getProvider = () => {
|
|
1188
|
-
|
|
1189
|
-
provider = this.fin.InterApplicationBus.Channel.create(`interop-broker-${name}`);
|
|
1190
|
-
}
|
|
1191
|
-
return provider;
|
|
2347
|
+
return this.fin.InterApplicationBus.Channel.create(`interop-broker-${name}`);
|
|
1192
2348
|
};
|
|
1193
2349
|
const throwingGetProvider = async () => {
|
|
1194
2350
|
// eslint-disable-next-line no-console
|
|
@@ -1234,7 +2390,11 @@ function requireFactory$3 () {
|
|
|
1234
2390
|
this.wire.sendAction('interop-connect-sync').catch(() => {
|
|
1235
2391
|
// don't expose, analytics-only call
|
|
1236
2392
|
});
|
|
1237
|
-
return new InteropClient_1.InteropClient(this.wire,
|
|
2393
|
+
return new InteropClient_1.InteropClient(this.wire, this.wire.environment.whenReady().then(() => {
|
|
2394
|
+
return this.fin.InterApplicationBus.Channel.connect(`interop-broker-${name}`, {
|
|
2395
|
+
payload: interopConfig
|
|
2396
|
+
});
|
|
2397
|
+
}));
|
|
1238
2398
|
}
|
|
1239
2399
|
}
|
|
1240
2400
|
Factory$8.InteropModule = InteropModule;
|
|
@@ -1271,7 +2431,7 @@ function requireInterop () {
|
|
|
1271
2431
|
};
|
|
1272
2432
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1273
2433
|
__exportStar(requireFactory$3(), exports);
|
|
1274
|
-
__exportStar(
|
|
2434
|
+
__exportStar(requireInteropClient(), exports);
|
|
1275
2435
|
__exportStar(requireInteropBroker(), exports);
|
|
1276
2436
|
} (interop));
|
|
1277
2437
|
return interop;
|
|
@@ -1676,6 +2836,62 @@ function requirePrivateChannelProvider () {
|
|
|
1676
2836
|
return PrivateChannelProvider;
|
|
1677
2837
|
}
|
|
1678
2838
|
|
|
2839
|
+
var lazy = {};
|
|
2840
|
+
|
|
2841
|
+
Object.defineProperty(lazy, "__esModule", { value: true });
|
|
2842
|
+
lazy.AsyncRetryableLazy = lazy.Lazy = void 0;
|
|
2843
|
+
/**
|
|
2844
|
+
* Handy class for managing asynchronous dependencies of classes.
|
|
2845
|
+
*
|
|
2846
|
+
* Will call the producer function once and only once when getValue is called,
|
|
2847
|
+
* returning the resultant value for every subsequent call.
|
|
2848
|
+
*/
|
|
2849
|
+
class Lazy {
|
|
2850
|
+
// eslint-disable-next-line
|
|
2851
|
+
constructor(producerFn) {
|
|
2852
|
+
this.producerFn = producerFn;
|
|
2853
|
+
}
|
|
2854
|
+
/**
|
|
2855
|
+
* Lazily get the value returned by the producer.
|
|
2856
|
+
* @returns The value returned from the producer function
|
|
2857
|
+
*/
|
|
2858
|
+
getValue() {
|
|
2859
|
+
if (!this.value) {
|
|
2860
|
+
this.value = this.producerFn();
|
|
2861
|
+
}
|
|
2862
|
+
return this.value;
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
lazy.Lazy = Lazy;
|
|
2866
|
+
/**
|
|
2867
|
+
* Handy class for managing asynchronous dependencies of classes.
|
|
2868
|
+
*
|
|
2869
|
+
* Will call asynchronous producer only after `getValue` is called. If the
|
|
2870
|
+
* deferred code errors, we can try it again by re-calling `getValue` after
|
|
2871
|
+
* the promise rejects.
|
|
2872
|
+
*/
|
|
2873
|
+
class AsyncRetryableLazy {
|
|
2874
|
+
// eslint-disable-next-line
|
|
2875
|
+
constructor(producerFn) {
|
|
2876
|
+
this.producerFn = producerFn;
|
|
2877
|
+
}
|
|
2878
|
+
/**
|
|
2879
|
+
* Lazily get the value returned by the async producer.
|
|
2880
|
+
*
|
|
2881
|
+
* @returns The value returned from the producer function
|
|
2882
|
+
*/
|
|
2883
|
+
async getValue() {
|
|
2884
|
+
if (!this.promise) {
|
|
2885
|
+
this.promise = this.producerFn().catch((e) => {
|
|
2886
|
+
delete this.promise;
|
|
2887
|
+
throw e;
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2890
|
+
return this.promise;
|
|
2891
|
+
}
|
|
2892
|
+
}
|
|
2893
|
+
lazy.AsyncRetryableLazy = AsyncRetryableLazy;
|
|
2894
|
+
|
|
1679
2895
|
var hasRequiredInteropBroker;
|
|
1680
2896
|
|
|
1681
2897
|
function requireInteropBroker () {
|
|
@@ -1692,14 +2908,15 @@ function requireInteropBroker () {
|
|
|
1692
2908
|
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");
|
|
1693
2909
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1694
2910
|
};
|
|
1695
|
-
var _InteropBroker_fdc3Info, _InteropBroker_contextGroups;
|
|
2911
|
+
var _InteropBroker_fdc3Info, _InteropBroker_contextGroups, _InteropBroker_providerPromise;
|
|
1696
2912
|
Object.defineProperty(InteropBroker, "__esModule", { value: true });
|
|
1697
2913
|
InteropBroker.InteropBroker = void 0;
|
|
1698
2914
|
const base_1 = base;
|
|
1699
2915
|
const SessionContextGroupBroker_1 = requireSessionContextGroupBroker();
|
|
1700
|
-
const utils_1 = utils$
|
|
1701
|
-
const lodash_1 = require$$
|
|
2916
|
+
const utils_1 = utils$3;
|
|
2917
|
+
const lodash_1 = require$$3;
|
|
1702
2918
|
const PrivateChannelProvider_1 = requirePrivateChannelProvider();
|
|
2919
|
+
const lazy_1 = lazy;
|
|
1703
2920
|
const defaultContextGroups = [
|
|
1704
2921
|
{
|
|
1705
2922
|
id: 'green',
|
|
@@ -1867,12 +3084,15 @@ function requireInteropBroker () {
|
|
|
1867
3084
|
/**
|
|
1868
3085
|
* @internal
|
|
1869
3086
|
*/
|
|
1870
|
-
constructor(wire,
|
|
3087
|
+
constructor(wire, createProvider, options) {
|
|
1871
3088
|
// Tip from Pierre and Michael from the overrideCheck work: Don't use bound methods for overrideable InteropBroker functions.
|
|
1872
3089
|
super(wire);
|
|
1873
|
-
this.getProvider = getProvider;
|
|
1874
3090
|
_InteropBroker_fdc3Info.set(this, void 0);
|
|
1875
3091
|
_InteropBroker_contextGroups.set(this, void 0);
|
|
3092
|
+
_InteropBroker_providerPromise.set(this, void 0);
|
|
3093
|
+
this.getProvider = () => {
|
|
3094
|
+
return __classPrivateFieldGet(this, _InteropBroker_providerPromise, "f").getValue();
|
|
3095
|
+
};
|
|
1876
3096
|
this.interopClients = new Map();
|
|
1877
3097
|
this.contextGroupsById = new Map();
|
|
1878
3098
|
__classPrivateFieldSet(this, _InteropBroker_contextGroups, options.contextGroups ?? [...defaultContextGroups], "f");
|
|
@@ -1883,6 +3103,7 @@ function requireInteropBroker () {
|
|
|
1883
3103
|
this.intentClientMap = new Map();
|
|
1884
3104
|
this.lastContextMap = new Map();
|
|
1885
3105
|
this.sessionContextGroupMap = new Map();
|
|
3106
|
+
__classPrivateFieldSet(this, _InteropBroker_providerPromise, new lazy_1.Lazy(createProvider), "f");
|
|
1886
3107
|
this.setContextGroupMap();
|
|
1887
3108
|
this.setupChannelProvider();
|
|
1888
3109
|
}
|
|
@@ -2966,7 +4187,7 @@ function requireInteropBroker () {
|
|
|
2966
4187
|
}
|
|
2967
4188
|
};
|
|
2968
4189
|
InteropBroker.InteropBroker = InteropBroker$1;
|
|
2969
|
-
_InteropBroker_fdc3Info = new WeakMap(), _InteropBroker_contextGroups = new WeakMap();
|
|
4190
|
+
_InteropBroker_fdc3Info = new WeakMap(), _InteropBroker_contextGroups = new WeakMap(), _InteropBroker_providerPromise = new WeakMap();
|
|
2970
4191
|
return InteropBroker;
|
|
2971
4192
|
}
|
|
2972
4193
|
|
|
@@ -3239,7 +4460,7 @@ var emitterMap = {};
|
|
|
3239
4460
|
|
|
3240
4461
|
Object.defineProperty(emitterMap, "__esModule", { value: true });
|
|
3241
4462
|
emitterMap.EmitterMap = void 0;
|
|
3242
|
-
const events_1$6 = require$$0
|
|
4463
|
+
const events_1$6 = require$$0;
|
|
3243
4464
|
class EmitterMap {
|
|
3244
4465
|
constructor() {
|
|
3245
4466
|
this.storage = new Map();
|
|
@@ -3497,62 +4718,6 @@ function requireFactory$2 () {
|
|
|
3497
4718
|
|
|
3498
4719
|
var Instance$7 = {};
|
|
3499
4720
|
|
|
3500
|
-
var lazy = {};
|
|
3501
|
-
|
|
3502
|
-
Object.defineProperty(lazy, "__esModule", { value: true });
|
|
3503
|
-
lazy.AsyncRetryableLazy = lazy.Lazy = void 0;
|
|
3504
|
-
/**
|
|
3505
|
-
* Handy class for managing asynchronous dependencies of classes.
|
|
3506
|
-
*
|
|
3507
|
-
* Will call the producer function once and only once when getValue is called,
|
|
3508
|
-
* returning the resultant value for every subsequent call.
|
|
3509
|
-
*/
|
|
3510
|
-
class Lazy {
|
|
3511
|
-
// eslint-disable-next-line
|
|
3512
|
-
constructor(producerFn) {
|
|
3513
|
-
this.producerFn = producerFn;
|
|
3514
|
-
}
|
|
3515
|
-
/**
|
|
3516
|
-
* Lazily get the value returned by the producer.
|
|
3517
|
-
* @returns The value returned from the producer function
|
|
3518
|
-
*/
|
|
3519
|
-
getValue() {
|
|
3520
|
-
if (!this.value) {
|
|
3521
|
-
this.value = this.producerFn();
|
|
3522
|
-
}
|
|
3523
|
-
return this.value;
|
|
3524
|
-
}
|
|
3525
|
-
}
|
|
3526
|
-
lazy.Lazy = Lazy;
|
|
3527
|
-
/**
|
|
3528
|
-
* Handy class for managing asynchronous dependencies of classes.
|
|
3529
|
-
*
|
|
3530
|
-
* Will call asynchronous producer only after `getValue` is called. If the
|
|
3531
|
-
* deferred code errors, we can try it again by re-calling `getValue` after
|
|
3532
|
-
* the promise rejects.
|
|
3533
|
-
*/
|
|
3534
|
-
class AsyncRetryableLazy {
|
|
3535
|
-
// eslint-disable-next-line
|
|
3536
|
-
constructor(producerFn) {
|
|
3537
|
-
this.producerFn = producerFn;
|
|
3538
|
-
}
|
|
3539
|
-
/**
|
|
3540
|
-
* Lazily get the value returned by the async producer.
|
|
3541
|
-
*
|
|
3542
|
-
* @returns The value returned from the producer function
|
|
3543
|
-
*/
|
|
3544
|
-
async getValue() {
|
|
3545
|
-
if (!this.promise) {
|
|
3546
|
-
this.promise = this.producerFn().catch((e) => {
|
|
3547
|
-
delete this.promise;
|
|
3548
|
-
throw e;
|
|
3549
|
-
});
|
|
3550
|
-
}
|
|
3551
|
-
return this.promise;
|
|
3552
|
-
}
|
|
3553
|
-
}
|
|
3554
|
-
lazy.AsyncRetryableLazy = AsyncRetryableLazy;
|
|
3555
|
-
|
|
3556
4721
|
var layoutEntities = {};
|
|
3557
4722
|
|
|
3558
4723
|
var apiExposer$1 = {};
|
|
@@ -6430,6 +7595,37 @@ function requireApplication () {
|
|
|
6430
7595
|
return application;
|
|
6431
7596
|
}
|
|
6432
7597
|
|
|
7598
|
+
var promisifySubscription$1 = {};
|
|
7599
|
+
|
|
7600
|
+
Object.defineProperty(promisifySubscription$1, "__esModule", { value: true });
|
|
7601
|
+
promisifySubscription$1.promisifySubscription = void 0;
|
|
7602
|
+
const promisifySubscription = async (emitter, eventName, predicate = () => true, timeout) => {
|
|
7603
|
+
let resolve;
|
|
7604
|
+
let reject;
|
|
7605
|
+
let timer;
|
|
7606
|
+
const valuePromise = new Promise((y, n) => {
|
|
7607
|
+
resolve = y;
|
|
7608
|
+
reject = n;
|
|
7609
|
+
});
|
|
7610
|
+
const listener = (e) => {
|
|
7611
|
+
if (predicate(e)) {
|
|
7612
|
+
clearTimeout(timer);
|
|
7613
|
+
resolve(e);
|
|
7614
|
+
}
|
|
7615
|
+
};
|
|
7616
|
+
await emitter.on(eventName, listener);
|
|
7617
|
+
if (timeout) {
|
|
7618
|
+
timer = setTimeout(() => reject(new Error('event timed out')), timeout);
|
|
7619
|
+
}
|
|
7620
|
+
valuePromise.finally(() => {
|
|
7621
|
+
emitter.removeListener(eventName, listener).catch(() => null);
|
|
7622
|
+
});
|
|
7623
|
+
return {
|
|
7624
|
+
getValue: () => valuePromise
|
|
7625
|
+
};
|
|
7626
|
+
};
|
|
7627
|
+
promisifySubscription$1.promisifySubscription = promisifySubscription;
|
|
7628
|
+
|
|
6433
7629
|
var hasRequiredInstance$1;
|
|
6434
7630
|
|
|
6435
7631
|
function requireInstance$1 () {
|
|
@@ -6445,6 +7641,7 @@ function requireInstance$1 () {
|
|
|
6445
7641
|
const main_1 = main;
|
|
6446
7642
|
const view_1 = requireView();
|
|
6447
7643
|
const warnings_1 = warnings;
|
|
7644
|
+
const promisifySubscription_1 = promisifySubscription$1;
|
|
6448
7645
|
/**
|
|
6449
7646
|
* A basic window that wraps a native HTML window. Provides more fine-grained
|
|
6450
7647
|
* control over the window state such as the ability to minimize, maximize, restore, etc.
|
|
@@ -6460,79 +7657,60 @@ function requireInstance$1 () {
|
|
|
6460
7657
|
constructor(wire, identity) {
|
|
6461
7658
|
super(wire, identity, 'window');
|
|
6462
7659
|
}
|
|
6463
|
-
|
|
6464
|
-
* create a new window
|
|
6465
|
-
* @internal
|
|
6466
|
-
*/
|
|
6467
|
-
createWindow(options) {
|
|
7660
|
+
async createWindow(options) {
|
|
6468
7661
|
this.wire.sendAction('window-create-window', this.identity).catch((e) => {
|
|
6469
7662
|
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
6470
7663
|
});
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
try {
|
|
6522
|
-
// this is to enforce a 5.0 contract that the child's main function
|
|
6523
|
-
// will not fire before the parent's success callback on creation.
|
|
6524
|
-
// if the child window is not accessible (CORS) this contract does
|
|
6525
|
-
// not hold.
|
|
6526
|
-
const webWindow = this.getWebWindow();
|
|
6527
|
-
webWindow.fin.__internal_.openerSuccessCBCalled();
|
|
6528
|
-
}
|
|
6529
|
-
catch (e) {
|
|
6530
|
-
// common for main windows, we do not want to expose this error. here just to have a debug target.
|
|
6531
|
-
// console.error(e);
|
|
6532
|
-
}
|
|
6533
|
-
})
|
|
6534
|
-
.catch(reject);
|
|
6535
|
-
});
|
|
7664
|
+
const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
|
|
7665
|
+
const responseSubscription = await (0, promisifySubscription_1.promisifySubscription)(this, CONSTRUCTOR_CB_TOPIC);
|
|
7666
|
+
// set defaults:
|
|
7667
|
+
if (options.waitForPageLoad === undefined) {
|
|
7668
|
+
options.waitForPageLoad = false;
|
|
7669
|
+
}
|
|
7670
|
+
if (options.autoShow === undefined) {
|
|
7671
|
+
options.autoShow = true;
|
|
7672
|
+
}
|
|
7673
|
+
(0, warnings_1.handleDeprecatedWarnings)(options);
|
|
7674
|
+
const windowCreation = this.wire.environment.createChildContent({ entityType: 'window', options });
|
|
7675
|
+
const [response] = await Promise.all([responseSubscription.getValue(), windowCreation]);
|
|
7676
|
+
let cbPayload;
|
|
7677
|
+
const { success } = response;
|
|
7678
|
+
const responseData = response.data;
|
|
7679
|
+
const { message } = responseData;
|
|
7680
|
+
if (success) {
|
|
7681
|
+
cbPayload = {
|
|
7682
|
+
httpResponseCode: responseData.httpResponseCode,
|
|
7683
|
+
apiInjected: responseData.apiInjected
|
|
7684
|
+
};
|
|
7685
|
+
}
|
|
7686
|
+
else {
|
|
7687
|
+
cbPayload = {
|
|
7688
|
+
message: responseData.message,
|
|
7689
|
+
networkErrorCode: responseData.networkErrorCode,
|
|
7690
|
+
stack: responseData.stack
|
|
7691
|
+
};
|
|
7692
|
+
}
|
|
7693
|
+
const pageResolve = {
|
|
7694
|
+
message,
|
|
7695
|
+
cbPayload,
|
|
7696
|
+
success
|
|
7697
|
+
};
|
|
7698
|
+
try {
|
|
7699
|
+
// this is to enforce a 5.0 contract that the child's main function
|
|
7700
|
+
// will not fire before the parent's success callback on creation.
|
|
7701
|
+
// if the child window is not accessible (CORS) this contract does
|
|
7702
|
+
// not hold.
|
|
7703
|
+
const webWindow = this.getWebWindow();
|
|
7704
|
+
webWindow.fin.__internal_.openerSuccessCBCalled();
|
|
7705
|
+
}
|
|
7706
|
+
catch (e) {
|
|
7707
|
+
// common for main windows, we do not want to expose this error. here just to have a debug target.
|
|
7708
|
+
// console.error(e);
|
|
7709
|
+
}
|
|
7710
|
+
if (pageResolve.success) {
|
|
7711
|
+
return this;
|
|
7712
|
+
}
|
|
7713
|
+
return Promise.reject(pageResolve);
|
|
6536
7714
|
}
|
|
6537
7715
|
/**
|
|
6538
7716
|
* Retrieves an array of frame info objects representing the main frame and any
|
|
@@ -8997,7 +10175,7 @@ var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateF
|
|
|
8997
10175
|
var _Transport_wire, _Transport_fin;
|
|
8998
10176
|
Object.defineProperty(transport, "__esModule", { value: true });
|
|
8999
10177
|
var Transport_1 = transport.Transport = void 0;
|
|
9000
|
-
const events_1$5 = require$$0
|
|
10178
|
+
const events_1$5 = require$$0;
|
|
9001
10179
|
const wire_1 = wire;
|
|
9002
10180
|
const transport_errors_1$2 = transportErrors;
|
|
9003
10181
|
const eventAggregator_1 = eventAggregator;
|
|
@@ -9214,7 +10392,7 @@ _Transport_wire = new WeakMap(), _Transport_fin = new WeakMap();
|
|
|
9214
10392
|
var websocket = {};
|
|
9215
10393
|
|
|
9216
10394
|
Object.defineProperty(websocket, "__esModule", { value: true });
|
|
9217
|
-
const events_1$4 = require$$0
|
|
10395
|
+
const events_1$4 = require$$0;
|
|
9218
10396
|
const transport_errors_1$1 = transportErrors;
|
|
9219
10397
|
const messageReceiver_1 = bridge.messageReceiver;
|
|
9220
10398
|
/* `READY_STATE` is an instance var set by `constructor` to reference the `WebTransportSocket.READY_STATE` enum.
|
|
@@ -9291,7 +10469,7 @@ system.System = void 0;
|
|
|
9291
10469
|
const base_1$d = base;
|
|
9292
10470
|
const transport_errors_1 = transportErrors;
|
|
9293
10471
|
const window_1 = requireWindow();
|
|
9294
|
-
const events_1$3 = require$$0
|
|
10472
|
+
const events_1$3 = require$$0;
|
|
9295
10473
|
/**
|
|
9296
10474
|
* An object representing the core of OpenFin Runtime. Allows the developer
|
|
9297
10475
|
* to perform system-level actions, such as accessing logs, viewing processes,
|
|
@@ -11204,9 +12382,10 @@ class ProtectedItems {
|
|
|
11204
12382
|
/**
|
|
11205
12383
|
* @internal
|
|
11206
12384
|
*/
|
|
11207
|
-
|
|
12385
|
+
// eslint-disable-next-line no-useless-constructor
|
|
12386
|
+
constructor(providerIdentity, close) {
|
|
11208
12387
|
this.providerIdentity = providerIdentity;
|
|
11209
|
-
this.
|
|
12388
|
+
this.close = close;
|
|
11210
12389
|
}
|
|
11211
12390
|
}
|
|
11212
12391
|
channel.ProtectedItems = ProtectedItems;
|
|
@@ -11593,7 +12772,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
11593
12772
|
/**
|
|
11594
12773
|
* @internal
|
|
11595
12774
|
*/
|
|
11596
|
-
constructor(routingInfo,
|
|
12775
|
+
constructor(routingInfo, close, strategy) {
|
|
11597
12776
|
super();
|
|
11598
12777
|
_ChannelClient_protectedObj.set(this, void 0);
|
|
11599
12778
|
_ChannelClient_strategy.set(this, void 0);
|
|
@@ -11603,7 +12782,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
11603
12782
|
channelClientsByEndpointId.delete(this.endpointId);
|
|
11604
12783
|
__classPrivateFieldGet$a(this, _ChannelClient_strategy, "f").close();
|
|
11605
12784
|
});
|
|
11606
|
-
__classPrivateFieldSet$8(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo,
|
|
12785
|
+
__classPrivateFieldSet$8(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
|
|
11607
12786
|
this.disconnectListener = () => undefined;
|
|
11608
12787
|
this.endpointId = routingInfo.endpointId;
|
|
11609
12788
|
__classPrivateFieldSet$8(this, _ChannelClient_strategy, strategy, "f");
|
|
@@ -11698,12 +12877,19 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
11698
12877
|
}
|
|
11699
12878
|
async sendDisconnectAction() {
|
|
11700
12879
|
const protectedObj = __classPrivateFieldGet$a(this, _ChannelClient_protectedObj, "f");
|
|
11701
|
-
|
|
11702
|
-
|
|
12880
|
+
await protectedObj.close();
|
|
12881
|
+
}
|
|
12882
|
+
/**
|
|
12883
|
+
* @internal
|
|
12884
|
+
* Writing this as a static to keep code together, but in environments with a wire, this will be DI'd into the protectedObject class as close.
|
|
12885
|
+
*/
|
|
12886
|
+
static async wireClose(wire, providerIdentity, endpointId) {
|
|
12887
|
+
const { channelName, uuid, name } = providerIdentity;
|
|
12888
|
+
await wire.sendAction('disconnect-from-channel', {
|
|
11703
12889
|
channelName,
|
|
11704
12890
|
uuid,
|
|
11705
12891
|
name,
|
|
11706
|
-
endpointId
|
|
12892
|
+
endpointId
|
|
11707
12893
|
});
|
|
11708
12894
|
}
|
|
11709
12895
|
}
|
|
@@ -12299,7 +13485,7 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
12299
13485
|
/**
|
|
12300
13486
|
* @internal
|
|
12301
13487
|
*/
|
|
12302
|
-
constructor(providerIdentity,
|
|
13488
|
+
constructor(providerIdentity, close, strategy) {
|
|
12303
13489
|
super();
|
|
12304
13490
|
_ChannelProvider_connections.set(this, void 0);
|
|
12305
13491
|
_ChannelProvider_protectedObj.set(this, void 0);
|
|
@@ -12327,7 +13513,7 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
12327
13513
|
remove();
|
|
12328
13514
|
}
|
|
12329
13515
|
});
|
|
12330
|
-
__classPrivateFieldSet$4(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity,
|
|
13516
|
+
__classPrivateFieldSet$4(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
|
|
12331
13517
|
this.connectListener = () => undefined;
|
|
12332
13518
|
this.disconnectListener = () => undefined;
|
|
12333
13519
|
__classPrivateFieldSet$4(this, _ChannelProvider_connections, [], "f");
|
|
@@ -12466,9 +13652,9 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
12466
13652
|
*/
|
|
12467
13653
|
async destroy() {
|
|
12468
13654
|
const protectedObj = __classPrivateFieldGet$6(this, _ChannelProvider_protectedObj, "f");
|
|
12469
|
-
|
|
13655
|
+
protectedObj.providerIdentity;
|
|
12470
13656
|
__classPrivateFieldSet$4(this, _ChannelProvider_connections, [], "f");
|
|
12471
|
-
await protectedObj.
|
|
13657
|
+
await protectedObj.close();
|
|
12472
13658
|
__classPrivateFieldGet$6(this, _ChannelProvider_close, "f").call(this);
|
|
12473
13659
|
}
|
|
12474
13660
|
/**
|
|
@@ -12560,6 +13746,9 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
12560
13746
|
static clientIsMultiRuntime(subscriptionIdentity) {
|
|
12561
13747
|
return subscriptionIdentity.runtimeUuid !== undefined;
|
|
12562
13748
|
}
|
|
13749
|
+
static async wireClose(wire, channelName) {
|
|
13750
|
+
await wire.sendAction('destroy-channel', { channelName });
|
|
13751
|
+
}
|
|
12563
13752
|
}
|
|
12564
13753
|
provider.ChannelProvider = ChannelProvider;
|
|
12565
13754
|
_ChannelProvider_connections = new WeakMap(), _ChannelProvider_protectedObj = new WeakMap(), _ChannelProvider_strategy = new WeakMap(), _ChannelProvider_removeEndpoint = new WeakMap(), _ChannelProvider_close = new WeakMap();
|
|
@@ -12829,7 +14018,7 @@ class ConnectionManager extends base_1$a.Base {
|
|
|
12829
14018
|
// Should be impossible.
|
|
12830
14019
|
throw new Error('failed to combine strategies');
|
|
12831
14020
|
}
|
|
12832
|
-
const channel = new provider_1$1.ChannelProvider(providerIdentity, this.wire, strategy);
|
|
14021
|
+
const channel = new provider_1$1.ChannelProvider(providerIdentity, () => provider_1$1.ChannelProvider.wireClose(this.wire, providerIdentity.channelName), strategy);
|
|
12833
14022
|
const key = providerIdentity.channelId;
|
|
12834
14023
|
this.providerMap.set(key, {
|
|
12835
14024
|
provider: channel,
|
|
@@ -13014,7 +14203,7 @@ var _Channel_connectionManager, _Channel_internalEmitter, _Channel_readyToConnec
|
|
|
13014
14203
|
Object.defineProperty(channel$1, "__esModule", { value: true });
|
|
13015
14204
|
channel$1.Channel = void 0;
|
|
13016
14205
|
/* eslint-disable no-console */
|
|
13017
|
-
const events_1$2 = require$$0
|
|
14206
|
+
const events_1$2 = require$$0;
|
|
13018
14207
|
const lazy_1$1 = lazy;
|
|
13019
14208
|
const base_1$9 = base;
|
|
13020
14209
|
const client_1 = client;
|
|
@@ -13250,7 +14439,7 @@ class Channel extends base_1$9.EmitterBase {
|
|
|
13250
14439
|
};
|
|
13251
14440
|
const routingInfo = await this.safeConnect(channelName, opts.wait, connectPayload);
|
|
13252
14441
|
const strategy = await __classPrivateFieldGet$4(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
|
|
13253
|
-
const channel = new client_1.ChannelClient(routingInfo, this.wire, strategy);
|
|
14442
|
+
const channel = new client_1.ChannelClient(routingInfo, () => client_1.ChannelClient.wireClose(this.wire, routingInfo, routingInfo.endpointId), strategy);
|
|
13254
14443
|
// It is the client's responsibility to handle endpoint disconnection to the provider.
|
|
13255
14444
|
// If the endpoint dies, the client will force a disconnection through the core.
|
|
13256
14445
|
// The provider does not care about endpoint disconnection.
|
|
@@ -13341,7 +14530,7 @@ interappbus.InterAppPayload = interappbus.InterApplicationBus = void 0;
|
|
|
13341
14530
|
*
|
|
13342
14531
|
* @packageDocumentation
|
|
13343
14532
|
*/
|
|
13344
|
-
const events_1$1 = require$$0
|
|
14533
|
+
const events_1$1 = require$$0;
|
|
13345
14534
|
const base_1$8 = base;
|
|
13346
14535
|
const ref_counter_1 = refCounter;
|
|
13347
14536
|
const index_1$2 = channel$1;
|
|
@@ -15904,7 +17093,7 @@ Factory.SnapshotSourceModule = SnapshotSourceModule;
|
|
|
15904
17093
|
|
|
15905
17094
|
Object.defineProperty(fin$1, "__esModule", { value: true });
|
|
15906
17095
|
var Fin_1 = fin$1.Fin = void 0;
|
|
15907
|
-
const events_1 = require$$0
|
|
17096
|
+
const events_1 = require$$0;
|
|
15908
17097
|
// Import from the file rather than the directory in case someone consuming types is using module resolution other than "node"
|
|
15909
17098
|
const index_1 = system;
|
|
15910
17099
|
const index_2 = requireWindow();
|