@openfin/fdc3-api 44.100.109 → 44.101.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 +182 -61
- package/out/fdc3-api-beta.d.ts +182 -61
- package/out/fdc3-api-public.d.ts +182 -61
- package/out/fdc3-api.d.ts +182 -61
- package/out/fdc3-api.js +344 -762
- package/package.json +2 -2
package/out/fdc3-api.js
CHANGED
|
@@ -1,121 +1,53 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var esToolkit = require('es-toolkit');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
(
|
|
12
|
-
|
|
13
|
-
exports.checkContextIntegrity = exports.wrapIntentHandler = exports.BROKER_ERRORS = exports.generateOverrideWarning = exports.generateOverrideError = exports.wrapContextHandler = exports.wrapInTryCatch = exports.generateId = void 0;
|
|
14
|
-
const generateId = () => `${Math.random()}${Date.now()}`;
|
|
15
|
-
exports.generateId = generateId;
|
|
16
|
-
const wrapInTryCatch = (f, prefix) => (...args) => {
|
|
17
|
-
try {
|
|
18
|
-
return f(...args);
|
|
19
|
-
}
|
|
20
|
-
catch (e) {
|
|
21
|
-
throw new Error((prefix || '') + e);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
exports.wrapInTryCatch = wrapInTryCatch;
|
|
25
|
-
const wrapContextHandler = (handler, handlerId) => {
|
|
26
|
-
return async (context) => {
|
|
27
|
-
try {
|
|
28
|
-
await handler(context);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
console.error(`Error thrown by handler ${handlerId} for context type ${context.type}: ${error}`);
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
exports.wrapContextHandler = wrapContextHandler;
|
|
37
|
-
const generateOverrideError = (clientApi, brokerApi) => {
|
|
38
|
-
return `You have tried to to use ${clientApi} but ${brokerApi} has not been overridden in the Interop Broker. Please override this function. Refer to our documentation for more info.`;
|
|
39
|
-
};
|
|
40
|
-
exports.generateOverrideError = generateOverrideError;
|
|
41
|
-
const generateOverrideWarning = (fdc3ClientApi, brokerApi, identity, interopClientApi) => {
|
|
42
|
-
const { uuid, name } = identity;
|
|
43
|
-
const message = interopClientApi
|
|
44
|
-
? `Entity with identity: ${uuid}/${name} has called ${interopClientApi} or ${fdc3ClientApi} but ${brokerApi} has not been overridden.`
|
|
45
|
-
: `Entity with identity: ${uuid}/${name} has called ${fdc3ClientApi} but ${brokerApi} has not been overridden.`;
|
|
46
|
-
return message;
|
|
47
|
-
};
|
|
48
|
-
exports.generateOverrideWarning = generateOverrideWarning;
|
|
49
|
-
exports.BROKER_ERRORS = {
|
|
50
|
-
fireIntent: (0, exports.generateOverrideError)('fireIntent', 'handleFiredIntent'),
|
|
51
|
-
fireIntentForContext: (0, exports.generateOverrideError)('fireIntentForContext', 'handleFiredIntentForContext'),
|
|
52
|
-
getInfoForIntent: (0, exports.generateOverrideError)('getInfoForIntent', 'handleInfoForIntent'),
|
|
53
|
-
getInfoForIntentsByContext: (0, exports.generateOverrideError)('getInfoForIntentsByContext', 'handleInfoForIntentsByContext'),
|
|
54
|
-
joinSessionContextGroupWithJoinContextGroup: 'The Context Group you have tried to join is a Session Context Group. Custom Context Groups can only be defined by the Interop Broker through code or manifest configuration. Please use joinSessionContextGroup.',
|
|
55
|
-
fdc3Open: (0, exports.generateOverrideError)('fdc3.open', 'fdc3HandleOpen'),
|
|
56
|
-
fdc3FindInstances: (0, exports.generateOverrideError)('fdc3.findInstances', 'fdc3HandleFindInstances'),
|
|
57
|
-
fdc3GetAppMetadata: (0, exports.generateOverrideError)('fdc3.getAppMetadata', 'fdc3HandleGetAppMetadata'),
|
|
58
|
-
fdc3GetInfo: (0, exports.generateOverrideError)('fdc3.getInfo', 'fdc3HandleGetInfo')
|
|
59
|
-
};
|
|
60
|
-
const wrapIntentHandler = (handler, handlerId) => {
|
|
61
|
-
return async (intent) => {
|
|
62
|
-
try {
|
|
63
|
-
return handler(intent);
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
console.error(`Error thrown by handler ${handlerId}: ${error}`);
|
|
67
|
-
throw error;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
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
|
-
return { isValid: true };
|
|
83
|
-
};
|
|
84
|
-
exports.checkContextIntegrity = checkContextIntegrity;
|
|
85
|
-
} (utils$2));
|
|
86
|
-
|
|
87
|
-
var fdc3Common = {};
|
|
88
|
-
|
|
89
|
-
var utils$1 = {};
|
|
90
|
-
|
|
91
|
-
var PrivateChannelClient$1 = {};
|
|
92
|
-
|
|
93
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
94
|
-
if (k2 === undefined) k2 = k;
|
|
95
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
96
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
97
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
98
|
-
}
|
|
99
|
-
Object.defineProperty(o, k2, desc);
|
|
100
|
-
}) : (function(o, m, k, k2) {
|
|
101
|
-
if (k2 === undefined) k2 = k;
|
|
102
|
-
o[k2] = m[k];
|
|
103
|
-
}));
|
|
104
|
-
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
105
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
106
|
-
}) : function(o, v) {
|
|
107
|
-
o["default"] = v;
|
|
108
|
-
});
|
|
109
|
-
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
110
|
-
if (mod && mod.__esModule) return mod;
|
|
111
|
-
var result = {};
|
|
112
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
113
|
-
__setModuleDefault(result, mod);
|
|
114
|
-
return result;
|
|
5
|
+
const generateId = () => `${Math.random()}${Date.now()}`;
|
|
6
|
+
const wrapInTryCatch = (f, prefix) => (...args) => {
|
|
7
|
+
try {
|
|
8
|
+
return f(...args);
|
|
9
|
+
}
|
|
10
|
+
catch (e) {
|
|
11
|
+
throw new Error((prefix || '') + e);
|
|
12
|
+
}
|
|
115
13
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
14
|
+
const wrapContextHandler = (handler, handlerId) => {
|
|
15
|
+
return async (context) => {
|
|
16
|
+
try {
|
|
17
|
+
await handler(context);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error(`Error thrown by handler ${handlerId} for context type ${context.type}: ${error}`);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const generateOverrideError = (clientApi, brokerApi) => {
|
|
26
|
+
return `You have tried to to use ${clientApi} but ${brokerApi} has not been overridden in the Interop Broker. Please override this function. Refer to our documentation for more info.`;
|
|
27
|
+
};
|
|
28
|
+
const BROKER_ERRORS = {
|
|
29
|
+
fireIntent: generateOverrideError('fireIntent', 'handleFiredIntent'),
|
|
30
|
+
fireIntentForContext: generateOverrideError('fireIntentForContext', 'handleFiredIntentForContext'),
|
|
31
|
+
getInfoForIntent: generateOverrideError('getInfoForIntent', 'handleInfoForIntent'),
|
|
32
|
+
getInfoForIntentsByContext: generateOverrideError('getInfoForIntentsByContext', 'handleInfoForIntentsByContext'),
|
|
33
|
+
joinSessionContextGroupWithJoinContextGroup: 'The Context Group you have tried to join is a Session Context Group. Custom Context Groups can only be defined by the Interop Broker through code or manifest configuration. Please use joinSessionContextGroup.',
|
|
34
|
+
fdc3Open: generateOverrideError('fdc3.open', 'fdc3HandleOpen'),
|
|
35
|
+
fdc3FindInstances: generateOverrideError('fdc3.findInstances', 'fdc3HandleFindInstances'),
|
|
36
|
+
fdc3GetAppMetadata: generateOverrideError('fdc3.getAppMetadata', 'fdc3HandleGetAppMetadata'),
|
|
37
|
+
fdc3GetInfo: generateOverrideError('fdc3.getInfo', 'fdc3HandleGetInfo')
|
|
38
|
+
};
|
|
39
|
+
const wrapIntentHandler = (handler, handlerId) => {
|
|
40
|
+
return async (intent) => {
|
|
41
|
+
try {
|
|
42
|
+
return handler(intent);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.error(`Error thrown by handler ${handlerId}: ${error}`);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
119
51
|
class PrivateChannelClient {
|
|
120
52
|
constructor(client, id) {
|
|
121
53
|
this.id = id;
|
|
@@ -134,12 +66,12 @@ class PrivateChannelClient {
|
|
|
134
66
|
}
|
|
135
67
|
let handlerId;
|
|
136
68
|
if (contextType) {
|
|
137
|
-
handlerId = `contextHandler:invoke-${this.id}-${contextType}-${
|
|
69
|
+
handlerId = `contextHandler:invoke-${this.id}-${contextType}-${generateId()}`;
|
|
138
70
|
}
|
|
139
71
|
else {
|
|
140
|
-
handlerId = `contextHandler:invoke-${this.id}-${
|
|
72
|
+
handlerId = `contextHandler:invoke-${this.id}-${generateId()}`;
|
|
141
73
|
}
|
|
142
|
-
this.client.register(handlerId,
|
|
74
|
+
this.client.register(handlerId, wrapContextHandler(handler, handlerId));
|
|
143
75
|
const listener = { unsubscribe: await this.createContextUnsubscribeCb(handlerId) };
|
|
144
76
|
this.listeners.set(handlerId, listener);
|
|
145
77
|
await this.client.dispatch(`contextHandlerAdded`, { handlerId, contextType });
|
|
@@ -160,7 +92,7 @@ class PrivateChannelClient {
|
|
|
160
92
|
};
|
|
161
93
|
}
|
|
162
94
|
onAddContextListener(handler) {
|
|
163
|
-
const handlerId = `onContextHandlerAdded:invoke-${this.id}-${
|
|
95
|
+
const handlerId = `onContextHandlerAdded:invoke-${this.id}-${generateId()}`;
|
|
164
96
|
this.client.register(handlerId, handler);
|
|
165
97
|
const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
|
|
166
98
|
this.listeners.set(handlerId, listener);
|
|
@@ -168,7 +100,7 @@ class PrivateChannelClient {
|
|
|
168
100
|
return listener;
|
|
169
101
|
}
|
|
170
102
|
onDisconnect(handler) {
|
|
171
|
-
const handlerId = `onDisconnect:invoke-${this.id}-${
|
|
103
|
+
const handlerId = `onDisconnect:invoke-${this.id}-${generateId()}`;
|
|
172
104
|
this.client.register(handlerId, handler);
|
|
173
105
|
const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
|
|
174
106
|
this.listeners.set(handlerId, listener);
|
|
@@ -176,7 +108,7 @@ class PrivateChannelClient {
|
|
|
176
108
|
return listener;
|
|
177
109
|
}
|
|
178
110
|
onUnsubscribe(handler) {
|
|
179
|
-
const handlerId = `onUnsubscribe:invoke-${this.id}-${
|
|
111
|
+
const handlerId = `onUnsubscribe:invoke-${this.id}-${generateId()}`;
|
|
180
112
|
this.client.register(handlerId, handler);
|
|
181
113
|
const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
|
|
182
114
|
this.listeners.set(handlerId, listener);
|
|
@@ -201,18 +133,7 @@ class PrivateChannelClient {
|
|
|
201
133
|
}
|
|
202
134
|
}
|
|
203
135
|
}
|
|
204
|
-
PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
|
|
205
136
|
|
|
206
|
-
var fdc3Channels2_0 = {};
|
|
207
|
-
|
|
208
|
-
var fdc3Channels1_2 = {};
|
|
209
|
-
|
|
210
|
-
var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
211
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
212
|
-
};
|
|
213
|
-
Object.defineProperty(fdc3Channels1_2, "__esModule", { value: true });
|
|
214
|
-
fdc3Channels1_2.createV1Channel = void 0;
|
|
215
|
-
const isEqual_1$1 = __importDefault$2(require$$0);
|
|
216
137
|
const createV1Channel = (sessionContextGroup) => {
|
|
217
138
|
return {
|
|
218
139
|
id: sessionContextGroup.id,
|
|
@@ -242,7 +163,7 @@ const createV1Channel = (sessionContextGroup) => {
|
|
|
242
163
|
const wrappedHandler = (context, contextMetadata) => {
|
|
243
164
|
if (first) {
|
|
244
165
|
first = false;
|
|
245
|
-
if (
|
|
166
|
+
if (esToolkit.isEqual(currentContext, context)) {
|
|
246
167
|
return;
|
|
247
168
|
}
|
|
248
169
|
}
|
|
@@ -258,246 +179,217 @@ const createV1Channel = (sessionContextGroup) => {
|
|
|
258
179
|
}
|
|
259
180
|
};
|
|
260
181
|
};
|
|
261
|
-
fdc3Channels1_2.createV1Channel = createV1Channel;
|
|
262
182
|
|
|
263
|
-
Object.defineProperty(fdc3Channels2_0, "__esModule", { value: true });
|
|
264
|
-
fdc3Channels2_0.createV2Channel = void 0;
|
|
265
|
-
const fdc3_channels_1_2_1$1 = fdc3Channels1_2;
|
|
266
183
|
const createV2Channel = (sessionContextGroup) => {
|
|
267
|
-
const channel =
|
|
184
|
+
const channel = createV1Channel(sessionContextGroup);
|
|
268
185
|
return {
|
|
269
186
|
...channel,
|
|
270
187
|
// @ts-expect-error Type incompatibility on signature.
|
|
271
188
|
addContextListener: async (...args) => channel.addContextListener(...args)
|
|
272
189
|
};
|
|
273
190
|
};
|
|
274
|
-
fdc3Channels2_0.createV2Channel = createV2Channel;
|
|
275
191
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
? await interopModule.fireIntent(intentObj)
|
|
466
|
-
: await interopModule.fireIntentForContext(intentObj);
|
|
467
|
-
if (typeof intentResolutionInfoFromBroker !== 'object') {
|
|
468
|
-
return {
|
|
469
|
-
source: {
|
|
470
|
-
appId: '',
|
|
471
|
-
instanceId: ''
|
|
472
|
-
},
|
|
473
|
-
intent: '',
|
|
474
|
-
version: '2.0',
|
|
475
|
-
getResult
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
return { ...intentResolutionInfoFromBroker, getResult };
|
|
479
|
-
};
|
|
480
|
-
exports.getIntentResolution = getIntentResolution;
|
|
481
|
-
} (utils$1));
|
|
482
|
-
|
|
483
|
-
var InteropClient$1 = {};
|
|
484
|
-
|
|
485
|
-
var base = {};
|
|
192
|
+
const getUnsupportedChannelApis = (channelType) => {
|
|
193
|
+
return {
|
|
194
|
+
addContextListener: () => {
|
|
195
|
+
throw new UnsupportedChannelApiError('Channel.addContextListener', channelType);
|
|
196
|
+
},
|
|
197
|
+
broadcast: () => {
|
|
198
|
+
throw new UnsupportedChannelApiError('Channel.broadcast', channelType);
|
|
199
|
+
},
|
|
200
|
+
getCurrentContext: () => {
|
|
201
|
+
throw new UnsupportedChannelApiError('Channel.getCurrentContext', channelType);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
class UnsupportedChannelApiError extends Error {
|
|
206
|
+
constructor(apiName, channelType = 'System') {
|
|
207
|
+
super(apiName);
|
|
208
|
+
this.message = `Calling ${apiName} on an instance of a ${channelType} Channel returned by fdc3.get${channelType}Channels is not supported. If you would like to use a ${channelType} Channel, please use fdc3.joinChannel, fdc3.addContextListener, and fdc3.broadcast instead.`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
var ResultError;
|
|
212
|
+
(function (ResultError) {
|
|
213
|
+
/** Returned if the `IntentHandler` exited without returning a Promise or that
|
|
214
|
+
* Promise was not resolved with a Context or Channel object.
|
|
215
|
+
*/
|
|
216
|
+
ResultError["NoResultReturned"] = "NoResultReturned";
|
|
217
|
+
/** Returned if the `IntentHandler` function processing the raised intent
|
|
218
|
+
* throws an error or rejects the Promise it returned.
|
|
219
|
+
*/
|
|
220
|
+
ResultError["IntentHandlerRejected"] = "IntentHandlerRejected";
|
|
221
|
+
})(ResultError || (ResultError = {}));
|
|
222
|
+
var ChannelError;
|
|
223
|
+
(function (ChannelError) {
|
|
224
|
+
/** Returned if the specified channel is not found when attempting to join a
|
|
225
|
+
* channel via the `joinUserChannel` function of the DesktopAgent (`fdc3`).
|
|
226
|
+
*/
|
|
227
|
+
ChannelError["NoChannelFound"] = "NoChannelFound";
|
|
228
|
+
/** SHOULD be returned when a request to join a user channel or to a retrieve
|
|
229
|
+
* a Channel object via the `joinUserChannel` or `getOrCreateChannel` methods
|
|
230
|
+
* of the DesktopAgent (`fdc3`) object is denied.
|
|
231
|
+
*/
|
|
232
|
+
ChannelError["AccessDenied"] = "AccessDenied";
|
|
233
|
+
/** SHOULD be returned when a channel cannot be created or retrieved via the
|
|
234
|
+
* `getOrCreateChannel` method of the DesktopAgent (`fdc3`).
|
|
235
|
+
*/
|
|
236
|
+
ChannelError["CreationFailed"] = "CreationFailed";
|
|
237
|
+
})(ChannelError || (ChannelError = {}));
|
|
238
|
+
const buildPrivateChannelObject = (privateChannelClient) => {
|
|
239
|
+
let clientDisconnected = false;
|
|
240
|
+
const checkIfClientDisconnected = () => {
|
|
241
|
+
if (clientDisconnected) {
|
|
242
|
+
throw new Error('Private Channel Client has been disconnected from the Private Channel');
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
return {
|
|
246
|
+
id: privateChannelClient.id,
|
|
247
|
+
type: 'private',
|
|
248
|
+
broadcast: async (context) => {
|
|
249
|
+
checkIfClientDisconnected();
|
|
250
|
+
return privateChannelClient.broadcast(context);
|
|
251
|
+
},
|
|
252
|
+
getCurrentContext: async (contextType) => {
|
|
253
|
+
checkIfClientDisconnected();
|
|
254
|
+
return privateChannelClient.getCurrentContext(contextType);
|
|
255
|
+
},
|
|
256
|
+
// @ts-expect-error TODO [CORE-1524]
|
|
257
|
+
addContextListener: async (contextType, handler) => {
|
|
258
|
+
checkIfClientDisconnected();
|
|
259
|
+
let handlerInUse = handler;
|
|
260
|
+
let contextTypeInUse = contextType;
|
|
261
|
+
if (typeof contextType === 'function') {
|
|
262
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
263
|
+
handlerInUse = contextType;
|
|
264
|
+
contextTypeInUse = null;
|
|
265
|
+
}
|
|
266
|
+
const listener = privateChannelClient.addContextListener(contextTypeInUse, handlerInUse);
|
|
267
|
+
return listener;
|
|
268
|
+
},
|
|
269
|
+
onAddContextListener: (handler) => {
|
|
270
|
+
checkIfClientDisconnected();
|
|
271
|
+
return privateChannelClient.onAddContextListener(handler);
|
|
272
|
+
},
|
|
273
|
+
disconnect: async () => {
|
|
274
|
+
checkIfClientDisconnected();
|
|
275
|
+
clientDisconnected = true;
|
|
276
|
+
return privateChannelClient.disconnect();
|
|
277
|
+
},
|
|
278
|
+
onDisconnect: (handler) => {
|
|
279
|
+
checkIfClientDisconnected();
|
|
280
|
+
return privateChannelClient.onDisconnect(handler);
|
|
281
|
+
},
|
|
282
|
+
onUnsubscribe: (handler) => {
|
|
283
|
+
checkIfClientDisconnected();
|
|
284
|
+
return privateChannelClient.onUnsubscribe(handler);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
const connectPrivateChannel = async (channelId) => {
|
|
289
|
+
try {
|
|
290
|
+
const channelClient = await fin.InterApplicationBus.Channel.connect(channelId);
|
|
291
|
+
const privateChannelClient = new PrivateChannelClient(channelClient, channelId);
|
|
292
|
+
return buildPrivateChannelObject(privateChannelClient);
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
throw new Error(`Private Channel with id: ${channelId} doesn't exist`);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
const isContext = (context) => {
|
|
299
|
+
if (context && typeof context === 'object' && 'type' in context) {
|
|
300
|
+
const { type } = context;
|
|
301
|
+
return typeof type === 'string';
|
|
302
|
+
}
|
|
303
|
+
return false;
|
|
304
|
+
};
|
|
305
|
+
const isChannel = (channel) => {
|
|
306
|
+
if (channel && typeof channel === 'object' && 'type' in channel && 'id' in channel) {
|
|
307
|
+
const { type, id } = channel;
|
|
308
|
+
return typeof type === 'string' && typeof id === 'string' && (type === 'app' || type === 'private');
|
|
309
|
+
}
|
|
310
|
+
return false;
|
|
311
|
+
};
|
|
312
|
+
const getIntentResolution = async (interopModule, context, app, intent) => {
|
|
313
|
+
// Generate an ID to make a session context group with. We will pass that ID to the Broker.
|
|
314
|
+
// The broker will then setContext on that session context group later with our Intent Result,
|
|
315
|
+
const guid = generateId(); // TODO make this undefined in web
|
|
316
|
+
// Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
|
|
317
|
+
const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
|
|
318
|
+
const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
|
|
319
|
+
// Promise we'll use in getResult
|
|
320
|
+
const getResultPromise = new Promise((resolve, reject) => {
|
|
321
|
+
fin.InterApplicationBus.subscribe({ uuid: '*' }, guid, (intentResult) => {
|
|
322
|
+
resolve(intentResult);
|
|
323
|
+
}).catch(() => {
|
|
324
|
+
// not supported in web, suppress the error
|
|
325
|
+
if (interopModule.wire.environment.type === 'other') {
|
|
326
|
+
resolve(undefined);
|
|
327
|
+
}
|
|
328
|
+
reject(new Error('getResult is not supported in this environment'));
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
// Set up the getResult call.
|
|
332
|
+
const getResult = async () => {
|
|
333
|
+
let intentResult = await getResultPromise;
|
|
334
|
+
// void / no payload, or web path where subscribe resolves undefined (see getResultPromise above)
|
|
335
|
+
if (intentResult == null) {
|
|
336
|
+
return undefined;
|
|
337
|
+
}
|
|
338
|
+
if (typeof intentResult !== 'object') {
|
|
339
|
+
throw new Error(ResultError.NoResultReturned);
|
|
340
|
+
}
|
|
341
|
+
const { error } = intentResult;
|
|
342
|
+
if (error) {
|
|
343
|
+
throw new Error(ResultError.IntentHandlerRejected);
|
|
344
|
+
}
|
|
345
|
+
if (isChannel(intentResult)) {
|
|
346
|
+
const { id, type } = intentResult;
|
|
347
|
+
switch (type) {
|
|
348
|
+
case 'private': {
|
|
349
|
+
intentResult = await connectPrivateChannel(id);
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
case 'app': {
|
|
353
|
+
const sessionContextGroup = await interopModule.joinSessionContextGroup(id);
|
|
354
|
+
intentResult = createV2Channel(sessionContextGroup);
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
else if (!isContext(intentResult)) {
|
|
360
|
+
throw new Error(ResultError.NoResultReturned);
|
|
361
|
+
}
|
|
362
|
+
return intentResult;
|
|
363
|
+
};
|
|
364
|
+
// Finally fire the intent.
|
|
365
|
+
const intentResolutionInfoFromBroker = intent
|
|
366
|
+
? await interopModule.fireIntent(intentObj)
|
|
367
|
+
: await interopModule.fireIntentForContext(intentObj);
|
|
368
|
+
if (typeof intentResolutionInfoFromBroker !== 'object') {
|
|
369
|
+
return {
|
|
370
|
+
source: {
|
|
371
|
+
appId: '',
|
|
372
|
+
instanceId: ''
|
|
373
|
+
},
|
|
374
|
+
intent: '',
|
|
375
|
+
version: '2.0',
|
|
376
|
+
getResult
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
return { ...intentResolutionInfoFromBroker, getResult };
|
|
380
|
+
};
|
|
486
381
|
|
|
487
|
-
|
|
382
|
+
(undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
488
383
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
489
384
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
490
385
|
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");
|
|
491
386
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
492
387
|
};
|
|
493
|
-
|
|
388
|
+
(undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
494
389
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
495
390
|
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");
|
|
496
391
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
497
392
|
};
|
|
498
|
-
var _EmitterBase_emitterAccessor, _EmitterBase_deregisterOnceListeners;
|
|
499
|
-
Object.defineProperty(base, "__esModule", { value: true });
|
|
500
|
-
base.Reply = base.EmitterBase = base.Base = void 0;
|
|
501
393
|
class Base {
|
|
502
394
|
/**
|
|
503
395
|
* @internal
|
|
@@ -537,236 +429,20 @@ class Base {
|
|
|
537
429
|
return this.wire.me;
|
|
538
430
|
}
|
|
539
431
|
}
|
|
540
|
-
base.Base = Base;
|
|
541
|
-
/**
|
|
542
|
-
* An entity that emits OpenFin events.
|
|
543
|
-
*
|
|
544
|
-
* @remarks Event-binding methods are asynchronous as they must cross process boundaries
|
|
545
|
-
* and setup the listener in the browser process. When the `EventEmitter` receives an event from the browser process
|
|
546
|
-
* and emits on the renderer, all of the functions attached to that specific event are called synchronously. Any values
|
|
547
|
-
* returned by the called listeners are ignored and will be discarded. If the execution context of the window is destroyed
|
|
548
|
-
* by page navigation or reload, any events that have been setup in that context will be destroyed.
|
|
549
|
-
*
|
|
550
|
-
* It is important to keep in mind that when an ordinary listener function is called, the standard `this` keyword is intentionally
|
|
551
|
-
* set to reference the `EventEmitter` instance to which the listener is attached. It is possible to use ES6 Arrow Functions as
|
|
552
|
-
* listeners, however, when doing so, the `this` keyword will no longer reference the `EventEmitter` instance.
|
|
553
|
-
*
|
|
554
|
-
* Events re-propagate from smaller/more-local scopes to larger/more-global scopes. For example, an event emitted on a specific
|
|
555
|
-
* view will propagate to the window in which the view is embedded, and then to the application in which the window is running, and
|
|
556
|
-
* finally to the OpenFin runtime itself at the "system" level. Re-propagated events are prefixed with the name of the scope in which
|
|
557
|
-
* they originated - for example, a "shown" event emitted on a view will be re-propagated at the window level as "view-shown", and
|
|
558
|
-
* then to the application as "window-view-shown", and finally at the system level as "application-window-view-shown".
|
|
559
|
-
*
|
|
560
|
-
* All event propagations are visible at the System level, regardless of source, so transitive re-propagations (e.g. from view to window
|
|
561
|
-
* to application) are visible in their entirety at the system level. So, we can listen to the above event as "shown", "view-shown",
|
|
562
|
-
* "window-view-shown", or "application-window-view-shown."
|
|
563
|
-
*/
|
|
564
|
-
class EmitterBase extends Base {
|
|
565
|
-
constructor(wire, topic, ...additionalAccessors) {
|
|
566
|
-
super(wire);
|
|
567
|
-
this.topic = topic;
|
|
568
|
-
_EmitterBase_emitterAccessor.set(this, void 0);
|
|
569
|
-
_EmitterBase_deregisterOnceListeners.set(this, void 0);
|
|
570
|
-
this.eventNames = () => (this.hasEmitter() ? this.getOrCreateEmitter().eventNames() : []);
|
|
571
|
-
/**
|
|
572
|
-
* @internal
|
|
573
|
-
*/
|
|
574
|
-
this.emit = (eventType, payload, ...args) => {
|
|
575
|
-
return this.hasEmitter() ? this.getOrCreateEmitter().emit(eventType, payload, ...args) : false;
|
|
576
|
-
};
|
|
577
|
-
this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$4(this, _EmitterBase_emitterAccessor, "f"));
|
|
578
|
-
this.getOrCreateEmitter = () => {
|
|
579
|
-
return this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$4(this, _EmitterBase_emitterAccessor, "f"));
|
|
580
|
-
};
|
|
581
|
-
this.listeners = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(type) : [];
|
|
582
|
-
this.listenerCount = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listenerCount(type) : 0;
|
|
583
|
-
this.registerEventListener = async (eventType, options = {}, applySubscription, undoSubscription) => {
|
|
584
|
-
const runtimeEvent = {
|
|
585
|
-
...this.identity,
|
|
586
|
-
timestamp: options.timestamp || Date.now(),
|
|
587
|
-
topic: this.topic,
|
|
588
|
-
type: eventType
|
|
589
|
-
};
|
|
590
|
-
const emitter = this.getOrCreateEmitter();
|
|
591
|
-
// We apply the subscription and then undo if the async call fails to avoid
|
|
592
|
-
// indeterminacy in subscription application order, which can break things elsewhere
|
|
593
|
-
applySubscription(emitter);
|
|
594
|
-
try {
|
|
595
|
-
await this.wire.sendAction('subscribe-to-desktop-event', runtimeEvent);
|
|
596
|
-
}
|
|
597
|
-
catch (e) {
|
|
598
|
-
undoSubscription(emitter);
|
|
599
|
-
this.deleteEmitterIfNothingRegistered(emitter);
|
|
600
|
-
throw e;
|
|
601
|
-
}
|
|
602
|
-
};
|
|
603
|
-
this.deregisterEventListener = async (eventType, options = {}) => {
|
|
604
|
-
if (this.hasEmitter()) {
|
|
605
|
-
const runtimeEvent = {
|
|
606
|
-
...this.identity,
|
|
607
|
-
timestamp: options.timestamp || Date.now(),
|
|
608
|
-
topic: this.topic,
|
|
609
|
-
type: eventType
|
|
610
|
-
};
|
|
611
|
-
await this.wire.sendAction('unsubscribe-to-desktop-event', runtimeEvent).catch(() => null);
|
|
612
|
-
return this.getOrCreateEmitter();
|
|
613
|
-
}
|
|
614
|
-
// This will only be reached if unsubscribe from event that does not exist but do not want to error here
|
|
615
|
-
return Promise.resolve();
|
|
616
|
-
};
|
|
617
|
-
__classPrivateFieldSet$4(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
|
|
618
|
-
__classPrivateFieldSet$4(this, _EmitterBase_deregisterOnceListeners, new WeakMap(), "f");
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* Adds a listener to the end of the listeners array for the specified event.
|
|
622
|
-
*
|
|
623
|
-
* @remarks Event payloads are documented in the {@link OpenFin.Events} namespace.
|
|
624
|
-
*/
|
|
625
|
-
async on(eventType, listener, options) {
|
|
626
|
-
await this.registerEventListener(eventType, options, (emitter) => {
|
|
627
|
-
emitter.on(eventType, listener);
|
|
628
|
-
}, (emitter) => {
|
|
629
|
-
emitter.removeListener(eventType, listener);
|
|
630
|
-
});
|
|
631
|
-
return this;
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* Adds a listener to the end of the listeners array for the specified event.
|
|
635
|
-
*/
|
|
636
|
-
async addListener(eventType, listener, options) {
|
|
637
|
-
return this.on(eventType, listener, options);
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.
|
|
641
|
-
*
|
|
642
|
-
* @remarks Event payloads are documented in the {@link OpenFin.Events} namespace.
|
|
643
|
-
*/
|
|
644
|
-
async once(eventType, listener, options) {
|
|
645
|
-
const deregister = () => this.deregisterEventListener(eventType);
|
|
646
|
-
__classPrivateFieldGet$4(this, _EmitterBase_deregisterOnceListeners, "f").set(listener, deregister);
|
|
647
|
-
await this.registerEventListener(eventType, options, (emitter) => {
|
|
648
|
-
emitter.once(eventType, deregister);
|
|
649
|
-
emitter.once(eventType, listener);
|
|
650
|
-
}, (emitter) => {
|
|
651
|
-
emitter.removeListener(eventType, deregister);
|
|
652
|
-
emitter.removeListener(eventType, listener);
|
|
653
|
-
});
|
|
654
|
-
return this;
|
|
655
|
-
}
|
|
656
|
-
/**
|
|
657
|
-
* Adds a listener to the beginning of the listeners array for the specified event.
|
|
658
|
-
*
|
|
659
|
-
* @remarks Event payloads are documented in the {@link OpenFin.Events} namespace.
|
|
660
|
-
*/
|
|
661
|
-
async prependListener(eventType, listener, options) {
|
|
662
|
-
await this.registerEventListener(eventType, options, (emitter) => {
|
|
663
|
-
emitter.prependListener(eventType, listener);
|
|
664
|
-
}, (emitter) => {
|
|
665
|
-
emitter.removeListener(eventType, listener);
|
|
666
|
-
});
|
|
667
|
-
return this;
|
|
668
|
-
}
|
|
669
|
-
/**
|
|
670
|
-
* Adds a one time listener for the event. The listener is invoked only the first time the event is fired,
|
|
671
|
-
* after which it is removed. The listener is added to the beginning of the listeners array.
|
|
672
|
-
*
|
|
673
|
-
* @remarks Event payloads are documented in the {@link OpenFin.Events} namespace.
|
|
674
|
-
*/
|
|
675
|
-
async prependOnceListener(eventType, listener, options) {
|
|
676
|
-
const deregister = () => this.deregisterEventListener(eventType);
|
|
677
|
-
__classPrivateFieldGet$4(this, _EmitterBase_deregisterOnceListeners, "f").set(listener, deregister);
|
|
678
|
-
await this.registerEventListener(eventType, options, (emitter) => {
|
|
679
|
-
emitter.prependOnceListener(eventType, listener);
|
|
680
|
-
emitter.once(eventType, deregister);
|
|
681
|
-
}, (emitter) => {
|
|
682
|
-
emitter.removeListener(eventType, listener);
|
|
683
|
-
emitter.removeListener(eventType, deregister);
|
|
684
|
-
});
|
|
685
|
-
return this;
|
|
686
|
-
}
|
|
687
|
-
/**
|
|
688
|
-
* Remove a listener from the listener array for the specified event.
|
|
689
|
-
*
|
|
690
|
-
* @remarks Caution: Calling this method changes the array indices in the listener array behind the listener.
|
|
691
|
-
*/
|
|
692
|
-
async removeListener(eventType, listener, options) {
|
|
693
|
-
const emitter = await this.deregisterEventListener(eventType, options);
|
|
694
|
-
if (emitter) {
|
|
695
|
-
emitter.removeListener(eventType, listener);
|
|
696
|
-
const deregister = __classPrivateFieldGet$4(this, _EmitterBase_deregisterOnceListeners, "f").get(listener);
|
|
697
|
-
if (deregister) {
|
|
698
|
-
emitter.removeListener(eventType, deregister);
|
|
699
|
-
}
|
|
700
|
-
this.deleteEmitterIfNothingRegistered(emitter);
|
|
701
|
-
}
|
|
702
|
-
return this;
|
|
703
|
-
}
|
|
704
|
-
async deregisterAllListeners(eventType) {
|
|
705
|
-
const runtimeEvent = { ...this.identity, type: eventType, topic: this.topic };
|
|
706
|
-
if (this.hasEmitter()) {
|
|
707
|
-
const emitter = this.getOrCreateEmitter();
|
|
708
|
-
const refCount = emitter.listenerCount(runtimeEvent.type);
|
|
709
|
-
const unsubscribePromises = [];
|
|
710
|
-
for (let i = 0; i < refCount; i++) {
|
|
711
|
-
unsubscribePromises.push(this.wire.sendAction('unsubscribe-to-desktop-event', runtimeEvent).catch(() => null));
|
|
712
|
-
}
|
|
713
|
-
await Promise.all(unsubscribePromises);
|
|
714
|
-
return emitter;
|
|
715
|
-
}
|
|
716
|
-
return undefined;
|
|
717
|
-
}
|
|
718
|
-
/**
|
|
719
|
-
* Removes all listeners, or those of the specified event.
|
|
720
|
-
*
|
|
721
|
-
*/
|
|
722
|
-
async removeAllListeners(eventType) {
|
|
723
|
-
const removeByEvent = async (event) => {
|
|
724
|
-
const emitter = await this.deregisterAllListeners(event);
|
|
725
|
-
if (emitter) {
|
|
726
|
-
emitter.removeAllListeners(event);
|
|
727
|
-
this.deleteEmitterIfNothingRegistered(emitter);
|
|
728
|
-
}
|
|
729
|
-
};
|
|
730
|
-
if (eventType) {
|
|
731
|
-
await removeByEvent(eventType);
|
|
732
|
-
}
|
|
733
|
-
else if (this.hasEmitter()) {
|
|
734
|
-
const events = this.getOrCreateEmitter().eventNames();
|
|
735
|
-
await Promise.all(events.map(removeByEvent));
|
|
736
|
-
}
|
|
737
|
-
return this;
|
|
738
|
-
}
|
|
739
|
-
deleteEmitterIfNothingRegistered(emitter) {
|
|
740
|
-
// TODO: maybe emitterMap should clean up itself..
|
|
741
|
-
if (emitter.eventNames().length === 0) {
|
|
742
|
-
this.wire.eventAggregator.delete(__classPrivateFieldGet$4(this, _EmitterBase_emitterAccessor, "f"));
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
base.EmitterBase = EmitterBase;
|
|
747
|
-
_EmitterBase_emitterAccessor = new WeakMap(), _EmitterBase_deregisterOnceListeners = new WeakMap();
|
|
748
|
-
class Reply {
|
|
749
|
-
}
|
|
750
|
-
base.Reply = Reply;
|
|
751
432
|
|
|
752
|
-
var
|
|
753
|
-
|
|
754
|
-
var __classPrivateFieldSet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
433
|
+
var __classPrivateFieldSet$3 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
755
434
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
756
435
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
757
436
|
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");
|
|
758
437
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
759
438
|
};
|
|
760
|
-
var __classPrivateFieldGet$3 = (
|
|
439
|
+
var __classPrivateFieldGet$3 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
761
440
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
762
441
|
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");
|
|
763
442
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
764
443
|
};
|
|
765
444
|
var _SessionContextGroupClient_clientPromise;
|
|
766
|
-
|
|
767
|
-
const base_1$1 = base;
|
|
768
|
-
const utils_1$4 = utils$2;
|
|
769
|
-
class SessionContextGroupClient extends base_1$1.Base {
|
|
445
|
+
class SessionContextGroupClient extends Base {
|
|
770
446
|
constructor(wire, client, id) {
|
|
771
447
|
super(wire);
|
|
772
448
|
_SessionContextGroupClient_clientPromise.set(this, void 0);
|
|
@@ -809,12 +485,12 @@ class SessionContextGroupClient extends base_1$1.Base {
|
|
|
809
485
|
const client = await __classPrivateFieldGet$3(this, _SessionContextGroupClient_clientPromise, "f");
|
|
810
486
|
let handlerId;
|
|
811
487
|
if (contextType) {
|
|
812
|
-
handlerId = `sessionContextHandler:invoke-${this.id}-${contextType}-${
|
|
488
|
+
handlerId = `sessionContextHandler:invoke-${this.id}-${contextType}-${generateId()}`;
|
|
813
489
|
}
|
|
814
490
|
else {
|
|
815
491
|
handlerId = `sessionContextHandler:invoke-${this.id}`;
|
|
816
492
|
}
|
|
817
|
-
client.register(handlerId,
|
|
493
|
+
client.register(handlerId, wrapContextHandler(contextHandler, handlerId));
|
|
818
494
|
await client.dispatch(`sessionContextGroup:handlerAdded-${this.id}`, { handlerId, contextType });
|
|
819
495
|
return { unsubscribe: await this.createUnsubscribeCb(handlerId) };
|
|
820
496
|
}
|
|
@@ -828,31 +504,26 @@ class SessionContextGroupClient extends base_1$1.Base {
|
|
|
828
504
|
getUserInstance() {
|
|
829
505
|
return {
|
|
830
506
|
id: this.id,
|
|
831
|
-
setContext:
|
|
832
|
-
getCurrentContext:
|
|
833
|
-
addContextHandler:
|
|
507
|
+
setContext: wrapInTryCatch(this.setContext.bind(this), 'Failed to set context: '),
|
|
508
|
+
getCurrentContext: wrapInTryCatch(this.getCurrentContext.bind(this), 'Failed to get context: '),
|
|
509
|
+
addContextHandler: wrapInTryCatch(this.addContextHandler.bind(this), 'Failed to add context handler: ')
|
|
834
510
|
};
|
|
835
511
|
}
|
|
836
512
|
}
|
|
837
|
-
SessionContextGroupClient$1.default = SessionContextGroupClient;
|
|
838
513
|
_SessionContextGroupClient_clientPromise = new WeakMap();
|
|
839
514
|
|
|
840
|
-
var
|
|
841
|
-
|
|
842
|
-
var __classPrivateFieldSet$2 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
515
|
+
var __classPrivateFieldSet$2 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
843
516
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
844
517
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
845
518
|
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");
|
|
846
519
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
847
520
|
};
|
|
848
|
-
var __classPrivateFieldGet$2 = (
|
|
521
|
+
var __classPrivateFieldGet$2 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
849
522
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
850
523
|
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");
|
|
851
524
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
852
525
|
};
|
|
853
526
|
var _a, _ChannelEvents_channelClient, _ChannelEvents_isChannelReady, _ChannelEvents_actionsByClient, _ChannelEvents_getActions, _ChannelEvents_createRegistration, _ChannelEvents_getRegistration, _ChannelEvents_getOrCreateRegistration;
|
|
854
|
-
Object.defineProperty(channelEvents, "__esModule", { value: true });
|
|
855
|
-
channelEvents.ChannelEvents = void 0;
|
|
856
527
|
/**
|
|
857
528
|
* Channel events creates a event like syntax out of a channel action, allowing multiple events to be triggered
|
|
858
529
|
* from a single action (normally only one callback can be created per action).
|
|
@@ -960,7 +631,6 @@ class ChannelEvents {
|
|
|
960
631
|
});
|
|
961
632
|
}
|
|
962
633
|
}
|
|
963
|
-
channelEvents.ChannelEvents = ChannelEvents;
|
|
964
634
|
_a = ChannelEvents, _ChannelEvents_channelClient = new WeakMap(), _ChannelEvents_isChannelReady = new WeakMap(), _ChannelEvents_getActions = new WeakMap(), _ChannelEvents_createRegistration = new WeakMap(), _ChannelEvents_getRegistration = new WeakMap(), _ChannelEvents_getOrCreateRegistration = new WeakMap();
|
|
965
635
|
/**
|
|
966
636
|
* Static map of actions by channel client. This ensures we can reuse the same event and keep track of all its callbacks.
|
|
@@ -970,27 +640,18 @@ _a = ChannelEvents, _ChannelEvents_channelClient = new WeakMap(), _ChannelEvents
|
|
|
970
640
|
*/
|
|
971
641
|
_ChannelEvents_actionsByClient = { value: new WeakMap() };
|
|
972
642
|
|
|
973
|
-
var __classPrivateFieldSet$1 = (
|
|
643
|
+
var __classPrivateFieldSet$1 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
974
644
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
975
645
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
976
646
|
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");
|
|
977
647
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
978
648
|
};
|
|
979
|
-
var __classPrivateFieldGet$1 = (
|
|
649
|
+
var __classPrivateFieldGet$1 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
980
650
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
981
651
|
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");
|
|
982
652
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
983
653
|
};
|
|
984
|
-
var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
985
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
986
|
-
};
|
|
987
654
|
var _InteropClient_clientPromise, _InteropClient_sessionContextGroups, _InteropClient_fdc3Factory, _InteropClient_channelEvents;
|
|
988
|
-
Object.defineProperty(InteropClient$1, "__esModule", { value: true });
|
|
989
|
-
InteropClient$1.InteropClient = void 0;
|
|
990
|
-
const base_1 = base;
|
|
991
|
-
const SessionContextGroupClient_1 = __importDefault$1(SessionContextGroupClient$1);
|
|
992
|
-
const utils_1$3 = utils$2;
|
|
993
|
-
const channel_events_1 = channelEvents;
|
|
994
655
|
/**
|
|
995
656
|
* The Interop Client API is broken up into two groups:
|
|
996
657
|
*
|
|
@@ -1040,7 +701,7 @@ const channel_events_1 = channelEvents;
|
|
|
1040
701
|
* * {@link InteropClient#getAllClientsInContextGroup getAllClientsInContextGroup(contextGroupId)}
|
|
1041
702
|
*
|
|
1042
703
|
*/
|
|
1043
|
-
class InteropClient extends
|
|
704
|
+
class InteropClient extends Base {
|
|
1044
705
|
/**
|
|
1045
706
|
* @internal
|
|
1046
707
|
*/
|
|
@@ -1084,7 +745,7 @@ class InteropClient extends base_1.Base {
|
|
|
1084
745
|
__classPrivateFieldSet$1(this, _InteropClient_sessionContextGroups, new Map(), "f");
|
|
1085
746
|
__classPrivateFieldSet$1(this, _InteropClient_clientPromise, clientPromise, "f");
|
|
1086
747
|
__classPrivateFieldSet$1(this, _InteropClient_fdc3Factory, fdc3Factory, "f");
|
|
1087
|
-
__classPrivateFieldSet$1(this, _InteropClient_channelEvents, new
|
|
748
|
+
__classPrivateFieldSet$1(this, _InteropClient_channelEvents, new ChannelEvents(clientPromise), "f");
|
|
1088
749
|
}
|
|
1089
750
|
/**
|
|
1090
751
|
* Sets a context for the context group of the current entity.
|
|
@@ -1179,12 +840,12 @@ class InteropClient extends base_1.Base {
|
|
|
1179
840
|
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1180
841
|
let handlerId;
|
|
1181
842
|
if (contextType) {
|
|
1182
|
-
handlerId = `invokeContextHandler-${contextType}-${
|
|
843
|
+
handlerId = `invokeContextHandler-${contextType}-${generateId()}`;
|
|
1183
844
|
}
|
|
1184
845
|
else {
|
|
1185
846
|
handlerId = 'invokeContextHandler';
|
|
1186
847
|
}
|
|
1187
|
-
const wrappedHandler =
|
|
848
|
+
const wrappedHandler = wrapContextHandler(handler, handlerId);
|
|
1188
849
|
client.register(handlerId, wrappedHandler);
|
|
1189
850
|
await client.dispatch('contextHandlerRegistered', { handlerId, contextType });
|
|
1190
851
|
return {
|
|
@@ -1381,7 +1042,7 @@ class InteropClient extends base_1.Base {
|
|
|
1381
1042
|
});
|
|
1382
1043
|
const client = await __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f");
|
|
1383
1044
|
const handlerId = `intent-handler-${intentName}`;
|
|
1384
|
-
const wrappedHandler =
|
|
1045
|
+
const wrappedHandler = wrapIntentHandler(handler, handlerId);
|
|
1385
1046
|
try {
|
|
1386
1047
|
await client.register(handlerId, wrappedHandler);
|
|
1387
1048
|
await client.dispatch('intentHandlerRegistered', { handlerId, ...options });
|
|
@@ -1548,7 +1209,7 @@ class InteropClient extends base_1.Base {
|
|
|
1548
1209
|
if (hasConflict) {
|
|
1549
1210
|
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.`);
|
|
1550
1211
|
}
|
|
1551
|
-
const newSessionContextGroup = new
|
|
1212
|
+
const newSessionContextGroup = new SessionContextGroupClient(this.wire, __classPrivateFieldGet$1(this, _InteropClient_clientPromise, "f"), sessionContextGroupId);
|
|
1552
1213
|
__classPrivateFieldGet$1(this, _InteropClient_sessionContextGroups, "f").set(sessionContextGroupId, newSessionContextGroup);
|
|
1553
1214
|
return newSessionContextGroup.getUserInstance();
|
|
1554
1215
|
}
|
|
@@ -1598,30 +1259,20 @@ class InteropClient extends base_1.Base {
|
|
|
1598
1259
|
return client.dispatch(action, payload || null);
|
|
1599
1260
|
}
|
|
1600
1261
|
}
|
|
1601
|
-
InteropClient$1.InteropClient = InteropClient;
|
|
1602
1262
|
_InteropClient_clientPromise = new WeakMap(), _InteropClient_sessionContextGroups = new WeakMap(), _InteropClient_fdc3Factory = new WeakMap(), _InteropClient_channelEvents = new WeakMap();
|
|
1603
1263
|
|
|
1604
|
-
var __classPrivateFieldGet = (
|
|
1264
|
+
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
1605
1265
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1606
1266
|
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");
|
|
1607
1267
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1608
1268
|
};
|
|
1609
|
-
var __classPrivateFieldSet = (
|
|
1269
|
+
var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
1610
1270
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
1611
1271
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
1612
1272
|
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");
|
|
1613
1273
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
1614
1274
|
};
|
|
1615
|
-
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1616
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1617
|
-
};
|
|
1618
1275
|
var _FDC3ModuleBase_producer;
|
|
1619
|
-
Object.defineProperty(fdc3Common, "__esModule", { value: true });
|
|
1620
|
-
fdc3Common.FDC3ModuleBase = void 0;
|
|
1621
|
-
const utils_1$2 = utils$1;
|
|
1622
|
-
const utils_2$1 = utils$2;
|
|
1623
|
-
const InteropClient_1$1 = InteropClient$1;
|
|
1624
|
-
const isEqual_1 = __importDefault(require$$0);
|
|
1625
1276
|
class FDC3ModuleBase {
|
|
1626
1277
|
get client() {
|
|
1627
1278
|
return __classPrivateFieldGet(this, _FDC3ModuleBase_producer, "f").call(this);
|
|
@@ -1643,9 +1294,7 @@ class FDC3ModuleBase {
|
|
|
1643
1294
|
* @static
|
|
1644
1295
|
*/
|
|
1645
1296
|
async broadcast(context) {
|
|
1646
|
-
this.wire.
|
|
1647
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1648
|
-
});
|
|
1297
|
+
this.wire.recordAnalytic('fdc3-broadcast');
|
|
1649
1298
|
return this.client.setContext(context);
|
|
1650
1299
|
}
|
|
1651
1300
|
/**
|
|
@@ -1656,14 +1305,12 @@ class FDC3ModuleBase {
|
|
|
1656
1305
|
* @tutorial fdc3.open
|
|
1657
1306
|
*/
|
|
1658
1307
|
async _open(app, context) {
|
|
1659
|
-
this.wire.
|
|
1660
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1661
|
-
});
|
|
1308
|
+
this.wire.recordAnalytic('fdc3-open');
|
|
1662
1309
|
try {
|
|
1663
|
-
return await
|
|
1310
|
+
return await InteropClient.ferryFdc3Call(this.client, 'fdc3Open', { app, context });
|
|
1664
1311
|
}
|
|
1665
1312
|
catch (error) {
|
|
1666
|
-
const errorToThrow = error.message ===
|
|
1313
|
+
const errorToThrow = error.message === BROKER_ERRORS.fdc3Open ? 'ResolverUnavailable' : error.message;
|
|
1667
1314
|
throw new Error(errorToThrow);
|
|
1668
1315
|
}
|
|
1669
1316
|
}
|
|
@@ -1672,7 +1319,7 @@ class FDC3ModuleBase {
|
|
|
1672
1319
|
// fdc3 implementation of getSystemChannels returns an array of channels, have to decorate over
|
|
1673
1320
|
// this so people know that these APIs are not supported
|
|
1674
1321
|
return channels.map((channel) => {
|
|
1675
|
-
return { ...channel, type: 'system', ...
|
|
1322
|
+
return { ...channel, type: 'system', ...getUnsupportedChannelApis() };
|
|
1676
1323
|
});
|
|
1677
1324
|
}
|
|
1678
1325
|
/**
|
|
@@ -1682,19 +1329,17 @@ class FDC3ModuleBase {
|
|
|
1682
1329
|
* @tutorial fdc3.getOrCreateChannel
|
|
1683
1330
|
*/
|
|
1684
1331
|
async getOrCreateChannel(channelId, fdc3Factory) {
|
|
1685
|
-
this.wire.
|
|
1686
|
-
|
|
1687
|
-
});
|
|
1688
|
-
const hasChannelIdBeenUsed = await InteropClient_1$1.InteropClient.ferryFdc3Call(this.client, 'isIdUsedByPrivateChannel', {
|
|
1332
|
+
this.wire.recordAnalytic('fdc3-get-or-create-channel');
|
|
1333
|
+
const hasChannelIdBeenUsed = await InteropClient.ferryFdc3Call(this.client, 'isIdUsedByPrivateChannel', {
|
|
1689
1334
|
channelId
|
|
1690
1335
|
});
|
|
1691
1336
|
if (hasChannelIdBeenUsed) {
|
|
1692
|
-
throw new Error(
|
|
1337
|
+
throw new Error(ChannelError.AccessDenied);
|
|
1693
1338
|
}
|
|
1694
1339
|
const systemChannels = await this._getChannels();
|
|
1695
1340
|
const userChannel = systemChannels.find((channel) => channel.id === channelId);
|
|
1696
1341
|
if (userChannel) {
|
|
1697
|
-
return { ...userChannel, type: 'system', ...
|
|
1342
|
+
return { ...userChannel, type: 'system', ...getUnsupportedChannelApis() };
|
|
1698
1343
|
}
|
|
1699
1344
|
try {
|
|
1700
1345
|
const sessionContextGroup = await this.client.joinSessionContextGroup(channelId);
|
|
@@ -1702,7 +1347,7 @@ class FDC3ModuleBase {
|
|
|
1702
1347
|
}
|
|
1703
1348
|
catch (error) {
|
|
1704
1349
|
console.error(error.message);
|
|
1705
|
-
throw new Error(
|
|
1350
|
+
throw new Error(ChannelError.CreationFailed);
|
|
1706
1351
|
}
|
|
1707
1352
|
}
|
|
1708
1353
|
/**
|
|
@@ -1712,9 +1357,7 @@ class FDC3ModuleBase {
|
|
|
1712
1357
|
* @static
|
|
1713
1358
|
*/
|
|
1714
1359
|
async getSystemChannels() {
|
|
1715
|
-
this.wire.
|
|
1716
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1717
|
-
});
|
|
1360
|
+
this.wire.recordAnalytic('fdc3-get-system-channels');
|
|
1718
1361
|
return this._getChannels();
|
|
1719
1362
|
}
|
|
1720
1363
|
/**
|
|
@@ -1729,23 +1372,21 @@ class FDC3ModuleBase {
|
|
|
1729
1372
|
* @static
|
|
1730
1373
|
*/
|
|
1731
1374
|
async joinChannel(channelId) {
|
|
1732
|
-
this.wire.
|
|
1733
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1734
|
-
});
|
|
1375
|
+
this.wire.recordAnalytic('fdc3-join-channel');
|
|
1735
1376
|
try {
|
|
1736
1377
|
return await this.client.joinContextGroup(channelId);
|
|
1737
1378
|
}
|
|
1738
1379
|
catch (error) {
|
|
1739
|
-
if (error.message ===
|
|
1380
|
+
if (error.message === BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup) {
|
|
1740
1381
|
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.');
|
|
1741
1382
|
}
|
|
1742
1383
|
else {
|
|
1743
1384
|
console.error(error.message);
|
|
1744
1385
|
}
|
|
1745
1386
|
if (error.message.startsWith('Attempting to join a context group that does not exist')) {
|
|
1746
|
-
throw new Error(
|
|
1387
|
+
throw new Error(ChannelError.NoChannelFound);
|
|
1747
1388
|
}
|
|
1748
|
-
throw new Error(
|
|
1389
|
+
throw new Error(ChannelError.AccessDenied);
|
|
1749
1390
|
}
|
|
1750
1391
|
}
|
|
1751
1392
|
/**
|
|
@@ -1754,9 +1395,7 @@ class FDC3ModuleBase {
|
|
|
1754
1395
|
* @tutorial fdc3.getCurrentChannel
|
|
1755
1396
|
*/
|
|
1756
1397
|
async getCurrentChannel() {
|
|
1757
|
-
this.wire.
|
|
1758
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1759
|
-
});
|
|
1398
|
+
this.wire.recordAnalytic('fdc3-get-current-channel');
|
|
1760
1399
|
const currentContextGroupInfo = await this.getCurrentContextGroupInfo();
|
|
1761
1400
|
if (!currentContextGroupInfo) {
|
|
1762
1401
|
return null;
|
|
@@ -1771,9 +1410,7 @@ class FDC3ModuleBase {
|
|
|
1771
1410
|
* @static
|
|
1772
1411
|
*/
|
|
1773
1412
|
async leaveCurrentChannel() {
|
|
1774
|
-
this.wire.
|
|
1775
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1776
|
-
});
|
|
1413
|
+
this.wire.recordAnalytic('fdc3-leave-current-channel');
|
|
1777
1414
|
return this.client.removeFromContextGroup();
|
|
1778
1415
|
}
|
|
1779
1416
|
// utils
|
|
@@ -1816,7 +1453,7 @@ class FDC3ModuleBase {
|
|
|
1816
1453
|
const wrappedHandler = (context, contextMetadata) => {
|
|
1817
1454
|
if (first) {
|
|
1818
1455
|
first = false;
|
|
1819
|
-
if (
|
|
1456
|
+
if (esToolkit.isEqual(currentContext, context)) {
|
|
1820
1457
|
return;
|
|
1821
1458
|
}
|
|
1822
1459
|
}
|
|
@@ -1841,14 +1478,8 @@ class FDC3ModuleBase {
|
|
|
1841
1478
|
};
|
|
1842
1479
|
}
|
|
1843
1480
|
}
|
|
1844
|
-
fdc3Common.FDC3ModuleBase = FDC3ModuleBase;
|
|
1845
1481
|
_FDC3ModuleBase_producer = new WeakMap();
|
|
1846
1482
|
|
|
1847
|
-
Object.defineProperty(fdc31_2, "__esModule", { value: true });
|
|
1848
|
-
exports.Fdc3Module = fdc31_2.Fdc3Module = void 0;
|
|
1849
|
-
const utils_1$1 = utils$2;
|
|
1850
|
-
const fdc3_common_1$1 = fdc3Common;
|
|
1851
|
-
const fdc3_channels_1_2_1 = fdc3Channels1_2;
|
|
1852
1483
|
/**
|
|
1853
1484
|
* @version 1.2
|
|
1854
1485
|
* The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
|
|
@@ -1884,7 +1515,7 @@ const fdc3_channels_1_2_1 = fdc3Channels1_2;
|
|
|
1884
1515
|
* }
|
|
1885
1516
|
* ```
|
|
1886
1517
|
*/
|
|
1887
|
-
class Fdc3Module extends
|
|
1518
|
+
class Fdc3Module extends FDC3ModuleBase {
|
|
1888
1519
|
async open(app, context) {
|
|
1889
1520
|
// eslint-disable-next-line no-underscore-dangle
|
|
1890
1521
|
await super._open(app, context);
|
|
@@ -1899,9 +1530,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
|
|
|
1899
1530
|
*/
|
|
1900
1531
|
// @ts-expect-error TODO [CORE-1524]
|
|
1901
1532
|
addContextListener(contextType, handler) {
|
|
1902
|
-
this.wire.
|
|
1903
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1904
|
-
});
|
|
1533
|
+
this.wire.recordAnalytic('fdc3-add-context-listener');
|
|
1905
1534
|
let listener;
|
|
1906
1535
|
if (typeof contextType === 'function') {
|
|
1907
1536
|
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
@@ -1924,9 +1553,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
|
|
|
1924
1553
|
* @static
|
|
1925
1554
|
*/
|
|
1926
1555
|
addIntentListener(intent, handler) {
|
|
1927
|
-
this.wire.
|
|
1928
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1929
|
-
});
|
|
1556
|
+
this.wire.recordAnalytic('fdc3-add-intent-listener');
|
|
1930
1557
|
const contextHandler = (raisedIntent) => {
|
|
1931
1558
|
const { context, metadata: intentMetadata } = raisedIntent;
|
|
1932
1559
|
const { metadata } = context;
|
|
@@ -1954,9 +1581,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
|
|
|
1954
1581
|
* @static
|
|
1955
1582
|
*/
|
|
1956
1583
|
async raiseIntent(intent, context, app) {
|
|
1957
|
-
this.wire.
|
|
1958
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1959
|
-
});
|
|
1584
|
+
this.wire.recordAnalytic('fdc3-raise-intent');
|
|
1960
1585
|
const intentObj = app
|
|
1961
1586
|
? { name: intent, context, metadata: { target: app } }
|
|
1962
1587
|
: { name: intent, context };
|
|
@@ -1964,7 +1589,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
|
|
|
1964
1589
|
return await this.client.fireIntent(intentObj);
|
|
1965
1590
|
}
|
|
1966
1591
|
catch (error) {
|
|
1967
|
-
const errorToThrow = error.message ===
|
|
1592
|
+
const errorToThrow = error.message === BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error.message;
|
|
1968
1593
|
throw new Error(errorToThrow);
|
|
1969
1594
|
}
|
|
1970
1595
|
}
|
|
@@ -1976,14 +1601,12 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
|
|
|
1976
1601
|
* @tutorial fdc3.findIntent
|
|
1977
1602
|
*/
|
|
1978
1603
|
async findIntent(intent, context) {
|
|
1979
|
-
this.wire.
|
|
1980
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1981
|
-
});
|
|
1604
|
+
this.wire.recordAnalytic('fdc3-find-intent');
|
|
1982
1605
|
try {
|
|
1983
1606
|
return await this.client.getInfoForIntent({ name: intent, context });
|
|
1984
1607
|
}
|
|
1985
1608
|
catch (error) {
|
|
1986
|
-
const errorToThrow = error.message ===
|
|
1609
|
+
const errorToThrow = error.message === BROKER_ERRORS.getInfoForIntent ? 'ResolverUnavailable' : error.message;
|
|
1987
1610
|
throw new Error(errorToThrow);
|
|
1988
1611
|
}
|
|
1989
1612
|
}
|
|
@@ -1994,14 +1617,12 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
|
|
|
1994
1617
|
* @tutorial fdc3.findIntentsByContext
|
|
1995
1618
|
*/
|
|
1996
1619
|
async findIntentsByContext(context) {
|
|
1997
|
-
this.wire.
|
|
1998
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
1999
|
-
});
|
|
1620
|
+
this.wire.recordAnalytic('fdc3-find-intents-by-context');
|
|
2000
1621
|
try {
|
|
2001
1622
|
return await this.client.getInfoForIntentsByContext(context);
|
|
2002
1623
|
}
|
|
2003
1624
|
catch (error) {
|
|
2004
|
-
const errorToThrow = error.message ===
|
|
1625
|
+
const errorToThrow = error.message === BROKER_ERRORS.getInfoForIntentsByContext ? 'ResolverUnavailable' : error.message;
|
|
2005
1626
|
throw new Error(errorToThrow);
|
|
2006
1627
|
}
|
|
2007
1628
|
}
|
|
@@ -2013,14 +1634,12 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
|
|
|
2013
1634
|
* @tutorial fdc3.raiseIntentForContext
|
|
2014
1635
|
*/
|
|
2015
1636
|
async raiseIntentForContext(context, app) {
|
|
2016
|
-
this.wire.
|
|
2017
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2018
|
-
});
|
|
1637
|
+
this.wire.recordAnalytic('fdc3-raise-intent-for-context');
|
|
2019
1638
|
try {
|
|
2020
1639
|
return await this.client.fireIntentForContext({ ...context, metadata: { target: app } });
|
|
2021
1640
|
}
|
|
2022
1641
|
catch (error) {
|
|
2023
|
-
const errorToThrow = error.message ===
|
|
1642
|
+
const errorToThrow = error.message === BROKER_ERRORS.fireIntentForContext ? 'ResolverUnavailable' : error.message;
|
|
2024
1643
|
throw new Error(errorToThrow);
|
|
2025
1644
|
}
|
|
2026
1645
|
}
|
|
@@ -2031,7 +1650,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
|
|
|
2031
1650
|
* @tutorial fdc3.getOrCreateChannel
|
|
2032
1651
|
*/
|
|
2033
1652
|
async getOrCreateChannel(channelId) {
|
|
2034
|
-
return super.getOrCreateChannel(channelId,
|
|
1653
|
+
return super.getOrCreateChannel(channelId, createV1Channel);
|
|
2035
1654
|
}
|
|
2036
1655
|
/**
|
|
2037
1656
|
* 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.
|
|
@@ -2039,9 +1658,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
|
|
|
2039
1658
|
* @tutorial fdc3.getInfo
|
|
2040
1659
|
*/
|
|
2041
1660
|
getInfo() {
|
|
2042
|
-
this.wire.
|
|
2043
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2044
|
-
});
|
|
1661
|
+
this.wire.recordAnalytic('fdc3-get-info');
|
|
2045
1662
|
const version = this.wire.environment.getAdapterVersionSync();
|
|
2046
1663
|
return {
|
|
2047
1664
|
providerVersion: version,
|
|
@@ -2050,20 +1667,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
|
|
|
2050
1667
|
};
|
|
2051
1668
|
}
|
|
2052
1669
|
}
|
|
2053
|
-
exports.Fdc3Module = fdc31_2.Fdc3Module = Fdc3Module;
|
|
2054
|
-
|
|
2055
|
-
var fdc3 = {};
|
|
2056
1670
|
|
|
2057
|
-
var fdc32_0 = {};
|
|
2058
|
-
|
|
2059
|
-
Object.defineProperty(fdc32_0, "__esModule", { value: true });
|
|
2060
|
-
exports.Fdc3Module2 = fdc32_0.Fdc3Module2 = void 0;
|
|
2061
|
-
const fdc3_common_1 = fdc3Common;
|
|
2062
|
-
const utils_1 = utils$2;
|
|
2063
|
-
const InteropClient_1 = InteropClient$1;
|
|
2064
|
-
const utils_2 = utils$1;
|
|
2065
|
-
const PrivateChannelClient_1 = PrivateChannelClient$1;
|
|
2066
|
-
const fdc3_channels_2_0_1 = fdc3Channels2_0;
|
|
2067
1671
|
/**
|
|
2068
1672
|
* @version 2.0
|
|
2069
1673
|
* The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
|
|
@@ -2099,7 +1703,7 @@ const fdc3_channels_2_0_1 = fdc3Channels2_0;
|
|
|
2099
1703
|
* }
|
|
2100
1704
|
* ```
|
|
2101
1705
|
*/
|
|
2102
|
-
class Fdc3Module2 extends
|
|
1706
|
+
class Fdc3Module2 extends FDC3ModuleBase {
|
|
2103
1707
|
/**
|
|
2104
1708
|
* Launches an app, specified via an AppIdentifier object.
|
|
2105
1709
|
* @param app
|
|
@@ -2121,14 +1725,12 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
|
2121
1725
|
* @tutorial fdc3v2.findInstances
|
|
2122
1726
|
*/
|
|
2123
1727
|
async findInstances(app) {
|
|
2124
|
-
this.wire.
|
|
2125
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2126
|
-
});
|
|
1728
|
+
this.wire.recordAnalytic('fdc3-find-instances');
|
|
2127
1729
|
try {
|
|
2128
|
-
return await
|
|
1730
|
+
return await InteropClient.ferryFdc3Call(this.client, 'fdc3FindInstances', app);
|
|
2129
1731
|
}
|
|
2130
1732
|
catch (error) {
|
|
2131
|
-
const errorToThrow = error.message ===
|
|
1733
|
+
const errorToThrow = error.message === BROKER_ERRORS.fdc3FindInstances ? 'ResolverUnavailable' : error.message;
|
|
2132
1734
|
throw new Error(errorToThrow);
|
|
2133
1735
|
}
|
|
2134
1736
|
}
|
|
@@ -2139,14 +1741,12 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
|
2139
1741
|
* @tutorial fdc3v2.getAppMetadata
|
|
2140
1742
|
*/
|
|
2141
1743
|
async getAppMetadata(app) {
|
|
2142
|
-
this.wire.
|
|
2143
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2144
|
-
});
|
|
1744
|
+
this.wire.recordAnalytic('fdc3-get-app-metadata');
|
|
2145
1745
|
try {
|
|
2146
|
-
return await
|
|
1746
|
+
return await InteropClient.ferryFdc3Call(this.client, 'fdc3GetAppMetadata', app);
|
|
2147
1747
|
}
|
|
2148
1748
|
catch (error) {
|
|
2149
|
-
const errorToThrow = error.message ===
|
|
1749
|
+
const errorToThrow = error.message === BROKER_ERRORS.fdc3GetAppMetadata ? 'ResolverUnavailable' : error.message;
|
|
2150
1750
|
throw new Error(errorToThrow);
|
|
2151
1751
|
}
|
|
2152
1752
|
}
|
|
@@ -2159,9 +1759,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
|
2159
1759
|
*/
|
|
2160
1760
|
// @ts-expect-error TODO [CORE-1524]
|
|
2161
1761
|
async addContextListener(contextType, handler) {
|
|
2162
|
-
this.wire.
|
|
2163
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2164
|
-
});
|
|
1762
|
+
this.wire.recordAnalytic('fdc3-add-context-listener');
|
|
2165
1763
|
// The FDC3 ContextHandler only expects the context and optional ContextMetadata, so we wrap the handler
|
|
2166
1764
|
// here so it only gets passed these parameters
|
|
2167
1765
|
const getWrappedHandler = (handlerToWrap) => {
|
|
@@ -2190,14 +1788,12 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
|
2190
1788
|
* @tutorial fdc3.findIntent
|
|
2191
1789
|
*/
|
|
2192
1790
|
async findIntent(intent, context, resultType) {
|
|
2193
|
-
this.wire.
|
|
2194
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2195
|
-
});
|
|
1791
|
+
this.wire.recordAnalytic('fdc3-find-intent');
|
|
2196
1792
|
try {
|
|
2197
1793
|
return await this.client.getInfoForIntent({ name: intent, context, metadata: { resultType } });
|
|
2198
1794
|
}
|
|
2199
1795
|
catch (error) {
|
|
2200
|
-
const errorToThrow = error.message ===
|
|
1796
|
+
const errorToThrow = error.message === BROKER_ERRORS.getInfoForIntent ? 'ResolverUnavailable' : error.message;
|
|
2201
1797
|
throw new Error(errorToThrow);
|
|
2202
1798
|
}
|
|
2203
1799
|
}
|
|
@@ -2209,15 +1805,13 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
|
2209
1805
|
* @tutorial fdc3v2.findIntentsByContext
|
|
2210
1806
|
*/
|
|
2211
1807
|
async findIntentsByContext(context, resultType) {
|
|
2212
|
-
this.wire.
|
|
2213
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2214
|
-
});
|
|
1808
|
+
this.wire.recordAnalytic('fdc3-find-intents-by-context');
|
|
2215
1809
|
const payload = resultType ? { context, metadata: { resultType } } : context;
|
|
2216
1810
|
try {
|
|
2217
|
-
return await
|
|
1811
|
+
return await InteropClient.ferryFdc3Call(this.client, 'fdc3v2FindIntentsByContext', payload);
|
|
2218
1812
|
}
|
|
2219
1813
|
catch (error) {
|
|
2220
|
-
const errorToThrow = error.message ===
|
|
1814
|
+
const errorToThrow = error.message === BROKER_ERRORS.getInfoForIntentsByContext ? 'ResolverUnavailable' : error.message;
|
|
2221
1815
|
throw new Error(errorToThrow);
|
|
2222
1816
|
}
|
|
2223
1817
|
}
|
|
@@ -2230,17 +1824,15 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
|
2230
1824
|
* @tutorial fdc3v2.raiseIntent
|
|
2231
1825
|
*/
|
|
2232
1826
|
async raiseIntent(intent, context, app) {
|
|
2233
|
-
this.wire.
|
|
2234
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2235
|
-
});
|
|
1827
|
+
this.wire.recordAnalytic('fdc3-raise-intent');
|
|
2236
1828
|
try {
|
|
2237
1829
|
if (typeof app === 'string') {
|
|
2238
1830
|
console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
|
|
2239
1831
|
}
|
|
2240
|
-
return
|
|
1832
|
+
return getIntentResolution(this.client, context, app, intent);
|
|
2241
1833
|
}
|
|
2242
1834
|
catch (error) {
|
|
2243
|
-
const errorToThrow = error.message ===
|
|
1835
|
+
const errorToThrow = error.message === BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error.message;
|
|
2244
1836
|
throw new Error(errorToThrow);
|
|
2245
1837
|
}
|
|
2246
1838
|
}
|
|
@@ -2253,17 +1845,15 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
|
2253
1845
|
*/
|
|
2254
1846
|
async raiseIntentForContext(context, app) {
|
|
2255
1847
|
// TODO: We have to do the same thing we do for raiseIntent here as well.
|
|
2256
|
-
this.wire.
|
|
2257
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2258
|
-
});
|
|
1848
|
+
this.wire.recordAnalytic('fdc3-raise-intent-for-context');
|
|
2259
1849
|
try {
|
|
2260
1850
|
if (typeof app === 'string') {
|
|
2261
1851
|
console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
|
|
2262
1852
|
}
|
|
2263
|
-
return
|
|
1853
|
+
return getIntentResolution(this.client, context, app);
|
|
2264
1854
|
}
|
|
2265
1855
|
catch (error) {
|
|
2266
|
-
const errorToThrow = error.message ===
|
|
1856
|
+
const errorToThrow = error.message === BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error.message;
|
|
2267
1857
|
throw new Error(errorToThrow);
|
|
2268
1858
|
}
|
|
2269
1859
|
}
|
|
@@ -2275,9 +1865,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
|
2275
1865
|
* @tutorial fdc3.addIntentListener
|
|
2276
1866
|
*/
|
|
2277
1867
|
async addIntentListener(intent, handler) {
|
|
2278
|
-
this.wire.
|
|
2279
|
-
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
2280
|
-
});
|
|
1868
|
+
this.wire.recordAnalytic('fdc3-add-intent-listener');
|
|
2281
1869
|
if (typeof intent !== 'string') {
|
|
2282
1870
|
throw new Error('First argument must be an Intent name');
|
|
2283
1871
|
}
|
|
@@ -2315,7 +1903,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
|
2315
1903
|
* @tutorial fdc3.getOrCreateChannel
|
|
2316
1904
|
*/
|
|
2317
1905
|
async getOrCreateChannel(channelId) {
|
|
2318
|
-
return super.getOrCreateChannel(channelId,
|
|
1906
|
+
return super.getOrCreateChannel(channelId, createV2Channel);
|
|
2319
1907
|
}
|
|
2320
1908
|
/**
|
|
2321
1909
|
* 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.
|
|
@@ -2323,11 +1911,11 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
|
2323
1911
|
* @tutorial fdc3v2.createPrivateChannel
|
|
2324
1912
|
*/
|
|
2325
1913
|
async createPrivateChannel() {
|
|
2326
|
-
const channelId =
|
|
2327
|
-
await
|
|
1914
|
+
const channelId = generateId();
|
|
1915
|
+
await InteropClient.ferryFdc3Call(this.client, 'createPrivateChannelProvider', { channelId });
|
|
2328
1916
|
const channelClient = await this.fin.InterApplicationBus.Channel.connect(channelId);
|
|
2329
|
-
const newPrivateChannelClient = new
|
|
2330
|
-
return
|
|
1917
|
+
const newPrivateChannelClient = new PrivateChannelClient(channelClient, channelId);
|
|
1918
|
+
return buildPrivateChannelObject(newPrivateChannelClient);
|
|
2331
1919
|
}
|
|
2332
1920
|
/**
|
|
2333
1921
|
* Retrieves a list of the User Channels available for the app to join.
|
|
@@ -2340,7 +1928,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
|
2340
1928
|
// this so people know that these APIs are not supported
|
|
2341
1929
|
return channels.map((channel) => {
|
|
2342
1930
|
// @ts-expect-error TODO [CORE-1524]
|
|
2343
|
-
return { ...channel, type: 'user', ...
|
|
1931
|
+
return { ...channel, type: 'user', ...getUnsupportedChannelApis('User') };
|
|
2344
1932
|
});
|
|
2345
1933
|
}
|
|
2346
1934
|
/**
|
|
@@ -2396,40 +1984,34 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
|
|
2396
1984
|
* @tutorial fdc3v2.getInfo
|
|
2397
1985
|
*/
|
|
2398
1986
|
async getInfo() {
|
|
2399
|
-
return
|
|
1987
|
+
return InteropClient.ferryFdc3Call(this.client, 'fdc3v2GetInfo', { fdc3Version: '2.0' });
|
|
2400
1988
|
}
|
|
2401
1989
|
}
|
|
2402
|
-
exports.Fdc3Module2 = fdc32_0.Fdc3Module2 = Fdc3Module2;
|
|
2403
1990
|
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
const Fdc3Api = exports.versionMap[version];
|
|
2423
|
-
const fdc3 = new Fdc3Api(() => transport.getFin().me.interop, transport);
|
|
2424
|
-
window.dispatchEvent(new CustomEvent('fdc3Ready'));
|
|
2425
|
-
return fdc3;
|
|
2426
|
-
}
|
|
2427
|
-
exports.getFdc3 = getFdc3;
|
|
2428
|
-
} (fdc3));
|
|
1991
|
+
/* eslint-disable no-console */
|
|
1992
|
+
/* eslint-disable no-param-reassign */
|
|
1993
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
1994
|
+
const versionMap = {
|
|
1995
|
+
'1.2': Fdc3Module,
|
|
1996
|
+
'2.0': Fdc3Module2
|
|
1997
|
+
};
|
|
1998
|
+
const latestVersion = '2.0';
|
|
1999
|
+
function getFdc3(transport, version = latestVersion) {
|
|
2000
|
+
if (!(version in versionMap)) {
|
|
2001
|
+
console.warn(`FDC3 API version: ${version} is not supported. Defaulting to latest version: ${latestVersion}.`);
|
|
2002
|
+
version = latestVersion;
|
|
2003
|
+
}
|
|
2004
|
+
const Fdc3Api = versionMap[version];
|
|
2005
|
+
const fdc3 = new Fdc3Api(() => transport.getFin().me.interop, transport);
|
|
2006
|
+
window.dispatchEvent(new CustomEvent('fdc3Ready'));
|
|
2007
|
+
return fdc3;
|
|
2008
|
+
}
|
|
2429
2009
|
|
|
2430
2010
|
async function fdc3FromFin(fin, { fdc3Version } = { fdc3Version: '2.0' }) {
|
|
2431
2011
|
// @ts-expect-error
|
|
2432
|
-
return
|
|
2012
|
+
return getFdc3(fin.wire, fdc3Version);
|
|
2433
2013
|
}
|
|
2434
2014
|
|
|
2015
|
+
exports.Fdc3Module = Fdc3Module;
|
|
2016
|
+
exports.Fdc3Module2 = Fdc3Module2;
|
|
2435
2017
|
exports.fdc3FromFin = fdc3FromFin;
|