@openfin/fdc3-api 40.105.7 → 40.200.2
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/out/fdc3-api-alpha.d.ts +438 -992
- package/out/fdc3-api-beta.d.ts +438 -992
- package/out/fdc3-api-public.d.ts +438 -992
- package/out/fdc3-api.d.ts +475 -1037
- package/out/fdc3-api.js +1456 -1483
- package/package.json +2 -3
package/out/fdc3-api.js
CHANGED
|
@@ -10,7 +10,7 @@ var utils$2 = {};
|
|
|
10
10
|
|
|
11
11
|
(function (exports) {
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
13
|
+
exports.wrapIntentHandler = exports.BROKER_ERRORS = exports.generateOverrideWarning = exports.generateOverrideError = exports.wrapContextHandler = exports.wrapInTryCatch = exports.generateId = void 0;
|
|
14
14
|
const generateId = () => `${Math.random()}${Date.now()}`;
|
|
15
15
|
exports.generateId = generateId;
|
|
16
16
|
const wrapInTryCatch = (f, prefix) => (...args) => {
|
|
@@ -68,45 +68,7 @@ var utils$2 = {};
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
|
-
exports.wrapIntentHandler = wrapIntentHandler;
|
|
72
|
-
const checkContextIntegrity = (context) => {
|
|
73
|
-
if (!context) {
|
|
74
|
-
return { isValid: false, reason: 'No context supplied' };
|
|
75
|
-
}
|
|
76
|
-
if (typeof context !== 'object') {
|
|
77
|
-
return { isValid: false, reason: 'Context must be an Object' };
|
|
78
|
-
}
|
|
79
|
-
if (!context.type) {
|
|
80
|
-
return { isValid: false, reason: 'Context must have a type property' };
|
|
81
|
-
}
|
|
82
|
-
if (context.id && typeof context.id !== 'object') {
|
|
83
|
-
return {
|
|
84
|
-
isValid: false,
|
|
85
|
-
reason: 'Context id must be an Object populated with key-value identifiers (if set)'
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
if (context.id) {
|
|
89
|
-
const { id } = context;
|
|
90
|
-
const keys = Object.keys(id);
|
|
91
|
-
let foundBadIdentifier = false;
|
|
92
|
-
if (!keys.length) {
|
|
93
|
-
return { isValid: false, reason: 'Context id must have at least one key-value identifier' };
|
|
94
|
-
}
|
|
95
|
-
keys.forEach((key) => {
|
|
96
|
-
if (typeof key !== 'string' || typeof id[key] !== 'string') {
|
|
97
|
-
foundBadIdentifier = true;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
if (foundBadIdentifier) {
|
|
101
|
-
return { isValid: false, reason: 'Context id key-value identifiers must be of type string' };
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (context.name && typeof context.name !== 'string') {
|
|
105
|
-
return { isValid: false, reason: 'Context name must be of string type (if set)' };
|
|
106
|
-
}
|
|
107
|
-
return { isValid: true };
|
|
108
|
-
};
|
|
109
|
-
exports.checkContextIntegrity = checkContextIntegrity;
|
|
71
|
+
exports.wrapIntentHandler = wrapIntentHandler;
|
|
110
72
|
} (utils$2));
|
|
111
73
|
|
|
112
74
|
var fdc3Common = {};
|
|
@@ -416,13 +378,7 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
|
|
|
416
378
|
const getResultPromise = new Promise((resolve, reject) => {
|
|
417
379
|
fin.InterApplicationBus.subscribe({ uuid: '*' }, guid, (intentResult) => {
|
|
418
380
|
resolve(intentResult);
|
|
419
|
-
}).catch(() =>
|
|
420
|
-
// not supported in web, suppress the error
|
|
421
|
-
if (interopModule.wire.environment.type === 'other') {
|
|
422
|
-
resolve(undefined);
|
|
423
|
-
}
|
|
424
|
-
reject(new Error('getResult is not supported in this environment'));
|
|
425
|
-
});
|
|
381
|
+
}).catch(() => reject(new Error('getResult is not supported in this environment')));
|
|
426
382
|
});
|
|
427
383
|
// Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
|
|
428
384
|
const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
|
|
@@ -476,7 +432,7 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
|
|
|
476
432
|
exports.getIntentResolution = getIntentResolution;
|
|
477
433
|
} (utils$1));
|
|
478
434
|
|
|
479
|
-
var InteropClient
|
|
435
|
+
var InteropClient = {};
|
|
480
436
|
|
|
481
437
|
var base = {};
|
|
482
438
|
|
|
@@ -509,18 +465,18 @@ async function promiseMapSerial(arr, func) {
|
|
|
509
465
|
}
|
|
510
466
|
promises.promiseMapSerial = promiseMapSerial;
|
|
511
467
|
|
|
512
|
-
var __classPrivateFieldSet$
|
|
468
|
+
var __classPrivateFieldSet$1 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
513
469
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
514
470
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
515
471
|
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");
|
|
516
472
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
517
473
|
};
|
|
518
|
-
var __classPrivateFieldGet$
|
|
474
|
+
var __classPrivateFieldGet$1 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
519
475
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
520
476
|
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");
|
|
521
477
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
522
478
|
};
|
|
523
|
-
var _EmitterBase_emitterAccessor
|
|
479
|
+
var _EmitterBase_emitterAccessor;
|
|
524
480
|
Object.defineProperty(base, "__esModule", { value: true });
|
|
525
481
|
base.Reply = base.EmitterBase = base.Base = void 0;
|
|
526
482
|
const promises_1 = promises;
|
|
@@ -592,7 +548,6 @@ class EmitterBase extends Base {
|
|
|
592
548
|
super(wire);
|
|
593
549
|
this.topic = topic;
|
|
594
550
|
_EmitterBase_emitterAccessor.set(this, void 0);
|
|
595
|
-
_EmitterBase_deregisterOnceListeners.set(this, void 0);
|
|
596
551
|
this.eventNames = () => (this.hasEmitter() ? this.getOrCreateEmitter().eventNames() : []);
|
|
597
552
|
/**
|
|
598
553
|
* @internal
|
|
@@ -600,29 +555,8 @@ class EmitterBase extends Base {
|
|
|
600
555
|
this.emit = (eventType, payload, ...args) => {
|
|
601
556
|
return this.hasEmitter() ? this.getOrCreateEmitter().emit(eventType, payload, ...args) : false;
|
|
602
557
|
};
|
|
603
|
-
this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$
|
|
604
|
-
|
|
605
|
-
* Cleans up after removal of a listener, e.g. deleting any lingering deregistration handlers for a
|
|
606
|
-
* `once` subscription.
|
|
607
|
-
*
|
|
608
|
-
* @remarks Implementing this as a `removeListener` handler ensures that direct removal of a listener
|
|
609
|
-
* on the base emitter will not leak additional core handlers. We could do this in the forwarding method,
|
|
610
|
-
* which would involve less "magic," but would be more-vulnerable to accidental re-introduction of a leak.
|
|
611
|
-
*/
|
|
612
|
-
this.cleanUpRemovedListener = (eventType, listener) => {
|
|
613
|
-
const deregister = __classPrivateFieldGet$3(this, _EmitterBase_deregisterOnceListeners, "f").get(listener);
|
|
614
|
-
if (deregister) {
|
|
615
|
-
const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$3(this, _EmitterBase_emitterAccessor, "f"));
|
|
616
|
-
emitter.removeListener(eventType, deregister);
|
|
617
|
-
}
|
|
618
|
-
};
|
|
619
|
-
this.getOrCreateEmitter = () => {
|
|
620
|
-
const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$3(this, _EmitterBase_emitterAccessor, "f"));
|
|
621
|
-
if (!emitter.listeners('removeListener').includes(this.cleanUpRemovedListener)) {
|
|
622
|
-
emitter.on('removeListener', this.cleanUpRemovedListener);
|
|
623
|
-
}
|
|
624
|
-
return emitter;
|
|
625
|
-
};
|
|
558
|
+
this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$1(this, _EmitterBase_emitterAccessor, "f"));
|
|
559
|
+
this.getOrCreateEmitter = () => this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$1(this, _EmitterBase_emitterAccessor, "f"));
|
|
626
560
|
this.listeners = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(type) : [];
|
|
627
561
|
this.listenerCount = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listenerCount(type) : 0;
|
|
628
562
|
this.registerEventListener = async (eventType, options = {}, applySubscription, undoSubscription) => {
|
|
@@ -654,13 +588,13 @@ class EmitterBase extends Base {
|
|
|
654
588
|
type: eventType
|
|
655
589
|
};
|
|
656
590
|
await this.wire.sendAction('unsubscribe-to-desktop-event', runtimeEvent).catch(() => null);
|
|
657
|
-
|
|
591
|
+
const emitter = this.getOrCreateEmitter();
|
|
592
|
+
return emitter;
|
|
658
593
|
}
|
|
659
594
|
// This will only be reached if unsubscribe from event that does not exist but do not want to error here
|
|
660
595
|
return Promise.resolve();
|
|
661
596
|
};
|
|
662
|
-
__classPrivateFieldSet$
|
|
663
|
-
__classPrivateFieldSet$3(this, _EmitterBase_deregisterOnceListeners, new WeakMap(), "f");
|
|
597
|
+
__classPrivateFieldSet$1(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
|
|
664
598
|
this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
|
|
665
599
|
}
|
|
666
600
|
/**
|
|
@@ -689,7 +623,6 @@ class EmitterBase extends Base {
|
|
|
689
623
|
*/
|
|
690
624
|
async once(eventType, listener, options) {
|
|
691
625
|
const deregister = () => this.deregisterEventListener(eventType);
|
|
692
|
-
__classPrivateFieldGet$3(this, _EmitterBase_deregisterOnceListeners, "f").set(listener, deregister);
|
|
693
626
|
await this.registerEventListener(eventType, options, (emitter) => {
|
|
694
627
|
emitter.once(eventType, deregister);
|
|
695
628
|
emitter.once(eventType, listener);
|
|
@@ -720,7 +653,6 @@ class EmitterBase extends Base {
|
|
|
720
653
|
*/
|
|
721
654
|
async prependOnceListener(eventType, listener, options) {
|
|
722
655
|
const deregister = () => this.deregisterEventListener(eventType);
|
|
723
|
-
__classPrivateFieldGet$3(this, _EmitterBase_deregisterOnceListeners, "f").set(listener, deregister);
|
|
724
656
|
await this.registerEventListener(eventType, options, (emitter) => {
|
|
725
657
|
emitter.prependOnceListener(eventType, listener);
|
|
726
658
|
emitter.once(eventType, deregister);
|
|
@@ -779,40 +711,40 @@ class EmitterBase extends Base {
|
|
|
779
711
|
return this;
|
|
780
712
|
}
|
|
781
713
|
deleteEmitterIfNothingRegistered(emitter) {
|
|
782
|
-
if (emitter.eventNames().
|
|
783
|
-
this.wire.eventAggregator.delete(__classPrivateFieldGet$
|
|
714
|
+
if (emitter.eventNames().length === 0) {
|
|
715
|
+
this.wire.eventAggregator.delete(__classPrivateFieldGet$1(this, _EmitterBase_emitterAccessor, "f"));
|
|
784
716
|
}
|
|
785
717
|
}
|
|
786
718
|
}
|
|
787
719
|
base.EmitterBase = EmitterBase;
|
|
788
|
-
_EmitterBase_emitterAccessor = new WeakMap()
|
|
720
|
+
_EmitterBase_emitterAccessor = new WeakMap();
|
|
789
721
|
class Reply {
|
|
790
722
|
}
|
|
791
723
|
base.Reply = Reply;
|
|
792
724
|
|
|
793
725
|
var SessionContextGroupClient$1 = {};
|
|
794
726
|
|
|
795
|
-
var __classPrivateFieldSet
|
|
727
|
+
var __classPrivateFieldSet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
796
728
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
797
729
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
798
730
|
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");
|
|
799
731
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
800
732
|
};
|
|
801
|
-
var __classPrivateFieldGet
|
|
733
|
+
var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
802
734
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
803
735
|
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");
|
|
804
736
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
805
737
|
};
|
|
806
738
|
var _SessionContextGroupClient_clientPromise;
|
|
807
739
|
Object.defineProperty(SessionContextGroupClient$1, "__esModule", { value: true });
|
|
808
|
-
const base_1
|
|
809
|
-
const utils_1
|
|
810
|
-
class SessionContextGroupClient extends base_1
|
|
740
|
+
const base_1 = base;
|
|
741
|
+
const utils_1 = utils$2;
|
|
742
|
+
class SessionContextGroupClient extends base_1.Base {
|
|
811
743
|
constructor(wire, client, id) {
|
|
812
744
|
super(wire);
|
|
813
745
|
_SessionContextGroupClient_clientPromise.set(this, void 0);
|
|
814
746
|
this.id = id;
|
|
815
|
-
__classPrivateFieldSet
|
|
747
|
+
__classPrivateFieldSet(this, _SessionContextGroupClient_clientPromise, client, "f");
|
|
816
748
|
}
|
|
817
749
|
/**
|
|
818
750
|
* Sets a context for the session context group.
|
|
@@ -824,7 +756,7 @@ class SessionContextGroupClient extends base_1$1.Base {
|
|
|
824
756
|
this.wire.sendAction('interop-session-context-group-set-context').catch((e) => {
|
|
825
757
|
// don't expose, analytics-only call
|
|
826
758
|
});
|
|
827
|
-
const client = await __classPrivateFieldGet
|
|
759
|
+
const client = await __classPrivateFieldGet(this, _SessionContextGroupClient_clientPromise, "f");
|
|
828
760
|
return client.dispatch(`sessionContextGroup:setContext-${this.id}`, {
|
|
829
761
|
sessionContextGroupId: this.id,
|
|
830
762
|
context
|
|
@@ -834,7 +766,7 @@ class SessionContextGroupClient extends base_1$1.Base {
|
|
|
834
766
|
this.wire.sendAction('interop-session-context-group-get-context').catch((e) => {
|
|
835
767
|
// don't expose, analytics-only call
|
|
836
768
|
});
|
|
837
|
-
const client = await __classPrivateFieldGet
|
|
769
|
+
const client = await __classPrivateFieldGet(this, _SessionContextGroupClient_clientPromise, "f");
|
|
838
770
|
return client.dispatch(`sessionContextGroup:getContext-${this.id}`, {
|
|
839
771
|
sessionContextGroupId: this.id,
|
|
840
772
|
type
|
|
@@ -847,20 +779,20 @@ class SessionContextGroupClient extends base_1$1.Base {
|
|
|
847
779
|
if (typeof contextHandler !== 'function') {
|
|
848
780
|
throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
|
|
849
781
|
}
|
|
850
|
-
const client = await __classPrivateFieldGet
|
|
782
|
+
const client = await __classPrivateFieldGet(this, _SessionContextGroupClient_clientPromise, "f");
|
|
851
783
|
let handlerId;
|
|
852
784
|
if (contextType) {
|
|
853
|
-
handlerId = `sessionContextHandler:invoke-${this.id}-${contextType}-${(0, utils_1
|
|
785
|
+
handlerId = `sessionContextHandler:invoke-${this.id}-${contextType}-${(0, utils_1.generateId)()}`;
|
|
854
786
|
}
|
|
855
787
|
else {
|
|
856
788
|
handlerId = `sessionContextHandler:invoke-${this.id}`;
|
|
857
789
|
}
|
|
858
|
-
client.register(handlerId, (0, utils_1
|
|
790
|
+
client.register(handlerId, (0, utils_1.wrapContextHandler)(contextHandler, handlerId));
|
|
859
791
|
await client.dispatch(`sessionContextGroup:handlerAdded-${this.id}`, { handlerId, contextType });
|
|
860
792
|
return { unsubscribe: await this.createUnsubscribeCb(handlerId) };
|
|
861
793
|
}
|
|
862
794
|
async createUnsubscribeCb(handlerId) {
|
|
863
|
-
const client = await __classPrivateFieldGet
|
|
795
|
+
const client = await __classPrivateFieldGet(this, _SessionContextGroupClient_clientPromise, "f");
|
|
864
796
|
return async () => {
|
|
865
797
|
client.remove(handlerId);
|
|
866
798
|
await client.dispatch(`sessionContextGroup:handlerRemoved-${this.id}`, { handlerId });
|
|
@@ -869,1406 +801,1443 @@ class SessionContextGroupClient extends base_1$1.Base {
|
|
|
869
801
|
getUserInstance() {
|
|
870
802
|
return {
|
|
871
803
|
id: this.id,
|
|
872
|
-
setContext: (0, utils_1
|
|
873
|
-
getCurrentContext: (0, utils_1
|
|
874
|
-
addContextHandler: (0, utils_1
|
|
804
|
+
setContext: (0, utils_1.wrapInTryCatch)(this.setContext.bind(this), 'Failed to set context: '),
|
|
805
|
+
getCurrentContext: (0, utils_1.wrapInTryCatch)(this.getCurrentContext.bind(this), 'Failed to get context: '),
|
|
806
|
+
addContextHandler: (0, utils_1.wrapInTryCatch)(this.addContextHandler.bind(this), 'Failed to add context handler: ')
|
|
875
807
|
};
|
|
876
808
|
}
|
|
877
809
|
}
|
|
878
810
|
SessionContextGroupClient$1.default = SessionContextGroupClient;
|
|
879
811
|
_SessionContextGroupClient_clientPromise = new WeakMap();
|
|
880
812
|
|
|
881
|
-
var
|
|
882
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
883
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
884
|
-
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");
|
|
885
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
886
|
-
};
|
|
887
|
-
var __classPrivateFieldGet$1 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
888
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
889
|
-
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");
|
|
890
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
891
|
-
};
|
|
892
|
-
var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
893
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
894
|
-
};
|
|
895
|
-
var _InteropClient_clientPromise, _InteropClient_sessionContextGroups, _InteropClient_fdc3Factory;
|
|
896
|
-
Object.defineProperty(InteropClient$1, "__esModule", { value: true });
|
|
897
|
-
InteropClient$1.InteropClient = void 0;
|
|
898
|
-
const base_1 = base;
|
|
899
|
-
const SessionContextGroupClient_1 = __importDefault$1(SessionContextGroupClient$1);
|
|
900
|
-
const utils_1$3 = utils$2;
|
|
901
|
-
/**
|
|
902
|
-
* The Interop Client API is broken up into two groups:
|
|
903
|
-
*
|
|
904
|
-
* **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.
|
|
905
|
-
*
|
|
906
|
-
* **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.
|
|
907
|
-
*
|
|
908
|
-
* ---
|
|
909
|
-
*
|
|
910
|
-
* All APIs are available at the `fin.me.interop` namespace.
|
|
911
|
-
*
|
|
912
|
-
* ---
|
|
913
|
-
*
|
|
914
|
-
* **You only need 2 things to participate in Interop Context Grouping:**
|
|
915
|
-
* * A Context Handler for incoming context: {@link InteropClient#addContextHandler addContextHandler(handler, contextType?)}
|
|
916
|
-
* * Call setContext on your context group when you want to share context with other group members: {@link InteropClient#setContext setContext(context)}
|
|
917
|
-
*
|
|
918
|
-
* ---
|
|
919
|
-
*
|
|
920
|
-
* ##### Constructor
|
|
921
|
-
* Returned by {@link Interop.connectSync Interop.connectSync}.
|
|
922
|
-
*
|
|
923
|
-
* ---
|
|
924
|
-
*
|
|
925
|
-
* ##### Interop methods intended for Views
|
|
926
|
-
*
|
|
927
|
-
*
|
|
928
|
-
* **Context Groups API**
|
|
929
|
-
* * {@link InteropClient#addContextHandler addContextHandler(handler, contextType?)}
|
|
930
|
-
* * {@link InteropClient#setContext setContext(context)}
|
|
931
|
-
* * {@link InteropClient#getCurrentContext getCurrentContext(contextType?)}
|
|
932
|
-
* * {@link InteropClient#joinSessionContextGroup joinSessionContextGroup(sessionContextGroupId)}
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
* **Intents API**
|
|
936
|
-
* * {@link InteropClient#fireIntent fireIntent(intent)}
|
|
937
|
-
* * {@link InteropClient#registerIntentHandler registerIntentHandler(intentHandler, intentName)}
|
|
938
|
-
* * {@link InteropClient#getInfoForIntent getInfoForIntent(infoForIntentOptions)}
|
|
939
|
-
* * {@link InteropClient#getInfoForIntentsByContext getInfoForIntentsByContext(context)}
|
|
940
|
-
* * {@link InteropClient#fireIntentForContext fireIntentForContext(contextForIntent)}
|
|
941
|
-
*
|
|
942
|
-
* ##### Interop methods intended for Windows
|
|
943
|
-
* * {@link InteropClient#getContextGroups getContextGroups()}
|
|
944
|
-
* * {@link InteropClient#joinContextGroup joinContextGroup(contextGroupId, target?)}
|
|
945
|
-
* * {@link InteropClient#removeFromContextGroup removeFromContextGroup(target?)}
|
|
946
|
-
* * {@link InteropClient#getInfoForContextGroup getInfoForContextGroup(contextGroupId)}
|
|
947
|
-
* * {@link InteropClient#getAllClientsInContextGroup getAllClientsInContextGroup(contextGroupId)}
|
|
948
|
-
*
|
|
949
|
-
*/
|
|
950
|
-
class InteropClient extends base_1.Base {
|
|
951
|
-
/**
|
|
952
|
-
* @internal
|
|
953
|
-
*/
|
|
954
|
-
constructor(wire, clientPromise, fdc3Factory) {
|
|
955
|
-
super(wire);
|
|
956
|
-
_InteropClient_clientPromise.set(this, void 0);
|
|
957
|
-
_InteropClient_sessionContextGroups.set(this, void 0);
|
|
958
|
-
_InteropClient_fdc3Factory.set(this, void 0);
|
|
959
|
-
__classPrivateFieldSet$1(this, _InteropClient_sessionContextGroups, new Map(), "f");
|
|
960
|
-
__classPrivateFieldSet$1(this, _InteropClient_clientPromise, clientPromise, "f");
|
|
961
|
-
__classPrivateFieldSet$1(this, _InteropClient_fdc3Factory, fdc3Factory, "f");
|
|
962
|
-
}
|
|
963
|
-
/*
|
|
964
|
-
Client APIs
|
|
965
|
-
*/
|
|
966
|
-
/**
|
|
967
|
-
* Sets a context for the context group of the current entity.
|
|
968
|
-
*
|
|
969
|
-
* @remarks The entity must be part of a context group in order set a context.
|
|
970
|
-
*
|
|
971
|
-
* @param context - New context to set.
|
|
972
|
-
*
|
|
973
|
-
* @example
|
|
974
|
-
* ```js
|
|
975
|
-
* setInstrumentContext = async (ticker) => {
|
|
976
|
-
* fin.me.interop.setContext({type: 'instrument', id: {ticker}})
|
|
977
|
-
* }
|
|
978
|
-
*
|
|
979
|
-
* // 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
|
|
980
|
-
* instrumentElement.on('click', (evt) => {
|
|
981
|
-
* setInstrumentContext(evt.ticker)
|
|
982
|
-
* })
|
|
983
|
-
* ```
|
|
984
|
-
*/
|
|
985
|
-
async setContext(context) {
|
|
986
|
-
this.wire.sendAction('interop-client-set-context').catch((e) => {
|
|
987
|
-
// don't expose, analytics-only call
|
|
988
|
-
});
|
|
989
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
990
|
-
return client.dispatch('setContext', { context });
|
|
991
|
-
}
|
|
992
|
-
/**
|
|
993
|
-
* Add a context handler for incoming context. If an entity is part of a context group, and then sets its context handler,
|
|
994
|
-
* it will receive all of its declared contexts.
|
|
995
|
-
*
|
|
996
|
-
* @param handler - Handler for incoming context.
|
|
997
|
-
* @param contextType - The type of context you wish to handle.
|
|
998
|
-
*
|
|
999
|
-
* @example
|
|
1000
|
-
* ```js
|
|
1001
|
-
* function handleIncomingContext(contextInfo) {
|
|
1002
|
-
* const { type, id } = contextInfo;
|
|
1003
|
-
* switch (type) {
|
|
1004
|
-
* case 'instrument':
|
|
1005
|
-
* handleInstrumentContext(contextInfo);
|
|
1006
|
-
* break;
|
|
1007
|
-
* case 'country':
|
|
1008
|
-
* handleCountryContext(contextInfo);
|
|
1009
|
-
* break;
|
|
1010
|
-
*
|
|
1011
|
-
* default:
|
|
1012
|
-
* break;
|
|
1013
|
-
* }
|
|
1014
|
-
* }
|
|
1015
|
-
*
|
|
1016
|
-
*
|
|
1017
|
-
* function handleInstrumentContext(contextInfo) {
|
|
1018
|
-
* const { type, id } = contextInfo;
|
|
1019
|
-
* console.log('contextInfo for instrument', contextInfo)
|
|
1020
|
-
* }
|
|
1021
|
-
*
|
|
1022
|
-
* function handleCountryContext(contextInfo) {
|
|
1023
|
-
* const { type, id } = contextInfo;
|
|
1024
|
-
* console.log('contextInfo for country', contextInfo)
|
|
1025
|
-
* }
|
|
1026
|
-
*
|
|
1027
|
-
* fin.me.interop.addContextHandler(handleIncomingContext);
|
|
1028
|
-
* ```
|
|
1029
|
-
*
|
|
1030
|
-
*
|
|
1031
|
-
* Passing in a context type as the second parameter will cause the handler to only be invoked with that context type.
|
|
1032
|
-
*
|
|
1033
|
-
* ```js
|
|
1034
|
-
* function handleInstrumentContext(contextInfo) {
|
|
1035
|
-
* const { type, id } = contextInfo;
|
|
1036
|
-
* console.log('contextInfo for instrument', contextInfo)
|
|
1037
|
-
* }
|
|
1038
|
-
*
|
|
1039
|
-
* function handleCountryContext(contextInfo) {
|
|
1040
|
-
* const { type, id } = contextInfo;
|
|
1041
|
-
* console.log('contextInfo for country', contextInfo)
|
|
1042
|
-
* }
|
|
1043
|
-
*
|
|
1044
|
-
*
|
|
1045
|
-
* fin.me.interop.addContextHandler(handleInstrumentContext, 'instrument')
|
|
1046
|
-
* fin.me.interop.addContextHandler(handleCountryContext, 'country')
|
|
1047
|
-
* ```
|
|
1048
|
-
*/
|
|
1049
|
-
async addContextHandler(handler, contextType) {
|
|
1050
|
-
this.wire.sendAction('interop-client-add-context-handler').catch((e) => {
|
|
1051
|
-
// don't expose, analytics-only call
|
|
1052
|
-
});
|
|
1053
|
-
if (typeof handler !== 'function') {
|
|
1054
|
-
throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
|
|
1055
|
-
}
|
|
1056
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1057
|
-
let handlerId;
|
|
1058
|
-
if (contextType) {
|
|
1059
|
-
handlerId = `invokeContextHandler-${contextType}-${(0, utils_1$3.generateId)()}`;
|
|
1060
|
-
}
|
|
1061
|
-
else {
|
|
1062
|
-
handlerId = 'invokeContextHandler';
|
|
1063
|
-
}
|
|
1064
|
-
const wrappedHandler = (0, utils_1$3.wrapContextHandler)(handler, handlerId);
|
|
1065
|
-
client.register(handlerId, wrappedHandler);
|
|
1066
|
-
await client.dispatch('contextHandlerRegistered', { handlerId, contextType });
|
|
1067
|
-
return {
|
|
1068
|
-
unsubscribe: async () => {
|
|
1069
|
-
client.remove(handlerId);
|
|
1070
|
-
await client.dispatch('removeContextHandler', { handlerId });
|
|
1071
|
-
}
|
|
1072
|
-
};
|
|
1073
|
-
}
|
|
1074
|
-
/*
|
|
1075
|
-
Platform Window APIs
|
|
1076
|
-
*/
|
|
1077
|
-
/**
|
|
1078
|
-
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
1079
|
-
* Used by Platform Windows.
|
|
1080
|
-
*
|
|
1081
|
-
* @example
|
|
1082
|
-
* ```js
|
|
1083
|
-
* fin.me.interop.getContextGroups()
|
|
1084
|
-
* .then(contextGroups => {
|
|
1085
|
-
* contextGroups.forEach(contextGroup => {
|
|
1086
|
-
* console.log(contextGroup.displayMetadata.name)
|
|
1087
|
-
* console.log(contextGroup.displayMetadata.color)
|
|
1088
|
-
* })
|
|
1089
|
-
* })
|
|
1090
|
-
* ```
|
|
1091
|
-
*/
|
|
1092
|
-
async getContextGroups() {
|
|
1093
|
-
this.wire.sendAction('interop-client-get-context-groups').catch((e) => {
|
|
1094
|
-
// don't expose, analytics-only call
|
|
1095
|
-
});
|
|
1096
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1097
|
-
return client.dispatch('getContextGroups');
|
|
1098
|
-
}
|
|
1099
|
-
/**
|
|
1100
|
-
* Join all Interop Clients at the given identity to context group `contextGroupId`.
|
|
1101
|
-
* If no target is specified, it adds the sender to the context group.
|
|
1102
|
-
*
|
|
1103
|
-
* @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.
|
|
1104
|
-
* 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.
|
|
1105
|
-
* 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.
|
|
1106
|
-
* Used by Platform Windows.
|
|
1107
|
-
*
|
|
1108
|
-
* @param contextGroupId - Id of the context group.
|
|
1109
|
-
* @param target - Identity of the entity you wish to join to a context group.
|
|
1110
|
-
*
|
|
1111
|
-
* @example
|
|
1112
|
-
* ```js
|
|
1113
|
-
* joinViewToContextGroup = async (contextGroupId, view) => {
|
|
1114
|
-
* await fin.me.interop.joinContextGroup(contextGroupId, view);
|
|
1115
|
-
* }
|
|
1116
|
-
*
|
|
1117
|
-
* getLastFocusedView()
|
|
1118
|
-
* .then(lastFocusedViewIdentity => {
|
|
1119
|
-
* joinViewToContextGroup('red', lastFocusedViewIdentity)
|
|
1120
|
-
* })
|
|
1121
|
-
* ```
|
|
1122
|
-
*/
|
|
1123
|
-
async joinContextGroup(contextGroupId, target) {
|
|
1124
|
-
this.wire.sendAction('interop-client-join-context-group').catch((e) => {
|
|
1125
|
-
// don't expose, analytics-only call
|
|
1126
|
-
});
|
|
1127
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1128
|
-
if (!contextGroupId) {
|
|
1129
|
-
throw new Error('No contextGroupId specified for joinContextGroup.');
|
|
1130
|
-
}
|
|
1131
|
-
return client.dispatch('joinContextGroup', { contextGroupId, target });
|
|
1132
|
-
}
|
|
1133
|
-
/**
|
|
1134
|
-
* Removes the specified target from a context group.
|
|
1135
|
-
* If no target is specified, it removes the sender from their context group.
|
|
1136
|
-
* Used by Platform Windows.
|
|
1137
|
-
*
|
|
1138
|
-
* @param target - Identity of the entity you wish to join to a context group.
|
|
1139
|
-
*
|
|
1140
|
-
* @example
|
|
1141
|
-
* ```js
|
|
1142
|
-
* removeViewFromContextGroup = async (view) => {
|
|
1143
|
-
* await fin.me.interop.removeFromContextGroup(view);
|
|
1144
|
-
* }
|
|
1145
|
-
*
|
|
1146
|
-
* getLastFocusedView()
|
|
1147
|
-
* .then(lastFocusedViewIdentity => {
|
|
1148
|
-
* removeViewFromContextGroup(lastFocusedViewIdentity)
|
|
1149
|
-
* })
|
|
1150
|
-
* ```
|
|
1151
|
-
*/
|
|
1152
|
-
async removeFromContextGroup(target) {
|
|
1153
|
-
this.wire.sendAction('interop-client-remove-from-context-group').catch((e) => {
|
|
1154
|
-
// don't expose, analytics-only call
|
|
1155
|
-
});
|
|
1156
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1157
|
-
return client.dispatch('removeFromContextGroup', { target });
|
|
1158
|
-
}
|
|
1159
|
-
/**
|
|
1160
|
-
* Gets all clients for a context group.
|
|
1161
|
-
*
|
|
1162
|
-
* @remarks **This is primarily used for platform windows. Views within a platform should not have to use this API.**
|
|
1163
|
-
*
|
|
1164
|
-
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
1165
|
-
* @param contextGroupId - The id of context group you wish to get clients for.
|
|
1166
|
-
*
|
|
1167
|
-
* @example
|
|
1168
|
-
* ```js
|
|
1169
|
-
* fin.me.interop.getAllClientsInContextGroup('red')
|
|
1170
|
-
* .then(clientsInContextGroup => {
|
|
1171
|
-
* console.log(clientsInContextGroup)
|
|
1172
|
-
* })
|
|
1173
|
-
* ```
|
|
1174
|
-
*/
|
|
1175
|
-
async getAllClientsInContextGroup(contextGroupId) {
|
|
1176
|
-
this.wire.sendAction('interop-client-get-all-clients-in-context-group').catch((e) => {
|
|
1177
|
-
// don't expose, analytics-only call
|
|
1178
|
-
});
|
|
1179
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1180
|
-
if (!contextGroupId) {
|
|
1181
|
-
throw new Error('No contextGroupId specified for getAllClientsInContextGroup.');
|
|
1182
|
-
}
|
|
1183
|
-
return client.dispatch('getAllClientsInContextGroup', { contextGroupId });
|
|
1184
|
-
}
|
|
1185
|
-
/**
|
|
1186
|
-
* Gets display info for a context group
|
|
1187
|
-
*
|
|
1188
|
-
* @remarks Used by Platform Windows.
|
|
1189
|
-
* @param contextGroupId - The id of context group you wish to get display info for.
|
|
1190
|
-
*
|
|
1191
|
-
* @example
|
|
1192
|
-
* ```js
|
|
1193
|
-
* fin.me.interop.getInfoForContextGroup('red')
|
|
1194
|
-
* .then(contextGroupInfo => {
|
|
1195
|
-
* console.log(contextGroupInfo.displayMetadata.name)
|
|
1196
|
-
* console.log(contextGroupInfo.displayMetadata.color)
|
|
1197
|
-
* })
|
|
1198
|
-
* ```
|
|
1199
|
-
*/
|
|
1200
|
-
async getInfoForContextGroup(contextGroupId) {
|
|
1201
|
-
this.wire.sendAction('interop-client-get-info-for-context-group').catch((e) => {
|
|
1202
|
-
// don't expose, analytics-only call
|
|
1203
|
-
});
|
|
1204
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1205
|
-
if (!contextGroupId) {
|
|
1206
|
-
throw new Error('No contextGroupId specified for getInfoForContextGroup.');
|
|
1207
|
-
}
|
|
1208
|
-
return client.dispatch('getInfoForContextGroup', { contextGroupId });
|
|
1209
|
-
}
|
|
1210
|
-
/**
|
|
1211
|
-
* Sends an intent to the Interop Broker to resolve.
|
|
1212
|
-
* @param intent - The combination of an action and a context that is passed to an application for resolution.
|
|
1213
|
-
*
|
|
1214
|
-
* @example
|
|
1215
|
-
* ```js
|
|
1216
|
-
* // View wants to fire an Intent after a user clicks on a ticker
|
|
1217
|
-
* tickerElement.on('click', (element) => {
|
|
1218
|
-
* const ticker = element.innerText;
|
|
1219
|
-
* const intent = {
|
|
1220
|
-
* name: 'ViewChart',
|
|
1221
|
-
* context: {type: 'fdc3.instrument', id: { ticker }}
|
|
1222
|
-
* }
|
|
1223
|
-
*
|
|
1224
|
-
* fin.me.interop.fireIntent(intent);
|
|
1225
|
-
* })
|
|
1226
|
-
* ```
|
|
1227
|
-
*/
|
|
1228
|
-
async fireIntent(intent) {
|
|
1229
|
-
this.wire.sendAction('interop-client-fire-intent').catch((e) => {
|
|
1230
|
-
// don't expose, this is only for api analytics purposes
|
|
1231
|
-
});
|
|
1232
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1233
|
-
return client.dispatch('fireIntent', intent);
|
|
1234
|
-
}
|
|
1235
|
-
/**
|
|
1236
|
-
* Adds an intent handler for incoming intents. The last intent sent of the name subscribed to will be received.
|
|
1237
|
-
* @param handler - Registered function meant to handle a specific intent type.
|
|
1238
|
-
* @param intentName - The name of an intent.
|
|
1239
|
-
*
|
|
1240
|
-
* @example
|
|
1241
|
-
* ```js
|
|
1242
|
-
* const intentHandler = (intent) => {
|
|
1243
|
-
* const { context } = intent;
|
|
1244
|
-
* myViewChartHandler(context);
|
|
1245
|
-
* };
|
|
1246
|
-
*
|
|
1247
|
-
* const subscription = await fin.me.interop.registerIntentHandler(intentHandler, 'ViewChart');
|
|
1248
|
-
*
|
|
1249
|
-
* function myAppCloseSequence() {
|
|
1250
|
-
* // to unsubscribe the handler, simply call:
|
|
1251
|
-
* subscription.unsubscribe();
|
|
1252
|
-
* }
|
|
1253
|
-
* ```
|
|
1254
|
-
*/
|
|
1255
|
-
async registerIntentHandler(handler, intentName, options) {
|
|
1256
|
-
this.wire.sendAction('interop-client-register-intent-handler').catch((e) => {
|
|
1257
|
-
// don't expose, this is only for api analytics purposes
|
|
1258
|
-
});
|
|
1259
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1260
|
-
const handlerId = `intent-handler-${intentName}`;
|
|
1261
|
-
const wrappedHandler = (0, utils_1$3.wrapIntentHandler)(handler, handlerId);
|
|
1262
|
-
try {
|
|
1263
|
-
await client.register(handlerId, wrappedHandler);
|
|
1264
|
-
await client.dispatch('intentHandlerRegistered', { handlerId, ...options });
|
|
1265
|
-
}
|
|
1266
|
-
catch (error) {
|
|
1267
|
-
throw new Error('Unable to register intent handler');
|
|
1268
|
-
}
|
|
1269
|
-
return {
|
|
1270
|
-
unsubscribe: async () => {
|
|
1271
|
-
client.remove(handlerId);
|
|
1272
|
-
}
|
|
1273
|
-
};
|
|
1274
|
-
}
|
|
1275
|
-
/**
|
|
1276
|
-
* Gets the last context of the Context Group currently subscribed to. It takes an optional Context Type and returns the
|
|
1277
|
-
* last context of that type.
|
|
1278
|
-
* @param contextType
|
|
1279
|
-
*
|
|
1280
|
-
* @example
|
|
1281
|
-
* ```js
|
|
1282
|
-
* await fin.me.interop.joinContextGroup('yellow');
|
|
1283
|
-
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
|
1284
|
-
* const currentContext = await fin.me.interop.getCurrentContext();
|
|
1285
|
-
*
|
|
1286
|
-
* // with a specific context
|
|
1287
|
-
* await fin.me.interop.joinContextGroup('yellow');
|
|
1288
|
-
* await fin.me.interop.setContext({ type: 'country', id: { ISOALPHA3: 'US' }});
|
|
1289
|
-
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
|
1290
|
-
* const currentContext = await fin.me.interop.getCurrentContext('country');
|
|
1291
|
-
* ```
|
|
1292
|
-
*/
|
|
1293
|
-
async getCurrentContext(contextType) {
|
|
1294
|
-
this.wire.sendAction('interop-client-get-current-context').catch((e) => {
|
|
1295
|
-
// don't expose, analytics-only call
|
|
1296
|
-
});
|
|
1297
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1298
|
-
return client.dispatch('getCurrentContext', { contextType });
|
|
1299
|
-
}
|
|
1300
|
-
/**
|
|
1301
|
-
* Get information for a particular Intent from the Interop Broker.
|
|
1302
|
-
*
|
|
1303
|
-
* @remarks To resolve this info, the function handleInfoForIntent is meant to be overridden in the Interop Broker.
|
|
1304
|
-
* The format for the response will be determined by the App Provider overriding the function.
|
|
1305
|
-
*
|
|
1306
|
-
* @param options
|
|
1307
|
-
*
|
|
1308
|
-
* @example
|
|
1309
|
-
* ```js
|
|
1310
|
-
* const intentInfo = await fin.me.interop.getInfoForIntent('ViewChart');
|
|
1311
|
-
* ```
|
|
1312
|
-
*/
|
|
1313
|
-
async getInfoForIntent(options) {
|
|
1314
|
-
this.wire.sendAction('interop-client-get-info-for-intent').catch((e) => {
|
|
1315
|
-
// don't expose, analytics-only call
|
|
1316
|
-
});
|
|
1317
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1318
|
-
return client.dispatch('getInfoForIntent', options);
|
|
1319
|
-
}
|
|
1320
|
-
/**
|
|
1321
|
-
* Get information from the Interop Broker on all Intents that are meant to handle a particular context.
|
|
1322
|
-
*
|
|
1323
|
-
* @remarks To resolve this info, the function handleInfoForIntentsByContext is meant to be overridden in the Interop Broker.
|
|
1324
|
-
* The format for the response will be determined by the App Provider overriding the function.
|
|
1325
|
-
*
|
|
1326
|
-
* @param context
|
|
1327
|
-
*
|
|
1328
|
-
* @example
|
|
1329
|
-
* ```js
|
|
1330
|
-
* tickerElement.on('click', (element) => {
|
|
1331
|
-
* const ticker = element.innerText;
|
|
1332
|
-
*
|
|
1333
|
-
* const context = {
|
|
1334
|
-
* type: 'fdc3.instrument',
|
|
1335
|
-
* id: {
|
|
1336
|
-
* ticker
|
|
1337
|
-
* }
|
|
1338
|
-
* }
|
|
1339
|
-
*
|
|
1340
|
-
* const intentsInfo = await fin.me.interop.getInfoForIntentByContext(context);
|
|
1341
|
-
* })
|
|
1342
|
-
* ```
|
|
1343
|
-
*/
|
|
1344
|
-
async getInfoForIntentsByContext(context) {
|
|
1345
|
-
this.wire.sendAction('interop-client-get-info-for-intents-by-context').catch((e) => {
|
|
1346
|
-
// don't expose, analytics-only call
|
|
1347
|
-
});
|
|
1348
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1349
|
-
return client.dispatch('getInfoForIntentsByContext', context);
|
|
1350
|
-
}
|
|
1351
|
-
/**
|
|
1352
|
-
* Sends a Context that will be resolved to an Intent by the Interop Broker.
|
|
1353
|
-
* This context accepts a metadata property.
|
|
1354
|
-
*
|
|
1355
|
-
* @remarks To resolve this info, the function handleFiredIntentByContext is meant to be overridden in the Interop Broker.
|
|
1356
|
-
* The format for the response will be determined by the App Provider overriding the function.
|
|
1357
|
-
*
|
|
1358
|
-
* @param context
|
|
1359
|
-
*
|
|
1360
|
-
* @example
|
|
1361
|
-
* ```js
|
|
1362
|
-
* tickerElement.on('click', (element) => {
|
|
1363
|
-
* const ticker = element.innerText;
|
|
1364
|
-
*
|
|
1365
|
-
* const context = {
|
|
1366
|
-
* type: 'fdc3.instrument',
|
|
1367
|
-
* id: {
|
|
1368
|
-
* ticker
|
|
1369
|
-
* }
|
|
1370
|
-
* }
|
|
1371
|
-
*
|
|
1372
|
-
* const intentResolution = await fin.me.interop.fireIntentForContext(context);
|
|
1373
|
-
* })
|
|
1374
|
-
* ```
|
|
1375
|
-
*/
|
|
1376
|
-
async fireIntentForContext(context) {
|
|
1377
|
-
this.wire.sendAction('interop-client-fire-intent-for-context').catch((e) => {
|
|
1378
|
-
// don't expose, analytics-only call
|
|
1379
|
-
});
|
|
1380
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1381
|
-
return client.dispatch('fireIntentForContext', context);
|
|
1382
|
-
}
|
|
1383
|
-
/**
|
|
1384
|
-
* Join the current entity to session context group `sessionContextGroupId` and return a sessionContextGroup instance.
|
|
1385
|
-
* If the sessionContextGroup doesn't exist, one will get created.
|
|
1386
|
-
*
|
|
1387
|
-
* @remarks Session Context Groups do not persist between runs and aren't present on snapshots.
|
|
1388
|
-
* @param sessionContextGroupId - Id of the context group.
|
|
1389
|
-
*
|
|
1390
|
-
* @example
|
|
1391
|
-
* Say we want to have a Session Context Group that holds UI theme information for all apps to consume:
|
|
1392
|
-
*
|
|
1393
|
-
* My color-picker View:
|
|
1394
|
-
* ```js
|
|
1395
|
-
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
|
1396
|
-
*
|
|
1397
|
-
* const myColorPickerElement = document.getElementById('color-palette-picker');
|
|
1398
|
-
* myColorPickerElement.addEventListener('change', event => {
|
|
1399
|
-
* themeSessionContextGroup.setContext({ type: 'color-palette', selection: event.value });
|
|
1400
|
-
* });
|
|
1401
|
-
* ```
|
|
1402
|
-
*
|
|
1403
|
-
* In other views:
|
|
1404
|
-
* ```js
|
|
1405
|
-
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
|
1406
|
-
*
|
|
1407
|
-
* const changeColorPalette = ({ selection }) => {
|
|
1408
|
-
* // change the color palette to the selection
|
|
1409
|
-
* };
|
|
1410
|
-
*
|
|
1411
|
-
* // If the context is already set by the time the handler was set, the handler will get invoked immediately with the current context.
|
|
1412
|
-
* themeSessionContextGroup.addContextHandler(changeColorPalette, 'color-palette');
|
|
1413
|
-
* ```
|
|
1414
|
-
*/
|
|
1415
|
-
async joinSessionContextGroup(sessionContextGroupId) {
|
|
1416
|
-
try {
|
|
1417
|
-
const currentSessionContextGroup = __classPrivateFieldGet$1(this, _InteropClient_sessionContextGroups, "f").get(sessionContextGroupId);
|
|
1418
|
-
if (currentSessionContextGroup) {
|
|
1419
|
-
return currentSessionContextGroup.getUserInstance();
|
|
1420
|
-
}
|
|
1421
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1422
|
-
const { hasConflict } = await client.dispatch('sessionContextGroup:createIfNeeded', {
|
|
1423
|
-
sessionContextGroupId
|
|
1424
|
-
});
|
|
1425
|
-
if (hasConflict) {
|
|
1426
|
-
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.`);
|
|
1427
|
-
}
|
|
1428
|
-
const newSessionContextGroup = new SessionContextGroupClient_1.default(this.wire, __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f"), sessionContextGroupId);
|
|
1429
|
-
__classPrivateFieldGet$1(this, _InteropClient_sessionContextGroups, "f").set(sessionContextGroupId, newSessionContextGroup);
|
|
1430
|
-
return newSessionContextGroup.getUserInstance();
|
|
1431
|
-
}
|
|
1432
|
-
catch (error) {
|
|
1433
|
-
console.error(`Error thrown trying to create Session Context Group with id "${sessionContextGroupId}": ${error}`);
|
|
1434
|
-
throw error;
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
/**
|
|
1438
|
-
* Register a listener that is called when the Interop Client has been disconnected from the Interop Broker.
|
|
1439
|
-
* Only one listener per Interop Client can be set.
|
|
1440
|
-
* @param listener
|
|
1441
|
-
*
|
|
1442
|
-
* @example
|
|
1443
|
-
* ```js
|
|
1444
|
-
* const listener = (event) => {
|
|
1445
|
-
* const { type, topic, brokerName} = event;
|
|
1446
|
-
* console.log(`Disconnected from Interop Broker ${brokerName} `);
|
|
1447
|
-
* }
|
|
1448
|
-
*
|
|
1449
|
-
* await fin.me.interop.onDisconnection(listener);
|
|
1450
|
-
* ```
|
|
1451
|
-
*/
|
|
1452
|
-
async onDisconnection(listener) {
|
|
1453
|
-
this.wire.sendAction('interop-client-add-ondisconnection-listener').catch((e) => {
|
|
1454
|
-
// don't expose, analytics-only call
|
|
1455
|
-
});
|
|
1456
|
-
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1457
|
-
return client.onDisconnection((event) => {
|
|
1458
|
-
const { uuid } = event;
|
|
1459
|
-
listener({ type: 'interop-broker', topic: 'disconnected', brokerName: uuid });
|
|
1460
|
-
});
|
|
1461
|
-
}
|
|
1462
|
-
getFDC3Sync(version) {
|
|
1463
|
-
return __classPrivateFieldGet$1(this, _InteropClient_fdc3Factory, "f").call(this, version, this, this.wire);
|
|
1464
|
-
}
|
|
1465
|
-
async getFDC3(version) {
|
|
1466
|
-
return this.getFDC3Sync(version);
|
|
1467
|
-
}
|
|
1468
|
-
/**
|
|
1469
|
-
* @internal
|
|
1470
|
-
*
|
|
1471
|
-
* Used to ferry fdc3-only calls from the fdc3 shim to the Interop Broker
|
|
1472
|
-
*/
|
|
1473
|
-
static async ferryFdc3Call(interopClient, action, payload) {
|
|
1474
|
-
const client = await __classPrivateFieldGet$1(interopClient, _InteropClient_clientPromise, "f");
|
|
1475
|
-
return client.dispatch(action, payload || null);
|
|
1476
|
-
}
|
|
1477
|
-
}
|
|
1478
|
-
InteropClient$1.InteropClient = InteropClient;
|
|
1479
|
-
_InteropClient_clientPromise = new WeakMap(), _InteropClient_sessionContextGroups = new WeakMap(), _InteropClient_fdc3Factory = new WeakMap();
|
|
813
|
+
var fdc32_0 = {};
|
|
1480
814
|
|
|
1481
|
-
var
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
815
|
+
var hasRequiredFdc32_0;
|
|
816
|
+
|
|
817
|
+
function requireFdc32_0 () {
|
|
818
|
+
if (hasRequiredFdc32_0) return fdc32_0;
|
|
819
|
+
hasRequiredFdc32_0 = 1;
|
|
820
|
+
Object.defineProperty(fdc32_0, "__esModule", { value: true });
|
|
821
|
+
fdc32_0.Fdc3Module2 = void 0;
|
|
822
|
+
const fdc3_common_1 = requireFdc3Common();
|
|
823
|
+
const utils_1 = utils$2;
|
|
824
|
+
const InteropClient_1 = requireInteropClient();
|
|
825
|
+
const utils_2 = utils$1;
|
|
826
|
+
const PrivateChannelClient_1 = PrivateChannelClient$1;
|
|
827
|
+
/**
|
|
828
|
+
* @version 2.0
|
|
829
|
+
* The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
|
|
830
|
+
* while using our Interop API under the hood. In order to use this set of APIs
|
|
831
|
+
* 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
|
|
832
|
+
* our {@link https://developers.openfin.co/of-docs/docs/enable-context-sharing Interop API}.
|
|
833
|
+
*
|
|
834
|
+
* To enable the FDC3 APIs in a {@link Window Window} or {@link View View}, add the fdc3InteropApi
|
|
835
|
+
* property to its options:
|
|
836
|
+
*
|
|
837
|
+
* ```js
|
|
838
|
+
* {
|
|
839
|
+
* autoShow: false,
|
|
840
|
+
* saveWindowState: true,
|
|
841
|
+
* url: 'https://openfin.co',
|
|
842
|
+
* fdc3InteropApi: '2.0'
|
|
843
|
+
* }
|
|
844
|
+
* ```
|
|
845
|
+
*
|
|
846
|
+
* If using a {@link Platform Platform } application, you can set this property in defaultWindowOptions and defaultViewOptions.
|
|
847
|
+
*
|
|
848
|
+
* In order to ensure that the FDC3 Api is ready before use, you can use the 'fdc3Ready' event fired on the DOM Window object:
|
|
849
|
+
*
|
|
850
|
+
* ```js
|
|
851
|
+
* function fdc3Action() {
|
|
852
|
+
* // Make some fdc3 API calls here
|
|
853
|
+
* }
|
|
854
|
+
*
|
|
855
|
+
* if (window.fdc3) {
|
|
856
|
+
* fdc3Action();
|
|
857
|
+
* } else {
|
|
858
|
+
* window.addEventListener('fdc3Ready', fdc3Action);
|
|
859
|
+
* }
|
|
860
|
+
* ```
|
|
861
|
+
*/
|
|
862
|
+
class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
863
|
+
/**
|
|
864
|
+
* Launches an app, specified via an AppIdentifier object.
|
|
865
|
+
* @param app
|
|
866
|
+
* @param context
|
|
867
|
+
*
|
|
868
|
+
* @tutorial fdc3.open
|
|
869
|
+
*/
|
|
870
|
+
async open(app, context) {
|
|
871
|
+
if (typeof app === 'string') {
|
|
872
|
+
console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
|
|
873
|
+
}
|
|
874
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
875
|
+
return super._open(app, context);
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Find all the available instances for a particular application.
|
|
879
|
+
* @param app
|
|
880
|
+
*
|
|
881
|
+
* @tutorial fdc3v2.findInstances
|
|
882
|
+
*/
|
|
883
|
+
async findInstances(app) {
|
|
884
|
+
this.wire.sendAction('fdc3-find-instances').catch((e) => {
|
|
885
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
886
|
+
});
|
|
887
|
+
try {
|
|
888
|
+
return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3FindInstances', app);
|
|
889
|
+
}
|
|
890
|
+
catch (error) {
|
|
891
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fdc3FindInstances ? 'ResolverUnavailable' : error.message;
|
|
892
|
+
throw new Error(errorToThrow);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* 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.
|
|
897
|
+
* @param app
|
|
898
|
+
*
|
|
899
|
+
* @tutorial fdc3v2.getAppMetadata
|
|
900
|
+
*/
|
|
901
|
+
async getAppMetadata(app) {
|
|
902
|
+
this.wire.sendAction('fdc3-get-app-metadata').catch((e) => {
|
|
903
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
904
|
+
});
|
|
905
|
+
try {
|
|
906
|
+
return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3GetAppMetadata', app);
|
|
907
|
+
}
|
|
908
|
+
catch (error) {
|
|
909
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fdc3GetAppMetadata ? 'ResolverUnavailable' : error.message;
|
|
910
|
+
throw new Error(errorToThrow);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* 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.
|
|
915
|
+
* @param contextType
|
|
916
|
+
* @param handler
|
|
917
|
+
*
|
|
918
|
+
* @tutorial fdc3.addContextListener
|
|
919
|
+
*/
|
|
920
|
+
// @ts-expect-error TODO [CORE-1524]
|
|
921
|
+
async addContextListener(contextType, handler) {
|
|
922
|
+
this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
|
|
923
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
924
|
+
});
|
|
925
|
+
// The FDC3 ContextHandler only expects the context and optional ContextMetadata, so we wrap the handler
|
|
926
|
+
// here so it only gets passed these parameters
|
|
927
|
+
const getWrappedHandler = (handlerToWrap) => {
|
|
928
|
+
return (context) => {
|
|
929
|
+
const { contextMetadata, ...rest } = context;
|
|
930
|
+
const args = contextMetadata ? [{ ...rest }, contextMetadata] : [context, null];
|
|
931
|
+
handlerToWrap(...args);
|
|
932
|
+
};
|
|
933
|
+
};
|
|
934
|
+
let actualHandler = handler;
|
|
935
|
+
let wrappedHandler = getWrappedHandler(actualHandler);
|
|
936
|
+
if (typeof contextType === 'function') {
|
|
937
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
938
|
+
actualHandler = contextType;
|
|
939
|
+
wrappedHandler = getWrappedHandler(actualHandler);
|
|
940
|
+
return this.client.addContextHandler(wrappedHandler);
|
|
941
|
+
}
|
|
942
|
+
return this.client.addContextHandler(wrappedHandler, contextType === null ? undefined : contextType);
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Find out more information about a particular intent by passing its name, and optionally its context and resultType.
|
|
946
|
+
* @param intent Name of the Intent
|
|
947
|
+
* @param context Context
|
|
948
|
+
* @param resultType The type of result returned for any intent specified during resolution.
|
|
949
|
+
*
|
|
950
|
+
* @tutorial fdc3.findIntent
|
|
951
|
+
*/
|
|
952
|
+
async findIntent(intent, context, resultType) {
|
|
953
|
+
this.wire.sendAction('fdc3-find-intent').catch((e) => {
|
|
954
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
955
|
+
});
|
|
956
|
+
try {
|
|
957
|
+
return await this.client.getInfoForIntent({ name: intent, context, metadata: { resultType } });
|
|
958
|
+
}
|
|
959
|
+
catch (error) {
|
|
960
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntent ? 'ResolverUnavailable' : error.message;
|
|
961
|
+
throw new Error(errorToThrow);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Find all the available intents for a particular context.
|
|
966
|
+
* @param context
|
|
967
|
+
* @param resultType The type of result returned for any intent specified during resolution.
|
|
968
|
+
*
|
|
969
|
+
* @tutorial fdc3v2.findIntentsByContext
|
|
970
|
+
*/
|
|
971
|
+
async findIntentsByContext(context, resultType) {
|
|
972
|
+
this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
|
|
973
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
974
|
+
});
|
|
975
|
+
const payload = resultType ? { context, metadata: { resultType } } : context;
|
|
976
|
+
try {
|
|
977
|
+
return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3v2FindIntentsByContext', payload);
|
|
978
|
+
}
|
|
979
|
+
catch (error) {
|
|
980
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntentsByContext ? 'ResolverUnavailable' : error.message;
|
|
981
|
+
throw new Error(errorToThrow);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Raises a specific intent for resolution against apps registered with the desktop agent.
|
|
986
|
+
* @param intent Name of the Intent
|
|
987
|
+
* @param context Context associated with the Intent
|
|
988
|
+
* @param app
|
|
989
|
+
*
|
|
990
|
+
* @tutorial fdc3v2.raiseIntent
|
|
991
|
+
*/
|
|
992
|
+
async raiseIntent(intent, context, app) {
|
|
993
|
+
this.wire.sendAction('fdc3-raise-intent').catch((e) => {
|
|
994
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
995
|
+
});
|
|
996
|
+
try {
|
|
997
|
+
if (typeof app === 'string') {
|
|
998
|
+
console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
|
|
999
|
+
}
|
|
1000
|
+
return (0, utils_2.getIntentResolution)(this.client, context, app, intent);
|
|
1001
|
+
}
|
|
1002
|
+
catch (error) {
|
|
1003
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error.message;
|
|
1004
|
+
throw new Error(errorToThrow);
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Finds and raises an intent against apps registered with the desktop agent based purely on the type of the context data.
|
|
1009
|
+
* @param context Context associated with the Intent
|
|
1010
|
+
* @param app
|
|
1011
|
+
*
|
|
1012
|
+
* @tutorial fdc3v2.raiseIntentForContext
|
|
1013
|
+
*/
|
|
1014
|
+
async raiseIntentForContext(context, app) {
|
|
1015
|
+
// TODO: We have to do the same thing we do for raiseIntent here as well.
|
|
1016
|
+
this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
|
|
1017
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1018
|
+
});
|
|
1019
|
+
try {
|
|
1020
|
+
if (typeof app === 'string') {
|
|
1021
|
+
console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
|
|
1022
|
+
}
|
|
1023
|
+
return (0, utils_2.getIntentResolution)(this.client, context, app);
|
|
1024
|
+
}
|
|
1025
|
+
catch (error) {
|
|
1026
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error.message;
|
|
1027
|
+
throw new Error(errorToThrow);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Adds a listener for incoming intents.
|
|
1032
|
+
* @param intent Name of the Intent
|
|
1033
|
+
* @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.
|
|
1034
|
+
*
|
|
1035
|
+
* @tutorial fdc3.addIntentListener
|
|
1036
|
+
*/
|
|
1037
|
+
async addIntentListener(intent, handler) {
|
|
1038
|
+
this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
|
|
1039
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1040
|
+
});
|
|
1041
|
+
if (typeof intent !== 'string') {
|
|
1042
|
+
throw new Error('First argument must be an Intent name');
|
|
1043
|
+
}
|
|
1044
|
+
// The FDC3 Intenter handler only expects the context and contextMetadata to be passed to the handler,
|
|
1045
|
+
// so we wrap it here and only pass those paramaters.
|
|
1046
|
+
const contextHandler = async (raisedIntent) => {
|
|
1047
|
+
let intentResult;
|
|
1048
|
+
let intentResultToSend;
|
|
1049
|
+
const { context, metadata: intentMetadata } = raisedIntent;
|
|
1050
|
+
const { contextMetadata, metadata, ...rest } = context;
|
|
1051
|
+
const intentResolutionResultId = intentMetadata?.intentResolutionResultId || metadata?.intentResolutionResultId;
|
|
1052
|
+
try {
|
|
1053
|
+
const newContext = metadata ? { metadata, ...rest } : { ...rest };
|
|
1054
|
+
intentResult = await handler(newContext, contextMetadata);
|
|
1055
|
+
intentResultToSend = intentResult;
|
|
1056
|
+
}
|
|
1057
|
+
catch (error) {
|
|
1058
|
+
intentResult = error;
|
|
1059
|
+
intentResultToSend = { error: true };
|
|
1060
|
+
}
|
|
1061
|
+
if (intentResolutionResultId) {
|
|
1062
|
+
this.fin.InterApplicationBus.publish(intentResolutionResultId, intentResultToSend).catch(() => null);
|
|
1063
|
+
}
|
|
1064
|
+
if (intentResult instanceof Error) {
|
|
1065
|
+
throw new Error(intentResult.message);
|
|
1066
|
+
}
|
|
1067
|
+
return intentResult;
|
|
1068
|
+
};
|
|
1069
|
+
return this.client.registerIntentHandler(contextHandler, intent, { fdc3Version: '2.0' });
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Returns a Channel object for the specified channel, creating it as an App Channel if it does not exist.
|
|
1073
|
+
* @param channelId
|
|
1074
|
+
*
|
|
1075
|
+
* @tutorial fdc3.getOrCreateChannel
|
|
1076
|
+
*/
|
|
1077
|
+
async getOrCreateChannel(channelId) {
|
|
1078
|
+
return super.getOrCreateChannel(channelId);
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* 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.
|
|
1082
|
+
*
|
|
1083
|
+
* @tutorial fdc3v2.createPrivateChannel
|
|
1084
|
+
*/
|
|
1085
|
+
async createPrivateChannel() {
|
|
1086
|
+
const channelId = (0, utils_1.generateId)();
|
|
1087
|
+
await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'createPrivateChannelProvider', { channelId });
|
|
1088
|
+
const channelClient = await this.fin.InterApplicationBus.Channel.connect(channelId);
|
|
1089
|
+
const newPrivateChannelClient = new PrivateChannelClient_1.PrivateChannelClient(channelClient, channelId);
|
|
1090
|
+
return (0, utils_2.buildPrivateChannelObject)(newPrivateChannelClient);
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Retrieves a list of the User Channels available for the app to join.
|
|
1094
|
+
*
|
|
1095
|
+
* @tutorial fdc3v2.getUserChannels
|
|
1096
|
+
*/
|
|
1097
|
+
async getUserChannels() {
|
|
1098
|
+
const channels = await this.client.getContextGroups();
|
|
1099
|
+
// fdc3 implementation of getUserChannels returns on array of channels, have to decorate over
|
|
1100
|
+
// this so people know that these APIs are not supported
|
|
1101
|
+
return channels.map((channel) => {
|
|
1102
|
+
// @ts-expect-error TODO [CORE-1524]
|
|
1103
|
+
return { ...channel, type: 'user', ...(0, utils_2.getUnsupportedChannelApis)('User') };
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Retrieves a list of the User Channels available for the app to join.
|
|
1108
|
+
*
|
|
1109
|
+
* @deprecated Please use {@link fdc3.getUserChannels fdc3.getUserChannels} instead
|
|
1110
|
+
* @tutorial fdc3.getSystemChannels
|
|
1111
|
+
*/
|
|
1112
|
+
async getSystemChannels() {
|
|
1113
|
+
console.warn('This API has been deprecated. Please use fdc3.getUserChannels instead.');
|
|
1114
|
+
return super.getSystemChannels();
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Join an app to a specified User channel.
|
|
1118
|
+
* @param channelId Channel name
|
|
1119
|
+
*
|
|
1120
|
+
* @tutorial fdc3v2.joinUserChannel
|
|
1121
|
+
*/
|
|
1122
|
+
async joinUserChannel(channelId) {
|
|
1123
|
+
return super.joinChannel(channelId);
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Join an app to a specified User channel.
|
|
1127
|
+
* @param channelId Channel name
|
|
1128
|
+
* @deprecated Please use {@link fdc3.joinUserChannel fdc3.joinUserChannel} instead
|
|
1129
|
+
*
|
|
1130
|
+
* @tutorial fdc3.joinChannel
|
|
1131
|
+
*/
|
|
1132
|
+
async joinChannel(channelId) {
|
|
1133
|
+
console.warn('This API has been deprecated. Please use fdc3.joinUserChannel instead.');
|
|
1134
|
+
return super.joinChannel(channelId);
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Returns the Channel object for the current User channel membership
|
|
1138
|
+
*
|
|
1139
|
+
* @tutorial fdc3.getCurrentChannel
|
|
1140
|
+
*/
|
|
1141
|
+
async getCurrentChannel() {
|
|
1142
|
+
const currentChannel = await super.getCurrentChannel();
|
|
1143
|
+
if (!currentChannel) {
|
|
1144
|
+
return null;
|
|
1145
|
+
}
|
|
1146
|
+
return {
|
|
1147
|
+
...currentChannel,
|
|
1148
|
+
type: 'user',
|
|
1149
|
+
broadcast: this.broadcast.bind(this)
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* 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.
|
|
1154
|
+
* fdc3HandleGetInfo must be overridden in the InteropBroker so that the ImplementationMetadata will have the appMetadata info.
|
|
1155
|
+
*
|
|
1156
|
+
* @tutorial fdc3v2.getInfo
|
|
1157
|
+
*/
|
|
1158
|
+
async getInfo() {
|
|
1159
|
+
return InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3v2GetInfo', { fdc3Version: '2.0' });
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
fdc32_0.Fdc3Module2 = Fdc3Module2;
|
|
1163
|
+
return fdc32_0;
|
|
1714
1164
|
}
|
|
1715
|
-
fdc3Common.FDC3ModuleBase = FDC3ModuleBase;
|
|
1716
|
-
_FDC3ModuleBase_producer = new WeakMap();
|
|
1717
1165
|
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1166
|
+
var hasRequiredInteropClient;
|
|
1167
|
+
|
|
1168
|
+
function requireInteropClient () {
|
|
1169
|
+
if (hasRequiredInteropClient) return InteropClient;
|
|
1170
|
+
hasRequiredInteropClient = 1;
|
|
1171
|
+
var __classPrivateFieldSet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
1172
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
1173
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
1174
|
+
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");
|
|
1175
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
1176
|
+
};
|
|
1177
|
+
var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
1178
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1179
|
+
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");
|
|
1180
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1181
|
+
};
|
|
1182
|
+
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1183
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1184
|
+
};
|
|
1185
|
+
var _InteropClient_clientPromise, _InteropClient_sessionContextGroups;
|
|
1186
|
+
Object.defineProperty(InteropClient, "__esModule", { value: true });
|
|
1187
|
+
InteropClient.InteropClient = void 0;
|
|
1188
|
+
const base_1 = base;
|
|
1189
|
+
const SessionContextGroupClient_1 = __importDefault(SessionContextGroupClient$1);
|
|
1190
|
+
const fdc3_1_2_1 = requireFdc31_2();
|
|
1191
|
+
const fdc3_2_0_1 = requireFdc32_0();
|
|
1192
|
+
const utils_1 = utils$2;
|
|
1193
|
+
/**
|
|
1194
|
+
* The Interop Client API is broken up into two groups:
|
|
1195
|
+
*
|
|
1196
|
+
* **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.
|
|
1197
|
+
*
|
|
1198
|
+
* **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.
|
|
1199
|
+
*
|
|
1200
|
+
* ---
|
|
1201
|
+
*
|
|
1202
|
+
* All APIs are available at the `fin.me.interop` namespace.
|
|
1203
|
+
*
|
|
1204
|
+
* ---
|
|
1205
|
+
*
|
|
1206
|
+
* **You only need 2 things to participate in Interop Context Grouping:**
|
|
1207
|
+
* * A Context Handler for incoming context: {@link InteropClient#addContextHandler addContextHandler(handler, contextType?)}
|
|
1208
|
+
* * Call setContext on your context group when you want to share context with other group members: {@link InteropClient#setContext setContext(context)}
|
|
1209
|
+
*
|
|
1210
|
+
* ---
|
|
1211
|
+
*
|
|
1212
|
+
* ##### Constructor
|
|
1213
|
+
* Returned by {@link Interop.connectSync Interop.connectSync}.
|
|
1214
|
+
*
|
|
1215
|
+
* ---
|
|
1216
|
+
*
|
|
1217
|
+
* ##### Interop methods intended for Views
|
|
1218
|
+
*
|
|
1219
|
+
*
|
|
1220
|
+
* **Context Groups API**
|
|
1221
|
+
* * {@link InteropClient#addContextHandler addContextHandler(handler, contextType?)}
|
|
1222
|
+
* * {@link InteropClient#setContext setContext(context)}
|
|
1223
|
+
* * {@link InteropClient#getCurrentContext getCurrentContext(contextType?)}
|
|
1224
|
+
* * {@link InteropClient#joinSessionContextGroup joinSessionContextGroup(sessionContextGroupId)}
|
|
1225
|
+
*
|
|
1226
|
+
*
|
|
1227
|
+
* **Intents API**
|
|
1228
|
+
* * {@link InteropClient#fireIntent fireIntent(intent)}
|
|
1229
|
+
* * {@link InteropClient#registerIntentHandler registerIntentHandler(intentHandler, intentName)}
|
|
1230
|
+
* * {@link InteropClient#getInfoForIntent getInfoForIntent(infoForIntentOptions)}
|
|
1231
|
+
* * {@link InteropClient#getInfoForIntentsByContext getInfoForIntentsByContext(context)}
|
|
1232
|
+
* * {@link InteropClient#fireIntentForContext fireIntentForContext(contextForIntent)}
|
|
1233
|
+
*
|
|
1234
|
+
* ##### Interop methods intended for Windows
|
|
1235
|
+
* * {@link InteropClient#getContextGroups getContextGroups()}
|
|
1236
|
+
* * {@link InteropClient#joinContextGroup joinContextGroup(contextGroupId, target?)}
|
|
1237
|
+
* * {@link InteropClient#removeFromContextGroup removeFromContextGroup(target?)}
|
|
1238
|
+
* * {@link InteropClient#getInfoForContextGroup getInfoForContextGroup(contextGroupId)}
|
|
1239
|
+
* * {@link InteropClient#getAllClientsInContextGroup getAllClientsInContextGroup(contextGroupId)}
|
|
1240
|
+
*
|
|
1241
|
+
*/
|
|
1242
|
+
let InteropClient$1 = class InteropClient extends base_1.Base {
|
|
1243
|
+
/**
|
|
1244
|
+
* @internal
|
|
1245
|
+
*/
|
|
1246
|
+
constructor(wire, clientPromise) {
|
|
1247
|
+
super(wire);
|
|
1248
|
+
_InteropClient_clientPromise.set(this, void 0);
|
|
1249
|
+
_InteropClient_sessionContextGroups.set(this, void 0);
|
|
1250
|
+
__classPrivateFieldSet(this, _InteropClient_sessionContextGroups, new Map(), "f");
|
|
1251
|
+
__classPrivateFieldSet(this, _InteropClient_clientPromise, clientPromise, "f");
|
|
1252
|
+
}
|
|
1253
|
+
/*
|
|
1254
|
+
Client APIs
|
|
1255
|
+
*/
|
|
1256
|
+
/**
|
|
1257
|
+
* Sets a context for the context group of the current entity.
|
|
1258
|
+
*
|
|
1259
|
+
* @remarks The entity must be part of a context group in order set a context.
|
|
1260
|
+
*
|
|
1261
|
+
* @param context - New context to set.
|
|
1262
|
+
*
|
|
1263
|
+
* @example
|
|
1264
|
+
* ```js
|
|
1265
|
+
* setInstrumentContext = async (ticker) => {
|
|
1266
|
+
* fin.me.interop.setContext({type: 'instrument', id: {ticker}})
|
|
1267
|
+
* }
|
|
1268
|
+
*
|
|
1269
|
+
* // 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
|
|
1270
|
+
* instrumentElement.on('click', (evt) => {
|
|
1271
|
+
* setInstrumentContext(evt.ticker)
|
|
1272
|
+
* })
|
|
1273
|
+
* ```
|
|
1274
|
+
*/
|
|
1275
|
+
async setContext(context) {
|
|
1276
|
+
this.wire.sendAction('interop-client-set-context').catch((e) => {
|
|
1277
|
+
// don't expose, analytics-only call
|
|
1278
|
+
});
|
|
1279
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1280
|
+
return client.dispatch('setContext', { context });
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Add a context handler for incoming context. If an entity is part of a context group, and then sets its context handler,
|
|
1284
|
+
* it will receive all of its declared contexts.
|
|
1285
|
+
*
|
|
1286
|
+
* @param handler - Handler for incoming context.
|
|
1287
|
+
* @param contextType - The type of context you wish to handle.
|
|
1288
|
+
*
|
|
1289
|
+
* @example
|
|
1290
|
+
* ```js
|
|
1291
|
+
* function handleIncomingContext(contextInfo) {
|
|
1292
|
+
* const { type, id } = contextInfo;
|
|
1293
|
+
* switch (type) {
|
|
1294
|
+
* case 'instrument':
|
|
1295
|
+
* handleInstrumentContext(contextInfo);
|
|
1296
|
+
* break;
|
|
1297
|
+
* case 'country':
|
|
1298
|
+
* handleCountryContext(contextInfo);
|
|
1299
|
+
* break;
|
|
1300
|
+
*
|
|
1301
|
+
* default:
|
|
1302
|
+
* break;
|
|
1303
|
+
* }
|
|
1304
|
+
* }
|
|
1305
|
+
*
|
|
1306
|
+
*
|
|
1307
|
+
* function handleInstrumentContext(contextInfo) {
|
|
1308
|
+
* const { type, id } = contextInfo;
|
|
1309
|
+
* console.log('contextInfo for instrument', contextInfo)
|
|
1310
|
+
* }
|
|
1311
|
+
*
|
|
1312
|
+
* function handleCountryContext(contextInfo) {
|
|
1313
|
+
* const { type, id } = contextInfo;
|
|
1314
|
+
* console.log('contextInfo for country', contextInfo)
|
|
1315
|
+
* }
|
|
1316
|
+
*
|
|
1317
|
+
* fin.me.interop.addContextHandler(handleIncomingContext);
|
|
1318
|
+
* ```
|
|
1319
|
+
*
|
|
1320
|
+
*
|
|
1321
|
+
* Passing in a context type as the second parameter will cause the handler to only be invoked with that context type.
|
|
1322
|
+
*
|
|
1323
|
+
* ```js
|
|
1324
|
+
* function handleInstrumentContext(contextInfo) {
|
|
1325
|
+
* const { type, id } = contextInfo;
|
|
1326
|
+
* console.log('contextInfo for instrument', contextInfo)
|
|
1327
|
+
* }
|
|
1328
|
+
*
|
|
1329
|
+
* function handleCountryContext(contextInfo) {
|
|
1330
|
+
* const { type, id } = contextInfo;
|
|
1331
|
+
* console.log('contextInfo for country', contextInfo)
|
|
1332
|
+
* }
|
|
1333
|
+
*
|
|
1334
|
+
*
|
|
1335
|
+
* fin.me.interop.addContextHandler(handleInstrumentContext, 'instrument')
|
|
1336
|
+
* fin.me.interop.addContextHandler(handleCountryContext, 'country')
|
|
1337
|
+
* ```
|
|
1338
|
+
*/
|
|
1339
|
+
async addContextHandler(handler, contextType) {
|
|
1340
|
+
this.wire.sendAction('interop-client-add-context-handler').catch((e) => {
|
|
1341
|
+
// don't expose, analytics-only call
|
|
1342
|
+
});
|
|
1343
|
+
if (typeof handler !== 'function') {
|
|
1344
|
+
throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
|
|
1345
|
+
}
|
|
1346
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1347
|
+
let handlerId;
|
|
1348
|
+
if (contextType) {
|
|
1349
|
+
handlerId = `invokeContextHandler-${contextType}-${(0, utils_1.generateId)()}`;
|
|
1350
|
+
}
|
|
1351
|
+
else {
|
|
1352
|
+
handlerId = 'invokeContextHandler';
|
|
1353
|
+
}
|
|
1354
|
+
const wrappedHandler = (0, utils_1.wrapContextHandler)(handler, handlerId);
|
|
1355
|
+
client.register(handlerId, wrappedHandler);
|
|
1356
|
+
await client.dispatch('contextHandlerRegistered', { handlerId, contextType });
|
|
1357
|
+
return {
|
|
1358
|
+
unsubscribe: async () => {
|
|
1359
|
+
client.remove(handlerId);
|
|
1360
|
+
await client.dispatch('removeContextHandler', { handlerId });
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
/*
|
|
1365
|
+
Platform Window APIs
|
|
1366
|
+
*/
|
|
1367
|
+
/**
|
|
1368
|
+
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
1369
|
+
* Used by Platform Windows.
|
|
1370
|
+
*
|
|
1371
|
+
* @example
|
|
1372
|
+
* ```js
|
|
1373
|
+
* fin.me.interop.getContextGroups()
|
|
1374
|
+
* .then(contextGroups => {
|
|
1375
|
+
* contextGroups.forEach(contextGroup => {
|
|
1376
|
+
* console.log(contextGroup.displayMetadata.name)
|
|
1377
|
+
* console.log(contextGroup.displayMetadata.color)
|
|
1378
|
+
* })
|
|
1379
|
+
* })
|
|
1380
|
+
* ```
|
|
1381
|
+
*/
|
|
1382
|
+
async getContextGroups() {
|
|
1383
|
+
this.wire.sendAction('interop-client-get-context-groups').catch((e) => {
|
|
1384
|
+
// don't expose, analytics-only call
|
|
1385
|
+
});
|
|
1386
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1387
|
+
return client.dispatch('getContextGroups');
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Join all Interop Clients at the given identity to context group `contextGroupId`.
|
|
1391
|
+
* If no target is specified, it adds the sender to the context group.
|
|
1392
|
+
*
|
|
1393
|
+
* @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.
|
|
1394
|
+
* 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.
|
|
1395
|
+
* 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.
|
|
1396
|
+
* Used by Platform Windows.
|
|
1397
|
+
*
|
|
1398
|
+
* @param contextGroupId - Id of the context group.
|
|
1399
|
+
* @param target - Identity of the entity you wish to join to a context group.
|
|
1400
|
+
*
|
|
1401
|
+
* @example
|
|
1402
|
+
* ```js
|
|
1403
|
+
* joinViewToContextGroup = async (contextGroupId, view) => {
|
|
1404
|
+
* await fin.me.interop.joinContextGroup(contextGroupId, view);
|
|
1405
|
+
* }
|
|
1406
|
+
*
|
|
1407
|
+
* getLastFocusedView()
|
|
1408
|
+
* .then(lastFocusedViewIdentity => {
|
|
1409
|
+
* joinViewToContextGroup('red', lastFocusedViewIdentity)
|
|
1410
|
+
* })
|
|
1411
|
+
* ```
|
|
1412
|
+
*/
|
|
1413
|
+
async joinContextGroup(contextGroupId, target) {
|
|
1414
|
+
this.wire.sendAction('interop-client-join-context-group').catch((e) => {
|
|
1415
|
+
// don't expose, analytics-only call
|
|
1416
|
+
});
|
|
1417
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1418
|
+
if (!contextGroupId) {
|
|
1419
|
+
throw new Error('No contextGroupId specified for joinContextGroup.');
|
|
1420
|
+
}
|
|
1421
|
+
return client.dispatch('joinContextGroup', { contextGroupId, target });
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Removes the specified target from a context group.
|
|
1425
|
+
* If no target is specified, it removes the sender from their context group.
|
|
1426
|
+
* Used by Platform Windows.
|
|
1427
|
+
*
|
|
1428
|
+
* @param target - Identity of the entity you wish to join to a context group.
|
|
1429
|
+
*
|
|
1430
|
+
* @example
|
|
1431
|
+
* ```js
|
|
1432
|
+
* removeViewFromContextGroup = async (view) => {
|
|
1433
|
+
* await fin.me.interop.removeFromContextGroup(view);
|
|
1434
|
+
* }
|
|
1435
|
+
*
|
|
1436
|
+
* getLastFocusedView()
|
|
1437
|
+
* .then(lastFocusedViewIdentity => {
|
|
1438
|
+
* removeViewFromContextGroup(lastFocusedViewIdentity)
|
|
1439
|
+
* })
|
|
1440
|
+
* ```
|
|
1441
|
+
*/
|
|
1442
|
+
async removeFromContextGroup(target) {
|
|
1443
|
+
this.wire.sendAction('interop-client-remove-from-context-group').catch((e) => {
|
|
1444
|
+
// don't expose, analytics-only call
|
|
1445
|
+
});
|
|
1446
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1447
|
+
return client.dispatch('removeFromContextGroup', { target });
|
|
1448
|
+
}
|
|
1449
|
+
/**
|
|
1450
|
+
* Gets all clients for a context group.
|
|
1451
|
+
*
|
|
1452
|
+
* @remarks **This is primarily used for platform windows. Views within a platform should not have to use this API.**
|
|
1453
|
+
*
|
|
1454
|
+
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
1455
|
+
* @param contextGroupId - The id of context group you wish to get clients for.
|
|
1456
|
+
*
|
|
1457
|
+
* @example
|
|
1458
|
+
* ```js
|
|
1459
|
+
* fin.me.interop.getAllClientsInContextGroup('red')
|
|
1460
|
+
* .then(clientsInContextGroup => {
|
|
1461
|
+
* console.log(clientsInContextGroup)
|
|
1462
|
+
* })
|
|
1463
|
+
* ```
|
|
1464
|
+
*/
|
|
1465
|
+
async getAllClientsInContextGroup(contextGroupId) {
|
|
1466
|
+
this.wire.sendAction('interop-client-get-all-clients-in-context-group').catch((e) => {
|
|
1467
|
+
// don't expose, analytics-only call
|
|
1468
|
+
});
|
|
1469
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1470
|
+
if (!contextGroupId) {
|
|
1471
|
+
throw new Error('No contextGroupId specified for getAllClientsInContextGroup.');
|
|
1472
|
+
}
|
|
1473
|
+
return client.dispatch('getAllClientsInContextGroup', { contextGroupId });
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Gets display info for a context group
|
|
1477
|
+
*
|
|
1478
|
+
* @remarks Used by Platform Windows.
|
|
1479
|
+
* @param contextGroupId - The id of context group you wish to get display info for.
|
|
1480
|
+
*
|
|
1481
|
+
* @example
|
|
1482
|
+
* ```js
|
|
1483
|
+
* fin.me.interop.getInfoForContextGroup('red')
|
|
1484
|
+
* .then(contextGroupInfo => {
|
|
1485
|
+
* console.log(contextGroupInfo.displayMetadata.name)
|
|
1486
|
+
* console.log(contextGroupInfo.displayMetadata.color)
|
|
1487
|
+
* })
|
|
1488
|
+
* ```
|
|
1489
|
+
*/
|
|
1490
|
+
async getInfoForContextGroup(contextGroupId) {
|
|
1491
|
+
this.wire.sendAction('interop-client-get-info-for-context-group').catch((e) => {
|
|
1492
|
+
// don't expose, analytics-only call
|
|
1493
|
+
});
|
|
1494
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1495
|
+
if (!contextGroupId) {
|
|
1496
|
+
throw new Error('No contextGroupId specified for getInfoForContextGroup.');
|
|
1497
|
+
}
|
|
1498
|
+
return client.dispatch('getInfoForContextGroup', { contextGroupId });
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Sends an intent to the Interop Broker to resolve.
|
|
1502
|
+
* @param intent - The combination of an action and a context that is passed to an application for resolution.
|
|
1503
|
+
*
|
|
1504
|
+
* @example
|
|
1505
|
+
* ```js
|
|
1506
|
+
* // View wants to fire an Intent after a user clicks on a ticker
|
|
1507
|
+
* tickerElement.on('click', (element) => {
|
|
1508
|
+
* const ticker = element.innerText;
|
|
1509
|
+
* const intent = {
|
|
1510
|
+
* name: 'ViewChart',
|
|
1511
|
+
* context: {type: 'fdc3.instrument', id: { ticker }}
|
|
1512
|
+
* }
|
|
1513
|
+
*
|
|
1514
|
+
* fin.me.interop.fireIntent(intent);
|
|
1515
|
+
* })
|
|
1516
|
+
* ```
|
|
1517
|
+
*/
|
|
1518
|
+
async fireIntent(intent) {
|
|
1519
|
+
this.wire.sendAction('interop-client-fire-intent').catch((e) => {
|
|
1520
|
+
// don't expose, this is only for api analytics purposes
|
|
1521
|
+
});
|
|
1522
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1523
|
+
return client.dispatch('fireIntent', intent);
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Adds an intent handler for incoming intents. The last intent sent of the name subscribed to will be received.
|
|
1527
|
+
* @param handler - Registered function meant to handle a specific intent type.
|
|
1528
|
+
* @param intentName - The name of an intent.
|
|
1529
|
+
*
|
|
1530
|
+
* @example
|
|
1531
|
+
* ```js
|
|
1532
|
+
* const intentHandler = (intent) => {
|
|
1533
|
+
* const { context } = intent;
|
|
1534
|
+
* myViewChartHandler(context);
|
|
1535
|
+
* };
|
|
1536
|
+
*
|
|
1537
|
+
* const subscription = await fin.me.interop.registerIntentHandler(intentHandler, 'ViewChart');
|
|
1538
|
+
*
|
|
1539
|
+
* function myAppCloseSequence() {
|
|
1540
|
+
* // to unsubscribe the handler, simply call:
|
|
1541
|
+
* subscription.unsubscribe();
|
|
1542
|
+
* }
|
|
1543
|
+
* ```
|
|
1544
|
+
*/
|
|
1545
|
+
async registerIntentHandler(handler, intentName, options) {
|
|
1546
|
+
this.wire.sendAction('interop-client-register-intent-handler').catch((e) => {
|
|
1547
|
+
// don't expose, this is only for api analytics purposes
|
|
1548
|
+
});
|
|
1549
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1550
|
+
const handlerId = `intent-handler-${intentName}`;
|
|
1551
|
+
const wrappedHandler = (0, utils_1.wrapIntentHandler)(handler, handlerId);
|
|
1552
|
+
try {
|
|
1553
|
+
await client.register(handlerId, wrappedHandler);
|
|
1554
|
+
await client.dispatch('intentHandlerRegistered', { handlerId, ...options });
|
|
1555
|
+
}
|
|
1556
|
+
catch (error) {
|
|
1557
|
+
throw new Error('Unable to register intent handler');
|
|
1558
|
+
}
|
|
1559
|
+
return {
|
|
1560
|
+
unsubscribe: async () => {
|
|
1561
|
+
client.remove(handlerId);
|
|
1562
|
+
}
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
/**
|
|
1566
|
+
* Gets the last context of the Context Group currently subscribed to. It takes an optional Context Type and returns the
|
|
1567
|
+
* last context of that type.
|
|
1568
|
+
* @param contextType
|
|
1569
|
+
*
|
|
1570
|
+
* @example
|
|
1571
|
+
* ```js
|
|
1572
|
+
* await fin.me.interop.joinContextGroup('yellow');
|
|
1573
|
+
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
|
1574
|
+
* const currentContext = await fin.me.interop.getCurrentContext();
|
|
1575
|
+
*
|
|
1576
|
+
* // with a specific context
|
|
1577
|
+
* await fin.me.interop.joinContextGroup('yellow');
|
|
1578
|
+
* await fin.me.interop.setContext({ type: 'country', id: { ISOALPHA3: 'US' }});
|
|
1579
|
+
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
|
1580
|
+
* const currentContext = await fin.me.interop.getCurrentContext('country');
|
|
1581
|
+
* ```
|
|
1582
|
+
*/
|
|
1583
|
+
async getCurrentContext(contextType) {
|
|
1584
|
+
this.wire.sendAction('interop-client-get-current-context').catch((e) => {
|
|
1585
|
+
// don't expose, analytics-only call
|
|
1586
|
+
});
|
|
1587
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1588
|
+
return client.dispatch('getCurrentContext', { contextType });
|
|
1589
|
+
}
|
|
1590
|
+
/**
|
|
1591
|
+
* Get information for a particular Intent from the Interop Broker.
|
|
1592
|
+
*
|
|
1593
|
+
* @remarks To resolve this info, the function handleInfoForIntent is meant to be overridden in the Interop Broker.
|
|
1594
|
+
* The format for the response will be determined by the App Provider overriding the function.
|
|
1595
|
+
*
|
|
1596
|
+
* @param options
|
|
1597
|
+
*
|
|
1598
|
+
* @example
|
|
1599
|
+
* ```js
|
|
1600
|
+
* const intentInfo = await fin.me.interop.getInfoForIntent('ViewChart');
|
|
1601
|
+
* ```
|
|
1602
|
+
*/
|
|
1603
|
+
async getInfoForIntent(options) {
|
|
1604
|
+
this.wire.sendAction('interop-client-get-info-for-intent').catch((e) => {
|
|
1605
|
+
// don't expose, analytics-only call
|
|
1606
|
+
});
|
|
1607
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1608
|
+
return client.dispatch('getInfoForIntent', options);
|
|
1609
|
+
}
|
|
1610
|
+
/**
|
|
1611
|
+
* Get information from the Interop Broker on all Intents that are meant to handle a particular context.
|
|
1612
|
+
*
|
|
1613
|
+
* @remarks To resolve this info, the function handleInfoForIntentsByContext is meant to be overridden in the Interop Broker.
|
|
1614
|
+
* The format for the response will be determined by the App Provider overriding the function.
|
|
1615
|
+
*
|
|
1616
|
+
* @param context
|
|
1617
|
+
*
|
|
1618
|
+
* @example
|
|
1619
|
+
* ```js
|
|
1620
|
+
* tickerElement.on('click', (element) => {
|
|
1621
|
+
* const ticker = element.innerText;
|
|
1622
|
+
*
|
|
1623
|
+
* const context = {
|
|
1624
|
+
* type: 'fdc3.instrument',
|
|
1625
|
+
* id: {
|
|
1626
|
+
* ticker
|
|
1627
|
+
* }
|
|
1628
|
+
* }
|
|
1629
|
+
*
|
|
1630
|
+
* const intentsInfo = await fin.me.interop.getInfoForIntentByContext(context);
|
|
1631
|
+
* })
|
|
1632
|
+
* ```
|
|
1633
|
+
*/
|
|
1634
|
+
async getInfoForIntentsByContext(context) {
|
|
1635
|
+
this.wire.sendAction('interop-client-get-info-for-intents-by-context').catch((e) => {
|
|
1636
|
+
// don't expose, analytics-only call
|
|
1637
|
+
});
|
|
1638
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1639
|
+
return client.dispatch('getInfoForIntentsByContext', context);
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Sends a Context that will be resolved to an Intent by the Interop Broker.
|
|
1643
|
+
* This context accepts a metadata property.
|
|
1644
|
+
*
|
|
1645
|
+
* @remarks To resolve this info, the function handleFiredIntentByContext is meant to be overridden in the Interop Broker.
|
|
1646
|
+
* The format for the response will be determined by the App Provider overriding the function.
|
|
1647
|
+
*
|
|
1648
|
+
* @param context
|
|
1649
|
+
*
|
|
1650
|
+
* @example
|
|
1651
|
+
* ```js
|
|
1652
|
+
* tickerElement.on('click', (element) => {
|
|
1653
|
+
* const ticker = element.innerText;
|
|
1654
|
+
*
|
|
1655
|
+
* const context = {
|
|
1656
|
+
* type: 'fdc3.instrument',
|
|
1657
|
+
* id: {
|
|
1658
|
+
* ticker
|
|
1659
|
+
* }
|
|
1660
|
+
* }
|
|
1661
|
+
*
|
|
1662
|
+
* const intentResolution = await fin.me.interop.fireIntentForContext(context);
|
|
1663
|
+
* })
|
|
1664
|
+
* ```
|
|
1665
|
+
*/
|
|
1666
|
+
async fireIntentForContext(context) {
|
|
1667
|
+
this.wire.sendAction('interop-client-fire-intent-for-context').catch((e) => {
|
|
1668
|
+
// don't expose, analytics-only call
|
|
1669
|
+
});
|
|
1670
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1671
|
+
return client.dispatch('fireIntentForContext', context);
|
|
1672
|
+
}
|
|
1673
|
+
/**
|
|
1674
|
+
* Join the current entity to session context group `sessionContextGroupId` and return a sessionContextGroup instance.
|
|
1675
|
+
* If the sessionContextGroup doesn't exist, one will get created.
|
|
1676
|
+
*
|
|
1677
|
+
* @remarks Session Context Groups do not persist between runs and aren't present on snapshots.
|
|
1678
|
+
* @param sessionContextGroupId - Id of the context group.
|
|
1679
|
+
*
|
|
1680
|
+
* @example
|
|
1681
|
+
* Say we want to have a Session Context Group that holds UI theme information for all apps to consume:
|
|
1682
|
+
*
|
|
1683
|
+
* My color-picker View:
|
|
1684
|
+
* ```js
|
|
1685
|
+
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
|
1686
|
+
*
|
|
1687
|
+
* const myColorPickerElement = document.getElementById('color-palette-picker');
|
|
1688
|
+
* myColorPickerElement.addEventListener('change', event => {
|
|
1689
|
+
* themeSessionContextGroup.setContext({ type: 'color-palette', selection: event.value });
|
|
1690
|
+
* });
|
|
1691
|
+
* ```
|
|
1692
|
+
*
|
|
1693
|
+
* In other views:
|
|
1694
|
+
* ```js
|
|
1695
|
+
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
|
1696
|
+
*
|
|
1697
|
+
* const changeColorPalette = ({ selection }) => {
|
|
1698
|
+
* // change the color palette to the selection
|
|
1699
|
+
* };
|
|
1700
|
+
*
|
|
1701
|
+
* // If the context is already set by the time the handler was set, the handler will get invoked immediately with the current context.
|
|
1702
|
+
* themeSessionContextGroup.addContextHandler(changeColorPalette, 'color-palette');
|
|
1703
|
+
* ```
|
|
1704
|
+
*/
|
|
1705
|
+
async joinSessionContextGroup(sessionContextGroupId) {
|
|
1706
|
+
try {
|
|
1707
|
+
const currentSessionContextGroup = __classPrivateFieldGet(this, _InteropClient_sessionContextGroups, "f").get(sessionContextGroupId);
|
|
1708
|
+
if (currentSessionContextGroup) {
|
|
1709
|
+
return currentSessionContextGroup.getUserInstance();
|
|
1710
|
+
}
|
|
1711
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1712
|
+
const { hasConflict } = await client.dispatch('sessionContextGroup:createIfNeeded', {
|
|
1713
|
+
sessionContextGroupId
|
|
1714
|
+
});
|
|
1715
|
+
if (hasConflict) {
|
|
1716
|
+
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.`);
|
|
1717
|
+
}
|
|
1718
|
+
const newSessionContextGroup = new SessionContextGroupClient_1.default(this.wire, __classPrivateFieldGet(this, _InteropClient_clientPromise, "f"), sessionContextGroupId);
|
|
1719
|
+
__classPrivateFieldGet(this, _InteropClient_sessionContextGroups, "f").set(sessionContextGroupId, newSessionContextGroup);
|
|
1720
|
+
return newSessionContextGroup.getUserInstance();
|
|
1721
|
+
}
|
|
1722
|
+
catch (error) {
|
|
1723
|
+
console.error(`Error thrown trying to create Session Context Group with id "${sessionContextGroupId}": ${error}`);
|
|
1724
|
+
throw error;
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Register a listener that is called when the Interop Client has been disconnected from the Interop Broker.
|
|
1729
|
+
* Only one listener per Interop Client can be set.
|
|
1730
|
+
* @param listener
|
|
1731
|
+
*
|
|
1732
|
+
* @example
|
|
1733
|
+
* ```js
|
|
1734
|
+
* const listener = (event) => {
|
|
1735
|
+
* const { type, topic, brokerName} = event;
|
|
1736
|
+
* console.log(`Disconnected from Interop Broker ${brokerName} `);
|
|
1737
|
+
* }
|
|
1738
|
+
*
|
|
1739
|
+
* await fin.me.interop.onDisconnection(listener);
|
|
1740
|
+
* ```
|
|
1741
|
+
*/
|
|
1742
|
+
async onDisconnection(listener) {
|
|
1743
|
+
this.wire.sendAction('interop-client-add-ondisconnection-listener').catch((e) => {
|
|
1744
|
+
// don't expose, analytics-only call
|
|
1745
|
+
});
|
|
1746
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
|
1747
|
+
return client.onDisconnection((event) => {
|
|
1748
|
+
const { uuid } = event;
|
|
1749
|
+
listener({ type: 'interop-broker', topic: 'disconnected', brokerName: uuid });
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
getFDC3Sync(version) {
|
|
1753
|
+
switch (version) {
|
|
1754
|
+
case '1.2':
|
|
1755
|
+
return new fdc3_1_2_1.Fdc3Module(() => this, this.wire);
|
|
1756
|
+
case '2.0':
|
|
1757
|
+
return new fdc3_2_0_1.Fdc3Module2(() => this, this.wire);
|
|
1758
|
+
default:
|
|
1759
|
+
throw new Error(`Invalid FDC3 version provided: ${version}. Must be '1.2' or '2.0'`);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
async getFDC3(version) {
|
|
1763
|
+
return this.getFDC3Sync(version);
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* @internal
|
|
1767
|
+
*
|
|
1768
|
+
* Used to ferry fdc3-only calls from the fdc3 shim to the Interop Broker
|
|
1769
|
+
*/
|
|
1770
|
+
static async ferryFdc3Call(interopClient, action, payload) {
|
|
1771
|
+
const client = await __classPrivateFieldGet(interopClient, _InteropClient_clientPromise, "f");
|
|
1772
|
+
return client.dispatch(action, payload || null);
|
|
1773
|
+
}
|
|
1774
|
+
};
|
|
1775
|
+
InteropClient.InteropClient = InteropClient$1;
|
|
1776
|
+
_InteropClient_clientPromise = new WeakMap(), _InteropClient_sessionContextGroups = new WeakMap();
|
|
1777
|
+
return InteropClient;
|
|
1922
1778
|
}
|
|
1923
|
-
exports.Fdc3Module = fdc31_2.Fdc3Module = Fdc3Module;
|
|
1924
1779
|
|
|
1925
|
-
var
|
|
1780
|
+
var hasRequiredFdc3Common;
|
|
1926
1781
|
|
|
1927
|
-
|
|
1782
|
+
function requireFdc3Common () {
|
|
1783
|
+
if (hasRequiredFdc3Common) return fdc3Common;
|
|
1784
|
+
hasRequiredFdc3Common = 1;
|
|
1785
|
+
var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
1786
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1787
|
+
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");
|
|
1788
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1789
|
+
};
|
|
1790
|
+
var __classPrivateFieldSet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
1791
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
1792
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
1793
|
+
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");
|
|
1794
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
1795
|
+
};
|
|
1796
|
+
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1797
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1798
|
+
};
|
|
1799
|
+
var _FDC3ModuleBase_producer;
|
|
1800
|
+
Object.defineProperty(fdc3Common, "__esModule", { value: true });
|
|
1801
|
+
fdc3Common.FDC3ModuleBase = void 0;
|
|
1802
|
+
const utils_1 = utils$1;
|
|
1803
|
+
const utils_2 = utils$2;
|
|
1804
|
+
const InteropClient_1 = requireInteropClient();
|
|
1805
|
+
const isEqual_1 = __importDefault(require$$2);
|
|
1806
|
+
class FDC3ModuleBase {
|
|
1807
|
+
get client() {
|
|
1808
|
+
return __classPrivateFieldGet(this, _FDC3ModuleBase_producer, "f").call(this);
|
|
1809
|
+
}
|
|
1810
|
+
get fin() {
|
|
1811
|
+
return this.wire.getFin();
|
|
1812
|
+
}
|
|
1813
|
+
// eslint-disable-next-line no-useless-constructor
|
|
1814
|
+
constructor(producer, wire) {
|
|
1815
|
+
this.wire = wire;
|
|
1816
|
+
_FDC3ModuleBase_producer.set(this, void 0);
|
|
1817
|
+
__classPrivateFieldSet(this, _FDC3ModuleBase_producer, producer, "f");
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Broadcasts a context for the channel of the current entity.
|
|
1821
|
+
* @param context - New context to set.
|
|
1822
|
+
*
|
|
1823
|
+
* @tutorial fdc3.broadcast
|
|
1824
|
+
* @static
|
|
1825
|
+
*/
|
|
1826
|
+
async broadcast(context) {
|
|
1827
|
+
this.wire.sendAction('fdc3-broadcast').catch((e) => {
|
|
1828
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1829
|
+
});
|
|
1830
|
+
return this.client.setContext(context);
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Launches an app with target information, which can either be a string or an AppMetadata object.
|
|
1834
|
+
* @param app
|
|
1835
|
+
* @param context
|
|
1836
|
+
*
|
|
1837
|
+
* @tutorial fdc3.open
|
|
1838
|
+
*/
|
|
1839
|
+
async _open(app, context) {
|
|
1840
|
+
this.wire.sendAction('fdc3-open').catch((e) => {
|
|
1841
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1842
|
+
});
|
|
1843
|
+
try {
|
|
1844
|
+
return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3Open', { app, context });
|
|
1845
|
+
}
|
|
1846
|
+
catch (error) {
|
|
1847
|
+
const errorToThrow = error.message === utils_2.BROKER_ERRORS.fdc3Open ? 'ResolverUnavailable' : error.message;
|
|
1848
|
+
throw new Error(errorToThrow);
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
async _getChannels() {
|
|
1852
|
+
const channels = await this.client.getContextGroups();
|
|
1853
|
+
// fdc3 implementation of getSystemChannels returns an array of channels, have to decorate over
|
|
1854
|
+
// this so people know that these APIs are not supported
|
|
1855
|
+
return channels.map((channel) => {
|
|
1856
|
+
return { ...channel, type: 'system', ...(0, utils_1.getUnsupportedChannelApis)() };
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
/**
|
|
1860
|
+
* Returns a Channel object for the specified channel, creating it as an App Channel if it does not exist.
|
|
1861
|
+
* @param channelId
|
|
1862
|
+
*
|
|
1863
|
+
* @tutorial fdc3.getOrCreateChannel
|
|
1864
|
+
*/
|
|
1865
|
+
async getOrCreateChannel(channelId) {
|
|
1866
|
+
this.wire.sendAction('fdc3-get-or-create-channel').catch((e) => {
|
|
1867
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1868
|
+
});
|
|
1869
|
+
const systemChannels = await this._getChannels();
|
|
1870
|
+
const userChannel = systemChannels.find((channel) => channel.id === channelId);
|
|
1871
|
+
if (userChannel) {
|
|
1872
|
+
return { ...userChannel, type: 'system', ...(0, utils_1.getUnsupportedChannelApis)() };
|
|
1873
|
+
}
|
|
1874
|
+
try {
|
|
1875
|
+
const sessionContextGroup = await this.client.joinSessionContextGroup(channelId);
|
|
1876
|
+
return (0, utils_1.buildAppChannelObject)(sessionContextGroup);
|
|
1877
|
+
}
|
|
1878
|
+
catch (error) {
|
|
1879
|
+
console.error(error.message);
|
|
1880
|
+
throw new Error(utils_1.ChannelError.CreationFailed);
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
/**
|
|
1884
|
+
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
1885
|
+
*
|
|
1886
|
+
* @tutorial fdc3.getSystemChannels
|
|
1887
|
+
* @static
|
|
1888
|
+
*/
|
|
1889
|
+
async getSystemChannels() {
|
|
1890
|
+
this.wire.sendAction('fdc3-get-system-channels').catch((e) => {
|
|
1891
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1892
|
+
});
|
|
1893
|
+
return this._getChannels();
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* Join all Interop Clients at the given identity to context group `contextGroupId`.
|
|
1897
|
+
* If no target is specified, it adds the sender to the context group.
|
|
1898
|
+
* 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.
|
|
1899
|
+
* 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.
|
|
1900
|
+
* 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.
|
|
1901
|
+
* @param channelId - Id of the context group.
|
|
1902
|
+
*
|
|
1903
|
+
* @tutorial fdc3.joinChannel
|
|
1904
|
+
* @static
|
|
1905
|
+
*/
|
|
1906
|
+
async joinChannel(channelId) {
|
|
1907
|
+
this.wire.sendAction('fdc3-join-channel').catch((e) => {
|
|
1908
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1909
|
+
});
|
|
1910
|
+
try {
|
|
1911
|
+
return await this.client.joinContextGroup(channelId);
|
|
1912
|
+
}
|
|
1913
|
+
catch (error) {
|
|
1914
|
+
if (error.message === utils_2.BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup) {
|
|
1915
|
+
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.');
|
|
1916
|
+
}
|
|
1917
|
+
else {
|
|
1918
|
+
console.error(error.message);
|
|
1919
|
+
}
|
|
1920
|
+
if (error.message.startsWith('Attempting to join a context group that does not exist')) {
|
|
1921
|
+
throw new Error(utils_1.ChannelError.NoChannelFound);
|
|
1922
|
+
}
|
|
1923
|
+
throw new Error(utils_1.ChannelError.AccessDenied);
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
/**
|
|
1927
|
+
* Returns the Channel that the entity is subscribed to. Returns null if not joined to a channel.
|
|
1928
|
+
*
|
|
1929
|
+
* @tutorial fdc3.getCurrentChannel
|
|
1930
|
+
*/
|
|
1931
|
+
async getCurrentChannel() {
|
|
1932
|
+
this.wire.sendAction('fdc3-get-current-channel').catch((e) => {
|
|
1933
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1934
|
+
});
|
|
1935
|
+
const currentContextGroupInfo = await this.getCurrentContextGroupInfo();
|
|
1936
|
+
if (!currentContextGroupInfo) {
|
|
1937
|
+
return null;
|
|
1938
|
+
}
|
|
1939
|
+
return this.buildChannelObject(currentContextGroupInfo);
|
|
1940
|
+
}
|
|
1941
|
+
/**
|
|
1942
|
+
* Removes the specified target from a context group.
|
|
1943
|
+
* If no target is specified, it removes the sender from their context group.
|
|
1944
|
+
*
|
|
1945
|
+
* @tutorial fdc3.leaveCurrentChannel
|
|
1946
|
+
* @static
|
|
1947
|
+
*/
|
|
1948
|
+
async leaveCurrentChannel() {
|
|
1949
|
+
this.wire.sendAction('fdc3-leave-current-channel').catch((e) => {
|
|
1950
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1951
|
+
});
|
|
1952
|
+
return this.client.removeFromContextGroup();
|
|
1953
|
+
}
|
|
1954
|
+
// utils
|
|
1955
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1956
|
+
async getCurrentContextGroupInfo() {
|
|
1957
|
+
const contextGroups = await this.client.getContextGroups();
|
|
1958
|
+
const clientsInCtxGroupsPromise = contextGroups.map(async (ctxGroup) => {
|
|
1959
|
+
return this.client.getAllClientsInContextGroup(ctxGroup.id);
|
|
1960
|
+
});
|
|
1961
|
+
const clientsInCtxGroups = await Promise.all(clientsInCtxGroupsPromise);
|
|
1962
|
+
const clientIdx = clientsInCtxGroups.findIndex((clientIdentityArr) => {
|
|
1963
|
+
return clientIdentityArr.some((clientIdentity) => {
|
|
1964
|
+
const { uuid, name } = clientIdentity;
|
|
1965
|
+
return this.wire.me.uuid === uuid && this.wire.me.name === name;
|
|
1966
|
+
});
|
|
1967
|
+
});
|
|
1968
|
+
return contextGroups[clientIdx];
|
|
1969
|
+
}
|
|
1970
|
+
async buildChannelObject(currentContextGroupInfo) {
|
|
1971
|
+
// @ts-expect-error
|
|
1972
|
+
return {
|
|
1973
|
+
...currentContextGroupInfo,
|
|
1974
|
+
type: 'system',
|
|
1975
|
+
addContextListener: (...[contextType, handler]) => {
|
|
1976
|
+
let realHandler;
|
|
1977
|
+
let realType;
|
|
1978
|
+
if (typeof contextType === 'function') {
|
|
1979
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
1980
|
+
realHandler = contextType;
|
|
1981
|
+
}
|
|
1982
|
+
else {
|
|
1983
|
+
realHandler = handler;
|
|
1984
|
+
if (typeof contextType === 'string') {
|
|
1985
|
+
realType = contextType;
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
const listener = (async () => {
|
|
1989
|
+
let first = true;
|
|
1990
|
+
const currentContext = await this.client.getCurrentContext(realType);
|
|
1991
|
+
const wrappedHandler = (context, contextMetadata) => {
|
|
1992
|
+
if (first) {
|
|
1993
|
+
first = false;
|
|
1994
|
+
if ((0, isEqual_1.default)(currentContext, context)) {
|
|
1995
|
+
return;
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
// eslint-disable-next-line consistent-return
|
|
1999
|
+
return realHandler(context, contextMetadata);
|
|
2000
|
+
};
|
|
2001
|
+
return this.client.addContextHandler(wrappedHandler, realType);
|
|
2002
|
+
})();
|
|
2003
|
+
// @ts-expect-error TODO [CORE-1524]
|
|
2004
|
+
return {
|
|
2005
|
+
...listener,
|
|
2006
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
2007
|
+
};
|
|
2008
|
+
},
|
|
2009
|
+
broadcast: this.broadcast.bind(this),
|
|
2010
|
+
// @ts-expect-error Typescript fails to infer the returntype is a Promise
|
|
2011
|
+
getCurrentContext: async (contextType) => {
|
|
2012
|
+
const context = await this.client.getCurrentContext(contextType);
|
|
2013
|
+
// @ts-expect-error Typescript fails to infer the returntype is a Promise
|
|
2014
|
+
return context === undefined ? null : context;
|
|
2015
|
+
}
|
|
2016
|
+
};
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
fdc3Common.FDC3ModuleBase = FDC3ModuleBase;
|
|
2020
|
+
_FDC3ModuleBase_producer = new WeakMap();
|
|
2021
|
+
return fdc3Common;
|
|
2022
|
+
}
|
|
1928
2023
|
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
* @param intent Name of the Intent
|
|
2142
|
-
* @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.
|
|
2143
|
-
*
|
|
2144
|
-
* @tutorial fdc3.addIntentListener
|
|
2145
|
-
*/
|
|
2146
|
-
async addIntentListener(intent, handler) {
|
|
2147
|
-
this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
|
|
2148
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2149
|
-
});
|
|
2150
|
-
if (typeof intent !== 'string') {
|
|
2151
|
-
throw new Error('First argument must be an Intent name');
|
|
2152
|
-
}
|
|
2153
|
-
// The FDC3 Intenter handler only expects the context and contextMetadata to be passed to the handler,
|
|
2154
|
-
// so we wrap it here and only pass those paramaters.
|
|
2155
|
-
const contextHandler = async (raisedIntent) => {
|
|
2156
|
-
let intentResult;
|
|
2157
|
-
let intentResultToSend;
|
|
2158
|
-
const { context, metadata: intentMetadata } = raisedIntent;
|
|
2159
|
-
const { contextMetadata, metadata, ...rest } = context;
|
|
2160
|
-
const intentResolutionResultId = intentMetadata?.intentResolutionResultId || metadata?.intentResolutionResultId;
|
|
2161
|
-
try {
|
|
2162
|
-
const newContext = metadata ? { metadata, ...rest } : { ...rest };
|
|
2163
|
-
intentResult = await handler(newContext, contextMetadata);
|
|
2164
|
-
intentResultToSend = intentResult;
|
|
2165
|
-
}
|
|
2166
|
-
catch (error) {
|
|
2167
|
-
intentResult = error;
|
|
2168
|
-
intentResultToSend = { error: true };
|
|
2169
|
-
}
|
|
2170
|
-
if (intentResolutionResultId) {
|
|
2171
|
-
this.fin.InterApplicationBus.publish(intentResolutionResultId, intentResultToSend).catch(() => null);
|
|
2172
|
-
}
|
|
2173
|
-
if (intentResult instanceof Error) {
|
|
2174
|
-
throw new Error(intentResult.message);
|
|
2175
|
-
}
|
|
2176
|
-
return intentResult;
|
|
2177
|
-
};
|
|
2178
|
-
return this.client.registerIntentHandler(contextHandler, intent, { fdc3Version: '2.0' });
|
|
2179
|
-
}
|
|
2180
|
-
/**
|
|
2181
|
-
* Returns a Channel object for the specified channel, creating it as an App Channel if it does not exist.
|
|
2182
|
-
* @param channelId
|
|
2183
|
-
*
|
|
2184
|
-
* @tutorial fdc3.getOrCreateChannel
|
|
2185
|
-
*/
|
|
2186
|
-
async getOrCreateChannel(channelId) {
|
|
2187
|
-
return super.getOrCreateChannel(channelId);
|
|
2188
|
-
}
|
|
2189
|
-
/**
|
|
2190
|
-
* 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.
|
|
2191
|
-
*
|
|
2192
|
-
* @tutorial fdc3v2.createPrivateChannel
|
|
2193
|
-
*/
|
|
2194
|
-
async createPrivateChannel() {
|
|
2195
|
-
const channelId = (0, utils_1.generateId)();
|
|
2196
|
-
await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'createPrivateChannelProvider', { channelId });
|
|
2197
|
-
const channelClient = await this.fin.InterApplicationBus.Channel.connect(channelId);
|
|
2198
|
-
const newPrivateChannelClient = new PrivateChannelClient_1.PrivateChannelClient(channelClient, channelId);
|
|
2199
|
-
return (0, utils_2.buildPrivateChannelObject)(newPrivateChannelClient);
|
|
2200
|
-
}
|
|
2201
|
-
/**
|
|
2202
|
-
* Retrieves a list of the User Channels available for the app to join.
|
|
2203
|
-
*
|
|
2204
|
-
* @tutorial fdc3v2.getUserChannels
|
|
2205
|
-
*/
|
|
2206
|
-
async getUserChannels() {
|
|
2207
|
-
const channels = await this.client.getContextGroups();
|
|
2208
|
-
// fdc3 implementation of getUserChannels returns on array of channels, have to decorate over
|
|
2209
|
-
// this so people know that these APIs are not supported
|
|
2210
|
-
return channels.map((channel) => {
|
|
2211
|
-
// @ts-expect-error TODO [CORE-1524]
|
|
2212
|
-
return { ...channel, type: 'user', ...(0, utils_2.getUnsupportedChannelApis)('User') };
|
|
2213
|
-
});
|
|
2214
|
-
}
|
|
2215
|
-
/**
|
|
2216
|
-
* Retrieves a list of the User Channels available for the app to join.
|
|
2217
|
-
*
|
|
2218
|
-
* @deprecated Please use {@link fdc3.getUserChannels fdc3.getUserChannels} instead
|
|
2219
|
-
* @tutorial fdc3.getSystemChannels
|
|
2220
|
-
*/
|
|
2221
|
-
async getSystemChannels() {
|
|
2222
|
-
console.warn('This API has been deprecated. Please use fdc3.getUserChannels instead.');
|
|
2223
|
-
return super.getSystemChannels();
|
|
2224
|
-
}
|
|
2225
|
-
/**
|
|
2226
|
-
* Join an app to a specified User channel.
|
|
2227
|
-
* @param channelId Channel name
|
|
2228
|
-
*
|
|
2229
|
-
* @tutorial fdc3v2.joinUserChannel
|
|
2230
|
-
*/
|
|
2231
|
-
async joinUserChannel(channelId) {
|
|
2232
|
-
return super.joinChannel(channelId);
|
|
2233
|
-
}
|
|
2234
|
-
/**
|
|
2235
|
-
* Join an app to a specified User channel.
|
|
2236
|
-
* @param channelId Channel name
|
|
2237
|
-
* @deprecated Please use {@link fdc3.joinUserChannel fdc3.joinUserChannel} instead
|
|
2238
|
-
*
|
|
2239
|
-
* @tutorial fdc3.joinChannel
|
|
2240
|
-
*/
|
|
2241
|
-
async joinChannel(channelId) {
|
|
2242
|
-
console.warn('This API has been deprecated. Please use fdc3.joinUserChannel instead.');
|
|
2243
|
-
return super.joinChannel(channelId);
|
|
2244
|
-
}
|
|
2245
|
-
/**
|
|
2246
|
-
* Returns the Channel object for the current User channel membership
|
|
2247
|
-
*
|
|
2248
|
-
* @tutorial fdc3.getCurrentChannel
|
|
2249
|
-
*/
|
|
2250
|
-
async getCurrentChannel() {
|
|
2251
|
-
const currentChannel = await super.getCurrentChannel();
|
|
2252
|
-
if (!currentChannel) {
|
|
2253
|
-
return null;
|
|
2254
|
-
}
|
|
2255
|
-
return {
|
|
2256
|
-
...currentChannel,
|
|
2257
|
-
type: 'user',
|
|
2258
|
-
broadcast: this.broadcast.bind(this)
|
|
2259
|
-
};
|
|
2260
|
-
}
|
|
2261
|
-
/**
|
|
2262
|
-
* 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.
|
|
2263
|
-
* fdc3HandleGetInfo must be overridden in the InteropBroker so that the ImplementationMetadata will have the appMetadata info.
|
|
2264
|
-
*
|
|
2265
|
-
* @tutorial fdc3v2.getInfo
|
|
2266
|
-
*/
|
|
2267
|
-
async getInfo() {
|
|
2268
|
-
return InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3v2GetInfo', { fdc3Version: '2.0' });
|
|
2269
|
-
}
|
|
2024
|
+
var hasRequiredFdc31_2;
|
|
2025
|
+
|
|
2026
|
+
function requireFdc31_2 () {
|
|
2027
|
+
if (hasRequiredFdc31_2) return fdc31_2;
|
|
2028
|
+
hasRequiredFdc31_2 = 1;
|
|
2029
|
+
Object.defineProperty(fdc31_2, "__esModule", { value: true });
|
|
2030
|
+
fdc31_2.Fdc3Module = void 0;
|
|
2031
|
+
const utils_1 = utils$2;
|
|
2032
|
+
const fdc3_common_1 = requireFdc3Common();
|
|
2033
|
+
/**
|
|
2034
|
+
* @version 1.2
|
|
2035
|
+
* The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
|
|
2036
|
+
* while using our Interop API under the hood. In order to use this set of APIs
|
|
2037
|
+
* 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
|
|
2038
|
+
* our {@link https://developers.openfin.co/of-docs/docs/enable-color-linking Interop API}.
|
|
2039
|
+
*
|
|
2040
|
+
* To enable the FDC3 APIs in a {@link Window Window} or {@link View View}, add the fdc3InteropApi
|
|
2041
|
+
* property to its options:
|
|
2042
|
+
*
|
|
2043
|
+
* ```js
|
|
2044
|
+
* {
|
|
2045
|
+
* autoShow: false,
|
|
2046
|
+
* saveWindowState: true,
|
|
2047
|
+
* url: 'https://openfin.co',
|
|
2048
|
+
* fdc3InteropApi: '1.2'
|
|
2049
|
+
* }
|
|
2050
|
+
* ```
|
|
2051
|
+
*
|
|
2052
|
+
* If using a {@link Platform Platform } application, you can set this property in defaultWindowOptions and defaultViewOptions.
|
|
2053
|
+
*
|
|
2054
|
+
* In order to ensure that the FDC3 Api is ready before use, you can use the 'fdc3Ready' event fired on the DOM Window object:
|
|
2055
|
+
*
|
|
2056
|
+
* ```js
|
|
2057
|
+
* function fdc3Action() {
|
|
2058
|
+
* // Make some fdc3 API calls here
|
|
2059
|
+
* }
|
|
2060
|
+
*
|
|
2061
|
+
* if (window.fdc3) {
|
|
2062
|
+
* fdc3Action();
|
|
2063
|
+
* } else {
|
|
2064
|
+
* window.addEventListener('fdc3Ready', fdc3Action);
|
|
2065
|
+
* }
|
|
2066
|
+
* ```
|
|
2067
|
+
*/
|
|
2068
|
+
class Fdc3Module extends fdc3_common_1.FDC3ModuleBase {
|
|
2069
|
+
async open(app, context) {
|
|
2070
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
2071
|
+
await super._open(app, context);
|
|
2072
|
+
}
|
|
2073
|
+
/**
|
|
2074
|
+
* 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.
|
|
2075
|
+
* @param contextType - The type of context you wish to handle.
|
|
2076
|
+
* @param handler - Handler for incoming context.
|
|
2077
|
+
*
|
|
2078
|
+
* @tutorial fdc3.addContextListener
|
|
2079
|
+
* @static
|
|
2080
|
+
*/
|
|
2081
|
+
// @ts-expect-error TODO [CORE-1524]
|
|
2082
|
+
addContextListener(contextType, handler) {
|
|
2083
|
+
this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
|
|
2084
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2085
|
+
});
|
|
2086
|
+
let listener;
|
|
2087
|
+
if (typeof contextType === 'function') {
|
|
2088
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
2089
|
+
listener = this.client.addContextHandler(contextType);
|
|
2090
|
+
}
|
|
2091
|
+
else {
|
|
2092
|
+
listener = this.client.addContextHandler(handler, contextType === null ? undefined : contextType);
|
|
2093
|
+
}
|
|
2094
|
+
return {
|
|
2095
|
+
...listener,
|
|
2096
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
2097
|
+
};
|
|
2098
|
+
}
|
|
2099
|
+
/**
|
|
2100
|
+
* Adds a listener for incoming Intents.
|
|
2101
|
+
* @param intent - Name of the Intent
|
|
2102
|
+
* @param handler - Handler for incoming Intent
|
|
2103
|
+
*
|
|
2104
|
+
* @tutorial fdc3.addIntentListener
|
|
2105
|
+
* @static
|
|
2106
|
+
*/
|
|
2107
|
+
addIntentListener(intent, handler) {
|
|
2108
|
+
this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
|
|
2109
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2110
|
+
});
|
|
2111
|
+
const contextHandler = (raisedIntent) => {
|
|
2112
|
+
const { context, metadata: intentMetadata } = raisedIntent;
|
|
2113
|
+
const { metadata } = context;
|
|
2114
|
+
const intentResolutionResultId = intentMetadata?.intentResolutionResultId || metadata?.intentResolutionResultId;
|
|
2115
|
+
if (intentResolutionResultId) {
|
|
2116
|
+
this.fin.InterApplicationBus.publish(intentResolutionResultId, null).catch(() => null);
|
|
2117
|
+
}
|
|
2118
|
+
handler(raisedIntent.context);
|
|
2119
|
+
};
|
|
2120
|
+
const listener = this.client.registerIntentHandler(contextHandler, intent, {
|
|
2121
|
+
fdc3Version: '1.2'
|
|
2122
|
+
});
|
|
2123
|
+
return {
|
|
2124
|
+
...listener,
|
|
2125
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
2128
|
+
/**
|
|
2129
|
+
* Raises a specific intent.
|
|
2130
|
+
* @param intent Name of the Intent.
|
|
2131
|
+
* @param context Context associated with the Intent.
|
|
2132
|
+
* @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}.
|
|
2133
|
+
*
|
|
2134
|
+
* @tutorial fdc3.raiseIntent
|
|
2135
|
+
* @static
|
|
2136
|
+
*/
|
|
2137
|
+
async raiseIntent(intent, context, app) {
|
|
2138
|
+
this.wire.sendAction('fdc3-raise-intent').catch((e) => {
|
|
2139
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2140
|
+
});
|
|
2141
|
+
const intentObj = app
|
|
2142
|
+
? { name: intent, context, metadata: { target: app } }
|
|
2143
|
+
: { name: intent, context };
|
|
2144
|
+
try {
|
|
2145
|
+
return await this.client.fireIntent(intentObj);
|
|
2146
|
+
}
|
|
2147
|
+
catch (error) {
|
|
2148
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error.message;
|
|
2149
|
+
throw new Error(errorToThrow);
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
/**
|
|
2153
|
+
* Find out more information about a particular intent by passing its name, and optionally its context.
|
|
2154
|
+
* @param intent Name of the Intent
|
|
2155
|
+
* @param context
|
|
2156
|
+
*
|
|
2157
|
+
* @tutorial fdc3.findIntent
|
|
2158
|
+
*/
|
|
2159
|
+
async findIntent(intent, context) {
|
|
2160
|
+
this.wire.sendAction('fdc3-find-intent').catch((e) => {
|
|
2161
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2162
|
+
});
|
|
2163
|
+
try {
|
|
2164
|
+
return await this.client.getInfoForIntent({ name: intent, context });
|
|
2165
|
+
}
|
|
2166
|
+
catch (error) {
|
|
2167
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntent ? 'ResolverUnavailable' : error.message;
|
|
2168
|
+
throw new Error(errorToThrow);
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
/**
|
|
2172
|
+
* Find all the available intents for a particular context.
|
|
2173
|
+
* @param context
|
|
2174
|
+
*
|
|
2175
|
+
* @tutorial fdc3.findIntentsByContext
|
|
2176
|
+
*/
|
|
2177
|
+
async findIntentsByContext(context) {
|
|
2178
|
+
this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
|
|
2179
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2180
|
+
});
|
|
2181
|
+
try {
|
|
2182
|
+
return await this.client.getInfoForIntentsByContext(context);
|
|
2183
|
+
}
|
|
2184
|
+
catch (error) {
|
|
2185
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntentsByContext ? 'ResolverUnavailable' : error.message;
|
|
2186
|
+
throw new Error(errorToThrow);
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
/**
|
|
2190
|
+
* Finds and raises an intent against a target app based purely on context data.
|
|
2191
|
+
* @param context
|
|
2192
|
+
* @param app
|
|
2193
|
+
*
|
|
2194
|
+
* @tutorial fdc3.raiseIntentForContext
|
|
2195
|
+
*/
|
|
2196
|
+
async raiseIntentForContext(context, app) {
|
|
2197
|
+
this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
|
|
2198
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2199
|
+
});
|
|
2200
|
+
try {
|
|
2201
|
+
return await this.client.fireIntentForContext({ ...context, metadata: { target: app } });
|
|
2202
|
+
}
|
|
2203
|
+
catch (error) {
|
|
2204
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntentForContext ? 'ResolverUnavailable' : error.message;
|
|
2205
|
+
throw new Error(errorToThrow);
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
/**
|
|
2209
|
+
* Returns a Channel object for the specified channel, creating it as an App Channel if it does not exist.
|
|
2210
|
+
* @param channelId
|
|
2211
|
+
*
|
|
2212
|
+
* @tutorial fdc3.getOrCreateChannel
|
|
2213
|
+
*/
|
|
2214
|
+
async getOrCreateChannel(channelId) {
|
|
2215
|
+
return super.getOrCreateChannel(channelId);
|
|
2216
|
+
}
|
|
2217
|
+
/**
|
|
2218
|
+
* 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.
|
|
2219
|
+
*
|
|
2220
|
+
* @tutorial fdc3.getInfo
|
|
2221
|
+
*/
|
|
2222
|
+
getInfo() {
|
|
2223
|
+
this.wire.sendAction('fdc3-get-info').catch((e) => {
|
|
2224
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2225
|
+
});
|
|
2226
|
+
const version = this.wire.environment.getAdapterVersionSync();
|
|
2227
|
+
return {
|
|
2228
|
+
providerVersion: version,
|
|
2229
|
+
provider: `openfin-${this.wire.me.uuid}`,
|
|
2230
|
+
fdc3Version: '1.2'
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
fdc31_2.Fdc3Module = Fdc3Module;
|
|
2235
|
+
return fdc31_2;
|
|
2270
2236
|
}
|
|
2271
|
-
|
|
2237
|
+
|
|
2238
|
+
var fdc31_2Exports = requireFdc31_2();
|
|
2239
|
+
|
|
2240
|
+
var fdc3 = {};
|
|
2272
2241
|
|
|
2273
2242
|
(function (exports) {
|
|
2274
2243
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -2276,8 +2245,8 @@ exports.Fdc3Module2 = fdc32_0.Fdc3Module2 = Fdc3Module2;
|
|
|
2276
2245
|
/* eslint-disable no-console */
|
|
2277
2246
|
/* eslint-disable no-param-reassign */
|
|
2278
2247
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2279
|
-
const fdc3_1_2_1 =
|
|
2280
|
-
const fdc3_2_0_1 =
|
|
2248
|
+
const fdc3_1_2_1 = requireFdc31_2();
|
|
2249
|
+
const fdc3_2_0_1 = requireFdc32_0();
|
|
2281
2250
|
exports.versionMap = {
|
|
2282
2251
|
'1.2': fdc3_1_2_1.Fdc3Module,
|
|
2283
2252
|
'2.0': fdc3_2_0_1.Fdc3Module2
|
|
@@ -2296,9 +2265,13 @@ exports.Fdc3Module2 = fdc32_0.Fdc3Module2 = Fdc3Module2;
|
|
|
2296
2265
|
exports.getFdc3 = getFdc3;
|
|
2297
2266
|
} (fdc3));
|
|
2298
2267
|
|
|
2268
|
+
var fdc32_0Exports = requireFdc32_0();
|
|
2269
|
+
|
|
2299
2270
|
async function fdc3FromFin(fin, { fdc3Version } = { fdc3Version: '2.0' }) {
|
|
2300
2271
|
// @ts-expect-error
|
|
2301
2272
|
return fdc3.getFdc3(fin.wire, fdc3Version);
|
|
2302
2273
|
}
|
|
2303
2274
|
|
|
2275
|
+
exports.Fdc3Module = fdc31_2Exports.Fdc3Module;
|
|
2276
|
+
exports.Fdc3Module2 = fdc32_0Exports.Fdc3Module2;
|
|
2304
2277
|
exports.fdc3FromFin = fdc3FromFin;
|