@openfin/remote-adapter 37.80.39 → 37.81.19
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 +301 -465
- package/out/remote-adapter-beta.d.ts +301 -465
- package/out/remote-adapter-public.d.ts +301 -465
- package/out/remote-adapter.d.ts +309 -473
- package/out/remote-adapter.js +1954 -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,1773 @@ 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
|
+
* We are also testing the ability to add a context handler for specific contexts. If you would like to use
|
|
1821
|
+
* this, please make sure you add your context handlers at the top level of your application, on a page that
|
|
1822
|
+
* does not navigate/reload/re-render, to avoid memory leaks. This feature is experimental:
|
|
1823
|
+
*
|
|
1824
|
+
* ```js
|
|
1825
|
+
* function handleInstrumentContext(contextInfo) {
|
|
1826
|
+
* const { type, id } = contextInfo;
|
|
1827
|
+
* console.log('contextInfo for instrument', contextInfo)
|
|
1828
|
+
* }
|
|
1829
|
+
*
|
|
1830
|
+
* function handleCountryContext(contextInfo) {
|
|
1831
|
+
* const { type, id } = contextInfo;
|
|
1832
|
+
* console.log('contextInfo for country', contextInfo)
|
|
1833
|
+
* }
|
|
1834
|
+
*
|
|
1835
|
+
*
|
|
1836
|
+
* fin.me.interop.addContextHandler(handleInstrumentContext, 'instrument')
|
|
1837
|
+
* fin.me.interop.addContextHandler(handleCountryContext, 'country')
|
|
1838
|
+
* ```
|
|
1839
|
+
*/
|
|
1840
|
+
async addContextHandler(handler, contextType) {
|
|
1841
|
+
this.wire.sendAction('interop-client-add-context-handler').catch((e) => {
|
|
1842
|
+
// don't expose, analytics-only call
|
|
1843
|
+
});
|
|
1844
|
+
if (typeof handler !== 'function') {
|
|
1845
|
+
throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
|
|
1846
|
+
}
|
|
1847
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1848
|
+
let handlerId;
|
|
1849
|
+
if (contextType) {
|
|
1850
|
+
handlerId = `invokeContextHandler-${contextType}-${(0, utils_1.generateId)()}`;
|
|
1851
|
+
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.`);
|
|
1852
|
+
}
|
|
1853
|
+
else {
|
|
1854
|
+
handlerId = 'invokeContextHandler';
|
|
1855
|
+
}
|
|
1856
|
+
const wrappedHandler = (0, utils_1.wrapContextHandler)(handler, handlerId);
|
|
1857
|
+
client.register(handlerId, wrappedHandler);
|
|
1858
|
+
await client.dispatch('contextHandlerRegistered', { handlerId, contextType });
|
|
1859
|
+
return {
|
|
1860
|
+
unsubscribe: async () => {
|
|
1861
|
+
client.remove(handlerId);
|
|
1862
|
+
await client.dispatch('removeContextHandler', { handlerId });
|
|
1863
|
+
}
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
/*
|
|
1867
|
+
Platform Window APIs
|
|
1868
|
+
*/
|
|
1869
|
+
/**
|
|
1870
|
+
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
1871
|
+
* Used by Platform Windows.
|
|
1872
|
+
*
|
|
1873
|
+
* @example
|
|
1874
|
+
* ```js
|
|
1875
|
+
* fin.me.interop.getContextGroups()
|
|
1876
|
+
* .then(contextGroups => {
|
|
1877
|
+
* contextGroups.forEach(contextGroup => {
|
|
1878
|
+
* console.log(contextGroup.displayMetadata.name)
|
|
1879
|
+
* console.log(contextGroup.displayMetadata.color)
|
|
1880
|
+
* })
|
|
1881
|
+
* })
|
|
1882
|
+
* ```
|
|
1883
|
+
*/
|
|
1884
|
+
async getContextGroups() {
|
|
1885
|
+
this.wire.sendAction('interop-client-get-context-groups').catch((e) => {
|
|
1886
|
+
// don't expose, analytics-only call
|
|
1887
|
+
});
|
|
1888
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1889
|
+
return client.dispatch('getContextGroups');
|
|
1890
|
+
}
|
|
1891
|
+
/**
|
|
1892
|
+
* Join all Interop Clients at the given identity to context group `contextGroupId`.
|
|
1893
|
+
* If no target is specified, it adds the sender to the context group.
|
|
1894
|
+
*
|
|
1895
|
+
* @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.
|
|
1896
|
+
* 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.
|
|
1897
|
+
* 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.
|
|
1898
|
+
* Used by Platform Windows.
|
|
1899
|
+
*
|
|
1900
|
+
* @param contextGroupId - Id of the context group.
|
|
1901
|
+
* @param target - Identity of the entity you wish to join to a context group.
|
|
1902
|
+
*
|
|
1903
|
+
* @example
|
|
1904
|
+
* ```js
|
|
1905
|
+
* joinViewToContextGroup = async (contextGroupId, view) => {
|
|
1906
|
+
* await fin.me.interop.joinContextGroup(contextGroupId, view);
|
|
1907
|
+
* }
|
|
1908
|
+
*
|
|
1909
|
+
* getLastFocusedView()
|
|
1910
|
+
* .then(lastFocusedViewIdentity => {
|
|
1911
|
+
* joinViewToContextGroup('red', lastFocusedViewIdentity)
|
|
1912
|
+
* })
|
|
1913
|
+
* ```
|
|
1914
|
+
*/
|
|
1915
|
+
async joinContextGroup(contextGroupId, target) {
|
|
1916
|
+
this.wire.sendAction('interop-client-join-context-group').catch((e) => {
|
|
1917
|
+
// don't expose, analytics-only call
|
|
1918
|
+
});
|
|
1919
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1920
|
+
if (!contextGroupId) {
|
|
1921
|
+
throw new Error('No contextGroupId specified for joinContextGroup.');
|
|
1922
|
+
}
|
|
1923
|
+
return client.dispatch('joinContextGroup', { contextGroupId, target });
|
|
1924
|
+
}
|
|
1925
|
+
/**
|
|
1926
|
+
* Removes the specified target from a context group.
|
|
1927
|
+
* If no target is specified, it removes the sender from their context group.
|
|
1928
|
+
* Used by Platform Windows.
|
|
1929
|
+
*
|
|
1930
|
+
* @param target - Identity of the entity you wish to join to a context group.
|
|
1931
|
+
*
|
|
1932
|
+
* @example
|
|
1933
|
+
* ```js
|
|
1934
|
+
* removeViewFromContextGroup = async (view) => {
|
|
1935
|
+
* await fin.me.interop.removeFromContextGroup(view);
|
|
1936
|
+
* }
|
|
1937
|
+
*
|
|
1938
|
+
* getLastFocusedView()
|
|
1939
|
+
* .then(lastFocusedViewIdentity => {
|
|
1940
|
+
* removeViewFromContextGroup(lastFocusedViewIdentity)
|
|
1941
|
+
* })
|
|
1942
|
+
* ```
|
|
1943
|
+
*/
|
|
1944
|
+
async removeFromContextGroup(target) {
|
|
1945
|
+
this.wire.sendAction('interop-client-remove-from-context-group').catch((e) => {
|
|
1946
|
+
// don't expose, analytics-only call
|
|
1947
|
+
});
|
|
1948
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1949
|
+
return client.dispatch('removeFromContextGroup', { target });
|
|
1950
|
+
}
|
|
1951
|
+
/**
|
|
1952
|
+
* Gets all clients for a context group.
|
|
1953
|
+
*
|
|
1954
|
+
* @remarks **This is primarily used for platform windows. Views within a platform should not have to use this API.**
|
|
1955
|
+
*
|
|
1956
|
+
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
1957
|
+
* @param contextGroupId - The id of context group you wish to get clients for.
|
|
1958
|
+
*
|
|
1959
|
+
* @example
|
|
1960
|
+
* ```js
|
|
1961
|
+
* fin.me.interop.getAllClientsInContextGroup('red')
|
|
1962
|
+
* .then(clientsInContextGroup => {
|
|
1963
|
+
* console.log(clientsInContextGroup)
|
|
1964
|
+
* })
|
|
1965
|
+
* ```
|
|
1966
|
+
*/
|
|
1967
|
+
async getAllClientsInContextGroup(contextGroupId) {
|
|
1968
|
+
this.wire.sendAction('interop-client-get-all-clients-in-context-group').catch((e) => {
|
|
1969
|
+
// don't expose, analytics-only call
|
|
1970
|
+
});
|
|
1971
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1972
|
+
if (!contextGroupId) {
|
|
1973
|
+
throw new Error('No contextGroupId specified for getAllClientsInContextGroup.');
|
|
1974
|
+
}
|
|
1975
|
+
return client.dispatch('getAllClientsInContextGroup', { contextGroupId });
|
|
1976
|
+
}
|
|
1977
|
+
/**
|
|
1978
|
+
* Gets display info for a context group
|
|
1979
|
+
*
|
|
1980
|
+
* @remarks Used by Platform Windows.
|
|
1981
|
+
* @param contextGroupId - The id of context group you wish to get display info for.
|
|
1982
|
+
*
|
|
1983
|
+
* @example
|
|
1984
|
+
* ```js
|
|
1985
|
+
* fin.me.interop.getInfoForContextGroup('red')
|
|
1986
|
+
* .then(contextGroupInfo => {
|
|
1987
|
+
* console.log(contextGroupInfo.displayMetadata.name)
|
|
1988
|
+
* console.log(contextGroupInfo.displayMetadata.color)
|
|
1989
|
+
* })
|
|
1990
|
+
* ```
|
|
1991
|
+
*/
|
|
1992
|
+
async getInfoForContextGroup(contextGroupId) {
|
|
1993
|
+
this.wire.sendAction('interop-client-get-info-for-context-group').catch((e) => {
|
|
1994
|
+
// don't expose, analytics-only call
|
|
1995
|
+
});
|
|
1996
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1997
|
+
if (!contextGroupId) {
|
|
1998
|
+
throw new Error('No contextGroupId specified for getInfoForContextGroup.');
|
|
1999
|
+
}
|
|
2000
|
+
return client.dispatch('getInfoForContextGroup', { contextGroupId });
|
|
2001
|
+
}
|
|
2002
|
+
/**
|
|
2003
|
+
* Sends an intent to the Interop Broker to resolve.
|
|
2004
|
+
* @param intent - The combination of an action and a context that is passed to an application for resolution.
|
|
2005
|
+
*
|
|
2006
|
+
* @example
|
|
2007
|
+
* ```js
|
|
2008
|
+
* // View wants to fire an Intent after a user clicks on a ticker
|
|
2009
|
+
* tickerElement.on('click', (element) => {
|
|
2010
|
+
* const ticker = element.innerText;
|
|
2011
|
+
* const intent = {
|
|
2012
|
+
* name: 'ViewChart',
|
|
2013
|
+
* context: {type: 'fdc3.instrument', id: { ticker }}
|
|
2014
|
+
* }
|
|
2015
|
+
*
|
|
2016
|
+
* fin.me.interop.fireIntent(intent);
|
|
2017
|
+
* })
|
|
2018
|
+
* ```
|
|
2019
|
+
*/
|
|
2020
|
+
async fireIntent(intent) {
|
|
2021
|
+
this.wire.sendAction('interop-client-fire-intent').catch((e) => {
|
|
2022
|
+
// don't expose, this is only for api analytics purposes
|
|
2023
|
+
});
|
|
2024
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2025
|
+
return client.dispatch('fireIntent', intent);
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* Adds an intent handler for incoming intents. The last intent sent of the name subscribed to will be received.
|
|
2029
|
+
* @param handler - Registered function meant to handle a specific intent type.
|
|
2030
|
+
* @param intentName - The name of an intent.
|
|
2031
|
+
*
|
|
2032
|
+
* @example
|
|
2033
|
+
* ```js
|
|
2034
|
+
* const intentHandler = (intent) => {
|
|
2035
|
+
* const { context } = intent;
|
|
2036
|
+
* myViewChartHandler(context);
|
|
2037
|
+
* };
|
|
2038
|
+
*
|
|
2039
|
+
* const subscription = await fin.me.interop.registerIntentHandler(intentHandler, 'ViewChart');
|
|
2040
|
+
*
|
|
2041
|
+
* function myAppCloseSequence() {
|
|
2042
|
+
* // to unsubscribe the handler, simply call:
|
|
2043
|
+
* subscription.unsubscribe();
|
|
2044
|
+
* }
|
|
2045
|
+
* ```
|
|
2046
|
+
*/
|
|
2047
|
+
async registerIntentHandler(handler, intentName, options) {
|
|
2048
|
+
this.wire.sendAction('interop-client-register-intent-handler').catch((e) => {
|
|
2049
|
+
// don't expose, this is only for api analytics purposes
|
|
2050
|
+
});
|
|
2051
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2052
|
+
const handlerId = `intent-handler-${intentName}`;
|
|
2053
|
+
const wrappedHandler = (0, utils_1.wrapIntentHandler)(handler, handlerId);
|
|
2054
|
+
try {
|
|
2055
|
+
await client.register(handlerId, wrappedHandler);
|
|
2056
|
+
await client.dispatch('intentHandlerRegistered', { handlerId, ...options });
|
|
2057
|
+
}
|
|
2058
|
+
catch (error) {
|
|
2059
|
+
throw new Error('Unable to register intent handler');
|
|
2060
|
+
}
|
|
2061
|
+
return {
|
|
2062
|
+
unsubscribe: async () => {
|
|
2063
|
+
client.remove(handlerId);
|
|
2064
|
+
}
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
/**
|
|
2068
|
+
* Gets the last context of the Context Group currently subscribed to. It takes an optional Context Type and returns the
|
|
2069
|
+
* last context of that type.
|
|
2070
|
+
* @param contextType
|
|
2071
|
+
*
|
|
2072
|
+
* @example
|
|
2073
|
+
* ```js
|
|
2074
|
+
* await fin.me.interop.joinContextGroup('yellow');
|
|
2075
|
+
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
|
2076
|
+
* const currentContext = await fin.me.interop.getCurrentContext();
|
|
2077
|
+
*
|
|
2078
|
+
* // with a specific context
|
|
2079
|
+
* await fin.me.interop.joinContextGroup('yellow');
|
|
2080
|
+
* await fin.me.interop.setContext({ type: 'country', id: { ISOALPHA3: 'US' }});
|
|
2081
|
+
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
|
2082
|
+
* const currentContext = await fin.me.interop.getCurrentContext('country');
|
|
2083
|
+
* ```
|
|
2084
|
+
*/
|
|
2085
|
+
async getCurrentContext(contextType) {
|
|
2086
|
+
this.wire.sendAction('interop-client-get-current-context').catch((e) => {
|
|
2087
|
+
// don't expose, analytics-only call
|
|
2088
|
+
});
|
|
2089
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2090
|
+
return client.dispatch('getCurrentContext', { contextType });
|
|
2091
|
+
}
|
|
2092
|
+
/**
|
|
2093
|
+
* Get information for a particular Intent from the Interop Broker.
|
|
2094
|
+
*
|
|
2095
|
+
* @remarks To resolve this info, the function handleInfoForIntent is meant to be overridden in the Interop Broker.
|
|
2096
|
+
* The format for the response will be determined by the App Provider overriding the function.
|
|
2097
|
+
*
|
|
2098
|
+
* @param options
|
|
2099
|
+
*
|
|
2100
|
+
* @example
|
|
2101
|
+
* ```js
|
|
2102
|
+
* const intentInfo = await fin.me.interop.getInfoForIntent('ViewChart');
|
|
2103
|
+
* ```
|
|
2104
|
+
*/
|
|
2105
|
+
async getInfoForIntent(options) {
|
|
2106
|
+
this.wire.sendAction('interop-client-get-info-for-intent').catch((e) => {
|
|
2107
|
+
// don't expose, analytics-only call
|
|
2108
|
+
});
|
|
2109
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2110
|
+
return client.dispatch('getInfoForIntent', options);
|
|
2111
|
+
}
|
|
2112
|
+
/**
|
|
2113
|
+
* Get information from the Interop Broker on all Intents that are meant to handle a particular context.
|
|
2114
|
+
*
|
|
2115
|
+
* @remarks To resolve this info, the function handleInfoForIntentsByContext is meant to be overridden in the Interop Broker.
|
|
2116
|
+
* The format for the response will be determined by the App Provider overriding the function.
|
|
2117
|
+
*
|
|
2118
|
+
* @param context
|
|
2119
|
+
*
|
|
2120
|
+
* @example
|
|
2121
|
+
* ```js
|
|
2122
|
+
* tickerElement.on('click', (element) => {
|
|
2123
|
+
* const ticker = element.innerText;
|
|
2124
|
+
*
|
|
2125
|
+
* const context = {
|
|
2126
|
+
* type: 'fdc3.instrument',
|
|
2127
|
+
* id: {
|
|
2128
|
+
* ticker
|
|
2129
|
+
* }
|
|
2130
|
+
* }
|
|
2131
|
+
*
|
|
2132
|
+
* const intentsInfo = await fin.me.interop.getInfoForIntentByContext(context);
|
|
2133
|
+
* })
|
|
2134
|
+
* ```
|
|
2135
|
+
*/
|
|
2136
|
+
async getInfoForIntentsByContext(context) {
|
|
2137
|
+
this.wire.sendAction('interop-client-get-info-for-intents-by-context').catch((e) => {
|
|
2138
|
+
// don't expose, analytics-only call
|
|
2139
|
+
});
|
|
2140
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2141
|
+
return client.dispatch('getInfoForIntentsByContext', context);
|
|
2142
|
+
}
|
|
2143
|
+
/**
|
|
2144
|
+
* Sends a Context that will be resolved to an Intent by the Interop Broker.
|
|
2145
|
+
* This context accepts a metadata property.
|
|
2146
|
+
*
|
|
2147
|
+
* @remarks To resolve this info, the function handleFiredIntentByContext is meant to be overridden in the Interop Broker.
|
|
2148
|
+
* The format for the response will be determined by the App Provider overriding the function.
|
|
2149
|
+
*
|
|
2150
|
+
* @param context
|
|
2151
|
+
*
|
|
2152
|
+
* @example
|
|
2153
|
+
* ```js
|
|
2154
|
+
* tickerElement.on('click', (element) => {
|
|
2155
|
+
* const ticker = element.innerText;
|
|
2156
|
+
*
|
|
2157
|
+
* const context = {
|
|
2158
|
+
* type: 'fdc3.instrument',
|
|
2159
|
+
* id: {
|
|
2160
|
+
* ticker
|
|
2161
|
+
* }
|
|
2162
|
+
* }
|
|
2163
|
+
*
|
|
2164
|
+
* const intentResolution = await fin.me.interop.fireIntentForContext(context);
|
|
2165
|
+
* })
|
|
2166
|
+
* ```
|
|
2167
|
+
*/
|
|
2168
|
+
async fireIntentForContext(context) {
|
|
2169
|
+
this.wire.sendAction('interop-client-fire-intent-for-context').catch((e) => {
|
|
2170
|
+
// don't expose, analytics-only call
|
|
2171
|
+
});
|
|
2172
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2173
|
+
return client.dispatch('fireIntentForContext', context);
|
|
2174
|
+
}
|
|
2175
|
+
/**
|
|
2176
|
+
* Join the current entity to session context group `sessionContextGroupId` and return a sessionContextGroup instance.
|
|
2177
|
+
* If the sessionContextGroup doesn't exist, one will get created.
|
|
2178
|
+
*
|
|
2179
|
+
* @remarks Session Context Groups do not persist between runs and aren't present on snapshots.
|
|
2180
|
+
* @param sessionContextGroupId - Id of the context group.
|
|
2181
|
+
*
|
|
2182
|
+
* @example
|
|
2183
|
+
* Say we want to have a Session Context Group that holds UI theme information for all apps to consume:
|
|
2184
|
+
*
|
|
2185
|
+
* My color-picker View:
|
|
2186
|
+
* ```js
|
|
2187
|
+
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
|
2188
|
+
*
|
|
2189
|
+
* const myColorPickerElement = document.getElementById('color-palette-picker');
|
|
2190
|
+
* myColorPickerElement.addEventListener('change', event => {
|
|
2191
|
+
* themeSessionContextGroup.setContext({ type: 'color-palette', selection: event.value });
|
|
2192
|
+
* });
|
|
2193
|
+
* ```
|
|
2194
|
+
*
|
|
2195
|
+
* In other views:
|
|
2196
|
+
* ```js
|
|
2197
|
+
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
|
2198
|
+
*
|
|
2199
|
+
* const changeColorPalette = ({ selection }) => {
|
|
2200
|
+
* // change the color palette to the selection
|
|
2201
|
+
* };
|
|
2202
|
+
*
|
|
2203
|
+
* // If the context is already set by the time the handler was set, the handler will get invoked immediately with the current context.
|
|
2204
|
+
* themeSessionContextGroup.addContextHandler(changeColorPalette, 'color-palette');
|
|
2205
|
+
* ```
|
|
2206
|
+
*/
|
|
2207
|
+
async joinSessionContextGroup(sessionContextGroupId) {
|
|
2208
|
+
try {
|
|
2209
|
+
const currentSessionContextGroup = __classPrivateFieldGet(this, _InteropClient_sessionContextGroups, "f").get(sessionContextGroupId);
|
|
2210
|
+
if (currentSessionContextGroup) {
|
|
2211
|
+
return currentSessionContextGroup.getUserInstance();
|
|
2212
|
+
}
|
|
2213
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2214
|
+
const { hasConflict } = await client.dispatch('sessionContextGroup:createIfNeeded', {
|
|
2215
|
+
sessionContextGroupId
|
|
2216
|
+
});
|
|
2217
|
+
if (hasConflict) {
|
|
2218
|
+
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.`);
|
|
2219
|
+
}
|
|
2220
|
+
const newSessionContextGroup = new SessionContextGroupClient_1.default(this.wire, __classPrivateFieldGet(this, _InteropClient_clientPromise, "f"), sessionContextGroupId);
|
|
2221
|
+
__classPrivateFieldGet(this, _InteropClient_sessionContextGroups, "f").set(sessionContextGroupId, newSessionContextGroup);
|
|
2222
|
+
return newSessionContextGroup.getUserInstance();
|
|
2223
|
+
}
|
|
2224
|
+
catch (error) {
|
|
2225
|
+
console.error(`Error thrown trying to create Session Context Group with id "${sessionContextGroupId}": ${error}`);
|
|
2226
|
+
throw error;
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
/**
|
|
2230
|
+
* Register a listener that is called when the Interop Client has been disconnected from the Interop Broker.
|
|
2231
|
+
* Only one listener per Interop Client can be set.
|
|
2232
|
+
* @param listener
|
|
2233
|
+
*
|
|
2234
|
+
* @example
|
|
2235
|
+
* ```js
|
|
2236
|
+
* const listener = (event) => {
|
|
2237
|
+
* const { type, topic, brokerName} = event;
|
|
2238
|
+
* console.log(`Disconnected from Interop Broker ${brokerName} `);
|
|
2239
|
+
* }
|
|
2240
|
+
*
|
|
2241
|
+
* await fin.me.interop.onDisconnection(listener);
|
|
2242
|
+
* ```
|
|
2243
|
+
*/
|
|
2244
|
+
async onDisconnection(listener) {
|
|
2245
|
+
this.wire.sendAction('interop-client-add-ondisconnection-listener').catch((e) => {
|
|
2246
|
+
// don't expose, analytics-only call
|
|
2247
|
+
});
|
|
2248
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
2249
|
+
return client.onDisconnection((event) => {
|
|
2250
|
+
const { uuid } = event;
|
|
2251
|
+
listener({ type: 'interop-broker', topic: 'disconnected', brokerName: uuid });
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
getFDC3Sync(version) {
|
|
2255
|
+
switch (version) {
|
|
2256
|
+
case '1.2':
|
|
2257
|
+
return new fdc3_1_2_1.Fdc3Module(() => this, this.wire);
|
|
2258
|
+
case '2.0':
|
|
2259
|
+
return new fdc3_2_0_1.Fdc3Module2(() => this, this.wire);
|
|
2260
|
+
default:
|
|
2261
|
+
throw new Error(`Invalid FDC3 version provided: ${version}. Must be '1.2' or '2.0'`);
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
async getFDC3(version) {
|
|
2265
|
+
return this.getFDC3Sync(version);
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* @internal
|
|
2269
|
+
*
|
|
2270
|
+
* Used to ferry fdc3-only calls from the fdc3 shim to the Interop Broker
|
|
2271
|
+
*/
|
|
2272
|
+
static async ferryFdc3Call(interopClient, action, payload) {
|
|
2273
|
+
const client = await __classPrivateFieldGet(interopClient, _InteropClient_clientPromise, "f");
|
|
2274
|
+
return client.dispatch(action, payload || null);
|
|
2275
|
+
}
|
|
2276
|
+
};
|
|
2277
|
+
InteropClient.InteropClient = InteropClient$1;
|
|
2278
|
+
_InteropClient_clientPromise = new WeakMap(), _InteropClient_sessionContextGroups = new WeakMap();
|
|
2279
|
+
return InteropClient;
|
|
2280
|
+
}
|
|
1118
2281
|
|
|
1119
2282
|
var commonUtils = {};
|
|
1120
2283
|
|
|
@@ -1145,11 +2308,11 @@ function requireFactory$3 () {
|
|
|
1145
2308
|
hasRequiredFactory$3 = 1;
|
|
1146
2309
|
Object.defineProperty(Factory$8, "__esModule", { value: true });
|
|
1147
2310
|
Factory$8.InteropModule = void 0;
|
|
1148
|
-
const lodash_1 = require$$
|
|
2311
|
+
const lodash_1 = require$$3;
|
|
1149
2312
|
const inaccessibleObject_1 = inaccessibleObject;
|
|
1150
2313
|
const base_1 = base;
|
|
1151
2314
|
const InteropBroker_1 = requireInteropBroker();
|
|
1152
|
-
const InteropClient_1 =
|
|
2315
|
+
const InteropClient_1 = requireInteropClient();
|
|
1153
2316
|
const overrideCheck_1 = requireOverrideCheck();
|
|
1154
2317
|
const common_utils_1 = commonUtils;
|
|
1155
2318
|
const defaultOverride = (Class) => new Class();
|
|
@@ -1183,12 +2346,8 @@ function requireFactory$3 () {
|
|
|
1183
2346
|
const options = await this.wire.environment.getInteropInfo(this.wire.getFin());
|
|
1184
2347
|
const objectThatThrows = (0, inaccessibleObject_1.createUnusableObject)(BrokerParamAccessError);
|
|
1185
2348
|
const warningOptsClone = (0, inaccessibleObject_1.createWarningObject)(BrokerParamAccessError, (0, lodash_1.cloneDeep)(options));
|
|
1186
|
-
let provider;
|
|
1187
2349
|
const getProvider = () => {
|
|
1188
|
-
|
|
1189
|
-
provider = this.fin.InterApplicationBus.Channel.create(`interop-broker-${name}`);
|
|
1190
|
-
}
|
|
1191
|
-
return provider;
|
|
2350
|
+
return this.fin.InterApplicationBus.Channel.create(`interop-broker-${name}`);
|
|
1192
2351
|
};
|
|
1193
2352
|
const throwingGetProvider = async () => {
|
|
1194
2353
|
// eslint-disable-next-line no-console
|
|
@@ -1234,7 +2393,11 @@ function requireFactory$3 () {
|
|
|
1234
2393
|
this.wire.sendAction('interop-connect-sync').catch(() => {
|
|
1235
2394
|
// don't expose, analytics-only call
|
|
1236
2395
|
});
|
|
1237
|
-
return new InteropClient_1.InteropClient(this.wire,
|
|
2396
|
+
return new InteropClient_1.InteropClient(this.wire, this.wire.environment.whenReady().then(() => {
|
|
2397
|
+
return this.fin.InterApplicationBus.Channel.connect(`interop-broker-${name}`, {
|
|
2398
|
+
payload: interopConfig
|
|
2399
|
+
});
|
|
2400
|
+
}));
|
|
1238
2401
|
}
|
|
1239
2402
|
}
|
|
1240
2403
|
Factory$8.InteropModule = InteropModule;
|
|
@@ -1271,7 +2434,7 @@ function requireInterop () {
|
|
|
1271
2434
|
};
|
|
1272
2435
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1273
2436
|
__exportStar(requireFactory$3(), exports);
|
|
1274
|
-
__exportStar(
|
|
2437
|
+
__exportStar(requireInteropClient(), exports);
|
|
1275
2438
|
__exportStar(requireInteropBroker(), exports);
|
|
1276
2439
|
} (interop));
|
|
1277
2440
|
return interop;
|
|
@@ -1676,6 +2839,62 @@ function requirePrivateChannelProvider () {
|
|
|
1676
2839
|
return PrivateChannelProvider;
|
|
1677
2840
|
}
|
|
1678
2841
|
|
|
2842
|
+
var lazy = {};
|
|
2843
|
+
|
|
2844
|
+
Object.defineProperty(lazy, "__esModule", { value: true });
|
|
2845
|
+
lazy.AsyncRetryableLazy = lazy.Lazy = void 0;
|
|
2846
|
+
/**
|
|
2847
|
+
* Handy class for managing asynchronous dependencies of classes.
|
|
2848
|
+
*
|
|
2849
|
+
* Will call the producer function once and only once when getValue is called,
|
|
2850
|
+
* returning the resultant value for every subsequent call.
|
|
2851
|
+
*/
|
|
2852
|
+
class Lazy {
|
|
2853
|
+
// eslint-disable-next-line
|
|
2854
|
+
constructor(producerFn) {
|
|
2855
|
+
this.producerFn = producerFn;
|
|
2856
|
+
}
|
|
2857
|
+
/**
|
|
2858
|
+
* Lazily get the value returned by the producer.
|
|
2859
|
+
* @returns The value returned from the producer function
|
|
2860
|
+
*/
|
|
2861
|
+
getValue() {
|
|
2862
|
+
if (!this.value) {
|
|
2863
|
+
this.value = this.producerFn();
|
|
2864
|
+
}
|
|
2865
|
+
return this.value;
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
lazy.Lazy = Lazy;
|
|
2869
|
+
/**
|
|
2870
|
+
* Handy class for managing asynchronous dependencies of classes.
|
|
2871
|
+
*
|
|
2872
|
+
* Will call asynchronous producer only after `getValue` is called. If the
|
|
2873
|
+
* deferred code errors, we can try it again by re-calling `getValue` after
|
|
2874
|
+
* the promise rejects.
|
|
2875
|
+
*/
|
|
2876
|
+
class AsyncRetryableLazy {
|
|
2877
|
+
// eslint-disable-next-line
|
|
2878
|
+
constructor(producerFn) {
|
|
2879
|
+
this.producerFn = producerFn;
|
|
2880
|
+
}
|
|
2881
|
+
/**
|
|
2882
|
+
* Lazily get the value returned by the async producer.
|
|
2883
|
+
*
|
|
2884
|
+
* @returns The value returned from the producer function
|
|
2885
|
+
*/
|
|
2886
|
+
async getValue() {
|
|
2887
|
+
if (!this.promise) {
|
|
2888
|
+
this.promise = this.producerFn().catch((e) => {
|
|
2889
|
+
delete this.promise;
|
|
2890
|
+
throw e;
|
|
2891
|
+
});
|
|
2892
|
+
}
|
|
2893
|
+
return this.promise;
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
lazy.AsyncRetryableLazy = AsyncRetryableLazy;
|
|
2897
|
+
|
|
1679
2898
|
var hasRequiredInteropBroker;
|
|
1680
2899
|
|
|
1681
2900
|
function requireInteropBroker () {
|
|
@@ -1692,14 +2911,15 @@ function requireInteropBroker () {
|
|
|
1692
2911
|
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
2912
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1694
2913
|
};
|
|
1695
|
-
var _InteropBroker_fdc3Info, _InteropBroker_contextGroups;
|
|
2914
|
+
var _InteropBroker_fdc3Info, _InteropBroker_contextGroups, _InteropBroker_providerPromise;
|
|
1696
2915
|
Object.defineProperty(InteropBroker, "__esModule", { value: true });
|
|
1697
2916
|
InteropBroker.InteropBroker = void 0;
|
|
1698
2917
|
const base_1 = base;
|
|
1699
2918
|
const SessionContextGroupBroker_1 = requireSessionContextGroupBroker();
|
|
1700
|
-
const utils_1 = utils$
|
|
1701
|
-
const lodash_1 = require$$
|
|
2919
|
+
const utils_1 = utils$3;
|
|
2920
|
+
const lodash_1 = require$$3;
|
|
1702
2921
|
const PrivateChannelProvider_1 = requirePrivateChannelProvider();
|
|
2922
|
+
const lazy_1 = lazy;
|
|
1703
2923
|
const defaultContextGroups = [
|
|
1704
2924
|
{
|
|
1705
2925
|
id: 'green',
|
|
@@ -1867,12 +3087,15 @@ function requireInteropBroker () {
|
|
|
1867
3087
|
/**
|
|
1868
3088
|
* @internal
|
|
1869
3089
|
*/
|
|
1870
|
-
constructor(wire,
|
|
3090
|
+
constructor(wire, createProvider, options) {
|
|
1871
3091
|
// Tip from Pierre and Michael from the overrideCheck work: Don't use bound methods for overrideable InteropBroker functions.
|
|
1872
3092
|
super(wire);
|
|
1873
|
-
this.getProvider = getProvider;
|
|
1874
3093
|
_InteropBroker_fdc3Info.set(this, void 0);
|
|
1875
3094
|
_InteropBroker_contextGroups.set(this, void 0);
|
|
3095
|
+
_InteropBroker_providerPromise.set(this, void 0);
|
|
3096
|
+
this.getProvider = () => {
|
|
3097
|
+
return __classPrivateFieldGet(this, _InteropBroker_providerPromise, "f").getValue();
|
|
3098
|
+
};
|
|
1876
3099
|
this.interopClients = new Map();
|
|
1877
3100
|
this.contextGroupsById = new Map();
|
|
1878
3101
|
__classPrivateFieldSet(this, _InteropBroker_contextGroups, options.contextGroups ?? [...defaultContextGroups], "f");
|
|
@@ -1883,6 +3106,7 @@ function requireInteropBroker () {
|
|
|
1883
3106
|
this.intentClientMap = new Map();
|
|
1884
3107
|
this.lastContextMap = new Map();
|
|
1885
3108
|
this.sessionContextGroupMap = new Map();
|
|
3109
|
+
__classPrivateFieldSet(this, _InteropBroker_providerPromise, new lazy_1.Lazy(createProvider), "f");
|
|
1886
3110
|
this.setContextGroupMap();
|
|
1887
3111
|
this.setupChannelProvider();
|
|
1888
3112
|
}
|
|
@@ -2966,7 +4190,7 @@ function requireInteropBroker () {
|
|
|
2966
4190
|
}
|
|
2967
4191
|
};
|
|
2968
4192
|
InteropBroker.InteropBroker = InteropBroker$1;
|
|
2969
|
-
_InteropBroker_fdc3Info = new WeakMap(), _InteropBroker_contextGroups = new WeakMap();
|
|
4193
|
+
_InteropBroker_fdc3Info = new WeakMap(), _InteropBroker_contextGroups = new WeakMap(), _InteropBroker_providerPromise = new WeakMap();
|
|
2970
4194
|
return InteropBroker;
|
|
2971
4195
|
}
|
|
2972
4196
|
|
|
@@ -3239,7 +4463,7 @@ var emitterMap = {};
|
|
|
3239
4463
|
|
|
3240
4464
|
Object.defineProperty(emitterMap, "__esModule", { value: true });
|
|
3241
4465
|
emitterMap.EmitterMap = void 0;
|
|
3242
|
-
const events_1$6 = require$$0
|
|
4466
|
+
const events_1$6 = require$$0;
|
|
3243
4467
|
class EmitterMap {
|
|
3244
4468
|
constructor() {
|
|
3245
4469
|
this.storage = new Map();
|
|
@@ -3497,62 +4721,6 @@ function requireFactory$2 () {
|
|
|
3497
4721
|
|
|
3498
4722
|
var Instance$7 = {};
|
|
3499
4723
|
|
|
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
4724
|
var layoutEntities = {};
|
|
3557
4725
|
|
|
3558
4726
|
var apiExposer$1 = {};
|
|
@@ -6430,6 +7598,37 @@ function requireApplication () {
|
|
|
6430
7598
|
return application;
|
|
6431
7599
|
}
|
|
6432
7600
|
|
|
7601
|
+
var promisifySubscription$1 = {};
|
|
7602
|
+
|
|
7603
|
+
Object.defineProperty(promisifySubscription$1, "__esModule", { value: true });
|
|
7604
|
+
promisifySubscription$1.promisifySubscription = void 0;
|
|
7605
|
+
const promisifySubscription = async (emitter, eventName, predicate = () => true, timeout) => {
|
|
7606
|
+
let resolve;
|
|
7607
|
+
let reject;
|
|
7608
|
+
let timer;
|
|
7609
|
+
const valuePromise = new Promise((y, n) => {
|
|
7610
|
+
resolve = y;
|
|
7611
|
+
reject = n;
|
|
7612
|
+
});
|
|
7613
|
+
const listener = (e) => {
|
|
7614
|
+
if (predicate(e)) {
|
|
7615
|
+
clearTimeout(timer);
|
|
7616
|
+
resolve(e);
|
|
7617
|
+
}
|
|
7618
|
+
};
|
|
7619
|
+
await emitter.on(eventName, listener);
|
|
7620
|
+
if (timeout) {
|
|
7621
|
+
timer = setTimeout(() => reject(new Error('event timed out')), timeout);
|
|
7622
|
+
}
|
|
7623
|
+
valuePromise.finally(() => {
|
|
7624
|
+
emitter.removeListener(eventName, listener).catch(() => null);
|
|
7625
|
+
});
|
|
7626
|
+
return {
|
|
7627
|
+
getValue: () => valuePromise
|
|
7628
|
+
};
|
|
7629
|
+
};
|
|
7630
|
+
promisifySubscription$1.promisifySubscription = promisifySubscription;
|
|
7631
|
+
|
|
6433
7632
|
var hasRequiredInstance$1;
|
|
6434
7633
|
|
|
6435
7634
|
function requireInstance$1 () {
|
|
@@ -6445,6 +7644,7 @@ function requireInstance$1 () {
|
|
|
6445
7644
|
const main_1 = main;
|
|
6446
7645
|
const view_1 = requireView();
|
|
6447
7646
|
const warnings_1 = warnings;
|
|
7647
|
+
const promisifySubscription_1 = promisifySubscription$1;
|
|
6448
7648
|
/**
|
|
6449
7649
|
* A basic window that wraps a native HTML window. Provides more fine-grained
|
|
6450
7650
|
* control over the window state such as the ability to minimize, maximize, restore, etc.
|
|
@@ -6460,79 +7660,60 @@ function requireInstance$1 () {
|
|
|
6460
7660
|
constructor(wire, identity) {
|
|
6461
7661
|
super(wire, identity, 'window');
|
|
6462
7662
|
}
|
|
6463
|
-
|
|
6464
|
-
* create a new window
|
|
6465
|
-
* @internal
|
|
6466
|
-
*/
|
|
6467
|
-
createWindow(options) {
|
|
7663
|
+
async createWindow(options) {
|
|
6468
7664
|
this.wire.sendAction('window-create-window', this.identity).catch((e) => {
|
|
6469
7665
|
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
6470
7666
|
});
|
|
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
|
-
});
|
|
7667
|
+
const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
|
|
7668
|
+
const responseSubscription = await (0, promisifySubscription_1.promisifySubscription)(this, CONSTRUCTOR_CB_TOPIC);
|
|
7669
|
+
// set defaults:
|
|
7670
|
+
if (options.waitForPageLoad === undefined) {
|
|
7671
|
+
options.waitForPageLoad = false;
|
|
7672
|
+
}
|
|
7673
|
+
if (options.autoShow === undefined) {
|
|
7674
|
+
options.autoShow = true;
|
|
7675
|
+
}
|
|
7676
|
+
(0, warnings_1.handleDeprecatedWarnings)(options);
|
|
7677
|
+
const windowCreation = this.wire.environment.createChildContent({ entityType: 'window', options });
|
|
7678
|
+
const [response] = await Promise.all([responseSubscription.getValue(), windowCreation]);
|
|
7679
|
+
let cbPayload;
|
|
7680
|
+
const { success } = response;
|
|
7681
|
+
const responseData = response.data;
|
|
7682
|
+
const { message } = responseData;
|
|
7683
|
+
if (success) {
|
|
7684
|
+
cbPayload = {
|
|
7685
|
+
httpResponseCode: responseData.httpResponseCode,
|
|
7686
|
+
apiInjected: responseData.apiInjected
|
|
7687
|
+
};
|
|
7688
|
+
}
|
|
7689
|
+
else {
|
|
7690
|
+
cbPayload = {
|
|
7691
|
+
message: responseData.message,
|
|
7692
|
+
networkErrorCode: responseData.networkErrorCode,
|
|
7693
|
+
stack: responseData.stack
|
|
7694
|
+
};
|
|
7695
|
+
}
|
|
7696
|
+
const pageResolve = {
|
|
7697
|
+
message,
|
|
7698
|
+
cbPayload,
|
|
7699
|
+
success
|
|
7700
|
+
};
|
|
7701
|
+
try {
|
|
7702
|
+
// this is to enforce a 5.0 contract that the child's main function
|
|
7703
|
+
// will not fire before the parent's success callback on creation.
|
|
7704
|
+
// if the child window is not accessible (CORS) this contract does
|
|
7705
|
+
// not hold.
|
|
7706
|
+
const webWindow = this.getWebWindow();
|
|
7707
|
+
webWindow.fin.__internal_.openerSuccessCBCalled();
|
|
7708
|
+
}
|
|
7709
|
+
catch (e) {
|
|
7710
|
+
// common for main windows, we do not want to expose this error. here just to have a debug target.
|
|
7711
|
+
// console.error(e);
|
|
7712
|
+
}
|
|
7713
|
+
if (pageResolve.success) {
|
|
7714
|
+
return this;
|
|
7715
|
+
}
|
|
7716
|
+
return Promise.reject(pageResolve);
|
|
6536
7717
|
}
|
|
6537
7718
|
/**
|
|
6538
7719
|
* Retrieves an array of frame info objects representing the main frame and any
|
|
@@ -8997,7 +10178,7 @@ var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateF
|
|
|
8997
10178
|
var _Transport_wire, _Transport_fin;
|
|
8998
10179
|
Object.defineProperty(transport, "__esModule", { value: true });
|
|
8999
10180
|
var Transport_1 = transport.Transport = void 0;
|
|
9000
|
-
const events_1$5 = require$$0
|
|
10181
|
+
const events_1$5 = require$$0;
|
|
9001
10182
|
const wire_1 = wire;
|
|
9002
10183
|
const transport_errors_1$2 = transportErrors;
|
|
9003
10184
|
const eventAggregator_1 = eventAggregator;
|
|
@@ -9214,7 +10395,7 @@ _Transport_wire = new WeakMap(), _Transport_fin = new WeakMap();
|
|
|
9214
10395
|
var websocket = {};
|
|
9215
10396
|
|
|
9216
10397
|
Object.defineProperty(websocket, "__esModule", { value: true });
|
|
9217
|
-
const events_1$4 = require$$0
|
|
10398
|
+
const events_1$4 = require$$0;
|
|
9218
10399
|
const transport_errors_1$1 = transportErrors;
|
|
9219
10400
|
const messageReceiver_1 = bridge.messageReceiver;
|
|
9220
10401
|
/* `READY_STATE` is an instance var set by `constructor` to reference the `WebTransportSocket.READY_STATE` enum.
|
|
@@ -9291,7 +10472,7 @@ system.System = void 0;
|
|
|
9291
10472
|
const base_1$d = base;
|
|
9292
10473
|
const transport_errors_1 = transportErrors;
|
|
9293
10474
|
const window_1 = requireWindow();
|
|
9294
|
-
const events_1$3 = require$$0
|
|
10475
|
+
const events_1$3 = require$$0;
|
|
9295
10476
|
/**
|
|
9296
10477
|
* An object representing the core of OpenFin Runtime. Allows the developer
|
|
9297
10478
|
* to perform system-level actions, such as accessing logs, viewing processes,
|
|
@@ -11204,9 +12385,10 @@ class ProtectedItems {
|
|
|
11204
12385
|
/**
|
|
11205
12386
|
* @internal
|
|
11206
12387
|
*/
|
|
11207
|
-
|
|
12388
|
+
// eslint-disable-next-line no-useless-constructor
|
|
12389
|
+
constructor(providerIdentity, close) {
|
|
11208
12390
|
this.providerIdentity = providerIdentity;
|
|
11209
|
-
this.
|
|
12391
|
+
this.close = close;
|
|
11210
12392
|
}
|
|
11211
12393
|
}
|
|
11212
12394
|
channel.ProtectedItems = ProtectedItems;
|
|
@@ -11593,7 +12775,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
11593
12775
|
/**
|
|
11594
12776
|
* @internal
|
|
11595
12777
|
*/
|
|
11596
|
-
constructor(routingInfo,
|
|
12778
|
+
constructor(routingInfo, close, strategy) {
|
|
11597
12779
|
super();
|
|
11598
12780
|
_ChannelClient_protectedObj.set(this, void 0);
|
|
11599
12781
|
_ChannelClient_strategy.set(this, void 0);
|
|
@@ -11603,7 +12785,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
11603
12785
|
channelClientsByEndpointId.delete(this.endpointId);
|
|
11604
12786
|
__classPrivateFieldGet$a(this, _ChannelClient_strategy, "f").close();
|
|
11605
12787
|
});
|
|
11606
|
-
__classPrivateFieldSet$8(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo,
|
|
12788
|
+
__classPrivateFieldSet$8(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
|
|
11607
12789
|
this.disconnectListener = () => undefined;
|
|
11608
12790
|
this.endpointId = routingInfo.endpointId;
|
|
11609
12791
|
__classPrivateFieldSet$8(this, _ChannelClient_strategy, strategy, "f");
|
|
@@ -11698,12 +12880,19 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
11698
12880
|
}
|
|
11699
12881
|
async sendDisconnectAction() {
|
|
11700
12882
|
const protectedObj = __classPrivateFieldGet$a(this, _ChannelClient_protectedObj, "f");
|
|
11701
|
-
|
|
11702
|
-
|
|
12883
|
+
await protectedObj.close();
|
|
12884
|
+
}
|
|
12885
|
+
/**
|
|
12886
|
+
* @internal
|
|
12887
|
+
* 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.
|
|
12888
|
+
*/
|
|
12889
|
+
static async wireClose(wire, providerIdentity, endpointId) {
|
|
12890
|
+
const { channelName, uuid, name } = providerIdentity;
|
|
12891
|
+
await wire.sendAction('disconnect-from-channel', {
|
|
11703
12892
|
channelName,
|
|
11704
12893
|
uuid,
|
|
11705
12894
|
name,
|
|
11706
|
-
endpointId
|
|
12895
|
+
endpointId
|
|
11707
12896
|
});
|
|
11708
12897
|
}
|
|
11709
12898
|
}
|
|
@@ -12299,7 +13488,7 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
12299
13488
|
/**
|
|
12300
13489
|
* @internal
|
|
12301
13490
|
*/
|
|
12302
|
-
constructor(providerIdentity,
|
|
13491
|
+
constructor(providerIdentity, close, strategy) {
|
|
12303
13492
|
super();
|
|
12304
13493
|
_ChannelProvider_connections.set(this, void 0);
|
|
12305
13494
|
_ChannelProvider_protectedObj.set(this, void 0);
|
|
@@ -12327,7 +13516,7 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
12327
13516
|
remove();
|
|
12328
13517
|
}
|
|
12329
13518
|
});
|
|
12330
|
-
__classPrivateFieldSet$4(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity,
|
|
13519
|
+
__classPrivateFieldSet$4(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
|
|
12331
13520
|
this.connectListener = () => undefined;
|
|
12332
13521
|
this.disconnectListener = () => undefined;
|
|
12333
13522
|
__classPrivateFieldSet$4(this, _ChannelProvider_connections, [], "f");
|
|
@@ -12466,9 +13655,9 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
12466
13655
|
*/
|
|
12467
13656
|
async destroy() {
|
|
12468
13657
|
const protectedObj = __classPrivateFieldGet$6(this, _ChannelProvider_protectedObj, "f");
|
|
12469
|
-
|
|
13658
|
+
protectedObj.providerIdentity;
|
|
12470
13659
|
__classPrivateFieldSet$4(this, _ChannelProvider_connections, [], "f");
|
|
12471
|
-
await protectedObj.
|
|
13660
|
+
await protectedObj.close();
|
|
12472
13661
|
__classPrivateFieldGet$6(this, _ChannelProvider_close, "f").call(this);
|
|
12473
13662
|
}
|
|
12474
13663
|
/**
|
|
@@ -12560,6 +13749,9 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
12560
13749
|
static clientIsMultiRuntime(subscriptionIdentity) {
|
|
12561
13750
|
return subscriptionIdentity.runtimeUuid !== undefined;
|
|
12562
13751
|
}
|
|
13752
|
+
static async wireClose(wire, channelName) {
|
|
13753
|
+
await wire.sendAction('destroy-channel', { channelName });
|
|
13754
|
+
}
|
|
12563
13755
|
}
|
|
12564
13756
|
provider.ChannelProvider = ChannelProvider;
|
|
12565
13757
|
_ChannelProvider_connections = new WeakMap(), _ChannelProvider_protectedObj = new WeakMap(), _ChannelProvider_strategy = new WeakMap(), _ChannelProvider_removeEndpoint = new WeakMap(), _ChannelProvider_close = new WeakMap();
|
|
@@ -12829,7 +14021,7 @@ class ConnectionManager extends base_1$a.Base {
|
|
|
12829
14021
|
// Should be impossible.
|
|
12830
14022
|
throw new Error('failed to combine strategies');
|
|
12831
14023
|
}
|
|
12832
|
-
const channel = new provider_1$1.ChannelProvider(providerIdentity, this.wire, strategy);
|
|
14024
|
+
const channel = new provider_1$1.ChannelProvider(providerIdentity, () => provider_1$1.ChannelProvider.wireClose(this.wire, providerIdentity.channelName), strategy);
|
|
12833
14025
|
const key = providerIdentity.channelId;
|
|
12834
14026
|
this.providerMap.set(key, {
|
|
12835
14027
|
provider: channel,
|
|
@@ -13014,7 +14206,7 @@ var _Channel_connectionManager, _Channel_internalEmitter, _Channel_readyToConnec
|
|
|
13014
14206
|
Object.defineProperty(channel$1, "__esModule", { value: true });
|
|
13015
14207
|
channel$1.Channel = void 0;
|
|
13016
14208
|
/* eslint-disable no-console */
|
|
13017
|
-
const events_1$2 = require$$0
|
|
14209
|
+
const events_1$2 = require$$0;
|
|
13018
14210
|
const lazy_1$1 = lazy;
|
|
13019
14211
|
const base_1$9 = base;
|
|
13020
14212
|
const client_1 = client;
|
|
@@ -13250,7 +14442,7 @@ class Channel extends base_1$9.EmitterBase {
|
|
|
13250
14442
|
};
|
|
13251
14443
|
const routingInfo = await this.safeConnect(channelName, opts.wait, connectPayload);
|
|
13252
14444
|
const strategy = await __classPrivateFieldGet$4(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
|
|
13253
|
-
const channel = new client_1.ChannelClient(routingInfo, this.wire, strategy);
|
|
14445
|
+
const channel = new client_1.ChannelClient(routingInfo, () => client_1.ChannelClient.wireClose(this.wire, routingInfo, routingInfo.endpointId), strategy);
|
|
13254
14446
|
// It is the client's responsibility to handle endpoint disconnection to the provider.
|
|
13255
14447
|
// If the endpoint dies, the client will force a disconnection through the core.
|
|
13256
14448
|
// The provider does not care about endpoint disconnection.
|
|
@@ -13341,7 +14533,7 @@ interappbus.InterAppPayload = interappbus.InterApplicationBus = void 0;
|
|
|
13341
14533
|
*
|
|
13342
14534
|
* @packageDocumentation
|
|
13343
14535
|
*/
|
|
13344
|
-
const events_1$1 = require$$0
|
|
14536
|
+
const events_1$1 = require$$0;
|
|
13345
14537
|
const base_1$8 = base;
|
|
13346
14538
|
const ref_counter_1 = refCounter;
|
|
13347
14539
|
const index_1$2 = channel$1;
|
|
@@ -15904,7 +17096,7 @@ Factory.SnapshotSourceModule = SnapshotSourceModule;
|
|
|
15904
17096
|
|
|
15905
17097
|
Object.defineProperty(fin$1, "__esModule", { value: true });
|
|
15906
17098
|
var Fin_1 = fin$1.Fin = void 0;
|
|
15907
|
-
const events_1 = require$$0
|
|
17099
|
+
const events_1 = require$$0;
|
|
15908
17100
|
// Import from the file rather than the directory in case someone consuming types is using module resolution other than "node"
|
|
15909
17101
|
const index_1 = system;
|
|
15910
17102
|
const index_2 = requireWindow();
|