@interopio/fdc3 2.0.4 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +8 -0
- package/dist/fdc3.electron.es.js +70 -46
- package/dist/fdc3.electron.umd.js +70 -46
- package/dist/fdc3.es.js +70 -46
- package/dist/fdc3.umd.js +70 -46
- package/package.json +2 -2
package/changelog.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
2.1.1
|
|
2
|
+
chore: Refactor updating of channel contexts
|
|
3
|
+
fix: multiple invocations of addContextListener's callback
|
|
4
|
+
2.1.0
|
|
5
|
+
fix: removed Electron dependency
|
|
6
|
+
fix: Update application title to be optional in intent handler interface
|
|
7
|
+
fix: fdc3.open() rejects when the app does not add a context listener on the DesktopAgent model
|
|
8
|
+
fix: Remove custom event listener when glue initialization pass/fail
|
|
1
9
|
2.0.3
|
|
2
10
|
fix: fixed electron dependency - introduced electron bundles
|
|
3
11
|
2.0.2
|
package/dist/fdc3.electron.es.js
CHANGED
|
@@ -1054,20 +1054,15 @@ class GlueController {
|
|
|
1054
1054
|
}
|
|
1055
1055
|
updateContextWithLatestFdc3Type(contextId, context) {
|
|
1056
1056
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
data: this.channelsParser.parseFDC3ContextToGlueContexts(context),
|
|
1061
|
-
latest_fdc3_type: this.channelsParser.mapFDC3TypeToChannelsDelimiter(context.type)
|
|
1062
|
-
});
|
|
1063
|
-
}
|
|
1064
|
-
return this.updateContext(contextId, Object.assign(Object.assign({}, prevContextData), { data: Object.assign(Object.assign({}, prevContextData.data), this.channelsParser.parseFDC3ContextToGlueContexts(context)), latest_fdc3_type: this.channelsParser.mapFDC3TypeToChannelsDelimiter(context.type) }));
|
|
1057
|
+
const { path, value } = this.channelsParser.parseFDC3ContextToGlueContexts(context);
|
|
1058
|
+
const latestTypePathValue = { path: "latest_fdc3_type", value: this.channelsParser.mapFDC3TypeToChannelsDelimiter(context.type) };
|
|
1059
|
+
yield this.contextsSetPaths(contextId, [{ path: `data.${path}`, value: value }, latestTypePathValue]);
|
|
1065
1060
|
});
|
|
1066
1061
|
}
|
|
1067
1062
|
channelsUpdate(channelId, context) {
|
|
1068
1063
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1069
|
-
const
|
|
1070
|
-
return this.glue.channels.publish(
|
|
1064
|
+
const { path, value } = this.channelsParser.parseFDC3ContextToGlueContexts(context);
|
|
1065
|
+
return this.glue.channels.publish({ [path]: value }, channelId);
|
|
1071
1066
|
});
|
|
1072
1067
|
}
|
|
1073
1068
|
joinChannel(channelId) {
|
|
@@ -1137,7 +1132,7 @@ class GlueController {
|
|
|
1137
1132
|
getInteropMethods(filter) {
|
|
1138
1133
|
return this.glue.interop.methods(filter);
|
|
1139
1134
|
}
|
|
1140
|
-
channelsSubscribe(callback) {
|
|
1135
|
+
channelsSubscribe(callback, contextType) {
|
|
1141
1136
|
const didReplay = { replayed: false };
|
|
1142
1137
|
return this.glue.channels.subscribe((_, context, updaterId) => __awaiter(this, void 0, void 0, function* () {
|
|
1143
1138
|
if (this.isUpdateFromMe(updaterId) || !context) {
|
|
@@ -1148,11 +1143,11 @@ class GlueController {
|
|
|
1148
1143
|
return;
|
|
1149
1144
|
}
|
|
1150
1145
|
if (!didReplay.replayed) {
|
|
1151
|
-
this.invokePreviouslyBroadcastedData(callback, contextData, this.getContextMetadata(updaterId));
|
|
1146
|
+
this.invokePreviouslyBroadcastedData({ callback, contextData, metadata: this.getContextMetadata(updaterId), contextType });
|
|
1152
1147
|
didReplay.replayed = true;
|
|
1153
1148
|
return;
|
|
1154
1149
|
}
|
|
1155
|
-
this.parseDataAndInvokeSubscribeCallback(callback, contextData, this.getContextMetadata(updaterId));
|
|
1150
|
+
this.parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata: this.getContextMetadata(updaterId), contextType });
|
|
1156
1151
|
}));
|
|
1157
1152
|
}
|
|
1158
1153
|
contextsSubscribe(contextName, callback) {
|
|
@@ -1164,7 +1159,7 @@ class GlueController {
|
|
|
1164
1159
|
if (!this.checkIfAppChannelShouldInvokeInitialReplay(didReplay, contextData)) {
|
|
1165
1160
|
return;
|
|
1166
1161
|
}
|
|
1167
|
-
this.parseDataAndInvokeSubscribeCallback(callback, contextData, this.getContextMetadata(extraData === null || extraData === void 0 ? void 0 : extraData.updaterId));
|
|
1162
|
+
this.parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata: this.getContextMetadata(extraData === null || extraData === void 0 ? void 0 : extraData.updaterId) });
|
|
1168
1163
|
});
|
|
1169
1164
|
}
|
|
1170
1165
|
getInteropServers(methodFilter) {
|
|
@@ -1173,14 +1168,11 @@ class GlueController {
|
|
|
1173
1168
|
initSubLogger(name) {
|
|
1174
1169
|
return this.logger.subLogger(name);
|
|
1175
1170
|
}
|
|
1176
|
-
invokePreviouslyBroadcastedData(callback, contextData, metadata) {
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
const parsedData = Object.assign({ type: this.channelsParser.revertGlueParsedTypeToInitialFDC3Type(key) }, value);
|
|
1182
|
-
callback(parsedData, metadata);
|
|
1183
|
-
});
|
|
1171
|
+
invokePreviouslyBroadcastedData({ callback, contextData, metadata, contextType }) {
|
|
1172
|
+
if (!contextData.latest_fdc3_type) {
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
this.parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata, contextType });
|
|
1184
1176
|
}
|
|
1185
1177
|
isUpdateFromMe(updaterId) {
|
|
1186
1178
|
return this.glue.interop.instance.peerId === updaterId;
|
|
@@ -1200,9 +1192,31 @@ class GlueController {
|
|
|
1200
1192
|
initializeLogger() {
|
|
1201
1193
|
this._logger = this.glue.logger;
|
|
1202
1194
|
}
|
|
1203
|
-
parseDataAndInvokeSubscribeCallback(callback,
|
|
1204
|
-
|
|
1205
|
-
|
|
1195
|
+
parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata, contextType }) {
|
|
1196
|
+
if (!contextType) {
|
|
1197
|
+
const parsedData = this.channelsParser.parseContextsDataToInitialFDC3Data(contextData);
|
|
1198
|
+
callback(parsedData, metadata);
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
const dataForContextType = this.getLatestBroadcastedDataByContextType(contextData, contextType);
|
|
1202
|
+
if (!dataForContextType) {
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
callback(dataForContextType, metadata);
|
|
1206
|
+
}
|
|
1207
|
+
getLatestBroadcastedDataByContextType(contextData, contextType) {
|
|
1208
|
+
let foundData;
|
|
1209
|
+
Object.entries(contextData.data).find(([key, value]) => {
|
|
1210
|
+
if (!this.channelsParser.isFdc3DataKey(key)) {
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
const parsedType = this.channelsParser.revertGlueParsedTypeToInitialFDC3Type(key);
|
|
1214
|
+
if (parsedType !== contextType) {
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
foundData = Object.assign({ type: parsedType }, value);
|
|
1218
|
+
});
|
|
1219
|
+
return foundData;
|
|
1206
1220
|
}
|
|
1207
1221
|
checkIfAppChannelShouldInvokeInitialReplay(didReplay, contextData) {
|
|
1208
1222
|
if (!didReplay.replayed) {
|
|
@@ -1214,6 +1228,11 @@ class GlueController {
|
|
|
1214
1228
|
}
|
|
1215
1229
|
return true;
|
|
1216
1230
|
}
|
|
1231
|
+
contextsSetPaths(name, paths) {
|
|
1232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1233
|
+
yield this.glue.contexts.setPaths(name, paths);
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1217
1236
|
}
|
|
1218
1237
|
|
|
1219
1238
|
const GLUE42_EVENT_NAME = "Glue42";
|
|
@@ -1466,7 +1485,7 @@ class ChannelsParser {
|
|
|
1466
1485
|
parseFDC3ContextToGlueContexts(context) {
|
|
1467
1486
|
const { type } = context, rest = __rest$1(context, ["type"]);
|
|
1468
1487
|
const parsedType = this.mapFDC3TypeToChannelsDelimiter(type);
|
|
1469
|
-
return {
|
|
1488
|
+
return { path: `${this.channelsFdc3DataPrefix}${parsedType}`, value: rest };
|
|
1470
1489
|
}
|
|
1471
1490
|
mapFDC3TypeToChannelsDelimiter(type) {
|
|
1472
1491
|
return type.split(".").join(this.fdc3Delimiter);
|
|
@@ -1982,7 +2001,7 @@ class IntentsController {
|
|
|
1982
2001
|
}
|
|
1983
2002
|
}
|
|
1984
2003
|
|
|
1985
|
-
var version = "2.
|
|
2004
|
+
var version = "2.1.1";
|
|
1986
2005
|
|
|
1987
2006
|
class ApplicationsController {
|
|
1988
2007
|
constructor(glueController) {
|
|
@@ -2060,9 +2079,9 @@ class ApplicationsController {
|
|
|
2060
2079
|
this.logger.info(`${commandId} - getInfo() invoked`);
|
|
2061
2080
|
const appMetadata = yield this.getCurrentAppMetadata();
|
|
2062
2081
|
return {
|
|
2063
|
-
provider: "
|
|
2082
|
+
provider: "io.Connect",
|
|
2064
2083
|
providerVersion: version,
|
|
2065
|
-
fdc3Version: "2.0
|
|
2084
|
+
fdc3Version: "2.0",
|
|
2066
2085
|
optionalFeatures: {
|
|
2067
2086
|
OriginatingAppMetadata: true,
|
|
2068
2087
|
UserChannelMembershipAPIs: true
|
|
@@ -2213,7 +2232,7 @@ class ChannelsController {
|
|
|
2213
2232
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2214
2233
|
yield this.initDonePromise;
|
|
2215
2234
|
this.logger.info(`[${commandId}] - addContextListener() invoked for contextType ${contextType} and channelId ${channelId}`);
|
|
2216
|
-
if (this.invokeContextHandlerWithStartupContext) {
|
|
2235
|
+
if (this.invokeContextHandlerWithStartupContext && !channelId) {
|
|
2217
2236
|
this.logger.info(`[${commandId}] - trying to invoke context handler with window context`);
|
|
2218
2237
|
this.handleWindowContextOnOpening(commandId, handler, contextType).catch((err) => this.logger.warn(`[${commandId}] - ${err}`));
|
|
2219
2238
|
}
|
|
@@ -2508,7 +2527,7 @@ class ChannelsController {
|
|
|
2508
2527
|
const subHandler = parseContextHandler(handler, contextType);
|
|
2509
2528
|
if (!channelId) {
|
|
2510
2529
|
this.logger.info(`[${commandId}] - Creating a channel subscription using glue.channels.subscribe`);
|
|
2511
|
-
const unsubscribe = this.glueController.channelsSubscribe(subHandler);
|
|
2530
|
+
const unsubscribe = this.glueController.channelsSubscribe(subHandler, contextType);
|
|
2512
2531
|
return { unsubscribe };
|
|
2513
2532
|
}
|
|
2514
2533
|
const channelType = this.getChannelTypeById(channelId);
|
|
@@ -2543,7 +2562,7 @@ class ChannelsController {
|
|
|
2543
2562
|
throw { message: ChannelError.AccessDenied, reason: "Cannot add a context listener on an invalid channel" };
|
|
2544
2563
|
});
|
|
2545
2564
|
}
|
|
2546
|
-
addContextListenerOnUserChannel({ commandId, channelId, handler, invokedOnChannelModel }) {
|
|
2565
|
+
addContextListenerOnUserChannel({ commandId, channelId, handler, invokedOnChannelModel, contextType }) {
|
|
2547
2566
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2548
2567
|
let unsubscribe;
|
|
2549
2568
|
if (invokedOnChannelModel) {
|
|
@@ -2553,7 +2572,7 @@ class ChannelsController {
|
|
|
2553
2572
|
}
|
|
2554
2573
|
else {
|
|
2555
2574
|
this.logger.info(`[${commandId}] - subscribing for fdc3 user channel with id ${channelId}`);
|
|
2556
|
-
unsubscribe = this.glueController.channelsSubscribe(handler);
|
|
2575
|
+
unsubscribe = this.glueController.channelsSubscribe(handler, contextType);
|
|
2557
2576
|
}
|
|
2558
2577
|
return {
|
|
2559
2578
|
unsubscribe: () => {
|
|
@@ -2630,22 +2649,24 @@ class EventReceiver {
|
|
|
2630
2649
|
this.eventDispatcher.fireNotifyStarted();
|
|
2631
2650
|
}
|
|
2632
2651
|
wireCustomEventListener() {
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
if (!data || !data.glue42) {
|
|
2636
|
-
return;
|
|
2637
|
-
}
|
|
2638
|
-
const glue42Event = data.glue42.event;
|
|
2639
|
-
const foundHandler = this.events[glue42Event];
|
|
2640
|
-
if (!foundHandler) {
|
|
2641
|
-
return;
|
|
2642
|
-
}
|
|
2643
|
-
foundHandler.handle(data.glue42.message);
|
|
2644
|
-
});
|
|
2652
|
+
this._glueReceiverHandler = this.glueReceiverHandler.bind(this);
|
|
2653
|
+
window.addEventListener(GLUE42_EVENT_NAME, this._glueReceiverHandler);
|
|
2645
2654
|
}
|
|
2646
2655
|
handleStart() {
|
|
2647
2656
|
this.eventDispatcher.fireRequestGlue();
|
|
2648
2657
|
}
|
|
2658
|
+
glueReceiverHandler(event) {
|
|
2659
|
+
const data = event.detail;
|
|
2660
|
+
if (!data || !data.glue42) {
|
|
2661
|
+
return;
|
|
2662
|
+
}
|
|
2663
|
+
const glue42Event = data.glue42.event;
|
|
2664
|
+
const foundHandler = this.events[glue42Event];
|
|
2665
|
+
if (!foundHandler) {
|
|
2666
|
+
return;
|
|
2667
|
+
}
|
|
2668
|
+
foundHandler.handle(data.glue42.message);
|
|
2669
|
+
}
|
|
2649
2670
|
handleRequestGlueResponse(data) {
|
|
2650
2671
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2651
2672
|
if (this.glueResponseReceived && this.glueInitialized) {
|
|
@@ -2655,8 +2676,11 @@ class EventReceiver {
|
|
|
2655
2676
|
const { glue } = data;
|
|
2656
2677
|
const glueValidator = this.glueController.validateGlue(glue);
|
|
2657
2678
|
if (!glueValidator.isValid) {
|
|
2658
|
-
|
|
2679
|
+
this.glueController.initializeFailed(glueValidator.error);
|
|
2680
|
+
window.removeEventListener(GLUE42_EVENT_NAME, this._glueReceiverHandler);
|
|
2681
|
+
return;
|
|
2659
2682
|
}
|
|
2683
|
+
window.removeEventListener(GLUE42_EVENT_NAME, this._glueReceiverHandler);
|
|
2660
2684
|
this.glueController.initialize(glue);
|
|
2661
2685
|
yield this.eventsController.initialize();
|
|
2662
2686
|
this.eventDispatcher.fireFdc3Ready();
|
|
@@ -1060,20 +1060,15 @@
|
|
|
1060
1060
|
}
|
|
1061
1061
|
updateContextWithLatestFdc3Type(contextId, context) {
|
|
1062
1062
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
data: this.channelsParser.parseFDC3ContextToGlueContexts(context),
|
|
1067
|
-
latest_fdc3_type: this.channelsParser.mapFDC3TypeToChannelsDelimiter(context.type)
|
|
1068
|
-
});
|
|
1069
|
-
}
|
|
1070
|
-
return this.updateContext(contextId, Object.assign(Object.assign({}, prevContextData), { data: Object.assign(Object.assign({}, prevContextData.data), this.channelsParser.parseFDC3ContextToGlueContexts(context)), latest_fdc3_type: this.channelsParser.mapFDC3TypeToChannelsDelimiter(context.type) }));
|
|
1063
|
+
const { path, value } = this.channelsParser.parseFDC3ContextToGlueContexts(context);
|
|
1064
|
+
const latestTypePathValue = { path: "latest_fdc3_type", value: this.channelsParser.mapFDC3TypeToChannelsDelimiter(context.type) };
|
|
1065
|
+
yield this.contextsSetPaths(contextId, [{ path: `data.${path}`, value: value }, latestTypePathValue]);
|
|
1071
1066
|
});
|
|
1072
1067
|
}
|
|
1073
1068
|
channelsUpdate(channelId, context) {
|
|
1074
1069
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1075
|
-
const
|
|
1076
|
-
return this.glue.channels.publish(
|
|
1070
|
+
const { path, value } = this.channelsParser.parseFDC3ContextToGlueContexts(context);
|
|
1071
|
+
return this.glue.channels.publish({ [path]: value }, channelId);
|
|
1077
1072
|
});
|
|
1078
1073
|
}
|
|
1079
1074
|
joinChannel(channelId) {
|
|
@@ -1143,7 +1138,7 @@
|
|
|
1143
1138
|
getInteropMethods(filter) {
|
|
1144
1139
|
return this.glue.interop.methods(filter);
|
|
1145
1140
|
}
|
|
1146
|
-
channelsSubscribe(callback) {
|
|
1141
|
+
channelsSubscribe(callback, contextType) {
|
|
1147
1142
|
const didReplay = { replayed: false };
|
|
1148
1143
|
return this.glue.channels.subscribe((_, context, updaterId) => __awaiter(this, void 0, void 0, function* () {
|
|
1149
1144
|
if (this.isUpdateFromMe(updaterId) || !context) {
|
|
@@ -1154,11 +1149,11 @@
|
|
|
1154
1149
|
return;
|
|
1155
1150
|
}
|
|
1156
1151
|
if (!didReplay.replayed) {
|
|
1157
|
-
this.invokePreviouslyBroadcastedData(callback, contextData, this.getContextMetadata(updaterId));
|
|
1152
|
+
this.invokePreviouslyBroadcastedData({ callback, contextData, metadata: this.getContextMetadata(updaterId), contextType });
|
|
1158
1153
|
didReplay.replayed = true;
|
|
1159
1154
|
return;
|
|
1160
1155
|
}
|
|
1161
|
-
this.parseDataAndInvokeSubscribeCallback(callback, contextData, this.getContextMetadata(updaterId));
|
|
1156
|
+
this.parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata: this.getContextMetadata(updaterId), contextType });
|
|
1162
1157
|
}));
|
|
1163
1158
|
}
|
|
1164
1159
|
contextsSubscribe(contextName, callback) {
|
|
@@ -1170,7 +1165,7 @@
|
|
|
1170
1165
|
if (!this.checkIfAppChannelShouldInvokeInitialReplay(didReplay, contextData)) {
|
|
1171
1166
|
return;
|
|
1172
1167
|
}
|
|
1173
|
-
this.parseDataAndInvokeSubscribeCallback(callback, contextData, this.getContextMetadata(extraData === null || extraData === void 0 ? void 0 : extraData.updaterId));
|
|
1168
|
+
this.parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata: this.getContextMetadata(extraData === null || extraData === void 0 ? void 0 : extraData.updaterId) });
|
|
1174
1169
|
});
|
|
1175
1170
|
}
|
|
1176
1171
|
getInteropServers(methodFilter) {
|
|
@@ -1179,14 +1174,11 @@
|
|
|
1179
1174
|
initSubLogger(name) {
|
|
1180
1175
|
return this.logger.subLogger(name);
|
|
1181
1176
|
}
|
|
1182
|
-
invokePreviouslyBroadcastedData(callback, contextData, metadata) {
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
const parsedData = Object.assign({ type: this.channelsParser.revertGlueParsedTypeToInitialFDC3Type(key) }, value);
|
|
1188
|
-
callback(parsedData, metadata);
|
|
1189
|
-
});
|
|
1177
|
+
invokePreviouslyBroadcastedData({ callback, contextData, metadata, contextType }) {
|
|
1178
|
+
if (!contextData.latest_fdc3_type) {
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
this.parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata, contextType });
|
|
1190
1182
|
}
|
|
1191
1183
|
isUpdateFromMe(updaterId) {
|
|
1192
1184
|
return this.glue.interop.instance.peerId === updaterId;
|
|
@@ -1206,9 +1198,31 @@
|
|
|
1206
1198
|
initializeLogger() {
|
|
1207
1199
|
this._logger = this.glue.logger;
|
|
1208
1200
|
}
|
|
1209
|
-
parseDataAndInvokeSubscribeCallback(callback,
|
|
1210
|
-
|
|
1211
|
-
|
|
1201
|
+
parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata, contextType }) {
|
|
1202
|
+
if (!contextType) {
|
|
1203
|
+
const parsedData = this.channelsParser.parseContextsDataToInitialFDC3Data(contextData);
|
|
1204
|
+
callback(parsedData, metadata);
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
const dataForContextType = this.getLatestBroadcastedDataByContextType(contextData, contextType);
|
|
1208
|
+
if (!dataForContextType) {
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
callback(dataForContextType, metadata);
|
|
1212
|
+
}
|
|
1213
|
+
getLatestBroadcastedDataByContextType(contextData, contextType) {
|
|
1214
|
+
let foundData;
|
|
1215
|
+
Object.entries(contextData.data).find(([key, value]) => {
|
|
1216
|
+
if (!this.channelsParser.isFdc3DataKey(key)) {
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
const parsedType = this.channelsParser.revertGlueParsedTypeToInitialFDC3Type(key);
|
|
1220
|
+
if (parsedType !== contextType) {
|
|
1221
|
+
return;
|
|
1222
|
+
}
|
|
1223
|
+
foundData = Object.assign({ type: parsedType }, value);
|
|
1224
|
+
});
|
|
1225
|
+
return foundData;
|
|
1212
1226
|
}
|
|
1213
1227
|
checkIfAppChannelShouldInvokeInitialReplay(didReplay, contextData) {
|
|
1214
1228
|
if (!didReplay.replayed) {
|
|
@@ -1220,6 +1234,11 @@
|
|
|
1220
1234
|
}
|
|
1221
1235
|
return true;
|
|
1222
1236
|
}
|
|
1237
|
+
contextsSetPaths(name, paths) {
|
|
1238
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1239
|
+
yield this.glue.contexts.setPaths(name, paths);
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1223
1242
|
}
|
|
1224
1243
|
|
|
1225
1244
|
const GLUE42_EVENT_NAME = "Glue42";
|
|
@@ -1472,7 +1491,7 @@
|
|
|
1472
1491
|
parseFDC3ContextToGlueContexts(context) {
|
|
1473
1492
|
const { type } = context, rest = __rest$1(context, ["type"]);
|
|
1474
1493
|
const parsedType = this.mapFDC3TypeToChannelsDelimiter(type);
|
|
1475
|
-
return {
|
|
1494
|
+
return { path: `${this.channelsFdc3DataPrefix}${parsedType}`, value: rest };
|
|
1476
1495
|
}
|
|
1477
1496
|
mapFDC3TypeToChannelsDelimiter(type) {
|
|
1478
1497
|
return type.split(".").join(this.fdc3Delimiter);
|
|
@@ -1988,7 +2007,7 @@
|
|
|
1988
2007
|
}
|
|
1989
2008
|
}
|
|
1990
2009
|
|
|
1991
|
-
var version = "2.
|
|
2010
|
+
var version = "2.1.1";
|
|
1992
2011
|
|
|
1993
2012
|
class ApplicationsController {
|
|
1994
2013
|
constructor(glueController) {
|
|
@@ -2066,9 +2085,9 @@
|
|
|
2066
2085
|
this.logger.info(`${commandId} - getInfo() invoked`);
|
|
2067
2086
|
const appMetadata = yield this.getCurrentAppMetadata();
|
|
2068
2087
|
return {
|
|
2069
|
-
provider: "
|
|
2088
|
+
provider: "io.Connect",
|
|
2070
2089
|
providerVersion: version,
|
|
2071
|
-
fdc3Version: "2.0
|
|
2090
|
+
fdc3Version: "2.0",
|
|
2072
2091
|
optionalFeatures: {
|
|
2073
2092
|
OriginatingAppMetadata: true,
|
|
2074
2093
|
UserChannelMembershipAPIs: true
|
|
@@ -2219,7 +2238,7 @@
|
|
|
2219
2238
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2220
2239
|
yield this.initDonePromise;
|
|
2221
2240
|
this.logger.info(`[${commandId}] - addContextListener() invoked for contextType ${contextType} and channelId ${channelId}`);
|
|
2222
|
-
if (this.invokeContextHandlerWithStartupContext) {
|
|
2241
|
+
if (this.invokeContextHandlerWithStartupContext && !channelId) {
|
|
2223
2242
|
this.logger.info(`[${commandId}] - trying to invoke context handler with window context`);
|
|
2224
2243
|
this.handleWindowContextOnOpening(commandId, handler, contextType).catch((err) => this.logger.warn(`[${commandId}] - ${err}`));
|
|
2225
2244
|
}
|
|
@@ -2514,7 +2533,7 @@
|
|
|
2514
2533
|
const subHandler = parseContextHandler(handler, contextType);
|
|
2515
2534
|
if (!channelId) {
|
|
2516
2535
|
this.logger.info(`[${commandId}] - Creating a channel subscription using glue.channels.subscribe`);
|
|
2517
|
-
const unsubscribe = this.glueController.channelsSubscribe(subHandler);
|
|
2536
|
+
const unsubscribe = this.glueController.channelsSubscribe(subHandler, contextType);
|
|
2518
2537
|
return { unsubscribe };
|
|
2519
2538
|
}
|
|
2520
2539
|
const channelType = this.getChannelTypeById(channelId);
|
|
@@ -2549,7 +2568,7 @@
|
|
|
2549
2568
|
throw { message: ChannelError.AccessDenied, reason: "Cannot add a context listener on an invalid channel" };
|
|
2550
2569
|
});
|
|
2551
2570
|
}
|
|
2552
|
-
addContextListenerOnUserChannel({ commandId, channelId, handler, invokedOnChannelModel }) {
|
|
2571
|
+
addContextListenerOnUserChannel({ commandId, channelId, handler, invokedOnChannelModel, contextType }) {
|
|
2553
2572
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2554
2573
|
let unsubscribe;
|
|
2555
2574
|
if (invokedOnChannelModel) {
|
|
@@ -2559,7 +2578,7 @@
|
|
|
2559
2578
|
}
|
|
2560
2579
|
else {
|
|
2561
2580
|
this.logger.info(`[${commandId}] - subscribing for fdc3 user channel with id ${channelId}`);
|
|
2562
|
-
unsubscribe = this.glueController.channelsSubscribe(handler);
|
|
2581
|
+
unsubscribe = this.glueController.channelsSubscribe(handler, contextType);
|
|
2563
2582
|
}
|
|
2564
2583
|
return {
|
|
2565
2584
|
unsubscribe: () => {
|
|
@@ -2636,22 +2655,24 @@
|
|
|
2636
2655
|
this.eventDispatcher.fireNotifyStarted();
|
|
2637
2656
|
}
|
|
2638
2657
|
wireCustomEventListener() {
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
if (!data || !data.glue42) {
|
|
2642
|
-
return;
|
|
2643
|
-
}
|
|
2644
|
-
const glue42Event = data.glue42.event;
|
|
2645
|
-
const foundHandler = this.events[glue42Event];
|
|
2646
|
-
if (!foundHandler) {
|
|
2647
|
-
return;
|
|
2648
|
-
}
|
|
2649
|
-
foundHandler.handle(data.glue42.message);
|
|
2650
|
-
});
|
|
2658
|
+
this._glueReceiverHandler = this.glueReceiverHandler.bind(this);
|
|
2659
|
+
window.addEventListener(GLUE42_EVENT_NAME, this._glueReceiverHandler);
|
|
2651
2660
|
}
|
|
2652
2661
|
handleStart() {
|
|
2653
2662
|
this.eventDispatcher.fireRequestGlue();
|
|
2654
2663
|
}
|
|
2664
|
+
glueReceiverHandler(event) {
|
|
2665
|
+
const data = event.detail;
|
|
2666
|
+
if (!data || !data.glue42) {
|
|
2667
|
+
return;
|
|
2668
|
+
}
|
|
2669
|
+
const glue42Event = data.glue42.event;
|
|
2670
|
+
const foundHandler = this.events[glue42Event];
|
|
2671
|
+
if (!foundHandler) {
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
2674
|
+
foundHandler.handle(data.glue42.message);
|
|
2675
|
+
}
|
|
2655
2676
|
handleRequestGlueResponse(data) {
|
|
2656
2677
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2657
2678
|
if (this.glueResponseReceived && this.glueInitialized) {
|
|
@@ -2661,8 +2682,11 @@
|
|
|
2661
2682
|
const { glue } = data;
|
|
2662
2683
|
const glueValidator = this.glueController.validateGlue(glue);
|
|
2663
2684
|
if (!glueValidator.isValid) {
|
|
2664
|
-
|
|
2685
|
+
this.glueController.initializeFailed(glueValidator.error);
|
|
2686
|
+
window.removeEventListener(GLUE42_EVENT_NAME, this._glueReceiverHandler);
|
|
2687
|
+
return;
|
|
2665
2688
|
}
|
|
2689
|
+
window.removeEventListener(GLUE42_EVENT_NAME, this._glueReceiverHandler);
|
|
2666
2690
|
this.glueController.initialize(glue);
|
|
2667
2691
|
yield this.eventsController.initialize();
|
|
2668
2692
|
this.eventDispatcher.fireFdc3Ready();
|
package/dist/fdc3.es.js
CHANGED
|
@@ -1043,20 +1043,15 @@ class GlueController {
|
|
|
1043
1043
|
}
|
|
1044
1044
|
updateContextWithLatestFdc3Type(contextId, context) {
|
|
1045
1045
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1046
|
-
const
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
data: this.channelsParser.parseFDC3ContextToGlueContexts(context),
|
|
1050
|
-
latest_fdc3_type: this.channelsParser.mapFDC3TypeToChannelsDelimiter(context.type)
|
|
1051
|
-
});
|
|
1052
|
-
}
|
|
1053
|
-
return this.updateContext(contextId, Object.assign(Object.assign({}, prevContextData), { data: Object.assign(Object.assign({}, prevContextData.data), this.channelsParser.parseFDC3ContextToGlueContexts(context)), latest_fdc3_type: this.channelsParser.mapFDC3TypeToChannelsDelimiter(context.type) }));
|
|
1046
|
+
const { path, value } = this.channelsParser.parseFDC3ContextToGlueContexts(context);
|
|
1047
|
+
const latestTypePathValue = { path: "latest_fdc3_type", value: this.channelsParser.mapFDC3TypeToChannelsDelimiter(context.type) };
|
|
1048
|
+
yield this.contextsSetPaths(contextId, [{ path: `data.${path}`, value: value }, latestTypePathValue]);
|
|
1054
1049
|
});
|
|
1055
1050
|
}
|
|
1056
1051
|
channelsUpdate(channelId, context) {
|
|
1057
1052
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1058
|
-
const
|
|
1059
|
-
return this.glue.channels.publish(
|
|
1053
|
+
const { path, value } = this.channelsParser.parseFDC3ContextToGlueContexts(context);
|
|
1054
|
+
return this.glue.channels.publish({ [path]: value }, channelId);
|
|
1060
1055
|
});
|
|
1061
1056
|
}
|
|
1062
1057
|
joinChannel(channelId) {
|
|
@@ -1126,7 +1121,7 @@ class GlueController {
|
|
|
1126
1121
|
getInteropMethods(filter) {
|
|
1127
1122
|
return this.glue.interop.methods(filter);
|
|
1128
1123
|
}
|
|
1129
|
-
channelsSubscribe(callback) {
|
|
1124
|
+
channelsSubscribe(callback, contextType) {
|
|
1130
1125
|
const didReplay = { replayed: false };
|
|
1131
1126
|
return this.glue.channels.subscribe((_, context, updaterId) => __awaiter(this, void 0, void 0, function* () {
|
|
1132
1127
|
if (this.isUpdateFromMe(updaterId) || !context) {
|
|
@@ -1137,11 +1132,11 @@ class GlueController {
|
|
|
1137
1132
|
return;
|
|
1138
1133
|
}
|
|
1139
1134
|
if (!didReplay.replayed) {
|
|
1140
|
-
this.invokePreviouslyBroadcastedData(callback, contextData, this.getContextMetadata(updaterId));
|
|
1135
|
+
this.invokePreviouslyBroadcastedData({ callback, contextData, metadata: this.getContextMetadata(updaterId), contextType });
|
|
1141
1136
|
didReplay.replayed = true;
|
|
1142
1137
|
return;
|
|
1143
1138
|
}
|
|
1144
|
-
this.parseDataAndInvokeSubscribeCallback(callback, contextData, this.getContextMetadata(updaterId));
|
|
1139
|
+
this.parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata: this.getContextMetadata(updaterId), contextType });
|
|
1145
1140
|
}));
|
|
1146
1141
|
}
|
|
1147
1142
|
contextsSubscribe(contextName, callback) {
|
|
@@ -1153,7 +1148,7 @@ class GlueController {
|
|
|
1153
1148
|
if (!this.checkIfAppChannelShouldInvokeInitialReplay(didReplay, contextData)) {
|
|
1154
1149
|
return;
|
|
1155
1150
|
}
|
|
1156
|
-
this.parseDataAndInvokeSubscribeCallback(callback, contextData, this.getContextMetadata(extraData === null || extraData === void 0 ? void 0 : extraData.updaterId));
|
|
1151
|
+
this.parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata: this.getContextMetadata(extraData === null || extraData === void 0 ? void 0 : extraData.updaterId) });
|
|
1157
1152
|
});
|
|
1158
1153
|
}
|
|
1159
1154
|
getInteropServers(methodFilter) {
|
|
@@ -1162,14 +1157,11 @@ class GlueController {
|
|
|
1162
1157
|
initSubLogger(name) {
|
|
1163
1158
|
return this.logger.subLogger(name);
|
|
1164
1159
|
}
|
|
1165
|
-
invokePreviouslyBroadcastedData(callback, contextData, metadata) {
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
const parsedData = Object.assign({ type: this.channelsParser.revertGlueParsedTypeToInitialFDC3Type(key) }, value);
|
|
1171
|
-
callback(parsedData, metadata);
|
|
1172
|
-
});
|
|
1160
|
+
invokePreviouslyBroadcastedData({ callback, contextData, metadata, contextType }) {
|
|
1161
|
+
if (!contextData.latest_fdc3_type) {
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
this.parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata, contextType });
|
|
1173
1165
|
}
|
|
1174
1166
|
isUpdateFromMe(updaterId) {
|
|
1175
1167
|
return this.glue.interop.instance.peerId === updaterId;
|
|
@@ -1189,9 +1181,31 @@ class GlueController {
|
|
|
1189
1181
|
initializeLogger() {
|
|
1190
1182
|
this._logger = this.glue.logger;
|
|
1191
1183
|
}
|
|
1192
|
-
parseDataAndInvokeSubscribeCallback(callback,
|
|
1193
|
-
|
|
1194
|
-
|
|
1184
|
+
parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata, contextType }) {
|
|
1185
|
+
if (!contextType) {
|
|
1186
|
+
const parsedData = this.channelsParser.parseContextsDataToInitialFDC3Data(contextData);
|
|
1187
|
+
callback(parsedData, metadata);
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
const dataForContextType = this.getLatestBroadcastedDataByContextType(contextData, contextType);
|
|
1191
|
+
if (!dataForContextType) {
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
callback(dataForContextType, metadata);
|
|
1195
|
+
}
|
|
1196
|
+
getLatestBroadcastedDataByContextType(contextData, contextType) {
|
|
1197
|
+
let foundData;
|
|
1198
|
+
Object.entries(contextData.data).find(([key, value]) => {
|
|
1199
|
+
if (!this.channelsParser.isFdc3DataKey(key)) {
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
const parsedType = this.channelsParser.revertGlueParsedTypeToInitialFDC3Type(key);
|
|
1203
|
+
if (parsedType !== contextType) {
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1206
|
+
foundData = Object.assign({ type: parsedType }, value);
|
|
1207
|
+
});
|
|
1208
|
+
return foundData;
|
|
1195
1209
|
}
|
|
1196
1210
|
checkIfAppChannelShouldInvokeInitialReplay(didReplay, contextData) {
|
|
1197
1211
|
if (!didReplay.replayed) {
|
|
@@ -1203,6 +1217,11 @@ class GlueController {
|
|
|
1203
1217
|
}
|
|
1204
1218
|
return true;
|
|
1205
1219
|
}
|
|
1220
|
+
contextsSetPaths(name, paths) {
|
|
1221
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1222
|
+
yield this.glue.contexts.setPaths(name, paths);
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1206
1225
|
}
|
|
1207
1226
|
|
|
1208
1227
|
const GLUE42_EVENT_NAME = "Glue42";
|
|
@@ -1455,7 +1474,7 @@ class ChannelsParser {
|
|
|
1455
1474
|
parseFDC3ContextToGlueContexts(context) {
|
|
1456
1475
|
const { type } = context, rest = __rest$1(context, ["type"]);
|
|
1457
1476
|
const parsedType = this.mapFDC3TypeToChannelsDelimiter(type);
|
|
1458
|
-
return {
|
|
1477
|
+
return { path: `${this.channelsFdc3DataPrefix}${parsedType}`, value: rest };
|
|
1459
1478
|
}
|
|
1460
1479
|
mapFDC3TypeToChannelsDelimiter(type) {
|
|
1461
1480
|
return type.split(".").join(this.fdc3Delimiter);
|
|
@@ -1971,7 +1990,7 @@ class IntentsController {
|
|
|
1971
1990
|
}
|
|
1972
1991
|
}
|
|
1973
1992
|
|
|
1974
|
-
var version = "2.
|
|
1993
|
+
var version = "2.1.1";
|
|
1975
1994
|
|
|
1976
1995
|
class ApplicationsController {
|
|
1977
1996
|
constructor(glueController) {
|
|
@@ -2049,9 +2068,9 @@ class ApplicationsController {
|
|
|
2049
2068
|
this.logger.info(`${commandId} - getInfo() invoked`);
|
|
2050
2069
|
const appMetadata = yield this.getCurrentAppMetadata();
|
|
2051
2070
|
return {
|
|
2052
|
-
provider: "
|
|
2071
|
+
provider: "io.Connect",
|
|
2053
2072
|
providerVersion: version,
|
|
2054
|
-
fdc3Version: "2.0
|
|
2073
|
+
fdc3Version: "2.0",
|
|
2055
2074
|
optionalFeatures: {
|
|
2056
2075
|
OriginatingAppMetadata: true,
|
|
2057
2076
|
UserChannelMembershipAPIs: true
|
|
@@ -2202,7 +2221,7 @@ class ChannelsController {
|
|
|
2202
2221
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2203
2222
|
yield this.initDonePromise;
|
|
2204
2223
|
this.logger.info(`[${commandId}] - addContextListener() invoked for contextType ${contextType} and channelId ${channelId}`);
|
|
2205
|
-
if (this.invokeContextHandlerWithStartupContext) {
|
|
2224
|
+
if (this.invokeContextHandlerWithStartupContext && !channelId) {
|
|
2206
2225
|
this.logger.info(`[${commandId}] - trying to invoke context handler with window context`);
|
|
2207
2226
|
this.handleWindowContextOnOpening(commandId, handler, contextType).catch((err) => this.logger.warn(`[${commandId}] - ${err}`));
|
|
2208
2227
|
}
|
|
@@ -2497,7 +2516,7 @@ class ChannelsController {
|
|
|
2497
2516
|
const subHandler = parseContextHandler(handler, contextType);
|
|
2498
2517
|
if (!channelId) {
|
|
2499
2518
|
this.logger.info(`[${commandId}] - Creating a channel subscription using glue.channels.subscribe`);
|
|
2500
|
-
const unsubscribe = this.glueController.channelsSubscribe(subHandler);
|
|
2519
|
+
const unsubscribe = this.glueController.channelsSubscribe(subHandler, contextType);
|
|
2501
2520
|
return { unsubscribe };
|
|
2502
2521
|
}
|
|
2503
2522
|
const channelType = this.getChannelTypeById(channelId);
|
|
@@ -2532,7 +2551,7 @@ class ChannelsController {
|
|
|
2532
2551
|
throw { message: ChannelError.AccessDenied, reason: "Cannot add a context listener on an invalid channel" };
|
|
2533
2552
|
});
|
|
2534
2553
|
}
|
|
2535
|
-
addContextListenerOnUserChannel({ commandId, channelId, handler, invokedOnChannelModel }) {
|
|
2554
|
+
addContextListenerOnUserChannel({ commandId, channelId, handler, invokedOnChannelModel, contextType }) {
|
|
2536
2555
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2537
2556
|
let unsubscribe;
|
|
2538
2557
|
if (invokedOnChannelModel) {
|
|
@@ -2542,7 +2561,7 @@ class ChannelsController {
|
|
|
2542
2561
|
}
|
|
2543
2562
|
else {
|
|
2544
2563
|
this.logger.info(`[${commandId}] - subscribing for fdc3 user channel with id ${channelId}`);
|
|
2545
|
-
unsubscribe = this.glueController.channelsSubscribe(handler);
|
|
2564
|
+
unsubscribe = this.glueController.channelsSubscribe(handler, contextType);
|
|
2546
2565
|
}
|
|
2547
2566
|
return {
|
|
2548
2567
|
unsubscribe: () => {
|
|
@@ -2619,22 +2638,24 @@ class EventReceiver {
|
|
|
2619
2638
|
this.eventDispatcher.fireNotifyStarted();
|
|
2620
2639
|
}
|
|
2621
2640
|
wireCustomEventListener() {
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
if (!data || !data.glue42) {
|
|
2625
|
-
return;
|
|
2626
|
-
}
|
|
2627
|
-
const glue42Event = data.glue42.event;
|
|
2628
|
-
const foundHandler = this.events[glue42Event];
|
|
2629
|
-
if (!foundHandler) {
|
|
2630
|
-
return;
|
|
2631
|
-
}
|
|
2632
|
-
foundHandler.handle(data.glue42.message);
|
|
2633
|
-
});
|
|
2641
|
+
this._glueReceiverHandler = this.glueReceiverHandler.bind(this);
|
|
2642
|
+
window.addEventListener(GLUE42_EVENT_NAME, this._glueReceiverHandler);
|
|
2634
2643
|
}
|
|
2635
2644
|
handleStart() {
|
|
2636
2645
|
this.eventDispatcher.fireRequestGlue();
|
|
2637
2646
|
}
|
|
2647
|
+
glueReceiverHandler(event) {
|
|
2648
|
+
const data = event.detail;
|
|
2649
|
+
if (!data || !data.glue42) {
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
const glue42Event = data.glue42.event;
|
|
2653
|
+
const foundHandler = this.events[glue42Event];
|
|
2654
|
+
if (!foundHandler) {
|
|
2655
|
+
return;
|
|
2656
|
+
}
|
|
2657
|
+
foundHandler.handle(data.glue42.message);
|
|
2658
|
+
}
|
|
2638
2659
|
handleRequestGlueResponse(data) {
|
|
2639
2660
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2640
2661
|
if (this.glueResponseReceived && this.glueInitialized) {
|
|
@@ -2644,8 +2665,11 @@ class EventReceiver {
|
|
|
2644
2665
|
const { glue } = data;
|
|
2645
2666
|
const glueValidator = this.glueController.validateGlue(glue);
|
|
2646
2667
|
if (!glueValidator.isValid) {
|
|
2647
|
-
|
|
2668
|
+
this.glueController.initializeFailed(glueValidator.error);
|
|
2669
|
+
window.removeEventListener(GLUE42_EVENT_NAME, this._glueReceiverHandler);
|
|
2670
|
+
return;
|
|
2648
2671
|
}
|
|
2672
|
+
window.removeEventListener(GLUE42_EVENT_NAME, this._glueReceiverHandler);
|
|
2649
2673
|
this.glueController.initialize(glue);
|
|
2650
2674
|
yield this.eventsController.initialize();
|
|
2651
2675
|
this.eventDispatcher.fireFdc3Ready();
|
package/dist/fdc3.umd.js
CHANGED
|
@@ -1049,20 +1049,15 @@
|
|
|
1049
1049
|
}
|
|
1050
1050
|
updateContextWithLatestFdc3Type(contextId, context) {
|
|
1051
1051
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
data: this.channelsParser.parseFDC3ContextToGlueContexts(context),
|
|
1056
|
-
latest_fdc3_type: this.channelsParser.mapFDC3TypeToChannelsDelimiter(context.type)
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
return this.updateContext(contextId, Object.assign(Object.assign({}, prevContextData), { data: Object.assign(Object.assign({}, prevContextData.data), this.channelsParser.parseFDC3ContextToGlueContexts(context)), latest_fdc3_type: this.channelsParser.mapFDC3TypeToChannelsDelimiter(context.type) }));
|
|
1052
|
+
const { path, value } = this.channelsParser.parseFDC3ContextToGlueContexts(context);
|
|
1053
|
+
const latestTypePathValue = { path: "latest_fdc3_type", value: this.channelsParser.mapFDC3TypeToChannelsDelimiter(context.type) };
|
|
1054
|
+
yield this.contextsSetPaths(contextId, [{ path: `data.${path}`, value: value }, latestTypePathValue]);
|
|
1060
1055
|
});
|
|
1061
1056
|
}
|
|
1062
1057
|
channelsUpdate(channelId, context) {
|
|
1063
1058
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1064
|
-
const
|
|
1065
|
-
return this.glue.channels.publish(
|
|
1059
|
+
const { path, value } = this.channelsParser.parseFDC3ContextToGlueContexts(context);
|
|
1060
|
+
return this.glue.channels.publish({ [path]: value }, channelId);
|
|
1066
1061
|
});
|
|
1067
1062
|
}
|
|
1068
1063
|
joinChannel(channelId) {
|
|
@@ -1132,7 +1127,7 @@
|
|
|
1132
1127
|
getInteropMethods(filter) {
|
|
1133
1128
|
return this.glue.interop.methods(filter);
|
|
1134
1129
|
}
|
|
1135
|
-
channelsSubscribe(callback) {
|
|
1130
|
+
channelsSubscribe(callback, contextType) {
|
|
1136
1131
|
const didReplay = { replayed: false };
|
|
1137
1132
|
return this.glue.channels.subscribe((_, context, updaterId) => __awaiter(this, void 0, void 0, function* () {
|
|
1138
1133
|
if (this.isUpdateFromMe(updaterId) || !context) {
|
|
@@ -1143,11 +1138,11 @@
|
|
|
1143
1138
|
return;
|
|
1144
1139
|
}
|
|
1145
1140
|
if (!didReplay.replayed) {
|
|
1146
|
-
this.invokePreviouslyBroadcastedData(callback, contextData, this.getContextMetadata(updaterId));
|
|
1141
|
+
this.invokePreviouslyBroadcastedData({ callback, contextData, metadata: this.getContextMetadata(updaterId), contextType });
|
|
1147
1142
|
didReplay.replayed = true;
|
|
1148
1143
|
return;
|
|
1149
1144
|
}
|
|
1150
|
-
this.parseDataAndInvokeSubscribeCallback(callback, contextData, this.getContextMetadata(updaterId));
|
|
1145
|
+
this.parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata: this.getContextMetadata(updaterId), contextType });
|
|
1151
1146
|
}));
|
|
1152
1147
|
}
|
|
1153
1148
|
contextsSubscribe(contextName, callback) {
|
|
@@ -1159,7 +1154,7 @@
|
|
|
1159
1154
|
if (!this.checkIfAppChannelShouldInvokeInitialReplay(didReplay, contextData)) {
|
|
1160
1155
|
return;
|
|
1161
1156
|
}
|
|
1162
|
-
this.parseDataAndInvokeSubscribeCallback(callback, contextData, this.getContextMetadata(extraData === null || extraData === void 0 ? void 0 : extraData.updaterId));
|
|
1157
|
+
this.parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata: this.getContextMetadata(extraData === null || extraData === void 0 ? void 0 : extraData.updaterId) });
|
|
1163
1158
|
});
|
|
1164
1159
|
}
|
|
1165
1160
|
getInteropServers(methodFilter) {
|
|
@@ -1168,14 +1163,11 @@
|
|
|
1168
1163
|
initSubLogger(name) {
|
|
1169
1164
|
return this.logger.subLogger(name);
|
|
1170
1165
|
}
|
|
1171
|
-
invokePreviouslyBroadcastedData(callback, contextData, metadata) {
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
const parsedData = Object.assign({ type: this.channelsParser.revertGlueParsedTypeToInitialFDC3Type(key) }, value);
|
|
1177
|
-
callback(parsedData, metadata);
|
|
1178
|
-
});
|
|
1166
|
+
invokePreviouslyBroadcastedData({ callback, contextData, metadata, contextType }) {
|
|
1167
|
+
if (!contextData.latest_fdc3_type) {
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
this.parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata, contextType });
|
|
1179
1171
|
}
|
|
1180
1172
|
isUpdateFromMe(updaterId) {
|
|
1181
1173
|
return this.glue.interop.instance.peerId === updaterId;
|
|
@@ -1195,9 +1187,31 @@
|
|
|
1195
1187
|
initializeLogger() {
|
|
1196
1188
|
this._logger = this.glue.logger;
|
|
1197
1189
|
}
|
|
1198
|
-
parseDataAndInvokeSubscribeCallback(callback,
|
|
1199
|
-
|
|
1200
|
-
|
|
1190
|
+
parseDataAndInvokeSubscribeCallback({ callback, contextData, metadata, contextType }) {
|
|
1191
|
+
if (!contextType) {
|
|
1192
|
+
const parsedData = this.channelsParser.parseContextsDataToInitialFDC3Data(contextData);
|
|
1193
|
+
callback(parsedData, metadata);
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
const dataForContextType = this.getLatestBroadcastedDataByContextType(contextData, contextType);
|
|
1197
|
+
if (!dataForContextType) {
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
callback(dataForContextType, metadata);
|
|
1201
|
+
}
|
|
1202
|
+
getLatestBroadcastedDataByContextType(contextData, contextType) {
|
|
1203
|
+
let foundData;
|
|
1204
|
+
Object.entries(contextData.data).find(([key, value]) => {
|
|
1205
|
+
if (!this.channelsParser.isFdc3DataKey(key)) {
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
const parsedType = this.channelsParser.revertGlueParsedTypeToInitialFDC3Type(key);
|
|
1209
|
+
if (parsedType !== contextType) {
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1212
|
+
foundData = Object.assign({ type: parsedType }, value);
|
|
1213
|
+
});
|
|
1214
|
+
return foundData;
|
|
1201
1215
|
}
|
|
1202
1216
|
checkIfAppChannelShouldInvokeInitialReplay(didReplay, contextData) {
|
|
1203
1217
|
if (!didReplay.replayed) {
|
|
@@ -1209,6 +1223,11 @@
|
|
|
1209
1223
|
}
|
|
1210
1224
|
return true;
|
|
1211
1225
|
}
|
|
1226
|
+
contextsSetPaths(name, paths) {
|
|
1227
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1228
|
+
yield this.glue.contexts.setPaths(name, paths);
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1212
1231
|
}
|
|
1213
1232
|
|
|
1214
1233
|
const GLUE42_EVENT_NAME = "Glue42";
|
|
@@ -1461,7 +1480,7 @@
|
|
|
1461
1480
|
parseFDC3ContextToGlueContexts(context) {
|
|
1462
1481
|
const { type } = context, rest = __rest$1(context, ["type"]);
|
|
1463
1482
|
const parsedType = this.mapFDC3TypeToChannelsDelimiter(type);
|
|
1464
|
-
return {
|
|
1483
|
+
return { path: `${this.channelsFdc3DataPrefix}${parsedType}`, value: rest };
|
|
1465
1484
|
}
|
|
1466
1485
|
mapFDC3TypeToChannelsDelimiter(type) {
|
|
1467
1486
|
return type.split(".").join(this.fdc3Delimiter);
|
|
@@ -1977,7 +1996,7 @@
|
|
|
1977
1996
|
}
|
|
1978
1997
|
}
|
|
1979
1998
|
|
|
1980
|
-
var version = "2.
|
|
1999
|
+
var version = "2.1.1";
|
|
1981
2000
|
|
|
1982
2001
|
class ApplicationsController {
|
|
1983
2002
|
constructor(glueController) {
|
|
@@ -2055,9 +2074,9 @@
|
|
|
2055
2074
|
this.logger.info(`${commandId} - getInfo() invoked`);
|
|
2056
2075
|
const appMetadata = yield this.getCurrentAppMetadata();
|
|
2057
2076
|
return {
|
|
2058
|
-
provider: "
|
|
2077
|
+
provider: "io.Connect",
|
|
2059
2078
|
providerVersion: version,
|
|
2060
|
-
fdc3Version: "2.0
|
|
2079
|
+
fdc3Version: "2.0",
|
|
2061
2080
|
optionalFeatures: {
|
|
2062
2081
|
OriginatingAppMetadata: true,
|
|
2063
2082
|
UserChannelMembershipAPIs: true
|
|
@@ -2208,7 +2227,7 @@
|
|
|
2208
2227
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2209
2228
|
yield this.initDonePromise;
|
|
2210
2229
|
this.logger.info(`[${commandId}] - addContextListener() invoked for contextType ${contextType} and channelId ${channelId}`);
|
|
2211
|
-
if (this.invokeContextHandlerWithStartupContext) {
|
|
2230
|
+
if (this.invokeContextHandlerWithStartupContext && !channelId) {
|
|
2212
2231
|
this.logger.info(`[${commandId}] - trying to invoke context handler with window context`);
|
|
2213
2232
|
this.handleWindowContextOnOpening(commandId, handler, contextType).catch((err) => this.logger.warn(`[${commandId}] - ${err}`));
|
|
2214
2233
|
}
|
|
@@ -2503,7 +2522,7 @@
|
|
|
2503
2522
|
const subHandler = parseContextHandler(handler, contextType);
|
|
2504
2523
|
if (!channelId) {
|
|
2505
2524
|
this.logger.info(`[${commandId}] - Creating a channel subscription using glue.channels.subscribe`);
|
|
2506
|
-
const unsubscribe = this.glueController.channelsSubscribe(subHandler);
|
|
2525
|
+
const unsubscribe = this.glueController.channelsSubscribe(subHandler, contextType);
|
|
2507
2526
|
return { unsubscribe };
|
|
2508
2527
|
}
|
|
2509
2528
|
const channelType = this.getChannelTypeById(channelId);
|
|
@@ -2538,7 +2557,7 @@
|
|
|
2538
2557
|
throw { message: ChannelError.AccessDenied, reason: "Cannot add a context listener on an invalid channel" };
|
|
2539
2558
|
});
|
|
2540
2559
|
}
|
|
2541
|
-
addContextListenerOnUserChannel({ commandId, channelId, handler, invokedOnChannelModel }) {
|
|
2560
|
+
addContextListenerOnUserChannel({ commandId, channelId, handler, invokedOnChannelModel, contextType }) {
|
|
2542
2561
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2543
2562
|
let unsubscribe;
|
|
2544
2563
|
if (invokedOnChannelModel) {
|
|
@@ -2548,7 +2567,7 @@
|
|
|
2548
2567
|
}
|
|
2549
2568
|
else {
|
|
2550
2569
|
this.logger.info(`[${commandId}] - subscribing for fdc3 user channel with id ${channelId}`);
|
|
2551
|
-
unsubscribe = this.glueController.channelsSubscribe(handler);
|
|
2570
|
+
unsubscribe = this.glueController.channelsSubscribe(handler, contextType);
|
|
2552
2571
|
}
|
|
2553
2572
|
return {
|
|
2554
2573
|
unsubscribe: () => {
|
|
@@ -2625,22 +2644,24 @@
|
|
|
2625
2644
|
this.eventDispatcher.fireNotifyStarted();
|
|
2626
2645
|
}
|
|
2627
2646
|
wireCustomEventListener() {
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
if (!data || !data.glue42) {
|
|
2631
|
-
return;
|
|
2632
|
-
}
|
|
2633
|
-
const glue42Event = data.glue42.event;
|
|
2634
|
-
const foundHandler = this.events[glue42Event];
|
|
2635
|
-
if (!foundHandler) {
|
|
2636
|
-
return;
|
|
2637
|
-
}
|
|
2638
|
-
foundHandler.handle(data.glue42.message);
|
|
2639
|
-
});
|
|
2647
|
+
this._glueReceiverHandler = this.glueReceiverHandler.bind(this);
|
|
2648
|
+
window.addEventListener(GLUE42_EVENT_NAME, this._glueReceiverHandler);
|
|
2640
2649
|
}
|
|
2641
2650
|
handleStart() {
|
|
2642
2651
|
this.eventDispatcher.fireRequestGlue();
|
|
2643
2652
|
}
|
|
2653
|
+
glueReceiverHandler(event) {
|
|
2654
|
+
const data = event.detail;
|
|
2655
|
+
if (!data || !data.glue42) {
|
|
2656
|
+
return;
|
|
2657
|
+
}
|
|
2658
|
+
const glue42Event = data.glue42.event;
|
|
2659
|
+
const foundHandler = this.events[glue42Event];
|
|
2660
|
+
if (!foundHandler) {
|
|
2661
|
+
return;
|
|
2662
|
+
}
|
|
2663
|
+
foundHandler.handle(data.glue42.message);
|
|
2664
|
+
}
|
|
2644
2665
|
handleRequestGlueResponse(data) {
|
|
2645
2666
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2646
2667
|
if (this.glueResponseReceived && this.glueInitialized) {
|
|
@@ -2650,8 +2671,11 @@
|
|
|
2650
2671
|
const { glue } = data;
|
|
2651
2672
|
const glueValidator = this.glueController.validateGlue(glue);
|
|
2652
2673
|
if (!glueValidator.isValid) {
|
|
2653
|
-
|
|
2674
|
+
this.glueController.initializeFailed(glueValidator.error);
|
|
2675
|
+
window.removeEventListener(GLUE42_EVENT_NAME, this._glueReceiverHandler);
|
|
2676
|
+
return;
|
|
2654
2677
|
}
|
|
2678
|
+
window.removeEventListener(GLUE42_EVENT_NAME, this._glueReceiverHandler);
|
|
2655
2679
|
this.glueController.initialize(glue);
|
|
2656
2680
|
yield this.eventsController.initialize();
|
|
2657
2681
|
this.eventDispatcher.fireFdc3Ready();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interopio/fdc3",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "IO Connect implementation of the FDC3 standard",
|
|
5
5
|
"main": "dist/fdc3.umd.js",
|
|
6
6
|
"module": "dist/fdc3.es.js",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"decoder-validate": "^0.0.2",
|
|
51
51
|
"nanoid": "^4.0.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "3ec7bcdce291c0b617bcfc04e437998a02eefa71"
|
|
54
54
|
}
|